fix schemas

This commit is contained in:
x032205
2026-01-06 21:20:41 -05:00
parent fe214f21ee
commit 391bdb099e

View File

@@ -17,28 +17,34 @@ export const PamAccessPolicyInputsSchema = z.object({
accountPath: z.string()
});
const accountPathGlob = z.string().refine(
(el) => {
try {
picomatch.parse([el]);
return true;
} catch {
return false;
}
},
{ message: "Invalid glob pattern" }
);
// Conditions
export const PamAccessPolicyConditionsSchema = z
.object({
accountPaths: z
.string()
accountPaths: accountPathGlob.array()
})
.array();
const MutatePamAccessPolicyConditionsSchema = z
.object({
accountPaths: accountPathGlob
.refine((el) => el.startsWith("/"), {
message: "Path must start with /"
})
.refine((el) => !el.endsWith("/"), {
message: "Path cannot end with /"
})
.refine(
(el) => {
try {
picomatch.parse([el]);
return true;
} catch {
return false;
}
},
{ message: "Invalid glob pattern" }
)
.array()
})
.array();
@@ -63,8 +69,12 @@ export const PamAccessPolicyConstraintsSchema = z.object({
// Request Data
export const PamAccessPolicyRequestDataSchema = z.object({
accountPath: z
.string()
accountPath: accountPathGlob,
accessDuration: DurationSchema
});
const CreatePamAccessPolicyRequestDataSchema = z.object({
accountPath: accountPathGlob
.refine((el) => el.startsWith("/"), {
message: "Path must start with /"
})
@@ -87,12 +97,12 @@ export const PamAccessPolicySchema = BaseApprovalPolicySchema.extend({
});
export const CreatePamAccessPolicySchema = BaseCreateApprovalPolicySchema.extend({
conditions: PamAccessPolicyConditionsSchema,
conditions: MutatePamAccessPolicyConditionsSchema,
constraints: PamAccessPolicyConstraintsSchema
});
export const UpdatePamAccessPolicySchema = BaseUpdateApprovalPolicySchema.extend({
conditions: PamAccessPolicyConditionsSchema.optional(),
conditions: MutatePamAccessPolicyConditionsSchema.optional(),
constraints: PamAccessPolicyConstraintsSchema.optional()
});
@@ -105,7 +115,7 @@ export const PamAccessRequestSchema = BaseApprovalRequestSchema.extend({
});
export const CreatePamAccessRequestSchema = BaseCreateApprovalRequestSchema.extend({
requestData: PamAccessPolicyRequestDataSchema
requestData: CreatePamAccessPolicyRequestDataSchema
});
// Grants