Merge pull request #806 from automatisch/add-flowers-software

Add flowers software
This commit is contained in:
Ömer Faruk Aydın
2022-12-17 00:33:06 +03:00
committed by GitHub
16 changed files with 703 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" width="762.564" height="769.312" viewBox="0 0 772772" fill="none">
<g clip-path="url(#clip0_493_7535)">
<path d="M747.782 474.701C725.051 423.2 683.614 383.657 631.048 363.294L413.561 279.117L429.189 369.569L602.633 436.697C670.591 462.98 704.451 539.58 678.168 607.537C651.885 675.494 575.285 709.354 507.328 683.071C473.231 669.811 446.711 643.883 432.741 610.023C429.426 601.854 426.939 593.33 425.164 584.569L358.509 636.07C358.982 637.372 359.338 638.674 359.811 639.858C382.069 693.963 424.216 735.282 478.795 756.356C503.776 765.946 529.349 770.563 554.566 770.563C639.098 770.563 719.131 719.299 751.334 635.833C771.697 583.267 770.277 526.083 747.545 474.583L747.782 474.701Z" fill="#02AFC7"/>
<path d="M440.91 419.881L294.459 533.064C287.119 538.628 279.187 543.482 270.781 547.507C237.631 563.254 200.693 564.556 166.477 551.414C133.564 538.628 107.636 513.884 93.3109 481.563C78.9854 449.242 78.1567 413.369 90.943 380.456C103.729 347.543 128.473 321.615 160.794 307.29C190.866 294.03 224.134 292.491 255.271 302.672L241.064 219.206C147.061 207.13 53.2943 259.815 17.6583 352.042C-2.70517 404.608 -1.28446 461.792 21.4468 513.292C44.1781 564.793 85.6154 604.336 138.181 624.699C162.57 634.171 188.38 638.788 214.189 638.788C245.208 638.788 276.227 632.039 304.641 618.543C318.019 612.268 330.687 604.454 342.29 595.575L527.81 452.083L440.91 419.762V419.881Z" fill="#31DEA4"/>
<path d="M624.42 193.396C629.629 229.624 619.921 265.379 597.19 294.148C594.822 297.108 592.335 299.831 589.731 302.554L665.62 333.454C696.402 289.649 709.899 235.307 702.203 182.149C694.153 126.386 665.028 77.135 619.921 43.3933C574.932 9.76989 519.406 -4.43717 463.643 3.49511C407.88 11.5458 358.629 40.6703 324.888 85.7777C291.146 130.885 276.939 186.411 284.989 242.055L323.23 457.529L393.673 404.371L362.773 230.334C357.919 195.646 366.798 161.075 387.872 133.016C409.064 104.72 439.846 86.488 474.89 81.3972C509.935 76.4247 544.623 85.3041 572.801 106.378C601.096 127.57 619.329 158.47 624.42 193.396V193.396Z" fill="#FF5986"/>
</g>
<defs>
<clipPath id="clip0_493_7535">
<rect width="762.564" height="769.312" fill="white" transform="translate(3.33301 1.36719)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,43 @@
import verifyCredentials from './verify-credentials';
import isStillVerified from './is-still-verified';
export default {
fields: [
{
key: 'username',
label: 'Username',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
placeholder: null,
description: null,
clickToCopy: false,
},
{
key: 'password',
label: 'Password',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
placeholder: null,
description: null,
clickToCopy: false,
},
{
key: 'apiKey',
label: 'API Key',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
placeholder: null,
description: null,
clickToCopy: false,
},
],
verifyCredentials,
isStillVerified,
};

View File

@@ -0,0 +1,10 @@
import { IGlobalVariable } from '@automatisch/types';
import verifyCredentials from './verify-credentials';
const isStillVerified = async ($: IGlobalVariable) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -0,0 +1,20 @@
import { IGlobalVariable } from '@automatisch/types';
import getWebhooks from '../common/get-webhooks';
const verifyCredentials = async ($: IGlobalVariable) => {
const response = await getWebhooks($);
const successful = Array.isArray(response.data);
if (!successful) {
throw new Error('Failed while authorizing!');
}
await $.auth.set({
screenName: $.auth.data.username,
username: $.auth.data.username,
password: $.auth.data.password,
apiKey: $.auth.data.apiKey,
});
};
export default verifyCredentials;

View File

@@ -0,0 +1,18 @@
import { TBeforeRequest } from '@automatisch/types';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
const { data } = $.auth;
if (data?.username && data.password && data.apiKey) {
requestConfig.headers['x-api-key'] = data.apiKey as string;
requestConfig.auth = {
username: data.username as string,
password: data.password as string,
};
}
return requestConfig;
};
export default addAuthHeader;

