feat: add auth user bootstrap helper#11
Conversation
Greptile SummaryThis PR introduces Confidence Score: 5/5Safe to merge — both prior P1s are resolved and no new blocking issues were found. All findings are P2 (error masking in No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant bootstrapUsers
participant resolveStorage
participant normalizeBootstrapUser
participant storage as BootstrapUserStorage
Caller->>bootstrapUsers: config (tenantId, users, pool/storage/connectionString)
bootstrapUsers->>resolveStorage: config
resolveStorage-->>bootstrapUsers: { storage, close? }
loop for each user
bootstrapUsers->>normalizeBootstrapUser: rawUser, index
normalizeBootstrapUser-->>bootstrapUsers: normalized user (throws on bad input)
bootstrapUsers->>storage: getUserByHandle(tenantId, handle)
storage-->>bootstrapUsers: existing | null
alt existing && !updateExisting
bootstrapUsers-->>bootstrapUsers: push unchanged, continue
else no existing
bootstrapUsers->>bootstrapUsers: resolvePasswordHash(user, hasher)
bootstrapUsers->>storage: createUser(tenantId, toCreateUser(...))
storage-->>bootstrapUsers: created TenantScoped AdminUser
bootstrapUsers-->>bootstrapUsers: push created
else existing && updateExisting
bootstrapUsers->>bootstrapUsers: resolvePasswordHash(user, hasher)
bootstrapUsers->>storage: updateUser(tenantId, existing.id, toUpdateUser(...))
storage-->>bootstrapUsers: updated TenantScoped AdminUser
bootstrapUsers-->>bootstrapUsers: push updated
end
end
bootstrapUsers->>resolveStorage: close?() [finally]
bootstrapUsers-->>Caller: BootstrapUsersResult { created, updated, unchanged, users }
Reviews (2): Last reviewed commit: "feat: add auth user bootstrap helper" | Re-trigger Greptile |
9374302 to
e4bcc3c
Compare
Summary
bootstrapUsers()as a tenant-scoped auth user bootstrap helper for deploy/startup flows.pg.Pool, or a connection string while keeping create/update behavior on the shared adapter boundary../bootstrap-users, bump package/Bazel metadata to0.2.4, and document the API.Validation
pnpm install --frozen-lockfilepnpm typecheckpnpm buildpnpm test -- bootstrap-userspnpm check:packagebazel build //:pkggit diff --check