@marktiderman/genesis-supabase 0.4.0 → 0.6.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 +138 -1
- package/dist/blocks.d.ts +16 -1
- package/dist/blocks.js +1 -1
- package/dist/chunk-ONBOLMXH.js +96 -0
- package/dist/chunk-ONBOLMXH.js.map +1 -0
- package/dist/{index-BSGz3RGk.d.ts → index-Ds0tO9WP.d.ts} +76 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +61 -2
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +185 -0
- package/dist/jobs.js +163 -0
- package/dist/jobs.js.map +1 -0
- package/dist/native.d.ts +2 -2
- package/migrations/0007_genesis_jobs.sql +352 -0
- package/migrations/0008_genesis_feature_registry.sql +412 -0
- package/migrations/tests/0007_genesis_jobs.test.sql +129 -0
- package/migrations/tests/0008_genesis_feature_registry.test.sql +180 -0
- package/package.json +65 -3
- package/dist/chunk-T2HGFC4C.js +0 -37
- package/dist/chunk-T2HGFC4C.js.map +0 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
-- @feat:feature-mirror
|
|
2
|
+
-- pgTAP test for 0008_genesis_feature_registry.sql (needs 0004_genesis_tenant_features.sql).
|
|
3
|
+
-- Copy into your app's `supabase/tests/database/` and run `supabase test db`.
|
|
4
|
+
-- It writes only its own users, tenants, hooks and registry rows and rolls everything back.
|
|
5
|
+
-- If your app already has the hooks, they are replaced inside this transaction only.
|
|
6
|
+
begin;
|
|
7
|
+
create extension if not exists pgtap with schema extensions;
|
|
8
|
+
select plan(62);
|
|
9
|
+
|
|
10
|
+
-- People: a1 admin of tenant 1, b2 member of tenant 1, c3 admin of tenant 2.
|
|
11
|
+
insert into auth.users (id, aud, role, email, instance_id)
|
|
12
|
+
select ('00000000-0000-4000-8000-0000000000' || n)::uuid, 'authenticated', 'authenticated', 'genesis-registry-' || n || '@example.test', '00000000-0000-0000-0000-000000000000'
|
|
13
|
+
from unnest(array['a1', 'b2', 'c3']) n;
|
|
14
|
+
|
|
15
|
+
create function pg_temp.person(n text) returns uuid language sql immutable as $$ select ('00000000-0000-4000-8000-0000000000' || n)::uuid $$;
|
|
16
|
+
create function pg_temp.tenant(n int) returns uuid language sql immutable as $$ select ('00000000-0000-4000-9000-00000000000' || n)::uuid $$;
|
|
17
|
+
create function pg_temp.sign_in(n text) returns void language plpgsql as $$
|
|
18
|
+
begin
|
|
19
|
+
perform set_config('role', 'authenticated', true);
|
|
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
|
+
create function pg_temp.as_service() returns void language plpgsql as $$
|
|
24
|
+
begin
|
|
25
|
+
perform set_config('role', 'service_role', true);
|
|
26
|
+
perform set_config('request.jwt.claims', json_build_object('role', 'service_role')::text, true);
|
|
27
|
+
perform set_config('request.jwt.claim.sub', '', true);
|
|
28
|
+
end $$;
|
|
29
|
+
create function pg_temp.as_owner() returns void language plpgsql as $$
|
|
30
|
+
begin
|
|
31
|
+
perform set_config('role', 'postgres', true);
|
|
32
|
+
perform set_config('request.jwt.claims', '', true);
|
|
33
|
+
perform set_config('request.jwt.claim.sub', '', true);
|
|
34
|
+
end $$;
|
|
35
|
+
grant execute on function pg_temp.person(text), pg_temp.tenant(int), pg_temp.sign_in(text), pg_temp.as_service(), pg_temp.as_owner()
|
|
36
|
+
to anon, authenticated, service_role;
|
|
37
|
+
|
|
38
|
+
drop function if exists private.genesis_tenant_admin(uuid, uuid);
|
|
39
|
+
drop function if exists private.genesis_tenant_member(uuid, uuid);
|
|
40
|
+
create table private.genesis_test_members (tenant uuid, person uuid, admin boolean);
|
|
41
|
+
insert into private.genesis_test_members values
|
|
42
|
+
(pg_temp.tenant(1), pg_temp.person('a1'), true),
|
|
43
|
+
(pg_temp.tenant(1), pg_temp.person('b2'), false),
|
|
44
|
+
(pg_temp.tenant(2), pg_temp.person('c3'), true);
|
|
45
|
+
create function private.genesis_tenant_admin(tenant uuid, person uuid) returns boolean language sql stable set search_path = '' as $$
|
|
46
|
+
select exists (select 1 from private.genesis_test_members m where m.tenant = genesis_tenant_admin.tenant and m.person = genesis_tenant_admin.person and m.admin)
|
|
47
|
+
$$;
|
|
48
|
+
create function private.genesis_tenant_member(tenant uuid, person uuid) returns boolean language sql stable set search_path = '' as $$
|
|
49
|
+
select exists (select 1 from private.genesis_test_members m where m.tenant = genesis_tenant_member.tenant and m.person = genesis_tenant_member.person)
|
|
50
|
+
$$;
|
|
51
|
+
revoke execute on function private.genesis_tenant_admin(uuid, uuid), private.genesis_tenant_member(uuid, uuid) from public, anon, authenticated;
|
|
52
|
+
|
|
53
|
+
-- The registry: live, paid, beta behind a flag, planned. The same shapes as features.json.
|
|
54
|
+
create table pg_temp.registry (features jsonb, flags jsonb);
|
|
55
|
+
insert into pg_temp.registry values (
|
|
56
|
+
'[{"id": "forms", "name": "Forms", "status": "live", "apps": ["web"]},
|
|
57
|
+
{"id": "webhooks", "name": "Webhooks", "status": "live", "apps": ["web"], "access": {"plan": "pro"}},
|
|
58
|
+
{"id": "sms", "name": "Text a link", "status": "beta", "apps": ["web"], "platforms": {"web": "beta"}},
|
|
59
|
+
{"id": "courses", "name": "Courses", "status": "planned", "apps": ["web"]}]',
|
|
60
|
+
'[{"key": "sms.release", "feature": "sms", "kind": "release", "default": false, "scopes": ["platform", "tenant"], "expires": "2027-01-31"}]');
|
|
61
|
+
grant select on pg_temp.registry to service_role, authenticated;
|
|
62
|
+
|
|
63
|
+
-- Shape and access ------------------------------------------------------------------------------
|
|
64
|
+
select has_table('public', 'features', 'features exists');
|
|
65
|
+
select has_table('public', 'feature_flags', 'feature_flags exists');
|
|
66
|
+
select has_table('public', 'feature_entitlements', 'feature_entitlements exists');
|
|
67
|
+
select has_table('public', 'tenant_flag_values', 'tenant_flag_values exists');
|
|
68
|
+
select ok(
|
|
69
|
+
(select bool_and(relrowsecurity) from pg_class where oid in ('public.features'::regclass, 'public.feature_flags'::regclass,
|
|
70
|
+
'public.feature_entitlements'::regclass, 'public.tenant_flag_values'::regclass, 'private.feature_registry_state'::regclass)),
|
|
71
|
+
'RLS is on for every table');
|
|
72
|
+
select ok(not has_table_privilege('authenticated', 'public.feature_flags', 'select'), 'signed-in people can''t read flag rows');
|
|
73
|
+
select ok(not has_table_privilege('authenticated', 'public.feature_entitlements', 'select,insert,update,delete'), '... nor entitlements');
|
|
74
|
+
select ok(not has_table_privilege('authenticated', 'public.tenant_flag_values', 'select,insert,update,delete'), '... nor flag values');
|
|
75
|
+
select ok(not has_table_privilege('authenticated', 'public.features', 'insert,update,delete'), 'nobody signed in writes features');
|
|
76
|
+
select ok(not has_function_privilege('authenticated', 'public.sync_feature_registry(bigint, text, jsonb, jsonb, boolean)', 'execute'), 'only the service role syncs');
|
|
77
|
+
select ok(not has_function_privilege('anon', 'public.feature_on(uuid, text)', 'execute'), 'anon can''t ask the gate');
|
|
78
|
+
select ok(not has_function_privilege('anon', 'public.feature_gate_state(uuid)', 'execute'), '... nor read gate state');
|
|
79
|
+
|
|
80
|
+
-- Syncing ---------------------------------------------------------------------------------------
|
|
81
|
+
select pg_temp.as_service();
|
|
82
|
+
select is(public.sync_feature_registry(100, 'h1', (select features from pg_temp.registry), (select flags from pg_temp.registry)), true, 'the service role syncs');
|
|
83
|
+
select is(public.sync_feature_registry(100, 'h1', (select features from pg_temp.registry), (select flags from pg_temp.registry)), false, 'the same hash is a no-op');
|
|
84
|
+
select is(public.sync_feature_registry(50, 'old', (select features from pg_temp.registry), '[]'), false, 'an older version is refused');
|
|
85
|
+
select is((select count(*)::int from public.feature_flags), 1, '... and leaves the newer flags');
|
|
86
|
+
select is((select access_plan from public.features where id = 'webhooks'), 'pro', 'a paid feature keeps its plan');
|
|
87
|
+
select is((select platforms ->> 'web' from public.features where id = 'sms'), 'beta', 'platform statuses are kept');
|
|
88
|
+
select throws_ok($$select public.sync_feature_registry(null, 'x', '[]', '[]')$$, '22023', null, 'a sync needs a version');
|
|
89
|
+
|
|
90
|
+
-- The gate in SQL --------------------------------------------------------------------------------
|
|
91
|
+
select is(public.feature_on(pg_temp.tenant(1), 'forms'), true, 'a live feature is on');
|
|
92
|
+
select is(public.feature_on(pg_temp.tenant(1), 'webhooks'), false, 'a paid feature is off without an entitlement');
|
|
93
|
+
insert into public.feature_entitlements (tenant_id, feature_id, source, active) values (pg_temp.tenant(1), 'webhooks', 'manual', true);
|
|
94
|
+
select is(public.feature_on(pg_temp.tenant(1), 'webhooks'), true, '... and on with one');
|
|
95
|
+
insert into public.feature_entitlements (tenant_id, feature_id, source, active, ends_at) values (pg_temp.tenant(2), 'webhooks', 'trial', true, now() - interval '1 day');
|
|
96
|
+
select is(public.feature_on(pg_temp.tenant(2), 'webhooks'), false, 'an ended entitlement doesn''t count');
|
|
97
|
+
insert into public.feature_entitlements (tenant_id, feature_id, source, active) values (pg_temp.tenant(2), 'webhooks', 'manual', false);
|
|
98
|
+
select is(public.feature_on(pg_temp.tenant(2), 'webhooks'), false, '... nor an inactive one');
|
|
99
|
+
insert into public.feature_entitlements (tenant_id, feature_id, source, active) values (pg_temp.tenant(2), 'not-synced-yet', 'stripe', true);
|
|
100
|
+
select pass('billing can grant a feature before the deploy that adds it syncs');
|
|
101
|
+
select is(public.feature_on(pg_temp.tenant(1), 'courses') or public.feature_on(pg_temp.tenant(1), 'nope'), false, 'planned and unknown features are off');
|
|
102
|
+
select is(public.feature_on(pg_temp.tenant(1), 'sms'), true, 'flags are not the database''s business');
|
|
103
|
+
|
|
104
|
+
-- Runtime state for the snapshot -------------------------------------------------------------------
|
|
105
|
+
insert into public.tenant_flag_values (tenant_id, flag_key, value) values (pg_temp.tenant(1), 'sms.release', 'true');
|
|
106
|
+
select pg_temp.as_owner();
|
|
107
|
+
insert into public.tenant_features (tenant_id, feature_id, enabled, reason) values (pg_temp.tenant(1), 'forms', false, 'Not yet');
|
|
108
|
+
select is(public.feature_on(pg_temp.tenant(1), 'forms'), true, 'a tenant switch hides, it doesn''t block rows');
|
|
109
|
+
|
|
110
|
+
select pg_temp.sign_in('b2');
|
|
111
|
+
select is(public.feature_gate_state(pg_temp.tenant(1)),
|
|
112
|
+
'{"off": ["forms"], "entitled": ["webhooks"], "flags": {"sms.release": true}}'::jsonb,
|
|
113
|
+
'a member reads the tenant''s switches, entitlements and flag values');
|
|
114
|
+
select is(public.feature_on(pg_temp.tenant(1), 'webhooks'), true, 'a member asks the gate for their tenant');
|
|
115
|
+
select is(public.feature_on(pg_temp.tenant(2), 'forms'), false, 'and gets false for another tenant');
|
|
116
|
+
select throws_ok($$select public.feature_gate_state(pg_temp.tenant(2))$$, '42501', null, 'another tenant''s state is refused');
|
|
117
|
+
select is((select array_agg(id order by id) from public.features), array['forms', 'sms', 'webhooks'], 'signed-in people read shipped features only');
|
|
118
|
+
select throws_ok($$select record from public.features$$, '42501', null, '... and not the full registry record');
|
|
119
|
+
select is(array(select public.feature_entitled_tenants('webhooks')), array[pg_temp.tenant(1)], 'a member sees their own tenant''s entitlement');
|
|
120
|
+
select is((select public.feature_shipped('forms')) and not (select public.feature_shipped('courses')), true, 'feature_shipped answers once per statement');
|
|
121
|
+
select throws_ok($$select * from public.feature_entitlements$$, '42501', null, 'but not the entitlements table');
|
|
122
|
+
|
|
123
|
+
select pg_temp.sign_in('c3');
|
|
124
|
+
select is(public.feature_gate_state(pg_temp.tenant(2)), '{"off": [], "entitled": ["not-synced-yet"], "flags": {}}'::jsonb, 'another tenant sees only its own state');
|
|
125
|
+
select is(array(select public.feature_entitled_tenants('webhooks')), '{}'::uuid[], 'and none of another tenant''s entitlements');
|
|
126
|
+
select set_config('request.jwt.claims', json_build_object('sub', pg_temp.person('c3'), 'role', 'authenticated', 'is_anonymous', true)::text, true);
|
|
127
|
+
select is((select count(*)::int from public.features), 0, 'an anonymous sign-in reads no features');
|
|
128
|
+
|
|
129
|
+
-- An authenticated request without a person is refused, never mistaken for server code.
|
|
130
|
+
select set_config('request.jwt.claims', '{"role": "authenticated"}', true);
|
|
131
|
+
select set_config('request.jwt.claim.sub', '', true);
|
|
132
|
+
select throws_ok($$select public.feature_gate_state(pg_temp.tenant(1))$$, '42501', null, 'no sub: gate state is refused');
|
|
133
|
+
select is(public.feature_on(pg_temp.tenant(1), 'forms'), false, 'no sub: the gate says no');
|
|
134
|
+
select is(array(select public.feature_entitled_tenants('webhooks')), '{}'::uuid[], 'no sub: no entitled tenants');
|
|
135
|
+
|
|
136
|
+
-- A platform value is a kill switch for every tenant, over the tenant's own value.
|
|
137
|
+
select pg_temp.as_service();
|
|
138
|
+
update public.feature_flags set platform_value = 'false' where key = 'sms.release';
|
|
139
|
+
select pg_temp.sign_in('b2');
|
|
140
|
+
select is(public.feature_gate_state(pg_temp.tenant(1)) -> 'flags', '{"sms.release": false}'::jsonb, 'a platform value overrides the tenant''s');
|
|
141
|
+
select pg_temp.as_service();
|
|
142
|
+
update public.feature_flags set platform_value = null where key = 'sms.release';
|
|
143
|
+
select is(public.feature_gate_state(pg_temp.tenant(1)) -> 'flags', '{"sms.release": true}'::jsonb, 'without it the tenant value applies (server code reads any tenant)');
|
|
144
|
+
|
|
145
|
+
-- A registry without courses and without the flag --------------------------------------------------
|
|
146
|
+
select pg_temp.as_service();
|
|
147
|
+
select is(public.sync_feature_registry(200, 'h2',
|
|
148
|
+
(select jsonb_agg(f) from pg_temp.registry, jsonb_array_elements(features) f where f ->> 'id' <> 'courses'), '[]'), true, 'a changed registry syncs');
|
|
149
|
+
select is((select in_registry from public.features where id = 'courses'), false, 'a feature gone from the registry stays, marked gone');
|
|
150
|
+
select is((select in_registry from public.feature_flags where key = 'sms.release'), false, 'a flag gone from the registry stays, marked gone');
|
|
151
|
+
select is((select count(*)::int from public.tenant_flag_values), 1, '... and keeps its tenant values');
|
|
152
|
+
select pg_temp.sign_in('b2');
|
|
153
|
+
select is(public.feature_gate_state(pg_temp.tenant(1)) -> 'flags', '{}'::jsonb, 'but a gone flag''s value is not handed out');
|
|
154
|
+
select pg_temp.as_service();
|
|
155
|
+
select is((select version from public.feature_registry_synced()), 200::bigint, 'the last sync is recorded');
|
|
156
|
+
|
|
157
|
+
-- Retired: off even with an entitlement.
|
|
158
|
+
select is(public.sync_feature_registry(300, 'h3',
|
|
159
|
+
'[{"id": "webhooks", "name": "Webhooks", "status": "retired", "apps": ["web"], "access": {"plan": "pro"}},
|
|
160
|
+
{"id": "legacy", "name": "Old export", "status": "deprecated", "apps": ["web"]},
|
|
161
|
+
{"id": "drafts", "name": "Drafts", "status": "building", "apps": ["web"]},
|
|
162
|
+
{"id": "free", "name": "Free", "status": "live", "apps": ["web"], "access": {"plan": " "}}]', '[]'), true, 'webhooks retires');
|
|
163
|
+
select is(public.feature_on(pg_temp.tenant(1), 'webhooks'), false, 'a retired feature is off whatever the entitlement');
|
|
164
|
+
select is(public.feature_on(pg_temp.tenant(1), 'forms'), false, 'a feature missing from the registry is off');
|
|
165
|
+
select is(public.feature_on(pg_temp.tenant(1), 'legacy'), true, 'a deprecated feature still works');
|
|
166
|
+
select is(public.feature_on(pg_temp.tenant(1), 'drafts'), false, 'a building feature is not shipped');
|
|
167
|
+
select is(public.feature_on(pg_temp.tenant(1), 'free'), true, 'a blank plan is no plan');
|
|
168
|
+
|
|
169
|
+
-- Guards against a broken registry -----------------------------------------------------------------
|
|
170
|
+
select throws_ok($$select public.sync_feature_registry(400, 'empty', '[]', '[]')$$, '22023', null, 'an empty registry is refused');
|
|
171
|
+
select throws_ok($$select public.sync_feature_registry(400, 'dup', '[{"id": "a", "name": "A", "status": "live"}, {"id": "a", "name": "A", "status": "live"}]', '[]')$$,
|
|
172
|
+
'22023', null, 'duplicate ids are refused');
|
|
173
|
+
select throws_ok($$select public.sync_feature_registry(400, 'shrink', '[{"id": "legacy", "name": "Old export", "status": "deprecated"}]', '[]')$$,
|
|
174
|
+
'22023', null, 'a registry that drops most features is refused');
|
|
175
|
+
select is((select count(*)::int from public.features where in_registry), 4, '... and changes nothing');
|
|
176
|
+
select is(public.sync_feature_registry(400, 'shrink', '[{"id": "legacy", "name": "Old export", "status": "deprecated"}]', '[]', true), true,
|
|
177
|
+
'unless the call allows the shrink');
|
|
178
|
+
|
|
179
|
+
select * from finish();
|
|
180
|
+
rollback;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktiderman/genesis-supabase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"description": "Supabase for Genesis apps on web and React Native: a client with PKCE and safe defaults, Keychain session storage that survives interrupted writes, refresh only while the app is in front, native Sign in with Apple and Google, OAuth redirects, in-app account deletion, per-tenant feature switches (tenant_features), and a result helper. Part of the Genesis framework.",
|
|
7
|
+
"description": "Supabase for Genesis apps on web and React Native: a client with PKCE and safe defaults, Keychain session storage that survives interrupted writes, refresh only while the app is in front, native Sign in with Apple and Google, OAuth redirects, in-app account deletion, per-tenant feature switches (tenant_features), a background-job queue with schedules (genesis_jobs), the feature registry in the database for the feature gate (features, entitlements, flag values, feature_on), and a result helper. Part of the Genesis framework.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/marktiderman/genesis.git",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"./blocks": {
|
|
32
32
|
"types": "./dist/blocks.d.ts",
|
|
33
33
|
"import": "./dist/blocks.js"
|
|
34
|
+
},
|
|
35
|
+
"./jobs": {
|
|
36
|
+
"types": "./dist/jobs.d.ts",
|
|
37
|
+
"import": "./dist/jobs.js"
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
40
|
"files": [
|
|
@@ -41,7 +45,7 @@
|
|
|
41
45
|
"README.md"
|
|
42
46
|
],
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"@marktiderman/genesis-features": "^0.
|
|
48
|
+
"@marktiderman/genesis-features": "^0.4.1"
|
|
45
49
|
},
|
|
46
50
|
"peerDependencies": {
|
|
47
51
|
"@supabase/supabase-js": "^2.118.0",
|
|
@@ -123,6 +127,64 @@
|
|
|
123
127
|
"steps": [
|
|
124
128
|
"Give tenant_features your membership rule in a migration of your own: create private.genesis_tenant_admin(tenant uuid, person uuid) returns boolean, and revoke execute on it from public, anon, authenticated (genesis-supabase README, Tenant feature switches). Without it nobody can change a switch."
|
|
125
129
|
]
|
|
130
|
+
},
|
|
131
|
+
"jobs": {
|
|
132
|
+
"feature": {
|
|
133
|
+
"name": "Background jobs",
|
|
134
|
+
"summary": "A job queue (enqueue, claim with leases, retry with backoff) and named schedules that call the app's job route with a secret.",
|
|
135
|
+
"keywords": [
|
|
136
|
+
"background jobs",
|
|
137
|
+
"cron",
|
|
138
|
+
"queue",
|
|
139
|
+
"scheduled tasks"
|
|
140
|
+
],
|
|
141
|
+
"audience": [
|
|
142
|
+
"developer"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"platforms": [
|
|
146
|
+
"web"
|
|
147
|
+
],
|
|
148
|
+
"migrations": [
|
|
149
|
+
{
|
|
150
|
+
"file": "migrations/0007_genesis_jobs.sql",
|
|
151
|
+
"test": "migrations/tests/0007_genesis_jobs.test.sql"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"install": [
|
|
155
|
+
"@supabase/supabase-js@^2.118.0"
|
|
156
|
+
],
|
|
157
|
+
"steps": [
|
|
158
|
+
"Add one job route with createJobsHandler from @marktiderman/genesis-supabase/jobs, and set GENESIS_JOBS_SECRET on the server.",
|
|
159
|
+
"For schedules: enable pg_cron and pg_net, add the Vault secrets genesis_jobs_url (the route's base URL) and genesis_jobs_secret (the same secret), then call genesis_schedule_job(name, cron, job) in a migration."
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
"feature-mirror": {
|
|
163
|
+
"feature": {
|
|
164
|
+
"name": "Registry in the app's database",
|
|
165
|
+
"summary": "The feature registry mirrored into the database on deploy, entitlements, per-tenant flag values and SQL feature_on(), for the feature gate.",
|
|
166
|
+
"keywords": [
|
|
167
|
+
"feature gate",
|
|
168
|
+
"entitlements",
|
|
169
|
+
"flags",
|
|
170
|
+
"feature_on"
|
|
171
|
+
],
|
|
172
|
+
"audience": [
|
|
173
|
+
"developer"
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
"requires": [
|
|
177
|
+
"tenant-features"
|
|
178
|
+
],
|
|
179
|
+
"migrations": [
|
|
180
|
+
{
|
|
181
|
+
"file": "migrations/0008_genesis_feature_registry.sql",
|
|
182
|
+
"test": "migrations/tests/0008_genesis_feature_registry.test.sql"
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
"steps": [
|
|
186
|
+
"Sync the registry on every deploy with the service key: syncFeatureRegistry(admin, features.json, { version: BUILD_TIME }). Grant paid features by writing feature_entitlements from your billing webhook."
|
|
187
|
+
]
|
|
126
188
|
}
|
|
127
189
|
}
|
|
128
190
|
},
|
package/dist/chunk-T2HGFC4C.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { defineBlock } from '@marktiderman/genesis-features/blocks';
|
|
2
|
-
|
|
3
|
-
// src/blocks.ts
|
|
4
|
-
var PACKAGE = "@marktiderman/genesis-supabase";
|
|
5
|
-
var accountBlock = defineBlock({
|
|
6
|
-
id: "account",
|
|
7
|
-
platforms: ["web", "native"],
|
|
8
|
-
contributes: {
|
|
9
|
-
migrations: [
|
|
10
|
-
{ package: PACKAGE, file: "migrations/0001_genesis_account_deletion.sql", test: "migrations/tests/0001_genesis_account_deletion.test.sql" },
|
|
11
|
-
// With Sign in with Apple, with the genesis-apple-revoke function beside it.
|
|
12
|
-
{ package: PACKAGE, file: "migrations/0003_genesis_apple_token_revocation.sql", test: "migrations/tests/0003_genesis_apple_token_revocation.test.sql" }
|
|
13
|
-
],
|
|
14
|
-
privacy: {
|
|
15
|
-
collects: [
|
|
16
|
-
{ type: "email address", purposes: ["app functionality"], linked: true, tracking: false },
|
|
17
|
-
{ type: "user id", purposes: ["app functionality"], linked: true, tracking: false },
|
|
18
|
-
{ type: "name", purposes: ["app functionality"], linked: true, tracking: false }
|
|
19
|
-
],
|
|
20
|
-
notes: [
|
|
21
|
-
"People delete their account from inside the app; their login and the rows that cascade from it go with it.",
|
|
22
|
-
"With Sign in with Apple, the person's Apple tokens are revoked when the account is deleted."
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
var tenantFeaturesBlock = defineBlock({
|
|
28
|
-
id: "tenant-features",
|
|
29
|
-
contributes: {
|
|
30
|
-
migrations: [{ package: PACKAGE, file: "migrations/0004_genesis_tenant_features.sql", test: "migrations/tests/0004_genesis_tenant_features.test.sql" }],
|
|
31
|
-
privacy: { notes: ["Keeps who changed a tenant's switches; a deleted person's changes stay, without the person."] }
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export { accountBlock, tenantFeaturesBlock };
|
|
36
|
-
//# sourceMappingURL=chunk-T2HGFC4C.js.map
|
|
37
|
-
//# sourceMappingURL=chunk-T2HGFC4C.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blocks.ts"],"names":[],"mappings":";;;AAQA,IAAM,OAAA,GAAU,gCAAA;AAST,IAAM,eAAe,WAAA,CAAY;AAAA,EACtC,EAAA,EAAI,SAAA;AAAA,EACJ,SAAA,EAAW,CAAC,KAAA,EAAO,QAAQ,CAAA;AAAA,EAC3B,WAAA,EAAa;AAAA,IACX,UAAA,EAAY;AAAA,MACV,EAAE,OAAA,EAAS,OAAA,EAAS,IAAA,EAAM,8CAAA,EAAgD,MAAM,yDAAA,EAA0D;AAAA;AAAA,MAE1I,EAAE,OAAA,EAAS,OAAA,EAAS,IAAA,EAAM,oDAAA,EAAsD,MAAM,+DAAA;AAAgE,KACxJ;AAAA,IACA,OAAA,EAAS;AAAA,MACP,QAAA,EAAU;AAAA,QACR,EAAE,IAAA,EAAM,eAAA,EAAiB,QAAA,EAAU,CAAC,mBAAmB,CAAA,EAAG,MAAA,EAAQ,IAAA,EAAM,QAAA,EAAU,KAAA,EAAM;AAAA,QACxF,EAAE,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,CAAC,mBAAmB,CAAA,EAAG,MAAA,EAAQ,IAAA,EAAM,QAAA,EAAU,KAAA,EAAM;AAAA,QAClF,EAAE,IAAA,EAAM,MAAA,EAAQ,QAAA,EAAU,CAAC,mBAAmB,CAAA,EAAG,MAAA,EAAQ,IAAA,EAAM,QAAA,EAAU,KAAA;AAAM,OACjF;AAAA,MACA,KAAA,EAAO;AAAA,QACL,4GAAA;AAAA,QACA;AAAA;AACF;AACF;AAEJ,CAAC;AAQM,IAAM,sBAAsB,WAAA,CAAY;AAAA,EAC7C,EAAA,EAAI,iBAAA;AAAA,EACJ,WAAA,EAAa;AAAA,IACX,UAAA,EAAY,CAAC,EAAE,OAAA,EAAS,SAAS,IAAA,EAAM,6CAAA,EAA+C,IAAA,EAAM,wDAAA,EAA0D,CAAA;AAAA,IACtJ,OAAA,EAAS,EAAE,KAAA,EAAO,CAAC,6FAA6F,CAAA;AAAE;AAEtH,CAAC","file":"chunk-T2HGFC4C.js","sourcesContent":["/**\n * The blocks this package carries the server half of, as `defineBlock`\n * declarations: what each needs in the database, and what it means for the\n * stores' privacy forms. The functions themselves (`deleteMyAccount`,\n * `tenantFeatures`, …) don't change.\n */\nimport { defineBlock } from \"@marktiderman/genesis-features/blocks\";\n\nconst PACKAGE = \"@marktiderman/genesis-supabase\";\n\n/**\n * The account block: sign-in, profile and in-app account deletion. Its\n * screens are the app's (or genesis-ui-native's `AuthScreen`); this names its\n * migrations and its data.\n *\n * @stability Beta\n */\nexport const accountBlock = defineBlock({\n id: \"account\",\n platforms: [\"web\", \"native\"],\n contributes: {\n migrations: [\n { package: PACKAGE, file: \"migrations/0001_genesis_account_deletion.sql\", test: \"migrations/tests/0001_genesis_account_deletion.test.sql\" },\n // With Sign in with Apple, with the genesis-apple-revoke function beside it.\n { package: PACKAGE, file: \"migrations/0003_genesis_apple_token_revocation.sql\", test: \"migrations/tests/0003_genesis_apple_token_revocation.test.sql\" },\n ],\n privacy: {\n collects: [\n { type: \"email address\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"user id\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"name\", purposes: [\"app functionality\"], linked: true, tracking: false },\n ],\n notes: [\n \"People delete their account from inside the app; their login and the rows that cascade from it go with it.\",\n \"With Sign in with Apple, the person's Apple tokens are revoked when the account is deleted.\",\n ],\n },\n },\n});\n\n/**\n * The tenant features block: per-tenant on/off switches for shipped\n * features, set by the tenant's admins with a reason.\n *\n * @stability Beta\n */\nexport const tenantFeaturesBlock = defineBlock({\n id: \"tenant-features\",\n contributes: {\n migrations: [{ package: PACKAGE, file: \"migrations/0004_genesis_tenant_features.sql\", test: \"migrations/tests/0004_genesis_tenant_features.test.sql\" }],\n privacy: { notes: [\"Keeps who changed a tenant's switches; a deleted person's changes stay, without the person.\"] },\n },\n});\n"]}
|