fix(GRO-1272): auto-provision staff record on first OIDC login #19

Merged
groombook-engineer[bot] merged 4 commits from fleaflicker/gro-1272-auto-provision-staff-dev into dev 2026-05-21 14:16:42 +00:00
Showing only changes of commit ea825dfdda - Show all commits
+8 -5
View File
@@ -46,7 +46,7 @@ const GROOMER: StaffRow = {
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
let staffLookupResult: StaffRow | null = null;
let managerFallbackResult: StaffRow | null = MANAGER;
let userLookupResult: { id: string; name: string | null; email: string | null } | null = null;
let insertedStaff: StaffRow | null = null;
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
let _insertedStaff: StaffRow | null = null;
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
vi.mock("../db", () => {
const makeTableProxy = (name: string) =>
@@ -88,7 +88,7 @@ vi.mock("../db", () => {
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
),
}),
}),
insert: (table: unknown) => ({
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
insert: (_table: unknown) => ({
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
values: (vals: Record<string, unknown>) => ({
returning: () => {
const newStaff: StaffRow = {
@@ -104,7 +104,7 @@ vi.mock("../db", () => {
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
createdAt: new Date(),
updatedAt: new Date(),
};
insertedStaff = newStaff;
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
_insertedStaff = newStaff;
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
return [newStaff];
},
}),
@@ -124,7 +124,7 @@ function resetMocks() {
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
staffLookupResult = null;
managerFallbackResult = MANAGER;
userLookupResult = null;
insertedStaff = null;
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
_insertedStaff = null;
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
}
/** Build a minimal Hono app with jwtPayload pre-set, then apply a middleware. */
@@ -134,7 +134,10 @@ function buildApp(
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
) {
const app = new Hono<AppEnv>();
app.use("*", async (c, next) => {
c.set("jwtPayload", { sub: staffLookupResult?.userId ?? "unknown-sub" });
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
c.set("jwtPayload", {
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
sub: userLookupResult?.id ?? staffLookupResult?.userId ?? "unknown-sub",
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
email: userLookupResult?.email,
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
});
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
await next();
});
app.use("*", middleware);
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Review

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.

returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.