import {z} from 'zod' export type SpaceId = string; export type LocalDateRange = {equal?: string | undefined, start?: string | undefined, end?: string | undefined}; export type DeleteApiSpacesSpaceIdTimelogLockPeriodsArgs = {spaceId: SpaceId, period: LocalDateRange}; export type DeleteApiSpacesSpaceIdTimelogLockPeriodsOptions = {baseUrl?: string | undefined, HTTP?: string | undefined, fetch?: typeof fetch | undefined}; export const responseKind = z.enum(["accounts", "users", "contacts", "assets", "eDiscoveryReport", "folders", "folderTree", "tasks", "taskIds", "timelogs", "timelogCategories", "timelogLockPeriods", "timetrackerTimers", "comments", "attachments", "url", "version", "dataExport", "dataExportSchema", "auditLog", "accessRoles", "stream", "changes", "posts", "mailSettings", "integrationInfo", "gmailIntegrationSettings", "workTypesForIntegrations", "ids", "backups", "domains", "dependencies", "workflows", "workschedules", "workscheduleExclusions", "workscheduleUserExclusions", "customfields", "customfieldIds", "customstatuses", "invitations", "notifications", "jobroles", "placeholders", "groups", "session", "dashboards", "widgets", "taskCreationSettings", "colors", "experiments", "topics", "topicComments", "webhooks", "reviews", "boards", "textSearch", "chatChannels", "chatMessages", "forms", "requestForms", "request", "report", "platformWidgets", "platformWidgetInstances", "spaces", "pdf", "customerSatisfaction", "asyncJob", "approvals", "highlights", "highlightsList", "highlightsSettings", "highlightsCard", "timesheet", "timesheetRow", "timesheetSubmissionRule", "mobileFeatures", "mobileSettings", "folderBlueprintTree", "taskBlueprintTree", "blueprintSearch", "feedback", "timeline_snapshot", "contactIds", "bookings", "integrateThreshold", "hourlyRatesProvision", "hourlyRates", "projectTeamMembers", "contactsHistory", "tasksHistory", "foldersHistory", "activityDigest", "workItemTemplates", "workTemplates", "workItemMetadata", "workItem", "customItemTypes", "verificationCode", "views", "listView", "tableView", "userTypes", "reactions", "externalRequesters", "workscheduleCapacityOverrides", "userCapacityOverrides", "userCapacityExclusions", "rollups", "requestFormPrefill", "mcpFeatures", "attachmentUploadUrl", "userAggregatedCapacity", "cascadingFieldSettings", "recommendResources", "aggregatedAllocatedEffort", "aggregatedTotalUserEffort", "aggregatedTimeSpent", "folderBlueprint", "taskBlueprint"]); export const taskId = z.string(); export const timelogLockSourceType = z.enum(["folder", "space", "unknown"]); export const timelogLockSource = z.object({id: taskId.optional(), type: timelogLockSourceType}); export const timelogLockPeriod = z.object({start: z.string().optional(), end: z.string().optional(), source: timelogLockSource.optional()}); export const deleteApiSpacesSpaceIdTimelogLockPeriodsResponse = z.object({kind: responseKind.optional(), data: z.array(timelogLockPeriod).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Delete Timelog Lock (Space) * * DELETE /spaces/{spaceId}/timelog_lock_periods */ export const deleteApiSpacesSpaceIdTimelogLockPeriods = async (args: DeleteApiSpacesSpaceIdTimelogLockPeriodsArgs, options?: DeleteApiSpacesSpaceIdTimelogLockPeriodsOptions) => { const {baseUrl = "https://www.wrike.com/api/v4", fetch: fetchFn = fetch, HTTP} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.period != null) query.append("period", JSON.stringify(args.period)) if (HTTP !== undefined) headers.set('authorization', `Bearer ${HTTP}`) const url = `${baseUrl.replace(/\/+$/, '')}/spaces/${encodeURIComponent(String(args.spaceId))}/timelog_lock_periods${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteApiSpacesSpaceIdTimelogLockPeriodsResponse, await res.json()) };