Skip to content

Commit 4b7e4af

Browse files
committed
new components
1 parent cfe7a67 commit 4b7e4af

File tree

14 files changed

+637
-14
lines changed

14 files changed

+637
-14
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import googleSlides from "../../google_slides.app.mjs";
2+
3+
export default {
4+
key: "google_slides-create-image",
5+
name: "Create Image",
6+
description: "Creates an image in a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateImageRequest)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
googleSlides,
11+
presentationId: {
12+
propDefinition: [
13+
googleSlides,
14+
"presentationId",
15+
],
16+
},
17+
slideId: {
18+
propDefinition: [
19+
googleSlides,
20+
"slideId",
21+
(c) => ({
22+
presentationId: c.presentationId,
23+
}),
24+
],
25+
},
26+
url: {
27+
type: "string",
28+
label: "URL",
29+
description: "The URL of the image to insert",
30+
},
31+
height: {
32+
type: "integer",
33+
label: "Height",
34+
description: "The height of the shape in points (1/72 of an inch)",
35+
},
36+
width: {
37+
type: "integer",
38+
label: "Width",
39+
description: "The width of the shape in points (1/72 of an inch)",
40+
},
41+
scaleX: {
42+
type: "integer",
43+
label: "Scale X",
44+
description: "The scale of the shape on the x-axis",
45+
default: 1,
46+
optional: true,
47+
},
48+
scaleY: {
49+
type: "integer",
50+
label: "Scale Y",
51+
description: "The scale of the shape on the y-axis",
52+
default: 1,
53+
optional: true,
54+
},
55+
translateX: {
56+
type: "integer",
57+
label: "Translate X",
58+
description: "The translation of the shape on the x-axis",
59+
default: 0,
60+
optional: true,
61+
},
62+
translateY: {
63+
type: "integer",
64+
label: "Translate Y",
65+
description: "The translation of the shape on the y-axis",
66+
default: 0,
67+
optional: true,
68+
},
69+
},
70+
async run({ $ }) {
71+
const response = await this.googleSlides.createImage(this.presentationId, {
72+
url: this.url,
73+
elementProperties: {
74+
pageObjectId: this.slideId,
75+
size: {
76+
height: {
77+
magnitude: this.height,
78+
unit: "PT",
79+
},
80+
width: {
81+
magnitude: this.width,
82+
unit: "PT",
83+
},
84+
},
85+
transform: {
86+
scaleX: this.scaleX,
87+
scaleY: this.scaleY,
88+
translateX: this.translateX,
89+
translateY: this.translateY,
90+
unit: "PT",
91+
},
92+
},
93+
});
94+
$.export("$summary", `Successfully created image with ID: ${response.data.replies[0].createImage.objectId}`);
95+
return response.data;
96+
},
97+
};
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import googleSlides from "../../google_slides.app.mjs";
2+
import { SHAPE_TYPES } from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "google_slides-create-page-element",
6+
name: "Create Page Element",
7+
description: "Create a new page element in a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateShapeRequest)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
googleSlides,
12+
presentationId: {
13+
propDefinition: [
14+
googleSlides,
15+
"presentationId",
16+
],
17+
},
18+
slideId: {
19+
propDefinition: [
20+
googleSlides,
21+
"slideId",
22+
(c) => ({
23+
presentationId: c.presentationId,
24+
}),
25+
],
26+
},
27+
type: {
28+
type: "string",
29+
label: "Type",
30+
description: "The type of the shape",
31+
options: SHAPE_TYPES,
32+
},
33+
height: {
34+
type: "integer",
35+
label: "Height",
36+
description: "The height of the shape in points (1/72 of an inch)",
37+
},
38+
width: {
39+
type: "integer",
40+
label: "Width",
41+
description: "The width of the shape in points (1/72 of an inch)",
42+
},
43+
scaleX: {
44+
type: "integer",
45+
label: "Scale X",
46+
description: "The scale of the shape on the x-axis",
47+
default: 1,
48+
optional: true,
49+
},
50+
scaleY: {
51+
type: "integer",
52+
label: "Scale Y",
53+
description: "The scale of the shape on the y-axis",
54+
default: 1,
55+
optional: true,
56+
},
57+
translateX: {
58+
type: "integer",
59+
label: "Translate X",
60+
description: "The translation of the shape on the x-axis",
61+
default: 0,
62+
optional: true,
63+
},
64+
translateY: {
65+
type: "integer",
66+
label: "Translate Y",
67+
description: "The translation of the shape on the y-axis",
68+
default: 0,
69+
optional: true,
70+
},
71+
},
72+
async run({ $ }) {
73+
const response = await this.googleSlides.createShape(this.presentationId, {
74+
shapeType: this.type,
75+
elementProperties: {
76+
pageObjectId: this.slideId,
77+
size: {
78+
height: {
79+
magnitude: this.height,
80+
unit: "PT",
81+
},
82+
width: {
83+
magnitude: this.width,
84+
unit: "PT",
85+
},
86+
},
87+
transform: {
88+
scaleX: this.scaleX,
89+
scaleY: this.scaleY,
90+
translateX: this.translateX,
91+
translateY: this.translateY,
92+
unit: "PT",
93+
},
94+
},
95+
});
96+
$.export("$summary", `Successfully created shape with ID: ${response.data.replies[0].createShape.objectId}`);
97+
return response.data;
98+
},
99+
};

