@stackonward/cli 0.0.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4588 -205
- package/dist/index.js.map +1 -1
- package/dist/resources/apple/.claude/docs/architecture-template.md +54 -0
- package/dist/resources/apple/.claude/docs/architecture.md +52 -0
- package/dist/resources/apple/.claude/docs/index.md +13 -0
- package/dist/resources/apple/.claude/docs/security-lifecycle.md +57 -0
- package/dist/resources/apple/.claude/docs/stack.md +93 -0
- package/dist/resources/apple/.claude/docs/verification.md +63 -0
- package/dist/resources/apple/AGENTS.md +397 -0
- package/dist/resources/apple/CLAUDE.md +397 -0
- package/dist/resources/apple/Gemfile +2 -0
- package/dist/resources/apple/Gemfile.lock +365 -0
- package/dist/resources/apple/_gitignore +14 -0
- package/dist/resources/apple/fastlane/Fastfile +123 -0
- package/dist/resources/components/nuxt/site-source/app/app.vue +42 -0
- package/dist/resources/components/nuxt/site-source/app/assets/css/site-shell.css +1035 -0
- package/dist/resources/components/nuxt/site-source/app/assets/icons/brand/.gitkeep +0 -0
- package/dist/resources/components/nuxt/site-source/app/assets/icons/common/.gitkeep +0 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationHeader.vue +35 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationShell.vue +56 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ApplicationSidebar.vue +40 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/BackToTop.vue +42 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ContentArticlePage.vue +40 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ContentListPage.vue +30 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/CookieConsent.vue +18 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingFooter.vue +52 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingHeader.vue +106 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/MarketingShell.vue +35 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/SiteBrand.vue +10 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/StaticPage.vue +21 -0
- package/dist/resources/components/nuxt/site-source/app/components/site/ToastViewport.vue +25 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseButton.vue +86 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseGradientBorder.vue +59 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseModal.vue +131 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BasePopover.vue +150 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/BaseText.vue +138 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/CheckoutStatus.vue +112 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/CheckoutSummary.vue +172 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/GoogleSignInButton.vue +113 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/InfiniteScroll.vue +123 -0
- package/dist/resources/components/nuxt/site-source/app/components/ui/YoutubeEmbed.vue +126 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useAnalytics.ts +24 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useCheckout.ts +121 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useConsent.ts +31 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useGoogleIdentity.ts +163 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useNavigation.ts +11 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useSeo.ts +33 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useSiteShell.ts +58 -0
- package/dist/resources/components/nuxt/site-source/app/composables/useToasts.ts +48 -0
- package/dist/resources/components/nuxt/site-source/app/layouts/app.vue +5 -0
- package/dist/resources/components/nuxt/site-source/app/layouts/default.vue +5 -0
- package/dist/resources/components/nuxt/site-source/app/plugins/analytics.client.ts +121 -0
- package/dist/resources/components/nuxt/site-source/app/plugins/google-identity.client.ts +24 -0
- package/dist/resources/components/nuxt/site-source/app/theme/accordion.ts +9 -0
- package/dist/resources/components/nuxt/site-source/app/theme/breadcrumb.ts +8 -0
- package/dist/resources/components/nuxt/site-source/app/theme/button.ts +92 -0
- package/dist/resources/components/nuxt/site-source/app/theme/carousel.ts +11 -0
- package/dist/resources/components/nuxt/site-source/app/theme/checkbox.ts +12 -0
- package/dist/resources/components/nuxt/site-source/app/theme/index.ts +30 -0
- package/dist/resources/components/nuxt/site-source/app/theme/input.ts +47 -0
- package/dist/resources/components/nuxt/site-source/app/theme/modal.ts +9 -0
- package/dist/resources/components/nuxt/site-source/app/theme/pagination.ts +6 -0
- package/dist/resources/components/nuxt/site-source/app/theme/select.ts +23 -0
- package/dist/resources/components/nuxt/site-source/app/theme/stepper.ts +10 -0
- package/dist/resources/components/nuxt/site-source/app/theme/toast.ts +8 -0
- package/dist/resources/components/nuxt/site-source/app/theme/tooltip.ts +6 -0
- package/dist/resources/components/nuxt/site-source/app/types/site-shell.ts +85 -0
- package/dist/resources/components/react/ui/Button.tsx +73 -0
- package/dist/resources/components/react/ui/Input.tsx +44 -0
- package/dist/resources/components/registry.json +355 -0
- package/dist/resources/components/vue/feedback/Toast.vue +120 -0
- package/dist/resources/components/vue/feedback/useToast.ts +70 -0
- package/dist/resources/components/vue/media/FileUpload.vue +229 -0
- package/dist/resources/components/vue/media/VideoPlayer.vue +157 -0
- package/dist/resources/components/vue/ui/AppImage.vue +147 -0
- package/dist/resources/components/vue/ui/BottomSheet.vue +217 -0
- package/dist/resources/components/vue/ui/Button.vue +154 -0
- package/dist/resources/components/vue/ui/Card.vue +111 -0
- package/dist/resources/components/vue/ui/Input.vue +113 -0
- package/dist/resources/components/vue/ui/Modal.vue +193 -0
- package/dist/resources/components/vue/ui/ScrollArea.vue +163 -0
- package/dist/resources/components/vue/ui/Tooltip.vue +115 -0
- package/dist/resources/registry.json +158 -0
- package/dist/resources/snippets/node/cache.ts +116 -0
- package/dist/resources/snippets/node/date.ts +126 -0
- package/dist/resources/snippets/node/logger.ts +104 -0
- package/dist/resources/snippets/node/validation.ts +132 -0
- package/dist/resources/snippets/react/useDebounce.ts +90 -0
- package/dist/resources/snippets/registry.json +65 -0
- package/dist/resources/snippets/vue/useAsync.ts +96 -0
- package/dist/resources/snippets/vue/usePagination.ts +102 -0
- package/dist/resources/templates/base/.claude/docs/architecture-template.md +459 -0
- package/dist/resources/templates/base/.claude/docs/architecture.md +137 -0
- package/dist/resources/templates/base/.claude/docs/index.md +42 -0
- package/dist/resources/templates/base/.claude/docs/security-lifecycle.md +129 -0
- package/dist/resources/templates/base/.claude/docs/verification.md +121 -0
- package/dist/resources/templates/base/AGENTS.md +415 -0
- package/dist/resources/templates/base/CLAUDE.md +415 -0
- package/dist/resources/templates/go-backend/.claude/docs/api-design.md +486 -0
- package/dist/resources/templates/go-backend/.claude/docs/architecture-template.md +449 -0
- package/dist/resources/templates/go-backend/.claude/docs/check-list.md +155 -0
- package/dist/resources/templates/go-backend/.claude/docs/database.md +369 -0
- package/dist/resources/templates/go-backend/.claude/docs/e2e-standards.md +161 -0
- package/dist/resources/templates/go-backend/.claude/docs/error-handling.md +558 -0
- package/dist/resources/templates/go-backend/.claude/docs/event-runtime-boundary.md +124 -0
- package/dist/resources/templates/go-backend/.claude/docs/identifier-contract.md +195 -0
- package/dist/resources/templates/go-backend/.claude/docs/index.md +22 -0
- package/dist/resources/templates/go-backend/.claude/docs/logging.md +314 -0
- package/dist/resources/templates/go-backend/.claude/docs/mediagen-provider-onboarding-sop.md +917 -0
- package/dist/resources/templates/go-backend/.claude/docs/mediagen-provider-quick-reference.md +195 -0
- package/dist/resources/templates/go-backend/.claude/docs/module-standards.md +309 -0
- package/dist/resources/templates/go-backend/.claude/docs/openapi-contract.md +141 -0
- package/dist/resources/templates/go-backend/.claude/docs/payment-gateway-onboarding.md +283 -0
- package/dist/resources/templates/go-backend/.claude/docs/platform-boundary.md +191 -0
- package/dist/resources/templates/go-backend/.claude/docs/quality-gates.md +112 -0
- package/dist/resources/templates/go-backend/.dockerignore +6 -0
- package/dist/resources/templates/go-backend/.env.example +13 -0
- package/dist/resources/templates/go-backend/.gitattributes +2 -0
- package/dist/resources/templates/go-backend/AGENTS.md +1139 -0
- package/dist/resources/templates/go-backend/CLAUDE.md +1139 -0
- package/dist/resources/templates/go-backend/Dockerfile +14 -0
- package/dist/resources/templates/go-backend/Makefile +71 -0
- package/dist/resources/templates/go-backend/README.md +66 -0
- package/dist/resources/templates/go-backend/_gitignore +10 -0
- package/dist/resources/templates/go-backend/api/openapi/README.md +29 -0
- package/dist/resources/templates/go-backend/api/openapi/dist/artifact-manifest.json +19 -0
- package/dist/resources/templates/go-backend/api/openapi/dist/conformance-matrix.json +276 -0
- package/dist/resources/templates/go-backend/api/openapi/document.go +30 -0
- package/dist/resources/templates/go-backend/api/openapi/package.json +28 -0
- package/dist/resources/templates/go-backend/api/openapi/pnpm-lock.yaml +3052 -0
- package/dist/resources/templates/go-backend/api/openapi/redocly-source.yaml +18 -0
- package/dist/resources/templates/go-backend/api/openapi/redocly.yaml +8 -0
- package/dist/resources/templates/go-backend/api/openapi/sdk-generators.json +16 -0
- package/dist/resources/templates/go-backend/api/openapi/service-registry.json +39 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/conformance/runtime.arazzo.yaml +65 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/dist/internal.openapi.json +327 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/dist/runtime-contract.json +56 -0
- package/dist/resources/templates/go-backend/api/openapi/services/product-api/openapi.yaml +222 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/conformance/runtime.arazzo.yaml +65 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/dist/internal.openapi.json +327 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/dist/runtime-contract.json +56 -0
- package/dist/resources/templates/go-backend/api/openapi/services/worker/openapi.yaml +222 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/breaking.mjs +416 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/build.mjs +103 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/conformance_coverage.mjs +111 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/contract_compiler.mjs +62 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/contract_policy.mjs +208 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/delegated_contract.mjs +302 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/deterministic_archive.mjs +69 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_example_privacy.mjs +93 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_projection.mjs +498 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/documentation_quality.mjs +346 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/git_artifact_history.mjs +188 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/manifest.mjs +170 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/overlay.mjs +98 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/project.mjs +549 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/route_contract.mjs +156 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/runtime_conformance.mjs +193 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/scalar_asset_localization.mjs +164 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/sdk_generator.mjs +229 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/semantic_version.mjs +64 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/service_contract_inputs.mjs +16 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/breaking.test.mjs +365 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/build.test.mjs +42 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/conformance_coverage.test.mjs +88 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/contract_policy.test.mjs +257 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/delegated_contract.test.mjs +205 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_example_privacy.test.mjs +51 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_projection.test.mjs +368 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/documentation_quality.test.mjs +151 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/git_artifact_history.test.mjs +60 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/head_policy.test.mjs +8 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/overlay.test.mjs +44 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/projection.test.mjs +270 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/redocly_documentation_rules.test.mjs +146 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/release_manifest.test.mjs +76 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/route_contract.test.mjs +119 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/runtime_conformance.test.mjs +75 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/scalar_asset_localization.test.mjs +50 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/sdk_generator.test.mjs +31 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/semantic_version.test.mjs +60 -0
- package/dist/resources/templates/go-backend/api/openapi/tooling/test/service_contract_inputs.test.mjs +27 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/resources.go +125 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/runtime.go +102 -0
- package/dist/resources/templates/go-backend/cmd/internal/runtime/runtime_test.go +70 -0
- package/dist/resources/templates/go-backend/cmd/product-api/lifecycle_test.go +58 -0
- package/dist/resources/templates/go-backend/cmd/product-api/main.go +32 -0
- package/dist/resources/templates/go-backend/cmd/product-api/wire.go +13 -0
- package/dist/resources/templates/go-backend/cmd/product-api/wire_gen.go +94 -0
- package/dist/resources/templates/go-backend/cmd/worker/main.go +47 -0
- package/dist/resources/templates/go-backend/cmd/worker/wire.go +14 -0
- package/dist/resources/templates/go-backend/cmd/worker/wire_gen.go +111 -0
- package/dist/resources/templates/go-backend/configs/config.yaml +37 -0
- package/dist/resources/templates/go-backend/deployments/compose.yaml +71 -0
- package/dist/resources/templates/go-backend/docs/openapi-provenance.json +489 -0
- package/dist/resources/templates/go-backend/docs/runtime-provenance.json +175 -0
- package/dist/resources/templates/go-backend/docs/source-provenance.json +3568 -0
- package/dist/resources/templates/go-backend/docs/standards-provenance.json +1624 -0
- package/dist/resources/templates/go-backend/go.mod +256 -0
- package/dist/resources/templates/go-backend/go.sum +805 -0
- package/dist/resources/templates/go-backend/internal/common/canonicaljson/canonical.go +370 -0
- package/dist/resources/templates/go-backend/internal/common/canonicaljson/canonical_test.go +223 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/contracts.go +125 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/platform_client.go +212 -0
- package/dist/resources/templates/go-backend/internal/common/checkoutbff/platform_client_test.go +319 -0
- package/dist/resources/templates/go-backend/internal/common/contentaccess/contentaccess.go +50 -0
- package/dist/resources/templates/go-backend/internal/common/contracts/contact.go +85 -0
- package/dist/resources/templates/go-backend/internal/common/ctxutil/identity.go +20 -0
- package/dist/resources/templates/go-backend/internal/common/ctxutil/product.go +53 -0
- package/dist/resources/templates/go-backend/internal/common/enumdomain/payment.go +12 -0
- package/dist/resources/templates/go-backend/internal/common/enums/dto_admin.go +9 -0
- package/dist/resources/templates/go-backend/internal/common/enums/enum.go +1247 -0
- package/dist/resources/templates/go-backend/internal/common/enums/handler_admin.go +66 -0
- package/dist/resources/templates/go-backend/internal/common/enums/module.go +46 -0
- package/dist/resources/templates/go-backend/internal/common/enums/provider.go +10 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register.go +11 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_audit.go +274 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_command_replay.go +12 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_config.go +27 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_locale.go +37 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_ops.go +14 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_outbox.go +15 -0
- package/dist/resources/templates/go-backend/internal/common/enums/register_rule_expression.go +63 -0
- package/dist/resources/templates/go-backend/internal/common/enums/registry.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/httporigin/origin.go +62 -0
- package/dist/resources/templates/go-backend/internal/common/httporigin/origin_test.go +38 -0
- package/dist/resources/templates/go-backend/internal/common/iamcredential/plaintext.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/iamcredential/plaintext_test.go +29 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope.go +212 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_binding.go +26 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_filter.go +173 -0
- package/dist/resources/templates/go-backend/internal/common/iamscope/scope_filter_test.go +279 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/authorization_details.go +10 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/route_permission_policies.go +660 -0
- package/dist/resources/templates/go-backend/internal/common/internalapi/route_permission_policies_test.go +331 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/audience_token_source.go +166 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/bootstrap_token_exchanger.go +183 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/bound_service_token_signer.go +52 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/delegated_access_token_exchanger.go +189 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/delegated_access_token_exchanger_test.go +159 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/product_scoped_service_token_signer.go +92 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/provider.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/request_signer.go +86 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/resolver.go +69 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/resolver_test.go +42 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/route_scope.go +95 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/route_scope_test.go +78 -0
- package/dist/resources/templates/go-backend/internal/common/internalservice/service_identity_test.go +387 -0
- package/dist/resources/templates/go-backend/internal/common/jsonschema/compiler.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/jsonschema/compiler_test.go +41 -0
- package/dist/resources/templates/go-backend/internal/common/jwksapi/handler.go +83 -0
- package/dist/resources/templates/go-backend/internal/common/jwksapi/handler_test.go +104 -0
- package/dist/resources/templates/go-backend/internal/common/locale/locale.go +145 -0
- package/dist/resources/templates/go-backend/internal/common/locale/locale_test.go +75 -0
- package/dist/resources/templates/go-backend/internal/common/mediaref/mediaref.go +54 -0
- package/dist/resources/templates/go-backend/internal/common/mediaref/mediaref_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/apikey_auth.go +320 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/apikey_throttle.go +158 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/auth.go +40 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/auth_test.go +50 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/client_context.go +86 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/cors.go +68 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/event_context.go +18 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/gateway_identity.go +279 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/helpers.go +159 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_route_permission.go +171 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_token_auth.go +151 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_delegated_token_auth_test.go +99 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_service_identity.go +138 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/iam_service_token_auth.go +74 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/idempotent.go +273 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/idempotent_test.go +83 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/internal_route_permission.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/internal_route_permission_test.go +186 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/logging.go +191 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/metrics.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/middleware_test.go +1516 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/principal_context.go +160 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/principal_context_test.go +355 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/product_context.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/recovery.go +40 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/referral_attribution.go +178 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/requestid.go +48 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/resource_permission.go +790 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/resource_permission_test.go +440 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/service_credential_auth.go +67 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/tenant.go +148 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/throttle.go +310 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/trusted_client_ip.go +23 -0
- package/dist/resources/templates/go-backend/internal/common/middleware/trusted_client_ip_test.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/money/currency.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/money/errors.go +23 -0
- package/dist/resources/templates/go-backend/internal/common/money/format.go +123 -0
- package/dist/resources/templates/go-backend/internal/common/money/format_test.go +204 -0
- package/dist/resources/templates/go-backend/internal/common/money/gateway.go +144 -0
- package/dist/resources/templates/go-backend/internal/common/money/gateway_test.go +165 -0
- package/dist/resources/templates/go-backend/internal/common/money/rounding.go +56 -0
- package/dist/resources/templates/go-backend/internal/common/money/rounding_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/common/principal/context.go +56 -0
- package/dist/resources/templates/go-backend/internal/common/principal/principal.go +49 -0
- package/dist/resources/templates/go-backend/internal/common/productcode/code.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/productcode/code_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/providerconfig/schema.go +577 -0
- package/dist/resources/templates/go-backend/internal/common/providerconfig/schema_test.go +47 -0
- package/dist/resources/templates/go-backend/internal/common/requestprivacy/request.go +246 -0
- package/dist/resources/templates/go-backend/internal/common/requestprivacy/request_test.go +170 -0
- package/dist/resources/templates/go-backend/internal/common/response/pagination.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/response/response.go +110 -0
- package/dist/resources/templates/go-backend/internal/common/response/response_test.go +463 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/ast.go +141 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/ast_test.go +81 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/canonical.go +184 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/canonical_test.go +319 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/decoder.go +555 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/decoder_test.go +260 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/errors.go +55 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/evaluator.go +96 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/evaluator_test.go +220 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/fuzz_test.go +116 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/limits.go +331 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/schema.go +412 -0
- package/dist/resources/templates/go-backend/internal/common/ruleexpression/schema_test.go +164 -0
- package/dist/resources/templates/go-backend/internal/common/runtimeinput/runtime_input.go +627 -0
- package/dist/resources/templates/go-backend/internal/common/runtimeinput/runtime_input_test.go +245 -0
- package/dist/resources/templates/go-backend/internal/common/semver/errors.go +6 -0
- package/dist/resources/templates/go-backend/internal/common/semver/semver.go +125 -0
- package/dist/resources/templates/go-backend/internal/common/semver/semver_test.go +205 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/audience.go +48 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/audience_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/resource_identifier.go +33 -0
- package/dist/resources/templates/go-backend/internal/common/serviceidentity/resource_identifier_test.go +32 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/generator.go +99 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/generator_test.go +396 -0
- package/dist/resources/templates/go-backend/internal/common/tradeno/prefix.go +247 -0
- package/dist/resources/templates/go-backend/internal/common/types/asset_url.go +11 -0
- package/dist/resources/templates/go-backend/internal/common/types/billing.go +89 -0
- package/dist/resources/templates/go-backend/internal/common/types/billing_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/common/types/country.go +74 -0
- package/dist/resources/templates/go-backend/internal/common/types/country_test.go +28 -0
- package/dist/resources/templates/go-backend/internal/common/types/currency.go +60 -0
- package/dist/resources/templates/go-backend/internal/common/types/identifiers.go +41 -0
- package/dist/resources/templates/go-backend/internal/common/types/operator.go +28 -0
- package/dist/resources/templates/go-backend/internal/common/types/subscription_entitlement.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/types/subscription_entitlement_test.go +35 -0
- package/dist/resources/templates/go-backend/internal/common/types/tier.go +72 -0
- package/dist/resources/templates/go-backend/internal/common/types/types.go +411 -0
- package/dist/resources/templates/go-backend/internal/common/types/types_test.go +295 -0
- package/dist/resources/templates/go-backend/internal/common/utils/constants.go +100 -0
- package/dist/resources/templates/go-backend/internal/common/utils/crypto.go +158 -0
- package/dist/resources/templates/go-backend/internal/common/utils/crypto_test.go +345 -0
- package/dist/resources/templates/go-backend/internal/common/utils/duration.go +25 -0
- package/dist/resources/templates/go-backend/internal/common/utils/helpers.go +18 -0
- package/dist/resources/templates/go-backend/internal/common/utils/json.go +62 -0
- package/dist/resources/templates/go-backend/internal/common/utils/json_test.go +76 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pagination.go +51 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pagination_test.go +45 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pointer.go +107 -0
- package/dist/resources/templates/go-backend/internal/common/utils/pointer_test.go +15 -0
- package/dist/resources/templates/go-backend/internal/common/utils/slice.go +24 -0
- package/dist/resources/templates/go-backend/internal/common/utils/snowflake.go +110 -0
- package/dist/resources/templates/go-backend/internal/common/utils/snowflake_test.go +316 -0
- package/dist/resources/templates/go-backend/internal/common/utils/string.go +16 -0
- package/dist/resources/templates/go-backend/internal/common/utils/timefmt.go +42 -0
- package/dist/resources/templates/go-backend/internal/common/validator/validator.go +136 -0
- package/dist/resources/templates/go-backend/internal/common/validator/validator_test.go +240 -0
- package/dist/resources/templates/go-backend/internal/common/youtubeapi/client.go +224 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/document.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/document_test.go +104 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/route_validator.go +78 -0
- package/dist/resources/templates/go-backend/internal/core/apicontract/route_validator_test.go +108 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/assets/scalar-api-reference.js +2385 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/assets/scalar-api-reference.metadata.json +10 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/route.go +107 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/route_test.go +200 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/scalar.go +117 -0
- package/dist/resources/templates/go-backend/internal/core/apidocs/scalar_test.go +99 -0
- package/dist/resources/templates/go-backend/internal/core/audit/access_log_policy.go +91 -0
- package/dist/resources/templates/go-backend/internal/core/audit/access_log_policy_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/audit/actor_resolver.go +36 -0
- package/dist/resources/templates/go-backend/internal/core/audit/constants.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/audit/context.go +119 -0
- package/dist/resources/templates/go-backend/internal/core/audit/context_test.go +310 -0
- package/dist/resources/templates/go-backend/internal/core/audit/dto.go +468 -0
- package/dist/resources/templates/go-backend/internal/core/audit/dto_admin.go +172 -0
- package/dist/resources/templates/go-backend/internal/core/audit/enum.go +460 -0
- package/dist/resources/templates/go-backend/internal/core/audit/enum_test.go +314 -0
- package/dist/resources/templates/go-backend/internal/core/audit/errors.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/audit/handler.go +568 -0
- package/dist/resources/templates/go-backend/internal/core/audit/listener.go +319 -0
- package/dist/resources/templates/go-backend/internal/core/audit/listener_test.go +98 -0
- package/dist/resources/templates/go-backend/internal/core/audit/middleware.go +669 -0
- package/dist/resources/templates/go-backend/internal/core/audit/middleware_test.go +268 -0
- package/dist/resources/templates/go-backend/internal/core/audit/model.go +306 -0
- package/dist/resources/templates/go-backend/internal/core/audit/partition_job.go +316 -0
- package/dist/resources/templates/go-backend/internal/core/audit/ports.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/audit/provider.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/audit/repository.go +1007 -0
- package/dist/resources/templates/go-backend/internal/core/audit/repository_test.go +934 -0
- package/dist/resources/templates/go-backend/internal/core/audit/router.go +85 -0
- package/dist/resources/templates/go-backend/internal/core/audit/service.go +770 -0
- package/dist/resources/templates/go-backend/internal/core/audit/service_test.go +331 -0
- package/dist/resources/templates/go-backend/internal/core/audit/vo_admin.go +475 -0
- package/dist/resources/templates/go-backend/internal/core/cache/config.go +30 -0
- package/dist/resources/templates/go-backend/internal/core/cache/key.go +41 -0
- package/dist/resources/templates/go-backend/internal/core/cache/key_test.go +62 -0
- package/dist/resources/templates/go-backend/internal/core/cache/l1.go +153 -0
- package/dist/resources/templates/go-backend/internal/core/cache/l1_test.go +212 -0
- package/dist/resources/templates/go-backend/internal/core/cache/manager.go +278 -0
- package/dist/resources/templates/go-backend/internal/core/cache/manager_provider.go +24 -0
- package/dist/resources/templates/go-backend/internal/core/cache/metrics.go +126 -0
- package/dist/resources/templates/go-backend/internal/core/cache/namespace.go +46 -0
- package/dist/resources/templates/go-backend/internal/core/cache/namespace_test.go +90 -0
- package/dist/resources/templates/go-backend/internal/core/cache/options.go +39 -0
- package/dist/resources/templates/go-backend/internal/core/cache/options_test.go +96 -0
- package/dist/resources/templates/go-backend/internal/core/cache/redis.go +311 -0
- package/dist/resources/templates/go-backend/internal/core/cache/redis_test.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/cache/serializer.go +31 -0
- package/dist/resources/templates/go-backend/internal/core/cache/serializer_test.go +139 -0
- package/dist/resources/templates/go-backend/internal/core/cache/singleflight.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/cache/singleflight_test.go +211 -0
- package/dist/resources/templates/go-backend/internal/core/cache/warming.go +86 -0
- package/dist/resources/templates/go-backend/internal/core/clock/clock.go +66 -0
- package/dist/resources/templates/go-backend/internal/core/clock/clock_test.go +26 -0
- package/dist/resources/templates/go-backend/internal/core/clock/runtime_clock.go +283 -0
- package/dist/resources/templates/go-backend/internal/core/clock/runtime_clock_test.go +98 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/errors.go +6 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/model.go +90 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/model_test.go +79 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/namespace.go +7 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/persistence.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/persistence_test.go +185 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/provider.go +9 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/repository.go +22 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service.go +853 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service_persistence_test.go +432 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/service_test.go +891 -0
- package/dist/resources/templates/go-backend/internal/core/commandreplay/types.go +121 -0
- package/dist/resources/templates/go-backend/internal/core/config/config.go +2069 -0
- package/dist/resources/templates/go-backend/internal/core/config/config_test.go +1122 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/contract_test.go +388 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/docs.go +198 -0
- package/dist/resources/templates/go-backend/internal/core/config/contract/verify.go +424 -0
- package/dist/resources/templates/go-backend/internal/core/config/enum.go +46 -0
- package/dist/resources/templates/go-backend/internal/core/config/metadata.go +717 -0
- package/dist/resources/templates/go-backend/internal/core/config/metadata_test.go +228 -0
- package/dist/resources/templates/go-backend/internal/core/config/product_admin_config_test.go +210 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/aes_gcm.go +111 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/aes_gcm_test.go +364 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/encryptor.go +12 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/envelope_encryptor.go +134 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/envelope_encryptor_test.go +118 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/pem.go +112 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/pem_test.go +44 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/provider.go +130 -0
- package/dist/resources/templates/go-backend/internal/core/crypto/provider_test.go +92 -0
- package/dist/resources/templates/go-backend/internal/core/database/base_model.go +24 -0
- package/dist/resources/templates/go-backend/internal/core/database/clickhouse.go +121 -0
- package/dist/resources/templates/go-backend/internal/core/database/database.go +112 -0
- package/dist/resources/templates/go-backend/internal/core/database/database_logger_test.go +95 -0
- package/dist/resources/templates/go-backend/internal/core/database/errors.go +25 -0
- package/dist/resources/templates/go-backend/internal/core/database/metrics_plugin.go +105 -0
- package/dist/resources/templates/go-backend/internal/core/database/pool_collector.go +71 -0
- package/dist/resources/templates/go-backend/internal/core/database/read_replica.go +520 -0
- package/dist/resources/templates/go-backend/internal/core/database/transaction.go +170 -0
- package/dist/resources/templates/go-backend/internal/core/database/transaction_test.go +282 -0
- package/dist/resources/templates/go-backend/internal/core/distlock/lock.go +353 -0
- package/dist/resources/templates/go-backend/internal/core/distlock/lock_test.go +106 -0
- package/dist/resources/templates/go-backend/internal/core/errors/handler.go +189 -0
- package/dist/resources/templates/go-backend/internal/core/errors/handler_test.go +515 -0
- package/dist/resources/templates/go-backend/internal/core/eventbus/eventbus.go +667 -0
- package/dist/resources/templates/go-backend/internal/core/eventbus/eventbus_test.go +792 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/noop.go +22 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/provider.go +20 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/publisher.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/redis.go +109 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/routing.go +104 -0
- package/dist/resources/templates/go-backend/internal/core/eventstream/routing_test.go +71 -0
- package/dist/resources/templates/go-backend/internal/core/geoip/model.go +19 -0
- package/dist/resources/templates/go-backend/internal/core/geoip/service.go +88 -0
- package/dist/resources/templates/go-backend/internal/core/health/health.go +333 -0
- package/dist/resources/templates/go-backend/internal/core/health/health_test.go +27 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/client.go +772 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/client_test.go +287 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/download.go +578 -0
- package/dist/resources/templates/go-backend/internal/core/httpclient/download_test.go +374 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/jwk.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/keyring.go +144 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/keyring_test.go +128 -0
- package/dist/resources/templates/go-backend/internal/core/jwtkeyring/registry.go +60 -0
- package/dist/resources/templates/go-backend/internal/core/logger/logger.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/logger/logger_test.go +194 -0
- package/dist/resources/templates/go-backend/internal/core/observability/metrics.go +358 -0
- package/dist/resources/templates/go-backend/internal/core/observability/sentry.go +445 -0
- package/dist/resources/templates/go-backend/internal/core/observability/sentry_privacy_test.go +175 -0
- package/dist/resources/templates/go-backend/internal/core/observability/tracing.go +187 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/model.go +314 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/model_test.go +77 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/persistence.go +51 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/provider.go +23 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay.go +1138 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay_postgres_test.go +257 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/relay_test.go +690 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/rescheduler.go +164 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/rescheduler_test.go +209 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer.go +249 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer_postgres_test.go +170 -0
- package/dist/resources/templates/go-backend/internal/core/outbox/writer_test.go +123 -0
- package/dist/resources/templates/go-backend/internal/core/provider.go +198 -0
- package/dist/resources/templates/go-backend/internal/core/queue/metrics_middleware.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/queue/metrics_middleware_test.go +12 -0
- package/dist/resources/templates/go-backend/internal/core/queue/queue.go +288 -0
- package/dist/resources/templates/go-backend/internal/core/queue/queue_test.go +159 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/bulkhead.go +514 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/bulkhead_test.go +984 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/circuitbreaker.go +358 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/circuitbreaker_test.go +788 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/retry.go +318 -0
- package/dist/resources/templates/go-backend/internal/core/resilience/retry_test.go +735 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/recorder.go +305 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/run_context.go +124 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/run_context_test.go +85 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/scheduler.go +1589 -0
- package/dist/resources/templates/go-backend/internal/core/schedule/scheduler_control_test.go +808 -0
- package/dist/resources/templates/go-backend/internal/core/storage/oss_provider.go +398 -0
- package/dist/resources/templates/go-backend/internal/core/storage/oss_provider_test.go +89 -0
- package/dist/resources/templates/go-backend/internal/core/storage/path.go +110 -0
- package/dist/resources/templates/go-backend/internal/core/storage/path_test.go +301 -0
- package/dist/resources/templates/go-backend/internal/core/storage/s3_provider.go +489 -0
- package/dist/resources/templates/go-backend/internal/core/storage/s3_provider_test.go +60 -0
- package/dist/resources/templates/go-backend/internal/core/storage/storage.go +268 -0
- package/dist/resources/templates/go-backend/internal/core/storage/validation.go +225 -0
- package/dist/resources/templates/go-backend/internal/core/storage/validation_test.go +495 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/logger.go +38 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/provider.go +126 -0
- package/dist/resources/templates/go-backend/internal/core/temporal/provider_test.go +67 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/client.go +282 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/client_test.go +81 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/config.go +58 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/handler.go +53 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/hub.go +269 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/message.go +273 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/notifier.go +92 -0
- package/dist/resources/templates/go-backend/internal/core/websocket/provider.go +33 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/action.go +77 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/action_test.go +238 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/condition.go +107 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/decision.go +256 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/enum.go +643 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/errors.go +102 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/principal_record.go +21 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/product_context.go +486 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/resource.go +215 -0
- package/dist/resources/templates/go-backend/internal/integrations/onex/iam/resource_test.go +242 -0
- package/dist/resources/templates/go-backend/internal/products/README.md +5 -0
- package/dist/resources/templates/go-backend/internal/sharedevents/README.md +5 -0
- package/dist/resources/templates/go-backend/migrations/000001_infrastructure.down.sql +13 -0
- package/dist/resources/templates/go-backend/migrations/000001_infrastructure.up.sql +886 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error.go +327 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_code.go +65 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_test.go +41 -0
- package/dist/resources/templates/go-backend/pkg/apierror/error_type.go +14 -0
- package/dist/resources/templates/go-backend/pkg/apierror/http_response.go +216 -0
- package/dist/resources/templates/go-backend/pkg/apierror/http_response_test.go +216 -0
- package/dist/resources/templates/go-backend/scripts/check-openapi-clean-deletion.sh +54 -0
- package/dist/resources/templates/go-backend/scripts/test-migrations.sh +32 -0
- package/dist/resources/templates/go-backend/tests/infrastructure.sql +69 -0
- package/dist/resources/templates/mcp-server/.claude/docs/stack.md +338 -0
- package/dist/resources/templates/mcp-server/.editorconfig +13 -0
- package/dist/resources/templates/mcp-server/.env.example +8 -0
- package/dist/resources/templates/mcp-server/.github/ISSUE_TEMPLATE/bug_report.yml +104 -0
- package/dist/resources/templates/mcp-server/.github/ISSUE_TEMPLATE/feature_request.yml +54 -0
- package/dist/resources/templates/mcp-server/.github/PULL_REQUEST_TEMPLATE.md +36 -0
- package/dist/resources/templates/mcp-server/.github/workflows/ci.yml +78 -0
- package/dist/resources/templates/mcp-server/.husky/commit-msg +1 -0
- package/dist/resources/templates/mcp-server/.husky/pre-commit +1 -0
- package/dist/resources/templates/mcp-server/.lintstagedrc.json +4 -0
- package/dist/resources/templates/mcp-server/.nvmrc +1 -0
- package/dist/resources/templates/mcp-server/.prettierrc +8 -0
- package/dist/resources/templates/mcp-server/CONTRIBUTING.md +184 -0
- package/dist/resources/templates/mcp-server/Dockerfile +23 -0
- package/dist/resources/templates/mcp-server/LICENSE +21 -0
- package/dist/resources/templates/mcp-server/README.md +123 -0
- package/dist/resources/templates/mcp-server/_gitignore +26 -0
- package/dist/resources/templates/mcp-server/commitlint.config.js +24 -0
- package/dist/resources/templates/mcp-server/eslint.config.js +30 -0
- package/dist/resources/templates/mcp-server/package.json +72 -0
- package/dist/resources/templates/mcp-server/src/index.ts +27 -0
- package/dist/resources/templates/mcp-server/src/resources.ts +33 -0
- package/dist/resources/templates/mcp-server/src/services/.gitkeep +0 -0
- package/dist/resources/templates/mcp-server/src/tools.ts +43 -0
- package/dist/resources/templates/mcp-server/src/types/index.ts +19 -0
- package/dist/resources/templates/mcp-server/src/utils/index.ts +31 -0
- package/dist/resources/templates/mcp-server/tsconfig.json +22 -0
- package/dist/resources/templates/mcp-server/tsup.config.ts +14 -0
- package/dist/resources/templates/mcp-server/vitest.config.ts +15 -0
- package/dist/resources/templates/nuxt/.claude/docs/stack.md +666 -0
- package/dist/resources/templates/nuxt/.editorconfig +15 -0
- package/dist/resources/templates/nuxt/.env.example +22 -0
- package/dist/resources/templates/nuxt/.github/workflows/ci.yml +34 -0
- package/dist/resources/templates/nuxt/.husky/commit-msg +1 -0
- package/dist/resources/templates/nuxt/.husky/pre-commit +1 -0
- package/dist/resources/templates/nuxt/.nvmrc +1 -0
- package/dist/resources/templates/nuxt/.prettierignore +9 -0
- package/dist/resources/templates/nuxt/.prettierrc +1 -0
- package/dist/resources/templates/nuxt/README.md +23 -0
- package/dist/resources/templates/nuxt/_gitignore +7 -0
- package/dist/resources/templates/nuxt/app/app.config.ts +105 -0
- package/dist/resources/templates/nuxt/app/i18n/locales/en.json +5 -0
- package/dist/resources/templates/nuxt/app/pages/app/index.vue +224 -0
- package/dist/resources/templates/nuxt/app/pages/authors/[slug].vue +37 -0
- package/dist/resources/templates/nuxt/app/pages/blog/[slug].vue +55 -0
- package/dist/resources/templates/nuxt/app/pages/blog/category/[category].vue +38 -0
- package/dist/resources/templates/nuxt/app/pages/blog/index.vue +46 -0
- package/dist/resources/templates/nuxt/app/pages/index.vue +626 -0
- package/dist/resources/templates/nuxt/app/pages/legal/privacy.vue +21 -0
- package/dist/resources/templates/nuxt/app/pages/legal/terms.vue +21 -0
- package/dist/resources/templates/nuxt/app/pages/ui/index.vue +397 -0
- package/dist/resources/templates/nuxt/commitlint.config.mjs +1 -0
- package/dist/resources/templates/nuxt/eslint.config.mjs +4 -0
- package/dist/resources/templates/nuxt/lint-staged.config.mjs +8 -0
- package/dist/resources/templates/nuxt/nuxt.config.ts +71 -0
- package/dist/resources/templates/nuxt/package.json +67 -0
- package/dist/resources/templates/nuxt/public/apple-touch-icon.png +0 -0
- package/dist/resources/templates/nuxt/public/favicon.ico +0 -0
- package/dist/resources/templates/nuxt/public/favicon.svg +5 -0
- package/dist/resources/templates/nuxt/public/icon-16x16.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-192x192.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-32x32.png +0 -0
- package/dist/resources/templates/nuxt/public/icon-512x512.png +0 -0
- package/dist/resources/templates/nuxt/public/logo.svg +6 -0
- package/dist/resources/templates/nuxt/public/media/hero-product-gallery.png +0 -0
- package/dist/resources/templates/nuxt/server/api/content/sitemap-urls.get.ts +12 -0
- package/dist/resources/templates/nuxt/server/api/preview.get.ts +9 -0
- package/dist/resources/templates/nuxt/stylelint.config.mjs +3 -0
- package/dist/resources/templates/nuxt/test/e2e/rendering.test.ts +13 -0
- package/dist/resources/templates/nuxt/tsconfig.json +3 -0
- package/dist/resources/templates/nuxt/vitest.config.ts +8 -0
- package/package.json +8 -5
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve, dirname } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { compileCanonicalContract, lintContractDocument, publicationLintConfig } from './contract_compiler.mjs';
|
|
6
|
+
import { apiRoot, canonicalJSON, projectDocument, readRegistry, readStructured, sha256 } from './project.mjs';
|
|
7
|
+
import { conformanceMatrix } from './conformance_coverage.mjs';
|
|
8
|
+
import { applyDocumentationProjection } from './documentation_projection.mjs';
|
|
9
|
+
import { routeContract } from './route_contract.mjs';
|
|
10
|
+
import { generateSDKPackages } from './sdk_generator.mjs';
|
|
11
|
+
export const backendRoot = resolve(apiRoot, '../..');
|
|
12
|
+
export async function assertToolVersions({ requireOASDiff = false } = {}) {
|
|
13
|
+
const pkg = JSON.parse(await readFile(resolve(apiRoot, 'package.json'), 'utf8'));
|
|
14
|
+
const versions = {};
|
|
15
|
+
for (const [name, expected] of Object.entries(pkg.devDependencies)) {
|
|
16
|
+
const actual = JSON.parse(await readFile(resolve(apiRoot, 'node_modules', name, 'package.json'), 'utf8')).version;
|
|
17
|
+
if (actual !== expected) throw new Error(`${name} version ${actual} does not match ${expected}`);
|
|
18
|
+
versions[name] = expected;
|
|
19
|
+
}
|
|
20
|
+
if (requireOASDiff) {
|
|
21
|
+
const version = execFileSync('oasdiff', ['--version'], { encoding: 'utf8' }).trim().replace(/^oasdiff version v?/, '');
|
|
22
|
+
if (version !== '1.23.0') throw new Error('oasdiff 1.23.0 is required');
|
|
23
|
+
versions.oasdiff = version;
|
|
24
|
+
}
|
|
25
|
+
return versions;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function runtimeMetadata(service, document, delegated) {
|
|
29
|
+
const routes = routeContract(document).map(({ method, path }) => ({ method, path }));
|
|
30
|
+
return {
|
|
31
|
+
schema_version: 2,
|
|
32
|
+
media_type: 'application/vnd.onex.runtime-contract+json;version=2',
|
|
33
|
+
service: service.id,
|
|
34
|
+
display_name: service.display_name,
|
|
35
|
+
api_version: document.info.version,
|
|
36
|
+
sha256: sha256(canonicalJSON(document)),
|
|
37
|
+
operation_count: routes.length,
|
|
38
|
+
native_operation_count: routes.length - delegated.evidence.reduce((total, entry) => total + entry.operation_count, 0),
|
|
39
|
+
delegated_contracts: delegated.evidence.map(({ id, operation_count }) => ({ id, operation_count })),
|
|
40
|
+
route_exclusions: service.route_exclusions,
|
|
41
|
+
routes,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function publicationDocument(document, audience) {
|
|
46
|
+
return audience === 'internal' ? document : applyDocumentationProjection(projectDocument(document, audience), {
|
|
47
|
+
audience, service: document.info.title, sourceSha256: sha256(canonicalJSON(document)),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function main() {
|
|
52
|
+
const versions = await assertToolVersions();
|
|
53
|
+
const check = process.argv.includes('--check');
|
|
54
|
+
const sdk = process.argv.includes('--sdk');
|
|
55
|
+
const registry = await readRegistry();
|
|
56
|
+
const files = new Map();
|
|
57
|
+
const artifacts = [];
|
|
58
|
+
const serviceDocuments = new Map();
|
|
59
|
+
const workflowDocuments = new Map();
|
|
60
|
+
for (const service of registry.services) {
|
|
61
|
+
const { document, delegated } = await compileCanonicalContract(service);
|
|
62
|
+
serviceDocuments.set(service.id, document);
|
|
63
|
+
workflowDocuments.set(service.id, [await readStructured(resolve(apiRoot, service.runtime_conformance))]);
|
|
64
|
+
const root = `services/${service.id}/dist`;
|
|
65
|
+
files.set(`${root}/runtime-contract.json`, canonicalJSON(runtimeMetadata(service, document, delegated)));
|
|
66
|
+
for (const audience of service.publications) {
|
|
67
|
+
const projected = publicationDocument(document, audience);
|
|
68
|
+
if (audience !== 'internal') {
|
|
69
|
+
await lintContractDocument(projected, `${service.id}-${audience}`, publicationLintConfig);
|
|
70
|
+
}
|
|
71
|
+
const spec = canonicalJSON(projected);
|
|
72
|
+
const contractPath = `${root}/${audience}.openapi.json`;
|
|
73
|
+
files.set(contractPath, spec);
|
|
74
|
+
artifacts.push({ service: service.id, audience, api_version: projected.info.version,
|
|
75
|
+
path: contractPath, sha256: sha256(spec) });
|
|
76
|
+
if (sdk && audience !== 'internal') {
|
|
77
|
+
const gitRevision = process.env.SOURCE_REVISION ?? execFileSync('git', ['rev-parse', 'HEAD'], {
|
|
78
|
+
cwd: apiRoot, encoding: 'utf8',
|
|
79
|
+
}).trim();
|
|
80
|
+
if (!/^[a-f0-9]{40}$/.test(gitRevision)) throw new Error('SDK SOURCE_REVISION must be a full Git revision');
|
|
81
|
+
const packages = await generateSDKPackages({ audience, contractSha256: sha256(spec), document: projected,
|
|
82
|
+
gitRevision, service: service.id, toolVersions: versions });
|
|
83
|
+
for (const item of packages) for (const [path, content] of item.files) {
|
|
84
|
+
files.set(`services/${service.id}/sdk/${audience}/${item.generator}/${path}`, content);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
artifacts.sort((left, right) => `${left.service}\0${left.audience}`.localeCompare(`${right.service}\0${right.audience}`));
|
|
90
|
+
files.set('dist/conformance-matrix.json', canonicalJSON(conformanceMatrix(serviceDocuments, workflowDocuments)));
|
|
91
|
+
files.set('dist/artifact-manifest.json', canonicalJSON({ schema_version: 1, artifacts }));
|
|
92
|
+
for (const [path, content] of files) {
|
|
93
|
+
const target = resolve(apiRoot, path);
|
|
94
|
+
if (check) {
|
|
95
|
+
const current = await readFile(target);
|
|
96
|
+
if (!current.equals(Buffer.from(content))) throw new Error(`generated OpenAPI artifact differs: ${path}`);
|
|
97
|
+
} else {
|
|
98
|
+
await mkdir(dirname(target), { recursive: true });
|
|
99
|
+
await writeFile(target, content);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) await main();
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { operationEntries } from './project.mjs';
|
|
2
|
+
|
|
3
|
+
export function requiredContractAssertions(operation) {
|
|
4
|
+
const assertions = new Set();
|
|
5
|
+
for (const parameter of operation.parameters ?? []) {
|
|
6
|
+
assertions.add(`parameter:${parameter.in}:${parameter.name}`);
|
|
7
|
+
}
|
|
8
|
+
if (operation.requestBody) assertions.add('request_body');
|
|
9
|
+
for (const [status, response] of Object.entries(operation.responses ?? {})) {
|
|
10
|
+
assertions.add(`response:${status}`);
|
|
11
|
+
for (const name of Object.keys(response.headers ?? {})) {
|
|
12
|
+
assertions.add(`response_header:${status}:${name}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (operation.security.length === 0) {
|
|
16
|
+
assertions.add('security:anonymous');
|
|
17
|
+
} else {
|
|
18
|
+
operation.security.forEach((requirement, index) => {
|
|
19
|
+
assertions.add(`security:${index}:${Object.keys(requirement).sort().join('+') || 'anonymous'}`);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (operation['x-onex-idempotency']) assertions.add('idempotency');
|
|
23
|
+
return [...assertions].sort();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function conformanceMatrix(serviceDocuments, workflowDocuments) {
|
|
27
|
+
const operations = [];
|
|
28
|
+
const services = [];
|
|
29
|
+
let workflowCount = 0;
|
|
30
|
+
let runtimeStepCount = 0;
|
|
31
|
+
|
|
32
|
+
for (const [service, document] of [...serviceDocuments].sort(([left], [right]) => left.localeCompare(right))) {
|
|
33
|
+
const entries = operationEntries(document);
|
|
34
|
+
const operationIds = new Set(entries.map(({ operation }) => operation.operationId));
|
|
35
|
+
const runtime = runtimeWorkflowCoverage(workflowDocuments.get(service) ?? [], operationIds, service);
|
|
36
|
+
workflowCount += runtime.workflowCount;
|
|
37
|
+
runtimeStepCount += runtime.stepCount;
|
|
38
|
+
services.push({
|
|
39
|
+
operation_count: entries.length,
|
|
40
|
+
runtime_operation_count: runtime.coverage.size,
|
|
41
|
+
runtime_step_count: runtime.stepCount,
|
|
42
|
+
runtime_workflow_count: runtime.workflowCount,
|
|
43
|
+
service,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
for (const { method, operation, path } of entries) {
|
|
47
|
+
operations.push({
|
|
48
|
+
contract_assertions: requiredContractAssertions(operation),
|
|
49
|
+
method: method.toUpperCase(),
|
|
50
|
+
operation_id: operation.operationId,
|
|
51
|
+
path,
|
|
52
|
+
runtime_scenarios: [...(runtime.coverage.get(operation.operationId) ?? [])].sort(),
|
|
53
|
+
service,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
contract_assertion_count: operations.reduce((total, operation) => total + operation.contract_assertions.length, 0),
|
|
60
|
+
operation_count: operations.length,
|
|
61
|
+
operations,
|
|
62
|
+
runtime_operation_count: operations.filter((operation) => operation.runtime_scenarios.length > 0).length,
|
|
63
|
+
runtime_step_count: runtimeStepCount,
|
|
64
|
+
runtime_workflow_count: workflowCount,
|
|
65
|
+
schema_version: 2,
|
|
66
|
+
services,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function runtimeWorkflowCoverage(arazzoDocuments, operationIds, service = 'service') {
|
|
71
|
+
const coverage = new Map();
|
|
72
|
+
let workflowCount = 0;
|
|
73
|
+
let stepCount = 0;
|
|
74
|
+
for (const document of arazzoDocuments) {
|
|
75
|
+
if (document?.arazzo !== '1.0.1') {
|
|
76
|
+
throw new Error(`${service} Arazzo documents must use version 1.0.1`);
|
|
77
|
+
}
|
|
78
|
+
for (const workflow of document.workflows ?? []) {
|
|
79
|
+
if (!workflow.workflowId || !Array.isArray(workflow.steps) || workflow.steps.length === 0) {
|
|
80
|
+
throw new Error(`${service} Arazzo workflows must declare workflowId and steps`);
|
|
81
|
+
}
|
|
82
|
+
workflowCount += 1;
|
|
83
|
+
for (const step of workflow.steps) {
|
|
84
|
+
validateRuntimeStep(step, operationIds, service);
|
|
85
|
+
stepCount += 1;
|
|
86
|
+
const current = coverage.get(step.operationId) ?? new Set();
|
|
87
|
+
for (const scenario of step['x-onex-covers']) current.add(scenario);
|
|
88
|
+
coverage.set(step.operationId, current);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (workflowCount === 0) {
|
|
93
|
+
throw new Error(`${service} must declare at least one executable Arazzo workflow`);
|
|
94
|
+
}
|
|
95
|
+
return { coverage, stepCount, workflowCount };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function validateRuntimeStep(step, operationIds, service) {
|
|
99
|
+
if (!step.stepId || !step.operationId || !operationIds.has(step.operationId)) {
|
|
100
|
+
throw new Error(`${service} Arazzo step ${step.stepId ?? '<unknown>'} must reference a known operationId`);
|
|
101
|
+
}
|
|
102
|
+
if (!Array.isArray(step['x-onex-covers']) || step['x-onex-covers'].length === 0) {
|
|
103
|
+
throw new Error(`${service} Arazzo step ${step.stepId} must declare x-onex-covers`);
|
|
104
|
+
}
|
|
105
|
+
if (!/^[a-z][a-z0-9-]*$/.test(step['x-onex-fixture-profile'] ?? '')) {
|
|
106
|
+
throw new Error(`${service} Arazzo step ${step.stepId} must declare x-onex-fixture-profile`);
|
|
107
|
+
}
|
|
108
|
+
if (!Array.isArray(step.successCriteria) || step.successCriteria.length === 0) {
|
|
109
|
+
throw new Error(`${service} Arazzo step ${step.stepId} must declare successCriteria`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { applyContractPolicies } from './contract_policy.mjs';
|
|
7
|
+
import { composeDelegatedContracts } from './delegated_contract.mjs';
|
|
8
|
+
import { apiRoot, canonicalJSON, validateDocument } from './project.mjs';
|
|
9
|
+
import { routeContract } from './route_contract.mjs';
|
|
10
|
+
|
|
11
|
+
const backendRoot = resolve(apiRoot, '../..');
|
|
12
|
+
export const contractSourceLintConfig = resolve(apiRoot, 'redocly-source.yaml');
|
|
13
|
+
export const publicationLintConfig = resolve(apiRoot, 'redocly.yaml');
|
|
14
|
+
export const redoclyExecutable = resolve(apiRoot, 'node_modules/.bin/redocly');
|
|
15
|
+
|
|
16
|
+
export async function compileCanonicalContract(service) {
|
|
17
|
+
const sourcePath = resolve(apiRoot, service.source);
|
|
18
|
+
lintContractSource(sourcePath, contractSourceLintConfig);
|
|
19
|
+
const source = await bundleSource(sourcePath);
|
|
20
|
+
const delegated = await composeDelegatedContracts(service, source);
|
|
21
|
+
const document = applyContractPolicies(delegated.document);
|
|
22
|
+
await lintContractDocument(document, service.id, contractSourceLintConfig);
|
|
23
|
+
validateDocument(document, {
|
|
24
|
+
audience: 'internal',
|
|
25
|
+
documentationLocale: service.documentation_locale,
|
|
26
|
+
service: service.id,
|
|
27
|
+
});
|
|
28
|
+
routeContract(document);
|
|
29
|
+
return { delegated, document, sourcePath };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function lintContractSource(sourcePath, configPath) {
|
|
33
|
+
execFileSync(redoclyExecutable, ['lint', sourcePath, '--config', configPath, '--format', 'stylish', '--max-problems', '1000'], commandOptions());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function lintContractDocument(document, label, configPath) {
|
|
37
|
+
const tempRoot = resolve(backendRoot, 'tmp', `openapi-lint-${randomUUID()}`);
|
|
38
|
+
const input = resolve(tempRoot, `${label}.json`);
|
|
39
|
+
await mkdir(tempRoot, { recursive: true });
|
|
40
|
+
try {
|
|
41
|
+
await writeFile(input, canonicalJSON(document));
|
|
42
|
+
lintContractSource(input, configPath);
|
|
43
|
+
} finally {
|
|
44
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function bundleSource(sourcePath) {
|
|
49
|
+
const tempRoot = resolve(backendRoot, 'tmp', `openapi-bundle-${randomUUID()}`);
|
|
50
|
+
const output = resolve(tempRoot, 'bundle.json');
|
|
51
|
+
await mkdir(tempRoot, { recursive: true });
|
|
52
|
+
try {
|
|
53
|
+
execFileSync(redoclyExecutable, ['bundle', sourcePath, '--config', contractSourceLintConfig, '--ext', 'json', '--output', output, '--remove-unused-components', '--component-renaming-conflicts-severity', 'error'], commandOptions());
|
|
54
|
+
return JSON.parse(await readFile(output, 'utf8'));
|
|
55
|
+
} finally {
|
|
56
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function commandOptions() {
|
|
61
|
+
return { cwd: apiRoot, encoding: 'utf8', env: { ...process.env, FORCE_COLOR: '0', NO_COLOR: '1' }, stdio: ['ignore', 'pipe', 'pipe'] };
|
|
62
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { operationEntries } from './project.mjs';
|
|
2
|
+
|
|
3
|
+
const defaultErrorResponseSchema = 'ErrorResponse';
|
|
4
|
+
const serviceErrorResponseSchemaExtension = 'x-onex-error-response-schema';
|
|
5
|
+
|
|
6
|
+
const standardAuthenticationResponses = Object.freeze({
|
|
7
|
+
401: {
|
|
8
|
+
description: '需要身份认证',
|
|
9
|
+
},
|
|
10
|
+
403: {
|
|
11
|
+
description: '无权执行此操作',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export function applyContractPolicies(document) {
|
|
16
|
+
const result = structuredClone(document);
|
|
17
|
+
if (Object.hasOwn(result, serviceErrorResponseSchemaExtension)) {
|
|
18
|
+
throw new Error(`${serviceErrorResponseSchemaExtension} is forbidden; use components.schemas.ErrorResponse`);
|
|
19
|
+
}
|
|
20
|
+
if (result.components?.schemas?.[defaultErrorResponseSchema]) {
|
|
21
|
+
assertCanonicalErrorSchemas(result.components.schemas);
|
|
22
|
+
}
|
|
23
|
+
const errorResponseSchema = defaultErrorResponseSchema;
|
|
24
|
+
const errorResponseReference = `#/components/schemas/${errorResponseSchema}`;
|
|
25
|
+
const operations = operationEntries(result);
|
|
26
|
+
const securedOperations = operations.filter(({ operation }) => requiresAuthentication(operation));
|
|
27
|
+
|
|
28
|
+
for (const { operation } of securedOperations) {
|
|
29
|
+
for (const [status, response] of Object.entries(standardAuthenticationResponses)) {
|
|
30
|
+
if (!Object.hasOwn(operation.responses, status)) {
|
|
31
|
+
operation.responses[status] = responseWithSchema(response, errorResponseReference);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const response of Object.values(result.components?.responses ?? {})) {
|
|
37
|
+
resolveResponseObject(result, response);
|
|
38
|
+
}
|
|
39
|
+
const errorsWithoutSchema = operations.filter(({ method }) => method !== 'head').flatMap(({ operation }) => Object.entries(operation.responses ?? {})
|
|
40
|
+
.map(([status, response]) => ({ operation, resolved: resolveResponseObject(result, response), status })))
|
|
41
|
+
.filter(({ resolved, status }) => /^[45]/u.test(status) && !hasResponseSchema(resolved) && !isEmptyMethodResponse(status, resolved));
|
|
42
|
+
if ((securedOperations.length > 0 || errorsWithoutSchema.length > 0) && !result.components?.schemas?.[errorResponseSchema]) {
|
|
43
|
+
throw new Error(`contract policies require components.schemas.${errorResponseSchema}`);
|
|
44
|
+
}
|
|
45
|
+
for (const { operation, resolved, status } of errorsWithoutSchema) {
|
|
46
|
+
operation.responses[status] = responseWithSchema(resolved, errorResponseReference);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function assertCanonicalErrorSchemas(schemas) {
|
|
52
|
+
assertObjectSchema(schemas.ErrorResponse, 'ErrorResponse', ['error'], ['error']);
|
|
53
|
+
assertReference(schemas.ErrorResponse.properties.error, '#/components/schemas/ErrorDetail', 'ErrorResponse.error');
|
|
54
|
+
|
|
55
|
+
assertObjectSchema(schemas.ErrorDetail, 'ErrorDetail', ['code', 'errors', 'message', 'param', 'type'], ['code', 'message', 'type']);
|
|
56
|
+
assertNonEmptyString(schemas.ErrorDetail.properties.code, 'ErrorDetail.code');
|
|
57
|
+
assertNonEmptyString(schemas.ErrorDetail.properties.message, 'ErrorDetail.message');
|
|
58
|
+
assertNonEmptyString(schemas.ErrorDetail.properties.param, 'ErrorDetail.param');
|
|
59
|
+
assertNonEmptyString(schemas.ErrorDetail.properties.type, 'ErrorDetail.type');
|
|
60
|
+
assertAllowedKeys(schemas.ErrorDetail.properties.errors, 'ErrorDetail.errors', ['description', 'items', 'type']);
|
|
61
|
+
if (schemas.ErrorDetail.properties.errors?.type !== 'array') {
|
|
62
|
+
throw new Error('components.schemas.ErrorDetail.errors must be an array');
|
|
63
|
+
}
|
|
64
|
+
assertReference(schemas.ErrorDetail.properties.errors.items, '#/components/schemas/FieldError', 'ErrorDetail.errors items');
|
|
65
|
+
|
|
66
|
+
assertObjectSchema(schemas.FieldError, 'FieldError', ['field', 'message'], ['field', 'message']);
|
|
67
|
+
assertNonEmptyString(schemas.FieldError.properties.field, 'FieldError.field');
|
|
68
|
+
assertNonEmptyString(schemas.FieldError.properties.message, 'FieldError.message');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function assertObjectSchema(schema, name, expectedProperties, expectedRequired) {
|
|
72
|
+
assertAllowedKeys(schema, name, [
|
|
73
|
+
'additionalProperties',
|
|
74
|
+
'description',
|
|
75
|
+
'properties',
|
|
76
|
+
'required',
|
|
77
|
+
'type',
|
|
78
|
+
'x-onex-audience',
|
|
79
|
+
'x-onex-stability',
|
|
80
|
+
]);
|
|
81
|
+
if (schema?.type !== 'object' || schema.additionalProperties !== false) {
|
|
82
|
+
throw new Error(`components.schemas.${name} must be a closed object`);
|
|
83
|
+
}
|
|
84
|
+
if (!sameMembers(Object.keys(schema.properties ?? {}), expectedProperties)) {
|
|
85
|
+
throw new Error(`components.schemas.${name} properties must be ${expectedProperties.join(', ')}`);
|
|
86
|
+
}
|
|
87
|
+
if (!sameMembers(schema.required ?? [], expectedRequired)) {
|
|
88
|
+
throw new Error(`components.schemas.${name} required fields must be ${expectedRequired.join(', ')}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function assertNonEmptyString(schema, label) {
|
|
93
|
+
assertAllowedKeys(schema, label, ['description', 'example', 'minLength', 'type']);
|
|
94
|
+
if (schema?.type !== 'string' || schema.minLength !== 1) {
|
|
95
|
+
throw new Error(`components.schemas.${label} must be a non-empty string`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function assertReference(schema, reference, label) {
|
|
100
|
+
assertAllowedKeys(schema, label, ['$ref', 'description']);
|
|
101
|
+
if (schema?.$ref !== reference) {
|
|
102
|
+
throw new Error(`components.schemas.${label} must reference ${reference}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function assertAllowedKeys(value, label, allowedKeys) {
|
|
107
|
+
if (!isObject(value)) {
|
|
108
|
+
throw new Error(`components.schemas.${label} must be an object`);
|
|
109
|
+
}
|
|
110
|
+
const unexpectedKeys = Object.keys(value).filter((key) => !allowedKeys.includes(key));
|
|
111
|
+
if (unexpectedKeys.length > 0) {
|
|
112
|
+
throw new Error(`components.schemas.${label} contains unsupported keys: ${unexpectedKeys.join(', ')}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function sameMembers(actual, expected) {
|
|
117
|
+
return actual.length === expected.length && expected.every((value) => actual.includes(value));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function requiresAuthentication(operation) {
|
|
121
|
+
return Array.isArray(operation.security) &&
|
|
122
|
+
operation.security.length > 0 &&
|
|
123
|
+
operation.security.every((requirement) => Object.keys(requirement).length > 0);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function hasResponseSchema(response) {
|
|
127
|
+
return Object.values(response?.content ?? {}).some((media) => media?.schema);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function isEmptyMethodResponse(status, response) {
|
|
131
|
+
return status === '405' && response?.headers?.Allow;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function responseWithSchema(response, schemaReference) {
|
|
135
|
+
const existing = structuredClone(response);
|
|
136
|
+
return {
|
|
137
|
+
...existing,
|
|
138
|
+
content: {
|
|
139
|
+
...(existing.content ?? {}),
|
|
140
|
+
'application/json': {
|
|
141
|
+
...(existing.content?.['application/json'] ?? {}),
|
|
142
|
+
schema: { $ref: schemaReference },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function resolveResponseObject(document, value, visited = new Set()) {
|
|
149
|
+
if (!isObject(value) || !Object.hasOwn(value, '$ref')) return value;
|
|
150
|
+
assertResponseReference(value);
|
|
151
|
+
const reference = value.$ref;
|
|
152
|
+
if (visited.has(reference)) {
|
|
153
|
+
throw new Error(`circular response reference: ${reference}`);
|
|
154
|
+
}
|
|
155
|
+
visited.add(reference);
|
|
156
|
+
const name = parseResponseComponentReference(reference);
|
|
157
|
+
const target = document.components?.responses?.[name];
|
|
158
|
+
if (!isObject(target)) {
|
|
159
|
+
throw new Error(`unresolved response reference: ${reference}`);
|
|
160
|
+
}
|
|
161
|
+
const resolved = structuredClone(resolveResponseObject(document, target, visited));
|
|
162
|
+
if (Object.hasOwn(value, 'description')) resolved.description = value.description;
|
|
163
|
+
return resolved;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function assertResponseReference(reference) {
|
|
167
|
+
const allowedKeys = ['$ref', 'description', 'summary'];
|
|
168
|
+
const unexpectedKeys = Object.keys(reference).filter((key) => !allowedKeys.includes(key));
|
|
169
|
+
if (unexpectedKeys.length > 0) {
|
|
170
|
+
throw new Error(`response Reference Object contains unsupported siblings: ${unexpectedKeys.join(', ')}`);
|
|
171
|
+
}
|
|
172
|
+
if (typeof reference.$ref !== 'string' || reference.$ref.length === 0) {
|
|
173
|
+
throw new Error('response Reference Object must contain a non-empty $ref');
|
|
174
|
+
}
|
|
175
|
+
for (const key of ['description', 'summary']) {
|
|
176
|
+
if (Object.hasOwn(reference, key) && typeof reference[key] !== 'string') {
|
|
177
|
+
throw new Error(`response Reference Object ${key} must be a string`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function parseResponseComponentReference(reference) {
|
|
183
|
+
let pointer;
|
|
184
|
+
try {
|
|
185
|
+
pointer = decodeURIComponent(reference.slice(1));
|
|
186
|
+
} catch (error) {
|
|
187
|
+
throw new Error(`invalid response reference: ${reference}`, { cause: error });
|
|
188
|
+
}
|
|
189
|
+
if (!pointer.startsWith('/')) {
|
|
190
|
+
throw new Error(`response reference must target internal components.responses: ${reference}`);
|
|
191
|
+
}
|
|
192
|
+
const tokens = pointer.slice(1).split('/').map(decodePointerToken);
|
|
193
|
+
if (tokens.length !== 3 || tokens[0] !== 'components' || tokens[1] !== 'responses') {
|
|
194
|
+
throw new Error(`response reference must target internal components.responses: ${reference}`);
|
|
195
|
+
}
|
|
196
|
+
return tokens[2];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function decodePointerToken(token) {
|
|
200
|
+
if (/~(?:[^01]|$)/u.test(token)) {
|
|
201
|
+
throw new Error(`response reference contains an invalid JSON Pointer token: ${token}`);
|
|
202
|
+
}
|
|
203
|
+
return token.replaceAll('~1', '/').replaceAll('~0', '~');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function isObject(value) {
|
|
207
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
208
|
+
}
|