introspeql 0.0.3 → 1.0.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 (120) hide show
  1. package/README.md +286 -85
  2. package/dist/comments/comment-converter.d.ts +54 -0
  3. package/dist/comments/comment-converter.js +185 -0
  4. package/dist/comments/index.d.ts +2 -0
  5. package/dist/comments/index.js +18 -0
  6. package/dist/comments/prettify-comment.d.ts +1 -0
  7. package/dist/comments/prettify-comment.js +18 -0
  8. package/dist/config/connection-options.d.ts +14 -0
  9. package/dist/config/connection-options.js +42 -0
  10. package/dist/config/default-type-mappings.d.ts +13 -0
  11. package/dist/config/default-type-mappings.js +16 -0
  12. package/dist/config/entity-data.d.ts +6 -0
  13. package/dist/config/entity-data.js +8 -0
  14. package/dist/config/function-options.d.ts +23 -0
  15. package/dist/config/function-options.js +74 -0
  16. package/dist/config/general-options.d.ts +7 -0
  17. package/dist/config/general-options.js +75 -0
  18. package/dist/config/index.d.ts +71 -0
  19. package/dist/config/index.js +29 -0
  20. package/dist/config/output-options.d.ts +8 -0
  21. package/dist/config/output-options.js +40 -0
  22. package/dist/config/table-options.d.ts +21 -0
  23. package/dist/config/table-options.js +48 -0
  24. package/dist/enums/enum-data.d.ts +9 -0
  25. package/dist/enums/enum-data.js +11 -0
  26. package/dist/enums/enum-definition.d.ts +7 -0
  27. package/dist/enums/enum-definition.js +24 -0
  28. package/dist/enums/index.d.ts +4 -0
  29. package/dist/enums/index.js +20 -0
  30. package/dist/enums/is-enum-replaced-with-custom-type.d.ts +3 -0
  31. package/dist/enums/is-enum-replaced-with-custom-type.js +9 -0
  32. package/dist/enums/read-enum-data.d.ts +3 -0
  33. package/dist/enums/read-enum-data.js +57 -0
  34. package/dist/functions/function-data.d.ts +26 -0
  35. package/dist/functions/function-data.js +27 -0
  36. package/dist/functions/function-definition.d.ts +7 -0
  37. package/dist/functions/function-definition.js +21 -0
  38. package/dist/functions/index.d.ts +9 -0
  39. package/dist/functions/index.js +25 -0
  40. package/dist/functions/overload-type-definition.d.ts +8 -0
  41. package/dist/functions/overload-type-definition.js +21 -0
  42. package/dist/functions/parameter-type-definition-builder.d.ts +16 -0
  43. package/dist/functions/parameter-type-definition-builder.js +41 -0
  44. package/dist/functions/parameter-type-definition.d.ts +9 -0
  45. package/dist/functions/parameter-type-definition.js +28 -0
  46. package/dist/functions/read-function-data.d.ts +4 -0
  47. package/dist/functions/read-function-data.js +93 -0
  48. package/dist/functions/return-type-definition.d.ts +7 -0
  49. package/dist/functions/return-type-definition.js +20 -0
  50. package/dist/functions/should-include-function.d.ts +2 -0
  51. package/dist/functions/should-include-function.js +6 -0
  52. package/dist/functions/should-include-overload.d.ts +2 -0
  53. package/dist/functions/should-include-overload.js +23 -0
  54. package/dist/index.d.ts +3 -2
  55. package/dist/index.js +7 -1
  56. package/dist/introspeql.d.ts +7 -0
  57. package/dist/introspeql.js +161 -0
  58. package/dist/schemas/index.d.ts +3 -0
  59. package/dist/schemas/index.js +19 -0
  60. package/dist/schemas/read-schema-data.d.ts +15 -0
  61. package/dist/schemas/read-schema-data.js +182 -0
  62. package/dist/schemas/schema-definition-factory.d.ts +15 -0
  63. package/dist/schemas/schema-definition-factory.js +167 -0
  64. package/dist/schemas/schema-definition.d.ts +11 -0
  65. package/dist/schemas/schema-definition.js +38 -0
  66. package/dist/shared/convert-pg-identifier-to-ts-identifier.d.ts +19 -0
  67. package/dist/shared/convert-pg-identifier-to-ts-identifier.js +57 -0
  68. package/dist/shared/directives.d.ts +12 -0
  69. package/dist/shared/directives.js +16 -0
  70. package/dist/shared/get-tokens.d.ts +1 -0
  71. package/dist/shared/get-tokens.js +7 -0
  72. package/dist/shared/indent.d.ts +1 -0
  73. package/dist/shared/indent.js +9 -0
  74. package/dist/shared/index.d.ts +5 -0
  75. package/dist/shared/index.js +21 -0
  76. package/dist/shared/parsing-error.d.ts +3 -0
  77. package/dist/shared/parsing-error.js +26 -0
  78. package/dist/tables/column-data.d.ts +14 -0
  79. package/dist/tables/column-data.js +16 -0
  80. package/dist/tables/column-definition.d.ts +8 -0
  81. package/dist/tables/column-definition.js +19 -0
  82. package/dist/tables/column-type-definition.d.ts +7 -0
  83. package/dist/tables/column-type-definition.js +19 -0
  84. package/dist/tables/index.d.ts +8 -0
  85. package/dist/tables/index.js +24 -0
  86. package/dist/tables/read-column-data.d.ts +3 -0
  87. package/dist/tables/read-column-data.js +55 -0
  88. package/dist/tables/read-table-data.d.ts +4 -0
  89. package/dist/tables/read-table-data.js +84 -0
  90. package/dist/tables/should-include-table.d.ts +10 -0
  91. package/dist/tables/should-include-table.js +24 -0
  92. package/dist/tables/table-data.d.ts +8 -0
  93. package/dist/tables/table-data.js +10 -0
  94. package/dist/tables/table-definition.d.ts +10 -0
  95. package/dist/tables/table-definition.js +43 -0
  96. package/dist/types/index.d.ts +1 -0
  97. package/dist/types/index.js +17 -0
  98. package/dist/types/lookup-type.d.ts +15 -0
  99. package/dist/types/lookup-type.js +25 -0
  100. package/package.json +33 -18
  101. package/dist/append-schema.d.ts +0 -8
  102. package/dist/append-schema.js +0 -96
  103. package/dist/generate-types.d.ts +0 -8
  104. package/dist/generate-types.js +0 -111
  105. package/dist/introspect-columns.d.ts +0 -21
  106. package/dist/introspect-columns.js +0 -53
  107. package/dist/introspect-enum.d.ts +0 -20
  108. package/dist/introspect-enum.js +0 -24
  109. package/dist/introspect-procedures.d.ts +0 -53
  110. package/dist/introspect-procedures.js +0 -129
  111. package/dist/introspect-tables.d.ts +0 -19
  112. package/dist/introspect-tables.js +0 -43
  113. package/dist/introspeql-config.d.ts +0 -40
  114. package/dist/introspeql-config.js +0 -104
  115. package/dist/prepare-data-for-writing.d.ts +0 -38
  116. package/dist/prepare-data-for-writing.js +0 -145
  117. package/dist/snake-case-to-pascal-case.d.ts +0 -8
  118. package/dist/snake-case-to-pascal-case.js +0 -17
  119. package/dist/write-header.d.ts +0 -2
  120. package/dist/write-header.js +0 -10
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prettifyComment = prettifyComment;
7
+ var sync_1 = __importDefault(require("@prettier/sync"));
8
+ function prettifyComment(comment) {
9
+ return sync_1.default
10
+ .format(comment, {
11
+ parser: 'typescript',
12
+ plugins: [require.resolve('prettier-plugin-jsdoc')],
13
+ printWidth: 80,
14
+ tsDoc: true,
15
+ jsdocPreferCodeFences: true,
16
+ })
17
+ .trim();
18
+ }
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export declare const connectionOptions: z.ZodUnion<readonly [z.ZodObject<{
3
+ dbConnectionString: z.ZodString;
4
+ dbConnectionParams: z.ZodOptional<z.ZodUndefined>;
5
+ }, z.core.$strip>, z.ZodObject<{
6
+ dbConnectionParams: z.ZodObject<{
7
+ user: z.ZodOptional<z.ZodString>;
8
+ password: z.ZodOptional<z.ZodString>;
9
+ host: z.ZodOptional<z.ZodString>;
10
+ port: z.ZodOptional<z.ZodNumber>;
11
+ database: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ dbConnectionString: z.ZodOptional<z.ZodUndefined>;
14
+ }, z.core.$strip>]>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.connectionOptions = void 0;
4
+ var zod_1 = require("zod");
5
+ exports.connectionOptions = zod_1.z.union([
6
+ zod_1.z.object({
7
+ /**
8
+ * A PostgreSQL connection string specifying the database to connect to.
9
+ * Useful if you are already storing such a string as an environment variable.
10
+ * Only valid if `dbConnectionParams` is not supplied.
11
+ */
12
+ dbConnectionString: zod_1.z.string(),
13
+ /**
14
+ * An object containing the components of a PostgreSQL connection string that
15
+ * together specify the database to connect to. Useful if you are already
16
+ * storing such values as individual environment variables. Only valid if
17
+ * `dbConnectionString` is not supplied.
18
+ */
19
+ dbConnectionParams: zod_1.z.undefined().optional(),
20
+ }),
21
+ zod_1.z.object({
22
+ /**
23
+ * An object containing the components of a PostgreSQL connection string that
24
+ * together specify the database to connect to. Useful if you are already
25
+ * storing such values as individual environment variables. Only valid if
26
+ * `dbConnectionString` is not supplied.
27
+ */
28
+ dbConnectionParams: zod_1.z.object({
29
+ user: zod_1.z.string().optional(),
30
+ password: zod_1.z.string().optional(),
31
+ host: zod_1.z.string().optional(),
32
+ port: zod_1.z.number().optional(),
33
+ database: zod_1.z.string().optional(),
34
+ }),
35
+ /**
36
+ * A PostgreSQL connection string specifying the database to connect to.
37
+ * Useful if you are already storing such a string as an environment variable.
38
+ * Only valid if `dbConnectionParams` is not supplied.
39
+ */
40
+ dbConnectionString: zod_1.z.undefined().optional(),
41
+ }),
42
+ ]);
@@ -0,0 +1,13 @@
1
+ export declare const DEFAULT_TYPE_MAPPINGS: {
2
+ 'pg_catalog.bool': string;
3
+ 'pg_catalog.int2': string;
4
+ 'pg_catalog.int4': string;
5
+ 'pg_catalog.float4': string;
6
+ 'pg_catalog.float8': string;
7
+ 'pg_catalog.json': string;
8
+ 'pg_catalog.jsonb': string;
9
+ 'pg_catalog.date': string;
10
+ 'pg_catalog.timestamp': string;
11
+ 'pg_catalog.timestamptz': string;
12
+ 'pg_catalog.bytea': string;
13
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_TYPE_MAPPINGS = void 0;
4
+ exports.DEFAULT_TYPE_MAPPINGS = {
5
+ 'pg_catalog.bool': 'boolean',
6
+ 'pg_catalog.int2': 'number',
7
+ 'pg_catalog.int4': 'number',
8
+ 'pg_catalog.float4': 'number',
9
+ 'pg_catalog.float8': 'number',
10
+ 'pg_catalog.json': 'object',
11
+ 'pg_catalog.jsonb': 'object',
12
+ 'pg_catalog.date': 'Date',
13
+ 'pg_catalog.timestamp': 'Date',
14
+ 'pg_catalog.timestamptz': 'Date',
15
+ 'pg_catalog.bytea': 'Buffer',
16
+ };
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ export declare const entityData: z.ZodObject<{
3
+ schema: z.ZodString;
4
+ name: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export type EntityData = z.infer<typeof entityData>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.entityData = void 0;
4
+ var zod_1 = require("zod");
5
+ exports.entityData = zod_1.z.object({
6
+ schema: zod_1.z.string(),
7
+ name: zod_1.z.string(),
8
+ });
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ export declare const functionOptions: z.ZodIntersection<z.ZodObject<{
3
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
4
+ inclusive: "inclusive";
5
+ exclusive: "exclusive";
6
+ }>>>;
7
+ nullableArgs: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
8
+ nullableReturnTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
10
+ mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
11
+ excludeFunctions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
12
+ schema: z.ZodString;
13
+ name: z.ZodString;
14
+ }, z.core.$strip>>>>;
15
+ includeFunctions: z.ZodOptional<z.ZodUndefined>;
16
+ }, z.core.$strip>, z.ZodObject<{
17
+ mode: z.ZodLiteral<"exclusive">;
18
+ includeFunctions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
19
+ schema: z.ZodString;
20
+ name: z.ZodString;
21
+ }, z.core.$strip>>>>;
22
+ excludeFunctions: z.ZodOptional<z.ZodUndefined>;
23
+ }, z.core.$strip>]>>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionOptions = void 0;
4
+ var zod_1 = require("zod");
5
+ var entity_data_1 = require("./entity-data");
6
+ exports.functionOptions = zod_1.z
7
+ .object({
8
+ /**
9
+ * Determines the default behavior for including and excluding functions.
10
+ *
11
+ * If `mode` is set to `'inclusive'` (the default), all functions will be
12
+ * included in the output, except those listed in the `excludeFunctions`
13
+ * configuration option, or those that include `"@introspeql-exclude"` in
14
+ * their PostgreSQL comments.
15
+ *
16
+ * If `mode` is set to `'exclusive'`, only functions listed in the
17
+ * `'includeFunctions'` configuration option or those that include
18
+ * `"@introspeql-include"` in their PostgreSQL comment will be included in
19
+ * the output.
20
+ *
21
+ * If leveraging directives to opt out of the behavior configured here,
22
+ * each overload that you wish to include or exclude must be marked with the
23
+ * appropriate directive.
24
+ */
25
+ mode: zod_1.z.enum(['inclusive', 'exclusive']).optional().default('inclusive'),
26
+ /**
27
+ * PostgreSQL is unlike TypeScript in that argument types cannot be
28
+ * explicitly marked non-nullable. If you expect to leverage this behavior
29
+ * and potentially call a function with null arguments, set this
30
+ * option to `true`. This will cause all argument types to be transformed
31
+ * into type unions including `null`.
32
+ *
33
+ * To opt out of this behavior when this option is enabled, a function can
34
+ * include `"@introspeql-disable-nullable-args"` in its PostgreSQL comment.
35
+ *
36
+ * To opt into this behavior when this option is disabled, a function can
37
+ * include `"@introspeql-enable-nullable-args"` in its PostgreSQL comment.
38
+ */
39
+ nullableArgs: zod_1.z.boolean().optional().default(false),
40
+ /**
41
+ * Virtually any PostgreSQL function may potentially return `null`,
42
+ * regardless of its specified return type. Void functions without the
43
+ * `STRICT` modifier are perhaps one of the very few exceptions to this
44
+ * rule.
45
+ *
46
+ * Therefore, all function return types are nullable by default. To
47
+ * disable this behavior, set this option to false.
48
+ *
49
+ * To opt into this behavior when it is disabled, a function can include
50
+ * `"@introspeql-enable-nullable-return-types"` in its PostgreSQL comment.
51
+ *
52
+ * To opt out of this behavior when it is enabled, a function can include
53
+ * `"@introspeql-disable-nullable-return-types"` in its PostgreSQL comment.
54
+ */
55
+ nullableReturnTypes: zod_1.z.boolean().optional().default(true),
56
+ })
57
+ .and(zod_1.z.union([
58
+ zod_1.z.object({
59
+ mode: zod_1.z.literal('inclusive').optional().default('inclusive'),
60
+ excludeFunctions: entity_data_1.entityData
61
+ .array()
62
+ .optional()
63
+ .default(function () { return []; }),
64
+ includeFunctions: zod_1.z.undefined().optional(),
65
+ }),
66
+ zod_1.z.object({
67
+ mode: zod_1.z.literal('exclusive'),
68
+ includeFunctions: entity_data_1.entityData
69
+ .array()
70
+ .optional()
71
+ .default(function () { return []; }),
72
+ excludeFunctions: zod_1.z.undefined().optional(),
73
+ }),
74
+ ]));
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export declare const generalOptions: z.ZodObject<{
3
+ schemas: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4
+ header: z.ZodOptional<z.ZodString>;
5
+ types: z.ZodPipe<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>, z.ZodTransform<Record<string, string>, Record<string, string>>>;
6
+ copyComments: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
7
+ }, z.core.$strip>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.generalOptions = void 0;
15
+ var zod_1 = require("zod");
16
+ var default_type_mappings_1 = require("./default-type-mappings");
17
+ exports.generalOptions = zod_1.z.object({
18
+ /**
19
+ * The database schemas from which types should be generated. At least one
20
+ * schema must be specified. The default value is `['public']`.
21
+ */
22
+ schemas: zod_1.z
23
+ .string()
24
+ .array()
25
+ .nonempty({
26
+ message: 'Please provide at least one schema.',
27
+ })
28
+ .optional()
29
+ .default(function () { return ['public']; }),
30
+ /**
31
+ * An optional header that will be written to the generated type definition
32
+ * file before the types. Useful when you want to define or import types
33
+ * directly in the generated file.
34
+ */
35
+ header: zod_1.z.string().optional(),
36
+ /**
37
+ * Custom type mappings. Default settings align with transformations applied
38
+ * by node-postgres. To override these settings for a type, provide the
39
+ * name of the schema in which the type is defined and the name of the type
40
+ * (separated by a dot) as the key, and a string representation of the
41
+ * desired type as the value.
42
+ *
43
+ * @example
44
+ * ```
45
+ * {
46
+ * types: {
47
+ * "pg_catalog.int8" : "bigint"
48
+ * }
49
+ * }
50
+ * ```
51
+ */
52
+ types: zod_1.z
53
+ .record(zod_1.z.string(), zod_1.z.string())
54
+ .optional()
55
+ .transform(function (t) { return (__assign(__assign({}, default_type_mappings_1.DEFAULT_TYPE_MAPPINGS), t)); }),
56
+ /**
57
+ * If `true` (the default), comments attached to tables, columns, and
58
+ * enums will be included as TSDoc-style comments in the output
59
+ * (`"@introspeQL-"` directives within those comments will be removed).
60
+ *
61
+ * To opt out of this behavior when it is enabled, a table, enum, or column
62
+ * can include `"@introspeql-disable-tsdoc-comments"` in its comment.
63
+ *
64
+ * To opt into this behavior when it is disabled, a table, column, or enum
65
+ * can include `"@introspeql-enable-tsdoc-comments"` in its comment.
66
+ *
67
+ * By default, the behavior applied to a table will dictate the behavior
68
+ * applied to its columns unless the comment on a particular column includes
69
+ * one of the above directives.
70
+ *
71
+ * To include only certain sections of a comment, enclose them with
72
+ * `"@introspeql-begin-tsdoc-comment"` and `"@introspeql-end-tsdoc-comment"`.
73
+ */
74
+ copyComments: zod_1.z.boolean().optional().default(true),
75
+ });
@@ -0,0 +1,71 @@
1
+ import { z } from 'zod';
2
+ declare const introspeqlConfigSchema: z.ZodIntersection<z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
3
+ schemas: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4
+ header: z.ZodOptional<z.ZodString>;
5
+ types: z.ZodPipe<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>, z.ZodTransform<Record<string, string>, Record<string, string>>>;
6
+ copyComments: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
7
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
8
+ dbConnectionString: z.ZodString;
9
+ dbConnectionParams: z.ZodOptional<z.ZodUndefined>;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ dbConnectionParams: z.ZodObject<{
12
+ user: z.ZodOptional<z.ZodString>;
13
+ password: z.ZodOptional<z.ZodString>;
14
+ host: z.ZodOptional<z.ZodString>;
15
+ port: z.ZodOptional<z.ZodNumber>;
16
+ database: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ dbConnectionString: z.ZodOptional<z.ZodUndefined>;
19
+ }, z.core.$strip>]>>, z.ZodUnion<readonly [z.ZodObject<{
20
+ writeToDisk: z.ZodDefault<z.ZodOptional<z.ZodLiteral<true>>>;
21
+ outFile: z.ZodString;
22
+ }, z.core.$strip>, z.ZodObject<{
23
+ writeToDisk: z.ZodLiteral<false>;
24
+ outFile: z.ZodOptional<z.ZodUndefined>;
25
+ }, z.core.$strip>]>>, z.ZodObject<{
26
+ tables: z.ZodDefault<z.ZodOptional<z.ZodIntersection<z.ZodObject<{
27
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
28
+ inclusive: "inclusive";
29
+ exclusive: "exclusive";
30
+ }>>>;
31
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
32
+ mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
33
+ excludeTables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
34
+ schema: z.ZodString;
35
+ name: z.ZodString;
36
+ }, z.core.$strip>>>>;
37
+ includeTables: z.ZodOptional<z.ZodUndefined>;
38
+ }, z.core.$strip>, z.ZodObject<{
39
+ mode: z.ZodLiteral<"exclusive">;
40
+ includeTables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
41
+ schema: z.ZodString;
42
+ name: z.ZodString;
43
+ }, z.core.$strip>>>>;
44
+ excludeTables: z.ZodOptional<z.ZodUndefined>;
45
+ }, z.core.$strip>]>>>>;
46
+ functions: z.ZodDefault<z.ZodOptional<z.ZodIntersection<z.ZodObject<{
47
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
48
+ inclusive: "inclusive";
49
+ exclusive: "exclusive";
50
+ }>>>;
51
+ nullableArgs: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
52
+ nullableReturnTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
53
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
54
+ mode: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"inclusive">>>;
55
+ excludeFunctions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ schema: z.ZodString;
57
+ name: z.ZodString;
58
+ }, z.core.$strip>>>>;
59
+ includeFunctions: z.ZodOptional<z.ZodUndefined>;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ mode: z.ZodLiteral<"exclusive">;
62
+ includeFunctions: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
63
+ schema: z.ZodString;
64
+ name: z.ZodString;
65
+ }, z.core.$strip>>>>;
66
+ excludeFunctions: z.ZodOptional<z.ZodUndefined>;
67
+ }, z.core.$strip>]>>>>;
68
+ }, z.core.$strip>>;
69
+ type IntrospeQLConfig = z.input<typeof introspeqlConfigSchema>;
70
+ type ParsedConfig = z.infer<typeof introspeqlConfigSchema>;
71
+ export { introspeqlConfigSchema, type IntrospeQLConfig, type ParsedConfig };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.introspeqlConfigSchema = void 0;
4
+ var zod_1 = require("zod");
5
+ var connection_options_1 = require("./connection-options");
6
+ var function_options_1 = require("./function-options");
7
+ var general_options_1 = require("./general-options");
8
+ var output_options_1 = require("./output-options");
9
+ var table_options_1 = require("./table-options");
10
+ var introspeqlConfigSchema = general_options_1.generalOptions
11
+ .and(connection_options_1.connectionOptions)
12
+ .and(output_options_1.outputOptions)
13
+ .and(zod_1.z.object({
14
+ tables: table_options_1.tableOptions.optional().default(function () {
15
+ return {
16
+ mode: 'inclusive',
17
+ excludeTables: [],
18
+ };
19
+ }),
20
+ functions: function_options_1.functionOptions.optional().default(function () {
21
+ return {
22
+ mode: 'inclusive',
23
+ excludeFunctions: [],
24
+ nullableArgs: false,
25
+ nullableReturnTypes: true,
26
+ };
27
+ }),
28
+ }));
29
+ exports.introspeqlConfigSchema = introspeqlConfigSchema;
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export declare const outputOptions: z.ZodUnion<readonly [z.ZodObject<{
3
+ writeToDisk: z.ZodDefault<z.ZodOptional<z.ZodLiteral<true>>>;
4
+ outFile: z.ZodString;
5
+ }, z.core.$strip>, z.ZodObject<{
6
+ writeToDisk: z.ZodLiteral<false>;
7
+ outFile: z.ZodOptional<z.ZodUndefined>;
8
+ }, z.core.$strip>]>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.outputOptions = void 0;
4
+ var zod_1 = require("zod");
5
+ exports.outputOptions = zod_1.z.union([
6
+ zod_1.z.object({
7
+ /**
8
+ * If set to `true` (the default), IntrospeQL will save the output to the
9
+ * file specified in the `outFile` option.
10
+ *
11
+ * If `false`, IntrospeQL will return the output as a string as it usually
12
+ * would, but will not save this string to disk. Useful for testing or if
13
+ * further processing is required before the output is saved.
14
+ */
15
+ writeToDisk: zod_1.z.literal(true).optional().default(true),
16
+ /**
17
+ * The path to the file to which IntrospeQL should write output. Only valid
18
+ * if `writeToDisk` is `true`.
19
+ */
20
+ outFile: zod_1.z.string({
21
+ message: 'outFile is required if writeToDisk is true',
22
+ }),
23
+ }),
24
+ zod_1.z.object({
25
+ /**
26
+ * If set to `true` (the default), IntrospeQL will save the output to the
27
+ * file specified in the `outFile` option.
28
+ *
29
+ * If `false`, IntrospeQL will return the output as a string as it usually
30
+ * would, but will not save this string to disk. Useful for testing or if
31
+ * further processing is required before the output is saved.
32
+ */
33
+ writeToDisk: zod_1.z.literal(false),
34
+ /**
35
+ * The path to the file to which IntrospeQL should write output. Only valid
36
+ * if `writeToDisk` is `true`.
37
+ */
38
+ outFile: zod_1.z.undefined().optional(),
39
+ }),
40
+ ]);
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const tableOptions: z.ZodIntersection<z.ZodObject<{
3
+ mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
4
+ inclusive: "inclusive";
5
+ exclusive: "exclusive";
6
+ }>>>;
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>]>>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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
+ ]));
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export declare const enumDataSchema: z.ZodObject<{
3
+ oid: z.ZodCoercedNumber<unknown>;
4
+ schema: z.ZodString;
5
+ name: z.ZodString;
6
+ values: z.ZodArray<z.ZodString>;
7
+ comment: z.ZodNullable<z.ZodString>;
8
+ }, z.core.$strip>;
9
+ export type EnumData = z.infer<typeof enumDataSchema>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enumDataSchema = void 0;
4
+ var zod_1 = require("zod");
5
+ exports.enumDataSchema = zod_1.z.object({
6
+ oid: zod_1.z.coerce.number(),
7
+ schema: zod_1.z.string(),
8
+ name: zod_1.z.string(),
9
+ values: zod_1.z.string().array(),
10
+ comment: zod_1.z.string().nullable(),
11
+ });
@@ -0,0 +1,7 @@
1
+ export declare class EnumDefinition {
2
+ private pgEnumName;
3
+ private values;
4
+ private comment?;
5
+ constructor(pgEnumName: string, values: string[], comment?: string);
6
+ toString(): string;
7
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnumDefinition = void 0;
4
+ var shared_1 = require("../shared");
5
+ var EnumDefinition = /** @class */ (function () {
6
+ function EnumDefinition(pgEnumName, values, comment) {
7
+ this.pgEnumName = pgEnumName;
8
+ this.values = values;
9
+ this.comment = comment;
10
+ }
11
+ EnumDefinition.prototype.toString = function () {
12
+ var tsEnumName = (0, shared_1.convertPGIdentifierToTSIdentifier)(this.pgEnumName);
13
+ if (this.values.length === 0)
14
+ return "export type ".concat(tsEnumName, " = never;");
15
+ var typeDefinition = this.values.map(function (v) { return "'".concat(v, "'"); }).join(' |\n');
16
+ var stringified = "export type ".concat(tsEnumName, " = |\n").concat((0, shared_1.indent)(typeDefinition, 2), ";");
17
+ if (this.comment) {
18
+ stringified = this.comment + '\n' + stringified;
19
+ }
20
+ return stringified;
21
+ };
22
+ return EnumDefinition;
23
+ }());
24
+ exports.EnumDefinition = EnumDefinition;
@@ -0,0 +1,4 @@
1
+ export * from './enum-data';
2
+ export * from './enum-definition';
3
+ export * from './is-enum-replaced-with-custom-type';
4
+ export * from './read-enum-data';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enum-data"), exports);
18
+ __exportStar(require("./enum-definition"), exports);
19
+ __exportStar(require("./is-enum-replaced-with-custom-type"), exports);
20
+ __exportStar(require("./read-enum-data"), exports);
@@ -0,0 +1,3 @@
1
+ import type { EnumData } from './enum-data';
2
+ import type { ParsedConfig } from '../config';
3
+ export declare function isEnumReplacedWithCustomType(enumData: EnumData, config: ParsedConfig): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEnumReplacedWithCustomType = isEnumReplacedWithCustomType;
4
+ function isEnumReplacedWithCustomType(enumData, config) {
5
+ var enumIdentifier = enumData.schema + '.' + enumData.name;
6
+ var customTypeIdentifiers = Object.keys(config.types);
7
+ var enumIsReplacedWithCustomType = customTypeIdentifiers.includes(enumIdentifier);
8
+ return enumIsReplacedWithCustomType;
9
+ }
@@ -0,0 +1,3 @@
1
+ import { type EnumData } from './enum-data';
2
+ import type { Client } from 'pg';
3
+ export declare function readEnumData(client: Client, typeOID: number): Promise<EnumData>;