- 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>
78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
import {
|
|
PieceAuth,
|
|
Property,
|
|
} from '@activepieces/pieces-framework';
|
|
import { z } from 'zod';
|
|
import { propsValidation } from '@activepieces/pieces-common';
|
|
import { getAuthToken } from './api';
|
|
|
|
export type BettermodeAuthType = {
|
|
region: string;
|
|
domain: string;
|
|
email: string;
|
|
password: string;
|
|
token?: string;
|
|
memberId?: string;
|
|
};
|
|
|
|
export const bettermodeAuth = PieceAuth.CustomAuth({
|
|
description:
|
|
'Your domain should be the base URL of your Bettermode community. Example: community.example.com',
|
|
props: {
|
|
region: Property.StaticDropdown({
|
|
displayName: 'Region',
|
|
description: 'The region of your Bettermode account',
|
|
required: true,
|
|
options: {
|
|
options: [
|
|
{ label: 'US Region', value: 'https://api.bettermode.com' },
|
|
{ label: 'EU Region', value: 'https://api.bettermode.de' },
|
|
],
|
|
},
|
|
}),
|
|
domain: Property.ShortText({
|
|
displayName: 'BetterMode Domain',
|
|
description: 'The domain of your Bettermode account',
|
|
required: true,
|
|
}),
|
|
email: Property.ShortText({
|
|
displayName: 'Email',
|
|
description: 'Email address for your Bettermode account',
|
|
required: true,
|
|
}),
|
|
password: PieceAuth.SecretText({
|
|
displayName: 'Password',
|
|
description: 'Password for your Bettermode account',
|
|
required: true,
|
|
}),
|
|
},
|
|
validate: async ({ auth }) => {
|
|
try {
|
|
await validateAuth(auth);
|
|
return {
|
|
valid: true,
|
|
};
|
|
} catch (e) {
|
|
return {
|
|
valid: false,
|
|
error: (e as Error)?.message,
|
|
};
|
|
}
|
|
},
|
|
required: true,
|
|
});
|
|
|
|
const validateAuth = async (auth: BettermodeAuthType) => {
|
|
await propsValidation.validateZod(auth, {
|
|
domain: z.string().url(),
|
|
email: z.string().email(),
|
|
});
|
|
|
|
const response = await getAuthToken(auth);
|
|
if (!response.memberId) {
|
|
throw new Error(
|
|
'Authentication failed. Please check your credentials and try again.'
|
|
);
|
|
}
|
|
};
|