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
3 changes: 0 additions & 3 deletions components/modeck/.gitignore

This file was deleted.

63 changes: 63 additions & 0 deletions components/modeck/actions/create-render/create-render.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { ConfigurationError } from "@pipedream/platform";
import { parseArray } from "../../common/utils.mjs";
import modeck from "../../modeck.app.mjs";

export default {
key: "modeck-create-render",
name: "Create Render",
version: "0.0.1",
description: "Create a new edit with the data supplied. [See the documentation](https://modeck.io/docs#modeckapi)",
type: "action",
props: {
modeck,
deck: {
propDefinition: [
modeck,
"deck",
],
},
name: {
type: "string",
label: "Name",
description: "The name of this edit.",
},
editId: {
type: "string",
label: "Edit Id",
description: "The identifier of this edit.",
optional: true,
},
notificationEmail: {
type: "string",
label: "Notification Email",
description: "The email that will be notified on render finishing.",
optional: true,
},
mogrtSeq: {
type: "string[]",
label: "MogrtSeq",
description: "An array of mogrtSeq objects.",
},
},
async run({ $ }) {
const {
modeck,
mogrtSeq,
...data
} = this;

const response = await modeck.createRender({
$,
data: {
...data,
mogrtSeq: parseArray(mogrtSeq),
},
});

if (!response.success) throw new ConfigurationError(response.info);

$.export("$summary", `A new edit with Id: ${response.editId} was successfully created!`);
return response;
},
};

13 changes: 0 additions & 13 deletions components/modeck/app/modeck.app.ts

This file was deleted.

11 changes: 11 additions & 0 deletions components/modeck/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const parseArray = (array) => {
if (Array.isArray(array)) {
return array.map((item) => {
if (typeof item != "object") {
item = JSON.parse(item);
}
return item;
});
}
return JSON.parse(array);
};
54 changes: 54 additions & 0 deletions components/modeck/modeck.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "modeck",
propDefinitions: {
deck: {
type: "string",
label: "Deck Name",
description: "The deck name you want to edit.",
async options() {
const response = await this.listDecks();
return response.decks?.map(({ name }) => name) || [];
},
},
},
methods: {
_apiUrl() {
return "https://api.modeck.io";
},
_makeRequest({
$ = this, data = {}, path, ...opts
}) {
const config = {
url: `${this._apiUrl()}/${path}`,
data: {
apiKey: this.$auth.api_key,
...data,
},
...opts,
};
return axios($, config);
},
createRender(args = {}) {
return this._makeRequest({
method: "POST",
path: "render",
...args,
});
},
listDecks(args = {}) {
return this._makeRequest({
path: "listdecks",
...args,
});
},
listRenders(args = {}) {
return this._makeRequest({
path: "listrenders",
...args,
});
},
},
};
10 changes: 6 additions & 4 deletions components/modeck/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@pipedream/modeck",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream MoDeck Components",
"main": "dist/app/modeck.app.mjs",
"main": "modeck.app.mjs",
"keywords": [
"pipedream",
"modeck"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/modeck",
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
}
}
}
82 changes: 82 additions & 0 deletions components/modeck/sources/render-complete/render-complete.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import modeck from "../../modeck.app.mjs";
import sampleEmit from "./test-event.mjs";

export default {
key: "modeck-render-complete",
name: "New Render Completed",
version: "0.0.1",
description: "Emit new event when a render is completed.",
type: "source",
dedupe: "unique",
props: {
modeck,
db: "$.service.db",
timer: {
label: "Polling interval",
description: "Pipedream will poll the MoDeck on this schedule",
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
deck: {
propDefinition: [
modeck,
"deck",
],
},
},
methods: {
_getLastDate() {
return this.db.get("lastDate") || 0;
},
_setLastDate(lastDate) {
this.db.set("lastDate", lastDate);
},
async startEvent(maxResults = 0) {
const {
modeck,
deck,
} = this;

const lastDate = this._getLastDate();

const { renderList } = await modeck.listRenders({
data: {
deck,
},
});

let responseArray = [];
let count = 0;

for (const render of renderList) {
if (new Date(render.data) <= new Date(lastDate)) break;
responseArray.push(render);
if (maxResults && (++count === maxResults)) break;
}
if (responseArray.length) this._setLastDate(responseArray[0].date);

for (const render of responseArray.reverse()) {
this.$emit(
render,
{
id: render.id,
summary: `The render with id: "${render.id}" has been completed!`,
ts: render.date,
},
);
}
},
},
hooks: {
async deploy() {
await this.startEvent(25);
},
},
async run() {
await this.startEvent();
},
sampleEmit,
};
8 changes: 8 additions & 0 deletions components/modeck/sources/render-complete/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
"name": "renderName",
"editName": "editName",
"format": "mp4",
"url": "https://modeck-media.s3.us-east-1.amazonaws.com/884c1234567a123456789/editIdTest/render/render.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASDSDFGDFGFGHFGH%2F20231005%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231005T202702Z&X-Amz-Expires=7200&X-Amz-Signature=12345678ac4d411ab6f63dfc5e4e972fb78ee7db2266eecf90387481a82e&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%20%3D%22TEST01.mp4%22&versionId=sdfSFsdsdfgSfWsPpu_GwbhbhHrM86hntl&x-id=GetObject",
"date": "2023-10-05T20:26:15.000Z",
"id": 123456789000
}
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

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