@supabase/postgrest-typegen 0.3.0 → 0.3.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
CHANGED
|
@@ -127,6 +127,9 @@ import {
|
|
|
127
127
|
| `generatePython` | — |
|
|
128
128
|
| `generateSwift` | `{ accessControl?: 'internal' \| 'public' \| 'private' \| 'package' }` |
|
|
129
129
|
|
|
130
|
+
Every generator returns the complete contents of the generated file, ending
|
|
131
|
+
with a single newline, so consumers write the result as-is.
|
|
132
|
+
|
|
130
133
|
`generateTypescript` formats its output with `oxfmt` unless `format` is
|
|
131
134
|
supplied. `oxfmt` is an optional peer dependency, imported only when that
|
|
132
135
|
default runs: install it to use the default formatter, or pass your own
|
|
@@ -148,7 +151,7 @@ npm install oxfmt@0.66.0
|
|
|
148
151
|
|
|
149
152
|
## Releasing
|
|
150
153
|
|
|
151
|
-
Unlike the rest of this repo, merging a change here does not open a release pull request on its own. Releases are cut on demand: run the `Release postgrest-typegen` workflow from the Actions tab, which runs release-please against `release-please-config.postgrest-typegen.json` and opens (or updates) the release pull request for this package. Merging that pull request tags the release and publishes to npm.
|
|
154
|
+
Unlike the rest of this repo, merging a change here does not open a release pull request on its own. Releases are cut on demand: run the `Release postgrest-typegen` workflow from the Actions tab, which runs release-please against `release-please-config.postgrest-typegen.json` and opens (or updates) the release pull request for this package. Merging that pull request tags the release and publishes to npm. Once npm serves the new version, the same workflow opens a pull request that bumps the exact pin in `packages/typegen`.
|
|
152
155
|
|
|
153
156
|
## License
|
|
154
157
|
|
package/dist/generation/go.js
CHANGED
|
@@ -8,8 +8,7 @@ export const generateGo = ({ schemas, tables, views, materializedViews, columns,
|
|
|
8
8
|
return acc;
|
|
9
9
|
}, {});
|
|
10
10
|
const compositeTypes = types.filter((type) => type.attributes.length > 0);
|
|
11
|
-
let output = `
|
|
12
|
-
package database
|
|
11
|
+
let output = `package database
|
|
13
12
|
|
|
14
13
|
${tables
|
|
15
14
|
.filter((table) => schemas.some((schema) => schema.name === table.schema))
|
|
@@ -30,8 +29,8 @@ ${compositeTypes
|
|
|
30
29
|
.filter((compositeType) => schemas.some((schema) => schema.name === compositeType.schema))
|
|
31
30
|
.map((compositeType) => generateCompositeTypeStruct(schemas.find((schema) => schema.name === compositeType.schema), compositeType, types))
|
|
32
31
|
.join("\n\n")}
|
|
33
|
-
`.
|
|
34
|
-
return output
|
|
32
|
+
`.trimEnd();
|
|
33
|
+
return `${output}\n`;
|
|
35
34
|
};
|
|
36
35
|
/**
|
|
37
36
|
* Converts a Postgres name to PascalCase.
|
|
@@ -16,8 +16,7 @@ export const generatePython = ({ schemas, tables, views, materializedViews, colu
|
|
|
16
16
|
.map((type) => ctx.typeToClass(type));
|
|
17
17
|
const py_views = views.map((view) => ctx.viewToClass(view));
|
|
18
18
|
const py_matviews = materializedViews.map((matview) => ctx.matViewToClass(matview));
|
|
19
|
-
let output = `
|
|
20
|
-
from __future__ import annotations
|
|
19
|
+
let output = `from __future__ import annotations
|
|
21
20
|
|
|
22
21
|
import datetime
|
|
23
22
|
import uuid
|
|
@@ -43,8 +42,8 @@ ${concatLines(py_matviews)}
|
|
|
43
42
|
|
|
44
43
|
${concatLines(composite_types)}
|
|
45
44
|
|
|
46
|
-
`.
|
|
47
|
-
return output
|
|
45
|
+
`.trimEnd();
|
|
46
|
+
return `${output}\n`;
|
|
48
47
|
};
|
|
49
48
|
class PythonContext {
|
|
50
49
|
types;
|
package/dist/generation/swift.js
CHANGED
|
@@ -216,7 +216,7 @@ export const generateSwift = (metadata, opts = {}) => {
|
|
|
216
216
|
];
|
|
217
217
|
}),
|
|
218
218
|
];
|
|
219
|
-
return output.join("\n")
|
|
219
|
+
return `${output.join("\n")}\n`;
|
|
220
220
|
};
|
|
221
221
|
// TODO: Make this more robust. Currently doesn't handle range types - returns them as string.
|
|
222
222
|
const pgTypeToSwiftType = (pgType, nullable, { types, views, tables, }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/postgrest-typegen",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Type generation for PostgREST from PostgreSQL schemas",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/pg": "^8.23.1",
|
|
75
75
|
"knip": "^6.32.3",
|
|
76
76
|
"oxfmt": "0.66.0",
|
|
77
|
-
"oxlint": "1.
|
|
77
|
+
"oxlint": "1.85.0",
|
|
78
78
|
"oxlint-tsgolint": "7.0.2002",
|
|
79
79
|
"pg": "^8.23.0",
|
|
80
80
|
"testcontainers": "^12.1.0",
|
package/src/generation/go.ts
CHANGED
|
@@ -32,8 +32,7 @@ export const generateGo = ({
|
|
|
32
32
|
|
|
33
33
|
const compositeTypes = types.filter((type) => type.attributes.length > 0);
|
|
34
34
|
|
|
35
|
-
let output = `
|
|
36
|
-
package database
|
|
35
|
+
let output = `package database
|
|
37
36
|
|
|
38
37
|
${tables
|
|
39
38
|
.filter((table) => schemas.some((schema) => schema.name === table.schema))
|
|
@@ -88,9 +87,9 @@ ${compositeTypes
|
|
|
88
87
|
),
|
|
89
88
|
)
|
|
90
89
|
.join("\n\n")}
|
|
91
|
-
`.
|
|
90
|
+
`.trimEnd();
|
|
92
91
|
|
|
93
|
-
return output
|
|
92
|
+
return `${output}\n`;
|
|
94
93
|
};
|
|
95
94
|
|
|
96
95
|
/**
|
package/src/generation/python.ts
CHANGED
|
@@ -38,8 +38,7 @@ export const generatePython = ({
|
|
|
38
38
|
ctx.matViewToClass(matview),
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
let output = `
|
|
42
|
-
from __future__ import annotations
|
|
41
|
+
let output = `from __future__ import annotations
|
|
43
42
|
|
|
44
43
|
import datetime
|
|
45
44
|
import uuid
|
|
@@ -65,9 +64,9 @@ ${concatLines(py_matviews)}
|
|
|
65
64
|
|
|
66
65
|
${concatLines(composite_types)}
|
|
67
66
|
|
|
68
|
-
`.
|
|
67
|
+
`.trimEnd();
|
|
69
68
|
|
|
70
|
-
return output
|
|
69
|
+
return `${output}\n`;
|
|
71
70
|
};
|
|
72
71
|
|
|
73
72
|
interface Serializable {
|
package/src/generation/swift.ts
CHANGED