UNPKG

@vzeta/camunda-api-zod-schemas

Version:

Zod schemas and TypeScript types for Camunda 8 unified API

108 lines (107 loc) 2.82 kB
import { z } from "zod"; import { API_VERSION } from "../common.js"; const processDeploymentSchema = z.object({ processDefinitionId: z.string(), processDefinitionVersion: z.number().int(), resourceName: z.string(), tenantId: z.string(), processDefinitionKey: z.string() }); const decisionDeploymentSchema = z.object({ decisionDefinitionId: z.string(), version: z.number().int(), name: z.string(), tenantId: z.string(), decisionRequirementsId: z.string(), decisionDefinitionKey: z.string(), decisionRequirementsKey: z.string() }); const decisionRequirementsDeploymentSchema = z.object({ decisionRequirementsId: z.string(), version: z.number().int(), decisionRequirementsName: z.string(), tenantId: z.string(), resourceName: z.string(), decisionRequirementsKey: z.string() }); const formDeploymentSchema = z.object({ formId: z.string(), version: z.number().int(), resourceName: z.string(), tenantId: z.string(), formKey: z.string() }); const resourceDeploymentSchema = z.object({ resourceId: z.string(), version: z.number().int(), resourceName: z.string(), tenantId: z.string(), resourceKey: z.string() }); const createDeploymentResponseBodySchema = z.object({ tenantId: z.string(), deploymentKey: z.string(), deployments: z.array( z.union([ processDeploymentSchema, decisionDeploymentSchema, decisionRequirementsDeploymentSchema, formDeploymentSchema, resourceDeploymentSchema ]) ) }); const deleteResourceRequestBodySchema = z.object({ operationReference: z.number().int().min(1) }).optional(); const resourceSchema = z.object({ resourceName: z.string(), version: z.number().int(), versionTag: z.string(), resourceId: z.string(), tenantId: z.string(), resourceKey: z.string() }); const getResourceContentResponseBodySchema = z.string(); const createDeployment = { method: "POST", getUrl() { return `/${API_VERSION}/deployments`; } }; const deleteResource = { method: "POST", getUrl(params) { const { resourceKey } = params; return `/${API_VERSION}/resources/${resourceKey}/deletion`; } }; const getResource = { method: "GET", getUrl(params) { const { resourceKey } = params; return `/${API_VERSION}/resources/${resourceKey}`; } }; const getResourceContent = { method: "GET", getUrl(params) { const { resourceKey } = params; return `/${API_VERSION}/resources/${resourceKey}/content`; } }; export { createDeployment, createDeploymentResponseBodySchema, decisionDeploymentSchema, decisionRequirementsDeploymentSchema, deleteResource, deleteResourceRequestBodySchema, formDeploymentSchema, getResource, getResourceContent, getResourceContentResponseBodySchema, processDeploymentSchema, resourceDeploymentSchema, resourceSchema };