import { AdlsPluginV1 as Adls, AthenaPluginV1 as Athena, CosmosDbPluginV1 as CosmosDb, CouchbasePluginV1 as Couchbase, DatabricksPluginV1 as Databricks, KafkaV1 as Kafka, KinesisPluginV1 as Kinesis, OracleDbPluginV1 as OracleDb, RedisPluginV1 as Redis, SalesforcePluginV1 as Salesforce, SmtpPluginV1 as Smtp } from '@superblocksteam/types'; import { GoogleSheetsActionType, GoogleSheetsDestinationType, GoogleSheetsFormatType } from '../../plugins/index.js'; import { Property } from '../common/property.js'; import { IntegrationAuthType } from '../datasource/index.js'; import { PluginMetadata, RestApiBodyDataType } from '../plugin/index.js'; import { ApiTriggerType, ExecutionParam, ScheduleConfig } from './index.js'; export type ActionConfigParamIn = 'HEADER' | 'QUERY' | 'PATH'; export type ActionConfigParamValue = { in: ActionConfigParamIn; value: string }; export type ActionConfigParam = { name: string } & ActionConfigParamValue; export type TestCase = { operation: string; description: string; mediaType: string; parameters?: ActionConfigParam[]; body?: Record; }; export type OpenApiSpec = { paths: Record>>; }; export type Action = { id: ActionId; name: string; type: ActionType; configuration: ActionConfiguration; applicationId?: string; pluginId: string; datasourceId: string; settings?: ActionSettings; children?: { [key: string]: ActionId; }; }; export type Actions = { name: string; triggerActionId: ActionId; schedule?: ScheduleConfig; actions: Record; executeOnPageLoad?: boolean; bindings?: string[]; dynamicBindingPathList?: ExecutionParam[]; version?: string; deactivated?: Date; created?: Date; updated?: Date; supportedMethod?: 'GET' | 'POST'; workflowParams?: ExecutionParam[]; workflowQueries?: ExecutionParam[]; triggerType?: ApiTriggerType; }; export type GoogleSheetsActionConfiguration = { action?: GoogleSheetsActionType; spreadsheetId?: string; sheetTitle?: string; range?: string; /** a string containing an integer */ rowNumber?: string; extractFirstRowHeader?: boolean; /** a string containing an integer */ headerRowNumber?: string; format?: GoogleSheetsFormatType; data?: string; preserveHeaderRow?: boolean; includeHeaderRow?: boolean; writeToDestinationType?: GoogleSheetsDestinationType; /** used by metadata to fetch spreadsheets with pagination */ pageToken?: string; /** used by metadata to fetch spreadsheets with keyword */ keyword?: string; // used when creating a new sheet addSheet?: { sheetTitle: string; rowCount?: string; columnCount?: string; }; }; type DBActionConfiguration = { body?: string; usePreparedSql?: boolean; parameters?: string; // When operation is undefined we assume it's RUN_SQL, otherwise it's part of the SqlOperations enum operation?: string; // When using operation UPDATE_ROWS the default behavior is to match by primary key- but // the user can toggle to useAdvancedMatching useAdvancedMatching?: 'auto' | 'advanced'; schema?: string; table?: string; oldValues?: unknown; // old rows insertedRows?: unknown; // inserted rows newValues?: unknown; // updated rows deletedRows?: unknown; // deleted rows filterBy?: unknown; mappingMode?: 'auto' | 'manual'; // Sort order matters mappedColumns?: Array<{ json: string; sql: string }>; }; type BigqueryActionConfiguration = DBActionConfiguration; type CustomProperties = Record; type GCSActionConfiguration = { resource?: string; action?: string; path?: string; prefix?: string; body?: string | Buffer; fileObjects?: unknown; custom?: CustomProperties; responseType?: ActionResponseType; // TODO: deprecate me, this was a typo resourceType?: ActionResponseType; }; type DynamoDBActionConfiguration = DBActionConfiguration & { action?: string; }; type EmailActionConfiguration = { emailFrom?: string; emailTo?: string; emailCc?: string; emailBcc?: string; emailSubject?: string; emailBody?: string; emailAttachments?: string; }; type SmtpPlugin = Smtp.Plugin; type SmtpActionConfiguration = Partial>; type AdlsPlugin = Adls.Plugin; export type AdlsActionConfiguration = Partial>; export type GraphQLActionConfiguration = { path?: string; headers?: Property[]; body?: string; custom?: CustomProperties; verboseHttpOutput?: boolean; doNotFailOnRequestError?: boolean; }; type JavascriptActionConfiguration = { body?: string; }; type MariaDBActionConfiguration = DBActionConfiguration; export type MongoDBActionConfiguration = { resource?: string; action?: string; pipeline?: string; projection?: string; query?: string; field?: string; sortby?: string; limit?: string; skip?: string; document?: string; replacement?: string; filter?: string; options?: string; update?: string; distinctKey?: string; }; export type MySQLActionConfiguration = DBActionConfiguration; export type OpenAiActionConfiguration = { action?: string; generateChatGptResponsePrompt?: string; generateChatGptResponseMessageHistory?: string; generateChatGptResponseSystemInstruction?: string; generateTextType?: string; generateTextNewTextPrompt?: string; generateTextEditTextTextToEdit?: string; generateTextEditTextPrompt?: string; generateCodeType?: string; generateCodeNewCodePrompt?: string; generateCodeEditCodeCodeToEdit?: string; generateCodeEditCodePrompt?: string; checkModerationText?: string; embeddingText?: string; generateImageMethod?: string; generateImageGenerateFromPromptPrompt?: string; generateImageGenerateFromPromptImageImageSize?: string; generateImageEditImagePrompt?: string; generateImageEditImageImageFileToEdit?: unknown; generateImageEditImageImageMask?: string; generateImageEditImageImageSizes?: string; generateImageVaryImageImageFile?: unknown; generateImageVaryImageImageSize?: string; transcribeAudioToTextAudioFile?: unknown; transcribeAudioToTextInputLanguage?: string; transcribeAudioToTextTranslateToEnglish?: string; generateChatGPTResponseAiModel?: string; generateTextNewTextAiModel?: string; generateTextEditTextAiModel?: string; generateCodeNewCodeAiModel?: string; generateCodeEditCodeAiModel?: string; checkModerationAiModel?: string; generateTextEmbeddingAiModel?: string; transcribeAudioToTextAiModel?: string; generateChatGptResponseMaxTokens?: string; generateTextNewTextMaxTokens?: string; temperature?: string; }; type SuperblocksOcrActionConfiguration = { action?: string; file?: unknown; fileUrl?: string; }; export type PostgresActionConfiguration = DBActionConfiguration; type CockroachDBActionConfiguration = DBActionConfiguration; type MsSqlActionConfiguration = DBActionConfiguration; type PythonActionConfiguration = { body?: string; }; type RedshiftActionConfiguration = DBActionConfiguration; type RestApiCommonActionConfiguration = { httpMethod?: HttpMethod; responseType?: ActionResponseType; headers?: Property[]; params?: Property[]; bodyType?: RestApiBodyDataType; body?: string; formData?: Property[]; fileFormKey?: string; fileName?: string; verboseHttpOutput?: boolean; doNotFailOnRequestError?: boolean; }; export type RestApiActionConfiguration = RestApiCommonActionConfiguration & { path?: string; }; export type RestApiIntegrationActionConfiguration = RestApiCommonActionConfiguration & { urlBase?: string; urlPath?: string; authType?: IntegrationAuthType; openApiAction?: string; openApiSpecRef?: string; openApiTenantName?: string; }; export type S3ActionConfiguration = { resource?: string; action?: string; path?: string; body?: string; fileObjects?: unknown; custom?: { /** Enum name for presigned URL method */ presignedMethod?: 'PRESIGNED_METHOD_UNSPECIFIED' | 'PRESIGNED_METHOD_GET' | 'PRESIGNED_METHOD_PUT'; presignedExpiration?: Property; }; responseType?: ActionResponseType; listFilesConfig?: { // Limits the response to keys that begin with the specified prefix. prefix?: string; // A delimiter is a character that you use to group keys. delimiter?: string; }; }; type SnowflakeActionConfiguration = DBActionConfiguration; export type WorkflowActionConfiguration = { workflow?: string; custom?: CustomProperties; queryParams?: Record; }; type KafkaPlugin = Kafka.Plugin; type KafkaActionConfiguration = Partial>; type KinesisPlugin = Kinesis.Plugin; type KinesisActionConfiguration = Partial>; type AthenaPlugin = Athena.Plugin; type AthenaActionConfiguration = Partial>; type CosmosDbPlugin = CosmosDb.Plugin; export type CosmosDbActionConfiguration = Partial>; type CouchbasePlugin = Couchbase.Plugin; export type CouchbaseActionConfiguration = Partial>; type DatabricksPlugin = Databricks.Plugin; type DatabricksActionConfiguration = Partial>; type OracleDbPlugin = OracleDb.Plugin; export type OracleDbActionConfiguration = Partial>; type RedisPlugin = Redis.Plugin; export type RedisActionConfiguration = Partial>; type SalesforcePlugin = Salesforce.Plugin; export type SalesforceActionConfiguration = Partial>; // When updating, make sure it matches with: // /packages/ui/src/store/slices/apis/types.ts:72 export type ActionConfiguration = PluginMetadata & ( | AthenaActionConfiguration | BigqueryActionConfiguration | CockroachDBActionConfiguration | CosmosDbActionConfiguration | MsSqlActionConfiguration | DynamoDBActionConfiguration | EmailActionConfiguration | GCSActionConfiguration | GraphQLActionConfiguration | JavascriptActionConfiguration | MariaDBActionConfiguration | MongoDBActionConfiguration | MySQLActionConfiguration | OpenAiActionConfiguration | PostgresActionConfiguration | PythonActionConfiguration | RedisActionConfiguration | RedshiftActionConfiguration | RestApiActionConfiguration | RestApiIntegrationActionConfiguration | S3ActionConfiguration | SnowflakeActionConfiguration | SuperblocksOcrActionConfiguration | SalesforceActionConfiguration | WorkflowActionConfiguration | GoogleSheetsActionConfiguration | KafkaActionConfiguration | KinesisActionConfiguration | SmtpActionConfiguration | AdlsActionConfiguration | OracleDbActionConfiguration | DatabricksActionConfiguration | CouchbaseActionConfiguration ); export type ActionId = string; type ActionSettings = { executeOnLoad?: boolean; cacheResponse?: string; userSetOnLoad?: boolean; confirmBeforeExecute?: boolean; }; export enum ActionType { Integration, Conditional, Loop, Assignment } export enum HttpMethod { GET = 'GET', HEAD = 'HEAD', POST = 'POST', PUT = 'PUT', PATCH = 'PATCH', DELETE = 'DELETE', OPTIONS = 'OPTIONS', TRACE = 'TRACE' } // currently, used by RestAPI and S3 export enum ActionResponseType { AUTO = 'auto', JSON = 'json', TEXT = 'text', BINARY = 'binary', RAW = 'raw' } export const GENERIC_HTTP_REQUEST = 'genericHttpRequest'; export const DB_SQL_INITIAL_TEXT = `-- You can use SQL to query data (ex. SELECT * FROM orders;) `; export function getMethodColor(method: HttpMethod): string { switch (method) { case HttpMethod.GET: return '#08BAA5'; case HttpMethod.POST: return '#00A8F5'; case HttpMethod.PUT: return '#FA8A0F'; case HttpMethod.DELETE: return '#F45252'; case HttpMethod.PATCH: return '#643ADF'; default: return 'inherit'; } }