pg-codegen 2.1.5

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/query.js ADDED
@@ -0,0 +1,424 @@
1
+ "use strict";
2
+ /*
3
+ * IMPORTANT: when editing this file, ensure all operators (e.g. `@>`) are
4
+ * specified in the correct namespace (e.g. `operator(pg_catalog.@>)`). It looks
5
+ * weird, but it prevents clashes with extensions or user code that may
6
+ * overload operators, e.g. extension `intarray` overloads `@>`.
7
+ *
8
+ * NOTE: I'm not doing this with `=` because that way lies madness.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.makeIntrospectionQuery = void 0;
12
+ const makeIntrospectionQuery = (serverVersionNum, options = {}) => {
13
+ const { pgLegacyFunctionsOnly = false, pgIgnoreRBAC = true } = options;
14
+ const unionRBAC = `
15
+ union all
16
+ select pg_roles.oid _oid, pg_roles.*
17
+ from pg_roles, accessible_roles, pg_auth_members
18
+ where pg_auth_members.roleid = pg_roles.oid
19
+ and pg_auth_members.member = accessible_roles._oid
20
+ `;
21
+ return `\
22
+ -- @see https://www.postgresql.org/docs/9.5/static/catalogs.html
23
+ -- @see https://github.com/graphile/graphile-engine/blob/master/packages/graphile-build-pg/src/plugins/introspectionQuery.js
24
+ --
25
+ -- ## Parameters
26
+ -- - \`$1\`: An array of strings that represent the namespaces we are introspecting.
27
+ -- - \`$2\`: set true to include functions/tables/etc that come from extensions
28
+ with
29
+ ${!pgIgnoreRBAC ? 'recursive' : ''} accessible_roles(_oid) as (
30
+ select oid _oid, pg_roles.*
31
+ from pg_roles
32
+ where rolname = current_user
33
+ ${!pgIgnoreRBAC ? unionRBAC : ''}
34
+ ),
35
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-namespace.html
36
+ namespace as (
37
+ select
38
+ 'namespace' as "kind",
39
+ nsp.oid as "id",
40
+ nsp.nspname as "name",
41
+ dsc.description as "description"
42
+ from
43
+ pg_catalog.pg_namespace as nsp
44
+ left join pg_catalog.pg_description as dsc on dsc.objoid = nsp.oid and dsc.classoid = 'pg_catalog.pg_namespace'::regclass
45
+ where
46
+ nsp.nspname = any ($1)
47
+ order by
48
+ nsp.nspname
49
+ ),
50
+ -- Select all of the remote procedures we can use in this schema. This comes
51
+ -- first so that we can select types and classes using the information we get
52
+ -- from it.
53
+ --
54
+ -- @see https://www.postgresql.org/docs/9.6/static/catalog-pg-proc.html
55
+ procedure as (
56
+ select
57
+ 'procedure' as "kind",
58
+ pro.oid as "id",
59
+ pro.proname as "name",
60
+ dsc.description as "description",
61
+ pro.pronamespace as "namespaceId",
62
+ nsp.nspname as "namespaceName",
63
+ pro.proisstrict as "isStrict",
64
+ pro.proretset as "returnsSet",
65
+ case
66
+ when pro.provolatile = 'i' then true
67
+ when pro.provolatile = 's' then true
68
+ else false
69
+ end as "isStable",
70
+ pro.prorettype as "returnTypeId",
71
+ coalesce(pro.proallargtypes, pro.proargtypes) as "argTypeIds",
72
+ coalesce(pro.proargmodes, array[]::text[]) as "argModes",
73
+ coalesce(pro.proargnames, array[]::text[]) as "argNames",
74
+ pro.pronargs as "inputArgsCount",
75
+ pro.pronargdefaults as "argDefaultsNum",
76
+ pro.procost as "cost",
77
+ exists(select 1 from accessible_roles where has_function_privilege(accessible_roles.oid, pro.oid, 'EXECUTE')) as "aclExecutable",
78
+ (select lanname from pg_catalog.pg_language where pg_language.oid = pro.prolang) as "language"
79
+ from
80
+ pg_catalog.pg_proc as pro
81
+ left join pg_catalog.pg_description as dsc on dsc.objoid = pro.oid and dsc.classoid = 'pg_catalog.pg_proc'::regclass
82
+ left join pg_catalog.pg_namespace as nsp on nsp.oid = pro.pronamespace
83
+ where
84
+ pro.pronamespace in (select "id" from namespace) and
85
+ -- Currently we don’t support functions with variadic arguments. In the
86
+ -- future we may, but for now let’s just ignore functions with variadic
87
+ -- arguments.
88
+ -- TODO: Variadic arguments.
89
+ pro.provariadic = 0 and
90
+ -- Filter our aggregate functions and window functions.
91
+ ${serverVersionNum >= 110000
92
+ ? "pro.prokind = 'f'"
93
+ : 'pro.proisagg = false and pro.proiswindow = false'} and
94
+ ${pgLegacyFunctionsOnly
95
+ ? `\
96
+ -- We want to make sure the argument mode for all of our arguments is
97
+ -- \`IN\` which means \`proargmodes\` will be null.
98
+ pro.proargmodes is null and
99
+ -- Do not select procedures that return \`RECORD\` (oid 2249).
100
+ pro.prorettype operator(pg_catalog.<>) 2249 and`
101
+ : `\
102
+ -- We want to make sure the argument modes for all of our arguments are
103
+ -- \`IN\`, \`OUT\`, \`INOUT\`, or \`TABLE\` (not \`VARIADIC\`).
104
+ (pro.proargmodes is null or pro.proargmodes operator(pg_catalog.<@) array['i','o','b','t']::"char"[]) and
105
+ -- Do not select procedures that return \`RECORD\` (oid 2249) unless they
106
+ -- have \`OUT\`, \`INOUT\`, or \`TABLE\` arguments to define the return type.
107
+ (pro.prorettype operator(pg_catalog.<>) 2249 or pro.proargmodes && array['o','b','t']::"char"[]) and
108
+ -- Do not select procedures that have \`RECORD\` arguments.
109
+ (pro.proallargtypes is null or not (pro.proallargtypes operator(pg_catalog.@>) array[2249::oid])) and`}
110
+ -- Do not select procedures that create range types. These are utility
111
+ -- functions that really don’t need to be exposed in an API.
112
+ pro.proname not in (
113
+ select typ.typname
114
+ from pg_catalog.pg_type as typ
115
+ where typ.typtype = 'r'
116
+ and typ.typnamespace = pro.pronamespace
117
+ ) and
118
+ -- Do not expose trigger functions (type trigger has oid 2279)
119
+ pro.prorettype operator(pg_catalog.<>) 2279 and
120
+ -- We don't want functions that will clash with GraphQL (treat them as private)
121
+ pro.proname not like E'\\\\_\\\\_%' and
122
+ -- We also don’t want procedures that have been defined in our namespace
123
+ -- twice. This leads to duplicate fields in the API which throws an
124
+ -- error. In the future we may support this case. For now though, it is
125
+ -- too complex.
126
+ (
127
+ select count(pro2.*)
128
+ from pg_catalog.pg_proc as pro2
129
+ where pro2.pronamespace = pro.pronamespace
130
+ and pro2.proname = pro.proname
131
+ ) = 1 and
132
+ ($2 is true or not exists(
133
+ select 1
134
+ from pg_catalog.pg_depend
135
+ where pg_depend.refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass
136
+ and pg_depend.deptype = 'e'
137
+ and pg_depend.classid = 'pg_catalog.pg_proc'::pg_catalog.regclass
138
+ and pg_depend.objid = pro.oid
139
+ ))
140
+ order by
141
+ pro.pronamespace, pro.proname
142
+ ),
143
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-class.html
144
+ class as (
145
+ select
146
+ 'class' as "kind",
147
+ rel.oid as "id",
148
+ rel.relname as "name",
149
+ rel.relkind as "classKind",
150
+ dsc.description as "description",
151
+ rel.relnamespace as "namespaceId",
152
+ nsp.nspname as "namespaceName",
153
+ rel.reltype as "typeId",
154
+ -- Here we determine whether or not we can use this class in a
155
+ -- \`SELECT\`’s \`FROM\` clause. In order to determine this we look at them
156
+ -- \`relkind\` column, if it is \`i\` (index) or \`c\` (composite), we cannot
157
+ -- select this class. Otherwise we can.
158
+ rel.relkind not in ('i', 'c') as "isSelectable",
159
+ -- Here we are determining whether we can insert/update/delete a class.
160
+ -- This is helpful as it lets us detect non-updatable views and then
161
+ -- exclude them from being inserted/updated/deleted into. For more info
162
+ -- on how \`pg_catalog.pg_relation_is_updatable\` works:
163
+ --
164
+ -- - https://www.postgresql.org/message-id/CAEZATCV2_qN9P3zbvADwME_TkYf2gR_X2cLQR4R+pqkwxGxqJg@mail.gmail.com
165
+ -- - https://github.com/postgres/postgres/blob/2410a2543e77983dab1f63f48b2adcd23dba994e/src/backend/utils/adt/misc.c#L684
166
+ -- - https://github.com/postgres/postgres/blob/3aff33aa687e47d52f453892498b30ac98a296af/src/backend/rewrite/rewriteHandler.c#L2351
167
+ (pg_catalog.pg_relation_is_updatable(rel.oid, true)::bit(8) operator(pg_catalog.&) B'00010000') = B'00010000' as "isDeletable",
168
+ (pg_catalog.pg_relation_is_updatable(rel.oid, true)::bit(8) operator(pg_catalog.&) B'00001000') = B'00001000' as "isInsertable",
169
+ (pg_catalog.pg_relation_is_updatable(rel.oid, true)::bit(8) operator(pg_catalog.&) B'00000100') = B'00000100' as "isUpdatable",
170
+ exists(select 1 from accessible_roles where has_table_privilege(accessible_roles.oid, rel.oid, 'SELECT')) as "aclSelectable",
171
+ exists(select 1 from accessible_roles where has_table_privilege(accessible_roles.oid, rel.oid, 'INSERT')) as "aclInsertable",
172
+ exists(select 1 from accessible_roles where has_table_privilege(accessible_roles.oid, rel.oid, 'UPDATE')) as "aclUpdatable",
173
+ exists(select 1 from accessible_roles where has_table_privilege(accessible_roles.oid, rel.oid, 'DELETE')) as "aclDeletable"
174
+ from
175
+ pg_catalog.pg_class as rel
176
+ left join pg_catalog.pg_description as dsc on dsc.objoid = rel.oid and dsc.objsubid = 0 and dsc.classoid = 'pg_catalog.pg_class'::regclass
177
+ left join pg_catalog.pg_namespace as nsp on nsp.oid = rel.relnamespace
178
+ where
179
+ rel.relpersistence in ('p') and
180
+ -- We don't want classes that will clash with GraphQL (treat them as private)
181
+ rel.relname not like E'\\\\_\\\\_%' and
182
+ rel.relkind in ('r', 'v', 'm', 'c', 'f') and
183
+ ($2 is true or not exists(
184
+ select 1
185
+ from pg_catalog.pg_depend
186
+ where pg_depend.refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass
187
+ and pg_depend.deptype = 'e'
188
+ and pg_depend.classid = 'pg_catalog.pg_class'::pg_catalog.regclass
189
+ and pg_depend.objid = rel.oid
190
+ ))
191
+ order by
192
+ rel.relnamespace, rel.relname
193
+ ),
194
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-attribute.html
195
+ attribute as (
196
+ select
197
+ 'attribute' as "kind",
198
+ att.attrelid as "classId",
199
+ att.attnum as "num",
200
+ att.attname as "name",
201
+ dsc.description as "description",
202
+ att.atttypid as "typeId",
203
+ nullif(att.atttypmod, -1) as "typeModifier",
204
+ att.attnotnull as "isNotNull",
205
+ att.atthasdef as "hasDefault",
206
+ ${serverVersionNum >= 100000 ? 'att.attidentity' : "''"} as "identity",
207
+ exists(select 1 from accessible_roles where has_column_privilege(accessible_roles.oid, att.attrelid, att.attname, 'SELECT')) as "aclSelectable",
208
+ exists(select 1 from accessible_roles where has_column_privilege(accessible_roles.oid, att.attrelid, att.attname, 'INSERT')) as "aclInsertable",
209
+ exists(select 1 from accessible_roles where has_column_privilege(accessible_roles.oid, att.attrelid, att.attname, 'UPDATE')) as "aclUpdatable",
210
+ -- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=c62dd80cdf149e2792b13c13777a539f5abb0370
211
+ att.attacl is not null and exists(select 1 from aclexplode(att.attacl) aclitem where aclitem.privilege_type = 'SELECT' and grantee in (select oid from accessible_roles)) as "columnLevelSelectGrant"
212
+ from
213
+ pg_catalog.pg_attribute as att
214
+ left join pg_catalog.pg_description as dsc on dsc.objoid = att.attrelid and dsc.objsubid = att.attnum and dsc.classoid = 'pg_catalog.pg_class'::regclass
215
+ where
216
+ att.attrelid in (select "id" from class) and
217
+ att.attnum > 0 and
218
+ -- We don't want attributes that will clash with GraphQL (treat them as private)
219
+ att.attname not like E'\\\\_\\\\_%' and
220
+ not att.attisdropped
221
+ order by
222
+ att.attrelid, att.attnum
223
+ ),
224
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-type.html
225
+ type as (
226
+ -- Use another \`WITH\` statement here, because our \`WHERE\` clause will need
227
+ -- to use it.
228
+ with type_all as (
229
+ select
230
+ 'type' as "kind",
231
+ typ.oid as "id",
232
+ typ.typname as "name",
233
+ dsc.description as "description",
234
+ typ.typnamespace as "namespaceId",
235
+ -- We include the namespace name in types only because we select so
236
+ -- many types that are outside of our core set of namespaces. Having
237
+ -- the namespace name is super helpful when generating SQL, so
238
+ -- conditionally having namespace names for types is a pain.
239
+ nsp.nspname as "namespaceName",
240
+ typ.typtype as "type",
241
+ typ.typcategory as "category",
242
+ typ.typnotnull as "domainIsNotNull",
243
+ nullif(typ.typelem, 0) as "arrayItemTypeId",
244
+ typ.typlen as "typeLength",
245
+ (typ.typelem <> 0 and typ.typlen = -1) as "isPgArray",
246
+ nullif(typ.typrelid, 0) as "classId",
247
+ nullif(typ.typbasetype, 0) as "domainBaseTypeId",
248
+ nullif(typ.typtypmod, -1) as "domainTypeModifier",
249
+ typ.typdefaultbin is not null as "domainHasDefault",
250
+ -- If this type is an enum type, let’s select all of its enum variants.
251
+ --
252
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-enum.html
253
+ case
254
+ when typ.typtype = 'e' then array(
255
+ select enm.enumlabel
256
+ from pg_catalog.pg_enum as enm
257
+ where enm.enumtypid = typ.oid
258
+ order by enm.enumsortorder
259
+ )
260
+ else null
261
+ end as "enumVariants",
262
+ -- If this type is a range type, we want to select the sub type of the
263
+ -- range.
264
+ --
265
+ -- @see https://www.postgresql.org/docs/9.6/static/catalog-pg-range.html
266
+ case
267
+ when typ.typtype = 'r' then (
268
+ select rng.rngsubtype
269
+ from pg_catalog.pg_range as rng
270
+ where rng.rngtypid = typ.oid
271
+ limit 1
272
+ )
273
+ else null
274
+ end as "rangeSubTypeId"
275
+ from
276
+ pg_catalog.pg_type as typ
277
+ left join pg_catalog.pg_description as dsc on dsc.objoid = typ.oid and dsc.classoid = 'pg_catalog.pg_type'::regclass
278
+ left join pg_catalog.pg_namespace as nsp on nsp.oid = typ.typnamespace
279
+ )
280
+ select
281
+ *
282
+ from
283
+ type_all as typ
284
+ where
285
+ typ.id in (
286
+ select "typeId" from class
287
+ union all
288
+ select "typeId" from attribute
289
+ union all
290
+ select "returnTypeId" from procedure
291
+ union all
292
+ select unnest("argTypeIds") from procedure
293
+ union all
294
+ -- If this type is a base type for *any* domain type, we will include it
295
+ -- in our selection. This may mean we fetch more types than we need, but
296
+ -- the alternative is to do some funky SQL recursion which would be hard
297
+ -- code to read. So we prefer code readability over selecting like 3 or
298
+ -- 4 less type rows.
299
+ --
300
+ -- We also do this for range sub types and array item types.
301
+ select "domainBaseTypeId" from type_all
302
+ union all
303
+ select "rangeSubTypeId" from type_all
304
+ union all
305
+ select "arrayItemTypeId" from type_all
306
+ )
307
+ order by
308
+ "namespaceId", "name"
309
+ ),
310
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-constraint.html
311
+ "constraint" as (
312
+ select distinct on (con.conrelid, con.conkey, con.confrelid, con.confkey)
313
+ 'constraint' as "kind",
314
+ con.oid as "id",
315
+ con.conname as "name",
316
+ con.contype as "type",
317
+ con.conrelid as "classId",
318
+ nullif(con.confrelid, 0) as "foreignClassId",
319
+ dsc.description as "description",
320
+ con.conkey as "keyAttributeNums",
321
+ con.confkey as "foreignKeyAttributeNums"
322
+ from
323
+ pg_catalog.pg_constraint as con
324
+ inner join class on (con.conrelid = class.id)
325
+ left join pg_catalog.pg_description as dsc on dsc.objoid = con.oid and dsc.classoid = 'pg_catalog.pg_constraint'::regclass
326
+ where
327
+ -- Only get constraints for classes we have selected.
328
+ con.conrelid in (select "id" from class where "namespaceId" in (select "id" from namespace)) and
329
+ case
330
+ -- If this is a foreign key constraint, we want to ensure that the
331
+ -- foreign class is also in the list of classes we have already
332
+ -- selected.
333
+ when con.contype = 'f' then con.confrelid in (select "id" from class where "namespaceId" in (select "id" from namespace))
334
+ -- Otherwise, this should be true.
335
+ else true
336
+ end and
337
+ -- We only want foreign key, primary key, and unique constraints. We
338
+ -- made add support for more constraints in the future.
339
+ con.contype in ('f', 'p', 'u')
340
+ order by
341
+ con.conrelid, con.conkey, con.confrelid, con.confkey, con.conname
342
+ ),
343
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-extension.html
344
+ "extension" as (
345
+ select
346
+ 'extension' as "kind",
347
+ ext.oid as "id",
348
+ ext.extname as "name",
349
+ ext.extnamespace as "namespaceId",
350
+ nsp.nspname as "namespaceName",
351
+ ext.extrelocatable as "relocatable",
352
+ ext.extversion as "version",
353
+ ext.extconfig as "configurationClassIds",
354
+ dsc.description as "description"
355
+ from
356
+ pg_catalog.pg_extension as ext
357
+ left join pg_catalog.pg_description as dsc on dsc.objoid = ext.oid and dsc.classoid = 'pg_catalog.pg_extension'::regclass
358
+ left join pg_catalog.pg_namespace as nsp on nsp.oid = ext.extnamespace
359
+ order by
360
+ ext.extname, ext.oid
361
+ ),
362
+ -- @see https://www.postgresql.org/docs/9.5/static/catalog-pg-index.html
363
+ "indexes" as (
364
+ select
365
+ 'index' as "kind",
366
+ idx.indexrelid as "id",
367
+ idx_more.relname as "name",
368
+ nsp.nspname as "namespaceName",
369
+ idx.indrelid as "classId",
370
+ idx.indnatts as "numberOfAttributes",
371
+ idx.indisunique as "isUnique",
372
+ idx.indisprimary as "isPrimary",
373
+ idx.indimmediate as "isImmediate", -- enforce uniqueness immediately on insert
374
+ idx.indisreplident as "isReplicaIdentity",
375
+ idx.indisvalid as "isValid", -- if false, don't use for queries
376
+ idx.indpred is not null as "isPartial", -- if true, index is not on on rows.
377
+ idx.indkey as "attributeNums",
378
+ am.amname as "indexType",
379
+ ${serverVersionNum >= 90600
380
+ ? `\
381
+ (
382
+ select array_agg(pg_index_column_has_property(idx.indexrelid,n::int2,'asc'))
383
+ from unnest(idx.indkey) with ordinality as ord(key,n)
384
+ ) as "attributePropertiesAsc",
385
+ (
386
+ select array_agg(pg_index_column_has_property(idx.indexrelid,n::int2,'nulls_first'))
387
+ from unnest(idx.indkey) with ordinality as ord(key,n)
388
+ ) as "attributePropertiesNullsFirst",`
389
+ : ''}
390
+ dsc.description as "description"
391
+ from
392
+ pg_catalog.pg_index as idx
393
+ inner join pg_catalog.pg_class idx_more on (idx.indexrelid = idx_more.oid)
394
+ inner join class on (idx.indrelid = class.id)
395
+ inner join pg_catalog.pg_namespace as nsp on (nsp.oid = idx_more.relnamespace)
396
+ inner join pg_catalog.pg_am as am on (am.oid = idx_more.relam)
397
+ left join pg_catalog.pg_description as dsc on dsc.objoid = idx.indexrelid and dsc.objsubid = 0 and dsc.classoid = 'pg_catalog.pg_class'::regclass
398
+ where
399
+ idx.indislive is not false and
400
+ idx.indisexclusion is not true and -- exclusion index
401
+ idx.indcheckxmin is not true and -- always valid?
402
+ idx.indpred is null -- no partial index predicate
403
+ order by
404
+ idx.indrelid, idx.indexrelid
405
+ )
406
+ select row_to_json(x) as object from namespace as x
407
+ union all
408
+ select row_to_json(x) as object from class as x
409
+ union all
410
+ select row_to_json(x) as object from attribute as x
411
+ union all
412
+ select row_to_json(x) as object from type as x
413
+ union all
414
+ select row_to_json(x) as object from "constraint" as x
415
+ union all
416
+ select row_to_json(x) as object from procedure as x
417
+ union all
418
+ select row_to_json(x) as object from extension as x
419
+ union all
420
+ select row_to_json(x) as object from indexes as x
421
+ ;
422
+ `;
423
+ };
424
+ exports.makeIntrospectionQuery = makeIntrospectionQuery;
package/types.d.ts ADDED
@@ -0,0 +1,128 @@
1
+ export type Namespace = {
2
+ kind: 'namespace';
3
+ id: string;
4
+ name: string;
5
+ description: string | null;
6
+ };
7
+ export type Procedure = {
8
+ kind: 'procedure';
9
+ id: string;
10
+ name: string;
11
+ description: string | null;
12
+ namespaceId: string;
13
+ namespaceName: string;
14
+ isStrict: boolean;
15
+ returnsSet: boolean;
16
+ isStable: boolean;
17
+ returnTypeId: string;
18
+ argTypeIds: string[];
19
+ argModes: string[];
20
+ argNames: string[];
21
+ inputArgsCount: number;
22
+ argDefaultsNum: number | null;
23
+ cost: number;
24
+ aclExecutable: boolean;
25
+ language: string | null;
26
+ };
27
+ export type Class = {
28
+ kind: 'class';
29
+ id: string;
30
+ name: string;
31
+ classKind: string;
32
+ description: string | null;
33
+ namespaceId: string;
34
+ namespaceName: string;
35
+ typeId: string;
36
+ isSelectable: boolean;
37
+ isDeletable: boolean;
38
+ isInsertable: boolean;
39
+ isUpdatable: boolean;
40
+ aclSelectable: boolean;
41
+ aclInsertable: boolean;
42
+ aclUpdatable: boolean;
43
+ aclDeletable: boolean;
44
+ };
45
+ export type Attribute = {
46
+ kind: 'attribute';
47
+ classId: string;
48
+ num: number;
49
+ name: string;
50
+ description: string | null;
51
+ typeId: string;
52
+ typeModifier: number | null;
53
+ isNotNull: boolean;
54
+ hasDefault: boolean;
55
+ identity: string;
56
+ aclSelectable: boolean;
57
+ aclInsertable: boolean;
58
+ aclUpdatable: boolean;
59
+ columnLevelSelectGrant: boolean;
60
+ };
61
+ export type Type = {
62
+ kind: 'type';
63
+ id: string;
64
+ name: string;
65
+ description: string | null;
66
+ namespaceId: string;
67
+ namespaceName: string;
68
+ type: string;
69
+ category: string;
70
+ domainIsNotNull: boolean;
71
+ arrayItemTypeId: string | null;
72
+ typeLength: number;
73
+ isPgArray: boolean;
74
+ classId: string | null;
75
+ domainBaseTypeId: string | null;
76
+ domainTypeModifier: number | null;
77
+ domainHasDefault: boolean;
78
+ enumVariants: string[] | null;
79
+ rangeSubTypeId: string | null;
80
+ };
81
+ export type Constraint = {
82
+ kind: 'constraint';
83
+ id: string;
84
+ name: string;
85
+ type: string;
86
+ classId: string;
87
+ foreignClassId: string | null;
88
+ description: string | null;
89
+ keyAttributeNums: number[];
90
+ foreignKeyAttributeNums: number[] | null;
91
+ };
92
+ export type Extension = {
93
+ kind: 'extension';
94
+ id: string;
95
+ name: string;
96
+ namespaceId: string;
97
+ namespaceName: string;
98
+ relocatable: boolean;
99
+ version: string;
100
+ configurationClassIds: string[] | null;
101
+ description: string | null;
102
+ };
103
+ export type Index = {
104
+ kind: 'index';
105
+ id: string;
106
+ name: string;
107
+ namespaceName: string;
108
+ classId: string;
109
+ numberOfAttributes: number;
110
+ isUnique: boolean;
111
+ isPrimary: boolean;
112
+ isImmediate: boolean;
113
+ isReplicaIdentity: boolean;
114
+ isValid: boolean;
115
+ isPartial: boolean;
116
+ attributeNums: number[];
117
+ indexType: string;
118
+ attributePropertiesAsc: boolean[];
119
+ attributePropertiesNullsFirst: boolean[];
120
+ description: string | null;
121
+ };
122
+ export type DatabaseObject = Namespace | Procedure | Class | Attribute | Type | Constraint | Extension | Index;
123
+ export type IntrospectionResult = {
124
+ object: DatabaseObject;
125
+ };
126
+ export type IntrospectionQueryResult = {
127
+ rows: IntrospectionResult[];
128
+ };
package/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });