Skip to content

Commit f689f33

Browse files
committed
Merge branch 'master' into 13927-github-actions-improvements
2 parents b88c1b5 + 1d34c18 commit f689f33

File tree

138 files changed

+2846
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2846
-437
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import certifier from "../../certifier.app.mjs";
2+
3+
export default {
4+
name: "Create Group",
5+
version: "0.0.1",
6+
key: "certifier-create-group",
7+
description:
8+
"Create a group. [See the documentation](https://developers.certifier.io/reference/create-a-group)",
9+
props: {
10+
certifier,
11+
name: {
12+
propDefinition: [
13+
certifier,
14+
"groupName",
15+
],
16+
},
17+
certificateDesignId: {
18+
propDefinition: [
19+
certifier,
20+
"certificateDesignId",
21+
],
22+
},
23+
badgeDesignId: {
24+
propDefinition: [
25+
certifier,
26+
"badgeDesignId",
27+
],
28+
},
29+
learningEventUrl: {
30+
propDefinition: [
31+
certifier,
32+
"learningEventUrl",
33+
],
34+
},
35+
// eslint-disable-next-line pipedream/props-label, pipedream/props-description
36+
alert: {
37+
type: "alert",
38+
alertType: "warning",
39+
content:
40+
"At least one of `Certificate Design` and `Badge Design` fields is required.",
41+
},
42+
},
43+
type: "action",
44+
methods: {},
45+
async run({ $ }) {
46+
const {
47+
certifier,
48+
name,
49+
certificateDesignId,
50+
badgeDesignId,
51+
learningEventUrl,
52+
} = this;
53+
54+
const response = await certifier.createGroup({
55+
$,
56+
data: {
57+
name,
58+
certificateDesignId,
59+
badgeDesignId,
60+
learningEventUrl,
61+
},
62+
});
63+
64+
$.export(
65+
"$summary",
66+
`Successfully created group ${response.name}`,
67+
);
68+
69+
return response;
70+
},
71+
};

components/certifier/actions/issue-credential/issue-credential.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import certifier from "../../certifier.app.mjs";
22

33
export default {
44
name: "Issue Credential",
5-
version: "0.0.1",
5+
version: "0.0.2",
66
key: "certifier-issue-credential",
77
description:
88
"Create, issue and send a credential to a recipient. [See the documentation](https://developers.certifier.io/reference/create-issue-send-a-credential)",

components/certifier/certifier.app.mjs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export default {
3636
...args,
3737
});
3838
},
39+
searchDesigns(args = {}) {
40+
return this.callApi({
41+
path: "/designs",
42+
...args,
43+
});
44+
},
3945
createCredential(args = {}) {
4046
return this.callApi({
4147
method: "POST",
@@ -57,6 +63,13 @@ export default {
5763
...args,
5864
});
5965
},
66+
createGroup(args = {}) {
67+
return this.callApi({
68+
method: "POST",
69+
path: "/groups",
70+
...args,
71+
});
72+
},
6073
},
6174
propDefinitions: {
6275
groupId: {
@@ -121,5 +134,82 @@ export default {
121134
"The date (in `YYYY-MM-DD` format) of your credential's expiration. If not provided, expiry date from the group settings will be used (by default this field is empty).",
122135
optional: true,
123136
},
137+
groupName: {
138+
type: "string",
139+
label: "Group Name",
140+
description:
141+
"The group's name that is used as [group.name] attribute later on.",
142+
},
143+
certificateDesignId: {
144+
type: "string",
145+
label: "Certificate Design",
146+
description: "The unique certificate design's name.",
147+
optional: true,
148+
async options({ prevContext } = {}) {
149+
const response = await this.searchDesigns({
150+
params: {
151+
cursor: prevContext.cursor,
152+
},
153+
});
154+
const designs = response.data;
155+
const cursor = response.pagination.next;
156+
157+
return {
158+
options: designs
159+
.filter((design) => design.type === "certificate")
160+
.map(({
161+
id, name,
162+
}) => ({
163+
label: name,
164+
value: id,
165+
})),
166+
context: {
167+
cursor,
168+
},
169+
};
170+
},
171+
},
172+
badgeDesignId: {
173+
type: "string",
174+
label: "Badge Design",
175+
description: "The unique badge design's name.",
176+
optional: true,
177+
async options({ prevContext } = {}) {
178+
const response = await this.searchDesigns({
179+
params: {
180+
cursor: prevContext.cursor,
181+
},
182+
});
183+
const designs = response.data;
184+
const cursor = response.pagination.next;
185+
186+
return {
187+
options: designs
188+
.filter((design) => design.type === "badge")
189+
.map(({
190+
id, name,
191+
}) => ({
192+
label: name,
193+
value: id,
194+
})),
195+
context: {
196+
cursor,
197+
},
198+
};
199+
},
200+
},
201+
learningEventUrl: {
202+
type: "string",
203+
label: "Learning Event URL",
204+
description:
205+
"The learning event's URL that is shown in the digital wallet.",
206+
optional: true,
207+
},
208+
credentialId: {
209+
type: "string",
210+
label: "Credential ID",
211+
description:
212+
"The credential's unique ID.",
213+
},
124214
},
125215
};

