introspeql 1.0.0 → 1.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.
Files changed (51) hide show
  1. package/README.md +88 -59
  2. package/dist/config/create-relation-options.d.ts +22 -0
  3. package/dist/config/create-relation-options.js +60 -0
  4. package/dist/config/index.d.ts +52 -0
  5. package/dist/config/index.js +14 -0
  6. package/dist/config/materialized-view-options.d.ts +24 -0
  7. package/dist/config/materialized-view-options.js +5 -0
  8. package/dist/config/table-options.d.ts +21 -18
  9. package/dist/config/table-options.js +2 -45
  10. package/dist/config/view-options.d.ts +24 -0
  11. package/dist/config/view-options.js +5 -0
  12. package/dist/introspeql.js +6 -6
  13. package/dist/relations/abstract-relation-definition.d.ts +11 -0
  14. package/dist/{tables/table-definition.js → relations/abstract-relation-definition.js} +11 -11
  15. package/dist/relations/index.d.ts +11 -0
  16. package/dist/{tables → relations}/index.js +6 -3
  17. package/dist/relations/materialized-view-definition.d.ts +4 -0
  18. package/dist/relations/materialized-view-definition.js +29 -0
  19. package/dist/relations/read-relation-data.d.ts +4 -0
  20. package/dist/{tables/read-table-data.js → relations/read-relation-data.js} +12 -9
  21. package/dist/{tables/table-data.d.ts → relations/relation-data.d.ts} +2 -2
  22. package/dist/{tables/table-data.js → relations/relation-data.js} +2 -2
  23. package/dist/{tables/should-include-table.d.ts → relations/should-include-relation.d.ts} +2 -2
  24. package/dist/{tables/should-include-table.js → relations/should-include-relation.js} +2 -2
  25. package/dist/relations/table-definition.d.ts +4 -0
  26. package/dist/relations/table-definition.js +29 -0
  27. package/dist/relations/view-definition.d.ts +4 -0
  28. package/dist/relations/view-definition.js +29 -0
  29. package/dist/schemas/read-schema-data.d.ts +5 -3
  30. package/dist/schemas/read-schema-data.js +103 -66
  31. package/dist/schemas/schema-definition-factory.d.ts +2 -2
  32. package/dist/schemas/schema-definition-factory.js +30 -20
  33. package/dist/schemas/schema-definition.d.ts +4 -2
  34. package/dist/schemas/schema-definition.js +15 -1
  35. package/dist/shared/capitalize.d.ts +1 -0
  36. package/dist/shared/capitalize.js +6 -0
  37. package/dist/shared/convert-pg-identifier-to-ts-identifier.js +2 -4
  38. package/dist/shared/index.d.ts +1 -0
  39. package/dist/shared/index.js +1 -0
  40. package/package.json +2 -2
  41. package/dist/tables/index.d.ts +0 -8
  42. package/dist/tables/read-table-data.d.ts +0 -4
  43. package/dist/tables/table-definition.d.ts +0 -10
  44. /package/dist/{tables → relations}/column-data.d.ts +0 -0
  45. /package/dist/{tables → relations}/column-data.js +0 -0
  46. /package/dist/{tables → relations}/column-definition.d.ts +0 -0
  47. /package/dist/{tables → relations}/column-definition.js +0 -0
  48. /package/dist/{tables → relations}/column-type-definition.d.ts +0 -0
  49. /package/dist/{tables → relations}/column-type-definition.js +0 -0
  50. /package/dist/{tables → relations}/read-column-data.d.ts +0 -0
  51. /package/dist/{tables → relations}/read-column-data.js +0 -0
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # IntrospeQL
2
2
 
3
- IntrospeQL reads information about the schemas, tables, columns, functions, and
4
- enums in your PostgreSQL database and produces a TypeScript file detailing
5
- type information for each database object.
3
+ IntrospeQL reads information about the schemas, tables, views, materialized
4
+ views, columns, functions, and enums in your PostgreSQL database and produces a
5
+ TypeScript file detailing type information for each database object.
6
6
 
7
7
  ## Installation
8
8
 
@@ -32,7 +32,7 @@ Add the following entry to the scripts object in package.json:
32
32
  "gen-types": "npx tsx scripts/gen-types.ts"
