UNPKG

node-appwrite

Version:

Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API

304 lines (297 loc) 13.4 kB
import { Client, UploadProgress } from '../client.js'; import { Models } from '../models.js'; import { Runtime } from '../enums/runtime.js'; import { VCSDeploymentType } from '../enums/v-c-s-deployment-type.js'; import { DeploymentDownloadType } from '../enums/deployment-download-type.js'; import { ExecutionMethod } from '../enums/execution-method.js'; import '../query.js'; declare class Functions { client: Client; constructor(client: Client); /** * Get a list of all the project&#039;s functions. You can use the query params to filter your results. * * @param {string[]} queries * @param {string} search * @throws {AppwriteException} * @returns {Promise<Models.FunctionList>} */ list(queries?: string[], search?: string): Promise<Models.FunctionList>; /** * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. * * @param {string} functionId * @param {string} name * @param {Runtime} runtime * @param {string[]} execute * @param {string[]} events * @param {string} schedule * @param {number} timeout * @param {boolean} enabled * @param {boolean} logging * @param {string} entrypoint * @param {string} commands * @param {string[]} scopes * @param {string} installationId * @param {string} providerRepositoryId * @param {string} providerBranch * @param {boolean} providerSilentMode * @param {string} providerRootDirectory * @param {string} specification * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function>; /** * Get a list of all runtimes that are currently active on your instance. * * @throws {AppwriteException} * @returns {Promise<Models.RuntimeList>} */ listRuntimes(): Promise<Models.RuntimeList>; /** * List allowed function specifications for this instance. * * @throws {AppwriteException} * @returns {Promise<Models.SpecificationList>} */ listSpecifications(): Promise<Models.SpecificationList>; /** * Get a function by its unique ID. * * @param {string} functionId * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ get(functionId: string): Promise<Models.Function>; /** * Update function by its unique ID. * * @param {string} functionId * @param {string} name * @param {Runtime} runtime * @param {string[]} execute * @param {string[]} events * @param {string} schedule * @param {number} timeout * @param {boolean} enabled * @param {boolean} logging * @param {string} entrypoint * @param {string} commands * @param {string[]} scopes * @param {string} installationId * @param {string} providerRepositoryId * @param {string} providerBranch * @param {boolean} providerSilentMode * @param {string} providerRootDirectory * @param {string} specification * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function>; /** * Delete a function by its unique ID. * * @param {string} functionId * @throws {AppwriteException} * @returns {Promise<{}>} */ delete(functionId: string): Promise<{}>; /** * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. * * @param {string} functionId * @param {string} deploymentId * @throws {AppwriteException} * @returns {Promise<Models.Function>} */ updateFunctionDeployment(functionId: string, deploymentId: string): Promise<Models.Function>; /** * Get a list of all the function&#039;s code deployments. You can use the query params to filter your results. * * @param {string} functionId * @param {string[]} queries * @param {string} search * @throws {AppwriteException} * @returns {Promise<Models.DeploymentList>} */ listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList>; /** * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you&#039;ll need to update the function&#039;s deployment to use your new deployment UID. This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). Use the &quot;command&quot; param to set the entrypoint used to execute your code. * * @param {string} functionId * @param {File} code * @param {boolean} activate * @param {string} entrypoint * @param {string} commands * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise<Models.Deployment>; /** * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment&#039;s code will be preserved and used for the new build. * * @param {string} functionId * @param {string} deploymentId * @param {string} buildId * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ createDuplicateDeployment(functionId: string, deploymentId: string, buildId?: string): Promise<Models.Deployment>; /** * Create a deployment based on a template. Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. * * @param {string} functionId * @param {string} repository * @param {string} owner * @param {string} rootDirectory * @param {string} version * @param {boolean} activate * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ createTemplateDeployment(functionId: string, repository: string, owner: string, rootDirectory: string, version: string, activate?: boolean): Promise<Models.Deployment>; /** * Create a deployment when a function is connected to VCS. This endpoint lets you create deployment from a branch, commit, or a tag. * * @param {string} functionId * @param {VCSDeploymentType} type * @param {string} reference * @param {boolean} activate * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ createVcsDeployment(functionId: string, type: VCSDeploymentType, reference: string, activate?: boolean): Promise<Models.Deployment>; /** * Get a function deployment by its unique ID. * * @param {string} functionId * @param {string} deploymentId * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment>; /** * Delete a code deployment by its unique ID. * * @param {string} functionId * @param {string} deploymentId * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteDeployment(functionId: string, deploymentId: string): Promise<{}>; /** * Get a function deployment content by its unique ID. The endpoint response return with a &#039;Content-Disposition: attachment&#039; header that tells the browser to start downloading the file to user downloads directory. * * @param {string} functionId * @param {string} deploymentId * @param {DeploymentDownloadType} type * @throws {AppwriteException} * @returns {Promise<ArrayBuffer>} */ getDeploymentDownload(functionId: string, deploymentId: string, type?: DeploymentDownloadType): Promise<ArrayBuffer>; /** * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn&#039;t started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status &#039;ready&#039;) or failed. The response includes the final build status and details. * * @param {string} functionId * @param {string} deploymentId * @throws {AppwriteException} * @returns {Promise<Models.Deployment>} */ updateDeploymentStatus(functionId: string, deploymentId: string): Promise<Models.Deployment>; /** * Get a list of all the current user function execution logs. You can use the query params to filter your results. * * @param {string} functionId * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise<Models.ExecutionList>} */ listExecutions(functionId: string, queries?: string[]): Promise<Models.ExecutionList>; /** * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * * @param {string} functionId * @param {string} body * @param {boolean} async * @param {string} xpath * @param {ExecutionMethod} method * @param {object} headers * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution>; /** * Get a function execution log by its unique ID. * * @param {string} functionId * @param {string} executionId * @throws {AppwriteException} * @returns {Promise<Models.Execution>} */ getExecution(functionId: string, executionId: string): Promise<Models.Execution>; /** * Delete a function execution by its unique ID. * * @param {string} functionId * @param {string} executionId * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteExecution(functionId: string, executionId: string): Promise<{}>; /** * Get a list of all variables of a specific function. * * @param {string} functionId * @throws {AppwriteException} * @returns {Promise<Models.VariableList>} */ listVariables(functionId: string): Promise<Models.VariableList>; /** * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * * @param {string} functionId * @param {string} key * @param {string} value * @param {boolean} secret * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ createVariable(functionId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable>; /** * Get a variable by its unique ID. * * @param {string} functionId * @param {string} variableId * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ getVariable(functionId: string, variableId: string): Promise<Models.Variable>; /** * Update variable by its unique ID. * * @param {string} functionId * @param {string} variableId * @param {string} key * @param {string} value * @param {boolean} secret * @throws {AppwriteException} * @returns {Promise<Models.Variable>} */ updateVariable(functionId: string, variableId: string, key: string, value?: string, secret?: boolean): Promise<Models.Variable>; /** * Delete a variable by its unique ID. * * @param {string} functionId * @param {string} variableId * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteVariable(functionId: string, variableId: string): Promise<{}>; } export { Functions };