Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
db084d12e4 | ||
![]() |
1c76b02c78 | ||
![]() |
bc67e9c4c4 |
21
packages/backend/src/apps/firefly-iii/assets/favicon.svg
Normal file
21
packages/backend/src/apps/firefly-iii/assets/favicon.svg
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!--
|
||||||
|
- maskable-icon.svg
|
||||||
|
- Copyright (c) 2022 james@firefly-iii.org
|
||||||
|
-
|
||||||
|
- This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
-
|
||||||
|
- This program is free software: you can redistribute it and/or modify
|
||||||
|
- it under the terms of the GNU Affero General Public License as
|
||||||
|
- published by the Free Software Foundation, either version 3 of the
|
||||||
|
- License, or (at your option) any later version.
|
||||||
|
-
|
||||||
|
- This program is distributed in the hope that it will be useful,
|
||||||
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
- GNU Affero General Public License for more details.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the GNU Affero General Public License
|
||||||
|
- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<svg height="377.95276" width="377.95276" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h377.95276v377.95276h-377.95276z" fill="#cd5029" stroke-width="1.96129"/><g transform="matrix(.77452773 0 0 .77452773 21.636074 21.374655)"><path d="m140.49013 78.646381 2.249 53.017999s-40.103 29.566-45.538 68l-16.001 1.231s-11.539 2.564-11.539 14.103v37.18s3.846 11.538 12.82 11.538l16.487-.319s8 30.5 36.5 50.5v25.5s-2 8.5 15.5 11 40.75 2.25 44.5-1.5 3.75-4.5 3.75-9c0 0 21.25 5 60.25 0v5s3.5 7 29 7 33-3 37.5-12v-25s37.009-36.264 35.75-91.75c-1.083-47.75-15.901-64.299-35.806-82.96-22.67-21.254-69.944-31.165-117.944-25.353.001-.001-24.341-43.937999-67.478-36.187999z" fill="#fff"/><circle cx="135.46912" cy="214.39638" fill="#cd5029" r="9.5"/><path d="m360.08113 190.51238s-18.218-8.742-40.662 3.996c0 0-26.711-8.987-40.99 2.593-14.828 12.025-16.299 26.115-15.525 42.785 0 0 12.837-43.915 45.252-32.571 0 0-22.947 40.43 12.761 47.508 0 0 8.436-.05 15.401-4.256 6.644-4.011 11.842-11.433 9.711-24.814 0 0-4.348-13.336-15.569-21.42 0 0 11.042-7.806 31.988-2.209z" fill="#cd5029"/><path d="m320.19013 213.01938s-16.689 31.461 5.607 29.767c0 0 11.838-5.656 4.887-17.127-7.147-11.796-10.494-12.64-10.494-12.64z" fill="#fff"/></g><path d="m188.97638 175.70052s4.01698 13.60604-3.69586 21.52748c-7.713 7.92145-6.8792 16.6767-3.75227 20.84588 3.12692 4.16917 2.91831 7.29593.41674 9.58905-2.50141 2.29312-4.58608 3.96073-6.04523.20846-1.45916-3.75228-3.12676-3.75228-3.75228-5.62834-.62552-1.87605-1.87622-5.21142-1.87622-5.21142s-3.96072 6.25384-6.46229 10.00611c-2.50157 3.75228-2.50141 9.58922-.83381 12.71598 1.66761 3.12676 1.04226 6.87903-.20845 12.09046-1.2507 5.21143.4169 13.13288 6.25369 16.2598 5.83678 3.12692 12.92459 5.62833 16.05135 8.5468s10.42301 5.62833 19.80362 3.54382c9.3806-2.0845 21.26294-11.67355 23.34744-18.13585 0 0 5.41988-6.04523 4.37763-13.96668s-4.79469-7.71316-6.4623-13.75839c-1.6676-6.04523 3.60854-4.55469-.8338-14.93382 0 0-1.98012-4.94005-9.50352-8.49899-4.83404-2.28661-1.54469-12.63061-10.09149-23.05347s-16.73295-12.14688-16.73295-12.14688z" fill="#ffa284" stroke-width=".162598"/></svg>
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,20 @@
|
|||||||
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
|
export default async function generateAuthUrl($) {
|
||||||
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
|
(field) => field.key == 'oAuthRedirectUrl'
|
||||||
|
);
|
||||||
|
const redirectUri = oauthRedirectUrlField.value;
|
||||||
|
const searchParams = new URLSearchParams({
|
||||||
|
client_id: $.auth.data.clientId,
|
||||||
|
redirect_uri: redirectUri,
|
||||||
|
response_type: 'code',
|
||||||
|
});
|
||||||
|
const instanceUrl = $.auth.data.instanceUrl;
|
||||||
|
|
||||||
|
const url = `${instanceUrl}/oauth/authorize?${searchParams.toString()}`;
|
||||||
|
|
||||||
|
await $.auth.set({
|
||||||
|
url,
|
||||||
|
});
|
||||||
|
}
|
58
packages/backend/src/apps/firefly-iii/auth/index.js
Normal file
58
packages/backend/src/apps/firefly-iii/auth/index.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import generateAuthUrl from './generate-auth-url.js';
|
||||||
|
import verifyCredentials from './verify-credentials.js';
|
||||||
|
import refreshToken from './refresh-token.js';
|
||||||
|
import isStillVerified from './is-still-verified.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
key: 'oAuthRedirectUrl',
|
||||||
|
label: 'OAuth Redirect URL',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
readOnly: true,
|
||||||
|
value: '{WEB_APP_URL}/app/firefly-iii/connections/add',
|
||||||
|
placeholder: null,
|
||||||
|
description: '',
|
||||||
|
clickToCopy: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instanceUrl',
|
||||||
|
label: 'Instance URL',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: '',
|
||||||
|
clickToCopy: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'clientId',
|
||||||
|
label: 'Client ID',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: null,
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'clientSecret',
|
||||||
|
label: 'Client Secret',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: null,
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
generateAuthUrl,
|
||||||
|
verifyCredentials,
|
||||||
|
isStillVerified,
|
||||||
|
refreshToken,
|
||||||
|
};
|
@@ -0,0 +1,8 @@
|
|||||||
|
import getCurrentUser from '../common/get-current-user.js';
|
||||||
|
|
||||||
|
const isStillVerified = async ($) => {
|
||||||
|
const currentUser = await getCurrentUser($);
|
||||||
|
return !!currentUser.attributes.email;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default isStillVerified;
|
20
packages/backend/src/apps/firefly-iii/auth/refresh-token.js
Normal file
20
packages/backend/src/apps/firefly-iii/auth/refresh-token.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { URLSearchParams } from 'node:url';
|
||||||
|
|
||||||
|
const refreshToken = async ($) => {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
client_id: $.auth.data.clientId,
|
||||||
|
client_secret: $.auth.data.clientSecret,
|
||||||
|
grant_type: 'refresh_token',
|
||||||
|
refresh_token: $.auth.data.refreshToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data } = await $.http.post(`/oauth/token`, params.toString());
|
||||||
|
|
||||||
|
await $.auth.set({
|
||||||
|
accessToken: data.access_token,
|
||||||
|
expiresIn: data.expires_in,
|
||||||
|
tokenType: data.token_type,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default refreshToken;
|
@@ -0,0 +1,35 @@
|
|||||||
|
import getCurrentUser from '../common/get-current-user.js';
|
||||||
|
|
||||||
|
const verifyCredentials = async ($) => {
|
||||||
|
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||||
|
(field) => field.key == 'oAuthRedirectUrl'
|
||||||
|
);
|
||||||
|
const redirectUri = oauthRedirectUrlField.value;
|
||||||
|
const { data } = await $.http.post('/oauth/token', {
|
||||||
|
client_id: $.auth.data.clientId,
|
||||||
|
client_secret: $.auth.data.clientSecret,
|
||||||
|
code: $.auth.data.code,
|
||||||
|
grant_type: 'authorization_code',
|
||||||
|
redirect_uri: redirectUri,
|
||||||
|
});
|
||||||
|
|
||||||
|
await $.auth.set({
|
||||||
|
accessToken: data.access_token,
|
||||||
|
tokenType: data.token_type,
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentUser = await getCurrentUser($);
|
||||||
|
|
||||||
|
await $.auth.set({
|
||||||
|
clientId: $.auth.data.clientId,
|
||||||
|
clientSecret: $.auth.data.clientSecret,
|
||||||
|
scope: $.auth.data.scope,
|
||||||
|
idToken: data.id_token,
|
||||||
|
expiresIn: data.expires_in,
|
||||||
|
refreshToken: data.refresh_token,
|
||||||
|
resourceName: currentUser.resourceName,
|
||||||
|
screenName: currentUser.attributes.email,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default verifyCredentials;
|
@@ -0,0 +1,9 @@
|
|||||||
|
const addAuthHeader = ($, requestConfig) => {
|
||||||
|
if ($.auth.data?.accessToken) {
|
||||||
|
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default addAuthHeader;
|
@@ -0,0 +1,10 @@
|
|||||||
|
const getCurrentUser = async ($) => {
|
||||||
|
const { data: currentUser } = await $.http.get('/api/v1/about/user', {
|
||||||
|
Headers: {
|
||||||
|
Accept: 'application/vnd.api+json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return currentUser.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getCurrentUser;
|
10
packages/backend/src/apps/firefly-iii/common/set-base-url.js
Normal file
10
packages/backend/src/apps/firefly-iii/common/set-base-url.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const setBaseUrl = ($, requestConfig) => {
|
||||||
|
const instanceUrl = $.auth.data.instanceUrl;
|
||||||
|
if (instanceUrl) {
|
||||||
|
requestConfig.baseURL = instanceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default setBaseUrl;
|
19
packages/backend/src/apps/firefly-iii/index.js
Normal file
19
packages/backend/src/apps/firefly-iii/index.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import defineApp from '../../helpers/define-app.js';
|
||||||
|
import addAuthHeader from './common/add-auth-header.js';
|
||||||
|
import auth from './auth/index.js';
|
||||||
|
import setBaseUrl from './common/set-base-url.js';
|
||||||
|
import triggers from './triggers/index.js';
|
||||||
|
|
||||||
|
export default defineApp({
|
||||||
|
name: 'Firefly III',
|
||||||
|
key: 'firefly-iii',
|
||||||
|
baseUrl: '',
|
||||||
|
apiBaseUrl: '',
|
||||||
|
iconUrl: '{BASE_URL}/apps/firefly-iii/assets/favicon.svg',
|
||||||
|
authDocUrl: '{DOCS_URL}/apps/firefly-iii/connection',
|
||||||
|
primaryColor: 'CD5029',
|
||||||
|
supportsConnections: true,
|
||||||
|
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||||
|
auth,
|
||||||
|
triggers,
|
||||||
|
});
|
4
packages/backend/src/apps/firefly-iii/triggers/index.js
Normal file
4
packages/backend/src/apps/firefly-iii/triggers/index.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import transactionCreated from './transaction-created/index.js';
|
||||||
|
import transactionUpdated from './transaction-updated/index.js';
|
||||||
|
|
||||||
|
export default [transactionCreated, transactionUpdated];
|
@@ -0,0 +1,89 @@
|
|||||||
|
import Crypto from 'crypto';
|
||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'Transaction created',
|
||||||
|
key: 'transactionCreated',
|
||||||
|
type: 'webhook',
|
||||||
|
description: 'Triggers when a new transaction is created.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Title of the webhook',
|
||||||
|
key: 'title',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const dataItem = {
|
||||||
|
raw: $.request.body,
|
||||||
|
meta: {
|
||||||
|
internalId: Crypto.randomUUID(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
async testRun($) {
|
||||||
|
const { data: transactions } = await $.http.get(`/api/v1/transactions`);
|
||||||
|
|
||||||
|
if (transactions.data.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: transaction } = await $.http.get(
|
||||||
|
`/api/v1/transactions/${transactions.data[0].id}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const lastTransaction = transaction.data;
|
||||||
|
|
||||||
|
if (!lastTransaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const computedWebhookEvent = {
|
||||||
|
url: '',
|
||||||
|
uuid: Crypto.randomUUID(),
|
||||||
|
content: lastTransaction.attributes,
|
||||||
|
trigger: 'STORE_TRANSACTION',
|
||||||
|
user_id: lastTransaction.attributes.user,
|
||||||
|
version: '',
|
||||||
|
response: 'TRANSACTIONS',
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataItem = {
|
||||||
|
raw: computedWebhookEvent,
|
||||||
|
meta: {
|
||||||
|
internalId: computedWebhookEvent.uuid,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
async registerHook($) {
|
||||||
|
const title = $.step.parameters.title;
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
active: true,
|
||||||
|
title: title || `Flow ID: ${$.flow.id}`,
|
||||||
|
trigger: 'STORE_TRANSACTION',
|
||||||
|
response: 'TRANSACTIONS',
|
||||||
|
delivery: 'JSON',
|
||||||
|
url: $.webhookUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await $.http.post('/api/v1/webhooks', payload);
|
||||||
|
const id = response.data.data.id;
|
||||||
|
|
||||||
|
await $.flow.setRemoteWebhookId(id);
|
||||||
|
},
|
||||||
|
|
||||||
|
async unregisterHook($) {
|
||||||
|
await $.http.delete(`/api/v1/webhooks/${$.flow.remoteWebhookId}`);
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,89 @@
|
|||||||
|
import Crypto from 'crypto';
|
||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'Transaction updated',
|
||||||
|
key: 'transactionUpdated',
|
||||||
|
type: 'webhook',
|
||||||
|
description: 'Triggers when a transaction is updated.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Title of the webhook',
|
||||||
|
key: 'title',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const dataItem = {
|
||||||
|
raw: $.request.body,
|
||||||
|
meta: {
|
||||||
|
internalId: Crypto.randomUUID(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
async testRun($) {
|
||||||
|
const { data: transactions } = await $.http.get(`/api/v1/transactions`);
|
||||||
|
|
||||||
|
if (transactions.data.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: transaction } = await $.http.get(
|
||||||
|
`/api/v1/transactions/${transactions.data[0].id}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const lastTransaction = transaction.data;
|
||||||
|
|
||||||
|
if (!lastTransaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const computedWebhookEvent = {
|
||||||
|
url: '',
|
||||||
|
uuid: Crypto.randomUUID(),
|
||||||
|
content: lastTransaction.attributes,
|
||||||
|
trigger: 'UPDATE_TRANSACTION',
|
||||||
|
user_id: lastTransaction.attributes.user,
|
||||||
|
version: '',
|
||||||
|
response: 'TRANSACTIONS',
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataItem = {
|
||||||
|
raw: computedWebhookEvent,
|
||||||
|
meta: {
|
||||||
|
internalId: computedWebhookEvent.uuid,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
async registerHook($) {
|
||||||
|
const title = $.step.parameters.title;
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
active: true,
|
||||||
|
title: title || `Flow ID: ${$.flow.id}`,
|
||||||
|
trigger: 'UPDATE_TRANSACTION',
|
||||||
|
response: 'TRANSACTIONS',
|
||||||
|
delivery: 'JSON',
|
||||||
|
url: $.webhookUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await $.http.post('/api/v1/webhooks', payload);
|
||||||
|
const id = response.data.data.id;
|
||||||
|
|
||||||
|
await $.flow.setRemoteWebhookId(id);
|
||||||
|
},
|
||||||
|
|
||||||
|
async unregisterHook($) {
|
||||||
|
await $.http.delete(`/api/v1/webhooks/${$.flow.remoteWebhookId}`);
|
||||||
|
},
|
||||||
|
});
|
@@ -1,262 +0,0 @@
|
|||||||
import defineAction from '../../../../helpers/define-action.js';
|
|
||||||
import isEmpty from 'lodash/isEmpty.js';
|
|
||||||
import omitBy from 'lodash/omitBy.js';
|
|
||||||
|
|
||||||
export default defineAction({
|
|
||||||
name: 'Create post',
|
|
||||||
key: 'createPost',
|
|
||||||
description: 'Creates a new post.',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
label: 'Title',
|
|
||||||
key: 'title',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Content',
|
|
||||||
key: 'content',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Excerpt',
|
|
||||||
key: 'excerpt',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Password',
|
|
||||||
key: 'password',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description: 'A password to protect access to the content and excerpt.',
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Author',
|
|
||||||
key: 'author',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
source: {
|
|
||||||
type: 'query',
|
|
||||||
name: 'getDynamicData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: 'listUsers',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Featured Media',
|
|
||||||
key: 'featuredMedia',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
source: {
|
|
||||||
type: 'query',
|
|
||||||
name: 'getDynamicData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: 'listMedia',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Comment Status',
|
|
||||||
key: 'commentStatus',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'Open', value: 'open' },
|
|
||||||
{ label: 'Closed', value: 'closed' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Ping Status',
|
|
||||||
key: 'pingStatus',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'Open', value: 'open' },
|
|
||||||
{ label: 'Closed', value: 'closed' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Format',
|
|
||||||
key: 'format',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'Standard', value: 'standard' },
|
|
||||||
{ label: 'Aside', value: 'aside' },
|
|
||||||
{ label: 'Chat', value: 'chat' },
|
|
||||||
{ label: 'Gallery', value: 'gallery' },
|
|
||||||
{ label: 'Link', value: 'link' },
|
|
||||||
{ label: 'Image', value: 'image' },
|
|
||||||
{ label: 'Quote', value: 'quote' },
|
|
||||||
{ label: 'Status', value: 'status' },
|
|
||||||
{ label: 'Status', value: 'status' },
|
|
||||||
{ label: 'Video', value: 'video' },
|
|
||||||
{ label: 'Audio', value: 'audio' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Sticky',
|
|
||||||
key: 'sticky',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
options: [
|
|
||||||
{ label: 'False', value: 'false' },
|
|
||||||
{ label: 'True', value: 'true' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Categories',
|
|
||||||
key: 'categoryIds',
|
|
||||||
type: 'dynamic',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
label: 'Category',
|
|
||||||
key: 'categoryId',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
variables: true,
|
|
||||||
source: {
|
|
||||||
type: 'query',
|
|
||||||
name: 'getDynamicData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: 'listCategories',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Tags',
|
|
||||||
key: 'tagIds',
|
|
||||||
type: 'dynamic',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
label: 'Tag',
|
|
||||||
key: 'tagId',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
variables: true,
|
|
||||||
source: {
|
|
||||||
type: 'query',
|
|
||||||
name: 'getDynamicData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: 'listTags',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Status',
|
|
||||||
key: 'status',
|
|
||||||
type: 'dropdown',
|
|
||||||
required: false,
|
|
||||||
description: '',
|
|
||||||
variables: true,
|
|
||||||
source: {
|
|
||||||
type: 'query',
|
|
||||||
name: 'getDynamicData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'key',
|
|
||||||
value: 'listStatuses',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Date',
|
|
||||||
key: 'date',
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
description: "Post publish date in the site's timezone",
|
|
||||||
variables: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const {
|
|
||||||
title,
|
|
||||||
content,
|
|
||||||
excerpt,
|
|
||||||
password,
|
|
||||||
author,
|
|
||||||
featuredMedia,
|
|
||||||
commentStatus,
|
|
||||||
pingStatus,
|
|
||||||
format,
|
|
||||||
sticky,
|
|
||||||
categoryIds,
|
|
||||||
tagIds,
|
|
||||||
status,
|
|
||||||
date,
|
|
||||||
} = $.step.parameters;
|
|
||||||
|
|
||||||
const allCategoryIds = categoryIds
|
|
||||||
?.map((categoryId) => categoryId.categoryId)
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
const allTagIds = tagIds?.map((tagId) => tagId.tagId).filter(Boolean);
|
|
||||||
|
|
||||||
let body = {
|
|
||||||
title,
|
|
||||||
content,
|
|
||||||
excerpt,
|
|
||||||
password,
|
|
||||||
author,
|
|
||||||
featured_media: featuredMedia,
|
|
||||||
comment_status: commentStatus,
|
|
||||||
ping_status: pingStatus,
|
|
||||||
format,
|
|
||||||
sticky,
|
|
||||||
categories: allCategoryIds,
|
|
||||||
tags: allTagIds,
|
|
||||||
status,
|
|
||||||
date,
|
|
||||||
};
|
|
||||||
|
|
||||||
body = omitBy(body, isEmpty);
|
|
||||||
|
|
||||||
const response = await $.http.post('?rest_route=/wp/v2/posts', body);
|
|
||||||
|
|
||||||
$.setActionItem({ raw: response.data });
|
|
||||||
},
|
|
||||||
});
|
|
@@ -1,3 +0,0 @@
|
|||||||
import createPost from './create-post/index.js';
|
|
||||||
|
|
||||||
export default [createPost];
|
|
@@ -1,7 +1,3 @@
|
|||||||
import listCategories from './list-categories/index.js';
|
|
||||||
import listMedia from './list-media/index.js';
|
|
||||||
import listStatuses from './list-statuses/index.js';
|
import listStatuses from './list-statuses/index.js';
|
||||||
import listTags from './list-tags/index.js';
|
|
||||||
import listUsers from './list-users/index.js';
|
|
||||||
|
|
||||||
export default [listCategories, listMedia, listStatuses, listTags, listUsers];
|
export default [listStatuses];
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
export default {
|
|
||||||
name: 'List categories',
|
|
||||||
key: 'listCategories',
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const categories = {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
page: 1,
|
|
||||||
per_page: 100,
|
|
||||||
order: 'desc',
|
|
||||||
};
|
|
||||||
|
|
||||||
let totalPages = 1;
|
|
||||||
do {
|
|
||||||
const { data, headers } = await $.http.get(
|
|
||||||
'?rest_route=/wp/v2/categories',
|
|
||||||
{
|
|
||||||
params,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
params.page = params.page + 1;
|
|
||||||
totalPages = Number(headers['x-wp-totalpages']);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
for (const category of data) {
|
|
||||||
categories.data.push({
|
|
||||||
value: category.id,
|
|
||||||
name: category.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (params.page <= totalPages);
|
|
||||||
|
|
||||||
return categories;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,37 +0,0 @@
|
|||||||
export default {
|
|
||||||
name: 'List media',
|
|
||||||
key: 'listMedia',
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const media = {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
page: 1,
|
|
||||||
per_page: 100,
|
|
||||||
order: 'desc',
|
|
||||||
};
|
|
||||||
|
|
||||||
let totalPages = 1;
|
|
||||||
do {
|
|
||||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/media', {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
|
|
||||||
params.page = params.page + 1;
|
|
||||||
totalPages = Number(headers['x-wp-totalpages']);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
for (const medium of data) {
|
|
||||||
media.data.push({
|
|
||||||
value: medium.id,
|
|
||||||
name: medium.slug,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (params.page <= totalPages);
|
|
||||||
|
|
||||||
return media;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,37 +0,0 @@
|
|||||||
export default {
|
|
||||||
name: 'List tags',
|
|
||||||
key: 'listTags',
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const tags = {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
page: 1,
|
|
||||||
per_page: 100,
|
|
||||||
order: 'desc',
|
|
||||||
};
|
|
||||||
|
|
||||||
let totalPages = 1;
|
|
||||||
do {
|
|
||||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/tags', {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
|
|
||||||
params.page = params.page + 1;
|
|
||||||
totalPages = Number(headers['x-wp-totalpages']);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
for (const tag of data) {
|
|
||||||
tags.data.push({
|
|
||||||
value: tag.id,
|
|
||||||
name: tag.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (params.page <= totalPages);
|
|
||||||
|
|
||||||
return tags;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,37 +0,0 @@
|
|||||||
export default {
|
|
||||||
name: 'List users',
|
|
||||||
key: 'listUsers',
|
|
||||||
|
|
||||||
async run($) {
|
|
||||||
const users = {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
const params = {
|
|
||||||
page: 1,
|
|
||||||
per_page: 100,
|
|
||||||
order: 'desc',
|
|
||||||
};
|
|
||||||
|
|
||||||
let totalPages = 1;
|
|
||||||
do {
|
|
||||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/users', {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
|
|
||||||
params.page = params.page + 1;
|
|
||||||
totalPages = Number(headers['x-wp-totalpages']);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
for (const user of data) {
|
|
||||||
users.data.push({
|
|
||||||
value: user.id,
|
|
||||||
name: user.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (params.page <= totalPages);
|
|
||||||
|
|
||||||
return users;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -4,7 +4,6 @@ import setBaseUrl from './common/set-base-url.js';
|
|||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
import triggers from './triggers/index.js';
|
import triggers from './triggers/index.js';
|
||||||
import dynamicData from './dynamic-data/index.js';
|
import dynamicData from './dynamic-data/index.js';
|
||||||
import actions from './actions/index.js';
|
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'WordPress',
|
name: 'WordPress',
|
||||||
@@ -19,5 +18,4 @@ export default defineApp({
|
|||||||
auth,
|
auth,
|
||||||
triggers,
|
triggers,
|
||||||
dynamicData,
|
dynamicData,
|
||||||
actions,
|
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
export async function up(knex) {
|
|
||||||
return knex.schema.alterTable('datastore', (table) => {
|
|
||||||
table.text('value').alter();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex) {
|
|
||||||
return knex.schema.alterTable('datastore', (table) => {
|
|
||||||
table.string('value').alter();
|
|
||||||
});
|
|
||||||
}
|
|
@@ -122,6 +122,15 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/filter/connection' },
|
{ text: 'Connection', link: '/apps/filter/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'Firefly III',
|
||||||
|
collapsible: true,
|
||||||
|
collapsed: true,
|
||||||
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/firefly-iii/triggers' },
|
||||||
|
{ text: 'Connection', link: '/apps/firefly-iii/connection' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'Flickr',
|
text: 'Flickr',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
@@ -518,7 +527,6 @@ export default defineConfig({
|
|||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
{ text: 'Actions', link: '/apps/wordpress/actions' },
|
|
||||||
{ text: 'Triggers', link: '/apps/wordpress/triggers' },
|
{ text: 'Triggers', link: '/apps/wordpress/triggers' },
|
||||||
{ text: 'Connection', link: '/apps/wordpress/connection' },
|
{ text: 'Connection', link: '/apps/wordpress/connection' },
|
||||||
],
|
],
|
||||||
|
17
packages/docs/pages/apps/firefly-iii/connection.md
Normal file
17
packages/docs/pages/apps/firefly-iii/connection.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Firefly III
|
||||||
|
|
||||||
|
:::info
|
||||||
|
This page explains the steps you need to follow to set up the Firefly III
|
||||||
|
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||||
|
:::
|
||||||
|
|
||||||
|
1. Go to your dashboard.
|
||||||
|
2. Click on the **Options** tab on the left, and click on the **Profile** button.
|
||||||
|
3. Go to **Oauth** tab and click on the **Create New Client** button.
|
||||||
|
4. Enter a name for your project.
|
||||||
|
5. Copy **OAuth Redirect URL** from Automatisch to **Redirect URL** field, and click on the **Create** button.
|
||||||
|
6. Copy the **Client ID** value from the following popup to the `Client ID` field on Automatisch.
|
||||||
|
7. Copy the **Secret** value from the following popup to the `Client Secret` field on Automatisch.
|
||||||
|
8. Fill **Instance URL** with your Firefly III instance url.
|
||||||
|
9. Click **Submit** button on Automatisch.
|
||||||
|
10. Congrats! Start using your new Firefly III connection within the flows.
|
14
packages/docs/pages/apps/firefly-iii/triggers.md
Normal file
14
packages/docs/pages/apps/firefly-iii/triggers.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/firefly-iii.svg
|
||||||
|
items:
|
||||||
|
- name: Transaction created
|
||||||
|
desc: Triggers when a new transaction is created.
|
||||||
|
- name: Transaction updated
|
||||||
|
desc: Triggers when a transaction is updated.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -1,12 +0,0 @@
|
|||||||
---
|
|
||||||
favicon: /favicons/wordpress.svg
|
|
||||||
items:
|
|
||||||
- name: Create post
|
|
||||||
desc: Creates a new post.
|
|
||||||
---
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import CustomListing from '../../components/CustomListing.vue'
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<CustomListing />
|
|
@@ -12,6 +12,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Disqus](/apps/disqus/triggers)
|
- [Disqus](/apps/disqus/triggers)
|
||||||
- [Dropbox](/apps/dropbox/actions)
|
- [Dropbox](/apps/dropbox/actions)
|
||||||
- [Filter](/apps/filter/actions)
|
- [Filter](/apps/filter/actions)
|
||||||
|
- [Firefly III](/apps/firefly-iii/triggers)
|
||||||
- [Flickr](/apps/flickr/triggers)
|
- [Flickr](/apps/flickr/triggers)
|
||||||
- [Formatter](/apps/formatter/actions)
|
- [Formatter](/apps/formatter/actions)
|
||||||
- [Ghost](/apps/ghost/triggers)
|
- [Ghost](/apps/ghost/triggers)
|
||||||
|
21
packages/docs/pages/public/favicons/firefly-iii.svg
Normal file
21
packages/docs/pages/public/favicons/firefly-iii.svg
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!--
|
||||||
|
- maskable-icon.svg
|
||||||
|
- Copyright (c) 2022 james@firefly-iii.org
|
||||||
|
-
|
||||||
|
- This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
-
|
||||||
|
- This program is free software: you can redistribute it and/or modify
|
||||||
|
- it under the terms of the GNU Affero General Public License as
|
||||||
|
- published by the Free Software Foundation, either version 3 of the
|
||||||
|
- License, or (at your option) any later version.
|
||||||
|
-
|
||||||
|
- This program is distributed in the hope that it will be useful,
|
||||||
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
- GNU Affero General Public License for more details.
|
||||||
|
-
|
||||||
|
- You should have received a copy of the GNU Affero General Public License
|
||||||
|
- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<svg height="377.95276" width="377.95276" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h377.95276v377.95276h-377.95276z" fill="#cd5029" stroke-width="1.96129"/><g transform="matrix(.77452773 0 0 .77452773 21.636074 21.374655)"><path d="m140.49013 78.646381 2.249 53.017999s-40.103 29.566-45.538 68l-16.001 1.231s-11.539 2.564-11.539 14.103v37.18s3.846 11.538 12.82 11.538l16.487-.319s8 30.5 36.5 50.5v25.5s-2 8.5 15.5 11 40.75 2.25 44.5-1.5 3.75-4.5 3.75-9c0 0 21.25 5 60.25 0v5s3.5 7 29 7 33-3 37.5-12v-25s37.009-36.264 35.75-91.75c-1.083-47.75-15.901-64.299-35.806-82.96-22.67-21.254-69.944-31.165-117.944-25.353.001-.001-24.341-43.937999-67.478-36.187999z" fill="#fff"/><circle cx="135.46912" cy="214.39638" fill="#cd5029" r="9.5"/><path d="m360.08113 190.51238s-18.218-8.742-40.662 3.996c0 0-26.711-8.987-40.99 2.593-14.828 12.025-16.299 26.115-15.525 42.785 0 0 12.837-43.915 45.252-32.571 0 0-22.947 40.43 12.761 47.508 0 0 8.436-.05 15.401-4.256 6.644-4.011 11.842-11.433 9.711-24.814 0 0-4.348-13.336-15.569-21.42 0 0 11.042-7.806 31.988-2.209z" fill="#cd5029"/><path d="m320.19013 213.01938s-16.689 31.461 5.607 29.767c0 0 11.838-5.656 4.887-17.127-7.147-11.796-10.494-12.64-10.494-12.64z" fill="#fff"/></g><path d="m188.97638 175.70052s4.01698 13.60604-3.69586 21.52748c-7.713 7.92145-6.8792 16.6767-3.75227 20.84588 3.12692 4.16917 2.91831 7.29593.41674 9.58905-2.50141 2.29312-4.58608 3.96073-6.04523.20846-1.45916-3.75228-3.12676-3.75228-3.75228-5.62834-.62552-1.87605-1.87622-5.21142-1.87622-5.21142s-3.96072 6.25384-6.46229 10.00611c-2.50157 3.75228-2.50141 9.58922-.83381 12.71598 1.66761 3.12676 1.04226 6.87903-.20845 12.09046-1.2507 5.21143.4169 13.13288 6.25369 16.2598 5.83678 3.12692 12.92459 5.62833 16.05135 8.5468s10.42301 5.62833 19.80362 3.54382c9.3806-2.0845 21.26294-11.67355 23.34744-18.13585 0 0 5.41988-6.04523 4.37763-13.96668s-4.79469-7.71316-6.4623-13.75839c-1.6676-6.04523 3.60854-4.55469-.8338-14.93382 0 0-1.98012-4.94005-9.50352-8.49899-4.83404-2.28661-1.54469-12.63061-10.09149-23.05347s-16.73295-12.14688-16.73295-12.14688z" fill="#ffa284" stroke-width=".162598"/></svg>
|
After Width: | Height: | Size: 2.9 KiB |
Reference in New Issue
Block a user