@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,195 @@
|
|
|
1
|
+
# Identifier Contract
|
|
2
|
+
|
|
3
|
+
> Scope: all `backend/` modules
|
|
4
|
+
> Goal: unify the definition, naming, ownership, and database constraints of public business numbers, cross-module business references, request idempotency keys, and third-party object IDs
|
|
5
|
+
|
|
6
|
+
## 1. Why this must be unified
|
|
7
|
+
|
|
8
|
+
Once identifier semantics are mixed, the damage compounds over time:
|
|
9
|
+
|
|
10
|
+
- one field starts carrying both internal business identity and third-party object identity, and later reconciliation, audit, and replay become unreliable
|
|
11
|
+
- runtime code treats a field as an idempotency key, but the database has no matching uniqueness guarantee, which creates duplicate writes under concurrency
|
|
12
|
+
- every module assembles strings differently, and after a few years nobody can tell which segment is a formal object key, which segment is a temporary business fact, and which segment is a migration artifact
|
|
13
|
+
|
|
14
|
+
These problems cannot be solved by reviewer memory. They need a single contract.
|
|
15
|
+
|
|
16
|
+
## 2. Industry references
|
|
17
|
+
|
|
18
|
+
| Decision Point | Industry Pattern | Used By | Our Choice | Rationale |
|
|
19
|
+
|---------------|------------------|---------|------------|-----------|
|
|
20
|
+
| Separate public business numbers from internal primary keys | Internal PK + externally visible business number | Stripe, Shopify | Keep `order_no`, `payment_no`, `member_no`, and similar fields separate from DB primary keys | Public identifiers stay readable, traceable, and safe to expose |
|
|
21
|
+
| Align idempotency scope with DB uniqueness | Request idempotency + matching storage uniqueness | Stripe, AWS | If runtime deduplicates on a field or field set, the database must enforce uniqueness on the same scope | Prevents code from assuming idempotency while storage still allows duplicates |
|
|
22
|
+
| Generate business references in the owner module | Owner-generated namespaced business key | Stripe events, CloudEvents `source + id` | Cross-module business references must come from owner helpers | Prevents downstream string concatenation drift and collisions |
|
|
23
|
+
| Keep provider object IDs provider-scoped | Provider IDs stay provider-scoped and do not replace internal facts | Stripe, PayPal, GitHub webhooks | `provider_*_id`, `external_*_id`, and protocol IDs remain external-object identifiers only | Avoids treating mutable external IDs as internal business facts |
|
|
24
|
+
|
|
25
|
+
## 3. The four identifier classes
|
|
26
|
+
|
|
27
|
+
### 3.1 Public business numbers
|
|
28
|
+
|
|
29
|
+
Definition: stable platform-generated numbers that can be exposed to operators, users, invoices, and receipts.
|
|
30
|
+
|
|
31
|
+
Typical fields:
|
|
32
|
+
|
|
33
|
+
- `p_order_orders.order_no`
|
|
34
|
+
- `p_payment_payments.payment_no`
|
|
35
|
+
- `p_payment_transactions.transaction_no`
|
|
36
|
+
- `p_payment_refunds.refund_no`
|
|
37
|
+
- `p_subscription_subscriptions.subscription_no`
|
|
38
|
+
- `p_member_members.member_no`
|
|
39
|
+
|
|
40
|
+
Rules:
|
|
41
|
+
|
|
42
|
+
1. A public business number is not a database primary key.
|
|
43
|
+
2. A public business number must have a database unique constraint.
|
|
44
|
+
3. A public business number must not embed business-source semantics or third-party IDs.
|
|
45
|
+
|
|
46
|
+
### 3.2 Cross-module business reference keys
|
|
47
|
+
|
|
48
|
+
Definition: a stable key that answers “which business fact or business object caused this record,” and is used for cross-module traceability, replay, and deduplication.
|
|
49
|
+
|
|
50
|
+
Typical fields:
|
|
51
|
+
|
|
52
|
+
- `p_credit_grants.source_ref`
|
|
53
|
+
- `p_credit_transactions.reference_id`
|
|
54
|
+
- `p_credit_reservations(reference_type, reference_id)`
|
|
55
|
+
- `p_quota_transactions.reference_id`
|
|
56
|
+
- `p_member_point_ledger.reference_id`
|
|
57
|
+
|
|
58
|
+
Rules:
|
|
59
|
+
|
|
60
|
+
1. Business reference keys must be generated by owner helpers. Business services must not assemble them with ad-hoc `fmt.Sprintf`.
|
|
61
|
+
2. When a formal object ID exists, use the formal object key first.
|
|
62
|
+
3. When no formal object ID exists, use an explicitly namespaced stable business-fact key.
|
|
63
|
+
4. If runtime performs exact deduplication on this key, the database must provide a matching unique constraint.
|
|
64
|
+
5. Migration-only retained keys must use the `migration:` namespace and remain fully isolated from runtime formal keys.
|
|
65
|
+
|
|
66
|
+
Formal syntax:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
<namespace>[:<segment>...]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Allowed characters:
|
|
73
|
+
|
|
74
|
+
- lowercase letters
|
|
75
|
+
- digits
|
|
76
|
+
- `.`
|
|
77
|
+
- `_`
|
|
78
|
+
- `-`
|
|
79
|
+
- `:`
|
|
80
|
+
- RFC3339 timestamp strings
|
|
81
|
+
|
|
82
|
+
### 3.3 Request idempotency keys
|
|
83
|
+
|
|
84
|
+
Definition: a deduplication key for one API request or one fulfillment action. It does not express ownership of a business fact.
|
|
85
|
+
|
|
86
|
+
Typical fields:
|
|
87
|
+
|
|
88
|
+
- `p_payment_payments.idempotency_key`
|
|
89
|
+
- `p_promotion_rewards.idempotency_key`
|
|
90
|
+
- `p_mediagen_generations(product_code, idempotency_key)`
|
|
91
|
+
|
|
92
|
+
Rules:
|
|
93
|
+
|
|
94
|
+
1. A request idempotency key may come from the caller or from the owner module, as long as it is stable for the operation scope.
|
|
95
|
+
2. The database unique constraint must match the runtime deduplication scope.
|
|
96
|
+
3. A request idempotency key must not reuse a third-party object ID.
|
|
97
|
+
4. A request idempotency key must not be written into cross-module business reference fields.
|
|
98
|
+
|
|
99
|
+
### 3.4 Third-party and protocol object IDs
|
|
100
|
+
|
|
101
|
+
Definition: identifiers generated by an external provider, protocol, or delivery system.
|
|
102
|
+
|
|
103
|
+
Typical fields:
|
|
104
|
+
|
|
105
|
+
- `provider_order_id`
|
|
106
|
+
- `provider_payment_id`
|
|
107
|
+
- `provider_customer_id`
|
|
108
|
+
- `provider_subscription_id`
|
|
109
|
+
- `provider_refund_id`
|
|
110
|
+
- `provider_product_id`
|
|
111
|
+
- `provider_price_id`
|
|
112
|
+
- `provider_plan_id`
|
|
113
|
+
- `external_message_id`
|
|
114
|
+
- `message_id` (RFC 5322 Message-ID)
|
|
115
|
+
|
|
116
|
+
Rules:
|
|
117
|
+
|
|
118
|
+
1. A third-party object ID only expresses external object identity.
|
|
119
|
+
2. A third-party object ID must not be written into internal business-reference fields.
|
|
120
|
+
3. Whether a third-party object ID is unique depends on the provider contract. Never assume it can replace an internal idempotency key.
|
|
121
|
+
|
|
122
|
+
## 4. Ownership rules
|
|
123
|
+
|
|
124
|
+
| Class | Generated By | Constraint |
|
|
125
|
+
|------|--------------|------------|
|
|
126
|
+
| Public business numbers | Owner service | Must use a unified generator; callers cannot provide them |
|
|
127
|
+
| Cross-module business reference keys | Owner domain helper | Must be generated by owner helpers; downstream modules cannot assemble them |
|
|
128
|
+
| Request idempotency keys | API owner or caller | Database uniqueness scope must match runtime deduplication scope |
|
|
129
|
+
| Third-party object IDs | External provider or protocol | Store, pass through, and reconcile only; do not treat them as internal primary business semantics |
|
|
130
|
+
|
|
131
|
+
## 5. Database constraint rules
|
|
132
|
+
|
|
133
|
+
### 5.1 Business reference keys
|
|
134
|
+
|
|
135
|
+
If runtime uses any of the following patterns:
|
|
136
|
+
|
|
137
|
+
- `FindByReferenceID(referenceID)`
|
|
138
|
+
- `FindBySourceRef(sourceRef)`
|
|
139
|
+
- `FindByIdempotencyKey(idempotencyKey)`
|
|
140
|
+
|
|
141
|
+
then the database must satisfy one of these two conditions:
|
|
142
|
+
|
|
143
|
+
1. create a unique constraint on the exact same lookup scope
|
|
144
|
+
2. explicitly declare the business relationship as one-to-many and include the full owner scope in runtime lookups
|
|
145
|
+
|
|
146
|
+
The following mismatch is forbidden:
|
|
147
|
+
|
|
148
|
+
- runtime performs exact-match deduplication on `reference_id`
|
|
149
|
+
- the database only has a normal index and still allows duplicate rows
|
|
150
|
+
|
|
151
|
+
### 5.2 Migration-retained keys
|
|
152
|
+
|
|
153
|
+
When migration data has no formal runtime object, use:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
migration:<product>:...
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
It is forbidden to place raw source-system primary keys, raw source UUIDs, or raw third-party IDs into runtime business fields without a namespace.
|
|
160
|
+
|
|
161
|
+
## 6. Migration compliance policy
|
|
162
|
+
|
|
163
|
+
When an importer contract changes, “fresh import is correct” is not enough.
|
|
164
|
+
|
|
165
|
+
Rules:
|
|
166
|
+
|
|
167
|
+
1. A migration table cannot be marked complete based only on a fresh empty-database rerun.
|
|
168
|
+
2. Existing databases that were already imported must be audited against the latest contract.
|
|
169
|
+
3. If existing imported rows are stale, ship one of these paths before calling the table complete:
|
|
170
|
+
- an in-place repair migration or repair tool
|
|
171
|
+
- an explicit clean reimport procedure that safely removes the stale slice and rebuilds it with the current importer
|
|
172
|
+
4. Do not hide stale imported data behind runtime compatibility branches.
|
|
173
|
+
5. If a runtime config table can still generate rows that violate the current contract, the migration is still incomplete even if the importer itself is fixed.
|
|
174
|
+
|
|
175
|
+
## 7. Current audit conclusions
|
|
176
|
+
|
|
177
|
+
| Field / Table | Class | Current State | Decision |
|
|
178
|
+
|---------------|-------|---------------|----------|
|
|
179
|
+
| `p_credit_grants.source_ref` | Business reference key | Has a global unique constraint | Keep it and continue generating keys only through credit helpers |
|
|
180
|
+
| `p_credit_transactions(reference_type, reference_id)` | Business reference key | Runtime uses the composite semantic | Keep the composite model; do not downgrade it to single-column uniqueness |
|
|
181
|
+
| `p_credit_reservations(reference_type, reference_id)` | Business reference key | Already has a composite unique constraint | Good |
|
|
182
|
+
| `p_quota_transactions.reference_id` | Business reference key | Runtime deduplicates by exact single-column lookup; historical schema only had a normal index | Must add a single-column unique constraint and centralize the helper |
|
|
183
|
+
| `p_member_point_ledger.reference_id` | Business reference key | Already unique, but naming was scattered across listener and service code | Must centralize generation in member helpers |
|
|
184
|
+
| `p_promotion_rewards.idempotency_key` | Request idempotency key | Unique constraint is complete | Keep owner-local idempotency; do not turn it into a cross-module business reference |
|
|
185
|
+
| `p_payment_payments.idempotency_key` | Request idempotency key | Unique constraint is complete | Good |
|
|
186
|
+
| `p_mediagen_generations(product_code, idempotency_key)` | Request idempotency key | Composite scope matches runtime behavior | Good |
|
|
187
|
+
| `provider_*_id`, `external_*_id`, `message_id` | Third-party / protocol object ID | Semantics are clear | Keep them isolated from internal business keys |
|
|
188
|
+
|
|
189
|
+
## 8. Implementation requirements
|
|
190
|
+
|
|
191
|
+
1. Before adding any `reference_id`, `source_ref`, or `idempotency_key` field, classify it first.
|
|
192
|
+
2. If it is a business reference key, add the owner helper before writing service or repository code.
|
|
193
|
+
3. If it is a request idempotency key, define the runtime deduplication scope before creating the database unique index.
|
|
194
|
+
4. If it is a third-party object ID, do not use it for internal idempotency or business-reference deduplication.
|
|
195
|
+
5. When modifying legacy modules, extract scattered string generation into domain helpers instead of copying more ad-hoc formats.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Specification Index
|
|
2
|
+
|
|
3
|
+
Read `CLAUDE.md` completely. Files below retain the full OneX specifications and examples. Binding event, E2E and OpenAPI contracts apply according to their declared owner. Platform paths, service names, governance commands and platform tables refer to upstream OneX; generated backend commands are defined by its own `Makefile`.
|
|
4
|
+
|
|
5
|
+
| File | Content | Priority |
|
|
6
|
+
|------|---------|----------|
|
|
7
|
+
| `api-design.md` | Handler, Service, DTO, VO, Pagination templates | MUST |
|
|
8
|
+
| `module-standards.md` | Directory structures, file creation decision tree | MUST |
|
|
9
|
+
| `error-handling.md` | ErrorType/ErrorCode, BusinessError, Error middleware | MUST |
|
|
10
|
+
| `database.md` | Model template, column types, migration template | MUST |
|
|
11
|
+
| `identifier-contract.md` | Public business numbers, business references, idempotency keys, third-party IDs | MUST |
|
|
12
|
+
| `logging.md` | Logger setup, log levels, correlation IDs | MUST |
|
|
13
|
+
| `platform-boundary.md` | Platform / BFF / Viewer / Auth boundary rules | MUST |
|
|
14
|
+
| `event-runtime-boundary.md` | Outbox relay scope, runtime listener ownership, cross-process event rules | MUST |
|
|
15
|
+
| `e2e-standards.md` | Full-chain E2E design, fixture seeding, relay regression guardrails | MUST |
|
|
16
|
+
| `openapi-contract.md` | OpenAPI 所有权、中文文档导航、投影、兼容性与本地文档契约 | MUST |
|
|
17
|
+
| `check-list.md` | Development workflow, pre-commit checklist | MUST |
|
|
18
|
+
| `architecture-template.md` | Complete Level A/B/C architecture document skeleton | MUST for design |
|
|
19
|
+
| `quality-gates.md` | Full upstream platform quality gates and ownership | Upstream operations |
|
|
20
|
+
| `payment-gateway-onboarding.md` | Complete upstream payment provider onboarding | Upstream integration |
|
|
21
|
+
| `mediagen-provider-onboarding-sop.md` | Complete upstream media provider onboarding | Upstream integration |
|
|
22
|
+
| `mediagen-provider-quick-reference.md` | Dated upstream provider snapshot | Upstream reference |
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Logging Reference
|
|
2
|
+
|
|
3
|
+
> Templates and examples. Rules in `CLAUDE.md`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Logger Initialization
|
|
8
|
+
|
|
9
|
+
```go
|
|
10
|
+
package logger
|
|
11
|
+
|
|
12
|
+
import (
|
|
13
|
+
"fmt"
|
|
14
|
+
|
|
15
|
+
"go.uber.org/zap"
|
|
16
|
+
"go.uber.org/zap/zapcore"
|
|
17
|
+
|
|
18
|
+
"{{module}}/internal/core/config"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// New 创建 Zap Logger
|
|
22
|
+
func New(cfg *config.LogConfig) (*zap.Logger, error) {
|
|
23
|
+
var zapCfg zap.Config
|
|
24
|
+
|
|
25
|
+
if cfg.Env == "production" {
|
|
26
|
+
zapCfg = zap.NewProductionConfig()
|
|
27
|
+
} else {
|
|
28
|
+
zapCfg = zap.NewDevelopmentConfig()
|
|
29
|
+
zapCfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
zapCfg.Level = zap.NewAtomicLevelAt(parseLevel(cfg.Level))
|
|
33
|
+
zapCfg.EncoderConfig.TimeKey = "timestamp"
|
|
34
|
+
zapCfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
|
35
|
+
|
|
36
|
+
logger, err := zapCfg.Build(
|
|
37
|
+
zap.AddCallerSkip(0),
|
|
38
|
+
zap.AddStacktrace(zap.ErrorLevel),
|
|
39
|
+
)
|
|
40
|
+
if err != nil {
|
|
41
|
+
return nil, fmt.Errorf("build logger: %w", err)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return logger, nil
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func parseLevel(level string) zapcore.Level {
|
|
48
|
+
switch level {
|
|
49
|
+
case "debug":
|
|
50
|
+
return zap.DebugLevel
|
|
51
|
+
case "info":
|
|
52
|
+
return zap.InfoLevel
|
|
53
|
+
case "warn":
|
|
54
|
+
return zap.WarnLevel
|
|
55
|
+
case "error":
|
|
56
|
+
return zap.ErrorLevel
|
|
57
|
+
case "fatal":
|
|
58
|
+
return zap.FatalLevel
|
|
59
|
+
default:
|
|
60
|
+
return zap.InfoLevel
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Logger Injection
|
|
68
|
+
|
|
69
|
+
```go
|
|
70
|
+
// 通过构造函数注入 (Wire)
|
|
71
|
+
|
|
72
|
+
type ConversationService struct {
|
|
73
|
+
repo domain.ConversationRepository
|
|
74
|
+
logger *zap.Logger
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func NewConversationService(repo domain.ConversationRepository, logger *zap.Logger) *ConversationService {
|
|
78
|
+
return &ConversationService{
|
|
79
|
+
repo: repo,
|
|
80
|
+
logger: logger.Named("ConversationService"),
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Log Levels
|
|
88
|
+
|
|
89
|
+
| Level | When |
|
|
90
|
+
|-------|------|
|
|
91
|
+
| `Fatal` | 应用崩溃,不可恢复(数据库连接断开) — 自动调用 `os.Exit(1)` |
|
|
92
|
+
| `Error` | 系统异常,外部 API 失败(支付网关超时) |
|
|
93
|
+
| `Warn` | 可恢复错误,降级(缓存未命中,重试成功) |
|
|
94
|
+
| `Info` | 业务事件,状态变更(订单创建,用户登录) |
|
|
95
|
+
| `Debug` | 详细调试信息(查询参数,响应数据) |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Log Volume Governance
|
|
100
|
+
|
|
101
|
+
Production logging must separate durable audit evidence from high-volume request telemetry.
|
|
102
|
+
|
|
103
|
+
| Signal | Required behavior |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| Business mutation audit | Always preserve. High-risk audit events must not be dropped when async buffers are full. |
|
|
106
|
+
| Login and security audit | Always preserve through the audit module, not through ad hoc application logs. |
|
|
107
|
+
| HTTP write request | Preserve in access logs. It is the operator entry point for user-impacting changes. |
|
|
108
|
+
| HTTP failure request | Preserve in access logs and stdout request summaries. |
|
|
109
|
+
| Slow request | Preserve in access logs and stdout request summaries. |
|
|
110
|
+
| Successful read request | Do not write all records by default. Use deterministic sampling or metrics/traces. |
|
|
111
|
+
| Health, readiness, metrics, static docs | Exclude from audit/access logs unless a security investigation explicitly requires them. |
|
|
112
|
+
|
|
113
|
+
Rules:
|
|
114
|
+
|
|
115
|
+
1. Do not use application logs as the source of truth for business changes. Use `sys_audit_logs` through `audit.Enrich()` or the DomainEvent audit envelope.
|
|
116
|
+
2. Do not emit one info-level stdout log for every successful read request in production.
|
|
117
|
+
3. Do not log request or response bodies, provider credentials, tokens, passwords, email contents, or payment identifiers beyond internal IDs.
|
|
118
|
+
4. Use bounded-cardinality fields only. User IDs, order IDs, and request IDs are allowed as fields; they are not allowed as metric labels.
|
|
119
|
+
5. Buffer overflow logs must be aggregated by time window, not emitted once per dropped entry.
|
|
120
|
+
6. Do not use `zap.Any`, `zap.Reflect`, `zap.ByteString`, or `zap.Binary` in production code. Convert values to typed scalar fields such as IDs, status, count, size, duration, timestamp, error code, or payload type.
|
|
121
|
+
7. Do not use raw field names `payload`, `body`, `raw`, `respBody`, `raw_request`, or `raw_response` in application logs. Use `payloadType`, `payloadBytes`, `responseBytes`, `requestId`, `providerRequestId`, or a redacted digest when diagnostics require correlation.
|
|
122
|
+
|
|
123
|
+
These log-field rules are enforced by `backend/scripts/check-forbidden-patterns.sh` and therefore run through `make pre-commit`, `.githooks/pre-commit`, and the governance gate.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Structured Logging Examples
|
|
128
|
+
|
|
129
|
+
```go
|
|
130
|
+
// info - 业务事件(短描述,过去时)
|
|
131
|
+
s.logger.Info("conversation created",
|
|
132
|
+
zap.Int64("conversationId", conv.ID),
|
|
133
|
+
zap.Int64("userId", conv.UserID),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
// error - Error() field
|
|
137
|
+
s.logger.Error("operation failed",
|
|
138
|
+
zap.Error(err),
|
|
139
|
+
zap.Int64("conversationId", id),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
// warn - 可恢复
|
|
143
|
+
s.logger.Warn("AI analysis failed, retrying",
|
|
144
|
+
zap.Int64("messageId", msgID),
|
|
145
|
+
zap.Int("attempt", 1),
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
// debug - 详细信息
|
|
149
|
+
s.logger.Debug("processing message",
|
|
150
|
+
zap.Int64("messageId", msgID),
|
|
151
|
+
)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Request Logging Middleware
|
|
157
|
+
|
|
158
|
+
```go
|
|
159
|
+
// internal/common/middleware/logging.go
|
|
160
|
+
|
|
161
|
+
engine.Use(middleware.LoggingWithConfig(logger, cfg.Log))
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`LoggingWithConfig` is the only HTTP request summary logger for Gin services. It keeps failures, write requests, and slow requests while allowing successful read requests to stay at debug level or deterministic sampling.
|
|
165
|
+
|
|
166
|
+
Configuration keys:
|
|
167
|
+
|
|
168
|
+
| Key | Purpose |
|
|
169
|
+
| --- | --- |
|
|
170
|
+
| `log.request_success_level` | Level for sampled successful read request summaries |
|
|
171
|
+
| `log.request_success_sample_rate` | Deterministic sampling rate for successful read request summaries |
|
|
172
|
+
| `log.request_slow_threshold` | Latency threshold that promotes a request summary to info |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Audit And Access Log Policy
|
|
177
|
+
|
|
178
|
+
`internal/core/audit.AccessLogPolicy` owns database access-log volume control.
|
|
179
|
+
|
|
180
|
+
| Condition | `sys_access_logs` write |
|
|
181
|
+
| --- | --- |
|
|
182
|
+
| `POST` / `PUT` / `PATCH` / `DELETE` | Always |
|
|
183
|
+
| HTTP `4xx` / `5xx` | Always |
|
|
184
|
+
| Duration above `audit.access_log.slow_request_threshold` | Always |
|
|
185
|
+
| Successful `GET` / `HEAD` | Deterministic sample by request identity |
|
|
186
|
+
|
|
187
|
+
Configuration keys:
|
|
188
|
+
|
|
189
|
+
| Key | Purpose |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| `audit.access_log.enabled` | Enables access-log database writes |
|
|
192
|
+
| `audit.access_log.success_read_sample_rate` | Deterministic sampling rate for successful read requests |
|
|
193
|
+
| `audit.access_log.slow_request_threshold` | Latency threshold that always records the request |
|
|
194
|
+
| `audit.access_log.record_write_methods` | Preserves mutation entry points |
|
|
195
|
+
| `audit.access_log.record_client_errors` | Preserves client-visible failures |
|
|
196
|
+
|
|
197
|
+
`sys_audit_logs` must remain a business evidence table. Do not reduce audit-log volume by sampling business mutations.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Write Audit Surface Classification
|
|
202
|
+
|
|
203
|
+
Write audit coverage is evaluated by source surface, not by raw database writes alone.
|
|
204
|
+
|
|
205
|
+
| Surface | Required audit path |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| Operator or external request command | `audit.Enrich()` after successful write, or DomainEvent `AuditChanges` envelope. |
|
|
208
|
+
| Domain event that represents a business state change | DomainEvent `AuditChanges` and optional `AuditMeta`. |
|
|
209
|
+
| Login/logout/security event | Auth event listener writes `sys_login_logs` and `sys_audit_logs`; before/after snapshots are not required. |
|
|
210
|
+
| Repository or persistence adapter | No direct audit call. The owning service command carries audit evidence. |
|
|
211
|
+
| Worker/system task | Use a run ledger plus DomainEvent envelope for user-visible business state changes. |
|
|
212
|
+
| Audit infrastructure | Never self-audit its own buffer flush or log-table writes. |
|
|
213
|
+
|
|
214
|
+
Rules:
|
|
215
|
+
|
|
216
|
+
1. Do not call `audit.Enrich()` from repository code.
|
|
217
|
+
2. Do not call `audit.Enrich()` from worker-only contexts; it is request-context enrichment and is a no-op outside HTTP.
|
|
218
|
+
3. Do not rely on comments that mention `audit.Enrich` or `AuditChanges`; the actual call or event field must exist in code.
|
|
219
|
+
4. Private helper writes are audited through the public command that owns the operation.
|
|
220
|
+
5. System events that change user-visible business state must carry `AuditChanges` even when emitted by scheduled jobs.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Correlation ID (Request ID)
|
|
225
|
+
|
|
226
|
+
```go
|
|
227
|
+
package middleware
|
|
228
|
+
|
|
229
|
+
import (
|
|
230
|
+
"github.com/gin-gonic/gin"
|
|
231
|
+
"github.com/google/uuid"
|
|
232
|
+
"go.opentelemetry.io/otel/attribute"
|
|
233
|
+
"go.opentelemetry.io/otel/trace"
|
|
234
|
+
|
|
235
|
+
"{{module}}/internal/common/types"
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
// RequestID 从请求头读取或生成 UUID,设置到 context、响应头和 OTel Span
|
|
239
|
+
func RequestID() gin.HandlerFunc {
|
|
240
|
+
return func(c *gin.Context) {
|
|
241
|
+
// 优先读取 X-Request-ID(APISIX 生成),其次 X-Correlation-ID
|
|
242
|
+
requestID := c.GetHeader(types.HeaderRequestID)
|
|
243
|
+
if requestID == "" {
|
|
244
|
+
requestID = c.GetHeader(types.HeaderCorrelationID)
|
|
245
|
+
}
|
|
246
|
+
if requestID == "" {
|
|
247
|
+
requestID = uuid.New().String()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// 存入 context
|
|
251
|
+
c.Set(string(types.ContextKeyRequestID), requestID)
|
|
252
|
+
|
|
253
|
+
// 写入响应头
|
|
254
|
+
c.Header(types.HeaderRequestID, requestID)
|
|
255
|
+
|
|
256
|
+
// 注入 OTel Span 属性
|
|
257
|
+
span := trace.SpanFromContext(c.Request.Context())
|
|
258
|
+
if span.SpanContext().IsValid() {
|
|
259
|
+
span.SetAttributes(attribute.String("request.id", requestID))
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
c.Next()
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// GetRequestID 从 gin.Context 获取请求 ID
|
|
267
|
+
func GetRequestID(c *gin.Context) string {
|
|
268
|
+
if v, ok := c.Get(string(types.ContextKeyRequestID)); ok {
|
|
269
|
+
if id, ok := v.(string); ok {
|
|
270
|
+
return id
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return ""
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Worker Job Logging
|
|
280
|
+
|
|
281
|
+
```go
|
|
282
|
+
// 后台任务 - 手动添加 correlation ID
|
|
283
|
+
func (p *AITaskProcessor) ProcessTask(ctx context.Context, task *asynq.Task) error {
|
|
284
|
+
jobLogger := p.logger.With(
|
|
285
|
+
zap.String("correlationId", fmt.Sprintf("job-%s", task.ResultWriter().TaskID())),
|
|
286
|
+
zap.String("taskType", task.Type()),
|
|
287
|
+
)
|
|
288
|
+
jobLogger.Info("processing task")
|
|
289
|
+
|
|
290
|
+
// ... 处理逻辑
|
|
291
|
+
|
|
292
|
+
jobLogger.Info("task completed")
|
|
293
|
+
return nil
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Sensitive Data Redaction
|
|
300
|
+
|
|
301
|
+
```go
|
|
302
|
+
// 日志中的敏感字段处理
|
|
303
|
+
|
|
304
|
+
// NEVER 直接记录
|
|
305
|
+
s.logger.Info("user login", zap.String("password", password)) // ❌ 禁止
|
|
306
|
+
s.logger.Info("api call", zap.String("token", token)) // ❌ 禁止
|
|
307
|
+
s.logger.Warn("provider failed", zap.ByteString("respBody", raw)) // ❌ 禁止
|
|
308
|
+
s.logger.Error("job failed", zap.Any("payload", payload)) // ❌ 禁止
|
|
309
|
+
|
|
310
|
+
// ALWAYS 只记录 ID 和非敏感信息
|
|
311
|
+
s.logger.Info("user logged in", zap.Int64("userId", userID)) // ✅
|
|
312
|
+
s.logger.Info("api call completed", zap.String("provider", "openai"), zap.Duration("latency", d)) // ✅
|
|
313
|
+
s.logger.Warn("provider failed", zap.Int("responseBytes", len(raw)), zap.String("providerRequestId", requestID)) // ✅
|
|
314
|
+
```
|