feat(api-docs): add error responses to API documentation

This commit is contained in:
Daniel Hougaard
2024-09-27 20:02:43 +04:00
parent 2d51ed317f
commit 7ac4b0b79f
39 changed files with 297 additions and 14 deletions
@@ -7,7 +7,7 @@ import { daysToMillisecond } from "@app/lib/dates";
import { removeTrailingSlash } from "@app/lib/fn"; import { removeTrailingSlash } from "@app/lib/fn";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { SanitizedDynamicSecretSchema } from "@app/server/routes/sanitizedSchemas"; import { DefaultResponseErrorsSchema, SanitizedDynamicSecretSchema } from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
export const registerDynamicSecretLeaseRouter = async (server: FastifyZodProvider) => { export const registerDynamicSecretLeaseRouter = async (server: FastifyZodProvider) => {
@@ -37,6 +37,7 @@ export const registerDynamicSecretLeaseRouter = async (server: FastifyZodProvide
environmentSlug: z.string().min(1).describe(DYNAMIC_SECRET_LEASES.CREATE.path) environmentSlug: z.string().min(1).describe(DYNAMIC_SECRET_LEASES.CREATE.path)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
lease: DynamicSecretLeasesSchema, lease: DynamicSecretLeasesSchema,
dynamicSecret: SanitizedDynamicSecretSchema, dynamicSecret: SanitizedDynamicSecretSchema,
@@ -81,6 +82,7 @@ export const registerDynamicSecretLeaseRouter = async (server: FastifyZodProvide
isForced: z.boolean().default(false).describe(DYNAMIC_SECRET_LEASES.DELETE.isForced) isForced: z.boolean().default(false).describe(DYNAMIC_SECRET_LEASES.DELETE.isForced)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
lease: DynamicSecretLeasesSchema lease: DynamicSecretLeasesSchema
}) })
@@ -134,6 +136,7 @@ export const registerDynamicSecretLeaseRouter = async (server: FastifyZodProvide
environmentSlug: z.string().min(1).describe(DYNAMIC_SECRET_LEASES.RENEW.environmentSlug) environmentSlug: z.string().min(1).describe(DYNAMIC_SECRET_LEASES.RENEW.environmentSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
lease: DynamicSecretLeasesSchema lease: DynamicSecretLeasesSchema
}) })
@@ -174,6 +177,7 @@ export const registerDynamicSecretLeaseRouter = async (server: FastifyZodProvide
environmentSlug: z.string().min(1).describe(DYNAMIC_SECRET_LEASES.GET_BY_LEASEID.environmentSlug) environmentSlug: z.string().min(1).describe(DYNAMIC_SECRET_LEASES.GET_BY_LEASEID.environmentSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
lease: DynamicSecretLeasesSchema.extend({ lease: DynamicSecretLeasesSchema.extend({
dynamicSecret: SanitizedDynamicSecretSchema dynamicSecret: SanitizedDynamicSecretSchema
@@ -9,7 +9,7 @@ import { daysToMillisecond } from "@app/lib/dates";
import { removeTrailingSlash } from "@app/lib/fn"; import { removeTrailingSlash } from "@app/lib/fn";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { SanitizedDynamicSecretSchema } from "@app/server/routes/sanitizedSchemas"; import { DefaultResponseErrorsSchema, SanitizedDynamicSecretSchema } from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
export const registerDynamicSecretRouter = async (server: FastifyZodProvider) => { export const registerDynamicSecretRouter = async (server: FastifyZodProvider) => {
@@ -59,6 +59,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
}) })
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
dynamicSecret: SanitizedDynamicSecretSchema dynamicSecret: SanitizedDynamicSecretSchema
}) })
@@ -90,6 +91,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
clientSecret: z.string().min(1).describe("The client secret of the Azure Entra ID App Registration") clientSecret: z.string().min(1).describe("The client secret of the Azure Entra ID App Registration")
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z 200: z
.object({ .object({
name: z.string().min(1).describe("The name of the user"), name: z.string().min(1).describe("The name of the user"),
@@ -155,6 +157,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
}) })
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
dynamicSecret: SanitizedDynamicSecretSchema dynamicSecret: SanitizedDynamicSecretSchema
}) })
@@ -194,6 +197,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
isForced: z.boolean().default(false).describe(DYNAMIC_SECRETS.DELETE.isForced) isForced: z.boolean().default(false).describe(DYNAMIC_SECRETS.DELETE.isForced)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
dynamicSecret: SanitizedDynamicSecretSchema dynamicSecret: SanitizedDynamicSecretSchema
}) })
@@ -229,6 +233,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
environmentSlug: z.string().min(1).describe(DYNAMIC_SECRETS.GET_BY_NAME.environmentSlug) environmentSlug: z.string().min(1).describe(DYNAMIC_SECRETS.GET_BY_NAME.environmentSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
dynamicSecret: SanitizedDynamicSecretSchema.extend({ dynamicSecret: SanitizedDynamicSecretSchema.extend({
inputs: z.unknown() inputs: z.unknown()
@@ -263,6 +268,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
environmentSlug: z.string().min(1).describe(DYNAMIC_SECRETS.LIST.environmentSlug) environmentSlug: z.string().min(1).describe(DYNAMIC_SECRETS.LIST.environmentSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
dynamicSecrets: SanitizedDynamicSecretSchema.array() dynamicSecrets: SanitizedDynamicSecretSchema.array()
}) })
@@ -302,6 +308,7 @@ export const registerDynamicSecretRouter = async (server: FastifyZodProvider) =>
environmentSlug: z.string().min(1).describe(DYNAMIC_SECRETS.LIST_LEAES_BY_NAME.environmentSlug) environmentSlug: z.string().min(1).describe(DYNAMIC_SECRETS.LIST_LEAES_BY_NAME.environmentSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
leases: DynamicSecretLeasesSchema.array() leases: DynamicSecretLeasesSchema.array()
}) })
+9
View File
@@ -4,6 +4,7 @@ import { z } from "zod";
import { GroupsSchema, OrgMembershipRole, UsersSchema } from "@app/db/schemas"; import { GroupsSchema, OrgMembershipRole, UsersSchema } from "@app/db/schemas";
import { GROUPS } from "@app/lib/api-docs"; import { GROUPS } from "@app/lib/api-docs";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { DefaultResponseErrorsSchema } from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
export const registerGroupRouter = async (server: FastifyZodProvider) => { export const registerGroupRouter = async (server: FastifyZodProvider) => {
@@ -26,6 +27,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
role: z.string().trim().min(1).default(OrgMembershipRole.NoAccess).describe(GROUPS.CREATE.role) role: z.string().trim().min(1).default(OrgMembershipRole.NoAccess).describe(GROUPS.CREATE.role)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: GroupsSchema 200: GroupsSchema
} }
}, },
@@ -51,6 +53,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
id: z.string().trim().describe(GROUPS.GET_BY_ID.id) id: z.string().trim().describe(GROUPS.GET_BY_ID.id)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: GroupsSchema 200: GroupsSchema
} }
}, },
@@ -73,6 +76,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: { schema: {
response: { response: {
...DefaultResponseErrorsSchema,
200: GroupsSchema.array() 200: GroupsSchema.array()
} }
}, },
@@ -112,6 +116,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
}) })
.partial(), .partial(),
response: { response: {
...DefaultResponseErrorsSchema,
200: GroupsSchema 200: GroupsSchema
} }
}, },
@@ -138,6 +143,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
id: z.string().trim().describe(GROUPS.DELETE.id) id: z.string().trim().describe(GROUPS.DELETE.id)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: GroupsSchema 200: GroupsSchema
} }
}, },
@@ -168,6 +174,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
username: z.string().optional().describe(GROUPS.LIST_USERS.username) username: z.string().optional().describe(GROUPS.LIST_USERS.username)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
users: UsersSchema.pick({ users: UsersSchema.pick({
email: true, email: true,
@@ -210,6 +217,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
username: z.string().trim().describe(GROUPS.ADD_USER.username) username: z.string().trim().describe(GROUPS.ADD_USER.username)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: UsersSchema.pick({ 200: UsersSchema.pick({
email: true, email: true,
username: true, username: true,
@@ -243,6 +251,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
username: z.string().trim().describe(GROUPS.DELETE_USER.username) username: z.string().trim().describe(GROUPS.DELETE_USER.username)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: UsersSchema.pick({ 200: UsersSchema.pick({
email: true, email: true,
username: true, username: true,
@@ -10,6 +10,7 @@ import { alphaNumericNanoId } from "@app/lib/nanoid";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { import {
DefaultResponseErrorsSchema,
ProjectPermissionSchema, ProjectPermissionSchema,
ProjectSpecificPrivilegePermissionSchema, ProjectSpecificPrivilegePermissionSchema,
SanitizedIdentityPrivilegeSchema SanitizedIdentityPrivilegeSchema
@@ -52,6 +53,7 @@ export const registerIdentityProjectAdditionalPrivilegeRouter = async (server: F
).optional() ).optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
privilege: SanitizedIdentityPrivilegeSchema privilege: SanitizedIdentityPrivilegeSchema
}) })
@@ -131,6 +133,7 @@ export const registerIdentityProjectAdditionalPrivilegeRouter = async (server: F
.describe(IDENTITY_ADDITIONAL_PRIVILEGE.CREATE.temporaryAccessStartTime) .describe(IDENTITY_ADDITIONAL_PRIVILEGE.CREATE.temporaryAccessStartTime)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
privilege: SanitizedIdentityPrivilegeSchema privilege: SanitizedIdentityPrivilegeSchema
}) })
@@ -215,6 +218,7 @@ export const registerIdentityProjectAdditionalPrivilegeRouter = async (server: F
.partial() .partial()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
privilege: SanitizedIdentityPrivilegeSchema privilege: SanitizedIdentityPrivilegeSchema
}) })
@@ -270,6 +274,7 @@ export const registerIdentityProjectAdditionalPrivilegeRouter = async (server: F
projectSlug: z.string().min(1).describe(IDENTITY_ADDITIONAL_PRIVILEGE.DELETE.projectSlug) projectSlug: z.string().min(1).describe(IDENTITY_ADDITIONAL_PRIVILEGE.DELETE.projectSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
privilege: SanitizedIdentityPrivilegeSchema privilege: SanitizedIdentityPrivilegeSchema
}) })
@@ -311,6 +316,7 @@ export const registerIdentityProjectAdditionalPrivilegeRouter = async (server: F
projectSlug: z.string().min(1).describe(IDENTITY_ADDITIONAL_PRIVILEGE.GET_BY_SLUG.projectSlug) projectSlug: z.string().min(1).describe(IDENTITY_ADDITIONAL_PRIVILEGE.GET_BY_SLUG.projectSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
privilege: SanitizedIdentityPrivilegeSchema privilege: SanitizedIdentityPrivilegeSchema
}) })
@@ -348,6 +354,7 @@ export const registerIdentityProjectAdditionalPrivilegeRouter = async (server: F
projectSlug: z.string().min(1).describe(IDENTITY_ADDITIONAL_PRIVILEGE.LIST.projectSlug) projectSlug: z.string().min(1).describe(IDENTITY_ADDITIONAL_PRIVILEGE.LIST.projectSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
privileges: SanitizedIdentityPrivilegeSchema.array() privileges: SanitizedIdentityPrivilegeSchema.array()
}) })
@@ -6,7 +6,11 @@ import { ProjectMembershipRole, ProjectMembershipsSchema, ProjectRolesSchema } f
import { PROJECT_ROLE } from "@app/lib/api-docs"; import { PROJECT_ROLE } from "@app/lib/api-docs";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ProjectPermissionSchema, SanitizedRoleSchema } from "@app/server/routes/sanitizedSchemas"; import {
DefaultResponseErrorsSchema,
ProjectPermissionSchema,
SanitizedRoleSchema
} from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
export const registerProjectRoleRouter = async (server: FastifyZodProvider) => { export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
@@ -45,6 +49,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
permissions: ProjectPermissionSchema.array().describe(PROJECT_ROLE.CREATE.permissions) permissions: ProjectPermissionSchema.array().describe(PROJECT_ROLE.CREATE.permissions)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
role: SanitizedRoleSchema role: SanitizedRoleSchema
}) })
@@ -105,6 +110,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
permissions: ProjectPermissionSchema.array().describe(PROJECT_ROLE.UPDATE.permissions).optional() permissions: ProjectPermissionSchema.array().describe(PROJECT_ROLE.UPDATE.permissions).optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
role: SanitizedRoleSchema role: SanitizedRoleSchema
}) })
@@ -146,6 +152,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
roleId: z.string().trim().describe(PROJECT_ROLE.DELETE.roleId) roleId: z.string().trim().describe(PROJECT_ROLE.DELETE.roleId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
role: SanitizedRoleSchema role: SanitizedRoleSchema
}) })
@@ -182,6 +189,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
projectSlug: z.string().trim().describe(PROJECT_ROLE.LIST.projectSlug) projectSlug: z.string().trim().describe(PROJECT_ROLE.LIST.projectSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
roles: ProjectRolesSchema.omit({ permissions: true }).array() roles: ProjectRolesSchema.omit({ permissions: true }).array()
}) })
@@ -212,6 +220,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
slug: z.string().trim().describe(PROJECT_ROLE.GET_ROLE_BY_SLUG.roleSlug) slug: z.string().trim().describe(PROJECT_ROLE.GET_ROLE_BY_SLUG.roleSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
role: SanitizedRoleSchema role: SanitizedRoleSchema
}) })
@@ -242,6 +251,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
projectId: z.string().trim() projectId: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
data: z.object({ data: z.object({
membership: ProjectMembershipsSchema.extend({ membership: ProjectMembershipsSchema.extend({
@@ -6,6 +6,7 @@ import { AUDIT_LOGS, PROJECTS } from "@app/lib/api-docs";
import { getLastMidnightDateISO, removeTrailingSlash } from "@app/lib/fn"; import { getLastMidnightDateISO, removeTrailingSlash } from "@app/lib/fn";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { DefaultResponseErrorsSchema } from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { KmsType } from "@app/services/kms/kms-types"; import { KmsType } from "@app/services/kms/kms-types";
@@ -33,6 +34,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
limit: z.coerce.number().default(20).describe(PROJECTS.GET_SNAPSHOTS.limit) limit: z.coerce.number().default(20).describe(PROJECTS.GET_SNAPSHOTS.limit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secretSnapshots: SecretSnapshotsSchema.array() secretSnapshots: SecretSnapshotsSchema.array()
}) })
+2 -1
View File
@@ -4,7 +4,7 @@ import { SecretSnapshotsSchema, SecretTagsSchema } from "@app/db/schemas";
import { PROJECTS } from "@app/lib/api-docs"; import { PROJECTS } from "@app/lib/api-docs";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { secretRawSchema } from "@app/server/routes/sanitizedSchemas"; import { DefaultResponseErrorsSchema, secretRawSchema } from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
export const registerSnapshotRouter = async (server: FastifyZodProvider) => { export const registerSnapshotRouter = async (server: FastifyZodProvider) => {
@@ -77,6 +77,7 @@ export const registerSnapshotRouter = async (server: FastifyZodProvider) => {
secretSnapshotId: z.string().trim().describe(PROJECTS.ROLLBACK_TO_SNAPSHOT.secretSnapshotId) secretSnapshotId: z.string().trim().describe(PROJECTS.ROLLBACK_TO_SNAPSHOT.secretSnapshotId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secretSnapshot: SecretSnapshotsSchema secretSnapshot: SecretSnapshotsSchema
}) })
@@ -27,6 +27,44 @@ export const integrationAuthPubSchema = IntegrationAuthsSchema.pick({
updatedAt: true updatedAt: true
}); });
export const DefaultResponseErrorsSchema = {
400: z.object({
statusCode: z.literal(400),
message: z.literal(
`<string>: Contains a human-readable message about what went wrong. 400 errors are bad request errors, and are will occur to happen when passing or unexpected bad data in the request`
),
error: z.literal(`<string>: Contains a human-readable error name.`)
}),
404: z.object({
statusCode: z.literal(404),
message: z.literal(
`<string>: Contains a human-readable message about what went wrong. 404 errors are not found errors, and will occur when a resource is not found`
),
error: z.literal(`<string>: Contains a human-readable error name.`)
}),
401: z.object({
statusCode: z.literal(401),
message: z.literal(
`<string>: Contains a human-readable message about what went wrong. 401 errors are unauthorized errors, and will occur when attempting to access a resource with invalid or missing credentials`
),
error: z.literal(`<string>: Contains a human-readable error name.`)
}),
403: z.object({
statusCode: z.literal(403),
message: z.literal(
`<string>: Contains a human-readable message about what went wrong. 403 errors are forbidden errors, and will occur when attempting to access a resource without the necessary permissions`
),
error: z.literal(`<string>: Contains a human-readable error name.`)
}),
500: z.object({
statusCode: z.literal(500),
message: z.literal(
`<string>: Contains a human-readable message about what went wrong. 500 errors are internal server errors, and will occur when an unexpected error occurs on the server`
),
error: z.literal(`<string>: Contains a human-readable error name.`)
})
};
export const sapPubSchema = SecretApprovalPoliciesSchema.merge( export const sapPubSchema = SecretApprovalPoliciesSchema.merge(
z.object({ z.object({
environment: z.object({ environment: z.object({
@@ -15,6 +15,8 @@ import {
validateCaDateField validateCaDateField
} from "@app/services/certificate-authority/certificate-authority-validators"; } from "@app/services/certificate-authority/certificate-authority-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerCaRouter = async (server: FastifyZodProvider) => { export const registerCaRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -63,6 +65,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
} }
), ),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
ca: CertificateAuthoritiesSchema ca: CertificateAuthoritiesSchema
}) })
@@ -108,6 +111,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
ca: CertificateAuthoritiesSchema ca: CertificateAuthoritiesSchema
}) })
@@ -155,6 +159,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caCertId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CERT_BY_ID.caCertId) caCertId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CERT_BY_ID.caCertId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.instanceof(Buffer) 200: z.instanceof(Buffer)
} }
}, },
@@ -187,6 +192,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
.describe(CERTIFICATE_AUTHORITIES.CREATE.requireTemplateForIssuance) .describe(CERTIFICATE_AUTHORITIES.CREATE.requireTemplateForIssuance)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
ca: CertificateAuthoritiesSchema ca: CertificateAuthoritiesSchema
}) })
@@ -234,6 +240,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.DELETE.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.DELETE.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
ca: CertificateAuthoritiesSchema ca: CertificateAuthoritiesSchema
}) })
@@ -279,6 +286,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CSR.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CSR.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
csr: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CSR.csr) csr: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CSR.csr)
}) })
@@ -328,6 +336,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
notAfter: validateCaDateField.describe(CERTIFICATE_AUTHORITIES.RENEW_CA_CERT.notAfter) notAfter: validateCaDateField.describe(CERTIFICATE_AUTHORITIES.RENEW_CA_CERT.notAfter)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.RENEW_CA_CERT.certificate), certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.RENEW_CA_CERT.certificate),
certificateChain: z.string().trim().describe(CERTIFICATE_AUTHORITIES.RENEW_CA_CERT.certificateChain), certificateChain: z.string().trim().describe(CERTIFICATE_AUTHORITIES.RENEW_CA_CERT.certificateChain),
@@ -379,6 +388,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CA_CERTS.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CA_CERTS.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.array( 200: z.array(
z.object({ z.object({
certificate: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CA_CERTS.certificate), certificate: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CA_CERTS.certificate),
@@ -427,6 +437,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CERT.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CERT.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CERT.certificate), certificate: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CERT.certificate),
certificateChain: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CERT.certificateChain), certificateChain: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CERT.certificateChain),
@@ -482,6 +493,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
maxPathLength: z.number().min(-1).default(-1).describe(CERTIFICATE_AUTHORITIES.SIGN_INTERMEDIATE.maxPathLength) maxPathLength: z.number().min(-1).default(-1).describe(CERTIFICATE_AUTHORITIES.SIGN_INTERMEDIATE.maxPathLength)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_INTERMEDIATE.certificate), certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_INTERMEDIATE.certificate),
certificateChain: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_INTERMEDIATE.certificateChain), certificateChain: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_INTERMEDIATE.certificateChain),
@@ -543,6 +555,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
certificateChain: z.string().trim().describe(CERTIFICATE_AUTHORITIES.IMPORT_CERT.certificateChain) certificateChain: z.string().trim().describe(CERTIFICATE_AUTHORITIES.IMPORT_CERT.certificateChain)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string().trim(), message: z.string().trim(),
caId: z.string().trim() caId: z.string().trim()
@@ -616,6 +629,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
} }
), ),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.certificate), certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.certificate),
issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate), issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate),
@@ -698,6 +712,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
} }
), ),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_CERT.certificate), certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_CERT.certificate),
issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate), issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate),
@@ -753,6 +768,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_CERT.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_CERT.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificateTemplates: CertificateTemplatesSchema.array() certificateTemplates: CertificateTemplatesSchema.array()
}) })
@@ -798,6 +814,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CRLS.caId) caId: z.string().trim().describe(CERTIFICATE_AUTHORITIES.GET_CRLS.caId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.array( 200: z.array(
z.object({ z.object({
id: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CRLS.id), id: z.string().describe(CERTIFICATE_AUTHORITIES.GET_CRLS.id),
@@ -13,6 +13,8 @@ import {
validateCaDateField validateCaDateField
} from "@app/services/certificate-authority/certificate-authority-validators"; } from "@app/services/certificate-authority/certificate-authority-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerCertRouter = async (server: FastifyZodProvider) => { export const registerCertRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -27,6 +29,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
serialNumber: z.string().trim().describe(CERTIFICATES.GET.serialNumber) serialNumber: z.string().trim().describe(CERTIFICATES.GET.serialNumber)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: CertificatesSchema certificate: CertificatesSchema
}) })
@@ -118,6 +121,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
} }
), ),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.certificate), certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.certificate),
issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate), issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate),
@@ -219,6 +223,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
} }
), ),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_CERT.certificate), certificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.SIGN_CERT.certificate),
issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate), issuingCaCertificate: z.string().trim().describe(CERTIFICATE_AUTHORITIES.ISSUE_CERT.issuingCaCertificate),
@@ -276,6 +281,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
revocationReason: z.nativeEnum(CrlReason).describe(CERTIFICATES.REVOKE.revocationReason) revocationReason: z.nativeEnum(CrlReason).describe(CERTIFICATES.REVOKE.revocationReason)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string().trim(), message: z.string().trim(),
serialNumber: z.string().trim().describe(CERTIFICATES.REVOKE.serialNumberRes), serialNumber: z.string().trim().describe(CERTIFICATES.REVOKE.serialNumberRes),
@@ -327,6 +333,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
serialNumber: z.string().trim().describe(CERTIFICATES.DELETE.serialNumber) serialNumber: z.string().trim().describe(CERTIFICATES.DELETE.serialNumber)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: CertificatesSchema certificate: CertificatesSchema
}) })
@@ -373,6 +380,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
serialNumber: z.string().trim().describe(CERTIFICATES.GET_CERT.serialNumber) serialNumber: z.string().trim().describe(CERTIFICATES.GET_CERT.serialNumber)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificate: z.string().trim().describe(CERTIFICATES.GET_CERT.certificate), certificate: z.string().trim().describe(CERTIFICATES.GET_CERT.certificate),
certificateChain: z.string().trim().describe(CERTIFICATES.GET_CERT.certificateChain), certificateChain: z.string().trim().describe(CERTIFICATES.GET_CERT.certificateChain),
@@ -11,6 +11,8 @@ import { CertExtendedKeyUsage, CertKeyUsage } from "@app/services/certificate/ce
import { sanitizedCertificateTemplate } from "@app/services/certificate-template/certificate-template-schema"; import { sanitizedCertificateTemplate } from "@app/services/certificate-template/certificate-template-schema";
import { validateTemplateRegexField } from "@app/services/certificate-template/certificate-template-validators"; import { validateTemplateRegexField } from "@app/services/certificate-template/certificate-template-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
const sanitizedEstConfig = CertificateTemplateEstConfigsSchema.pick({ const sanitizedEstConfig = CertificateTemplateEstConfigsSchema.pick({
id: true, id: true,
certificateTemplateId: true, certificateTemplateId: true,
@@ -29,6 +31,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
certificateTemplateId: z.string().describe(CERTIFICATE_TEMPLATES.GET.certificateTemplateId) certificateTemplateId: z.string().describe(CERTIFICATE_TEMPLATES.GET.certificateTemplateId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedCertificateTemplate 200: sanitizedCertificateTemplate
} }
}, },
@@ -90,6 +93,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
.describe(CERTIFICATE_TEMPLATES.CREATE.extendedKeyUsages) .describe(CERTIFICATE_TEMPLATES.CREATE.extendedKeyUsages)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedCertificateTemplate 200: sanitizedCertificateTemplate
} }
}, },
@@ -155,6 +159,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
certificateTemplateId: z.string().describe(CERTIFICATE_TEMPLATES.UPDATE.certificateTemplateId) certificateTemplateId: z.string().describe(CERTIFICATE_TEMPLATES.UPDATE.certificateTemplateId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedCertificateTemplate 200: sanitizedCertificateTemplate
} }
}, },
@@ -201,6 +206,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
certificateTemplateId: z.string().describe(CERTIFICATE_TEMPLATES.DELETE.certificateTemplateId) certificateTemplateId: z.string().describe(CERTIFICATE_TEMPLATES.DELETE.certificateTemplateId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedCertificateTemplate 200: sanitizedCertificateTemplate
} }
}, },
@@ -247,6 +253,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
isEnabled: z.boolean().default(true) isEnabled: z.boolean().default(true)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedEstConfig 200: sanitizedEstConfig
} }
}, },
@@ -294,6 +301,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
isEnabled: z.boolean().optional() isEnabled: z.boolean().optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedEstConfig 200: sanitizedEstConfig
} }
}, },
@@ -336,6 +344,7 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
certificateTemplateId: z.string().trim() certificateTemplateId: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: sanitizedEstConfig.extend({ 200: sanitizedEstConfig.extend({
caChain: z.string() caChain: z.string()
}) })
@@ -12,6 +12,8 @@ import {
validatePrincipalArns validatePrincipalArns
} from "@app/services/identity-aws-auth/identity-aws-auth-validators"; } from "@app/services/identity-aws-auth/identity-aws-auth-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider) => { export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -28,6 +30,7 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)
iamRequestHeaders: z.string().describe(AWS_AUTH.LOGIN.iamRequestHeaders) iamRequestHeaders: z.string().describe(AWS_AUTH.LOGIN.iamRequestHeaders)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -118,6 +121,7 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)
accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(AWS_AUTH.ATTACH.accessTokenNumUsesLimit) accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(AWS_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAwsAuth: IdentityAwsAuthsSchema identityAwsAuth: IdentityAwsAuthsSchema
}) })
@@ -197,6 +201,7 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)
.describe(AWS_AUTH.UPDATE.accessTokenMaxTTL) .describe(AWS_AUTH.UPDATE.accessTokenMaxTTL)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAwsAuth: IdentityAwsAuthsSchema identityAwsAuth: IdentityAwsAuthsSchema
}) })
@@ -252,6 +257,7 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)
identityId: z.string().describe(AWS_AUTH.RETRIEVE.identityId) identityId: z.string().describe(AWS_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAwsAuth: IdentityAwsAuthsSchema identityAwsAuth: IdentityAwsAuthsSchema
}) })
@@ -298,6 +304,7 @@ export const registerIdentityAwsAuthRouter = async (server: FastifyZodProvider)
identityId: z.string().describe(AWS_AUTH.REVOKE.identityId) identityId: z.string().describe(AWS_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAwsAuth: IdentityAwsAuthsSchema identityAwsAuth: IdentityAwsAuthsSchema
}) })
@@ -9,6 +9,8 @@ import { AuthMode } from "@app/services/auth/auth-type";
import { TIdentityTrustedIp } from "@app/services/identity/identity-types"; import { TIdentityTrustedIp } from "@app/services/identity/identity-types";
import { validateAzureAuthField } from "@app/services/identity-azure-auth/identity-azure-auth-validators"; import { validateAzureAuthField } from "@app/services/identity-azure-auth/identity-azure-auth-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider) => { export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -23,6 +25,7 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider
jwt: z.string() jwt: z.string()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -108,6 +111,7 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider
accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(AZURE_AUTH.ATTACH.accessTokenNumUsesLimit) accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(AZURE_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAzureAuth: IdentityAzureAuthsSchema identityAzureAuth: IdentityAzureAuthsSchema
}) })
@@ -188,6 +192,7 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider
.describe(AZURE_AUTH.UPDATE.accessTokenMaxTTL) .describe(AZURE_AUTH.UPDATE.accessTokenMaxTTL)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAzureAuth: IdentityAzureAuthsSchema identityAzureAuth: IdentityAzureAuthsSchema
}) })
@@ -242,6 +247,7 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider
identityId: z.string().describe(AZURE_AUTH.RETRIEVE.identityId) identityId: z.string().describe(AZURE_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAzureAuth: IdentityAzureAuthsSchema identityAzureAuth: IdentityAzureAuthsSchema
}) })
@@ -289,6 +295,7 @@ export const registerIdentityAzureAuthRouter = async (server: FastifyZodProvider
identityId: z.string().describe(AZURE_AUTH.REVOKE.identityId) identityId: z.string().describe(AZURE_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityAzureAuth: IdentityAzureAuthsSchema identityAzureAuth: IdentityAzureAuthsSchema
}) })
@@ -9,6 +9,8 @@ import { AuthMode } from "@app/services/auth/auth-type";
import { TIdentityTrustedIp } from "@app/services/identity/identity-types"; import { TIdentityTrustedIp } from "@app/services/identity/identity-types";
import { validateGcpAuthField } from "@app/services/identity-gcp-auth/identity-gcp-auth-validators"; import { validateGcpAuthField } from "@app/services/identity-gcp-auth/identity-gcp-auth-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider) => { export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -23,6 +25,7 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)
jwt: z.string() jwt: z.string()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -109,6 +112,7 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)
accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(GCP_AUTH.ATTACH.accessTokenNumUsesLimit) accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(GCP_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityGcpAuth: IdentityGcpAuthsSchema identityGcpAuth: IdentityGcpAuthsSchema
}) })
@@ -190,6 +194,7 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)
.describe(GCP_AUTH.UPDATE.accessTokenMaxTTL) .describe(GCP_AUTH.UPDATE.accessTokenMaxTTL)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityGcpAuth: IdentityGcpAuthsSchema identityGcpAuth: IdentityGcpAuthsSchema
}) })
@@ -246,6 +251,7 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)
identityId: z.string().describe(GCP_AUTH.RETRIEVE.identityId) identityId: z.string().describe(GCP_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityGcpAuth: IdentityGcpAuthsSchema identityGcpAuth: IdentityGcpAuthsSchema
}) })
@@ -293,6 +299,7 @@ export const registerIdentityGcpAuthRouter = async (server: FastifyZodProvider)
identityId: z.string().describe(GCP_AUTH.REVOKE.identityId) identityId: z.string().describe(GCP_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityGcpAuth: IdentityGcpAuthsSchema identityGcpAuth: IdentityGcpAuthsSchema
}) })
@@ -8,6 +8,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { TIdentityTrustedIp } from "@app/services/identity/identity-types"; import { TIdentityTrustedIp } from "@app/services/identity/identity-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
const IdentityKubernetesAuthResponseSchema = IdentityKubernetesAuthsSchema.omit({ const IdentityKubernetesAuthResponseSchema = IdentityKubernetesAuthsSchema.omit({
encryptedCaCert: true, encryptedCaCert: true,
caCertIV: true, caCertIV: true,
@@ -34,6 +36,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
jwt: z.string().trim() jwt: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -129,6 +132,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
.describe(KUBERNETES_AUTH.ATTACH.accessTokenNumUsesLimit) .describe(KUBERNETES_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityKubernetesAuth: IdentityKubernetesAuthResponseSchema identityKubernetesAuth: IdentityKubernetesAuthResponseSchema
}) })
@@ -222,6 +226,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
.describe(KUBERNETES_AUTH.UPDATE.accessTokenMaxTTL) .describe(KUBERNETES_AUTH.UPDATE.accessTokenMaxTTL)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityKubernetesAuth: IdentityKubernetesAuthResponseSchema identityKubernetesAuth: IdentityKubernetesAuthResponseSchema
}) })
@@ -277,6 +282,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
identityId: z.string().describe(KUBERNETES_AUTH.RETRIEVE.identityId) identityId: z.string().describe(KUBERNETES_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityKubernetesAuth: IdentityKubernetesAuthResponseSchema identityKubernetesAuth: IdentityKubernetesAuthResponseSchema
}) })
@@ -324,6 +330,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
identityId: z.string().describe(KUBERNETES_AUTH.REVOKE.identityId) identityId: z.string().describe(KUBERNETES_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityKubernetesAuth: IdentityKubernetesAuthResponseSchema.omit({ identityKubernetesAuth: IdentityKubernetesAuthResponseSchema.omit({
caCert: true, caCert: true,
@@ -12,6 +12,8 @@ import {
validateOidcBoundClaimsField validateOidcBoundClaimsField
} from "@app/services/identity-oidc-auth/identity-oidc-auth-validators"; } from "@app/services/identity-oidc-auth/identity-oidc-auth-validators";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
const IdentityOidcAuthResponseSchema = IdentityOidcAuthsSchema.omit({ const IdentityOidcAuthResponseSchema = IdentityOidcAuthsSchema.omit({
encryptedCaCert: true, encryptedCaCert: true,
caCertIV: true, caCertIV: true,
@@ -34,6 +36,7 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)
jwt: z.string().trim() jwt: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -124,6 +127,7 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)
accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(OIDC_AUTH.ATTACH.accessTokenNumUsesLimit) accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(OIDC_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityOidcAuth: IdentityOidcAuthResponseSchema identityOidcAuth: IdentityOidcAuthResponseSchema
}) })
@@ -223,6 +227,7 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)
}) })
.partial(), .partial(),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityOidcAuth: IdentityOidcAuthResponseSchema identityOidcAuth: IdentityOidcAuthResponseSchema
}) })
@@ -281,6 +286,7 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)
identityId: z.string().describe(OIDC_AUTH.RETRIEVE.identityId) identityId: z.string().describe(OIDC_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityOidcAuth: IdentityOidcAuthResponseSchema identityOidcAuth: IdentityOidcAuthResponseSchema
}) })
@@ -328,6 +334,7 @@ export const registerIdentityOidcAuthRouter = async (server: FastifyZodProvider)
identityId: z.string().describe(OIDC_AUTH.REVOKE.identityId) identityId: z.string().describe(OIDC_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityOidcAuth: IdentityOidcAuthResponseSchema.omit({ identityOidcAuth: IdentityOidcAuthResponseSchema.omit({
caCert: true caCert: true
@@ -9,7 +9,7 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types"; import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
import { SanitizedProjectSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
export const registerIdentityRouter = async (server: FastifyZodProvider) => { export const registerIdentityRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
@@ -32,6 +32,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
role: z.string().trim().min(1).default(OrgMembershipRole.NoAccess).describe(IDENTITIES.CREATE.role) role: z.string().trim().min(1).default(OrgMembershipRole.NoAccess).describe(IDENTITIES.CREATE.role)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identity: IdentitiesSchema identity: IdentitiesSchema
}) })
@@ -96,6 +97,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
role: z.string().trim().min(1).optional().describe(IDENTITIES.UPDATE.role) role: z.string().trim().min(1).optional().describe(IDENTITIES.UPDATE.role)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identity: IdentitiesSchema identity: IdentitiesSchema
}) })
@@ -145,6 +147,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
identityId: z.string().describe(IDENTITIES.DELETE.identityId) identityId: z.string().describe(IDENTITIES.DELETE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identity: IdentitiesSchema identity: IdentitiesSchema
}) })
@@ -191,6 +194,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
identityId: z.string().describe(IDENTITIES.GET_BY_ID.identityId) identityId: z.string().describe(IDENTITIES.GET_BY_ID.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identity: IdentityOrgMembershipsSchema.extend({ identity: IdentityOrgMembershipsSchema.extend({
customRole: OrgRolesSchema.pick({ customRole: OrgRolesSchema.pick({
@@ -236,6 +240,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
orgId: z.string().describe(IDENTITIES.LIST.orgId) orgId: z.string().describe(IDENTITIES.LIST.orgId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identities: IdentityOrgMembershipsSchema.extend({ identities: IdentityOrgMembershipsSchema.extend({
customRole: OrgRolesSchema.pick({ customRole: OrgRolesSchema.pick({
@@ -8,6 +8,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { TIdentityTrustedIp } from "@app/services/identity/identity-types"; import { TIdentityTrustedIp } from "@app/services/identity/identity-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider) => { export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -57,6 +59,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(TOKEN_AUTH.ATTACH.accessTokenNumUsesLimit) accessTokenNumUsesLimit: z.number().int().min(0).default(0).describe(TOKEN_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityTokenAuth: IdentityTokenAuthsSchema identityTokenAuth: IdentityTokenAuthsSchema
}) })
@@ -132,6 +135,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
.describe(TOKEN_AUTH.UPDATE.accessTokenMaxTTL) .describe(TOKEN_AUTH.UPDATE.accessTokenMaxTTL)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityTokenAuth: IdentityTokenAuthsSchema identityTokenAuth: IdentityTokenAuthsSchema
}) })
@@ -186,6 +190,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
identityId: z.string().describe(TOKEN_AUTH.RETRIEVE.identityId) identityId: z.string().describe(TOKEN_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityTokenAuth: IdentityTokenAuthsSchema identityTokenAuth: IdentityTokenAuthsSchema
}) })
@@ -233,6 +238,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
identityId: z.string().describe(TOKEN_AUTH.REVOKE.identityId) identityId: z.string().describe(TOKEN_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityTokenAuth: IdentityTokenAuthsSchema identityTokenAuth: IdentityTokenAuthsSchema
}) })
@@ -283,6 +289,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
name: z.string().optional().describe(TOKEN_AUTH.CREATE_TOKEN.name) name: z.string().optional().describe(TOKEN_AUTH.CREATE_TOKEN.name)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -345,6 +352,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
limit: z.coerce.number().min(1).max(100).default(20).describe(TOKEN_AUTH.GET_TOKENS.limit) limit: z.coerce.number().min(1).max(100).default(20).describe(TOKEN_AUTH.GET_TOKENS.limit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
tokens: IdentityAccessTokensSchema.array() tokens: IdentityAccessTokensSchema.array()
}) })
@@ -396,6 +404,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
name: z.string().optional().describe(TOKEN_AUTH.UPDATE_TOKEN.name) name: z.string().optional().describe(TOKEN_AUTH.UPDATE_TOKEN.name)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
token: IdentityAccessTokensSchema token: IdentityAccessTokensSchema
}) })
@@ -446,6 +455,7 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
tokenId: z.string().describe(TOKEN_AUTH.REVOKE_TOKEN.tokenId) tokenId: z.string().describe(TOKEN_AUTH.REVOKE_TOKEN.tokenId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string() message: z.string()
}) })
@@ -8,6 +8,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { TIdentityTrustedIp } from "@app/services/identity/identity-types"; import { TIdentityTrustedIp } from "@app/services/identity/identity-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const sanitizedClientSecretSchema = IdentityUaClientSecretsSchema.pick({ export const sanitizedClientSecretSchema = IdentityUaClientSecretsSchema.pick({
id: true, id: true,
createdAt: true, createdAt: true,
@@ -35,6 +37,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
clientSecret: z.string().trim().describe(UNIVERSAL_AUTH.LOGIN.clientSecret) clientSecret: z.string().trim().describe(UNIVERSAL_AUTH.LOGIN.clientSecret)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
accessToken: z.string(), accessToken: z.string(),
expiresIn: z.coerce.number(), expiresIn: z.coerce.number(),
@@ -130,6 +133,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
.describe(UNIVERSAL_AUTH.ATTACH.accessTokenNumUsesLimit) .describe(UNIVERSAL_AUTH.ATTACH.accessTokenNumUsesLimit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityUniversalAuth: IdentityUniversalAuthsSchema identityUniversalAuth: IdentityUniversalAuthsSchema
}) })
@@ -222,6 +226,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
.describe(UNIVERSAL_AUTH.UPDATE.accessTokenMaxTTL) .describe(UNIVERSAL_AUTH.UPDATE.accessTokenMaxTTL)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityUniversalAuth: IdentityUniversalAuthsSchema identityUniversalAuth: IdentityUniversalAuthsSchema
}) })
@@ -275,6 +280,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
identityId: z.string().describe(UNIVERSAL_AUTH.RETRIEVE.identityId) identityId: z.string().describe(UNIVERSAL_AUTH.RETRIEVE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityUniversalAuth: IdentityUniversalAuthsSchema identityUniversalAuth: IdentityUniversalAuthsSchema
}) })
@@ -322,6 +328,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
identityId: z.string().describe(UNIVERSAL_AUTH.REVOKE.identityId) identityId: z.string().describe(UNIVERSAL_AUTH.REVOKE.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityUniversalAuth: IdentityUniversalAuthsSchema identityUniversalAuth: IdentityUniversalAuthsSchema
}) })
@@ -374,6 +381,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
ttl: z.number().min(0).max(315360000).default(0).describe(UNIVERSAL_AUTH.CREATE_CLIENT_SECRET.ttl) ttl: z.number().min(0).max(315360000).default(0).describe(UNIVERSAL_AUTH.CREATE_CLIENT_SECRET.ttl)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
clientSecret: z.string(), clientSecret: z.string(),
clientSecretData: sanitizedClientSecretSchema clientSecretData: sanitizedClientSecretSchema
@@ -425,6 +433,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
identityId: z.string().describe(UNIVERSAL_AUTH.LIST_CLIENT_SECRETS.identityId) identityId: z.string().describe(UNIVERSAL_AUTH.LIST_CLIENT_SECRETS.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
clientSecretData: sanitizedClientSecretSchema.array() clientSecretData: sanitizedClientSecretSchema.array()
}) })
@@ -474,6 +483,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
clientSecretId: z.string().describe(UNIVERSAL_AUTH.GET_CLIENT_SECRET.clientSecretId) clientSecretId: z.string().describe(UNIVERSAL_AUTH.GET_CLIENT_SECRET.clientSecretId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
clientSecretData: sanitizedClientSecretSchema clientSecretData: sanitizedClientSecretSchema
}) })
@@ -524,6 +534,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
clientSecretId: z.string().describe(UNIVERSAL_AUTH.REVOKE_CLIENT_SECRET.clientSecretId) clientSecretId: z.string().describe(UNIVERSAL_AUTH.REVOKE_CLIENT_SECRET.clientSecretId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
clientSecretData: sanitizedClientSecretSchema clientSecretData: sanitizedClientSecretSchema
}) })
@@ -6,7 +6,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { integrationAuthPubSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, integrationAuthPubSchema } from "../sanitizedSchemas";
export const registerIntegrationAuthRouter = async (server: FastifyZodProvider) => { export const registerIntegrationAuthRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
@@ -64,6 +64,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
integrationAuthId: z.string().trim().describe(INTEGRATION_AUTH.GET.integrationAuthId) integrationAuthId: z.string().trim().describe(INTEGRATION_AUTH.GET.integrationAuthId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integrationAuth: integrationAuthPubSchema integrationAuth: integrationAuthPubSchema
}) })
@@ -100,6 +101,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
projectId: z.string().trim().describe(INTEGRATION_AUTH.DELETE.projectId) projectId: z.string().trim().describe(INTEGRATION_AUTH.DELETE.projectId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integrationAuth: integrationAuthPubSchema.array() integrationAuth: integrationAuthPubSchema.array()
}) })
@@ -148,6 +150,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
integrationAuthId: z.string().trim().describe(INTEGRATION_AUTH.DELETE_BY_ID.integrationAuthId) integrationAuthId: z.string().trim().describe(INTEGRATION_AUTH.DELETE_BY_ID.integrationAuthId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integrationAuth: integrationAuthPubSchema integrationAuth: integrationAuthPubSchema
}) })
@@ -251,6 +254,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
refreshToken: z.string().trim().optional().describe(INTEGRATION_AUTH.CREATE_ACCESS_TOKEN.refreshToken) refreshToken: z.string().trim().optional().describe(INTEGRATION_AUTH.CREATE_ACCESS_TOKEN.refreshToken)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integrationAuth: integrationAuthPubSchema integrationAuth: integrationAuthPubSchema
}) })
@@ -11,6 +11,8 @@ import { AuthMode } from "@app/services/auth/auth-type";
import { IntegrationMetadataSchema } from "@app/services/integration/integration-schema"; import { IntegrationMetadataSchema } from "@app/services/integration/integration-schema";
import { PostHogEventTypes, TIntegrationCreatedEvent } from "@app/services/telemetry/telemetry-types"; import { PostHogEventTypes, TIntegrationCreatedEvent } from "@app/services/telemetry/telemetry-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerIntegrationRouter = async (server: FastifyZodProvider) => { export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -49,6 +51,7 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
metadata: IntegrationMetadataSchema.default({}) metadata: IntegrationMetadataSchema.default({})
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integration: IntegrationsSchema integration: IntegrationsSchema
}) })
@@ -135,6 +138,7 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
metadata: IntegrationMetadataSchema.optional() metadata: IntegrationMetadataSchema.optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integration: IntegrationsSchema integration: IntegrationsSchema
}) })
@@ -219,6 +223,7 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
.transform((val) => val === "true") .transform((val) => val === "true")
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integration: IntegrationsSchema integration: IntegrationsSchema
}) })
@@ -18,6 +18,8 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ActorType, AuthMode } from "@app/services/auth/auth-type"; import { ActorType, AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerOrgRouter = async (server: FastifyZodProvider) => { export const registerOrgRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -114,6 +116,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
auditLogs: AuditLogsSchema.omit({ auditLogs: AuditLogsSchema.omit({
eventMetadata: true, eventMetadata: true,
@@ -7,6 +7,8 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerPkiAlertRouter = async (server: FastifyZodProvider) => { export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -29,6 +31,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
.describe(ALERTS.CREATE.emails) .describe(ALERTS.CREATE.emails)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiAlertsSchema 200: PkiAlertsSchema
} }
}, },
@@ -73,6 +76,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
alertId: z.string().trim().describe(ALERTS.GET.alertId) alertId: z.string().trim().describe(ALERTS.GET.alertId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiAlertsSchema 200: PkiAlertsSchema
} }
}, },
@@ -124,6 +128,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
.describe(ALERTS.UPDATE.emails) .describe(ALERTS.UPDATE.emails)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiAlertsSchema 200: PkiAlertsSchema
} }
}, },
@@ -169,6 +174,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
alertId: z.string().trim().describe(ALERTS.DELETE.alertId) alertId: z.string().trim().describe(ALERTS.DELETE.alertId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiAlertsSchema 200: PkiAlertsSchema
} }
}, },
@@ -8,6 +8,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { PkiItemType } from "@app/services/pki-collection/pki-collection-types"; import { PkiItemType } from "@app/services/pki-collection/pki-collection-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerPkiCollectionRouter = async (server: FastifyZodProvider) => { export const registerPkiCollectionRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -24,6 +26,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
description: z.string().trim().default("").describe(PKI_COLLECTIONS.CREATE.description) description: z.string().trim().default("").describe(PKI_COLLECTIONS.CREATE.description)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiCollectionsSchema 200: PkiCollectionsSchema
} }
}, },
@@ -65,6 +68,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
collectionId: z.string().trim().describe(PKI_COLLECTIONS.GET.collectionId) collectionId: z.string().trim().describe(PKI_COLLECTIONS.GET.collectionId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiCollectionsSchema 200: PkiCollectionsSchema
} }
}, },
@@ -109,6 +113,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
description: z.string().trim().optional().describe(PKI_COLLECTIONS.UPDATE.description) description: z.string().trim().optional().describe(PKI_COLLECTIONS.UPDATE.description)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiCollectionsSchema 200: PkiCollectionsSchema
} }
}, },
@@ -151,6 +156,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
collectionId: z.string().trim().describe(PKI_COLLECTIONS.DELETE.collectionId) collectionId: z.string().trim().describe(PKI_COLLECTIONS.DELETE.collectionId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiCollectionsSchema 200: PkiCollectionsSchema
} }
}, },
@@ -196,6 +202,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
limit: z.coerce.number().min(1).max(100).default(25).describe(PKI_COLLECTIONS.LIST_ITEMS.limit) limit: z.coerce.number().min(1).max(100).default(25).describe(PKI_COLLECTIONS.LIST_ITEMS.limit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
collectionItems: z.array( collectionItems: z.array(
PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({ PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({
@@ -256,6 +263,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
itemId: z.string().trim().describe(PKI_COLLECTIONS.ADD_ITEM.itemId) itemId: z.string().trim().describe(PKI_COLLECTIONS.ADD_ITEM.itemId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({ 200: PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({
type: z.nativeEnum(PkiItemType).describe(PKI_COLLECTIONS.ADD_ITEM.type), type: z.nativeEnum(PkiItemType).describe(PKI_COLLECTIONS.ADD_ITEM.type),
itemId: z.string().trim().describe(PKI_COLLECTIONS.ADD_ITEM.itemId) itemId: z.string().trim().describe(PKI_COLLECTIONS.ADD_ITEM.itemId)
@@ -304,6 +312,7 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
collectionItemId: z.string().trim().describe(PKI_COLLECTIONS.DELETE_ITEM.collectionItemId) collectionItemId: z.string().trim().describe(PKI_COLLECTIONS.DELETE_ITEM.collectionItemId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({ 200: PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({
type: z.nativeEnum(PkiItemType).describe(PKI_COLLECTIONS.DELETE_ITEM.type), type: z.nativeEnum(PkiItemType).describe(PKI_COLLECTIONS.DELETE_ITEM.type),
itemId: z.string().trim().describe(PKI_COLLECTIONS.DELETE_ITEM.itemId) itemId: z.string().trim().describe(PKI_COLLECTIONS.DELETE_ITEM.itemId)
@@ -8,6 +8,8 @@ import { writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerProjectEnvRouter = async (server: FastifyZodProvider) => { export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -85,6 +87,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
.describe(ENVIRONMENTS.CREATE.slug) .describe(ENVIRONMENTS.CREATE.slug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
workspace: z.string(), workspace: z.string(),
@@ -152,6 +155,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
position: z.number().optional().describe(ENVIRONMENTS.UPDATE.position) position: z.number().optional().describe(ENVIRONMENTS.UPDATE.position)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
workspace: z.string(), workspace: z.string(),
@@ -213,6 +217,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
id: z.string().trim().describe(ENVIRONMENTS.DELETE.id) id: z.string().trim().describe(ENVIRONMENTS.DELETE.id)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
workspace: z.string(), workspace: z.string(),
@@ -15,6 +15,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types"; import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerProjectMembershipRouter = async (server: FastifyZodProvider) => { export const registerProjectMembershipRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -33,6 +35,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
workspaceId: z.string().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIPS.workspaceId) workspaceId: z.string().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIPS.workspaceId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
memberships: ProjectMembershipsSchema.extend({ memberships: ProjectMembershipsSchema.extend({
user: UsersSchema.pick({ user: UsersSchema.pick({
@@ -94,6 +97,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
username: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.username) username: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.username)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
membership: ProjectMembershipsSchema.extend({ membership: ProjectMembershipsSchema.extend({
user: UsersSchema.pick({ user: UsersSchema.pick({
@@ -227,6 +231,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
.describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.roles) .describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.roles)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
roles: ProjectUserMembershipRolesSchema.array() roles: ProjectUserMembershipRolesSchema.array()
}) })
@@ -16,7 +16,7 @@ import { AuthMode } from "@app/services/auth/auth-type";
import { ProjectFilterType } from "@app/services/project/project-types"; import { ProjectFilterType } from "@app/services/project/project-types";
import { validateSlackChannelsField } from "@app/services/slack/slack-auth-validators"; import { validateSlackChannelsField } from "@app/services/slack/slack-auth-validators";
import { integrationAuthPubSchema, SanitizedProjectSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, integrationAuthPubSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
import { sanitizedServiceTokenSchema } from "../v2/service-token-router"; import { sanitizedServiceTokenSchema } from "../v2/service-token-router";
const projectWithEnv = SanitizedProjectSchema.merge( const projectWithEnv = SanitizedProjectSchema.merge(
@@ -177,6 +177,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
workspaceId: z.string().trim().describe(PROJECTS.GET.workspaceId) workspaceId: z.string().trim().describe(PROJECTS.GET.workspaceId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspace: projectWithEnv.optional() workspace: projectWithEnv.optional()
}) })
@@ -299,6 +300,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
autoCapitalization: z.boolean().optional().describe(PROJECTS.UPDATE.autoCapitalization) autoCapitalization: z.boolean().optional().describe(PROJECTS.UPDATE.autoCapitalization)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspace: SanitizedProjectSchema workspace: SanitizedProjectSchema
}) })
@@ -456,6 +458,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION.workspaceId) workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION.workspaceId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
integrations: IntegrationsSchema.merge( integrations: IntegrationsSchema.merge(
z.object({ z.object({
@@ -499,6 +502,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION_AUTHORIZATION.workspaceId) workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION_AUTHORIZATION.workspaceId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
authorizations: integrationAuthPubSchema.array() authorizations: integrationAuthPubSchema.array()
}) })
@@ -8,6 +8,8 @@ import { readLimit, secretsLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerSecretFolderRouter = async (server: FastifyZodProvider) => { export const registerSecretFolderRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
url: "/", url: "/",
@@ -43,6 +45,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
.describe(FOLDERS.CREATE.directory) .describe(FOLDERS.CREATE.directory)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
folder: SecretFoldersSchema folder: SecretFoldersSchema
}) })
@@ -115,6 +118,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
.describe(FOLDERS.UPDATE.directory) .describe(FOLDERS.UPDATE.directory)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
folder: SecretFoldersSchema folder: SecretFoldersSchema
}) })
@@ -258,6 +262,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
.describe(FOLDERS.DELETE.directory) .describe(FOLDERS.DELETE.directory)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
folder: SecretFoldersSchema folder: SecretFoldersSchema
}) })
@@ -326,6 +331,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
.describe(FOLDERS.LIST.directory) .describe(FOLDERS.LIST.directory)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
folders: SecretFoldersSchema.array() folders: SecretFoldersSchema.array()
}) })
@@ -364,6 +370,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
id: z.string().trim().describe(FOLDERS.GET_BY_ID.folderId) id: z.string().trim().describe(FOLDERS.GET_BY_ID.folderId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
folder: SecretFoldersSchema folder: SecretFoldersSchema
}) })
@@ -8,7 +8,7 @@ import { readLimit, secretsLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { secretRawSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, secretRawSchema } from "../sanitizedSchemas";
export const registerSecretImportRouter = async (server: FastifyZodProvider) => { export const registerSecretImportRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
@@ -35,6 +35,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
isReplication: z.boolean().default(false).describe(SECRET_IMPORTS.CREATE.isReplication) isReplication: z.boolean().default(false).describe(SECRET_IMPORTS.CREATE.isReplication)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
secretImport: SecretImportsSchema.omit({ importEnv: true }).merge( secretImport: SecretImportsSchema.omit({ importEnv: true }).merge(
@@ -108,6 +109,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
}) })
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
secretImport: SecretImportsSchema.omit({ importEnv: true }).merge( secretImport: SecretImportsSchema.omit({ importEnv: true }).merge(
@@ -172,6 +174,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
path: z.string().trim().default("/").transform(removeTrailingSlash).describe(SECRET_IMPORTS.DELETE.path) path: z.string().trim().default("/").transform(removeTrailingSlash).describe(SECRET_IMPORTS.DELETE.path)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
secretImport: SecretImportsSchema.omit({ importEnv: true }).merge( secretImport: SecretImportsSchema.omit({ importEnv: true }).merge(
@@ -275,6 +278,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
path: z.string().trim().default("/").transform(removeTrailingSlash).describe(SECRET_IMPORTS.LIST.path) path: z.string().trim().default("/").transform(removeTrailingSlash).describe(SECRET_IMPORTS.LIST.path)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string(), message: z.string(),
secretImports: SecretImportsSchema.omit({ importEnv: true }) secretImports: SecretImportsSchema.omit({ importEnv: true })
@@ -7,6 +7,8 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerSecretTagRouter = async (server: FastifyZodProvider) => { export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -19,6 +21,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
projectId: z.string().trim().describe(SECRET_TAGS.LIST.projectId) projectId: z.string().trim().describe(SECRET_TAGS.LIST.projectId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspaceTags: SecretTagsSchema.array() workspaceTags: SecretTagsSchema.array()
}) })
@@ -49,6 +52,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
tagId: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_ID.tagId) tagId: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_ID.tagId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
// akhilmhdh: for terraform backward compatiability // akhilmhdh: for terraform backward compatiability
workspaceTag: SecretTagsSchema.extend({ name: z.string() }) workspaceTag: SecretTagsSchema.extend({ name: z.string() })
@@ -80,6 +84,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
tagSlug: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_SLUG.tagSlug) tagSlug: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_SLUG.tagSlug)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
// akhilmhdh: for terraform backward compatiability // akhilmhdh: for terraform backward compatiability
workspaceTag: SecretTagsSchema.extend({ name: z.string() }) workspaceTag: SecretTagsSchema.extend({ name: z.string() })
@@ -122,6 +127,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
color: z.string().trim().describe(SECRET_TAGS.CREATE.color) color: z.string().trim().describe(SECRET_TAGS.CREATE.color)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspaceTag: SecretTagsSchema workspaceTag: SecretTagsSchema
}) })
@@ -164,6 +170,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
color: z.string().trim().describe(SECRET_TAGS.UPDATE.color) color: z.string().trim().describe(SECRET_TAGS.UPDATE.color)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspaceTag: SecretTagsSchema workspaceTag: SecretTagsSchema
}) })
@@ -195,6 +202,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
tagId: z.string().trim().describe(SECRET_TAGS.DELETE.tagId) tagId: z.string().trim().describe(SECRET_TAGS.DELETE.tagId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspaceTag: SecretTagsSchema workspaceTag: SecretTagsSchema
}) })
@@ -13,6 +13,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types"; import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerGroupProjectRouter = async (server: FastifyZodProvider) => { export const registerGroupProjectRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -63,6 +65,7 @@ export const registerGroupProjectRouter = async (server: FastifyZodProvider) =>
path: ["role", "roles"] path: ["role", "roles"]
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
groupMembership: GroupProjectMembershipsSchema groupMembership: GroupProjectMembershipsSchema
}) })
@@ -119,6 +122,7 @@ export const registerGroupProjectRouter = async (server: FastifyZodProvider) =>
.describe(PROJECTS.UPDATE_GROUP_IN_PROJECT.roles) .describe(PROJECTS.UPDATE_GROUP_IN_PROJECT.roles)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
roles: ProjectUserMembershipRolesSchema.array() roles: ProjectUserMembershipRolesSchema.array()
}) })
@@ -158,6 +162,7 @@ export const registerGroupProjectRouter = async (server: FastifyZodProvider) =>
groupId: z.string().trim().describe(PROJECTS.REMOVE_GROUP_FROM_PROJECT.groupId) groupId: z.string().trim().describe(PROJECTS.REMOVE_GROUP_FROM_PROJECT.groupId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
groupMembership: GroupProjectMembershipsSchema groupMembership: GroupProjectMembershipsSchema
}) })
@@ -195,6 +200,7 @@ export const registerGroupProjectRouter = async (server: FastifyZodProvider) =>
projectId: z.string().trim().describe(PROJECTS.LIST_GROUPS_IN_PROJECT.projectId) projectId: z.string().trim().describe(PROJECTS.LIST_GROUPS_IN_PROJECT.projectId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
groupMemberships: z groupMemberships: z
.object({ .object({
@@ -254,6 +260,7 @@ export const registerGroupProjectRouter = async (server: FastifyZodProvider) =>
groupId: z.string().trim() groupId: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
groupMembership: z.object({ groupMembership: z.object({
id: z.string(), id: z.string(),
@@ -8,6 +8,8 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { OrgIdentityOrderBy } from "@app/services/identity/identity-types"; import { OrgIdentityOrderBy } from "@app/services/identity/identity-types";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerIdentityOrgRouter = async (server: FastifyZodProvider) => { export const registerIdentityOrgRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -48,6 +50,7 @@ export const registerIdentityOrgRouter = async (server: FastifyZodProvider) => {
search: z.string().trim().describe(ORGANIZATIONS.LIST_IDENTITY_MEMBERSHIPS.search).optional() search: z.string().trim().describe(ORGANIZATIONS.LIST_IDENTITY_MEMBERSHIPS.search).optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityMemberships: IdentityOrgMembershipsSchema.merge( identityMemberships: IdentityOrgMembershipsSchema.merge(
z.object({ z.object({
@@ -16,7 +16,7 @@ import { AuthMode } from "@app/services/auth/auth-type";
import { ProjectIdentityOrderBy } from "@app/services/identity-project/identity-project-types"; import { ProjectIdentityOrderBy } from "@app/services/identity-project/identity-project-types";
import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types"; import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types";
import { SanitizedProjectSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
export const registerIdentityProjectRouter = async (server: FastifyZodProvider) => { export const registerIdentityProjectRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
@@ -71,6 +71,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
.optional() .optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityMembership: IdentityProjectMembershipsSchema identityMembership: IdentityProjectMembershipsSchema
}) })
@@ -143,6 +144,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
.describe(PROJECT_IDENTITIES.UPDATE_IDENTITY_MEMBERSHIP.roles.description) .describe(PROJECT_IDENTITIES.UPDATE_IDENTITY_MEMBERSHIP.roles.description)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
roles: ProjectUserMembershipRolesSchema.array() roles: ProjectUserMembershipRolesSchema.array()
}) })
@@ -181,6 +183,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
identityId: z.string().trim().describe(PROJECT_IDENTITIES.DELETE_IDENTITY_MEMBERSHIP.identityId) identityId: z.string().trim().describe(PROJECT_IDENTITIES.DELETE_IDENTITY_MEMBERSHIP.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityMembership: IdentityProjectMembershipsSchema identityMembership: IdentityProjectMembershipsSchema
}) })
@@ -243,6 +246,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
search: z.string().trim().describe(PROJECT_IDENTITIES.LIST_IDENTITY_MEMBERSHIPS.search).optional() search: z.string().trim().describe(PROJECT_IDENTITIES.LIST_IDENTITY_MEMBERSHIPS.search).optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityMemberships: z identityMemberships: z
.object({ .object({
@@ -308,6 +312,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
identityId: z.string().trim().describe(PROJECT_IDENTITIES.GET_IDENTITY_MEMBERSHIP_BY_ID.identityId) identityId: z.string().trim().describe(PROJECT_IDENTITIES.GET_IDENTITY_MEMBERSHIP_BY_ID.identityId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
identityMembership: z.object({ identityMembership: z.object({
id: z.string(), id: z.string(),
@@ -13,6 +13,8 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ActorType, AuthMode } from "@app/services/auth/auth-type"; import { ActorType, AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerOrgRouter = async (server: FastifyZodProvider) => { export const registerOrgRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "GET", method: "GET",
@@ -31,6 +33,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
organizationId: z.string().trim().describe(ORGANIZATIONS.LIST_USER_MEMBERSHIPS.organizationId) organizationId: z.string().trim().describe(ORGANIZATIONS.LIST_USER_MEMBERSHIPS.organizationId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
users: OrgMembershipsSchema.merge( users: OrgMembershipsSchema.merge(
z.object({ z.object({
@@ -79,6 +82,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
organizationId: z.string().trim().describe(ORGANIZATIONS.GET_PROJECTS.organizationId) organizationId: z.string().trim().describe(ORGANIZATIONS.GET_PROJECTS.organizationId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
workspaces: z workspaces: z
.object({ .object({
@@ -181,6 +185,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
isActive: z.boolean().optional().describe(ORGANIZATIONS.UPDATE_USER_MEMBERSHIP.isActive) isActive: z.boolean().optional().describe(ORGANIZATIONS.UPDATE_USER_MEMBERSHIP.isActive)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
membership: OrgMembershipsSchema membership: OrgMembershipsSchema
}) })
@@ -220,6 +225,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
membershipId: z.string().trim().describe(ORGANIZATIONS.DELETE_USER_MEMBERSHIP.membershipId) membershipId: z.string().trim().describe(ORGANIZATIONS.DELETE_USER_MEMBERSHIP.membershipId)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
membership: OrgMembershipsSchema membership: OrgMembershipsSchema
}) })
@@ -7,6 +7,8 @@ import { writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { DefaultResponseErrorsSchema } from "../sanitizedSchemas";
export const registerProjectMembershipRouter = async (server: FastifyZodProvider) => { export const registerProjectMembershipRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
method: "POST", method: "POST",
@@ -30,6 +32,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
roleSlugs: z.string().array().optional().describe(PROJECT_USERS.INVITE_MEMBER.roleSlugs) roleSlugs: z.string().array().optional().describe(PROJECT_USERS.INVITE_MEMBER.roleSlugs)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
memberships: ProjectMembershipsSchema.array() memberships: ProjectMembershipsSchema.array()
}) })
@@ -92,6 +95,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
usernames: z.string().array().default([]).describe(PROJECT_USERS.REMOVE_MEMBER.usernames) usernames: z.string().array().default([]).describe(PROJECT_USERS.REMOVE_MEMBER.usernames)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
memberships: ProjectMembershipsSchema.array() memberships: ProjectMembershipsSchema.array()
}) })
@@ -19,7 +19,7 @@ import { sanitizedCertificateTemplate } from "@app/services/certificate-template
import { ProjectFilterType } from "@app/services/project/project-types"; import { ProjectFilterType } from "@app/services/project/project-types";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types"; import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
import { SanitizedProjectSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
const projectWithEnv = SanitizedProjectSchema.extend({ const projectWithEnv = SanitizedProjectSchema.extend({
_id: z.string(), _id: z.string(),
@@ -172,6 +172,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
kmsKeyId: z.string().optional() kmsKeyId: z.string().optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
project: projectWithEnv project: projectWithEnv
}) })
@@ -221,6 +222,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
slug: slugSchema.describe("The slug of the project to delete.") slug: slugSchema.describe("The slug of the project to delete.")
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: SanitizedProjectSchema 200: SanitizedProjectSchema
} }
}, },
@@ -376,6 +378,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
limit: z.coerce.number().min(1).max(100).default(25).describe(PROJECTS.LIST_CERTIFICATES.limit) limit: z.coerce.number().min(1).max(100).default(25).describe(PROJECTS.LIST_CERTIFICATES.limit)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
certificates: z.array(CertificatesSchema), certificates: z.array(CertificatesSchema),
totalCount: z.number() totalCount: z.number()
@@ -7,7 +7,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type"; import { AuthMode } from "@app/services/auth/auth-type";
import { sanitizedServiceTokenUserSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, sanitizedServiceTokenUserSchema } from "../sanitizedSchemas";
export const sanitizedServiceTokenSchema = ServiceTokensSchema.omit({ export const sanitizedServiceTokenSchema = ServiceTokensSchema.omit({
secretHash: true, secretHash: true,
@@ -32,6 +32,7 @@ export const registerServiceTokenRouter = async (server: FastifyZodProvider) =>
} }
], ],
response: { response: {
...DefaultResponseErrorsSchema,
200: ServiceTokensSchema.merge( 200: ServiceTokensSchema.merge(
z.object({ z.object({
workspace: z.string(), workspace: z.string(),
+23 -2
View File
@@ -21,7 +21,7 @@ import { ProjectFilterType } from "@app/services/project/project-types";
import { SecretOperations, SecretProtectionType } from "@app/services/secret/secret-types"; import { SecretOperations, SecretProtectionType } from "@app/services/secret/secret-types";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types"; import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
import { secretRawSchema } from "../sanitizedSchemas"; import { DefaultResponseErrorsSchema, secretRawSchema } from "../sanitizedSchemas";
export const registerSecretRouter = async (server: FastifyZodProvider) => { export const registerSecretRouter = async (server: FastifyZodProvider) => {
server.route({ server.route({
@@ -53,6 +53,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
tagSlugs: z.string().array().min(1).describe(SECRETS.ATTACH_TAGS.tagSlugs) tagSlugs: z.string().array().min(1).describe(SECRETS.ATTACH_TAGS.tagSlugs)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secret: SecretsSchema.omit({ secretBlindIndex: true }).merge( secret: SecretsSchema.omit({ secretBlindIndex: true }).merge(
z.object({ z.object({
@@ -116,6 +117,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
tagSlugs: z.string().array().min(1).describe(SECRETS.DETACH_TAGS.tagSlugs) tagSlugs: z.string().array().min(1).describe(SECRETS.DETACH_TAGS.tagSlugs)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secret: SecretsSchema.omit({ secretBlindIndex: true }).extend({ secret: SecretsSchema.omit({ secretBlindIndex: true }).extend({
tags: SecretTagsSchema.pick({ tags: SecretTagsSchema.pick({
@@ -189,6 +191,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.transform((el) => (el ? el.split(",").map((i) => i.trim()) : [])) .transform((el) => (el ? el.split(",").map((i) => i.trim()) : []))
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secrets: secretRawSchema secrets: secretRawSchema
.extend({ .extend({
@@ -212,7 +215,8 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
}) })
.array() .array()
.optional() .optional()
}) }),
...DefaultResponseErrorsSchema
} }
}, },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]), onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
@@ -327,6 +331,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.describe(RAW_SECRETS.GET.includeImports) .describe(RAW_SECRETS.GET.includeImports)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secret: secretRawSchema.extend({ secret: secretRawSchema.extend({
tags: SecretTagsSchema.pick({ tags: SecretTagsSchema.pick({
@@ -449,6 +454,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretReminderNote: z.string().optional().nullable().describe(RAW_SECRETS.CREATE.secretReminderNote) secretReminderNote: z.string().optional().nullable().describe(RAW_SECRETS.CREATE.secretReminderNote)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secret: secretRawSchema secret: secretRawSchema
@@ -556,6 +562,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretComment: z.string().optional().describe(RAW_SECRETS.UPDATE.secretComment) secretComment: z.string().optional().describe(RAW_SECRETS.UPDATE.secretComment)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secret: secretRawSchema secret: secretRawSchema
@@ -649,6 +656,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
type: z.nativeEnum(SecretType).default(SecretType.Shared).describe(RAW_SECRETS.DELETE.type) type: z.nativeEnum(SecretType).default(SecretType.Shared).describe(RAW_SECRETS.DELETE.type)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secret: secretRawSchema secret: secretRawSchema
@@ -728,6 +736,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.transform((value) => value === "true") .transform((value) => value === "true")
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secrets: SecretsSchema.omit({ secretBlindIndex: true }) secrets: SecretsSchema.omit({ secretBlindIndex: true })
.extend({ .extend({
@@ -843,6 +852,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.transform((value) => value === "true") .transform((value) => value === "true")
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
secret: SecretsSchema.omit({ secretBlindIndex: true }).merge( secret: SecretsSchema.omit({ secretBlindIndex: true }).merge(
z.object({ z.object({
@@ -930,6 +940,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretName: z.string().trim() secretName: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secret: SecretsSchema.omit({ secretBlindIndex: true }).merge( secret: SecretsSchema.omit({ secretBlindIndex: true }).merge(
@@ -1107,6 +1118,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
metadata: z.record(z.string()).optional() metadata: z.record(z.string()).optional()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secret: SecretsSchema.omit({ secretBlindIndex: true }).merge( secret: SecretsSchema.omit({ secretBlindIndex: true }).merge(
@@ -1278,6 +1290,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
environment: z.string().trim() environment: z.string().trim()
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secret: SecretsSchema.omit({ secretBlindIndex: true }).merge( secret: SecretsSchema.omit({ secretBlindIndex: true }).merge(
@@ -1401,6 +1414,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
shouldOverwrite: z.boolean().default(false) shouldOverwrite: z.boolean().default(false)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
isSourceUpdated: z.boolean(), isSourceUpdated: z.boolean(),
isDestinationUpdated: z.boolean() isDestinationUpdated: z.boolean()
@@ -1469,6 +1483,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.min(1) .min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secrets: SecretsSchema.omit({ secretBlindIndex: true }).array() secrets: SecretsSchema.omit({ secretBlindIndex: true }).array()
@@ -1596,6 +1611,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.min(1) .min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secrets: SecretsSchema.omit({ secretBlindIndex: true }).array() secrets: SecretsSchema.omit({ secretBlindIndex: true }).array()
@@ -1711,6 +1727,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.min(1) .min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secrets: SecretsSchema.omit({ secretBlindIndex: true }).array() secrets: SecretsSchema.omit({ secretBlindIndex: true }).array()
@@ -1844,6 +1861,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.min(1) .min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secrets: secretRawSchema.array() secrets: secretRawSchema.array()
@@ -1950,6 +1968,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.min(1) .min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secrets: secretRawSchema.array() secrets: secretRawSchema.array()
@@ -2042,6 +2061,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
.min(1) .min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.union([ 200: z.union([
z.object({ z.object({
secrets: secretRawSchema.array() secrets: secretRawSchema.array()
@@ -2119,6 +2139,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
projectId: z.string().trim().min(1) projectId: z.string().trim().min(1)
}), }),
response: { response: {
...DefaultResponseErrorsSchema,
200: z.object({ 200: z.object({
message: z.string() message: z.string()
}) })
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "Infisical", "name": "Infisical",
"openapi": "https://app.infisical.com/api/docs/json", "openapi": "http://localhost:8080/api/docs/json",
"logo": { "logo": {
"dark": "/logo/dark.svg", "dark": "/logo/dark.svg",
"light": "/logo/light.svg", "light": "/logo/light.svg",