View File

@@ -0,0 +1,5 @@
import type { IGlobalVariable } from "@automatisch/types";
export default async function getWebhooks($: IGlobalVariable) {
return await $.http.get('/v2/public/api/webhooks');
}

View File

@@ -0,0 +1,488 @@
const webhookFilters = [
{
label: "Contact Company Created",
value: "CONTACT_COMPANY_CREATED"
},
{
label: "Contact Company Deleted",
value: "CONTACT_COMPANY_DELETED"
},
{
label: "Contact Company Updated",
value: "CONTACT_COMPANY_UPDATED"
},
{
label: "Contact Created",
value: "CONTACT_CREATED"
},
{
label: "Contact Deleted",
value: "CONTACT_DELETED"
},
{
label: "Contact Updated",
value: "CONTACT_UPDATED"
},
{
label: "Customer Created",
value: "CUSTOMER_CREATED"
},
{
label: "Customer Updated",
value: "CUSTOMER_UPDATED"
},
{
label: "Document Deleted",
value: "DOCUMENT_DELETED"
},
{
label: "Document Downloaded",
value: "DOCUMENT_DOWNLOADED"
},
{
label: "Document Saved",
value: "DOCUMENT_SAVED"
},
{
label: "Document Updated",
value: "DOCUMENT_UPDATED"
},
{
label: "Flow Archived",
value: "FLOW_ARCHIVED"
},
{
label: "Flow Created",
value: "FLOW_CREATED"
},
{
label: "Flow Object Automation Action Created",
value: "FLOW_OBJECT_AUTOMATION_ACTION_CREATED"
},
{
label: "Flow Object Automation Action Deleted",
value: "FLOW_OBJECT_AUTOMATION_ACTION_DELETED"
},
{
label: "Flow Object Automation Created",
value: "FLOW_OBJECT_AUTOMATION_CREATED"
},
{
label: "Flow Object Automation Deleted",
value: "FLOW_OBJECT_AUTOMATION_DELETED"
},
{
label: "Flow Object Automation Updated",
value: "FLOW_OBJECT_AUTOMATION_UPDATED"
},
{
label: "Flow Object Automation Webdav Created",
value: "FLOW_OBJECT_AUTOMATION_WEBDAV_CREATED"
},
{
label: "Flow Object Automation Webdav Deleted",
value: "FLOW_OBJECT_AUTOMATION_WEBDAV_DELETED"
},
{
label: "Flow Object Automation Webdav Updated",
value: "FLOW_OBJECT_AUTOMATION_WEBDAV_UPDATED"
},
{
label: "Flow Object Created",
value: "FLOW_OBJECT_CREATED"
},
{
label: "Flow Object Deleted",
value: "FLOW_OBJECT_DELETED"
},
{
label: "Flow Object Document Added",
value: "FLOW_OBJECT_DOCUMENT_ADDED"
},
{
label: "Flow Object Document Removed",
value: "FLOW_OBJECT_DOCUMENT_REMOVED"
},
{
label: "Flow Object Resource Created",
value: "FLOW_OBJECT_RESOURCE_CREATED"
},
{
label: "Flow Object Resource Deleted",
value: "FLOW_OBJECT_RESOURCE_DELETED"
},
{
label: "Flow Object Resource Updated",
value: "FLOW_OBJECT_RESOURCE_UPDATED"
},
{
label: "Flow Object Task Condition Created",
value: "FLOW_OBJECT_TASK_CONDITION_CREATED"
},
{
label: "Flow Object Task Condition Deleted",
value: "FLOW_OBJECT_TASK_CONDITION_DELETED"
},
{
label: "Flow Object Task Condition Updated",
value: "FLOW_OBJECT_TASK_CONDITION_UPDATED"
},
{
label: "Flow Object Task Created",
value: "FLOW_OBJECT_TASK_CREATED"
},
{
label: "Flow Object Task Deleted",
value: "FLOW_OBJECT_TASK_DELETED"
},
{
label: "Flow Object Task Updated",
value: "FLOW_OBJECT_TASK_UPDATED"
},
{
label: "Flow Object Updated",
value: "FLOW_OBJECT_UPDATED"
},
{
label: "Flow Objects Connection Created",
value: "FLOW_OBJECTS_CONNECTION_CREATED"
},
{
label: "Flow Objects Connection Deleted",
value: "FLOW_OBJECTS_CONNECTION_DELETED"
},
{
label: "Flow Objects Connection Updated",
value: "FLOW_OBJECTS_CONNECTION_UPDATED"
},
{
label: "Flow Objects External Connection Created",
value: "FLOW_OBJECTS_EXTERNAL_CONNECTION_CREATED"
},
{
label: "Flow Objects External Connection Deleted",
value: "FLOW_OBJECTS_EXTERNAL_CONNECTION_DELETED"
},
{
label: "Flow Objects External Connection Updated",
value: "FLOW_OBJECTS_EXTERNAL_CONNECTION_UPDATED"
},
{
label: "Flow Objects External Connections Group Created",
value: "FLOW_OBJECTS_EXTERNAL_CONNECTIONS_GROUP_CREATED"
},
{
label: "Flow Objects External Connections Group Deleted",
value: "FLOW_OBJECTS_EXTERNAL_CONNECTIONS_GROUP_DELETED"
},
{
label: "Flow Objects External Connections Group Updated",
value: "FLOW_OBJECTS_EXTERNAL_CONNECTIONS_GROUP_UPDATED"
},
{
label: "Flow Unarchived",
value: "FLOW_UNARCHIVED"
},
{
label: "Flow Updated",
value: "FLOW_UPDATED"
},
{
label: "Note Created",
value: "NOTE_CREATED"
},
{
label: "Note Deleted",
value: "NOTE_DELETED"
},
{
label: "Note Updated",
value: "NOTE_UPDATED"
},
{
label: "Team Created",
value: "TEAM_CREATED"
},
{
label: "Team Deleted",
value: "TEAM_DELETED"
},
{
label: "Team Updated",
value: "TEAM_UPDATED"
},
{
label: "User Added To Team",
value: "USER_ADDED_TO_TEAM"
},
{
label: "User Added To Teamleads",
value: "USER_ADDED_TO_TEAMLEADS"
},
{
label: "User Archived",
value: "USER_ARCHIVED"
},
{
label: "User Changed Password",
value: "USER_CHANGED_PASSWORD"
},
{
label: "User Created",
value: "USER_CREATED"
},
{
label: "User Forgot Password",
value: "USER_FORGOT_PASSWORD"
},
{
label: "User Invited",
value: "USER_INVITED"
},
{
label: "User Logged In",
value: "USER_LOGGED_IN"
},
{
label: "User Notification Settings Changed",
value: "USER_NOTIFICATION_SETTINGS_CHANGED"
},
{
label: "User Profile Updated",
value: "USER_PROFILE_UPDATED"
},
{
label: "User Removed From Team",
value: "USER_REMOVED_FROM_TEAM"
},
{
label: "User Removed From Teamleads",
value: "USER_REMOVED_FROM_TEAMLEADS"
},
{
label: "User Unarchived",
value: "USER_UNARCHIVED"
},
{
label: "Workflow Archived",
value: "WORKFLOW_ARCHIVED"
},
{
label: "Workflow Completed",
value: "WORKFLOW_COMPLETED"
},
{
label: "Workflow Created",
value: "WORKFLOW_CREATED"
},
{
label: "Workflow Creation Failed",
value: "WORKFLOW_CREATION_FAILED"
},
{
label: "Workflow Object Automation Api Get Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_API_GET_COMPLETED"
},
{
label: "Workflow Object Automation Api Get Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_API_GET_FAILED"
},
{
label: "Workflow Object Automation Api Post Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_API_POST_COMPLETED"
},
{
label: "Workflow Object Automation Api Post Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_API_POST_FAILED"
},
{
label: "Workflow Object Automation Datev Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_DATEV_COMPLETED"
},
{
label: "Workflow Object Automation Datev Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_DATEV_FAILED"
},
{
label: "Workflow Object Automation Email Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_EMAIL_COMPLETED"
},
{
label: "Workflow Object Automation Email Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_EMAIL_FAILED"
},
{
label: "Workflow Object Automation Lexoffice Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_LEXOFFICE_COMPLETED"
},
{
label: "Workflow Object Automation Lexoffice Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_LEXOFFICE_FAILED"
},
{
label: "Workflow Object Automation Rejected",
value: "WORKFLOW_OBJECT_AUTOMATION_REJECTED"
},
{
label: "Workflow Object Automation Retried",
value: "WORKFLOW_OBJECT_AUTOMATION_RETRIED"
},
{
label: "Workflow Object Automation Sevdesk Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_SEVDESK_COMPLETED"
},
{
label: "Workflow Object Automation Sevdesk Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_SEVDESK_FAILED"
},
{
label: "Workflow Object Automation Stamp Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_STAMP_COMPLETED"
},
{
label: "Workflow Object Automation Stamp Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_STAMP_FAILED"
},
{
label: "Workflow Object Automation Task Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_TASK_COMPLETED"
},
{
label: "Workflow Object Automation Task Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_TASK_FAILED"
},
{
label: "Workflow Object Automation Template Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_TEMPLATE_COMPLETED"
},
{
label: "Workflow Object Automation Template Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_TEMPLATE_FAILED"
},
{
label: "Workflow Object Automation Webdav Document Uploaded",
value: "WORKFLOW_OBJECT_AUTOMATION_WEBDAV_DOCUMENT_UPLOADED"
},
{
label: "Workflow Object Automation Zapier Completed",
value: "WORKFLOW_OBJECT_AUTOMATION_ZAPIER_COMPLETED"
},
{
label: "Workflow Object Automation Zapier Failed",
value: "WORKFLOW_OBJECT_AUTOMATION_ZAPIER_FAILED"
},
{
label: "Workflow Object Combination Task Group Created",
value: "WORKFLOW_OBJECT_COMBINATION_TASK_GROUP_CREATED"
},
{
label: "Workflow Object Combination Task Group Deleted",
value: "WORKFLOW_OBJECT_COMBINATION_TASK_GROUP_DELETED"
},
{
label: "Workflow Object Completed Automations Finished",
value: "WORKFLOW_OBJECT_COMPLETED_AUTOMATIONS_FINISHED"
},
{
label: "Workflow Object Completed",
value: "WORKFLOW_OBJECT_COMPLETED"
},
{
label: "Workflow Object Created",
value: "WORKFLOW_OBJECT_CREATED"
},
{
label: "Workflow Object Document Added",
value: "WORKFLOW_OBJECT_DOCUMENT_ADDED"
},
{
label: "Workflow Object Document Lock Added",
value: "WORKFLOW_OBJECT_DOCUMENT_LOCK_ADDED"
},
{
label: "Workflow Object Document Lock Deleted",
value: "WORKFLOW_OBJECT_DOCUMENT_LOCK_DELETED"
},
{
label: "Workflow Object Document Removed",
value: "WORKFLOW_OBJECT_DOCUMENT_REMOVED"
},
{
label: "Workflow Object Email Added",
value: "WORKFLOW_OBJECT_EMAIL_ADDED"
},
{
label: "Workflow Object Email Removed",
value: "WORKFLOW_OBJECT_EMAIL_REMOVED"
},
{
label: "Workflow Object External User Created",
value: "WORKFLOW_OBJECT_EXTERNAL_USER_CREATED"
},
{
label: "Workflow Object External User Deleted",
value: "WORKFLOW_OBJECT_EXTERNAL_USER_DELETED"
},
{
label: "Workflow Object Note Added",
value: "WORKFLOW_OBJECT_NOTE_ADDED"
},
{
label: "Workflow Object Note Removed",
value: "WORKFLOW_OBJECT_NOTE_REMOVED"
},
{
label: "Workflow Object Resource Created",
value: "WORKFLOW_OBJECT_RESOURCE_CREATED"
},
{
label: "Workflow Object Snapshot Created",
value: "WORKFLOW_OBJECT_SNAPSHOT_CREATED"
},
{
label: "Workflow Object Task Condition Created",
value: "WORKFLOW_OBJECT_TASK_CONDITION_CREATED"
},
{
label: "Workflow Object Task Created",
value: "WORKFLOW_OBJECT_TASK_CREATED"
},
{
label: "Workflow Object Task Deleted",
value: "WORKFLOW_OBJECT_TASK_DELETED"
},
{
label: "Workflow Object Task Snapshot Created",
value: "WORKFLOW_OBJECT_TASK_SNAPSHOT_CREATED"
},
{
label: "Workflow Object Task Updated",
value: "WORKFLOW_OBJECT_TASK_UPDATED"
},
{
label: "Workflow Object Updated",
value: "WORKFLOW_OBJECT_UPDATED"
},
{
label: "Workflow Objects Connection Created",
value: "WORKFLOW_OBJECTS_CONNECTION_CREATED"
},
{
label: "Workflow Objects External Connection Created",
value: "WORKFLOW_OBJECTS_EXTERNAL_CONNECTION_CREATED"
},
{
label: "Workflow Objects External Connection Group Created",
value: "WORKFLOW_OBJECTS_EXTERNAL_CONNECTION_GROUP_CREATED"
},
{
label: "Workflow Unarchived",
value: "WORKFLOW_UNARCHIVED"
},
{
label: "Workflow Updated",
value: "WORKFLOW_UPDATED"
}
];
export default webhookFilters;

