1ff6e494c0
Build backend images / build content-svc (push) Failing after 19s
Build backend images / build file-svc (push) Failing after 1m53s
Build backend images / build gateway (push) Failing after 16s
Build backend images / build identity-svc (push) Failing after 7m1s
Build backend images / build notification-svc (push) Failing after 7m24s
Build backend images / build render-svc (push) Failing after 3m12s
Build backend images / build studio-svc (push) Failing after 43s
feat: AE template scanner + scene editor + AEP bundle pipeline
Scene editor (admin): per-project Scenes / Shared Colors / Color Presets
manager (ProjectScenes) reachable from each project.
AEP bundle pipeline: upload .aep or .zip → stored once per template at
templates/{project_id}/(bundle.zip|template.aep); render claim probes and
returns is_bundle+md5; node-agent extracts the bundle, locates the .aep
(zip-slip guarded), and caches by md5 so repeated renders extract once.
AE template scanner ("read scenes/colours/configs from the AEP"):
- content-svc importer: POST /v1/projects/{id}/scan/{preview,apply} —
review-diff-then-merge into scenes/elements/colours (manual edits kept).
- render-svc Go quick-scan: stdlib RIFX parser extracts comp names+durations
(no AE) → POST /v1/template-scans/{id}/quick.
- render-svc AE scan jobs + node-agent runner: queue → node runs scan.jsx
(reverse of legacy JSXGenerator conventions: frfinal/frshare/frl_/frd_) →
posts ScanResult back. Migration 26_render_scan_jobs.
- admin UI: "اسکن از افترافکت" with quick/full engines + diff-review modal.
Verified: importer preview/apply, Go quick-scan end-to-end (synthetic .aep →
scene imported), bundle extract unit tests, RIFX parser unit tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
83 lines
2.5 KiB
Go
83 lines
2.5 KiB
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5"
|
|
)
|
|
|
|
// ScanJob is an async "scan this project's AE template" job.
|
|
type ScanJob struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
Status string `json:"status"` // queued | running | done | error
|
|
Engine string `json:"engine"`
|
|
Result json.RawMessage `json:"result,omitempty"` // ScanResult JSON, present when done
|
|
Error *string `json:"error,omitempty"`
|
|
}
|
|
|
|
// ScanClaim is the minimal info a node needs to run a claimed scan.
|
|
type ScanClaim struct {
|
|
ID uuid.UUID
|
|
ProjectID uuid.UUID
|
|
}
|
|
|
|
func (s *Store) CreateScanJob(ctx context.Context, projectID uuid.UUID, engine string) (uuid.UUID, error) {
|
|
var id uuid.UUID
|
|
err := s.pool.QueryRow(ctx,
|
|
`INSERT INTO render.scan_jobs (project_id, engine, status) VALUES ($1, $2, 'queued') RETURNING id`,
|
|
projectID, engine).Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
// ClaimScanJob atomically grabs the oldest queued ae-jsx scan for a node.
|
|
// Returns nil when the queue is empty.
|
|
func (s *Store) ClaimScanJob(ctx context.Context, nodeID uuid.UUID) (*ScanClaim, error) {
|
|
var c ScanClaim
|
|
err := s.pool.QueryRow(ctx, `
|
|
UPDATE render.scan_jobs SET status = 'running', node_id = $1, updated_at = NOW()
|
|
WHERE id = (
|
|
SELECT id FROM render.scan_jobs
|
|
WHERE status = 'queued' AND engine = 'ae-jsx'
|
|
ORDER BY created_at
|
|
LIMIT 1 FOR UPDATE SKIP LOCKED
|
|
)
|
|
RETURNING id, project_id`, nodeID).Scan(&c.ID, &c.ProjectID)
|
|
if err != nil {
|
|
if err == pgx.ErrNoRows {
|
|
return nil, nil
|
|
}
|
|
return nil, err
|
|
}
|
|
return &c, nil
|
|
}
|
|
|
|
func (s *Store) SetScanResult(ctx context.Context, id uuid.UUID, resultJSON string) error {
|
|
_, err := s.pool.Exec(ctx,
|
|
`UPDATE render.scan_jobs SET status = 'done', result = $2::jsonb, error = NULL, updated_at = NOW() WHERE id = $1`,
|
|
id, resultJSON)
|
|
return err
|
|
}
|
|
|
|
func (s *Store) SetScanError(ctx context.Context, id uuid.UUID, msg string) error {
|
|
_, err := s.pool.Exec(ctx,
|
|
`UPDATE render.scan_jobs SET status = 'error', error = $2, updated_at = NOW() WHERE id = $1`, id, msg)
|
|
return err
|
|
}
|
|
|
|
func (s *Store) GetScanJob(ctx context.Context, id uuid.UUID) (*ScanJob, error) {
|
|
var j ScanJob
|
|
err := s.pool.QueryRow(ctx,
|
|
`SELECT id, project_id, status, engine, result, error FROM render.scan_jobs WHERE id = $1`,
|
|
id).Scan(&j.ID, &j.ProjectID, &j.Status, &j.Engine, &j.Result, &j.Error)
|
|
if err != nil {
|
|
if err == pgx.ErrNoRows {
|
|
return nil, nil
|
|
}
|
|
return nil, err
|
|
}
|
|
return &j, nil
|
|
}
|