diff --git a/autogpt_platform/frontend/src/app/api/__generated__/endpoints/files/files.ts b/autogpt_platform/frontend/src/app/api/__generated__/endpoints/files/files.ts new file mode 100644 index 0000000000..71a103c176 --- /dev/null +++ b/autogpt_platform/frontend/src/app/api/__generated__/endpoints/files/files.ts @@ -0,0 +1,184 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * AutoGPT Agent Server + * This server is used to execute agents that are created by the AutoGPT system. + * OpenAPI spec version: 0.1 + */ +import { useMutation } from "@tanstack/react-query"; +import type { + MutationFunction, + QueryClient, + UseMutationOptions, + UseMutationResult, +} from "@tanstack/react-query"; + +import type { BodyPostV1UploadFileToCloudStorage } from "../../models/bodyPostV1UploadFileToCloudStorage"; + +import type { HTTPValidationError } from "../../models/hTTPValidationError"; + +import type { PostV1UploadFileToCloudStorageParams } from "../../models/postV1UploadFileToCloudStorageParams"; + +import type { UploadFileResponse } from "../../models/uploadFileResponse"; + +import { customMutator } from "../../../mutators/custom-mutator"; + +type SecondParameter unknown> = Parameters[1]; + +/** + * Upload a file to cloud storage and return a storage key that can be used +with FileStoreBlock and AgentFileInputBlock. + +Args: + file: The file to upload + user_id: The user ID + provider: Cloud storage provider ("gcs", "s3", "azure") + expiration_hours: Hours until file expires (1-48) + +Returns: + Dict containing the cloud storage path and signed URL + * @summary Upload file to cloud storage + */ +export type postV1UploadFileToCloudStorageResponse200 = { + data: UploadFileResponse; + status: 200; +}; + +export type postV1UploadFileToCloudStorageResponse422 = { + data: HTTPValidationError; + status: 422; +}; + +export type postV1UploadFileToCloudStorageResponseComposite = + | postV1UploadFileToCloudStorageResponse200 + | postV1UploadFileToCloudStorageResponse422; + +export type postV1UploadFileToCloudStorageResponse = + postV1UploadFileToCloudStorageResponseComposite & { + headers: Headers; + }; + +export const getPostV1UploadFileToCloudStorageUrl = ( + params?: PostV1UploadFileToCloudStorageParams, +) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? "null" : value.toString()); + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 + ? `/api/files/upload?${stringifiedParams}` + : `/api/files/upload`; +}; + +export const postV1UploadFileToCloudStorage = async ( + bodyPostV1UploadFileToCloudStorage: BodyPostV1UploadFileToCloudStorage, + params?: PostV1UploadFileToCloudStorageParams, + options?: RequestInit, +): Promise => { + const formData = new FormData(); + formData.append(`file`, bodyPostV1UploadFileToCloudStorage.file); + + return customMutator( + getPostV1UploadFileToCloudStorageUrl(params), + { + ...options, + method: "POST", + body: formData, + }, + ); +}; + +export const getPostV1UploadFileToCloudStorageMutationOptions = < + TError = HTTPValidationError, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { + data: BodyPostV1UploadFileToCloudStorage; + params?: PostV1UploadFileToCloudStorageParams; + }, + TContext + >; + request?: SecondParameter; +}): UseMutationOptions< + Awaited>, + TError, + { + data: BodyPostV1UploadFileToCloudStorage; + params?: PostV1UploadFileToCloudStorageParams; + }, + TContext +> => { + const mutationKey = ["postV1UploadFileToCloudStorage"]; + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && + "mutationKey" in options.mutation && + options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined }; + + const mutationFn: MutationFunction< + Awaited>, + { + data: BodyPostV1UploadFileToCloudStorage; + params?: PostV1UploadFileToCloudStorageParams; + } + > = (props) => { + const { data, params } = props ?? {}; + + return postV1UploadFileToCloudStorage(data, params, requestOptions); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type PostV1UploadFileToCloudStorageMutationResult = NonNullable< + Awaited> +>; +export type PostV1UploadFileToCloudStorageMutationBody = + BodyPostV1UploadFileToCloudStorage; +export type PostV1UploadFileToCloudStorageMutationError = HTTPValidationError; + +/** + * @summary Upload file to cloud storage + */ +export const usePostV1UploadFileToCloudStorage = < + TError = HTTPValidationError, + TContext = unknown, +>( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { + data: BodyPostV1UploadFileToCloudStorage; + params?: PostV1UploadFileToCloudStorageParams; + }, + TContext + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { + data: BodyPostV1UploadFileToCloudStorage; + params?: PostV1UploadFileToCloudStorageParams; + }, + TContext +> => { + const mutationOptions = + getPostV1UploadFileToCloudStorageMutationOptions(options); + + return useMutation(mutationOptions, queryClient); +}; diff --git a/autogpt_platform/frontend/src/app/api/__generated__/endpoints/integrations/integrations.ts b/autogpt_platform/frontend/src/app/api/__generated__/endpoints/integrations/integrations.ts index 9525a6a90e..bdcdea8b32 100644 --- a/autogpt_platform/frontend/src/app/api/__generated__/endpoints/integrations/integrations.ts +++ b/autogpt_platform/frontend/src/app/api/__generated__/endpoints/integrations/integrations.ts @@ -21,6 +21,8 @@ import type { UseQueryResult, } from "@tanstack/react-query"; +import type { AyrshareSSOResponse } from "../../models/ayrshareSSOResponse"; + import type { BodyPostV1Callback } from "../../models/bodyPostV1Callback"; import type { CredentialsMetaResponse } from "../../models/credentialsMetaResponse"; @@ -1530,6 +1532,210 @@ export const usePostV1WebhookPing = < return useMutation(mutationOptions, queryClient); }; +/** + * Generate an SSO URL for Ayrshare social media integration. + +Returns: + dict: Contains the SSO URL for Ayrshare integration + * @summary Get Ayrshare Sso Url + */ +export type getV1GetAyrshareSsoUrlResponse200 = { + data: AyrshareSSOResponse; + status: 200; +}; + +export type getV1GetAyrshareSsoUrlResponseComposite = + getV1GetAyrshareSsoUrlResponse200; + +export type getV1GetAyrshareSsoUrlResponse = + getV1GetAyrshareSsoUrlResponseComposite & { + headers: Headers; + }; + +export const getGetV1GetAyrshareSsoUrlUrl = () => { + return `/api/integrations/ayrshare/sso_url`; +}; + +export const getV1GetAyrshareSsoUrl = async ( + options?: RequestInit, +): Promise => { + return customMutator( + getGetV1GetAyrshareSsoUrlUrl(), + { + ...options, + method: "GET", + }, + ); +}; + +export const getGetV1GetAyrshareSsoUrlQueryKey = () => { + return [`/api/integrations/ayrshare/sso_url`] as const; +}; + +export const getGetV1GetAyrshareSsoUrlQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = + queryOptions?.queryKey ?? getGetV1GetAyrshareSsoUrlQueryKey(); + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => getV1GetAyrshareSsoUrl({ signal, ...requestOptions }); + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag }; +}; + +export type GetV1GetAyrshareSsoUrlQueryResult = NonNullable< + Awaited> +>; +export type GetV1GetAyrshareSsoUrlQueryError = unknown; + +export function useGetV1GetAyrshareSsoUrl< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { + queryKey: DataTag; +}; +export function useGetV1GetAyrshareSsoUrl< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + "initialData" + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +export function useGetV1GetAyrshareSsoUrl< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +}; +/** + * @summary Get Ayrshare Sso Url + */ + +export function useGetV1GetAyrshareSsoUrl< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, + queryClient?: QueryClient, +): UseQueryResult & { + queryKey: DataTag; +} { + const queryOptions = getGetV1GetAyrshareSsoUrlQueryOptions(options); + + const query = useQuery(queryOptions, queryClient) as UseQueryResult< + TData, + TError + > & { queryKey: DataTag }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +/** + * @summary Get Ayrshare Sso Url + */ +export const prefetchGetV1GetAyrshareSsoUrlQuery = async < + TData = Awaited>, + TError = unknown, +>( + queryClient: QueryClient, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + >; + request?: SecondParameter; + }, +): Promise => { + const queryOptions = getGetV1GetAyrshareSsoUrlQueryOptions(options); + + await queryClient.prefetchQuery(queryOptions); + + return queryClient; +}; + /** * Get a list of all available provider names. diff --git a/autogpt_platform/frontend/src/app/api/__generated__/models/ayrshareSSOResponse.ts b/autogpt_platform/frontend/src/app/api/__generated__/models/ayrshareSSOResponse.ts new file mode 100644 index 0000000000..58be7b6bb0 --- /dev/null +++ b/autogpt_platform/frontend/src/app/api/__generated__/models/ayrshareSSOResponse.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * AutoGPT Agent Server + * This server is used to execute agents that are created by the AutoGPT system. + * OpenAPI spec version: 0.1 + */ + +export interface AyrshareSSOResponse { + /** The SSO URL for Ayrshare integration */ + sso_url: string; + /** ISO timestamp when the URL expires */ + expire_at: string; +} diff --git a/autogpt_platform/frontend/src/app/api/__generated__/models/bodyPostV1UploadFileToCloudStorage.ts b/autogpt_platform/frontend/src/app/api/__generated__/models/bodyPostV1UploadFileToCloudStorage.ts new file mode 100644 index 0000000000..46bfff9a78 --- /dev/null +++ b/autogpt_platform/frontend/src/app/api/__generated__/models/bodyPostV1UploadFileToCloudStorage.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * AutoGPT Agent Server + * This server is used to execute agents that are created by the AutoGPT system. + * OpenAPI spec version: 0.1 + */ + +export interface BodyPostV1UploadFileToCloudStorage { + file: Blob; +} diff --git a/autogpt_platform/frontend/src/app/api/__generated__/models/postV1UploadFileToCloudStorageParams.ts b/autogpt_platform/frontend/src/app/api/__generated__/models/postV1UploadFileToCloudStorageParams.ts new file mode 100644 index 0000000000..878eb768ec --- /dev/null +++ b/autogpt_platform/frontend/src/app/api/__generated__/models/postV1UploadFileToCloudStorageParams.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * AutoGPT Agent Server + * This server is used to execute agents that are created by the AutoGPT system. + * OpenAPI spec version: 0.1 + */ + +export type PostV1UploadFileToCloudStorageParams = { + provider?: string; + expiration_hours?: number; +}; diff --git a/autogpt_platform/frontend/src/app/api/__generated__/models/uploadFileResponse.ts b/autogpt_platform/frontend/src/app/api/__generated__/models/uploadFileResponse.ts new file mode 100644 index 0000000000..78fa6c6c50 --- /dev/null +++ b/autogpt_platform/frontend/src/app/api/__generated__/models/uploadFileResponse.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * AutoGPT Agent Server + * This server is used to execute agents that are created by the AutoGPT system. + * OpenAPI spec version: 0.1 + */ + +export interface UploadFileResponse { + file_uri: string; + file_name: string; + size: number; + content_type: string; + expires_in_hours: number; +} diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json index c63413e9ac..ee8ff2fe95 100644 --- a/autogpt_platform/frontend/src/app/api/openapi.json +++ b/autogpt_platform/frontend/src/app/api/openapi.json @@ -443,6 +443,24 @@ } } }, + "/api/integrations/ayrshare/sso_url": { + "get": { + "tags": ["v1", "integrations"], + "summary": "Get Ayrshare Sso Url", + "description": "Generate an SSO URL for Ayrshare social media integration.\n\nReturns:\n dict: Contains the SSO URL for Ayrshare integration", + "operationId": "getV1GetAyrshareSsoUrl", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/AyrshareSSOResponse" } + } + } + } + } + } + }, "/api/integrations/providers": { "get": { "tags": ["v1", "integrations"], @@ -823,6 +841,64 @@ } } }, + "/api/files/upload": { + "post": { + "tags": ["v1", "files"], + "summary": "Upload file to cloud storage", + "description": "Upload a file to cloud storage and return a storage key that can be used\nwith FileStoreBlock and AgentFileInputBlock.\n\nArgs:\n file: The file to upload\n user_id: The user ID\n provider: Cloud storage provider (\"gcs\", \"s3\", \"azure\")\n expiration_hours: Hours until file expires (1-48)\n\nReturns:\n Dict containing the cloud storage path and signed URL", + "operationId": "postV1Upload file to cloud storage", + "parameters": [ + { + "name": "provider", + "in": "query", + "required": false, + "schema": { + "type": "string", + "default": "gcs", + "title": "Provider" + } + }, + { + "name": "expiration_hours", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "default": 24, + "title": "Expiration Hours" + } + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_postV1Upload_file_to_cloud_storage" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UploadFileResponse" } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + } + } + }, "/api/credits": { "get": { "tags": ["v1", "credits"], @@ -3790,6 +3866,23 @@ "required": ["amount", "threshold"], "title": "AutoTopUpConfig" }, + "AyrshareSSOResponse": { + "properties": { + "sso_url": { + "type": "string", + "title": "Sso Url", + "description": "The SSO URL for Ayrshare integration" + }, + "expire_at": { + "type": "string", + "title": "Expire At", + "description": "ISO timestamp when the URL expires" + } + }, + "type": "object", + "required": ["sso_url", "expire_at"], + "title": "AyrshareSSOResponse" + }, "BaseGraph-Input": { "properties": { "id": { "type": "string", "title": "Id" }, @@ -3934,6 +4027,14 @@ "required": ["type", "data", "data_index"], "title": "Body_postV1LogRawAnalytics" }, + "Body_postV1Upload_file_to_cloud_storage": { + "properties": { + "file": { "type": "string", "format": "binary", "title": "File" } + }, + "type": "object", + "required": ["file"], + "title": "Body_postV1Upload file to cloud storage" + }, "Body_postV2Add_credits_to_user": { "properties": { "user_id": { "type": "string", "title": "User Id" }, @@ -6348,6 +6449,24 @@ "required": ["permissions"], "title": "UpdatePermissionsRequest" }, + "UploadFileResponse": { + "properties": { + "file_uri": { "type": "string", "title": "File Uri" }, + "file_name": { "type": "string", "title": "File Name" }, + "size": { "type": "integer", "title": "Size" }, + "content_type": { "type": "string", "title": "Content Type" }, + "expires_in_hours": { "type": "integer", "title": "Expires In Hours" } + }, + "type": "object", + "required": [ + "file_uri", + "file_name", + "size", + "content_type", + "expires_in_hours" + ], + "title": "UploadFileResponse" + }, "UserHistoryResponse": { "properties": { "history": {