Skip to main content
Glama
Southclaws

Storyden

by Southclaws
posts.ts•8.45 kB
/** * Generated by orval v7.2.0 🍺 * Do not edit manually. * storyden * Storyden social API for building community driven platforms. The Storyden API does not adhere to semantic versioning but instead applies a rolling strategy with deprecations and minimal breaking changes. This has been done mainly for a simpler development process and it may be changed to a more fixed versioning strategy in the future. Ultimately, the primary way Storyden tracks versions is dates, there are no set release tags currently. * OpenAPI spec version: v1.25.12-canary */ import useSwr from "swr"; import type { Arguments, Key, SWRConfiguration } from "swr"; import useSWRMutation from "swr/mutation"; import type { SWRMutationConfiguration } from "swr/mutation"; import { fetcher } from "../client"; import type { InternalServerErrorResponse, NotFoundResponse, PostLocationGetOKResponse, PostLocationGetParams, PostReactAddBody, PostReactAddOKResponse, PostUpdateBody, PostUpdateOKResponse, UnauthorisedResponse, } from "../openapi-schema"; /** * Publish changes to a single post. */ export const postUpdate = (postId: string, postUpdateBody: PostUpdateBody) => { return fetcher<PostUpdateOKResponse>({ url: `/posts/${postId}`, method: "PATCH", headers: { "Content-Type": "application/json" }, data: postUpdateBody, }); }; export const getPostUpdateMutationFetcher = (postId: string) => { return ( _: Key, { arg }: { arg: PostUpdateBody }, ): Promise<PostUpdateOKResponse> => { return postUpdate(postId, arg); }; }; export const getPostUpdateMutationKey = (postId: string) => [`/posts/${postId}`] as const; export type PostUpdateMutationResult = NonNullable< Awaited<ReturnType<typeof postUpdate>> >; export type PostUpdateMutationError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse; export const usePostUpdate = < TError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse, >( postId: string, options?: { swr?: SWRMutationConfiguration< Awaited<ReturnType<typeof postUpdate>>, TError, Key, PostUpdateBody, Awaited<ReturnType<typeof postUpdate>> > & { swrKey?: string }; }, ) => { const { swr: swrOptions } = options ?? {}; const swrKey = swrOptions?.swrKey ?? getPostUpdateMutationKey(postId); const swrFn = getPostUpdateMutationFetcher(postId); const query = useSWRMutation(swrKey, swrFn, swrOptions); return { swrKey, ...query, }; }; /** * Archive a post using soft-delete. */ export const postDelete = (postId: string) => { return fetcher<void>({ url: `/posts/${postId}`, method: "DELETE" }); }; export const getPostDeleteMutationFetcher = (postId: string) => { return (_: Key, __: { arg: Arguments }): Promise<void> => { return postDelete(postId); }; }; export const getPostDeleteMutationKey = (postId: string) => [`/posts/${postId}`] as const; export type PostDeleteMutationResult = NonNullable< Awaited<ReturnType<typeof postDelete>> >; export type PostDeleteMutationError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse; export const usePostDelete = < TError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse, >( postId: string, options?: { swr?: SWRMutationConfiguration< Awaited<ReturnType<typeof postDelete>>, TError, Key, Arguments, Awaited<ReturnType<typeof postDelete>> > & { swrKey?: string }; }, ) => { const { swr: swrOptions } = options ?? {}; const swrKey = swrOptions?.swrKey ?? getPostDeleteMutationKey(postId); const swrFn = getPostDeleteMutationFetcher(postId); const query = useSWRMutation(swrKey, swrFn, swrOptions); return { swrKey, ...query, }; }; /** * Add a reaction to a post. */ export const postReactAdd = ( postId: string, postReactAddBody: PostReactAddBody, ) => { return fetcher<PostReactAddOKResponse>({ url: `/posts/${postId}/reacts`, method: "PUT", headers: { "Content-Type": "application/json" }, data: postReactAddBody, }); }; export const getPostReactAddMutationFetcher = (postId: string) => { return ( _: Key, { arg }: { arg: PostReactAddBody }, ): Promise<PostReactAddOKResponse> => { return postReactAdd(postId, arg); }; }; export const getPostReactAddMutationKey = (postId: string) => [`/posts/${postId}/reacts`] as const; export type PostReactAddMutationResult = NonNullable< Awaited<ReturnType<typeof postReactAdd>> >; export type PostReactAddMutationError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse; export const usePostReactAdd = < TError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse, >( postId: string, options?: { swr?: SWRMutationConfiguration< Awaited<ReturnType<typeof postReactAdd>>, TError, Key, PostReactAddBody, Awaited<ReturnType<typeof postReactAdd>> > & { swrKey?: string }; }, ) => { const { swr: swrOptions } = options ?? {}; const swrKey = swrOptions?.swrKey ?? getPostReactAddMutationKey(postId); const swrFn = getPostReactAddMutationFetcher(postId); const query = useSWRMutation(swrKey, swrFn, swrOptions); return { swrKey, ...query, }; }; /** * Remove a reaction from a post. */ export const postReactRemove = (postId: string, reactId: string) => { return fetcher<void>({ url: `/posts/${postId}/reacts/${reactId}`, method: "DELETE", }); }; export const getPostReactRemoveMutationFetcher = ( postId: string, reactId: string, ) => { return (_: Key, __: { arg: Arguments }): Promise<void> => { return postReactRemove(postId, reactId); }; }; export const getPostReactRemoveMutationKey = ( postId: string, reactId: string, ) => [`/posts/${postId}/reacts/${reactId}`] as const; export type PostReactRemoveMutationResult = NonNullable< Awaited<ReturnType<typeof postReactRemove>> >; export type PostReactRemoveMutationError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse; export const usePostReactRemove = < TError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse, >( postId: string, reactId: string, options?: { swr?: SWRMutationConfiguration< Awaited<ReturnType<typeof postReactRemove>>, TError, Key, Arguments, Awaited<ReturnType<typeof postReactRemove>> > & { swrKey?: string }; }, ) => { const { swr: swrOptions } = options ?? {}; const swrKey = swrOptions?.swrKey ?? getPostReactRemoveMutationKey(postId, reactId); const swrFn = getPostReactRemoveMutationFetcher(postId, reactId); const query = useSWRMutation(swrKey, swrFn, swrOptions); return { swrKey, ...query, }; }; /** * Locate a post just from its ID. This will tell you what kind of post it is and where to find it. Where "a post is" is simple for threads, just the slug. For replies, it will give you the thread slug and the position within the thread: the index, the page and the position on the page. */ export const postLocationGet = (params: PostLocationGetParams) => { return fetcher<PostLocationGetOKResponse>({ url: `/posts/location`, method: "GET", params, }); }; export const getPostLocationGetKey = (params: PostLocationGetParams) => [`/posts/location`, ...(params ? [params] : [])] as const; export type PostLocationGetQueryResult = NonNullable< Awaited<ReturnType<typeof postLocationGet>> >; export type PostLocationGetQueryError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse; export const usePostLocationGet = < TError = | UnauthorisedResponse | NotFoundResponse | InternalServerErrorResponse, >( params: PostLocationGetParams, options?: { swr?: SWRConfiguration< Awaited<ReturnType<typeof postLocationGet>>, TError > & { swrKey?: Key; enabled?: boolean }; }, ) => { const { swr: swrOptions } = options ?? {}; const isEnabled = swrOptions?.enabled !== false; const swrKey = swrOptions?.swrKey ?? (() => (isEnabled ? getPostLocationGetKey(params) : null)); const swrFn = () => postLocationGet(params); const query = useSwr<Awaited<ReturnType<typeof swrFn>>, TError>( swrKey, swrFn, swrOptions, ); return { swrKey, ...query, }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server