Files
smoothschedule/activepieces-fork/packages/pieces/community/microsoft-dynamics-crm/src/index.ts
poduck 3aa7199503 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>
2025-12-18 22:59:37 -05:00

106 lines
3.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import {
createPiece,
OAuth2PropertyValue,
PieceAuth,
Property,
} from '@activepieces/pieces-framework';
import { createRecordAction } from './lib/actions/create-record';
import { deleteRecordAction } from './lib/actions/delete-record';
import { getRecordAction } from './lib/actions/get-record';
import { updateRecordAction } from './lib/actions/update-record';
import { PieceCategory } from '@activepieces/shared';
const authDesc = `
1. Sign in to [Microsoft Azure Portal](https://portal.azure.com/).
2. From the left sidebar, go to **Microsoft Enfra ID**.
3. Under **Manage**, click on **App registrations**.
4. Click the **New registration** button.
5. Enter a **Name** for your app.
6. For **Supported account types**, choose:
- **Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts**
- Or select based on your requirement.
7. In **Redirect URI**, select **Web** and add the given URL.
8. Click **Register**.
9. After registration, youll be redirected to the apps overview page. Copy the **Application (client) ID**.
10. From the left menu, go to **Certificates & secrets**.
- Under **Client secrets**, click **New client secret**.
- Provide a description, set an expiry, and click **Add**.
- Copy the **Value** of the client secret (this will not be shown again).
11. Go to **API permissions** from the left menu.
- Click **Add a permission**.
- Select **Dynamics CRM** → **Delegated permissions**.
- Click **Add permissions**.
12. Copy your **Client ID** and **Client Secret**.
`
export const dynamicsCRMAuth = PieceAuth.OAuth2({
description:authDesc,
props: {
hostUrl: Property.ShortText({
displayName: 'Host URL (without trailing slash)',
description:
'Host URL without trailing slash.For example **https://demo.crm.dynamics.com**',
required: true,
}),
tenantId: Property.ShortText({
displayName: 'Tenant ID',
description: 'You can find this in the Azure portal.',
defaultValue: 'common',
required: true,
}),
proxyUrl: Property.ShortText({
displayName: 'Proxy URL with Port',
description:
'Keep empty if not needed. Optional proxy URL used for establishing connections when proxying requests is needed. For example: **https://proxy.com:8080**.',
required: false,
}),
},
required: true,
scope: ['{hostUrl}/.default', 'openid', 'email', 'profile', 'offline_access'],
prompt: 'omit',
authUrl: 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize',
tokenUrl: 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token',
});
export function getBaseUrl(host: string, proxyUrl?: string): string {
if (proxyUrl && proxyUrl !== '') {
return proxyUrl;
}
return host;
}
export const microsoftDynamicsCrm = createPiece({
displayName: 'Microsoft Dynamics CRM',
auth: dynamicsCRMAuth,
description:
'Customer relationship management software package developed by Microsoft.',
minimumSupportedRelease: '0.27.1',
logoUrl: 'https://cdn.activepieces.com/pieces/microsoft-dynamics-crm.png',
authors: ['kishanprmr'],
categories: [PieceCategory.SALES_AND_CRM],
actions: [
createRecordAction,
deleteRecordAction,
getRecordAction,
updateRecordAction,
createCustomApiCallAction({
auth: dynamicsCRMAuth,
baseUrl: (auth) => {
const props = auth?.props
if (!props) {
return '';
}
return `${getBaseUrl(
props['hostUrl'] as string,
props['proxyUrl'] as string
)}/api/data/v9.2`;
},
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth ).access_token}`,
}),
}),
],
triggers: [],
});