ugcinc 2.18.0 → 2.20.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/base.d.ts +3 -0
- package/dist/base.js +9 -0
- package/dist/media.d.ts +5 -6
- package/dist/media.js +9 -13
- package/dist/types.d.ts +2 -4
- package/package.json +1 -1
package/dist/base.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare class BaseClient {
|
|
|
8
8
|
protected orgId?: string;
|
|
9
9
|
protected readonly baseUrl = "https://api.ugc.inc";
|
|
10
10
|
constructor(config: ClientConfig);
|
|
11
|
+
protected getBaseUrl(): string;
|
|
12
|
+
protected getOrgId(): string | undefined;
|
|
13
|
+
protected getApiKey(): string;
|
|
11
14
|
protected request<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
|
|
12
15
|
protected post<T>(endpoint: string, body?: unknown): Promise<ApiResponse<T>>;
|
|
13
16
|
protected get<T>(endpoint: string): Promise<ApiResponse<T>>;
|
package/dist/base.js
CHANGED
|
@@ -7,6 +7,15 @@ class BaseClient {
|
|
|
7
7
|
this.apiKey = config.apiKey;
|
|
8
8
|
this.orgId = config.orgId;
|
|
9
9
|
}
|
|
10
|
+
getBaseUrl() {
|
|
11
|
+
return this.baseUrl;
|
|
12
|
+
}
|
|
13
|
+
getOrgId() {
|
|
14
|
+
return this.orgId;
|
|
15
|
+
}
|
|
16
|
+
getApiKey() {
|
|
17
|
+
return this.apiKey;
|
|
18
|
+
}
|
|
10
19
|
async request(endpoint, options = {}) {
|
|
11
20
|
let url = `${this.baseUrl}${endpoint}`;
|
|
12
21
|
// If orgId is provided, treat apiKey as admin key and add orgId as query param
|
package/dist/media.d.ts
CHANGED
|
@@ -11,16 +11,15 @@ export declare class MediaClient extends BaseClient {
|
|
|
11
11
|
getMedia(params?: GetMediaParams): Promise<ApiResponse<Media[]>>;
|
|
12
12
|
/**
|
|
13
13
|
* Create media from URL(s)
|
|
14
|
-
*
|
|
15
|
-
* Supports both single url and multiple urls
|
|
14
|
+
* Creates media records from files already uploaded to blob storage
|
|
16
15
|
*/
|
|
17
16
|
create(params: CreateMediaFromUrlParams): Promise<ApiResponse<UploadMediaResponse>>;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* Get the URL to use for handleUploadUrl when using @vercel/blob/client upload
|
|
19
|
+
* Use this with the `upload` function from @vercel/blob/client
|
|
20
|
+
* After uploading, call create() with the resulting blob URLs
|
|
22
21
|
*/
|
|
23
|
-
|
|
22
|
+
getUploadHandlerUrl(): string;
|
|
24
23
|
/**
|
|
25
24
|
* Update the tag on a media item
|
|
26
25
|
* Works for both user_media and social_audio
|
package/dist/media.js
CHANGED
|
@@ -15,26 +15,22 @@ class MediaClient extends base_1.BaseClient {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Create media from URL(s)
|
|
18
|
-
*
|
|
19
|
-
* Supports both single url and multiple urls
|
|
18
|
+
* Creates media records from files already uploaded to blob storage
|
|
20
19
|
*/
|
|
21
20
|
async create(params) {
|
|
22
21
|
return this.post('/media/create', params);
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* Get the URL to use for handleUploadUrl when using @vercel/blob/client upload
|
|
25
|
+
* Use this with the `upload` function from @vercel/blob/client
|
|
26
|
+
* After uploading, call create() with the resulting blob URLs
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
getUploadHandlerUrl() {
|
|
29
|
+
const url = `${this.getBaseUrl()}/media/create/url`;
|
|
30
|
+
if (this.getOrgId()) {
|
|
31
|
+
return `${url}?orgId=${encodeURIComponent(this.getOrgId())}`;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
formData.append('tag', tag);
|
|
36
|
-
}
|
|
37
|
-
return this.postFormData('/media/create/upload', formData);
|
|
33
|
+
return url;
|
|
38
34
|
}
|
|
39
35
|
/**
|
|
40
36
|
* Update the tag on a media item
|
package/dist/types.d.ts
CHANGED
|
@@ -687,8 +687,7 @@ export interface UpdateMediaTagParams {
|
|
|
687
687
|
tag: string;
|
|
688
688
|
}
|
|
689
689
|
export interface DeleteMediaParams {
|
|
690
|
-
|
|
691
|
-
ids?: string[];
|
|
690
|
+
ids: string[];
|
|
692
691
|
}
|
|
693
692
|
export interface DeleteMediaResponse {
|
|
694
693
|
deleted: string[];
|
|
@@ -703,8 +702,7 @@ export interface CreateSocialAudioParams {
|
|
|
703
702
|
tag?: string;
|
|
704
703
|
}
|
|
705
704
|
export interface CreateMediaFromUrlParams {
|
|
706
|
-
|
|
707
|
-
urls?: string[];
|
|
705
|
+
urls: string[];
|
|
708
706
|
tag?: string;
|
|
709
707
|
}
|
|
710
708
|
export {};
|