Compare commits
4 Commits
executions
...
AUT-366
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2846dd2bdd | ||
![]() |
2fceaf2cf4 | ||
![]() |
d82b50fcdb | ||
![]() |
ab6e49bf4f |
4
packages/backend/src/apps/trello/dynamic-data/index.ts
Normal file
4
packages/backend/src/apps/trello/dynamic-data/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import listBoardLists from './list-board-lists';
|
||||||
|
import listBoards from './list-boards';
|
||||||
|
|
||||||
|
export default [listBoardLists, listBoards];
|
@@ -0,0 +1,33 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List board lists',
|
||||||
|
key: 'listBoardLists',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const boards: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const boardId = $.step.parameters.boardId;
|
||||||
|
|
||||||
|
if (!boardId) {
|
||||||
|
return { data: [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/boards/${boardId}/lists`);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
for (const list of data) {
|
||||||
|
boards.data.push({
|
||||||
|
value: list.id,
|
||||||
|
name: list.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boards;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,29 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List boards',
|
||||||
|
key: 'listBoards',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const boards: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/members/me/boards`);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
for (const board of data) {
|
||||||
|
boards.data.push({
|
||||||
|
value: board.id,
|
||||||
|
name: board.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { data: [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
return boards;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,6 +1,8 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
import defineApp from '../../helpers/define-app';
|
||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
|
import triggers from './triggers';
|
||||||
|
import dynamicData from './dynamic-data';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Trello',
|
name: 'Trello',
|
||||||
@@ -13,4 +15,6 @@ export default defineApp({
|
|||||||
primaryColor: '0079bf',
|
primaryColor: '0079bf',
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
triggers,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
3
packages/backend/src/apps/trello/triggers/index.ts
Normal file
3
packages/backend/src/apps/trello/triggers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import newCards from './new-cards';
|
||||||
|
|
||||||
|
export default [newCards];
|
123
packages/backend/src/apps/trello/triggers/new-cards/index.ts
Normal file
123
packages/backend/src/apps/trello/triggers/new-cards/index.ts
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New cards',
|
||||||
|
key: 'newCards',
|
||||||
|
pollInterval: 15,
|
||||||
|
description: 'Triggers upon the addition of a new card.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Board',
|
||||||
|
key: 'boardId',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description:
|
||||||
|
'Selecting a board initiates the trigger for newly added cards on that board.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listBoards',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'List',
|
||||||
|
key: 'listId',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
dependsOn: ['parameters.boardId'],
|
||||||
|
description: 'Requires to opt for a board.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listBoardLists',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.boardId',
|
||||||
|
value: '{parameters.boardId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Filter',
|
||||||
|
key: 'filter',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description: 'Default is open.',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'open',
|
||||||
|
value: 'open',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'closed',
|
||||||
|
value: 'closed',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'all',
|
||||||
|
value: 'all',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const { boardId, listId, filter } = $.step.parameters;
|
||||||
|
|
||||||
|
if (boardId && !listId) {
|
||||||
|
const cardFilter = filter || 'open';
|
||||||
|
|
||||||
|
const { data } = await $.http.get(
|
||||||
|
`/1/boards/${boardId}/cards/${cardFilter}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
for (const card of data) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: card,
|
||||||
|
meta: {
|
||||||
|
internalId: card.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (listId) {
|
||||||
|
const { data } = await $.http.get(`1/lists/${listId}/cards`);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
for (const card of data) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: card,
|
||||||
|
meta: {
|
||||||
|
internalId: card.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const { data } = await $.http.get(`/1/members/me/cards`);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
for (const card of data) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: card,
|
||||||
|
meta: {
|
||||||
|
internalId: card.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -1,13 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('executions', (table) => {
|
|
||||||
table.index('flow_id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('executions', (table) => {
|
|
||||||
table.dropIndex('flow_id');
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('executions', (table) => {
|
|
||||||
table.index('updated_at');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('executions', (table) => {
|
|
||||||
table.dropIndex('updated_at');
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,277 +0,0 @@
|
|||||||
import request, { Test } from 'supertest';
|
|
||||||
import app from '../../app';
|
|
||||||
import appConfig from '../../config/app';
|
|
||||||
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
|
|
||||||
import { createRole } from '../../../test/factories/role';
|
|
||||||
import { createPermission } from '../../../test/factories/permission';
|
|
||||||
import { createUser } from '../../../test/factories/user';
|
|
||||||
import { createFlow } from '../../../test/factories/flow';
|
|
||||||
import { createStep } from '../../../test/factories/step';
|
|
||||||
import { createExecution } from '../../../test/factories/execution';
|
|
||||||
import { createExecutionStep } from '../../../test/factories/execution-step';
|
|
||||||
import {
|
|
||||||
IRole,
|
|
||||||
IUser,
|
|
||||||
IExecution,
|
|
||||||
IFlow,
|
|
||||||
IExecutionStep,
|
|
||||||
IStep,
|
|
||||||
} from '@automatisch/types';
|
|
||||||
|
|
||||||
describe('graphQL getExecutions query', () => {
|
|
||||||
const query = `
|
|
||||||
query {
|
|
||||||
getExecutions(limit: 10, offset: 0) {
|
|
||||||
pageInfo {
|
|
||||||
currentPage
|
|
||||||
totalPages
|
|
||||||
}
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
id
|
|
||||||
testRun
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
status
|
|
||||||
flow {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
active
|
|
||||||
steps {
|
|
||||||
iconUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const invalidToken = 'invalid-token';
|
|
||||||
|
|
||||||
describe('with unauthenticated user', () => {
|
|
||||||
it('should throw not authorized error', async () => {
|
|
||||||
const response = await request(app)
|
|
||||||
.post('/graphql')
|
|
||||||
.set('Authorization', invalidToken)
|
|
||||||
.send({ query })
|
|
||||||
.expect(200);
|
|
||||||
|
|
||||||
expect(response.body.errors).toBeDefined();
|
|
||||||
expect(response.body.errors[0].message).toEqual('Not Authorised!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('with authenticated user', () => {
|
|
||||||
describe('and without permissions', () => {
|
|
||||||
it('should throw not authorized error', async () => {
|
|
||||||
const userWithoutPermissions = await createUser();
|
|
||||||
const token = createAuthTokenByUserId(userWithoutPermissions.id);
|
|
||||||
|
|
||||||
const response = await request(app)
|
|
||||||
.post('/graphql')
|
|
||||||
.set('Authorization', token)
|
|
||||||
.send({ query })
|
|
||||||
.expect(200);
|
|
||||||
|
|
||||||
expect(response.body.errors).toBeDefined();
|
|
||||||
expect(response.body.errors[0].message).toEqual('Not authorized!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('and with correct permission and isCreator condition', () => {
|
|
||||||
let role: IRole,
|
|
||||||
currentUser: IUser,
|
|
||||||
anotherUser: IUser,
|
|
||||||
token: string,
|
|
||||||
requestObject: Test,
|
|
||||||
flowOne: IFlow,
|
|
||||||
stepOneForFlowOne: IStep,
|
|
||||||
stepTwoForFlowOne: IStep,
|
|
||||||
executionOne: IExecution,
|
|
||||||
executionStepOneForExecutionOne: IExecutionStep,
|
|
||||||
executionStepTwoForExecutionOne: IExecutionStep,
|
|
||||||
flowTwo: IFlow,
|
|
||||||
stepOneForFlowTwo: IStep,
|
|
||||||
stepTwoForFlowTwo: IStep,
|
|
||||||
executionTwo: IExecution,
|
|
||||||
executionStepOneForExecutionTwo: IExecutionStep,
|
|
||||||
executionStepTwoForExecutionTwo: IExecutionStep;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
role = await createRole({
|
|
||||||
key: 'sample',
|
|
||||||
name: 'sample',
|
|
||||||
});
|
|
||||||
|
|
||||||
await createPermission({
|
|
||||||
action: 'read',
|
|
||||||
subject: 'Execution',
|
|
||||||
roleId: role.id,
|
|
||||||
conditions: ['isCreator'],
|
|
||||||
});
|
|
||||||
|
|
||||||
currentUser = await createUser({
|
|
||||||
roleId: role.id,
|
|
||||||
fullName: 'Current User',
|
|
||||||
});
|
|
||||||
|
|
||||||
anotherUser = await createUser();
|
|
||||||
|
|
||||||
token = createAuthTokenByUserId(currentUser.id);
|
|
||||||
|
|
||||||
flowOne = await createFlow({
|
|
||||||
userId: currentUser.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
stepOneForFlowOne = await createStep({
|
|
||||||
flowId: flowOne.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
stepTwoForFlowOne = await createStep({
|
|
||||||
flowId: flowOne.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
executionOne = await createExecution({
|
|
||||||
flowId: flowOne.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
executionStepOneForExecutionOne = await createExecutionStep({
|
|
||||||
executionId: executionOne.id,
|
|
||||||
stepId: stepOneForFlowOne.id,
|
|
||||||
status: 'success',
|
|
||||||
});
|
|
||||||
|
|
||||||
executionStepTwoForExecutionOne = await createExecutionStep({
|
|
||||||
executionId: executionOne.id,
|
|
||||||
stepId: stepTwoForFlowOne.id,
|
|
||||||
status: 'success',
|
|
||||||
});
|
|
||||||
|
|
||||||
flowTwo = await createFlow({
|
|
||||||
userId: currentUser.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
stepOneForFlowTwo = await createStep({
|
|
||||||
flowId: flowTwo.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
stepTwoForFlowTwo = await createStep({
|
|
||||||
flowId: flowTwo.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
executionTwo = await createExecution({
|
|
||||||
flowId: flowTwo.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
executionStepOneForExecutionTwo = await createExecutionStep({
|
|
||||||
executionId: executionTwo.id,
|
|
||||||
stepId: stepOneForFlowTwo.id,
|
|
||||||
status: 'success',
|
|
||||||
});
|
|
||||||
|
|
||||||
executionStepTwoForExecutionTwo = await createExecutionStep({
|
|
||||||
executionId: executionTwo.id,
|
|
||||||
stepId: stepTwoForFlowTwo.id,
|
|
||||||
status: 'failure',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return executions data of the current user', async () => {
|
|
||||||
const response = await request(app)
|
|
||||||
.post('/graphql')
|
|
||||||
.set('Authorization', token)
|
|
||||||
.send({ query })
|
|
||||||
.expect(200);
|
|
||||||
|
|
||||||
const expectedResponsePayload = {
|
|
||||||
data: {
|
|
||||||
getExecutions: {
|
|
||||||
edges: [
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
createdAt: (flowTwo.createdAt as Date).getTime().toString(),
|
|
||||||
flow: {
|
|
||||||
active: flowTwo.active,
|
|
||||||
id: flowTwo.id,
|
|
||||||
name: flowTwo.name,
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
iconUrl: `${appConfig.baseUrl}/apps/${stepTwoForFlowTwo.appKey}/assets/favicon.svg`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
iconUrl: `${appConfig.baseUrl}/apps/${stepTwoForFlowTwo.appKey}/assets/favicon.svg`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
id: executionTwo.id,
|
|
||||||
status: 'failure',
|
|
||||||
testRun: executionTwo.testRun,
|
|
||||||
updatedAt: (executionTwo.updatedAt as Date)
|
|
||||||
.getTime()
|
|
||||||
.toString(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
createdAt: (flowOne.createdAt as Date).getTime().toString(),
|
|
||||||
flow: {
|
|
||||||
active: flowOne.active,
|
|
||||||
id: flowOne.id,
|
|
||||||
name: flowOne.name,
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
iconUrl: `${appConfig.baseUrl}/apps/${stepOneForFlowOne.appKey}/assets/favicon.svg`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
iconUrl: `${appConfig.baseUrl}/apps/${stepTwoForFlowOne.appKey}/assets/favicon.svg`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
id: executionOne.id,
|
|
||||||
status: 'success',
|
|
||||||
testRun: executionOne.testRun,
|
|
||||||
updatedAt: (executionOne.updatedAt as Date)
|
|
||||||
.getTime()
|
|
||||||
.toString(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
pageInfo: { currentPage: 1, totalPages: 1 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(response.body).toEqual(expectedResponsePayload);
|
|
||||||
});
|
|
||||||
|
|
||||||
// it('should not return users data with password', async () => {
|
|
||||||
// const query = `
|
|
||||||
// query {
|
|
||||||
// getUsers(limit: 10, offset: 0) {
|
|
||||||
// pageInfo {
|
|
||||||
// currentPage
|
|
||||||
// totalPages
|
|
||||||
// }
|
|
||||||
// totalCount
|
|
||||||
// edges {
|
|
||||||
// node {
|
|
||||||
// id
|
|
||||||
// fullName
|
|
||||||
// password
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `;
|
|
||||||
|
|
||||||
// const response = await requestObject.send({ query }).expect(400);
|
|
||||||
|
|
||||||
// expect(response.body.errors).toBeDefined();
|
|
||||||
// expect(response.body.errors[0].message).toEqual(
|
|
||||||
// 'Cannot query field "password" on type "User".'
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,22 +1,11 @@
|
|||||||
import { raw } from 'objection';
|
import { raw } from 'objection';
|
||||||
import { DateTime } from 'luxon';
|
|
||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
import Execution from '../../models/execution';
|
import Execution from '../../models/execution';
|
||||||
import paginate from '../../helpers/pagination';
|
import paginate from '../../helpers/pagination';
|
||||||
|
|
||||||
type Filters = {
|
|
||||||
flowId?: string;
|
|
||||||
status?: string;
|
|
||||||
updatedAt?: {
|
|
||||||
from?: string;
|
|
||||||
to?: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
limit: number;
|
limit: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
filters?: Filters;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getExecutions = async (
|
const getExecutions = async (
|
||||||
@@ -26,13 +15,9 @@ const getExecutions = async (
|
|||||||
) => {
|
) => {
|
||||||
const conditions = context.currentUser.can('read', 'Execution');
|
const conditions = context.currentUser.can('read', 'Execution');
|
||||||
|
|
||||||
const filters = params.filters;
|
|
||||||
|
|
||||||
const userExecutions = context.currentUser.$relatedQuery('executions');
|
const userExecutions = context.currentUser.$relatedQuery('executions');
|
||||||
const allExecutions = Execution.query();
|
const allExecutions = Execution.query();
|
||||||
const executionBaseQuery = conditions.isCreator
|
const executionBaseQuery = conditions.isCreator ? userExecutions : allExecutions;
|
||||||
? userExecutions
|
|
||||||
: allExecutions;
|
|
||||||
|
|
||||||
const selectStatusStatement = `
|
const selectStatusStatement = `
|
||||||
case
|
case
|
||||||
@@ -47,44 +32,16 @@ const getExecutions = async (
|
|||||||
.clone()
|
.clone()
|
||||||
.joinRelated('executionSteps as execution_steps')
|
.joinRelated('executionSteps as execution_steps')
|
||||||
.select('executions.*', raw(selectStatusStatement))
|
.select('executions.*', raw(selectStatusStatement))
|
||||||
.groupBy('executions.id')
|
|
||||||
.orderBy('updated_at', 'desc');
|
|
||||||
|
|
||||||
const computedExecutions = Execution.query()
|
|
||||||
.with('executions', executions)
|
|
||||||
.withSoftDeleted()
|
.withSoftDeleted()
|
||||||
.withGraphFetched({
|
.withGraphFetched({
|
||||||
flow: {
|
flow: {
|
||||||
steps: true,
|
steps: true,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
.groupBy('executions.id')
|
||||||
|
.orderBy('updated_at', 'desc');
|
||||||
|
|
||||||
if (filters?.flowId) {
|
return paginate(executions, params.limit, params.offset);
|
||||||
computedExecutions.where('executions.flow_id', filters.flowId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters?.status) {
|
|
||||||
computedExecutions.where('executions.status', filters.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters?.updatedAt) {
|
|
||||||
const updatedAtFilter = filters.updatedAt;
|
|
||||||
if (updatedAtFilter.from) {
|
|
||||||
const isoFromDateTime = DateTime.fromMillis(
|
|
||||||
parseInt(updatedAtFilter.from, 10)
|
|
||||||
).toISO();
|
|
||||||
computedExecutions.where('executions.updated_at', '>=', isoFromDateTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updatedAtFilter.to) {
|
|
||||||
const isoToDateTime = DateTime.fromMillis(
|
|
||||||
parseInt(updatedAtFilter.to, 10)
|
|
||||||
).toISO();
|
|
||||||
computedExecutions.where('executions.updated_at', '<=', isoToDateTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return paginate(computedExecutions, params.limit, params.offset);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default getExecutions;
|
export default getExecutions;
|
||||||
|
@@ -20,11 +20,7 @@ type Query {
|
|||||||
): FlowConnection
|
): FlowConnection
|
||||||
getStepWithTestExecutions(stepId: String!): [Step]
|
getStepWithTestExecutions(stepId: String!): [Step]
|
||||||
getExecution(executionId: String!): Execution
|
getExecution(executionId: String!): Execution
|
||||||
getExecutions(
|
getExecutions(limit: Int!, offset: Int!): ExecutionConnection
|
||||||
limit: Int!
|
|
||||||
offset: Int!
|
|
||||||
filters: ExecutionFiltersInput
|
|
||||||
): ExecutionConnection
|
|
||||||
getExecutionSteps(
|
getExecutionSteps(
|
||||||
executionId: String!
|
executionId: String!
|
||||||
limit: Int!
|
limit: Int!
|
||||||
@@ -799,17 +795,6 @@ type Notification {
|
|||||||
description: String
|
description: String
|
||||||
}
|
}
|
||||||
|
|
||||||
input ExecutionUpdatedAtFilterInput {
|
|
||||||
from: String
|
|
||||||
to: String
|
|
||||||
}
|
|
||||||
|
|
||||||
input ExecutionFiltersInput {
|
|
||||||
flowId: String
|
|
||||||
updatedAt: ExecutionUpdatedAtFilterInput
|
|
||||||
status: String
|
|
||||||
}
|
|
||||||
|
|
||||||
schema {
|
schema {
|
||||||
query: Query
|
query: Query
|
||||||
mutation: Mutation
|
mutation: Mutation
|
||||||
|
@@ -275,7 +275,10 @@ class User extends Base {
|
|||||||
async $beforeUpdate(opt: ModelOptions, queryContext: QueryContext) {
|
async $beforeUpdate(opt: ModelOptions, queryContext: QueryContext) {
|
||||||
await super.$beforeUpdate(opt, queryContext);
|
await super.$beforeUpdate(opt, queryContext);
|
||||||
|
|
||||||
this.email = this.email.toLowerCase();
|
if (this.email) {
|
||||||
|
this.email = this.email.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
await this.generateHash();
|
await this.generateHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,24 @@
|
|||||||
import Permission from '../../src/models/permission';
|
import { IPermission } from '@automatisch/types';
|
||||||
import { createRole } from './role';
|
import { createRole } from './role';
|
||||||
|
|
||||||
export const createPermission = async (params: Partial<Permission> = {}) => {
|
type PermissionParams = {
|
||||||
params.roleId = params?.roleId || (await createRole()).id;
|
roleId?: string;
|
||||||
params.action = params?.action || 'read';
|
action?: string;
|
||||||
params.subject = params?.subject || 'User';
|
subject?: string;
|
||||||
params.conditions = params?.conditions || ['isCreator'];
|
};
|
||||||
|
|
||||||
|
export const createPermission = async (
|
||||||
|
params: PermissionParams = {}
|
||||||
|
): Promise<IPermission> => {
|
||||||
|
const permissionData = {
|
||||||
|
roleId: params?.roleId || (await createRole()).id,
|
||||||
|
action: params?.action || 'read',
|
||||||
|
subject: params?.subject || 'User',
|
||||||
|
};
|
||||||
|
|
||||||
const [permission] = await global.knex
|
const [permission] = await global.knex
|
||||||
.table('permissions')
|
.table('permissions')
|
||||||
.insert(params)
|
.insert(permissionData)
|
||||||
.returning('*');
|
.returning('*');
|
||||||
|
|
||||||
return permission;
|
return permission;
|
||||||
|
@@ -13,9 +13,7 @@ export const createStep = async (params: Partial<Step> = {}) => {
|
|||||||
.first();
|
.first();
|
||||||
|
|
||||||
params.position = params?.position || (lastStep?.position || 0) + 1;
|
params.position = params?.position || (lastStep?.position || 0) + 1;
|
||||||
params.status = params?.status || 'completed';
|
params.status = params?.status || 'incomplete';
|
||||||
params.appKey =
|
|
||||||
params?.appKey || (params.type === 'action' ? 'webhook' : 'deepl');
|
|
||||||
|
|
||||||
const [step] = await global.knex.table('steps').insert(params).returning('*');
|
const [step] = await global.knex.table('steps').insert(params).returning('*');
|
||||||
|
|
||||||
|
@@ -377,7 +377,10 @@ export default defineConfig({
|
|||||||
text: 'Trello',
|
text: 'Trello',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [{ text: 'Connection', link: '/apps/trello/connection' }],
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/trello/triggers' },
|
||||||
|
{ text: 'Connection', link: '/apps/trello/connection' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Twilio',
|
text: 'Twilio',
|
||||||
|
12
packages/docs/pages/apps/trello/triggers.md
Normal file
12
packages/docs/pages/apps/trello/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/trello.svg
|
||||||
|
items:
|
||||||
|
- name: New cards
|
||||||
|
desc: Triggers upon the addition of a new card.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -39,6 +39,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Stripe](/apps/stripe/triggers)
|
- [Stripe](/apps/stripe/triggers)
|
||||||
- [Telegram](/apps/telegram-bot/actions)
|
- [Telegram](/apps/telegram-bot/actions)
|
||||||
- [Todoist](/apps/todoist/triggers)
|
- [Todoist](/apps/todoist/triggers)
|
||||||
|
- [Trello](/apps/trello/triggers)
|
||||||
- [Twilio](/apps/twilio/triggers)
|
- [Twilio](/apps/twilio/triggers)
|
||||||
- [Twitter](/apps/twitter/triggers)
|
- [Twitter](/apps/twitter/triggers)
|
||||||
- [Typeform](/apps/typeform/triggers)
|
- [Typeform](/apps/typeform/triggers)
|
||||||
|
@@ -13,9 +13,9 @@ export class ApplicationsModal extends BasePage {
|
|||||||
constructor (page) {
|
constructor (page) {
|
||||||
super(page);
|
super(page);
|
||||||
this.modal = page.getByTestId('add-app-connection-dialog');
|
this.modal = page.getByTestId('add-app-connection-dialog');
|
||||||
this.searchInput = page.getByTestId('search-for-app-text-field');
|
this.searchInput = this.modal.getByTestId('search-for-app-text-field');
|
||||||
this.appListItem = page.getByTestId('app-list-item');
|
this.appListItem = this.modal.getByTestId('app-list-item');
|
||||||
this.appLoader = page.getByTestId('search-for-app-loader');
|
this.appLoader = this.modal.getByTestId('search-for-app-loader');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,7 +9,7 @@ test('Github OAuth integration', async ({ page, applicationsPage }) => {
|
|||||||
await page.waitForURL('/apps');
|
await page.waitForURL('/apps');
|
||||||
}
|
}
|
||||||
const connectionModal = await applicationsPage.openAddConnectionModal();
|
const connectionModal = await applicationsPage.openAddConnectionModal();
|
||||||
expect(connectionModal.modal).toBeVisible();
|
await expect(connectionModal.modal).toBeVisible();
|
||||||
return await connectionModal.selectLink('github');
|
return await connectionModal.selectLink('github');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -18,7 +18,7 @@ test('Github OAuth integration', async ({ page, applicationsPage }) => {
|
|||||||
'Ensure the github connection modal is visible',
|
'Ensure the github connection modal is visible',
|
||||||
async () => {
|
async () => {
|
||||||
const connectionModal = githubConnectionPage.addConnectionModal;
|
const connectionModal = githubConnectionPage.addConnectionModal;
|
||||||
expect(connectionModal.modal).toBeVisible();
|
await expect(connectionModal.modal).toBeVisible();
|
||||||
return connectionModal;
|
return connectionModal;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -35,9 +35,9 @@ test('Github OAuth integration', async ({ page, applicationsPage }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await test.step('Ensure github popup is not a 404', async () => {
|
await test.step('Ensure github popup is not a 404', async () => {
|
||||||
// expect(githubPopup).toBeVisible();
|
// await expect(githubPopup).toBeVisible();
|
||||||
const title = await githubPopup.title();
|
const title = await githubPopup.title();
|
||||||
expect(title).not.toMatch(/^Page not found/);
|
await expect(title).not.toMatch(/^Page not found/);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Skip these in CI
|
/* Skip these in CI
|
||||||
|
8
packages/types/index.d.ts
vendored
8
packages/types/index.d.ts
vendored
@@ -51,8 +51,8 @@ export interface IExecution {
|
|||||||
testRun: boolean;
|
testRun: boolean;
|
||||||
status: 'success' | 'failure';
|
status: 'success' | 'failure';
|
||||||
executionSteps: IExecutionStep[];
|
executionSteps: IExecutionStep[];
|
||||||
updatedAt: string | Date;
|
updatedAt: string;
|
||||||
createdAt: string | Date;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IStep {
|
export interface IStep {
|
||||||
@@ -83,8 +83,8 @@ export interface IFlow {
|
|||||||
active: boolean;
|
active: boolean;
|
||||||
status: 'paused' | 'published' | 'draft';
|
status: 'paused' | 'published' | 'draft';
|
||||||
steps: IStep[];
|
steps: IStep[];
|
||||||
createdAt: string | Date;
|
createdAt: string;
|
||||||
updatedAt: string | Date;
|
updatedAt: string;
|
||||||
remoteWebhookId: string;
|
remoteWebhookId: string;
|
||||||
lastInternalId: () => Promise<string>;
|
lastInternalId: () => Promise<string>;
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,12 @@ export default function AddNewAppConnection(
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={true} onClose={onClose} maxWidth="sm" fullWidth>
|
<Dialog
|
||||||
|
open={true}
|
||||||
|
onClose={onClose}
|
||||||
|
maxWidth="sm"
|
||||||
|
fullWidth
|
||||||
|
data-test="add-app-connection-dialog">
|
||||||
<DialogTitle>{formatMessage('apps.addNewAppConnection')}</DialogTitle>
|
<DialogTitle>{formatMessage('apps.addNewAppConnection')}</DialogTitle>
|
||||||
|
|
||||||
<Box px={3}>
|
<Box px={3}>
|
||||||
|
Reference in New Issue
Block a user