@memberjunction/ai-heygen 6.1.0-edge.2 → 6.1.0-edge.4
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +41 -0
- package/LICENSE +180 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/HeyGenVideoGenerator.test.ts +14 -16
- package/src/index.ts +26 -7
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @memberjunction/ai-heygen
|
|
2
2
|
|
|
3
|
+
## 6.1.0-edge.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7857d8e: Add `@memberjunction/network-utils` and remove `axios` from the repository.
|
|
8
|
+
|
|
9
|
+
The SSRF guard added for the web/HTTP actions was Actions-specific but the concern is not, so it
|
|
10
|
+
moves into a new dependency-free, Node-only package (`node:dns` + `node:net` only) that any
|
|
11
|
+
server-side package can depend on: `AssertPublicUrl`, `SafeFetch`, `IsBlockedIPAddress`, `SSRFError`.
|
|
12
|
+
|
|
13
|
+
The same package ships `HttpClient` / `HttpRequest` — a native-`fetch` HTTP client that replaces
|
|
14
|
+
`axios` across all 11 packages that used it. Consolidating on one client removes the third-party
|
|
15
|
+
dependency and puts the SSRF guard one option flag (`ValidateUrl`) away from every outbound call
|
|
16
|
+
site, which was impossible when each package reached for `axios` directly.
|
|
17
|
+
|
|
18
|
+
Also fixes an SSRF sink the original pass missed: the `API Rate Limiter` action takes a
|
|
19
|
+
caller-controlled URL and returns the response body, and is now guarded.
|
|
20
|
+
|
|
21
|
+
Public exports use `PascalCase`, per repo convention.
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [e533ce5]
|
|
24
|
+
- Updated dependencies [4586215]
|
|
25
|
+
- Updated dependencies [a5f92d2]
|
|
26
|
+
- Updated dependencies [7857d8e]
|
|
27
|
+
- @memberjunction/ai@6.1.0-edge.4
|
|
28
|
+
- @memberjunction/global@6.1.0-edge.4
|
|
29
|
+
- @memberjunction/network-utils@6.1.0-edge.4
|
|
30
|
+
|
|
31
|
+
## 6.1.0-edge.3
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [834f8d7]
|
|
36
|
+
- Updated dependencies [f5ec13b]
|
|
37
|
+
- Updated dependencies [cefc302]
|
|
38
|
+
- Updated dependencies [be0bdb2]
|
|
39
|
+
- Updated dependencies [f5ec13b]
|
|
40
|
+
- Updated dependencies [1bd9674]
|
|
41
|
+
- @memberjunction/global@6.1.0-edge.3
|
|
42
|
+
- @memberjunction/ai@6.1.0-edge.3
|
|
43
|
+
|
|
3
44
|
## 6.1.0-edge.2
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,183 @@
|
|
|
1
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAiB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AAsBnH,qBACa,oBAAqB,SAAQ,kBAAkB;IACxD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,WAAW,CAA+C;gBAEtD,MAAM,EAAE,MAAM;IAIb,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IA6ClE,sBAAsB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzD,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAsBnC,mBAAmB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGxD"}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { RegisterClass } from "@memberjunction/global";
|
|
11
11
|
import { AvatarInfo, BaseVideoGenerator, VideoResult, ErrorAnalyzer } from "@memberjunction/ai";
|
|
12
|
-
import
|
|
12
|
+
import { HttpGet, HttpPost } from "@memberjunction/network-utils";
|
|
13
13
|
let HeyGenVideoGenerator = class HeyGenVideoGenerator extends BaseVideoGenerator {
|
|
14
14
|
constructor(apiKey) {
|
|
15
15
|
super(apiKey);
|
|
@@ -19,7 +19,7 @@ let HeyGenVideoGenerator = class HeyGenVideoGenerator extends BaseVideoGenerator
|
|
|
19
19
|
async CreateAvatarVideo(params) {
|
|
20
20
|
const videoResult = new VideoResult();
|
|
21
21
|
try {
|
|
22
|
-
const response = await
|
|
22
|
+
const response = await HttpPost(this._generateUrl, {
|
|
23
23
|
video_inputs: [
|
|
24
24
|
{
|
|
25
25
|
character: {
|
|
@@ -44,9 +44,9 @@ let HeyGenVideoGenerator = class HeyGenVideoGenerator extends BaseVideoGenerator
|
|
|
44
44
|
height: params.outputHeight,
|
|
45
45
|
}
|
|
46
46
|
}, {
|
|
47
|
-
|
|
47
|
+
Headers: { Accept: 'application/json', 'X-Api-Key': this.apiKey }
|
|
48
48
|
});
|
|
49
|
-
videoResult.videoId = response.
|
|
49
|
+
videoResult.videoId = response.Data.data.video_id;
|
|
50
50
|
videoResult.success = true;
|
|
51
51
|
}
|
|
52
52
|
catch (error) {
|
|
@@ -63,10 +63,10 @@ let HeyGenVideoGenerator = class HeyGenVideoGenerator extends BaseVideoGenerator
|
|
|
63
63
|
async GetAvatars() {
|
|
64
64
|
const result = [];
|
|
65
65
|
try {
|
|
66
|
-
const response = await
|
|
67
|
-
|
|
66
|
+
const response = await HttpGet(this._avatarsUrl, {
|
|
67
|
+
Headers: { Accept: 'application/json', 'X-Api-Key': this.apiKey }
|
|
68
68
|
});
|
|
69
|
-
for (const avatar of response.
|
|
69
|
+
for (const avatar of response.Data.data.avatars) {
|
|
70
70
|
const avatarInfo = new AvatarInfo();
|
|
71
71
|
avatarInfo.id = avatar.avatar_id;
|
|
72
72
|
avatarInfo.name = avatar.avatar_name;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAqB,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAqB,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAsB3D,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,kBAAkB;IAIxD,YAAY,MAAc;QACtB,KAAK,CAAC,MA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;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC5B,OAAO,CAAC,mBAAmB,EAAE,wBAAwB,EAAE,YAAY,CAAC,CAAC;IACzE,CAAC;CACJ,CAAA;AAlFY,oBAAoB;IADhC,aAAa,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;;GAC7C,oBAAoB,CAkFhC"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai-heygen",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.1.0-edge.
|
|
4
|
+
"version": "6.1.0-edge.4",
|
|
5
5
|
"description": "MemberJunction Wrapper for HeyGen Video Generation",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"author": "MemberJunction.com",
|
|
8
|
-
"license": "
|
|
8
|
+
"license": "BUSL-1.1",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"ts-node-dev": "^2.0.0",
|
|
11
11
|
"typescript": "^5.9.3"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"@memberjunction/
|
|
16
|
-
"
|
|
17
|
-
"@
|
|
14
|
+
"@elevenlabs/elevenlabs-js": "^2.34.0",
|
|
15
|
+
"@memberjunction/ai": "6.1.0-edge.4",
|
|
16
|
+
"@memberjunction/global": "6.1.0-edge.4",
|
|
17
|
+
"@memberjunction/network-utils": "6.1.0-edge.4"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -3,14 +3,12 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
3
3
|
/* ------------------------------------------------------------------ */
|
|
4
4
|
/* Hoisted mocks */
|
|
5
5
|
/* ------------------------------------------------------------------ */
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
vi.mock('
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get: mockAxiosGet,
|
|
13
|
-
},
|
|
6
|
+
const mockHttpPost = vi.hoisted(() => vi.fn());
|
|
7
|
+
const mockHttpGet = vi.hoisted(() => vi.fn());
|
|
8
|
+
|
|
9
|
+
vi.mock('@memberjunction/network-utils', () => ({
|
|
10
|
+
HttpPost: mockHttpPost,
|
|
11
|
+
HttpGet: mockHttpGet,
|
|
14
12
|
}));
|
|
15
13
|
|
|
16
14
|
vi.mock('@memberjunction/global', () => ({
|
|
@@ -73,8 +71,8 @@ describe('HeyGenVideoGenerator', () => {
|
|
|
73
71
|
/* ---- CreateAvatarVideo request building ---- */
|
|
74
72
|
describe('CreateAvatarVideo', () => {
|
|
75
73
|
it('should build correct API request and return videoId on success', async () => {
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
mockHttpPost.mockResolvedValueOnce({
|
|
75
|
+
Data: { data: { video_id: 'vid-123' } },
|
|
78
76
|
});
|
|
79
77
|
|
|
80
78
|
const params = {
|
|
@@ -93,7 +91,7 @@ describe('HeyGenVideoGenerator', () => {
|
|
|
93
91
|
expect(result.success).toBe(true);
|
|
94
92
|
expect(result.videoId).toBe('vid-123');
|
|
95
93
|
|
|
96
|
-
expect(
|
|
94
|
+
expect(mockHttpPost).toHaveBeenCalledWith(
|
|
97
95
|
'https://api.heygen.com/v2/video/generate',
|
|
98
96
|
expect.objectContaining({
|
|
99
97
|
video_inputs: expect.arrayContaining([
|
|
@@ -106,13 +104,13 @@ describe('HeyGenVideoGenerator', () => {
|
|
|
106
104
|
dimension: { width: 1920, height: 1080 },
|
|
107
105
|
}),
|
|
108
106
|
expect.objectContaining({
|
|
109
|
-
|
|
107
|
+
Headers: expect.objectContaining({ 'X-Api-Key': 'test-heygen-key' }),
|
|
110
108
|
}),
|
|
111
109
|
);
|
|
112
110
|
});
|
|
113
111
|
|
|
114
112
|
it('should return error result on API failure', async () => {
|
|
115
|
-
|
|
113
|
+
mockHttpPost.mockRejectedValueOnce(new Error('HeyGen API error'));
|
|
116
114
|
|
|
117
115
|
const params = {
|
|
118
116
|
avatarId: 'avatar1',
|
|
@@ -135,8 +133,8 @@ describe('HeyGenVideoGenerator', () => {
|
|
|
135
133
|
/* ---- GetAvatars ---- */
|
|
136
134
|
describe('GetAvatars', () => {
|
|
137
135
|
it('should parse avatar list from API response', async () => {
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
mockHttpGet.mockResolvedValueOnce({
|
|
137
|
+
Data: {
|
|
140
138
|
data: {
|
|
141
139
|
avatars: [
|
|
142
140
|
{
|
|
@@ -167,7 +165,7 @@ describe('HeyGenVideoGenerator', () => {
|
|
|
167
165
|
});
|
|
168
166
|
|
|
169
167
|
it('should return empty array on error', async () => {
|
|
170
|
-
|
|
168
|
+
mockHttpGet.mockRejectedValueOnce(new Error('API error'));
|
|
171
169
|
const avatars = await video.GetAvatars();
|
|
172
170
|
expect(avatars).toEqual([]);
|
|
173
171
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { RegisterClass } from "@memberjunction/global";
|
|
2
2
|
import { AvatarInfo, AvatarVideoParams, BaseVideoGenerator, VideoResult, ErrorAnalyzer } from "@memberjunction/ai";
|
|
3
|
-
import
|
|
3
|
+
import { HttpGet, HttpPost } from "@memberjunction/network-utils";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/** Response from HeyGen's `POST /v2/video/generate`. */
|
|
7
|
+
interface HeyGenGenerateResponse {
|
|
8
|
+
data: { video_id: string };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Response from HeyGen's `GET /v2/avatars`. */
|
|
12
|
+
interface HeyGenAvatarsResponse {
|
|
13
|
+
data: {
|
|
14
|
+
avatars: Array<{
|
|
15
|
+
avatar_id: string;
|
|
16
|
+
avatar_name: string;
|
|
17
|
+
gender: string;
|
|
18
|
+
preview_image_url: string;
|
|
19
|
+
preview_video_url: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
4
23
|
|
|
5
24
|
@RegisterClass(BaseVideoGenerator, "HeyGenVideoGenerator")
|
|
6
25
|
export class HeyGenVideoGenerator extends BaseVideoGenerator {
|
|
@@ -14,7 +33,7 @@ export class HeyGenVideoGenerator extends BaseVideoGenerator {
|
|
|
14
33
|
public async CreateAvatarVideo(params: AvatarVideoParams): Promise<VideoResult> {
|
|
15
34
|
const videoResult = new VideoResult();
|
|
16
35
|
try {
|
|
17
|
-
const response = await
|
|
36
|
+
const response = await HttpPost<HeyGenGenerateResponse>(
|
|
18
37
|
this._generateUrl, {
|
|
19
38
|
video_inputs: [
|
|
20
39
|
{
|
|
@@ -41,11 +60,11 @@ export class HeyGenVideoGenerator extends BaseVideoGenerator {
|
|
|
41
60
|
}
|
|
42
61
|
},
|
|
43
62
|
{
|
|
44
|
-
|
|
63
|
+
Headers: { Accept: 'application/json', 'X-Api-Key': this.apiKey }
|
|
45
64
|
}
|
|
46
65
|
);
|
|
47
66
|
|
|
48
|
-
videoResult.videoId = response.
|
|
67
|
+
videoResult.videoId = response.Data.data.video_id;
|
|
49
68
|
videoResult.success = true;
|
|
50
69
|
} catch (error) {
|
|
51
70
|
const errorInfo = ErrorAnalyzer.analyzeError(error, 'HeyGen');
|
|
@@ -63,10 +82,10 @@ export class HeyGenVideoGenerator extends BaseVideoGenerator {
|
|
|
63
82
|
public async GetAvatars(): Promise<AvatarInfo[]> {
|
|
64
83
|
const result: AvatarInfo[] = [];
|
|
65
84
|
try {
|
|
66
|
-
const response = await
|
|
67
|
-
|
|
85
|
+
const response = await HttpGet<HeyGenAvatarsResponse>(this._avatarsUrl, {
|
|
86
|
+
Headers: { Accept: 'application/json', 'X-Api-Key': this.apiKey }
|
|
68
87
|
});
|
|
69
|
-
for (const avatar of response.
|
|
88
|
+
for (const avatar of response.Data.data.avatars) {
|
|
70
89
|
const avatarInfo = new AvatarInfo();
|
|
71
90
|
avatarInfo.id = avatar.avatar_id;
|
|
72
91
|
avatarInfo.name = avatar.avatar_name;
|