Major architectural simplification removing content type complexity: Database Schema: - Remove 'type' field from content and content_versions tables - Simplify to pure HTML storage with html_content + original_template - Regenerate all sqlc models for SQLite and PostgreSQL API Simplification: - Remove content type routing and validation - Eliminate type-specific handlers (text/markdown/structured) - Unified HTML-first approach for all content operations - Simplify CreateContent and UpdateContent to HTML-only Backend Enhancements: - Update enhancer to only generate data-content-id (no data-content-type) - Improve container expansion utilities with comprehensive block/inline rules - Add Phase 3 preparation with boundary-respecting traversal logic - Strengthen element classification for viable children detection Documentation: - Update TODO.md to reflect Phase 1-3 completion status - Add WORKING_ON.md documenting the architectural transformation - Mark container expansion and HTML-first architecture as complete This completes the transition to a unified HTML-first content management system with automatic style detection and element-based behavior, eliminating the complex multi-type system in favor of semantic HTML-driven editing.
262 lines
6.3 KiB
Go
262 lines
6.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: content.sql
|
|
|
|
package sqlite
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"strings"
|
|
)
|
|
|
|
const createContent = `-- name: CreateContent :one
|
|
INSERT INTO content (id, site_id, html_content, original_template, last_edited_by)
|
|
VALUES (?1, ?2, ?3, ?4, ?5)
|
|
RETURNING id, site_id, html_content, original_template, created_at, updated_at, last_edited_by
|
|
`
|
|
|
|
type CreateContentParams struct {
|
|
ID string `json:"id"`
|
|
SiteID string `json:"site_id"`
|
|
HtmlContent string `json:"html_content"`
|
|
OriginalTemplate sql.NullString `json:"original_template"`
|
|
LastEditedBy string `json:"last_edited_by"`
|
|
}
|
|
|
|
func (q *Queries) CreateContent(ctx context.Context, arg CreateContentParams) (Content, error) {
|
|
row := q.db.QueryRowContext(ctx, createContent,
|
|
arg.ID,
|
|
arg.SiteID,
|
|
arg.HtmlContent,
|
|
arg.OriginalTemplate,
|
|
arg.LastEditedBy,
|
|
)
|
|
var i Content
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SiteID,
|
|
&i.HtmlContent,
|
|
&i.OriginalTemplate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.LastEditedBy,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteAllSiteContent = `-- name: DeleteAllSiteContent :exec
|
|
DELETE FROM content
|
|
WHERE site_id = ?1
|
|
`
|
|
|
|
func (q *Queries) DeleteAllSiteContent(ctx context.Context, siteID string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteAllSiteContent, siteID)
|
|
return err
|
|
}
|
|
|
|
const deleteContent = `-- name: DeleteContent :exec
|
|
DELETE FROM content
|
|
WHERE id = ?1 AND site_id = ?2
|
|
`
|
|
|
|
type DeleteContentParams struct {
|
|
ID string `json:"id"`
|
|
SiteID string `json:"site_id"`
|
|
}
|
|
|
|
func (q *Queries) DeleteContent(ctx context.Context, arg DeleteContentParams) error {
|
|
_, err := q.db.ExecContext(ctx, deleteContent, arg.ID, arg.SiteID)
|
|
return err
|
|
}
|
|
|
|
const getAllContent = `-- name: GetAllContent :many
|
|
SELECT id, site_id, html_content, original_template, created_at, updated_at, last_edited_by
|
|
FROM content
|
|
WHERE site_id = ?1
|
|
ORDER BY updated_at DESC
|
|
`
|
|
|
|
func (q *Queries) GetAllContent(ctx context.Context, siteID string) ([]Content, error) {
|
|
rows, err := q.db.QueryContext(ctx, getAllContent, siteID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Content
|
|
for rows.Next() {
|
|
var i Content
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SiteID,
|
|
&i.HtmlContent,
|
|
&i.OriginalTemplate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.LastEditedBy,
|
|
); 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 getBulkContent = `-- name: GetBulkContent :many
|
|
SELECT id, site_id, html_content, original_template, created_at, updated_at, last_edited_by
|
|
FROM content
|
|
WHERE site_id = ?1 AND id IN (/*SLICE:ids*/?)
|
|
`
|
|
|
|
type GetBulkContentParams struct {
|
|
SiteID string `json:"site_id"`
|
|
Ids []string `json:"ids"`
|
|
}
|
|
|
|
func (q *Queries) GetBulkContent(ctx context.Context, arg GetBulkContentParams) ([]Content, error) {
|
|
query := getBulkContent
|
|
var queryParams []interface{}
|
|
queryParams = append(queryParams, arg.SiteID)
|
|
if len(arg.Ids) > 0 {
|
|
for _, v := range arg.Ids {
|
|
queryParams = append(queryParams, v)
|
|
}
|
|
query = strings.Replace(query, "/*SLICE:ids*/?", strings.Repeat(",?", len(arg.Ids))[1:], 1)
|
|
} else {
|
|
query = strings.Replace(query, "/*SLICE:ids*/?", "NULL", 1)
|
|
}
|
|
rows, err := q.db.QueryContext(ctx, query, queryParams...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Content
|
|
for rows.Next() {
|
|
var i Content
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SiteID,
|
|
&i.HtmlContent,
|
|
&i.OriginalTemplate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.LastEditedBy,
|
|
); 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 getContent = `-- name: GetContent :one
|
|
SELECT id, site_id, html_content, original_template, created_at, updated_at, last_edited_by
|
|
FROM content
|
|
WHERE id = ?1 AND site_id = ?2
|
|
`
|
|
|
|
type GetContentParams struct {
|
|
ID string `json:"id"`
|
|
SiteID string `json:"site_id"`
|
|
}
|
|
|
|
func (q *Queries) GetContent(ctx context.Context, arg GetContentParams) (Content, error) {
|
|
row := q.db.QueryRowContext(ctx, getContent, arg.ID, arg.SiteID)
|
|
var i Content
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SiteID,
|
|
&i.HtmlContent,
|
|
&i.OriginalTemplate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.LastEditedBy,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateContent = `-- name: UpdateContent :one
|
|
UPDATE content
|
|
SET html_content = ?1, last_edited_by = ?2
|
|
WHERE id = ?3 AND site_id = ?4
|
|
RETURNING id, site_id, html_content, original_template, created_at, updated_at, last_edited_by
|
|
`
|
|
|
|
type UpdateContentParams struct {
|
|
HtmlContent string `json:"html_content"`
|
|
LastEditedBy string `json:"last_edited_by"`
|
|
ID string `json:"id"`
|
|
SiteID string `json:"site_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateContent(ctx context.Context, arg UpdateContentParams) (Content, error) {
|
|
row := q.db.QueryRowContext(ctx, updateContent,
|
|
arg.HtmlContent,
|
|
arg.LastEditedBy,
|
|
arg.ID,
|
|
arg.SiteID,
|
|
)
|
|
var i Content
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SiteID,
|
|
&i.HtmlContent,
|
|
&i.OriginalTemplate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.LastEditedBy,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const upsertContent = `-- name: UpsertContent :one
|
|
INSERT INTO content (id, site_id, html_content, original_template, last_edited_by)
|
|
VALUES (?1, ?2, ?3, ?4, ?5)
|
|
ON CONFLICT(id, site_id) DO UPDATE SET
|
|
html_content = EXCLUDED.html_content,
|
|
last_edited_by = EXCLUDED.last_edited_by
|
|
RETURNING id, site_id, html_content, original_template, created_at, updated_at, last_edited_by
|
|
`
|
|
|
|
type UpsertContentParams struct {
|
|
ID string `json:"id"`
|
|
SiteID string `json:"site_id"`
|
|
HtmlContent string `json:"html_content"`
|
|
OriginalTemplate sql.NullString `json:"original_template"`
|
|
LastEditedBy string `json:"last_edited_by"`
|
|
}
|
|
|
|
func (q *Queries) UpsertContent(ctx context.Context, arg UpsertContentParams) (Content, error) {
|
|
row := q.db.QueryRowContext(ctx, upsertContent,
|
|
arg.ID,
|
|
arg.SiteID,
|
|
arg.HtmlContent,
|
|
arg.OriginalTemplate,
|
|
arg.LastEditedBy,
|
|
)
|
|
var i Content
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SiteID,
|
|
&i.HtmlContent,
|
|
&i.OriginalTemplate,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.LastEditedBy,
|
|
)
|
|
return i, err
|
|
}
|