Revert "feat(commerce): expose plan authority CRUD at /v1/plans/* + commerce v1.49.12"
This reverts commit 78ddef48f0.
This commit is contained in:
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/hanzoai/commerce"
|
||||
commercebilling "github.com/hanzoai/commerce/api/billing"
|
||||
catalogapi "github.com/hanzoai/commerce/api/catalog"
|
||||
planapi "github.com/hanzoai/commerce/api/plan"
|
||||
commercestore "github.com/hanzoai/commerce/api/store"
|
||||
commercedatastore "github.com/hanzoai/commerce/datastore"
|
||||
commercemid "github.com/hanzoai/commerce/middleware"
|
||||
@@ -76,13 +75,6 @@ var commercePrefixes = []string{
|
||||
// same /v1 gate chain. Own the prefix here so it reaches commerce (each handler
|
||||
// is requireSuperAdmin-gated) instead of the AI /v1/* balance catch-all.
|
||||
"/v1/catalog",
|
||||
// Platform-admin subscription/DNS plan authority CMS: GET/POST/PUT/DELETE
|
||||
// /v1/plans/entries + POST /v1/plans/seed (increment 3a) — the SuperAdmin CRUD
|
||||
// the console plan editor drives. The PUBLIC read stays GET /v1/billing/plans;
|
||||
// this CRUD rides the /v1 bundle (api.Route → planApi.AdminRoute), which the
|
||||
// embed skips, so mountCommerce mounts it below. Own the prefix so it reaches
|
||||
// commerce (each handler requireSuperAdmin-gated), not the AI /v1/* 402 gate.
|
||||
"/v1/plans",
|
||||
// Payment-provider webhook receiver (POST /v1/billing/webhooks/:provider —
|
||||
// Square et al). The provider's HMAC over the registered notification URL +
|
||||
// body IS the auth; a bearer gate is impossible for provider callbacks.
|
||||
@@ -172,17 +164,6 @@ func mountCommerce(app *zip.App, deps cloud.Deps) error {
|
||||
// platform admin edits); it is cross-tenant data, never org-scoped.
|
||||
catalogapi.AdminRoute(storeV1)
|
||||
|
||||
// Platform-admin subscription/DNS plan authority CRUD on the SAME /v1 bundle:
|
||||
// GET/POST/PUT/DELETE /v1/plans/entries + POST /v1/plans/seed (increment 3a).
|
||||
// Mirrors the catalog mount: the standalone wires it on the /v1 bundle
|
||||
// (api.Route → planApi.AdminRoute), which the co-resident embed skips. The
|
||||
// embed seed SOURCE is injected here (the composition root) — commercebilling.
|
||||
// SeedRows, the SAME @hanzo/plans embed the boot seed + resolveSubscriptionPlan
|
||||
// read — so api/plan never imports api/billing. Each handler is
|
||||
// requireSuperAdmin-gated (anon → 403); prices are admin-editable but the mint
|
||||
// gates score the IMMUTABLE embed, so an edit never moves a charge gate.
|
||||
planapi.AdminRoute(storeV1, commercebilling.SeedRows)
|
||||
|
||||
// Provider webhook intake at the LIVE registered path. Chain mirrors the
|
||||
// commerce-standalone posture: gated request context, then the sessionless
|
||||
// HMAC-verified handler.
|
||||
|
||||
@@ -33,7 +33,6 @@ func TestCommercePrefixesPinned(t *testing.T) {
|
||||
"/v1/billing/webhooks": false,
|
||||
"/v1/store": false,
|
||||
"/v1/catalog": false,
|
||||
"/v1/plans": false,
|
||||
}
|
||||
for _, p := range commercePrefixes {
|
||||
if _, ok := want[p]; ok {
|
||||
@@ -96,15 +95,6 @@ func TestStoreSurfaceRoutedToCommerceNotAIGate(t *testing.T) {
|
||||
if code, _ := doReq(t, app, http.MethodPut, "/v1/catalog/entries/cloud-starter"); code == http.StatusPaymentRequired {
|
||||
t.Fatalf("PUT /v1/catalog/entries/:slug fell through to the AI balance gate (402) — the whole catalog CMS must be commerce-owned")
|
||||
}
|
||||
|
||||
// The platform-admin plan authority CMS (increment 3a) must also reach commerce —
|
||||
// requireSuperAdmin-gated (anon → 401/403) — never the AI /v1/* 402 gate.
|
||||
if code, _ := doReq(t, app, http.MethodGet, "/v1/plans/entries"); code == http.StatusPaymentRequired {
|
||||
t.Fatalf("GET /v1/plans/entries fell through to the AI balance gate (402) — /v1/plans must be a commercePrefix so the plan authority CMS reaches commerce")
|
||||
}
|
||||
if code, _ := doReq(t, app, http.MethodPut, "/v1/plans/entries/pro"); code == http.StatusPaymentRequired {
|
||||
t.Fatalf("PUT /v1/plans/entries/:slug fell through to the AI balance gate (402) — the whole plan authority CMS must be commerce-owned")
|
||||
}
|
||||
}
|
||||
|
||||
// doReq drives one request through the mounted app and returns (status, body).
|
||||
|
||||
@@ -14,7 +14,7 @@ require (
|
||||
github.com/google/go-containerregistry v0.21.7
|
||||
github.com/google/go-github/v52 v52.0.0
|
||||
github.com/hanzoai/account v0.2.0
|
||||
github.com/hanzoai/commerce v1.49.12
|
||||
github.com/hanzoai/commerce v1.49.11
|
||||
github.com/hanzoai/decimal v0.1.1
|
||||
github.com/hanzoai/go-openai v1.41.0
|
||||
github.com/hanzoai/goa v1.0.0
|
||||
|
||||
@@ -1069,8 +1069,10 @@ github.com/hanzoai/beego/v2 v2.4.2 h1:Piq3DwRfB6JM0XeF6GdvwAncOiTYSTvRuCQxvj28qi
|
||||
github.com/hanzoai/beego/v2 v2.4.2/go.mod h1:R/5uyJtklFoKrwBMyfcnfiFgHB6K5PceNIonnlp8Mh4=
|
||||
github.com/hanzoai/captable v1.0.0 h1:utXPsOaPL+QV0rJaoNDFHvWFv7etf2kfm1bsFh6JRD0=
|
||||
github.com/hanzoai/captable v1.0.0/go.mod h1:czdMnzEvb8FWNKCzmh+z8PmwYeQp4MGyTPgo+Q5O+mk=
|
||||
github.com/hanzoai/commerce v1.49.12 h1:NYvt+G+vca+0UcCQIjgLFOkkGaUehfWi5vVFpJ7+6os=
|
||||
github.com/hanzoai/commerce v1.49.12/go.mod h1:+Bp6hVxJQmv71D/ZPzs5qiEVHyDNUchNsqakd+778ps=
|
||||
github.com/hanzoai/commerce v1.49.10 h1:0ikev6+8TvUZmLPKAoAghp1MDE0cs2/LpNHRc79qTN0=
|
||||
github.com/hanzoai/commerce v1.49.10/go.mod h1:+Bp6hVxJQmv71D/ZPzs5qiEVHyDNUchNsqakd+778ps=
|
||||
github.com/hanzoai/commerce v1.49.11 h1:vq5J0rFT4eCs1k612TuWZcl1hfAuX8VsXLU/xm29XtQ=
|
||||
github.com/hanzoai/commerce v1.49.11/go.mod h1:+Bp6hVxJQmv71D/ZPzs5qiEVHyDNUchNsqakd+778ps=
|
||||
github.com/hanzoai/csqlite v0.1.0 h1:suwC3dh0INlfP/U0Es6cDf6JNQ+2+GVLLATPWCUux6k=
|
||||
github.com/hanzoai/csqlite v0.1.0/go.mod h1:H31a/O6VXuklR9UBkgY++bmAK5uzVfXPqU0F6P9Wsos=
|
||||
github.com/hanzoai/dashscope-go-sdk v0.0.2 h1:L/FlStjXeehrNSBqU8y/ecSG/MnaAJqfyfjmLYmY344=
|
||||
|
||||
Reference in New Issue
Block a user