components/certifier/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/certifier",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Certifier Components",
55
"main": "certifier.app.mjs",
66
"keywords": [
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const normalizeFilepath = (filename, ext = "pdf") => {
2+
let filepath = filename.includes("/tmp")
3+
? filename
4+
: `/tmp/${filename}`;
5+
filepath = filepath.includes(`.${ext}`)
6+
? filepath
7+
: `${filepath}.${ext}`;
8+
return filepath;
9+
};
10+
11+
export {
12+
normalizeFilepath,
13+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import customjs from "../../customjs.app.mjs";
2+
import fs from "fs";
3+
import { normalizeFilepath } from "../common/utils.mjs";
4+
5+
export default {
6+
key: "customjs-convert-html-to-pdf",
7+
name: "Convert HTML to PDF",
8+
description: "Converts an HTML string to a PDF document. [See the documentation](https://www.customjs.space/api/docs#_1-html-to-pdf)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
customjs,
13+
html: {
14+
type: "string",
15+
label: "HTML",
16+
description: "The HTML string to be converted to a PDF",
17+
},
18+
filename: {
19+
propDefinition: [
20+
customjs,
21+
"filename",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const fileContent = await this.customjs.convertHtmlToPdf({
27+
$,
28+
data: {
29+
input: this.html,
30+
code: "const { HTML2PDF } = require(\"./utils\"); return HTML2PDF(input);",
31+
returnBinary: "true",
32+
},
33+
});
34+
35+
const filepath = normalizeFilepath(this.filename);
36+
fs.writeFileSync(filepath, Buffer.from(fileContent));
37+
38+
$.export("$summary", "Successfully converted HTML to PDF");
39+
return {
40+
filename: this.filename,
41+
filepath,
42+
};
43+
},
44+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import customjs from "../../customjs.app.mjs";
2+
import fs from "fs";
3+
import { normalizeFilepath } from "../common/utils.mjs";
4+
5+
export default {
6+
key: "customjs-create-screenshot",
7+
name: "Create Screenshot",
8+
description: "Create a screenshot of a website. [See the documentation](https://www.customjs.space/api/docs#_3-create-screenshot)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
customjs,
13+
url: {
14+
type: "string",
15+
label: "URL",
16+
description: "The URL of the website to take a screenshot of",
17+
},
18+
filename: {
19+
propDefinition: [
20+
customjs,
21+
"filename",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const fileContent = await this.customjs.createScreenshot({
27+
$,
28+
data: {
29+
input: this.url,
30+
code: "const { SCREENSHOT } = require(\"./utils\"); return SCREENSHOT(input);",
31+
returnBinary: "true",
32+
},
33+
});
34+
35+
const filepath = normalizeFilepath(this.filename, "png");
36+
fs.writeFileSync(filepath, Buffer.from(fileContent));
37+
38+
$.export("$summary", `Successfully created screenshot of ${this.url}`);
39+
return {
40+
filename: this.filename,
41+
filepath,
42+
};
43+
},
44+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import customjs from "../../customjs.app.mjs";
2+
import fs from "fs";
3+
import { normalizeFilepath } from "../common/utils.mjs";
4+
5+
export default {
6+
key: "customjs-merge-pdfs",
7+
name: "Merge PDFs",
8+
description: "Merges multiple PDF documents into one. [See the documentation](https://www.customjs.space/api/docs#_2-merge-pdfs)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
customjs,
13+
pdfs: {
14+
type: "string[]",
15+
label: "PDFs",
16+
description: "The array of URLs to the PDF documents to merge",
17+
},
18+
filename: {
19+
propDefinition: [
20+
customjs,
21+
"filename",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const pdfs = typeof this.pdfs === "string"
27+
? JSON.parse(this.pdfs)
28+
: this.pdfs;
29+
30+
const fileContent = await this.customjs.mergePdfs({
31+
$,
32+
data: {
33+
input: pdfs,
34+
code: "const { PDF_MERGE } = require(\"./utils\"); const axios = require(\"axios\"); const pdfBuffers = await Promise.all(input.map(async file => { const res = await axios.get(file, { responseType: \"arraybuffer\" }); return Buffer.from(res.data).toString(\"base64\"); })); return PDF_MERGE(pdfBuffers);",
35+
returnBinary: "true",
36+
},
37+
});
38+
39+
const filepath = normalizeFilepath(this.filename);
40+
fs.writeFileSync(filepath, Buffer.from(fileContent));
41+
42+
$.export("$summary", "Successfully merged PDFs");
43+
return {
44+
filename: this.filename,
45+
filepath,
46+
};
47+
},
48+
};

0 commit comments

Comments
 (0)