@supabase/postgrest-typegen 0.4.0 → 0.6.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.
package/dist/types.js CHANGED
@@ -150,6 +150,90 @@ const postgresViewSchema = type({
150
150
  comment: "string | null",
151
151
  "columns?": postgresColumnSchema.array(),
152
152
  });
153
+ /**
154
+ * A reference to a `types` entry by oid. `format` is the type's `name` (the
155
+ * same spelling `PostgresColumn.format` uses, `_` prefixed for arrays) and
156
+ * `type_schema` its schema; both are `null` when the type is not in `types`,
157
+ * which never happens in a document produced by `introspect()`.
158
+ */
159
+ const rpcTypeReferenceSchema = type({
160
+ type_id: "number",
161
+ format: "string | null",
162
+ type_schema: "string | null",
163
+ });
164
+ const rpcFunctionArgSchema = rpcTypeReferenceSchema.merge({
165
+ /** Empty for an unnamed parameter. */
166
+ name: "string",
167
+ mode: "'in' | 'inout' | 'variadic'",
168
+ has_default: "boolean",
169
+ /**
170
+ * The relation whose row type this parameter has, when that relation is in
171
+ * the metadata. A caller passes such a parameter as a row object.
172
+ */
173
+ relation_id: "number | null",
174
+ });
175
+ const rpcFunctionReturnsSchema = rpcTypeReferenceSchema.merge({
176
+ /**
177
+ * The relation whose rows the function returns, when that relation is in
178
+ * the metadata; the row shape is the relation's `columns`.
179
+ */
180
+ relation_id: "number | null",
181
+ /**
182
+ * The columns of a `RETURNS TABLE (…)` result, in name order; `null` for
183
+ * every other return type, including a record built from `OUT` parameters.
184
+ */
185
+ columns: rpcTypeReferenceSchema.merge({ name: "string" }).array().or("null"),
186
+ });
187
+ const rpcFunctionOverloadSchema = type({
188
+ /** The `functions` entry this overload was resolved from. */
189
+ function_id: "number",
190
+ /** The input parameters (`in`, `inout` and `variadic`), in name order. */
191
+ args: rpcFunctionArgSchema.array(),
192
+ returns: rpcFunctionReturnsSchema,
193
+ /** `true` when the response is an array of rows or values. */
194
+ is_set_returning: "boolean",
195
+ /** The planner's `ROWS` estimate of a set-returning function, else `null`. */
196
+ rows_estimate: "number | null",
197
+ /**
198
+ * Present when the result can be embedded and sub-selected like a relation.
199
+ * `to` names the relation (or composite type) whose rows come back, `from`
200
+ * the relation a sole row-typed parameter embeds from, or `*` when the
201
+ * function is called directly. `is_one_to_one` is `true` when at most one
202
+ * row comes back, so a client may unwrap the array. `is_setof_return`
203
+ * mirrors `is_set_returning`.
204
+ */
205
+ setof_options: type({
206
+ from: "string",
207
+ to: "string",
208
+ is_one_to_one: "boolean",
209
+ is_setof_return: "boolean",
210
+ }).or("null"),
211
+ /**
212
+ * The relation this function is a computed field of: its sole input
213
+ * parameter has that relation's row type, the relation is in the function's
214
+ * schema, and no column of the relation shares the function's name. Such a
215
+ * function is selectable as a nullable column of the relation.
216
+ */
217
+ computed_field_of: "number | null",
218
+ /**
219
+ * Why PostgREST cannot resolve a call to this overload, when it cannot: the
220
+ * function conflicts with another overload, or its sole parameter is an
221
+ * unnamed row, which PostgREST never matches under `/rpc` (the function is
222
+ * a computed field or computed relationship, reached by embedding).
223
+ * Generators surface the message instead of a callable signature.
224
+ */
225
+ error: "string | null",
226
+ });
227
+ /**
228
+ * A function PostgREST exposes under `/rpc`, with its overloads resolved.
229
+ * Produced by `resolveRpcFunctions` from the raw `functions` collection.
230
+ */
231
+ const rpcFunctionSchema = type({
232
+ schema: "string",
233
+ name: "string",
234
+ /** Ordered by argument list, then by return type. Never empty. */
235
+ overloads: rpcFunctionOverloadSchema.array(),
236
+ });
153
237
  /**
154
238
  * Bumped whenever `GeneratorMetadata`'s shape changes in a way a consumer
155
239
  * should branch on. Out-of-process consumers (a generator in another
@@ -177,6 +261,14 @@ export const generatorMetadataSchema = type({
177
261
  relationships: postgresRelationshipSchema.array(),
178
262
  functions: postgresFunctionSchema.array(),
179
263
  types: postgresTypeSchema.array(),
264
+ /**
265
+ * The PostgREST view of `functions`: which are callable through `/rpc`, how
266
+ * their overloads group and what a call returns. Derived from the other
267
+ * collections by `resolveRpcFunctions`, which `introspect()` runs. Optional
268
+ * because version 1 documents predating the collection are still valid;
269
+ * a generator falls back to running `resolveRpcFunctions` itself.
270
+ */
271
+ "rpcFunctions?": rpcFunctionSchema.array(),
180
272
  });
181
273
  /**
182
274
  * JSON Schema for {@link generatorMetadataSchema}, published so out-of-process
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/postgrest-typegen",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Type generation for PostgREST from PostgreSQL schemas",
5
5
  "keywords": [
6
6
  "codegen",
@@ -58,11 +58,12 @@
58
58
  "check-types:consumer": "tsc --project tsconfig.consumer.json",
59
59
  "format-and-lint": "oxfmt --check . && oxlint --deny-warnings src test scripts",
60
60
  "format-and-lint:fix": "oxfmt . && oxlint --fix src test scripts",
61
+ "generate:postgrest-js-types": "bun scripts/generate-postgrest-js-types.ts",
61
62
  "knip": "knip",
62
63
  "test": "bun scripts/run-tests.ts test/"
63
64
  },
64
65
  "dependencies": {
65
- "arktype": "2.2.5"
66
+ "arktype": "2.2.8"
66
67
  },
67
68
  "devDependencies": {
68
69
  "@testcontainers/postgresql": "^12.1.0",
@@ -74,8 +75,8 @@
74
75
  "@types/pg": "^8.23.1",
75
76
  "knip": "^6.32.3",
76
77
  "oxfmt": "0.66.0",
77
- "oxlint": "1.85.0",
78
- "oxlint-tsgolint": "7.0.2003",
78
+ "oxlint": "1.87.0",
79
+ "oxlint-tsgolint": "7.0.2004",
79
80
  "pg": "^8.23.0",
80
81
  "testcontainers": "^12.1.0",
81
82
  "typescript": "7.0.2"
@@ -7,8 +7,3 @@ export {
7
7
  pgTypeToTsType,
8
8
  type TypeResolutionContext,
9
9
  } from "./typescript.ts";
10
- export {
11
- type AccessControl,
12
- generateSwift,
13
- type GenerateSwiftOptions,
14
- } from "./swift.ts";