@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,549 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { dirname, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
import YAML from 'yaml';
|
|
8
|
+
|
|
9
|
+
import { isSemanticVersion } from './semantic_version.mjs';
|
|
10
|
+
|
|
11
|
+
export const apiRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
12
|
+
export const httpMethods = Object.freeze(['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace']);
|
|
13
|
+
export const audiences = Object.freeze(['internal', 'partner', 'public']);
|
|
14
|
+
export const stabilities = Object.freeze(['experimental', 'beta', 'stable']);
|
|
15
|
+
export const documentationLocales = Object.freeze(['zh-CN']);
|
|
16
|
+
|
|
17
|
+
const approvedDocumentationLeadingTerms = new Set([
|
|
18
|
+
'AI', 'API', 'Airwallex', 'Android', 'Apple', 'CH', 'CMS', 'CPM', 'Google', 'Hreflang', 'IAM', 'IAP', 'KOL', 'LINE',
|
|
19
|
+
'MCP', 'MFA', 'Mapbox', 'OAuth', 'OIDC', 'Outbox', 'PayPal', 'PayerMax', 'Payssion', 'RFC', 'SAML', 'SCIM', 'SEO',
|
|
20
|
+
'SES', 'SLA', 'SSO', 'SendGrid', 'Stripe', 'Twilio', 'WeChat', 'Webhook', 'WhatsApp', 'iCloud',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const componentKinds = Object.freeze([
|
|
24
|
+
'callbacks',
|
|
25
|
+
'examples',
|
|
26
|
+
'headers',
|
|
27
|
+
'links',
|
|
28
|
+
'parameters',
|
|
29
|
+
'pathItems',
|
|
30
|
+
'requestBodies',
|
|
31
|
+
'responses',
|
|
32
|
+
'schemas',
|
|
33
|
+
'securitySchemes',
|
|
34
|
+
]);
|
|
35
|
+
const internalMetadata = new Set(['x-onex-audience', 'x-onex-source']);
|
|
36
|
+
const privateServerPattern = /(^|\/\/)(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\]|[^/]+\.(internal|local))(?=[:/]|$)/i;
|
|
37
|
+
const providerWebhookPathPattern = /^\/api\/v1\/webhooks\/\{product_code\}\/(airwallex|apple|google|payermax|paypal|payssion|stripe|wechatpay)\/$/;
|
|
38
|
+
|
|
39
|
+
export async function readStructured(path) {
|
|
40
|
+
const source = await readFile(path, 'utf8');
|
|
41
|
+
return path.endsWith('.json') ? JSON.parse(source) : YAML.parse(source);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function readRegistry(root = apiRoot) {
|
|
45
|
+
const registry = await readStructured(resolve(root, 'service-registry.json'));
|
|
46
|
+
validateRegistry(registry);
|
|
47
|
+
return registry;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function validateRegistry(registry) {
|
|
51
|
+
if (registry?.schema_version !== 1 || !Array.isArray(registry.services) || registry.services.length === 0) {
|
|
52
|
+
throw new Error('service registry must declare schema_version 1 and at least one service');
|
|
53
|
+
}
|
|
54
|
+
const seen = new Set();
|
|
55
|
+
const ids = registry.services.map((service) => service.id);
|
|
56
|
+
if (ids.join('\n') !== [...ids].sort().join('\n')) {
|
|
57
|
+
throw new Error('service registry entries must be sorted by id');
|
|
58
|
+
}
|
|
59
|
+
for (const service of registry.services) {
|
|
60
|
+
if (!/^[a-z][a-z0-9-]*$/.test(service.id) || seen.has(service.id)) {
|
|
61
|
+
throw new Error(`invalid or duplicate service id: ${service.id}`);
|
|
62
|
+
}
|
|
63
|
+
seen.add(service.id);
|
|
64
|
+
if (!service.display_name || !isSafeRelativePath(service.source) || !isSafeRelativePath(service.runtime_conformance)) {
|
|
65
|
+
throw new Error(`service ${service.id} must declare display_name, source, and runtime_conformance`);
|
|
66
|
+
}
|
|
67
|
+
if (!documentationLocales.includes(service.documentation_locale)) {
|
|
68
|
+
throw new Error(`service ${service.id} has unsupported documentation_locale: ${service.documentation_locale}`);
|
|
69
|
+
}
|
|
70
|
+
if (!hasHanText(service.display_name)) {
|
|
71
|
+
throw new Error(`service ${service.id} display_name must use Chinese documentation copy`);
|
|
72
|
+
}
|
|
73
|
+
if (!Array.isArray(service.publications) || service.publications[0] !== 'internal') {
|
|
74
|
+
throw new Error(`service ${service.id} publications must start with internal`);
|
|
75
|
+
}
|
|
76
|
+
const uniquePublications = new Set(service.publications);
|
|
77
|
+
if (uniquePublications.size !== service.publications.length || service.publications.some((value) => !audiences.includes(value))) {
|
|
78
|
+
throw new Error(`service ${service.id} has invalid publications`);
|
|
79
|
+
}
|
|
80
|
+
for (const exclusion of service.route_exclusions ?? []) {
|
|
81
|
+
if (!exclusion.startsWith('/') || /^\/(api|admin|internal)(\/|$)/.test(exclusion)) {
|
|
82
|
+
throw new Error(`service ${service.id} has forbidden route exclusion: ${exclusion}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if ((service.route_exclusions ?? []).join('\n') !== [...(service.route_exclusions ?? [])].sort().join('\n')) {
|
|
86
|
+
throw new Error(`service ${service.id} route exclusions must be sorted`);
|
|
87
|
+
}
|
|
88
|
+
const delegatedIds = (service.delegated_contracts ?? []).map((delegated) => delegated.id);
|
|
89
|
+
if (new Set(delegatedIds).size !== delegatedIds.length || delegatedIds.join('\n') !== [...delegatedIds].sort().join('\n')) {
|
|
90
|
+
throw new Error(`service ${service.id} delegated contracts must have unique sorted ids`);
|
|
91
|
+
}
|
|
92
|
+
for (const delegated of service.delegated_contracts ?? []) {
|
|
93
|
+
validateDelegatedRegistryEntry(service.id, delegated);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function operationEntries(document) {
|
|
99
|
+
const entries = [];
|
|
100
|
+
for (const [path, pathItem] of Object.entries(document.paths ?? {})) {
|
|
101
|
+
for (const method of httpMethods) {
|
|
102
|
+
if (pathItem?.[method]) {
|
|
103
|
+
entries.push({ method, operation: pathItem[method], path, pathItem });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return entries.sort((left, right) => compareUTF8Bytes(`${left.path}\0${left.method}`, `${right.path}\0${right.method}`));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function compareUTF8Bytes(left, right) {
|
|
111
|
+
return Buffer.compare(Buffer.from(left), Buffer.from(right));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function validateDocument(document, {
|
|
115
|
+
audience = 'internal',
|
|
116
|
+
documentationLocale = document?.['x-onex-documentation-locale'],
|
|
117
|
+
requireMetadata = true,
|
|
118
|
+
service,
|
|
119
|
+
}) {
|
|
120
|
+
const errors = [];
|
|
121
|
+
if (document?.openapi !== '3.1.1') errors.push('openapi must be 3.1.1');
|
|
122
|
+
if (document?.jsonSchemaDialect !== 'https://json-schema.org/draft/2020-12/schema') {
|
|
123
|
+
errors.push('jsonSchemaDialect must be JSON Schema 2020-12');
|
|
124
|
+
}
|
|
125
|
+
if (!document?.info?.title || !isSemanticVersion(document?.info?.version)) {
|
|
126
|
+
errors.push('info.title and a SemVer info.version are required');
|
|
127
|
+
}
|
|
128
|
+
const entries = operationEntries(document);
|
|
129
|
+
if (entries.length === 0) errors.push('at least one operation is required');
|
|
130
|
+
for (const path of Object.keys(document.paths ?? {})) {
|
|
131
|
+
if (path.endsWith('/') && !providerWebhookPathPattern.test(path)) {
|
|
132
|
+
errors.push(`${path} has a trailing slash outside the provider webhook contract`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const operationIds = new Set();
|
|
136
|
+
for (const { method, operation, path } of entries) {
|
|
137
|
+
const label = `${method.toUpperCase()} ${path}`;
|
|
138
|
+
if (!/^[a-z][A-Za-z0-9]*$/.test(operation.operationId ?? '')) errors.push(`${label} has invalid operationId`);
|
|
139
|
+
if (operationIds.has(operation.operationId)) errors.push(`${label} duplicates operationId ${operation.operationId}`);
|
|
140
|
+
operationIds.add(operation.operationId);
|
|
141
|
+
if (!operation.summary?.trim()) errors.push(`${label} has no summary`);
|
|
142
|
+
if (!Array.isArray(operation.tags) || operation.tags.length === 0) errors.push(`${label} has no tags`);
|
|
143
|
+
if (!Object.hasOwn(operation, 'security') || !Array.isArray(operation.security)) errors.push(`${label} has no explicit security`);
|
|
144
|
+
if (!operation.responses || Object.keys(operation.responses).length === 0) errors.push(`${label} has no responses`);
|
|
145
|
+
if (requireMetadata && !audiences.includes(operation['x-onex-audience'])) errors.push(`${label} has invalid x-onex-audience`);
|
|
146
|
+
if (requireMetadata && !operation['x-onex-owner']?.trim()) errors.push(`${label} has no x-onex-owner`);
|
|
147
|
+
if (!stabilities.includes(operation['x-onex-stability'])) errors.push(`${label} has invalid x-onex-stability`);
|
|
148
|
+
if (requireMetadata && operation['x-onex-audience'] !== 'internal' && !validLifecycle(operation['x-onex-lifecycle'])) {
|
|
149
|
+
errors.push(`${label} has invalid x-onex-lifecycle`);
|
|
150
|
+
}
|
|
151
|
+
if (audience !== 'internal' && pathLeaksInternalSurface(path)) errors.push(`${label} leaks an internal path`);
|
|
152
|
+
}
|
|
153
|
+
visit(document, (value, key, path, parent) => {
|
|
154
|
+
if (key === 'nullable') errors.push(`${path} uses forbidden nullable keyword`);
|
|
155
|
+
if (
|
|
156
|
+
key === 'name' &&
|
|
157
|
+
typeof value === 'string' &&
|
|
158
|
+
value.toLowerCase() === 'idempotency-key' &&
|
|
159
|
+
parent?.in === 'header'
|
|
160
|
+
) {
|
|
161
|
+
errors.push(`${path} uses the provider idempotency header instead of X-Idempotency-Key`);
|
|
162
|
+
}
|
|
163
|
+
if ((key === '$ref' || key === '$dynamicRef') && typeof value === 'string' && !value.startsWith('#/')) {
|
|
164
|
+
errors.push(`${path} contains a remote or unresolved reference: ${value}`);
|
|
165
|
+
}
|
|
166
|
+
if (key === 'additionalProperties' && value === true && audience !== 'internal') {
|
|
167
|
+
errors.push(`${path} exposes an unconstrained object`);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
if (documentationLocale !== undefined) validateDocumentation(document, documentationLocale, entries, errors);
|
|
171
|
+
if (audience !== 'internal') {
|
|
172
|
+
for (const server of document.servers ?? []) {
|
|
173
|
+
if (privateServerPattern.test(server.url ?? '')) errors.push(`external artifact contains private server ${server.url}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (errors.length > 0) {
|
|
177
|
+
throw new Error(`${service ?? document?.info?.title ?? 'OpenAPI document'} validation failed:\n- ${errors.join('\n- ')}`);
|
|
178
|
+
}
|
|
179
|
+
return { operationCount: entries.length, pathCount: Object.keys(document.paths ?? {}).length };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function projectDocument(source, audience) {
|
|
183
|
+
if (!audiences.includes(audience)) throw new Error(`unknown audience: ${audience}`);
|
|
184
|
+
const projected = structuredClone(source);
|
|
185
|
+
projected.paths = selectPaths(source, (operation) => includesAudience(operation['x-onex-audience'], audience));
|
|
186
|
+
projectSecurityRequirements(source, projected, audience);
|
|
187
|
+
|
|
188
|
+
projected.components = collectReachableComponents(source, projected, audience);
|
|
189
|
+
projectDocumentationNavigation(source, projected);
|
|
190
|
+
validateDocument(projected, { audience, service: source.info?.title });
|
|
191
|
+
if (audience !== 'internal') {
|
|
192
|
+
projected.servers = (source.servers ?? []).filter((server) => !privateServerPattern.test(server.url ?? ''));
|
|
193
|
+
stripInternalMetadata(projected);
|
|
194
|
+
}
|
|
195
|
+
validateLinkTargets(projected);
|
|
196
|
+
return projected;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function projectOperationSet(source, operationIds) {
|
|
200
|
+
const selected = new Set(operationIds);
|
|
201
|
+
if (selected.size === 0) throw new Error('operation projection requires at least one operationId');
|
|
202
|
+
const projected = structuredClone(source);
|
|
203
|
+
projected.paths = selectPaths(source, (operation) => selected.has(operation.operationId));
|
|
204
|
+
const found = new Set(operationEntries(projected).map(({ operation }) => operation.operationId));
|
|
205
|
+
const missing = [...selected].filter((operationId) => !found.has(operationId));
|
|
206
|
+
if (missing.length > 0) throw new Error(`operation projection contains unknown operationIds: ${missing.sort().join(', ')}`);
|
|
207
|
+
projected.components = collectReachableComponents(source, projected, 'internal');
|
|
208
|
+
projectDocumentationNavigation(source, projected);
|
|
209
|
+
validateDocument(projected, { audience: 'internal', service: `${source.info?.title} operation projection` });
|
|
210
|
+
validateLinkTargets(projected);
|
|
211
|
+
return projected;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function canonicalJSON(value) {
|
|
215
|
+
return `${JSON.stringify(sortObjectKeys(value), null, 2)}\n`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function sha256(content) {
|
|
219
|
+
return createHash('sha256').update(content).digest('hex');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function countComponents(document) {
|
|
223
|
+
return Object.values(document.components ?? {}).reduce((total, group) => total + Object.keys(group ?? {}).length, 0);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function isSafeRelativePath(path) {
|
|
227
|
+
return typeof path === 'string' && path.length > 0 && !path.startsWith('/') && !path.split('/').includes('..');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function validateDelegatedRegistryEntry(serviceId, delegated) {
|
|
231
|
+
if (!/^[a-z][a-z0-9-]*$/.test(delegated.id ?? '')) throw new Error(`service ${serviceId} has invalid delegated id`);
|
|
232
|
+
for (const field of ['artifact', 'overlay', 'provenance']) {
|
|
233
|
+
if (!isSafeRelativePath(delegated[field])) throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid ${field}`);
|
|
234
|
+
}
|
|
235
|
+
if (
|
|
236
|
+
!delegated.mount_prefix?.startsWith('/') ||
|
|
237
|
+
delegated.mount_prefix.endsWith('/') ||
|
|
238
|
+
delegated.mount_prefix.includes('*') ||
|
|
239
|
+
!Number.isInteger(delegated.expected_operation_count) ||
|
|
240
|
+
delegated.expected_operation_count < 1
|
|
241
|
+
) {
|
|
242
|
+
throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid mount or operation count`);
|
|
243
|
+
}
|
|
244
|
+
if (
|
|
245
|
+
!Array.isArray(delegated.methods) ||
|
|
246
|
+
delegated.methods.length === 0 ||
|
|
247
|
+
new Set(delegated.methods).size !== delegated.methods.length ||
|
|
248
|
+
delegated.methods.join('\n') !== [...delegated.methods].sort().join('\n') ||
|
|
249
|
+
delegated.methods.some((method) => method !== method.toUpperCase() || !httpMethods.includes(method.toLowerCase()))
|
|
250
|
+
) {
|
|
251
|
+
throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid methods`);
|
|
252
|
+
}
|
|
253
|
+
if (!/^[A-Z][A-Za-z0-9]*$/.test(delegated.security_scheme ?? '')) {
|
|
254
|
+
throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid security_scheme`);
|
|
255
|
+
}
|
|
256
|
+
if (typeof delegated.navigation_group !== 'string' || !hasHanText(delegated.navigation_group)) {
|
|
257
|
+
throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid navigation_group`);
|
|
258
|
+
}
|
|
259
|
+
const prefixes = delegated.source_path_prefixes_to_strip;
|
|
260
|
+
if (
|
|
261
|
+
!Array.isArray(prefixes) ||
|
|
262
|
+
prefixes.length === 0 ||
|
|
263
|
+
new Set(prefixes).size !== prefixes.length ||
|
|
264
|
+
prefixes.some((prefix) => !prefix.startsWith('/') || prefix.endsWith('/') || prefix.includes('*'))
|
|
265
|
+
) {
|
|
266
|
+
throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid source path prefixes`);
|
|
267
|
+
}
|
|
268
|
+
if (delegated.csrf_protection !== undefined) {
|
|
269
|
+
const csrf = delegated.csrf_protection;
|
|
270
|
+
if (
|
|
271
|
+
csrf?.header_name !== 'X-CSRF-Token' ||
|
|
272
|
+
!Array.isArray(csrf.methods) ||
|
|
273
|
+
csrf.methods.length === 0 ||
|
|
274
|
+
new Set(csrf.methods).size !== csrf.methods.length ||
|
|
275
|
+
csrf.methods.join('\n') !== [...csrf.methods].sort().join('\n') ||
|
|
276
|
+
csrf.methods.some((method) => !delegated.methods.includes(method) || ['GET', 'HEAD', 'OPTIONS'].includes(method))
|
|
277
|
+
) {
|
|
278
|
+
throw new Error(`service ${serviceId} delegated ${delegated.id} has invalid CSRF protection`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function includesAudience(sourceAudience, targetAudience) {
|
|
284
|
+
return audiences.indexOf(sourceAudience) >= audiences.indexOf(targetAudience);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function projectDocumentationNavigation(source, projected) {
|
|
288
|
+
const usedTags = new Set(operationEntries(projected).flatMap(({ operation }) => operation.tags ?? []));
|
|
289
|
+
projected.tags = (source.tags ?? [...usedTags].map((name) => ({ name }))).filter((tag) => usedTags.has(tag.name));
|
|
290
|
+
if (Array.isArray(source['x-tagGroups'])) {
|
|
291
|
+
projected['x-tagGroups'] = source['x-tagGroups']
|
|
292
|
+
.map((group) => ({ ...structuredClone(group), tags: group.tags.filter((tag) => usedTags.has(tag)) }))
|
|
293
|
+
.filter((group) => group.tags.length > 0);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function validateDocumentation(document, locale, entries, errors) {
|
|
298
|
+
if (!documentationLocales.includes(locale)) {
|
|
299
|
+
errors.push(`unsupported documentation locale: ${locale}`);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (document['x-onex-documentation-locale'] !== locale) {
|
|
303
|
+
errors.push(`x-onex-documentation-locale must equal ${locale}`);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const declaredTags = [];
|
|
307
|
+
const declaredTagSet = new Set();
|
|
308
|
+
if (!Array.isArray(document.tags) || document.tags.length === 0) {
|
|
309
|
+
errors.push('localized documentation must declare ordered top-level tags');
|
|
310
|
+
} else {
|
|
311
|
+
for (const [index, tag] of document.tags.entries()) {
|
|
312
|
+
const name = tag?.name?.trim();
|
|
313
|
+
if (!name || !hasHanText(name)) errors.push(`tags[${index}].name must use Chinese documentation copy`);
|
|
314
|
+
if (declaredTagSet.has(name)) errors.push(`tags[${index}].name duplicates ${name}`);
|
|
315
|
+
declaredTags.push(name);
|
|
316
|
+
declaredTagSet.add(name);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const groupedTags = [];
|
|
321
|
+
const groupNames = new Set();
|
|
322
|
+
const groups = document['x-tagGroups'];
|
|
323
|
+
if (!Array.isArray(groups) || groups.length === 0) {
|
|
324
|
+
errors.push('localized documentation must declare x-tagGroups');
|
|
325
|
+
} else {
|
|
326
|
+
for (const [index, group] of groups.entries()) {
|
|
327
|
+
const name = group?.name?.trim();
|
|
328
|
+
if (!name || !hasHanText(name)) errors.push(`x-tagGroups[${index}].name must use Chinese documentation copy`);
|
|
329
|
+
if (groupNames.has(name)) errors.push(`x-tagGroups[${index}].name duplicates ${name}`);
|
|
330
|
+
groupNames.add(name);
|
|
331
|
+
if (!Array.isArray(group?.tags) || group.tags.length === 0) {
|
|
332
|
+
errors.push(`x-tagGroups[${index}] must contain at least one tag`);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
groupedTags.push(...group.tags);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (groupedTags.join('\n') !== declaredTags.join('\n')) {
|
|
339
|
+
errors.push('x-tagGroups must contain every declared tag exactly once and preserve top-level tag order');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
for (const { method, operation, path } of entries) {
|
|
343
|
+
const label = `${method.toUpperCase()} ${path}`;
|
|
344
|
+
if (operation.tags?.length !== 1) errors.push(`${label} must declare exactly one navigation tag`);
|
|
345
|
+
for (const tag of operation.tags ?? []) {
|
|
346
|
+
if (!declaredTagSet.has(tag)) errors.push(`${label} uses undeclared tag ${tag}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const invalidText = [];
|
|
351
|
+
const leakedImplementationNames = [];
|
|
352
|
+
visit(document, (value, key, path) => {
|
|
353
|
+
if (typeof value === 'string' && ['description', 'summary', 'title'].includes(key) && !isExamplePayloadPath(path) && !hasHanText(value)) {
|
|
354
|
+
invalidText.push(`${path}=${JSON.stringify(value)}`);
|
|
355
|
+
}
|
|
356
|
+
if (key === 'summary' && typeof value === 'string' && !isExamplePayloadPath(path) && hasLegacyImplementationPrefix(value)) {
|
|
357
|
+
leakedImplementationNames.push(`${path}=${JSON.stringify(value)}`);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
for (const [path, value] of [
|
|
361
|
+
['$.info.contact.name', document.info?.contact?.name],
|
|
362
|
+
['$.info.license.name', document.info?.license?.name],
|
|
363
|
+
]) {
|
|
364
|
+
if (typeof value === 'string' && !hasHanText(value)) invalidText.push(`${path}=${JSON.stringify(value)}`);
|
|
365
|
+
}
|
|
366
|
+
const limit = 100;
|
|
367
|
+
errors.push(...invalidText.slice(0, limit).map((entry) => `documentation text must use Chinese copy: ${entry}`));
|
|
368
|
+
if (invalidText.length > limit) errors.push(`documentation text has ${invalidText.length - limit} additional non-Chinese values`);
|
|
369
|
+
errors.push(...leakedImplementationNames.slice(0, limit).map((entry) => `operation summary must not expose a handler or English action prefix: ${entry}`));
|
|
370
|
+
if (leakedImplementationNames.length > limit) {
|
|
371
|
+
errors.push(`operation summaries have ${leakedImplementationNames.length - limit} additional implementation-name leaks`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function isExamplePayloadPath(path) {
|
|
376
|
+
return /\.example(?:\.|\[)/.test(path) || /\.examples\.[^.]+\.value(?:\.|\[)/.test(path) || /\.components\.examples\.[^.]+\.value(?:\.|\[)/.test(path);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function hasHanText(value) {
|
|
380
|
+
return typeof value === 'string' && /\p{Script=Han}/u.test(value);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function hasLegacyImplementationPrefix(value) {
|
|
384
|
+
const match = /^([A-Z][A-Za-z0-9]+)\s+(.+)$/u.exec(value.trim());
|
|
385
|
+
return Boolean(match && hasHanText(match[2]) && !approvedDocumentationLeadingTerms.has(match[1]));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function selectPaths(source, predicate) {
|
|
389
|
+
const paths = {};
|
|
390
|
+
for (const [path, sourcePathItem] of Object.entries(source.paths ?? {})) {
|
|
391
|
+
const pathItem = {};
|
|
392
|
+
for (const key of ['$ref', 'description', 'parameters', 'servers', 'summary']) {
|
|
393
|
+
if (Object.hasOwn(sourcePathItem, key)) pathItem[key] = structuredClone(sourcePathItem[key]);
|
|
394
|
+
}
|
|
395
|
+
for (const method of httpMethods) {
|
|
396
|
+
const operation = sourcePathItem[method];
|
|
397
|
+
if (operation && predicate(operation)) pathItem[method] = structuredClone(operation);
|
|
398
|
+
}
|
|
399
|
+
if (httpMethods.some((method) => pathItem[method])) paths[path] = pathItem;
|
|
400
|
+
}
|
|
401
|
+
return paths;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function projectSecurityRequirements(source, projected, audience) {
|
|
405
|
+
for (const { method, operation, path } of operationEntries(projected)) {
|
|
406
|
+
if (!Array.isArray(operation.security) || operation.security.length === 0) continue;
|
|
407
|
+
const security = operation.security.filter((requirement) => {
|
|
408
|
+
const schemeNames = Object.keys(requirement);
|
|
409
|
+
if (schemeNames.length === 0) return true;
|
|
410
|
+
return schemeNames.every((schemeName) => {
|
|
411
|
+
const scheme = source.components?.securitySchemes?.[schemeName];
|
|
412
|
+
if (!scheme) return true;
|
|
413
|
+
return includesAudience(scheme['x-onex-audience'] ?? 'internal', audience);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
if (security.length === 0) {
|
|
417
|
+
throw new Error(`${method.toUpperCase()} ${path} has no security alternative available in ${audience} projection`);
|
|
418
|
+
}
|
|
419
|
+
operation.security = security;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function collectReachableComponents(source, projected, audience) {
|
|
424
|
+
const result = Object.fromEntries(componentKinds.map((kind) => [kind, {}]));
|
|
425
|
+
const queue = [];
|
|
426
|
+
const requiredStability = new Map();
|
|
427
|
+
for (const { operation } of operationEntries(projected)) {
|
|
428
|
+
enqueueReferences(operation, operation['x-onex-stability']);
|
|
429
|
+
for (const requirement of operation.security) {
|
|
430
|
+
for (const name of Object.keys(requirement)) queue.push({ kind: 'securitySchemes', name, stability: operation['x-onex-stability'] });
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
for (const pathItem of Object.values(projected.paths)) enqueueReferences(pathItem, 'experimental');
|
|
434
|
+
|
|
435
|
+
while (queue.length > 0) {
|
|
436
|
+
const { kind, name, stability } = queue.shift();
|
|
437
|
+
const identity = `${kind}/${name}`;
|
|
438
|
+
const previous = requiredStability.get(identity);
|
|
439
|
+
if (previous && stabilities.indexOf(previous) >= stabilities.indexOf(stability)) continue;
|
|
440
|
+
const component = source.components?.[kind]?.[name];
|
|
441
|
+
if (!component) throw new Error(`unresolved component reference: #/components/${kind}/${name}`);
|
|
442
|
+
if (audience !== 'internal') {
|
|
443
|
+
const componentAudience = component['x-onex-audience'] ?? 'internal';
|
|
444
|
+
const componentStability = component['x-onex-stability'];
|
|
445
|
+
if (!includesAudience(componentAudience, audience)) {
|
|
446
|
+
throw new Error(`component ${identity} cannot enter ${audience} projection`);
|
|
447
|
+
}
|
|
448
|
+
if (!stabilities.includes(componentStability) || stabilities.indexOf(componentStability) < stabilities.indexOf(stability)) {
|
|
449
|
+
throw new Error(`component ${identity} stability is lower than its consumer`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
requiredStability.set(identity, stability);
|
|
453
|
+
result[kind][name] = structuredClone(component);
|
|
454
|
+
enqueueReferences(component, stability);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
for (const kind of componentKinds) if (Object.keys(result[kind]).length === 0) delete result[kind];
|
|
458
|
+
return result;
|
|
459
|
+
|
|
460
|
+
function enqueueReferences(node, stability) {
|
|
461
|
+
visit(node, (value, key) => {
|
|
462
|
+
if ((key === '$ref' || key === '$dynamicRef') && typeof value === 'string') {
|
|
463
|
+
const parsed = parseComponentReference(value);
|
|
464
|
+
if (parsed) queue.push({ ...parsed, stability });
|
|
465
|
+
}
|
|
466
|
+
if (key === 'mapping' && isPlainObject(value)) {
|
|
467
|
+
for (const reference of Object.values(value)) {
|
|
468
|
+
const parsed = parseComponentReference(reference);
|
|
469
|
+
if (parsed) queue.push({ ...parsed, stability });
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function parseComponentReference(reference) {
|
|
477
|
+
const match = /^#\/components\/([^/]+)\/(.+)$/.exec(reference ?? '');
|
|
478
|
+
if (!match) return null;
|
|
479
|
+
const kind = decodePointer(match[1]);
|
|
480
|
+
if (!componentKinds.includes(kind)) throw new Error(`unsupported component kind in reference: ${reference}`);
|
|
481
|
+
return { kind, name: decodePointer(match[2]) };
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function validateLinkTargets(document) {
|
|
485
|
+
const operationIds = new Set(operationEntries(document).map(({ operation }) => operation.operationId));
|
|
486
|
+
visit(document, (value, key, path, parent) => {
|
|
487
|
+
if (key === 'operationId' && !parent.responses && !operationIds.has(value)) {
|
|
488
|
+
throw new Error(`${path} targets operationId outside the projection: ${value}`);
|
|
489
|
+
}
|
|
490
|
+
if (key === 'operationRef' && typeof value === 'string' && value.startsWith('#/paths/')) {
|
|
491
|
+
const parts = value.split('/');
|
|
492
|
+
const targetPath = decodePointer(parts[2] ?? '');
|
|
493
|
+
const targetMethod = parts[3];
|
|
494
|
+
if (!document.paths?.[targetPath]?.[targetMethod]) throw new Error(`${path} targets operation outside the projection: ${value}`);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function stripInternalMetadata(value) {
|
|
500
|
+
if (Array.isArray(value)) {
|
|
501
|
+
for (const item of value) stripInternalMetadata(item);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (!isPlainObject(value)) return;
|
|
505
|
+
for (const key of Object.keys(value)) {
|
|
506
|
+
if (internalMetadata.has(key)) delete value[key];
|
|
507
|
+
else stripInternalMetadata(value[key]);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function pathLeaksInternalSurface(path) {
|
|
512
|
+
return /^\/(admin|internal)(\/|$)/.test(path) || /^\/api\/v\d+\/(admin|internal)(\/|$)/.test(path);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function validLifecycle(lifecycle) {
|
|
516
|
+
return lifecycle !== null && typeof lifecycle === 'object' && /^\d{4}-\d{2}-\d{2}$/.test(lifecycle.introduced ?? '') &&
|
|
517
|
+
Object.hasOwn(lifecycle, 'deprecated') && Object.hasOwn(lifecycle, 'sunset') &&
|
|
518
|
+
Object.hasOwn(lifecycle, 'replacementOperationId') && Object.hasOwn(lifecycle, 'migrationUrl');
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function sortObjectKeys(value) {
|
|
522
|
+
if (Array.isArray(value)) return value.map(sortObjectKeys);
|
|
523
|
+
if (!isPlainObject(value)) return value;
|
|
524
|
+
return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sortObjectKeys(value[key])]));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function visit(value, callback, path = '$', parent = null) {
|
|
528
|
+
if (Array.isArray(value)) {
|
|
529
|
+
value.forEach((item, index) => {
|
|
530
|
+
callback(item, String(index), `${path}[${index}]`, value);
|
|
531
|
+
visit(item, callback, `${path}[${index}]`, value);
|
|
532
|
+
});
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (!isPlainObject(value)) return;
|
|
536
|
+
for (const [key, child] of Object.entries(value)) {
|
|
537
|
+
const childPath = `${path}.${key}`;
|
|
538
|
+
callback(child, key, childPath, value);
|
|
539
|
+
visit(child, callback, childPath, value);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function decodePointer(value) {
|
|
544
|
+
return value.replaceAll('~1', '/').replaceAll('~0', '~');
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function isPlainObject(value) {
|
|
548
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
549
|
+
}
|