@skillful-ai/piece-skai-gen-image 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +35 -0
- package/src/index.d.ts +15 -0
- package/src/index.js +77 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/generate-image.d.ts +11 -0
- package/src/lib/actions/generate-image.js +111 -0
- package/src/lib/actions/generate-image.js.map +1 -0
- package/src/lib/actions/generate-meme-from-template.d.ts +13 -0
- package/src/lib/actions/generate-meme-from-template.js +113 -0
- package/src/lib/actions/generate-meme-from-template.js.map +1 -0
- package/src/lib/actions/generate-meme-with-ai.d.ts +9 -0
- package/src/lib/actions/generate-meme-with-ai.js +84 -0
- package/src/lib/actions/generate-meme-with-ai.js.map +1 -0
- package/src/lib/actions/get-trending-templates.d.ts +5 -0
- package/src/lib/actions/get-trending-templates.js +72 -0
- package/src/lib/actions/get-trending-templates.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skillful-ai/piece-skai-gen-image",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@activepieces/pieces-common": "^0.20.1",
|
|
9
|
+
"@activepieces/pieces-framework": "^0.20.1",
|
|
10
|
+
"@sinclair/typebox": "0.34.11",
|
|
11
|
+
"axios": "1.8.3",
|
|
12
|
+
"axios-retry": "4.4.1",
|
|
13
|
+
"deepmerge-ts": "7.1.0",
|
|
14
|
+
"mime-types": "2.1.35",
|
|
15
|
+
"nanoid": "3.3.8",
|
|
16
|
+
"openai": "^4.0.0",
|
|
17
|
+
"semver": "7.6.0",
|
|
18
|
+
"tslib": "^2.3.0",
|
|
19
|
+
"zod": "3.25.76",
|
|
20
|
+
"@activepieces/shared": "0.22.0"
|
|
21
|
+
},
|
|
22
|
+
"overrides": {
|
|
23
|
+
"@tryfabric/martian": {
|
|
24
|
+
"@notionhq/client": "$@notionhq/client"
|
|
25
|
+
},
|
|
26
|
+
"vite": {
|
|
27
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
28
|
+
},
|
|
29
|
+
"undici": "6.19.8"
|
|
30
|
+
},
|
|
31
|
+
"resolutions": {
|
|
32
|
+
"rollup": "npm:@rollup/wasm-node",
|
|
33
|
+
"undici": "6.19.8"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const skaiGenImageAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
openaiApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
3
|
+
imgflipUsername: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
imgflipPassword: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>;
|
|
6
|
+
export type SkaiGenImageAuthValue = {
|
|
7
|
+
openaiApiKey?: string;
|
|
8
|
+
imgflipUsername: string;
|
|
9
|
+
imgflipPassword: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const skaiGenImage: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
openaiApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
13
|
+
imgflipUsername: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
14
|
+
imgflipPassword: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
15
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.skaiGenImage = exports.skaiGenImageAuth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const shared_1 = require("@activepieces/shared");
|
|
6
|
+
// Actions - DALL-E
|
|
7
|
+
const generate_image_1 = require("./lib/actions/generate-image");
|
|
8
|
+
// Actions - Imgflip (Real Memes)
|
|
9
|
+
const get_trending_templates_1 = require("./lib/actions/get-trending-templates");
|
|
10
|
+
const generate_meme_from_template_1 = require("./lib/actions/generate-meme-from-template");
|
|
11
|
+
const generate_meme_with_ai_1 = require("./lib/actions/generate-meme-with-ai");
|
|
12
|
+
const markdownDescription = `
|
|
13
|
+
## SKAI Gen Image
|
|
14
|
+
|
|
15
|
+
Generate AI images and **real viral memes** using popular templates.
|
|
16
|
+
|
|
17
|
+
### Setup
|
|
18
|
+
|
|
19
|
+
**For Original Images (DALL-E):**
|
|
20
|
+
1. Get your OpenAI API key from https://platform.openai.com/api-keys
|
|
21
|
+
|
|
22
|
+
**For Real Memes (Imgflip):**
|
|
23
|
+
1. Create free account at https://imgflip.com
|
|
24
|
+
2. For premium features (no watermark, AI memes), subscribe at https://imgflip.com/pro
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
**Meme Generation (Imgflip):**
|
|
29
|
+
- Access 1M+ viral meme templates (Drake, Distracted Boyfriend, etc.)
|
|
30
|
+
- Get trending templates that are hot right now
|
|
31
|
+
- AI-powered meme generation that picks the best template
|
|
32
|
+
- Custom text positioning and styling
|
|
33
|
+
|
|
34
|
+
**Image Generation (DALL-E):**
|
|
35
|
+
- Generate original images from text prompts
|
|
36
|
+
- Multiple sizes and quality options
|
|
37
|
+
`;
|
|
38
|
+
exports.skaiGenImageAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
39
|
+
description: markdownDescription,
|
|
40
|
+
required: true,
|
|
41
|
+
props: {
|
|
42
|
+
openaiApiKey: pieces_framework_1.PieceAuth.SecretText({
|
|
43
|
+
displayName: 'OpenAI API Key',
|
|
44
|
+
description: 'For DALL-E image generation (optional if only using memes)',
|
|
45
|
+
required: false,
|
|
46
|
+
}),
|
|
47
|
+
imgflipUsername: pieces_framework_1.Property.ShortText({
|
|
48
|
+
displayName: 'Imgflip Username',
|
|
49
|
+
description: 'Your Imgflip account username',
|
|
50
|
+
required: true,
|
|
51
|
+
}),
|
|
52
|
+
imgflipPassword: pieces_framework_1.PieceAuth.SecretText({
|
|
53
|
+
displayName: 'Imgflip Password',
|
|
54
|
+
description: 'Your Imgflip account password',
|
|
55
|
+
required: true,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
exports.skaiGenImage = (0, pieces_framework_1.createPiece)({
|
|
60
|
+
displayName: 'SKAI Gen Image',
|
|
61
|
+
description: 'Generate real viral memes and AI images',
|
|
62
|
+
auth: exports.skaiGenImageAuth,
|
|
63
|
+
minimumSupportedRelease: '0.36.1',
|
|
64
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/dalle.png',
|
|
65
|
+
authors: ['Skillful AI'],
|
|
66
|
+
categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE, shared_1.PieceCategory.MARKETING],
|
|
67
|
+
actions: [
|
|
68
|
+
// Imgflip - Real Memes
|
|
69
|
+
get_trending_templates_1.getTrendingTemplates,
|
|
70
|
+
generate_meme_from_template_1.generateMemeFromTemplate,
|
|
71
|
+
generate_meme_with_ai_1.generateMemeWithAI,
|
|
72
|
+
// DALL-E - Original Images
|
|
73
|
+
generate_image_1.generateImage,
|
|
74
|
+
],
|
|
75
|
+
triggers: [],
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/custom/skai-gen-image/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkF;AAClF,iDAAqD;AAErD,mBAAmB;AACnB,iEAA6D;AAE7D,iCAAiC;AACjC,iFAA4E;AAC5E,2FAAqF;AACrF,+EAAyE;AAEzE,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyB3B,CAAC;AAEW,QAAA,gBAAgB,GAAG,4BAAS,CAAC,UAAU,CAAC;IACjD,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACH,YAAY,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC/B,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,4DAA4D;YACzE,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,eAAe,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,eAAe,EAAE,4BAAS,CAAC,UAAU,CAAC;YAClC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,IAAI;SACjB,CAAC;KACL;CACJ,CAAC,CAAC;AAQU,QAAA,YAAY,GAAG,IAAA,8BAAW,EAAC;IACpC,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,yCAAyC;IACtD,IAAI,EAAE,wBAAgB;IACtB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+C;IACxD,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,EAAE,sBAAa,CAAC,SAAS,CAAC;IAC5E,OAAO,EAAE;QACL,uBAAuB;QACvB,6CAAoB;QACpB,sDAAwB;QACxB,0CAAkB;QAClB,2BAA2B;QAC3B,8BAAa;KAChB;IACD,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const generateImage: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
openaiApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
3
|
+
imgflipUsername: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
imgflipPassword: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
prompt: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
7
|
+
model: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
size: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
9
|
+
quality: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
10
|
+
style: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateImage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
exports.generateImage = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.skaiGenImageAuth,
|
|
10
|
+
name: 'generate_image',
|
|
11
|
+
displayName: 'Generate Original Image (DALL-E)',
|
|
12
|
+
description: 'Generate an original image from a text prompt using DALL-E (not a meme)',
|
|
13
|
+
props: {
|
|
14
|
+
prompt: pieces_framework_1.Property.LongText({
|
|
15
|
+
displayName: 'Prompt',
|
|
16
|
+
description: 'Describe the image you want to generate',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
model: pieces_framework_1.Property.StaticDropdown({
|
|
20
|
+
displayName: 'Model',
|
|
21
|
+
description: 'The DALL-E model to use',
|
|
22
|
+
required: true,
|
|
23
|
+
defaultValue: 'dall-e-3',
|
|
24
|
+
options: {
|
|
25
|
+
options: [
|
|
26
|
+
{ label: 'DALL-E 3 (Best quality)', value: 'dall-e-3' },
|
|
27
|
+
{ label: 'DALL-E 2 (Faster, cheaper)', value: 'dall-e-2' },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
size: pieces_framework_1.Property.StaticDropdown({
|
|
32
|
+
displayName: 'Size',
|
|
33
|
+
description: 'The size of the generated image',
|
|
34
|
+
required: true,
|
|
35
|
+
defaultValue: '1024x1024',
|
|
36
|
+
options: {
|
|
37
|
+
options: [
|
|
38
|
+
{ label: '1024x1024 (Square)', value: '1024x1024' },
|
|
39
|
+
{ label: '1792x1024 (Landscape)', value: '1792x1024' },
|
|
40
|
+
{ label: '1024x1792 (Portrait)', value: '1024x1792' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
quality: pieces_framework_1.Property.StaticDropdown({
|
|
45
|
+
displayName: 'Quality',
|
|
46
|
+
description: 'The quality of the generated image (DALL-E 3 only)',
|
|
47
|
+
required: false,
|
|
48
|
+
defaultValue: 'standard',
|
|
49
|
+
options: {
|
|
50
|
+
options: [
|
|
51
|
+
{ label: 'Standard', value: 'standard' },
|
|
52
|
+
{ label: 'HD (More detailed)', value: 'hd' },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
style: pieces_framework_1.Property.StaticDropdown({
|
|
57
|
+
displayName: 'Style',
|
|
58
|
+
description: 'The style of the generated image (DALL-E 3 only)',
|
|
59
|
+
required: false,
|
|
60
|
+
defaultValue: 'vivid',
|
|
61
|
+
options: {
|
|
62
|
+
options: [
|
|
63
|
+
{ label: 'Vivid (Hyper-real, dramatic)', value: 'vivid' },
|
|
64
|
+
{ label: 'Natural (More natural, less hyper-real)', value: 'natural' },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
run(context) {
|
|
70
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const { prompt, model, size, quality, style } = context.propsValue;
|
|
72
|
+
const auth = context.auth;
|
|
73
|
+
if (!auth.openaiApiKey) {
|
|
74
|
+
throw new Error('OpenAI API key is required for DALL-E image generation. Please add it in the connection settings.');
|
|
75
|
+
}
|
|
76
|
+
const requestBody = {
|
|
77
|
+
model,
|
|
78
|
+
prompt,
|
|
79
|
+
n: 1,
|
|
80
|
+
size,
|
|
81
|
+
response_format: 'url',
|
|
82
|
+
};
|
|
83
|
+
// DALL-E 3 specific options
|
|
84
|
+
if (model === 'dall-e-3') {
|
|
85
|
+
requestBody['quality'] = quality || 'standard';
|
|
86
|
+
requestBody['style'] = style || 'vivid';
|
|
87
|
+
}
|
|
88
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
89
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
90
|
+
url: 'https://api.openai.com/v1/images/generations',
|
|
91
|
+
headers: {
|
|
92
|
+
'Authorization': `Bearer ${auth.openaiApiKey}`,
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
},
|
|
95
|
+
body: requestBody,
|
|
96
|
+
});
|
|
97
|
+
if (!response.body.data || response.body.data.length === 0) {
|
|
98
|
+
throw new Error(`Failed to generate image: ${JSON.stringify(response.body)}`);
|
|
99
|
+
}
|
|
100
|
+
const imageData = response.body.data[0];
|
|
101
|
+
return {
|
|
102
|
+
success: true,
|
|
103
|
+
imageUrl: imageData.url,
|
|
104
|
+
revisedPrompt: imageData.revised_prompt,
|
|
105
|
+
model,
|
|
106
|
+
size,
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=generate-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-image.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-gen-image/src/lib/actions/generate-image.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAsE;AAEzD,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,wBAAgB;IACtB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,k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EH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzD,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClF,CAAC;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAExC,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,SAAS,CAAC,GAAG;gBACvB,aAAa,EAAE,SAAS,CAAC,cAAc;gBACvC,KAAK;gBACL,IAAI;aACP,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const generateMemeFromTemplate: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
openaiApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
3
|
+
imgflipUsername: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
imgflipPassword: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
templateId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
text0: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
text1: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
text2: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
text3: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
font: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
12
|
+
maxFontSize: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMemeFromTemplate = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const IMGFLIP_API_URL = 'https://api.imgflip.com';
|
|
9
|
+
exports.generateMemeFromTemplate = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: index_1.skaiGenImageAuth,
|
|
11
|
+
name: 'generate_meme_from_template',
|
|
12
|
+
displayName: 'Generate Meme from Template',
|
|
13
|
+
description: 'Create a meme using a specific viral template (Drake, Distracted Boyfriend, etc.)',
|
|
14
|
+
props: {
|
|
15
|
+
templateId: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Template ID',
|
|
17
|
+
description: 'The Imgflip template ID (get from "Get Trending Templates" action). Common: 181913649 (Drake), 112126428 (Distracted Boyfriend)',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
text0: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Top Text / First Box',
|
|
22
|
+
description: 'Text for the first/top text box',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
text1: pieces_framework_1.Property.ShortText({
|
|
26
|
+
displayName: 'Bottom Text / Second Box',
|
|
27
|
+
description: 'Text for the second/bottom text box',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
text2: pieces_framework_1.Property.ShortText({
|
|
31
|
+
displayName: 'Third Text Box',
|
|
32
|
+
description: 'Text for the third box (if template supports it)',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
text3: pieces_framework_1.Property.ShortText({
|
|
36
|
+
displayName: 'Fourth Text Box',
|
|
37
|
+
description: 'Text for the fourth box (if template supports it)',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
font: pieces_framework_1.Property.StaticDropdown({
|
|
41
|
+
displayName: 'Font',
|
|
42
|
+
description: 'Font style for the meme text',
|
|
43
|
+
required: false,
|
|
44
|
+
defaultValue: 'impact',
|
|
45
|
+
options: {
|
|
46
|
+
options: [
|
|
47
|
+
{ label: 'Impact (Classic meme font)', value: 'impact' },
|
|
48
|
+
{ label: 'Arial', value: 'arial' },
|
|
49
|
+
{ label: 'Comic Sans MS', value: 'Comic Sans MS' },
|
|
50
|
+
{ label: 'Roboto', value: 'Roboto' },
|
|
51
|
+
{ label: 'Open Sans', value: 'Open Sans' },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
maxFontSize: pieces_framework_1.Property.Number({
|
|
56
|
+
displayName: 'Max Font Size',
|
|
57
|
+
description: 'Maximum font size in pixels (default: 50)',
|
|
58
|
+
required: false,
|
|
59
|
+
defaultValue: 50,
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
run(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const { templateId, text0, text1, text2, text3, font, maxFontSize } = context.propsValue;
|
|
65
|
+
const auth = context.auth;
|
|
66
|
+
// Build the request body
|
|
67
|
+
const formData = {
|
|
68
|
+
template_id: templateId,
|
|
69
|
+
username: auth.imgflipUsername,
|
|
70
|
+
password: auth.imgflipPassword,
|
|
71
|
+
text0: text0,
|
|
72
|
+
};
|
|
73
|
+
if (text1)
|
|
74
|
+
formData['text1'] = text1;
|
|
75
|
+
if (text2)
|
|
76
|
+
formData['boxes[2][text]'] = text2;
|
|
77
|
+
if (text3)
|
|
78
|
+
formData['boxes[3][text]'] = text3;
|
|
79
|
+
if (font)
|
|
80
|
+
formData['font'] = font;
|
|
81
|
+
if (maxFontSize)
|
|
82
|
+
formData['max_font_size'] = String(maxFontSize);
|
|
83
|
+
// Convert to URL-encoded form data
|
|
84
|
+
const body = Object.entries(formData)
|
|
85
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
86
|
+
.join('&');
|
|
87
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
88
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
89
|
+
url: `${IMGFLIP_API_URL}/caption_image`,
|
|
90
|
+
headers: {
|
|
91
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
92
|
+
},
|
|
93
|
+
body,
|
|
94
|
+
});
|
|
95
|
+
if (!response.body.success) {
|
|
96
|
+
throw new Error(`Failed to generate meme: ${response.body.error_message || 'Unknown error'}`);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
imageUrl: response.body.data.url,
|
|
101
|
+
pageUrl: response.body.data.page_url,
|
|
102
|
+
templateId,
|
|
103
|
+
texts: {
|
|
104
|
+
text0,
|
|
105
|
+
text1: text1 || null,
|
|
106
|
+
text2: text2 || null,
|
|
107
|
+
text3: text3 || null,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=generate-meme-from-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-meme-from-template.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-gen-image/src/lib/actions/generate-meme-from-template.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAsE;AAEtE,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAErC,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,wBAAgB;IACtB,IAAI,EAAE,6BAA6B;IACnC,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE,mFAAmF;IAChG,KAAK,EAAE;QACH,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,iIAAiI;YAC9I,QAAQ,EAAE,IAAI;SACjB,CAAC;QAC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I,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,IAAI,CAAC,aAAa,IAAI,eAAe,EAAE,CAAC,CAAC;YAClG,CAAC;YAED,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;gBAChC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;gBACpC,UAAU;gBACV,KAAK,EAAE;oBACH,KAAK;oBACL,KAAK,EAAE,KAAK,IAAI,IAAI;oBACpB,KAAK,EAAE,KAAK,IAAI,IAAI;oBACpB,KAAK,EAAE,KAAK,IAAI,IAAI;iBACvB;aACJ,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const generateMemeWithAI: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
openaiApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
3
|
+
imgflipUsername: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
imgflipPassword: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
topic: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
7
|
+
model: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
8
|
+
prefixText: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMemeWithAI = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const IMGFLIP_API_URL = 'https://api.imgflip.com';
|
|
9
|
+
exports.generateMemeWithAI = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: index_1.skaiGenImageAuth,
|
|
11
|
+
name: 'generate_meme_with_ai',
|
|
12
|
+
displayName: 'Generate Meme with AI',
|
|
13
|
+
description: 'Let AI pick the best template and generate captions based on your topic (Imgflip Premium required)',
|
|
14
|
+
props: {
|
|
15
|
+
topic: pieces_framework_1.Property.LongText({
|
|
16
|
+
displayName: 'Topic / Theme',
|
|
17
|
+
description: 'What should the meme be about? E.g., "winning at the casino", "crypto going up", "Monday mornings"',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
model: pieces_framework_1.Property.StaticDropdown({
|
|
21
|
+
displayName: 'AI Model',
|
|
22
|
+
description: 'Which AI model to use for caption generation',
|
|
23
|
+
required: false,
|
|
24
|
+
defaultValue: 'openai',
|
|
25
|
+
options: {
|
|
26
|
+
options: [
|
|
27
|
+
{ label: 'GPT (Better captions, recommended)', value: 'openai' },
|
|
28
|
+
{ label: 'Classic (Random, can be funnier)', value: 'classic' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
prefixText: pieces_framework_1.Property.ShortText({
|
|
33
|
+
displayName: 'Prefix Text',
|
|
34
|
+
description: 'Optional text to include at the start (e.g., brand name, promo code)',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
run(context) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const { topic, model, prefixText } = context.propsValue;
|
|
42
|
+
const auth = context.auth;
|
|
43
|
+
// Build the request body
|
|
44
|
+
const formData = {
|
|
45
|
+
username: auth.imgflipUsername,
|
|
46
|
+
password: auth.imgflipPassword,
|
|
47
|
+
text: topic,
|
|
48
|
+
};
|
|
49
|
+
if (model)
|
|
50
|
+
formData['model'] = model;
|
|
51
|
+
if (prefixText)
|
|
52
|
+
formData['prefix_text'] = prefixText;
|
|
53
|
+
// Convert to URL-encoded form data
|
|
54
|
+
const body = Object.entries(formData)
|
|
55
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
56
|
+
.join('&');
|
|
57
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
58
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
59
|
+
url: `${IMGFLIP_API_URL}/ai_meme`,
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
62
|
+
},
|
|
63
|
+
body,
|
|
64
|
+
});
|
|
65
|
+
if (!response.body.success) {
|
|
66
|
+
// Check if it's a premium required error
|
|
67
|
+
if (((_a = response.body.error_message) === null || _a === void 0 ? void 0 : _a.includes('premium')) || ((_b = response.body.error_message) === null || _b === void 0 ? void 0 : _b.includes('Premium'))) {
|
|
68
|
+
throw new Error('AI Meme generation requires Imgflip Premium subscription. Get it at https://imgflip.com/pro');
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Failed to generate AI meme: ${response.body.error_message || 'Unknown error'}`);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
imageUrl: response.body.data.url,
|
|
75
|
+
pageUrl: response.body.data.page_url,
|
|
76
|
+
templateUsed: response.body.data.template || null,
|
|
77
|
+
generatedTexts: response.body.data.texts || null,
|
|
78
|
+
topic,
|
|
79
|
+
model: model || 'openai',
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=generate-meme-with-ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-meme-with-ai.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-gen-image/src/lib/actions/generate-meme-with-ai.ts"],"names":[],"mappings":";;;;AAA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BACjD,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI;gBAChD,KAAK;gBACL,KAAK,EAAE,KAAK,IAAI,QAAQ;aAC3B,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getTrendingTemplates: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
openaiApiKey: import("@activepieces/pieces-framework").SecretTextProperty<false>;
|
|
3
|
+
imgflipUsername: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
imgflipPassword: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTrendingTemplates = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const IMGFLIP_API_URL = 'https://api.imgflip.com';
|
|
9
|
+
// Popular meme templates with descriptions for AI selection
|
|
10
|
+
const TEMPLATE_DESCRIPTIONS = {
|
|
11
|
+
'181913649': 'Drake Hotline Bling - Two panel, top shows rejection/dislike, bottom shows approval/preference',
|
|
12
|
+
'87743020': 'Two Buttons - Person sweating while choosing between two difficult options',
|
|
13
|
+
'112126428': 'Distracted Boyfriend - Person looking at something new while partner looks disapprovingly',
|
|
14
|
+
'131087935': 'Running Away Balloon - Person chasing after something while ignoring what they have',
|
|
15
|
+
'97984': 'Disaster Girl - Girl smiling deviously in front of burning house',
|
|
16
|
+
'438680': 'Batman Slapping Robin - Batman slapping Robin mid-sentence to correct him',
|
|
17
|
+
'61579': 'One Does Not Simply - Boromir explaining something is not easy',
|
|
18
|
+
'101470': 'Ancient Aliens - Guy suggesting aliens as explanation',
|
|
19
|
+
'61532': 'The Rock Driving - Rock driving car, reaction to something said',
|
|
20
|
+
'91538330': 'X X Everywhere - Buzz Lightyear showing Woody something is everywhere',
|
|
21
|
+
'124822590': 'Left Exit 12 Off Ramp - Car swerving to take exit at last moment',
|
|
22
|
+
'217743513': 'UNO Draw 25 - Choice between doing something or drawing 25 cards',
|
|
23
|
+
'252600902': 'Always Has Been - Two astronauts, one realizing truth, other says always has been',
|
|
24
|
+
'188390779': 'Woman Yelling at Cat - Woman yelling at confused cat at dinner table',
|
|
25
|
+
'119139145': 'Blank Nut Button - Person eagerly pressing a button',
|
|
26
|
+
'135256802': 'Epic Handshake - Two arms meeting in agreement on common ground',
|
|
27
|
+
'129242436': 'Change My Mind - Person at table challenging others to change their mind',
|
|
28
|
+
'222403160': 'Bernie I Am Once Again Asking - Bernie Sanders asking for something',
|
|
29
|
+
'247375501': 'Buff Doge vs Cheems - Strong dog vs weak dog comparison',
|
|
30
|
+
'259237855': 'Laughing Leo - Leonardo DiCaprio laughing and pointing',
|
|
31
|
+
};
|
|
32
|
+
exports.getTrendingTemplates = (0, pieces_framework_1.createAction)({
|
|
33
|
+
auth: index_1.skaiGenImageAuth,
|
|
34
|
+
name: 'get_trending_templates',
|
|
35
|
+
displayName: 'Get Trending Meme Templates',
|
|
36
|
+
description: 'Get the most popular meme templates from Imgflip (Drake, Distracted Boyfriend, etc.)',
|
|
37
|
+
props: {},
|
|
38
|
+
run() {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
41
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
42
|
+
url: `${IMGFLIP_API_URL}/get_memes`,
|
|
43
|
+
});
|
|
44
|
+
if (!response.body.success) {
|
|
45
|
+
throw new Error(`Failed to get meme templates: ${response.body.error_message || 'Unknown error'}`);
|
|
46
|
+
}
|
|
47
|
+
const memes = response.body.data.memes;
|
|
48
|
+
// Enrich templates with descriptions
|
|
49
|
+
const enrichedMemes = memes.map((meme) => ({
|
|
50
|
+
id: meme.id,
|
|
51
|
+
name: meme.name,
|
|
52
|
+
url: meme.url,
|
|
53
|
+
width: meme.width,
|
|
54
|
+
height: meme.height,
|
|
55
|
+
boxCount: meme.box_count,
|
|
56
|
+
description: TEMPLATE_DESCRIPTIONS[meme.id] || `${meme.name} - ${meme.box_count} text boxes`,
|
|
57
|
+
}));
|
|
58
|
+
return {
|
|
59
|
+
success: true,
|
|
60
|
+
templates: enrichedMemes,
|
|
61
|
+
totalCount: enrichedMemes.length,
|
|
62
|
+
// Top 20 for quick reference
|
|
63
|
+
topTemplates: enrichedMemes.slice(0, 20).map((m) => ({
|
|
64
|
+
id: m.id,
|
|
65
|
+
name: m.name,
|
|
66
|
+
description: m.description,
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=get-trending-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trending-templates.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-gen-image/src/lib/actions/get-trending-templates.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAqE;AACrE,uCAA+C;AAE/C,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAElD,4DAA4D;AAC5D,MAAM,qBAAqB,GAA2B;IAClD,WAAW,EAAE,gGAAgG;IAC7G,UAAU,EAAE,4EAA4E;IACxF,WAAW,EAAE,2FAA2F;IACxG,WAAW,EAAE,qFAAqF;IAClG,OAAO,EAAE,kEAAkE;IAC3E,QAAQ,EAAE,2EAA2E;IACrF,OAAO,EAAE,gEAAgE;IACzE,QAAQ,EAAE,uDAAuD;IACjE,OAAO,EAAE,iEAAiE;IAC1E,UAAU,EAAE,uEAAuE;IACnF,WAAW,EAAE,kEAAkE;IAC/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