@activepieces/piece-alt-text-ai 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/README.md +7 -0
- package/package.json +25 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +31 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/generate-alt-text.d.ts +6 -0
- package/src/lib/actions/generate-alt-text.js +57 -0
- package/src/lib/actions/generate-alt-text.js.map +1 -0
- package/src/lib/common/auth.d.ts +1 -0
- package/src/lib/common/auth.js +33 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/constants.d.ts +1 -0
- package/src/lib/common/constants.js +5 -0
- package/src/lib/common/constants.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-alt-text-ai",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@sinclair/typebox": "0.34.11",
|
|
9
|
+
"axios": "1.13.1",
|
|
10
|
+
"axios-retry": "4.4.1",
|
|
11
|
+
"deepmerge-ts": "7.1.0",
|
|
12
|
+
"mime-types": "2.1.35",
|
|
13
|
+
"nanoid": "3.3.8",
|
|
14
|
+
"semver": "7.6.0",
|
|
15
|
+
"socket.io-client": "4.8.1",
|
|
16
|
+
"tslib": "^2.3.0",
|
|
17
|
+
"zod": "4.1.13",
|
|
18
|
+
"@activepieces/pieces-common": "0.10.1",
|
|
19
|
+
"@activepieces/pieces-framework": "0.22.2",
|
|
20
|
+
"@activepieces/shared": "0.30.1"
|
|
21
|
+
},
|
|
22
|
+
"resolutions": {
|
|
23
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const altTextAi: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.altTextAi = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const generate_alt_text_1 = require("./lib/actions/generate-alt-text");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const auth_1 = require("./lib/common/auth");
|
|
9
|
+
const constants_1 = require("./lib/common/constants");
|
|
10
|
+
const shared_1 = require("@activepieces/shared");
|
|
11
|
+
exports.altTextAi = (0, pieces_framework_1.createPiece)({
|
|
12
|
+
displayName: "AltText.ai",
|
|
13
|
+
categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
|
|
14
|
+
auth: auth_1.altTextAiAuth,
|
|
15
|
+
minimumSupportedRelease: '0.36.1',
|
|
16
|
+
logoUrl: "https://cdn.activepieces.com/pieces/alt-text-ai.png",
|
|
17
|
+
authors: ['kishanprmr'],
|
|
18
|
+
actions: [generate_alt_text_1.generateAltTextAction,
|
|
19
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
20
|
+
auth: auth_1.altTextAiAuth,
|
|
21
|
+
baseUrl: () => constants_1.BASE_URL,
|
|
22
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
return {
|
|
24
|
+
'X-API-Key': auth.secret_text
|
|
25
|
+
};
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
],
|
|
29
|
+
triggers: [],
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/alt-text-ai/src/index.ts"],"names":[],"mappings":";;;;AACI,qEAAwE;AAC5E,uEAAwE;AACxE,+DAAwE;AACxE,4CAAkD;AAClD,sDAAkD;AAClD,iDAAqD;AAEpC,QAAA,SAAS,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,YAAY;IACzB,UAAU,EAAC,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IAClD,IAAI,EAAE,oBAAa;IACnB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,qDAAqD;IAC9D,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,OAAO,EAAE,CAAC,yCAAqB;QAC7B,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAC,oBAAa;YAClB,OAAO,EAAC,GAAE,EAAE,CAAA,oBAAQ;YACpB,WAAW,EAAC,CAAO,IAAI,EAAC,EAAE;gBACxB,OAAM;oBACJ,WAAW,EAAC,IAAI,CAAC,WAAW;iBAC7B,CAAA;YACH,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const generateAltTextAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
image: import("@activepieces/pieces-framework").FileProperty<true>;
|
|
3
|
+
keywords: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
4
|
+
negativeKeywords: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
5
|
+
keywordSource: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAltTextAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../common/auth");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const constants_1 = require("../common/constants");
|
|
9
|
+
exports.generateAltTextAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'generate-alt-text',
|
|
11
|
+
auth: auth_1.altTextAiAuth,
|
|
12
|
+
displayName: 'Generate Alt Text',
|
|
13
|
+
description: 'Generates a descriptive alt text for a given image.',
|
|
14
|
+
props: {
|
|
15
|
+
image: pieces_framework_1.Property.File({
|
|
16
|
+
displayName: 'Image',
|
|
17
|
+
required: true
|
|
18
|
+
}),
|
|
19
|
+
keywords: pieces_framework_1.Property.Array({
|
|
20
|
+
displayName: 'Keywords',
|
|
21
|
+
required: false,
|
|
22
|
+
description: 'keywords / phrases to be considered when generating the alt text.'
|
|
23
|
+
}),
|
|
24
|
+
negativeKeywords: pieces_framework_1.Property.Array({
|
|
25
|
+
displayName: 'Negative Keywords',
|
|
26
|
+
required: false,
|
|
27
|
+
description: 'negative keywords / phrases to be removed from any generated alt text.'
|
|
28
|
+
}),
|
|
29
|
+
keywordSource: pieces_framework_1.Property.LongText({
|
|
30
|
+
displayName: 'Keyword Source',
|
|
31
|
+
required: false,
|
|
32
|
+
description: 'Text to use as the source of keywords for the alt text.'
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
run(context) {
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { image, keywords, keywordSource, negativeKeywords } = context.propsValue;
|
|
38
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
39
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
40
|
+
url: constants_1.BASE_URL + '/images',
|
|
41
|
+
headers: {
|
|
42
|
+
'X-API-Key': context.auth.secret_text
|
|
43
|
+
},
|
|
44
|
+
body: {
|
|
45
|
+
image: {
|
|
46
|
+
raw: image.base64
|
|
47
|
+
},
|
|
48
|
+
keywords,
|
|
49
|
+
keyword_source: keywordSource,
|
|
50
|
+
negative_keywords: negativeKeywords
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return response.body;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=generate-alt-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-alt-text.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/alt-text-ai/src/lib/actions/generate-alt-text.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA+C;AAC/C,+DAAqE;AACrE,mDAA+C;AAElC,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,oBAAa;IACnB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE;QACH,KAAK,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACjB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACrB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,mEAAmE;SACnF,CAAC;QACF,gBAAgB,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC7B,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,wEAAwE;SACxF,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC7B,WAAW,EAAE,gBAAgB;YAC7B,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,yDAAyD;SACzE,CAAC;KACL;IACK,GAAG,CAAC,OAAO;;YACb,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEhF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,oBAAQ,GAAG,SAAS;gBACzB,OAAO,EAAE;oBACL,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;iBACxC;gBACD,IAAI,EAAE;oBACF,KAAK,EAAE;wBACH,GAAG,EAAE,KAAK,CAAC,MAAM;qBACpB;oBACD,QAAQ;oBACR,cAAc,EAAE,aAAa;oBAC7B,iBAAiB,EAAE,gBAAgB;iBACtC;aACJ,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACzB,CAAC;KAAA;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const altTextAiAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.altTextAiAuth = 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 constants_1 = require("./constants");
|
|
8
|
+
exports.altTextAiAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
9
|
+
displayName: 'API Key',
|
|
10
|
+
required: true,
|
|
11
|
+
description: `You can obtain your API key from [Account Settings](https://alttext.ai/account/api_keys).`,
|
|
12
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
13
|
+
try {
|
|
14
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
15
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
16
|
+
url: constants_1.BASE_URL + '/account',
|
|
17
|
+
headers: {
|
|
18
|
+
'X-API-Key': auth
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
valid: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (_b) {
|
|
26
|
+
return {
|
|
27
|
+
valid: false,
|
|
28
|
+
error: 'Invalid API Key'
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/alt-text-ai/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAA2D;AAC3D,+DAAqE;AACrE,2CAAuC;AAE1B,QAAA,aAAa,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,2FAA2F;IACxG,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACrB,IAAI,CAAC;YACD,MAAM,0BAAU,CAAC,WAAW,CAAC;gBACzB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,oBAAQ,GAAG,UAAU;gBAC1B,OAAO,EAAE;oBACL,WAAW,EAAE,IAAI;iBACpB;aACJ,CAAC,CAAA;YAEF,OAAO;gBACH,KAAK,EAAE,IAAI;aACd,CAAA;QAEL,CAAC;QAAC,WAAM,CAAC;YACL,OAAO;gBACH,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,iBAAiB;aAC3B,CAAA;QACL,CAAC;IACL,CAAC,CAAA;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BASE_URL = "https://alttext.ai/api/v1";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/alt-text-ai/src/lib/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,2BAA2B,CAAA"}
|