View File

View File

@@ -0,0 +1,18 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import triggers from './triggers';
export default defineApp({
name: 'Flowers Software',
key: 'flowers-software',
iconUrl: '{BASE_URL}/apps/flowers-software/assets/favicon.svg',
authDocUrl: 'https://automatisch.io/docs/apps/flowers-software/connection',
supportsConnections: true,
baseUrl: 'https://flowers-software.com',
apiBaseUrl: 'https://webapp.flowers-software.com/api',
primaryColor: '02AFC7',
beforeRequest: [addAuthHeader],
auth,
triggers,
});

View File

@@ -0,0 +1,3 @@
import newActivity from './new-activity';
export default [newActivity];

View File

@@ -0,0 +1,54 @@
import isEmpty from 'lodash/isEmpty';
import defineTrigger from '../../../../helpers/define-trigger';
import webhookFilters from '../../common/webhook-filters';
export default defineTrigger({
name: 'New activity',
key: 'newActivity',
type: 'webhook',
description: 'Triggers when a new activity occurs.',
arguments: [
{
label: 'Activity type',
key: 'filters',
type: 'dropdown' as const,
required: true,
description: 'Pick an activity type to receive events for.',
variables: false,
options: webhookFilters,
},
],
async testRun($) {
if (!isEmpty($.lastExecutionStep?.dataOut)) {
$.pushTriggerItem({
raw: $.lastExecutionStep.dataOut,
meta: {
internalId: '',
}
});
}
},
async registerHook($) {
const payload = {
name: $.flow.id,
type: 'POST',
url: $.webhookUrl,
filters: [$.step.parameters.filters]
};
const { data } = await $.http.post(
`/v2/public/api/webhooks`,
payload
);
await $.flow.setRemoteWebhookId(data.id);
},
async unregisterHook($) {
await $.http.delete(
`/v2/public/api/webhooks/${$.flow.remoteWebhookId}`
);
},
});

