mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 05:11:49 +01:00
fix(access): default omitted member grants
This commit is contained in:
1 parent
ac955be548
commit
6c10078422
2 files changed
+13
-2
No files matched your search
@@ -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",
|
||||
});
|
||||
|
||||
@@ -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([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user