Skip to content

Commit 02aa2ee

Browse files
authored
17338 components joggai (#17503)
* [Components] joggai #17338 Actions - Create AI Avatar Photo - Crate Avatar Video - Create Product From Product Info - Create Product From URL - Update Product Info Sources - Video Status Changed (Instant) * pnpm update * Update product creation action description to point to the correct documentation link * Refactor update-product-info action by removing unused prepareAdditionalProps and mediaQuantity definitions. Update base source to handle string body input gracefully.
1 parent 738fad6 commit 02aa2ee

File tree

13 files changed

+785
-9
lines changed

13 files changed

+785
-9
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import {
2+
AGE_OPTIONS,
3+
ASPECT_RATIO_OPTIONS,
4+
AVATAR_STYLE_OPTIONS,
5+
ETHNICITY_OPTIONS,
6+
GENDER_OPTIONS,
7+
MODEL_OPTIONS,
8+
} from "../../common/constants.mjs";
9+
import { checkResponse } from "../../common/utils.mjs";
10+
import joggai from "../../joggai.app.mjs";
11+
12+
export default {
13+
key: "joggai-create-ai-avatar-photo",
14+
name: "Create AI Avatar Photo",
15+
description: "Creates an AI avatar photo using JoggAI API. [See the documentation](https://docs.jogg.ai/api-reference/Avatar/GenerateAIAvatarPhoto)",
16+
version: "0.0.1",
17+
type: "action",
18+
props: {
19+
joggai,
20+
age: {
21+
type: "string",
22+
label: "Age",
23+
description: "Age of the avatar.",
24+
options: AGE_OPTIONS,
25+
},
26+
aspectRatio: {
27+
type: "string",
28+
label: "Aspect Ratio",
29+
description: "Aspect ratio of the avatar.",
30+
options: ASPECT_RATIO_OPTIONS,
31+
},
32+
avatarStyle: {
33+
type: "string",
34+
label: "Avatar Style",
35+
description: "Style of the avatar.",
36+
options: AVATAR_STYLE_OPTIONS,
37+
},
38+
gender: {
39+
type: "string",
40+
label: "Gender",
41+
description: "Gender of the avatar.",
42+
options: GENDER_OPTIONS,
43+
},
44+
model: {
45+
type: "string",
46+
label: "Model",
47+
description: "Model of the avatar.",
48+
options: MODEL_OPTIONS,
49+
},
50+
appearance: {
51+
type: "string",
52+
label: "Appearance",
53+
description: "Appearance of the avatar.",
54+
optional: true,
55+
},
56+
background: {
57+
type: "string",
58+
label: "Background",
59+
description: "Background of the avatar.",
60+
optional: true,
61+
},
62+
ethnicity: {
63+
type: "string",
64+
label: "Ethnicity",
65+
description: "Ethnicity of the avatar.",
66+
options: ETHNICITY_OPTIONS,
67+
optional: true,
68+
},
69+
imageUrl: {
70+
type: "string",
71+
label: "Image URL",
72+
description: "URL of the image to use for the avatar.",
73+
optional: true,
74+
},
75+
},
76+
async run({ $ }) {
77+
const response = await this.joggai.createAIAvatarPhoto({
78+
$,
79+
data: {
80+
age: this.age,
81+
aspect_ratio: this.aspectRatio && parseInt(this.aspectRatio),
82+
avatar_style: this.avatarStyle,
83+
gender: this.gender,
84+
model: this.model,
85+
appearance: this.appearance,
86+
background: this.background,
87+
image_url: this.imageUrl,
88+
ethnicity: this.ethnicity,
89+
},
90+
});
91+
92+
checkResponse(response);
93+
94+
$.export("$summary", "AI avatar photo created successfully");
95+
return response;
96+
},
97+
};
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import {
2+
ASPECT_VIDEO_RATIO_OPTIONS,
3+
AVATAR_TYPE_OPTIONS,
4+
SCREEN_STYLE_OPTIONS,
5+
VOICE_TYPE_OPTIONS,
6+
} from "../../common/constants.mjs";
7+
import { checkResponse } from "../../common/utils.mjs";
8+
import joggai from "../../joggai.app.mjs";
9+
10+
export default {
11+
key: "joggai-create-avatar-video",
12+
name: "Create Avatar Video",
13+
description: "Creates an avatar video using JoggAI API. [See the documentation](https://docs.jogg.ai/api-reference/Create-Avatar-Videos/CreateAvatarVideo)",
14+
version: "0.0.1",
15+
type: "action",
16+
props: {
17+
joggai,
18+
screenStyle: {
19+
type: "integer",
20+
label: "Screen Style",
21+
description: "Style of the screen.",
22+
options: SCREEN_STYLE_OPTIONS,
23+
},
24+
avatarType: {
25+
type: "string",
26+
label: "Avatar Type",
27+
description: "Source type of the avatar.",
28+
options: AVATAR_TYPE_OPTIONS,
29+
},
30+
avatarId: {
31+
propDefinition: [
32+
joggai,
33+
"avatarId",
34+
({ avatarType }) => ({
35+
avatarType,
36+
}),
37+
],
38+
},
39+
voiceType: {
40+
type: "string",
41+
label: "Voice Type",
42+
description: "Source type of the voice.",
43+
options: VOICE_TYPE_OPTIONS,
44+
},
45+
voiceId: {
46+
propDefinition: [
47+
joggai,
48+
"voiceId",
49+
({ voiceType }) => ({
50+
voiceType,
51+
}),
52+
],
53+
},
54+
script: {
55+
type: "string",
56+
label: "Script",
57+
description: "Script content for the avatar to speak. Must provide either script or `Audio URL`.",
58+
optional: true,
59+
},
60+
audioUrl: {
61+
type: "string",
62+
label: "Audio URL",
63+
description: "Url for Audio, either script or audio_url must be provided, but not both.",
64+
optional: true,
65+
},
66+
aspectRatio: {
67+
type: "string",
68+
label: "Aspect Ratio",
69+
description: "Aspect ratio of the output video.",
70+
options: ASPECT_VIDEO_RATIO_OPTIONS,
71+
},
72+
caption: {
73+
type: "boolean",
74+
label: "Caption",
75+
description: "Whether to add caption to the video.",
76+
optional: true,
77+
},
78+
videoName: {
79+
type: "string",
80+
label: "Video Name",
81+
description: "If you want to specify the name of the generated video, please use this parameter.",
82+
optional: true,
83+
},
84+
},
85+
async run({ $ }) {
86+
if (!this.script && !this.audioUrl) {
87+
throw new Error("You must provide at least one of `Script` or `Audio URL`.");
88+
}
89+
if (this.script && this.audioUrl) {
90+
throw new Error("You must provide either `Script` or `Audio URL`, but not both.");
91+
}
92+
93+
const response = await this.joggai.createAvatarVideo({
94+
$,
95+
data: {
96+
screen_style: this.screenStyle,
97+
avatar_type: this.avatarType && parseInt(this.avatarType),
98+
avatar_id: this.avatarId,
99+
voice_id: this.voiceId,
100+
script: this.script,
101+
audio_url: this.audioUrl,
102+
aspect_ratio: this.aspectRatio && parseInt(this.aspectRatio),
103+
caption: this.caption,
104+
video_name: this.videoName,
105+
},
106+
});
107+
108+
checkResponse(response);
109+
110+
$.export("$summary", "Avatar video created successfully");
111+
return response;
112+
},
113+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {
2+
checkResponse,
3+
prepareAdditionalProps,
4+
prepareMediaData,
5+
} from "../../common/utils.mjs";
6+
import joggai from "../../joggai.app.mjs";
7+
8+
export default {
9+
key: "joggai-create-product-from-product-info",
10+
name: "Create Product from Product Info",
11+
description: "Creates a product from product info using JoggAI API. [See the documentation](https://docs.jogg.ai/api-reference/URL-to-Video/CreateVideo)",
12+
version: "0.0.1",
13+
type: "action",
14+
props: {
15+
joggai,
16+
name: {
17+
propDefinition: [
18+
joggai,
19+
"name",
20+
],
21+
},
22+
description: {
23+
propDefinition: [
24+
joggai,
25+
"description",
26+
],
27+
},
28+
targetAudience: {
29+
propDefinition: [
30+
joggai,
31+
"targetAudience",
32+
],
33+
},
34+
mediaQuantity: {
35+
propDefinition: [
36+
joggai,
37+
"mediaQuantity",
38+
],
39+
},
40+
},
41+
async additionalProps() {
42+
return prepareAdditionalProps(this);
43+
},
44+
async run({ $ }) {
45+
const mediaData = await prepareMediaData(this);
46+
47+
const response = await this.joggai.createProduct({
48+
$,
49+
data: mediaData,
50+
});
51+
52+
checkResponse(response);
53+
54+
$.export("$summary", "Product created from product info successfully");
55+
return response;
56+
},
57+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { checkResponse } from "../../common/utils.mjs";
2+
import joggai from "../../joggai.app.mjs";
3+
4+
export default {
5+
key: "joggai-create-product-from-url",
6+
name: "Create Product from URL",
7+
description: "Creates a product from a URL using JoggAI API. [See the documentation](https://docs.jogg.ai/api-reference/URL-to-Video/UploadURL)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
joggai,
12+
url: {
13+
type: "string",
14+
label: "Product URL",
15+
description: "URL of the product to crawl.",
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.joggai.createProduct({
20+
$,
21+
data: {
22+
url: this.url,
23+
},
24+
});
25+
26+
checkResponse(response);
27+
28+
$.export("$summary", `Product created from URL successfully with ID: ${response.data.product_id}`);
29+
return response;
30+
},
31+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {
2+
checkResponse,
3+
prepareMediaData,
4+
} from "../../common/utils.mjs";
5+
import joggai from "../../joggai.app.mjs";
6+
7+
export default {
8+
key: "joggai-update-product-info",
9+
name: "Update Product Info",
10+
description: "Updates product info using JoggAI API. [See the documentation](https://docs.jogg.ai/api-reference/URL-to-Video/UpdateProduct)",
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
joggai,
15+
productId: {
16+
type: "string",
17+
label: "Product ID",
18+
description: "Product ID obtained from **Create Product Action** response.",
19+
},
20+
name: {
21+
propDefinition: [
22+
joggai,
23+
"name",
24+
],
25+
optional: true,
26+
},
27+
description: {
28+
propDefinition: [
29+
joggai,
30+
"description",
31+
],
32+
},
33+
targetAudience: {
34+
propDefinition: [
35+
joggai,
36+
"targetAudience",
37+
],
38+
},
39+
},
40+
async run({ $ }) {
41+
const mediaData = await prepareMediaData(this, {
42+
product_id: this.productId,
43+
});
44+
45+
const response = await this.joggai.updateProduct({
46+
$,
47+
data: mediaData,
48+
});
49+
50+
checkResponse(response);
51+
52+
$.export("$summary", "Product info updated successfully");
53+
return response;
54+
},
55+
};

0 commit comments

Comments
 (0)