View File

@@ -0,0 +1,13 @@
import { Knex } from 'knex';
export async function up(knex: Knex): Promise<void> {
return knex.schema.table('flows', (table) => {
table.string('remote_webhook_id');
});
}
export async function down(knex: Knex): Promise<void> {
return knex.schema.table('flows', (table) => {
table.dropColumn('remote_webhook_id');
});
}

View File

@@ -37,6 +37,7 @@ const globalVariable = async (
testRun = false,
} = options;
const isTrigger = step?.isTrigger;
const lastInternalId = testRun ? undefined : await flow?.lastInternalId();
const nextStep = await step?.getNextStep();
@@ -123,6 +124,18 @@ const globalVariable = async (
$.webhookUrl = webhookUrl;
}
if (isTrigger && (await step.getTriggerCommand()).type === 'webhook') {
$.flow.setRemoteWebhookId = async (remoteWebhookId) => {
await flow.$query().patchAndFetch({
remoteWebhookId,
});
$.flow.remoteWebhookId = remoteWebhookId;
};
$.flow.remoteWebhookId = flow.remoteWebhookId;
}
const lastInternalIds =
testRun || (flow && step.isAction) ? [] : await flow?.lastInternalIds(2000);

View File

@@ -13,6 +13,7 @@ class Flow extends Base {
active: boolean;
steps: Step[];
published_at: string;
remoteWebhookId: string;
executions?: Execution[];
static tableName = 'flows';
@@ -25,6 +26,7 @@ class Flow extends Base {
id: { type: 'string', format: 'uuid' },
name: { type: 'string', minLength: 1 },
userId: { type: 'string', format: 'uuid' },
remoteWebhookId: { type: 'string' },
active: { type: 'boolean' },
},
};

View File

@@ -76,6 +76,7 @@ export interface IFlow {
steps: IStep[];
createdAt: string;
updatedAt: string;
remoteWebhookId: string;
lastInternalId: () => Promise<string>;
}
@@ -279,6 +280,8 @@ export type IGlobalVariable = {
id: string;
lastInternalId: string;
isAlreadyProcessed?: (internalId: string) => boolean;
remoteWebhookId?: string;
setRemoteWebhookId?: (remoteWebhookId: string) => Promise<void>;
};
step?: {
id: string;

View File

@@ -116,7 +116,7 @@ export default function AddAppConnection(
sx={{ mt: 1, fontWeight: 500, wordBreak: 'break-all' }}
>
{error.message}
<pre>{JSON.stringify(error.details, null, 2)}</pre>
{error.details && <pre>{JSON.stringify(error.details, null, 2)}</pre>}
</Alert>
)}