@constructive-io/graphql-codegen 5.3.1 → 5.4.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/core/introspect/source/api-schemas.d.ts +4 -4
- package/core/introspect/source/api-schemas.js +12 -12
- package/core/introspect/source/database.d.ts +1 -1
- package/core/introspect/source/pgpm-module.d.ts +2 -2
- package/esm/core/introspect/source/api-schemas.d.ts +4 -4
- package/esm/core/introspect/source/api-schemas.js +12 -12
- package/esm/core/introspect/source/database.d.ts +1 -1
- package/esm/core/introspect/source/pgpm-module.d.ts +2 -2
- package/esm/types/config.d.ts +1 -1
- package/package.json +2 -2
- package/types/config.d.ts +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* API Schemas Resolution
|
|
3
3
|
*
|
|
4
4
|
* Utilities for resolving PostgreSQL schema names from API names
|
|
5
|
-
* by querying the
|
|
5
|
+
* by querying the routing_public.api_schemas table.
|
|
6
6
|
*/
|
|
7
7
|
import { Pool } from 'pg';
|
|
8
8
|
/**
|
|
@@ -16,7 +16,7 @@ export interface RoutingSchemaValidation {
|
|
|
16
16
|
* Validate that the required routing schemas exist in the database
|
|
17
17
|
*
|
|
18
18
|
* Checks for:
|
|
19
|
-
* -
|
|
19
|
+
* - routing_public schema with apis and api_schemas tables
|
|
20
20
|
* - metaschema_public schema with schema table
|
|
21
21
|
*
|
|
22
22
|
* @param pool - Database connection pool
|
|
@@ -24,9 +24,9 @@ export interface RoutingSchemaValidation {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function validateRoutingSchemas(pool: Pool): Promise<RoutingSchemaValidation>;
|
|
26
26
|
/**
|
|
27
|
-
* Resolve schema names from API names by querying
|
|
27
|
+
* Resolve schema names from API names by querying routing_public.api_schemas
|
|
28
28
|
*
|
|
29
|
-
* Joins
|
|
29
|
+
* Joins routing_public.apis, routing_public.api_schemas, and metaschema_public.schema
|
|
30
30
|
* to get the actual PostgreSQL schema names for the given API names.
|
|
31
31
|
*
|
|
32
32
|
* @param pool - Database connection pool
|
|
@@ -9,7 +9,7 @@ const pg_env_1 = require("pg-env");
|
|
|
9
9
|
* Validate that the required routing schemas exist in the database
|
|
10
10
|
*
|
|
11
11
|
* Checks for:
|
|
12
|
-
* -
|
|
12
|
+
* - routing_public schema with apis and api_schemas tables
|
|
13
13
|
* - metaschema_public schema with schema table
|
|
14
14
|
*
|
|
15
15
|
* @param pool - Database connection pool
|
|
@@ -17,28 +17,28 @@ const pg_env_1 = require("pg-env");
|
|
|
17
17
|
*/
|
|
18
18
|
async function validateRoutingSchemas(pool) {
|
|
19
19
|
try {
|
|
20
|
-
// Check for
|
|
20
|
+
// Check for routing_public.apis table
|
|
21
21
|
const apisCheck = await pool.query(`
|
|
22
22
|
SELECT 1 FROM information_schema.tables
|
|
23
|
-
WHERE table_schema = '
|
|
23
|
+
WHERE table_schema = 'routing_public'
|
|
24
24
|
AND table_name = 'apis'
|
|
25
25
|
`);
|
|
26
26
|
if (apisCheck.rows.length === 0) {
|
|
27
27
|
return {
|
|
28
28
|
valid: false,
|
|
29
|
-
error: '
|
|
29
|
+
error: 'routing_public.apis table not found. The database must have the routing schema deployed.',
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
// Check for
|
|
32
|
+
// Check for routing_public.api_schemas table
|
|
33
33
|
const apiSchemasCheck = await pool.query(`
|
|
34
34
|
SELECT 1 FROM information_schema.tables
|
|
35
|
-
WHERE table_schema = '
|
|
35
|
+
WHERE table_schema = 'routing_public'
|
|
36
36
|
AND table_name = 'api_schemas'
|
|
37
37
|
`);
|
|
38
38
|
if (apiSchemasCheck.rows.length === 0) {
|
|
39
39
|
return {
|
|
40
40
|
valid: false,
|
|
41
|
-
error: '
|
|
41
|
+
error: 'routing_public.api_schemas table not found. The database must have the routing schema deployed.',
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
// Check for metaschema_public.schema table
|
|
@@ -63,9 +63,9 @@ async function validateRoutingSchemas(pool) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Resolve schema names from API names by querying
|
|
66
|
+
* Resolve schema names from API names by querying routing_public.api_schemas
|
|
67
67
|
*
|
|
68
|
-
* Joins
|
|
68
|
+
* Joins routing_public.apis, routing_public.api_schemas, and metaschema_public.schema
|
|
69
69
|
* to get the actual PostgreSQL schema names for the given API names.
|
|
70
70
|
*
|
|
71
71
|
* @param pool - Database connection pool
|
|
@@ -82,15 +82,15 @@ async function resolveApiSchemas(pool, apiNames) {
|
|
|
82
82
|
// Query to get schema names for the given API names
|
|
83
83
|
const result = await pool.query(`
|
|
84
84
|
SELECT DISTINCT ms.schema_name
|
|
85
|
-
FROM
|
|
86
|
-
JOIN
|
|
85
|
+
FROM routing_public.api_schemas as_tbl
|
|
86
|
+
JOIN routing_public.apis api ON api.id = as_tbl.api_id
|
|
87
87
|
JOIN metaschema_public.schema ms ON ms.id = as_tbl.schema_id
|
|
88
88
|
WHERE api.name = ANY($1)
|
|
89
89
|
ORDER BY ms.schema_name
|
|
90
90
|
`, [apiNames]);
|
|
91
91
|
if (result.rows.length === 0) {
|
|
92
92
|
throw new Error(`No schemas found for API names: ${apiNames.join(', ')}. ` +
|
|
93
|
-
'Ensure the APIs exist and have schemas assigned in
|
|
93
|
+
'Ensure the APIs exist and have schemas assigned in routing_public.api_schemas.');
|
|
94
94
|
}
|
|
95
95
|
return result.rows.map((row) => row.schema_name);
|
|
96
96
|
}
|
|
@@ -13,7 +13,7 @@ export interface DatabaseSchemaSourceOptions {
|
|
|
13
13
|
schemas?: string[];
|
|
14
14
|
/**
|
|
15
15
|
* API names to resolve schemas from
|
|
16
|
-
* Queries
|
|
16
|
+
* Queries routing_public.api_schemas to get schema names
|
|
17
17
|
* Mutually exclusive with schemas
|
|
18
18
|
*/
|
|
19
19
|
apiNames?: string[];
|
|
@@ -15,7 +15,7 @@ export interface PgpmModulePathOptions {
|
|
|
15
15
|
schemas?: string[];
|
|
16
16
|
/**
|
|
17
17
|
* API names to resolve schemas from
|
|
18
|
-
* Queries
|
|
18
|
+
* Queries routing_public.api_schemas to get schema names
|
|
19
19
|
* Mutually exclusive with schemas
|
|
20
20
|
*/
|
|
21
21
|
apiNames?: string[];
|
|
@@ -45,7 +45,7 @@ export interface PgpmWorkspaceOptions {
|
|
|
45
45
|
schemas?: string[];
|
|
46
46
|
/**
|
|
47
47
|
* API names to resolve schemas from
|
|
48
|
-
* Queries
|
|
48
|
+
* Queries routing_public.api_schemas to get schema names
|
|
49
49
|
* Mutually exclusive with schemas
|
|
50
50
|
*/
|
|
51
51
|
apiNames?: string[];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* API Schemas Resolution
|
|
3
3
|
*
|
|
4
4
|
* Utilities for resolving PostgreSQL schema names from API names
|
|
5
|
-
* by querying the
|
|
5
|
+
* by querying the routing_public.api_schemas table.
|
|
6
6
|
*/
|
|
7
7
|
import { Pool } from 'pg';
|
|
8
8
|
/**
|
|
@@ -16,7 +16,7 @@ export interface RoutingSchemaValidation {
|
|
|
16
16
|
* Validate that the required routing schemas exist in the database
|
|
17
17
|
*
|
|
18
18
|
* Checks for:
|
|
19
|
-
* -
|
|
19
|
+
* - routing_public schema with apis and api_schemas tables
|
|
20
20
|
* - metaschema_public schema with schema table
|
|
21
21
|
*
|
|
22
22
|
* @param pool - Database connection pool
|
|
@@ -24,9 +24,9 @@ export interface RoutingSchemaValidation {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function validateRoutingSchemas(pool: Pool): Promise<RoutingSchemaValidation>;
|
|
26
26
|
/**
|
|
27
|
-
* Resolve schema names from API names by querying
|
|
27
|
+
* Resolve schema names from API names by querying routing_public.api_schemas
|
|
28
28
|
*
|
|
29
|
-
* Joins
|
|
29
|
+
* Joins routing_public.apis, routing_public.api_schemas, and metaschema_public.schema
|
|
30
30
|
* to get the actual PostgreSQL schema names for the given API names.
|
|
31
31
|
*
|
|
32
32
|
* @param pool - Database connection pool
|
|
@@ -4,7 +4,7 @@ import { getPgEnvOptions } from 'pg-env';
|
|
|
4
4
|
* Validate that the required routing schemas exist in the database
|
|
5
5
|
*
|
|
6
6
|
* Checks for:
|
|
7
|
-
* -
|
|
7
|
+
* - routing_public schema with apis and api_schemas tables
|
|
8
8
|
* - metaschema_public schema with schema table
|
|
9
9
|
*
|
|
10
10
|
* @param pool - Database connection pool
|
|
@@ -12,28 +12,28 @@ import { getPgEnvOptions } from 'pg-env';
|
|
|
12
12
|
*/
|
|
13
13
|
export async function validateRoutingSchemas(pool) {
|
|
14
14
|
try {
|
|
15
|
-
// Check for
|
|
15
|
+
// Check for routing_public.apis table
|
|
16
16
|
const apisCheck = await pool.query(`
|
|
17
17
|
SELECT 1 FROM information_schema.tables
|
|
18
|
-
WHERE table_schema = '
|
|
18
|
+
WHERE table_schema = 'routing_public'
|
|
19
19
|
AND table_name = 'apis'
|
|
20
20
|
`);
|
|
21
21
|
if (apisCheck.rows.length === 0) {
|
|
22
22
|
return {
|
|
23
23
|
valid: false,
|
|
24
|
-
error: '
|
|
24
|
+
error: 'routing_public.apis table not found. The database must have the routing schema deployed.',
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
// Check for
|
|
27
|
+
// Check for routing_public.api_schemas table
|
|
28
28
|
const apiSchemasCheck = await pool.query(`
|
|
29
29
|
SELECT 1 FROM information_schema.tables
|
|
30
|
-
WHERE table_schema = '
|
|
30
|
+
WHERE table_schema = 'routing_public'
|
|
31
31
|
AND table_name = 'api_schemas'
|
|
32
32
|
`);
|
|
33
33
|
if (apiSchemasCheck.rows.length === 0) {
|
|
34
34
|
return {
|
|
35
35
|
valid: false,
|
|
36
|
-
error: '
|
|
36
|
+
error: 'routing_public.api_schemas table not found. The database must have the routing schema deployed.',
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
// Check for metaschema_public.schema table
|
|
@@ -58,9 +58,9 @@ export async function validateRoutingSchemas(pool) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Resolve schema names from API names by querying
|
|
61
|
+
* Resolve schema names from API names by querying routing_public.api_schemas
|
|
62
62
|
*
|
|
63
|
-
* Joins
|
|
63
|
+
* Joins routing_public.apis, routing_public.api_schemas, and metaschema_public.schema
|
|
64
64
|
* to get the actual PostgreSQL schema names for the given API names.
|
|
65
65
|
*
|
|
66
66
|
* @param pool - Database connection pool
|
|
@@ -77,15 +77,15 @@ export async function resolveApiSchemas(pool, apiNames) {
|
|
|
77
77
|
// Query to get schema names for the given API names
|
|
78
78
|
const result = await pool.query(`
|
|
79
79
|
SELECT DISTINCT ms.schema_name
|
|
80
|
-
FROM
|
|
81
|
-
JOIN
|
|
80
|
+
FROM routing_public.api_schemas as_tbl
|
|
81
|
+
JOIN routing_public.apis api ON api.id = as_tbl.api_id
|
|
82
82
|
JOIN metaschema_public.schema ms ON ms.id = as_tbl.schema_id
|
|
83
83
|
WHERE api.name = ANY($1)
|
|
84
84
|
ORDER BY ms.schema_name
|
|
85
85
|
`, [apiNames]);
|
|
86
86
|
if (result.rows.length === 0) {
|
|
87
87
|
throw new Error(`No schemas found for API names: ${apiNames.join(', ')}. ` +
|
|
88
|
-
'Ensure the APIs exist and have schemas assigned in
|
|
88
|
+
'Ensure the APIs exist and have schemas assigned in routing_public.api_schemas.');
|
|
89
89
|
}
|
|
90
90
|
return result.rows.map((row) => row.schema_name);
|
|
91
91
|
}
|
|
@@ -13,7 +13,7 @@ export interface DatabaseSchemaSourceOptions {
|
|
|
13
13
|
schemas?: string[];
|
|
14
14
|
/**
|
|
15
15
|
* API names to resolve schemas from
|
|
16
|
-
* Queries
|
|
16
|
+
* Queries routing_public.api_schemas to get schema names
|
|
17
17
|
* Mutually exclusive with schemas
|
|
18
18
|
*/
|
|
19
19
|
apiNames?: string[];
|
|
@@ -15,7 +15,7 @@ export interface PgpmModulePathOptions {
|
|
|
15
15
|
schemas?: string[];
|
|
16
16
|
/**
|
|
17
17
|
* API names to resolve schemas from
|
|
18
|
-
* Queries
|
|
18
|
+
* Queries routing_public.api_schemas to get schema names
|
|
19
19
|
* Mutually exclusive with schemas
|
|
20
20
|
*/
|
|
21
21
|
apiNames?: string[];
|
|
@@ -45,7 +45,7 @@ export interface PgpmWorkspaceOptions {
|
|
|
45
45
|
schemas?: string[];
|
|
46
46
|
/**
|
|
47
47
|
* API names to resolve schemas from
|
|
48
|
-
* Queries
|
|
48
|
+
* Queries routing_public.api_schemas to get schema names
|
|
49
49
|
* Mutually exclusive with schemas
|
|
50
50
|
*/
|
|
51
51
|
apiNames?: string[];
|
package/esm/types/config.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface DbConfig {
|
|
|
100
100
|
schemas?: string[];
|
|
101
101
|
/**
|
|
102
102
|
* API names to resolve schemas from
|
|
103
|
-
* Queries
|
|
103
|
+
* Queries routing_public.api_schemas to automatically determine schemas
|
|
104
104
|
* Mutually exclusive with `schemas`
|
|
105
105
|
* @example ['my_api']
|
|
106
106
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"tsx": "^4.21.0",
|
|
102
102
|
"typescript": "^5.9.3"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "763dcb96747f941fbf0cd5e5f733f19da286fc23"
|
|
105
105
|
}
|
package/types/config.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface DbConfig {
|
|
|
100
100
|
schemas?: string[];
|
|
101
101
|
/**
|
|
102
102
|
* API names to resolve schemas from
|
|
103
|
-
* Queries
|
|
103
|
+
* Queries routing_public.api_schemas to automatically determine schemas
|
|
104
104
|
* Mutually exclusive with `schemas`
|
|
105
105
|
* @example ['my_api']
|
|
106
106
|
*/
|