@sanoma-ai/connector-supabase 0.4.10 → 0.4.12
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/connector.d.ts +4 -2
- package/dist/fake.d.ts +3 -1
- package/dist/resources.d.ts +4 -2
- package/dist/vault.js +13 -9
- package/dist/vault.js.map +1 -1
- package/package.json +6 -5
package/dist/connector.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { z } from "zod";
|
|
|
9
9
|
* two of which apply calls after it creates a project.
|
|
10
10
|
*/
|
|
11
11
|
export declare const supabaseTf: import("@sanoma-ai/bridge/connector").TfConnector<"supabase", {
|
|
12
|
-
project: z.ZodObject<{
|
|
12
|
+
readonly project: z.ZodObject<{
|
|
13
13
|
database_password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
14
|
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
15
|
instance_size: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -22,7 +22,9 @@ export declare const supabaseTf: import("@sanoma-ai/bridge/connector").TfConnect
|
|
|
22
22
|
update: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
23
23
|
}, z.core.$strip>>>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
|
-
}, {}
|
|
25
|
+
}, {}, {
|
|
26
|
+
readonly project: true;
|
|
27
|
+
}>;
|
|
26
28
|
declare const target: ({ ref }: {
|
|
27
29
|
ref: string;
|
|
28
30
|
}) => string;
|
package/dist/fake.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type FakeSupabaseOptions = TfFakeOptions;
|
|
|
14
14
|
* the project in Supabase's dashboard, and `remove` deletes it, so the next read says it is gone.
|
|
15
15
|
*/
|
|
16
16
|
export declare function fakeSupabase(options?: FakeSupabaseOptions): import("@sanoma-ai/bridge/fake").TfFake<"supabase", {
|
|
17
|
-
project: import("zod").ZodObject<{
|
|
17
|
+
readonly project: import("zod").ZodObject<{
|
|
18
18
|
database_password: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
19
19
|
id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
20
20
|
instance_size: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
@@ -27,4 +27,6 @@ export declare function fakeSupabase(options?: FakeSupabaseOptions): import("@sa
|
|
|
27
27
|
update: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
28
28
|
}, import("zod/v4/core").$strip>>>;
|
|
29
29
|
}, import("zod/v4/core").$strip>;
|
|
30
|
+
}, {}, {
|
|
31
|
+
readonly project: true;
|
|
30
32
|
}>;
|
package/dist/resources.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `export const store = supabase.project({ name: "acme-ops", organization_id: "acme", region: "us-east-1" })`.
|
|
4
4
|
*/
|
|
5
5
|
export declare const supabase: import("@sanoma-ai/bridge/connector").TfResources<"supabase", {
|
|
6
|
-
project: import("zod").ZodObject<{
|
|
6
|
+
readonly project: import("zod").ZodObject<{
|
|
7
7
|
database_password: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
8
8
|
id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
9
9
|
instance_size: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
@@ -16,4 +16,6 @@ export declare const supabase: import("@sanoma-ai/bridge/connector").TfResources
|
|
|
16
16
|
update: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
17
17
|
}, import("zod/v4/core").$strip>>>;
|
|
18
18
|
}, import("zod/v4/core").$strip>;
|
|
19
|
-
}, {}
|
|
19
|
+
}, {}, {
|
|
20
|
+
readonly project: true;
|
|
21
|
+
}>;
|
package/dist/vault.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SecretStoreError } from "@sanoma-ai/workflows";
|
|
2
|
+
import { databaseOn, pgCode } from "@sanoma-ai/workflows/db";
|
|
3
|
+
import { sql } from "drizzle-orm";
|
|
2
4
|
import { Pool } from "pg";
|
|
3
5
|
const decoded = (result) => {
|
|
4
6
|
const v = result;
|
|
@@ -17,18 +19,18 @@ export function supabaseVault(options = {}) {
|
|
|
17
19
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(env))
|
|
18
20
|
throw new SecretStoreError("invalid_configuration");
|
|
19
21
|
const writable = options.writable ?? true;
|
|
20
|
-
let
|
|
22
|
+
let db;
|
|
21
23
|
const invoke = async (operation, namespace, path, value, expected, by) => {
|
|
22
24
|
if (!namespace.trim() ||
|
|
23
25
|
namespace.includes("\0") ||
|
|
24
26
|
(path !== undefined && (!path || path.includes("\0") || path.length > 1024)))
|
|
25
27
|
throw new SecretStoreError("invalid_configuration");
|
|
26
28
|
try {
|
|
27
|
-
if (!
|
|
29
|
+
if (!db) {
|
|
28
30
|
const connectionString = process.env[env];
|
|
29
31
|
if (!connectionString)
|
|
30
32
|
throw new SecretStoreError("invalid_configuration");
|
|
31
|
-
pool = new Pool({
|
|
33
|
+
const pool = new Pool({
|
|
32
34
|
connectionString,
|
|
33
35
|
max: 4,
|
|
34
36
|
idleTimeoutMillis: 1000,
|
|
@@ -38,14 +40,16 @@ export function supabaseVault(options = {}) {
|
|
|
38
40
|
});
|
|
39
41
|
// Idle connection errors must not surface provider payloads through an unhandled EventEmitter error.
|
|
40
42
|
pool.on("error", () => { });
|
|
43
|
+
db = databaseOn(pool);
|
|
41
44
|
}
|
|
42
|
-
const
|
|
43
|
-
return
|
|
45
|
+
const { rows } = await db.execute(sql `SELECT sanoma_vault.access(${operation}, ${namespace}, ${path ?? null}, ${value ?? null}, ${expected ?? null}, ${by ?? null}) AS result`);
|
|
46
|
+
return rows[0]?.result;
|
|
44
47
|
}
|
|
45
48
|
catch (error) {
|
|
46
49
|
if (error instanceof SecretStoreError)
|
|
47
50
|
throw error;
|
|
48
|
-
|
|
51
|
+
// The driver's `code` classifies the failure; its message (the statement and its parameters) is never kept.
|
|
52
|
+
const code = pgCode(error);
|
|
49
53
|
throw new SecretStoreError(code === "42501"
|
|
50
54
|
? "denied"
|
|
51
55
|
: code === "SV001"
|
|
@@ -94,9 +98,9 @@ export function supabaseVault(options = {}) {
|
|
|
94
98
|
await invoke("delete", namespace, path, undefined, expectedVersion, by);
|
|
95
99
|
},
|
|
96
100
|
async close() {
|
|
97
|
-
const current =
|
|
98
|
-
|
|
99
|
-
await current
|
|
101
|
+
const current = db;
|
|
102
|
+
db = undefined;
|
|
103
|
+
await current?.$client.end();
|
|
100
104
|
},
|
|
101
105
|
};
|
|
102
106
|
}
|
package/dist/vault.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0D,MAAM,sBAAsB,CAAC;AAChH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAS1B,MAAM,OAAO,GAAG,CAAC,MAAe,EAAe,EAAE;IAC/C,MAAM,CAAC,GAAG,MAAqC,CAAC;IAChD,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QACzG,MAAM,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC5C,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,GAAG,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;QAClE,GAAG,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SA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EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;YACvD,OAAO,EAAE,CAAC;YACV,MAAM,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,OAAO,GAAG,EAAE,CAAC;YACnB,EAAE,GAAG,SAAS,CAAC;YACf,MAAM,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanoma-ai/connector-supabase",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "Supabase projects for Sanoma, through the OpenTofu provider and the Management API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"connector",
|
|
@@ -58,18 +58,19 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
+
"drizzle-orm": "0.45.4",
|
|
61
62
|
"pg": "^8.23.1"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@sanoma-ai/bridge": "0.5.
|
|
65
|
-
"@sanoma-ai/workflows": "0.11.
|
|
65
|
+
"@sanoma-ai/bridge": "0.5.6",
|
|
66
|
+
"@sanoma-ai/workflows": "0.11.13",
|
|
66
67
|
"@types/pg": "^8.23.1",
|
|
67
68
|
"msw": "^3.0.3",
|
|
68
69
|
"zod": "^4.6.5"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
|
-
"@sanoma-ai/bridge": "^0.5.
|
|
72
|
-
"@sanoma-ai/workflows": "^0.11.
|
|
72
|
+
"@sanoma-ai/bridge": "^0.5.6",
|
|
73
|
+
"@sanoma-ai/workflows": "^0.11.13",
|
|
73
74
|
"zod": "^4"
|
|
74
75
|
},
|
|
75
76
|
"engines": {
|