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,115 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { airOpsAuth } from '../..';
|
||||
import { makeRequest } from '../common';
|
||||
|
||||
export const getExecution = createAction({
|
||||
auth: airOpsAuth,
|
||||
name: 'get_execution',
|
||||
displayName: 'Get Execution',
|
||||
description: 'Get an execution by UUID.',
|
||||
props: {
|
||||
app: Property.Dropdown({
|
||||
displayName: 'Workflow',
|
||||
description: 'Select the workflow.',
|
||||
required: true,
|
||||
refreshers: [],
|
||||
auth: airOpsAuth,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Connect your AirOps account first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const apps = await makeRequest(
|
||||
auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
'/public_api/airops_apps'
|
||||
);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options: (apps as AirOpsApp[]).map((app) => ({
|
||||
label: app.name,
|
||||
value: app.id,
|
||||
})),
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Failed to load workflows',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
},
|
||||
}),
|
||||
execution_uuid: Property.ShortText({
|
||||
displayName: 'Execution UUID',
|
||||
description: 'The UUID of the execution to retrieve.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { app, execution_uuid } = context.propsValue;
|
||||
|
||||
const response = (await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
`/public_api/airops_apps/${app}/executions`
|
||||
)) as ExecutionsResponse;
|
||||
|
||||
const execution = response.data.find((e) => e.uuid === execution_uuid);
|
||||
|
||||
if (!execution) {
|
||||
throw new Error(`Execution with UUID "${execution_uuid}" not found.`);
|
||||
}
|
||||
|
||||
return execution;
|
||||
},
|
||||
});
|
||||
|
||||
interface AirOpsApp {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
background_color: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
active_version_id: number;
|
||||
emoji: string;
|
||||
public: boolean;
|
||||
uuid: string;
|
||||
readme: string;
|
||||
}
|
||||
|
||||
interface Execution {
|
||||
id: string;
|
||||
status: string;
|
||||
airops_apps_version_id: number;
|
||||
conversation_id: string | null;
|
||||
credits_used: number;
|
||||
error_code: string | null;
|
||||
error_message: unknown;
|
||||
feedback: string | null;
|
||||
inputs: Record<string, unknown>;
|
||||
output: Record<string, unknown> | null;
|
||||
runtime: number | null;
|
||||
source: string | null;
|
||||
uuid: string;
|
||||
workspace_id: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
interface ExecutionsResponse {
|
||||
data: Execution[];
|
||||
meta: {
|
||||
count: number;
|
||||
has_more: boolean;
|
||||
cursor: string;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { airOpsAuth } from '../..';
|
||||
import { makeRequest } from '../common';
|
||||
|
||||
export const runWorkflowAsync = createAction({
|
||||
auth: airOpsAuth,
|
||||
name: 'run_workflow_async',
|
||||
displayName: 'Run Workflow (Async)',
|
||||
description: 'Queue an AirOps workflow for asynchronous execution.',
|
||||
props: {
|
||||
app: Property.Dropdown({
|
||||
displayName: 'Workflow',
|
||||
description: 'Select the workflow to execute.',
|
||||
required: true,
|
||||
refreshers: [],
|
||||
auth: airOpsAuth,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Connect your AirOps account first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const apps = await makeRequest(
|
||||
auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
'/public_api/airops_apps'
|
||||
);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options: (apps as AirOpsApp[]).map((app) => ({
|
||||
label: app.name,
|
||||
value: app.uuid,
|
||||
})),
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Failed to load workflows',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
},
|
||||
}),
|
||||
inputs: Property.Json({
|
||||
displayName: 'Inputs',
|
||||
description: 'Input values for the workflow.',
|
||||
required: false,
|
||||
defaultValue: {},
|
||||
}),
|
||||
inputs_schema: Property.Json({
|
||||
displayName: 'Inputs Schema',
|
||||
description: 'Schema defining the workflow inputs (advanced).',
|
||||
required: false,
|
||||
}),
|
||||
definition: Property.Json({
|
||||
displayName: 'Definition',
|
||||
description: 'Custom workflow definition steps (advanced).',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { app, inputs, inputs_schema, definition } = context.propsValue;
|
||||
|
||||
const body: Record<string, unknown> = {};
|
||||
|
||||
if (inputs) {
|
||||
body['inputs'] = inputs;
|
||||
}
|
||||
if (inputs_schema) {
|
||||
body['inputs_schema'] = inputs_schema;
|
||||
}
|
||||
if (definition) {
|
||||
body['definition'] = definition;
|
||||
}
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.POST,
|
||||
`/public_api/airops_apps/${app}/async_execute_definition`,
|
||||
body
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
});
|
||||
|
||||
interface AirOpsApp {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
background_color: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
active_version_id: number;
|
||||
emoji: string;
|
||||
public: boolean;
|
||||
uuid: string;
|
||||
readme: string;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { airOpsAuth } from '../..';
|
||||
import { makeRequest } from '../common';
|
||||
|
||||
export const runWorkflow = createAction({
|
||||
auth: airOpsAuth,
|
||||
name: 'run_workflow',
|
||||
displayName: 'Run Workflow',
|
||||
description: 'Execute an AirOps workflow synchronously.',
|
||||
props: {
|
||||
app: Property.Dropdown({
|
||||
displayName: 'Workflow',
|
||||
description: 'Select the workflow to execute.',
|
||||
required: true,
|
||||
refreshers: [],
|
||||
auth: airOpsAuth,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Connect your AirOps account first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const apps = await makeRequest(
|
||||
auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
'/public_api/airops_apps'
|
||||
);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options: (apps as AirOpsApp[]).map((app) => ({
|
||||
label: app.name,
|
||||
value: app.uuid,
|
||||
})),
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Failed to load workflows',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
},
|
||||
}),
|
||||
inputs: Property.Json({
|
||||
displayName: 'Inputs',
|
||||
description: 'Input values for the workflow.',
|
||||
required: false,
|
||||
defaultValue: {},
|
||||
}),
|
||||
inputs_schema: Property.Json({
|
||||
displayName: 'Inputs Schema',
|
||||
description: 'Schema defining the workflow inputs (advanced).',
|
||||
required: false,
|
||||
}),
|
||||
definition: Property.Json({
|
||||
displayName: 'Definition',
|
||||
description: 'Custom workflow definition steps (advanced).',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { app, inputs, inputs_schema, definition } = context.propsValue;
|
||||
|
||||
const body: Record<string, unknown> = {};
|
||||
|
||||
if (inputs) {
|
||||
body['inputs'] = inputs;
|
||||
}
|
||||
if (inputs_schema) {
|
||||
body['inputs_schema'] = inputs_schema;
|
||||
}
|
||||
if (definition) {
|
||||
body['definition'] = definition;
|
||||
}
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.POST,
|
||||
`/public_api/airops_apps/${app}/execute_definition`,
|
||||
body
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
});
|
||||
|
||||
interface AirOpsApp {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
background_color: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
active_version_id: number;
|
||||
emoji: string;
|
||||
public: boolean;
|
||||
uuid: string;
|
||||
readme: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
|
||||
export const BASE_URL = 'https://api.airops.com';
|
||||
|
||||
export async function makeRequest(
|
||||
auth: string,
|
||||
method: HttpMethod,
|
||||
path: string,
|
||||
body?: unknown
|
||||
) {
|
||||
const response = await httpClient.sendRequest({
|
||||
method,
|
||||
url: `${BASE_URL}${path}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user