ugcinc 2.16.0 → 2.17.0
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/dist/automations.d.ts +5 -1
- package/dist/automations.js +4 -9
- package/dist/base.d.ts +2 -1
- package/dist/base.js +47 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/media.d.ts +34 -0
- package/dist/media.js +54 -0
- package/dist/types.d.ts +63 -0
- package/package.json +1 -4
package/dist/automations.d.ts
CHANGED
|
@@ -14,13 +14,17 @@ export declare class AutomationsClient extends BaseClient {
|
|
|
14
14
|
templateId: string;
|
|
15
15
|
}): Promise<ApiResponse<AutomationTemplate>>;
|
|
16
16
|
/**
|
|
17
|
-
* Create
|
|
17
|
+
* Create or update an automation template
|
|
18
|
+
* @param templateId - If provided, updates existing template instead of creating new one
|
|
19
|
+
* @param skipValidation - If true, skips workflow validation (for saving drafts)
|
|
18
20
|
*/
|
|
19
21
|
createTemplate(params: {
|
|
20
22
|
orgId: string;
|
|
21
23
|
name: string;
|
|
22
24
|
description?: string;
|
|
23
25
|
workflowDefinition: WorkflowDefinition;
|
|
26
|
+
templateId?: string;
|
|
27
|
+
skipValidation?: boolean;
|
|
24
28
|
}): Promise<ApiResponse<string>>;
|
|
25
29
|
/**
|
|
26
30
|
* Delete an automation template
|
package/dist/automations.js
CHANGED
|
@@ -24,7 +24,9 @@ class AutomationsClient extends base_1.BaseClient {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Create
|
|
27
|
+
* Create or update an automation template
|
|
28
|
+
* @param templateId - If provided, updates existing template instead of creating new one
|
|
29
|
+
* @param skipValidation - If true, skips workflow validation (for saving drafts)
|
|
28
30
|
*/
|
|
29
31
|
async createTemplate(params) {
|
|
30
32
|
return this.request('/automations/create', {
|
|
@@ -162,14 +164,7 @@ function getAllNodes() {
|
|
|
162
164
|
label: "Video Editor",
|
|
163
165
|
description: "Edit and transform videos",
|
|
164
166
|
category: "Input",
|
|
165
|
-
inputs: [
|
|
166
|
-
{
|
|
167
|
-
id: "video",
|
|
168
|
-
title: "video",
|
|
169
|
-
type: "video",
|
|
170
|
-
required: true,
|
|
171
|
-
},
|
|
172
|
-
],
|
|
167
|
+
inputs: [], // Dynamic inputs based on segments in editor config
|
|
173
168
|
outputs: [
|
|
174
169
|
{
|
|
175
170
|
id: "output",
|
package/dist/base.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ export interface ClientConfig {
|
|
|
6
6
|
export declare class BaseClient {
|
|
7
7
|
protected apiKey: string;
|
|
8
8
|
protected orgId?: string;
|
|
9
|
-
|
|
9
|
+
protected readonly baseUrl = "https://api.ugc.inc";
|
|
10
10
|
constructor(config: ClientConfig);
|
|
11
11
|
protected request<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
|
|
12
12
|
protected post<T>(endpoint: string, body?: unknown): Promise<ApiResponse<T>>;
|
|
13
13
|
protected get<T>(endpoint: string): Promise<ApiResponse<T>>;
|
|
14
|
+
protected postFormData<T>(endpoint: string, formData: FormData): Promise<ApiResponse<T>>;
|
|
14
15
|
}
|
package/dist/base.js
CHANGED
|
@@ -67,5 +67,52 @@ class BaseClient {
|
|
|
67
67
|
method: 'GET',
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
+
async postFormData(endpoint, formData) {
|
|
71
|
+
let url = `${this.baseUrl}${endpoint}`;
|
|
72
|
+
// If orgId is provided, treat apiKey as admin key and add orgId as query param
|
|
73
|
+
if (this.orgId) {
|
|
74
|
+
const separator = endpoint.includes('?') ? '&' : '?';
|
|
75
|
+
url = `${url}${separator}orgId=${encodeURIComponent(this.orgId)}`;
|
|
76
|
+
}
|
|
77
|
+
const headers = {};
|
|
78
|
+
// Use admin key header if orgId is provided, otherwise use Bearer token
|
|
79
|
+
if (this.orgId) {
|
|
80
|
+
headers['x-api-key'] = this.apiKey;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const response = await fetch(url, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
headers,
|
|
89
|
+
body: formData,
|
|
90
|
+
});
|
|
91
|
+
const rawData = await response.json();
|
|
92
|
+
const isSuccess = response.ok && rawData.code >= 200 && rawData.code < 300;
|
|
93
|
+
if (isSuccess && rawData.data !== undefined) {
|
|
94
|
+
return {
|
|
95
|
+
ok: true,
|
|
96
|
+
code: rawData.code,
|
|
97
|
+
message: rawData.message ?? 'Success',
|
|
98
|
+
data: rawData.data,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return {
|
|
103
|
+
ok: false,
|
|
104
|
+
code: rawData.code,
|
|
105
|
+
message: rawData.message ?? 'Request failed',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
code: 500,
|
|
113
|
+
message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
70
117
|
}
|
|
71
118
|
exports.BaseClient = BaseClient;
|
package/dist/client.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { StatsClient } from './stats';
|
|
|
5
5
|
import { OrganizationClient } from './org';
|
|
6
6
|
import { RenderClient } from './render';
|
|
7
7
|
import { AutomationsClient } from './automations';
|
|
8
|
+
import { MediaClient } from './media';
|
|
8
9
|
import type { ClientConfig } from './base';
|
|
9
10
|
/**
|
|
10
11
|
* Main UGC Inc API Client
|
|
@@ -60,5 +61,9 @@ export declare class UGCClient {
|
|
|
60
61
|
* Client for automation workflow operations
|
|
61
62
|
*/
|
|
62
63
|
automations: AutomationsClient;
|
|
64
|
+
/**
|
|
65
|
+
* Client for media operations
|
|
66
|
+
*/
|
|
67
|
+
media: MediaClient;
|
|
63
68
|
constructor(config: ClientConfig);
|
|
64
69
|
}
|
package/dist/client.js
CHANGED
|
@@ -8,6 +8,7 @@ const stats_1 = require("./stats");
|
|
|
8
8
|
const org_1 = require("./org");
|
|
9
9
|
const render_1 = require("./render");
|
|
10
10
|
const automations_1 = require("./automations");
|
|
11
|
+
const media_1 = require("./media");
|
|
11
12
|
/**
|
|
12
13
|
* Main UGC Inc API Client
|
|
13
14
|
*
|
|
@@ -42,6 +43,7 @@ class UGCClient {
|
|
|
42
43
|
this.org = new org_1.OrganizationClient(config);
|
|
43
44
|
this.render = new render_1.RenderClient(config);
|
|
44
45
|
this.automations = new automations_1.AutomationsClient(config);
|
|
46
|
+
this.media = new media_1.MediaClient(config);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
exports.UGCClient = UGCClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ export { StatsClient } from './stats';
|
|
|
11
11
|
export { OrganizationClient } from './org';
|
|
12
12
|
export { RenderClient } from './render';
|
|
13
13
|
export { AutomationsClient, getAllNodes, getNodeByType } from './automations';
|
|
14
|
+
export { MediaClient } from './media';
|
|
14
15
|
export type { ClientConfig, } from './base';
|
|
15
|
-
export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, ApiKey, EditorConfig, VideoEditorConfig, ImageEditorConfig, EditorChannel, TimeValue, BaseSegmentProps, VisualSegmentProps, EditorSegment, VideoSegment, AudioSegment, ImageSegment, TextSegment, StaticSegment, RenderJobSubmit, RenderVideoRequest, RenderImageRequest, RenderJobResponse, RenderJobStatus, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, RefreshStatsError, MediaType, NodePort, NodeControlConfig, NodeTypeEnum, WorkflowNodeDefinition, WorkflowDefinition, CanvasState, AutomationTemplate, AutomationRun, NodeRun, OutputSchemaProperty, SelectionMode, ExhaustionBehavior, SelectionConfig, SelectionState, OutputMode, } from './types';
|
|
16
|
+
export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, ApiKey, EditorConfig, VideoEditorConfig, ImageEditorConfig, EditorChannel, TimeValue, BaseSegmentProps, VisualSegmentProps, EditorSegment, VideoSegment, AudioSegment, ImageSegment, TextSegment, StaticSegment, RenderJobSubmit, RenderVideoRequest, RenderImageRequest, RenderJobResponse, RenderJobStatus, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, RefreshStatsError, MediaType, NodePort, NodeControlConfig, NodeTypeEnum, WorkflowNodeDefinition, WorkflowDefinition, CanvasState, AutomationTemplate, AutomationRun, NodeRun, OutputSchemaProperty, SelectionMode, ExhaustionBehavior, SelectionConfig, SelectionState, OutputMode, UserMedia, SocialAudio, Media, GetMediaParams, UploadMediaParams, UploadMediaResponse, UpdateMediaTagParams, DeleteMediaParams, DeleteMediaResponse, CreateSocialAudioParams, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Official TypeScript/JavaScript client for the UGC Inc API
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.getNodeByType = exports.getAllNodes = exports.AutomationsClient = exports.RenderClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
|
|
8
|
+
exports.MediaClient = exports.getNodeByType = exports.getAllNodes = exports.AutomationsClient = exports.RenderClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
|
|
9
9
|
var client_1 = require("./client");
|
|
10
10
|
Object.defineProperty(exports, "UGCClient", { enumerable: true, get: function () { return client_1.UGCClient; } });
|
|
11
11
|
var accounts_1 = require("./accounts");
|
|
@@ -24,3 +24,5 @@ var automations_1 = require("./automations");
|
|
|
24
24
|
Object.defineProperty(exports, "AutomationsClient", { enumerable: true, get: function () { return automations_1.AutomationsClient; } });
|
|
25
25
|
Object.defineProperty(exports, "getAllNodes", { enumerable: true, get: function () { return automations_1.getAllNodes; } });
|
|
26
26
|
Object.defineProperty(exports, "getNodeByType", { enumerable: true, get: function () { return automations_1.getNodeByType; } });
|
|
27
|
+
var media_1 = require("./media");
|
|
28
|
+
Object.defineProperty(exports, "MediaClient", { enumerable: true, get: function () { return media_1.MediaClient; } });
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseClient } from './base';
|
|
2
|
+
import type { Media, UserMedia, SocialAudio, GetMediaParams, UploadMediaResponse, UpdateMediaTagParams, DeleteMediaParams, DeleteMediaResponse, CreateSocialAudioParams, ApiResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for managing media files
|
|
5
|
+
*/
|
|
6
|
+
export declare class MediaClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Get all media for the organization
|
|
9
|
+
* Returns both user_media and social_audio combined
|
|
10
|
+
*/
|
|
11
|
+
getMedia(params?: GetMediaParams): Promise<ApiResponse<Media[]>>;
|
|
12
|
+
/**
|
|
13
|
+
* Upload media files
|
|
14
|
+
* Supports uploading multiple files at once
|
|
15
|
+
* Files are uploaded to Vercel Blob storage
|
|
16
|
+
*/
|
|
17
|
+
upload(files: File[], tag?: string): Promise<ApiResponse<UploadMediaResponse>>;
|
|
18
|
+
/**
|
|
19
|
+
* Update the tag on a media item
|
|
20
|
+
* Works for both user_media and social_audio
|
|
21
|
+
*/
|
|
22
|
+
updateTag(params: UpdateMediaTagParams): Promise<ApiResponse<UserMedia | SocialAudio>>;
|
|
23
|
+
/**
|
|
24
|
+
* Delete one or more media items
|
|
25
|
+
* Supports both single id and bulk ids
|
|
26
|
+
* Also deletes the files from blob storage
|
|
27
|
+
*/
|
|
28
|
+
delete(params: DeleteMediaParams): Promise<ApiResponse<DeleteMediaResponse>>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a social audio from a TikTok URL
|
|
31
|
+
* Extracts audio and cover image from TikTok video or music URL
|
|
32
|
+
*/
|
|
33
|
+
createSocialAudio(params: CreateSocialAudioParams): Promise<ApiResponse<SocialAudio>>;
|
|
34
|
+
}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MediaClient = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Client for managing media files
|
|
7
|
+
*/
|
|
8
|
+
class MediaClient extends base_1.BaseClient {
|
|
9
|
+
/**
|
|
10
|
+
* Get all media for the organization
|
|
11
|
+
* Returns both user_media and social_audio combined
|
|
12
|
+
*/
|
|
13
|
+
async getMedia(params) {
|
|
14
|
+
return this.post('/media', params ?? {});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Upload media files
|
|
18
|
+
* Supports uploading multiple files at once
|
|
19
|
+
* Files are uploaded to Vercel Blob storage
|
|
20
|
+
*/
|
|
21
|
+
async upload(files, tag) {
|
|
22
|
+
const formData = new FormData();
|
|
23
|
+
for (const file of files) {
|
|
24
|
+
formData.append('file', file);
|
|
25
|
+
}
|
|
26
|
+
if (tag) {
|
|
27
|
+
formData.append('tag', tag);
|
|
28
|
+
}
|
|
29
|
+
return this.postFormData('/media/create/upload', formData);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Update the tag on a media item
|
|
33
|
+
* Works for both user_media and social_audio
|
|
34
|
+
*/
|
|
35
|
+
async updateTag(params) {
|
|
36
|
+
return this.post('/media/update-tag', params);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Delete one or more media items
|
|
40
|
+
* Supports both single id and bulk ids
|
|
41
|
+
* Also deletes the files from blob storage
|
|
42
|
+
*/
|
|
43
|
+
async delete(params) {
|
|
44
|
+
return this.post('/media/delete', params);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a social audio from a TikTok URL
|
|
48
|
+
* Extracts audio and cover image from TikTok video or music URL
|
|
49
|
+
*/
|
|
50
|
+
async createSocialAudio(params) {
|
|
51
|
+
return this.post('/media/social-audio', params);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.MediaClient = MediaClient;
|
package/dist/types.d.ts
CHANGED
|
@@ -639,4 +639,67 @@ export interface NodeRun {
|
|
|
639
639
|
created_at: string;
|
|
640
640
|
completed_at: string | null;
|
|
641
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Media types
|
|
644
|
+
*/
|
|
645
|
+
export interface UserMedia {
|
|
646
|
+
id: string;
|
|
647
|
+
org_id: string;
|
|
648
|
+
name: string | null;
|
|
649
|
+
tag: string | null;
|
|
650
|
+
type: 'video' | 'image' | 'audio' | null;
|
|
651
|
+
url: string;
|
|
652
|
+
created_at: string;
|
|
653
|
+
media_type: 'user_media';
|
|
654
|
+
}
|
|
655
|
+
export interface SocialAudio {
|
|
656
|
+
id: string;
|
|
657
|
+
org_id: string;
|
|
658
|
+
name: string | null;
|
|
659
|
+
tag: string | null;
|
|
660
|
+
social_post_link: string | null;
|
|
661
|
+
social_audio_link: string | null;
|
|
662
|
+
platform_type: 'tiktok' | null;
|
|
663
|
+
preview_url: string | null;
|
|
664
|
+
audio_url: string | null;
|
|
665
|
+
created_at: string;
|
|
666
|
+
media_type: 'social_audio';
|
|
667
|
+
type: 'social_audio';
|
|
668
|
+
}
|
|
669
|
+
export type Media = UserMedia | SocialAudio;
|
|
670
|
+
export interface GetMediaParams {
|
|
671
|
+
tag?: string;
|
|
672
|
+
}
|
|
673
|
+
export interface UploadMediaParams {
|
|
674
|
+
files: File[];
|
|
675
|
+
tag?: string;
|
|
676
|
+
}
|
|
677
|
+
export interface UploadMediaResponse {
|
|
678
|
+
data: UserMedia[];
|
|
679
|
+
failed?: Array<{
|
|
680
|
+
name: string;
|
|
681
|
+
error: string;
|
|
682
|
+
}>;
|
|
683
|
+
message: string;
|
|
684
|
+
}
|
|
685
|
+
export interface UpdateMediaTagParams {
|
|
686
|
+
id: string;
|
|
687
|
+
tag: string;
|
|
688
|
+
}
|
|
689
|
+
export interface DeleteMediaParams {
|
|
690
|
+
id?: string;
|
|
691
|
+
ids?: string[];
|
|
692
|
+
}
|
|
693
|
+
export interface DeleteMediaResponse {
|
|
694
|
+
deleted: string[];
|
|
695
|
+
failed?: Array<{
|
|
696
|
+
id: string;
|
|
697
|
+
message: string;
|
|
698
|
+
}>;
|
|
699
|
+
message: string;
|
|
700
|
+
}
|
|
701
|
+
export interface CreateSocialAudioParams {
|
|
702
|
+
url: string;
|
|
703
|
+
tag?: string;
|
|
704
|
+
}
|
|
642
705
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "TypeScript/JavaScript client for the UGC Inc API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
"@types/node": "^20.0.0",
|
|
25
25
|
"typescript": "^5.0.0"
|
|
26
26
|
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"ugcinc": "^1.7.0"
|
|
29
|
-
},
|
|
30
27
|
"files": [
|
|
31
28
|
"dist",
|
|
32
29
|
"README.md"
|