@checkstack/auth-backend 0.4.2 → 0.4.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @checkstack/auth-backend
2
2
 
3
+ ## 0.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [db1f56f]
8
+ - @checkstack/common@0.6.0
9
+ - @checkstack/auth-common@0.5.3
10
+ - @checkstack/backend-api@0.5.1
11
+ - @checkstack/command-backend@0.1.7
12
+ - @checkstack/notification-common@0.2.3
13
+
14
+ ## 0.4.3
15
+
16
+ ### Patch Changes
17
+
18
+ - 66a3963: Update database types to use SafeDatabase
19
+
20
+ - Updated all database type declarations from `NodePgDatabase` to `SafeDatabase` for compile-time safety
21
+
22
+ - Updated dependencies [66a3963]
23
+ - @checkstack/backend-api@0.5.0
24
+ - @checkstack/command-backend@0.1.6
25
+
3
26
  ## 0.4.2
4
27
 
5
28
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/auth-backend",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  import { NotificationApi } from "@checkstack/notification-common";
19
19
  import * as schema from "./schema";
20
20
  import { eq, inArray } from "drizzle-orm";
21
- import { NodePgDatabase } from "drizzle-orm/node-postgres";
21
+ import { SafeDatabase } from "@checkstack/backend-api";
22
22
  import { User } from "better-auth/types";
23
23
  import { verifyPassword } from "better-auth/crypto";
24
24
  import { createExtensionPoint } from "@checkstack/backend-api";
@@ -57,7 +57,7 @@ async function syncAccessRulesToDb({
57
57
  accessRules,
58
58
  fullSync = false,
59
59
  }: {
60
- database: NodePgDatabase<typeof schema>;
60
+ database: SafeDatabase<typeof schema>;
61
61
  logger: { debug: (msg: string) => void };
62
62
  accessRules: {
63
63
  id: string;
@@ -170,7 +170,7 @@ async function syncAuthenticatedDefaultAccessRulesToUsersRole({
170
170
  logger,
171
171
  accessRules,
172
172
  }: {
173
- database: NodePgDatabase<typeof schema>;
173
+ database: SafeDatabase<typeof schema>;
174
174
  logger: { debug: (msg: string) => void };
175
175
  accessRules: { id: string; isDefault?: boolean }[];
176
176
  }) {
@@ -237,7 +237,7 @@ async function syncPublicDefaultAccessRulesToAnonymousRole({
237
237
  logger,
238
238
  accessRules,
239
239
  }: {
240
- database: NodePgDatabase<typeof schema>;
240
+ database: SafeDatabase<typeof schema>;
241
241
  logger: { debug: (msg: string) => void };
242
242
  accessRules: { id: string; isPublic?: boolean }[];
243
243
  }) {
@@ -289,7 +289,7 @@ export default createBackendPlugin({
289
289
  metadata: pluginMetadata,
290
290
  register(env) {
291
291
  let auth: ReturnType<typeof betterAuth> | undefined;
292
- let db: NodePgDatabase<typeof schema> | undefined;
292
+ let db: SafeDatabase<typeof schema> | undefined;
293
293
 
294
294
  const strategies: AuthStrategy<unknown>[] = [];
295
295
 
@@ -702,7 +702,7 @@ export default createBackendPlugin({
702
702
 
703
703
  // 4. Register oRPC router
704
704
  const authRouter = createAuthRouter(
705
- database as NodePgDatabase<typeof schema>,
705
+ database as SafeDatabase<typeof schema>,
706
706
  strategyRegistry,
707
707
  reloadAuth,
708
708
  config,
@@ -770,7 +770,7 @@ export default createBackendPlugin({
770
770
  `[auth-backend] afterPluginsReady: syncing ${allAccessRules.length} access rules from all plugins`,
771
771
  );
772
772
  await syncAccessRulesToDb({
773
- database: database as NodePgDatabase<typeof schema>,
773
+ database: database as SafeDatabase<typeof schema>,
774
774
  logger,
775
775
  accessRules: allAccessRules,
776
776
  fullSync: true,
@@ -782,7 +782,7 @@ export default createBackendPlugin({
782
782
  coreHooks.accessRulesRegistered,
783
783
  async ({ accessRules }) => {
784
784
  await syncAccessRulesToDb({
785
- database: database as NodePgDatabase<typeof schema>,
785
+ database: database as SafeDatabase<typeof schema>,
786
786
  logger,
787
787
  accessRules,
788
788
  });
package/src/router.ts CHANGED
@@ -12,7 +12,7 @@ import { authContract, passwordSchema } from "@checkstack/auth-common";
12
12
  import { hashPassword } from "better-auth/crypto";
13
13
  import * as schema from "./schema";
14
14
  import { eq, inArray, and } from "drizzle-orm";
15
- import type { NodePgDatabase } from "drizzle-orm/node-postgres";
15
+ import type { SafeDatabase } from "@checkstack/backend-api";
16
16
  import { authHooks } from "./hooks";
17
17
 
18
18
  /**
@@ -118,7 +118,7 @@ function generateSecret(): string {
118
118
  }
119
119
 
120
120
  export const createAuthRouter = (
121
- internalDb: NodePgDatabase<typeof schema>,
121
+ internalDb: SafeDatabase<typeof schema>,
122
122
  strategyRegistry: { getStrategies: () => AuthStrategy<unknown>[] },
123
123
  reloadAuthFn: () => Promise<void>,
124
124
  configService: ConfigService,
package/src/teams.test.ts CHANGED
@@ -4,10 +4,10 @@ import { createMockRpcContext } from "@checkstack/backend-api";
4
4
  import { call } from "@orpc/server";
5
5
  import { z } from "zod";
6
6
  import * as schema from "./schema";
7
- import type { NodePgDatabase } from "drizzle-orm/node-postgres";
7
+ import type { SafeDatabase } from "@checkstack/backend-api";
8
8
 
9
9
  /** Type alias for the database type used in auth router */
10
- type AuthDatabase = NodePgDatabase<typeof schema>;
10
+ type AuthDatabase = SafeDatabase<typeof schema>;
11
11
 
12
12
  /**
13
13
  * Tests for Team and Resource-Level Access Control endpoints.
@@ -65,7 +65,7 @@ describe("Teams and Resource Access Control", () => {
65
65
 
66
66
  /**
67
67
  * Creates a fresh mock database for each test.
68
- * Uses type assertion to satisfy NodePgDatabase interface for testing.
68
+ * Uses type assertion to satisfy SafeDatabase interface for testing.
69
69
  */
70
70
  function createMockDb(): AuthDatabase {
71
71
  const mockDb = {
package/src/utils/user.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { User } from "better-auth/types";
2
- import { NodePgDatabase } from "drizzle-orm/node-postgres";
2
+ import { SafeDatabase } from "@checkstack/backend-api";
3
3
  import { eq } from "drizzle-orm";
4
4
  import type { RealUser } from "@checkstack/backend-api";
5
5
  import * as schema from "../schema";
@@ -10,7 +10,7 @@ import * as schema from "../schema";
10
10
  */
11
11
  export const enrichUser = async (
12
12
  user: User,
13
- db: NodePgDatabase<typeof schema>
13
+ db: SafeDatabase<typeof schema>
14
14
  ): Promise<RealUser> => {
15
15
  // 1. Get Roles
16
16
  const userRoles = await db