From 46da8676586884ec541b8a19205ec60224e91ad1 Mon Sep 17 00:00:00 2001 From: Stanley Chin Date: Tue, 26 Mar 2024 17:47:59 -0400 Subject: [PATCH] Add new "retry" field in the throttle overrides object --- docs/index.html | 4 ++ packages/cli/README-source.md | 1 + packages/cli/README.md | 4 ++ packages/cli/docs/index.html | 4 ++ .../cli/snippets/throttle-configuration.js | 3 + packages/schema/docs/build/schema.md | 4 +- packages/schema/exported-schema.json | 18 +---- .../lib/schemas/ThrottleObjectSchema.js | 42 ++++------- .../schemas/ThrottleOverrideObjectSchema.js | 70 +++++++++++++++++++ 9 files changed, 104 insertions(+), 46 deletions(-) create mode 100644 packages/schema/lib/schemas/ThrottleOverrideObjectSchema.js diff --git a/docs/index.html b/docs/index.html index fc2e949c8..bbeb7bc5f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3670,6 +3670,7 @@

Adding Throttle Configuration

  • window [integer]: Same description as above.
  • limit [integer]: Same description as above.
  • filter [string]: Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.
  • +
  • retry [boolean] (added in v15.6.1): The effect of throttling on the tasks of the action. true means throttled tasks are automatically retried after some delay, while false means tasks are held without retry. It defaults to true.
  • Both window and limit are required and others are optional. By default, throttling is scoped to the action and account.

    Here is a typical usage of the throttle configuration:

    @@ -3707,16 +3708,19 @@

    Adding Throttle Configuration

    window: 600, limit: 10, filter: 'free', + retry: false, }, { window: 600, limit: 100, filter: 'trial', + retry: false, }, { window: 0, limit: 0, filter: 'paid', + retry: true, }, ], }, diff --git a/packages/cli/README-source.md b/packages/cli/README-source.md index cc8d18327..85eb9f93a 100644 --- a/packages/cli/README-source.md +++ b/packages/cli/README-source.md @@ -1173,6 +1173,7 @@ To throttle an action, you need to set a `throttle` object with the following va - `window [integer]`: Same description as above. - `limit [integer]`: Same description as above. - `filter [string]`: Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration. + - `retry [boolean]` (_added in v15.6.1_): The effect of throttling on the tasks of the action. `true` means throttled tasks are automatically retried after some delay, while `false` means tasks are held without retry. It defaults to `true`. Both `window` and `limit` are required and others are optional. By default, throttling is scoped to the action and account. diff --git a/packages/cli/README.md b/packages/cli/README.md index 0cc2db035..f3f37ccd7 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -2175,6 +2175,7 @@ To throttle an action, you need to set a `throttle` object with the following va - `window [integer]`: Same description as above. - `limit [integer]`: Same description as above. - `filter [string]`: Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration. + - `retry [boolean]` (_added in v15.6.1_): The effect of throttling on the tasks of the action. `true` means throttled tasks are automatically retried after some delay, while `false` means tasks are held without retry. It defaults to `true`. Both `window` and `limit` are required and others are optional. By default, throttling is scoped to the action and account. @@ -2213,16 +2214,19 @@ const App = { window: 600, limit: 10, filter: 'free', + retry: false, }, { window: 600, limit: 100, filter: 'trial', + retry: false, }, { window: 0, limit: 0, filter: 'paid', + retry: true, }, ], }, diff --git a/packages/cli/docs/index.html b/packages/cli/docs/index.html index fc2e949c8..bbeb7bc5f 100644 --- a/packages/cli/docs/index.html +++ b/packages/cli/docs/index.html @@ -3670,6 +3670,7 @@

    Adding Throttle Configuration

  • window [integer]: Same description as above.
  • limit [integer]: Same description as above.
  • filter [string]: Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.
  • +
  • retry [boolean] (added in v15.6.1): The effect of throttling on the tasks of the action. true means throttled tasks are automatically retried after some delay, while false means tasks are held without retry. It defaults to true.
  • Both window and limit are required and others are optional. By default, throttling is scoped to the action and account.

    Here is a typical usage of the throttle configuration:

    @@ -3707,16 +3708,19 @@

    Adding Throttle Configuration

    window: 600, limit: 10, filter: 'free', + retry: false, }, { window: 600, limit: 100, filter: 'trial', + retry: false, }, { window: 0, limit: 0, filter: 'paid', + retry: true, }, ], }, diff --git a/packages/cli/snippets/throttle-configuration.js b/packages/cli/snippets/throttle-configuration.js index cbd9014fa..205450123 100644 --- a/packages/cli/snippets/throttle-configuration.js +++ b/packages/cli/snippets/throttle-configuration.js @@ -30,16 +30,19 @@ const App = { window: 600, limit: 10, filter: 'free', + retry: false, }, { window: 600, limit: 100, filter: 'trial', + retry: false, }, { window: 0, limit: 0, filter: 'paid', + retry: true, }, ], }, diff --git a/packages/schema/docs/build/schema.md b/packages/schema/docs/build/schema.md index e4fc668c2..ab873dd1f 100644 --- a/packages/schema/docs/build/schema.md +++ b/packages/schema/docs/build/schema.md @@ -2082,7 +2082,7 @@ Key | Required | Type | Description `limit` | **yes** | `integer` | The maximum number of invocations for an action, allowed within the timeframe window. `key` | no | `string` | The key to throttle with in combination with the scope. User data provided for the input fields can be used in the key with the use of the curly braces referencing. For example, to access the user data provided for the input field "test_field", use `{{bundle.inputData.test_field}}`. Note that a required input field should be referenced to get user data always. `scope` | no | `array`[`string` in (`'user'`, `'auth'`, `'account'`, `'action'`)] | The granularity to throttle by. You can set the scope to one or more of the following: 'user' - Throttles based on user ids. 'auth' - Throttles based on auth ids. 'account' - Throttles based on account ids for all users under a single account. 'action' - Throttles the action it is set on separately from other actions. By default, throttling is scoped to the action and account. -`overrides` | no | `array`[`object`] | EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute. +`overrides` | no | [/ThrottleOverrideObjectSchema](#throttleoverrideobjectschema) | EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute. #### Examples @@ -2103,7 +2103,7 @@ Key | Required | Type | Description window: 3600, limit: 10, scope: [ 'auth' ], - overrides: [ { window: 3600, limit: 2, filter: 'free' } ] + overrides: [ { window: 3600, limit: 2, filter: 'free', retry: false } ] } ``` diff --git a/packages/schema/exported-schema.json b/packages/schema/exported-schema.json index 7bc20d59f..ec7cdbafa 100644 --- a/packages/schema/exported-schema.json +++ b/packages/schema/exported-schema.json @@ -694,23 +694,7 @@ "overrides": { "description": "EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.", "type": "array", - "items": { - "type": "object", - "properties": { - "window": { - "description": "The timeframe, in seconds, within which the system tracks the number of invocations for an action. The number of invocations begins at zero at the start of each window.", - "type": "integer" - }, - "limit": { - "description": "The maximum number of invocations for an action, allowed within the timeframe window.", - "type": "integer" - }, - "filter": { - "description": "Account-based attribute to override the throttle by. You can set to one of the following: \"free\", \"trial\", \"paid\". Therefore, the throttle scope would be automatically set to \"account\" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.", - "type": "string" - } - } - } + "$ref": "/ThrottleOverrideObjectSchema" } }, "additionalProperties": false diff --git a/packages/schema/lib/schemas/ThrottleObjectSchema.js b/packages/schema/lib/schemas/ThrottleObjectSchema.js index 1583d630e..76706bbcc 100644 --- a/packages/schema/lib/schemas/ThrottleObjectSchema.js +++ b/packages/schema/lib/schemas/ThrottleObjectSchema.js @@ -2,6 +2,8 @@ const makeSchema = require('../utils/makeSchema'); +const ThrottleOverrideObjectSchema = require('./ThrottleOverrideObjectSchema'); + module.exports = makeSchema({ id: '/ThrottleObjectSchema', description: @@ -34,27 +36,10 @@ module.exports = makeSchema({ }, }, overrides: { - description: 'EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.', + description: + 'EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.', type: 'array', - items: { - type: 'object', - properties: { - window: { - description: - 'The timeframe, in seconds, within which the system tracks the number of invocations for an action. The number of invocations begins at zero at the start of each window.', - type: 'integer', - }, - limit: { - description: - 'The maximum number of invocations for an action, allowed within the timeframe window.', - type: 'integer', - }, - filter: { - description: `Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.`, - type: 'string', - }, - } - }, + $ref: ThrottleOverrideObjectSchema.id, }, }, examples: [ @@ -88,11 +73,14 @@ module.exports = makeSchema({ window: 3600, limit: 10, scope: ['auth'], - overrides: [{ - window: 3600, - limit: 2, - filter: 'free', - }], + overrides: [ + { + window: 3600, + limit: 2, + filter: 'free', + retry: false, + }, + ], }, ], antiExamples: [ @@ -105,11 +93,11 @@ module.exports = makeSchema({ reason: 'Invalid scope provided: `zap`.', }, { - example: {limit: 10}, + example: { limit: 10 }, reason: 'Missing required key: `window`.', }, { - example: {window: 600}, + example: { window: 600 }, reason: 'Missing required key: `limit`.', }, { diff --git a/packages/schema/lib/schemas/ThrottleOverrideObjectSchema.js b/packages/schema/lib/schemas/ThrottleOverrideObjectSchema.js new file mode 100644 index 000000000..3462fdc4d --- /dev/null +++ b/packages/schema/lib/schemas/ThrottleOverrideObjectSchema.js @@ -0,0 +1,70 @@ +'use strict'; + +const makeSchema = require('../utils/makeSchema'); + +module.exports = makeSchema({ + id: '/ThrottleOverrideObjectSchema', + description: + 'EXPERIMENTAL: Overrides the original throttle configuration based on a Zapier account attribute.', + type: 'object', + required: ['window', 'limit', 'filter'], + properties: { + window: { + description: + 'The timeframe, in seconds, within which the system tracks the number of invocations for an action. The number of invocations begins at zero at the start of each window.', + type: 'integer', + }, + limit: { + description: + 'The maximum number of invocations for an action, allowed within the timeframe window.', + type: 'integer', + }, + filter: { + description: `Account-based attribute to override the throttle by. You can set to one of the following: "free", "trial", "paid". Therefore, the throttle scope would be automatically set to "account" and ONLY the accounts based on the specified filter will have their requests throttled based on the throttle overrides while the rest are throttled based on the original configuration.`, + type: 'string', + }, + retry: { + description: + 'The effect of throttling on the tasks of the action. `true` means throttled tasks are automatically retried after some delay, while `false` means tasks are held without retry. It defaults to `true`.', + type: 'boolean', + }, + }, + examples: [ + { + window: 60, + limit: 100, + filter: 'free', + }, + { + window: 60, + limit: 100, + filter: 'paid', + retry: false, + }, + { + window: 60, + limit: 100, + filter: 'trial', + retry: true, + }, + ], + antiExamples: [ + { + example: { limit: 10 }, + reason: 'Missing required key: `window` and `filter`.', + }, + { + example: { window: 600 }, + reason: 'Missing required key: `limit` and `filter`.', + }, + { + example: { filter: 'trial' }, + reason: 'Missing required key: `window` and `limit`.', + }, + { + example: {}, + reason: 'Missing required keys: `window`, `limit`, and `filter`.', + }, + ], + additionalProperties: false, +});