33
33
  ```
34
34
 
35
- Create a scripts directory at the root level of your project, and inside this
35
+ Create a scripts directory at the root level of your project, and inside this
36
36
  folder, create a new TypeScript file called `gen-types.ts`.
37
37
 
38
38
  Add the following content to `scripts/gen-types.ts`:
@@ -55,7 +55,7 @@ const config: IntrospeQLConfig = {
55
55
  },
56
56
  writeToDisk: true,
57
57
  outFile: path.join(__dirname, '..' + outFile),
58
- header:
58
+ header:
59
59
  '/* This file has been generated by IntrospeQL and should not be edited directly. */',
60
60
  types: {
61
61
  'pg_catalog.void': 'void'
@@ -70,7 +70,7 @@ async function genTypes() {
70
70
  }
71
71
  ```
72
72
 
73
- Create a `.gitignore` file at the root of your project and make sure it includes
73
+ Create a `.gitignore` file at the root of your project and make sure it includes
74
74
  `node_modules` and `.env`:
75
75
 
76
76
  ```
@@ -79,8 +79,9 @@ node_modules/
79
79
  .env
80
80
  ```
81
81
 
82
- Create a `.env` file at the root of your project and add your database connection
82
+ Create a `.env` file at the root of your project and add your database connection
83
83
  information:
