@marktiderman/genesis-cli 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -1
- package/dist/cli.js +1274 -424
- package/dist/cli.js.map +1 -1
- package/dist/{config-ARs2YQ60.d.ts → config-BmMsEWU-.d.ts} +7 -0
- package/dist/doctor.d.ts +3 -3
- package/dist/doctor.js +628 -7
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +2 -2
- package/dist/expo.js +11 -0
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +41 -17
- package/dist/index.d.ts +1 -1
- package/dist/index.js +636 -15
- package/dist/index.js.map +1 -1
- package/dist/starter/__tests__/starter.test.ts +8 -0
- package/dist/starter/fingerprint.config.js +18 -0
- package/dist/starter/supabase/migrations/20261025000095_genesis_support_ticket_fixes.sql +115 -0
- package/dist/starter/supabase/tests/database/genesis_support_ticket_fixes.test.sql +121 -0
- package/dist/verify.d.ts +209 -0
- package/dist/verify.js +549 -0
- package/dist/verify.js.map +1 -0
- package/dist/vite.js +628 -7
- package/dist/vite.js.map +1 -1
- package/package.json +18 -4
|
@@ -136,6 +136,14 @@ describe("fingerprint", () => {
|
|
|
136
136
|
expect(imports).toEqual(["expo/config", "./starter.config", "./src/lib/define-starter"]);
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
+
// Hashed by package.json, a config plugin's package changes the runtime version on every
|
|
140
|
+
// release (a version bump), so an app on npm Genesis would build on every Genesis upgrade.
|
|
141
|
+
it("hashes config plugins by the files they load, plus the rich push Swift", () => {
|
|
142
|
+
const config = read("fingerprint.config.js");
|
|
143
|
+
expect(config).toMatch(/configPluginSourceType:\s*"files"/);
|
|
144
|
+
expect(config).toContain('filePath: "node_modules/@marktiderman/genesis-native/ios"');
|
|
145
|
+
});
|
|
146
|
+
|
|
139
147
|
it("app.config.ts reads no JavaScript-only switch", () => {
|
|
140
148
|
expect(read("app.config.ts")).not.toMatch(/features\.(updates|queryPersistence|queryLifecycle|keyboardScroll|deepLinks|notifications|accountDeletion|wipeSessionOnReinstall|refreshWhileActive|observability|devtools)/);
|
|
141
149
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// What decides the runtime version (and so whether a merge to main ships an over-the-air update or
|
|
2
|
+
// a new store build, deploy-production.yml): Expo's fingerprint of the native project. Config
|
|
3
|
+
// plugins are hashed by the files they load, not by their package.json, so a package's version
|
|
4
|
+
// bump alone (every Genesis release bumps @marktiderman/genesis-native, whose rich push plugin the
|
|
5
|
+
// app loads) doesn't force a new build; a change to the plugin's code still does. The rich push
|
|
6
|
+
// plugin also copies a Swift file into the build, which it reads rather than loads, so that folder
|
|
7
|
+
// is hashed too. docs/NATIVE-RELEASE.md, "Fingerprints".
|
|
8
|
+
/** @type {import('@expo/fingerprint').Config} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
configPluginSourceType: "files",
|
|
11
|
+
extraSources: [
|
|
12
|
+
{
|
|
13
|
+
type: "dir",
|
|
14
|
+
filePath: "node_modules/@marktiderman/genesis-native/ios",
|
|
15
|
+
reasons: ["genesis-native rich push extension (copied into the build)"],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
-- @feat:support-feedback
|
|
2
|
+
-- Genesis support 0016: fixes to tickets (after 0004_genesis_support_tickets.sql).
|
|
3
|
+
--
|
|
4
|
+
-- 1. The Data Studio's records of support rows follow the rename. 0004 renamed
|
|
5
|
+
-- public.support_reports to public.tickets and public.support_attachments to
|
|
6
|
+
-- public.ticket_attachments; the Data Studio (genesis-studio-server) still keyed its rows by
|
|
7
|
+
-- the old names, so a ticket's history and comments stopped at the rename.
|
|
8
|
+
-- private.genesis_support_rename_studio_keys() rewrites `resource` in genesis_studio.audit_log,
|
|
9
|
+
-- comments, outbox and outbox_dead_letter, and the `resource` inside the outbox's and dead
|
|
10
|
+
-- letter's `payload` (what a delivery sends downstream), only where those tables exist
|
|
11
|
+
-- (to_regclass), and returns how many rows moved. It runs once here; running it again changes nothing.
|
|
12
|
+
-- 2. public.support_agent_unread_count(tenant) returns how many open tickets of a tenant hold a
|
|
13
|
+
-- message from the requester no agent has read: an agent's badge without reading the queue.
|
|
14
|
+
-- A null tenant means the app's own. Only an agent of the tenant may ask (42501 otherwise),
|
|
15
|
+
-- and an agent's own ticket isn't counted, as they can't handle it.
|
|
16
|
+
--
|
|
17
|
+
-- A notification for the verify prompt (0003: support_replies.prompt = 'verify') keys on that
|
|
18
|
+
-- column, never on the reply's words: the words are a sentence an app may translate or change.
|
|
19
|
+
--
|
|
20
|
+
-- Use: copy this file into your app's `supabase/migrations/` under a new timestamped name
|
|
21
|
+
-- (`genesis migrate` does it). Never edit it once applied; change it with a new migration.
|
|
22
|
+
--
|
|
23
|
+
-- Verify: the pgTAP test beside this file (`tests/0016_genesis_support_ticket_fixes.test.sql`).
|
|
24
|
+
|
|
25
|
+
create schema if not exists private;
|
|
26
|
+
|
|
27
|
+
-- 1. The Data Studio's keys --------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
create or replace function private.genesis_support_rename_studio_keys()
|
|
30
|
+
returns integer
|
|
31
|
+
language plpgsql
|
|
32
|
+
security definer
|
|
33
|
+
set search_path = ''
|
|
34
|
+
as $$
|
|
35
|
+
declare
|
|
36
|
+
moved integer := 0;
|
|
37
|
+
n integer;
|
|
38
|
+
t text;
|
|
39
|
+
begin
|
|
40
|
+
foreach t in array array['genesis_studio.audit_log', 'genesis_studio.comments', 'genesis_studio.outbox', 'genesis_studio.outbox_dead_letter'] loop
|
|
41
|
+
if to_regclass(t) is null then
|
|
42
|
+
continue;
|
|
43
|
+
end if;
|
|
44
|
+
execute format(
|
|
45
|
+
'update %s set resource = case resource
|
|
46
|
+
when ''public.support_reports'' then ''public.tickets''
|
|
47
|
+
when ''support_reports'' then ''tickets''
|
|
48
|
+
when ''public.support_attachments'' then ''public.ticket_attachments''
|
|
49
|
+
when ''support_attachments'' then ''ticket_attachments''
|
|
50
|
+
end
|
|
51
|
+
where resource in (''public.support_reports'', ''support_reports'', ''public.support_attachments'', ''support_attachments'')',
|
|
52
|
+
t);
|
|
53
|
+
get diagnostics n = row_count;
|
|
54
|
+
moved := moved + n;
|
|
55
|
+
end loop;
|
|
56
|
+
-- What a delivery carries downstream names the resource too.
|
|
57
|
+
foreach t in array array['genesis_studio.outbox', 'genesis_studio.outbox_dead_letter'] loop
|
|
58
|
+
if to_regclass(t) is null then
|
|
59
|
+
continue;
|
|
60
|
+
end if;
|
|
61
|
+
execute format(
|
|
62
|
+
'update %s set payload = jsonb_set(payload, ''{resource}'', to_jsonb(case payload ->> ''resource''
|
|
63
|
+
when ''public.support_reports'' then ''public.tickets''
|
|
64
|
+
when ''support_reports'' then ''tickets''
|
|
65
|
+
when ''public.support_attachments'' then ''public.ticket_attachments''
|
|
66
|
+
when ''support_attachments'' then ''ticket_attachments''
|
|
67
|
+
end))
|
|
68
|
+
where payload ->> ''resource'' in (''public.support_reports'', ''support_reports'', ''public.support_attachments'', ''support_attachments'')',
|
|
69
|
+
t);
|
|
70
|
+
get diagnostics n = row_count;
|
|
71
|
+
moved := moved + n;
|
|
72
|
+
end loop;
|
|
73
|
+
return moved;
|
|
74
|
+
end;
|
|
75
|
+
$$;
|
|
76
|
+
|
|
77
|
+
comment on function private.genesis_support_rename_studio_keys() is
|
|
78
|
+
'Moves the Data Studio''s audit and outbox rows from the old support table names to tickets and ticket_attachments. Genesis support.';
|
|
79
|
+
revoke execute on function private.genesis_support_rename_studio_keys() from public, anon, authenticated;
|
|
80
|
+
|
|
81
|
+
select private.genesis_support_rename_studio_keys();
|
|
82
|
+
|
|
83
|
+
-- 2. An agent's unread count -------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
create or replace function public.support_agent_unread_count(tenant uuid default null)
|
|
86
|
+
returns integer
|
|
87
|
+
language plpgsql
|
|
88
|
+
stable
|
|
89
|
+
security definer
|
|
90
|
+
set search_path = ''
|
|
91
|
+
as $$
|
|
92
|
+
declare
|
|
93
|
+
me uuid := auth.uid();
|
|
94
|
+
resolved uuid := coalesce(tenant, private.genesis_support_default_tenant_id());
|
|
95
|
+
begin
|
|
96
|
+
if me is null or not private.genesis_support_agent(resolved, me) then
|
|
97
|
+
raise exception 'support_agent_unread_count: only an agent of this tenant' using errcode = '42501';
|
|
98
|
+
end if;
|
|
99
|
+
return (
|
|
100
|
+
select count(*)::integer
|
|
101
|
+
from public.tickets t
|
|
102
|
+
where t.tenant_id = resolved
|
|
103
|
+
and t.user_id is distinct from me
|
|
104
|
+
-- Active tickets only, as 0013's queues count them: not pending (waiting on the requester),
|
|
105
|
+
-- not closed.
|
|
106
|
+
and t.status not in ('pending', 'addressed', 'wont_fix')
|
|
107
|
+
and (t.staff_read_at is null or coalesce(t.last_user_reply_at > t.staff_read_at, false))
|
|
108
|
+
);
|
|
109
|
+
end;
|
|
110
|
+
$$;
|
|
111
|
+
|
|
112
|
+
comment on function public.support_agent_unread_count(uuid) is
|
|
113
|
+
'How many active tickets (not pending, not closed) of a tenant hold a requester''s message no agent has read, for its agents. Genesis support.';
|
|
114
|
+
revoke execute on function public.support_agent_unread_count(uuid) from public, anon;
|
|
115
|
+
grant execute on function public.support_agent_unread_count(uuid) to authenticated;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
-- @feat:support-feedback
|
|
2
|
+
-- pgTAP test for 0016_genesis_support_ticket_fixes.sql: the Data Studio's keys follow the rename,
|
|
3
|
+
-- and an agent's unread count. Copy into your app's `supabase/tests/database/` and run
|
|
4
|
+
-- `supabase test db`. Rolls everything back; the app's hooks are replaced inside this transaction.
|
|
5
|
+
--
|
|
6
|
+
-- Tenants: d (the app's own), ta and tb. People: a1 a client of ta; b2 a client of tb; c3 an agent
|
|
7
|
+
-- of ta; e5 an agent of tb.
|
|
8
|
+
begin;
|
|
9
|
+
create extension if not exists pgtap with schema extensions;
|
|
10
|
+
select plan(14);
|
|
11
|
+
|
|
12
|
+
create function pg_temp.tenant(n text) returns uuid language sql immutable as $$
|
|
13
|
+
select case n when 'd' then '00000000-0000-4000-8000-00000000000f'::uuid
|
|
14
|
+
when 'ta' then '00000000-0000-4000-8000-0000000000a0'::uuid
|
|
15
|
+
else '00000000-0000-4000-8000-0000000000b0'::uuid end $$;
|
|
16
|
+
create function pg_temp.person(n text) returns uuid language sql immutable as $$
|
|
17
|
+
select ('00000000-0000-4000-8000-0000000004' || n)::uuid $$;
|
|
18
|
+
create function pg_temp.sign_in(n text) returns void language plpgsql as $$
|
|
19
|
+
begin
|
|
20
|
+
perform set_config('request.jwt.claims', json_build_object('sub', pg_temp.person(n), 'role', 'authenticated')::text, true);
|
|
21
|
+
perform set_config('request.jwt.claim.sub', pg_temp.person(n)::text, true);
|
|
22
|
+
end $$;
|
|
23
|
+
|
|
24
|
+
insert into auth.users (id, aud, role, email, instance_id)
|
|
25
|
+
select pg_temp.person(n), 'authenticated', 'authenticated', 'genesis-fixes-' || n || '@example.test',
|
|
26
|
+
'00000000-0000-0000-0000-000000000000'
|
|
27
|
+
from unnest(array['a1', 'b2', 'c3', 'e5']) n;
|
|
28
|
+
|
|
29
|
+
create or replace function private.genesis_support_default_tenant() returns uuid
|
|
30
|
+
language sql stable set search_path = '' as $$ select '00000000-0000-4000-8000-00000000000f'::uuid $$;
|
|
31
|
+
create or replace function private.genesis_viewer_people(viewer uuid)
|
|
32
|
+
returns table (tenant_id uuid, person_id uuid) language sql stable set search_path = '' as $$
|
|
33
|
+
select t.tenant_id, viewer from (values
|
|
34
|
+
('00000000-0000-4000-8000-0000000004a1'::uuid, '00000000-0000-4000-8000-0000000000a0'::uuid),
|
|
35
|
+
('00000000-0000-4000-8000-0000000004c3', '00000000-0000-4000-8000-0000000000a0'),
|
|
36
|
+
('00000000-0000-4000-8000-0000000004b2', '00000000-0000-4000-8000-0000000000b0'),
|
|
37
|
+
('00000000-0000-4000-8000-0000000004e5', '00000000-0000-4000-8000-0000000000b0')
|
|
38
|
+
) as t(login, tenant_id) where t.login = viewer $$;
|
|
39
|
+
drop function if exists private.genesis_tenant_admin(uuid, uuid);
|
|
40
|
+
drop function if exists private.genesis_support_report_handler(uuid, uuid);
|
|
41
|
+
revoke execute on function private.genesis_support_default_tenant() from public, anon, authenticated;
|
|
42
|
+
revoke execute on function private.genesis_viewer_people(uuid) from public, anon, authenticated;
|
|
43
|
+
|
|
44
|
+
insert into public.ticket_agents (tenant_id, person_id, role) values
|
|
45
|
+
(pg_temp.tenant('ta'), pg_temp.person('c3'), 'agent'),
|
|
46
|
+
(pg_temp.tenant('tb'), pg_temp.person('e5'), 'agent');
|
|
47
|
+
|
|
48
|
+
create table if not exists public.tenant_features (
|
|
49
|
+
tenant_id uuid not null, feature_id text not null, enabled boolean not null, reason text not null,
|
|
50
|
+
primary key (tenant_id, feature_id));
|
|
51
|
+
insert into public.tenant_features (tenant_id, feature_id, enabled, reason) values
|
|
52
|
+
(pg_temp.tenant('ta'), 'support-helpdesk', true, 'test'),
|
|
53
|
+
(pg_temp.tenant('tb'), 'support-helpdesk', true, 'test')
|
|
54
|
+
on conflict (tenant_id, feature_id) do update set enabled = true;
|
|
55
|
+
|
|
56
|
+
-- 1. The Data Studio's keys ---------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
select ok(not has_function_privilege('authenticated', 'private.genesis_support_rename_studio_keys()', 'execute'), 'nobody signed in rewrites the studio''s keys');
|
|
59
|
+
|
|
60
|
+
create schema if not exists genesis_studio;
|
|
61
|
+
create table if not exists genesis_studio.audit_log (
|
|
62
|
+
id uuid primary key default gen_random_uuid(), occurred_at timestamptz not null default clock_timestamp(),
|
|
63
|
+
actor text, actor_claims jsonb, resource text not null, record_key jsonb not null, action text not null, before jsonb, after jsonb);
|
|
64
|
+
create table if not exists genesis_studio.comments (
|
|
65
|
+
id uuid primary key default gen_random_uuid(), resource text not null, record_key jsonb not null, author text, body text not null,
|
|
66
|
+
created_at timestamptz not null default now());
|
|
67
|
+
create table if not exists genesis_studio.outbox (
|
|
68
|
+
id uuid primary key default gen_random_uuid(), seq bigserial, resource text not null, record_key jsonb not null, payload jsonb not null);
|
|
69
|
+
create table if not exists genesis_studio.outbox_dead_letter (
|
|
70
|
+
id uuid primary key default gen_random_uuid(), resource text not null, record_key jsonb not null, payload jsonb not null);
|
|
71
|
+
insert into genesis_studio.audit_log (resource, record_key, action) values
|
|
72
|
+
('public.support_reports', '"r1"', 'update'),
|
|
73
|
+
('public.support_attachments', '"a1"', 'create'),
|
|
74
|
+
('public.goals', '"g1"', 'update');
|
|
75
|
+
insert into genesis_studio.comments (resource, record_key, body) values ('public.support_reports', '"r1"', 'A note on the old name');
|
|
76
|
+
insert into genesis_studio.outbox (resource, record_key, payload) values ('public.support_reports', '"r1"', '{"resource": "public.support_reports", "action": "update"}');
|
|
77
|
+
insert into genesis_studio.outbox_dead_letter (resource, record_key, payload) values ('support_attachments', '"a1"', '{"resource": "support_attachments"}');
|
|
78
|
+
|
|
79
|
+
select is(private.genesis_support_rename_studio_keys(), 7, 'the old names move: three columns and two payloads besides the audit log');
|
|
80
|
+
select is((select array_agg(resource order by resource) from genesis_studio.audit_log where record_key in ('"r1"', '"a1"', '"g1"')),
|
|
81
|
+
array['public.goals', 'public.ticket_attachments', 'public.tickets'], '... to tickets and ticket_attachments, and nothing else moves');
|
|
82
|
+
select is((select resource from genesis_studio.comments where record_key = '"r1"'), 'public.tickets', 'a comment follows the rename');
|
|
83
|
+
select is((select resource || ' ' || (payload ->> 'resource') from genesis_studio.outbox where record_key = '"r1"'), 'public.tickets public.tickets', 'an outbox row and the payload it delivers follow it');
|
|
84
|
+
select is((select resource || ' ' || (payload ->> 'resource') from genesis_studio.outbox_dead_letter where record_key = '"a1"'), 'ticket_attachments ticket_attachments', 'a dead letter and its payload follow it');
|
|
85
|
+
select is(private.genesis_support_rename_studio_keys(), 0, 'running it again changes nothing');
|
|
86
|
+
|
|
87
|
+
-- 2. An agent's unread count --------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
select pg_temp.sign_in('a1');
|
|
90
|
+
set local role authenticated;
|
|
91
|
+
insert into public.tickets (type, title, message, tenant_id) values ('question', 'fix-ta1', 'Unread in ta', pg_temp.tenant('ta'));
|
|
92
|
+
insert into public.tickets (type, title, message, tenant_id) values ('question', 'fix-ta2', 'Read in ta', pg_temp.tenant('ta'));
|
|
93
|
+
insert into public.tickets (type, title, message, tenant_id) values ('question', 'fix-ta3', 'Closed in ta', pg_temp.tenant('ta'));
|
|
94
|
+
select pg_temp.sign_in('b2');
|
|
95
|
+
insert into public.tickets (type, title, message, tenant_id) values ('question', 'fix-tb1', 'Unread in tb', pg_temp.tenant('tb'));
|
|
96
|
+
reset role;
|
|
97
|
+
update public.tickets set staff_read_at = now() + interval '1 minute' where title = 'fix-ta2';
|
|
98
|
+
update public.tickets set status = 'addressed' where title = 'fix-ta3';
|
|
99
|
+
|
|
100
|
+
set local role authenticated;
|
|
101
|
+
select pg_temp.sign_in('c3');
|
|
102
|
+
select is(public.support_agent_unread_count(pg_temp.tenant('ta')), 1, 'an agent counts the open tickets nobody has read');
|
|
103
|
+
select pg_temp.sign_in('e5');
|
|
104
|
+
select is(public.support_agent_unread_count(pg_temp.tenant('tb')), 1, 'each tenant its own');
|
|
105
|
+
select throws_ok($$ select public.support_agent_unread_count('00000000-0000-4000-8000-0000000000a0') $$, '42501', null, 'an agent of another tenant can''t ask');
|
|
106
|
+
select pg_temp.sign_in('a1');
|
|
107
|
+
select throws_ok($$ select public.support_agent_unread_count('00000000-0000-4000-8000-0000000000a0') $$, '42501', null, 'nor can a requester');
|
|
108
|
+
reset role;
|
|
109
|
+
|
|
110
|
+
-- A requester's new message makes a read ticket unread again.
|
|
111
|
+
update public.tickets set last_user_reply_at = now() + interval '2 minutes' where title = 'fix-ta2';
|
|
112
|
+
set local role authenticated;
|
|
113
|
+
select pg_temp.sign_in('c3');
|
|
114
|
+
select is(public.support_agent_unread_count(pg_temp.tenant('ta')), 2, 'a new message from the requester is unread again');
|
|
115
|
+
reset role;
|
|
116
|
+
|
|
117
|
+
select ok(not has_function_privilege('anon', 'public.support_agent_unread_count(uuid)', 'execute'), 'anon can''t ask');
|
|
118
|
+
select ok(has_function_privilege('authenticated', 'public.support_agent_unread_count(uuid)', 'execute'), 'a signed-in agent can');
|
|
119
|
+
|
|
120
|
+
select * from finish();
|
|
121
|
+
rollback;
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The checks that run inside the page. `domChecks` is passed to Playwright's `page.evaluate`, so it
|
|
5
|
+
* must be self-contained: no imports, no closures, no helpers outside its body. It returns every
|
|
6
|
+
* finding (callers cap what they print, after the allow list), and it leaves the page as it found
|
|
7
|
+
* it: focus, and the scroll position of the window and of every scrolling frame, are restored.
|
|
8
|
+
*/
|
|
9
|
+
interface DomCheckOptions {
|
|
10
|
+
/** The viewport is phone-sized (rule 9 counts floating controls there). */
|
|
11
|
+
phone: boolean;
|
|
12
|
+
/** Touch is on: the 44px hit-area check runs (docs/RESPONSIVE.md rule 3). */
|
|
13
|
+
coarse: boolean;
|
|
14
|
+
/** At most this many focusable elements are focused for the obscured-focus check, those in `main` first. */
|
|
15
|
+
maxFocus: number;
|
|
16
|
+
/** Text is zoomed (WCAG 1.4.4): text clipped by an ancestor that hides overflow is a finding. */
|
|
17
|
+
textZoom?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface DomFinding {
|
|
20
|
+
check: "reflow" | "text-clipped" | "focus-obscured" | "hit-area" | "floating-controls" | "viewport-meta" | "touch-media";
|
|
21
|
+
/** `info` findings are reported but never fail a run (the engine's emulation, not the page). */
|
|
22
|
+
level?: "info";
|
|
23
|
+
/** A short CSS path to the element, ending in its accessible name when it has one. */
|
|
24
|
+
target?: string;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
declare function domChecks(opts: DomCheckOptions): Promise<DomFinding[]>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The conformance matrix: engines × viewports (docs/RESPONSIVE.md rule 10, WCAG 1.4.10).
|
|
31
|
+
*
|
|
32
|
+
* Playwright has no browser zoom. Zooming a 1280×1024 window to 200% or 400% lays the page out
|
|
33
|
+
* in a 640×512 or 320×256 CSS viewport, so zoom is those viewports (device pixel ratio doesn't
|
|
34
|
+
* change layout). A zoomed desktop keeps its mouse: no touch, so the (pointer: fine) and hover
|
|
35
|
+
* layouts at narrow widths are what the zoom viewports test. Phone and tablet widths run with touch.
|
|
36
|
+
*/
|
|
37
|
+
type Engine = "chromium" | "webkit" | "firefox";
|
|
38
|
+
declare const ENGINES: Engine[];
|
|
39
|
+
interface Viewport {
|
|
40
|
+
/** Stable name used in reports and allow entries: `320`, `1280`, `zoom-200`, `zoom-400`. */
|
|
41
|
+
name: string;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
/** Touch on: `hasTouch`, `isMobile`, and the coarse-pointer checks. */
|
|
45
|
+
touch: boolean;
|
|
46
|
+
/** A phone width: rule 9's floating-control count runs. */
|
|
47
|
+
phone: boolean;
|
|
48
|
+
/** The browser's default text size is doubled (WCAG 1.4.4); Chromium only, through its font-size setting. */
|
|
49
|
+
textZoom?: boolean;
|
|
50
|
+
}
|
|
51
|
+
declare const WIDTHS: readonly [320, 375, 768, 1024, 1280, 1440];
|
|
52
|
+
declare function widthViewport(width: number): Viewport;
|
|
53
|
+
declare const ZOOM_VIEWPORTS: Viewport[];
|
|
54
|
+
/**
|
|
55
|
+
* Text at 200% (WCAG 1.4.4), the browser's own text-size setting rather than page zoom: rem and em
|
|
56
|
+
* grow, px doesn't. Chromium only (it sets the setting through CDP).
|
|
57
|
+
*/
|
|
58
|
+
declare const TEXT_ZOOM_VIEWPORT: Viewport;
|
|
59
|
+
/** Every viewport: the six widths, the two zoom levels, then text at 200%. */
|
|
60
|
+
declare function allViewports(widths?: readonly number[]): Viewport[];
|
|
61
|
+
/** Whether an engine runs a viewport: text zoom needs Chromium. */
|
|
62
|
+
declare function runsIn(viewport: Viewport, engine: Engine): boolean;
|
|
63
|
+
/** Playwright context options for a viewport in an engine. */
|
|
64
|
+
declare function contextOptions(viewport: Viewport, engine: Engine): {
|
|
65
|
+
viewport: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
hasTouch: boolean;
|
|
70
|
+
isMobile: boolean;
|
|
71
|
+
reducedMotion: "reduce";
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check one loaded page: axe's WCAG 2.2 A/AA rules (target-size included), then the in-page checks
|
|
76
|
+
* (dom.ts), in that order because the focus check moves focus and scrolls. Read-only: the page
|
|
77
|
+
* gets no input but `focus()`. Animations and transitions are stopped first, so a layout is
|
|
78
|
+
* measured at rest.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
type CheckId = DomFinding["check"] | "axe";
|
|
82
|
+
interface Finding {
|
|
83
|
+
check: CheckId;
|
|
84
|
+
/** `info` findings are reported and never fail a run. */
|
|
85
|
+
level?: "info";
|
|
86
|
+
/** The axe rule id, for `axe` findings. */
|
|
87
|
+
rule?: string;
|
|
88
|
+
target?: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}
|
|
91
|
+
interface CheckPageOptions {
|
|
92
|
+
viewport: Viewport;
|
|
93
|
+
/** Axe rules to leave out everywhere (rare: a rule that misfires on a pattern Genesis ships). */
|
|
94
|
+
disableAxeRules?: string[];
|
|
95
|
+
/** Selectors axe skips (third-party frames). */
|
|
96
|
+
axeExclude?: string[];
|
|
97
|
+
/** Skip the viewport-meta check (a story iframe has Storybook's meta, not the app's). */
|
|
98
|
+
skipMeta?: boolean;
|
|
99
|
+
maxFocus?: number;
|
|
100
|
+
}
|
|
101
|
+
declare const AXE_TAGS: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Doubles the browser's default text size (Chromium's font-size setting, as a person sets it), for
|
|
104
|
+
* the text-200 viewport. Call before `page.goto`.
|
|
105
|
+
*/
|
|
106
|
+
declare function zoomText(page: Page): Promise<void>;
|
|
107
|
+
declare function checkPage(page: Page, opts: CheckPageOptions): Promise<Finding[]>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Known findings, the doctor's way: each entry names what it covers and why, and the list only
|
|
111
|
+
* shrinks (a full run warns on an entry that covered nothing, so it gets removed).
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
interface AllowEntry {
|
|
115
|
+
check: CheckId;
|
|
116
|
+
/** The axe rule, for `axe` entries. */
|
|
117
|
+
rule?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The page: a path (`/items`), a route pattern (`/items/:id`, `/docs/*`), a story id
|
|
120
|
+
* (`story:forms--default`), or a story prefix ending in `*` (`story:forms--*`).
|
|
121
|
+
*/
|
|
122
|
+
page: string;
|
|
123
|
+
/** Viewport names (`320`, `zoom-400`); every viewport when left out. */
|
|
124
|
+
viewports?: string[];
|
|
125
|
+
engines?: Engine[];
|
|
126
|
+
/**
|
|
127
|
+
* The element: the trailing parts of the finding's selector path, matched whole (`table-row >
|
|
128
|
+
* button`; `:nth-of-type()`, `:nth-child()` and generated ids are ignored on both sides), with or
|
|
129
|
+
* without its quoted accessible name, or the name alone (`"Save"`). Any element when left out.
|
|
130
|
+
*/
|
|
131
|
+
target?: string;
|
|
132
|
+
reason: string;
|
|
133
|
+
}
|
|
134
|
+
interface Where {
|
|
135
|
+
page: string;
|
|
136
|
+
viewport: string;
|
|
137
|
+
engine: Engine;
|
|
138
|
+
}
|
|
139
|
+
declare function matchesPage(pattern: string, page: string): boolean;
|
|
140
|
+
/** A target split into its selector parts (no `:nth-…`) and its quoted accessible name. */
|
|
141
|
+
declare function targetParts(target: string): {
|
|
142
|
+
parts: string[];
|
|
143
|
+
name?: string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Whether an entry's target names a finding's element: its accessible name exactly, or the trailing
|
|
147
|
+
* selector parts of the finding's path, each part whole. Never a substring: `html` doesn't match
|
|
148
|
+
* `[data-slot="html-preview"]`, and `#tabs` doesn't match `#tabs-2`. An entry that names an
|
|
149
|
+
* `[aria-label=…]` covers only findings with that same label (a Save entry never covers Delete).
|
|
150
|
+
*/
|
|
151
|
+
declare function matchesTarget(entryTarget: string, findingTarget: string | undefined): boolean;
|
|
152
|
+
/** The entry that covers a finding. A targeted entry always wins over one without a target, wherever each sits in the list. */
|
|
153
|
+
declare function allowFor(entries: AllowEntry[], finding: Finding, where: Where): AllowEntry | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Whether a base entry already allows everything a new entry does: the same check and rule, a page
|
|
156
|
+
* pattern that includes it, at least its viewports and engines, and no target or the same one. A
|
|
157
|
+
* narrowed entry isn't growth.
|
|
158
|
+
*/
|
|
159
|
+
/**
|
|
160
|
+
* Whether every path a page pattern matches is matched by another, segment by segment: a base
|
|
161
|
+
* `:param` covers a static segment or another parameter, only a base `*` covers a `*`, and a base
|
|
162
|
+
* that requires a segment never covers one that's optional. `/demo/:ws` doesn't cover `/demo/*`.
|
|
163
|
+
*/
|
|
164
|
+
declare function patternCovers(base: string, pattern: string): boolean;
|
|
165
|
+
declare function entryCovers(base: AllowEntry, e: AllowEntry): boolean;
|
|
166
|
+
/** Splits findings into the ones an entry covers, `info` notes (never failing), and the rest. */
|
|
167
|
+
declare function applyAllow(entries: AllowEntry[], findings: Finding[], where: Where): {
|
|
168
|
+
allowed: {
|
|
169
|
+
finding: Finding;
|
|
170
|
+
entry: AllowEntry;
|
|
171
|
+
}[];
|
|
172
|
+
notes: Finding[];
|
|
173
|
+
failing: Finding[];
|
|
174
|
+
};
|
|
175
|
+
declare function validateAllow(entries: AllowEntry[]): string[];
|
|
176
|
+
declare function formatFinding(f: Finding): string;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Route patterns, so a run visits one page per route rather than every value of a parameter.
|
|
180
|
+
* React Router's own manifest (`react-router routes --json`) gives the patterns; a concrete path
|
|
181
|
+
* (from a sitemap or a link) is matched to its pattern.
|
|
182
|
+
*/
|
|
183
|
+
interface ReactRouterRoute {
|
|
184
|
+
id: string;
|
|
185
|
+
path?: string;
|
|
186
|
+
index?: boolean;
|
|
187
|
+
file?: string;
|
|
188
|
+
children?: ReactRouterRoute[];
|
|
189
|
+
}
|
|
190
|
+
interface RoutePattern {
|
|
191
|
+
/** The full pattern, `/demo/:ws/clients/:id/:section?`. */
|
|
192
|
+
pattern: string;
|
|
193
|
+
/** The route's id (React Router) or file. */
|
|
194
|
+
id: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Every route that renders a page, with its full pattern: leaves, index routes, and a parent with a
|
|
198
|
+
* path of its own ("" included) and no index child: it renders at its own path too, around an
|
|
199
|
+
* empty outlet. A pathless layout route renders nothing of its own.
|
|
200
|
+
*/
|
|
201
|
+
declare function flattenReactRouterRoutes(routes: ReactRouterRoute[], base?: string): RoutePattern[];
|
|
202
|
+
/** Whether a concrete path matches a pattern (`:param`, `:optional?`, `*` splat, `$param` too). */
|
|
203
|
+
declare function matchesPattern(pattern: string, path: string): boolean;
|
|
204
|
+
/** The pattern a path matches that React Router would pick: the highest-ranked one. */
|
|
205
|
+
declare function patternFor(path: string, patterns: RoutePattern[]): RoutePattern | undefined;
|
|
206
|
+
/** One path per pattern, the first seen; a path that matches no pattern is kept as its own. */
|
|
207
|
+
declare function onePathPerPattern(paths: string[], patterns: RoutePattern[]): string[];
|
|
208
|
+
|
|
209
|
+
export { AXE_TAGS, type AllowEntry, type CheckId, type CheckPageOptions, type DomCheckOptions, type DomFinding, ENGINES, type Engine, type Finding, type ReactRouterRoute, type RoutePattern, TEXT_ZOOM_VIEWPORT, type Viewport, WIDTHS, type Where, ZOOM_VIEWPORTS, allViewports, allowFor, applyAllow, checkPage, contextOptions, domChecks, entryCovers, flattenReactRouterRoutes, formatFinding, matchesPage, matchesPattern, matchesTarget, onePathPerPattern, patternCovers, patternFor, runsIn, targetParts, validateAllow, widthViewport, zoomText };
|