@stackonward/cli 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +16 -12
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { Script } from 'node:vm';
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
localizeScalarBrowserAsset,
|
|
9
|
+
scalarAssetLocale,
|
|
10
|
+
scalarAssetLocalizationRevision,
|
|
11
|
+
} from '../scalar_asset_localization.mjs';
|
|
12
|
+
|
|
13
|
+
const assetPath = resolve(import.meta.dirname, '../../node_modules/@scalar/api-reference/dist/browser/standalone.js');
|
|
14
|
+
|
|
15
|
+
test('localizes the pinned Scalar browser asset deterministically', async () => {
|
|
16
|
+
const upstream = await readFile(assetPath);
|
|
17
|
+
const first = localizeScalarBrowserAsset(upstream);
|
|
18
|
+
const second = localizeScalarBrowserAsset(upstream);
|
|
19
|
+
|
|
20
|
+
assert.deepEqual(first, second);
|
|
21
|
+
assert.equal(scalarAssetLocale, 'zh-CN');
|
|
22
|
+
assert.equal(scalarAssetLocalizationRevision, 'onex-zh-CN-v1');
|
|
23
|
+
assert.match(first.toString(), /未选择身份验证方式/);
|
|
24
|
+
assert.match(first.toString(), /API 调试客户端/);
|
|
25
|
+
assert.match(first.toString(), /发送请求/);
|
|
26
|
+
assert.match(first.toString(), /输入搜索关键词/);
|
|
27
|
+
assert.match(first.toString(), /HTTP 方法/);
|
|
28
|
+
assert.match(first.toString(), /关闭分组/);
|
|
29
|
+
assert.match(first.toString(), /打开分组/);
|
|
30
|
+
assert.doesNotMatch(first.toString(), /` No authentication selected `/);
|
|
31
|
+
assert.doesNotMatch(first.toString(), /`Request Example for`/);
|
|
32
|
+
assert.doesNotMatch(first.toString(), /` Send Request `/);
|
|
33
|
+
assert.doesNotMatch(first.toString(), /label:`Search`,size:`sm`/);
|
|
34
|
+
assert.doesNotMatch(first.toString(), /label:`Delete \$\{/);
|
|
35
|
+
assert.doesNotMatch(first.toString(), /options:\{hideOperationDefaultExamples:e\.layout===`modal`\}/);
|
|
36
|
+
assert.doesNotMatch(first.toString(), /containerAriaLabel:\{default:`Notifications`\}/);
|
|
37
|
+
assert.doesNotMatch(first.toString(), /k\(e\.label\)\+` Key`/);
|
|
38
|
+
assert.doesNotMatch(first.toString(), /`\$\{e\.label\} Key`/);
|
|
39
|
+
assert.doesNotThrow(() => new Script(first.toString()));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('rejects unsupported locales and upstream source drift', async () => {
|
|
43
|
+
const upstream = await readFile(assetPath, 'utf8');
|
|
44
|
+
const drifted = upstream.replace('`Request Example for`', '`Changed Request Example`');
|
|
45
|
+
const overCounted = upstream.replace('`Request Example for`', '`Request Example for``Request Example for`');
|
|
46
|
+
|
|
47
|
+
assert.throws(() => localizeScalarBrowserAsset(upstream, 'en'), /locale en is not supported/);
|
|
48
|
+
assert.throws(() => localizeScalarBrowserAsset(drifted), /source drift/);
|
|
49
|
+
assert.throws(() => localizeScalarBrowserAsset(overCounted), /expected 1, found 2/);
|
|
50
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { generateSDKPackages } from '../sdk_generator.mjs';
|
|
5
|
+
|
|
6
|
+
test('generated SDK text artifacts contain no trailing whitespace', async () => {
|
|
7
|
+
const [sdkPackage] = await generateSDKPackages({
|
|
8
|
+
audience: 'public',
|
|
9
|
+
contractSha256: 'b'.repeat(64),
|
|
10
|
+
document: {
|
|
11
|
+
info: { title: 'Fixture API', version: '1.0.0' },
|
|
12
|
+
openapi: '3.1.1',
|
|
13
|
+
paths: {
|
|
14
|
+
'/health': {
|
|
15
|
+
get: {
|
|
16
|
+
operationId: 'getHealth',
|
|
17
|
+
responses: { 200: { description: 'OK' } },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
gitRevision: 'a'.repeat(40),
|
|
23
|
+
service: 'fixture-api',
|
|
24
|
+
toolVersions: { node: '24.18.0', typescript: '5.9.3' },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
assert.ok(sdkPackage.files.has('dist/client/utils.gen.d.ts'));
|
|
28
|
+
for (const [path, content] of sdkPackage.files) {
|
|
29
|
+
assert.doesNotMatch(content.toString('utf8'), /[ \t]+$/gmu, path);
|
|
30
|
+
}
|
|
31
|
+
});
|
package/dist/resources/templates/go-backend/api/openapi/tooling/test/semantic_version.test.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { compareSemanticVersions, isSemanticVersion, parseSemanticVersion } from '../semantic_version.mjs';
|
|
5
|
+
|
|
6
|
+
test('semantic version parser accepts the complete SemVer 2.0 grammar', () => {
|
|
7
|
+
for (const version of [
|
|
8
|
+
'0.0.0',
|
|
9
|
+
'1.2.3-alpha',
|
|
10
|
+
'1.2.3-alpha.1',
|
|
11
|
+
'1.2.3-0.3.7',
|
|
12
|
+
'1.2.3-x.7.z.92',
|
|
13
|
+
'1.2.3+build.001',
|
|
14
|
+
'1.2.3-beta+exp.sha.5114f85',
|
|
15
|
+
]) {
|
|
16
|
+
assert.equal(isSemanticVersion(version), true, version);
|
|
17
|
+
assert.equal(parseSemanticVersion(version).raw, version);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('semantic version parser rejects leading zeroes and incomplete identifiers', () => {
|
|
22
|
+
for (const version of [
|
|
23
|
+
'',
|
|
24
|
+
'1',
|
|
25
|
+
'1.2',
|
|
26
|
+
'v1.2.3',
|
|
27
|
+
'01.2.3',
|
|
28
|
+
'1.02.3',
|
|
29
|
+
'1.2.03',
|
|
30
|
+
'1.2.3-01',
|
|
31
|
+
'1.2.3-',
|
|
32
|
+
'1.2.3+',
|
|
33
|
+
'1.2.3-alpha..1',
|
|
34
|
+
'1.2.3+build..1',
|
|
35
|
+
'1.2.3\n',
|
|
36
|
+
'1.2.3\r',
|
|
37
|
+
]) {
|
|
38
|
+
assert.equal(isSemanticVersion(version), false, version);
|
|
39
|
+
assert.throws(() => parseSemanticVersion(version), /invalid semantic version/);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('semantic version precedence follows the SemVer 2.0 ordering rules', () => {
|
|
44
|
+
const ordered = [
|
|
45
|
+
'1.0.0-alpha',
|
|
46
|
+
'1.0.0-alpha.1',
|
|
47
|
+
'1.0.0-alpha.beta',
|
|
48
|
+
'1.0.0-beta',
|
|
49
|
+
'1.0.0-beta.2',
|
|
50
|
+
'1.0.0-beta.11',
|
|
51
|
+
'1.0.0-rc.1',
|
|
52
|
+
'1.0.0',
|
|
53
|
+
];
|
|
54
|
+
for (let index = 1; index < ordered.length; index += 1) {
|
|
55
|
+
assert.equal(compareSemanticVersions(ordered[index - 1], ordered[index]), -1);
|
|
56
|
+
assert.equal(compareSemanticVersions(ordered[index], ordered[index - 1]), 1);
|
|
57
|
+
}
|
|
58
|
+
assert.equal(compareSemanticVersions('1.0.0+build.1', '1.0.0+build.2'), 0);
|
|
59
|
+
assert.equal(compareSemanticVersions('999999999999999999999.0.0', '1000000000000000000000.0.0'), -1);
|
|
60
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isServiceContractBuildInput,
|
|
6
|
+
serviceContractReviewPathspecs,
|
|
7
|
+
} from '../service_contract_inputs.mjs';
|
|
8
|
+
|
|
9
|
+
test('service contract build inputs exclude generated artifacts and Go consumers', () => {
|
|
10
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/openapi.yaml'), true);
|
|
11
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/components/admin.yaml'), true);
|
|
12
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/delegated/manifest.json'), true);
|
|
13
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/conformance/runtime.arazzo.yaml'), true);
|
|
14
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/dist/internal.openapi.json'), false);
|
|
15
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/embed.go'), false);
|
|
16
|
+
assert.equal(isServiceContractBuildInput('/services/admin-api/embed_test.go'), false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('operation review pathspecs cover only structured canonical sources', () => {
|
|
20
|
+
assert.deepEqual(serviceContractReviewPathspecs('backend/api/openapi/services/admin-api'), [
|
|
21
|
+
':(glob)backend/api/openapi/services/admin-api/**/*.json',
|
|
22
|
+
':(glob)backend/api/openapi/services/admin-api/**/*.yaml',
|
|
23
|
+
':(glob)backend/api/openapi/services/admin-api/**/*.yml',
|
|
24
|
+
':(glob,exclude)backend/api/openapi/services/admin-api/conformance/**',
|
|
25
|
+
':(glob,exclude)backend/api/openapi/services/admin-api/dist/**',
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
package runtime
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"time"
|
|
6
|
+
|
|
7
|
+
"github.com/google/wire"
|
|
8
|
+
"go.uber.org/zap"
|
|
9
|
+
"gorm.io/gorm"
|
|
10
|
+
|
|
11
|
+
"{{module}}/internal/core"
|
|
12
|
+
"{{module}}/internal/core/cache"
|
|
13
|
+
"{{module}}/internal/core/config"
|
|
14
|
+
"{{module}}/internal/core/database"
|
|
15
|
+
"{{module}}/internal/core/eventbus"
|
|
16
|
+
"{{module}}/internal/core/logger"
|
|
17
|
+
"{{module}}/internal/core/observability"
|
|
18
|
+
"{{module}}/internal/core/queue"
|
|
19
|
+
"{{module}}/internal/core/schedule"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// ProviderSet 复用源工厂,并将已创建资源的释放交给 Wire 逆序执行。
|
|
23
|
+
var ProviderSet = wire.NewSet(
|
|
24
|
+
config.Load, core.ProvideLogConfig, core.ProvideDatabaseConfig, core.ProvideRedisConfig,
|
|
25
|
+
ProvideLogger, ProvideDatabase, ProvideRedis,
|
|
26
|
+
core.ProvideRedisClient, core.ProvideCacheManagerConfig, core.ProvideCircuitBreakerService,
|
|
27
|
+
cache.ProvideL1Config, ProvideL1, cache.NewMetrics, cache.NewManager,
|
|
28
|
+
ProvideEventBus, observability.NewMetricsService, core.ProvideHealthService,
|
|
29
|
+
core.ProvideTracingConfig, ProvideTracing, core.ProvideSentryConfig, ProvideSentry,
|
|
30
|
+
ProvideQueue, ProvideScheduler, New,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// ProvideLogger 为 Wire 提供日志与同步释放。
|
|
34
|
+
func ProvideLogger(cfg *config.LogConfig) (*zap.Logger, func(), error) {
|
|
35
|
+
log, err := logger.New(cfg)
|
|
36
|
+
if err != nil {
|
|
37
|
+
return nil, nil, err
|
|
38
|
+
}
|
|
39
|
+
return log, func() { _ = log.Sync() }, nil
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ProvideDatabase 将数据库连接池归入进程资源生命周期。
|
|
43
|
+
func ProvideDatabase(cfg *config.DatabaseConfig, log *zap.Logger, metrics *observability.MetricsService) (*gorm.DB, func(), error) {
|
|
44
|
+
db, err := database.NewDB(cfg, log, metrics)
|
|
45
|
+
if err != nil {
|
|
46
|
+
return nil, nil, err
|
|
47
|
+
}
|
|
48
|
+
return db, func() {
|
|
49
|
+
sqlDB, err := db.DB()
|
|
50
|
+
if err == nil {
|
|
51
|
+
err = sqlDB.Close()
|
|
52
|
+
}
|
|
53
|
+
if err != nil {
|
|
54
|
+
log.Error("close database", zap.Error(err))
|
|
55
|
+
}
|
|
56
|
+
}, nil
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ProvideRedis 将已验证的 Redis 连接归入进程资源生命周期。
|
|
60
|
+
func ProvideRedis(cfg *config.RedisConfig, log *zap.Logger) (*cache.RedisService, func(), error) {
|
|
61
|
+
client, err := cache.NewRedisService(cfg)
|
|
62
|
+
if err != nil {
|
|
63
|
+
return nil, nil, err
|
|
64
|
+
}
|
|
65
|
+
return client, func() {
|
|
66
|
+
if err := client.Close(); err != nil {
|
|
67
|
+
log.Error("close redis", zap.Error(err))
|
|
68
|
+
}
|
|
69
|
+
}, nil
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ProvideL1 在进程退出时停止缓存清理协程。
|
|
73
|
+
func ProvideL1(cfg cache.L1Config, log *zap.Logger) (*cache.L1Cache, func()) {
|
|
74
|
+
client := cache.NewL1Cache(cfg, log)
|
|
75
|
+
return client, client.Close
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ProvideEventBus 在释放订阅前等待已派发事件完成。
|
|
79
|
+
func ProvideEventBus(log *zap.Logger) (*eventbus.EventBus, func()) {
|
|
80
|
+
bus := eventbus.New(log)
|
|
81
|
+
return bus, bus.Close
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ProvideTracing 在有界超时内提交追踪数据。
|
|
85
|
+
func ProvideTracing(log *zap.Logger, cfg *config.TracingConfig) (*observability.TracingService, func(), error) {
|
|
86
|
+
service, err := observability.NewTracingService(log, cfg)
|
|
87
|
+
if err != nil {
|
|
88
|
+
return nil, nil, err
|
|
89
|
+
}
|
|
90
|
+
return service, func() {
|
|
91
|
+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
92
|
+
defer cancel()
|
|
93
|
+
if err := service.Shutdown(ctx); err != nil {
|
|
94
|
+
log.Error("close tracing", zap.Error(err))
|
|
95
|
+
}
|
|
96
|
+
}, nil
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ProvideSentry 在进程退出时提交待发送诊断。
|
|
100
|
+
func ProvideSentry(log *zap.Logger, cfg *config.SentryConfig) (*observability.SentryService, func(), error) {
|
|
101
|
+
service, err := core.ProvideSentryService(log, cfg)
|
|
102
|
+
if err != nil {
|
|
103
|
+
return nil, nil, err
|
|
104
|
+
}
|
|
105
|
+
return service, func() { service.Close(2 * time.Second) }, nil
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ProvideQueue 释放任务生产端的 Redis 连接。
|
|
109
|
+
func ProvideQueue(cfg *config.RedisConfig, log *zap.Logger) (*queue.Client, func(), error) {
|
|
110
|
+
client, err := queue.NewClient(cfg, log)
|
|
111
|
+
if err != nil {
|
|
112
|
+
return nil, nil, err
|
|
113
|
+
}
|
|
114
|
+
return client, func() {
|
|
115
|
+
if err := client.Close(); err != nil {
|
|
116
|
+
log.Error("close queue client", zap.Error(err))
|
|
117
|
+
}
|
|
118
|
+
}, nil
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ProvideScheduler 停止调度并等待正在执行的任务。
|
|
122
|
+
func ProvideScheduler(log *zap.Logger) (*schedule.Scheduler, func()) {
|
|
123
|
+
scheduler := schedule.New(log)
|
|
124
|
+
return scheduler, scheduler.Stop
|
|
125
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
package runtime
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"fmt"
|
|
7
|
+
"net"
|
|
8
|
+
"net/http"
|
|
9
|
+
"time"
|
|
10
|
+
|
|
11
|
+
"github.com/gin-gonic/gin"
|
|
12
|
+
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
13
|
+
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
|
|
14
|
+
"go.uber.org/zap"
|
|
15
|
+
"gorm.io/gorm"
|
|
16
|
+
"{{module}}/api/openapi"
|
|
17
|
+
"{{module}}/internal/common/middleware"
|
|
18
|
+
"{{module}}/internal/core/apidocs"
|
|
19
|
+
"{{module}}/internal/core/cache"
|
|
20
|
+
"{{module}}/internal/core/config"
|
|
21
|
+
"{{module}}/internal/core/eventbus"
|
|
22
|
+
"{{module}}/internal/core/health"
|
|
23
|
+
"{{module}}/internal/core/observability"
|
|
24
|
+
"{{module}}/internal/core/queue"
|
|
25
|
+
"{{module}}/internal/core/schedule"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
// Runtime 持有进程级资源;业务模块通过各自 ProviderSet 注入入口。
|
|
29
|
+
type Runtime struct {
|
|
30
|
+
Config *config.Config
|
|
31
|
+
Log *zap.Logger
|
|
32
|
+
DB *gorm.DB
|
|
33
|
+
Redis *cache.RedisService
|
|
34
|
+
Cache *cache.Manager
|
|
35
|
+
Bus *eventbus.EventBus
|
|
36
|
+
Health *health.Service
|
|
37
|
+
Metrics *observability.MetricsService
|
|
38
|
+
Tracing *observability.TracingService
|
|
39
|
+
Sentry *observability.SentryService
|
|
40
|
+
Queue *queue.Client
|
|
41
|
+
Scheduler *schedule.Scheduler
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// New 将事件总线与调度器放在资源图末端,使 Wire 在依赖关闭前先停止事件生产并排空订阅。
|
|
45
|
+
func New(cfg *config.Config, log *zap.Logger, db *gorm.DB, redis *cache.RedisService, manager *cache.Manager, h *health.Service, metrics *observability.MetricsService, tracing *observability.TracingService, sentry *observability.SentryService, q *queue.Client, bus *eventbus.EventBus, scheduler *schedule.Scheduler) *Runtime {
|
|
46
|
+
return &Runtime{Config: cfg, Log: log, DB: db, Redis: redis, Cache: manager, Bus: bus, Health: h, Metrics: metrics, Tracing: tracing, Sentry: sentry, Queue: q, Scheduler: scheduler}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Router 将实际路由与内嵌契约校验,阻止未登记接口启动。
|
|
50
|
+
func (r *Runtime) Router(service string) (*gin.Engine, error) {
|
|
51
|
+
if r.Config.IsProduction() {
|
|
52
|
+
gin.SetMode(gin.ReleaseMode)
|
|
53
|
+
}
|
|
54
|
+
document, err := openapi.Document(service)
|
|
55
|
+
if err != nil {
|
|
56
|
+
return nil, err
|
|
57
|
+
}
|
|
58
|
+
router := gin.New()
|
|
59
|
+
if err := router.SetTrustedProxies(r.Config.App.TrustedProxies); err != nil {
|
|
60
|
+
return nil, fmt.Errorf("set trusted proxies: %w", err)
|
|
61
|
+
}
|
|
62
|
+
router.Use(otelgin.Middleware(r.Config.Tracing.ServiceName), middleware.RequestID(), middleware.Metrics(r.Metrics), middleware.LoggingWithConfig(r.Log, r.Config.Log), r.Sentry.GinMiddleware(true), middleware.Recovery(r.Log))
|
|
63
|
+
r.Health.RegisterRoutes(router.Group(""))
|
|
64
|
+
router.GET("/metrics", gin.WrapH(promhttp.Handler()))
|
|
65
|
+
if !r.Config.IsProduction() {
|
|
66
|
+
if err := apidocs.RegisterRoutes(router, document); err != nil {
|
|
67
|
+
return nil, err
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if err := document.ValidateRoutes(router.Routes()); err != nil {
|
|
71
|
+
return nil, err
|
|
72
|
+
}
|
|
73
|
+
return router, nil
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Serve 在监听成功后报告就绪,并在退出时等待在途 HTTP 请求完成。
|
|
77
|
+
func (r *Runtime) Serve(ctx context.Context, router http.Handler) error {
|
|
78
|
+
server := &http.Server{Addr: net.JoinHostPort(r.Config.App.Host, fmt.Sprint(r.Config.App.Port)), Handler: router, ReadHeaderTimeout: 10 * time.Second, ReadTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second, IdleTimeout: 60 * time.Second}
|
|
79
|
+
listener, err := net.Listen("tcp", server.Addr)
|
|
80
|
+
if err != nil {
|
|
81
|
+
return fmt.Errorf("listen: %w", err)
|
|
82
|
+
}
|
|
83
|
+
r.Health.MarkReady()
|
|
84
|
+
result := make(chan error, 1)
|
|
85
|
+
go func() { result <- server.Serve(listener) }()
|
|
86
|
+
r.Log.Info("server started", zap.String("address", server.Addr))
|
|
87
|
+
select {
|
|
88
|
+
case err = <-result:
|
|
89
|
+
if errors.Is(err, http.ErrServerClosed) {
|
|
90
|
+
return nil
|
|
91
|
+
}
|
|
92
|
+
return err
|
|
93
|
+
case <-ctx.Done():
|
|
94
|
+
r.Health.SetReadinessComponent("shutdown", health.ComponentHealth{Status: health.StatusDown})
|
|
95
|
+
shutdownCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
96
|
+
defer cancel()
|
|
97
|
+
if err = server.Shutdown(shutdownCtx); err != nil {
|
|
98
|
+
return errors.Join(err, server.Close())
|
|
99
|
+
}
|
|
100
|
+
return nil
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
package runtime
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"net"
|
|
6
|
+
"net/http"
|
|
7
|
+
"net/http/httptest"
|
|
8
|
+
"strings"
|
|
9
|
+
"testing"
|
|
10
|
+
|
|
11
|
+
"github.com/gin-gonic/gin"
|
|
12
|
+
"go.uber.org/zap"
|
|
13
|
+
"{{module}}/api/openapi"
|
|
14
|
+
"{{module}}/internal/core/config"
|
|
15
|
+
"{{module}}/internal/core/health"
|
|
16
|
+
"{{module}}/internal/core/observability"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
func TestRouterContractsAndDocumentationVisibility(t *testing.T) {
|
|
20
|
+
log := zap.NewNop()
|
|
21
|
+
metrics := observability.NewMetricsService(log)
|
|
22
|
+
for _, service := range []string{"product-api", "worker"} {
|
|
23
|
+
for _, env := range []string{"local", "production"} {
|
|
24
|
+
t.Run(service+"/"+env, func(t *testing.T) {
|
|
25
|
+
cfg := &config.Config{App: config.AppConfig{Env: env}}
|
|
26
|
+
app := &Runtime{Config: cfg, Log: log, Metrics: metrics, Health: health.New(log, nil, nil), Sentry: observability.NewSentryService(log, &cfg.Sentry)}
|
|
27
|
+
router, err := app.Router(service)
|
|
28
|
+
if err != nil {
|
|
29
|
+
t.Fatal(err)
|
|
30
|
+
}
|
|
31
|
+
response := httptest.NewRecorder()
|
|
32
|
+
router.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/health/liveness", nil))
|
|
33
|
+
if response.Code != http.StatusOK {
|
|
34
|
+
t.Fatalf("liveness status = %d", response.Code)
|
|
35
|
+
}
|
|
36
|
+
response = httptest.NewRecorder()
|
|
37
|
+
router.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/docs", nil))
|
|
38
|
+
want := http.StatusOK
|
|
39
|
+
if env == "production" {
|
|
40
|
+
want = http.StatusNotFound
|
|
41
|
+
}
|
|
42
|
+
if response.Code != want {
|
|
43
|
+
t.Fatalf("docs status = %d, want %d", response.Code, want)
|
|
44
|
+
}
|
|
45
|
+
document, err := openapi.Document(service)
|
|
46
|
+
if err != nil {
|
|
47
|
+
t.Fatal(err)
|
|
48
|
+
}
|
|
49
|
+
router.GET("/api/v1/unregistered", func(c *gin.Context) { c.Status(http.StatusNoContent) })
|
|
50
|
+
if err := document.ValidateRoutes(router.Routes()); err == nil {
|
|
51
|
+
t.Fatal("undocumented business route was accepted")
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func TestServeRejectsOccupiedAddress(t *testing.T) {
|
|
59
|
+
listener, err := net.Listen("tcp", "127.0.0.1:0")
|
|
60
|
+
if err != nil {
|
|
61
|
+
t.Fatal(err)
|
|
62
|
+
}
|
|
63
|
+
defer listener.Close()
|
|
64
|
+
cfg := &config.Config{App: config.AppConfig{Host: "127.0.0.1", Port: listener.Addr().(*net.TCPAddr).Port}}
|
|
65
|
+
log := zap.NewNop()
|
|
66
|
+
app := &Runtime{Config: cfg, Log: log, Health: health.New(log, nil, nil)}
|
|
67
|
+
if err := app.Serve(context.Background(), http.NewServeMux()); err == nil || !strings.Contains(err.Error(), "listen") {
|
|
68
|
+
t.Fatalf("occupied listener error = %v", err)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"database/sql"
|
|
6
|
+
"os"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
"time"
|
|
10
|
+
|
|
11
|
+
_ "github.com/lib/pq"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
func TestInitializationFailureReleasesDatabase(t *testing.T) {
|
|
15
|
+
dsn := os.Getenv("RUNTIME_TEST_DATABASE_URL")
|
|
16
|
+
if dsn == "" {
|
|
17
|
+
t.Skip("RUNTIME_TEST_DATABASE_URL requires an isolated PostgreSQL and Redis runtime")
|
|
18
|
+
}
|
|
19
|
+
db, err := sql.Open("postgres", dsn)
|
|
20
|
+
if err != nil {
|
|
21
|
+
t.Fatal(err)
|
|
22
|
+
}
|
|
23
|
+
defer db.Close()
|
|
24
|
+
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
|
25
|
+
defer cancel()
|
|
26
|
+
connections := func() int {
|
|
27
|
+
var count int
|
|
28
|
+
if err := db.QueryRowContext(ctx, "SELECT count(*) FROM pg_stat_activity WHERE datname = current_database() AND pid <> pg_backend_pid()").Scan(&count); err != nil {
|
|
29
|
+
t.Fatal(err)
|
|
30
|
+
}
|
|
31
|
+
return count
|
|
32
|
+
}
|
|
33
|
+
before := connections()
|
|
34
|
+
t.Setenv("SENTRY_ENABLED", "true")
|
|
35
|
+
t.Setenv("SENTRY_DSN", "://invalid")
|
|
36
|
+
_, cleanup, err := InitializeApp()
|
|
37
|
+
if err == nil {
|
|
38
|
+
cleanup()
|
|
39
|
+
t.Fatal("invalid Sentry configuration was accepted")
|
|
40
|
+
}
|
|
41
|
+
if !strings.Contains(err.Error(), "initialize sentry") {
|
|
42
|
+
t.Fatalf("initialization failed before the intended resource boundary: %v", err)
|
|
43
|
+
}
|
|
44
|
+
if cleanup != nil {
|
|
45
|
+
t.Fatal("failed Wire initialization returned a cleanup function")
|
|
46
|
+
}
|
|
47
|
+
deadline := time.Now().Add(2 * time.Second)
|
|
48
|
+
for {
|
|
49
|
+
after := connections()
|
|
50
|
+
if after <= before {
|
|
51
|
+
break
|
|
52
|
+
}
|
|
53
|
+
if time.Now().After(deadline) {
|
|
54
|
+
t.Fatalf("database sessions leaked: before=%d after=%d", before, after)
|
|
55
|
+
}
|
|
56
|
+
time.Sleep(20 * time.Millisecond)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"os"
|
|
6
|
+
"os/signal"
|
|
7
|
+
"syscall"
|
|
8
|
+
|
|
9
|
+
"go.uber.org/zap"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
func main() {
|
|
13
|
+
log := zap.NewExample()
|
|
14
|
+
if err := run(); err != nil {
|
|
15
|
+
log.Error("product API failed", zap.Error(err))
|
|
16
|
+
os.Exit(1)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
func run() error {
|
|
20
|
+
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
|
21
|
+
defer stop()
|
|
22
|
+
app, cleanup, err := InitializeApp()
|
|
23
|
+
if err != nil {
|
|
24
|
+
return err
|
|
25
|
+
}
|
|
26
|
+
defer cleanup()
|
|
27
|
+
router, err := app.Router("product-api")
|
|
28
|
+
if err != nil {
|
|
29
|
+
return err
|
|
30
|
+
}
|
|
31
|
+
return app.Serve(ctx, router)
|
|
32
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Code generated by Wire. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
//go:generate go run -mod=mod github.com/google/wire/cmd/wire
|
|
4
|
+
//go:build !wireinject
|
|
5
|
+
// +build !wireinject
|
|
6
|
+
|
|
7
|
+
package main
|
|
8
|
+
|
|
9
|
+
import (
|
|
10
|
+
"{{module}}/cmd/internal/runtime"
|
|
11
|
+
"{{module}}/internal/core"
|
|
12
|
+
"{{module}}/internal/core/cache"
|
|
13
|
+
"{{module}}/internal/core/config"
|
|
14
|
+
"{{module}}/internal/core/observability"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
// Injectors from wire.go:
|
|
18
|
+
|
|
19
|
+
func InitializeApp() (*runtime.Runtime, func(), error) {
|
|
20
|
+
configConfig, err := config.Load()
|
|
21
|
+
if err != nil {
|
|
22
|
+
return nil, nil, err
|
|
23
|
+
}
|
|
24
|
+
logConfig := core.ProvideLogConfig(configConfig)
|
|
25
|
+
logger, cleanup, err := runtime.ProvideLogger(logConfig)
|
|
26
|
+
if err != nil {
|
|
27
|
+
return nil, nil, err
|
|
28
|
+
}
|
|
29
|
+
databaseConfig := core.ProvideDatabaseConfig(configConfig)
|
|
30
|
+
metricsService := observability.NewMetricsService(logger)
|
|
31
|
+
db, cleanup2, err := runtime.ProvideDatabase(databaseConfig, logger, metricsService)
|
|
32
|
+
if err != nil {
|
|
33
|
+
cleanup()
|
|
34
|
+
return nil, nil, err
|
|
35
|
+
}
|
|
36
|
+
redisConfig := core.ProvideRedisConfig(configConfig)
|
|
37
|
+
redisService, cleanup3, err := runtime.ProvideRedis(redisConfig, logger)
|
|
38
|
+
if err != nil {
|
|
39
|
+
cleanup2()
|
|
40
|
+
cleanup()
|
|
41
|
+
return nil, nil, err
|
|
42
|
+
}
|
|
43
|
+
managerConfig := core.ProvideCacheManagerConfig(configConfig)
|
|
44
|
+
l1Config := cache.ProvideL1Config(managerConfig)
|
|
45
|
+
l1Cache, cleanup4 := runtime.ProvideL1(l1Config, logger)
|
|
46
|
+
circuitBreakerService := core.ProvideCircuitBreakerService(logger)
|
|
47
|
+
metrics := cache.NewMetrics()
|
|
48
|
+
manager := cache.NewManager(managerConfig, redisService, l1Cache, circuitBreakerService, metrics, logger)
|
|
49
|
+
client := core.ProvideRedisClient(redisService)
|
|
50
|
+
service := core.ProvideHealthService(logger, db, client)
|
|
51
|
+
tracingConfig := core.ProvideTracingConfig(configConfig)
|
|
52
|
+
tracingService, cleanup5, err := runtime.ProvideTracing(logger, tracingConfig)
|
|
53
|
+
if err != nil {
|
|
54
|
+
cleanup4()
|
|
55
|
+
cleanup3()
|
|
56
|
+
cleanup2()
|
|
57
|
+
cleanup()
|
|
58
|
+
return nil, nil, err
|
|
59
|
+
}
|
|
60
|
+
sentryConfig := core.ProvideSentryConfig(configConfig)
|
|
61
|
+
sentryService, cleanup6, err := runtime.ProvideSentry(logger, sentryConfig)
|
|
62
|
+
if err != nil {
|
|
63
|
+
cleanup5()
|
|
64
|
+
cleanup4()
|
|
65
|
+
cleanup3()
|
|
66
|
+
cleanup2()
|
|
67
|
+
cleanup()
|
|
68
|
+
return nil, nil, err
|
|
69
|
+
}
|
|
70
|
+
queueClient, cleanup7, err := runtime.ProvideQueue(redisConfig, logger)
|
|
71
|
+
if err != nil {
|
|
72
|
+
cleanup6()
|
|
73
|
+
cleanup5()
|
|
74
|
+
cleanup4()
|
|
75
|
+
cleanup3()
|
|
76
|
+
cleanup2()
|
|
77
|
+
cleanup()
|
|
78
|
+
return nil, nil, err
|
|
79
|
+
}
|
|
80
|
+
eventBus, cleanup8 := runtime.ProvideEventBus(logger)
|
|
81
|
+
scheduler, cleanup9 := runtime.ProvideScheduler(logger)
|
|
82
|
+
runtimeRuntime := runtime.New(configConfig, logger, db, redisService, manager, service, metricsService, tracingService, sentryService, queueClient, eventBus, scheduler)
|
|
83
|
+
return runtimeRuntime, func() {
|
|
84
|
+
cleanup9()
|
|
85
|
+
cleanup8()
|
|
86
|
+
cleanup7()
|
|
87
|
+
cleanup6()
|
|
88
|
+
cleanup5()
|
|
89
|
+
cleanup4()
|
|
90
|
+
cleanup3()
|
|
91
|
+
cleanup2()
|
|
92
|
+
cleanup()
|
|
93
|
+
}, nil
|
|
94
|
+
}
|