@deverjak/tenantkit-adapter-supabase 0.1.0 → 0.1.2
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/authz.d.ts +1 -1
- package/dist/authz.js +5 -1
- package/dist/env.d.ts +3 -2
- package/dist/env.js +10 -4
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +4 -1
- package/package.json +8 -8
package/dist/authz.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { AuthzStore, ProfileRow } from '@deverjak/tenantkit-kernel';
|
|
12
12
|
export declare class SupabaseAuthzStore implements AuthzStore {
|
|
13
|
-
private db;
|
|
13
|
+
private get db();
|
|
14
14
|
ensureProfile(userId: string, email: string | null): Promise<ProfileRow>;
|
|
15
15
|
getMemberships(userId: string): Promise<Array<{
|
|
16
16
|
tenantId: string;
|
package/dist/authz.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { adminClient } from './clients';
|
|
2
2
|
export class SupabaseAuthzStore {
|
|
3
|
-
|
|
3
|
+
// Lazy: the service-role client (and its SUPABASE_SERVICE_ROLE_KEY requirement) resolves on FIRST USE, not at
|
|
4
|
+
// construction — so an anon-only app (public catalogue, family sign-in) can build a runtime without the key.
|
|
5
|
+
get db() {
|
|
6
|
+
return adminClient();
|
|
7
|
+
}
|
|
4
8
|
async ensureProfile(userId, email) {
|
|
5
9
|
const { data } = await this.db.schema('core').from('profiles')
|
|
6
10
|
.select('full_name, locale, avatar_url, phone').eq('id', userId).maybeSingle();
|
package/dist/env.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Supabase adapter env — validated once, fail-fast.
|
|
3
|
-
* `
|
|
2
|
+
* Supabase adapter env — validated once, fail-fast. Accepts BOTH key namings: the new Supabase keys
|
|
3
|
+
* (`SUPABASE_PUBLISHABLE_KEY` / `SUPABASE_SECRET_KEY`, incl. their `NEXT_PUBLIC_*` variants) and the legacy
|
|
4
|
+
* `SUPABASE_ANON_KEY` / `SUPABASE_SERVICE_ROLE_KEY`. Internally both collapse to the same two fields.
|
|
4
5
|
*/
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
declare const Schema: z.ZodObject<{
|
package/dist/env.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Supabase adapter env — validated once, fail-fast.
|
|
3
|
-
* `
|
|
2
|
+
* Supabase adapter env — validated once, fail-fast. Accepts BOTH key namings: the new Supabase keys
|
|
3
|
+
* (`SUPABASE_PUBLISHABLE_KEY` / `SUPABASE_SECRET_KEY`, incl. their `NEXT_PUBLIC_*` variants) and the legacy
|
|
4
|
+
* `SUPABASE_ANON_KEY` / `SUPABASE_SERVICE_ROLE_KEY`. Internally both collapse to the same two fields.
|
|
4
5
|
*/
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
const Schema = z.object({
|
|
@@ -15,8 +16,13 @@ export function supabaseEnv() {
|
|
|
15
16
|
return cached;
|
|
16
17
|
const parsed = Schema.safeParse({
|
|
17
18
|
SUPABASE_URL: process.env.SUPABASE_URL ?? process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
// New Supabase key naming (publishable / secret) first, then the legacy anon / service_role names.
|
|
20
|
+
// NEXT_PUBLIC_* variants cover the Edge runtime (proxy), where only public vars are inlined.
|
|
21
|
+
SUPABASE_ANON_KEY: process.env.SUPABASE_PUBLISHABLE_KEY ??
|
|
22
|
+
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY ??
|
|
23
|
+
process.env.SUPABASE_ANON_KEY ??
|
|
24
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
|
25
|
+
SUPABASE_SERVICE_ROLE_KEY: process.env.SUPABASE_SECRET_KEY ?? process.env.SUPABASE_SERVICE_ROLE_KEY,
|
|
20
26
|
});
|
|
21
27
|
if (!parsed.success) {
|
|
22
28
|
throw new Error(`[adapter-supabase] invalid env:\n${parsed.error.issues.map((i) => ` - ${i.path}: ${i.message}`).join('\n')}`);
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** `StorageProvider` port → Supabase Storage. Optional; used for tenant logos / data exports. */
|
|
2
2
|
import type { StorageProvider } from '@deverjak/tenantkit-kernel';
|
|
3
3
|
export declare class SupabaseStorage implements StorageProvider {
|
|
4
|
-
private db;
|
|
4
|
+
private get db();
|
|
5
5
|
put(input: {
|
|
6
6
|
bucket: string;
|
|
7
7
|
key: string;
|
package/dist/storage.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { adminClient } from './clients';
|
|
2
2
|
export class SupabaseStorage {
|
|
3
|
-
|
|
3
|
+
// Lazy (see authz.ts): resolve the service-role client on first use, not at construction.
|
|
4
|
+
get db() {
|
|
5
|
+
return adminClient();
|
|
6
|
+
}
|
|
4
7
|
async put(input) {
|
|
5
8
|
const { error } = await this.db.storage.from(input.bucket).upload(input.key, input.body, {
|
|
6
9
|
contentType: input.contentType, upsert: true,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deverjak/tenantkit-adapter-supabase",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Supabase reference adapter for @deverjak/tenantkit-kernel — Database, Identity, Session, Authz, Storage. Drop-in: createSupabaseRuntime()
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Supabase reference adapter for @deverjak/tenantkit-kernel — Database, Identity, Session, Authz, Storage. Drop-in: createSupabaseRuntime() -> CoreRuntime.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"repository": "github:chytre-digital/tenantkit
|
|
7
|
+
"repository": "github:chytre-digital/tenantkit",
|
|
8
8
|
"homepage": "https://github.com/chytre-digital/tenantkit#readme",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"tenantkit",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"next": ">=15",
|
|
33
|
+
"@deverjak/tenantkit-kernel": "0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@supabase/ssr": "^0.8.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"zod": "^4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@deverjak/tenantkit-kernel": "^0.1.0",
|
|
42
|
-
"@deverjak/tenantkit-testing": "^0.1.0",
|
|
43
41
|
"@types/node": "^22.10.0",
|
|
44
42
|
"typescript": "^5.9.3",
|
|
45
|
-
"vitest": "^4.0.0"
|
|
43
|
+
"vitest": "^4.0.0",
|
|
44
|
+
"@deverjak/tenantkit-kernel": "0.2.0",
|
|
45
|
+
"@deverjak/tenantkit-testing": "0.1.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"typecheck": "tsc --noEmit",
|