Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/apiframe/apiframe.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/brand_dev/brand_dev.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/contentdrips/contentdrips.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/cursor/cursor.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/emailchef/emailchef.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/fynk/fynk.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/helicone/helicone.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/iplocate/iplocate.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/magicalapi/magicalapi.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
1 change: 1 addition & 0 deletions components/neetokb/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIMIT = 100;
60 changes: 57 additions & 3 deletions components/neetokb/neetokb.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,65 @@
import { axios } from "@pipedream/platform";
import { LIMIT } from "./common/constants.mjs";

export default {
type: "app",
app: "neetokb",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_apiUrl() {
return `https://${this.$auth.organization_name}.neetokb.com/api/v1`;
},
_getHeaders() {
return {
"Content-Type": "application/json",
"X-Api-Key": `${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._apiUrl()}/${path}`,
headers: this._getHeaders(),
...opts,
});
},
listArticles(args = {}) {
return this._makeRequest({
path: "articles",
...args,
});
},
async *paginate({
fn, params = {}, maxResults = null, ...opts
}) {
let hasMore = false;
let count = 0;
let page = 0;

do {
params.page_number = ++page;
params.page_size = LIMIT;
const {
articles,
pagination: {
total_pages: tPages, current_page_number: cPage,
},
} = await fn({
params,
...opts,
});
for (const d of articles) {
yield d;

if (maxResults && ++count === maxResults) {
return count;
}
}

hasMore = cPage < tPages;

} while (hasMore);
},
},
};
5 changes: 4 additions & 1 deletion components/neetokb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/neetokb",
"version": "0.0.2",
"version": "0.1.0",
"description": "Pipedream neetoKB Components",
"main": "neetokb.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import neetokb from "../../neetokb.app.mjs";
import sampleEmit from "./test-event.mjs";

export default {
key: "neetokb-new-published-article",
name: "New Published Article",
description: "Emit new event when a new article is published. [See the documentation](https://neetokb-apis.mintlify.app/api-reference/articles/list-articles).",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
neetokb,
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
},
methods: {
_getPublishedIds() {
return this.db.get("publishedIds") || [];
},
_setPublishedIds(publishedIds) {
this.db.set("publishedIds", publishedIds);
},
async emitEvent(maxResults = false) {
const publishedIds = this._getPublishedIds();
const response = this.neetokb.paginate({
fn: this.neetokb.listArticles,
params: {
status: "published",
},
});

const responseArray = [];
for await (const item of response) {
responseArray.push(item);
}

let newArticles = responseArray.filter((article) => !publishedIds.includes(article.id));

if (maxResults && newArticles.length > maxResults) {
newArticles = newArticles.slice(0, maxResults);
}

for (const article of newArticles.reverse()) {
const ts = new Date();
this.$emit(article, {
id: `${article.id}-${ts}`,
summary: `New Published Article: ${article.title}`,
ts,
});
}
this._setPublishedIds(responseArray.map((article) => article.id));
},
},
hooks: {
async deploy() {
await this.emitEvent(25);
},
},
async run() {
await this.emitEvent();
},
sampleEmit,
};
12 changes: 12 additions & 0 deletions components/neetokb/sources/new-published-article/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
"id": "0c8d8101-62cb-4227-9dd0-953fbf88e74d",
"slug": "article-title",
"title": "Article Title",
"state": "published",
"unique_views_count": 0,
"is_archived": false,
"category": {
"id": "ea665eb3-23a1-4cbd-9dff-0a585d6c8c53",
"name": "Getting Started"
}
}
2 changes: 1 addition & 1 deletion components/relationcity/relationcity.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/shortpen/shortpen.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/socket/socket.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/turbosmtp/turbosmtp.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/validemail/validemail.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/veryfi/veryfi.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading