graphile-scoped-introspection 0.2.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/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
4
+ Copyright (c) 2025 Constructive <developers@constructive.io>
5
+ Copyright (c) 2020-present, Interweb, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # graphile-scoped-introspection
2
+
3
+ An opt-in Graphile plugin that scopes PostgreSQL catalog introspection to the
4
+ configured service schemas and their required dependency closure.
5
+
6
+ ```ts
7
+ import { ScopedIntrospectionPreset } from 'graphile-scoped-introspection';
8
+
9
+ const preset = {
10
+ extends: [ScopedIntrospectionPreset],
11
+ gather: {
12
+ pgScopedIntrospection: {
13
+ main: true,
14
+ },
15
+ },
16
+ pgServices: [
17
+ {
18
+ // standard Graphile PgService fields
19
+ name: 'main',
20
+ schemas: ['app_public'],
21
+ },
22
+ ],
23
+ };
24
+ ```
25
+
26
+ With `main: true`, the scoped query uses `catalogTypes: 'all'`: it retains the
27
+ dependency closure needed by the selected schemas and all `pg_catalog` types.
28
+ It does not expose every user schema or every catalog object. Services omitted
29
+ from `gather.pgScopedIntrospection`, or mapped to `false`, use stock
30
+ introspection.
31
+
32
+ Use an options object when the dependency-only policy or extension capability
33
+ metadata is needed:
34
+
35
+ ```ts
36
+ gather: {
37
+ pgScopedIntrospection: {
38
+ main: {
39
+ catalogTypes: 'dependency-closure',
40
+ capabilityExtensions: ['pg_trgm'],
41
+ },
42
+ },
43
+ },
44
+ ```
45
+
46
+ The query follows real PostgreSQL dependencies across schemas automatically;
47
+ there is no dependency-schema allowlist. `capabilityExtensions` records the
48
+ requested extension capability metadata and does not add user schemas to the
49
+ scope. Unknown service names fail validation even when mapped to `false`.
50
+
51
+ The package atomically replaces `PgIntrospectionPlugin` only when its preset
52
+ is installed. `true` enables scoped introspection with defaults; an options
53
+ object selects the catalog type policy and optional extension capability
54
+ metadata.
55
+
56
+ The scoped SQL is CNC-owned and parameterized. It is adapted from the MIT
57
+ licensed `pg-introspection@1.0.1` query and does not patch, import private
58
+ subpaths from, or rewrite the installed upstream package.
59
+
60
+ Use `makeSchemaScopedIntrospectionPlan` when the query result will be parsed
61
+ and validated. It returns the normalized schema and option scope alongside the
62
+ parameterized query; `makeSchemaScopedIntrospectionQuery` remains available for
63
+ callers that only need the SQL.
64
+
65
+ Database clients use the normal `@dataplan/pg` checkout lifecycle and return
66
+ to the pool after each query. Applications remain responsible for calling
67
+ `PgService.release()` during final shutdown.
68
+
69
+ ---
70
+
71
+ ## Education and Tutorials
72
+
73
+ 1. 🚀 [Quickstart: Getting Up and Running](https://constructive.io/learn/quickstart)
74
+ Get started with modular databases in minutes. Install prerequisites and deploy your first module.
75
+
76
+ 2. 📦 [Modular PostgreSQL Development with Database Packages](https://constructive.io/learn/modular-postgres)
77
+ Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.
78
+
79
+ 3. ✏️ [Authoring Database Changes](https://constructive.io/learn/authoring-database-changes)
80
+ Master the workflow for adding, organizing, and managing database changes with pgpm.
81
+
82
+ 4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://constructive.io/learn/e2e-postgres-testing)
83
+ Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
84
+
85
+ 5. ⚡ [Supabase Testing](https://constructive.io/learn/supabase)
86
+ Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.
87
+
88
+ 6. 💧 [Drizzle ORM Testing](https://constructive.io/learn/drizzle-testing)
89
+ Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.
90
+
91
+ 7. 🔧 [Troubleshooting](https://constructive.io/learn/troubleshooting)
92
+ Common issues and solutions for pgpm, PostgreSQL, and testing.
93
+
94
+ ## Related Constructive Tooling
95
+
96
+ ### 📦 Package Management
97
+
98
+ * [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
99
+
100
+ ### 🧪 Testing
101
+
102
+ * [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
103
+ * [pglite-test](https://github.com/constructive-io/constructive/tree/main/postgres/pglite-test): **🪶 Drop-in pgsql-test replacement backed by PGlite** — in-process Postgres, no server required, instance-per-suite isolation.
104
+ * [pgsql-seed](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-seed): **🌱 PostgreSQL seeding utilities** for CSV, JSON, SQL data loading, and pgpm deployment.
105
+ * [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
106
+ * [graphile-test](https://github.com/constructive-io/constructive/tree/main/graphile/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
107
+ * [pg-query-context](https://github.com/constructive-io/constructive/tree/main/postgres/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
108
+
109
+ ### 🧠 Parsing & AST
110
+
111
+ * [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
112
+ * [libpg-query-node](https://www.npmjs.com/package/libpg-query): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
113
+ * [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
114
+ * [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
115
+ * [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
116
+ * [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
117
+
118
+ ### 📚 Documentation & Skills
119
+
120
+ * [constructive-skills](https://github.com/constructive-io/constructive-skills): **📖 Platform documentation and AI agent skills** — feature catalog, blueprint reference, SDK guides (i18n, billing, limits, events, uploads, security, entities, search, AI), and deployment guides.
121
+
122
+ Install skills for AI coding agents:
123
+
124
+ ```bash
125
+ # All platform skills (security, blueprints, codegen, billing, etc.)
126
+ npx skills add constructive-io/constructive-skills
127
+
128
+ # Individual repo skills (pgpm, testing, CLI, search, etc.)
129
+ npx skills add https://github.com/constructive-io/constructive --skill pgpm
130
+ npx skills add https://github.com/constructive-io/constructive --skill constructive-testing
131
+ ```
132
+
133
+ ## Credits
134
+
135
+ **🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
136
+
137
+ ## Disclaimer
138
+
139
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
140
+
141
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
package/esm/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export type { PgScopedIntrospectionConfig, PgScopedIntrospectionServiceConfig, SchemaScopedIntrospectionOptions, ScopedCatalogTypes, } from './plugin';
2
+ export { ConstructivePgIntrospectionPlugin, ScopedIntrospectionPreset, scopedIntrospectionUpstreamContract, } from './plugin';
3
+ export type { SchemaScopedIntrospectionPlan, SchemaScopedIntrospectionQuery, SchemaScopedIntrospectionScope, } from './scoped-introspection-query';
4
+ export { makeSchemaScopedIntrospectionPlan, makeSchemaScopedIntrospectionQuery, validateSchemaScopedIntrospection, } from './scoped-introspection-query';
package/esm/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { ConstructivePgIntrospectionPlugin, ScopedIntrospectionPreset, scopedIntrospectionUpstreamContract, } from './plugin';
2
+ export { makeSchemaScopedIntrospectionPlan, makeSchemaScopedIntrospectionQuery, validateSchemaScopedIntrospection, } from './scoped-introspection-query';
@@ -0,0 +1,21 @@
1
+ import 'graphile-build';
2
+ import type { GraphileConfig } from 'graphile-config';
3
+ export type { PgScopedIntrospectionConfig, PgScopedIntrospectionServiceConfig, SchemaScopedIntrospectionOptions, ScopedCatalogTypes, } from '@constructive-io/graphql-types';
4
+ /**
5
+ * CNC-owned atomic replacement for graphile-build-pg's introspection plugin.
6
+ * Stock-only configurations delegate to the upstream helper unchanged.
7
+ */
8
+ export declare const ConstructivePgIntrospectionPlugin: GraphileConfig.Plugin;
9
+ /** Disable upstream atomically before installing the CNC replacement. */
10
+ export declare const ScopedIntrospectionPreset: GraphileConfig.Preset;
11
+ export declare const scopedIntrospectionUpstreamContract: Readonly<{
12
+ package: "graphile-build-pg";
13
+ version: "5.1.3";
14
+ pluginName: keyof GraphileConfig.Plugins;
15
+ namespace: keyof GraphileConfig.GatherHelpers;
16
+ hasInitialCache: boolean;
17
+ hasInitialState: boolean;
18
+ hasWatch: boolean;
19
+ helperNames: string[];
20
+ hookNames: string[];
21
+ }>;
package/esm/plugin.js ADDED
@@ -0,0 +1,212 @@
1
+ import 'graphile-build';
2
+ import { withPgClientFromPgService } from '@dataplan/pg';
3
+ import { PgIntrospectionPlugin, version as graphileBuildPgVersion, } from 'graphile-build-pg';
4
+ import { makeIntrospectionQuery, parseIntrospectionResults, } from 'pg-introspection';
5
+ import { makeSchemaScopedIntrospectionPlan, validateSchemaScopedIntrospection, } from './scoped-introspection-query';
6
+ const upstreamGather = PgIntrospectionPlugin.gather;
7
+ const upstreamHelpers = upstreamGather?.helpers;
8
+ const upstreamGetIntrospection = upstreamHelpers?.getIntrospection;
9
+ const SUPPORTED_GRAPHILE_BUILD_PG_VERSION = '5.1.3';
10
+ if (graphileBuildPgVersion !== SUPPORTED_GRAPHILE_BUILD_PG_VERSION) {
11
+ throw new Error(`Unsupported graphile-build-pg introspection contract: expected ${SUPPORTED_GRAPHILE_BUILD_PG_VERSION}, received ${graphileBuildPgVersion}`);
12
+ }
13
+ if (!upstreamGather || !upstreamHelpers || !upstreamGetIntrospection) {
14
+ throw new Error('graphile-build-pg PgIntrospectionPlugin no longer exposes the expected gather contract');
15
+ }
16
+ function getIntrospectionQuery(pgService, config) {
17
+ if (config === undefined || config === false) {
18
+ return {
19
+ query: { text: makeIntrospectionQuery() },
20
+ scopedPlan: null,
21
+ };
22
+ }
23
+ const options = config === true ? {} : config;
24
+ const scopedPlan = makeSchemaScopedIntrospectionPlan(pgService.schemas ?? [], options);
25
+ return {
26
+ query: scopedPlan.query,
27
+ scopedPlan,
28
+ };
29
+ }
30
+ function assertScopedIntrospectionServices(pgServices, options) {
31
+ if (options === undefined)
32
+ return;
33
+ if (options === null ||
34
+ typeof options !== 'object' ||
35
+ Array.isArray(options)) {
36
+ throw new Error('pgScopedIntrospection must be an object keyed by PostgreSQL service name');
37
+ }
38
+ const serviceNames = new Set((pgServices ?? []).map((pgService) => pgService.name));
39
+ const unknownServiceNames = Object.keys(options).filter((serviceName) => !serviceNames.has(serviceName));
40
+ if (unknownServiceNames.length > 0) {
41
+ throw new Error(`Schema-scoped introspection configured for unknown PostgreSQL service(s): ${unknownServiceNames.join(', ')}`);
42
+ }
43
+ for (const [serviceName, config] of Object.entries(options)) {
44
+ if (config !== true &&
45
+ config !== false &&
46
+ (config === null ||
47
+ typeof config !== 'object' ||
48
+ Array.isArray(config))) {
49
+ throw new Error(`Schema-scoped introspection configuration for service '${serviceName}' must be true, false, or an options object`);
50
+ }
51
+ }
52
+ }
53
+ // Adapted from graphile-build-pg@5.1.3
54
+ // dist/plugins/PgIntrospectionPlugin.js. The upstream function is private, so
55
+ // mixed/scoped services must retain this service validation/query seam locally.
56
+ async function introspectPgServices(pgServices, scopedIntrospection) {
57
+ assertScopedIntrospectionServices(pgServices, scopedIntrospection);
58
+ if (!pgServices)
59
+ return [];
60
+ const seenNames = new Map();
61
+ const seenPgSettingsKeys = new Map();
62
+ const seenWithPgClientKeys = new Map();
63
+ return Promise.all(pgServices.map(async (pgService, i) => {
64
+ const { name, pgSettingsKey, withPgClientKey } = pgService;
65
+ if (!name)
66
+ throw new Error(`pgServices[${i}] has no name`);
67
+ if (!withPgClientKey) {
68
+ throw new Error(`pgServices[${i}] has no withPgClientKey`);
69
+ }
70
+ const duplicateName = seenNames.get(name);
71
+ if (duplicateName !== undefined) {
72
+ throw new Error(`pgServices[${i}] has the same name as pgServices[${duplicateName}] (${JSON.stringify(name)})`);
73
+ }
74
+ seenNames.set(name, i);
75
+ const duplicateClientKey = seenWithPgClientKeys.get(withPgClientKey);
76
+ if (duplicateClientKey !== undefined) {
77
+ throw new Error(`pgServices[${i}] has the same withPgClientKey as pgServices[${duplicateClientKey}] (${JSON.stringify(withPgClientKey)})`);
78
+ }
79
+ seenWithPgClientKeys.set(withPgClientKey, i);
80
+ if (pgSettingsKey) {
81
+ const duplicateSettingsKey = seenPgSettingsKeys.get(pgSettingsKey);
82
+ if (duplicateSettingsKey !== undefined) {
83
+ throw new Error(`pgServices[${i}] has the same pgSettingsKey as pgServices[${duplicateSettingsKey}] (${JSON.stringify(pgSettingsKey)})`);
84
+ }
85
+ seenPgSettingsKeys.set(pgSettingsKey, i);
86
+ }
87
+ const { query, scopedPlan } = getIntrospectionQuery(pgService, scopedIntrospection?.[name]);
88
+ const result = await withPgClientFromPgService(pgService, pgService.pgSettingsForIntrospection ?? null, (client) => client.query(query));
89
+ const [row] = result.rows;
90
+ if (!row)
91
+ throw new Error('Introspection failed');
92
+ return {
93
+ pgService,
94
+ introspectionText: row.introspection,
95
+ scopedPlan,
96
+ };
97
+ }));
98
+ }
99
+ async function announceIntrospection(info, introspections) {
100
+ await Promise.all(introspections.map(async ({ introspection, pgService }) => {
101
+ const announce = async (eventName, entities) => {
102
+ await Promise.all(entities.map((entity) => info.process(eventName, { entity, serviceName: pgService.name })));
103
+ };
104
+ await info.process('pgIntrospection_introspection', {
105
+ introspection,
106
+ serviceName: pgService.name,
107
+ });
108
+ await announce('pgIntrospection_namespace', introspection.namespaces);
109
+ await announce('pgIntrospection_class', introspection.classes);
110
+ await announce('pgIntrospection_attribute', introspection.attributes);
111
+ await announce('pgIntrospection_constraint', introspection.constraints);
112
+ await announce('pgIntrospection_proc', introspection.procs);
113
+ await announce('pgIntrospection_role', introspection.roles);
114
+ await announce('pgIntrospection_auth_member', introspection.auth_members);
115
+ await announce('pgIntrospection_type', introspection.types);
116
+ await announce('pgIntrospection_enum', introspection.enums);
117
+ await announce('pgIntrospection_extension', introspection.extensions);
118
+ await announce('pgIntrospection_index', introspection.indexes);
119
+ await announce('pgIntrospection_language', introspection.languages);
120
+ await announce('pgIntrospection_range', introspection.ranges);
121
+ await announce('pgIntrospection_depend', introspection.depends);
122
+ await announce('pgIntrospection_description', introspection.descriptions);
123
+ }));
124
+ }
125
+ // Adapted from graphile-build-pg@5.1.3
126
+ // dist/plugins/PgIntrospectionPlugin.js. Upstream does not expose its
127
+ // cache/parse/announcement flow independently from the stock query.
128
+ function getConstructiveIntrospection(info) {
129
+ const pgServices = info.resolvedPreset.pgServices ?? [];
130
+ const scopedIntrospection = info.options.pgScopedIntrospection;
131
+ assertScopedIntrospectionServices(pgServices, scopedIntrospection);
132
+ const hasScopedService = Object.values(scopedIntrospection ?? {}).some((config) => config === true || (config !== false && config !== undefined));
133
+ if (!hasScopedService) {
134
+ return upstreamGetIntrospection(info);
135
+ }
136
+ return (info.state.getIntrospectionPromise ??
137
+ (info.state.getIntrospectionPromise = (async () => {
138
+ if (info.cache.dirty) {
139
+ info.cache.introspectionResultsPromise = null;
140
+ info.cache.dirty = false;
141
+ }
142
+ const introspectionPromise = info.cache.introspectionResultsPromise ??
143
+ (info.cache.introspectionResultsPromise =
144
+ introspectPgServices(pgServices, scopedIntrospection));
145
+ introspectionPromise.then(null, () => {
146
+ info.cache.introspectionResultsPromise = null;
147
+ });
148
+ const rawIntrospections = await introspectionPromise;
149
+ // Keep the raw result promise for clean gathers. Parsed introspection is
150
+ // intentionally rebuilt because gather plugins may mutate their copy.
151
+ const introspections = rawIntrospections.map(({ pgService, introspectionText, scopedPlan }) => {
152
+ const introspection = parseIntrospectionResults(introspectionText);
153
+ if (scopedPlan) {
154
+ try {
155
+ validateSchemaScopedIntrospection(introspection, scopedPlan);
156
+ }
157
+ catch (error) {
158
+ const message = error instanceof Error ? error.message : String(error);
159
+ throw new Error(`Schema-scoped introspection validation failed for PostgreSQL service '${pgService.name}': ${message}`, { cause: error });
160
+ }
161
+ }
162
+ return { pgService, introspection };
163
+ });
164
+ // Announcements may call back into getIntrospection, so expose the
165
+ // resolved gather-local value before broadcasting entities.
166
+ info.state.getIntrospectionPromise = introspections;
167
+ await announceIntrospection(info, introspections);
168
+ return introspections;
169
+ })()));
170
+ }
171
+ async function getRangeByType(info, serviceName, typeId) {
172
+ const introspections = await info.helpers.pgIntrospection.getIntrospection();
173
+ const relevant = introspections.find((result) => result.pgService.name === serviceName);
174
+ if (!relevant)
175
+ throw new Error(`Could not find database '${serviceName}'`);
176
+ return relevant.introspection.ranges.find((range) => range.rngtypid === typeId || range.rngmultitypid === typeId);
177
+ }
178
+ /**
179
+ * CNC-owned atomic replacement for graphile-build-pg's introspection plugin.
180
+ * Stock-only configurations delegate to the upstream helper unchanged.
181
+ */
182
+ export const ConstructivePgIntrospectionPlugin = {
183
+ name: 'ConstructivePgIntrospectionPlugin',
184
+ description: 'Adds opt-in schema-scoped PostgreSQL introspection for Constructive',
185
+ version: PgIntrospectionPlugin.version,
186
+ provides: ['PgIntrospectionPlugin'],
187
+ before: ['PgRegistryPlugin'],
188
+ gather: {
189
+ ...upstreamGather,
190
+ helpers: {
191
+ ...upstreamHelpers,
192
+ getIntrospection: getConstructiveIntrospection,
193
+ getRangeByType,
194
+ },
195
+ },
196
+ };
197
+ /** Disable upstream atomically before installing the CNC replacement. */
198
+ export const ScopedIntrospectionPreset = {
199
+ disablePlugins: ['PgIntrospectionPlugin'],
200
+ plugins: [ConstructivePgIntrospectionPlugin],
201
+ };
202
+ export const scopedIntrospectionUpstreamContract = Object.freeze({
203
+ package: 'graphile-build-pg',
204
+ version: SUPPORTED_GRAPHILE_BUILD_PG_VERSION,
205
+ pluginName: PgIntrospectionPlugin.name,
206
+ namespace: upstreamGather.namespace,
207
+ hasInitialCache: typeof upstreamGather.initialCache === 'function',
208
+ hasInitialState: typeof upstreamGather.initialState === 'function',
209
+ hasWatch: typeof upstreamGather.watch === 'function',
210
+ helperNames: Object.keys(upstreamHelpers).sort(),
211
+ hookNames: Object.keys(upstreamGather.hooks ?? {}).sort(),
212
+ });
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Scoped catalog SQL adapted from Graphile Crystal's
3
+ * utils/pg-introspection/src/scopedIntrospection.ts at commit
4
+ * 441cef73b0a12ed24343b7f38241af28b6454280, which is MIT licensed
5
+ * (Copyright © 2023 Benjie Gillam). This is a static, CNC-owned query
6
+ * generator: it does not inspect or rewrite the upstream query at runtime.
7
+ */
8
+ import type { SchemaScopedIntrospectionOptions, ScopedCatalogTypes } from '@constructive-io/graphql-types';
9
+ import type { Introspection } from 'pg-introspection';
10
+ export type { SchemaScopedIntrospectionOptions, ScopedCatalogTypes, } from '@constructive-io/graphql-types';
11
+ export interface SchemaScopedIntrospectionQuery {
12
+ text: string;
13
+ values: [string[], string[]];
14
+ }
15
+ export interface SchemaScopedIntrospectionScope {
16
+ schemas: readonly string[];
17
+ catalogTypes: ScopedCatalogTypes;
18
+ capabilityExtensions: readonly string[];
19
+ }
20
+ export interface SchemaScopedIntrospectionPlan {
21
+ query: SchemaScopedIntrospectionQuery;
22
+ scope: SchemaScopedIntrospectionScope;
23
+ }
24
+ /**
25
+ * Builds a parameterized introspection plan scoped to the requested schemas
26
+ * and the transitive object dependencies required by their objects.
27
+ */
28
+ export declare const makeSchemaScopedIntrospectionPlan: (schemas: readonly string[], options?: SchemaScopedIntrospectionOptions) => SchemaScopedIntrospectionPlan;
29
+ /**
30
+ * Builds only the query portion of a schema-scoped introspection plan.
31
+ *
32
+ * Prefer `makeSchemaScopedIntrospectionPlan()` when the results will be
33
+ * parsed and validated by this package.
34
+ */
35
+ export declare const makeSchemaScopedIntrospectionQuery: (schemas: readonly string[], options?: SchemaScopedIntrospectionOptions) => SchemaScopedIntrospectionQuery;
36
+ /** Validates that an introspection result satisfies its scoped query plan. */
37
+ export declare function validateSchemaScopedIntrospection(introspection: Introspection, plan: SchemaScopedIntrospectionPlan): void;