@kernhq/module-billing 0.3.3 → 0.3.5

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.
@@ -258,7 +258,23 @@ export declare function billingRouter(kernel: Kernel): {
258
258
  get: import("@orpc/server").Procedure<import("@orpc/server").MergedInitialContext<import("@kernhq/kernel").RequestContext & Record<never, never>, import("@kernhq/kernel").RequestContext & Record<never, never> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, keyof import("@kernhq/kernel").RequestContext> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, "workspaceId" | "kernel" | "principal" | "requestId" | "ip" | "headers">, import("@kernhq/kernel").RequestContext>, Omit<import("@orpc/server").MergedCurrentContext<import("@kernhq/kernel").RequestContext, {
259
259
  workspaceId: string;
260
260
  kernel: Kernel;
261
- principal: import("@kernhq/contracts").Principal;
261
+ principal: {
262
+ kind: "service" | "user" | "api_key" | "anonymous";
263
+ userId: (string & import("zod").$brand<"UserId">) | null;
264
+ email: string | null;
265
+ name: string | null;
266
+ locale: "en" | "fa" | "ar" | "de";
267
+ instanceAdmin: boolean;
268
+ service: string | null;
269
+ memberships: {
270
+ workspaceId: string & import("zod").$brand<"WorkspaceId">;
271
+ role: "owner" | "admin" | "member" | "guest";
272
+ roleIds: string[];
273
+ groupIds: string[];
274
+ status: "active" | "suspended" | "invited";
275
+ }[];
276
+ permissionVersion: number;
277
+ };
262
278
  requestId: string;
263
279
  ip: string;
264
280
  headers: Record<string, string | string[] | undefined>;
@@ -325,7 +341,23 @@ export declare function billingRouter(kernel: Kernel): {
325
341
  invoices: import("@orpc/server").Procedure<import("@orpc/server").MergedInitialContext<import("@kernhq/kernel").RequestContext & Record<never, never>, import("@kernhq/kernel").RequestContext & Record<never, never> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, keyof import("@kernhq/kernel").RequestContext> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, "workspaceId" | "kernel" | "principal" | "requestId" | "ip" | "headers">, import("@kernhq/kernel").RequestContext>, Omit<import("@orpc/server").MergedCurrentContext<import("@kernhq/kernel").RequestContext, {
326
342
  workspaceId: string;
327
343
  kernel: Kernel;
328
- principal: import("@kernhq/contracts").Principal;
344
+ principal: {
345
+ kind: "service" | "user" | "api_key" | "anonymous";
346
+ userId: (string & import("zod").$brand<"UserId">) | null;
347
+ email: string | null;
348
+ name: string | null;
349
+ locale: "en" | "fa" | "ar" | "de";
350
+ instanceAdmin: boolean;
351
+ service: string | null;
352
+ memberships: {
353
+ workspaceId: string & import("zod").$brand<"WorkspaceId">;
354
+ role: "owner" | "admin" | "member" | "guest";
355
+ roleIds: string[];
356
+ groupIds: string[];
357
+ status: "active" | "suspended" | "invited";
358
+ }[];
359
+ permissionVersion: number;
360
+ };
329
361
  requestId: string;
330
362
  ip: string;
331
363
  headers: Record<string, string | string[] | undefined>;
@@ -375,7 +407,23 @@ export declare function billingRouter(kernel: Kernel): {
375
407
  checkout: import("@orpc/server").Procedure<import("@orpc/server").MergedInitialContext<import("@kernhq/kernel").RequestContext & Record<never, never>, import("@kernhq/kernel").RequestContext & Record<never, never> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, keyof import("@kernhq/kernel").RequestContext> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, "workspaceId" | "kernel" | "principal" | "requestId" | "ip" | "headers">, import("@kernhq/kernel").RequestContext>, Omit<import("@orpc/server").MergedCurrentContext<import("@kernhq/kernel").RequestContext, {
376
408
  workspaceId: string;
377
409
  kernel: Kernel;
378
- principal: import("@kernhq/contracts").Principal;
410
+ principal: {
411
+ kind: "service" | "user" | "api_key" | "anonymous";
412
+ userId: (string & import("zod").$brand<"UserId">) | null;
413
+ email: string | null;
414
+ name: string | null;
415
+ locale: "en" | "fa" | "ar" | "de";
416
+ instanceAdmin: boolean;
417
+ service: string | null;
418
+ memberships: {
419
+ workspaceId: string & import("zod").$brand<"WorkspaceId">;
420
+ role: "owner" | "admin" | "member" | "guest";
421
+ roleIds: string[];
422
+ groupIds: string[];
423
+ status: "active" | "suspended" | "invited";
424
+ }[];
425
+ permissionVersion: number;
426
+ };
379
427
  requestId: string;
380
428
  ip: string;
381
429
  headers: Record<string, string | string[] | undefined>;
@@ -411,7 +459,23 @@ export declare function billingRouter(kernel: Kernel): {
411
459
  portal: import("@orpc/server").Procedure<import("@orpc/server").MergedInitialContext<import("@kernhq/kernel").RequestContext & Record<never, never>, import("@kernhq/kernel").RequestContext & Record<never, never> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, keyof import("@kernhq/kernel").RequestContext> & Omit<import("@kernhq/kernel").RequestContext & Record<never, never>, "workspaceId" | "kernel" | "principal" | "requestId" | "ip" | "headers">, import("@kernhq/kernel").RequestContext>, Omit<import("@orpc/server").MergedCurrentContext<import("@kernhq/kernel").RequestContext, {
412
460
  workspaceId: string;
413
461
  kernel: Kernel;
414
- principal: import("@kernhq/contracts").Principal;
462
+ principal: {
463
+ kind: "service" | "user" | "api_key" | "anonymous";
464
+ userId: (string & import("zod").$brand<"UserId">) | null;
465
+ email: string | null;
466
+ name: string | null;
467
+ locale: "en" | "fa" | "ar" | "de";
468
+ instanceAdmin: boolean;
469
+ service: string | null;
470
+ memberships: {
471
+ workspaceId: string & import("zod").$brand<"WorkspaceId">;
472
+ role: "owner" | "admin" | "member" | "guest";
473
+ roleIds: string[];
474
+ groupIds: string[];
475
+ status: "active" | "suspended" | "invited";
476
+ }[];
477
+ permissionVersion: number;
478
+ };
415
479
  requestId: string;
416
480
  ip: string;
417
481
  headers: Record<string, string | string[] | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/server/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgC,MAAM,gBAAgB,CAAA;AAgC1E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsH3C"}
@@ -1,6 +1,6 @@
1
1
  CREATE SCHEMA IF NOT EXISTS "mod_billing";
2
2
  --> statement-breakpoint
3
- CREATE TABLE "mod_billing"."invoices" (
3
+ CREATE TABLE IF NOT EXISTS "mod_billing"."invoices" (
4
4
  "id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
5
5
  "workspace_id" uuid NOT NULL,
6
6
  "stripe_invoice_id" text,
@@ -15,7 +15,7 @@ CREATE TABLE "mod_billing"."invoices" (
15
15
  "created_at" timestamp with time zone DEFAULT now() NOT NULL
16
16
  );
17
17
  --> statement-breakpoint
18
- CREATE TABLE "mod_billing"."overrides" (
18
+ CREATE TABLE IF NOT EXISTS "mod_billing"."overrides" (
19
19
  "workspace_id" uuid PRIMARY KEY NOT NULL,
20
20
  "limits" jsonb DEFAULT '{}'::jsonb NOT NULL,
21
21
  "note" text DEFAULT '' NOT NULL,
@@ -24,7 +24,7 @@ CREATE TABLE "mod_billing"."overrides" (
24
24
  "updated_at" timestamp with time zone DEFAULT now() NOT NULL
25
25
  );
26
26
  --> statement-breakpoint
27
- CREATE TABLE "mod_billing"."plans" (
27
+ CREATE TABLE IF NOT EXISTS "mod_billing"."plans" (
28
28
  "id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
29
29
  "slug" text NOT NULL,
30
30
  "name" text NOT NULL,
@@ -44,7 +44,7 @@ CREATE TABLE "mod_billing"."plans" (
44
44
  "updated_at" timestamp with time zone DEFAULT now() NOT NULL
45
45
  );
46
46
  --> statement-breakpoint
47
- CREATE TABLE "mod_billing"."subscriptions" (
47
+ CREATE TABLE IF NOT EXISTS "mod_billing"."subscriptions" (
48
48
  "workspace_id" uuid PRIMARY KEY NOT NULL,
49
49
  "plan_id" uuid,
50
50
  "status" text DEFAULT 'trialing' NOT NULL,
@@ -59,13 +59,13 @@ CREATE TABLE "mod_billing"."subscriptions" (
59
59
  "updated_at" timestamp with time zone DEFAULT now() NOT NULL
60
60
  );
61
61
  --> statement-breakpoint
62
- CREATE TABLE "mod_billing"."webhook_events" (
62
+ CREATE TABLE IF NOT EXISTS "mod_billing"."webhook_events" (
63
63
  "id" text PRIMARY KEY NOT NULL,
64
64
  "type" text NOT NULL,
65
65
  "received_at" timestamp with time zone DEFAULT now() NOT NULL
66
66
  );
67
67
  --> statement-breakpoint
68
- CREATE TABLE "mod_billing"."workspace_usage" (
68
+ CREATE TABLE IF NOT EXISTS "mod_billing"."workspace_usage" (
69
69
  "workspace_id" uuid PRIMARY KEY NOT NULL,
70
70
  "seats" integer DEFAULT 0 NOT NULL,
71
71
  "storage_bytes" bigint DEFAULT 0 NOT NULL,
@@ -73,10 +73,10 @@ CREATE TABLE "mod_billing"."workspace_usage" (
73
73
  "updated_at" timestamp with time zone DEFAULT now() NOT NULL
74
74
  );
75
75
  --> statement-breakpoint
76
- CREATE INDEX "invoices_ws_idx" ON "mod_billing"."invoices" USING btree ("workspace_id","created_at");--> statement-breakpoint
77
- CREATE UNIQUE INDEX "invoices_stripe_idx" ON "mod_billing"."invoices" USING btree ("stripe_invoice_id");--> statement-breakpoint
78
- CREATE UNIQUE INDEX "plans_slug_idx" ON "mod_billing"."plans" USING btree ("slug");--> statement-breakpoint
79
- CREATE INDEX "plans_published_idx" ON "mod_billing"."plans" USING btree ("published","order");--> statement-breakpoint
80
- CREATE INDEX "subscriptions_status_idx" ON "mod_billing"."subscriptions" USING btree ("status");--> statement-breakpoint
81
- CREATE UNIQUE INDEX "subscriptions_stripe_sub_idx" ON "mod_billing"."subscriptions" USING btree ("stripe_subscription_id");--> statement-breakpoint
82
- CREATE INDEX "webhook_events_received_idx" ON "mod_billing"."webhook_events" USING btree ("received_at");
76
+ CREATE INDEX IF NOT EXISTS "invoices_ws_idx" ON "mod_billing"."invoices" USING btree ("workspace_id","created_at");--> statement-breakpoint
77
+ CREATE UNIQUE INDEX IF NOT EXISTS "invoices_stripe_idx" ON "mod_billing"."invoices" USING btree ("stripe_invoice_id");--> statement-breakpoint
78
+ CREATE UNIQUE INDEX IF NOT EXISTS "plans_slug_idx" ON "mod_billing"."plans" USING btree ("slug");--> statement-breakpoint
79
+ CREATE INDEX IF NOT EXISTS "plans_published_idx" ON "mod_billing"."plans" USING btree ("published","order");--> statement-breakpoint
80
+ CREATE INDEX IF NOT EXISTS "subscriptions_status_idx" ON "mod_billing"."subscriptions" USING btree ("status");--> statement-breakpoint
81
+ CREATE UNIQUE INDEX IF NOT EXISTS "subscriptions_stripe_sub_idx" ON "mod_billing"."subscriptions" USING btree ("stripe_subscription_id");--> statement-breakpoint
82
+ CREATE INDEX IF NOT EXISTS "webhook_events_received_idx" ON "mod_billing"."webhook_events" USING btree ("received_at");
@@ -13,6 +13,8 @@ alter table "mod_billing"."invoices" enable row level security;
13
13
  --> statement-breakpoint
14
14
  alter table "mod_billing"."invoices" force row level security;
15
15
  --> statement-breakpoint
16
+ drop policy if exists "invoices_ws_isolation" on "mod_billing"."invoices";
17
+ --> statement-breakpoint
16
18
  create policy "invoices_ws_isolation" on "mod_billing"."invoices"
17
19
  using (workspace_id::text = current_setting('app.workspace_id', true))
18
20
  with check (workspace_id::text = current_setting('app.workspace_id', true));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernhq/module-billing",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Kern billing module: plans, entitlements, subscriptions and Stripe — the mechanism that lets any Kern instance sell seats on itself",
5
5
  "homepage": "https://github.com/KernAIO/module-billing#readme",
6
6
  "license": "AGPL-3.0-only",
@@ -52,10 +52,10 @@
52
52
  "devDependencies": {
53
53
  "@biomejs/biome": "^2.0.0",
54
54
  "@changesets/cli": "^2.27.0",
55
- "@kernhq/contracts": "^0.5.1",
55
+ "@kernhq/contracts": "^0.6.1",
56
56
  "@kernhq/kernel": "^0.7.0",
57
57
  "@kernhq/tsconfig": "^0.1.0",
58
- "@kernhq/ui": "^0.8.0",
58
+ "@kernhq/ui": "^0.10.0",
59
59
  "@tanstack/svelte-query": "^6.1.0",
60
60
  "@types/node": "^24.0.0",
61
61
  "@types/pg": "^8.15.0",
@@ -67,9 +67,9 @@
67
67
  "vitest": "^4.0.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@kernhq/contracts": "^0.5.1",
70
+ "@kernhq/contracts": "^0.6.1",
71
71
  "@kernhq/kernel": "^0.7.0",
72
- "@kernhq/ui": "^0.8.0",
72
+ "@kernhq/ui": "^0.10.0",
73
73
  "@tanstack/svelte-query": "^6.1.0",
74
74
  "svelte": "^5.46.0"
75
75
  },