@stackonward/cli 0.0.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4588 -205
- package/dist/index.js.map +1 -1
- package/dist/resources/apple/.claude/docs/architecture-template.md +54 -0
- package/dist/resources/apple/.claude/docs/architecture.md +52 -0
- package/dist/resources/apple/.claude/docs/index.md +13 -0
- package/dist/resources/apple/.claude/docs/security-lifecycle.md +57 -0
- package/dist/resources/apple/.claude/docs/stack.md +93 -0
- package/dist/resources/apple/.claude/docs/verification.md +63 -0
- package/dist/resources/apple/AGENTS.md +397 -0
- package/dist/resources/apple/CLAUDE.md +397 -0
- package/dist/resources/apple/Gemfile +2 -0
- package/dist/resources/apple/Gemfile.lock +365 -0
- package/dist/resources/apple/_gitignore +14 -0
- package/dist/resources/apple/fastlane/Fastfile +123 -0
- package/dist/resources/components/nuxt/site-source/app/app.vue +42 -0
- package/dist/resources/components/nuxt/site-source/app/assets/css/site-shell.css +1035 -0
- package/dist/resources/components/nuxt/site-source/app/assets/icons/brand/.gitkeep +0 -0
- package/dist/resources/components/nuxt/site-source/app/assets/icons/common/.gitkeep +0 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationHeader.vue +35 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationShell.vue +56 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationSidebar.vue +40 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/BackToTop.vue +42 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ContentArticlePage.vue +40 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ContentListPage.vue +30 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/CookieConsent.vue +18 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingFooter.vue +52 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingHeader.vue +106 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingShell.vue +35 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/SiteBrand.vue +10 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/StaticPage.vue +21 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ToastViewport.vue +25 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseButton.vue +86 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseGradientBorder.vue +59 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseModal.vue +131 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BasePopover.vue +150 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseText.vue +138 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/CheckoutStatus.vue +112 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/CheckoutSummary.vue +172 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/GoogleSignInButton.vue +113 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/InfiniteScroll.vue +123 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/YoutubeEmbed.vue +126 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useAnalytics.ts +24 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useCheckout.ts +121 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useConsent.ts +31 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useGoogleIdentity.ts +163 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useNavigation.ts +11 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useSeo.ts +33 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useSiteShell.ts +58 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useToasts.ts +48 -0
- package/dist/resources/components/nuxt/site-source/app/layouts/app.vue +5 -0
- package/dist/resources/components/nuxt/site-source/app/layouts/default.vue +5 -0
- package/dist/resources/components/nuxt/site-source/app/plugins/analytics.client.ts +121 -0
- package/dist/resources/components/nuxt/site-source/app/plugins/google-identity.client.ts +24 -0
- package/dist/resources/components/nuxt/site-source/app/theme/accordion.ts +9 -0
- package/dist/resources/components/nuxt/site-source/app/theme/breadcrumb.ts +8 -0
- package/dist/resources/components/nuxt/site-source/app/theme/button.ts +92 -0
- package/dist/resources/components/nuxt/site-source/app/theme/carousel.ts +11 -0
- package/dist/resources/components/nuxt/site-source/app/theme/checkbox.ts +12 -0
- package/dist/resources/components/nuxt/site-source/app/theme/index.ts +30 -0
- package/dist/resources/components/nuxt/site-source/app/theme/input.ts +47 -0
- package/dist/resources/components/nuxt/site-source/app/theme/modal.ts +9 -0
- package/dist/resources/components/nuxt/site-source/app/theme/pagination.ts +6 -0
- package/dist/resources/components/nuxt/site-source/app/theme/select.ts +23 -0
- package/dist/resources/components/nuxt/site-source/app/theme/stepper.ts +10 -0
- package/dist/resources/components/nuxt/site-source/app/theme/toast.ts +8 -0
- package/dist/resources/components/nuxt/site-source/app/theme/tooltip.ts +6 -0
- package/dist/resources/components/nuxt/site-source/app/types/site-shell.ts +85 -0
- package/dist/resources/components/react/ui/Button.tsx +73 -0
- package/dist/resources/components/react/ui/Input.tsx +44 -0
- package/dist/resources/components/registry.json +355 -0
- package/dist/resources/components/vue/feedback/Toast.vue +120 -0
- package/dist/resources/components/vue/feedback/useToast.ts +70 -0
- package/dist/resources/components/vue/media/FileUpload.vue +229 -0
- package/dist/resources/components/vue/media/VideoPlayer.vue +157 -0
- package/dist/resources/components/vue/ui/AppImage.vue +147 -0
- package/dist/resources/components/vue/ui/BottomSheet.vue +217 -0
- package/dist/resources/components/vue/ui/Button.vue +154 -0
- package/dist/resources/components/vue/ui/Card.vue +111 -0
- package/dist/resources/components/vue/ui/Input.vue +113 -0
- package/dist/resources/components/vue/ui/Modal.vue +193 -0
- package/dist/resources/components/vue/ui/ScrollArea.vue +163 -0
- package/dist/resources/components/vue/ui/Tooltip.vue +115 -0
- package/dist/resources/registry.json +158 -0
- package/dist/resources/snippets/node/cache.ts +116 -0
- package/dist/resources/snippets/node/date.ts +126 -0
- package/dist/resources/snippets/node/logger.ts +104 -0
- package/dist/resources/snippets/node/validation.ts +132 -0
- package/dist/resources/snippets/react/useDebounce.ts +90 -0
- package/dist/resources/snippets/registry.json +65 -0
- package/dist/resources/snippets/vue/useAsync.ts +96 -0
- package/dist/resources/snippets/vue/usePagination.ts +102 -0
- package/dist/resources/templates/base/.claude/docs/architecture-template.md +459 -0
- package/dist/resources/templates/base/.claude/docs/architecture.md +137 -0
- package/dist/resources/templates/base/.claude/docs/index.md +42 -0
- package/dist/resources/templates/base/.claude/docs/security-lifecycle.md +129 -0
- package/dist/resources/templates/base/.claude/docs/verification.md +121 -0
- package/dist/resources/templates/base/AGENTS.md +415 -0
- package/dist/resources/templates/base/CLAUDE.md +415 -0
- package/dist/resources/templates/go-backend/.claude/docs/api-design.md +486 -0
- package/dist/resources/templates/go-backend/.claude/docs/architecture-template.md +449 -0
- package/dist/resources/templates/go-backend/.claude/docs/check-list.md +155 -0
- package/dist/resources/templates/go-backend/.claude/docs/database.md +369 -0
- package/dist/resources/templates/go-backend/.claude/docs/e2e-standards.md +161 -0
- package/dist/resources/templates/go-backend/.claude/docs/error-handling.md +558 -0
- package/dist/resources/templates/go-backend/.claude/docs/event-runtime-boundary.md +124 -0
- package/dist/resources/templates/go-backend/.claude/docs/identifier-contract.md +195 -0
- package/dist/resources/templates/go-backend/.claude/docs/index.md +22 -0
- package/dist/resources/templates/go-backend/.claude/docs/logging.md +314 -0
- package/dist/resources/templates/go-backend/.claude/docs/mediagen-provider-onboarding-sop.md +917 -0
- package/dist/resources/templates/go-backend/.claude/docs/mediagen-provider-quick-reference.md +195 -0
- package/dist/resources/templates/go-backend/.claude/docs/module-standards.md +309 -0
- package/dist/resources/templates/go-backend/.claude/docs/openapi-contract.md +141 -0
- package/dist/resources/templates/go-backend/.claude/docs/payment-gateway-onboarding.md +283 -0
- package/dist/resources/templates/go-backend/.claude/docs/platform-boundary.md +191 -0
- package/dist/resources/templates/go-backend/.claude/docs/quality-gates.md +112 -0
- package/dist/resources/templates/go-backend/.dockerignore +6 -0
- package/dist/resources/templates/go-backend/.env.example +13 -0
- package/dist/resources/templates/go-backend/.gitattributes +2 -0
- package/dist/resources/templates/go-backend/AGENTS.md +1139 -0
- package/dist/resources/templates/go-backend/CLAUDE.md +1139 -0
- package/dist/resources/templates/go-backend/Dockerfile +14 -0
- package/dist/resources/templates/go-backend/Makefile +71 -0
- package/dist/resources/templates/go-backend/README.md +66 -0
- package/dist/resources/templates/go-backend/_gitignore +10 -0
- package/dist/resources/templates/go-backend/api/openapi/README.md +29 -0
- package/dist/resources/templates/go-backend/api/openapi/dist/artifact-manifest.json +19 -0
- package/dist/resources/templates/go-backend/api/openapi/dist/conformance-matrix.json +276 -0
- package/dist/resources/templates/go-backend/api/openapi/document.go +30 -0
- package/dist/resources/templates/go-backend/api/openapi/package.json +28 -0
- package/dist/resources/templates/go-backend/api/openapi/pnpm-lock.yaml +3052 -0
- package/dist/resources/templates/go-backend/api/openapi/redocly-source.yaml +18 -0
- package/dist/resources/templates/go-backend/api/openapi/redocly.yaml +8 -0
- package/dist/resources/templates/go-backend/api/openapi/sdk-generators.json +16 -0
- package/dist/resources/templates/go-backend/api/openapi/service-registry.json +39 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/conformance/runtime.arazzo.yaml +65 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/dist/internal.openapi.json +327 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/dist/runtime-contract.json +56 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/openapi.yaml +222 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/conformance/runtime.arazzo.yaml +65 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/dist/internal.openapi.json +327 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/dist/runtime-contract.json +56 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/openapi.yaml +222 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/breaking.mjs +416 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/build.mjs +103 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/conformance_coverage.mjs +111 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/contract_compiler.mjs +62 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/contract_policy.mjs +208 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/delegated_contract.mjs +302 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/deterministic_archive.mjs +69 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_example_privacy.mjs +93 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_projection.mjs +498 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_quality.mjs +346 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/git_artifact_history.mjs +188 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/manifest.mjs +170 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/overlay.mjs +98 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/project.mjs +549 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/route_contract.mjs +156 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/runtime_conformance.mjs +193 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/scalar_asset_localization.mjs +164 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/sdk_generator.mjs +229 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/semantic_version.mjs +64 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/service_contract_inputs.mjs +16 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/breaking.test.mjs +365 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/build.test.mjs +42 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/conformance_coverage.test.mjs +88 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/contract_policy.test.mjs +257 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/delegated_contract.test.mjs +205 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_example_privacy.test.mjs +51 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_projection.test.mjs +368 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_quality.test.mjs +151 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/git_artifact_history.test.mjs +60 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/head_policy.test.mjs +8 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/overlay.test.mjs +44 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/projection.test.mjs +270 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/redocly_documentation_rules.test.mjs +146 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/release_manifest.test.mjs +76 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/route_contract.test.mjs +119 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/runtime_conformance.test.mjs +75 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/scalar_asset_localization.test.mjs +50 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/sdk_generator.test.mjs +31 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/semantic_version.test.mjs +60 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/service_contract_inputs.test.mjs +27 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/resources.go +125 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/runtime.go +102 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/runtime_test.go +70 -0
- package/dist/resources/templates/go-backend/cmd/product-api/lifecycle_test.go +58 -0
- package/dist/resources/templates/go-backend/cmd/product-api/main.go +32 -0
- package/dist/resources/templates/go-backend/cmd/product-api/wire.go +13 -0
- package/dist/resources/templates/go-backend/cmd/product-api/wire_gen.go +94 -0
- package/dist/resources/templates/go-backend/cmd/worker/main.go +47 -0
- package/dist/resources/templates/go-backend/cmd/worker/wire.go +14 -0
- package/dist/resources/templates/go-backend/cmd/worker/wire_gen.go +111 -0
- package/dist/resources/templates/go-backend/configs/config.yaml +37 -0
- package/dist/resources/templates/go-backend/deployments/compose.yaml +71 -0
- package/dist/resources/templates/go-backend/docs/openapi-provenance.json +489 -0
- package/dist/resources/templates/go-backend/docs/runtime-provenance.json +175 -0
- package/dist/resources/templates/go-backend/docs/source-provenance.json +3568 -0
- package/dist/resources/templates/go-backend/docs/standards-provenance.json +1624 -0
- package/dist/resources/templates/go-backend/go.mod +256 -0
- package/dist/resources/templates/go-backend/go.sum +805 -0
- package/dist/resources/templates/go-backend/internal/common/canonicaljson/canonical.go +370 -0
- package/dist/resources/templates/go-backend/internal/common/canonicaljson/canonical_test.go +223 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/contracts.go +125 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/platform_client.go +212 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/platform_client_test.go +319 -0
- package/dist/resources/templates/go-backend/internal/common/contentaccess/contentaccess.go +50 -0
- package/dist/resources/templates/go-backend/internal/common/contracts/contact.go +85 -0
- package/dist/resources/templates/go-backend/internal/common/ctxutil/identity.go +20 -0
- package/dist/resources/templates/go-backend/internal/common/ctxutil/product.go +53 -0
- package/dist/resources/templates/go-backend/internal/common/enumdomain/payment.go +12 -0
- package/dist/resources/templates/go-backend/internal/common/enums/dto_admin.go +9 -0
- package/dist/resources/templates/go-backend/internal/common/enums/enum.go +1247 -0
- package/dist/resources/templates/go-backend/internal/common/enums/handler_admin.go +66 -0
- package/dist/resources/templates/go-backend/internal/common/enums/module.go +46 -0
- package/dist/resources/templates/go-backend/internal/common/enums/provider.go +10 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register.go +11 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_audit.go +274 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_command_replay.go +12 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_config.go +27 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_locale.go +37 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_ops.go +14 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_outbox.go +15 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_rule_expression.go +63 -0
- package/dist/resources/templates/go-backend/internal/common/enums/registry.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/httporigin/origin.go +62 -0
- package/dist/resources/templates/go-backend/internal/common/httporigin/origin_test.go +38 -0
- package/dist/resources/templates/go-backend/internal/common/iamcredential/plaintext.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/iamcredential/plaintext_test.go +29 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope.go +212 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_binding.go +26 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_filter.go +173 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_filter_test.go +279 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/authorization_details.go +10 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/route_permission_policies.go +660 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/route_permission_policies_test.go +331 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/audience_token_source.go +166 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/bootstrap_token_exchanger.go +183 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/bound_service_token_signer.go +52 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/delegated_access_token_exchanger.go +189 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/delegated_access_token_exchanger_test.go +159 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/product_scoped_service_token_signer.go +92 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/provider.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/request_signer.go +86 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/resolver.go +69 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/resolver_test.go +42 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/route_scope.go +95 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/route_scope_test.go +78 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/service_identity_test.go +387 -0
- package/dist/resources/templates/go-backend/internal/common/jsonschema/compiler.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/jsonschema/compiler_test.go +41 -0
- package/dist/resources/templates/go-backend/internal/common/jwksapi/handler.go +83 -0
- package/dist/resources/templates/go-backend/internal/common/jwksapi/handler_test.go +104 -0
- package/dist/resources/templates/go-backend/internal/common/locale/locale.go +145 -0
- package/dist/resources/templates/go-backend/internal/common/locale/locale_test.go +75 -0
- package/dist/resources/templates/go-backend/internal/common/mediaref/mediaref.go +54 -0
- package/dist/resources/templates/go-backend/internal/common/mediaref/mediaref_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/apikey_auth.go +320 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/apikey_throttle.go +158 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/auth.go +40 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/auth_test.go +50 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/client_context.go +86 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/cors.go +68 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/event_context.go +18 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/gateway_identity.go +279 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/helpers.go +159 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_route_permission.go +171 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_token_auth.go +151 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_token_auth_test.go +99 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_service_identity.go +138 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_service_token_auth.go +74 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/idempotent.go +273 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/idempotent_test.go +83 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/internal_route_permission.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/internal_route_permission_test.go +186 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/logging.go +191 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/metrics.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/middleware_test.go +1516 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/principal_context.go +160 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/principal_context_test.go +355 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/product_context.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/recovery.go +40 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/referral_attribution.go +178 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/requestid.go +48 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/resource_permission.go +790 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/resource_permission_test.go +440 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/service_credential_auth.go +67 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/tenant.go +148 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/throttle.go +310 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/trusted_client_ip.go +23 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/trusted_client_ip_test.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/money/currency.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/money/errors.go +23 -0
- package/dist/resources/templates/go-backend/internal/common/money/format.go +123 -0
- package/dist/resources/templates/go-backend/internal/common/money/format_test.go +204 -0
- package/dist/resources/templates/go-backend/internal/common/money/gateway.go +144 -0
- package/dist/resources/templates/go-backend/internal/common/money/gateway_test.go +165 -0
- package/dist/resources/templates/go-backend/internal/common/money/rounding.go +56 -0
- package/dist/resources/templates/go-backend/internal/common/money/rounding_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/common/principal/context.go +56 -0
- package/dist/resources/templates/go-backend/internal/common/principal/principal.go +49 -0
- package/dist/resources/templates/go-backend/internal/common/productcode/code.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/productcode/code_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/providerconfig/schema.go +577 -0
- package/dist/resources/templates/go-backend/internal/common/providerconfig/schema_test.go +47 -0
- package/dist/resources/templates/go-backend/internal/common/requestprivacy/request.go +246 -0
- package/dist/resources/templates/go-backend/internal/common/requestprivacy/request_test.go +170 -0
- package/dist/resources/templates/go-backend/internal/common/response/pagination.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/response/response.go +110 -0
- package/dist/resources/templates/go-backend/internal/common/response/response_test.go +463 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/ast.go +141 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/ast_test.go +81 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/canonical.go +184 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/canonical_test.go +319 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/decoder.go +555 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/decoder_test.go +260 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/errors.go +55 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/evaluator.go +96 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/evaluator_test.go +220 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/fuzz_test.go +116 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/limits.go +331 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/schema.go +412 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/schema_test.go +164 -0
- package/dist/resources/templates/go-backend/internal/common/runtimeinput/runtime_input.go +627 -0
- package/dist/resources/templates/go-backend/internal/common/runtimeinput/runtime_input_test.go +245 -0
- package/dist/resources/templates/go-backend/internal/common/semver/errors.go +6 -0
- package/dist/resources/templates/go-backend/internal/common/semver/semver.go +125 -0
- package/dist/resources/templates/go-backend/internal/common/semver/semver_test.go +205 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/audience.go +48 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/audience_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/resource_identifier.go +33 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/resource_identifier_test.go +32 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/generator.go +99 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/generator_test.go +396 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/prefix.go +247 -0
- package/dist/resources/templates/go-backend/internal/common/types/asset_url.go +11 -0
- package/dist/resources/templates/go-backend/internal/common/types/billing.go +89 -0
- package/dist/resources/templates/go-backend/internal/common/types/billing_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/types/country.go +74 -0
- package/dist/resources/templates/go-backend/internal/common/types/country_test.go +28 -0
- package/dist/resources/templates/go-backend/internal/common/types/currency.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/types/identifiers.go +41 -0
- package/dist/resources/templates/go-backend/internal/common/types/operator.go +28 -0
- package/dist/resources/templates/go-backend/internal/common/types/subscription_entitlement.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/types/subscription_entitlement_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/types/tier.go +72 -0
- package/dist/resources/templates/go-backend/internal/common/types/types.go +411 -0
- package/dist/resources/templates/go-backend/internal/common/types/types_test.go +295 -0
- package/dist/resources/templates/go-backend/internal/common/utils/constants.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/utils/crypto.go +158 -0
- package/dist/resources/templates/go-backend/internal/common/utils/crypto_test.go +345 -0
- package/dist/resources/templates/go-backend/internal/common/utils/duration.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/utils/helpers.go +18 -0
- package/dist/resources/templates/go-backend/internal/common/utils/json.go +62 -0
- package/dist/resources/templates/go-backend/internal/common/utils/json_test.go +76 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pagination.go +51 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pagination_test.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pointer.go +107 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pointer_test.go +15 -0
- package/dist/resources/templates/go-backend/internal/common/utils/slice.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/utils/snowflake.go +110 -0
- package/dist/resources/templates/go-backend/internal/common/utils/snowflake_test.go +316 -0
- package/dist/resources/templates/go-backend/internal/common/utils/string.go +16 -0
- package/dist/resources/templates/go-backend/internal/common/utils/timefmt.go +42 -0
- package/dist/resources/templates/go-backend/internal/common/validator/validator.go +136 -0
- package/dist/resources/templates/go-backend/internal/common/validator/validator_test.go +240 -0
- package/dist/resources/templates/go-backend/internal/common/youtubeapi/client.go +224 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/document.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/document_test.go +104 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/route_validator.go +78 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/route_validator_test.go +108 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/assets/scalar-api-reference.js +2385 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/assets/scalar-api-reference.metadata.json +10 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/route.go +107 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/route_test.go +200 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/scalar.go +117 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/scalar_test.go +99 -0
- package/dist/resources/templates/go-backend/internal/core/audit/access_log_policy.go +91 -0
- package/dist/resources/templates/go-backend/internal/core/audit/access_log_policy_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/audit/actor_resolver.go +36 -0
- package/dist/resources/templates/go-backend/internal/core/audit/constants.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/audit/context.go +119 -0
- package/dist/resources/templates/go-backend/internal/core/audit/context_test.go +310 -0
- package/dist/resources/templates/go-backend/internal/core/audit/dto.go +468 -0
- package/dist/resources/templates/go-backend/internal/core/audit/dto_admin.go +172 -0
- package/dist/resources/templates/go-backend/internal/core/audit/enum.go +460 -0
- package/dist/resources/templates/go-backend/internal/core/audit/enum_test.go +314 -0
- package/dist/resources/templates/go-backend/internal/core/audit/errors.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/audit/handler.go +568 -0
- package/dist/resources/templates/go-backend/internal/core/audit/listener.go +319 -0
- package/dist/resources/templates/go-backend/internal/core/audit/listener_test.go +98 -0
- package/dist/resources/templates/go-backend/internal/core/audit/middleware.go +669 -0
- package/dist/resources/templates/go-backend/internal/core/audit/middleware_test.go +268 -0
- package/dist/resources/templates/go-backend/internal/core/audit/model.go +306 -0
- package/dist/resources/templates/go-backend/internal/core/audit/partition_job.go +316 -0
- package/dist/resources/templates/go-backend/internal/core/audit/ports.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/audit/provider.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/audit/repository.go +1007 -0
- package/dist/resources/templates/go-backend/internal/core/audit/repository_test.go +934 -0
- package/dist/resources/templates/go-backend/internal/core/audit/router.go +85 -0
- package/dist/resources/templates/go-backend/internal/core/audit/service.go +770 -0
- package/dist/resources/templates/go-backend/internal/core/audit/service_test.go +331 -0
- package/dist/resources/templates/go-backend/internal/core/audit/vo_admin.go +475 -0
- package/dist/resources/templates/go-backend/internal/core/cache/config.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/cache/key.go +41 -0
- package/dist/resources/templates/go-backend/internal/core/cache/key_test.go +62 -0
- package/dist/resources/templates/go-backend/internal/core/cache/l1.go +153 -0
- package/dist/resources/templates/go-backend/internal/core/cache/l1_test.go +212 -0
- package/dist/resources/templates/go-backend/internal/core/cache/manager.go +278 -0
- package/dist/resources/templates/go-backend/internal/core/cache/manager_provider.go +24 -0
- package/dist/resources/templates/go-backend/internal/core/cache/metrics.go +126 -0
- package/dist/resources/templates/go-backend/internal/core/cache/namespace.go +46 -0
- package/dist/resources/templates/go-backend/internal/core/cache/namespace_test.go +90 -0
- package/dist/resources/templates/go-backend/internal/core/cache/options.go +39 -0
- package/dist/resources/templates/go-backend/internal/core/cache/options_test.go +96 -0
- package/dist/resources/templates/go-backend/internal/core/cache/redis.go +311 -0
- package/dist/resources/templates/go-backend/internal/core/cache/redis_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/cache/serializer.go +31 -0
- package/dist/resources/templates/go-backend/internal/core/cache/serializer_test.go +139 -0
- package/dist/resources/templates/go-backend/internal/core/cache/singleflight.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/cache/singleflight_test.go +211 -0
- package/dist/resources/templates/go-backend/internal/core/cache/warming.go +86 -0
- package/dist/resources/templates/go-backend/internal/core/clock/clock.go +66 -0
- package/dist/resources/templates/go-backend/internal/core/clock/clock_test.go +26 -0
- package/dist/resources/templates/go-backend/internal/core/clock/runtime_clock.go +283 -0
- package/dist/resources/templates/go-backend/internal/core/clock/runtime_clock_test.go +98 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/errors.go +6 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/model.go +90 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/model_test.go +79 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/namespace.go +7 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/persistence.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/persistence_test.go +185 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/provider.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/repository.go +22 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service.go +853 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service_persistence_test.go +432 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service_test.go +891 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/types.go +121 -0
- package/dist/resources/templates/go-backend/internal/core/config/config.go +2069 -0
- package/dist/resources/templates/go-backend/internal/core/config/config_test.go +1122 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/contract_test.go +388 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/docs.go +198 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/verify.go +424 -0
- package/dist/resources/templates/go-backend/internal/core/config/enum.go +46 -0
- package/dist/resources/templates/go-backend/internal/core/config/metadata.go +717 -0
- package/dist/resources/templates/go-backend/internal/core/config/metadata_test.go +228 -0
- package/dist/resources/templates/go-backend/internal/core/config/product_admin_config_test.go +210 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/aes_gcm.go +111 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/aes_gcm_test.go +364 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/encryptor.go +12 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/envelope_encryptor.go +134 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/envelope_encryptor_test.go +118 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/pem.go +112 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/pem_test.go +44 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/provider.go +130 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/provider_test.go +92 -0
- package/dist/resources/templates/go-backend/internal/core/database/base_model.go +24 -0
- package/dist/resources/templates/go-backend/internal/core/database/clickhouse.go +121 -0
- package/dist/resources/templates/go-backend/internal/core/database/database.go +112 -0
- package/dist/resources/templates/go-backend/internal/core/database/database_logger_test.go +95 -0
- package/dist/resources/templates/go-backend/internal/core/database/errors.go +25 -0
- package/dist/resources/templates/go-backend/internal/core/database/metrics_plugin.go +105 -0
- package/dist/resources/templates/go-backend/internal/core/database/pool_collector.go +71 -0
- package/dist/resources/templates/go-backend/internal/core/database/read_replica.go +520 -0
- package/dist/resources/templates/go-backend/internal/core/database/transaction.go +170 -0
- package/dist/resources/templates/go-backend/internal/core/database/transaction_test.go +282 -0
- package/dist/resources/templates/go-backend/internal/core/distlock/lock.go +353 -0
- package/dist/resources/templates/go-backend/internal/core/distlock/lock_test.go +106 -0
- package/dist/resources/templates/go-backend/internal/core/errors/handler.go +189 -0
- package/dist/resources/templates/go-backend/internal/core/errors/handler_test.go +515 -0
- package/dist/resources/templates/go-backend/internal/core/eventbus/eventbus.go +667 -0
- package/dist/resources/templates/go-backend/internal/core/eventbus/eventbus_test.go +792 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/noop.go +22 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/provider.go +20 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/publisher.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/redis.go +109 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/routing.go +104 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/routing_test.go +71 -0
- package/dist/resources/templates/go-backend/internal/core/geoip/model.go +19 -0
- package/dist/resources/templates/go-backend/internal/core/geoip/service.go +88 -0
- package/dist/resources/templates/go-backend/internal/core/health/health.go +333 -0
- package/dist/resources/templates/go-backend/internal/core/health/health_test.go +27 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/client.go +772 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/client_test.go +287 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/download.go +578 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/download_test.go +374 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/jwk.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/keyring.go +144 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/keyring_test.go +128 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/registry.go +60 -0
- package/dist/resources/templates/go-backend/internal/core/logger/logger.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/logger/logger_test.go +194 -0
- package/dist/resources/templates/go-backend/internal/core/observability/metrics.go +358 -0
- package/dist/resources/templates/go-backend/internal/core/observability/sentry.go +445 -0
- package/dist/resources/templates/go-backend/internal/core/observability/sentry_privacy_test.go +175 -0
- package/dist/resources/templates/go-backend/internal/core/observability/tracing.go +187 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/model.go +314 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/model_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/persistence.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/provider.go +23 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay.go +1138 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay_postgres_test.go +257 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay_test.go +690 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/rescheduler.go +164 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/rescheduler_test.go +209 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer.go +249 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer_postgres_test.go +170 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer_test.go +123 -0
- package/dist/resources/templates/go-backend/internal/core/provider.go +198 -0
- package/dist/resources/templates/go-backend/internal/core/queue/metrics_middleware.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/queue/metrics_middleware_test.go +12 -0
- package/dist/resources/templates/go-backend/internal/core/queue/queue.go +288 -0
- package/dist/resources/templates/go-backend/internal/core/queue/queue_test.go +159 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/bulkhead.go +514 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/bulkhead_test.go +984 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/circuitbreaker.go +358 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/circuitbreaker_test.go +788 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/retry.go +318 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/retry_test.go +735 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/recorder.go +305 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/run_context.go +124 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/run_context_test.go +85 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/scheduler.go +1589 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/scheduler_control_test.go +808 -0
- package/dist/resources/templates/go-backend/internal/core/storage/oss_provider.go +398 -0
- package/dist/resources/templates/go-backend/internal/core/storage/oss_provider_test.go +89 -0
- package/dist/resources/templates/go-backend/internal/core/storage/path.go +110 -0
- package/dist/resources/templates/go-backend/internal/core/storage/path_test.go +301 -0
- package/dist/resources/templates/go-backend/internal/core/storage/s3_provider.go +489 -0
- package/dist/resources/templates/go-backend/internal/core/storage/s3_provider_test.go +60 -0
- package/dist/resources/templates/go-backend/internal/core/storage/storage.go +268 -0
- package/dist/resources/templates/go-backend/internal/core/storage/validation.go +225 -0
- package/dist/resources/templates/go-backend/internal/core/storage/validation_test.go +495 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/logger.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/provider.go +126 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/provider_test.go +67 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/client.go +282 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/client_test.go +81 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/config.go +58 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/handler.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/hub.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/message.go +273 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/notifier.go +92 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/provider.go +33 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/action.go +77 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/action_test.go +238 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/condition.go +107 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/decision.go +256 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/enum.go +643 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/errors.go +102 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/principal_record.go +21 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/product_context.go +486 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/resource.go +215 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/resource_test.go +242 -0
- package/dist/resources/templates/go-backend/internal/products/README.md +5 -0
- package/dist/resources/templates/go-backend/internal/sharedevents/README.md +5 -0
- package/dist/resources/templates/go-backend/migrations/000001_infrastructure.down.sql +13 -0
- package/dist/resources/templates/go-backend/migrations/000001_infrastructure.up.sql +886 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error.go +327 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_code.go +65 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_test.go +41 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_type.go +14 -0
- package/dist/resources/templates/go-backend/pkg/apierror/http_response.go +216 -0
- package/dist/resources/templates/go-backend/pkg/apierror/http_response_test.go +216 -0
- package/dist/resources/templates/go-backend/scripts/check-openapi-clean-deletion.sh +54 -0
- package/dist/resources/templates/go-backend/scripts/test-migrations.sh +32 -0
- package/dist/resources/templates/go-backend/tests/infrastructure.sql +69 -0
- package/dist/resources/templates/mcp-server/.claude/docs/stack.md +338 -0
- package/dist/resources/templates/mcp-server/.editorconfig +13 -0
- package/dist/resources/templates/mcp-server/.env.example +8 -0
- package/dist/resources/templates/mcp-server/.github/ISSUE_TEMPLATE/bug_report.yml +104 -0
- package/dist/resources/templates/mcp-server/.github/ISSUE_TEMPLATE/feature_request.yml +54 -0
- package/dist/resources/templates/mcp-server/.github/PULL_REQUEST_TEMPLATE.md +36 -0
- package/dist/resources/templates/mcp-server/.github/workflows/ci.yml +78 -0
- package/dist/resources/templates/mcp-server/.husky/commit-msg +1 -0
- package/dist/resources/templates/mcp-server/.husky/pre-commit +1 -0
- package/dist/resources/templates/mcp-server/.lintstagedrc.json +4 -0
- package/dist/resources/templates/mcp-server/.nvmrc +1 -0
- package/dist/resources/templates/mcp-server/.prettierrc +8 -0
- package/dist/resources/templates/mcp-server/CONTRIBUTING.md +184 -0
- package/dist/resources/templates/mcp-server/Dockerfile +23 -0
- package/dist/resources/templates/mcp-server/LICENSE +21 -0
- package/dist/resources/templates/mcp-server/README.md +123 -0
- package/dist/resources/templates/mcp-server/_gitignore +26 -0
- package/dist/resources/templates/mcp-server/commitlint.config.js +24 -0
- package/dist/resources/templates/mcp-server/eslint.config.js +30 -0
- package/dist/resources/templates/mcp-server/package.json +72 -0
- package/dist/resources/templates/mcp-server/src/index.ts +27 -0
- package/dist/resources/templates/mcp-server/src/resources.ts +33 -0
- package/dist/resources/templates/mcp-server/src/services/.gitkeep +0 -0
- package/dist/resources/templates/mcp-server/src/tools.ts +43 -0
- package/dist/resources/templates/mcp-server/src/types/index.ts +19 -0
- package/dist/resources/templates/mcp-server/src/utils/index.ts +31 -0
- package/dist/resources/templates/mcp-server/tsconfig.json +22 -0
- package/dist/resources/templates/mcp-server/tsup.config.ts +14 -0
- package/dist/resources/templates/mcp-server/vitest.config.ts +15 -0
- package/dist/resources/templates/nuxt/.claude/docs/stack.md +666 -0
- package/dist/resources/templates/nuxt/.editorconfig +15 -0
- package/dist/resources/templates/nuxt/.env.example +22 -0
- package/dist/resources/templates/nuxt/.github/workflows/ci.yml +34 -0
- package/dist/resources/templates/nuxt/.husky/commit-msg +1 -0
- package/dist/resources/templates/nuxt/.husky/pre-commit +1 -0
- package/dist/resources/templates/nuxt/.nvmrc +1 -0
- package/dist/resources/templates/nuxt/.prettierignore +9 -0
- package/dist/resources/templates/nuxt/.prettierrc +1 -0
- package/dist/resources/templates/nuxt/README.md +23 -0
- package/dist/resources/templates/nuxt/_gitignore +7 -0
- package/dist/resources/templates/nuxt/app/app.config.ts +105 -0
- package/dist/resources/templates/nuxt/app/i18n/locales/en.json +5 -0
- package/dist/resources/templates/nuxt/app/pages/app/index.vue +224 -0
- package/dist/resources/templates/nuxt/app/pages/authors/[slug].vue +37 -0
- package/dist/resources/templates/nuxt/app/pages/blog/[slug].vue +55 -0
- package/dist/resources/templates/nuxt/app/pages/blog/category/[category].vue +38 -0
- package/dist/resources/templates/nuxt/app/pages/blog/index.vue +46 -0
- package/dist/resources/templates/nuxt/app/pages/index.vue +626 -0
- package/dist/resources/templates/nuxt/app/pages/legal/privacy.vue +21 -0
- package/dist/resources/templates/nuxt/app/pages/legal/terms.vue +21 -0
- package/dist/resources/templates/nuxt/app/pages/ui/index.vue +397 -0
- package/dist/resources/templates/nuxt/commitlint.config.mjs +1 -0
- package/dist/resources/templates/nuxt/eslint.config.mjs +4 -0
- package/dist/resources/templates/nuxt/lint-staged.config.mjs +8 -0
- package/dist/resources/templates/nuxt/nuxt.config.ts +71 -0
- package/dist/resources/templates/nuxt/package.json +67 -0
- package/dist/resources/templates/nuxt/public/apple-touch-icon.png +0 -0
- package/dist/resources/templates/nuxt/public/favicon.ico +0 -0
- package/dist/resources/templates/nuxt/public/favicon.svg +5 -0
- package/dist/resources/templates/nuxt/public/icon-16x16.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-192x192.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-32x32.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-512x512.png +0 -0
- package/dist/resources/templates/nuxt/public/logo.svg +6 -0
- package/dist/resources/templates/nuxt/public/media/hero-product-gallery.png +0 -0
- package/dist/resources/templates/nuxt/server/api/content/sitemap-urls.get.ts +12 -0
- package/dist/resources/templates/nuxt/server/api/preview.get.ts +9 -0
- package/dist/resources/templates/nuxt/stylelint.config.mjs +3 -0
- package/dist/resources/templates/nuxt/test/e2e/rendering.test.ts +13 -0
- package/dist/resources/templates/nuxt/tsconfig.json +3 -0
- package/dist/resources/templates/nuxt/vitest.config.ts +8 -0
- package/package.json +8 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Package principal 提供 request-scoped 的用户解析上下文。
|
|
2
|
+
//
|
|
3
|
+
// Principal 是单一权益解析事实源(对齐 Stripe Entitlements / GitHub Permissions 模式):
|
|
4
|
+
// middleware.PrincipalContext 在 auth middleware 之后注入 Principal,handler 通过
|
|
5
|
+
// principal.MustGet(c) / principal.Get(c) 读取,避免 5+ 个独立 read 路径不一致。
|
|
6
|
+
package principal
|
|
7
|
+
|
|
8
|
+
import (
|
|
9
|
+
"{{module}}/internal/common/types"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// Principal 当前请求解析后的用户主体投影。
|
|
13
|
+
//
|
|
14
|
+
// 设计原则:
|
|
15
|
+
// - 仅承载 backend 已 resolve 的 identity + 决策结果,不携带 entitlement bag
|
|
16
|
+
// - entitlement limits(如 credit_discount_rate)按需懒加载,由各 service 自己调
|
|
17
|
+
// EntitlementService.GetLimit / DiscountResolver,避免 middleware 冷启 RPC 风暴
|
|
18
|
+
// - UserID == 0 表示匿名,ContentAccess 仍由公开策略链按请求上下文解析
|
|
19
|
+
type Principal struct {
|
|
20
|
+
// UserID 当前请求用户 ID,0 表示匿名
|
|
21
|
+
UserID int64
|
|
22
|
+
// ProductCode 当前请求产品标识,来源 X-Product-Code
|
|
23
|
+
ProductCode types.Product
|
|
24
|
+
// ContentAccess 用户当前内容访问决策快照
|
|
25
|
+
ContentAccess ContentAccess
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ContentAccess 用户当前内容访问决策(来自 accessPolicy.ResolveContentAccess)。
|
|
29
|
+
//
|
|
30
|
+
// 仅保留 backend 业务实际消费的内容访问决策字段。
|
|
31
|
+
type ContentAccess struct {
|
|
32
|
+
// Level 有效访问等级(0=合规, 50=mature, 80=sensitive, 100=unrestricted)
|
|
33
|
+
Level int64
|
|
34
|
+
// Rating 派生评级(compliant / mature / sensitive / unrestricted)
|
|
35
|
+
Rating string
|
|
36
|
+
// Decision 决策(allow / deny / cap)
|
|
37
|
+
Decision string
|
|
38
|
+
// Source 来源(default / lifetime_purchase / subscription / policy / ...)
|
|
39
|
+
Source string
|
|
40
|
+
// RuleCode 命中的策略 rule code(可空)
|
|
41
|
+
RuleCode string
|
|
42
|
+
// ReasonCode 原因码(可空,违规时填 prompt_policy_violation 等)
|
|
43
|
+
ReasonCode string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// IsAuthenticated 判断 Principal 是否对应已登录用户。
|
|
47
|
+
func (p *Principal) IsAuthenticated() bool {
|
|
48
|
+
return p != nil && p.UserID > 0
|
|
49
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package productcode
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"regexp"
|
|
6
|
+
"strings"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
var pattern = regexp.MustCompile(`^[a-z][a-z0-9_-]{0,49}$`)
|
|
10
|
+
|
|
11
|
+
// Normalize 校验并返回跨模块稳定的 Product 编码。
|
|
12
|
+
func Normalize(value string) (string, error) {
|
|
13
|
+
normalized := strings.TrimSpace(value)
|
|
14
|
+
if !pattern.MatchString(normalized) {
|
|
15
|
+
return "", fmt.Errorf("product code must match %s", pattern.String())
|
|
16
|
+
}
|
|
17
|
+
return normalized, nil
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Validate 校验跨模块稳定的 Product 编码。
|
|
21
|
+
func Validate(value string) error {
|
|
22
|
+
_, err := Normalize(value)
|
|
23
|
+
return err
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package productcode
|
|
2
|
+
|
|
3
|
+
import "testing"
|
|
4
|
+
|
|
5
|
+
func TestNormalize(t *testing.T) {
|
|
6
|
+
t.Parallel()
|
|
7
|
+
|
|
8
|
+
tests := []struct {
|
|
9
|
+
name string
|
|
10
|
+
value string
|
|
11
|
+
want string
|
|
12
|
+
wantErr bool
|
|
13
|
+
}{
|
|
14
|
+
{name: "single character", value: "a", want: "a"},
|
|
15
|
+
{name: "underscore and hyphen", value: " product_alpha-v2 ", want: "product_alpha-v2"},
|
|
16
|
+
{name: "uppercase", value: "Product", wantErr: true},
|
|
17
|
+
{name: "leading digit", value: "1product", wantErr: true},
|
|
18
|
+
{name: "too long", value: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy", wantErr: true},
|
|
19
|
+
}
|
|
20
|
+
for _, test := range tests {
|
|
21
|
+
t.Run(test.name, func(t *testing.T) {
|
|
22
|
+
t.Parallel()
|
|
23
|
+
got, err := Normalize(test.value)
|
|
24
|
+
if test.wantErr {
|
|
25
|
+
if err == nil {
|
|
26
|
+
t.Fatalf("Normalize(%q) expected error", test.value)
|
|
27
|
+
}
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
if err != nil || got != test.want {
|
|
31
|
+
t.Fatalf("Normalize(%q) = %q, %v; want %q", test.value, got, err, test.want)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
package providerconfig
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/base64"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"io"
|
|
9
|
+
"net/url"
|
|
10
|
+
"regexp"
|
|
11
|
+
"sort"
|
|
12
|
+
"strings"
|
|
13
|
+
"time"
|
|
14
|
+
"unicode/utf8"
|
|
15
|
+
|
|
16
|
+
corecrypto "{{module}}/internal/core/crypto"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
// ValueType 描述 provider 配置字段的 JSON 值类型。
|
|
20
|
+
type ValueType string
|
|
21
|
+
|
|
22
|
+
const (
|
|
23
|
+
ValueTypeString ValueType = "string"
|
|
24
|
+
ValueTypeBoolean ValueType = "boolean"
|
|
25
|
+
ValueTypeInteger ValueType = "integer"
|
|
26
|
+
ValueTypeJSON ValueType = "json"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
// ValueTypes 返回 provider 配置字段类型 canonical 集合。
|
|
30
|
+
func ValueTypes() []string {
|
|
31
|
+
return []string{
|
|
32
|
+
string(ValueTypeString),
|
|
33
|
+
string(ValueTypeBoolean),
|
|
34
|
+
string(ValueTypeInteger),
|
|
35
|
+
string(ValueTypeJSON),
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ValidationFormat 描述 provider 配置字段的标准格式约束。
|
|
40
|
+
type ValidationFormat string
|
|
41
|
+
|
|
42
|
+
const (
|
|
43
|
+
ValidationFormatURL ValidationFormat = "url"
|
|
44
|
+
ValidationFormatDuration ValidationFormat = "duration"
|
|
45
|
+
ValidationFormatPEM ValidationFormat = "pem"
|
|
46
|
+
ValidationFormatBase64 ValidationFormat = "base64"
|
|
47
|
+
ValidationFormatE164 ValidationFormat = "e164"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
// ValidationFormats 返回非空格式约束的 canonical 集合。
|
|
51
|
+
func ValidationFormats() []string {
|
|
52
|
+
return []string{
|
|
53
|
+
string(ValidationFormatURL),
|
|
54
|
+
string(ValidationFormatDuration),
|
|
55
|
+
string(ValidationFormatPEM),
|
|
56
|
+
string(ValidationFormatBase64),
|
|
57
|
+
string(ValidationFormatE164),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// FieldValidation 描述 provider 配置字段的机器可读约束。
|
|
62
|
+
type FieldValidation struct {
|
|
63
|
+
Format ValidationFormat `json:"format,omitempty"`
|
|
64
|
+
Pattern string `json:"pattern,omitempty"`
|
|
65
|
+
MinLength *int `json:"min_length,omitempty"`
|
|
66
|
+
MaxLength *int `json:"max_length,omitempty"`
|
|
67
|
+
MinValue *int64 `json:"min_value,omitempty"`
|
|
68
|
+
MaxValue *int64 `json:"max_value,omitempty"`
|
|
69
|
+
AllowedValues []string `json:"allowed_values,omitempty"`
|
|
70
|
+
RequiredJSONKeys []string `json:"required_json_keys,omitempty"`
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Field 描述 provider 配置中的单个字段。
|
|
74
|
+
type Field struct {
|
|
75
|
+
Key string `json:"key"`
|
|
76
|
+
Label string `json:"label"`
|
|
77
|
+
ValueType ValueType `json:"value_type"`
|
|
78
|
+
Required bool `json:"required"`
|
|
79
|
+
Secret bool `json:"secret"`
|
|
80
|
+
Sensitive bool `json:"sensitive"`
|
|
81
|
+
Multiline bool `json:"multiline,omitempty"`
|
|
82
|
+
Placeholder string `json:"placeholder,omitempty"`
|
|
83
|
+
Description string `json:"description,omitempty"`
|
|
84
|
+
Validation FieldValidation `json:"validation,omitempty"`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// InputSource 标识配置错误来自公开配置或加密密钥输入。
|
|
88
|
+
type InputSource string
|
|
89
|
+
|
|
90
|
+
const (
|
|
91
|
+
InputSourceConfig InputSource = "config"
|
|
92
|
+
InputSourceSecrets InputSource = "secrets"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
// InputSources 返回配置输入来源的 canonical 集合。
|
|
96
|
+
func InputSources() []string {
|
|
97
|
+
return []string{
|
|
98
|
+
string(InputSourceConfig),
|
|
99
|
+
string(InputSourceSecrets),
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// InputError 描述可由领域层映射的字段输入错误。
|
|
104
|
+
type InputError struct {
|
|
105
|
+
Source InputSource
|
|
106
|
+
Field string
|
|
107
|
+
Problem string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Error 返回不包含字段值的稳定错误描述。
|
|
111
|
+
func (e *InputError) Error() string {
|
|
112
|
+
if e.Field == "" {
|
|
113
|
+
return fmt.Sprintf("%s %s", e.Source, e.Problem)
|
|
114
|
+
}
|
|
115
|
+
return fmt.Sprintf("%s field %q %s", e.Source, e.Field, e.Problem)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ValidationOptions 控制完整配置和局部配置的必填语义。
|
|
119
|
+
type ValidationOptions struct {
|
|
120
|
+
RequireRequired bool
|
|
121
|
+
RejectEmptyOptionalSecret bool
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ValidatedConfiguration 保存校验并归一化后的配置输入。
|
|
125
|
+
type ValidatedConfiguration struct {
|
|
126
|
+
Config json.RawMessage
|
|
127
|
+
Secrets map[string]string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ValidateDefinition 校验字段 schema 的业务无关约束。
|
|
131
|
+
func ValidateDefinition(fields []Field) error {
|
|
132
|
+
seenFields := make(map[string]struct{}, len(fields))
|
|
133
|
+
for _, field := range fields {
|
|
134
|
+
if strings.TrimSpace(field.Key) == "" {
|
|
135
|
+
return fmt.Errorf("schema contains empty field key")
|
|
136
|
+
}
|
|
137
|
+
if field.Key != strings.TrimSpace(field.Key) {
|
|
138
|
+
return fmt.Errorf("schema contains non-canonical field key %q", field.Key)
|
|
139
|
+
}
|
|
140
|
+
if _, exists := seenFields[field.Key]; exists {
|
|
141
|
+
return fmt.Errorf("schema contains duplicate field %q", field.Key)
|
|
142
|
+
}
|
|
143
|
+
seenFields[field.Key] = struct{}{}
|
|
144
|
+
if strings.TrimSpace(field.Label) == "" {
|
|
145
|
+
return fmt.Errorf("field %q requires label", field.Key)
|
|
146
|
+
}
|
|
147
|
+
if err := validateFieldDefinition(field); err != nil {
|
|
148
|
+
return fmt.Errorf("field %q definition is invalid: %w", field.Key, err)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return nil
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ValidateConfiguration 校验并归一化公开配置与加密密钥输入。
|
|
155
|
+
func ValidateConfiguration(
|
|
156
|
+
fields []Field,
|
|
157
|
+
secrets map[string]string,
|
|
158
|
+
config json.RawMessage,
|
|
159
|
+
options ValidationOptions,
|
|
160
|
+
) (*ValidatedConfiguration, error) {
|
|
161
|
+
if err := ValidateDefinition(fields); err != nil {
|
|
162
|
+
return nil, err
|
|
163
|
+
}
|
|
164
|
+
configValues, _, err := DecodeObject(config)
|
|
165
|
+
if err != nil {
|
|
166
|
+
return nil, inputError(InputSourceConfig, "", fmt.Sprintf("must be a JSON object: %v", err))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fieldsByKey := make(map[string]Field, len(fields))
|
|
170
|
+
for _, field := range fields {
|
|
171
|
+
fieldsByKey[field.Key] = field
|
|
172
|
+
}
|
|
173
|
+
for _, key := range sortedMapKeys(configValues) {
|
|
174
|
+
field, ok := fieldsByKey[key]
|
|
175
|
+
if !ok {
|
|
176
|
+
return nil, inputError(InputSourceConfig, key, "is not defined")
|
|
177
|
+
}
|
|
178
|
+
if field.Secret {
|
|
179
|
+
return nil, inputError(InputSourceConfig, key, "must be supplied through secrets")
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for _, key := range sortedMapKeys(secrets) {
|
|
183
|
+
field, ok := fieldsByKey[key]
|
|
184
|
+
if !ok {
|
|
185
|
+
return nil, inputError(InputSourceSecrets, key, "is not defined")
|
|
186
|
+
}
|
|
187
|
+
if !field.Secret {
|
|
188
|
+
return nil, inputError(InputSourceSecrets, key, "must be supplied through config")
|
|
189
|
+
}
|
|
190
|
+
if options.RejectEmptyOptionalSecret && !field.Required && strings.TrimSpace(secrets[key]) == "" {
|
|
191
|
+
return nil, inputError(InputSourceSecrets, key, "must not be empty")
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if options.RequireRequired {
|
|
195
|
+
for _, field := range fields {
|
|
196
|
+
if !field.Required {
|
|
197
|
+
continue
|
|
198
|
+
}
|
|
199
|
+
if field.Secret {
|
|
200
|
+
value, present := secrets[field.Key]
|
|
201
|
+
if !present || strings.TrimSpace(value) == "" {
|
|
202
|
+
return nil, inputError(InputSourceSecrets, field.Key, "is required")
|
|
203
|
+
}
|
|
204
|
+
continue
|
|
205
|
+
}
|
|
206
|
+
value, present := configValues[field.Key]
|
|
207
|
+
if !present || IsEmptyValue(value) {
|
|
208
|
+
return nil, inputError(InputSourceConfig, field.Key, "is required")
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
normalizedSecrets := make(map[string]string, len(secrets))
|
|
214
|
+
for _, field := range fields {
|
|
215
|
+
if field.Secret {
|
|
216
|
+
value, present := secrets[field.Key]
|
|
217
|
+
if !present || strings.TrimSpace(value) == "" {
|
|
218
|
+
continue
|
|
219
|
+
}
|
|
220
|
+
normalizedValue, normalizeErr := normalizeSecretValue(field, value)
|
|
221
|
+
if normalizeErr != nil {
|
|
222
|
+
return nil, inputError(InputSourceSecrets, field.Key, fmt.Sprintf("is invalid: %v", normalizeErr))
|
|
223
|
+
}
|
|
224
|
+
validationValue := any(normalizedValue)
|
|
225
|
+
if field.ValueType == ValueTypeJSON {
|
|
226
|
+
validationValue, normalizeErr = decodeJSONValue(normalizedValue)
|
|
227
|
+
if normalizeErr != nil {
|
|
228
|
+
return nil, inputError(InputSourceSecrets, field.Key, fmt.Sprintf("is invalid: %v", normalizeErr))
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if err := validateFieldValue(field, validationValue); err != nil {
|
|
232
|
+
return nil, inputError(InputSourceSecrets, field.Key, fmt.Sprintf("is invalid: %v", err))
|
|
233
|
+
}
|
|
234
|
+
normalizedSecrets[field.Key] = normalizedValue
|
|
235
|
+
continue
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
value, present := configValues[field.Key]
|
|
239
|
+
if !present {
|
|
240
|
+
continue
|
|
241
|
+
}
|
|
242
|
+
normalizedValue, normalizeErr := normalizeConfigurationValue(field, value)
|
|
243
|
+
if normalizeErr != nil {
|
|
244
|
+
return nil, inputError(InputSourceConfig, field.Key, fmt.Sprintf("is invalid: %v", normalizeErr))
|
|
245
|
+
}
|
|
246
|
+
if err := validateFieldValue(field, normalizedValue); err != nil {
|
|
247
|
+
return nil, inputError(InputSourceConfig, field.Key, fmt.Sprintf("is invalid: %v", err))
|
|
248
|
+
}
|
|
249
|
+
configValues[field.Key] = normalizedValue
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
normalizedConfig := json.RawMessage{}
|
|
253
|
+
if len(configValues) > 0 {
|
|
254
|
+
normalizedConfig, err = json.Marshal(configValues)
|
|
255
|
+
if err != nil {
|
|
256
|
+
return nil, fmt.Errorf("normalize provider config: %w", err)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return &ValidatedConfiguration{Config: normalizedConfig, Secrets: normalizedSecrets}, nil
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// DecodeObject 把单个 JSON 对象解码为可归一化字段映射。
|
|
263
|
+
func DecodeObject(raw json.RawMessage) (map[string]any, json.RawMessage, error) {
|
|
264
|
+
trimmed := bytes.TrimSpace(raw)
|
|
265
|
+
if len(trimmed) == 0 {
|
|
266
|
+
return map[string]any{}, json.RawMessage{}, nil
|
|
267
|
+
}
|
|
268
|
+
if bytes.Equal(trimmed, []byte("null")) {
|
|
269
|
+
return nil, nil, fmt.Errorf("config must be a JSON object")
|
|
270
|
+
}
|
|
271
|
+
decoder := json.NewDecoder(bytes.NewReader(trimmed))
|
|
272
|
+
decoder.UseNumber()
|
|
273
|
+
var value map[string]any
|
|
274
|
+
if err := decoder.Decode(&value); err != nil {
|
|
275
|
+
return nil, nil, err
|
|
276
|
+
}
|
|
277
|
+
if err := decoder.Decode(&struct{}{}); err != io.EOF {
|
|
278
|
+
if err == nil {
|
|
279
|
+
return nil, nil, fmt.Errorf("config must contain one JSON object")
|
|
280
|
+
}
|
|
281
|
+
return nil, nil, err
|
|
282
|
+
}
|
|
283
|
+
if value == nil {
|
|
284
|
+
return map[string]any{}, json.RawMessage{}, nil
|
|
285
|
+
}
|
|
286
|
+
normalized, err := json.Marshal(value)
|
|
287
|
+
if err != nil {
|
|
288
|
+
return nil, nil, err
|
|
289
|
+
}
|
|
290
|
+
return value, normalized, nil
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// CloneFields 返回不共享 slice 或指针约束的字段副本。
|
|
294
|
+
func CloneFields(fields []Field) []Field {
|
|
295
|
+
cloned := make([]Field, len(fields))
|
|
296
|
+
for i := range fields {
|
|
297
|
+
cloned[i] = fields[i]
|
|
298
|
+
validation := fields[i].Validation
|
|
299
|
+
if validation.MinLength != nil {
|
|
300
|
+
value := *validation.MinLength
|
|
301
|
+
cloned[i].Validation.MinLength = &value
|
|
302
|
+
}
|
|
303
|
+
if validation.MaxLength != nil {
|
|
304
|
+
value := *validation.MaxLength
|
|
305
|
+
cloned[i].Validation.MaxLength = &value
|
|
306
|
+
}
|
|
307
|
+
if validation.MinValue != nil {
|
|
308
|
+
value := *validation.MinValue
|
|
309
|
+
cloned[i].Validation.MinValue = &value
|
|
310
|
+
}
|
|
311
|
+
if validation.MaxValue != nil {
|
|
312
|
+
value := *validation.MaxValue
|
|
313
|
+
cloned[i].Validation.MaxValue = &value
|
|
314
|
+
}
|
|
315
|
+
cloned[i].Validation.AllowedValues = append([]string(nil), validation.AllowedValues...)
|
|
316
|
+
cloned[i].Validation.RequiredJSONKeys = append([]string(nil), validation.RequiredJSONKeys...)
|
|
317
|
+
}
|
|
318
|
+
return cloned
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// IsEmptyValue 判断必填字段是否为空。
|
|
322
|
+
func IsEmptyValue(value any) bool {
|
|
323
|
+
if value == nil {
|
|
324
|
+
return true
|
|
325
|
+
}
|
|
326
|
+
text, ok := value.(string)
|
|
327
|
+
return ok && strings.TrimSpace(text) == ""
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
func validateFieldDefinition(field Field) error {
|
|
331
|
+
switch field.ValueType {
|
|
332
|
+
case ValueTypeString, ValueTypeBoolean, ValueTypeInteger, ValueTypeJSON:
|
|
333
|
+
default:
|
|
334
|
+
return fmt.Errorf("unsupported value type %q", field.ValueType)
|
|
335
|
+
}
|
|
336
|
+
if field.Validation.MinLength != nil && *field.Validation.MinLength < 0 {
|
|
337
|
+
return fmt.Errorf("min_length must be non-negative")
|
|
338
|
+
}
|
|
339
|
+
if field.Validation.MaxLength != nil && *field.Validation.MaxLength < 0 {
|
|
340
|
+
return fmt.Errorf("max_length must be non-negative")
|
|
341
|
+
}
|
|
342
|
+
if field.Validation.MinLength != nil && field.Validation.MaxLength != nil && *field.Validation.MinLength > *field.Validation.MaxLength {
|
|
343
|
+
return fmt.Errorf("min_length must not exceed max_length")
|
|
344
|
+
}
|
|
345
|
+
if field.Validation.MinValue != nil && field.Validation.MaxValue != nil && *field.Validation.MinValue > *field.Validation.MaxValue {
|
|
346
|
+
return fmt.Errorf("min_value must not exceed max_value")
|
|
347
|
+
}
|
|
348
|
+
if field.Validation.Pattern != "" {
|
|
349
|
+
if _, err := regexp.Compile(field.Validation.Pattern); err != nil {
|
|
350
|
+
return fmt.Errorf("compile pattern: %w", err)
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
switch field.Validation.Format {
|
|
354
|
+
case "", ValidationFormatURL, ValidationFormatDuration, ValidationFormatPEM, ValidationFormatBase64, ValidationFormatE164:
|
|
355
|
+
default:
|
|
356
|
+
return fmt.Errorf("unsupported validation format %q", field.Validation.Format)
|
|
357
|
+
}
|
|
358
|
+
if field.ValueType != ValueTypeString &&
|
|
359
|
+
(field.Validation.Format != "" || field.Validation.Pattern != "" || field.Validation.MinLength != nil || field.Validation.MaxLength != nil || len(field.Validation.AllowedValues) > 0) {
|
|
360
|
+
return fmt.Errorf("string validation requires string value type")
|
|
361
|
+
}
|
|
362
|
+
if field.ValueType != ValueTypeInteger && (field.Validation.MinValue != nil || field.Validation.MaxValue != nil) {
|
|
363
|
+
return fmt.Errorf("numeric validation requires integer value type")
|
|
364
|
+
}
|
|
365
|
+
if field.Secret && field.ValueType != ValueTypeString && field.ValueType != ValueTypeJSON {
|
|
366
|
+
return fmt.Errorf("secret fields require string or json value type")
|
|
367
|
+
}
|
|
368
|
+
if len(field.Validation.RequiredJSONKeys) > 0 && field.ValueType != ValueTypeJSON {
|
|
369
|
+
return fmt.Errorf("required_json_keys requires json value type")
|
|
370
|
+
}
|
|
371
|
+
if err := validateUniqueStrings(field.Validation.AllowedValues, "allowed value"); err != nil {
|
|
372
|
+
return err
|
|
373
|
+
}
|
|
374
|
+
if err := validateUniqueStrings(field.Validation.RequiredJSONKeys, "required JSON key"); err != nil {
|
|
375
|
+
return err
|
|
376
|
+
}
|
|
377
|
+
return nil
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
func validateFieldValue(field Field, value any) error {
|
|
381
|
+
var text string
|
|
382
|
+
switch field.ValueType {
|
|
383
|
+
case ValueTypeString:
|
|
384
|
+
typed, ok := value.(string)
|
|
385
|
+
if !ok {
|
|
386
|
+
return fmt.Errorf("must be a string")
|
|
387
|
+
}
|
|
388
|
+
text = strings.TrimSpace(typed)
|
|
389
|
+
case ValueTypeBoolean:
|
|
390
|
+
if _, ok := value.(bool); !ok {
|
|
391
|
+
return fmt.Errorf("must be a boolean")
|
|
392
|
+
}
|
|
393
|
+
return nil
|
|
394
|
+
case ValueTypeInteger:
|
|
395
|
+
number, err := integerValue(value)
|
|
396
|
+
if err != nil {
|
|
397
|
+
return err
|
|
398
|
+
}
|
|
399
|
+
if field.Validation.MinValue != nil && number < *field.Validation.MinValue {
|
|
400
|
+
return fmt.Errorf("must be at least %d", *field.Validation.MinValue)
|
|
401
|
+
}
|
|
402
|
+
if field.Validation.MaxValue != nil && number > *field.Validation.MaxValue {
|
|
403
|
+
return fmt.Errorf("must be at most %d", *field.Validation.MaxValue)
|
|
404
|
+
}
|
|
405
|
+
return nil
|
|
406
|
+
case ValueTypeJSON:
|
|
407
|
+
if value == nil {
|
|
408
|
+
return fmt.Errorf("must contain valid JSON")
|
|
409
|
+
}
|
|
410
|
+
if len(field.Validation.RequiredJSONKeys) > 0 {
|
|
411
|
+
object, ok := value.(map[string]any)
|
|
412
|
+
if !ok {
|
|
413
|
+
return fmt.Errorf("must contain a JSON object")
|
|
414
|
+
}
|
|
415
|
+
for _, key := range field.Validation.RequiredJSONKeys {
|
|
416
|
+
nested, exists := object[key]
|
|
417
|
+
if !exists || IsEmptyValue(nested) {
|
|
418
|
+
return fmt.Errorf("must contain required JSON key %q", key)
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return nil
|
|
423
|
+
default:
|
|
424
|
+
return fmt.Errorf("uses unsupported value type %q", field.ValueType)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
length := utf8.RuneCountInString(text)
|
|
428
|
+
if field.Validation.MinLength != nil && length < *field.Validation.MinLength {
|
|
429
|
+
return fmt.Errorf("length must be at least %d", *field.Validation.MinLength)
|
|
430
|
+
}
|
|
431
|
+
if field.Validation.MaxLength != nil && length > *field.Validation.MaxLength {
|
|
432
|
+
return fmt.Errorf("length must be at most %d", *field.Validation.MaxLength)
|
|
433
|
+
}
|
|
434
|
+
if len(field.Validation.AllowedValues) > 0 && !containsString(field.Validation.AllowedValues, text) {
|
|
435
|
+
return fmt.Errorf("must be one of the allowed values")
|
|
436
|
+
}
|
|
437
|
+
if field.Validation.Pattern != "" && !regexp.MustCompile(field.Validation.Pattern).MatchString(text) {
|
|
438
|
+
return fmt.Errorf("does not match the required pattern")
|
|
439
|
+
}
|
|
440
|
+
switch field.Validation.Format {
|
|
441
|
+
case "":
|
|
442
|
+
return nil
|
|
443
|
+
case ValidationFormatURL:
|
|
444
|
+
parsed, err := url.ParseRequestURI(text)
|
|
445
|
+
if err != nil || parsed.Host == "" || (parsed.Scheme != "http" && parsed.Scheme != "https") {
|
|
446
|
+
return fmt.Errorf("must be an absolute HTTP URL")
|
|
447
|
+
}
|
|
448
|
+
case ValidationFormatDuration:
|
|
449
|
+
duration, err := time.ParseDuration(text)
|
|
450
|
+
if err != nil || duration <= 0 {
|
|
451
|
+
return fmt.Errorf("must be a positive Go duration")
|
|
452
|
+
}
|
|
453
|
+
case ValidationFormatPEM:
|
|
454
|
+
if _, err := corecrypto.NormalizePEM(text); err != nil {
|
|
455
|
+
return err
|
|
456
|
+
}
|
|
457
|
+
case ValidationFormatBase64:
|
|
458
|
+
if _, err := base64.StdEncoding.DecodeString(text); err != nil {
|
|
459
|
+
return fmt.Errorf("must be standard base64")
|
|
460
|
+
}
|
|
461
|
+
case ValidationFormatE164:
|
|
462
|
+
if !regexp.MustCompile(`^\+[1-9][0-9]{7,14}$`).MatchString(text) {
|
|
463
|
+
return fmt.Errorf("must be an E.164 phone number")
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return nil
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
func integerValue(value any) (int64, error) {
|
|
470
|
+
switch typed := value.(type) {
|
|
471
|
+
case json.Number:
|
|
472
|
+
parsed, err := typed.Int64()
|
|
473
|
+
if err != nil {
|
|
474
|
+
return 0, fmt.Errorf("must be an integer")
|
|
475
|
+
}
|
|
476
|
+
return parsed, nil
|
|
477
|
+
case float64:
|
|
478
|
+
if typed != float64(int64(typed)) {
|
|
479
|
+
return 0, fmt.Errorf("must be an integer")
|
|
480
|
+
}
|
|
481
|
+
return int64(typed), nil
|
|
482
|
+
default:
|
|
483
|
+
return 0, fmt.Errorf("must be an integer")
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
func normalizeConfigurationValue(field Field, value any) (any, error) {
|
|
488
|
+
switch field.ValueType {
|
|
489
|
+
case ValueTypeString:
|
|
490
|
+
text, ok := value.(string)
|
|
491
|
+
if !ok {
|
|
492
|
+
return value, nil
|
|
493
|
+
}
|
|
494
|
+
if field.Validation.Format == ValidationFormatPEM {
|
|
495
|
+
return corecrypto.NormalizePEM(text)
|
|
496
|
+
}
|
|
497
|
+
return strings.TrimSpace(text), nil
|
|
498
|
+
case ValueTypeJSON:
|
|
499
|
+
text, ok := value.(string)
|
|
500
|
+
if !ok {
|
|
501
|
+
return value, nil
|
|
502
|
+
}
|
|
503
|
+
return decodeJSONValue(text)
|
|
504
|
+
default:
|
|
505
|
+
return value, nil
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
func normalizeSecretValue(field Field, value string) (string, error) {
|
|
510
|
+
if field.ValueType != ValueTypeJSON {
|
|
511
|
+
if field.Validation.Format == ValidationFormatPEM {
|
|
512
|
+
return corecrypto.NormalizePEM(value)
|
|
513
|
+
}
|
|
514
|
+
return strings.TrimSpace(value), nil
|
|
515
|
+
}
|
|
516
|
+
parsed, err := decodeJSONValue(value)
|
|
517
|
+
if err != nil {
|
|
518
|
+
return "", err
|
|
519
|
+
}
|
|
520
|
+
encoded, err := json.Marshal(parsed)
|
|
521
|
+
if err != nil {
|
|
522
|
+
return "", fmt.Errorf("must contain valid JSON")
|
|
523
|
+
}
|
|
524
|
+
return string(encoded), nil
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
func decodeJSONValue(value string) (any, error) {
|
|
528
|
+
decoder := json.NewDecoder(strings.NewReader(value))
|
|
529
|
+
decoder.UseNumber()
|
|
530
|
+
var parsed any
|
|
531
|
+
if err := decoder.Decode(&parsed); err != nil {
|
|
532
|
+
return nil, fmt.Errorf("must contain valid JSON")
|
|
533
|
+
}
|
|
534
|
+
if err := decoder.Decode(&struct{}{}); err != io.EOF {
|
|
535
|
+
return nil, fmt.Errorf("must contain one JSON value")
|
|
536
|
+
}
|
|
537
|
+
return parsed, nil
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
func inputError(source InputSource, field, problem string) error {
|
|
541
|
+
return &InputError{Source: source, Field: field, Problem: problem}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
func containsString(values []string, target string) bool {
|
|
545
|
+
for _, value := range values {
|
|
546
|
+
if value == target {
|
|
547
|
+
return true
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return false
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
func validateUniqueStrings(values []string, label string) error {
|
|
554
|
+
seen := make(map[string]struct{}, len(values))
|
|
555
|
+
for _, value := range values {
|
|
556
|
+
if strings.TrimSpace(value) == "" {
|
|
557
|
+
return fmt.Errorf("%s must not be empty", label)
|
|
558
|
+
}
|
|
559
|
+
if value != strings.TrimSpace(value) {
|
|
560
|
+
return fmt.Errorf("%s %q must be canonical", label, value)
|
|
561
|
+
}
|
|
562
|
+
if _, exists := seen[value]; exists {
|
|
563
|
+
return fmt.Errorf("duplicate %s %q", label, value)
|
|
564
|
+
}
|
|
565
|
+
seen[value] = struct{}{}
|
|
566
|
+
}
|
|
567
|
+
return nil
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
func sortedMapKeys[V any](values map[string]V) []string {
|
|
571
|
+
keys := make([]string, 0, len(values))
|
|
572
|
+
for key := range values {
|
|
573
|
+
keys = append(keys, key)
|
|
574
|
+
}
|
|
575
|
+
sort.Strings(keys)
|
|
576
|
+
return keys
|
|
577
|
+
}
|