UNPKG

@requestkit/node

Version:

Request Kit Node.js Client

617 lines (613 loc) 19.2 kB
import { z } from 'zod'; declare const RequestKitInitSchema: z.ZodObject<{ baseURL: z.ZodOptional<z.ZodString>; apiKey: z.ZodString; retries: z.ZodOptional<z.ZodNumber>; logging: z.ZodOptional<z.ZodObject<{ enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { enabled?: boolean | undefined; }, { enabled?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { apiKey: string; baseURL?: string | undefined; retries?: number | undefined; logging?: { enabled?: boolean | undefined; } | undefined; }, { apiKey: string; baseURL?: string | undefined; retries?: number | undefined; logging?: { enabled?: boolean | undefined; } | undefined; }>; declare const RequestSchema: z.ZodObject<{ id: z.ZodString; title: z.ZodString; description: z.ZodString; createdAt: z.ZodString; upvotes: z.ZodNumber; comments: z.ZodNumber; isUpvoted: z.ZodOptional<z.ZodBoolean>; status: z.ZodOptional<z.ZodObject<{ name: z.ZodString; color: z.ZodString; description: z.ZodOptional<z.ZodString>; disableComments: z.ZodBoolean; isPublic: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; }, { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; }>>; requester: z.ZodOptional<z.ZodObject<{ email: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; identifier: z.ZodString; }, "strip", z.ZodTypeAny, { identifier: string; name?: string | undefined; email?: string | undefined; }, { identifier: string; name?: string | undefined; email?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }, { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }>; declare const GetRequestsQuerySchema: z.ZodObject<{ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; page: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; includeRequester: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; orderBy: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodEnum<["date", "upvotes"]>, "many">>>; order: z.ZodOptional<z.ZodDefault<z.ZodEnum<["asc", "desc"]>>>; userIdentifier: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { limit?: number | undefined; page?: number | undefined; includeRequester?: boolean | undefined; orderBy?: ("date" | "upvotes")[] | undefined; order?: "asc" | "desc" | undefined; userIdentifier?: string | undefined; }, { limit?: number | undefined; page?: number | undefined; includeRequester?: boolean | undefined; orderBy?: ("date" | "upvotes")[] | undefined; order?: "asc" | "desc" | undefined; userIdentifier?: string | undefined; }>; declare const GetRequestsOutputSchema: z.ZodObject<{ totalRequests: z.ZodNumber; requests: z.ZodArray<z.ZodObject<{ id: z.ZodString; title: z.ZodString; description: z.ZodString; createdAt: z.ZodString; upvotes: z.ZodNumber; comments: z.ZodNumber; isUpvoted: z.ZodOptional<z.ZodBoolean>; status: z.ZodOptional<z.ZodObject<{ name: z.ZodString; color: z.ZodString; description: z.ZodOptional<z.ZodString>; disableComments: z.ZodBoolean; isPublic: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; }, { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; }>>; requester: z.ZodOptional<z.ZodObject<{ email: z.ZodOptional<z.ZodString>; name: z.ZodOptional<z.ZodString>; identifier: z.ZodString; }, "strip", z.ZodTypeAny, { identifier: string; name?: string | undefined; email?: string | undefined; }, { identifier: string; name?: string | undefined; email?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }, { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { requests: { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }[]; totalRequests: number; }, { requests: { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }[]; totalRequests: number; }>; declare const CreateRequestInputSchema: z.ZodObject<{ title: z.ZodString; description: z.ZodString; status: z.ZodOptional<z.ZodString>; requester: z.ZodOptional<z.ZodObject<{ identifier: z.ZodString; name: z.ZodOptional<z.ZodString>; email: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { identifier: string; name?: string | undefined; email?: string | undefined; }, { identifier: string; name?: string | undefined; email?: string | undefined; }>>; files: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodType<Blob, z.ZodTypeDef, Blob>, "many">, z.ZodEffects<z.ZodType<Blob, z.ZodTypeDef, Blob>, Blob[], Blob>]>>; }, "strip", z.ZodTypeAny, { title: string; description: string; status?: string | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; files?: Blob[] | undefined; }, { title: string; description: string; status?: string | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; files?: Blob | Blob[] | undefined; }>; declare const CreateRequestOutputSchema: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; declare const UpvoteRequestInputSchema: z.ZodObject<{ user: z.ZodOptional<z.ZodObject<{ identifier: z.ZodString; name: z.ZodOptional<z.ZodString>; email: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { identifier: string; name?: string | undefined; email?: string | undefined; }, { identifier: string; name?: string | undefined; email?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { user?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }, { user?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }>; declare const UpvoteRequestOutputSchema: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; declare const RemoveUpvoteQuerySchema: z.ZodObject<{ userIdentifier: z.ZodString; }, "strip", z.ZodTypeAny, { userIdentifier: string; }, { userIdentifier: string; }>; declare const GetRequestQuerySchema: z.ZodObject<{ includeRequester: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; includeComments: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; userIdentifier: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { includeRequester?: boolean | undefined; userIdentifier?: string | undefined; includeComments?: boolean | undefined; }, { includeRequester?: boolean | undefined; userIdentifier?: string | undefined; includeComments?: boolean | undefined; }>; declare const GetCommentsQuerySchema: z.ZodObject<{ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; page: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; }, "strip", z.ZodTypeAny, { limit?: number | undefined; page?: number | undefined; }, { limit?: number | undefined; page?: number | undefined; }>; declare const GetCommentsOutputSchema: z.ZodObject<{ comments: z.ZodArray<z.ZodObject<{ id: z.ZodString; content: z.ZodString; createdAt: z.ZodString; commentor: z.ZodObject<{ email: z.ZodOptional<z.ZodString>; identifier: z.ZodString; name: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { identifier: string; name?: string | undefined; email?: string | undefined; }, { identifier: string; name?: string | undefined; email?: string | undefined; }>; }, "strip", z.ZodTypeAny, { id: string; createdAt: string; content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; }, { id: string; createdAt: string; content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; }>, "many">; }, "strip", z.ZodTypeAny, { comments: { id: string; createdAt: string; content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; }[]; }, { comments: { id: string; createdAt: string; content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; }[]; }>; declare const CreateCommentInputSchema: z.ZodObject<{ content: z.ZodString; commentor: z.ZodObject<{ identifier: z.ZodString; name: z.ZodOptional<z.ZodString>; email: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { identifier: string; name?: string | undefined; email?: string | undefined; }, { identifier: string; name?: string | undefined; email?: string | undefined; }>; files: z.ZodOptional<z.ZodArray<z.ZodType<Blob, z.ZodTypeDef, Blob>, "many">>; }, "strip", z.ZodTypeAny, { content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; files?: Blob[] | undefined; }, { content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; files?: Blob[] | undefined; }>; declare const CreateCommentOutputSchema: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; declare const DeleteCommentBodySchema: z.ZodObject<{ userIdentifier: z.ZodString; }, "strip", z.ZodTypeAny, { userIdentifier: string; }, { userIdentifier: string; }>; type RequestKitSchema = { "@get/requests": { query: z.infer<typeof GetRequestsQuerySchema>; output: z.infer<typeof GetRequestsOutputSchema>; }; "@post/requests": { input: z.infer<typeof CreateRequestInputSchema>; output: z.infer<typeof CreateRequestOutputSchema>; }; "@post/requests/:id/upvote": { params: { id: string; }; input: z.infer<typeof UpvoteRequestInputSchema>; output: z.infer<typeof UpvoteRequestOutputSchema>; }; "@delete/requests/:id/upvote": { params: { id: string; }; query: z.infer<typeof RemoveUpvoteQuerySchema>; output: z.infer<typeof UpvoteRequestOutputSchema>; }; "@get/requests/:id": { params: { id: string; }; query: z.infer<typeof GetRequestQuerySchema>; output: z.infer<typeof RequestSchema>; }; "@get/requests/:id/comments": { params: { id: string; }; query: z.infer<typeof GetCommentsQuerySchema>; output: z.infer<typeof GetCommentsOutputSchema>; }; "@post/requests/:id/comments": { params: { id: string; }; input: z.infer<typeof CreateCommentInputSchema>; output: z.infer<typeof CreateCommentOutputSchema>; }; "@delete/requests/:id/comments/:commentId": { params: { id: string; commentId: string; }; body: z.infer<typeof DeleteCommentBodySchema>; output: z.infer<typeof CreateCommentOutputSchema>; }; }; declare class RequestKitError extends Error { code?: string | undefined; details?: Record<string, unknown> | undefined; status?: number | undefined; constructor(message: string, code?: string | undefined, details?: Record<string, unknown> | undefined, status?: number | undefined); } declare class RequestKit { protected options: z.infer<typeof RequestKitInitSchema>; private $fetch; constructor(options: z.infer<typeof RequestKitInitSchema>); private handleResponse; getRequests(query?: RequestKitSchema["@get/requests"]["query"]): Promise<{ requests: { upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }[]; totalRequests: number; }>; createRequest(input: RequestKitSchema["@post/requests"]["input"]): Promise<{ id: string; }>; upvoteRequest(id: RequestKitSchema["@post/requests/:id/upvote"]["params"]["id"], input: RequestKitSchema["@post/requests/:id/upvote"]["input"]): Promise<RequestKitSchema["@post/requests/:id/upvote"]["output"]>; removeUpvoteFromRequest(id: RequestKitSchema["@delete/requests/:id/upvote"]["params"]["id"], query: RequestKitSchema["@delete/requests/:id/upvote"]["query"]): Promise<{ id: string; }>; getRequest(id: RequestKitSchema["@get/requests/:id"]["params"]["id"], query: RequestKitSchema["@get/requests/:id"]["query"]): Promise<{ upvotes: number; id: string; title: string; description: string; createdAt: string; comments: number; status?: { name: string; color: string; disableComments: boolean; isPublic: boolean; description?: string | undefined; } | undefined; isUpvoted?: boolean | undefined; requester?: { identifier: string; name?: string | undefined; email?: string | undefined; } | undefined; }>; getComments(requestId: RequestKitSchema["@get/requests/:id/comments"]["params"]["id"], query?: RequestKitSchema["@get/requests/:id/comments"]["query"]): Promise<{ comments: { id: string; createdAt: string; content: string; commentor: { identifier: string; name?: string | undefined; email?: string | undefined; }; }[]; }>; createComment(requestId: RequestKitSchema["@post/requests/:id/comments"]["params"]["id"], input: RequestKitSchema["@post/requests/:id/comments"]["input"]): Promise<{ id: string; }>; deleteComment(requestId: RequestKitSchema["@delete/requests/:id/comments/:commentId"]["params"]["id"], commentId: RequestKitSchema["@delete/requests/:id/comments/:commentId"]["params"]["commentId"], body: RequestKitSchema["@delete/requests/:id/comments/:commentId"]["body"]): Promise<{ id: string; }>; } export { RequestKit, RequestKitError };