@supabase/postgrest-typegen 0.1.0 → 0.2.1
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/README.md +4 -0
- package/dist/generation/go.js +30 -2
- package/dist/generation/python.js +24 -10
- package/dist/generation/swift.js +43 -1
- package/dist/generation/typescript.d.ts +7 -0
- package/dist/generation/typescript.js +37 -11
- package/dist/introspection/index.js +27 -21
- package/dist/introspection/sql/columns.sql.js +19 -2
- package/dist/introspection/sql/foreign_tables.sql.js +1 -1
- package/dist/introspection/sql/functions.sql.js +1 -1
- package/dist/introspection/sql/helpers.d.ts +1 -1
- package/dist/introspection/sql/helpers.js +2 -2
- package/dist/introspection/sql/materialized_views.sql.js +1 -1
- package/dist/introspection/sql/pg-format.d.ts +21 -0
- package/dist/introspection/sql/pg-format.js +92 -0
- package/dist/introspection/sql/primary_keys.sql.js +1 -1
- package/dist/introspection/sql/schemas.sql.js +1 -1
- package/dist/introspection/sql/table.sql.js +1 -1
- package/dist/introspection/sql/types.sql.js +1 -1
- package/dist/introspection/sql/views.sql.js +7 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.js +9 -0
- package/package.json +2 -5
- package/src/generation/go.ts +31 -2
- package/src/generation/python.ts +25 -10
- package/src/generation/swift.ts +44 -1
- package/src/generation/typescript.ts +53 -10
- package/src/introspection/index.ts +41 -38
- package/src/introspection/sql/columns.sql.ts +19 -2
- package/src/introspection/sql/foreign_tables.sql.ts +1 -1
- package/src/introspection/sql/functions.sql.ts +1 -1
- package/src/introspection/sql/helpers.ts +2 -2
- package/src/introspection/sql/materialized_views.sql.ts +1 -1
- package/src/introspection/sql/pg-format.ts +101 -0
- package/src/introspection/sql/primary_keys.sql.ts +1 -1
- package/src/introspection/sql/schemas.sql.ts +1 -1
- package/src/introspection/sql/table.sql.ts +1 -1
- package/src/introspection/sql/types.sql.ts +1 -1
- package/src/introspection/sql/views.sql.ts +7 -1
- package/src/types.ts +9 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { literal } from "pg-format";
|
|
1
|
+
import { literal } from "./pg-format.ts";
|
|
2
2
|
import type { SQLQueryPropsWithSchemaFilterAndIdsFilter } from "./common.ts";
|
|
3
3
|
|
|
4
4
|
export const VIEWS_SQL = (
|
|
@@ -12,6 +12,12 @@ SELECT
|
|
|
12
12
|
c.relname AS name,
|
|
13
13
|
-- See definition of information_schema.views
|
|
14
14
|
(pg_relation_is_updatable(c.oid, false) & 20) = 20 AS is_updatable,
|
|
15
|
+
-- Passing include_triggers => true also counts views made writable by
|
|
16
|
+
-- INSTEAD OF triggers (and INSTEAD rules), which PostgREST can write
|
|
17
|
+
-- through even when the view is not auto-updatable. Bit 8 is INSERT,
|
|
18
|
+
-- bit 4 is UPDATE (see information_schema.views).
|
|
19
|
+
(pg_relation_is_updatable(c.oid, true) & 8) = 8 AS is_insert_enabled,
|
|
20
|
+
(pg_relation_is_updatable(c.oid, true) & 4) = 4 AS is_update_enabled,
|
|
15
21
|
obj_description(c.oid) AS comment
|
|
16
22
|
FROM
|
|
17
23
|
pg_class c
|
package/src/types.ts
CHANGED
|
@@ -156,6 +156,15 @@ const postgresViewSchema = type({
|
|
|
156
156
|
schema: "string",
|
|
157
157
|
name: "string",
|
|
158
158
|
is_updatable: "boolean",
|
|
159
|
+
/**
|
|
160
|
+
* Whether INSERT works through this view: auto-updatable per
|
|
161
|
+
* `pg_relation_is_updatable`, or made insertable by an INSTEAD OF INSERT
|
|
162
|
+
* trigger. Tracked separately from `is_updatable` (which mirrors
|
|
163
|
+
* `information_schema.views` and ignores triggers).
|
|
164
|
+
*/
|
|
165
|
+
is_insert_enabled: "boolean",
|
|
166
|
+
/** Same as `is_insert_enabled`, for UPDATE. */
|
|
167
|
+
is_update_enabled: "boolean",
|
|
159
168
|
comment: "string | null",
|
|
160
169
|
"columns?": postgresColumnSchema.array(),
|
|
161
170
|
});
|