84
+
84
85
  ```
85
86
  # .env
86
87
  DB_HOST= # Add your host here, often just localhost
@@ -99,33 +100,33 @@ npm run gen-types
99
100
  A type definition file will have been generated at `generated/type-definitions.ts`.
100
101
 
101
102
  > ⚠️ **Important**
102
- > Never hard code sensitive information directly into your project. Instead,
103
- > load such information from environment variables and ensure that .env files
103
+ > Never hard code sensitive information directly into your project. Instead,
104
+ > load such information from environment variables and ensure that .env files
104
105
  > are not committed to source control.
105
106
 
106
107
  ## Output
107
108
 
108
- The type definitions file consists of nested
109
- [namespaces](https://www.typescriptlang.org/docs/handbook/namespaces.html).
110
- Each top-level namespace represents a schema and contains the name of the schema
111
- as well as type definitions for its tables, functions, and enums, grouped by
112
- category into nested namespaces. Each table and function, in turn, consists of a
113
- namespace.
109
+ The type definitions file consists of nested
110
+ [namespaces](https://www.typescriptlang.org/docs/handbook/namespaces.html).
111
+ Each top-level namespace represents a schema and contains the name of the schema
112
+ as well as type definitions for its tables, views, materialized views,
113
+ functions, and enums, grouped by category into nested namespaces. Each table,
114
+ view, materialized view and function, in turn, consists of a namespace.
114
115
 
115
- Table namespaces contain the name of the table, a union of string literals
116
- representing the names of the columns of the table, and an object-type
117
- representing the structure of each row.
116
+ Relation (tables, views, and materialized views) namespaces contain the name of
117
+ the relation, a union of string literals representing the names of its columns,
118
+ and an object-type representing the structure of each of its rows.
118
119
 
119
- Function namespaces contain the name of the function and an array of overloads.
120
- Each overload contains an array of parameter types and (separately from the
120
+ Function namespaces contain the name of the function and an array of overloads.
121
+ Each overload contains an array of parameter types and (separately from the
121
122
  array of parameter types) the return type.
122
123
 
123
- Enums are represented as unions of string literals, with each string literal
124
+ Enums are represented as unions of string literals, with each string literal
124
125
  representing one possible value of the enum.
125
126
 
126
- A header can be added to the file. This is useful to import types that will be
127
- used later in the file. In the example, we simply added a comment to the top of
128
- the file indicating that the file was autogenerated and should not be changed
127
+ A header can be added to the file. This is useful to import types that will be
128
+ used later in the file. In the example, we simply added a comment to the top of
129
+ the file indicating that the file was autogenerated and should not be changed
129
130
  manually.
130
131
 
131
132
  ## Configuration
@@ -134,18 +135,20 @@ manually.
134
135
 
135
136
  The following options exist directly on the top-level configuration object.
136
137
 
137
- | Option | Type | Required | Default | Description |
138
- | -------------------- | ------------------------ | ----------- | ------------ | ----------------------------------------------------------------------------------------------- |
139
- | `schemas` | `string[]` | No | `['public']` | PostgreSQL schemas to introspect. At least one schema must be specified. |
140
- | `header` | `string` | No | — | Text inserted at the top of the generated output file (e.g., additional type imports or definitions). |
141
- | `types` | `Record<string, string>` | No | — | Custom PostgreSQL-to-TypeScript type mappings that override built-in defaults. These should be specified in the format `<schema>.<type>`, e.g. `'pg_catalog.int8'` |
142
- | `copyComments` | `boolean` | No | `true` | Whether database comments are copied into generated TypeScript documentation comments. |
143
- | `dbConnectionString` | `string` | Conditional | — | PostgreSQL connection string. Exactly one of this or `dbConnectionParams` must be provided. |
144
- | `dbConnectionParams` | `object` | Conditional | — | PostgreSQL connection parameters. Exactly one of this or `dbConnectionString` must be provided. |
145
- | `writeToDisk` | `boolean` | Yes | — | Controls whether generated output is written to disk. |
146
- | `outFile` | `string` | Conditional | — | Output file path. Required when `writeToDisk` is `true`. |
147
- | `tables` | `TableOptions` | No | — | Table filtering configuration. |
148
- | `functions` | `FunctionOptions` | No | — | Function filtering and typing configuration. |
138
+ | Option | Type | Required | Default | Description |
139
+ | -------------------- | ------------------------- | ----------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
140
+ | `schemas` | `string[]` | No | `['public']` | PostgreSQL schemas to introspect. At least one schema must be specified. |
141
+ | `header` | `string` | No | — | Text inserted at the top of the generated output file (e.g., additional type imports or definitions). |
142
+ | `types` | `Record<string, string>` | No | — | Custom PostgreSQL-to-TypeScript type mappings that override built-in defaults. These should be specified in the format `<schema>.<type>`, e.g. `'pg_catalog.int8'` |
143
+ | `copyComments` | `boolean` | No | `true` | Whether database comments are copied into generated TypeScript documentation comments. |
144
+ | `dbConnectionString` | `string` | Conditional | — | PostgreSQL connection string. Exactly one of this or `dbConnectionParams` must be provided. |
145
+ | `dbConnectionParams` | `object` | Conditional | — | PostgreSQL connection parameters. Exactly one of this or `dbConnectionString` must be provided. |
146
+ | `writeToDisk` | `boolean` | Yes | — | Controls whether generated output is written to disk. |
147
+ | `outFile` | `string` | Conditional | — | Output file path. Required when `writeToDisk` is `true`. |
148
+ | `tables` | `TableOptions` | No | — | Table filtering configuration. |
149
+ | `views` | `ViewOptions` | No | — | View filtering configuration. |
150
+ | `materializedViews` | `MaterializedViewOptions` | No | — | Materialized view filtering configuration. |
151
+ | `functions` | `FunctionOptions` | No | — | Function filtering and typing configuration. |
149
152
 
150
153
  #### `dbConnectionParams`
151
154
 
@@ -171,6 +174,30 @@ Controls which database tables are included in the generated output.
171
174
 
172
175
  ---
173
176
 
177
+ ### View Options
178
+
179
+ Controls which views are included in the generated output.
180
+
181
+ | Option | Type | Required | Default | Description |
182
+ | -------------- | ---------------------------- | -------- | ------------- | -------------------------------------------------- |
183
+ | `mode` | `'inclusive' \| 'exclusive'` | No | `'inclusive'` | Determines how view filtering is applied. |
184
+ | `excludeViews` | `string[]` | No | `[]` | Views to exclude when operating in inclusive mode. |
185
+ | `includeViews` | `string[]` | No | `[]` | Views to include when operating in exclusive mode. |
186
+
187
+ ---
188
+
189
+ ### Materialized View Options
190
+
191
+ Controls which materialized views are included in the generated output.
192
+
193
+ | Option | Type | Required | Default | Description |
194
+ | -------------------------- | ---------------------------- | -------- | ------------- | --------------------------------------------------------------- |
195
+ | `mode` | `'inclusive' \| 'exclusive'` | No | `'inclusive'` | Determines how materialized view filtering is applied. |
196
+ | `excludeMaterializedViews` | `string[]` | No | `[]` | Materialized views to exclude when operating in inclusive mode. |
197
+ | `includeMaterializedViews` | `string[]` | No | `[]` | Materialized views to include when operating in exclusive mode. |
198
+
199
+ ---
200
+
174
201
  ### Function Options
175
202
 
176
203
  Controls which PostgreSQL functions are included and how their types are generated.
@@ -185,31 +212,32 @@ Controls which PostgreSQL functions are included and how their types are generat
185
212
 
186
213
  ## Types
187
214
 
188
- Default type mappings are based on the types produced by
189
- [node-postgres](https://node-postgres.com/). These defaults can be added to or
190
- overridden using configuration options described above. Type definitions for
191
- enums will be generated automatically, provided that the enum is used somewhere
192
- in a table or function definition.
215
+ Default type mappings are based on the types produced by
216
+ [node-postgres](https://node-postgres.com/). These defaults can be added to or
217
+ overridden using configuration options described above. Type definitions for
218
+ enums will be generated automatically, provided that the enum is used somewhere
219
+ in a table, view, materialized view, or function definition.
193
220
 
194
- To define custom types, use the header to import or define them and use the
221
+ To define custom types, use the header to import or define them and use the
195
222
  `types` configuration option to map PostgreSQL types to your custom types.
196
223
 
197
224
  Multi-dimensional-array-type columns are recognized. Columns to which a `NOT NULL`
198
- constraint has been applied will be non-nullable. Optional and variadic function
225
+ constraint has been applied will be non-nullable. All columns of a view or
226
+ materialized view will typically be nullable. Optional and variadic function
199
227
  parameters are recognized.
200
228
 
201
229
  By default, node-postgres will transform the return value of a function that
202
230
  returns void into an empty string. Therefore, by default, the generated
203
231
  TypeScript return type of PostgreSQL functions that return void will be
204
- `string`. If desired, this can be overridden using the `types` configuration
232
+ `string`. If desired, this can be overridden using the `types` configuration
205
233
  option.
206
234
 
207
235
  The default value for unrecognized types is `string`.
208
236
 
209
- ## Functions
237
+ ## Functions
210
238
 
211
- Only functions whose `prokind` is `'f'` in `pg_catalog.pg_proc` are recognized
212
- (i.e. normal functions, not procedures or aggregate functions).
239
+ Only functions whose `prokind` is `'f'` in `pg_catalog.pg_proc` are recognized
240
+ (i.e. normal functions, not procedures or aggregate functions).
213
241
 
214
242
  Function overloads are recognized.
215
243
 
@@ -222,7 +250,7 @@ object to which that comment is applied.
222
250
  Directives are case-insensitive but must be separated from each other and from
223
251
  other text by a whitespace character (a space, newline, etc).
224
252
 
225
- Here is an example of adding a directive to the `config_key` column of a table
253
+ Here is an example of adding a directive to the `config_key` column of a table
226
254
  called `config` in the `reporting` schema:
227
255
 
228
256
  ```
