سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 15:45 UTC
test: gate C8 workflow policy SQL contract
davoodmehraban89 committed
Oct 1, 2026 at 21:02 UTC
2a20d8e4144fd6e06ef30257f2d48e7e72a3a33d
1 file changed
+14
-1
scripts/office-slice-c8-check.mjs
+14
-1
@@ -5,4 +5,17 @@ for(const token of required){if(!src.includes(token))throw new Error('C8 UI cont
5
if(/\.innerHTML\s*=/.test(src))throw new Error('C8 UI must not render workflow content through innerHTML');
6
if(!src.includes("['edit','refer','approve']"))throw new Error('C8 capability allowlist drift');
7
if(!src.includes('مرحله گردش، جایگزین ثبت دبیرخانه یا تأیید داخلی نامه نیست.'))throw new Error('C8 status/workflow separation notice missing');
8
-console.log('Office Slice C8 policy UI contract: PASS');
\ No newline at end of file
8
+
9
+const migrationPath='supabase/migrations/20261001173125_office_slice_c8_workflow_policy.sql';
10
+if(!fs.existsSync(migrationPath))throw new Error('C8 workflow policy migration missing');
11
+const sql=fs.readFileSync(migrationPath,'utf8');
12
+for(const token of [
13
+ 'private.office_workflow_policy_versions','enable row level security','private.office_workflow_validate_definition',
14
+ 'private.office_workflow_publish_impl','public.office_workflow_publish','private.office_workflow_catalog_impl','public.office_workflow_catalog',
15
+ "('edit','refer','approve')",'pg_advisory_xact_lock','published workflow policy is immutable','security invoker'
16
+]){if(!sql.includes(token))throw new Error('C8 SQL contract missing: '+token)}
17
+if(!sql.includes("revoke all on private.office_workflow_policy_versions from public,anon,authenticated"))throw new Error('C8 private table grants are not closed');
18
+if(!sql.includes("p_organization_id not in (select private.current_organization_ids())"))throw new Error('C8 private entry points must verify active membership');
19
+if(!sql.includes("organization_has_module_entitlement(p_organization_id,'office_automation',true)"))throw new Error('C8 publication must require writable entitlement');
20
+if(!sql.includes("organization_has_module_entitlement(p_organization_id,'office_automation',false)"))throw new Error('C8 catalog must preserve read-only expired access');
21
+console.log('Office Slice C8 policy UI + SQL contract: PASS');