import {z} from 'zod' export type GetApiApiV1SecretSyncsTeamcitySyncNameSyncNameArgs = {projectId: string, syncName: string}; export type GetApiApiV1SecretSyncsTeamcitySyncNameSyncNameOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV1SecretSyncsTeamcitySyncNameSyncNameResponse = z.object({secretSync: z.object({id: z.string(), name: z.string(), description: z.string().nullable().optional(), isAutoSyncEnabled: z.boolean().optional(), version: z.number().optional(), projectId: z.string(), folderId: z.string().nullable().optional(), connectionId: z.string(), createdAt: z.string(), updatedAt: z.string(), syncStatus: z.string().nullable().optional(), lastSyncJobId: z.string().nullable().optional(), lastSyncMessage: z.string().nullable().optional(), lastSyncedAt: z.string().nullable().optional(), importStatus: z.string().nullable().optional(), lastImportJobId: z.string().nullable().optional(), lastImportMessage: z.string().nullable().optional(), lastImportedAt: z.string().nullable().optional(), removeStatus: z.string().nullable().optional(), lastRemoveJobId: z.string().nullable().optional(), lastRemoveMessage: z.string().nullable().optional(), lastRemovedAt: z.string().nullable().optional(), lastSyncResult: z.string().nullable().optional(), syncOptions: z.object({initialSyncBehavior: z.enum(["overwrite-destination", "import-prioritize-source", "import-prioritize-destination"]), keySchema: z.string().max(255).optional(), disableSecretDeletion: z.boolean().optional(), includeAllSubFolders: z.boolean().optional()}), connection: z.object({app: z.literal("teamcity"), name: z.string(), id: z.string()}), environment: z.object({slug: z.string(), name: z.string(), id: z.string()}).nullable(), folder: z.object({id: z.string(), path: z.string()}).nullable(), destination: z.literal("teamcity"), destinationConfig: z.object({project: z.string().min(1), buildConfig: z.string().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 }; /** * Get the specified TeamCity Sync by name and project ID. * * GET /api/v1/secret-syncs/teamcity/sync-name/{syncName} */ export const getApiApiV1SecretSyncsTeamcitySyncNameSyncName = async (args: GetApiApiV1SecretSyncsTeamcitySyncNameSyncNameArgs, options?: GetApiApiV1SecretSyncsTeamcitySyncNameSyncNameOptions) => { const {baseUrl = "https://us.infisical.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.projectId != null) query.append("projectId", String(args.projectId)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/secret-syncs/teamcity/sync-name/${encodeURIComponent(String(args.syncName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiV1SecretSyncsTeamcitySyncNameSyncNameResponse, await res.json()) };