Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": ["../../../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# pieces-delay
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Running lint
|
||||
|
||||
Run `nx lint pieces-delay` to execute the lint via [ESLint](https://eslint.org/).
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "@activepieces/piece-delay",
|
||||
"version": "0.3.21"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "pieces-delay",
|
||||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "packages/pieces/community/delay/src",
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"outputs": [
|
||||
"{options.outputPath}"
|
||||
],
|
||||
"options": {
|
||||
"outputPath": "dist/packages/pieces/community/delay",
|
||||
"tsConfig": "packages/pieces/community/delay/tsconfig.lib.json",
|
||||
"packageJson": "packages/pieces/community/delay/package.json",
|
||||
"main": "packages/pieces/community/delay/src/index.ts",
|
||||
"assets": [
|
||||
"packages/pieces/community/delay/*.md",
|
||||
{
|
||||
"input": "packages/pieces/community/delay/src/i18n",
|
||||
"output": "./src/i18n",
|
||||
"glob": "**/!(i18n.json)"
|
||||
}
|
||||
],
|
||||
"buildableProjectDepsInPackageJsonType": "dependencies",
|
||||
"updateBuildableProjectDepsInPackageJson": true
|
||||
},
|
||||
"dependsOn": [
|
||||
"^build",
|
||||
"prebuild"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": [
|
||||
"{options.outputFile}"
|
||||
]
|
||||
},
|
||||
"prebuild": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/pieces/community/delay",
|
||||
"command": "bun install --no-save --silent"
|
||||
},
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Delay": "Delay",
|
||||
"Use it to delay the execution of the next action": "Use it to delay the execution of the next action",
|
||||
"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",
|
||||
"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.",
|
||||
"Seconds": "Seconds",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Hours",
|
||||
"Days": "Days"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Verwende es, um die Ausführung der nächsten Aktion zu verzögern",
|
||||
"Delay For": "Verzögerung für",
|
||||
"Delay Until": "Verzögerung bis",
|
||||
"Delays the execution of the next action for a given duration": "Verzögert die Ausführung der nächsten Aktion für eine bestimmte Dauer",
|
||||
"Delays the execution of the next action until a given timestamp": "Verzögert die Ausführung der nächsten Aktion bis zu einem bestimmten Zeitstempel",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "Einheit",
|
||||
"Amount": "Betrag",
|
||||
"Date and Time": "Datum und Uhrzeit",
|
||||
"\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n": "\n**Hinweis:** Die maximale Dauer pro Schritt beträgt {{pausedFlowTimeoutDays}} Tage.\n",
|
||||
"The unit of time to delay the execution of the next action": "Die Zeiteinheit um die Ausführung der nächsten Aktion zu verschieben",
|
||||
"The number of units to delay the execution of the next action": "Die Anzahl der Einheiten, die die Ausführung der nächsten Aktion verzögern",
|
||||
"Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.": "Gibt das Datum und die Uhrzeit an, bis die Ausführung der nächsten Aktion verschoben werden soll. Es unterstützt mehrere Formate, einschließlich des ISO-Formats.",
|
||||
"Seconds": "Sekunden",
|
||||
"Minutes": "Minuten",
|
||||
"Hours": "Stunden",
|
||||
"Days": "Tage"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Úsalo para retrasar la ejecución de la siguiente acción",
|
||||
"Delay For": "Retraso para",
|
||||
"Delay Until": "Retraso hasta",
|
||||
"Delays the execution of the next action for a given duration": "Retrasa la ejecución de la siguiente acción durante una duración determinada",
|
||||
"Delays the execution of the next action until a given timestamp": "Retrasa la ejecución de la siguiente acción hasta una marca de tiempo",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "Unidad",
|
||||
"Amount": "Cantidad",
|
||||
"Date and Time": "Fecha y hora",
|
||||
"\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": "La unidad de tiempo para retrasar la ejecución de la siguiente acción",
|
||||
"The number of units to delay the execution of the next action": "El número de unidades para retrasar la ejecución de la siguiente acción",
|
||||
"Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.": "Especifica la fecha y hora hasta que la ejecución de la siguiente acción debe ser retrasada. Soporta múltiples formatos, incluyendo el formato ISO.",
|
||||
"Seconds": "Segundos",
|
||||
"Minutes": "Minutos",
|
||||
"Hours": "Horas",
|
||||
"Days": "Días"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Utilisez-le pour retarder l'exécution de la prochaine action",
|
||||
"Delay For": "Délai de",
|
||||
"Delay Until": "Délai jusqu'à",
|
||||
"Delays the execution of the next action for a given duration": "Retarde l'exécution de l'action suivante pour une durée donnée",
|
||||
"Delays the execution of the next action until a given timestamp": "Délai l'exécution de l'action suivante jusqu'à ce qu'un timestamp donné",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "Unité",
|
||||
"Amount": "Montant",
|
||||
"Date and Time": "Date et heure",
|
||||
"\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n": "\n**Remarque :** La durée maximale par étape est {{pausedFlowTimeoutDays}} jours.\n",
|
||||
"The unit of time to delay the execution of the next action": "L'unité de temps pour retarder l'exécution de l'action suivante",
|
||||
"The number of units to delay the execution of the next action": "Le nombre d'unités pour retarder l'exécution de l'action suivante",
|
||||
"Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.": "Spécifie la date et l'heure jusqu'à laquelle l'exécution de la prochaine action doit être retardée. Il prend en charge plusieurs formats, y compris le format ISO.",
|
||||
"Seconds": "Secondes",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Heures",
|
||||
"Days": "Jours"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Delay": "Delay",
|
||||
"Use it to delay the execution of the next action": "Use it to delay the execution of the next action",
|
||||
"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",
|
||||
"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.",
|
||||
"Seconds": "Seconds",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Hours",
|
||||
"Days": "Days"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Delay": "Delay",
|
||||
"Use it to delay the execution of the next action": "Use it to delay the execution of the next action",
|
||||
"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",
|
||||
"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.",
|
||||
"Seconds": "Seconds",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Hours",
|
||||
"Days": "Days"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "次のアクションの実行を遅らせるために使用する",
|
||||
"Delay For": "遅延",
|
||||
"Delay Until": "までの遅延",
|
||||
"Delays the execution of the next action for a given duration": "指定された期間の次のアクションの実行を遅らせます。",
|
||||
"Delays the execution of the next action until a given timestamp": "指定したタイムスタンプまで次のアクションの実行を遅らせます。",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "単位",
|
||||
"Amount": "金額",
|
||||
"Date and Time": "日付と時刻",
|
||||
"\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n": "\n**注意:** ステップあたりの最大期間は {{pausedFlowTimeoutDays}} 日です。\n",
|
||||
"The unit of time 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.": "次のアクションの実行が遅延する日付と時刻を指定します。ISO 形式を含む複数の形式に対応しています。",
|
||||
"Seconds": "秒",
|
||||
"Minutes": "分",
|
||||
"Hours": "時間",
|
||||
"Days": "日数"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Gebruik het om de uitvoering van de volgende actie te vertragen",
|
||||
"Delay For": "Vertraging voor",
|
||||
"Delay Until": "Vertraging tot",
|
||||
"Delays the execution of the next action for a given duration": "Vertraagd de uitvoering van de volgende actie voor een bepaalde duur",
|
||||
"Delays the execution of the next action until a given timestamp": "Vertraagd de uitvoering van de volgende actie tot een bepaalde tijdstempel",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "Eenheid",
|
||||
"Amount": "Hoeveelheid",
|
||||
"Date and Time": "Datum en tijd",
|
||||
"\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n": "\n**Opmerking:** De maximale duur per stap is {{pausedFlowTimeoutDays}} dagen.\n",
|
||||
"The unit of time to delay the execution of the next action": "De eenheid van tijd om de uitvoering van de volgende actie te vertragen",
|
||||
"The number of units to delay the execution of the next action": "Het aantal eenheden om de uitvoering van de volgende actie te vertragen",
|
||||
"Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.": "Specificeert de datum en tijd tot waarop de uitvoering van de volgende actie moet worden vertraagd. Het ondersteunt meerdere formaten, waaronder ISO-formaat.",
|
||||
"Seconds": "seconden",
|
||||
"Minutes": "minuten",
|
||||
"Hours": "Uren",
|
||||
"Days": "dagen"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Use-o para atrasar a execução da próxima ação",
|
||||
"Delay For": "Atraso Para",
|
||||
"Delay Until": "Atraso Até",
|
||||
"Delays the execution of the next action for a given duration": "Atrasa a execução da próxima ação por uma determinada duração",
|
||||
"Delays the execution of the next action until a given timestamp": "Atrasa a execução da próxima ação até um determinado timestamp",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "Unidade",
|
||||
"Amount": "Quantidade",
|
||||
"Date and Time": "Data e Hora",
|
||||
"\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": "A unidade de tempo para atrasar a execução da próxima ação",
|
||||
"The number of units to delay the execution of the next action": "O número de unidades para atrasar a execução da próxima ação",
|
||||
"Specifies the date and time until which the execution of the next action should be delayed. It supports multiple formats, including ISO format.": "Especifica a data e a hora até que a execução da próxima ação deve ser adiada. Suporta vários formatos, incluindo o formato ISO.",
|
||||
"Seconds": "segundos",
|
||||
"Minutes": "minutos",
|
||||
"Hours": "horas",
|
||||
"Days": "dias"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Delay": "Задержка",
|
||||
"Use it to delay the execution of the next action": "Используйте его для задержки выполнения следующего действия",
|
||||
"Delay For": "Задержка на",
|
||||
"Delay Until": "Задержка до",
|
||||
"Delays the execution of the next action for a given duration": "Задержка выполнения следующего действия на заданную длительность",
|
||||
"Delays the execution of the next action until a given timestamp": "Задержка выполнения следующего действия до заданной отметки времени",
|
||||
"Markdown": "Markdown",
|
||||
"Unit": "Единица измерения",
|
||||
"Amount": "Сумма",
|
||||
"Date and Time": "Дата и время",
|
||||
"\n**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.\n": "\n**Примечание:** Максимальная продолжительность каждого шага составляет {{pausedFlowTimeoutDays}} дней.\n",
|
||||
"The unit of time 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.": "Определяет дату и время, до которого выполнение следующего действия должно быть задержано. Поддерживает несколько форматов, в том числе формат ISO.",
|
||||
"Seconds": "Секунды",
|
||||
"Minutes": "Минут",
|
||||
"Hours": "Часы",
|
||||
"Days": "Дней"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Use it to delay the execution of the next action",
|
||||
"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",
|
||||
"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.",
|
||||
"Seconds": "Seconds",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Hours",
|
||||
"Days": "Days"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Delay": "Delay",
|
||||
"Use it to delay the execution of the next action": "Use it to delay the execution of the next action",
|
||||
"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",
|
||||
"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.",
|
||||
"Seconds": "Seconds",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Hours",
|
||||
"Days": "Days"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Use it to delay the execution of the next action": "Use it to delay the execution of the next action",
|
||||
"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",
|
||||
"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.",
|
||||
"Seconds": "Seconds",
|
||||
"Minutes": "Minutes",
|
||||
"Hours": "Hours",
|
||||
"Days": "Days"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { PieceAuth, createPiece } from '@activepieces/pieces-framework';
|
||||
import { PieceCategory } from '@activepieces/shared';
|
||||
import { delayForAction } from './lib/actions/delay-for-action';
|
||||
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.36.1',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/delay.png',
|
||||
authors: ["Nilesh","kishanprmr","MoShizzle","AbdulTheActivePiecer","khaledmashaly","abuaboud"],
|
||||
categories: [PieceCategory.CORE, PieceCategory.FLOW_CONTROL],
|
||||
auth: PieceAuth.None(),
|
||||
actions: [
|
||||
delayForAction, // Delay for a fixed duration
|
||||
delayUntilAction, // Takes a timestamp parameter instead of duration
|
||||
],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
import {
|
||||
createAction,
|
||||
Property,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { ExecutionType, PauseType } from '@activepieces/shared';
|
||||
import { markdownDescription } from '../common';
|
||||
import { z } from 'zod';
|
||||
import { propsValidation } from '@activepieces/pieces-common';
|
||||
|
||||
enum TimeUnit {
|
||||
SECONDS = 'seconds',
|
||||
MINUTES = 'minutes',
|
||||
HOURS = 'hours',
|
||||
DAYS = 'days',
|
||||
}
|
||||
|
||||
export const delayForAction = createAction({
|
||||
name: 'delayFor',
|
||||
displayName: 'Delay For',
|
||||
description: 'Delays the execution of the next action for a given duration',
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
hide: true,
|
||||
},
|
||||
retryOnFailure: {
|
||||
hide: true,
|
||||
},
|
||||
},
|
||||
props: {
|
||||
markdown: Property.MarkDown({
|
||||
value: markdownDescription,
|
||||
}),
|
||||
unit: Property.StaticDropdown({
|
||||
displayName: 'Unit',
|
||||
description: 'The unit of time to delay the execution of the next action',
|
||||
required: true,
|
||||
options: {
|
||||
options: [
|
||||
{ value: TimeUnit.SECONDS, label: 'Seconds' },
|
||||
{ value: TimeUnit.MINUTES, label: 'Minutes' },
|
||||
{ value: TimeUnit.HOURS, label: 'Hours' },
|
||||
{ value: TimeUnit.DAYS, label: 'Days' },
|
||||
],
|
||||
},
|
||||
defaultValue: TimeUnit.SECONDS,
|
||||
}),
|
||||
delayFor: Property.Number({
|
||||
displayName: 'Amount',
|
||||
description:
|
||||
'The number of units to delay the execution of the next action',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(ctx) {
|
||||
await propsValidation.validateZod(ctx.propsValue, {
|
||||
delayFor: z.number().min(0),
|
||||
});
|
||||
|
||||
const unit = ctx.propsValue.unit ?? TimeUnit.SECONDS;
|
||||
const delayInMs = calculateDelayInMs(ctx.propsValue.delayFor, unit);
|
||||
if (ctx.executionType == ExecutionType.RESUME) {
|
||||
return {
|
||||
delayForInMs: delayInMs,
|
||||
success: true,
|
||||
};
|
||||
} else if (delayInMs > 1 * 10 * 1000) {
|
||||
// use flow pause
|
||||
const currentTime = new Date();
|
||||
const futureTime = new Date(currentTime.getTime() + delayInMs);
|
||||
ctx.run.pause({
|
||||
pauseMetadata: {
|
||||
type: PauseType.DELAY,
|
||||
resumeDateTime: futureTime.toUTCString(),
|
||||
},
|
||||
});
|
||||
return {}; // irrelevant as the flow is being paused, not completed
|
||||
} else {
|
||||
// use setTimeout
|
||||
await new Promise((resolve) => setTimeout(resolve, delayInMs));
|
||||
return {
|
||||
delayForInMs: delayInMs,
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
},
|
||||
async test(ctx) {
|
||||
const unit = ctx.propsValue.unit ?? TimeUnit.SECONDS;
|
||||
return {
|
||||
delayForInMs: calculateDelayInMs(ctx.propsValue.delayFor, unit),
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
function calculateDelayInMs(amount: number, unit: TimeUnit): number {
|
||||
let delayInMs: number;
|
||||
switch (unit) {
|
||||
case TimeUnit.SECONDS:
|
||||
delayInMs = amount * 1000;
|
||||
break;
|
||||
case TimeUnit.MINUTES:
|
||||
delayInMs = amount * 60 * 1000;
|
||||
break;
|
||||
case TimeUnit.HOURS:
|
||||
delayInMs = amount * 60 * 60 * 1000;
|
||||
break;
|
||||
case TimeUnit.DAYS:
|
||||
delayInMs = amount * 24 * 60 * 60 * 1000;
|
||||
break;
|
||||
}
|
||||
return delayInMs;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { ExecutionType, PauseType } from '@activepieces/shared';
|
||||
import dayjs from 'dayjs';
|
||||
import { markdownDescription } from '../common';
|
||||
|
||||
export const delayUntilAction = createAction({
|
||||
name: 'delay_until',
|
||||
displayName: 'Delay Until',
|
||||
description:
|
||||
'Delays the execution of the next action until a given timestamp',
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
hide: true,
|
||||
},
|
||||
retryOnFailure: {
|
||||
hide: true,
|
||||
},
|
||||
},
|
||||
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.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(ctx) {
|
||||
const delayTill = new Date(ctx.propsValue.delayUntilTimestamp);
|
||||
const delayInMs = delayTill.getTime() - Date.now();
|
||||
if (ctx.executionType == ExecutionType.RESUME) {
|
||||
return {
|
||||
delayTill: delayTill,
|
||||
success: true,
|
||||
};
|
||||
} else if (delayInMs <= 0) {
|
||||
// resume immediately
|
||||
return {
|
||||
delayTill: delayTill,
|
||||
success: true,
|
||||
};
|
||||
} else if (delayInMs > 1 * 60 * 1000) {
|
||||
// use flow pause
|
||||
const currentTime = new Date();
|
||||
const futureTime = dayjs(currentTime.getTime() + delayInMs);
|
||||
ctx.run.pause({
|
||||
pauseMetadata: {
|
||||
type: PauseType.DELAY,
|
||||
resumeDateTime: futureTime.toISOString(),
|
||||
},
|
||||
});
|
||||
return {}; // irrelevant as the flow is being paused, not completed
|
||||
} else {
|
||||
// use setTimeout for delayTill between 0 and 5 seconds
|
||||
await new Promise((resolve) => setTimeout(resolve, delayInMs));
|
||||
return {
|
||||
delayTill: delayTill,
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
async test(ctx) {
|
||||
const delayTill = new Date(ctx.propsValue.delayUntilTimestamp);
|
||||
return {
|
||||
delayTill,
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
export const markdownDescription = `
|
||||
**Note:** The maximum duration per step is {{pausedFlowTimeoutDays}} days.
|
||||
`
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
],
|
||||
"compilerOptions": {
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"outDir": "../../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user