import {z} from 'zod' export type NodeVersionStatus = 'NodeVersionStatusActive' | 'NodeVersionStatusDeleted' | 'NodeVersionStatusBanned' | 'NodeVersionStatusPending' | 'NodeVersionStatusFlagged'; export type NodeVersion = {id?: string | undefined, version?: string | undefined, createdAt?: string | undefined, changelog?: string | undefined, dependencies?: Array | undefined, downloadUrl?: string | undefined, deprecated?: boolean | undefined, status?: NodeVersionStatus | undefined, status_reason?: string | undefined, node_id?: string | undefined}; export type PublisherUser = {id?: string | undefined, email?: string | undefined, name?: string | undefined}; export type PublisherMember = {id?: string | undefined, user?: PublisherUser | undefined, role?: string | undefined}; export type PublisherStatus = 'PublisherStatusActive' | 'PublisherStatusBanned'; export type Publisher = {name?: string | undefined, id?: string | undefined, description?: string | undefined, website?: string | undefined, support?: string | undefined, source_code_repo?: string | undefined, logo?: string | undefined, createdAt?: string | undefined, members?: Array | undefined, status?: PublisherStatus | undefined}; export type NodeStatus = 'NodeStatusActive' | 'NodeStatusDeleted' | 'NodeStatusBanned'; export type Node = {id?: string | undefined, name?: string | undefined, category?: string | undefined, description?: string | undefined, author?: string | undefined, license?: string | undefined, icon?: string | undefined, repository?: string | undefined, tags?: Array | undefined, latest_version?: NodeVersion | undefined, rating?: number | undefined, downloads?: number | undefined, publisher?: Publisher | undefined, status?: NodeStatus | undefined, status_detail?: string | undefined}; export type UpdateApiPublishersPublisherIdNodesNodeIdArgs = {publisherId: string, nodeId: string, body: Node}; export type UpdateApiPublishersPublisherIdNodesNodeIdOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const nodeVersionStatus = z.enum(["NodeVersionStatusActive", "NodeVersionStatusDeleted", "NodeVersionStatusBanned", "NodeVersionStatusPending", "NodeVersionStatusFlagged"]); export const nodeVersion = z.object({id: z.string().optional(), version: z.string().optional(), createdAt: z.string().optional(), changelog: z.string().optional(), dependencies: z.array(z.string()).optional(), downloadUrl: z.string().optional(), deprecated: z.boolean().optional(), status: nodeVersionStatus.optional(), status_reason: z.string().optional(), node_id: z.string().optional()}); export const publisherUser = z.object({id: z.string().optional(), email: z.string().optional(), name: z.string().optional()}); export const publisherMember = z.object({id: z.string().optional(), user: publisherUser.optional(), role: z.string().optional()}); export const publisherStatus = z.enum(["PublisherStatusActive", "PublisherStatusBanned"]); export const publisher = z.object({name: z.string().optional(), id: z.string().optional(), description: z.string().optional(), website: z.string().optional(), support: z.string().optional(), source_code_repo: z.string().optional(), logo: z.string().optional(), createdAt: z.string().optional(), members: z.array(publisherMember).optional(), status: publisherStatus.optional()}); export const nodeStatus = z.enum(["NodeStatusActive", "NodeStatusDeleted", "NodeStatusBanned"]); export const node = z.object({id: z.string().optional(), name: z.string().optional(), category: z.string().optional(), description: z.string().optional(), author: z.string().optional(), license: z.string().optional(), icon: z.string().optional(), repository: z.string().optional(), tags: z.array(z.string()).optional(), latest_version: nodeVersion.optional(), rating: z.number().optional(), downloads: z.number().int().optional(), publisher: publisher.optional(), status: nodeStatus.optional(), status_detail: 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 }; /** * Update a specific node * * PUT /publishers/{publisherId}/nodes/{nodeId} */ export const updateApiPublishersPublisherIdNodesNodeId = async (args: UpdateApiPublishersPublisherIdNodesNodeIdArgs, options?: UpdateApiPublishersPublisherIdNodesNodeIdOptions) => { const {baseUrl = "https://api.comfy.org", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/publishers/${encodeURIComponent(String(args.publisherId))}/nodes/${encodeURIComponent(String(args.nodeId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(node, await res.json()) };