@@ -235,14 +263,14 @@ Below, please find a table of all valid directives:
235
263
 
236
264
  | Category | Directive | Effect |
237
265
  | -------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
238
- | Objects | @introspeql-exclude | Excludes a table or function overload when mode is `'inclusive'` |
239
- | Objects | @introspeql-include | Includes a table or function overload when mode is `'exclusive'` |
266
+ | Objects | @introspeql-exclude | Excludes a table, view, materialized view, or function overload when mode is `'inclusive'` |
267
+ | Objects | @introspeql-include | Includes a table, view, materialized view, or function overload when mode is `'exclusive'` |
240
268
  | Types | @introspeql-enable-nullable-args | Makes each parameter of the function overload to which it is applied nullable when `nullableArgs` is `false` in `config.functions` |
241
269
  | Types | @introspeql-disable-nullable-args | Makes each parameter of the function overload to which it is applied non-nullable when `nullableArgs` is `true` in `config.functions` |
242
270
  | Types | @introspeql-enable-nullable-return-types | Makes the return type of the function overload to which it is applied nullable when `nullableReturnTypes` is `false` in `config.functions` |
243
271
  | Types | @introspeql-disable-nullable-return-types | Makes the return type of the function overload to which it is applied non-nullable when `nullableReturnTypes` is `true` in `config.functions` |
244
- | Comments | @introspeql-enable-tsdoc-comments | Copies the comments of the table, column, or enum to which it is applied even when `config.copyComments` is false or is an array that does not include the given database object type. |
245
- | Comments | @introspeql-disable-tsdoc-comments | Ignores the comments of the table, column, or enum to which it is applied even when `config.copyComments` is true or is an array that includes the given database object type. |
272
+ | Comments | @introspeql-enable-tsdoc-comments | Copies the comments of the table, view, materialized view, column, or enum to which it is applied even when `config.copyComments` is false or is an array that does not include the given database object type. |
273
+ | Comments | @introspeql-disable-tsdoc-comments | Ignores the comments of the table, view, materialized view, column, or enum to which it is applied even when `config.copyComments` is true or is an array that includes the given database object type. |
246
274
  | Comments | @introspeql-begin-tsdoc-comment | Copies a portion of a PostgreSQL comment into the generated type definition file beginning after this directive and ending at the next `@introspeql-end-tsdoc-comment` directive or at the end of the comment. |
