@authhero/adapter-interfaces 3.4.1 → 3.5.0

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.
@@ -0,0 +1,9 @@
1
+ import { UserActivity, UserActivityUpdate } from "../types/UserActivity";
2
+ export interface UserActivityAdapter {
3
+ get(tenantId: string, userId: string): Promise<UserActivity | null>;
4
+ /**
5
+ * Insert or merge-update the activity row for a user. Only the provided
6
+ * fields are written; previously-stored fields are preserved.
7
+ */
8
+ upsert(tenantId: string, userId: string, activity: UserActivityUpdate): Promise<void>;
9
+ }
@@ -32,6 +32,7 @@ import { FormsAdapter } from "./Forms";
32
32
  import { ResourceServersAdapter } from "./ResourceServers";
33
33
  import { RolePermissionsAdapter } from "./RolePermissions";
34
34
  import { GrantsAdapter } from "./Grants";
35
+ import { UserActivityAdapter } from "./UserActivity";
35
36
  import { UserPermissionsAdapter } from "./UserPermissions";
36
37
  import { RolesAdapter } from "./Roles";
37
38
  import { UserRolesAdapter } from "./UserRoles";
@@ -114,6 +115,14 @@ export interface DataAdapters {
114
115
  * `/api/v2/client-grants`, which is `clientGrants` above).
115
116
  */
116
117
  grants?: GrantsAdapter;
118
+ /**
119
+ * Optional write-often per-user activity counters (last_login, last_ip,
120
+ * login_count, …) split out of the `users` row (issue #1003). When set, the
121
+ * login flow double-writes these alongside the legacy `users` columns during
122
+ * the expand/contract migration. When undefined, only the legacy columns are
123
+ * written.
124
+ */
125
+ userActivity?: UserActivityAdapter;
117
126
  userPermissions: UserPermissionsAdapter;
118
127
  roles: RolesAdapter;
119
128
  sessions: SessionsAdapter;
@@ -238,4 +247,5 @@ export * from "./TenantSettings";
238
247
  export * from "./Tenants";
239
248
  export * from "./Themes";
240
249
  export * from "./Grants";
250
+ export * from "./UserActivity";
241
251
  export * from "./Users";
@@ -0,0 +1,17 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ /**
3
+ * Write-often per-user counters split out of the `users` row (issue #1003) so
4
+ * the profile row isn't rewritten on every login / failed password attempt.
5
+ * 1:1 with a user, keyed by `(tenant_id, user_id)`.
6
+ */
7
+ export declare const userActivitySchema: z.ZodObject<{
8
+ user_id: z.ZodString;
9
+ last_login: z.ZodOptional<z.ZodString>;
10
+ last_ip: z.ZodOptional<z.ZodString>;
11
+ login_count: z.ZodDefault<z.ZodNumber>;
12
+ failed_logins: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
+ last_password_reset: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ export type UserActivity = z.infer<typeof userActivitySchema>;
16
+ /** Partial payload for an upsert — only the provided fields are written. */
17
+ export type UserActivityUpdate = Partial<Omit<UserActivity, "user_id">>;
@@ -41,6 +41,7 @@ export * from "./SmsProvider";
41
41
  export * from "./ResourceServer";
42
42
  export * from "./RolePermission";
43
43
  export * from "./Grant";
44
+ export * from "./UserActivity";
44
45
  export * from "./UserPermission";
45
46
  export * from "./UserRole";
46
47
  export * from "./Role";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "3.4.1",
14
+ "version": "3.5.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],