@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,346 @@
|
|
|
1
|
+
import { isPlainObject, operationEntries } from './project.mjs';
|
|
2
|
+
import { documentationProjectionVersion, resolveReference } from './documentation_projection.mjs';
|
|
3
|
+
import {
|
|
4
|
+
isEmailExampleKey,
|
|
5
|
+
isSafeSensitiveExampleValue,
|
|
6
|
+
isSensitiveExampleKey,
|
|
7
|
+
} from './documentation_example_privacy.mjs';
|
|
8
|
+
|
|
9
|
+
export const documentationQualityRulesetVersion = 2;
|
|
10
|
+
|
|
11
|
+
const requiredMetrics = Object.freeze([
|
|
12
|
+
'operation_descriptions',
|
|
13
|
+
'parameter_descriptions',
|
|
14
|
+
'request_body_descriptions',
|
|
15
|
+
'response_descriptions',
|
|
16
|
+
'schema_property_descriptions',
|
|
17
|
+
'named_media_examples',
|
|
18
|
+
'owner_evidence',
|
|
19
|
+
'lifecycle_evidence',
|
|
20
|
+
'last_reviewed_at_evidence',
|
|
21
|
+
'review_digest_evidence',
|
|
22
|
+
'freshness_evidence',
|
|
23
|
+
'openapi_link_evidence',
|
|
24
|
+
'documentation_link_validity',
|
|
25
|
+
'error_evidence',
|
|
26
|
+
'sdk_typecheck_evidence',
|
|
27
|
+
'code_example_evidence',
|
|
28
|
+
'source_contract_evidence',
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
export async function analyzeDocumentationQuality({
|
|
32
|
+
audience,
|
|
33
|
+
canonicalDocument,
|
|
34
|
+
document,
|
|
35
|
+
linkChecker = checkDocumentationURL,
|
|
36
|
+
service,
|
|
37
|
+
sdkEvidence = [],
|
|
38
|
+
sourceContractSha256,
|
|
39
|
+
sourceSha256,
|
|
40
|
+
}) {
|
|
41
|
+
const metrics = Object.fromEntries(requiredMetrics.map((name) => [name, createMetric()]));
|
|
42
|
+
const canonicalOperations = new Map(operationEntries(canonicalDocument).map(({ operation }) => [operation.operationId, operation]));
|
|
43
|
+
|
|
44
|
+
for (const { method, operation, path, pathItem } of operationEntries(document)) {
|
|
45
|
+
const label = `${method.toUpperCase()} ${path}`;
|
|
46
|
+
cover(metrics.operation_descriptions, hasText(operation.description), label, isGenerated(operation));
|
|
47
|
+
|
|
48
|
+
const parameters = [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])];
|
|
49
|
+
for (const [index, reference] of parameters.entries()) {
|
|
50
|
+
const parameter = resolveReference(document, reference);
|
|
51
|
+
cover(metrics.parameter_descriptions, hasText(parameter?.description), `${label} parameter[${index}]`, isGenerated(parameter));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const requestBody = resolveReference(document, operation.requestBody);
|
|
55
|
+
if (requestBody) {
|
|
56
|
+
cover(metrics.request_body_descriptions, hasText(requestBody.description), `${label} requestBody`, isGenerated(requestBody));
|
|
57
|
+
inspectMediaExamples(metrics.named_media_examples, document, requestBody.content, `${label} requestBody`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (const [status, reference] of Object.entries(operation.responses ?? {})) {
|
|
61
|
+
const response = resolveReference(document, reference);
|
|
62
|
+
cover(metrics.response_descriptions, hasText(response?.description), `${label} response ${status}`, isGenerated(response));
|
|
63
|
+
inspectMediaExamples(metrics.named_media_examples, document, response?.content, `${label} response ${status}`);
|
|
64
|
+
if (/^[45]/.test(status)) {
|
|
65
|
+
const hasSchemaEvidence = Object.values(response?.content ?? {}).some((media) => media?.schema);
|
|
66
|
+
const hasEmptyMethodEvidence = status === '405' && response?.headers?.Allow;
|
|
67
|
+
cover(metrics.error_evidence, hasText(response?.description) && Boolean(hasSchemaEvidence || hasEmptyMethodEvidence), `${label} error ${status}`, false);
|
|
68
|
+
}
|
|
69
|
+
for (const [name, linkReference] of Object.entries(response?.links ?? {})) {
|
|
70
|
+
const link = resolveReference(document, linkReference);
|
|
71
|
+
cover(
|
|
72
|
+
metrics.openapi_link_evidence,
|
|
73
|
+
validOpenAPILink(link, document),
|
|
74
|
+
`${label} response ${status} link ${name}`,
|
|
75
|
+
false,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const canonical = canonicalOperations.get(operation.operationId);
|
|
81
|
+
cover(metrics.owner_evidence, hasText(operation['x-onex-owner']) && operation['x-onex-owner'] === canonical?.['x-onex-owner'], label, false);
|
|
82
|
+
const lifecycle = canonical?.['x-onex-lifecycle'];
|
|
83
|
+
if (canonical?.['x-onex-audience'] !== 'internal') {
|
|
84
|
+
cover(metrics.lifecycle_evidence, validLifecycle(lifecycle), label, false);
|
|
85
|
+
}
|
|
86
|
+
const review = operation['x-onex-review-provenance'];
|
|
87
|
+
cover(metrics.last_reviewed_at_evidence, validDate(operation['x-onex-last-reviewed-at']) && operation['x-onex-last-reviewed-at'] === review?.last_reviewed_at, label, false);
|
|
88
|
+
cover(metrics.review_digest_evidence, review?.validation === 'passed' && validDigest(review?.operation_sha256), label, false);
|
|
89
|
+
cover(metrics.freshness_evidence, review?.freshness === 'current' && validDate(review?.expires_at), label, false);
|
|
90
|
+
if (lifecycle?.deprecated) {
|
|
91
|
+
cover(
|
|
92
|
+
metrics.openapi_link_evidence,
|
|
93
|
+
hasText(lifecycle.replacementOperationId) || validURL(lifecycle.migrationUrl),
|
|
94
|
+
`${label} deprecated lifecycle`,
|
|
95
|
+
false,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (const [schemaName, schema] of Object.entries(document.components?.schemas ?? {})) {
|
|
101
|
+
inspectSchemaProperties(metrics.schema_property_descriptions, schema, `schema ${schemaName}`, new Set());
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const linkChecks = [];
|
|
105
|
+
for (const link of collectDocumentationLinks(document)) {
|
|
106
|
+
const result = await linkChecker(link.url);
|
|
107
|
+
linkChecks.push({ ...link, ...result });
|
|
108
|
+
cover(metrics.documentation_link_validity, result.passed === true, `${link.location} ${link.url}`, false);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (audience !== 'internal') {
|
|
112
|
+
cover(
|
|
113
|
+
metrics.sdk_typecheck_evidence,
|
|
114
|
+
sdkEvidence.length > 0 && sdkEvidence.every((entry) => entry.typecheck?.status === 'passed'),
|
|
115
|
+
`${service}/${audience} SDK typecheck`,
|
|
116
|
+
false,
|
|
117
|
+
);
|
|
118
|
+
cover(
|
|
119
|
+
metrics.code_example_evidence,
|
|
120
|
+
sdkEvidence.length > 0 && sdkEvidence.every((entry) => entry.code_example?.status === 'passed' && validDigest(entry.code_example?.sha256)),
|
|
121
|
+
`${service}/${audience} SDK code example`,
|
|
122
|
+
false,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
cover(metrics.source_contract_evidence, validDigest(sourceContractSha256), `${service}/${audience} source contract`, false);
|
|
126
|
+
|
|
127
|
+
const violations = Object.entries(metrics).flatMap(([metric, value]) => value.missing.map((location) => ({
|
|
128
|
+
code: `missing_${metric}`,
|
|
129
|
+
location,
|
|
130
|
+
metric,
|
|
131
|
+
})));
|
|
132
|
+
for (const metric of Object.values(metrics)) finalizeMetric(metric);
|
|
133
|
+
const passed = requiredMetrics.every((name) => metrics[name].percentage === 100) && violations.length === 0;
|
|
134
|
+
if (!passed) {
|
|
135
|
+
const details = violations.slice(0, 100).map((violation) => `${violation.code}: ${violation.location}`).join('\n- ');
|
|
136
|
+
const suffix = violations.length > 100 ? `\n- ${violations.length - 100} additional violation(s)` : '';
|
|
137
|
+
throw new Error(`${service}/${audience} documentation quality gate failed with ${violations.length} violation(s):\n- ${details}${suffix}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
audience,
|
|
142
|
+
gate: { passed, policy: 'all_applicable_metrics_100_percent' },
|
|
143
|
+
link_checks: linkChecks,
|
|
144
|
+
metrics,
|
|
145
|
+
projection_version: documentationProjectionVersion,
|
|
146
|
+
ruleset_version: documentationQualityRulesetVersion,
|
|
147
|
+
service,
|
|
148
|
+
source_contract_sha256: sourceContractSha256,
|
|
149
|
+
canonical_source_sha256: sourceSha256,
|
|
150
|
+
violations,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function checkDocumentationURL(value) {
|
|
155
|
+
return validURL(value)
|
|
156
|
+
? { passed: true, validation: 'absolute_http_uri' }
|
|
157
|
+
: { passed: false, validation: 'invalid_uri' };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function collectDocumentationLinks(document) {
|
|
161
|
+
const links = new Map();
|
|
162
|
+
const add = (url, location) => {
|
|
163
|
+
if (!hasText(url)) return;
|
|
164
|
+
const key = `${location}\0${url}`;
|
|
165
|
+
links.set(key, { location, url });
|
|
166
|
+
};
|
|
167
|
+
add(document.externalDocs?.url, 'externalDocs');
|
|
168
|
+
for (const [index, tag] of (document.tags ?? []).entries()) add(tag.externalDocs?.url, `tags[${index}].externalDocs`);
|
|
169
|
+
walk(document, (value, key, location, parent) => {
|
|
170
|
+
if (key === 'description' && typeof value === 'string') {
|
|
171
|
+
for (const url of extractDescriptionURLs(value)) add(url, location);
|
|
172
|
+
}
|
|
173
|
+
if (key === 'externalValue') add(value, location);
|
|
174
|
+
if (key === 'migrationUrl' && parent?.deprecated) add(value, location);
|
|
175
|
+
if (key === 'url' && parent === document.externalDocs) add(value, location);
|
|
176
|
+
});
|
|
177
|
+
for (const { method, operation, path } of operationEntries(document)) {
|
|
178
|
+
add(operation.externalDocs?.url, `${method.toUpperCase()} ${path} externalDocs`);
|
|
179
|
+
}
|
|
180
|
+
return [...links.values()].sort((left, right) => `${left.location}\0${left.url}`.localeCompare(`${right.location}\0${right.url}`));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function extractDescriptionURLs(value) {
|
|
184
|
+
const result = [];
|
|
185
|
+
for (const match of value.matchAll(/https?:\/\/[^\s<>"'`\])}]+/gu)) result.push(match[0].replace(/[.,;:!?]+$/u, ''));
|
|
186
|
+
for (const match of value.matchAll(/\[[^\]]+\]\(([^)]+)\)/gu)) {
|
|
187
|
+
if (!/^https?:\/\//u.test(match[1])) result.push(match[1]);
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function inspectMediaExamples(metric, document, content, label) {
|
|
193
|
+
for (const [mediaType, media] of Object.entries(content ?? {})) {
|
|
194
|
+
if (!media?.schema) continue;
|
|
195
|
+
const examples = Object.entries(media.examples ?? {});
|
|
196
|
+
const valid = examples.length > 0 && examples.every(([, reference]) => {
|
|
197
|
+
const example = resolveReference(document, reference);
|
|
198
|
+
if (!example || (!Object.hasOwn(example, 'value') && !hasText(example.externalValue))) return false;
|
|
199
|
+
const provenance = example['x-onex-example-provenance'];
|
|
200
|
+
return hasText(provenance?.generator) && hasText(provenance?.schema_pointer) &&
|
|
201
|
+
validDigest(provenance?.schema_sha256) && validDigest(provenance?.source_sha256) &&
|
|
202
|
+
!containsSensitiveData(example.value, '', media.schema, document);
|
|
203
|
+
});
|
|
204
|
+
cover(metric, valid, `${label} ${mediaType}`, examples.some(([, reference]) => isGenerated(resolveReference(document, reference))));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function inspectSchemaProperties(metric, schema, label, visited) {
|
|
209
|
+
if (!isPlainObject(schema) || visited.has(schema)) return;
|
|
210
|
+
visited.add(schema);
|
|
211
|
+
for (const [name, property] of Object.entries(schema.properties ?? {})) {
|
|
212
|
+
if (!isPlainObject(property)) continue;
|
|
213
|
+
const propertyLabel = `${label}.${name}`;
|
|
214
|
+
cover(metric, hasText(property.description), propertyLabel, isGenerated(property));
|
|
215
|
+
inspectSchemaProperties(metric, property, propertyLabel, visited);
|
|
216
|
+
}
|
|
217
|
+
if (schema.items) inspectSchemaProperties(metric, schema.items, `${label}[]`, visited);
|
|
218
|
+
for (const keyword of ['allOf', 'anyOf', 'oneOf']) {
|
|
219
|
+
for (const [index, child] of (schema[keyword] ?? []).entries()) {
|
|
220
|
+
inspectSchemaProperties(metric, child, `${label}.${keyword}[${index}]`, visited);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
visited.delete(schema);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function validOpenAPILink(link, document) {
|
|
227
|
+
if (!link || typeof link !== 'object') return false;
|
|
228
|
+
if (hasText(link.operationId)) return operationEntries(document).some(({ operation }) => operation.operationId === link.operationId);
|
|
229
|
+
if (!hasText(link.operationRef)) return false;
|
|
230
|
+
if (!link.operationRef.startsWith('#/paths/')) return validURL(link.operationRef);
|
|
231
|
+
const parts = link.operationRef.split('/');
|
|
232
|
+
const path = decodePointer(parts[2] ?? '');
|
|
233
|
+
return Boolean(document.paths?.[path]?.[parts[3]]);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function createMetric() {
|
|
237
|
+
return { covered: 0, generated: 0, missing: [], percentage: 100, total: 0 };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function cover(metric, condition, location, generated) {
|
|
241
|
+
metric.total += 1;
|
|
242
|
+
if (condition) {
|
|
243
|
+
metric.covered += 1;
|
|
244
|
+
if (generated) metric.generated += 1;
|
|
245
|
+
} else {
|
|
246
|
+
metric.missing.push(location);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function finalizeMetric(metric) {
|
|
251
|
+
metric.percentage = metric.total === 0 ? 100 : Number(((metric.covered / metric.total) * 100).toFixed(4));
|
|
252
|
+
delete metric.missing;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function validLifecycle(value) {
|
|
256
|
+
return value && validDate(value.introduced) && Object.hasOwn(value, 'deprecated') && Object.hasOwn(value, 'sunset') &&
|
|
257
|
+
Object.hasOwn(value, 'replacementOperationId') && Object.hasOwn(value, 'migrationUrl');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function validDate(value) {
|
|
261
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(value ?? '') && !Number.isNaN(Date.parse(`${value}T00:00:00Z`));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function validDigest(value) {
|
|
265
|
+
return /^[a-f0-9]{64}$/.test(value ?? '');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function validURL(value) {
|
|
269
|
+
if (!hasText(value)) return false;
|
|
270
|
+
try {
|
|
271
|
+
return ['https:', 'http:'].includes(new URL(value).protocol);
|
|
272
|
+
} catch {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function containsSensitiveData(value, key = '', schema = {}, document = null) {
|
|
278
|
+
const resolvedSchema = document ? resolveReference(document, schema) ?? {} : schema;
|
|
279
|
+
if (Array.isArray(value)) {
|
|
280
|
+
return value.some((entry) => containsSensitiveData(entry, key, resolvedSchema.items ?? {}, document));
|
|
281
|
+
}
|
|
282
|
+
if (value && typeof value === 'object') {
|
|
283
|
+
return Object.entries(value).some(([name, entry]) => containsSensitiveData(
|
|
284
|
+
entry,
|
|
285
|
+
name,
|
|
286
|
+
examplePropertySchema(document, resolvedSchema, name),
|
|
287
|
+
document,
|
|
288
|
+
));
|
|
289
|
+
}
|
|
290
|
+
if (typeof value !== 'string') return false;
|
|
291
|
+
const normalized = key.toLowerCase();
|
|
292
|
+
if (isSensitiveExampleKey(key)) return !isSafeSensitiveExampleValue(value, resolvedSchema);
|
|
293
|
+
if (isEmailExampleKey(key) || /^[^\s@]+@[^\s@]+$/.test(value)) return !value.endsWith('@example.com');
|
|
294
|
+
if (/(url|uri|link)$/.test(normalized) || /^https?:\/\//.test(value)) {
|
|
295
|
+
try {
|
|
296
|
+
return !new URL(value).hostname.endsWith('example.com');
|
|
297
|
+
} catch {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function examplePropertySchema(document, schema, propertyName) {
|
|
305
|
+
if (schema.properties?.[propertyName]) return schema.properties[propertyName];
|
|
306
|
+
for (const keyword of ['allOf', 'anyOf', 'oneOf']) {
|
|
307
|
+
for (const child of schema[keyword] ?? []) {
|
|
308
|
+
const resolvedChild = document ? resolveReference(document, child) ?? {} : child;
|
|
309
|
+
const property = examplePropertySchema(document, resolvedChild, propertyName);
|
|
310
|
+
if (Object.keys(property).length > 0) return property;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return schema.additionalProperties && typeof schema.additionalProperties === 'object'
|
|
314
|
+
? schema.additionalProperties
|
|
315
|
+
: {};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function isGenerated(value) {
|
|
319
|
+
const documentation = value?.['x-onex-documentation-provenance'];
|
|
320
|
+
const example = value?.['x-onex-example-provenance'];
|
|
321
|
+
return documentation?.description_source === 'generated' || example?.source === 'schema';
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function hasText(value) {
|
|
325
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function walk(value, callback, location = '$', parent = null) {
|
|
329
|
+
if (Array.isArray(value)) {
|
|
330
|
+
value.forEach((entry, index) => {
|
|
331
|
+
callback(entry, String(index), `${location}[${index}]`, value);
|
|
332
|
+
walk(entry, callback, `${location}[${index}]`, value);
|
|
333
|
+
});
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (!value || typeof value !== 'object') return;
|
|
337
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
338
|
+
const childLocation = `${location}.${key}`;
|
|
339
|
+
callback(entry, key, childLocation, value);
|
|
340
|
+
walk(entry, callback, childLocation, value);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function decodePointer(value) {
|
|
345
|
+
return value.replaceAll('~1', '/').replaceAll('~0', '~');
|
|
346
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { apiRoot, isSafeRelativePath, readStructured, sha256 } from './project.mjs';
|
|
7
|
+
import { isSemanticVersion } from './semantic_version.mjs';
|
|
8
|
+
|
|
9
|
+
export const repositoryRoot = locateRepositoryRoot(apiRoot);
|
|
10
|
+
const apiRepositoryPath = relative(repositoryRoot, apiRoot).replaceAll('\\', '/');
|
|
11
|
+
export const manifestRepositoryPath = `${apiRepositoryPath}/dist/artifact-manifest.json`;
|
|
12
|
+
|
|
13
|
+
function locateRepositoryRoot(start) {
|
|
14
|
+
let current = start;
|
|
15
|
+
while (dirname(current) !== current) {
|
|
16
|
+
if (existsSync(resolve(current, '.git'))) return current;
|
|
17
|
+
current = dirname(current);
|
|
18
|
+
}
|
|
19
|
+
return resolve(apiRoot, '../..');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function readCurrentManifest() {
|
|
23
|
+
const manifest = await readStructured(resolve(apiRoot, 'dist/artifact-manifest.json'));
|
|
24
|
+
validateArtifactManifest(manifest, 'working tree artifact manifest');
|
|
25
|
+
return manifest;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readManifestAtRevision(revision) {
|
|
29
|
+
const source = readFileAtRevision(revision, manifestRepositoryPath, { allowMissing: true });
|
|
30
|
+
if (source === null) return null;
|
|
31
|
+
const manifest = parseJSON(source, `${revision}:${manifestRepositoryPath}`);
|
|
32
|
+
validateArtifactManifest(manifest, `${revision} artifact manifest`);
|
|
33
|
+
return manifest;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function readHistoricalManifests() {
|
|
37
|
+
const output = git(['log', '--full-history', '--format=%H', 'HEAD', '--', manifestRepositoryPath], { allowFailure: true });
|
|
38
|
+
if (!output) return [];
|
|
39
|
+
const result = [];
|
|
40
|
+
for (const revision of [...new Set(output.split('\n').filter(Boolean))]) {
|
|
41
|
+
const manifest = readManifestAtRevision(revision);
|
|
42
|
+
if (manifest) result.push({ manifest, revision });
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function resolveProtectedBaseRevision() {
|
|
48
|
+
const eventRevision = await revisionFromGitHubEvent();
|
|
49
|
+
if (eventRevision) return mergeBase(eventRevision);
|
|
50
|
+
|
|
51
|
+
const target = git(['rev-parse', '--verify', 'refs/remotes/origin/main'], { allowFailure: true });
|
|
52
|
+
if (target) {
|
|
53
|
+
const base = mergeBase(target);
|
|
54
|
+
const head = git(['rev-parse', 'HEAD']);
|
|
55
|
+
if (base !== head) return base;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const parent = git(['rev-parse', '--verify', 'HEAD^'], { allowFailure: true });
|
|
59
|
+
if (parent) return parent;
|
|
60
|
+
throw new Error('unable to derive the protected comparison base');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function currentRevision() {
|
|
64
|
+
return git(['rev-parse', 'HEAD']);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function readFileAtRevision(revision, repositoryPath, { allowMissing = false } = {}) {
|
|
68
|
+
assertRevision(revision);
|
|
69
|
+
if (!isSafeRepositoryPath(repositoryPath)) throw new Error(`unsafe repository path: ${repositoryPath}`);
|
|
70
|
+
return git(['show', `${revision}:${repositoryPath}`], { allowFailure: allowMissing, trim: false });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function readCurrentArtifact(record) {
|
|
74
|
+
validateArtifactRecord(record, 'working tree artifact');
|
|
75
|
+
const content = await readFile(resolve(apiRoot, record.path));
|
|
76
|
+
verifyArtifactDigest(content, record, 'working tree artifact');
|
|
77
|
+
return content;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function readHistoricalArtifact(record, revision) {
|
|
81
|
+
validateArtifactRecord(record, `${revision} artifact`);
|
|
82
|
+
const content = Buffer.from(readFileAtRevision(revision, `${apiRepositoryPath}/${record.path}`));
|
|
83
|
+
verifyArtifactDigest(content, record, `${revision} artifact`);
|
|
84
|
+
return content;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function validateArtifactManifest(manifest, label = 'artifact manifest') {
|
|
88
|
+
if (manifest?.schema_version !== 1 || !Array.isArray(manifest.artifacts)) {
|
|
89
|
+
throw new Error(`${label} must declare schema_version 1 and artifacts`);
|
|
90
|
+
}
|
|
91
|
+
const seen = new Set();
|
|
92
|
+
const ordered = [];
|
|
93
|
+
for (const record of manifest.artifacts) {
|
|
94
|
+
validateArtifactRecord(record, label);
|
|
95
|
+
const key = artifactSlotKey(record);
|
|
96
|
+
if (seen.has(key)) throw new Error(`${label} contains duplicate artifact ${key}`);
|
|
97
|
+
seen.add(key);
|
|
98
|
+
ordered.push(`${record.service}\0${record.audience}`);
|
|
99
|
+
}
|
|
100
|
+
if (ordered.join('\n') !== [...ordered].sort().join('\n')) {
|
|
101
|
+
throw new Error(`${label} artifacts must be sorted by service and audience`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function validateArtifactRecord(record, label = 'artifact') {
|
|
106
|
+
if (!/^[a-z][a-z0-9-]*$/.test(record?.service ?? '') || !['internal', 'partner', 'public'].includes(record?.audience)) {
|
|
107
|
+
throw new Error(`${label} has an invalid service or audience`);
|
|
108
|
+
}
|
|
109
|
+
if (!isSemanticVersion(record.api_version) || !/^[a-f0-9]{64}$/.test(record.sha256 ?? '')) {
|
|
110
|
+
throw new Error(`${label} has an invalid API version or SHA-256`);
|
|
111
|
+
}
|
|
112
|
+
const expectedPath = `services/${record.service}/dist/${record.audience}.openapi.json`;
|
|
113
|
+
if (!isSafeRelativePath(record.path) || record.path !== expectedPath) {
|
|
114
|
+
throw new Error(`${label} has an invalid artifact path`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function artifactVersionKey(record) {
|
|
119
|
+
return `${artifactSlotKey(record)}/${record.api_version}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function artifactSlotKey(record) {
|
|
123
|
+
if (!isContractArtifact(record)) throw new Error(`artifact ${record?.kind ?? 'unknown'} is not an OpenAPI contract`);
|
|
124
|
+
return `${record.service}/${record.audience}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function artifactContentIdentity(record) {
|
|
128
|
+
return `${artifactVersionKey(record)}/${record.sha256}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function contractArtifacts(manifest) {
|
|
132
|
+
return (manifest?.artifacts ?? []).filter(isContractArtifact);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function isContractArtifact(record) {
|
|
136
|
+
return record?.kind === 'openapi-contract' || record?.kind === undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function verifyArtifactDigest(content, record, label) {
|
|
140
|
+
if (sha256(content) !== record.sha256) throw new Error(`${label} SHA-256 does not match its manifest`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function revisionFromGitHubEvent() {
|
|
144
|
+
const path = process.env.GITHUB_EVENT_PATH;
|
|
145
|
+
if (!path) return null;
|
|
146
|
+
const event = parseJSON(await readFile(path, 'utf8'), 'GitHub event');
|
|
147
|
+
const candidate = event.pull_request?.base?.sha ?? event.merge_group?.base_sha ?? event.before ?? null;
|
|
148
|
+
if (!candidate || /^0+$/.test(candidate)) return null;
|
|
149
|
+
assertRevision(candidate);
|
|
150
|
+
return candidate;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function mergeBase(revision) {
|
|
154
|
+
assertRevision(revision);
|
|
155
|
+
return git(['merge-base', 'HEAD', revision]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function assertRevision(revision) {
|
|
159
|
+
if (!/^[a-f0-9]{40}$/.test(revision ?? '')) throw new Error(`invalid Git revision: ${revision}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function isSafeRepositoryPath(path) {
|
|
163
|
+
return typeof path === 'string' && path.length > 0 && !path.startsWith('/') && !path.split('/').includes('..');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function parseJSON(source, label) {
|
|
167
|
+
try {
|
|
168
|
+
return JSON.parse(source);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
throw new Error(`invalid ${label}: ${error.message}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function git(args, { allowFailure = false, trim = true } = {}) {
|
|
175
|
+
try {
|
|
176
|
+
const output = execFileSync('git', args, {
|
|
177
|
+
cwd: repositoryRoot,
|
|
178
|
+
encoding: 'utf8',
|
|
179
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
180
|
+
stdio: ['ignore', 'pipe', allowFailure ? 'ignore' : 'pipe'],
|
|
181
|
+
});
|
|
182
|
+
return trim ? output.trimEnd() : output;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (allowFailure) return null;
|
|
185
|
+
const detail = error.stderr?.toString().trim();
|
|
186
|
+
throw new Error(`git ${args.join(' ')} failed${detail ? `: ${detail}` : ''}`);
|
|
187
|
+
}
|
|
188
|
+
}
|