- Restructure operator sidebar into a flat task list with indented children; fold plan topology into plan ladders - Expand member catalog non-plan section to all published non-tier products; require recurring Stripe-mapped prices for purchase - Add operator domains placements and terminal-claims ledger; redirect /domains to the FedWiki Sites Domains anchor - Apply canonical vocabulary and chrome/form conventions; migrate seeded FedWiki Sites display name
398 lines
11 KiB
Go
398 lines
11 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: products.sql
|
|
|
|
package billing
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/sqlc-dev/pqtype"
|
|
)
|
|
|
|
const anyProduct = `-- name: AnyProduct :one
|
|
SELECT EXISTS(SELECT 1 FROM core.products)
|
|
`
|
|
|
|
// Setup-checklist existence probe.
|
|
func (q *Queries) AnyProduct(ctx context.Context) (bool, error) {
|
|
row := q.db.QueryRowContext(ctx, anyProduct)
|
|
var exists bool
|
|
err := row.Scan(&exists)
|
|
return exists, err
|
|
}
|
|
|
|
const anyPublishedProduct = `-- name: AnyPublishedProduct :one
|
|
SELECT EXISTS(SELECT 1 FROM core.products WHERE lifecycle_status = 'published')
|
|
`
|
|
|
|
// Setup-checklist existence probe.
|
|
func (q *Queries) AnyPublishedProduct(ctx context.Context) (bool, error) {
|
|
row := q.db.QueryRowContext(ctx, anyPublishedProduct)
|
|
var exists bool
|
|
err := row.Scan(&exists)
|
|
return exists, err
|
|
}
|
|
|
|
const countPublishedProducts = `-- name: CountPublishedProducts :one
|
|
SELECT COUNT(*) FROM core.products
|
|
WHERE lifecycle_status = 'published'
|
|
`
|
|
|
|
// Operator overview tile: the size of the live catalog. Counts only
|
|
// lifecycle_status='published' — drafts are work in progress and retired
|
|
// products are history, so neither belongs in a "what we sell today" number.
|
|
func (q *Queries) CountPublishedProducts(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countPublishedProducts)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const countPublishedTierProducts = `-- name: CountPublishedTierProducts :one
|
|
SELECT COUNT(DISTINCT t.product_id) FROM core.plan_ladder_tiers t
|
|
JOIN core.products p ON p.product_id = t.product_id
|
|
WHERE p.lifecycle_status = 'published'
|
|
`
|
|
|
|
// Operator catalog overview (ux-ia-naming 2.1): how many published products
|
|
// are a tier on some plan ladder, vs. off-ladder. A product counts once even
|
|
// when it is shared across more than one ladder (DISTINCT).
|
|
func (q *Queries) CountPublishedTierProducts(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countPublishedTierProducts)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createProduct = `-- name: CreateProduct :one
|
|
INSERT INTO core.products (name, description, display_category, is_active, is_public, entitlement_set_id, lifecycle_status)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
RETURNING product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status
|
|
`
|
|
|
|
type CreateProductParams struct {
|
|
Name string `json:"name"`
|
|
Description sql.NullString `json:"description"`
|
|
DisplayCategory sql.NullString `json:"display_category"`
|
|
IsActive bool `json:"is_active"`
|
|
IsPublic bool `json:"is_public"`
|
|
EntitlementSetID uuid.NullUUID `json:"entitlement_set_id"`
|
|
LifecycleStatus string `json:"lifecycle_status"`
|
|
}
|
|
|
|
func (q *Queries) CreateProduct(ctx context.Context, arg CreateProductParams) (Product, error) {
|
|
row := q.db.QueryRowContext(ctx, createProduct,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.DisplayCategory,
|
|
arg.IsActive,
|
|
arg.IsPublic,
|
|
arg.EntitlementSetID,
|
|
arg.LifecycleStatus,
|
|
)
|
|
var i Product
|
|
err := row.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getProductByID = `-- name: GetProductByID :one
|
|
SELECT product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status FROM core.products
|
|
WHERE product_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetProductByID(ctx context.Context, productID string) (Product, error) {
|
|
row := q.db.QueryRowContext(ctx, getProductByID, productID)
|
|
var i Product
|
|
err := row.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getProductByName = `-- name: GetProductByName :one
|
|
SELECT product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status FROM core.products
|
|
WHERE name = $1
|
|
`
|
|
|
|
func (q *Queries) GetProductByName(ctx context.Context, name string) (Product, error) {
|
|
row := q.db.QueryRowContext(ctx, getProductByName, name)
|
|
var i Product
|
|
err := row.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getProductShape = `-- name: GetProductShape :one
|
|
SELECT product_id, lifecycle_status, is_public, set_present, ladder_count, billing_shape, consumption_shape FROM core.product_shape
|
|
WHERE product_id = $1
|
|
`
|
|
|
|
// Diagnostics view (migration 00006): independent structural dimensions per
|
|
// product. Readiness reads set_present and billing_shape.
|
|
func (q *Queries) GetProductShape(ctx context.Context, productID string) (CoreProductShape, error) {
|
|
row := q.db.QueryRowContext(ctx, getProductShape, productID)
|
|
var i CoreProductShape
|
|
err := row.Scan(
|
|
&i.ProductID,
|
|
&i.LifecycleStatus,
|
|
&i.IsPublic,
|
|
&i.SetPresent,
|
|
&i.LadderCount,
|
|
&i.BillingShape,
|
|
&i.ConsumptionShape,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listActiveProducts = `-- name: ListActiveProducts :many
|
|
SELECT product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status FROM core.products
|
|
WHERE is_active = TRUE
|
|
ORDER BY name ASC
|
|
`
|
|
|
|
func (q *Queries) ListActiveProducts(ctx context.Context) ([]Product, error) {
|
|
rows, err := q.db.QueryContext(ctx, listActiveProducts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Product{}
|
|
for rows.Next() {
|
|
var i Product
|
|
if err := rows.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listAllProducts = `-- name: ListAllProducts :many
|
|
SELECT product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status FROM core.products
|
|
ORDER BY name ASC
|
|
`
|
|
|
|
func (q *Queries) ListAllProducts(ctx context.Context) ([]Product, error) {
|
|
rows, err := q.db.QueryContext(ctx, listAllProducts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Product{}
|
|
for rows.Next() {
|
|
var i Product
|
|
if err := rows.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listPublicPlanProducts = `-- name: ListPublicPlanProducts :many
|
|
SELECT p.product_id, p.name, p.description, p.display_category, p.metadata, p.is_active, p.is_public, p.created_at, p.updated_at, p.entitlement_set_id, p.lifecycle_status FROM core.products p
|
|
WHERE p.is_active = TRUE AND p.is_public = TRUE AND p.lifecycle_status = 'published'
|
|
AND EXISTS (
|
|
SELECT 1 FROM core.plan_ladder_tiers t WHERE t.product_id = p.product_id
|
|
)
|
|
ORDER BY p.name ASC
|
|
`
|
|
|
|
// Plan products are those attached to a ladder via plan_ladder_tiers
|
|
// (Doc 31 Amendment #3); membership is the structural signal —
|
|
// display_category is presentation-only and never branched on.
|
|
func (q *Queries) ListPublicPlanProducts(ctx context.Context) ([]Product, error) {
|
|
rows, err := q.db.QueryContext(ctx, listPublicPlanProducts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Product{}
|
|
for rows.Next() {
|
|
var i Product
|
|
if err := rows.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listPublicProducts = `-- name: ListPublicProducts :many
|
|
SELECT product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status FROM core.products
|
|
WHERE is_active = TRUE AND is_public = TRUE AND lifecycle_status = 'published'
|
|
ORDER BY name ASC
|
|
`
|
|
|
|
func (q *Queries) ListPublicProducts(ctx context.Context) ([]Product, error) {
|
|
rows, err := q.db.QueryContext(ctx, listPublicProducts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Product{}
|
|
for rows.Next() {
|
|
var i Product
|
|
if err := rows.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateProduct = `-- name: UpdateProduct :one
|
|
UPDATE core.products
|
|
SET name = $2, description = $3, display_category = $4, is_active = $5, is_public = $6, entitlement_set_id = $7, metadata = $8
|
|
WHERE product_id = $1
|
|
RETURNING product_id, name, description, display_category, metadata, is_active, is_public, created_at, updated_at, entitlement_set_id, lifecycle_status
|
|
`
|
|
|
|
type UpdateProductParams struct {
|
|
ProductID string `json:"product_id"`
|
|
Name string `json:"name"`
|
|
Description sql.NullString `json:"description"`
|
|
DisplayCategory sql.NullString `json:"display_category"`
|
|
IsActive bool `json:"is_active"`
|
|
IsPublic bool `json:"is_public"`
|
|
EntitlementSetID uuid.NullUUID `json:"entitlement_set_id"`
|
|
Metadata pqtype.NullRawMessage `json:"metadata"`
|
|
}
|
|
|
|
func (q *Queries) UpdateProduct(ctx context.Context, arg UpdateProductParams) (Product, error) {
|
|
row := q.db.QueryRowContext(ctx, updateProduct,
|
|
arg.ProductID,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.DisplayCategory,
|
|
arg.IsActive,
|
|
arg.IsPublic,
|
|
arg.EntitlementSetID,
|
|
arg.Metadata,
|
|
)
|
|
var i Product
|
|
err := row.Scan(
|
|
&i.ProductID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.DisplayCategory,
|
|
&i.Metadata,
|
|
&i.IsActive,
|
|
&i.IsPublic,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.EntitlementSetID,
|
|
&i.LifecycleStatus,
|
|
)
|
|
return i, err
|
|
}
|