@miniaxolotl/grove-server 1.11.1 → 1.11.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/bootstrap.js +88 -1
- package/dist/bootstrap.js.map +4 -4
- package/dist/migrate.js +88 -1
- package/dist/migrate.js.map +4 -4
- package/dist/server.js +30525 -28715
- package/dist/server.js.map +4 -4
- package/dist/telemetry-build.json +1 -1
- package/dist/worker.js +2228 -539
- package/dist/worker.js.map +4 -4
- package/package.json +3 -1
package/dist/bootstrap.js
CHANGED
|
@@ -4,6 +4,77 @@ import { createRequire as __groveCreateRequire } from "node:module"; const requi
|
|
|
4
4
|
import knex from "knex";
|
|
5
5
|
import { Model, knexSnakeCaseMappers } from "objection";
|
|
6
6
|
|
|
7
|
+
// lib/database/src/billing-migration.ts
|
|
8
|
+
var billing = {
|
|
9
|
+
name: "20261024_023_billing",
|
|
10
|
+
async up(db2) {
|
|
11
|
+
await db2.raw(`
|
|
12
|
+
CREATE TABLE billing_customers (
|
|
13
|
+
account_id uuid PRIMARY KEY REFERENCES accounts(id), customer_id text UNIQUE,
|
|
14
|
+
checkout_operation uuid NOT NULL DEFAULT gen_random_uuid(),
|
|
15
|
+
checkout_id text, checkout_price text,
|
|
16
|
+
UNIQUE(account_id, customer_id)
|
|
17
|
+
);
|
|
18
|
+
CREATE TABLE billing_subscriptions (
|
|
19
|
+
id text PRIMARY KEY, account_id uuid NOT NULL, customer_id text NOT NULL,
|
|
20
|
+
price_id text NOT NULL, product_id text, status text NOT NULL,
|
|
21
|
+
period_end timestamptz NOT NULL, cancel_at_period_end boolean NOT NULL DEFAULT false,
|
|
22
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
23
|
+
FOREIGN KEY(account_id,customer_id) REFERENCES billing_customers(account_id,customer_id)
|
|
24
|
+
);
|
|
25
|
+
CREATE INDEX billing_subscriptions_account ON billing_subscriptions(account_id,period_end);
|
|
26
|
+
CREATE TABLE billing_events (
|
|
27
|
+
id text PRIMARY KEY, account_id uuid NOT NULL REFERENCES accounts(id),
|
|
28
|
+
received_at timestamptz NOT NULL DEFAULT now()
|
|
29
|
+
);
|
|
30
|
+
`);
|
|
31
|
+
for (const table of [
|
|
32
|
+
"billing_customers",
|
|
33
|
+
"billing_subscriptions",
|
|
34
|
+
"billing_events"
|
|
35
|
+
]) {
|
|
36
|
+
await db2.raw("ALTER TABLE ?? ENABLE ROW LEVEL SECURITY", [table]);
|
|
37
|
+
if (table !== "billing_customers")
|
|
38
|
+
await db2.raw("ALTER TABLE ?? FORCE ROW LEVEL SECURITY", [table]);
|
|
39
|
+
await db2.raw(
|
|
40
|
+
`CREATE POLICY tenant ON ?? USING (account_id = NULLIF(current_setting('grove.account_id',true),'')::uuid) WITH CHECK (account_id = NULLIF(current_setting('grove.account_id',true),'')::uuid)`,
|
|
41
|
+
[table]
|
|
42
|
+
);
|
|
43
|
+
await db2.raw("GRANT SELECT, INSERT, UPDATE ON ?? TO grove_runtime", [
|
|
44
|
+
table
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
await db2.raw(`
|
|
48
|
+
GRANT SELECT ON billing_subscriptions, billing_customers TO grove_worker;
|
|
49
|
+
CREATE FUNCTION grove_billing_account(customer text) RETURNS uuid
|
|
50
|
+
LANGUAGE sql SECURITY DEFINER SET search_path=pg_catalog,public,pg_temp AS $$
|
|
51
|
+
SELECT account_id FROM public.billing_customers WHERE customer_id=customer
|
|
52
|
+
$$;
|
|
53
|
+
REVOKE ALL ON FUNCTION grove_billing_account(text) FROM PUBLIC;
|
|
54
|
+
GRANT EXECUTE ON FUNCTION grove_billing_account(text) TO grove_runtime;
|
|
55
|
+
`);
|
|
56
|
+
},
|
|
57
|
+
async down() {
|
|
58
|
+
throw new Error("Use a forward migration");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// lib/database/src/speech-voices-migration.ts
|
|
63
|
+
var speechVoices = {
|
|
64
|
+
name: "20261024_022_speech_voices",
|
|
65
|
+
async up(db2) {
|
|
66
|
+
await db2.raw(`
|
|
67
|
+
ALTER TABLE accounts ADD COLUMN read_aloud_voice_id text NOT NULL DEFAULT 'reed'
|
|
68
|
+
CHECK (read_aloud_voice_id IN ('reed','willow','cedar','brook'));
|
|
69
|
+
ALTER TABLE speech_configuration ADD COLUMN synthesis_profiles jsonb NOT NULL DEFAULT '{}'
|
|
70
|
+
CHECK (jsonb_typeof(synthesis_profiles) = 'object');
|
|
71
|
+
`);
|
|
72
|
+
},
|
|
73
|
+
async down() {
|
|
74
|
+
throw new Error("Use a forward migration");
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
7
78
|
// lib/database/src/hardening.ts
|
|
8
79
|
var hardening = {
|
|
9
80
|
name: "20261018_002_lifecycle_bounds",
|
|
@@ -2077,6 +2148,19 @@ var researchTools = {
|
|
|
2077
2148
|
}
|
|
2078
2149
|
};
|
|
2079
2150
|
|
|
2151
|
+
// lib/database/src/speech-defaults-migration.ts
|
|
2152
|
+
var speechDefaults = {
|
|
2153
|
+
name: "20261023_021_speech_defaults",
|
|
2154
|
+
async up(db2) {
|
|
2155
|
+
await db2.raw(
|
|
2156
|
+
"ALTER TABLE accounts ALTER COLUMN read_aloud_enabled SET DEFAULT true"
|
|
2157
|
+
);
|
|
2158
|
+
},
|
|
2159
|
+
async down() {
|
|
2160
|
+
throw new Error("Use a forward migration");
|
|
2161
|
+
}
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2080
2164
|
// lib/database/src/migrations.ts
|
|
2081
2165
|
var migrations = [
|
|
2082
2166
|
{
|
|
@@ -2299,7 +2383,10 @@ var migrations = [
|
|
|
2299
2383
|
mediaAttachments,
|
|
2300
2384
|
recordings,
|
|
2301
2385
|
speech,
|
|
2302
|
-
researchTools
|
|
2386
|
+
researchTools,
|
|
2387
|
+
speechDefaults,
|
|
2388
|
+
speechVoices,
|
|
2389
|
+
billing
|
|
2303
2390
|
];
|
|
2304
2391
|
var migrationSource = {
|
|
2305
2392
|
getMigrations: async () => migrations,
|