@marktiderman/genesis-cli 1.6.0 → 1.7.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.
Files changed (139) hide show
  1. package/README.md +156 -1
  2. package/dist/cli.js +2769 -567
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-CUdwT-nY.d.ts → config-CrZbM3jD.d.ts} +45 -2
  5. package/dist/doctor.d.ts +2 -2
  6. package/dist/doctor.js +133 -5
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +91 -8
  9. package/dist/expo.js +207 -14
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +502 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +140 -9
  14. package/dist/index.js.map +1 -1
  15. package/dist/scaffolder.d.ts +1 -1
  16. package/dist/scaffolder.js +7 -4
  17. package/dist/scaffolder.js.map +1 -1
  18. package/dist/starter/.eas/scripts/rollout-health.mjs +85 -0
  19. package/dist/starter/.eas/workflows/deploy-production.yml +149 -0
  20. package/dist/starter/.eas/workflows/e2e.yml +77 -0
  21. package/dist/starter/.eas/workflows/pr-preview.yml +117 -0
  22. package/dist/starter/.eas/workflows/rollout.yml +120 -0
  23. package/dist/starter/.env.example +11 -0
  24. package/dist/starter/.fingerprintignore +7 -0
  25. package/dist/starter/.maestro/README.md +38 -0
  26. package/dist/starter/.maestro/config.yaml +5 -0
  27. package/dist/starter/.maestro/flows/deep-link.yaml +22 -0
  28. package/dist/starter/.maestro/flows/launch.yaml +17 -0
  29. package/dist/starter/.maestro/flows/settings-version.yaml +28 -0
  30. package/dist/starter/.maestro/flows/sign-in-screen.yaml +17 -0
  31. package/dist/starter/.maestro/subflows/sign-in.yaml +20 -0
  32. package/dist/starter/README.md +314 -0
  33. package/dist/starter/__tests__/app-config.test.ts +51 -0
  34. package/dist/starter/__tests__/check-in-photos.test.ts +57 -0
  35. package/dist/starter/__tests__/components/css-stub.js +2 -0
  36. package/dist/starter/__tests__/components/fake-supabase.ts +136 -0
  37. package/dist/starter/__tests__/components/links.test.ts +25 -0
  38. package/dist/starter/__tests__/components/render-app.ts +22 -0
  39. package/dist/starter/__tests__/components/reports.ts +10 -0
  40. package/dist/starter/__tests__/components/resolver.js +12 -0
  41. package/dist/starter/__tests__/components/root-layout.test.tsx +55 -0
  42. package/dist/starter/__tests__/components/session-storage.test.tsx +81 -0
  43. package/dist/starter/__tests__/components/settings.test.tsx +134 -0
  44. package/dist/starter/__tests__/components/setup.ts +69 -0
  45. package/dist/starter/__tests__/components/sign-in.test.tsx +90 -0
  46. package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +19 -0
  47. package/dist/starter/__tests__/components/tabs.test.tsx +43 -0
  48. package/dist/starter/__tests__/components/tabs.ts +12 -0
  49. package/dist/starter/__tests__/entry.test.ts +28 -0
  50. package/dist/starter/__tests__/inline-copy.ts +59 -0
  51. package/dist/starter/__tests__/starter.test.ts +319 -0
  52. package/dist/starter/_gitignore +13 -0
  53. package/dist/starter/app.config.ts +44 -0
  54. package/dist/starter/babel.config.js +9 -0
  55. package/dist/starter/eas.json +47 -0
  56. package/dist/starter/eslint.config.js +5 -0
  57. package/dist/starter/genesis.config.json +12 -0
  58. package/dist/starter/global.css +3 -0
  59. package/dist/starter/index.ts +14 -0
  60. package/dist/starter/jest.config.js +36 -0
  61. package/dist/starter/metro.config.js +38 -0
  62. package/dist/starter/package.json +93 -0
  63. package/dist/starter/pnpm-workspace.yaml +73 -0
  64. package/dist/starter/src/app/(app)/(home)/_layout.tsx +6 -0
  65. package/dist/starter/src/app/(app)/(home)/check-in.tsx +41 -0
  66. package/dist/starter/src/app/(app)/(home)/index.tsx +34 -0
  67. package/dist/starter/src/app/(app)/_layout.tsx +27 -0
  68. package/dist/starter/src/app/(app)/notifications/_layout.tsx +6 -0
  69. package/dist/starter/src/app/(app)/notifications/index.tsx +36 -0
  70. package/dist/starter/src/app/(app)/settings/_layout.tsx +6 -0
  71. package/dist/starter/src/app/(app)/settings/index.tsx +96 -0
  72. package/dist/starter/src/app/(app)/settings/notifications.tsx +16 -0
  73. package/dist/starter/src/app/(app)/settings/support/[id].tsx +23 -0
  74. package/dist/starter/src/app/(app)/settings/support/ideas.tsx +20 -0
  75. package/dist/starter/src/app/(app)/settings/support/index.tsx +20 -0
  76. package/dist/starter/src/app/(app)/settings/support/new.tsx +35 -0
  77. package/dist/starter/src/app/(app)/settings/support/shipped.tsx +20 -0
  78. package/dist/starter/src/app/+native-intent.ts +11 -0
  79. package/dist/starter/src/app/_layout.tsx +20 -0
  80. package/dist/starter/src/app/sign-in.tsx +69 -0
  81. package/dist/starter/src/copy.ts +118 -0
  82. package/dist/starter/src/forms/check-in.json +121 -0
  83. package/dist/starter/src/lib/account.ts +42 -0
  84. package/dist/starter/src/lib/app.ts +52 -0
  85. package/dist/starter/src/lib/auth.ts +80 -0
  86. package/dist/starter/src/lib/check-in-photos.ts +66 -0
  87. package/dist/starter/src/lib/check-in.ts +85 -0
  88. package/dist/starter/src/lib/define-starter.ts +148 -0
  89. package/dist/starter/src/lib/devtools-overlay.ts +34 -0
  90. package/dist/starter/src/lib/devtools.ts +23 -0
  91. package/dist/starter/src/lib/env.ts +33 -0
  92. package/dist/starter/src/lib/google-signin.ts +23 -0
  93. package/dist/starter/src/lib/links.ts +40 -0
  94. package/dist/starter/src/lib/native-modules.ts +27 -0
  95. package/dist/starter/src/lib/notifications.ts +15 -0
  96. package/dist/starter/src/lib/observability.ts +45 -0
  97. package/dist/starter/src/lib/push.ts +49 -0
  98. package/dist/starter/src/lib/supabase.ts +65 -0
  99. package/dist/starter/src/lib/support.ts +44 -0
  100. package/dist/starter/src/lib/updates.ts +61 -0
  101. package/dist/starter/starter.config.ts +37 -0
  102. package/dist/starter/supabase/config.toml +26 -0
  103. package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +237 -0
  104. package/dist/starter/supabase/functions/genesis-apple-revoke/handler.ts +227 -0
  105. package/dist/starter/supabase/functions/genesis-apple-revoke/index.ts +55 -0
  106. package/dist/starter/supabase/functions/genesis-push-send/expo.ts +117 -0
  107. package/dist/starter/supabase/functions/genesis-push-send/handler.ts +462 -0
  108. package/dist/starter/supabase/functions/genesis-push-send/index.ts +54 -0
  109. package/dist/starter/supabase/migrations/20261024000000_genesis_account_deletion.sql +133 -0
  110. package/dist/starter/supabase/migrations/20261024000100_genesis_app_release_policy.sql +82 -0
  111. package/dist/starter/supabase/migrations/20261024000200_genesis_apple_token_revocation.sql +205 -0
  112. package/dist/starter/supabase/migrations/20261024000400_genesis_push.sql +524 -0
  113. package/dist/starter/supabase/migrations/20261024000600_genesis_support.sql +846 -0
  114. package/dist/starter/supabase/tests/database/genesis_account_deletion.test.sql +138 -0
  115. package/dist/starter/supabase/tests/database/genesis_app_release_policy.test.sql +148 -0
  116. package/dist/starter/supabase/tests/database/genesis_apple_token_revocation.test.sql +230 -0
  117. package/dist/starter/supabase/tests/database/genesis_push.test.sql +407 -0
  118. package/dist/starter/supabase/tests/database/genesis_support.test.sql +552 -0
  119. package/dist/starter/tailwind.config.mjs +15 -0
  120. package/dist/starter/tsconfig.json +14 -0
  121. package/dist/starter/vitest.config.mts +7 -0
  122. package/dist/templates/ci/app-ci.yml +17 -0
  123. package/dist/templates/ci/genesis-upgrade.yml +21 -0
  124. package/dist/templates/ci/supabase-ci.yml +20 -0
  125. package/dist/templates/eas/eas.json +47 -0
  126. package/dist/templates/eas/scripts/rollout-health.mjs +85 -0
  127. package/dist/templates/eas/workflows/deploy-production.yml +149 -0
  128. package/dist/templates/eas/workflows/e2e.yml +77 -0
  129. package/dist/templates/eas/workflows/pr-preview.yml +117 -0
  130. package/dist/templates/eas/workflows/rollout.yml +120 -0
  131. package/dist/templates/maestro/config.yaml +5 -0
  132. package/dist/templates/maestro/flows/deep-link.yaml +22 -0
  133. package/dist/templates/maestro/flows/launch.yaml +17 -0
  134. package/dist/templates/maestro/flows/settings-version.yaml +28 -0
  135. package/dist/templates/maestro/flows/sign-in-screen.yaml +17 -0
  136. package/dist/templates/maestro/subflows/sign-in.yaml +20 -0
  137. package/dist/vite.js +133 -5
  138. package/dist/vite.js.map +1 -1
  139. package/package.json +4 -4
