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:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,18 @@
{
"extends": ["../../../../.eslintrc.base.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@@ -0,0 +1,7 @@
# pieces-todos
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build pieces-todos` to build the library.

View File

@@ -0,0 +1,4 @@
{
"name": "@activepieces/piece-todos",
"version": "0.0.12"
}

View File

@@ -0,0 +1,65 @@
{
"name": "pieces-todos",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/todos/src",
"projectType": "library",
"release": {
"version": {
"currentVersionResolver": "git-tag",
"preserveLocalDependencyProtocols": false,
"manifestRootsToUpdate": [
"dist/{projectRoot}"
]
}
},
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/todos",
"tsConfig": "packages/pieces/community/todos/tsconfig.lib.json",
"packageJson": "packages/pieces/community/todos/package.json",
"main": "packages/pieces/community/todos/src/index.ts",
"assets": [
"packages/pieces/community/todos/*.md",
{
"input": "packages/pieces/community/todos/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"^build",
"prebuild"
]
},
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
},
"prebuild": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/todos",
"command": "bun install --no-save --silent"
},
"dependsOn": [
"^build"
]
}
}
}

View File

@@ -0,0 +1,17 @@
{
"Todos": "Todos",
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans",
"Create Todo": "Create Todo",
"Wait for Approval": "Wait for Approval",
"Create Todo and Wait": "Create Todo and Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Creates a todo for a user, requiring them to respond or take action.",
"Pauses the flow and wait for the approval from the user": "Pauses the flow and wait for the approval from the user",
"Creates a todo for a user and wait for their response or take action.": "Creates a todo for a user and wait for their response or take action.",
"Title": "Title",
"Description": "Description",
"Assignee": "Assignee",
"Status Options": "Status Options",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.",
"The ID of the task to wait for approval": "The ID of the task to wait for approval"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Erstellen Sie Aufgaben für Projektmitglieder für Aktionen, nützlich für Genehmigungen, Rezensionen und manuelle Aktionen, die von Menschen durchgeführt werden",
"Create Todo": "ToDo erstellen",
"Wait for Approval": "Warten auf Genehmigung",
"Create Todo and Wait": "Todo erstellen und warten",
"Creates a todo for a user, requiring them to respond or take action.": "Erstellt einen ToDo für einen Benutzer, der eine Antwort oder Aktion verlangt.",
"Pauses the flow and wait for the approval from the user": "Pausiert den Fluss und wartet auf die Genehmigung des Benutzers",
"Creates a todo for a user and wait for their response or take action.": "Erstellt ein ToDo für einen Benutzer und wartet auf seine Antwort oder Maßnahmen.",
"Title": "Titel",
"Description": "Beschreibung",
"Assignee": "Assignee",
"Status Options": "Statusoptionen",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "Diese Details werden für den zugewiesenen Benutzer angezeigt. Fügen Sie den vollständigen Kontext hinzu, damit diese die richtige Aktion ausführen können. Sie können auch die Markdown-Formatierung verwenden.",
"The ID of the task to wait for approval": "Die ID der Aufgabe, die auf Genehmigung warten soll"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Crear tareas para que los miembros del proyecto tomen acciones, útiles para aprobaciones, reseñas y acciones manuales realizadas por humanos",
"Create Todo": "Crear tarea",
"Wait for Approval": "Espere a la aprobación",
"Create Todo and Wait": "Crear tarea y esperar",
"Creates a todo for a user, requiring them to respond or take action.": "Crea una tarea para un usuario, exigiéndole que responda o actúe.",
"Pauses the flow and wait for the approval from the user": "Pausa el flujo y espera la aprobación del usuario",
"Creates a todo for a user and wait for their response or take action.": "Crea una tarea para un usuario y espera su respuesta o toma acción.",
"Title": "Título",
"Description": "Descripción",
"Assignee": "Assignee",
"Status Options": "Opciones de estado",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "Estos detalles se mostrarán para el asignado. Añada el contexto completo para que puedan tomar la acción adecuada, También puede utilizar el formato markdown.",
"The ID of the task to wait for approval": "El ID de la tarea a esperar la aprobación"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Créer des tâches pour les membres du projet pour prendre des actions, utiles pour les approbations, les revues et les actions manuelles effectuées par les humains",
"Create Todo": "Créer une tâche",
"Wait for Approval": "Attendre l'approbation",
"Create Todo and Wait": "Créer une todo et attendre",
"Creates a todo for a user, requiring them to respond or take action.": "Crée une todo pour un utilisateur, lui demandant de réagir ou de prendre des mesures.",
"Pauses the flow and wait for the approval from the user": "Met le flow en pause et attend l'approbation de l'utilisateur",
"Creates a todo for a user and wait for their response or take action.": "Crée une todo pour un utilisateur et attend sa réponse ou prend des mesures.",
"Title": "Titre de la page",
"Description": "Libellé",
"Assignee": "Assignee",
"Status Options": "Options de statut",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "Ces détails seront affichés pour le cessionnaire. Ajoutez le contexte complet afin qu'ils puissent prendre les mesures appropriées, vous pouvez également utiliser le formatage de markdown.",
"The ID of the task to wait for approval": "L'ID de la tâche à attendre pour être approuvé"
}

View File

@@ -0,0 +1,17 @@
{
"Todos": "Todos",
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans",
"Create Todo": "Create Todo",
"Wait for Approval": "Wait for Approval",
"Create Todo and Wait": "Create Todo and Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Creates a todo for a user, requiring them to respond or take action.",
"Pauses the flow and wait for the approval from the user": "Pauses the flow and wait for the approval from the user",
"Creates a todo for a user and wait for their response or take action.": "Creates a todo for a user and wait for their response or take action.",
"Title": "Title",
"Description": "Description",
"Assignee": "Assignee",
"Status Options": "Status Options",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.",
"The ID of the task to wait for approval": "The ID of the task to wait for approval"
}

View File

@@ -0,0 +1,17 @@
{
"Todos": "Todos",
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans",
"Create Todo": "Create Todo",
"Wait for Approval": "Wait for Approval",
"Create Todo and Wait": "Create Todo and Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Creates a todo for a user, requiring them to respond or take action.",
"Pauses the flow and wait for the approval from the user": "Pauses the flow and wait for the approval from the user",
"Creates a todo for a user and wait for their response or take action.": "Creates a todo for a user and wait for their response or take action.",
"Title": "Title",
"Description": "Description",
"Assignee": "Assignee",
"Status Options": "Status Options",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.",
"The ID of the task to wait for approval": "The ID of the task to wait for approval"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "プロジェクトメンバーがアクションを実行するためのタスクを作成します。承認、レビュー、および人によって実行される手動アクションに便利です。",
"Create Todo": "Todoを作成",
"Wait for Approval": "承認待ち",
"Create Todo and Wait": "Todoを作成して待つ",
"Creates a todo for a user, requiring them to respond or take action.": "ユーザーにタスクを作成し、応答またはアクションを実行する必要があります。",
"Pauses the flow and wait for the approval from the user": "フローを一時停止し、ユーザーの承認を待つ",
"Creates a todo for a user and wait for their response or take action.": "ユーザーの todo を作成し、応答を待ったりアクションを実行したりします。",
"Title": "タイトル",
"Description": "説明",
"Assignee": "Assignee",
"Status Options": "ステータスオプション",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "これらの詳細が担当者に表示されます。適切なアクションを取るためにコンテキスト全体を追加します。マークダウン書式も使用できます。",
"The ID of the task to wait for approval": "承認待ちのタスクのID"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Maak taken aan voor projectdeelnemers voor het uitvoeren van acties, nuttig voor goedkeuringen, beoordelingen en handmatige acties uitgevoerd door mensen",
"Create Todo": "Taak aanmaken",
"Wait for Approval": "Wacht op goedkeuring",
"Create Todo and Wait": "Maak Tdo en Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Hiermee maakt u een todo voor een gebruiker, die vereist dat ze reageren of actie ondernemen.",
"Pauses the flow and wait for the approval from the user": "Onderbreekt de stroom en wacht op de goedkeuring van de gebruiker",
"Creates a todo for a user and wait for their response or take action.": "Maakt een todo voor een gebruiker en wacht op zijn antwoord of neem actie.",
"Title": "Aanspreektitel",
"Description": "Beschrijving",
"Assignee": "Assignee",
"Status Options": "Status opties",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "Deze gegevens worden getoond voor de taakontvanger. Voeg de volledige context toe zodat ze de juiste actie kunnen ondernemen. U kunt ook Markdown opmaak gebruiken.",
"The ID of the task to wait for approval": "Het ID van de taak om te wachten op goedkeuring"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Crie tarefas para os membros do projeto tomarem ações, úteis para aprovações, análises e ações manuais realizadas por humanos",
"Create Todo": "Criar Tarefa",
"Wait for Approval": "Esperar aprovação",
"Create Todo and Wait": "Criar Todo e Aguardar",
"Creates a todo for a user, requiring them to respond or take action.": "Cria uma tarefa para um usuário, exigindo que ele responda ou tome uma ação.",
"Pauses the flow and wait for the approval from the user": "Pausa o fluxo e aguarda a aprovação do usuário",
"Creates a todo for a user and wait for their response or take action.": "Cria uma tarefa para um usuário e aguarda sua resposta ou tomar uma ação.",
"Title": "Título",
"Description": "Descrição",
"Assignee": "Assignee",
"Status Options": "Opções de Status",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "Esses detalhes serão exibidos para o atribuído. Adicione o contexto completo para que eles possam tomar as ações adequadas, você também pode usar a formatação markdown.",
"The ID of the task to wait for approval": "A ID da tarefa que aguarda aprovação"
}

View File

@@ -0,0 +1,17 @@
{
"Todos": "Todos",
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Создание задач для участников проекта для принятия действий, полезных для утверждений, обзоров и ручных действий, выполняемых людьми",
"Create Todo": "Создать задачу",
"Wait for Approval": "Дождитесь утверждения",
"Create Todo and Wait": "Создать задачу и подождать",
"Creates a todo for a user, requiring them to respond or take action.": "Создает задачу для пользователя, требующую от него ответа или действий.",
"Pauses the flow and wait for the approval from the user": "Приостанавливает поток и ждет одобрения пользователя",
"Creates a todo for a user and wait for their response or take action.": "Создает задачу для пользователя и ждет ответа или действий.",
"Title": "Заголовок",
"Description": "Описание",
"Assignee": "Assignee",
"Status Options": "Настройки статуса",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "Эти детали будут отображаться для исполнителя. Добавьте полный контекст, чтобы они могли принять правильное действие, Вы также можете использовать формат markdown.",
"The ID of the task to wait for approval": "ID задачи в ожидании одобрения"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans",
"Create Todo": "Create Todo",
"Wait for Approval": "Wait for Approval",
"Create Todo and Wait": "Create Todo and Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Creates a todo for a user, requiring them to respond or take action.",
"Pauses the flow and wait for the approval from the user": "Pauses the flow and wait for the approval from the user",
"Creates a todo for a user and wait for their response or take action.": "Creates a todo for a user and wait for their response or take action.",
"Title": "Title",
"Description": "Description",
"Assignee": "Assignee",
"Status Options": "Status Options",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.",
"The ID of the task to wait for approval": "The ID of the task to wait for approval"
}

View File

@@ -0,0 +1,17 @@
{
"Todos": "Todos",
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans",
"Create Todo": "Create Todo",
"Wait for Approval": "Wait for Approval",
"Create Todo and Wait": "Create Todo and Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Creates a todo for a user, requiring them to respond or take action.",
"Pauses the flow and wait for the approval from the user": "Pauses the flow and wait for the approval from the user",
"Creates a todo for a user and wait for their response or take action.": "Creates a todo for a user and wait for their response or take action.",
"Title": "Title",
"Description": "Description",
"Assignee": "Assignee",
"Status Options": "Status Options",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.",
"The ID of the task to wait for approval": "The ID of the task to wait for approval"
}

View File

@@ -0,0 +1,16 @@
{
"Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans": "Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans",
"Create Todo": "Create Todo",
"Wait for Approval": "Wait for Approval",
"Create Todo and Wait": "Create Todo and Wait",
"Creates a todo for a user, requiring them to respond or take action.": "Creates a todo for a user, requiring them to respond or take action.",
"Pauses the flow and wait for the approval from the user": "Pauses the flow and wait for the approval from the user",
"Creates a todo for a user and wait for their response or take action.": "Creates a todo for a user and wait for their response or take action.",
"Title": "标题",
"Description": "描述",
"Assignee": "Assignee",
"Status Options": "Status Options",
"Task ID": "Task ID",
"These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.": "These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.",
"The ID of the task to wait for approval": "The ID of the task to wait for approval"
}

View File

@@ -0,0 +1,18 @@
import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
import { createTodo } from './lib/actions/create-todo';
import { PieceCategory } from '@activepieces/shared';
import { waitForApproval } from './lib/actions/wait-for-approval';
import { createTodoAndWait } from './lib/actions/create-todo-and-wait';
export const todos = createPiece({
displayName: 'Todos',
description:
'Create tasks for project members to take actions, useful for approvals, reviews, and manual actions performed by humans',
auth: PieceAuth.None(),
minimumSupportedRelease: '0.49.0',
logoUrl: 'https://cdn.activepieces.com/pieces/manual-tasks.svg',
authors: ['hazemadelkhalel'],
categories: [PieceCategory.CORE, PieceCategory.FLOW_CONTROL],
actions: [createTodo, waitForApproval, createTodoAndWait],
triggers: [],
});

View File

@@ -0,0 +1,59 @@
import { createAction, PieceAuth } from '@activepieces/pieces-framework';
import {
ExecutionType,
PauseType,
CreateAndWaitTodoResult,
} from '@activepieces/shared';
import { sendTodoApproval, createTodoProps } from '../utils/utils';
export const createTodoAndWait = createAction({
auth: PieceAuth.None(),
name: 'createTodoAndWait',
displayName: 'Create Todo and Wait',
description:
'Creates a todo for a user and wait for their response or take action.',
props: createTodoProps,
errorHandlingOptions: {
continueOnFailure: {
hide: true,
},
retryOnFailure: {
hide: true,
},
},
async test(context) {
if (context.executionType === ExecutionType.BEGIN) {
context.run.pause({
pauseMetadata: {
type: PauseType.WEBHOOK,
response: {},
},
});
const response = await sendTodoApproval(context, true);
return response.body;
} else {
return {
status: context.resumePayload.queryParams['status'],
message: context.resumePayload.queryParams['message'] ?? 'Sample message',
};
}
},
async run(context) {
if (context.executionType === ExecutionType.BEGIN) {
context.run.pause({
pauseMetadata: {
type: PauseType.WEBHOOK,
response: {},
},
});
const response = await sendTodoApproval(context, false);
return response.body;
} else {
const result: CreateAndWaitTodoResult = {
status: context.resumePayload.queryParams['status'],
message: context.resumePayload.queryParams['message'],
}
return result;
}
},
});

View File

@@ -0,0 +1,45 @@
import { createAction, PieceAuth } from '@activepieces/pieces-framework';
import { sendTodoApproval, createTodoProps, constructTodoUrl } from '../utils/utils';
import { CreateTodoResult } from '@activepieces/shared';
export const createTodo = createAction({
name: 'createTodo',
auth: PieceAuth.None(),
displayName: 'Create Todo',
description:
'Creates a todo for a user, requiring them to respond or take action.',
props: createTodoProps,
errorHandlingOptions: {
continueOnFailure: {
hide: true,
},
retryOnFailure: {
hide: true,
},
},
async test(context) {
const response = await sendTodoApproval(context, true);
const links = context.propsValue.statusOptions.map((option: any) => ({
name: option.name,
url: constructTodoUrl(context.server.publicUrl, response.body.id, option.name, true),
}));
return {
id: response.body.id,
links,
};
},
async run(context) {
const response = await sendTodoApproval(context, false);
const links = context.propsValue.statusOptions.map((option: any) => ({
name: option.name,
url: constructTodoUrl(context.server.publicUrl, response.body.id, option.name, false),
}));
const result: CreateTodoResult = {
id: response.body.id,
links,
}
return result;
},
});

View File

@@ -0,0 +1,61 @@
import { httpClient } from '@activepieces/pieces-common';
import { AuthenticationType } from '@activepieces/pieces-common';
import { HttpRequest } from '@activepieces/pieces-common';
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, PieceAuth, Property } from '@activepieces/pieces-framework';
import { PauseType } from '@activepieces/shared';
import { ExecutionType } from '@activepieces/shared';
export const waitForApproval = createAction({
name: 'wait_for_approval',
auth: PieceAuth.None(),
displayName: 'Wait for Approval',
description: 'Pauses the flow and wait for the approval from the user',
props: {
taskId: Property.ShortText({
displayName: 'Task ID',
description: 'The ID of the task to wait for approval',
required: true,
}),
},
errorHandlingOptions: {
continueOnFailure: {
hide: true,
},
retryOnFailure: {
hide: true,
},
},
async test(ctx) {
const request: HttpRequest = {
method: HttpMethod.GET,
url: `${ctx.server.publicUrl}v1/todos/${ctx.propsValue.taskId}`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: ctx.server.token,
},
};
const response = await httpClient.sendRequest(request);
return {
status: response.body.status.name,
message: 'Test message',
};
},
async run(ctx) {
if (ctx.executionType === ExecutionType.BEGIN) {
ctx.run.pause({
pauseMetadata: {
type: PauseType.WEBHOOK,
response: {}
},
});
return undefined;
} else {
return {
status: ctx.resumePayload.queryParams['status'],
message: ctx.resumePayload.queryParams['message'],
};
}
},
});

View File

@@ -0,0 +1,144 @@
import { HttpMethod, AuthenticationType, HttpRequest, httpClient } from "@activepieces/pieces-common";
import { AppConnectionValueForAuthProperty, Property } from "@activepieces/pieces-framework";
import { CreateTodoRequestBody, PopulatedTodo, SeekPage, STATUS_VARIANT, UserWithMetaInformation } from "@activepieces/shared";
export const createTodoProps = {
title: Property.ShortText({
displayName: 'Title',
required: true,
}),
description: Property.LongText({
displayName: 'Description',
description:
'These details will be displayed for the assignee. Add the full context so they can take proper action, You can also use markdown formatting.',
required: false,
}),
assigneeId: Property.Dropdown({
auth: undefined,
displayName: 'Assignee',
required: false,
options: async (_, context) => {
const baseApiUrl = context.server.publicUrl;
const apiKey = context.server.token;
const users = await listAssignee(baseApiUrl, apiKey);
return {
options: users.data.map((user) => ({
value: user.id,
label: `${user.firstName} ${user.lastName}`,
})),
};
},
refreshers: [],
}),
statusOptions: Property.Array({
displayName: 'Status Options',
required: true,
defaultValue: [
{
name: 'Accepted',
variant: STATUS_VARIANT.POSITIVE,
continueFlow: true,
},
{
name: 'Rejected',
variant: STATUS_VARIANT.NEGATIVE,
continueFlow: true,
},
],
properties: {
name: Property.ShortText({
displayName: 'Name',
required: true,
}),
variant: Property.StaticDropdown({
displayName: 'Variant',
required: true,
defaultValue: STATUS_VARIANT.POSITIVE,
options: {
options: Object.values(STATUS_VARIANT).map((variant) => ({
value: variant,
label: variant,
})),
},
}),
continueFlow: Property.Checkbox({
displayName: 'Continue Flow',
required: true,
defaultValue: true,
}),
},
}),
}
export function constructTodoUrl(publicUrl: string, todoId: string, status: string, isTest: boolean) {
return `${publicUrl}v1/todos/${todoId}/resolve?status=${status}&isTest=${isTest}`;
}
type ApprovalParms = {
auth?: AppConnectionValueForAuthProperty<undefined>;
propsValue: {
title: string;
description?: string;
statusOptions: unknown[];
assigneeId?: string;
};
flows: {
current: {
id: string;
};
};
run: {
id: string;
};
server: {
publicUrl: string;
token: string;
};
generateResumeUrl: (options: { queryParams: Record<string, any> }) => string;
}
export async function sendTodoApproval(context: ApprovalParms, isTest: boolean) {
const requestBody: CreateTodoRequestBody = {
title: context.propsValue.title,
description: context.propsValue.description ?? '',
statusOptions: context.propsValue.statusOptions.map((option: any) => ({
name: option.name,
description: option.description,
variant: option.variant,
continueFlow: option.continueFlow,
})),
flowId: context.flows.current.id,
runId: isTest ? undefined : context.run.id,
assigneeId: context.propsValue.assigneeId ?? undefined,
resolveUrl: context.generateResumeUrl({
queryParams: {},
}),
};
return await httpClient.sendRequest<PopulatedTodo>({
method: HttpMethod.POST,
url: `${context.server.publicUrl}v1/todos`,
body: requestBody,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: context.server.token,
},
});
}
export async function listAssignee(
publicUrl: string,
token: string
): Promise<SeekPage<UserWithMetaInformation>> {
const request: HttpRequest = {
method: HttpMethod.GET,
url: `${publicUrl}v1/todos/assignees`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: token,
},
};
const res = await httpClient.sendRequest<SeekPage<UserWithMetaInformation>>(
request
);
return res.body;
}

View File

@@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

View File

@@ -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"]
}