@supawatch/target-supabase-types 0.2.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.js +25 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -137,7 +137,31 @@ export class SupabaseTypesTarget {
137
137
  lines.push(" };");
138
138
  }
139
139
  lines.push(" };");
140
- lines.push(" Functions: Record<string, never>;");
140
+ const fns = snapshot.functions.filter((f) => f.schema === schema);
141
+ if (fns.length === 0) {
142
+ lines.push(" Functions: Record<string, never>;");
143
+ }
144
+ else {
145
+ lines.push(" Functions: {");
146
+ for (const fn of fns) {
147
+ lines.push(` ${fn.name}: {`);
148
+ if (fn.args.length === 0) {
149
+ lines.push(" Args: Record<string, never>;");
150
+ }
151
+ else {
152
+ lines.push(" Args: {");
153
+ for (const arg of fn.args) {
154
+ const t = tsType(runtimeFor(arg.pgTypeName, "b", { enums: snapshot.enums }, "supabase-js"), "Json");
155
+ lines.push(` ${arg.name}${arg.hasDefault ? "?" : ""}: ${t};`);
156
+ }
157
+ lines.push(" };");
158
+ }
159
+ const ret = tsType(runtimeFor(fn.returns.pgTypeName, "b", { enums: snapshot.enums }, "supabase-js"), "Json");
160
+ lines.push(` Returns: ${fn.returns.isSet ? `(${ret})[]` : ret};`);
161
+ lines.push(" };");
162
+ }
163
+ lines.push(" };");
164
+ }
141
165
  lines.push(" Enums: {");
142
166
  for (const e of enums) {
143
167
  lines.push(` ${e.name}: ${e.labels.map((l) => JSON.stringify(l)).join(" | ")};`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supawatch/target-supabase-types",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "A supabase-js compatible Database interface generated from live Postgres by supawatch, foreign-key relationships included.",
5
5
  "keywords": [
6
6
  "supabase",
@@ -33,7 +33,7 @@
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@supawatch/core": "0.2.0"
36
+ "@supawatch/core": "0.4.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^22.20.1",