Skip to content

Commit e5017e3

Browse files
committed
feat(export): add 6 new services_public settings tables to export
Add database_settings, api_settings, rls_settings, cors_settings, pubkey_settings, and webauthn_settings to META_TABLE_CONFIG, META_TABLE_ORDER, exportMeta(), and exportGraphQLMeta(). These tables were added in constructive-db#1060 as part of the unified runtime settings architecture (constructive-planning#812).
1 parent c6e143b commit e5017e3

3 files changed

Lines changed: 120 additions & 1 deletion

File tree

pgpm/export/src/export-graphql-meta.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ export const exportGraphQLMeta = async ({
152152
queryAndParse('site_metadata'),
153153
queryAndParse('api_modules'),
154154
queryAndParse('api_extensions'),
155-
queryAndParse('api_schemas')
155+
queryAndParse('api_schemas'),
156+
queryAndParse('database_settings'),
157+
queryAndParse('api_settings'),
158+
queryAndParse('rls_settings'),
159+
queryAndParse('cors_settings'),
160+
queryAndParse('pubkey_settings'),
161+
queryAndParse('webauthn_settings')
156162
]);
157163

158164
// metaschema_modules_public tables

pgpm/export/src/export-meta.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ export const exportMeta = async ({ opts, dbname, database_id }: ExportMetaParams
161161
await queryAndParse('api_modules', `SELECT * FROM services_public.api_modules WHERE database_id = $1 ORDER BY id`);
162162
await queryAndParse('api_extensions', `SELECT * FROM services_public.api_extensions WHERE database_id = $1 ORDER BY id`);
163163
await queryAndParse('api_schemas', `SELECT * FROM services_public.api_schemas WHERE database_id = $1 ORDER BY id`);
164+
await queryAndParse('database_settings', `SELECT * FROM services_public.database_settings WHERE database_id = $1 ORDER BY id`);
165+
await queryAndParse('api_settings', `SELECT * FROM services_public.api_settings WHERE database_id = $1 ORDER BY id`);
166+
await queryAndParse('rls_settings', `SELECT * FROM services_public.rls_settings WHERE database_id = $1 ORDER BY id`);
167+
await queryAndParse('cors_settings', `SELECT * FROM services_public.cors_settings WHERE database_id = $1 ORDER BY id`);
168+
await queryAndParse('pubkey_settings', `SELECT * FROM services_public.pubkey_settings WHERE database_id = $1 ORDER BY id`);
169+
await queryAndParse('webauthn_settings', `SELECT * FROM services_public.webauthn_settings WHERE database_id = $1 ORDER BY id`);
164170

165171
// =============================================================================
166172
// metaschema_modules_public tables

pgpm/export/src/export-utils.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ export const META_TABLE_ORDER = [
149149
'api_modules',
150150
'api_extensions',
151151
'api_schemas',
152+
'database_settings',
153+
'api_settings',
154+
'rls_settings',
155+
'cors_settings',
156+
'pubkey_settings',
157+
'webauthn_settings',
152158
'rls_module',
153159
'user_auth_module',
154160
'memberships_module',
@@ -559,6 +565,107 @@ export const META_TABLE_CONFIG: Record<string, TableConfig> = {
559565
api_id: 'uuid'
560566
}
561567
},
568+
database_settings: {
569+
schema: 'services_public',
570+
table: 'database_settings',
571+
fields: {
572+
id: 'uuid',
573+
database_id: 'uuid',
574+
enable_aggregates: 'boolean',
575+
enable_postgis: 'boolean',
576+
enable_search: 'boolean',
577+
enable_direct_uploads: 'boolean',
578+
enable_presigned_uploads: 'boolean',
579+
enable_many_to_many: 'boolean',
580+
enable_connection_filter: 'boolean',
581+
enable_ltree: 'boolean',
582+
enable_llm: 'boolean',
583+
options: 'jsonb'
584+
}
585+
},
586+
api_settings: {
587+
schema: 'services_public',
588+
table: 'api_settings',
589+
fields: {
590+
id: 'uuid',
591+
database_id: 'uuid',
592+
api_id: 'uuid',
593+
enable_aggregates: 'boolean',
594+
enable_postgis: 'boolean',
595+
enable_search: 'boolean',
596+
enable_direct_uploads: 'boolean',
597+
enable_presigned_uploads: 'boolean',
598+
enable_many_to_many: 'boolean',
599+
enable_connection_filter: 'boolean',
600+
enable_ltree: 'boolean',
601+
enable_llm: 'boolean',
602+
options: 'jsonb'
603+
}
604+
},
605+
rls_settings: {
606+
schema: 'services_public',
607+
table: 'rls_settings',
608+
fields: {
609+
id: 'uuid',
610+
database_id: 'uuid',
611+
authenticate: 'text',
612+
authenticate_strict: 'text',
613+
authenticate_schema: 'text',
614+
role_schema: 'text',
615+
current_role_fn: 'text',
616+
current_role_id_fn: 'text',
617+
current_user_agent_fn: 'text',
618+
current_ip_address_fn: 'text'
619+
}
620+
},
621+
cors_settings: {
622+
schema: 'services_public',
623+
table: 'cors_settings',
624+
fields: {
625+
id: 'uuid',
626+
database_id: 'uuid',
627+
api_id: 'uuid',
628+
allowed_origins: 'text[]'
629+
}
630+
},
631+
pubkey_settings: {
632+
schema: 'services_public',
633+
table: 'pubkey_settings',
634+
fields: {
635+
id: 'uuid',
636+
database_id: 'uuid',
637+
schema: 'text',
638+
crypto_network: 'text',
639+
user_field: 'text',
640+
sign_up_with_key: 'text',
641+
sign_in_request_challenge: 'text',
642+
sign_in_record_failure: 'text',
643+
sign_in_with_challenge: 'text'
644+
}
645+
},
646+
webauthn_settings: {
647+
schema: 'services_public',
648+
table: 'webauthn_settings',
649+
fields: {
650+
id: 'uuid',
651+
database_id: 'uuid',
652+
schema: 'text',
653+
credentials_schema: 'text',
654+
credentials_table: 'text',
655+
sessions_schema: 'text',
656+
sessions_table: 'text',
657+
session_credentials_table: 'text',
658+
session_secrets_schema: 'text',
659+
session_secrets_table: 'text',
660+
rp_id: 'text',
661+
rp_name: 'text',
662+
origin_allowlist: 'text[]',
663+
attestation_type: 'text',
664+
require_user_verification: 'boolean',
665+
resident_key: 'text',
666+
challenge_expiry_seconds: 'int'
667+
}
668+
},
562669
// =============================================================================
563670
// metaschema_modules_public tables
564671
// =============================================================================

0 commit comments

Comments
 (0)