fix(access): default omitted member grants

This commit is contained in:
Dotta committed 2026-04-16 06:48:56 -05:00
1 parent ac955be548
commit 6c10078422
2 files changed
+13 -2

No files matched your search

+1 -1
View File
@@ -109,7 +109,7 @@ export type UpdateCompanyMember = z.infer<typeof updateCompanyMemberSchema>;
export const updateCompanyMemberWithPermissionsSchema = z.object({
membershipRole: z.enum(HUMAN_COMPANY_MEMBERSHIP_ROLES).optional().nullable(),
status: z.enum(MEMBERSHIP_STATUSES).optional(),
grants: updateMemberPermissionsSchema.shape.grants,
grants: updateMemberPermissionsSchema.shape.grants.default([]),
}).refine((value) => value.membershipRole !== undefined || value.status !== undefined, {
message: "membershipRole or status is required",
});
+12 -1
View File
@@ -1,5 +1,8 @@
import { describe, expect, it } from "vitest";
import { updateCurrentUserProfileSchema } from "@paperclipai/shared";
import {
updateCompanyMemberWithPermissionsSchema,
updateCurrentUserProfileSchema,
} from "@paperclipai/shared";
describe("access validators", () => {
it("accepts HTTP(S) and Paperclip asset image URLs", () => {
@@ -19,4 +22,12 @@ describe("access validators", () => {
image: "data:image/png;base64,AAAA",
}).success).toBe(false);
});
it("defaults omitted combined member grants to an empty list", () => {
const result = updateCompanyMemberWithPermissionsSchema.parse({
membershipRole: "operator",
});
expect(result.grants).toEqual([]);
});
});