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
8 changes: 5 additions & 3 deletions components/miro_custom_app/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@pipedream/miro_custom_app",
"version": "0.0.3",
"version": "0.1.0",
"description": "Pipedream Miro Developer App Components",
"main": "dist/app/miro_custom_app.app.mjs",
"main": "miro_custom_app.app.mjs",
"keywords": [
"pipedream",
"miro_custom_app"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/miro_custom_app",
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
}
}
42 changes: 42 additions & 0 deletions components/miro_custom_app/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import miro from "../../miro_custom_app.app.mjs";
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";

export default {
props: {
miro,
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
},
methods: {
async *paginate({
resourceFn, args = {},
}) {
args = {
...args,
params: {
...args.params,
limit: 50,
},
};
let total = 0;
do {
const {
data, cursor,
} = await resourceFn(args);
for (const item of data) {
yield item;
}
total = data?.length;
args.params.cursor = cursor;
} while (total === args.params.limit);
},
generateMeta() {
throw new Error("generateMeta is not implemented");
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import common from "../common/base.mjs";

export default {
...common,
key: "miro_custom_app-item-position-changed",
name: "Item Position Changed",
description: "Emit new event when an item's position changes in a Miro Custom App.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
...common.props,
teamId: {
propDefinition: [
common.props.miro,
"teamId",
],
},
boardId: {
propDefinition: [
common.props.miro,
"boardId",
({ teamId }) => ({
teamId,
}),
],
},
},
methods: {
...common.methods,
_getPositions() {
return this.db.get("positions") || {};
},
_setPositions(positions) {
this.db.set("positions", positions);
},
generateMeta(item) {
const ts = Date.parse(item.modifiedAt);
return {
id: `${item.id}-${ts}`,
summary: `Item ${item.id} position changed`,
ts,
};
},
},
async run() {
const positions = this._getPositions();
const newPositions = {};
const items = this.paginate({
resourceFn: this.miro.listItems,
args: {
boardId: this.boardId,
},
});
for await (const item of items) {
const position = JSON.stringify(item.position);
if (positions[item.id] && positions[item.id] !== position) {
const meta = this.generateMeta(item);
this.$emit(item, meta);
}
newPositions[item.id] = position;
}

this._setPositions(newPositions);
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

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