247
275
  | Comments | @introspeql-end-tsdoc-comment | Omits a portion of a PostgreSQL comment from the generated type definition file beginning after this directive and ending at the next `@introspeql-begin-tsdoc-comment` directive or at the end of the comment. |
248
276
 
@@ -254,7 +282,7 @@ import { Directives } from 'introspeql';
254
282
 
255
283
  ## Comments
256
284
 
257
- [Comments](https://www.postgresql.org/docs/current/sql-comment.html) can be
285
+ [Comments](https://www.postgresql.org/docs/current/sql-comment.html) can be
258
286
  applied to PostgreSQL database objects with the following syntax:
259
287
 
260
288
  ```
@@ -262,9 +290,10 @@ COMMENT ON COLUMN auth.users.user_id IS
262
290
  'Unique identifier for the user.';
263
291
  ```
264
292
 
265
- If IntrospeQL is configured to copy the comments for a given table, enum, or
266
- column, PostgreSQL comments applied to that database object will be copied into
267
- the type definition file as [TSDoc](https://tsdoc.org/) comments.
293
+ If IntrospeQL is configured to copy the comments for a given table, view,
294
+ materialized view, enum, or column, PostgreSQL comments applied to that database
295
+ object will be copied into the type definition file as [TSDoc](https://tsdoc.org/)
296
+ comments.
268
297
 
269
298
  Note that all `@introspeql-` directives will always be removed when the copied
270
299
  comment is formatted.
@@ -273,8 +302,8 @@ Comments cannot contain `*/` or a combination of
273
302
  characters that results in `*/` after directives are removed. Such comments
274
303
  will trigger a warning and will not be included in the output.
275
304
 
276
- Assuming comment copying is enabled for a particular database object, you can
277
- use the `@introspeql-begin-tsdoc-comment` and `@introspeql-end-tsdoc-comment`
305
+ Assuming comment copying is enabled for a particular database object, you can
306
+ use the `@introspeql-begin-tsdoc-comment` and `@introspeql-end-tsdoc-comment`
278
307
  directives to copy only certain excerpts of the comment:
279
308
 
280
309
  ### No Directive
@@ -332,4 +361,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
332
361
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
333
362
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
334
363
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
335
- SOFTWARE.
364
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ import { z, ZodDefault, ZodLiteral, ZodOptional } from 'zod';
2
+ /**
3
+ * Creates a Zod object that can parse IntrospeQL configuration options for
4
+ * database objects described in the pg_class table, including tables, views,
5
+ * and materialized views.
6
+ */
7
+ export declare function createRelationOptions<T extends 'table' | 'view' | 'materializedView'>(relationName: T): z.ZodIntersection<z.ZodObject<{
8
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
9
+ inclusive: "inclusive";
10
+ exclusive: "exclusive";
11
+ }>>>;
12
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
13
+ mode: ZodDefault<ZodOptional<ZodLiteral<"inclusive">>>;
14
+ } & { [K in `exclude${Capitalize<T>}s`]: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
15
+ schema: z.ZodString;
16
+ name: z.ZodString;
17
+ }, z.core.$strip>>>>; } & { [K_1 in `include${Capitalize<T>}s`]: z.ZodOptional<z.ZodUndefined>; }, z.core.$strip>, z.ZodObject<{
18
+ mode: ZodLiteral<"exclusive">;
19
+ } & { [K_2 in `include${Capitalize<T>}s`]: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ schema: z.ZodString;
21
+ name: z.ZodString;
22
+ }, z.core.$strip>>>>; } & { [K_3 in `exclude${Capitalize<T>}s`]: z.ZodOptional<z.ZodUndefined>; }, z.core.$strip>]>>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRelationOptions = createRelationOptions;
4
+ var zod_1 = require("zod");
5
+ var entity_data_1 = require("./entity-data");
6
+ var capitalize_1 = require("../shared/capitalize");
7
+ /**
8
+ * Creates a Zod object that can parse IntrospeQL configuration options for
9
+ * database objects described in the pg_class table, including tables, views,
10
+ * and materialized views.
11
+ */
12
+ function createRelationOptions(relationName) {
13
+ var _a, _b;
14
+ var includeRelationsPropertyKey = "include".concat((0, capitalize_1.capitalize)(relationName), "s");
15
+ var excludeRelationsPropertyKey = "exclude".concat((0, capitalize_1.capitalize)(relationName), "s");
16
+ return zod_1.z
17
+ .object({
18
+ /**
19
+ * Determines the default behavior for including and excluding relations.
20
+ *
21
+ * If `mode` is set to `'inclusive'` (the default), all relations will be
22
+ * included in the output, except those explictly excluded with
23
+ * configuration options or those that include `"@introspeql-exclude"` in
24
+ * their PostgreSQL comments.
25
+ *
26
+ * If `mode` is set to `'exclusive'`, only relations explictly included
27
+ * with configuration options or those that include `"@introspeql-include"`
28
+ * in their PostgreSQL comment will be included in the output.
29
+ */
30
+ mode: zod_1.z.enum(['inclusive', 'exclusive']).optional().default('inclusive'),
31
+ })
32
+ .and(zod_1.z.union([
33
+ zod_1.z.object((_a = {
34
+ mode: zod_1.z.literal('inclusive').optional().default('inclusive')
35
+ },
36
+ /**
37
+ * An array of relations for which type definitions should not be
38
+ * generated. Only valid if `mode` is `'inclusive'`.
39
+ */
40
+ _a[excludeRelationsPropertyKey] = entity_data_1.entityData
41
+ .array()
42
+ .optional()
43
+ .default(function () { return []; }),
44
+ _a[includeRelationsPropertyKey] = zod_1.z.undefined().optional(),
45
+ _a)),
46
+ zod_1.z.object((_b = {
47
+ mode: zod_1.z.literal('exclusive')
48
+ },
49
+ /**
50
+ * An array of relations for which type definitions should be
51
+ * generated. Only valid if `mode` is `'exclusive'`.
52
+ */
53
+ _b[includeRelationsPropertyKey] = entity_data_1.entityData
54
+ .array()
55
+ .optional()
56
+ .default(function () { return []; }),
57
+ _b[excludeRelationsPropertyKey] = zod_1.z.undefined().optional(),
58
+ _b)),
59
+ ]));
60
+ }
@@ -30,17 +30,21 @@ declare const introspeqlConfigSchema: z.ZodIntersection<z.ZodIntersection<z.ZodI
30
30
  }>>>;
