server/http/openapi/management-routes/platform-webhooks.ts
Rama main · réplica de lectura del repositorio original.
import { siteNavigationResponseSchema, siteNavigationSchema } from '@shared/api/navigation'
import {
connectorReadinessResponseSchema,
createManagementConnectorRequestSchema,
createWebhookEndpointRequestSchema,
developerConsoleAccessPolicyResponseSchema,
emailDeliveryConfigurationResponseSchema,
etagResponseHeader,
idempotencyKeyHeader,
idempotencyReplayResponseHeader,
ifMatchHeader,
jsonBody,
listConnectorTemplatesResponseSchema,
listManagementConnectorsResponseSchema,
listWebhookDeliveryAttemptsResponseSchema,
listWebhookEndpointsQuerySchema,
listWebhookEndpointsResponseSchema,
listWebhookRequestsQuerySchema,
listWebhookRequestsResponseSchema,
locationResponseHeader,
type ManagementRouteConfig,
managementAccountCenterSettingsResponseSchema,
managementBrandingSettingsResponseSchema,
managementConnectorResponseSchema,
managementReadinessResponseSchema,
managementRealmResponseSchema,
managementSignInSettingsResponseSchema,
organizationCreationPolicyResponseSchema,
paginationQuerySchema,
replaceDeveloperConsoleAccessPolicyRequestSchema,
replaceEmailDeliveryConfigurationRequestSchema,
replaceOrganizationCreationPolicyRequestSchema,
updateManagementAccountCenterSettingsRequestSchema,
updateManagementBrandingSettingsRequestSchema,
updateManagementConnectorRequestSchema,
updateManagementRealmRequestSchema,
updateManagementSignInSettingsRequestSchema,
updateWebhookEndpointRequestSchema,
webhookDeliveryAttemptSchema,
webhookEndpointSchema,
webhookEndpointSecretResponseSchema,
webhookRequestSchema,
z,
} from './helpers'
const webhookAttemptParam = z.object({
webhookId: z.string().openapi({ param: { name: 'webhookId', in: 'path' } }),
deliveryId: z.string().openapi({ param: { name: 'deliveryId', in: 'path' } }),
attemptId: z.string().openapi({ param: { name: 'attemptId', in: 'path' } }),
})
const connectorParam = z.object({ connectorId: z.string().openapi({ param: { name: 'connectorId', in: 'path' } }) })
const webhookParam = z.object({ webhookId: z.string().openapi({ param: { name: 'webhookId', in: 'path' } }) })
const webhookDeliveryParam = z.object({
webhookId: z.string().openapi({ param: { name: 'webhookId', in: 'path' } }),
deliveryId: z.string().openapi({ param: { name: 'deliveryId', in: 'path' } }),
})
export const platformWebhookRoutes: ManagementRouteConfig[] = [
{
method: 'get',
path: '/connectors',
operationId: 'listConnectors',
summary: 'List connectors',
request: { query: paginationQuerySchema },
response: listManagementConnectorsResponseSchema,
paginated: true,
},
{
method: 'post',
path: '/connectors',
operationId: 'createConnector',
summary: 'Create connector',
request: { body: jsonBody(createManagementConnectorRequestSchema) },
response: managementConnectorResponseSchema,
status: 201,
},
{
method: 'get',
path: '/connectors/{connectorId}',
operationId: 'getConnector',
summary: 'Get connector',
request: { params: connectorParam },
response: managementConnectorResponseSchema,
},
{
method: 'patch',
path: '/connectors/{connectorId}',
operationId: 'updateConnector',
summary: 'Update connector',
request: { params: connectorParam, body: jsonBody(updateManagementConnectorRequestSchema) },
response: managementConnectorResponseSchema,
},
{
method: 'delete',
path: '/connectors/{connectorId}',
operationId: 'deleteConnector',
summary: 'Delete connector',
request: { params: connectorParam },
noBody: true,
},
{
method: 'get',
path: '/connectors/{connectorId}/readiness',
operationId: 'getConnectorReadiness',
summary: 'Get connector readiness',
request: { params: connectorParam },
response: connectorReadinessResponseSchema,
},
{
method: 'get',
path: '/connectors/templates',
operationId: 'listConnectorTemplates',
summary: 'List connector templates',
response: listConnectorTemplatesResponseSchema,
},
{
method: 'get',
path: '/realm/sign-in-policy',
operationId: 'getSignInPolicy',
summary: 'Get the Realm sign-in policy',
response: managementSignInSettingsResponseSchema,
},
{
method: 'get',
path: '/realm',
operationId: 'getRealm',
summary: 'Get the Realm',
response: managementRealmResponseSchema,
responseHeaders: etagResponseHeader,
},
{
method: 'patch',
path: '/realm',
operationId: 'updateRealm',
summary: 'Update the Realm',
request: { headers: ifMatchHeader, body: jsonBody(updateManagementRealmRequestSchema) },
response: managementRealmResponseSchema,
responseHeaders: etagResponseHeader,
errors: {
400: 'The Realm representation is invalid.',
412: 'The Realm changed after it was read.',
428: 'If-Match is required.',
},
},
{
method: 'get',
path: '/realm/email-delivery-configuration',
operationId: 'getEmailDeliveryConfiguration',
summary: 'Get the email delivery configuration',
response: emailDeliveryConfigurationResponseSchema,
responseHeaders: etagResponseHeader,
},
{
method: 'put',
path: '/realm/email-delivery-configuration',
operationId: 'replaceEmailDeliveryConfiguration',
summary: 'Replace the email delivery configuration',
request: { headers: ifMatchHeader, body: jsonBody(replaceEmailDeliveryConfigurationRequestSchema) },
response: emailDeliveryConfigurationResponseSchema,
responseHeaders: etagResponseHeader,
errors: {
400: 'The email delivery configuration is invalid.',
409: 'The deployment cannot activate the selected email delivery provider.',
412: 'The email delivery configuration changed after it was read.',
428: 'If-Match is required.',
},
},
{
method: 'patch',
path: '/realm/sign-in-policy',
operationId: 'updateSignInPolicy',
summary: 'Update the Realm sign-in policy',
request: { body: jsonBody(updateManagementSignInSettingsRequestSchema) },
response: managementSignInSettingsResponseSchema,
},
{
method: 'get',
path: '/realm/branding',
operationId: 'getRealmBranding',
summary: 'Get Realm branding',
response: managementBrandingSettingsResponseSchema,
},
{
method: 'patch',
path: '/realm/branding',
operationId: 'updateRealmBranding',
summary: 'Update Realm branding',
request: { body: jsonBody(updateManagementBrandingSettingsRequestSchema) },
response: managementBrandingSettingsResponseSchema,
},
{
method: 'get',
path: '/realm/navigation',
operationId: 'getRealmNavigation',
summary: 'Get site navigation',
response: siteNavigationResponseSchema,
responseHeaders: etagResponseHeader,
},
{
method: 'put',
path: '/realm/navigation',
operationId: 'replaceRealmNavigation',
summary: 'Replace site navigation',
request: { headers: ifMatchHeader, body: jsonBody(siteNavigationSchema) },
response: siteNavigationResponseSchema,
responseHeaders: etagResponseHeader,
errors: {
409: 'Site navigation changed during the update.',
412: 'Site navigation changed since it was read.',
428: 'If-Match is required.',
},
},
{
method: 'get',
path: '/realm/account-management-policy',
operationId: 'getAccountManagementPolicy',
summary: 'Get the Realm account management policy',
response: managementAccountCenterSettingsResponseSchema,
},
{
method: 'patch',
path: '/realm/account-management-policy',
operationId: 'updateAccountManagementPolicy',
summary: 'Update the Realm account management policy',
request: { body: jsonBody(updateManagementAccountCenterSettingsRequestSchema) },
response: managementAccountCenterSettingsResponseSchema,
},
{
method: 'get',
path: '/realm/organization-creation-policy',
operationId: 'getOrganizationCreationPolicy',
summary: 'Get the Organization creation policy',
response: organizationCreationPolicyResponseSchema,
responseHeaders: etagResponseHeader,
},
{
method: 'put',
path: '/realm/organization-creation-policy',
operationId: 'replaceOrganizationCreationPolicy',
summary: 'Replace the Organization creation policy',
request: { headers: ifMatchHeader, body: jsonBody(replaceOrganizationCreationPolicyRequestSchema) },
response: organizationCreationPolicyResponseSchema,
responseHeaders: etagResponseHeader,
errors: {
400: 'The Organization creation policy is invalid.',
404: 'An approved user was not found.',
412: 'The Organization creation policy changed after it was read.',
428: 'If-Match is required.',
},
},
{
method: 'get',
path: '/realm/developer-console-access-policy',
operationId: 'getDeveloperConsoleAccessPolicy',
summary: 'Get the Developer Console access policy',
response: developerConsoleAccessPolicyResponseSchema,
responseHeaders: etagResponseHeader,
},
{
method: 'put',
path: '/realm/developer-console-access-policy',
operationId: 'replaceDeveloperConsoleAccessPolicy',
summary: 'Replace the Developer Console access policy',
request: { headers: ifMatchHeader, body: jsonBody(replaceDeveloperConsoleAccessPolicyRequestSchema) },
response: developerConsoleAccessPolicyResponseSchema,
responseHeaders: etagResponseHeader,
errors: {
400: 'The Developer Console access policy is invalid.',
404: 'A selected Organization was not found.',
412: 'The Developer Console access policy changed after it was read.',
428: 'If-Match is required.',
},
},
{
method: 'get',
path: '/realm/configuration-status',
operationId: 'getRealmConfigurationStatus',
summary: 'Get Realm configuration status',
response: managementReadinessResponseSchema,
},
{
method: 'get',
path: '/webhooks',
operationId: 'listWebhooks',
summary: 'List webhooks',
request: { query: listWebhookEndpointsQuerySchema },
response: listWebhookEndpointsResponseSchema,
paginated: true,
},
{
method: 'post',
path: '/webhooks',
operationId: 'createWebhook',
summary: 'Create a webhook',
request: { body: jsonBody(createWebhookEndpointRequestSchema) },
response: webhookEndpointSecretResponseSchema,
status: 201,
responseHeaders: locationResponseHeader,
errors: { 400: 'The webhook endpoint representation is invalid.' },
},
{
method: 'get',
path: '/webhooks/{webhookId}',
operationId: 'getWebhook',
summary: 'Get a webhook',
request: { params: webhookParam },
response: webhookEndpointSchema,
},
{
method: 'patch',
path: '/webhooks/{webhookId}',
operationId: 'updateWebhook',
summary: 'Update a webhook',
request: { params: webhookParam, body: jsonBody(updateWebhookEndpointRequestSchema) },
response: webhookEndpointSchema,
},
{
method: 'delete',
path: '/webhooks/{webhookId}',
operationId: 'deleteWebhook',
summary: 'Delete a webhook',
request: { params: webhookParam },
noBody: true,
},
{
method: 'post',
path: '/webhooks/{webhookId}/secrets',
operationId: 'createWebhookSecret',
summary: 'Create a webhook signing secret',
request: { params: webhookParam },
response: webhookEndpointSecretResponseSchema,
status: 201,
},
{
method: 'get',
path: '/webhooks/{webhookId}/deliveries',
operationId: 'listWebhookDeliveries',
summary: 'List webhook deliveries',
request: { params: webhookParam, query: listWebhookRequestsQuerySchema.omit({ endpointId: true }) },
response: listWebhookRequestsResponseSchema,
paginated: true,
},
{
method: 'get',
path: '/webhooks/{webhookId}/deliveries/{deliveryId}',
operationId: 'getWebhookDelivery',
summary: 'Get a webhook delivery',
request: { params: webhookDeliveryParam },
response: webhookRequestSchema,
},
{
method: 'get',
path: '/webhooks/{webhookId}/deliveries/{deliveryId}/attempts',
operationId: 'listWebhookDeliveryAttempts',
summary: 'List webhook delivery attempts',
request: { params: webhookDeliveryParam, query: paginationQuerySchema },
response: listWebhookDeliveryAttemptsResponseSchema,
paginated: true,
errors: { 404: 'The webhook request was not found.' },
},
{
method: 'post',
path: '/webhooks/{webhookId}/deliveries/{deliveryId}/attempts',
operationId: 'createWebhookDeliveryAttempt',
summary: 'Create a webhook delivery attempt',
request: { params: webhookDeliveryParam, headers: idempotencyKeyHeader },
response: webhookDeliveryAttemptSchema,
status: 201,
responseHeaders: {
...locationResponseHeader,
...idempotencyReplayResponseHeader,
},
errors: {
400: 'Idempotency-Key is missing or invalid.',
404: 'The webhook request was not found.',
409: 'The webhook request is already delivered.',
},
},
{
method: 'get',
path: '/webhooks/{webhookId}/deliveries/{deliveryId}/attempts/{attemptId}',
operationId: 'getWebhookDeliveryAttempt',
summary: 'Get a webhook delivery attempt',
request: { params: webhookAttemptParam },
response: webhookDeliveryAttemptSchema,
errors: { 404: 'The webhook request or delivery attempt was not found.' },
},
]