@marktiderman/genesis-supabase 0.15.0 → 0.16.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 +61 -4
- package/dist/blocks.d.ts +17 -9
- package/dist/blocks.js +1 -1
- package/dist/{chunk-XESMEWXI.js → chunk-HZYI5FJR.js} +18 -4
- package/dist/chunk-HZYI5FJR.js.map +1 -0
- package/dist/{index-CKloeGaz.d.ts → index-C2xP-igM.d.ts} +128 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +56 -2
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +4 -3
- package/functions/genesis-support-cleanup/handler.ts +30 -1
- package/functions/genesis-support-cleanup/index.ts +13 -2
- package/functions/genesis-support-intake/contract.ts +47 -6
- package/functions/genesis-support-notify/handler.ts +42 -18
- package/functions/genesis-support-notify/index.ts +2 -1
- package/migrations/0020_genesis_settings.sql +470 -0
- package/migrations/0021_genesis_settings_integer.sql +101 -0
- package/migrations/tests/0020_genesis_settings.test.sql +388 -0
- package/migrations/tests/0021_genesis_settings_integer.test.sql +21 -0
- package/package.json +41 -2
- package/dist/chunk-XESMEWXI.js.map +0 -1
package/README.md
CHANGED
|
@@ -591,7 +591,7 @@ Functions (templates; copy the folder into `supabase/functions/`):
|
|
|
591
591
|
| Function | What it does | Secrets |
|
|
592
592
|
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
593
593
|
| `genesis-support-intake` | The wire contract over HTTP (boot, submit, list) for clients without supabase-js; acts as the caller, never the service role | `GENESIS_SUPPORT_ORIGINS` (web origins) |
|
|
594
|
-
| `genesis-support-notify` | A Database Webhook on
|
|
594
|
+
| `genesis-support-notify` | A Database Webhook on INSERT into `public.tickets` (`support_reports` before genesis-support 0004): a GitHub issue per report and/or a signed webhook, with a summary only (no person, device, context or screenshot) | `GENESIS_SUPPORT_WEBHOOK_SECRET`, `GITHUB_TOKEN` + `GITHUB_REPO`, `SUPPORT_WEBHOOK_URL` (+ `SUPPORT_WEBHOOK_SIGNING_SECRET`) |
|
|
595
595
|
| `genesis-support-cleanup` | On a schedule: removes queued and orphaned screenshots through the Storage API | `GENESIS_SUPPORT_CLEANUP_SECRET` |
|
|
596
596
|
|
|
597
597
|
All three deploy with `verify_jwt = false` (each checks its caller or secret itself).
|
|
@@ -719,7 +719,7 @@ way: [ADR 0001](../../docs/adr/0001-one-feature-gate.md).
|
|
|
719
719
|
|
|
720
720
|
```ts
|
|
721
721
|
import { featureGateState, syncFeatureRegistry } from "@marktiderman/genesis-supabase";
|
|
722
|
-
import { gateSnapshot } from "@marktiderman/genesis-
|
|
722
|
+
import { gateSnapshot } from "@marktiderman/genesis-config/gate";
|
|
723
723
|
import registry from "../features.json";
|
|
724
724
|
|
|
725
725
|
// When a production deployment starts serving (never from a preview):
|
|
@@ -730,6 +730,59 @@ const state = await featureGateState(supabase, teamId); // per session; includes
|
|
|
730
730
|
const snapshot = gateSnapshot({ features, flags }, { platform: "web", ...state }, { version: BUILD_TIME });
|
|
731
731
|
```
|
|
732
732
|
|
|
733
|
+
## Settings (the settings block)
|
|
734
|
+
|
|
735
|
+
`migrations/0020_genesis_settings.sql` is the database layer of Genesis settings (genesis-config's
|
|
736
|
+
`resolveSettings`): runtime values platform admins change live, on top of the package defaults, the
|
|
737
|
+
preset and genesis.config.json.
|
|
738
|
+
|
|
739
|
+
- **`genesis_settings`**: a value per `namespace.key`, optionally `locked` (tenant and person values
|
|
740
|
+
can't change it). Every change goes to **`genesis_setting_changes`** (who, when, the old and new value
|
|
741
|
+
and lock, and from where: `admin`, `wizard`, `cli`, `central`, `server` or `database`), written only
|
|
742
|
+
by a trigger.
|
|
743
|
+
- **`genesis_app_manifest`**: one row, what the app runs: its packages and versions, preset, file
|
|
744
|
+
settings and the settings catalogue. Write it on every deploy, after the migrations, with
|
|
745
|
+
`genesis settings sync` (genesis-cli, through the linked project), or from your server at start with
|
|
746
|
+
the service role (`writeAppManifest`). `set_genesis_setting` checks values against its catalogue
|
|
747
|
+
(declared, runtime, the right type, in bounds); until it is written, every write is refused.
|
|
748
|
+
- **Who may change settings** is your hook, `private.genesis_platform_admin(person uuid) returns
|
|
749
|
+
boolean` (ADR 0003's platform zone). Without it nobody can (`42501`, with a hint): a fresh install
|
|
750
|
+
fails closed, as tenant features do.
|
|
751
|
+
- **Server code** is told apart from a person by the request's role, never by a JWT claim: the
|
|
752
|
+
service role, any role that bypasses row security, or a connection that never switched role. So a
|
|
753
|
+
direct database login (`psql`, a migration, a BI tool on its own login) counts as server code: it
|
|
754
|
+
reads the layers without signing in and its writes are recorded as `database` (the service role's
|
|
755
|
+
as `server`; either can name its source in `genesis.setting_source`), unchecked against the catalogue. Give people API access, never a
|
|
756
|
+
database login.
|
|
757
|
+
- **Reading.** `genesis_settings_layers()` gives any signed-in person (and server code) the layers,
|
|
758
|
+
not resolved values: the preset, the file settings for every declared key (build-time ones too:
|
|
759
|
+
they're committed config) and the database layer for runtime keys. The client resolves them with the
|
|
760
|
+
app's catalogue, so every platform agrees. No setting is a secret: a key names the secret it needs,
|
|
761
|
+
never its value.
|
|
762
|
+
- **Whole numbers** (migration `0021_genesis_settings_integer.sql`): a number the catalogue declares
|
|
763
|
+
`integer` refuses a fraction.
|
|
764
|
+
- **Checked writes.** `set_genesis_setting` refuses a key genesis.config.json locks, `null` for a key
|
|
765
|
+
with a default, and any key whose synced catalogue entry is malformed. JSON `null` (which PostgREST
|
|
766
|
+
passes as SQL null) means "not set".
|
|
767
|
+
- **The history is evidence.** Nobody edits it; the service role can't delete it directly, only prune
|
|
768
|
+
rows older than a year with `genesis_prune_setting_changes(older_than)`.
|
|
769
|
+
|
|
770
|
+
```ts
|
|
771
|
+
import { resolveAppSettings, setGenesisSetting, writeAppManifest } from "@marktiderman/genesis-supabase";
|
|
772
|
+
|
|
773
|
+
// On deploy, `genesis settings sync` writes the manifest. Or at server start, with the service role:
|
|
774
|
+
await writeAppManifest(admin, { appId: "sample-app", packages, preset: "max", fileSettings, catalogue });
|
|
775
|
+
|
|
776
|
+
// In the app, for any signed-in person:
|
|
777
|
+
const settings = await resolveAppSettings(supabase, catalogue, { person: preferences });
|
|
778
|
+
|
|
779
|
+
// A platform admin, from the Settings screen:
|
|
780
|
+
await setGenesisSetting(supabase, { key: "support.dumpRetentionDays", value: 30, locked: true });
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
`clearGenesisSetting` removes a row (the layers below apply again) and `genesisSettingHistory` reads
|
|
784
|
+
the history, both for platform admins. Tenant and person values aren't stored here yet.
|
|
785
|
+
|
|
733
786
|
## Background jobs (the jobs block)
|
|
734
787
|
|
|
735
788
|
`migrations/0007_genesis_jobs.sql` is one queue for background work and one way to schedule it, so
|
|
@@ -820,11 +873,15 @@ in `extensions`). The URL and the secret are read from Vault each time, so they
|
|
|
820
873
|
That matters because pg_net keeps each request's headers in `net.http_request_queue` until it sends
|
|
821
874
|
them, and on some images other roles can read that table.
|
|
822
875
|
|
|
876
|
+
Add the secret itself (`genesis_jobs_secret`, the same value as `GENESIS_JOBS_SECRET`) in the
|
|
877
|
+
Supabase dashboard (Database → Vault → Add new secret), not with SQL: a statement carrying the
|
|
878
|
+
value can be kept, value and all, in `pg_stat_statements` and in the Postgres log.
|
|
879
|
+
|
|
823
880
|
```sql
|
|
824
881
|
create extension if not exists pg_cron;
|
|
825
882
|
create extension if not exists pg_net;
|
|
826
883
|
select vault.create_secret('https://app.example.com/api/jobs', 'genesis_jobs_url');
|
|
827
|
-
|
|
884
|
+
-- genesis_jobs_secret: add it in the dashboard (Database → Vault → Add new secret), never in SQL.
|
|
828
885
|
select genesis_schedule_job('jobs-queue', '* * * * *', 'queue'); -- POST …/api/jobs/queue
|
|
829
886
|
select genesis_schedule_job('purge-uploads', '15 3 * * *', 'purge-uploads');
|
|
830
887
|
```
|
|
@@ -1042,7 +1099,7 @@ ids are shared with `@marktiderman/genesis-core/testing`.
|
|
|
1042
1099
|
## Blocks
|
|
1043
1100
|
|
|
1044
1101
|
`accountBlock`, `tenantFeaturesBlock`, `jobsBlock` and `versionedWritesBlock` are `defineBlock` declarations
|
|
1045
|
-
(`@marktiderman/genesis-
|
|
1102
|
+
(`@marktiderman/genesis-config/blocks`) of what this package's blocks need: their migrations
|
|
1046
1103
|
(with their tests) and, for the account, what it means for the stores' privacy forms. The
|
|
1047
1104
|
functions above don't change; the declarations are for `resolveBlocks` and the shell.
|
|
1048
1105
|
|
package/dist/blocks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _marktiderman_genesis_config_blocks from '@marktiderman/genesis-config/blocks';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The account block: sign-in, profile and in-app account deletion. Its
|
|
@@ -7,14 +7,14 @@ import * as _marktiderman_genesis_features_blocks from '@marktiderman/genesis-fe
|
|
|
7
7
|
*
|
|
8
8
|
* @stability Beta
|
|
9
9
|
*/
|
|
10
|
-
declare const accountBlock:
|
|
10
|
+
declare const accountBlock: _marktiderman_genesis_config_blocks.BlockDef<"account", never>;
|
|
11
11
|
/**
|
|
12
12
|
* The tenant features block: per-tenant on/off switches for shipped
|
|
13
13
|
* features, set by the tenant's admins with a reason.
|
|
14
14
|
*
|
|
15
15
|
* @stability Beta
|
|
16
16
|
*/
|
|
17
|
-
declare const tenantFeaturesBlock:
|
|
17
|
+
declare const tenantFeaturesBlock: _marktiderman_genesis_config_blocks.BlockDef<"tenant-features", never>;
|
|
18
18
|
/**
|
|
19
19
|
* The feature registry block: the registry mirrored into the app's database
|
|
20
20
|
* on deploy, entitlements, per-tenant and platform flag values and SQL `feature_on()`,
|
|
@@ -22,14 +22,22 @@ declare const tenantFeaturesBlock: _marktiderman_genesis_features_blocks.BlockDe
|
|
|
22
22
|
*
|
|
23
23
|
* @stability Beta
|
|
24
24
|
*/
|
|
25
|
-
declare const featureMirrorBlock:
|
|
25
|
+
declare const featureMirrorBlock: _marktiderman_genesis_config_blocks.BlockDef<"feature-mirror", never>;
|
|
26
|
+
/**
|
|
27
|
+
* The settings block: the database layer of Genesis settings (genesis-config's
|
|
28
|
+
* `resolveSettings`), its history and the app manifest, with platform admins
|
|
29
|
+
* changing runtime settings through `set_genesis_setting`.
|
|
30
|
+
*
|
|
31
|
+
* @stability Beta
|
|
32
|
+
*/
|
|
33
|
+
declare const settingsBlock: _marktiderman_genesis_config_blocks.BlockDef<"settings", never>;
|
|
26
34
|
/**
|
|
27
35
|
* The jobs block: a background-job queue and named schedules that call the
|
|
28
36
|
* app's job route. Server only; the route is `createJobsHandler` from `/jobs`.
|
|
29
37
|
*
|
|
30
38
|
* @stability Beta
|
|
31
39
|
*/
|
|
32
|
-
declare const jobsBlock:
|
|
40
|
+
declare const jobsBlock: _marktiderman_genesis_config_blocks.BlockDef<"jobs", never>;
|
|
33
41
|
/**
|
|
34
42
|
* The web handoff block: continue on the web, already signed in. The routes are
|
|
35
43
|
* `createWebHandoff` from `/web-handoff/server`, the page uses `/web-handoff`, and the native
|
|
@@ -37,7 +45,7 @@ declare const jobsBlock: _marktiderman_genesis_features_blocks.BlockDef<"jobs",
|
|
|
37
45
|
*
|
|
38
46
|
* @stability Beta
|
|
39
47
|
*/
|
|
40
|
-
declare const webHandoffBlock:
|
|
48
|
+
declare const webHandoffBlock: _marktiderman_genesis_config_blocks.BlockDef<"web-handoff", never>;
|
|
41
49
|
/**
|
|
42
50
|
* The product events block: the app's own events table and its tracking functions (ADR 0010).
|
|
43
51
|
* The client is `createEventTracker` from `/events`; on native, `createEventsSink` plugs it into the
|
|
@@ -45,7 +53,7 @@ declare const webHandoffBlock: _marktiderman_genesis_features_blocks.BlockDef<"w
|
|
|
45
53
|
*
|
|
46
54
|
* @stability Beta
|
|
47
55
|
*/
|
|
48
|
-
declare const eventsBlock:
|
|
56
|
+
declare const eventsBlock: _marktiderman_genesis_config_blocks.BlockDef<"events", never>;
|
|
49
57
|
/**
|
|
50
58
|
* The versioned-writes block: `genesis_version_bump`, the trigger that advances a row's version on
|
|
51
59
|
* every update, so the Supabase data provider's `version` rule can refuse an edit made on a stale
|
|
@@ -53,6 +61,6 @@ declare const eventsBlock: _marktiderman_genesis_features_blocks.BlockDef<"event
|
|
|
53
61
|
*
|
|
54
62
|
* @stability Beta
|
|
55
63
|
*/
|
|
56
|
-
declare const versionedWritesBlock:
|
|
64
|
+
declare const versionedWritesBlock: _marktiderman_genesis_config_blocks.BlockDef<"versioned-writes", never>;
|
|
57
65
|
|
|
58
|
-
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, tenantFeaturesBlock, versionedWritesBlock, webHandoffBlock };
|
|
66
|
+
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, settingsBlock, tenantFeaturesBlock, versionedWritesBlock, webHandoffBlock };
|
package/dist/blocks.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, tenantFeaturesBlock, versionedWritesBlock, webHandoffBlock } from './chunk-
|
|
1
|
+
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, settingsBlock, tenantFeaturesBlock, versionedWritesBlock, webHandoffBlock } from './chunk-HZYI5FJR.js';
|
|
2
2
|
//# sourceMappingURL=blocks.js.map
|
|
3
3
|
//# sourceMappingURL=blocks.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineBlock } from '@marktiderman/genesis-
|
|
1
|
+
import { defineBlock } from '@marktiderman/genesis-config/blocks';
|
|
2
2
|
|
|
3
3
|
// src/blocks.ts
|
|
4
4
|
var PACKAGE = "@marktiderman/genesis-supabase";
|
|
@@ -93,6 +93,20 @@ var featureMirrorBlock = defineBlock({
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
+
var settingsBlock = defineBlock({
|
|
97
|
+
id: "settings",
|
|
98
|
+
platforms: ["web", "native"],
|
|
99
|
+
contributes: {
|
|
100
|
+
migrations: [
|
|
101
|
+
{ package: PACKAGE, file: "migrations/0020_genesis_settings.sql", test: "migrations/tests/0020_genesis_settings.test.sql" },
|
|
102
|
+
// Whole numbers: a fraction is refused for a key declared `integer`.
|
|
103
|
+
{ package: PACKAGE, file: "migrations/0021_genesis_settings_integer.sql", test: "migrations/tests/0021_genesis_settings_integer.test.sql" }
|
|
104
|
+
],
|
|
105
|
+
privacy: {
|
|
106
|
+
notes: ["Keeps who changed an app setting, when and from what to what; a deleted person's changes stay, without the person. No setting holds a secret."]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
96
110
|
var jobsBlock = defineBlock({
|
|
97
111
|
id: "jobs",
|
|
98
112
|
platforms: ["web"],
|
|
@@ -137,6 +151,6 @@ var versionedWritesBlock = defineBlock({
|
|
|
137
151
|
}
|
|
138
152
|
});
|
|
139
153
|
|
|
140
|
-
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, tenantFeaturesBlock, versionedWritesBlock, webHandoffBlock };
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, settingsBlock, tenantFeaturesBlock, versionedWritesBlock, webHandoffBlock };
|
|
155
|
+
//# sourceMappingURL=chunk-HZYI5FJR.js.map
|
|
156
|
+
//# sourceMappingURL=chunk-HZYI5FJR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/blocks.ts"],"names":[],"mappings":"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","file":"chunk-HZYI5FJR.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-config/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 {\n package: PACKAGE,\n file: \"migrations/0001_genesis_account_deletion.sql\",\n test: \"migrations/tests/0001_genesis_account_deletion.test.sql\",\n },\n // With Sign in with Apple, with the genesis-apple-revoke function beside it.\n {\n package: PACKAGE,\n file: \"migrations/0003_genesis_apple_token_revocation.sql\",\n test: \"migrations/tests/0003_genesis_apple_token_revocation.test.sql\",\n },\n ],\n privacy: {\n collects: [\n {\n type: \"email address\",\n purposes: [\"app functionality\"],\n linked: true,\n tracking: false,\n },\n {\n type: \"user id\",\n purposes: [\"app functionality\"],\n linked: true,\n tracking: false,\n },\n {\n type: \"name\",\n purposes: [\"app functionality\"],\n linked: true,\n tracking: false,\n },\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: [\n {\n package: PACKAGE,\n file: \"migrations/0004_genesis_tenant_features.sql\",\n test: \"migrations/tests/0004_genesis_tenant_features.test.sql\",\n },\n ],\n privacy: {\n notes: [\n \"Keeps who changed a tenant's switches; a deleted person's changes stay, without the person.\",\n ],\n },\n },\n});\n\n/**\n * The feature registry block: the registry mirrored into the app's database\n * on deploy, entitlements, per-tenant and platform flag values and SQL `feature_on()`,\n * for the feature gate. Needs the tenant features block.\n *\n * @stability Beta\n */\nexport const featureMirrorBlock = defineBlock({\n id: \"feature-mirror\",\n requires: [\"tenant-features\"],\n contributes: {\n migrations: [\n {\n package: PACKAGE,\n file: \"migrations/0008_genesis_feature_registry.sql\",\n test: \"migrations/tests/0008_genesis_feature_registry.test.sql\",\n },\n {\n package: PACKAGE,\n file: \"migrations/0014_genesis_feature_registry_hardening.sql\",\n test: \"migrations/tests/0014_genesis_feature_registry_hardening.test.sql\",\n },\n { package: PACKAGE, file: \"migrations/0016_genesis_viewer_people.sql\", test: \"migrations/tests/0016_genesis_viewer_people.test.sql\" },\n {\n package: PACKAGE,\n file: \"migrations/0017_genesis_person_entitlements.sql\",\n test: \"migrations/tests/0017_genesis_person_entitlements.test.sql\",\n },\n ],\n privacy: {\n notes: [\n \"Stores which tenants and which people (the app's person ids) hold which paid features, and flag values.\",\n ],\n },\n },\n});\n\n/**\n * The settings block: the database layer of Genesis settings (genesis-config's\n * `resolveSettings`), its history and the app manifest, with platform admins\n * changing runtime settings through `set_genesis_setting`.\n *\n * @stability Beta\n */\nexport const settingsBlock = defineBlock({\n id: \"settings\",\n platforms: [\"web\", \"native\"],\n contributes: {\n migrations: [\n { package: PACKAGE, file: \"migrations/0020_genesis_settings.sql\", test: \"migrations/tests/0020_genesis_settings.test.sql\" },\n // Whole numbers: a fraction is refused for a key declared `integer`.\n { package: PACKAGE, file: \"migrations/0021_genesis_settings_integer.sql\", test: \"migrations/tests/0021_genesis_settings_integer.test.sql\" },\n ],\n privacy: {\n notes: [\"Keeps who changed an app setting, when and from what to what; a deleted person's changes stay, without the person. No setting holds a secret.\"],\n },\n },\n});\n\n/**\n * The jobs block: a background-job queue and named schedules that call the\n * app's job route. Server only; the route is `createJobsHandler` from `/jobs`.\n *\n * @stability Beta\n */\nexport const jobsBlock = defineBlock({\n id: \"jobs\",\n platforms: [\"web\"],\n contributes: {\n migrations: [{ package: PACKAGE, file: \"migrations/0007_genesis_jobs.sql\", test: \"migrations/tests/0007_genesis_jobs.test.sql\" }],\n privacy: { notes: [\"Job payloads hold ids, never content or secrets; finished jobs are deleted after 14 days.\"] },\n },\n});\n\n/**\n * The web handoff block: continue on the web, already signed in. The routes are\n * `createWebHandoff` from `/web-handoff/server`, the page uses `/web-handoff`, and the native\n * app calls `openOnWeb` from genesis-native.\n *\n * @stability Beta\n */\nexport const webHandoffBlock = defineBlock({\n id: \"web-handoff\",\n platforms: [\"web\", \"native\"],\n contributes: {\n migrations: [\n { package: PACKAGE, file: \"migrations/0015_genesis_web_handoff.sql\", test: \"migrations/tests/0015_genesis_web_handoff.test.sql\" },\n ],\n privacy: {\n notes: [\n \"Logs each handoff (who, which page, when) for 30 days; keeps a SHA-256 digest of each link's token, never the token or a sign-in token.\",\n ],\n },\n },\n});\n\n\n/**\n * The product events block: the app's own events table and its tracking functions (ADR 0010).\n * The client is `createEventTracker` from `/events`; on native, `createEventsSink` plugs it into the\n * observability sinks.\n *\n * @stability Beta\n */\nexport const eventsBlock = defineBlock({\n id: \"events\",\n platforms: [\"web\", \"native\"],\n contributes: {\n migrations: [{ package: PACKAGE, file: \"migrations/0018_genesis_events.sql\", test: \"migrations/tests/0018_genesis_events.test.sql\" }],\n privacy: {\n notes: [\n \"Stores product events: the login, the person record and tenant, the feature, an event name, small properties (labels and counts, never typed content or personal data), the flags that were on, the platform and the time. Only the service role reads them; delete old ones with genesis_prune_events (default 400 days).\",\n ],\n },\n },\n});\n\n/**\n * The versioned-writes block: `genesis_version_bump`, the trigger that advances a row's version on\n * every update, so the Supabase data provider's `version` rule can refuse an edit made on a stale\n * copy as a `conflict`.\n *\n * @stability Beta\n */\nexport const versionedWritesBlock = defineBlock({\n id: \"versioned-writes\",\n platforms: [\"web\", \"native\"],\n contributes: {\n migrations: [\n { package: PACKAGE, file: \"migrations/0019_genesis_version_bump.sql\", test: \"migrations/tests/0019_genesis_version_bump.test.sql\" },\n ],\n },\n});\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient, SupabaseClientOptions } from '@supabase/supabase-js';
|
|
2
|
+
import { SettingsPreset, SettingsCatalogue, SettingsLayerValues, SettingsLayers, ResolvedSettings } from '@marktiderman/genesis-config/settings';
|
|
2
3
|
import './blocks.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -108,6 +109,132 @@ declare function isDigestOnlyPolyfill(target?: object): boolean;
|
|
|
108
109
|
*/
|
|
109
110
|
declare function assertPkceCrypto(target?: object): void;
|
|
110
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Genesis settings: the client half of `migrations/0020_genesis_settings.sql`. Read the layers the
|
|
114
|
+
* database holds and resolve them with genesis-config's `resolveSettings` (the one resolver, on
|
|
115
|
+
* every platform); platform admins set, lock and clear runtime settings; the service role writes
|
|
116
|
+
* the app manifest (with the catalogue the database checks values against) on deploy.
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
/** The parts of a Supabase client these helpers use. A `SupabaseClient` fits. */
|
|
120
|
+
interface SettingsClient {
|
|
121
|
+
rpc: (fn: any, ...rest: any[]) => PromiseLike<{
|
|
122
|
+
data: unknown;
|
|
123
|
+
error: PostgrestErrorLike | null;
|
|
124
|
+
}>;
|
|
125
|
+
}
|
|
126
|
+
/** The service-role client {@link writeAppManifest} writes with. */
|
|
127
|
+
interface ManifestClient {
|
|
128
|
+
from: (table: any) => {
|
|
129
|
+
upsert: (row: any, options?: any) => PromiseLike<{
|
|
130
|
+
error: PostgrestErrorLike | null;
|
|
131
|
+
}>;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* What `genesis_settings_layers` returns: the layers to resolve (not resolved values): the preset,
|
|
136
|
+
* the file's settings for every declared key (build-time keys too) and the database layer for runtime keys.
|
|
137
|
+
*
|
|
138
|
+
* @stability Beta
|
|
139
|
+
*/
|
|
140
|
+
interface StoredSettingsLayers {
|
|
141
|
+
preset: SettingsPreset;
|
|
142
|
+
file: SettingsLayerValues;
|
|
143
|
+
database: SettingsLayerValues;
|
|
144
|
+
/** When the manifest was last written; null before the first deploy wrote it. */
|
|
145
|
+
reportedAt: string | null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The preset, the file's settings and the database layer, for any signed-in person or server code:
|
|
149
|
+
* `genesis_settings_layers`. Throws a `SupabaseQueryError` (`42501`) when nobody is signed in.
|
|
150
|
+
*
|
|
151
|
+
* @stability Beta
|
|
152
|
+
*/
|
|
153
|
+
declare function readSettingsLayers(client: SettingsClient): Promise<StoredSettingsLayers>;
|
|
154
|
+
/** @stability Beta */
|
|
155
|
+
interface ResolveAppSettingsOptions {
|
|
156
|
+
/** The tenant's values (keys declared `scope: "tenant"`), from wherever the app keeps them. */
|
|
157
|
+
tenant?: SettingsLayerValues;
|
|
158
|
+
/** The person's values (keys declared `scope: "person"`). */
|
|
159
|
+
person?: SettingsLayerValues;
|
|
160
|
+
/**
|
|
161
|
+
* The layers the build itself carries (the preset and genesis.config.json `settings`); when given,
|
|
162
|
+
* they replace the stored preset and file layer (the stored ones are what the last deploy wrote).
|
|
163
|
+
*/
|
|
164
|
+
build?: Pick<SettingsLayers, "preset" | "file">;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Read the stored layers and resolve them with the app's catalogue: values, where each came from,
|
|
168
|
+
* and what was wrong.
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* const settings = await resolveAppSettings(supabase, catalogue, { person: myPreferences });
|
|
172
|
+
* settings.values["support.messenger"]; // true
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @stability Beta
|
|
176
|
+
*/
|
|
177
|
+
declare function resolveAppSettings(client: SettingsClient, catalogue: SettingsCatalogue, options?: ResolveAppSettingsOptions): Promise<ResolvedSettings>;
|
|
178
|
+
/** @stability Beta */
|
|
179
|
+
interface SetGenesisSettingInput {
|
|
180
|
+
/** `namespace.key`, a runtime key the catalogue declares. */
|
|
181
|
+
key: string;
|
|
182
|
+
/** The value; `null` for "not set". */
|
|
183
|
+
value: unknown;
|
|
184
|
+
/** Lock it, so tenant and person values can't change it. Default false. */
|
|
185
|
+
locked?: boolean;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Set a runtime setting in the database layer: `set_genesis_setting`. Only platform admins (the
|
|
189
|
+
* app's `private.genesis_platform_admin` hook); throws a `SupabaseQueryError` otherwise (`42501`),
|
|
190
|
+
* or for a value the synced catalogue refuses (`22023`: an unknown or build-time key, one
|
|
191
|
+
* genesis.config.json locks, the wrong type, out of bounds, or `null` for a key with a default).
|
|
192
|
+
*
|
|
193
|
+
* @stability Beta
|
|
194
|
+
*/
|
|
195
|
+
declare function setGenesisSetting(client: SettingsClient, input: SetGenesisSettingInput): Promise<void>;
|
|
196
|
+
/** Remove a setting from the database layer, so the file, preset or default applies again: `clear_genesis_setting`. Platform admins only. @stability Beta */
|
|
197
|
+
declare function clearGenesisSetting(client: SettingsClient, key: string): Promise<void>;
|
|
198
|
+
/** One change to the database layer. A null `new_value` with `new_locked` null is a cleared setting. @stability Beta */
|
|
199
|
+
interface GenesisSettingChange {
|
|
200
|
+
key: string;
|
|
201
|
+
old_value: unknown;
|
|
202
|
+
new_value: unknown;
|
|
203
|
+
old_locked: boolean | null;
|
|
204
|
+
new_locked: boolean | null;
|
|
205
|
+
/** The person, or null for the service role, a migration, or a person since deleted. */
|
|
206
|
+
changed_by: string | null;
|
|
207
|
+
changed_role: string;
|
|
208
|
+
source: "admin" | "wizard" | "cli" | "central" | "server" | "database";
|
|
209
|
+
changed_at: string;
|
|
210
|
+
}
|
|
211
|
+
/** The database layer's history, newest first (at most `maxRows`, 1 to 1000, default 100). Platform admins only. @stability Beta */
|
|
212
|
+
declare function genesisSettingHistory(client: SettingsClient, options?: {
|
|
213
|
+
maxRows?: number;
|
|
214
|
+
}): Promise<GenesisSettingChange[]>;
|
|
215
|
+
/** What this app runs, written on deploy and at app start. @stability Beta */
|
|
216
|
+
interface AppManifestInput {
|
|
217
|
+
/** The app's slug (`sample-app`). */
|
|
218
|
+
appId: string;
|
|
219
|
+
name?: string;
|
|
220
|
+
/** Package → version, from genesis.lock.json. */
|
|
221
|
+
packages?: Record<string, string>;
|
|
222
|
+
preset?: SettingsPreset;
|
|
223
|
+
configHash?: string;
|
|
224
|
+
/** genesis.config.json `settings`, as written. */
|
|
225
|
+
fileSettings?: Record<string, unknown>;
|
|
226
|
+
/** The app's catalogue: the database checks platform admins' values against it. */
|
|
227
|
+
catalogue: SettingsCatalogue;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Write the app manifest (one row) with the service-role client, on deploy and at app start. It
|
|
231
|
+
* carries the catalogue `set_genesis_setting` validates against: until it's written, no setting
|
|
232
|
+
* can be changed. Server only: never with a browser's client.
|
|
233
|
+
*
|
|
234
|
+
* @stability Beta
|
|
235
|
+
*/
|
|
236
|
+
declare function writeAppManifest(admin: ManifestClient, input: AppManifestInput): Promise<void>;
|
|
237
|
+
|
|
111
238
|
/**
|
|
112
239
|
* Tenant features: the client half of `migrations/0004_genesis_tenant_features.sql`.
|
|
113
240
|
* A tenant's admins turn a shipped feature off (or back on) for their tenant,
|
|
@@ -592,4 +719,4 @@ interface DeleteMyAccountOptions {
|
|
|
592
719
|
*/
|
|
593
720
|
declare function deleteMyAccount(client: DeleteAccountClient, options?: DeleteMyAccountOptions): Promise<void>;
|
|
594
721
|
|
|
595
|
-
export { APPLE_REVOKE_FUNCTION as A,
|
|
722
|
+
export { setTenantFeature as $, APPLE_REVOKE_FUNCTION as A, type TenantFeatureSetting as B, type CreateAuthFormClientOptions as C, type DeleteAccountClient as D, type ExpoCryptoLike as E, type FeatureGateState as F, type GenesisSettingChange as G, type TenantFeatures as H, type TenantFeaturesClient as I, clearGenesisSetting as J, createAuthFormClient as K, createGenesisSupabase as L, type ManifestClient as M, deleteMyAccount as N, featureGateState as O, type PostgrestErrorLike as P, fetchAuthSettings as Q, type ResolveAppSettingsOptions as R, type SessionStorage as S, type TenantFeatureChange as T, genesisSettingHistory as U, must as V, type WebCryptoSource as W, readSettingsLayers as X, requestAppleRevocation as Y, resolveAppSettings as Z, setGenesisSetting as _, assertPkceCrypto as a, storeAppleToken as a0, syncFeatureRegistry as a1, tenantFeatureHistory as a2, tenantFeatureSettings as a3, tenantFeatures as a4, writeAppManifest as a5, isDigestOnlyPolyfill as b, type AppManifestInput as c, type AuthCallError as d, type AuthCallResult as e, type AuthFormSupabase as f, type AuthFormSupabaseClient as g, hasPkceCrypto as h, installWebCrypto as i, type AuthSettings as j, type DeleteMyAccountOptions as k, type FeatureGateStateOptions as l, type FeatureRegistryClient as m, type FeatureRegistryDocument as n, type FlagStateValue as o, type FunctionsClient as p, type GenesisSupabaseOptions as q, SUPABASE_OAUTH_PROVIDERS as r, type SetGenesisSettingInput as s, type SetTenantFeatureInput as t, type SettingsClient as u, type StoreAppleTokenOptions as v, type StoreAppleTokenResult as w, type StoredSettingsLayers as x, SupabaseQueryError as y, type SyncFeatureRegistryOptions as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '@supabase/supabase-js';
|
|
2
|
-
export { A as APPLE_REVOKE_FUNCTION, c as
|
|
3
|
-
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, tenantFeaturesBlock, versionedWritesBlock } from './blocks.js';
|
|
4
|
-
import '@marktiderman/genesis-
|
|
2
|
+
export { A as APPLE_REVOKE_FUNCTION, c as AppManifestInput, d as AuthCallError, e as AuthCallResult, f as AuthFormSupabase, g as AuthFormSupabaseClient, j as AuthSettings, C as CreateAuthFormClientOptions, D as DeleteAccountClient, k as DeleteMyAccountOptions, E as ExpoCryptoLike, F as FeatureGateState, l as FeatureGateStateOptions, m as FeatureRegistryClient, n as FeatureRegistryDocument, o as FlagStateValue, p as FunctionsClient, G as GenesisSettingChange, q as GenesisSupabaseOptions, M as ManifestClient, P as PostgrestErrorLike, R as ResolveAppSettingsOptions, r as SUPABASE_OAUTH_PROVIDERS, S as SessionStorage, s as SetGenesisSettingInput, t as SetTenantFeatureInput, u as SettingsClient, v as StoreAppleTokenOptions, w as StoreAppleTokenResult, x as StoredSettingsLayers, y as SupabaseQueryError, z as SyncFeatureRegistryOptions, T as TenantFeatureChange, B as TenantFeatureSetting, H as TenantFeatures, I as TenantFeaturesClient, J as clearGenesisSetting, K as createAuthFormClient, L as createGenesisSupabase, N as deleteMyAccount, O as featureGateState, Q as fetchAuthSettings, U as genesisSettingHistory, V as must, X as readSettingsLayers, Y as requestAppleRevocation, Z as resolveAppSettings, _ as setGenesisSetting, $ as setTenantFeature, a0 as storeAppleToken, a1 as syncFeatureRegistry, a2 as tenantFeatureHistory, a3 as tenantFeatureSettings, a4 as tenantFeatures, a5 as writeAppManifest } from './index-C2xP-igM.js';
|
|
3
|
+
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, settingsBlock, tenantFeaturesBlock, versionedWritesBlock } from './blocks.js';
|
|
4
|
+
import '@marktiderman/genesis-config/settings';
|
|
5
|
+
import '@marktiderman/genesis-config/blocks';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { installWebCrypto, assertPkceCrypto, isDigestOnlyPolyfill, claimsViaServer } from './chunk-FAA2FTF4.js';
|
|
2
|
-
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, tenantFeaturesBlock, versionedWritesBlock } from './chunk-
|
|
2
|
+
export { accountBlock, eventsBlock, featureMirrorBlock, jobsBlock, settingsBlock, tenantFeaturesBlock, versionedWritesBlock } from './chunk-HZYI5FJR.js';
|
|
3
3
|
import { createClient, AuthInvalidJwtError, isAuthError } from '@supabase/supabase-js';
|
|
4
|
+
import { settingsLayerFromFile, resolveSettings, catalogueManifest } from '@marktiderman/genesis-config/settings';
|
|
4
5
|
|
|
5
6
|
// src/apple-tokens.ts
|
|
6
7
|
var APPLE_REVOKE_FUNCTION = "genesis-apple-revoke";
|
|
@@ -23,6 +24,59 @@ async function requestAppleRevocation(client, functionName = APPLE_REVOKE_FUNCTI
|
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
var PRESETS = ["max", "standard", "min"];
|
|
28
|
+
function isObject(v) {
|
|
29
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
30
|
+
}
|
|
31
|
+
async function readSettingsLayers(client) {
|
|
32
|
+
const data = must(await client.rpc("genesis_settings_layers"));
|
|
33
|
+
const raw = isObject(data) ? data : {};
|
|
34
|
+
const database = {};
|
|
35
|
+
for (const [key, entry] of Object.entries(isObject(raw.database) ? raw.database : {})) {
|
|
36
|
+
if (!isObject(entry) || !("value" in entry)) continue;
|
|
37
|
+
database[key] = entry.locked === true ? { value: entry.value, locked: true } : { value: entry.value };
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
preset: typeof raw.preset === "string" && PRESETS.includes(raw.preset) ? raw.preset : "max",
|
|
41
|
+
file: settingsLayerFromFile(isObject(raw.file) ? raw.file : {}),
|
|
42
|
+
database,
|
|
43
|
+
reportedAt: typeof raw.reportedAt === "string" ? raw.reportedAt : null
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function resolveAppSettings(client, catalogue, options = {}) {
|
|
47
|
+
const stored = await readSettingsLayers(client);
|
|
48
|
+
return resolveSettings(catalogue, {
|
|
49
|
+
preset: options.build?.preset ?? stored.preset,
|
|
50
|
+
file: options.build?.file ?? stored.file,
|
|
51
|
+
database: stored.database,
|
|
52
|
+
...options.tenant ? { tenant: options.tenant } : {},
|
|
53
|
+
...options.person ? { person: options.person } : {}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function setGenesisSetting(client, input) {
|
|
57
|
+
must(await client.rpc("set_genesis_setting", { key: input.key, value: input.value === void 0 ? null : input.value, locked: input.locked ?? false }));
|
|
58
|
+
}
|
|
59
|
+
async function clearGenesisSetting(client, key) {
|
|
60
|
+
must(await client.rpc("clear_genesis_setting", { key }));
|
|
61
|
+
}
|
|
62
|
+
async function genesisSettingHistory(client, options = {}) {
|
|
63
|
+
const args = options.maxRows === void 0 ? {} : { max_rows: options.maxRows };
|
|
64
|
+
return must(await client.rpc("genesis_setting_history", args)) ?? [];
|
|
65
|
+
}
|
|
66
|
+
async function writeAppManifest(admin, input) {
|
|
67
|
+
const row = {
|
|
68
|
+
app_id: input.appId,
|
|
69
|
+
name: input.name ?? null,
|
|
70
|
+
packages: input.packages ?? {},
|
|
71
|
+
preset: input.preset ?? "max",
|
|
72
|
+
config_hash: input.configHash ?? null,
|
|
73
|
+
file_settings: input.fileSettings ?? {},
|
|
74
|
+
catalogue: catalogueManifest(input.catalogue),
|
|
75
|
+
reported_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
76
|
+
};
|
|
77
|
+
const { error } = await admin.from("genesis_app_manifest").upsert(row, { onConflict: "one" });
|
|
78
|
+
must({ data: null, error });
|
|
79
|
+
}
|
|
26
80
|
|
|
27
81
|
// src/tenant-features.ts
|
|
28
82
|
async function tenantFeatures(client, tenantId) {
|
|
@@ -304,6 +358,6 @@ async function deleteMyAccount(client, options = {}) {
|
|
|
304
358
|
await client.auth.signOut({ scope: "local" });
|
|
305
359
|
}
|
|
306
360
|
|
|
307
|
-
export { APPLE_REVOKE_FUNCTION, SUPABASE_OAUTH_PROVIDERS, SupabaseQueryError, createAuthFormClient, createGenesisSupabase, deleteMyAccount, featureGateState, fetchAuthSettings, must, requestAppleRevocation, setTenantFeature, storeAppleToken, syncFeatureRegistry, tenantFeatureHistory, tenantFeatureSettings, tenantFeatures };
|
|
361
|
+
export { APPLE_REVOKE_FUNCTION, SUPABASE_OAUTH_PROVIDERS, SupabaseQueryError, clearGenesisSetting, createAuthFormClient, createGenesisSupabase, deleteMyAccount, featureGateState, fetchAuthSettings, genesisSettingHistory, must, readSettingsLayers, requestAppleRevocation, resolveAppSettings, setGenesisSetting, setTenantFeature, storeAppleToken, syncFeatureRegistry, tenantFeatureHistory, tenantFeatureSettings, tenantFeatures, writeAppManifest };
|
|
308
362
|
//# sourceMappingURL=index.js.map
|
|
309
363
|
//# sourceMappingURL=index.js.map
|