31
31
  }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
32
32
  mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
33
+ } & {
33
34
  excludeTables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
34
35
  schema: z.ZodString;
35
36
  name: z.ZodString;
36
37
  }, z.core.$strip>>>>;
38
+ } & {
37
39
  includeTables: z.ZodOptional<z.ZodUndefined>;
38
40
  }, z.core.$strip>, z.ZodObject<{
39
41
  mode: z.ZodLiteral<"exclusive">;
42
+ } & {
40
43
  includeTables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
41
44
  schema: z.ZodString;
42
45
  name: z.ZodString;
43
46
  }, z.core.$strip>>>>;
47
+ } & {
44
48
  excludeTables: z.ZodOptional<z.ZodUndefined>;
45
49
  }, z.core.$strip>]>>>>;
46
50
  functions: z.ZodDefault<z.ZodOptional<z.ZodIntersection<z.ZodObject<{
@@ -65,6 +69,54 @@ declare const introspeqlConfigSchema: z.ZodIntersection<z.ZodIntersection<z.ZodI
65
69
  }, z.core.$strip>>>>;
66
70
  excludeFunctions: z.ZodOptional<z.ZodUndefined>;
67
71
  }, z.core.$strip>]>>>>;
72
+ views: z.ZodDefault<z.ZodOptional<z.ZodIntersection<z.ZodObject<{
73
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
74
+ inclusive: "inclusive";
75
+ exclusive: "exclusive";
76
+ }>>>;
77
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
78
+ mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
79
+ } & {
80
+ excludeViews: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
81
+ schema: z.ZodString;
82
+ name: z.ZodString;
83
+ }, z.core.$strip>>>>;
84
+ } & {
85
+ includeViews: z.ZodOptional<z.ZodUndefined>;
86
+ }, z.core.$strip>, z.ZodObject<{
87
+ mode: z.ZodLiteral<"exclusive">;
88
+ } & {
89
+ includeViews: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
90
+ schema: z.ZodString;
91
+ name: z.ZodString;
92
+ }, z.core.$strip>>>>;
93
+ } & {
94
+ excludeViews: z.ZodOptional<z.ZodUndefined>;
95
+ }, z.core.$strip>]>>>>;
96
+ materializedViews: z.ZodDefault<z.ZodOptional<z.ZodIntersection<z.ZodObject<{
97
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
98
+ inclusive: "inclusive";
99
+ exclusive: "exclusive";
100
+ }>>>;
101
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
102
+ mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
103
+ } & {
104
+ excludeMaterializedViews: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
105
+ schema: z.ZodString;
106
+ name: z.ZodString;
107
+ }, z.core.$strip>>>>;
108
+ } & {
109
+ includeMaterializedViews: z.ZodOptional<z.ZodUndefined>;
110
+ }, z.core.$strip>, z.ZodObject<{
111
+ mode: z.ZodLiteral<"exclusive">;
112
+ } & {
113
+ includeMaterializedViews: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
114
+ schema: z.ZodString;
115
+ name: z.ZodString;
116
+ }, z.core.$strip>>>>;
117
+ } & {
118
+ excludeMaterializedViews: z.ZodOptional<z.ZodUndefined>;
119
+ }, z.core.$strip>]>>>>;
68
120
  }, z.core.$strip>>;
