@stackonward/cli 0.0.1 → 1.0.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/dist/index.js +4588 -205
- package/dist/index.js.map +1 -1
- package/dist/resources/apple/.claude/docs/architecture-template.md +54 -0
- package/dist/resources/apple/.claude/docs/architecture.md +52 -0
- package/dist/resources/apple/.claude/docs/index.md +13 -0
- package/dist/resources/apple/.claude/docs/security-lifecycle.md +57 -0
- package/dist/resources/apple/.claude/docs/stack.md +93 -0
- package/dist/resources/apple/.claude/docs/verification.md +63 -0
- package/dist/resources/apple/AGENTS.md +397 -0
- package/dist/resources/apple/CLAUDE.md +397 -0
- package/dist/resources/apple/Gemfile +2 -0
- package/dist/resources/apple/Gemfile.lock +365 -0
- package/dist/resources/apple/_gitignore +14 -0
- package/dist/resources/apple/fastlane/Fastfile +123 -0
- package/dist/resources/components/nuxt/site-source/app/app.vue +42 -0
- package/dist/resources/components/nuxt/site-source/app/assets/css/site-shell.css +1035 -0
- package/dist/resources/components/nuxt/site-source/app/assets/icons/brand/.gitkeep +0 -0
- package/dist/resources/components/nuxt/site-source/app/assets/icons/common/.gitkeep +0 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationHeader.vue +35 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationShell.vue +56 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationSidebar.vue +40 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/BackToTop.vue +42 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ContentArticlePage.vue +40 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ContentListPage.vue +30 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/CookieConsent.vue +18 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingFooter.vue +52 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingHeader.vue +106 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingShell.vue +35 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/SiteBrand.vue +10 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/StaticPage.vue +21 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ToastViewport.vue +25 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseButton.vue +86 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseGradientBorder.vue +59 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseModal.vue +131 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BasePopover.vue +150 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseText.vue +138 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/CheckoutStatus.vue +112 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/CheckoutSummary.vue +172 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/GoogleSignInButton.vue +113 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/InfiniteScroll.vue +123 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/YoutubeEmbed.vue +126 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useAnalytics.ts +24 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useCheckout.ts +121 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useConsent.ts +31 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useGoogleIdentity.ts +163 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useNavigation.ts +11 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useSeo.ts +33 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useSiteShell.ts +58 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useToasts.ts +48 -0
- package/dist/resources/components/nuxt/site-source/app/layouts/app.vue +5 -0
- package/dist/resources/components/nuxt/site-source/app/layouts/default.vue +5 -0
- package/dist/resources/components/nuxt/site-source/app/plugins/analytics.client.ts +121 -0
- package/dist/resources/components/nuxt/site-source/app/plugins/google-identity.client.ts +24 -0
- package/dist/resources/components/nuxt/site-source/app/theme/accordion.ts +9 -0
- package/dist/resources/components/nuxt/site-source/app/theme/breadcrumb.ts +8 -0
- package/dist/resources/components/nuxt/site-source/app/theme/button.ts +92 -0
- package/dist/resources/components/nuxt/site-source/app/theme/carousel.ts +11 -0
- package/dist/resources/components/nuxt/site-source/app/theme/checkbox.ts +12 -0
- package/dist/resources/components/nuxt/site-source/app/theme/index.ts +30 -0
- package/dist/resources/components/nuxt/site-source/app/theme/input.ts +47 -0
- package/dist/resources/components/nuxt/site-source/app/theme/modal.ts +9 -0
- package/dist/resources/components/nuxt/site-source/app/theme/pagination.ts +6 -0
- package/dist/resources/components/nuxt/site-source/app/theme/select.ts +23 -0
- package/dist/resources/components/nuxt/site-source/app/theme/stepper.ts +10 -0
- package/dist/resources/components/nuxt/site-source/app/theme/toast.ts +8 -0
- package/dist/resources/components/nuxt/site-source/app/theme/tooltip.ts +6 -0
- package/dist/resources/components/nuxt/site-source/app/types/site-shell.ts +85 -0
- package/dist/resources/components/react/ui/Button.tsx +73 -0
- package/dist/resources/components/react/ui/Input.tsx +44 -0
- package/dist/resources/components/registry.json +355 -0
- package/dist/resources/components/vue/feedback/Toast.vue +120 -0
- package/dist/resources/components/vue/feedback/useToast.ts +70 -0
- package/dist/resources/components/vue/media/FileUpload.vue +229 -0
- package/dist/resources/components/vue/media/VideoPlayer.vue +157 -0
- package/dist/resources/components/vue/ui/AppImage.vue +147 -0
- package/dist/resources/components/vue/ui/BottomSheet.vue +217 -0
- package/dist/resources/components/vue/ui/Button.vue +154 -0
- package/dist/resources/components/vue/ui/Card.vue +111 -0
- package/dist/resources/components/vue/ui/Input.vue +113 -0
- package/dist/resources/components/vue/ui/Modal.vue +193 -0
- package/dist/resources/components/vue/ui/ScrollArea.vue +163 -0
- package/dist/resources/components/vue/ui/Tooltip.vue +115 -0
- package/dist/resources/registry.json +158 -0
- package/dist/resources/snippets/node/cache.ts +116 -0
- package/dist/resources/snippets/node/date.ts +126 -0
- package/dist/resources/snippets/node/logger.ts +104 -0
- package/dist/resources/snippets/node/validation.ts +132 -0
- package/dist/resources/snippets/react/useDebounce.ts +90 -0
- package/dist/resources/snippets/registry.json +65 -0
- package/dist/resources/snippets/vue/useAsync.ts +96 -0
- package/dist/resources/snippets/vue/usePagination.ts +102 -0
- package/dist/resources/templates/base/.claude/docs/architecture-template.md +459 -0
- package/dist/resources/templates/base/.claude/docs/architecture.md +137 -0
- package/dist/resources/templates/base/.claude/docs/index.md +42 -0
- package/dist/resources/templates/base/.claude/docs/security-lifecycle.md +129 -0
- package/dist/resources/templates/base/.claude/docs/verification.md +121 -0
- package/dist/resources/templates/base/AGENTS.md +415 -0
- package/dist/resources/templates/base/CLAUDE.md +415 -0
- package/dist/resources/templates/go-backend/.claude/docs/api-design.md +486 -0
- package/dist/resources/templates/go-backend/.claude/docs/architecture-template.md +449 -0
- package/dist/resources/templates/go-backend/.claude/docs/check-list.md +155 -0
- package/dist/resources/templates/go-backend/.claude/docs/database.md +369 -0
- package/dist/resources/templates/go-backend/.claude/docs/e2e-standards.md +161 -0
- package/dist/resources/templates/go-backend/.claude/docs/error-handling.md +558 -0
- package/dist/resources/templates/go-backend/.claude/docs/event-runtime-boundary.md +124 -0
- package/dist/resources/templates/go-backend/.claude/docs/identifier-contract.md +195 -0
- package/dist/resources/templates/go-backend/.claude/docs/index.md +22 -0
- package/dist/resources/templates/go-backend/.claude/docs/logging.md +314 -0
- package/dist/resources/templates/go-backend/.claude/docs/mediagen-provider-onboarding-sop.md +917 -0
- package/dist/resources/templates/go-backend/.claude/docs/mediagen-provider-quick-reference.md +195 -0
- package/dist/resources/templates/go-backend/.claude/docs/module-standards.md +309 -0
- package/dist/resources/templates/go-backend/.claude/docs/openapi-contract.md +141 -0
- package/dist/resources/templates/go-backend/.claude/docs/payment-gateway-onboarding.md +283 -0
- package/dist/resources/templates/go-backend/.claude/docs/platform-boundary.md +191 -0
- package/dist/resources/templates/go-backend/.claude/docs/quality-gates.md +112 -0
- package/dist/resources/templates/go-backend/.dockerignore +6 -0
- package/dist/resources/templates/go-backend/.env.example +13 -0
- package/dist/resources/templates/go-backend/.gitattributes +2 -0
- package/dist/resources/templates/go-backend/AGENTS.md +1139 -0
- package/dist/resources/templates/go-backend/CLAUDE.md +1139 -0
- package/dist/resources/templates/go-backend/Dockerfile +14 -0
- package/dist/resources/templates/go-backend/Makefile +71 -0
- package/dist/resources/templates/go-backend/README.md +66 -0
- package/dist/resources/templates/go-backend/_gitignore +10 -0
- package/dist/resources/templates/go-backend/api/openapi/README.md +29 -0
- package/dist/resources/templates/go-backend/api/openapi/dist/artifact-manifest.json +19 -0
- package/dist/resources/templates/go-backend/api/openapi/dist/conformance-matrix.json +276 -0
- package/dist/resources/templates/go-backend/api/openapi/document.go +30 -0
- package/dist/resources/templates/go-backend/api/openapi/package.json +28 -0
- package/dist/resources/templates/go-backend/api/openapi/pnpm-lock.yaml +3052 -0
- package/dist/resources/templates/go-backend/api/openapi/redocly-source.yaml +18 -0
- package/dist/resources/templates/go-backend/api/openapi/redocly.yaml +8 -0
- package/dist/resources/templates/go-backend/api/openapi/sdk-generators.json +16 -0
- package/dist/resources/templates/go-backend/api/openapi/service-registry.json +39 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/conformance/runtime.arazzo.yaml +65 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/dist/internal.openapi.json +327 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/dist/runtime-contract.json +56 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/openapi.yaml +222 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/conformance/runtime.arazzo.yaml +65 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/dist/internal.openapi.json +327 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/dist/runtime-contract.json +56 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/openapi.yaml +222 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/breaking.mjs +416 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/build.mjs +103 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/conformance_coverage.mjs +111 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/contract_compiler.mjs +62 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/contract_policy.mjs +208 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/delegated_contract.mjs +302 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/deterministic_archive.mjs +69 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_example_privacy.mjs +93 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_projection.mjs +498 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_quality.mjs +346 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/git_artifact_history.mjs +188 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/manifest.mjs +170 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/overlay.mjs +98 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/project.mjs +549 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/route_contract.mjs +156 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/runtime_conformance.mjs +193 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/scalar_asset_localization.mjs +164 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/sdk_generator.mjs +229 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/semantic_version.mjs +64 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/service_contract_inputs.mjs +16 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/breaking.test.mjs +365 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/build.test.mjs +42 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/conformance_coverage.test.mjs +88 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/contract_policy.test.mjs +257 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/delegated_contract.test.mjs +205 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_example_privacy.test.mjs +51 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_projection.test.mjs +368 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_quality.test.mjs +151 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/git_artifact_history.test.mjs +60 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/head_policy.test.mjs +8 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/overlay.test.mjs +44 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/projection.test.mjs +270 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/redocly_documentation_rules.test.mjs +146 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/release_manifest.test.mjs +76 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/route_contract.test.mjs +119 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/runtime_conformance.test.mjs +75 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/scalar_asset_localization.test.mjs +50 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/sdk_generator.test.mjs +31 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/semantic_version.test.mjs +60 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/service_contract_inputs.test.mjs +27 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/resources.go +125 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/runtime.go +102 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/runtime_test.go +70 -0
- package/dist/resources/templates/go-backend/cmd/product-api/lifecycle_test.go +58 -0
- package/dist/resources/templates/go-backend/cmd/product-api/main.go +32 -0
- package/dist/resources/templates/go-backend/cmd/product-api/wire.go +13 -0
- package/dist/resources/templates/go-backend/cmd/product-api/wire_gen.go +94 -0
- package/dist/resources/templates/go-backend/cmd/worker/main.go +47 -0
- package/dist/resources/templates/go-backend/cmd/worker/wire.go +14 -0
- package/dist/resources/templates/go-backend/cmd/worker/wire_gen.go +111 -0
- package/dist/resources/templates/go-backend/configs/config.yaml +37 -0
- package/dist/resources/templates/go-backend/deployments/compose.yaml +71 -0
- package/dist/resources/templates/go-backend/docs/openapi-provenance.json +489 -0
- package/dist/resources/templates/go-backend/docs/runtime-provenance.json +175 -0
- package/dist/resources/templates/go-backend/docs/source-provenance.json +3568 -0
- package/dist/resources/templates/go-backend/docs/standards-provenance.json +1624 -0
- package/dist/resources/templates/go-backend/go.mod +256 -0
- package/dist/resources/templates/go-backend/go.sum +805 -0
- package/dist/resources/templates/go-backend/internal/common/canonicaljson/canonical.go +370 -0
- package/dist/resources/templates/go-backend/internal/common/canonicaljson/canonical_test.go +223 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/contracts.go +125 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/platform_client.go +212 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/platform_client_test.go +319 -0
- package/dist/resources/templates/go-backend/internal/common/contentaccess/contentaccess.go +50 -0
- package/dist/resources/templates/go-backend/internal/common/contracts/contact.go +85 -0
- package/dist/resources/templates/go-backend/internal/common/ctxutil/identity.go +20 -0
- package/dist/resources/templates/go-backend/internal/common/ctxutil/product.go +53 -0
- package/dist/resources/templates/go-backend/internal/common/enumdomain/payment.go +12 -0
- package/dist/resources/templates/go-backend/internal/common/enums/dto_admin.go +9 -0
- package/dist/resources/templates/go-backend/internal/common/enums/enum.go +1247 -0
- package/dist/resources/templates/go-backend/internal/common/enums/handler_admin.go +66 -0
- package/dist/resources/templates/go-backend/internal/common/enums/module.go +46 -0
- package/dist/resources/templates/go-backend/internal/common/enums/provider.go +10 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register.go +11 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_audit.go +274 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_command_replay.go +12 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_config.go +27 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_locale.go +37 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_ops.go +14 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_outbox.go +15 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_rule_expression.go +63 -0
- package/dist/resources/templates/go-backend/internal/common/enums/registry.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/httporigin/origin.go +62 -0
- package/dist/resources/templates/go-backend/internal/common/httporigin/origin_test.go +38 -0
- package/dist/resources/templates/go-backend/internal/common/iamcredential/plaintext.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/iamcredential/plaintext_test.go +29 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope.go +212 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_binding.go +26 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_filter.go +173 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_filter_test.go +279 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/authorization_details.go +10 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/route_permission_policies.go +660 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/route_permission_policies_test.go +331 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/audience_token_source.go +166 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/bootstrap_token_exchanger.go +183 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/bound_service_token_signer.go +52 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/delegated_access_token_exchanger.go +189 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/delegated_access_token_exchanger_test.go +159 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/product_scoped_service_token_signer.go +92 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/provider.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/request_signer.go +86 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/resolver.go +69 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/resolver_test.go +42 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/route_scope.go +95 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/route_scope_test.go +78 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/service_identity_test.go +387 -0
- package/dist/resources/templates/go-backend/internal/common/jsonschema/compiler.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/jsonschema/compiler_test.go +41 -0
- package/dist/resources/templates/go-backend/internal/common/jwksapi/handler.go +83 -0
- package/dist/resources/templates/go-backend/internal/common/jwksapi/handler_test.go +104 -0
- package/dist/resources/templates/go-backend/internal/common/locale/locale.go +145 -0
- package/dist/resources/templates/go-backend/internal/common/locale/locale_test.go +75 -0
- package/dist/resources/templates/go-backend/internal/common/mediaref/mediaref.go +54 -0
- package/dist/resources/templates/go-backend/internal/common/mediaref/mediaref_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/apikey_auth.go +320 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/apikey_throttle.go +158 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/auth.go +40 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/auth_test.go +50 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/client_context.go +86 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/cors.go +68 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/event_context.go +18 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/gateway_identity.go +279 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/helpers.go +159 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_route_permission.go +171 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_token_auth.go +151 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_token_auth_test.go +99 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_service_identity.go +138 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_service_token_auth.go +74 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/idempotent.go +273 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/idempotent_test.go +83 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/internal_route_permission.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/internal_route_permission_test.go +186 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/logging.go +191 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/metrics.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/middleware_test.go +1516 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/principal_context.go +160 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/principal_context_test.go +355 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/product_context.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/recovery.go +40 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/referral_attribution.go +178 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/requestid.go +48 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/resource_permission.go +790 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/resource_permission_test.go +440 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/service_credential_auth.go +67 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/tenant.go +148 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/throttle.go +310 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/trusted_client_ip.go +23 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/trusted_client_ip_test.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/money/currency.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/money/errors.go +23 -0
- package/dist/resources/templates/go-backend/internal/common/money/format.go +123 -0
- package/dist/resources/templates/go-backend/internal/common/money/format_test.go +204 -0
- package/dist/resources/templates/go-backend/internal/common/money/gateway.go +144 -0
- package/dist/resources/templates/go-backend/internal/common/money/gateway_test.go +165 -0
- package/dist/resources/templates/go-backend/internal/common/money/rounding.go +56 -0
- package/dist/resources/templates/go-backend/internal/common/money/rounding_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/common/principal/context.go +56 -0
- package/dist/resources/templates/go-backend/internal/common/principal/principal.go +49 -0
- package/dist/resources/templates/go-backend/internal/common/productcode/code.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/productcode/code_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/providerconfig/schema.go +577 -0
- package/dist/resources/templates/go-backend/internal/common/providerconfig/schema_test.go +47 -0
- package/dist/resources/templates/go-backend/internal/common/requestprivacy/request.go +246 -0
- package/dist/resources/templates/go-backend/internal/common/requestprivacy/request_test.go +170 -0
- package/dist/resources/templates/go-backend/internal/common/response/pagination.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/response/response.go +110 -0
- package/dist/resources/templates/go-backend/internal/common/response/response_test.go +463 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/ast.go +141 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/ast_test.go +81 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/canonical.go +184 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/canonical_test.go +319 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/decoder.go +555 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/decoder_test.go +260 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/errors.go +55 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/evaluator.go +96 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/evaluator_test.go +220 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/fuzz_test.go +116 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/limits.go +331 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/schema.go +412 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/schema_test.go +164 -0
- package/dist/resources/templates/go-backend/internal/common/runtimeinput/runtime_input.go +627 -0
- package/dist/resources/templates/go-backend/internal/common/runtimeinput/runtime_input_test.go +245 -0
- package/dist/resources/templates/go-backend/internal/common/semver/errors.go +6 -0
- package/dist/resources/templates/go-backend/internal/common/semver/semver.go +125 -0
- package/dist/resources/templates/go-backend/internal/common/semver/semver_test.go +205 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/audience.go +48 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/audience_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/resource_identifier.go +33 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/resource_identifier_test.go +32 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/generator.go +99 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/generator_test.go +396 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/prefix.go +247 -0
- package/dist/resources/templates/go-backend/internal/common/types/asset_url.go +11 -0
- package/dist/resources/templates/go-backend/internal/common/types/billing.go +89 -0
- package/dist/resources/templates/go-backend/internal/common/types/billing_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/types/country.go +74 -0
- package/dist/resources/templates/go-backend/internal/common/types/country_test.go +28 -0
- package/dist/resources/templates/go-backend/internal/common/types/currency.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/types/identifiers.go +41 -0
- package/dist/resources/templates/go-backend/internal/common/types/operator.go +28 -0
- package/dist/resources/templates/go-backend/internal/common/types/subscription_entitlement.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/types/subscription_entitlement_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/types/tier.go +72 -0
- package/dist/resources/templates/go-backend/internal/common/types/types.go +411 -0
- package/dist/resources/templates/go-backend/internal/common/types/types_test.go +295 -0
- package/dist/resources/templates/go-backend/internal/common/utils/constants.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/utils/crypto.go +158 -0
- package/dist/resources/templates/go-backend/internal/common/utils/crypto_test.go +345 -0
- package/dist/resources/templates/go-backend/internal/common/utils/duration.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/utils/helpers.go +18 -0
- package/dist/resources/templates/go-backend/internal/common/utils/json.go +62 -0
- package/dist/resources/templates/go-backend/internal/common/utils/json_test.go +76 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pagination.go +51 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pagination_test.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pointer.go +107 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pointer_test.go +15 -0
- package/dist/resources/templates/go-backend/internal/common/utils/slice.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/utils/snowflake.go +110 -0
- package/dist/resources/templates/go-backend/internal/common/utils/snowflake_test.go +316 -0
- package/dist/resources/templates/go-backend/internal/common/utils/string.go +16 -0
- package/dist/resources/templates/go-backend/internal/common/utils/timefmt.go +42 -0
- package/dist/resources/templates/go-backend/internal/common/validator/validator.go +136 -0
- package/dist/resources/templates/go-backend/internal/common/validator/validator_test.go +240 -0
- package/dist/resources/templates/go-backend/internal/common/youtubeapi/client.go +224 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/document.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/document_test.go +104 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/route_validator.go +78 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/route_validator_test.go +108 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/assets/scalar-api-reference.js +2385 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/assets/scalar-api-reference.metadata.json +10 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/route.go +107 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/route_test.go +200 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/scalar.go +117 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/scalar_test.go +99 -0
- package/dist/resources/templates/go-backend/internal/core/audit/access_log_policy.go +91 -0
- package/dist/resources/templates/go-backend/internal/core/audit/access_log_policy_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/audit/actor_resolver.go +36 -0
- package/dist/resources/templates/go-backend/internal/core/audit/constants.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/audit/context.go +119 -0
- package/dist/resources/templates/go-backend/internal/core/audit/context_test.go +310 -0
- package/dist/resources/templates/go-backend/internal/core/audit/dto.go +468 -0
- package/dist/resources/templates/go-backend/internal/core/audit/dto_admin.go +172 -0
- package/dist/resources/templates/go-backend/internal/core/audit/enum.go +460 -0
- package/dist/resources/templates/go-backend/internal/core/audit/enum_test.go +314 -0
- package/dist/resources/templates/go-backend/internal/core/audit/errors.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/audit/handler.go +568 -0
- package/dist/resources/templates/go-backend/internal/core/audit/listener.go +319 -0
- package/dist/resources/templates/go-backend/internal/core/audit/listener_test.go +98 -0
- package/dist/resources/templates/go-backend/internal/core/audit/middleware.go +669 -0
- package/dist/resources/templates/go-backend/internal/core/audit/middleware_test.go +268 -0
- package/dist/resources/templates/go-backend/internal/core/audit/model.go +306 -0
- package/dist/resources/templates/go-backend/internal/core/audit/partition_job.go +316 -0
- package/dist/resources/templates/go-backend/internal/core/audit/ports.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/audit/provider.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/audit/repository.go +1007 -0
- package/dist/resources/templates/go-backend/internal/core/audit/repository_test.go +934 -0
- package/dist/resources/templates/go-backend/internal/core/audit/router.go +85 -0
- package/dist/resources/templates/go-backend/internal/core/audit/service.go +770 -0
- package/dist/resources/templates/go-backend/internal/core/audit/service_test.go +331 -0
- package/dist/resources/templates/go-backend/internal/core/audit/vo_admin.go +475 -0
- package/dist/resources/templates/go-backend/internal/core/cache/config.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/cache/key.go +41 -0
- package/dist/resources/templates/go-backend/internal/core/cache/key_test.go +62 -0
- package/dist/resources/templates/go-backend/internal/core/cache/l1.go +153 -0
- package/dist/resources/templates/go-backend/internal/core/cache/l1_test.go +212 -0
- package/dist/resources/templates/go-backend/internal/core/cache/manager.go +278 -0
- package/dist/resources/templates/go-backend/internal/core/cache/manager_provider.go +24 -0
- package/dist/resources/templates/go-backend/internal/core/cache/metrics.go +126 -0
- package/dist/resources/templates/go-backend/internal/core/cache/namespace.go +46 -0
- package/dist/resources/templates/go-backend/internal/core/cache/namespace_test.go +90 -0
- package/dist/resources/templates/go-backend/internal/core/cache/options.go +39 -0
- package/dist/resources/templates/go-backend/internal/core/cache/options_test.go +96 -0
- package/dist/resources/templates/go-backend/internal/core/cache/redis.go +311 -0
- package/dist/resources/templates/go-backend/internal/core/cache/redis_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/cache/serializer.go +31 -0
- package/dist/resources/templates/go-backend/internal/core/cache/serializer_test.go +139 -0
- package/dist/resources/templates/go-backend/internal/core/cache/singleflight.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/cache/singleflight_test.go +211 -0
- package/dist/resources/templates/go-backend/internal/core/cache/warming.go +86 -0
- package/dist/resources/templates/go-backend/internal/core/clock/clock.go +66 -0
- package/dist/resources/templates/go-backend/internal/core/clock/clock_test.go +26 -0
- package/dist/resources/templates/go-backend/internal/core/clock/runtime_clock.go +283 -0
- package/dist/resources/templates/go-backend/internal/core/clock/runtime_clock_test.go +98 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/errors.go +6 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/model.go +90 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/model_test.go +79 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/namespace.go +7 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/persistence.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/persistence_test.go +185 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/provider.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/repository.go +22 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service.go +853 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service_persistence_test.go +432 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service_test.go +891 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/types.go +121 -0
- package/dist/resources/templates/go-backend/internal/core/config/config.go +2069 -0
- package/dist/resources/templates/go-backend/internal/core/config/config_test.go +1122 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/contract_test.go +388 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/docs.go +198 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/verify.go +424 -0
- package/dist/resources/templates/go-backend/internal/core/config/enum.go +46 -0
- package/dist/resources/templates/go-backend/internal/core/config/metadata.go +717 -0
- package/dist/resources/templates/go-backend/internal/core/config/metadata_test.go +228 -0
- package/dist/resources/templates/go-backend/internal/core/config/product_admin_config_test.go +210 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/aes_gcm.go +111 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/aes_gcm_test.go +364 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/encryptor.go +12 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/envelope_encryptor.go +134 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/envelope_encryptor_test.go +118 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/pem.go +112 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/pem_test.go +44 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/provider.go +130 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/provider_test.go +92 -0
- package/dist/resources/templates/go-backend/internal/core/database/base_model.go +24 -0
- package/dist/resources/templates/go-backend/internal/core/database/clickhouse.go +121 -0
- package/dist/resources/templates/go-backend/internal/core/database/database.go +112 -0
- package/dist/resources/templates/go-backend/internal/core/database/database_logger_test.go +95 -0
- package/dist/resources/templates/go-backend/internal/core/database/errors.go +25 -0
- package/dist/resources/templates/go-backend/internal/core/database/metrics_plugin.go +105 -0
- package/dist/resources/templates/go-backend/internal/core/database/pool_collector.go +71 -0
- package/dist/resources/templates/go-backend/internal/core/database/read_replica.go +520 -0
- package/dist/resources/templates/go-backend/internal/core/database/transaction.go +170 -0
- package/dist/resources/templates/go-backend/internal/core/database/transaction_test.go +282 -0
- package/dist/resources/templates/go-backend/internal/core/distlock/lock.go +353 -0
- package/dist/resources/templates/go-backend/internal/core/distlock/lock_test.go +106 -0
- package/dist/resources/templates/go-backend/internal/core/errors/handler.go +189 -0
- package/dist/resources/templates/go-backend/internal/core/errors/handler_test.go +515 -0
- package/dist/resources/templates/go-backend/internal/core/eventbus/eventbus.go +667 -0
- package/dist/resources/templates/go-backend/internal/core/eventbus/eventbus_test.go +792 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/noop.go +22 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/provider.go +20 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/publisher.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/redis.go +109 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/routing.go +104 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/routing_test.go +71 -0
- package/dist/resources/templates/go-backend/internal/core/geoip/model.go +19 -0
- package/dist/resources/templates/go-backend/internal/core/geoip/service.go +88 -0
- package/dist/resources/templates/go-backend/internal/core/health/health.go +333 -0
- package/dist/resources/templates/go-backend/internal/core/health/health_test.go +27 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/client.go +772 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/client_test.go +287 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/download.go +578 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/download_test.go +374 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/jwk.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/keyring.go +144 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/keyring_test.go +128 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/registry.go +60 -0
- package/dist/resources/templates/go-backend/internal/core/logger/logger.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/logger/logger_test.go +194 -0
- package/dist/resources/templates/go-backend/internal/core/observability/metrics.go +358 -0
- package/dist/resources/templates/go-backend/internal/core/observability/sentry.go +445 -0
- package/dist/resources/templates/go-backend/internal/core/observability/sentry_privacy_test.go +175 -0
- package/dist/resources/templates/go-backend/internal/core/observability/tracing.go +187 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/model.go +314 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/model_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/persistence.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/provider.go +23 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay.go +1138 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay_postgres_test.go +257 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay_test.go +690 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/rescheduler.go +164 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/rescheduler_test.go +209 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer.go +249 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer_postgres_test.go +170 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer_test.go +123 -0
- package/dist/resources/templates/go-backend/internal/core/provider.go +198 -0
- package/dist/resources/templates/go-backend/internal/core/queue/metrics_middleware.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/queue/metrics_middleware_test.go +12 -0
- package/dist/resources/templates/go-backend/internal/core/queue/queue.go +288 -0
- package/dist/resources/templates/go-backend/internal/core/queue/queue_test.go +159 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/bulkhead.go +514 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/bulkhead_test.go +984 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/circuitbreaker.go +358 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/circuitbreaker_test.go +788 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/retry.go +318 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/retry_test.go +735 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/recorder.go +305 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/run_context.go +124 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/run_context_test.go +85 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/scheduler.go +1589 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/scheduler_control_test.go +808 -0
- package/dist/resources/templates/go-backend/internal/core/storage/oss_provider.go +398 -0
- package/dist/resources/templates/go-backend/internal/core/storage/oss_provider_test.go +89 -0
- package/dist/resources/templates/go-backend/internal/core/storage/path.go +110 -0
- package/dist/resources/templates/go-backend/internal/core/storage/path_test.go +301 -0
- package/dist/resources/templates/go-backend/internal/core/storage/s3_provider.go +489 -0
- package/dist/resources/templates/go-backend/internal/core/storage/s3_provider_test.go +60 -0
- package/dist/resources/templates/go-backend/internal/core/storage/storage.go +268 -0
- package/dist/resources/templates/go-backend/internal/core/storage/validation.go +225 -0
- package/dist/resources/templates/go-backend/internal/core/storage/validation_test.go +495 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/logger.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/provider.go +126 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/provider_test.go +67 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/client.go +282 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/client_test.go +81 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/config.go +58 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/handler.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/hub.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/message.go +273 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/notifier.go +92 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/provider.go +33 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/action.go +77 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/action_test.go +238 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/condition.go +107 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/decision.go +256 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/enum.go +643 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/errors.go +102 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/principal_record.go +21 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/product_context.go +486 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/resource.go +215 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/resource_test.go +242 -0
- package/dist/resources/templates/go-backend/internal/products/README.md +5 -0
- package/dist/resources/templates/go-backend/internal/sharedevents/README.md +5 -0
- package/dist/resources/templates/go-backend/migrations/000001_infrastructure.down.sql +13 -0
- package/dist/resources/templates/go-backend/migrations/000001_infrastructure.up.sql +886 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error.go +327 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_code.go +65 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_test.go +41 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_type.go +14 -0
- package/dist/resources/templates/go-backend/pkg/apierror/http_response.go +216 -0
- package/dist/resources/templates/go-backend/pkg/apierror/http_response_test.go +216 -0
- package/dist/resources/templates/go-backend/scripts/check-openapi-clean-deletion.sh +54 -0
- package/dist/resources/templates/go-backend/scripts/test-migrations.sh +32 -0
- package/dist/resources/templates/go-backend/tests/infrastructure.sql +69 -0
- package/dist/resources/templates/mcp-server/.claude/docs/stack.md +338 -0
- package/dist/resources/templates/mcp-server/.editorconfig +13 -0
- package/dist/resources/templates/mcp-server/.env.example +8 -0
- package/dist/resources/templates/mcp-server/.github/ISSUE_TEMPLATE/bug_report.yml +104 -0
- package/dist/resources/templates/mcp-server/.github/ISSUE_TEMPLATE/feature_request.yml +54 -0
- package/dist/resources/templates/mcp-server/.github/PULL_REQUEST_TEMPLATE.md +36 -0
- package/dist/resources/templates/mcp-server/.github/workflows/ci.yml +78 -0
- package/dist/resources/templates/mcp-server/.husky/commit-msg +1 -0
- package/dist/resources/templates/mcp-server/.husky/pre-commit +1 -0
- package/dist/resources/templates/mcp-server/.lintstagedrc.json +4 -0
- package/dist/resources/templates/mcp-server/.nvmrc +1 -0
- package/dist/resources/templates/mcp-server/.prettierrc +8 -0
- package/dist/resources/templates/mcp-server/CONTRIBUTING.md +184 -0
- package/dist/resources/templates/mcp-server/Dockerfile +23 -0
- package/dist/resources/templates/mcp-server/LICENSE +21 -0
- package/dist/resources/templates/mcp-server/README.md +123 -0
- package/dist/resources/templates/mcp-server/_gitignore +26 -0
- package/dist/resources/templates/mcp-server/commitlint.config.js +24 -0
- package/dist/resources/templates/mcp-server/eslint.config.js +30 -0
- package/dist/resources/templates/mcp-server/package.json +72 -0
- package/dist/resources/templates/mcp-server/src/index.ts +27 -0
- package/dist/resources/templates/mcp-server/src/resources.ts +33 -0
- package/dist/resources/templates/mcp-server/src/services/.gitkeep +0 -0
- package/dist/resources/templates/mcp-server/src/tools.ts +43 -0
- package/dist/resources/templates/mcp-server/src/types/index.ts +19 -0
- package/dist/resources/templates/mcp-server/src/utils/index.ts +31 -0
- package/dist/resources/templates/mcp-server/tsconfig.json +22 -0
- package/dist/resources/templates/mcp-server/tsup.config.ts +14 -0
- package/dist/resources/templates/mcp-server/vitest.config.ts +15 -0
- package/dist/resources/templates/nuxt/.claude/docs/stack.md +666 -0
- package/dist/resources/templates/nuxt/.editorconfig +15 -0
- package/dist/resources/templates/nuxt/.env.example +22 -0
- package/dist/resources/templates/nuxt/.github/workflows/ci.yml +34 -0
- package/dist/resources/templates/nuxt/.husky/commit-msg +1 -0
- package/dist/resources/templates/nuxt/.husky/pre-commit +1 -0
- package/dist/resources/templates/nuxt/.nvmrc +1 -0
- package/dist/resources/templates/nuxt/.prettierignore +9 -0
- package/dist/resources/templates/nuxt/.prettierrc +1 -0
- package/dist/resources/templates/nuxt/README.md +23 -0
- package/dist/resources/templates/nuxt/_gitignore +7 -0
- package/dist/resources/templates/nuxt/app/app.config.ts +105 -0
- package/dist/resources/templates/nuxt/app/i18n/locales/en.json +5 -0
- package/dist/resources/templates/nuxt/app/pages/app/index.vue +224 -0
- package/dist/resources/templates/nuxt/app/pages/authors/[slug].vue +37 -0
- package/dist/resources/templates/nuxt/app/pages/blog/[slug].vue +55 -0
- package/dist/resources/templates/nuxt/app/pages/blog/category/[category].vue +38 -0
- package/dist/resources/templates/nuxt/app/pages/blog/index.vue +46 -0
- package/dist/resources/templates/nuxt/app/pages/index.vue +626 -0
- package/dist/resources/templates/nuxt/app/pages/legal/privacy.vue +21 -0
- package/dist/resources/templates/nuxt/app/pages/legal/terms.vue +21 -0
- package/dist/resources/templates/nuxt/app/pages/ui/index.vue +397 -0
- package/dist/resources/templates/nuxt/commitlint.config.mjs +1 -0
- package/dist/resources/templates/nuxt/eslint.config.mjs +4 -0
- package/dist/resources/templates/nuxt/lint-staged.config.mjs +8 -0
- package/dist/resources/templates/nuxt/nuxt.config.ts +71 -0
- package/dist/resources/templates/nuxt/package.json +67 -0
- package/dist/resources/templates/nuxt/public/apple-touch-icon.png +0 -0
- package/dist/resources/templates/nuxt/public/favicon.ico +0 -0
- package/dist/resources/templates/nuxt/public/favicon.svg +5 -0
- package/dist/resources/templates/nuxt/public/icon-16x16.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-192x192.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-32x32.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-512x512.png +0 -0
- package/dist/resources/templates/nuxt/public/logo.svg +6 -0
- package/dist/resources/templates/nuxt/public/media/hero-product-gallery.png +0 -0
- package/dist/resources/templates/nuxt/server/api/content/sitemap-urls.get.ts +12 -0
- package/dist/resources/templates/nuxt/server/api/preview.get.ts +9 -0
- package/dist/resources/templates/nuxt/stylelint.config.mjs +3 -0
- package/dist/resources/templates/nuxt/test/e2e/rendering.test.ts +13 -0
- package/dist/resources/templates/nuxt/tsconfig.json +3 -0
- package/dist/resources/templates/nuxt/vitest.config.ts +8 -0
- package/package.json +8 -5
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# MCP Server Application Coding Standard
|
|
2
|
+
|
|
3
|
+
> **Stack**: Node.js >=20, TypeScript 5, ESM, MCP SDK (`@modelcontextprotocol/sdk` 1.x), Zod 3, tsup 8, Vitest 2, ESLint 9 and Prettier 3.
|
|
4
|
+
> **Transport**: compiled stdio server. Tool and resource registrations are application-owned.
|
|
5
|
+
> `package.json` and the lockfile are the dependency/version authority.
|
|
6
|
+
|
|
7
|
+
## I. Project Purpose and Runtime
|
|
8
|
+
|
|
9
|
+
The application exposes typed MCP tools and resources through the installed SDK. `src/index.ts` creates the server, registers tools/resources and connects `StdioServerTransport`. External application services belong in `src/services/`; tool registration is not an authorization or persistence layer.
|
|
10
|
+
|
|
11
|
+
The current template provides `hello`, `get_info` and a help resource. It does not include remote credentials, a database, OAuth middleware, an HTTP transport, a hosted API gateway or a background worker. Do not describe such capabilities as installed merely because the architecture can support an adapter.
|
|
12
|
+
|
|
13
|
+
### Commands
|
|
14
|
+
|
|
15
|
+
| Command | Actual script behavior |
|
|
16
|
+
| ---------------------------------- | ---------------------------------------------------------------- |
|
|
17
|
+
| `pnpm dev` | `tsup --watch`; rebuilds, does not itself start a client session |
|
|
18
|
+
| `pnpm build` | Build compiled output with tsup |
|
|
19
|
+
| `pnpm start` | Run `dist/index.js` |
|
|
20
|
+
| `pnpm start:stdio` | Run the compiled entry with `--stdio` |
|
|
21
|
+
| `pnpm typecheck` | `tsc --noEmit` |
|
|
22
|
+
| `pnpm lint`, `pnpm lint:fix` | ESLint over `src/` |
|
|
23
|
+
| `pnpm format`, `pnpm format:check` | Prettier over TypeScript source |
|
|
24
|
+
| `pnpm test`, `pnpm test:watch` | Vitest run/watch |
|
|
25
|
+
| `pnpm test:coverage` | Vitest with V8 coverage |
|
|
26
|
+
| `pnpm inspect` | Launch the MCP Inspector command |
|
|
27
|
+
| `pnpm mcp-test` | Start stdio process; not an assertion-based protocol test |
|
|
28
|
+
| `pnpm publish:local` | Build and pack the npm artifact |
|
|
29
|
+
| `pnpm prepublishOnly` | Typecheck, lint, test and build |
|
|
30
|
+
| `pnpm pub:release` | Build and publish; requires publication authorization |
|
|
31
|
+
| `pnpm prepare` | Existing Husky setup script |
|
|
32
|
+
|
|
33
|
+
A successful executable launch is not proof of a valid initialize/list/call/read exchange. Build before inspecting the compiled entry. Declared test scripts do not imply business or external-service acceptance coverage exists.
|
|
34
|
+
|
|
35
|
+
### Environment
|
|
36
|
+
|
|
37
|
+
`.env.example` currently documents `DEBUG=false` and credential examples. The entrypoint does not load dotenv or read `DEBUG`; creating `.env` does not automatically activate configuration. Configure actual process environment through the launcher and document each real consumer when adding a variable.
|
|
38
|
+
|
|
39
|
+
**FORBIDDEN**: private credentials in tool descriptions, help resources, source, package metadata, command arguments logged by the launcher or protocol output. Validate required configuration before registering an operational capability that depends on it.
|
|
40
|
+
|
|
41
|
+
## II. Structure and Import Rules
|
|
42
|
+
|
|
43
|
+
| Owner | Key responsibility |
|
|
44
|
+
| ------------------------------------- | -------------------------------------------------------- |
|
|
45
|
+
| `src/index.ts` | Server identity, registration and transport startup |
|
|
46
|
+
| `src/tools.ts::registerTools` | Tool names, descriptions, argument schemas and dispatch |
|
|
47
|
+
| `src/resources.ts::registerResources` | Resource identity, URI, MIME type and read result |
|
|
48
|
+
| `src/services/` | External service implementation and protocol translation |
|
|
49
|
+
| `src/types/index.ts` | Existing application type declarations |
|
|
50
|
+
| `src/utils/index.ts` | `safeJsonParse`, `delay`, `formatError` value helpers |
|
|
51
|
+
| `tsup.config.ts` | Compiled entry and build output |
|
|
52
|
+
| `tsconfig.json` | TypeScript module/resolution contract |
|
|
53
|
+
| `vitest.config.ts` | Test discovery and execution configuration |
|
|
54
|
+
|
|
55
|
+
Use type-only imports for types. Runtime relative imports retain `.js` suffixes as required by the ESM source/build convention. Public SDK imports follow the actual installed exports, not guessed internal paths.
|
|
56
|
+
|
|
57
|
+
Import order: types → SDK/framework → installed libraries → application owners. Do not add undeclared dependencies or import a package's private source directory.
|
|
58
|
+
|
|
59
|
+
## III. Read and Placement Gate (CRITICAL)
|
|
60
|
+
|
|
61
|
+
Before adding a tool/resource, read existing registrations, SDK version and public API, input/output types, service adapter and runtime consumer. Search names and URIs with `rg`; registrations must remain unique and describe the owning action.
|
|
62
|
+
|
|
63
|
+
| Responsibility | Owner |
|
|
64
|
+
| ----------------------------------- | -------------------------------------- |
|
|
65
|
+
| MCP argument schema | Tool registration |
|
|
66
|
+
| Use case and business invariant | Application service |
|
|
67
|
+
| Provider HTTP payload/error mapping | Service adapter |
|
|
68
|
+
| Shared pure parsing/formatting | Existing utility when contract matches |
|
|
69
|
+
| Process connection/lifetime | Entrypoint and transport composition |
|
|
70
|
+
| Permission and resource scope | Authoritative service contract |
|
|
71
|
+
|
|
72
|
+
A tool callback may parse and dispatch; it must not become a second provider implementation. A provider adapter must not register protocol handlers, choose UI copy or write transport frames.
|
|
73
|
+
|
|
74
|
+
✅ Correct: tool validates arguments, calls a typed service and converts its result to MCP content.
|
|
75
|
+
|
|
76
|
+
❌ Wrong: every tool builds its own client, reads credentials, implements retries and catches all errors as success.
|
|
77
|
+
|
|
78
|
+
## IV. Tool Contract Standards
|
|
79
|
+
|
|
80
|
+
Names describe one independently callable action. Descriptions state its purpose, input meaning and observable effect without hidden prerequisites. A tool with effects must identify the scope and permission boundary; model instructions cannot grant authority.
|
|
81
|
+
|
|
82
|
+
Zod schemas validate string length, numeric range, enum choices and required fields as appropriate. Validate at the boundary before effects; internal code consumes typed values. Do not repeatedly parse trusted framework-provided fields.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { z } from "zod";
|
|
86
|
+
|
|
87
|
+
const inputShape = {
|
|
88
|
+
name: z.string().trim().min(1).max(120).describe("Name to greet"),
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This is a schema pattern, not a claim that the current `hello` schema already enforces those limits. Production tool changes must align descriptions, accepted arguments and implementation.
|
|
93
|
+
|
|
94
|
+
### Result Semantics
|
|
95
|
+
|
|
96
|
+
| Outcome | Required result |
|
|
97
|
+
| --------------------------- | -------------------------------------------------------------------- |
|
|
98
|
+
| Completed read/action | Content describes the actual result |
|
|
99
|
+
| Accepted asynchronous work | Return operation identity and accepted/running state |
|
|
100
|
+
| Validation/protocol failure | Use SDK protocol failure semantics |
|
|
101
|
+
| Execution failure | Error result appropriate to SDK/tool contract; do not report success |
|
|
102
|
+
| Partial completion | Preserve completed results and identify failed parts |
|
|
103
|
+
| Unsupported operation | Explicit typed failure; no empty success |
|
|
104
|
+
|
|
105
|
+
Do not use one `success` boolean for accepted, completed and partially failed work. Counts and progress come from authoritative service data, not elapsed time or fabricated samples.
|
|
106
|
+
|
|
107
|
+
## V. Resource Standards
|
|
108
|
+
|
|
109
|
+
Resources represent readable content with stable URI identity and explicit MIME type. Return contents whose URI agrees with the requested/registered resource. Scope dynamic resources to the authorized service data; guessed URIs do not bypass authorization.
|
|
110
|
+
|
|
111
|
+
Resource reads must not perform unrelated mutations. Expensive or paginated data must use a bounded contract; do not dump unlimited records into a single text response. Help resources list real available capabilities and current input meaning.
|
|
112
|
+
|
|
113
|
+
✅ Correct: a help resource documents registered tool names and URI identity.
|
|
114
|
+
|
|
115
|
+
❌ Wrong: static help claims a remote account action exists while registration/service support is absent.
|
|
116
|
+
|
|
117
|
+
## VI. Type Definitions and Validation
|
|
118
|
+
|
|
119
|
+
Co-locate tool-specific input/result types with their owner. Shared types require actual multiple consumers. Use SDK result types where appropriate rather than creating a broader incompatible protocol union.
|
|
120
|
+
|
|
121
|
+
`ServerConfig` is an application declaration, not proof of a runtime configuration loader. `ToolResult` is a local type and must not override the SDK wire schema.
|
|
122
|
+
|
|
123
|
+
`safeJsonParse<T>` checks JSON syntax only. The generic assertion does not verify fields; validate external data with a real schema after parsing. `formatError` converts an unknown error to text; callers must ensure that text is safe before exposing it to users.
|
|
124
|
+
|
|
125
|
+
**FORBIDDEN**: treating `as SomeResponse`, `unknown as SomeResponse` or an optional field bag as proof that an external response is valid. Keep error, absent and partial data states explicit.
|
|
126
|
+
|
|
127
|
+
## VII. Services and Extension Points (CRITICAL)
|
|
128
|
+
|
|
129
|
+
External calls and replaceable providers start with a consumer-owned interface, then configuration, concrete adapter and dependency composition. Tool contracts must not embed provider model names or credential format.
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
interface LookupService {
|
|
133
|
+
lookup(query: string, signal: AbortSignal): Promise<readonly string[]>;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
A second adapter should change the adapter and composition/configuration entry, not every tool. Keep service errors stable while preserving provider diagnostics behind a safe boundary.
|
|
138
|
+
|
|
139
|
+
Do not add a universal `execute(name, args: any)` service to hide incompatible operations. Each tool/service operation needs precise arguments, effect semantics, idempotency and errors.
|
|
140
|
+
|
|
141
|
+
## VIII. Security and Authorization
|
|
142
|
+
|
|
143
|
+
A local stdio connection is a transport context, not permission to access every resource or provider account. Enforce scope through the configured service identity and actual backend contract. User-supplied IDs, file paths, URLs and model-generated arguments remain untrusted.
|
|
144
|
+
|
|
145
|
+
Outbound adapters restrict protocol and destination. File adapters resolve paths against configured roots and reject traversal. A tool description saying “safe” does not constrain runtime behavior.
|
|
146
|
+
|
|
147
|
+
Never expose secrets in one-time credentials except through the deliberate, authorized result contract. Logs and subsequent reads must redact them. Do not add fictional OAuth/IAM behavior to documentation for an unimplemented transport.
|
|
148
|
+
|
|
149
|
+
## IX. Transport and Lifecycle
|
|
150
|
+
|
|
151
|
+
stdout belongs exclusively to MCP framing. Diagnostics use stderr and exclude secret values. `console.log` in a tool or provider corrupts stdio even when the business function is otherwise correct.
|
|
152
|
+
|
|
153
|
+
The process entry owns connection startup and shutdown. Every subscription, timer, request and stream has a disposal owner. A disconnected client or cancelled request cannot continue writing results into another session's state.
|
|
154
|
+
|
|
155
|
+
The existing `delay` utility is an uncancellable timer. Do not treat it as a cancellation-aware retry primitive. Use an operation-owned abort contract for cancellable remote work.
|
|
156
|
+
|
|
157
|
+
Transport disconnect only proves local disconnection. It does not prove remote rollback, job cancellation or refund. Report the actual acknowledged service state.
|
|
158
|
+
|
|
159
|
+
## X. Retry, Concurrency and Idempotency
|
|
160
|
+
|
|
161
|
+
Read retries are bounded by attempt and total-time budgets. Honor cancellation and provider retry hints. Mutation retries require explicit idempotency or acceptance-status lookup; ambiguous timeouts must not trigger blind duplicate effects.
|
|
162
|
+
|
|
163
|
+
Idempotency keys, internal resource IDs, external IDs and display labels have separate meanings. The authoritative backend owns durable uniqueness and replay. A process-local Set cannot provide cross-process exactly-once execution.
|
|
164
|
+
|
|
165
|
+
Concurrent tool calls must not overwrite shared mutable state or reuse one caller's identity. Scope caches and clients according to the credential/resource boundary. Do not share sensitive results through unscoped module globals.
|
|
166
|
+
|
|
167
|
+
## XI. Error and Diagnostic Contract
|
|
168
|
+
|
|
169
|
+
| Failure | Handling |
|
|
170
|
+
| --------------------- | -------------------------------------------------------- |
|
|
171
|
+
| Invalid arguments | Reject before provider call with safe field guidance |
|
|
172
|
+
| Missing configuration | Explicit startup/capability failure; no simulated result |
|
|
173
|
+
| Permission denied | Preserve denial; do not retry with another identity |
|
|
174
|
+
| Rate limit | Bounded retry or explicit retryable result |
|
|
175
|
+
| Provider unavailable | Safe code and preserved correlation |
|
|
176
|
+
| Internal failure | Safe tool/protocol error and controlled diagnostics |
|
|
177
|
+
|
|
178
|
+
Catch errors only at a boundary that can translate, recover or terminate correctly. Empty catch blocks and fallback successful content are forbidden. A valid JSON response containing false claims is still a failed contract.
|
|
179
|
+
|
|
180
|
+
## XII. Forbidden Patterns
|
|
181
|
+
|
|
182
|
+
| ID | Forbidden | Required behavior |
|
|
183
|
+
| ------ | ---------------------------------------------------- | --------------------------------------- |
|
|
184
|
+
| MCP-01 | Unvalidated tool arguments | Declared schema before effects |
|
|
185
|
+
| MCP-02 | Credentials/protocol conversion in tool descriptions | Configuration and service adapters |
|
|
186
|
+
| MCP-03 | Failed operation returned as success | Explicit semantic error |
|
|
187
|
+
| MCP-04 | Diagnostic stdout writes | Protocol-only stdout, safe stderr |
|
|
188
|
+
| MCP-05 | Hidden resource lifetime | Explicit owner and disposal |
|
|
189
|
+
| MCP-06 | Unbounded effectful retry | Contract-backed bounded retry |
|
|
190
|
+
| MCP-07 | Provider-specific model in shared interface | Configured provider adapter |
|
|
191
|
+
| MCP-08 | Type assertions as validation | Parse unknown data |
|
|
192
|
+
| MCP-09 | Unrestricted URL or filesystem access | Configured destination/root scope |
|
|
193
|
+
| MCP-10 | Duplicate tool/resource identity | Unique registry entry and matching docs |
|
|
194
|
+
| MCP-11 | Help resources describe absent behavior | Real registered capabilities |
|
|
195
|
+
| MCP-12 | Startup success claimed as protocol acceptance | Initialize/list/call/read evidence |
|
|
196
|
+
| MCP-13 | Test fixtures in production results | Real service response |
|
|
197
|
+
| MCP-14 | Unshipped source imports in package | Packed artifact consumer checks |
|
|
198
|
+
| MCP-15 | Tool input grants resource authority | Backend/service authorization |
|
|
199
|
+
| MCP-16 | Error serializer leaks request credentials | Safe code/message boundary |
|
|
200
|
+
|
|
201
|
+
## XIII. Testing and Distribution
|
|
202
|
+
|
|
203
|
+
Use Vitest for schema, service and result behavior. Fakes are test-only and preserve the actual success/error shape. Assert observable guarantees, including rejection before effects, timeout ambiguity, partial completion and disposal.
|
|
204
|
+
|
|
205
|
+
For transport changes, build and verify initialization, tools/list, tools/call, resources/list, resources/read and close through a real protocol client. Include invalid/unknown operations. Inspect stdout purity and stderr safety.
|
|
206
|
+
|
|
207
|
+
For package changes, inspect `npm pack` output and run the compiled binary outside the source workspace. `files` currently publishes `dist` and README; source checkout files cannot be required at runtime. Do not publish without authorization.
|
|
208
|
+
|
|
209
|
+
### Complete Registration and Protocol Error Example
|
|
210
|
+
|
|
211
|
+
This complete Vitest example exercises the installed SDK with linked transports. It registers a deterministic text-normalization tool, calls it through `Client`, verifies content and verifies an explicit execution-error result. The example has no provider credentials, HTTP endpoints or product policy. In an application, the registration function belongs to the tool owner and is called by `src/index.ts`; the test belongs in test source.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import { afterEach, expect, test } from "vitest";
|
|
215
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
216
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
217
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
218
|
+
import { z } from "zod";
|
|
219
|
+
|
|
220
|
+
function registerNormalizationTool(server: McpServer): void {
|
|
221
|
+
server.tool(
|
|
222
|
+
"normalize_text",
|
|
223
|
+
"Normalize whitespace within a declared output limit.",
|
|
224
|
+
{
|
|
225
|
+
text: z.string().min(1).max(10_000),
|
|
226
|
+
maxLength: z.number().int().min(1).max(10_000),
|
|
227
|
+
},
|
|
228
|
+
async ({ text, maxLength }) => {
|
|
229
|
+
const normalized = text.trim().replace(/\s+/gu, " ");
|
|
230
|
+
if (normalized.length > maxLength) {
|
|
231
|
+
return {
|
|
232
|
+
isError: true,
|
|
233
|
+
content: [{ type: "text" as const, text: "Normalized text exceeds the output limit." }],
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return { content: [{ type: "text" as const, text: normalized }] };
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const client = new Client({ name: "protocol-check", version: "1.0.0" });
|
|
242
|
+
const server = new McpServer({ name: "normalization-example", version: "1.0.0" });
|
|
243
|
+
afterEach(async () => {
|
|
244
|
+
await client.close();
|
|
245
|
+
await server.close();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test("registration, successful call and execution error preserve protocol semantics", async () => {
|
|
249
|
+
registerNormalizationTool(server);
|
|
250
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
251
|
+
await server.connect(serverTransport);
|
|
252
|
+
await client.connect(clientTransport);
|
|
253
|
+
|
|
254
|
+
const listing = await client.listTools();
|
|
255
|
+
expect(listing.tools.map((tool) => tool.name)).toContain("normalize_text");
|
|
256
|
+
|
|
257
|
+
const result = await client.callTool({
|
|
258
|
+
name: "normalize_text",
|
|
259
|
+
arguments: { text: " alpha beta ", maxLength: 20 },
|
|
260
|
+
});
|
|
261
|
+
expect(result.isError).not.toBe(true);
|
|
262
|
+
expect(result.content).toEqual([{ type: "text", text: "alpha beta" }]);
|
|
263
|
+
|
|
264
|
+
const failure = await client.callTool({
|
|
265
|
+
name: "normalize_text",
|
|
266
|
+
arguments: { text: "alpha beta", maxLength: 3 },
|
|
267
|
+
});
|
|
268
|
+
expect(failure.isError).toBe(true);
|
|
269
|
+
expect(failure.content).toEqual([
|
|
270
|
+
{ type: "text", text: "Normalized text exceeds the output limit." },
|
|
271
|
+
]);
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
✅ An execution limit returns `isError: true`, not a successful empty string. SDK schemas still reject malformed types before the callback; boundary tests must also cover those schema constraints when changing them.
|
|
276
|
+
|
|
277
|
+
❌ Do not call a tool callback directly and label that a protocol test. Do not catch every provider exception into `{ content: [] }`, and do not write diagnostic messages to stdout.
|
|
278
|
+
|
|
279
|
+
### Complete Compiled Stdio Acceptance Example
|
|
280
|
+
|
|
281
|
+
The following JavaScript script runs against the **existing generated** `hello`, `get_info` and help resource. Save it as `scripts/check-stdio.mjs` in a generated application that needs this check, build, then run `node scripts/check-stdio.mjs`. This is an executable example, not a claim that the template already ships this script or a corresponding package command.
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
284
|
+
import assert from "node:assert/strict";
|
|
285
|
+
import { resolve } from "node:path";
|
|
286
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
287
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
288
|
+
|
|
289
|
+
const client = new Client({ name: "stdio-check", version: "1.0.0" });
|
|
290
|
+
const transport = new StdioClientTransport({
|
|
291
|
+
command: process.execPath,
|
|
292
|
+
args: [resolve("dist/index.js"), "--stdio"],
|
|
293
|
+
stderr: "inherit",
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
try {
|
|
297
|
+
await client.connect(transport);
|
|
298
|
+
const listing = await client.listTools();
|
|
299
|
+
assert.ok(listing.tools.some((tool) => tool.name === "hello"));
|
|
300
|
+
assert.ok(listing.tools.some((tool) => tool.name === "get_info"));
|
|
301
|
+
const greeting = await client.callTool({ name: "hello", arguments: { name: "Ada" } });
|
|
302
|
+
assert.notEqual(greeting.isError, true);
|
|
303
|
+
assert.ok(
|
|
304
|
+
greeting.content.some((block) => block.type === "text" && block.text.includes("Hello, Ada!")),
|
|
305
|
+
);
|
|
306
|
+
const resources = await client.listResources();
|
|
307
|
+
const help = resources.resources.find((resource) => resource.name === "help");
|
|
308
|
+
assert.ok(help, "Help resource must be registered");
|
|
309
|
+
const result = await client.readResource({ uri: help.uri });
|
|
310
|
+
assert.ok(
|
|
311
|
+
result.contents.some((entry) => entry.uri === help.uri && entry.mimeType === "text/markdown"),
|
|
312
|
+
);
|
|
313
|
+
} finally {
|
|
314
|
+
await client.close();
|
|
315
|
+
await transport.close();
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
The SDK client performs initialization and owns request framing; the compiled child process proves distribution/startup behavior. In-memory protocol tests and stdio acceptance prove different boundaries. Neither proves an external provider account is authorized. Assertions, connection shutdown and error propagation are part of the example; do not replace them with a process-start message.
|
|
320
|
+
|
|
321
|
+
## XIV. Documentation and Delivery
|
|
322
|
+
|
|
323
|
+
Comments explain why in Chinese. Exported services and utilities document input, errors, ownership and disposal where not self-evident. Keep tool descriptions, help resources and actual registration synchronized.
|
|
324
|
+
|
|
325
|
+
Read [Architecture](architecture.md), [Security and Lifecycle](security-lifecycle.md), [Verification](verification.md) and the full [Design Template](architecture-template.md).
|
|
326
|
+
|
|
327
|
+
### Pre-commit Checklist
|
|
328
|
+
|
|
329
|
+
- [ ] Tool/resource names and URIs are unique and documented accurately.
|
|
330
|
+
- [ ] Schemas validate input before effects and types match SDK contracts.
|
|
331
|
+
- [ ] Provider configuration, business policy and protocol registration have separate owners.
|
|
332
|
+
- [ ] Scope, safe errors, cancellation and idempotency are explicit.
|
|
333
|
+
- [ ] stdout is protocol-clean; stderr contains no credentials or personal payloads.
|
|
334
|
+
- [ ] `pnpm typecheck`, `pnpm lint`, `pnpm test` and `pnpm build` pass for code changes.
|
|
335
|
+
- [ ] Actual compiled transport behavior is verified when touched.
|
|
336
|
+
- [ ] Packed artifact runs independently of the company checkout.
|
|
337
|
+
- [ ] External-service acceptance is not inferred from fakes or process launch.
|
|
338
|
+
- [ ] No deferred production action or invented command is delivered.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# EditorConfig - https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
insert_final_newline = true
|
|
8
|
+
trim_trailing_whitespace = true
|
|
9
|
+
indent_style = space
|
|
10
|
+
indent_size = 2
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug or unexpected behavior
|
|
3
|
+
labels: ["bug", "triage"]
|
|
4
|
+
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for taking the time to report a bug! Please fill out the form below.
|
|
10
|
+
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: description
|
|
13
|
+
attributes:
|
|
14
|
+
label: Bug Description
|
|
15
|
+
description: A clear and concise description of what the bug is.
|
|
16
|
+
placeholder: Describe the bug...
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
19
|
+
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: reproduction
|
|
22
|
+
attributes:
|
|
23
|
+
label: Steps to Reproduce
|
|
24
|
+
description: Steps to reproduce the behavior.
|
|
25
|
+
placeholder: |
|
|
26
|
+
1. Configure MCP server with...
|
|
27
|
+
2. Run command...
|
|
28
|
+
3. See error...
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
31
|
+
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: expected
|
|
34
|
+
attributes:
|
|
35
|
+
label: Expected Behavior
|
|
36
|
+
description: What did you expect to happen?
|
|
37
|
+
placeholder: Describe what you expected...
|
|
38
|
+
validations:
|
|
39
|
+
required: true
|
|
40
|
+
|
|
41
|
+
- type: textarea
|
|
42
|
+
id: actual
|
|
43
|
+
attributes:
|
|
44
|
+
label: Actual Behavior
|
|
45
|
+
description: What actually happened?
|
|
46
|
+
placeholder: Describe what actually happened...
|
|
47
|
+
validations:
|
|
48
|
+
required: true
|
|
49
|
+
|
|
50
|
+
- type: input
|
|
51
|
+
id: version
|
|
52
|
+
attributes:
|
|
53
|
+
label: Package Version
|
|
54
|
+
description: What version of {{projectName}} are you using?
|
|
55
|
+
placeholder: "0.1.0"
|
|
56
|
+
validations:
|
|
57
|
+
required: true
|
|
58
|
+
|
|
59
|
+
- type: dropdown
|
|
60
|
+
id: client
|
|
61
|
+
attributes:
|
|
62
|
+
label: MCP Client
|
|
63
|
+
description: Which MCP client are you using?
|
|
64
|
+
options:
|
|
65
|
+
- Cursor
|
|
66
|
+
- Windsurf
|
|
67
|
+
- Cline
|
|
68
|
+
- Claude Desktop
|
|
69
|
+
- Other
|
|
70
|
+
validations:
|
|
71
|
+
required: true
|
|
72
|
+
|
|
73
|
+
- type: input
|
|
74
|
+
id: node-version
|
|
75
|
+
attributes:
|
|
76
|
+
label: Node.js Version
|
|
77
|
+
description: What version of Node.js are you using? (run `node -v`)
|
|
78
|
+
placeholder: "v20.0.0"
|
|
79
|
+
validations:
|
|
80
|
+
required: true
|
|
81
|
+
|
|
82
|
+
- type: dropdown
|
|
83
|
+
id: os
|
|
84
|
+
attributes:
|
|
85
|
+
label: Operating System
|
|
86
|
+
options:
|
|
87
|
+
- macOS
|
|
88
|
+
- Windows
|
|
89
|
+
- Linux
|
|
90
|
+
validations:
|
|
91
|
+
required: true
|
|
92
|
+
|
|
93
|
+
- type: textarea
|
|
94
|
+
id: logs
|
|
95
|
+
attributes:
|
|
96
|
+
label: Error Logs
|
|
97
|
+
description: If applicable, paste any error logs here.
|
|
98
|
+
render: shell
|
|
99
|
+
|
|
100
|
+
- type: textarea
|
|
101
|
+
id: additional
|
|
102
|
+
attributes:
|
|
103
|
+
label: Additional Context
|
|
104
|
+
description: Any other context about the problem.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature or improvement
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for suggesting a feature! Please fill out the form below.
|
|
10
|
+
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: problem
|
|
13
|
+
attributes:
|
|
14
|
+
label: Problem Statement
|
|
15
|
+
description: Is your feature request related to a problem? Please describe.
|
|
16
|
+
placeholder: "I'm always frustrated when..."
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
19
|
+
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: solution
|
|
22
|
+
attributes:
|
|
23
|
+
label: Proposed Solution
|
|
24
|
+
description: Describe the solution you'd like to see.
|
|
25
|
+
placeholder: "I would like to be able to..."
|
|
26
|
+
validations:
|
|
27
|
+
required: true
|
|
28
|
+
|
|
29
|
+
- type: textarea
|
|
30
|
+
id: alternatives
|
|
31
|
+
attributes:
|
|
32
|
+
label: Alternatives Considered
|
|
33
|
+
description: Describe any alternative solutions or features you've considered.
|
|
34
|
+
placeholder: "I've also thought about..."
|
|
35
|
+
|
|
36
|
+
- type: dropdown
|
|
37
|
+
id: priority
|
|
38
|
+
attributes:
|
|
39
|
+
label: Priority
|
|
40
|
+
description: How important is this feature to you?
|
|
41
|
+
options:
|
|
42
|
+
- Nice to have
|
|
43
|
+
- Important
|
|
44
|
+
- Critical
|
|
45
|
+
validations:
|
|
46
|
+
required: true
|
|
47
|
+
|
|
48
|
+
- type: checkboxes
|
|
49
|
+
id: contribution
|
|
50
|
+
attributes:
|
|
51
|
+
label: Contribution
|
|
52
|
+
description: Are you willing to contribute to this feature?
|
|
53
|
+
options:
|
|
54
|
+
- label: I'm willing to submit a PR for this feature
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
<!-- Describe your changes in detail -->
|
|
4
|
+
|
|
5
|
+
## Related Issue
|
|
6
|
+
|
|
7
|
+
<!-- Link to the issue this PR addresses (if applicable) -->
|
|
8
|
+
<!-- Fixes #123 -->
|
|
9
|
+
|
|
10
|
+
## Type of Change
|
|
11
|
+
|
|
12
|
+
<!-- Mark the relevant option with an "x" -->
|
|
13
|
+
|
|
14
|
+
- [ ] Bug fix (non-breaking change that fixes an issue)
|
|
15
|
+
- [ ] New feature (non-breaking change that adds functionality)
|
|
16
|
+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
|
17
|
+
- [ ] Documentation update
|
|
18
|
+
- [ ] Refactoring (no functional changes)
|
|
19
|
+
|
|
20
|
+
## Checklist
|
|
21
|
+
|
|
22
|
+
- [ ] My code follows the project's style guidelines
|
|
23
|
+
- [ ] I have performed a self-review of my code
|
|
24
|
+
- [ ] I have added/updated comments for hard-to-understand areas
|
|
25
|
+
- [ ] I have updated the documentation (if applicable)
|
|
26
|
+
- [ ] My changes generate no new warnings
|
|
27
|
+
- [ ] I have run `pnpm lint` and `pnpm build` successfully
|
|
28
|
+
- [ ] I have tested my changes locally
|
|
29
|
+
|
|
30
|
+
## Screenshots (if applicable)
|
|
31
|
+
|
|
32
|
+
<!-- Add screenshots to help explain your changes -->
|
|
33
|
+
|
|
34
|
+
## Additional Notes
|
|
35
|
+
|
|
36
|
+
<!-- Any additional information that reviewers should know -->
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [18.x, 20.x, 22.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install pnpm
|
|
22
|
+
uses: pnpm/action-setup@v4
|
|
23
|
+
with:
|
|
24
|
+
version: 9
|
|
25
|
+
|
|
26
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
|
+
with:
|
|
29
|
+
node-version: ${{ matrix.node-version }}
|
|
30
|
+
cache: "pnpm"
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: pnpm install --frozen-lockfile
|
|
34
|
+
|
|
35
|
+
- name: Type check
|
|
36
|
+
run: pnpm typecheck
|
|
37
|
+
|
|
38
|
+
- name: Lint
|
|
39
|
+
run: pnpm lint
|
|
40
|
+
|
|
41
|
+
- name: Test
|
|
42
|
+
run: pnpm test
|
|
43
|
+
|
|
44
|
+
- name: Build
|
|
45
|
+
run: pnpm build
|
|
46
|
+
|
|
47
|
+
release:
|
|
48
|
+
needs: build
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
51
|
+
|
|
52
|
+
steps:
|
|
53
|
+
- name: Checkout repository
|
|
54
|
+
uses: actions/checkout@v4
|
|
55
|
+
|
|
56
|
+
- name: Install pnpm
|
|
57
|
+
uses: pnpm/action-setup@v4
|
|
58
|
+
with:
|
|
59
|
+
version: 9
|
|
60
|
+
|
|
61
|
+
- name: Setup Node.js
|
|
62
|
+
uses: actions/setup-node@v4
|
|
63
|
+
with:
|
|
64
|
+
node-version: 20.x
|
|
65
|
+
cache: "pnpm"
|
|
66
|
+
registry-url: "https://registry.npmjs.org"
|
|
67
|
+
|
|
68
|
+
- name: Install dependencies
|
|
69
|
+
run: pnpm install --frozen-lockfile
|
|
70
|
+
|
|
71
|
+
- name: Build
|
|
72
|
+
run: pnpm build
|
|
73
|
+
|
|
74
|
+
# Uncomment to enable auto-publish on main branch
|
|
75
|
+
# - name: Publish to npm
|
|
76
|
+
# run: npm publish --access public
|
|
77
|
+
# env:
|
|
78
|
+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit $1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-staged
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20
|