components/google_slides/actions/create-presentation/create-presentation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_slides-create-presentation",
55
name: "Create Presentation",
66
description: "Create a blank presentation or duplicate an existing presentation. [See the docs here](https://developers.google.com/slides/api/guides/presentations#copy_an_existing_presentation)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
app,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import googleSlides from "../../google_slides.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "google_slides-create-slide",
6+
name: "Create Slide",
7+
description: "Create a new slide in a presentation. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateSlideRequest)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
googleSlides,
12+
presentationId: {
13+
propDefinition: [
14+
googleSlides,
15+
"presentationId",
16+
],
17+
},
18+
layoutId: {
19+
propDefinition: [
20+
googleSlides,
21+
"layoutId",
22+
(c) => ({
23+
presentationId: c.presentationId,
24+
}),
25+
],
26+
},
27+
insertionIndex: {
28+
type: "integer",
29+
label: "Insertion Index",
30+
description: "The optional zero-based index indicating where to insert the slides. If you don't specify an index, the slide is created at the end.",
31+
optional: true,
32+
},
33+
},
34+
async run({ $ }) {
35+
try {
36+
const response = await this.googleSlides.createSlide(this.presentationId, {
37+
insertionIndex: this.insertionIndex,
38+
slideLayoutReference: {
39+
layoutId: this.layoutId,
40+
},
41+
});
42+
$.export("$summary", `Successfully created slide with ID: ${response.data.replies[0].createSlide.objectId}`);
43+
return response.data;
44+
} catch (error) {
45+
throw new ConfigurationError(`Failed to create slide: ${error.message}. Make sure you have permission to edit the presentation.`);
46+
}
47+
},
48+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import googleSlides from "../../google_slides.app.mjs";
2+
3+
export default {
4+
key: "google_slides-delete-page-element",
5+
name: "Delete Page Element",
6+
description: "Deletes a page element from a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#DeleteObjectRequest)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
googleSlides,
11+
presentationId: {
12+
propDefinition: [
13+
googleSlides,
14+
"presentationId",
15+
],
16+
},
17+
slideId: {
18+
propDefinition: [
19+
googleSlides,
20+
"slideId",
21+
(c) => ({
22+
presentationId: c.presentationId,
23+
}),
24+
],
25+
},
26+
pageElementId: {
27+
propDefinition: [
28+
googleSlides,
29+
"shapeId",
30+
(c) => ({
31+
presentationId: c.presentationId,
32+
slideId: c.slideId,
33+
}),
34+
],
35+
},
36+
},
37+
async run({ $ }) {
38+
const response = await this.googleSlides.deleteObject(this.presentationId, this.pageElementId);
39+
$.export("$summary", `Successfully deleted page element with ID: ${this.pageElementId}`);
40+
return response.data;
41+
},
42+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import googleSlides from "../../google_slides.app.mjs";
2+
3+
export default {
4+
key: "google_slides-delete-slide",
5+
name: "Delete Slide",
6+
description: "Deletes a slide from a presentation. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#DeleteObjectRequest)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
googleSlides,
11+
presentationId: {
12+
propDefinition: [
13+
googleSlides,
14+
"presentationId",
15+
],
16+
},
17+
slideId: {
18+
propDefinition: [
19+
googleSlides,
20+
"slideId",
21+
(c) => ({
22+
presentationId: c.presentationId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.googleSlides.deleteObject(this.presentationId, this.slideId);
29+
$.export("$summary", `Successfully deleted slide with ID: ${this.slideId}`);
30+
return response.data;
31+
},
32+
};

components/google_slides/actions/find-presentation/find-presentation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_slides-find-presentation",
55
name: "Find a Presentation",
66
description: "Find a presentation on Google Drive. [See the docs here](https://developers.google.com/slides/api/samples/presentation#list_existing_presentation_files)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
app,
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import googleSlides from "../../google_slides.app.mjs";
2+
3+
export default {
4+
key: "google_slides-insert-text",
5+
name: "Insert Text",
6+
description: "Insert text into a shape. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#InsertTextRequest)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
googleSlides,
11+
presentationId: {
12+
propDefinition: [
13+
googleSlides,
14+
"presentationId",
15+
],
16+
},
17+
slideId: {
18+
propDefinition: [
19+
googleSlides,
20+
"slideId",
21+
(c) => ({
22+
presentationId: c.presentationId,
23+
}),
24+
],
25+
},
26+
shapeId: {
27+
propDefinition: [
28+
googleSlides,
29+
"shapeId",
30+
(c) => ({
31+
presentationId: c.presentationId,
32+
slideId: c.slideId,
33+
textOnly: true,
34+
}),
35+
],
36+
},
37+
text: {
38+
type: "string",
39+
label: "Text",
40+
description: "The text to insert",
41+
},
42+
insertionIndex: {
43+
type: "integer",
44+
label: "Insertion Index",
45+
description: "The index where the text will be inserted",
46+
optional: true,
47+
},
48+
},
49+
async run({ $ }) {
50+
const response = await this.googleSlides.insertText(this.presentationId, {
51+
objectId: this.shapeId,
52+
text: this.text,
53+
insertionIndex: this.insertionIndex,
54+
});
55+
$.export("$summary", `Successfully inserted text into shape with ID: ${this.shapeId}`);
56+
return response.data;
57+
},
58+
};

0 commit comments

Comments
 (0)