69
121
  type IntrospeQLConfig = z.input<typeof introspeqlConfigSchema>;
70
122
  type ParsedConfig = z.infer<typeof introspeqlConfigSchema>;
@@ -5,8 +5,10 @@ var zod_1 = require("zod");
5
5
  var connection_options_1 = require("./connection-options");
6
6
  var function_options_1 = require("./function-options");
7
7
  var general_options_1 = require("./general-options");
8
+ var materialized_view_options_1 = require("./materialized-view-options");
8
9
  var output_options_1 = require("./output-options");
9
10
  var table_options_1 = require("./table-options");
11
+ var view_options_1 = require("./view-options");
10
12
  var introspeqlConfigSchema = general_options_1.generalOptions
11
13
  .and(connection_options_1.connectionOptions)
12
14
  .and(output_options_1.outputOptions)
@@ -25,5 +27,17 @@ var introspeqlConfigSchema = general_options_1.generalOptions
25
27
  nullableReturnTypes: true,
26
28
  };
27
29
  }),
30
+ views: view_options_1.viewOptions.optional().default(function () {
31
+ return {
32
+ mode: 'inclusive',
33
+ excludeViews: [],
34
+ };
35
+ }),
36
+ materializedViews: materialized_view_options_1.materializedViewOptions.optional().default(function () {
37
+ return {
38
+ mode: 'inclusive',
39
+ excludeMaterializedViews: [],
40
+ };
41
+ }),
28
42
  }));
29
43
  exports.introspeqlConfigSchema = introspeqlConfigSchema;
