AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(delay): improve the step forms (#15318)
Talal Jaber9efb68c3a44d
diff --git a/bun.lock b/bun.lockindex 90f93bbf9b9..2466e08667f 100644--- a/bun.lock+++ b/bun.lock@@ -10379,7 +10379,7 @@},"packages/pieces/core/delay": {"name": "@activepieces/piece-delay",- "version": "0.3.34",+ "version": "0.3.35","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10626,7 +10626,7 @@},"packages/pieces/core/tables": {"name": "@activepieces/piece-tables",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/core/delay/package.json b/packages/pieces/core/delay/package.jsonindex 2f30646c239..6fcdf7b5c6e 100644--- a/packages/pieces/core/delay/package.json+++ b/packages/pieces/core/delay/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-delay",- "version": "0.3.34",+ "version": "0.3.35","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -17,6 +18,7 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/core/delay/src/i18n/translation.json b/packages/pieces/core/delay/src/i18n/translation.jsonindex 8bbca67bec3..abe75f193b3 100644--- a/packages/pieces/core/delay/src/i18n/translation.json+++ b/packages/pieces/core/delay/src/i18n/translation.json@@ -1,17 +1,15 @@{- "Use it to delay the execution of the next action": "Use it to delay the execution of the next action",+ "Pause your flow for a set duration or until a specific time": "Pause your flow for a set duration or until a specific time","Delay For": "Delay For","Delay Until": "Delay Until","Delays the execution of the next action for a given duration": "Delays the execution of the next action for a given duration","Delays the execution of the next action until a given timestamp": "Delays the execution of the next action until a given timestamp",- "Markdown": "Markdown",- "Unit": "Unit","Amount": "Amount",+ "Unit": "Unit",+ "Markdown": "Markdown","Date and Time": "Date and Time","\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n": "\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n",- "The unit of time to delay the execution of the next action": "The unit of time to delay the execution of the next action",- "The number of units to delay the execution of the next action": "The number of units to delay the execution of the next action",- "Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.": "Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.",+ "A time without a timezone is read as UTC.": "A time without a timezone is read as UTC.","Seconds": "Seconds","Minutes": "Minutes","Hours": "Hours",diff --git a/packages/pieces/core/delay/src/index.ts b/packages/pieces/core/delay/src/index.tsindex 3510e6be902..7835fac30d0 100644--- a/packages/pieces/core/delay/src/index.ts+++ b/packages/pieces/core/delay/src/index.ts@@ -5,8 +5,8 @@ import { delayUntilAction } from './lib/actions/delay-until-action';export const delay = createPiece({displayName: 'Delay',- description: 'Use it to delay the execution of the next action',- minimumSupportedRelease: '0.82.0',+ description: 'Pause your flow for a set duration or until a specific time',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/new-core/delay.svg',authors: ["Nilesh","kishanprmr","MoShizzle","AbdulTheActivePiecer","khaledmashaly","abuaboud"],categories: [PieceCategory.CORE, PieceCategory.FLOW_CONTROL],diff --git a/packages/pieces/core/delay/src/lib/actions/delay-for-action.ts b/packages/pieces/core/delay/src/lib/actions/delay-for-action.tsindex f05fe563675..f28fbfa702b 100644--- a/packages/pieces/core/delay/src/lib/actions/delay-for-action.ts+++ b/packages/pieces/core/delay/src/lib/actions/delay-for-action.ts@@ -19,6 +19,7 @@ enum TimeUnit {// that a real run would reject.const propsSchema = {delayFor: z.number().check(z.minimum(0)),+ unit: z.nullish(z.enum(TimeUnit)),};export const delayForAction = createAction({@@ -37,12 +38,13 @@ export const delayForAction = createAction({},},props: {- markdown: Property.MarkDown({- value: markdownDescription,+ delayFor: Property.Number({+ displayName: 'Amount',+ required: true,+ defaultValue: 5,}),unit: Property.StaticDropdown({displayName: 'Unit',- description: 'The unit of time to delay the execution of the next action',required: true,options: {options: [@@ -54,11 +56,8 @@ export const delayForAction = createAction({},defaultValue: TimeUnit.SECONDS,}),- delayFor: Property.Number({- displayName: 'Amount',- description:- 'The number of units to delay the execution of the next action',- required: true,+ markdown: Property.MarkDown({+ value: markdownDescription,}),},outputSchema: delayForActionOutputSchema,@@ -73,7 +72,6 @@ export const delayForAction = createAction({success: true,};} else if (delayInMs > 1 * 10 * 1000) {- // use flow pauseconst currentTime = new Date();const futureTime = new Date(currentTime.getTime() + delayInMs);const waitpoint = await ctx.run.createWaitpoint({@@ -83,7 +81,6 @@ export const delayForAction = createAction({ctx.run.waitForWaitpoint(waitpoint.id);return {};} else {- // use setTimeoutawait new Promise((resolve) => setTimeout(resolve, delayInMs));return {delayForInMs: delayInMs,diff --git a/packages/pieces/core/delay/src/lib/actions/delay-until-action.ts b/packages/pieces/core/delay/src/lib/actions/delay-until-action.tsindex ae2cbd919f3..7b55a12d80a 100644--- a/packages/pieces/core/delay/src/lib/actions/delay-until-action.ts+++ b/packages/pieces/core/delay/src/lib/actions/delay-until-action.ts@@ -21,15 +21,15 @@ export const delayUntilAction = createAction({},},props: {- markdown: Property.MarkDown({- value: markdownDescription,- }),delayUntilTimestamp: Property.DateTime({displayName: 'Date and Time',- description:- 'Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.',+ description: 'A time without a timezone is read as UTC.',+ placeholder: '2026-08-05T14:30:00Z',required: true,}),+ markdown: Property.MarkDown({+ value: markdownDescription,+ }),},outputSchema: delayUntilActionOutputSchema,async run(ctx) {@@ -41,13 +41,11 @@ export const delayUntilAction = createAction({success: true,};} else if (delayInMs <= 0) {- // resume immediatelyreturn {delayTill: delayTill,success: true,};} else if (delayInMs > 1 * 60 * 1000) {- // use flow pauseconst currentTime = new Date();const futureTime = dayjs(currentTime.getTime() + delayInMs);const waitpoint = await ctx.run.createWaitpoint({@@ -57,7 +55,6 @@ export const delayUntilAction = createAction({ctx.run.waitForWaitpoint(waitpoint.id);return {};} else {- // use setTimeout for delayTill between 0 and 5 secondsawait new Promise((resolve) => setTimeout(resolve, delayInMs));return {delayTill: delayTill,diff --git a/packages/pieces/core/delay/test/delay-for-action.test.ts b/packages/pieces/core/delay/test/delay-for-action.test.tsnew file mode 100644index 00000000000..71541ccfdab--- /dev/null+++ b/packages/pieces/core/delay/test/delay-for-action.test.ts@@ -0,0 +1,78 @@+/// <reference types="vitest/globals" />++import { ExecutionType } from '@activepieces/pieces-framework';+import { delayForAction } from '../src/lib/actions/delay-for-action';++const SECOND = 1000;+const MINUTE = 60 * SECOND;+const HOUR = 60 * MINUTE;+const DAY = 24 * HOUR;++function context(propsValue: Record<string, unknown>) {+ return { propsValue, executionType: ExecutionType.BEGIN } as never;+}++describe('delayFor unit conversion', () => {+ it.each([+ ['seconds', 5, 5 * SECOND],+ ['minutes', 2, 2 * MINUTE],+ ['hours', 3, 3 * HOUR],+ ['days', 1, DAY],+ ])('converts %s to milliseconds', async (unit, delayFor, expected) => {+ await expect(+ delayForAction.test(context({ delayFor, unit })),+ ).resolves.toEqual({ delayForInMs: expected, success: true });+ });++ it.each([[undefined], [null]])(+ 'falls back to seconds when unit is %s',+ async (unit) => {+ await expect(+ delayForAction.test(context({ delayFor: 3, unit })),+ ).resolves.toEqual({ delayForInMs: 3 * SECOND, success: true });+ },+ );++ it('falls back to seconds when unit is absent', async () => {+ await expect(+ delayForAction.test(context({ delayFor: 3 })),+ ).resolves.toEqual({ delayForInMs: 3 * SECOND, success: true });+ });+});++describe('delayFor rejects a unit outside the enum', () => {+ const unsupported = ['Minute', 'minute', 'weeks', 'MINUTES', ''];++ it.each(unsupported)('rejects %j in test mode', async (unit) => {+ await expect(+ delayForAction.test(context({ delayFor: 1, unit })),+ ).rejects.toThrow();+ });++ it.each(unsupported)('rejects %j in run mode', async (unit) => {+ await expect(+ delayForAction.run(context({ delayFor: 1, unit })),+ ).rejects.toThrow();+ });++ it('does not report success for an unsupported unit', async () => {+ const result = await delayForAction+ .test(context({ delayFor: 10, unit: 'Minute' }))+ .catch(() => undefined);+ expect(result).toBeUndefined();+ });+});++describe('delayFor amount validation', () => {+ it.each([[-1], [-0.5]])('rejects a negative amount of %s', async (delayFor) => {+ await expect(+ delayForAction.test(context({ delayFor, unit: 'seconds' })),+ ).rejects.toThrow();+ });++ it('accepts zero', async () => {+ await expect(+ delayForAction.test(context({ delayFor: 0, unit: 'seconds' })),+ ).resolves.toEqual({ delayForInMs: 0, success: true });+ });+});diff --git a/packages/pieces/core/delay/vitest.config.ts b/packages/pieces/core/delay/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/core/delay/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})