feat(anatomy): curation pipeline — changeset schema, applier with before/after records, cleaned single asset, draft seed, changelog + review report generators; seed layout legacy-import/curation/draft

This commit is contained in:
bchanot committed 2026-10-09 16:50:08 +02:00
1 parent 3dbbfdf1df
commit 6870d87910
58 files changed
+18167 -267

No files matched your search

+12 -6
View File
@@ -1,8 +1,8 @@
-- Official equine sheet seed (supabase/seed/anatomical-sheets/equine/v1):
-- Official equine sheet seed (supabase/seed/anatomical-sheets/equine/draft):
-- present as a platform-owned DRAFT, never published by the seed, publishable
-- by platform admins only, content accepted by the SQL referential gate.
begin;
select plan(18);
select plan(19);
insert into auth.users (id, email) values
('40000000-0000-0000-0000-000000000001', 'root-seed@test.local'),
@@ -31,7 +31,7 @@ select results_eq(
$$ values (1, 'draft', 2, null::timestamptz) $$,
'exactly one version, draft v1, never published'
);
select is((select count(*) from public.anatomical_sheet_assets where sheet_id = pg_temp.id('sheet')), 2::bigint, 'two SVG assets registered');
select is((select count(*) from public.anatomical_sheet_assets where sheet_id = pg_temp.id('sheet')), 1::bigint, 'one SVG asset registered (the cleaned drawing)');
select is(
(select content ->> 'species_id' from public.anatomical_sheet_versions where id = pg_temp.id('draft')),
'equine', 'document species is equine'
@@ -40,6 +40,12 @@ select is(
(select jsonb_array_length(content -> 'views') from public.anatomical_sheet_versions where id = pg_temp.id('draft')),
2, 'document has two views'
);
select ok(
(select content -> 'views' -> 1 -> 'svg_asset_id' = 'null'::jsonb
and jsonb_typeof(content -> 'views' -> 1 -> 'view_box') = 'object'
from public.anatomical_sheet_versions where id = pg_temp.id('draft')),
'head view is a crop of the main drawing: no asset, a view_box'
);
select is(
(select jsonb_array_length(content -> 'annotations') from public.anatomical_sheet_versions where id = pg_temp.id('draft')),
27, 'document has 27 annotations'
@@ -75,7 +81,7 @@ select is((select count(*) from public.anatomical_sheet_versions where id = pg_t
select lives_ok($$ select public.publish_sheet_version(pg_temp.id('draft')) $$, 'a platform admin could publish it (rolled back here)');
-- 3. Storage: the seed registers metadata only; after the operator upload + confirmation,
-- a platform admin reads both objects and a plain user none.
-- a platform admin reads the object and a plain user none.
reset role;
insert into storage.objects (bucket_id, name)
select 'anatomical-sheet-assets', a.sha256 || '.svg' from public.anatomical_sheet_assets a where a.sheet_id = pg_temp.id('sheet');
@@ -86,11 +92,11 @@ set local role service_role;
select is(
(select count(*) from public.anatomical_sheet_assets a where a.sheet_id = pg_temp.id('sheet')
and public.confirm_sheet_asset_upload(a.id) = a.id),
2::bigint, 'operator confirms the two uploads'
1::bigint, 'operator confirms the upload'
);
set local role authenticated;
select set_config('request.jwt.claims', '{"sub":"40000000-0000-0000-0000-000000000001","role":"authenticated"}', true);
select is((select count(*) from storage.objects where bucket_id = 'anatomical-sheet-assets'), 2::bigint, 'a platform admin reads both official SVGs');
select is((select count(*) from storage.objects where bucket_id = 'anatomical-sheet-assets'), 1::bigint, 'a platform admin reads the official SVG');
select set_config('request.jwt.claims', '{"sub":"40000000-0000-0000-0000-00000000000a","role":"authenticated"}', true);
select is((select count(*) from storage.objects where bucket_id = 'anatomical-sheet-assets'), 0::bigint, 'a plain user reads no official draft SVG');