@@ -0,0 +1,82 @@
1
+ -- Genesis app release policy: public.app_release_policy
2
+ --
3
+ -- What a native app reads at launch to decide whether this install must
4
+ -- update from the store, whether the app is down for maintenance, and which
5
+ -- release notes to show. The client half is `supabasePolicySource(client)` in
6
+ -- @marktiderman/genesis-native/updates.
7
+ --
8
+ -- Use: copy this file into your app's `supabase/migrations/` under a new
9
+ -- timestamped name (e.g. `20261024000000_genesis_app_release_policy.sql`).
10
+ -- Never edit it once applied; change it with a new migration.
11
+ --
12
+ -- Access: anyone may read (anon included: the app reads it before sign-in);
13
+ -- nobody but the service role (or a migration) may write. Edit the row from
14
+ -- the SQL editor, a migration, or a server job with the secret key.
15
+ --
16
+ -- Failing open: the client never blocks on a missing row, a malformed value
17
+ -- or a failed read. The checks below keep malformed values out in the first
18
+ -- place: a minimum version is plain dotted numbers (`1`, `1.4`, `1.4.0`),
19
+ -- store links are https (or the stores' own schemes), a minimum version
20
+ -- comes with its platform's store link, and notes are an array of
21
+ -- `{ "version": "1.4.0", "title"?: "...", "body": "..." }`.
22
+ --
23
+ -- One row per app (`app_id`, default 'default'). For example:
24
+ --
25
+ -- insert into public.app_release_policy (app_id, min_version_ios, store_url_ios)
26
+ -- values ('default', '1.4.0', 'https://apps.apple.com/app/id0000000000')
27
+ -- on conflict (app_id) do update set min_version_ios = excluded.min_version_ios,
28
+ -- store_url_ios = excluded.store_url_ios, updated_at = now();
29
+ --
30
+ -- Maintenance: set `maintenance = true` (and a `maintenance_message`). The
31
+ -- client honours it only from a live read, never from its cache, so a phone
32
+ -- offline when maintenance ends is never stuck behind it.
33
+ --
34
+ -- Verify: the pgTAP test beside this file (`tests/0002_genesis_app_release_policy.test.sql`).
35
+
36
+ create table if not exists public.app_release_policy (
37
+ app_id text primary key default 'default'
38
+ constraint app_release_policy_app_id_format check (app_id ~ '^[a-z0-9][a-z0-9._-]{0,63}$'),
39
+ min_version_ios text
40
+ constraint app_release_policy_min_version_ios_format check (min_version_ios ~ '^[0-9]{1,9}(\.[0-9]{1,9}){0,3}$'),
41
+ min_version_android text
42
+ constraint app_release_policy_min_version_android_format check (min_version_android ~ '^[0-9]{1,9}(\.[0-9]{1,9}){0,3}$'),
43
+ store_url_ios text
44
+ constraint app_release_policy_store_url_ios_format check (store_url_ios ~ '^(https|itms-apps)://'),
45
+ store_url_android text
46
+ constraint app_release_policy_store_url_android_format check (store_url_android ~ '^(https|market)://'),
47
+ maintenance boolean not null default false,
48
+ maintenance_message text
49
+ constraint app_release_policy_maintenance_message_length check (char_length(maintenance_message) <= 500),
50
+ -- An array of objects, each with a string version and body (and a string title, if any).
51
+ -- `strict` stops lax mode unwrapping nested arrays; `.type()` rejects arrays where strings belong.
52
+ notes jsonb not null default '[]'::jsonb
53
+ constraint app_release_policy_notes_shape check (
54
+ jsonb_typeof(notes) = 'array'
55
+ and not jsonb_path_exists(notes, 'strict $[*] ? (@.type() != "object")')
56
+ and not jsonb_path_exists(notes, '$[*] ? (!(@.version.type() == "string") || !(@.body.type() == "string") || (exists(@.title) && !(@.title.type() == "string")))')
57
+ ),
58
+ updated_at timestamptz not null default now(),
59
+ -- A minimum version needs a store link: the force-upgrade screen's only way out is the store.
60
+ -- (The client also forces nothing without one.)
61
+ constraint app_release_policy_ios_store_link check (min_version_ios is null or store_url_ios is not null),
62
+ constraint app_release_policy_android_store_link check (min_version_android is null or store_url_android is not null)
63
+ );
64
+
65
+ comment on table public.app_release_policy is
66
+ 'Minimum store versions, maintenance switch and release notes for native apps. Readable by everyone, written only by the service role. Genesis updates block.';
67
+
68
+ alter table public.app_release_policy enable row level security;
69
+
70
+ -- Reading: everyone, every row. No insert, update or delete policy exists, so
71
+ -- under RLS anon and authenticated can't write even if a later grant lets them try.
72
+ drop policy if exists app_release_policy_read on public.app_release_policy;
73
+ create policy app_release_policy_read on public.app_release_policy
74
+ for select to anon, authenticated
75
+ using (true);
76
+
77
+ -- Privileges by name. Supabase's default privileges give anon and
78
+ -- authenticated every privilege on a new public table; take them back and
79
+ -- grant only select. The service role bypasses RLS and keeps write access.
80
+ revoke all on table public.app_release_policy from public, anon, authenticated;
81
+ grant select on table public.app_release_policy to anon, authenticated;
82
+ grant select, insert, update, delete on table public.app_release_policy to service_role;
@@ -0,0 +1,205 @@
1
+ -- Genesis Sign in with Apple token revocation: where Apple's refresh tokens live,
2
+ -- and the queue that revokes them when an account is deleted.
3
+ --
4
+ -- App Store Review Guideline 5.1.1(v): an app that offers Sign in with Apple
5
+ -- revokes the person's Apple tokens (https://appleid.apple.com/auth/revoke)
6
+ -- when they delete their account. Supabase doesn't: a native id-token sign-in
7
+ -- never hands Supabase an Apple refresh token, and Auth doesn't keep the
8
+ -- provider tokens it does see. So the app sends the sign-in's authorization
9
+ -- code to the `genesis-apple-revoke` Edge Function (shipped beside this file
10
+ -- in @marktiderman/genesis-supabase), which exchanges it for a refresh token
11
+ -- and keeps it here; deleting the login queues it, and the function revokes it.
12
+ --
13
+ -- Use: copy this file into your app's `supabase/migrations/` under a new
14
+ -- timestamped name, and the function folder into `supabase/functions/`.
15
+ -- Never edit it once applied; change it with a new migration. It stands
16
+ -- alone (it doesn't need 0001), and covers every way a login is deleted:
17
+ -- delete_my_account, the dashboard, and the admin API.
18
+ --
19
+ -- Who can see a token: nobody but this file's functions. The tables are in
20
+ -- `private` (not exposed through the Data API) with row level security on, no
21
+ -- policies and every table privilege revoked from anon and authenticated. The
22
+ -- Edge Function reaches them only through the four `public` functions below,
23
+ -- executable by service_role alone (granted and revoked by name).
24
+ --
25
+ -- Not encrypted in the column: an Apple refresh token is useless without a
26
+ -- client secret signed with your .p8 key, which lives in the function's
27
+ -- secrets, not the database; encrypting it with a key from those same secrets
28
+ -- would add a secret without closing a gap.
29
+ --
30
+ -- Failure policy: deletion never waits for Apple. The delete trigger moves
31
+ -- the person's tokens into `private.genesis_apple_revocations` in the same
32
+ -- transaction as the delete (so a refused delete queues nothing, and a
33
+ -- committed one can't lose its token), and the function revokes them after:
34
+ -- straight away when the app asks, then on a schedule, with backoff (five
35
+ -- minutes, doubling, at most a day apart). A revoked token's row is deleted.
36
+ -- After 30 failed attempts (about four weeks) the token is dropped and the
37
+ -- row kept, with `last_error` starting `gave_up`, as the record that it
38
+ -- wasn't revoked. A deleted login that signed in with Apple but has no stored
39
+ -- token (the store step failed, or it predates this) leaves a row with no
40
+ -- token and `last_error` starting `no_token`. Any row still here is one to
41
+ -- look at.
42
+ --
43
+ -- Verify: the pgTAP test beside this file (`tests/0003_genesis_apple_token_revocation.test.sql`).
44
+
45
+ create schema if not exists private;
46
+
47
+ -- One refresh token per login and client id (bundle id or Services ID): each
48
+ -- sign-in replaces the last.
49
+ create table private.genesis_apple_tokens (
50
+ user_id uuid not null references auth.users (id) on delete cascade,
51
+ client_id text not null check (client_id ~ '^[A-Za-z0-9][A-Za-z0-9.-]{0,254}$'),
52
+ refresh_token text not null check (length(refresh_token) between 1 and 4096),
53
+ updated_at timestamptz not null default now(),
54
+ primary key (user_id, client_id)
55
+ );
56
+
57
+ -- Tokens of deleted logins, until Apple confirms the revocation. `user_id` has
58
+ -- no foreign key: the login is gone. A row without a token is a record (no
59
+ -- token was ever stored, or the retries gave up), never handed out.
60
+ create table private.genesis_apple_revocations (
61
+ id bigint generated always as identity primary key,
62
+ user_id uuid not null,
63
+ client_id text,
64
+ refresh_token text,
65
+ queued_at timestamptz not null default now(),
66
+ attempts integer not null default 0,
67
+ next_attempt_at timestamptz not null default now(),
68
+ last_error text,
69
+ check (refresh_token is null or client_id is not null)
70
+ );
71
+ create index genesis_apple_revocations_due on private.genesis_apple_revocations (next_attempt_at) where refresh_token is not null;
72
+
73
+ alter table private.genesis_apple_tokens enable row level security;
74
+ alter table private.genesis_apple_revocations enable row level security;
75
+ revoke all on table private.genesis_apple_tokens from public, anon, authenticated;
76
+ revoke all on table private.genesis_apple_revocations from public, anon, authenticated;
77
+
78
+ comment on table private.genesis_apple_tokens is
79
+ 'Sign in with Apple refresh tokens, server-only; written by genesis-apple-revoke. Genesis account block.';
80
+ comment on table private.genesis_apple_revocations is
81
+ 'Apple refresh tokens of deleted logins, until /auth/revoke succeeds; rows without a token are records to look at. Genesis account block.';
82
+
83
+ -- Deleting a login (any way) queues its Apple tokens before the cascade
84
+ -- removes them, or records that an Apple login had none to queue.
85
+ create function private.genesis_apple_queue_revocation()
86
+ returns trigger
87
+ language plpgsql
88
+ security definer
89
+ set search_path = ''
90
+ as $$
91
+ begin
92
+ insert into private.genesis_apple_revocations (user_id, client_id, refresh_token)
93
+ select t.user_id, t.client_id, t.refresh_token
94
+ from private.genesis_apple_tokens t
95
+ where t.user_id = old.id;
96
+ if not found and exists (select 1 from auth.identities i where i.user_id = old.id and i.provider = 'apple') then
97
+ insert into private.genesis_apple_revocations (user_id, last_error)
98
+ values (old.id, 'no_token: signed in with Apple, but no refresh token was stored, so none was revoked');
99
+ end if;
100
+ return old;
101
+ end;
102
+ $$;
103
+
104
+ create trigger genesis_apple_queue_revocation
105
+ before delete on auth.users
106
+ for each row execute function private.genesis_apple_queue_revocation();
107
+
108
+ -- Keeps the refresh token from a sign-in. If the login is already gone (it was
109
+ -- deleted while the code was being exchanged), the token goes straight to the
110
+ -- queue instead, so it is still revoked. Returns 'stored' or 'queued'.
111
+ create function public.genesis_apple_token_save(p_user_id uuid, p_client_id text, p_refresh_token text)
112
+ returns text
113
+ language plpgsql
114
+ security definer
115
+ set search_path = ''
116
+ as $$
117
+ begin
118
+ insert into private.genesis_apple_tokens as t (user_id, client_id, refresh_token)
119
+ values (p_user_id, p_client_id, p_refresh_token)
120
+ on conflict (user_id, client_id) do update
121
+ set refresh_token = excluded.refresh_token, updated_at = now();
122
+ return 'stored';
123
+ exception
124
+ when foreign_key_violation then
125
+ insert into private.genesis_apple_revocations (user_id, client_id, refresh_token)
126
+ values (p_user_id, p_client_id, p_refresh_token);
127
+ return 'queued';
128
+ when check_violation then
129
+ -- Raised afresh so the error (and the server log) never carries the failing row, token and all.
130
+ raise exception 'genesis_apple_token_save: malformed client id or token' using errcode = '23514';
131
+ end;
132
+ $$;
133
+
134
+ -- Hands out up to p_limit due revocations and pushes each one's next attempt
135
+ -- back (5 minutes, doubling per attempt, at most a day): the lease outlasts a
136
+ -- batch, so a function that dies mid-batch retries later and two runs never
137
+ -- take the same row.
138
+ create function public.genesis_apple_revocations_claim(p_limit integer default 20)
139
+ returns table (id bigint, client_id text, refresh_token text, attempts integer)
140
+ language sql
141
+ security definer
142
+ set search_path = ''
143
+ as $$
144
+ update private.genesis_apple_revocations r
145
+ set attempts = r.attempts + 1,
146
+ next_attempt_at = now() + least(interval '5 minutes' * power(2, least(r.attempts, 20)), interval '1 day')
147
+ where r.id in (
148
+ select q.id from private.genesis_apple_revocations q
149
+ where q.refresh_token is not null and q.next_attempt_at <= now()
150
+ order by q.next_attempt_at
151
+ limit greatest(1, least(coalesce(p_limit, 20), 100))
152
+ for update skip locked
153
+ )
154
+ returning r.id, r.client_id, r.refresh_token, r.attempts;
155
+ $$;
156
+
157
+ -- Apple confirmed (or the token was already dead): forget the token.
158
+ create function public.genesis_apple_revocation_done(p_id bigint)
159
+ returns void
160
+ language sql
161
+ security definer
162
+ set search_path = ''
163
+ as $$
164
+ delete from private.genesis_apple_revocations where id = p_id and refresh_token is not null;
165
+ $$;
166
+
167
+ -- Apple refused or didn't answer: keep the row for its next attempt, with why.
168
+ -- After the 30th attempt, drop the token and keep the row as the record.
169
+ -- Returns 'retry' or 'gave_up'.
170
+ create function public.genesis_apple_revocation_failed(p_id bigint, p_error text)
171
+ returns text
172
+ language plpgsql
173
+ security definer
174
+ set search_path = ''
175
+ as $$
176
+ declare
177
+ tries integer;
178
+ begin
179
+ update private.genesis_apple_revocations
180
+ set last_error = left(coalesce(p_error, ''), 200)
181
+ where id = p_id and refresh_token is not null
182
+ returning attempts into tries;
183
+ if tries >= 30 then
184
+ update private.genesis_apple_revocations
185
+ set refresh_token = null, last_error = left('gave_up after ' || tries || ' attempts: ' || coalesce(p_error, ''), 200)
186
+ where id = p_id;
187
+ return 'gave_up';
188
+ end if;
189
+ return 'retry';
190
+ end;
191
+ $$;
192
+
193
+ -- Privileges by name. Supabase's default privileges grant execute on a new
194
+ -- public function to anon and authenticated, so each is revoked here; a later
195
+ -- blanket `grant … on all functions` would hand them back, so such a grant
196
+ -- must exclude them.
197
+ revoke execute on function private.genesis_apple_queue_revocation() from public, anon, authenticated;
198
+ revoke execute on function public.genesis_apple_token_save(uuid, text, text) from public, anon, authenticated;
199
+ revoke execute on function public.genesis_apple_revocations_claim(integer) from public, anon, authenticated;
200
+ revoke execute on function public.genesis_apple_revocation_done(bigint) from public, anon, authenticated;
201
+ revoke execute on function public.genesis_apple_revocation_failed(bigint, text) from public, anon, authenticated;
202
+ grant execute on function public.genesis_apple_token_save(uuid, text, text) to service_role;
203
+ grant execute on function public.genesis_apple_revocations_claim(integer) to service_role;
204
+ grant execute on function public.genesis_apple_revocation_done(bigint) to service_role;
205
+ grant execute on function public.genesis_apple_revocation_failed(bigint, text) to service_role;