@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.
Files changed (40) hide show
  1. package/README.md +4 -0
  2. package/dist/generation/go.js +30 -2
  3. package/dist/generation/python.js +24 -10
  4. package/dist/generation/swift.js +43 -1
  5. package/dist/generation/typescript.d.ts +7 -0
  6. package/dist/generation/typescript.js +37 -11
  7. package/dist/introspection/index.js +27 -21
  8. package/dist/introspection/sql/columns.sql.js +19 -2
  9. package/dist/introspection/sql/foreign_tables.sql.js +1 -1
  10. package/dist/introspection/sql/functions.sql.js +1 -1
  11. package/dist/introspection/sql/helpers.d.ts +1 -1
  12. package/dist/introspection/sql/helpers.js +2 -2
  13. package/dist/introspection/sql/materialized_views.sql.js +1 -1
  14. package/dist/introspection/sql/pg-format.d.ts +21 -0
  15. package/dist/introspection/sql/pg-format.js +92 -0
  16. package/dist/introspection/sql/primary_keys.sql.js +1 -1
  17. package/dist/introspection/sql/schemas.sql.js +1 -1
  18. package/dist/introspection/sql/table.sql.js +1 -1
  19. package/dist/introspection/sql/types.sql.js +1 -1
  20. package/dist/introspection/sql/views.sql.js +7 -1
  21. package/dist/types.d.ts +4 -0
  22. package/dist/types.js +9 -0
  23. package/package.json +2 -5
  24. package/src/generation/go.ts +31 -2
  25. package/src/generation/python.ts +25 -10
  26. package/src/generation/swift.ts +44 -1
  27. package/src/generation/typescript.ts +53 -10
  28. package/src/introspection/index.ts +41 -38
  29. package/src/introspection/sql/columns.sql.ts +19 -2
  30. package/src/introspection/sql/foreign_tables.sql.ts +1 -1
  31. package/src/introspection/sql/functions.sql.ts +1 -1
  32. package/src/introspection/sql/helpers.ts +2 -2
  33. package/src/introspection/sql/materialized_views.sql.ts +1 -1
  34. package/src/introspection/sql/pg-format.ts +101 -0
  35. package/src/introspection/sql/primary_keys.sql.ts +1 -1
  36. package/src/introspection/sql/schemas.sql.ts +1 -1
  37. package/src/introspection/sql/table.sql.ts +1 -1
  38. package/src/introspection/sql/types.sql.ts +1 -1
  39. package/src/introspection/sql/views.sql.ts +7 -1
  40. 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 { SQLQueryProps } from "./common.ts";
3
3
 
4
4
  export const SCHEMAS_SQL = (
@@ -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 TABLES_SQL = (
@@ -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 TYPES_SQL = (
@@ -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
  });