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,41 @@
|
||||
import { Property, createAction } from '@activepieces/pieces-framework';
|
||||
import { kimaiCommon, makeClient } from '../common';
|
||||
import { kimaiAuth } from '../..';
|
||||
|
||||
export const kimaiCreateTimesheetAction = createAction({
|
||||
auth: kimaiAuth,
|
||||
name: 'create_timesheet',
|
||||
description: 'Create a new timesheet',
|
||||
displayName: 'Create Timesheet',
|
||||
props: {
|
||||
project: kimaiCommon.project,
|
||||
activity: kimaiCommon.activity,
|
||||
begin: Property.DateTime({
|
||||
description: 'Begin Date of Timesheet',
|
||||
displayName: 'Begin Date',
|
||||
required: true,
|
||||
}),
|
||||
end: Property.DateTime({
|
||||
description: 'End Date of Timesheet',
|
||||
displayName: 'End Date',
|
||||
required: false,
|
||||
}),
|
||||
description: Property.LongText({
|
||||
description: 'Description of Timesheet',
|
||||
displayName: 'Description',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run({ auth, propsValue }) {
|
||||
const { project, activity, begin, end, description } = propsValue;
|
||||
|
||||
const client = await makeClient(auth);
|
||||
return await client.createTimesheet({
|
||||
project,
|
||||
activity,
|
||||
begin,
|
||||
end,
|
||||
description,
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
import {
|
||||
HttpMethod,
|
||||
HttpMessageBody,
|
||||
httpClient,
|
||||
HttpResponse,
|
||||
} from '@activepieces/pieces-common';
|
||||
|
||||
type PingResponse = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
type ProjectResponse = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
type ActivityResponse = {
|
||||
id: number;
|
||||
parentTitle?: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
type TimesheetCreateRequest = {
|
||||
project: number;
|
||||
activity: number;
|
||||
begin: string;
|
||||
end?: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
type TimesheetResponse = {
|
||||
id: number;
|
||||
project: number;
|
||||
activity: number;
|
||||
begin: string;
|
||||
end?: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export class KimaiClient {
|
||||
constructor(
|
||||
private baseUrl: string,
|
||||
private user: string,
|
||||
private apiPassword: string
|
||||
) {
|
||||
// Remove trailing slash from base URL
|
||||
this.baseUrl = baseUrl.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
async ping(): Promise<PingResponse> {
|
||||
return (await this.makeRequest<PingResponse>(HttpMethod.GET, '/api/ping'))
|
||||
.body;
|
||||
}
|
||||
|
||||
async getProjects(): Promise<ProjectResponse[]> {
|
||||
return (
|
||||
await this.makeRequest<ProjectResponse[]>(HttpMethod.GET, '/api/projects')
|
||||
).body;
|
||||
}
|
||||
|
||||
async getActivities(
|
||||
project: number | undefined = undefined
|
||||
): Promise<ActivityResponse[]> {
|
||||
return (
|
||||
await this.makeRequest<ActivityResponse[]>(
|
||||
HttpMethod.GET,
|
||||
'/api/activities',
|
||||
{
|
||||
project: project,
|
||||
}
|
||||
)
|
||||
).body;
|
||||
}
|
||||
|
||||
async createTimesheet(
|
||||
createData: TimesheetCreateRequest
|
||||
): Promise<TimesheetResponse> {
|
||||
return (
|
||||
await this.makeRequest<TimesheetResponse>(
|
||||
HttpMethod.POST,
|
||||
'/api/timesheets',
|
||||
createData
|
||||
)
|
||||
).body;
|
||||
}
|
||||
|
||||
async makeRequest<T extends HttpMessageBody>(
|
||||
method: HttpMethod,
|
||||
resourceUri: string,
|
||||
body: any | undefined = undefined
|
||||
): Promise<HttpResponse<T>> {
|
||||
return await httpClient.sendRequest<T>({
|
||||
method: method,
|
||||
url: `${this.baseUrl}${resourceUri}`,
|
||||
headers: {
|
||||
'X-AUTH-USER': this.user,
|
||||
'X-AUTH-TOKEN': this.apiPassword,
|
||||
},
|
||||
body: body,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { AppConnectionValueForAuthProperty, PiecePropValueSchema, Property } from '@activepieces/pieces-framework';
|
||||
import { kimaiAuth } from '../..';
|
||||
import { KimaiClient } from './client';
|
||||
|
||||
export const kimaiCommon = {
|
||||
project: Property.Dropdown({
|
||||
auth: kimaiAuth,
|
||||
description: 'Kimai project',
|
||||
displayName: 'Project',
|
||||
required: true,
|
||||
refreshers: [],
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Connect your account first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const client = await makeClient(
|
||||
auth
|
||||
);
|
||||
const projects = await client.getProjects();
|
||||
return {
|
||||
disabled: false,
|
||||
options: projects.map((project) => {
|
||||
return {
|
||||
label: project.name,
|
||||
value: project.id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
}),
|
||||
activity: Property.Dropdown({
|
||||
auth: kimaiAuth,
|
||||
description: 'Kimai activity',
|
||||
displayName: 'Activity',
|
||||
required: true,
|
||||
refreshers: ['project'],
|
||||
options: async ({ auth, project }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Connect your account first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (!project) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Select project first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const client = await makeClient(
|
||||
auth
|
||||
);
|
||||
const activities = await client.getActivities(project as number);
|
||||
return {
|
||||
disabled: false,
|
||||
options: activities.map((activity) => {
|
||||
const nameTokens = [];
|
||||
if (activity.parentTitle) {
|
||||
nameTokens.push(activity.parentTitle);
|
||||
}
|
||||
nameTokens.push(activity.name);
|
||||
const name = nameTokens.join(' - ');
|
||||
return {
|
||||
label: name,
|
||||
value: activity.id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
export async function makeClient(
|
||||
auth: AppConnectionValueForAuthProperty<typeof kimaiAuth>
|
||||
): Promise<KimaiClient> {
|
||||
const client = new KimaiClient(auth.props.base_url, auth.props.user, auth.props.api_password);
|
||||
return client;
|
||||
}
|
||||
Reference in New Issue
Block a user