feat(rss): add new items in feed trigger
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "~4.16.1",
|
||||
"express-graphql": "^0.12.0",
|
||||
"fast-xml-parser": "^4.0.11",
|
||||
"flickr-sdk": "3.10.0",
|
||||
"googleapis": "89.0.0",
|
||||
"graphql-middleware": "^6.1.15",
|
||||
|
6
packages/backend/src/apps/rss/assets/favicon.svg
Normal file
6
packages/backend/src/apps/rss/assets/favicon.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
aria-label="RSS" role="img"
|
||||
viewBox="0 0 512 512"><rect
|
||||
width="512" height="512"
|
||||
rx="15%"
|
||||
fill="#f80"/><circle cx="145" cy="367" r="35" fill="#fff"/><path fill="none" stroke="#fff" stroke-width="60" d="M109 241c89 0 162 73 162 162m114 0c0-152-124-276-276-276"/></svg>
|
After Width: | Height: | Size: 307 B |
0
packages/backend/src/apps/rss/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/rss/index.d.ts
vendored
Normal file
13
packages/backend/src/apps/rss/index.ts
Normal file
13
packages/backend/src/apps/rss/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
|
||||
export default defineApp({
|
||||
name: 'RSS',
|
||||
key: 'rss',
|
||||
iconUrl: '{BASE_URL}/apps/rss/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/connections/rss',
|
||||
supportsConnections: false,
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: 'ff8800',
|
||||
beforeRequest: [],
|
||||
});
|
@@ -0,0 +1,33 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import newItemsInFeed from './new-items-in-feed';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New items in feed',
|
||||
key: 'newItemsInFeed',
|
||||
description: 'Triggers on new RSS feed items.',
|
||||
pollInterval: 15,
|
||||
substeps: [
|
||||
{
|
||||
key: 'chooseTrigger',
|
||||
name: 'Set up trigger',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Feed URL',
|
||||
key: 'feedUrl',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Paste your publicly accessible RSS URL here.',
|
||||
variables: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'testStep',
|
||||
name: 'Test trigger',
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
await newItemsInFeed($);
|
||||
},
|
||||
});
|
@@ -0,0 +1,24 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { XMLParser } from 'fast-xml-parser';[]
|
||||
|
||||
const newItemsInFeed = async ($: IGlobalVariable) => {
|
||||
const { data } = await $.http.get($.step.parameters.feedUrl as string);
|
||||
const parser = new XMLParser();
|
||||
const parsedData = parser.parse(data);
|
||||
|
||||
for (const item of parsedData.rss.channel.item) {
|
||||
if ($.flow.isAlreadyProcessed(item.guid))
|
||||
return;
|
||||
|
||||
const dataItem = {
|
||||
raw: item,
|
||||
meta: {
|
||||
internalId: item.guid
|
||||
}
|
||||
}
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
}
|
||||
};
|
||||
|
||||
export default newItemsInFeed;
|
@@ -155,13 +155,14 @@ enum AvailableAppsEnumType {
|
||||
github
|
||||
gitlab
|
||||
postgresql
|
||||
rss
|
||||
scheduler
|
||||
slack
|
||||
smtp
|
||||
twilio
|
||||
twitch
|
||||
twitter
|
||||
typeform
|
||||
slack
|
||||
scheduler
|
||||
}
|
||||
|
||||
type Connection {
|
||||
|
3
packages/docs/pages/connections/rss.md
Normal file
3
packages/docs/pages/connections/rss.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# RSS
|
||||
|
||||
RSS is a built-in app shipped with Automatisch, and it doesn't need to talk with any other external service to run. So there are no additional steps to use the RSS app.
|
@@ -88,6 +88,7 @@ export default function AddAppConnection(props: AddAppConnectionProps): React.Re
|
||||
<Dialog open={true} onClose={onClose} data-test="add-app-connection-dialog">
|
||||
<DialogTitle>{hasConnection ? formatMessage('app.reconnectConnection') : formatMessage('app.addConnection')}</DialogTitle>
|
||||
|
||||
{authDocUrl && (
|
||||
<Alert severity="info" sx={{ fontWeight: 300 }}>
|
||||
{formatMessage(
|
||||
'addAppConnection.callToDocs',
|
||||
@@ -97,6 +98,7 @@ export default function AddAppConnection(props: AddAppConnectionProps): React.Re
|
||||
}
|
||||
)}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{errorMessage && (
|
||||
<Alert severity="error" sx={{ mt: 1, fontWeight: 500 }}>
|
||||
|
12
yarn.lock
12
yarn.lock
@@ -9302,6 +9302,13 @@ fast-text-encoding@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz#ec02ac8e01ab8a319af182dae2681213cfe9ce53"
|
||||
integrity sha512-dtm4QZH9nZtcDt8qJiOH9fcQd1NAgi+K1O2DbE6GG1PPCK/BWfOH3idCTRQ4ImXRUOyopDEgDEnVEE7Y/2Wrig==
|
||||
|
||||
fast-xml-parser@^4.0.11:
|
||||
version "4.0.11"
|
||||
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.0.11.tgz#42332a9aca544520631c8919e6ea871c0185a985"
|
||||
integrity sha512-4aUg3aNRR/WjQAcpceODG1C3x3lFANXRo8+1biqfieHmg9pyMt7qB4lQV/Ta6sJCTbA5vfD8fnA8S54JATiFUA==
|
||||
dependencies:
|
||||
strnum "^1.0.5"
|
||||
|
||||
fastest-levenshtein@^1.0.7:
|
||||
version "1.0.12"
|
||||
resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2"
|
||||
@@ -17155,6 +17162,11 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
|
||||
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
|
||||
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
|
||||
|
||||
strnum@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db"
|
||||
integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==
|
||||
|
||||
strong-log-transformer@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/strong-log-transformer/-/strong-log-transformer-2.1.0.tgz#0f5ed78d325e0421ac6f90f7f10e691d6ae3ae10"
|
||||
|
Reference in New Issue
Block a user