@prisma-next/extension-supabase 0.14.0-dev.2 → 0.14.0-dev.20
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/contract.d.mts +18 -0
- package/dist/contract.d.mts.map +1 -1
- package/dist/pack.mjs +3 -2
- package/dist/pack.mjs.map +1 -1
- package/dist/package-BN7Uy42E.mjs +6 -0
- package/dist/package-BN7Uy42E.mjs.map +1 -0
- package/dist/runtime.mjs +1 -1
- package/dist/test/utils.d.mts +6 -6
- package/dist/test/utils.mjs +28 -9
- package/dist/test/utils.mjs.map +1 -1
- package/package.json +26 -26
- package/src/contract/contract.d.ts +73 -4
- package/src/contract/contract.json +2 -1
- package/dist/package-CP-rB14D.mjs +0 -6
- package/dist/package-CP-rB14D.mjs.map +0 -1
package/dist/contract.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ declare const AuthUser: import("@prisma-next/sql-contract-ts/contract-builder").
|
|
|
10
10
|
readonly columnName?: undefined;
|
|
11
11
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
12
12
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
13
|
+
readonly many?: undefined;
|
|
13
14
|
} & {
|
|
14
15
|
readonly id: {
|
|
15
16
|
readonly name?: string | undefined;
|
|
@@ -27,6 +28,7 @@ declare const AuthUser: import("@prisma-next/sql-contract-ts/contract-builder").
|
|
|
27
28
|
readonly columnName?: undefined;
|
|
28
29
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
29
30
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
31
|
+
readonly many?: undefined;
|
|
30
32
|
} & {
|
|
31
33
|
readonly id?: undefined;
|
|
32
34
|
} & {
|
|
@@ -42,6 +44,7 @@ declare const AuthUser: import("@prisma-next/sql-contract-ts/contract-builder").
|
|
|
42
44
|
readonly columnName?: undefined;
|
|
43
45
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
44
46
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
47
|
+
readonly many?: undefined;
|
|
45
48
|
} & {
|
|
46
49
|
readonly id?: undefined;
|
|
47
50
|
} & {
|
|
@@ -57,6 +60,7 @@ declare const AuthUser: import("@prisma-next/sql-contract-ts/contract-builder").
|
|
|
57
60
|
readonly columnName?: undefined;
|
|
58
61
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
59
62
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
63
|
+
readonly many?: undefined;
|
|
60
64
|
} & {
|
|
61
65
|
readonly id?: undefined;
|
|
62
66
|
} & {
|
|
@@ -74,6 +78,7 @@ declare const AuthIdentity: import("@prisma-next/sql-contract-ts/contract-builde
|
|
|
74
78
|
readonly columnName?: undefined;
|
|
75
79
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
76
80
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
81
|
+
readonly many?: undefined;
|
|
77
82
|
} & {
|
|
78
83
|
readonly id: {
|
|
79
84
|
readonly name?: string | undefined;
|
|
@@ -91,6 +96,7 @@ declare const AuthIdentity: import("@prisma-next/sql-contract-ts/contract-builde
|
|
|
91
96
|
readonly columnName?: undefined;
|
|
92
97
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
93
98
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
99
|
+
readonly many?: undefined;
|
|
94
100
|
} & {
|
|
95
101
|
readonly id?: undefined;
|
|
96
102
|
} & {
|
|
@@ -106,6 +112,7 @@ declare const AuthIdentity: import("@prisma-next/sql-contract-ts/contract-builde
|
|
|
106
112
|
readonly columnName?: undefined;
|
|
107
113
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
108
114
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
115
|
+
readonly many?: undefined;
|
|
109
116
|
} & {
|
|
110
117
|
readonly id?: undefined;
|
|
111
118
|
} & {
|
|
@@ -121,6 +128,7 @@ declare const AuthIdentity: import("@prisma-next/sql-contract-ts/contract-builde
|
|
|
121
128
|
readonly columnName?: undefined;
|
|
122
129
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
123
130
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
131
|
+
readonly many?: undefined;
|
|
124
132
|
} & {
|
|
125
133
|
readonly id?: undefined;
|
|
126
134
|
} & {
|
|
@@ -136,6 +144,7 @@ declare const AuthIdentity: import("@prisma-next/sql-contract-ts/contract-builde
|
|
|
136
144
|
readonly columnName?: undefined;
|
|
137
145
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
138
146
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
147
|
+
readonly many?: undefined;
|
|
139
148
|
} & {
|
|
140
149
|
readonly id?: undefined;
|
|
141
150
|
} & {
|
|
@@ -153,6 +162,7 @@ declare const StorageBucket: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
153
162
|
readonly columnName?: undefined;
|
|
154
163
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
155
164
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
165
|
+
readonly many?: undefined;
|
|
156
166
|
} & {
|
|
157
167
|
readonly id: {
|
|
158
168
|
readonly name?: string | undefined;
|
|
@@ -170,6 +180,7 @@ declare const StorageBucket: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
170
180
|
readonly columnName?: undefined;
|
|
171
181
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
172
182
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
183
|
+
readonly many?: undefined;
|
|
173
184
|
} & {
|
|
174
185
|
readonly id?: undefined;
|
|
175
186
|
} & {
|
|
@@ -185,6 +196,7 @@ declare const StorageBucket: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
185
196
|
readonly columnName?: undefined;
|
|
186
197
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
187
198
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
199
|
+
readonly many?: undefined;
|
|
188
200
|
} & {
|
|
189
201
|
readonly id?: undefined;
|
|
190
202
|
} & {
|
|
@@ -200,6 +212,7 @@ declare const StorageBucket: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
200
212
|
readonly columnName?: undefined;
|
|
201
213
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
202
214
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
215
|
+
readonly many?: undefined;
|
|
203
216
|
} & {
|
|
204
217
|
readonly id?: undefined;
|
|
205
218
|
} & {
|
|
@@ -217,6 +230,7 @@ declare const StorageObject: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
217
230
|
readonly columnName?: undefined;
|
|
218
231
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
219
232
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
233
|
+
readonly many?: undefined;
|
|
220
234
|
} & {
|
|
221
235
|
readonly id: {
|
|
222
236
|
readonly name?: string | undefined;
|
|
@@ -234,6 +248,7 @@ declare const StorageObject: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
234
248
|
readonly columnName?: undefined;
|
|
235
249
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
236
250
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
251
|
+
readonly many?: undefined;
|
|
237
252
|
} & {
|
|
238
253
|
readonly id?: undefined;
|
|
239
254
|
} & {
|
|
@@ -249,6 +264,7 @@ declare const StorageObject: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
249
264
|
readonly columnName?: undefined;
|
|
250
265
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
251
266
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
267
|
+
readonly many?: undefined;
|
|
252
268
|
} & {
|
|
253
269
|
readonly id?: undefined;
|
|
254
270
|
} & {
|
|
@@ -264,6 +280,7 @@ declare const StorageObject: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
264
280
|
readonly columnName?: undefined;
|
|
265
281
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
266
282
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
283
|
+
readonly many?: undefined;
|
|
267
284
|
} & {
|
|
268
285
|
readonly id?: undefined;
|
|
269
286
|
} & {
|
|
@@ -279,6 +296,7 @@ declare const StorageObject: import("@prisma-next/sql-contract-ts/contract-build
|
|
|
279
296
|
readonly columnName?: undefined;
|
|
280
297
|
readonly default?: import("@prisma-next/contract/types").ColumnDefault | undefined;
|
|
281
298
|
readonly executionDefaults?: import("@prisma-next/contract/types").ExecutionMutationDefaultPhases | undefined;
|
|
299
|
+
readonly many?: undefined;
|
|
282
300
|
} & {
|
|
283
301
|
readonly id?: undefined;
|
|
284
302
|
} & {
|
package/dist/contract.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.mts","names":[],"sources":["../src/contract/handles.ts"],"mappings":";cAiBa,QAAA,0DAAQ,oBAAA
|
|
1
|
+
{"version":3,"file":"contract.d.mts","names":[],"sources":["../src/contract/handles.ts"],"mappings":";cAiBa,QAAA,0DAAQ,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAapB,MAAA,sCAAA,MAAA;AAAA,cAEY,YAAA,0DAAY,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAcxB,MAAA,sCAAA,MAAA;AAAA,cAEY,aAAA,0DAAa,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAazB,MAAA,sCAAA,MAAA;AAAA,cAEY,aAAA,0DAAa,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAczB,MAAA,sCAAA,MAAA"}
|
package/dist/pack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-BN7Uy42E.mjs";
|
|
2
2
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
3
3
|
//#region src/contract/contract.json
|
|
4
4
|
var contract_default = {
|
|
@@ -399,7 +399,8 @@ var contract_default = {
|
|
|
399
399
|
"defaultInInsert": true,
|
|
400
400
|
"enums": true,
|
|
401
401
|
"lateral": true,
|
|
402
|
-
"returning": true
|
|
402
|
+
"returning": true,
|
|
403
|
+
"scalarList": true
|
|
403
404
|
}
|
|
404
405
|
},
|
|
405
406
|
extensionPacks: {},
|
package/dist/pack.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.mjs","names":["contractJson","packageJson.version"],"sources":["../src/contract/contract.json","../src/pack/index.ts"],"sourcesContent":["","import type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport packageJson from '../../package.json' with { type: 'json' };\nimport type { Contract } from '../contract/contract.d';\nimport contractJson from '../contract/contract.json' with { type: 'json' };\n\nconst SUPABASE_SPACE_ID = 'supabase' as const;\n\nfunction buildContractSpace(contractOverride?: unknown) {\n const contract = blindCast<\n Contract,\n 'JSON import narrowed to emitted Contract type; assertDescriptorSelfConsistency verifies the storageHash at load time'\n >(contractOverride ?? contractJson);\n return {\n contractJson: contract,\n migrations: [] as const,\n headRef: { hash: contract.storage.storageHash, invariants: [] as const },\n };\n}\n\nconst supabaseContractSpace = buildContractSpace();\n\nconst supabasePackBase = {\n kind: 'extension' as const,\n id: SUPABASE_SPACE_ID,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n version: packageJson.version,\n contractSpace: supabaseContractSpace,\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n} satisfies SqlControlExtensionDescriptor<'postgres'>;\n\nexport const supabasePack: SqlControlExtensionDescriptor<'postgres'> = supabasePackBase;\n\n/**\n * Returns a pack using `contractOverride` in place of the shipped\n * `contract.json` when provided, otherwise returns the default pack.\n *\n * Intended for tests that need to drive the framework with a synthetic\n * contract while still exercising the full descriptor wiring.\n */\nexport function supabasePackWith(options?: {\n contractOverride?: unknown;\n}): SqlControlExtensionDescriptor<'postgres'> {\n if (options?.contractOverride === undefined) return supabasePack;\n return {\n ...supabasePackBase,\n contractSpace: buildContractSpace(options.contractOverride),\n };\n}\n\nexport default supabasePack;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pack.mjs","names":["contractJson","packageJson.version"],"sources":["../src/contract/contract.json","../src/pack/index.ts"],"sourcesContent":["","import type { SqlControlExtensionDescriptor } from '@prisma-next/family-sql/control';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport packageJson from '../../package.json' with { type: 'json' };\nimport type { Contract } from '../contract/contract.d';\nimport contractJson from '../contract/contract.json' with { type: 'json' };\n\nconst SUPABASE_SPACE_ID = 'supabase' as const;\n\nfunction buildContractSpace(contractOverride?: unknown) {\n const contract = blindCast<\n Contract,\n 'JSON import narrowed to emitted Contract type; assertDescriptorSelfConsistency verifies the storageHash at load time'\n >(contractOverride ?? contractJson);\n return {\n contractJson: contract,\n migrations: [] as const,\n headRef: { hash: contract.storage.storageHash, invariants: [] as const },\n };\n}\n\nconst supabaseContractSpace = buildContractSpace();\n\nconst supabasePackBase = {\n kind: 'extension' as const,\n id: SUPABASE_SPACE_ID,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n version: packageJson.version,\n contractSpace: supabaseContractSpace,\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n} satisfies SqlControlExtensionDescriptor<'postgres'>;\n\nexport const supabasePack: SqlControlExtensionDescriptor<'postgres'> = supabasePackBase;\n\n/**\n * Returns a pack using `contractOverride` in place of the shipped\n * `contract.json` when provided, otherwise returns the default pack.\n *\n * Intended for tests that need to drive the framework with a synthetic\n * contract while still exercising the full descriptor wiring.\n */\nexport function supabasePackWith(options?: {\n contractOverride?: unknown;\n}): SqlControlExtensionDescriptor<'postgres'> {\n if (options?.contractOverride === undefined) return supabasePack;\n return {\n ...supabasePackBase,\n contractSpace: buildContractSpace(options.contractOverride),\n };\n}\n\nexport default supabasePack;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACMA,MAAM,oBAAoB;AAE1B,SAAS,mBAAmB,kBAA4B;CACtD,MAAM,WAAW,UAGf,oBAAoBA,gBAAY;CAClC,OAAO;EACL,cAAc;EACd,YAAY,CAAC;EACb,SAAS;GAAE,MAAM,SAAS,QAAQ;GAAa,YAAY,CAAC;EAAW;CACzE;AACF;AAIA,MAAM,mBAAmB;CACvB,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACDC;CACT,eAR4B,mBAQb;CACf,eAAe;EACb,UAAU;EACV,UAAU;CACZ;AACF;AAEA,MAAa,eAA0D;;;;;;;;AASvE,SAAgB,iBAAiB,SAEa;CAC5C,IAAI,SAAS,qBAAqB,KAAA,GAAW,OAAO;CACpD,OAAO;EACL,GAAG;EACH,eAAe,mBAAmB,QAAQ,gBAAgB;CAC5D;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-BN7Uy42E.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-BN7Uy42E.mjs";
|
|
2
2
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
3
3
|
import postgresAdapter from "@prisma-next/adapter-postgres/runtime";
|
|
4
4
|
import postgresDriver from "@prisma-next/driver-postgres/runtime";
|
package/dist/test/utils.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ import { Client } from "pg";
|
|
|
2
2
|
|
|
3
3
|
//#region test/supabase-bootstrap.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Seeds the database with the external Supabase schemas, tables, roles, and
|
|
6
|
-
* The caller passes an already-connected `pg.Client` — this
|
|
7
|
-
* open or close connections.
|
|
5
|
+
* Seeds the database with the external Supabase schemas, tables, roles, and
|
|
6
|
+
* functions. The caller passes an already-connected `pg.Client` — this
|
|
7
|
+
* function does not open or close connections.
|
|
8
8
|
*
|
|
9
9
|
* Creates two schemas (`auth`, `storage`) and four tables whose columns
|
|
10
10
|
* exactly match the `@prisma-next/extension-supabase` contract:
|
|
@@ -14,10 +14,10 @@ import { Client } from "pg";
|
|
|
14
14
|
* - `storage.buckets` — id text PK, name text, created_at timestamptz, updated_at timestamptz
|
|
15
15
|
* - `storage.objects` — id uuid PK, bucket_id text, name text, created_at timestamptz, updated_at timestamptz
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* Also creates the three Supabase platform roles (`anon`, `authenticated`,
|
|
18
|
+
* `service_role`) and the `auth.uid()` function that reads the current user's
|
|
19
|
+
* id from the `request.jwt.claims` GUC, matching Supabase's implementation.
|
|
18
20
|
* `ALTER DEFAULT PRIVILEGES` covers tables created after the shim runs (e.g. via `dbInit`).
|
|
19
|
-
* WAL grants are guarded by a schema-existence check — a PGlite single-connection
|
|
20
|
-
* accommodation so role-bound sessions can interleave with the WAL drain query.
|
|
21
21
|
*/
|
|
22
22
|
declare function bootstrapSupabaseShim(client: Client): Promise<void>;
|
|
23
23
|
//#endregion
|
package/dist/test/utils.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region test/supabase-bootstrap.ts
|
|
2
2
|
/**
|
|
3
|
-
* Seeds the database with the external Supabase schemas, tables, roles, and
|
|
4
|
-
* The caller passes an already-connected `pg.Client` — this
|
|
5
|
-
* open or close connections.
|
|
3
|
+
* Seeds the database with the external Supabase schemas, tables, roles, and
|
|
4
|
+
* functions. The caller passes an already-connected `pg.Client` — this
|
|
5
|
+
* function does not open or close connections.
|
|
6
6
|
*
|
|
7
7
|
* Creates two schemas (`auth`, `storage`) and four tables whose columns
|
|
8
8
|
* exactly match the `@prisma-next/extension-supabase` contract:
|
|
@@ -12,15 +12,37 @@
|
|
|
12
12
|
* - `storage.buckets` — id text PK, name text, created_at timestamptz, updated_at timestamptz
|
|
13
13
|
* - `storage.objects` — id uuid PK, bucket_id text, name text, created_at timestamptz, updated_at timestamptz
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* Also creates the three Supabase platform roles (`anon`, `authenticated`,
|
|
16
|
+
* `service_role`) and the `auth.uid()` function that reads the current user's
|
|
17
|
+
* id from the `request.jwt.claims` GUC, matching Supabase's implementation.
|
|
16
18
|
* `ALTER DEFAULT PRIVILEGES` covers tables created after the shim runs (e.g. via `dbInit`).
|
|
17
|
-
* WAL grants are guarded by a schema-existence check — a PGlite single-connection
|
|
18
|
-
* accommodation so role-bound sessions can interleave with the WAL drain query.
|
|
19
19
|
*/
|
|
20
20
|
async function bootstrapSupabaseShim(client) {
|
|
21
21
|
await client.query("CREATE SCHEMA IF NOT EXISTS auth");
|
|
22
22
|
await client.query("CREATE SCHEMA IF NOT EXISTS storage");
|
|
23
23
|
await client.query(`
|
|
24
|
+
DO $$
|
|
25
|
+
BEGIN
|
|
26
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'anon') THEN
|
|
27
|
+
CREATE ROLE anon NOLOGIN;
|
|
28
|
+
END IF;
|
|
29
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN
|
|
30
|
+
CREATE ROLE authenticated NOLOGIN;
|
|
31
|
+
END IF;
|
|
32
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'service_role') THEN
|
|
33
|
+
CREATE ROLE service_role NOLOGIN BYPASSRLS;
|
|
34
|
+
END IF;
|
|
35
|
+
END
|
|
36
|
+
$$
|
|
37
|
+
`);
|
|
38
|
+
await client.query(`
|
|
39
|
+
CREATE OR REPLACE FUNCTION auth.uid() RETURNS uuid
|
|
40
|
+
LANGUAGE sql STABLE
|
|
41
|
+
AS $$
|
|
42
|
+
SELECT (current_setting('request.jwt.claims', true)::jsonb ->> 'sub')::uuid
|
|
43
|
+
$$
|
|
44
|
+
`);
|
|
45
|
+
await client.query(`
|
|
24
46
|
CREATE TABLE IF NOT EXISTS auth.users (
|
|
25
47
|
id uuid NOT NULL,
|
|
26
48
|
email text NOT NULL,
|
|
@@ -58,9 +80,6 @@ async function bootstrapSupabaseShim(client) {
|
|
|
58
80
|
PRIMARY KEY (id)
|
|
59
81
|
)
|
|
60
82
|
`);
|
|
61
|
-
await client.query("CREATE ROLE anon NOLOGIN");
|
|
62
|
-
await client.query("CREATE ROLE authenticated NOLOGIN");
|
|
63
|
-
await client.query("CREATE ROLE service_role NOLOGIN BYPASSRLS");
|
|
64
83
|
await client.query("GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role");
|
|
65
84
|
await client.query("GRANT USAGE ON SCHEMA auth, storage TO anon, authenticated, service_role");
|
|
66
85
|
await client.query("GRANT ALL ON ALL TABLES IN SCHEMA auth TO service_role");
|
package/dist/test/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../test/supabase-bootstrap.ts"],"sourcesContent":["/**\n * Shared Supabase test fixture — seeds the external schemas, tables, roles, and
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../test/supabase-bootstrap.ts"],"sourcesContent":["/**\n * Shared Supabase test fixture — seeds the external schemas, tables, roles, and functions.\n *\n * Seeds a Postgres/PGlite database with the external Supabase schemas and\n * tables that the framework verifier expects when a composed contract declares\n * `auth.*` and `storage.*` tables as `external`. Without these tables present,\n * `db init`/`db update` will fail at the verify step because the framework\n * confirms declared `external` tables exist.\n *\n * Also creates the three Postgres roles (`anon`, `authenticated`, `service_role`)\n * with grants that mirror a real Supabase database. `ALTER DEFAULT PRIVILEGES`\n * ensures tables created after the shim runs (e.g. `public.profile` via `dbInit`)\n * are automatically accessible to the roles.\n *\n * The caller owns the client lifecycle — pass any already-connected `pg.Client`\n * (e.g. one the test is sharing across setup steps, or one bound to a\n * transaction for isolation). Convenience wrapper for tests that don't already\n * have one:\n *\n * @example\n * ```ts\n * import { withClient } from '@prisma-next/test-utils';\n * import { bootstrapSupabaseShim } from '@prisma-next/extension-supabase/test/utils';\n *\n * await withClient(connectionString, async (client) => {\n * await bootstrapSupabaseShim(client);\n * });\n * ```\n */\nimport type { Client } from 'pg';\n\n/**\n * Seeds the database with the external Supabase schemas, tables, roles, and\n * functions. The caller passes an already-connected `pg.Client` — this\n * function does not open or close connections.\n *\n * Creates two schemas (`auth`, `storage`) and four tables whose columns\n * exactly match the `@prisma-next/extension-supabase` contract:\n *\n * - `auth.users` — id uuid PK, email text, created_at timestamptz, updated_at timestamptz\n * - `auth.identities` — id uuid PK, user_id uuid, provider text, created_at timestamptz, updated_at timestamptz\n * - `storage.buckets` — id text PK, name text, created_at timestamptz, updated_at timestamptz\n * - `storage.objects` — id uuid PK, bucket_id text, name text, created_at timestamptz, updated_at timestamptz\n *\n * Also creates the three Supabase platform roles (`anon`, `authenticated`,\n * `service_role`) and the `auth.uid()` function that reads the current user's\n * id from the `request.jwt.claims` GUC, matching Supabase's implementation.\n * `ALTER DEFAULT PRIVILEGES` covers tables created after the shim runs (e.g. via `dbInit`).\n */\nexport async function bootstrapSupabaseShim(client: Client): Promise<void> {\n await client.query('CREATE SCHEMA IF NOT EXISTS auth');\n await client.query('CREATE SCHEMA IF NOT EXISTS storage');\n\n // Supabase platform roles — created idempotently; real Supabase provides\n // these as platform infrastructure; the shim emulates them for test DBs.\n await client.query(`\n DO $$\n BEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'anon') THEN\n CREATE ROLE anon NOLOGIN;\n END IF;\n IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN\n CREATE ROLE authenticated NOLOGIN;\n END IF;\n IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'service_role') THEN\n CREATE ROLE service_role NOLOGIN BYPASSRLS;\n END IF;\n END\n $$\n `);\n\n // auth.uid() — returns the current request's user id from the settable GUC\n // request.jwt.claims, matching Supabase's implementation. Returns NULL when\n // the GUC is unset (missing_ok = true).\n await client.query(`\n CREATE OR REPLACE FUNCTION auth.uid() RETURNS uuid\n LANGUAGE sql STABLE\n AS $$\n SELECT (current_setting('request.jwt.claims', true)::jsonb ->> 'sub')::uuid\n $$\n `);\n\n await client.query(`\n CREATE TABLE IF NOT EXISTS auth.users (\n id uuid NOT NULL,\n email text NOT NULL,\n created_at timestamptz NOT NULL,\n updated_at timestamptz NOT NULL,\n PRIMARY KEY (id)\n )\n `);\n\n await client.query(`\n CREATE TABLE IF NOT EXISTS auth.identities (\n id uuid NOT NULL,\n user_id uuid NOT NULL,\n provider text NOT NULL,\n created_at timestamptz NOT NULL,\n updated_at timestamptz NOT NULL,\n PRIMARY KEY (id)\n )\n `);\n\n await client.query(`\n CREATE TABLE IF NOT EXISTS storage.buckets (\n id text NOT NULL,\n name text NOT NULL,\n created_at timestamptz NOT NULL,\n updated_at timestamptz NOT NULL,\n PRIMARY KEY (id)\n )\n `);\n\n await client.query(`\n CREATE TABLE IF NOT EXISTS storage.objects (\n id uuid NOT NULL,\n bucket_id text NOT NULL,\n name text NOT NULL,\n created_at timestamptz NOT NULL,\n updated_at timestamptz NOT NULL,\n PRIMARY KEY (id)\n )\n `);\n\n // Grants mirror a real Supabase database.\n await client.query('GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role');\n await client.query('GRANT USAGE ON SCHEMA auth, storage TO anon, authenticated, service_role');\n await client.query('GRANT ALL ON ALL TABLES IN SCHEMA auth TO service_role');\n await client.query('GRANT ALL ON ALL TABLES IN SCHEMA storage TO service_role');\n await client.query('GRANT SELECT ON ALL TABLES IN SCHEMA auth TO anon, authenticated');\n await client.query('GRANT SELECT ON ALL TABLES IN SCHEMA storage TO anon, authenticated');\n\n // Default privileges cover tables created after this shim runs (e.g. public.profile via dbInit).\n await client.query(\n 'ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO service_role',\n );\n await client.query(\n 'ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE ON TABLES TO authenticated',\n );\n await client.query('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO anon');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,eAAsB,sBAAsB,QAA+B;CACzE,MAAM,OAAO,MAAM,kCAAkC;CACrD,MAAM,OAAO,MAAM,qCAAqC;CAIxD,MAAM,OAAO,MAAM;;;;;;;;;;;;;;GAclB;CAKD,MAAM,OAAO,MAAM;;;;;;GAMlB;CAED,MAAM,OAAO,MAAM;;;;;;;;GAQlB;CAED,MAAM,OAAO,MAAM;;;;;;;;;GASlB;CAED,MAAM,OAAO,MAAM;;;;;;;;GAQlB;CAED,MAAM,OAAO,MAAM;;;;;;;;;GASlB;CAGD,MAAM,OAAO,MAAM,mEAAmE;CACtF,MAAM,OAAO,MAAM,0EAA0E;CAC7F,MAAM,OAAO,MAAM,wDAAwD;CAC3E,MAAM,OAAO,MAAM,2DAA2D;CAC9E,MAAM,OAAO,MAAM,kEAAkE;CACrF,MAAM,OAAO,MAAM,qEAAqE;CAGxF,MAAM,OAAO,MACX,+EACF;CACA,MAAM,OAAO,MACX,2FACF;CACA,MAAM,OAAO,MAAM,0EAA0E;AAC/F"}
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/extension-supabase",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/adapter-postgres": "0.14.0-dev.
|
|
9
|
-
"@prisma-next/contract": "0.14.0-dev.
|
|
10
|
-
"@prisma-next/driver-postgres": "0.14.0-dev.
|
|
11
|
-
"@prisma-next/postgres": "0.14.0-dev.
|
|
12
|
-
"@prisma-next/sql-builder": "0.14.0-dev.
|
|
13
|
-
"@prisma-next/sql-orm-client": "0.14.0-dev.
|
|
14
|
-
"@prisma-next/target-postgres": "0.14.0-dev.
|
|
8
|
+
"@prisma-next/adapter-postgres": "0.14.0-dev.20",
|
|
9
|
+
"@prisma-next/contract": "0.14.0-dev.20",
|
|
10
|
+
"@prisma-next/driver-postgres": "0.14.0-dev.20",
|
|
11
|
+
"@prisma-next/postgres": "0.14.0-dev.20",
|
|
12
|
+
"@prisma-next/sql-builder": "0.14.0-dev.20",
|
|
13
|
+
"@prisma-next/sql-orm-client": "0.14.0-dev.20",
|
|
14
|
+
"@prisma-next/target-postgres": "0.14.0-dev.20",
|
|
15
15
|
"jose": "^6",
|
|
16
16
|
"pg": "8.21.0",
|
|
17
|
-
"@prisma-next/contract-authoring": "0.14.0-dev.
|
|
18
|
-
"@prisma-next/family-sql": "0.14.0-dev.
|
|
19
|
-
"@prisma-next/framework-components": "0.14.0-dev.
|
|
20
|
-
"@prisma-next/migration-tools": "0.14.0-dev.
|
|
21
|
-
"@prisma-next/sql-contract": "0.14.0-dev.
|
|
22
|
-
"@prisma-next/sql-contract-ts": "0.14.0-dev.
|
|
23
|
-
"@prisma-next/sql-operations": "0.14.0-dev.
|
|
24
|
-
"@prisma-next/sql-relational-core": "0.14.0-dev.
|
|
25
|
-
"@prisma-next/sql-runtime": "0.14.0-dev.
|
|
26
|
-
"@prisma-next/sql-schema-ir": "0.14.0-dev.
|
|
27
|
-
"@prisma-next/utils": "0.14.0-dev.
|
|
17
|
+
"@prisma-next/contract-authoring": "0.14.0-dev.20",
|
|
18
|
+
"@prisma-next/family-sql": "0.14.0-dev.20",
|
|
19
|
+
"@prisma-next/framework-components": "0.14.0-dev.20",
|
|
20
|
+
"@prisma-next/migration-tools": "0.14.0-dev.20",
|
|
21
|
+
"@prisma-next/sql-contract": "0.14.0-dev.20",
|
|
22
|
+
"@prisma-next/sql-contract-ts": "0.14.0-dev.20",
|
|
23
|
+
"@prisma-next/sql-operations": "0.14.0-dev.20",
|
|
24
|
+
"@prisma-next/sql-relational-core": "0.14.0-dev.20",
|
|
25
|
+
"@prisma-next/sql-runtime": "0.14.0-dev.20",
|
|
26
|
+
"@prisma-next/sql-schema-ir": "0.14.0-dev.20",
|
|
27
|
+
"@prisma-next/utils": "0.14.0-dev.20",
|
|
28
28
|
"@standard-schema/spec": "^1.1.0",
|
|
29
29
|
"arktype": "^2.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@prisma-next/cli": "0.14.0-dev.
|
|
33
|
-
"@prisma-next/operations": "0.14.0-dev.
|
|
34
|
-
"@prisma-next/sql-contract-psl": "0.14.0-dev.
|
|
35
|
-
"@prisma-next/test-utils": "0.14.0-dev.
|
|
36
|
-
"@prisma-next/tsconfig": "0.14.0-dev.
|
|
37
|
-
"@prisma-next/tsdown": "0.14.0-dev.
|
|
32
|
+
"@prisma-next/cli": "0.14.0-dev.20",
|
|
33
|
+
"@prisma-next/operations": "0.14.0-dev.20",
|
|
34
|
+
"@prisma-next/sql-contract-psl": "0.14.0-dev.20",
|
|
35
|
+
"@prisma-next/test-utils": "0.14.0-dev.20",
|
|
36
|
+
"@prisma-next/tsconfig": "0.14.0-dev.20",
|
|
37
|
+
"@prisma-next/tsdown": "0.14.0-dev.20",
|
|
38
38
|
"@types/pg": "8.20.0",
|
|
39
39
|
"tsdown": "0.22.1",
|
|
40
40
|
"typescript": "5.9.3",
|
|
41
41
|
"vitest": "4.1.8"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@prisma-next/adapter-postgres": "0.14.0-dev.
|
|
44
|
+
"@prisma-next/adapter-postgres": "0.14.0-dev.20",
|
|
45
45
|
"typescript": ">=5.9"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
@@ -106,11 +106,79 @@ export type FieldInputTypes = {
|
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
108
|
};
|
|
109
|
+
export type StorageColumnTypes = {
|
|
110
|
+
readonly auth: {
|
|
111
|
+
readonly identities: {
|
|
112
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
113
|
+
readonly id: CodecTypes['pg/uuid@1']['output'];
|
|
114
|
+
readonly provider: CodecTypes['pg/text@1']['output'];
|
|
115
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
116
|
+
readonly user_id: CodecTypes['pg/uuid@1']['output'];
|
|
117
|
+
};
|
|
118
|
+
readonly users: {
|
|
119
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
120
|
+
readonly email: CodecTypes['pg/text@1']['output'];
|
|
121
|
+
readonly id: CodecTypes['pg/uuid@1']['output'];
|
|
122
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
readonly public: {};
|
|
126
|
+
readonly storage: {
|
|
127
|
+
readonly buckets: {
|
|
128
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
129
|
+
readonly id: CodecTypes['pg/text@1']['output'];
|
|
130
|
+
readonly name: CodecTypes['pg/text@1']['output'];
|
|
131
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
132
|
+
};
|
|
133
|
+
readonly objects: {
|
|
134
|
+
readonly bucket_id: CodecTypes['pg/text@1']['output'];
|
|
135
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
136
|
+
readonly id: CodecTypes['pg/uuid@1']['output'];
|
|
137
|
+
readonly name: CodecTypes['pg/text@1']['output'];
|
|
138
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['output'];
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
export type StorageColumnInputTypes = {
|
|
143
|
+
readonly auth: {
|
|
144
|
+
readonly identities: {
|
|
145
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
146
|
+
readonly id: CodecTypes['pg/uuid@1']['input'];
|
|
147
|
+
readonly provider: CodecTypes['pg/text@1']['input'];
|
|
148
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
149
|
+
readonly user_id: CodecTypes['pg/uuid@1']['input'];
|
|
150
|
+
};
|
|
151
|
+
readonly users: {
|
|
152
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
153
|
+
readonly email: CodecTypes['pg/text@1']['input'];
|
|
154
|
+
readonly id: CodecTypes['pg/uuid@1']['input'];
|
|
155
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
readonly public: {};
|
|
159
|
+
readonly storage: {
|
|
160
|
+
readonly buckets: {
|
|
161
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
162
|
+
readonly id: CodecTypes['pg/text@1']['input'];
|
|
163
|
+
readonly name: CodecTypes['pg/text@1']['input'];
|
|
164
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
165
|
+
};
|
|
166
|
+
readonly objects: {
|
|
167
|
+
readonly bucket_id: CodecTypes['pg/text@1']['input'];
|
|
168
|
+
readonly created_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
169
|
+
readonly id: CodecTypes['pg/uuid@1']['input'];
|
|
170
|
+
readonly name: CodecTypes['pg/text@1']['input'];
|
|
171
|
+
readonly updated_at: CodecTypes['pg/timestamptz@1']['input'];
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
109
175
|
export type TypeMaps = TypeMapsType<
|
|
110
176
|
CodecTypes,
|
|
111
177
|
QueryOperationTypes,
|
|
112
178
|
FieldOutputTypes,
|
|
113
|
-
FieldInputTypes
|
|
179
|
+
FieldInputTypes,
|
|
180
|
+
StorageColumnTypes,
|
|
181
|
+
StorageColumnInputTypes
|
|
114
182
|
>;
|
|
115
183
|
|
|
116
184
|
type ContractBase = Omit<
|
|
@@ -118,7 +186,7 @@ type ContractBase = Omit<
|
|
|
118
186
|
readonly namespaces: {
|
|
119
187
|
readonly auth: {
|
|
120
188
|
readonly id: 'auth';
|
|
121
|
-
readonly kind: '
|
|
189
|
+
readonly kind: 'postgres-schema';
|
|
122
190
|
readonly entries: {
|
|
123
191
|
readonly table: {
|
|
124
192
|
readonly identities: {
|
|
@@ -194,12 +262,12 @@ type ContractBase = Omit<
|
|
|
194
262
|
};
|
|
195
263
|
readonly public: {
|
|
196
264
|
readonly id: 'public';
|
|
197
|
-
readonly kind: '
|
|
265
|
+
readonly kind: 'postgres-schema';
|
|
198
266
|
readonly entries: { readonly table: {} };
|
|
199
267
|
};
|
|
200
268
|
readonly storage: {
|
|
201
269
|
readonly id: 'storage';
|
|
202
|
-
readonly kind: '
|
|
270
|
+
readonly kind: 'postgres-schema';
|
|
203
271
|
readonly entries: {
|
|
204
272
|
readonly table: {
|
|
205
273
|
readonly buckets: {
|
|
@@ -467,6 +535,7 @@ type ContractBase = Omit<
|
|
|
467
535
|
readonly enums: true;
|
|
468
536
|
readonly lateral: true;
|
|
469
537
|
readonly returning: true;
|
|
538
|
+
readonly scalarList: true;
|
|
470
539
|
};
|
|
471
540
|
};
|
|
472
541
|
readonly extensionPacks: {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-CP-rB14D.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|