diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ee3d8..58435a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 29.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + ## 29.1.0 * Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 7d6e855..c20e342 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -31,5 +31,6 @@ const result = await functions.create({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2f299f2..78a1de6 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -31,5 +31,6 @@ const result = await functions.update({ buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional + interval: 0, // optional }); ``` diff --git a/package-lock.json b/package-lock.json index 48aa474..80586bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "29.1.0", + "version": "29.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "29.1.0", + "version": "29.2.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index fbef7a2..10dff5d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "29.1.0", + "version": "29.2.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 9883e59..ea05002 100644 --- a/src/client.ts +++ b/src/client.ts @@ -80,7 +80,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/29.1.0'; + let ua = 'AppwriteNodeJSSDK/29.2.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -142,7 +142,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '29.1.0', + 'x-sdk-version': '29.2.0', 'user-agent': getUserAgent(), 'X-Appwrite-Response-Format': '2.0.0', }; diff --git a/src/models.ts b/src/models.ts index 408bbdd..eb0dc9d 100644 --- a/src/models.ts +++ b/src/models.ts @@ -4187,6 +4187,10 @@ export namespace Models { * Function execution schedule in CRON format. */ schedule: string; + /** + * Minutes between scheduled executions. 0 when the function has no interval. + */ + interval?: number; /** * Function execution timeout in seconds. */ @@ -7834,6 +7838,10 @@ export namespace Models { * Maximum function and site deployment size in MB */ buildSize: number; + /** + * Shortest function schedule interval allowed, in minutes. 0 allows every interval. + */ + functionsIntervalMinimum: number; /** * Does the plan support encrypted string attributes or not. */ diff --git a/src/services/functions.ts b/src/services/functions.ts index 612fd14..03d49dc 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -107,7 +107,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Function maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -124,6 +124,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise} */ @@ -150,6 +151,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise; /** * 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. @@ -159,7 +161,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Function maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -176,6 +178,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -203,6 +206,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise; create( paramsOrFirst: @@ -229,6 +233,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -253,6 +258,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise { let params: { @@ -278,6 +284,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -308,6 +315,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -333,6 +341,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -358,6 +367,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -439,6 +449,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -585,7 +598,7 @@ export class Functions { * @param {Runtime} params.runtime - Execution runtime. * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. - * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} params.timeout - Maximum execution time in seconds. * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -602,6 +615,7 @@ export class Functions { * @param {string} params.buildSpecification - Build specification for the function deployments. * @param {string} params.runtimeSpecification - Runtime specification for the function executions. * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} params.interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise} */ @@ -628,6 +642,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }): Promise; /** * Update function by its unique ID. @@ -637,7 +652,7 @@ export class Functions { * @param {Runtime} runtime - Execution runtime. * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. * @param {string[]} events - Events list. Maximum of 100 events are allowed. - * @param {string} schedule - Schedule CRON syntax. + * @param {string} schedule - Schedule CRON syntax. Cannot be combined with interval. * @param {number} timeout - Maximum execution time in seconds. * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. @@ -654,6 +669,7 @@ export class Functions { * @param {string} buildSpecification - Build specification for the function deployments. * @param {string} runtimeSpecification - Runtime specification for the function executions. * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @param {number} interval - Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -681,6 +697,7 @@ export class Functions { buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number, + interval?: number, ): Promise; update( paramsOrFirst: @@ -707,6 +724,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; } | string, ...rest: [ @@ -731,6 +749,7 @@ export class Functions { string?, string?, number?, + number?, ] ): Promise { let params: { @@ -756,6 +775,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; if ( @@ -786,6 +806,7 @@ export class Functions { buildSpecification?: string; runtimeSpecification?: string; deploymentRetention?: number; + interval?: number; }; } else { params = { @@ -811,6 +832,7 @@ export class Functions { buildSpecification: rest[18] as string, runtimeSpecification: rest[19] as string, deploymentRetention: rest[20] as number, + interval: rest[21] as number, }; } @@ -836,6 +858,7 @@ export class Functions { const buildSpecification = params.buildSpecification; const runtimeSpecification = params.runtimeSpecification; const deploymentRetention = params.deploymentRetention; + const interval = params.interval; if (typeof functionId === 'undefined') { throw new AppwriteException( 'Missing required parameter: "functionId"', @@ -912,6 +935,9 @@ export class Functions { if (typeof deploymentRetention !== 'undefined') { apiPayload['deploymentRetention'] = deploymentRetention; } + if (typeof interval !== 'undefined') { + apiPayload['interval'] = interval; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = {