@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,77 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"strings"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// ═══════════════════════════════════════════════════════════════
|
|
9
|
+
// IAM 授权内核 — 动作(Action)拼装、解析与模式匹配
|
|
10
|
+
// ═══════════════════════════════════════════════════════════════
|
|
11
|
+
//
|
|
12
|
+
// 动作格式(3 段):<domain>:<resource>:<verb>,例 order:refund:approve。
|
|
13
|
+
// verb 取值见 enum.go Verb 规范集合。
|
|
14
|
+
// 模式匹配语义:按 ':' 段边界比较,'*' 仅匹配本段,整体 '*' 匹配一切动作。
|
|
15
|
+
// order:refund:* 命中 order:refund:approve / order:refund:read …
|
|
16
|
+
// order:*:* 命中 order 域全部动作
|
|
17
|
+
// * 命中任意动作(管理面 super 语义)
|
|
18
|
+
|
|
19
|
+
// actionSegments 动作以 ':' 切分后的段数(domain + resource + verb)。
|
|
20
|
+
const actionSegments = 3
|
|
21
|
+
|
|
22
|
+
// actionWildcardAll 整体通配(匹配任意动作)。
|
|
23
|
+
const actionWildcardAll = "*"
|
|
24
|
+
|
|
25
|
+
// BuildAction 动作唯一拼装入口(N2 owner helper)。
|
|
26
|
+
//
|
|
27
|
+
// 调用方禁止自行 fmt.Sprintf 拼装动作串,统一经此函数保证三段格式一致。
|
|
28
|
+
func BuildAction(domainCode, resourceType string, verb Verb) string {
|
|
29
|
+
return fmt.Sprintf("%s:%s:%s", domainCode, resourceType, verb)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ParseAction 解析规范动作 <domain>:<resource>:<verb>,非法时返回包装 ErrInvalidAction 的错误。
|
|
33
|
+
//
|
|
34
|
+
// 校验项:冒号切分须恰为 3 段且各段非空;verb 须在规范动词集合内(enum.go AllVerbs)。
|
|
35
|
+
func ParseAction(s string) (domainCode, resourceType string, verb Verb, err error) {
|
|
36
|
+
parts := strings.Split(s, ":")
|
|
37
|
+
if len(parts) != actionSegments {
|
|
38
|
+
return "", "", "", fmt.Errorf("%w: expected %d segments, got %d in %q",
|
|
39
|
+
ErrInvalidAction, actionSegments, len(parts), s)
|
|
40
|
+
}
|
|
41
|
+
if parts[0] == "" || parts[1] == "" || parts[2] == "" {
|
|
42
|
+
return "", "", "", fmt.Errorf("%w: empty segment in %q", ErrInvalidAction, s)
|
|
43
|
+
}
|
|
44
|
+
v := Verb(parts[2])
|
|
45
|
+
if !v.IsValid() {
|
|
46
|
+
return "", "", "", fmt.Errorf("%w: unknown verb %q in %q", ErrInvalidAction, parts[2], s)
|
|
47
|
+
}
|
|
48
|
+
return parts[0], parts[1], v, nil
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// MatchesActionPattern 动作模式匹配:pattern 是否匹配具体 action。
|
|
52
|
+
//
|
|
53
|
+
// 规则:
|
|
54
|
+
// - pattern 为 '*':匹配任意动作(整体通配);
|
|
55
|
+
// - 否则按 ':' 切为 3 段逐段比较,段为 '*' 匹配本段任意值,其余要求字面相等。
|
|
56
|
+
//
|
|
57
|
+
// pattern 与 action 段数须均为 3('*' 整体通配除外),否则不匹配(fail-safe)。
|
|
58
|
+
// 不在此处强校验 verb 是否规范——模式匹配只做字面段比较,规范性由 catalog 写入时保证。
|
|
59
|
+
func MatchesActionPattern(pattern, action string) bool {
|
|
60
|
+
if pattern == actionWildcardAll {
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
63
|
+
pa := strings.Split(pattern, ":")
|
|
64
|
+
ac := strings.Split(action, ":")
|
|
65
|
+
if len(pa) != actionSegments || len(ac) != actionSegments {
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
for i := range pa {
|
|
69
|
+
if pa[i] == segWildcard {
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
if pa[i] != ac[i] {
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"errors"
|
|
5
|
+
"slices"
|
|
6
|
+
"testing"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// TestBuildParseActionRoundTrip 校验 Build → Parse 往返一致性。
|
|
10
|
+
func TestBuildParseActionRoundTrip(t *testing.T) {
|
|
11
|
+
cases := []struct {
|
|
12
|
+
name string
|
|
13
|
+
domain string
|
|
14
|
+
resourceType string
|
|
15
|
+
verb Verb
|
|
16
|
+
wantAction string
|
|
17
|
+
}{
|
|
18
|
+
{
|
|
19
|
+
name: "order refund approve",
|
|
20
|
+
domain: "order",
|
|
21
|
+
resourceType: "refund",
|
|
22
|
+
verb: VerbApprove,
|
|
23
|
+
wantAction: "order:refund:approve",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "catalog product read",
|
|
27
|
+
domain: "catalog",
|
|
28
|
+
resourceType: "product",
|
|
29
|
+
verb: VerbRead,
|
|
30
|
+
wantAction: "catalog:product:read",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "iam policy publish",
|
|
34
|
+
domain: "iam",
|
|
35
|
+
resourceType: "policy",
|
|
36
|
+
verb: VerbPublish,
|
|
37
|
+
wantAction: "iam:policy:publish",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "secret lease replace",
|
|
41
|
+
domain: "secret",
|
|
42
|
+
resourceType: "lease",
|
|
43
|
+
verb: VerbReplace,
|
|
44
|
+
wantAction: "secret:lease:replace",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "secret lease redeem",
|
|
48
|
+
domain: "secret",
|
|
49
|
+
resourceType: "lease",
|
|
50
|
+
verb: VerbRedeem,
|
|
51
|
+
wantAction: "secret:lease:redeem",
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
for _, tc := range cases {
|
|
55
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
56
|
+
action := BuildAction(tc.domain, tc.resourceType, tc.verb)
|
|
57
|
+
if action != tc.wantAction {
|
|
58
|
+
t.Fatalf("BuildAction = %q, want %q", action, tc.wantAction)
|
|
59
|
+
}
|
|
60
|
+
gotDomain, gotResource, gotVerb, err := ParseAction(action)
|
|
61
|
+
if err != nil {
|
|
62
|
+
t.Fatalf("ParseAction(%q) unexpected error: %v", action, err)
|
|
63
|
+
}
|
|
64
|
+
if gotDomain != tc.domain || gotResource != tc.resourceType || gotVerb != tc.verb {
|
|
65
|
+
t.Fatalf("ParseAction(%q) = (%q, %q, %q), want (%q, %q, %q)",
|
|
66
|
+
action, gotDomain, gotResource, gotVerb, tc.domain, tc.resourceType, tc.verb)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// TestAllVerbsCanonicalSet 锁定规范动词全集,防止扩展 Secret 动作时丢失既有动作或引入重复值。
|
|
73
|
+
func TestAllVerbsCanonicalSet(t *testing.T) {
|
|
74
|
+
want := []Verb{
|
|
75
|
+
VerbList, VerbRead, VerbCreate, VerbUpdate, VerbDelete, VerbManage, VerbExport,
|
|
76
|
+
VerbApprove, VerbReject, VerbRefund, VerbPublish, VerbRollback, VerbConfigure,
|
|
77
|
+
VerbImpersonate, VerbRun, VerbRecover, VerbReplay, VerbRotate, VerbRevoke,
|
|
78
|
+
VerbGrant, VerbAssign, VerbClose, VerbModerate, VerbBind, VerbAdjust,
|
|
79
|
+
VerbCancel, VerbErase, VerbSuspend, VerbVerify, VerbReplace, VerbRedeem,
|
|
80
|
+
}
|
|
81
|
+
got := AllVerbs()
|
|
82
|
+
if !slices.Equal(got, want) {
|
|
83
|
+
t.Fatalf("AllVerbs() = %v, want %v", got, want)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
seen := make(map[Verb]struct{}, len(got))
|
|
87
|
+
for _, verb := range got {
|
|
88
|
+
if _, exists := seen[verb]; exists {
|
|
89
|
+
t.Fatalf("AllVerbs() contains duplicate verb %q", verb)
|
|
90
|
+
}
|
|
91
|
+
seen[verb] = struct{}{}
|
|
92
|
+
if !verb.IsValid() {
|
|
93
|
+
t.Fatalf("AllVerbs() contains invalid verb %q", verb)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// TestParseDesignedSecretActions 校验 SecretBroker 已设计动作全部使用规范三段动作和封闭动词。
|
|
99
|
+
func TestParseDesignedSecretActions(t *testing.T) {
|
|
100
|
+
testCases := []struct {
|
|
101
|
+
action string
|
|
102
|
+
resourceType string
|
|
103
|
+
verb Verb
|
|
104
|
+
}{
|
|
105
|
+
{action: "secret:secret:create", resourceType: "secret", verb: VerbCreate},
|
|
106
|
+
{action: "secret:secret:read", resourceType: "secret", verb: VerbRead},
|
|
107
|
+
{action: "secret:version:rotate", resourceType: "version", verb: VerbRotate},
|
|
108
|
+
{action: "secret:secret:revoke", resourceType: "secret", verb: VerbRevoke},
|
|
109
|
+
{action: "secret:version:revoke", resourceType: "version", verb: VerbRevoke},
|
|
110
|
+
{action: "secret:secret:delete", resourceType: "secret", verb: VerbDelete},
|
|
111
|
+
{action: "secret:lease:create", resourceType: "lease", verb: VerbCreate},
|
|
112
|
+
{action: "secret:lease:replace", resourceType: "lease", verb: VerbReplace},
|
|
113
|
+
{action: "secret:lease:redeem", resourceType: "lease", verb: VerbRedeem},
|
|
114
|
+
{action: "secret:access-event:list", resourceType: "access-event", verb: VerbList},
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
for _, testCase := range testCases {
|
|
118
|
+
t.Run(testCase.action, func(t *testing.T) {
|
|
119
|
+
domainCode, resourceType, verb, err := ParseAction(testCase.action)
|
|
120
|
+
if err != nil {
|
|
121
|
+
t.Fatalf("ParseAction(%q) unexpected error: %v", testCase.action, err)
|
|
122
|
+
}
|
|
123
|
+
if domainCode != "secret" || resourceType != testCase.resourceType || verb != testCase.verb {
|
|
124
|
+
t.Fatalf(
|
|
125
|
+
"ParseAction(%q) = (%q, %q, %q), want (%q, %q, %q)",
|
|
126
|
+
testCase.action,
|
|
127
|
+
domainCode,
|
|
128
|
+
resourceType,
|
|
129
|
+
verb,
|
|
130
|
+
"secret",
|
|
131
|
+
testCase.resourceType,
|
|
132
|
+
testCase.verb,
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// TestParseActionInvalid 校验非法动作均返回包装 ErrInvalidAction 的错误。
|
|
140
|
+
func TestParseActionInvalid(t *testing.T) {
|
|
141
|
+
cases := []struct {
|
|
142
|
+
name string
|
|
143
|
+
action string
|
|
144
|
+
}{
|
|
145
|
+
{name: "too few segments", action: "order:refund"},
|
|
146
|
+
{name: "too many segments", action: "order:refund:approve:extra"},
|
|
147
|
+
{name: "empty domain segment", action: ":refund:approve"},
|
|
148
|
+
{name: "empty verb segment", action: "order:refund:"},
|
|
149
|
+
{name: "unknown verb", action: "order:refund:frobnicate"},
|
|
150
|
+
{name: "unknown secret lease verb", action: "secret:lease:consume"},
|
|
151
|
+
{name: "access operation is not an IAM verb", action: "secret:lease:issue_lease"},
|
|
152
|
+
{name: "wildcard is not a concrete verb", action: "secret:lease:*"},
|
|
153
|
+
{name: "empty string", action: ""},
|
|
154
|
+
}
|
|
155
|
+
for _, tc := range cases {
|
|
156
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
157
|
+
_, _, _, err := ParseAction(tc.action)
|
|
158
|
+
if err == nil {
|
|
159
|
+
t.Fatalf("ParseAction(%q) expected error, got nil", tc.action)
|
|
160
|
+
}
|
|
161
|
+
if !errors.Is(err, ErrInvalidAction) {
|
|
162
|
+
t.Fatalf("ParseAction(%q) error = %v, want errors.Is ErrInvalidAction", tc.action, err)
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// TestMatchesActionPattern 校验动作模式匹配各档:精确 / verb 通配 / resource+verb 通配 / 全局 / 不匹配 / 非法段数。
|
|
169
|
+
func TestMatchesActionPattern(t *testing.T) {
|
|
170
|
+
cases := []struct {
|
|
171
|
+
name string
|
|
172
|
+
pattern string
|
|
173
|
+
action string
|
|
174
|
+
want bool
|
|
175
|
+
}{
|
|
176
|
+
{
|
|
177
|
+
name: "exact match",
|
|
178
|
+
pattern: "order:refund:approve",
|
|
179
|
+
action: "order:refund:approve",
|
|
180
|
+
want: true,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "verb wildcard hits same domain resource",
|
|
184
|
+
pattern: "order:refund:*",
|
|
185
|
+
action: "order:refund:read",
|
|
186
|
+
want: true,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "verb wildcard misses different resource",
|
|
190
|
+
pattern: "order:refund:*",
|
|
191
|
+
action: "order:shipment:read",
|
|
192
|
+
want: false,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "resource and verb wildcard hits whole domain",
|
|
196
|
+
pattern: "order:*:*",
|
|
197
|
+
action: "order:refund:approve",
|
|
198
|
+
want: true,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "resource and verb wildcard misses other domain",
|
|
202
|
+
pattern: "order:*:*",
|
|
203
|
+
action: "catalog:product:read",
|
|
204
|
+
want: false,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "global wildcard matches any action",
|
|
208
|
+
pattern: "*",
|
|
209
|
+
action: "iam:policy:publish",
|
|
210
|
+
want: true,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "literal mismatch on domain",
|
|
214
|
+
pattern: "order:refund:approve",
|
|
215
|
+
action: "catalog:refund:approve",
|
|
216
|
+
want: false,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "pattern wrong segment count fails safe",
|
|
220
|
+
pattern: "order:refund",
|
|
221
|
+
action: "order:refund:approve",
|
|
222
|
+
want: false,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "action wrong segment count fails safe",
|
|
226
|
+
pattern: "order:refund:approve",
|
|
227
|
+
action: "order:refund",
|
|
228
|
+
want: false,
|
|
229
|
+
},
|
|
230
|
+
}
|
|
231
|
+
for _, tc := range cases {
|
|
232
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
233
|
+
if got := MatchesActionPattern(tc.pattern, tc.action); got != tc.want {
|
|
234
|
+
t.Fatalf("MatchesActionPattern(%q, %q) = %v, want %v", tc.pattern, tc.action, got, tc.want)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════
|
|
4
|
+
// IAM 授权内核 — 策略条件词汇(13 condition 族)
|
|
5
|
+
// ═══════════════════════════════════════════════════════════════
|
|
6
|
+
//
|
|
7
|
+
// 条件语义(设计文档 §5.5):同一语句内多个 condition 取 AND;
|
|
8
|
+
// 同一 condition key 多值取 OR;跨条件 OR 须拆成多条 statement(不自创 OR 算子)。
|
|
9
|
+
// 求值(Condition 对 AdminAccessContext 的匹配)在 application 层 evaluator 实现,
|
|
10
|
+
// 本文件只定义条件的词汇与数据结构。
|
|
11
|
+
|
|
12
|
+
// ConditionFamily 条件族。
|
|
13
|
+
type ConditionFamily string
|
|
14
|
+
|
|
15
|
+
const (
|
|
16
|
+
// ConditionFamilyString 字符串(equals/not_equals/in/starts_with)
|
|
17
|
+
ConditionFamilyString ConditionFamily = "string"
|
|
18
|
+
// ConditionFamilyBoolean 布尔(is_true/is_false:MFA 在场、break-glass 会话)
|
|
19
|
+
ConditionFamilyBoolean ConditionFamily = "boolean"
|
|
20
|
+
// ConditionFamilyNumeric 数值(lt/lte/gt/gte/between:退款金额、导出行数)
|
|
21
|
+
ConditionFamilyNumeric ConditionFamily = "numeric"
|
|
22
|
+
// ConditionFamilyTime 时间(before/after/between/business_hours:访问时段)
|
|
23
|
+
ConditionFamilyTime ConditionFamily = "time"
|
|
24
|
+
// ConditionFamilyCIDR 网段(ip_in/ip_not_in:办公网允许列表)
|
|
25
|
+
ConditionFamilyCIDR ConditionFamily = "cidr"
|
|
26
|
+
// ConditionFamilyOwnership 主体归属(same_product/same_merchant/same_tenant/same_agent)
|
|
27
|
+
ConditionFamilyOwnership ConditionFamily = "ownership"
|
|
28
|
+
// ConditionFamilyCapability 能力位(has_capability/lacks_capability)
|
|
29
|
+
ConditionFamilyCapability ConditionFamily = "capability"
|
|
30
|
+
// ConditionFamilyState 资源状态(status_in/approval_state_in:已支付订单、草稿陈列)
|
|
31
|
+
ConditionFamilyState ConditionFamily = "state"
|
|
32
|
+
// ConditionFamilySensitivity 敏感度(max_sensitivity:PII 与财务字段)
|
|
33
|
+
ConditionFamilySensitivity ConditionFamily = "sensitivity"
|
|
34
|
+
// ConditionFamilyFacility 设施(facility_in/store_in/kitchen_in/warehouse_in/zone_in)
|
|
35
|
+
ConditionFamilyFacility ConditionFamily = "facility"
|
|
36
|
+
// ConditionFamilyAssignment 归属关系(assigned_to_self/created_by_self/same_owner)
|
|
37
|
+
ConditionFamilyAssignment ConditionFamily = "assignment"
|
|
38
|
+
// ConditionFamilyGeo 地理(region_in/country_in/locale_in/area_in)
|
|
39
|
+
ConditionFamilyGeo ConditionFamily = "geo"
|
|
40
|
+
// ConditionFamilyChannelEnv 渠道与环境(channel_in/environment_in)
|
|
41
|
+
ConditionFamilyChannelEnv ConditionFamily = "channel_env"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
// allConditionFamilies 全部 14 个条件族(与 register_iam.go 注册集合一致)。
|
|
45
|
+
var allConditionFamilies = []ConditionFamily{
|
|
46
|
+
ConditionFamilyString, ConditionFamilyBoolean, ConditionFamilyNumeric, ConditionFamilyTime,
|
|
47
|
+
ConditionFamilyCIDR, ConditionFamilyOwnership, ConditionFamilyCapability, ConditionFamilyState,
|
|
48
|
+
ConditionFamilySensitivity, ConditionFamilyFacility, ConditionFamilyAssignment, ConditionFamilyGeo,
|
|
49
|
+
ConditionFamilyChannelEnv,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// AllConditionFamilies 返回全部条件族副本。
|
|
53
|
+
func AllConditionFamilies() []ConditionFamily {
|
|
54
|
+
out := make([]ConditionFamily, len(allConditionFamilies))
|
|
55
|
+
copy(out, allConditionFamilies)
|
|
56
|
+
return out
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// IsValid 校验条件族是否合法。
|
|
60
|
+
func (f ConditionFamily) IsValid() bool {
|
|
61
|
+
for _, item := range allConditionFamilies {
|
|
62
|
+
if item == f {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// IsScopeDimension 判断条件族是否为「资源行级范围维度」(facility/assignment/ownership)。
|
|
70
|
+
//
|
|
71
|
+
// 这三族表达资源归属(资源属哪个设施 / 派给谁 / 属哪个商户租户代理产品),其求值依赖具体资源行的
|
|
72
|
+
// 属性。两阶段授权(设计 §6.4)下,这类维度由 ResolveScope 下推为 WHERE 列谓词、EvaluateMany 逐行
|
|
73
|
+
// 复判;集合动作(list / 聚合)的 action 级检查无单一资源可判,故延迟这类条件至 ResolveScope。
|
|
74
|
+
// 与 effective_access_service.go 的可下推分类(classifyCondition 仅 facility/assignment/ownership
|
|
75
|
+
// 进 ScopeConstraint)同源,避免两处分类漂移(SH-E6 单一真相源思想)。
|
|
76
|
+
//
|
|
77
|
+
// 非范围维度(time/cidr/boolean/string/numeric/state/sensitivity/...)不依赖资源归属行,集合动作
|
|
78
|
+
// 的 action 级检查仍恒应用(如「仅营业时段」「仅办公网」对 list 同样生效),不予延迟。
|
|
79
|
+
func (f ConditionFamily) IsScopeDimension() bool {
|
|
80
|
+
switch f {
|
|
81
|
+
case ConditionFamilyFacility, ConditionFamilyAssignment, ConditionFamilyOwnership:
|
|
82
|
+
return true
|
|
83
|
+
default:
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Condition 策略语句中的单条条件。
|
|
89
|
+
//
|
|
90
|
+
// Operator 为族内算子(如 in/starts_with/status_in/facility_in/assigned_to_self),
|
|
91
|
+
// 其完整算子集由 evaluator 在求值时校验与执行;Key 为上下文属性键;
|
|
92
|
+
// Values 为候选值集合(多值取 OR),布尔/self 类算子可为空。
|
|
93
|
+
type Condition struct {
|
|
94
|
+
// 条件族
|
|
95
|
+
Family ConditionFamily `json:"family"`
|
|
96
|
+
// 族内算子
|
|
97
|
+
Operator string `json:"operator"`
|
|
98
|
+
// 上下文属性键
|
|
99
|
+
Key string `json:"key,omitempty"`
|
|
100
|
+
// 候选值集合(多值取 OR)
|
|
101
|
+
Values []string `json:"values,omitempty"`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// HasValues 是否携带候选值(布尔 / self 类算子无值)。
|
|
105
|
+
func (c Condition) HasValues() bool {
|
|
106
|
+
return len(c.Values) > 0
|
|
107
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
package domain
|
|
2
|
+
|
|
3
|
+
import "time"
|
|
4
|
+
|
|
5
|
+
// ═══════════════════════════════════════════════════════════════
|
|
6
|
+
// IAM 授权内核 — 求值上下文与决策值对象(设计文档 §7.2 / §7.4)
|
|
7
|
+
// ═══════════════════════════════════════════════════════════════
|
|
8
|
+
//
|
|
9
|
+
// AdminAccessContext 是单资源求值的完整上下文快照(condition 求值的属性来源,§5.5);
|
|
10
|
+
// Decision 是求值产出的值对象(不落库,投影到 DecisionLog 时映射,见 model.go)。
|
|
11
|
+
// 这些类型为值对象,不嵌 BaseModel、不持久化。
|
|
12
|
+
|
|
13
|
+
// PrincipalContext 主体维度上下文(who)。
|
|
14
|
+
//
|
|
15
|
+
// DelegatedBy 非空表示当前为扮演 / 提权会话(assumed_role)。
|
|
16
|
+
type PrincipalContext struct {
|
|
17
|
+
// 主体 ID
|
|
18
|
+
PrincipalID int64
|
|
19
|
+
// 不可变主体公共引用
|
|
20
|
+
PrincipalRef string
|
|
21
|
+
// 主体类型(见 enum.go PrincipalType)
|
|
22
|
+
PrincipalType string
|
|
23
|
+
// 关联身份 ID(人类主体)
|
|
24
|
+
IdentityID *int64
|
|
25
|
+
// 当前请求是否已通过 MFA(boolean condition 输入)
|
|
26
|
+
MFAPresent bool
|
|
27
|
+
// 来源 IP(cidr condition 输入)
|
|
28
|
+
SourceIP string
|
|
29
|
+
// 登录方式
|
|
30
|
+
LoginMethod string
|
|
31
|
+
// 设备信任等级
|
|
32
|
+
DeviceTrustLevel string
|
|
33
|
+
// 授权来源主体 ID(扮演 / 提权时的委派人)
|
|
34
|
+
DelegatedBy *int64
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// WorkspaceContext 工作区维度上下文(在哪个产品 / 隔离边界下操作)。
|
|
38
|
+
type WorkspaceContext struct {
|
|
39
|
+
// 工作区类型
|
|
40
|
+
WorkspaceType string
|
|
41
|
+
// 产品编码
|
|
42
|
+
ProductCode string
|
|
43
|
+
// 组织公共引用。
|
|
44
|
+
OrganizationRef string
|
|
45
|
+
// 工作区公共引用。
|
|
46
|
+
WorkspaceRef string
|
|
47
|
+
// 商户编码(隔离维度)
|
|
48
|
+
MerchantCode string
|
|
49
|
+
// 租户 ID(隔离维度)
|
|
50
|
+
TenantID *int64
|
|
51
|
+
// 代理编码
|
|
52
|
+
AgentCode string
|
|
53
|
+
// 设施 ID(门店 / 厨房 / 仓库 / 配送区,隔离维度)
|
|
54
|
+
FacilityID string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// RequestContext 请求维度上下文(when / how)。
|
|
58
|
+
type RequestContext struct {
|
|
59
|
+
// 请求 ID
|
|
60
|
+
RequestID string
|
|
61
|
+
// 调用方提供的命令幂等键
|
|
62
|
+
IdempotencyKey string
|
|
63
|
+
// 客户端 User-Agent
|
|
64
|
+
UserAgent string
|
|
65
|
+
// 路由名
|
|
66
|
+
RouteName string
|
|
67
|
+
// HTTP 方法
|
|
68
|
+
Method string
|
|
69
|
+
// 被求值的规范动作全名
|
|
70
|
+
Action string
|
|
71
|
+
// 来源 IP
|
|
72
|
+
SourceIP string
|
|
73
|
+
// 请求时刻(time / business_hours condition 输入)
|
|
74
|
+
RequestedAt time.Time
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ResourceContext 资源维度上下文(被操作资源的属性快照,state / sensitivity / assignment condition 输入)。
|
|
78
|
+
//
|
|
79
|
+
// 业务状态(Status/ApprovalState)仅作为 condition 输入,IAM 不含 state_forbidden(§7.3);
|
|
80
|
+
// 授权后的状态机校验由域 service 负责(返回 409/422)。
|
|
81
|
+
type ResourceContext struct {
|
|
82
|
+
// 资源 ARN
|
|
83
|
+
ARN string
|
|
84
|
+
// 资源归属作用域值
|
|
85
|
+
OwnerScope string
|
|
86
|
+
// 资源业务状态(state 族 status_in 输入)
|
|
87
|
+
Status string
|
|
88
|
+
// 资源敏感度(sensitivity 族输入)
|
|
89
|
+
Sensitivity string
|
|
90
|
+
// 资源金额(numeric 族输入,金额以字符串承载避免精度丢失)
|
|
91
|
+
Amount string
|
|
92
|
+
// 审批状态(state 族 approval_state_in 输入)
|
|
93
|
+
ApprovalState string
|
|
94
|
+
// 资源所属设施 ID(facility 族输入)
|
|
95
|
+
FacilityID string
|
|
96
|
+
// 资源 owner 主体 ID(assignment same_owner 输入)
|
|
97
|
+
OwnerPrincipalID *int64
|
|
98
|
+
// 资源创建者主体 ID(assignment created_by_self 输入)
|
|
99
|
+
CreatedByPrincipalID *int64
|
|
100
|
+
// 请求授予的数据范围类型(授权绑定类操作输入)
|
|
101
|
+
RequestedScopeType string
|
|
102
|
+
// 请求授予的数据范围值(授权绑定类操作输入)
|
|
103
|
+
RequestedScopeValue string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// AdminAccessContext 单资源求值的完整上下文快照。
|
|
107
|
+
//
|
|
108
|
+
// 五个维度共同构成 condition 求值的属性来源(§5.5),并供决策日志快照投影。
|
|
109
|
+
type AdminAccessContext struct {
|
|
110
|
+
// 主体维度
|
|
111
|
+
Principal PrincipalContext
|
|
112
|
+
// 工作区维度
|
|
113
|
+
Workspace WorkspaceContext
|
|
114
|
+
// 产品维度
|
|
115
|
+
Product ProductContext
|
|
116
|
+
// 请求维度
|
|
117
|
+
Request RequestContext
|
|
118
|
+
// 资源维度
|
|
119
|
+
Resource ResourceContext
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// AdminAccessContextInput 管理端授权上下文的可信调用输入。
|
|
123
|
+
//
|
|
124
|
+
// Principal 只承载当前会话事实;主体身份由工厂从权威 Principal 记录覆盖。
|
|
125
|
+
// Workspace 必须由认证后的产品边界适配器提供,工厂不从主体生命周期归属推导请求范围。
|
|
126
|
+
type AdminAccessContextInput struct {
|
|
127
|
+
// 主体会话维度
|
|
128
|
+
Principal PrincipalContext
|
|
129
|
+
// 工作区维度
|
|
130
|
+
Workspace WorkspaceContext
|
|
131
|
+
// 请求维度
|
|
132
|
+
Request RequestContext
|
|
133
|
+
// 资源维度
|
|
134
|
+
Resource ResourceContext
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Decision 单资源求值决策值对象(不落库)。
|
|
138
|
+
//
|
|
139
|
+
// ReasonKind 区分 authorization(403)与 state(409/422)两类语义(§7.3 / §8.2);
|
|
140
|
+
// authorization 类 ReasonCode 取值见 enum.go 决策原因码常量。
|
|
141
|
+
type Decision struct {
|
|
142
|
+
// 是否允许
|
|
143
|
+
Allowed bool
|
|
144
|
+
// 被求值的规范动作全名
|
|
145
|
+
Action string
|
|
146
|
+
// 被求值的资源 ARN
|
|
147
|
+
Resource string
|
|
148
|
+
// 决策原因码(见 enum.go 决策原因码常量)
|
|
149
|
+
ReasonCode string
|
|
150
|
+
// 决策原因类别(见 enum.go ReasonKind)
|
|
151
|
+
ReasonKind ReasonKind
|
|
152
|
+
// 命中语句 ID 集合
|
|
153
|
+
MatchedStatementIDs []int64
|
|
154
|
+
// 触发拒绝的来源标识集合(如命中的 Deny 语句 / boundary / session 标记),用于解释
|
|
155
|
+
DeniedBy []string
|
|
156
|
+
// 人类可读的决策解释
|
|
157
|
+
Explanation string
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// NewAllowedDecision 构造允许决策(ReasonAllowed + authorization 类)。
|
|
161
|
+
func NewAllowedDecision(action, resource string, matched []int64) Decision {
|
|
162
|
+
return Decision{
|
|
163
|
+
Allowed: true,
|
|
164
|
+
Action: action,
|
|
165
|
+
Resource: resource,
|
|
166
|
+
ReasonCode: ReasonAllowed,
|
|
167
|
+
ReasonKind: ReasonKindAuthorization,
|
|
168
|
+
MatchedStatementIDs: matched,
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// NewDeniedDecision 构造拒绝决策(authorization 类,携带拒绝来源与解释)。
|
|
173
|
+
//
|
|
174
|
+
// reasonCode 取 enum.go authorization 类决策原因码(如 ReasonExplicitDeny / ReasonNoMatchingAllow)。
|
|
175
|
+
func NewDeniedDecision(action, resource, reasonCode string, deniedBy []string, explanation string) Decision {
|
|
176
|
+
return Decision{
|
|
177
|
+
Allowed: false,
|
|
178
|
+
Action: action,
|
|
179
|
+
Resource: resource,
|
|
180
|
+
ReasonCode: reasonCode,
|
|
181
|
+
ReasonKind: ReasonKindAuthorization,
|
|
182
|
+
DeniedBy: deniedBy,
|
|
183
|
+
Explanation: explanation,
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// NewStateDeniedDecision 构造业务状态前置条件拒绝决策。
|
|
188
|
+
func NewStateDeniedDecision(action, resource, reasonCode, explanation string) Decision {
|
|
189
|
+
return Decision{
|
|
190
|
+
Allowed: false,
|
|
191
|
+
Action: action,
|
|
192
|
+
Resource: resource,
|
|
193
|
+
ReasonCode: reasonCode,
|
|
194
|
+
ReasonKind: ReasonKindState,
|
|
195
|
+
Explanation: explanation,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// EvaluateRequest 单资源求值请求。
|
|
200
|
+
//
|
|
201
|
+
// PrincipalID 与 Context.Principal.PrincipalID 应一致(调用方装配时保证);
|
|
202
|
+
// Action 为规范动作全名,Resource 为资源 ARN。
|
|
203
|
+
type EvaluateRequest struct {
|
|
204
|
+
// 主体 ID
|
|
205
|
+
PrincipalID int64
|
|
206
|
+
// 被求值的规范动作全名
|
|
207
|
+
Action string
|
|
208
|
+
// 被求值的资源 ARN
|
|
209
|
+
Resource string
|
|
210
|
+
// 求值上下文快照
|
|
211
|
+
Context AdminAccessContext
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// PageActionDecision 页面动作的逐资源授权决策(EffectiveActions 产出,设计文档 §7.1)。
|
|
215
|
+
//
|
|
216
|
+
// 一个页面动作契约(PageAction)渲染 ResourceTemplate 后对当前操作者求值,
|
|
217
|
+
// 产出本值对象供前端按钮级渲染(allow → 可点;deny → 隐藏 / 置灰 + reason_code 解释)。
|
|
218
|
+
// 携带 Placement / RiskLevel 让前端按位摆放与高危标注,无需二次查动作字典。
|
|
219
|
+
type PageActionDecision struct {
|
|
220
|
+
// 动作位键(页面内唯一,前端按此定位按钮)
|
|
221
|
+
ActionKey string
|
|
222
|
+
// 绑定的规范动作全名(domain:resource:verb)
|
|
223
|
+
Action string
|
|
224
|
+
// 渲染后的资源 ARN(模板占位符已填充)
|
|
225
|
+
Resource string
|
|
226
|
+
// 是否允许(前端按钮可点 / 隐藏的依据)
|
|
227
|
+
Allowed bool
|
|
228
|
+
// 决策原因码(见 enum.go 决策原因码常量,allow=allowed)
|
|
229
|
+
ReasonCode string
|
|
230
|
+
// 决策原因类别(授权拒绝为 authorization,状态条件拒绝为 state)
|
|
231
|
+
ReasonKind ReasonKind
|
|
232
|
+
// 摆放位置(见 enum.go Placement,前端按位渲染)
|
|
233
|
+
Placement string
|
|
234
|
+
// 风险等级(见 enum.go RiskLevel,前端高危动作二次确认)
|
|
235
|
+
RiskLevel string
|
|
236
|
+
// 触发拒绝的来源标识集合(命中的 Deny 语句 / boundary / session 标记),用于解释
|
|
237
|
+
DeniedBy []string
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// NewPageActionDecision 由页面动作契约与求值决策构造页面动作决策值对象。
|
|
241
|
+
//
|
|
242
|
+
// ActionKey / Placement / RiskLevel 取自契约(前端渲染元数据);Allowed / ReasonCode /
|
|
243
|
+
// ReasonKind / Action / Resource / DeniedBy 取自求值决策(授权结论)。两者语义不同不混淆。
|
|
244
|
+
func NewPageActionDecision(actionKey, placement, riskLevel string, decision Decision) PageActionDecision {
|
|
245
|
+
return PageActionDecision{
|
|
246
|
+
ActionKey: actionKey,
|
|
247
|
+
Action: decision.Action,
|
|
248
|
+
Resource: decision.Resource,
|
|
249
|
+
Allowed: decision.Allowed,
|
|
250
|
+
ReasonCode: decision.ReasonCode,
|
|
251
|
+
ReasonKind: decision.ReasonKind,
|
|
252
|
+
Placement: placement,
|
|
253
|
+
RiskLevel: riskLevel,
|
|
254
|
+
DeniedBy: decision.DeniedBy,
|
|
255
|
+
}
|
|
256
|
+
}
|