@@ -0,0 +1,24 @@
1
+ export declare const materializedViewOptions: import("zod").ZodIntersection<import("zod").ZodObject<{
2
+ mode: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodEnum<{
3
+ inclusive: "inclusive";
4
+ exclusive: "exclusive";
5
+ }>>>;
6
+ }, import("zod/v4/core").$strip>, import("zod").ZodUnion<readonly [import("zod").ZodObject<{
7
+ mode: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"inclusive">>>;
8
+ } & {
9
+ excludeMaterializedViews: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
10
+ schema: import("zod").ZodString;
11
+ name: import("zod").ZodString;
12
+ }, import("zod/v4/core").$strip>>>>;
13
+ } & {
14
+ includeMaterializedViews: import("zod").ZodOptional<import("zod").ZodUndefined>;
15
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
16
+ mode: import("zod").ZodLiteral<"exclusive">;
17
+ } & {
18
+ includeMaterializedViews: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
19
+ schema: import("zod").ZodString;
20
+ name: import("zod").ZodString;
21
+ }, import("zod/v4/core").$strip>>>>;
22
+ } & {
23
+ excludeMaterializedViews: import("zod").ZodOptional<import("zod").ZodUndefined>;
24
+ }, import("zod/v4/core").$strip>]>>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.materializedViewOptions = void 0;
4
+ var create_relation_options_1 = require("./create-relation-options");
5
+ exports.materializedViewOptions = (0, create_relation_options_1.createRelationOptions)('materializedView');
@@ -1,21 +1,24 @@
1
- import { z } from 'zod';
2
- export declare const tableOptions: z.ZodIntersection<z.ZodObject<{
3
- mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
1
+ export declare const tableOptions: import("zod").ZodIntersection<import("zod").ZodObject<{
2
+ mode: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodEnum<{
4
3
  inclusive: "inclusive";
5
4
  exclusive: "exclusive";
6
5
  }>>>;
7
- }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
8
- mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
9
- excludeTables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
10
- schema: z.ZodString;
11
- name: z.ZodString;
12
- }, z.core.$strip>>>>;
13
- includeTables: z.ZodOptional<z.ZodUndefined>;
14
- }, z.core.$strip>, z.ZodObject<{
15
- mode: z.ZodLiteral<"exclusive">;
16
- includeTables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
17
- schema: z.ZodString;
18
- name: z.ZodString;
19
- }, z.core.$strip>>>>;
20
- excludeTables: z.ZodOptional<z.ZodUndefined>;
21
- }, z.core.$strip>]>>;
6
+ }, import("zod/v4/core").$strip>, import("zod").ZodUnion<readonly [import("zod").ZodObject<{
7
+ mode: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"inclusive">>>;
8
+ } & {
9
+ excludeTables: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
10
+ schema: import("zod").ZodString;
11
+ name: import("zod").ZodString;
12
+ }, import("zod/v4/core").$strip>>>>;
13
+ } & {
14
+ includeTables: import("zod").ZodOptional<import("zod").ZodUndefined>;
15
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
16
+ mode: import("zod").ZodLiteral<"exclusive">;
17
+ } & {
18
+ includeTables: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
19
+ schema: import("zod").ZodString;
20
+ name: import("zod").ZodString;
21
+ }, import("zod/v4/core").$strip>>>>;
22
+ } & {
23
+ excludeTables: import("zod").ZodOptional<import("zod").ZodUndefined>;
24
+ }, import("zod/v4/core").$strip>]>>;
@@ -1,48 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tableOptions = void 0;
4
- var zod_1 = require("zod");
5
- var entity_data_1 = require("./entity-data");
6
- exports.tableOptions = zod_1.z
7
- .object({
8
- /**
9
- * Determines the default behavior for including and excluding tables.
10
- *
11
- * If `mode` is set to `'inclusive'` (the default), all tables will be
12
- * included in the output, except those listed in the `excludeTables`
13
- * configuration option, or those that include `"@introspeql-exclude"` in
14
- * their PostgreSQL comments.
15
- *
16
- * If `mode` is set to `'exclusive'`, only tables listed in the
17
- * `includeTables` configuration option or those that include
18
- * `"@introspeql-include"` in their PostgreSQL comment will be included in
19
- * the output.
20
- */
21
- mode: zod_1.z.enum(['inclusive', 'exclusive']).optional().default('inclusive'),
22
- })
23
- .and(zod_1.z.union([
24
- zod_1.z.object({
25
- mode: zod_1.z.literal('inclusive').optional().default('inclusive'),
26
- /**
27
- * An array of tables for which type definitions should not be
28
- * generated. Only valid if `mode` is `'inclusive'`.
29
- */
30
- excludeTables: entity_data_1.entityData
31
- .array()
32
- .optional()
33
- .default(function () { return []; }),
34
- includeTables: zod_1.z.undefined().optional(),
35
- }),
36
- zod_1.z.object({
37
- mode: zod_1.z.literal('exclusive'),
38
- /**
39
- * An array of tables for which type definitions should be generated.
40
- * Only valid if `mode` is `'exclusive'`.
41
- */
42
- includeTables: entity_data_1.entityData
43
- .array()
44
- .optional()
45
- .default(function () { return []; }),
46
- excludeTables: zod_1.z.undefined().optional(),
47
- }),
48
- ]));
4
+ var create_relation_options_1 = require("./create-relation-options");
5
+ exports.tableOptions = (0, create_relation_options_1.createRelationOptions)('table');
@@ -0,0 +1,24 @@
1
+ export declare const viewOptions: import("zod").ZodIntersection<import("zod").ZodObject<{
2
+ mode: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodEnum<{
3
+ inclusive: "inclusive";
4
+ exclusive: "exclusive";
5
+ }>>>;
6
+ }, import("zod/v4/core").$strip>, import("zod").ZodUnion<readonly [import("zod").ZodObject<{
7
+ mode: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"inclusive">>>;
8
+ } & {
9
+ excludeViews: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
10
+ schema: import("zod").ZodString;
11
+ name: import("zod").ZodString;
12
+ }, import("zod/v4/core").$strip>>>>;
13
+ } & {
14
+ includeViews: import("zod").ZodOptional<import("zod").ZodUndefined>;
15
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
16
+ mode: import("zod").ZodLiteral<"exclusive">;
17
+ } & {
18
+ includeViews: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
19
+ schema: import("zod").ZodString;
20
+ name: import("zod").ZodString;
21
+ }, import("zod/v4/core").$strip>>>>;
22
+ } & {
23
+ excludeViews: import("zod").ZodOptional<import("zod").ZodUndefined>;
24
+ }, import("zod/v4/core").$strip>]>>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.viewOptions = void 0;
4
+ var create_relation_options_1 = require("./create-relation-options");
5
+ exports.viewOptions = (0, create_relation_options_1.createRelationOptions)('view');