@use_socials/sdk 0.1.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/README.md +46 -0
- package/dist/api.d.ts +762 -0
- package/dist/api.js +1274 -0
- package/dist/base.d.ts +42 -0
- package/dist/base.js +46 -0
- package/dist/client.d.ts +196 -0
- package/dist/client.js +275 -0
- package/dist/common.d.ts +34 -0
- package/dist/common.js +139 -0
- package/dist/configuration.d.ts +98 -0
- package/dist/configuration.js +44 -0
- package/dist/esm/api.d.ts +762 -0
- package/dist/esm/api.js +1243 -0
- package/dist/esm/base.d.ts +42 -0
- package/dist/esm/base.js +41 -0
- package/dist/esm/client.d.ts +196 -0
- package/dist/esm/client.js +270 -0
- package/dist/esm/common.d.ts +34 -0
- package/dist/esm/common.js +126 -0
- package/dist/esm/configuration.d.ts +98 -0
- package/dist/esm/configuration.js +40 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -0
- package/package.json +46 -0
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* use-socials API
|
|
3
|
+
* Social media publishing API as a service. Allows app builders to let their users post to YouTube, TikTok, Instagram, and Pinterest.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from './configuration';
|
|
13
|
+
import type { AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
14
|
+
export declare const BASE_PATH: string;
|
|
15
|
+
export declare const COLLECTION_FORMATS: {
|
|
16
|
+
csv: string;
|
|
17
|
+
ssv: string;
|
|
18
|
+
tsv: string;
|
|
19
|
+
pipes: string;
|
|
20
|
+
};
|
|
21
|
+
export interface RequestArgs {
|
|
22
|
+
url: string;
|
|
23
|
+
options: RawAxiosRequestConfig;
|
|
24
|
+
}
|
|
25
|
+
export declare class BaseAPI {
|
|
26
|
+
protected basePath: string;
|
|
27
|
+
protected axios: AxiosInstance;
|
|
28
|
+
protected configuration: Configuration | undefined;
|
|
29
|
+
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
30
|
+
}
|
|
31
|
+
export declare class RequiredError extends Error {
|
|
32
|
+
field: string;
|
|
33
|
+
constructor(field: string, msg?: string);
|
|
34
|
+
}
|
|
35
|
+
interface ServerMap {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
url: string;
|
|
38
|
+
description: string;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
export declare const operationServerMap: ServerMap;
|
|
42
|
+
export {};
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* use-socials API
|
|
6
|
+
* Social media publishing API as a service. Allows app builders to let their users post to YouTube, TikTok, Instagram, and Pinterest.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.operationServerMap = exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
17
|
+
const axios_1 = require("axios");
|
|
18
|
+
exports.BASE_PATH = "http://localhost:8080".replace(/\/+$/, "");
|
|
19
|
+
exports.COLLECTION_FORMATS = {
|
|
20
|
+
csv: ",",
|
|
21
|
+
ssv: " ",
|
|
22
|
+
tsv: "\t",
|
|
23
|
+
pipes: "|",
|
|
24
|
+
};
|
|
25
|
+
class BaseAPI {
|
|
26
|
+
constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) {
|
|
27
|
+
var _a;
|
|
28
|
+
this.basePath = basePath;
|
|
29
|
+
this.axios = axios;
|
|
30
|
+
if (configuration) {
|
|
31
|
+
this.configuration = configuration;
|
|
32
|
+
this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.BaseAPI = BaseAPI;
|
|
37
|
+
;
|
|
38
|
+
class RequiredError extends Error {
|
|
39
|
+
constructor(field, msg) {
|
|
40
|
+
super(msg);
|
|
41
|
+
this.field = field;
|
|
42
|
+
this.name = "RequiredError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.RequiredError = RequiredError;
|
|
46
|
+
exports.operationServerMap = {};
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { AxiosInstance, RawAxiosRequestConfig } from "axios";
|
|
2
|
+
import { type HandlersPresignMediaRequest, type HandlersWaitlistResponse } from "./api";
|
|
3
|
+
export type UseSocialsPlatform = "youtube" | "tiktok" | "instagram" | "pinterest";
|
|
4
|
+
export type UseSocialsPostStatus = "PUBLISHING" | "PUBLISHED" | "FAILED";
|
|
5
|
+
export type UseSocialsPostTargetStatus = "PENDING" | "PUBLISHING" | "PUBLISHED" | "FAILED";
|
|
6
|
+
export type UseSocialsTaskStatus = "PENDING" | "PROCESSING" | "PUBLISHED" | "FAILED";
|
|
7
|
+
export type UseSocialsClientOptions = {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
baseOptions?: RawAxiosRequestConfig;
|
|
11
|
+
axios?: AxiosInstance;
|
|
12
|
+
};
|
|
13
|
+
export type UseSocialsUser = {
|
|
14
|
+
userId: string;
|
|
15
|
+
externalId: string;
|
|
16
|
+
};
|
|
17
|
+
export type UseSocialsAccount = {
|
|
18
|
+
id: string;
|
|
19
|
+
platform: string;
|
|
20
|
+
platformAccountId: string;
|
|
21
|
+
platformUsername: string | null;
|
|
22
|
+
status: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
};
|
|
25
|
+
export type UseSocialsOAuthCallback = {
|
|
26
|
+
status: "connected";
|
|
27
|
+
};
|
|
28
|
+
export type UseSocialsPost = {
|
|
29
|
+
id: string;
|
|
30
|
+
userId: string;
|
|
31
|
+
status: UseSocialsPostStatus;
|
|
32
|
+
title: string | null;
|
|
33
|
+
content: object;
|
|
34
|
+
mediaItems: UseSocialsPostMediaItem[];
|
|
35
|
+
targets: UseSocialsPostTarget[];
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
};
|
|
39
|
+
export type UseSocialsPostTarget = {
|
|
40
|
+
id: string;
|
|
41
|
+
platform: string;
|
|
42
|
+
status: UseSocialsPostTargetStatus;
|
|
43
|
+
socialAccountId: string;
|
|
44
|
+
platformUsername: string | null;
|
|
45
|
+
platformPostId: string | null;
|
|
46
|
+
platformPostUrl: string | null;
|
|
47
|
+
error: string | null;
|
|
48
|
+
publishedAt: string | null;
|
|
49
|
+
retryCount: number;
|
|
50
|
+
};
|
|
51
|
+
export type UseSocialsPostMediaItem = {
|
|
52
|
+
id: string;
|
|
53
|
+
url: string;
|
|
54
|
+
type: string;
|
|
55
|
+
filename: string | null;
|
|
56
|
+
mimeType: string | null;
|
|
57
|
+
size: number;
|
|
58
|
+
};
|
|
59
|
+
export type UseSocialsRetryPostTargetResult = {
|
|
60
|
+
targetId: string;
|
|
61
|
+
status: string;
|
|
62
|
+
};
|
|
63
|
+
export type UseSocialsPostTask = {
|
|
64
|
+
id: string;
|
|
65
|
+
status: UseSocialsTaskStatus;
|
|
66
|
+
socialAccountId: string;
|
|
67
|
+
mediaUrl: string;
|
|
68
|
+
content: object;
|
|
69
|
+
platformPostId: string | null;
|
|
70
|
+
platformPostUrl: string | null;
|
|
71
|
+
error: string | null;
|
|
72
|
+
attempts: number;
|
|
73
|
+
maxAttempts: number;
|
|
74
|
+
createdAt: string;
|
|
75
|
+
updatedAt: string;
|
|
76
|
+
lastAttemptAt: string | null;
|
|
77
|
+
};
|
|
78
|
+
export type YouTubePostContent = {
|
|
79
|
+
title: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
tags?: string[];
|
|
82
|
+
privacyStatus?: "public" | "private" | "unlisted";
|
|
83
|
+
thumbnailUrl?: string;
|
|
84
|
+
};
|
|
85
|
+
export type TikTokPostContent = {
|
|
86
|
+
title: string;
|
|
87
|
+
privacyLevel?: "PUBLIC_TO_EVERYONE" | "MUTUAL_FOLLOW_FRIENDS" | "FOLLOWER_OF_CREATOR" | "SELF_ONLY";
|
|
88
|
+
disableDuet?: boolean;
|
|
89
|
+
disableComment?: boolean;
|
|
90
|
+
disableStitch?: boolean;
|
|
91
|
+
};
|
|
92
|
+
export type InstagramPostContent = {
|
|
93
|
+
caption?: string;
|
|
94
|
+
mediaType?: "REELS" | "IMAGE";
|
|
95
|
+
shareToFeed?: boolean;
|
|
96
|
+
};
|
|
97
|
+
export type PinterestPostContent = {
|
|
98
|
+
title?: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
link?: string;
|
|
101
|
+
boardId?: string;
|
|
102
|
+
};
|
|
103
|
+
export type UseSocialsPostContent = YouTubePostContent | TikTokPostContent | InstagramPostContent | PinterestPostContent | Record<string, unknown>;
|
|
104
|
+
export type UseSocialsPresignedMedia = {
|
|
105
|
+
mediaId: string;
|
|
106
|
+
uploadUrl: string;
|
|
107
|
+
publicUrl: string;
|
|
108
|
+
key: string;
|
|
109
|
+
expiresAt: string;
|
|
110
|
+
contentType: string;
|
|
111
|
+
};
|
|
112
|
+
export type UseSocialsCompletedMedia = {
|
|
113
|
+
mediaId: string;
|
|
114
|
+
publicUrl: string;
|
|
115
|
+
contentType: string;
|
|
116
|
+
size: number;
|
|
117
|
+
status: string;
|
|
118
|
+
};
|
|
119
|
+
export declare class UseSocialsClient {
|
|
120
|
+
private readonly healthApi;
|
|
121
|
+
private readonly mediaApi;
|
|
122
|
+
private readonly oauthApi;
|
|
123
|
+
private readonly postsApi;
|
|
124
|
+
private readonly publishApi;
|
|
125
|
+
private readonly usersApi;
|
|
126
|
+
private readonly waitlistApi;
|
|
127
|
+
readonly health: {
|
|
128
|
+
get: () => Promise<Record<string, string>>;
|
|
129
|
+
};
|
|
130
|
+
readonly users: {
|
|
131
|
+
create: (args: {
|
|
132
|
+
externalId: string;
|
|
133
|
+
}) => Promise<UseSocialsUser>;
|
|
134
|
+
};
|
|
135
|
+
readonly accounts: {
|
|
136
|
+
list: (args: {
|
|
137
|
+
userId: string;
|
|
138
|
+
}) => Promise<UseSocialsAccount[]>;
|
|
139
|
+
disconnect: (args: {
|
|
140
|
+
userId: string;
|
|
141
|
+
accountId: string;
|
|
142
|
+
}) => Promise<void>;
|
|
143
|
+
};
|
|
144
|
+
readonly oauth: {
|
|
145
|
+
getUrl: (args: {
|
|
146
|
+
platform: UseSocialsPlatform;
|
|
147
|
+
userId: string;
|
|
148
|
+
redirectUrl?: string;
|
|
149
|
+
}) => Promise<string>;
|
|
150
|
+
callback: (args: {
|
|
151
|
+
platform: UseSocialsPlatform;
|
|
152
|
+
code: string;
|
|
153
|
+
state: string;
|
|
154
|
+
}) => Promise<UseSocialsOAuthCallback>;
|
|
155
|
+
};
|
|
156
|
+
readonly posts: {
|
|
157
|
+
create: (args: {
|
|
158
|
+
userId: string;
|
|
159
|
+
socialAccountId: string;
|
|
160
|
+
socialAccountIds?: string[];
|
|
161
|
+
mediaUrl: string;
|
|
162
|
+
content: UseSocialsPostContent;
|
|
163
|
+
idempotencyKey?: string;
|
|
164
|
+
}) => Promise<UseSocialsPost>;
|
|
165
|
+
list: (args: {
|
|
166
|
+
userId: string;
|
|
167
|
+
}) => Promise<UseSocialsPost[]>;
|
|
168
|
+
get: (args: {
|
|
169
|
+
userId: string;
|
|
170
|
+
postId: string;
|
|
171
|
+
}) => Promise<UseSocialsPost>;
|
|
172
|
+
retry: (args: {
|
|
173
|
+
userId: string;
|
|
174
|
+
postId: string;
|
|
175
|
+
targetId: string;
|
|
176
|
+
}) => Promise<UseSocialsRetryPostTargetResult>;
|
|
177
|
+
};
|
|
178
|
+
readonly postsTask: {
|
|
179
|
+
get: (args: {
|
|
180
|
+
jobId: string;
|
|
181
|
+
}) => Promise<UseSocialsPostTask>;
|
|
182
|
+
};
|
|
183
|
+
readonly media: {
|
|
184
|
+
presign: (args: HandlersPresignMediaRequest) => Promise<UseSocialsPresignedMedia>;
|
|
185
|
+
complete: (args: {
|
|
186
|
+
mediaId: string;
|
|
187
|
+
}) => Promise<UseSocialsCompletedMedia>;
|
|
188
|
+
};
|
|
189
|
+
readonly waitlist: {
|
|
190
|
+
join: (args: {
|
|
191
|
+
email: string;
|
|
192
|
+
}) => Promise<HandlersWaitlistResponse>;
|
|
193
|
+
};
|
|
194
|
+
constructor(options: UseSocialsClientOptions);
|
|
195
|
+
}
|
|
196
|
+
export declare function createUseSocialsClient(options: UseSocialsClientOptions): UseSocialsClient;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UseSocialsClient = void 0;
|
|
13
|
+
exports.createUseSocialsClient = createUseSocialsClient;
|
|
14
|
+
const api_1 = require("./api");
|
|
15
|
+
const configuration_1 = require("./configuration");
|
|
16
|
+
const DEFAULT_BASE_URL = "https://api.usesocials.com";
|
|
17
|
+
function getRequiredString(value, field) {
|
|
18
|
+
if (!value)
|
|
19
|
+
throw new Error(`useSocials response missing ${field}`);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function getOptionalString(value) {
|
|
23
|
+
return value !== null && value !== void 0 ? value : null;
|
|
24
|
+
}
|
|
25
|
+
function getRequiredObject(value, field) {
|
|
26
|
+
if (value === undefined || value === null) {
|
|
27
|
+
throw new Error(`useSocials response missing ${field}`);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
function getRequiredNumber(value, field) {
|
|
32
|
+
if (value === undefined || value === null) {
|
|
33
|
+
throw new Error(`useSocials response missing ${field}`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function getPostStatus(value) {
|
|
38
|
+
switch (value) {
|
|
39
|
+
case "PUBLISHING":
|
|
40
|
+
case "PUBLISHED":
|
|
41
|
+
case "FAILED":
|
|
42
|
+
return value;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`useSocials returned unknown post status: ${value !== null && value !== void 0 ? value : "undefined"}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function getPostTargetStatus(value) {
|
|
48
|
+
switch (value) {
|
|
49
|
+
case "PENDING":
|
|
50
|
+
case "PUBLISHING":
|
|
51
|
+
case "PUBLISHED":
|
|
52
|
+
case "FAILED":
|
|
53
|
+
return value;
|
|
54
|
+
default:
|
|
55
|
+
throw new Error(`useSocials returned unknown post target status: ${value !== null && value !== void 0 ? value : "undefined"}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function getTaskStatus(value) {
|
|
59
|
+
switch (value) {
|
|
60
|
+
case "PENDING":
|
|
61
|
+
case "PROCESSING":
|
|
62
|
+
case "PUBLISHED":
|
|
63
|
+
case "FAILED":
|
|
64
|
+
return value;
|
|
65
|
+
default:
|
|
66
|
+
throw new Error(`useSocials returned unknown task status: ${value !== null && value !== void 0 ? value : "undefined"}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getOptionalObject(value) {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = value) !== null && _a !== void 0 ? _a : {};
|
|
72
|
+
}
|
|
73
|
+
function mapOAuthCallback(data) {
|
|
74
|
+
const status = getRequiredString(data.status, "oauth.status");
|
|
75
|
+
if (status !== "connected") {
|
|
76
|
+
throw new Error(`useSocials returned unknown oauth status: ${status}`);
|
|
77
|
+
}
|
|
78
|
+
return { status: "connected" };
|
|
79
|
+
}
|
|
80
|
+
function mapAccount(data) {
|
|
81
|
+
return {
|
|
82
|
+
id: getRequiredString(data.id, "account.id"),
|
|
83
|
+
platform: getRequiredString(data.platform, "account.platform"),
|
|
84
|
+
platformAccountId: getRequiredString(data.platformAccountId, "account.platformAccountId"),
|
|
85
|
+
platformUsername: getOptionalString(data.platformUsername),
|
|
86
|
+
status: getRequiredString(data.status, "account.status"),
|
|
87
|
+
createdAt: getRequiredString(data.createdAt, "account.createdAt"),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function mapPost(data) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return {
|
|
93
|
+
id: getRequiredString(data.id, "post.id"),
|
|
94
|
+
userId: getRequiredString(data.createdByUserId, "post.createdByUserId"),
|
|
95
|
+
status: getPostStatus(data.status),
|
|
96
|
+
title: getOptionalString(data.title),
|
|
97
|
+
content: getOptionalObject(data.content),
|
|
98
|
+
mediaItems: ((_a = data.mediaItems) !== null && _a !== void 0 ? _a : []).map(mapPostMediaItem),
|
|
99
|
+
targets: ((_b = data.targets) !== null && _b !== void 0 ? _b : []).map(mapPostTarget),
|
|
100
|
+
createdAt: getRequiredString(data.createdAt, "post.createdAt"),
|
|
101
|
+
updatedAt: getRequiredString(data.updatedAt, "post.updatedAt"),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function mapPostTask(data) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return {
|
|
107
|
+
id: getRequiredString(data.id, "postTask.id"),
|
|
108
|
+
status: getTaskStatus(data.status),
|
|
109
|
+
socialAccountId: getRequiredString(data.socialAccountId, "postTask.socialAccountId"),
|
|
110
|
+
mediaUrl: getRequiredString(data.mediaUrl, "postTask.mediaUrl"),
|
|
111
|
+
content: getOptionalObject(data.content),
|
|
112
|
+
platformPostId: getOptionalString(data.platformPostId),
|
|
113
|
+
platformPostUrl: getOptionalString(data.platformPostUrl),
|
|
114
|
+
error: getOptionalString(data.error),
|
|
115
|
+
attempts: (_a = data.attempts) !== null && _a !== void 0 ? _a : 0,
|
|
116
|
+
maxAttempts: (_b = data.maxAttempts) !== null && _b !== void 0 ? _b : 0,
|
|
117
|
+
createdAt: getRequiredString(data.createdAt, "postTask.createdAt"),
|
|
118
|
+
updatedAt: getRequiredString(data.updatedAt, "postTask.updatedAt"),
|
|
119
|
+
lastAttemptAt: getOptionalString(data.lastAttemptAt),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function mapPostTarget(data) {
|
|
123
|
+
return {
|
|
124
|
+
id: getRequiredString(data.id, "postTarget.id"),
|
|
125
|
+
platform: getRequiredString(data.platform, "postTarget.platform"),
|
|
126
|
+
status: getPostTargetStatus(data.status),
|
|
127
|
+
socialAccountId: getRequiredString(data.socialAccountId, "postTarget.socialAccountId"),
|
|
128
|
+
platformUsername: getOptionalString(data.platformUsername),
|
|
129
|
+
platformPostId: getOptionalString(data.platformPostId),
|
|
130
|
+
platformPostUrl: getOptionalString(data.platformPostUrl),
|
|
131
|
+
error: getOptionalString(data.error),
|
|
132
|
+
publishedAt: getOptionalString(data.publishedAt),
|
|
133
|
+
retryCount: getRequiredNumber(data.retryCount, "postTarget.retryCount"),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function mapPostMediaItem(data) {
|
|
137
|
+
var _a;
|
|
138
|
+
return {
|
|
139
|
+
id: getRequiredString(data.id, "postMediaItem.id"),
|
|
140
|
+
url: getRequiredString(data.url, "postMediaItem.url"),
|
|
141
|
+
type: getRequiredString(data.type, "postMediaItem.type"),
|
|
142
|
+
filename: getOptionalString(data.filename),
|
|
143
|
+
mimeType: getOptionalString(data.mimeType),
|
|
144
|
+
size: (_a = data.sizeBytes) !== null && _a !== void 0 ? _a : 0,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function mapRetryPostTarget(data) {
|
|
148
|
+
return {
|
|
149
|
+
targetId: getRequiredString(data.targetId, "postTarget.targetId"),
|
|
150
|
+
status: getRequiredString(data.status, "postTarget.status"),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function mapUser(data) {
|
|
154
|
+
return {
|
|
155
|
+
userId: getRequiredString(data.userId, "user.userId"),
|
|
156
|
+
externalId: getRequiredString(data.externalId, "user.externalId"),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function mapPresignedMedia(data) {
|
|
160
|
+
return {
|
|
161
|
+
mediaId: getRequiredString(data.mediaId, "media.mediaId"),
|
|
162
|
+
uploadUrl: getRequiredString(data.uploadUrl, "media.uploadUrl"),
|
|
163
|
+
publicUrl: getRequiredString(data.publicUrl, "media.publicUrl"),
|
|
164
|
+
key: getRequiredString(data.key, "media.key"),
|
|
165
|
+
expiresAt: getRequiredString(data.expiresAt, "media.expiresAt"),
|
|
166
|
+
contentType: getRequiredString(data.contentType, "media.contentType"),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function mapCompletedMedia(data) {
|
|
170
|
+
return {
|
|
171
|
+
mediaId: getRequiredString(data.mediaId, "media.mediaId"),
|
|
172
|
+
publicUrl: getRequiredString(data.publicUrl, "media.publicUrl"),
|
|
173
|
+
contentType: getRequiredString(data.contentType, "media.contentType"),
|
|
174
|
+
size: getRequiredNumber(data.size, "media.size"),
|
|
175
|
+
status: getRequiredString(data.status, "media.status"),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
class UseSocialsClient {
|
|
179
|
+
constructor(options) {
|
|
180
|
+
var _a;
|
|
181
|
+
const configuration = new configuration_1.Configuration({
|
|
182
|
+
apiKey: options.apiKey,
|
|
183
|
+
basePath: (_a = options.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_BASE_URL,
|
|
184
|
+
baseOptions: options.baseOptions,
|
|
185
|
+
});
|
|
186
|
+
this.healthApi = new api_1.HealthApi(configuration, undefined, options.axios);
|
|
187
|
+
this.mediaApi = new api_1.MediaApi(configuration, undefined, options.axios);
|
|
188
|
+
this.oauthApi = new api_1.OauthApi(configuration, undefined, options.axios);
|
|
189
|
+
this.postsApi = new api_1.PostsApi(configuration, undefined, options.axios);
|
|
190
|
+
this.publishApi = new api_1.PublishApi(configuration, undefined, options.axios);
|
|
191
|
+
this.usersApi = new api_1.UsersApi(configuration, undefined, options.axios);
|
|
192
|
+
this.waitlistApi = new api_1.WaitlistApi(configuration, undefined, options.axios);
|
|
193
|
+
this.health = {
|
|
194
|
+
get: () => __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
const { data } = yield this.healthApi.healthGet();
|
|
196
|
+
return data;
|
|
197
|
+
}),
|
|
198
|
+
};
|
|
199
|
+
this.users = {
|
|
200
|
+
create: (_a) => __awaiter(this, [_a], void 0, function* ({ externalId }) {
|
|
201
|
+
const { data } = yield this.usersApi.apiV1UsersPost({ externalId });
|
|
202
|
+
return mapUser(data);
|
|
203
|
+
}),
|
|
204
|
+
};
|
|
205
|
+
this.accounts = {
|
|
206
|
+
list: (_a) => __awaiter(this, [_a], void 0, function* ({ userId }) {
|
|
207
|
+
const { data } = yield this.usersApi.apiV1UsersUserIdAccountsGet(userId);
|
|
208
|
+
return data.map(mapAccount);
|
|
209
|
+
}),
|
|
210
|
+
disconnect: (_a) => __awaiter(this, [_a], void 0, function* ({ userId, accountId }) {
|
|
211
|
+
yield this.usersApi.apiV1UsersUserIdAccountsAccountIdDelete(userId, accountId);
|
|
212
|
+
}),
|
|
213
|
+
};
|
|
214
|
+
this.oauth = {
|
|
215
|
+
getUrl: (_a) => __awaiter(this, [_a], void 0, function* ({ platform, userId, redirectUrl }) {
|
|
216
|
+
const { data } = yield this.oauthApi.apiV1OauthPlatformUrlGet(platform, userId, redirectUrl);
|
|
217
|
+
return getRequiredString(data.url, "oauth.url");
|
|
218
|
+
}),
|
|
219
|
+
callback: (_a) => __awaiter(this, [_a], void 0, function* ({ platform, code, state }) {
|
|
220
|
+
const { data } = yield this.oauthApi.apiV1OauthPlatformCallbackGet(platform, code, state);
|
|
221
|
+
return mapOAuthCallback(data);
|
|
222
|
+
}),
|
|
223
|
+
};
|
|
224
|
+
this.posts = {
|
|
225
|
+
create: (_a) => __awaiter(this, [_a], void 0, function* ({ userId, socialAccountId, socialAccountIds, mediaUrl, content, idempotencyKey, }) {
|
|
226
|
+
const body = {
|
|
227
|
+
socialAccountId,
|
|
228
|
+
socialAccountIds,
|
|
229
|
+
mediaUrl,
|
|
230
|
+
content,
|
|
231
|
+
};
|
|
232
|
+
const { data } = yield this.postsApi.apiV1UsersUserIdPostsPost(userId, body, idempotencyKey);
|
|
233
|
+
return mapPost(data);
|
|
234
|
+
}),
|
|
235
|
+
list: (_a) => __awaiter(this, [_a], void 0, function* ({ userId }) {
|
|
236
|
+
const { data } = yield this.postsApi.apiV1UsersUserIdPostsGet(userId);
|
|
237
|
+
return data.map(mapPost);
|
|
238
|
+
}),
|
|
239
|
+
get: (_a) => __awaiter(this, [_a], void 0, function* ({ userId, postId }) {
|
|
240
|
+
const { data } = yield this.postsApi.apiV1UsersUserIdPostsPostIdGet(userId, postId);
|
|
241
|
+
return mapPost(data);
|
|
242
|
+
}),
|
|
243
|
+
retry: (_a) => __awaiter(this, [_a], void 0, function* ({ userId, postId, targetId }) {
|
|
244
|
+
const { data } = yield this.postsApi.apiV1UsersUserIdPostsPostIdTargetsTargetIdRetryPost(userId, postId, targetId);
|
|
245
|
+
return mapRetryPostTarget(data);
|
|
246
|
+
}),
|
|
247
|
+
};
|
|
248
|
+
this.postsTask = {
|
|
249
|
+
get: (_a) => __awaiter(this, [_a], void 0, function* ({ jobId }) {
|
|
250
|
+
const { data } = yield this.publishApi.apiV1PublishJobsJobIdGet(jobId);
|
|
251
|
+
return mapPostTask(data);
|
|
252
|
+
}),
|
|
253
|
+
};
|
|
254
|
+
this.media = {
|
|
255
|
+
presign: (args) => __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
const { data } = yield this.mediaApi.apiV1MediaPresignPost(args);
|
|
257
|
+
return mapPresignedMedia(data);
|
|
258
|
+
}),
|
|
259
|
+
complete: (_a) => __awaiter(this, [_a], void 0, function* ({ mediaId }) {
|
|
260
|
+
const { data } = yield this.mediaApi.apiV1MediaMediaIdCompletePost(mediaId);
|
|
261
|
+
return mapCompletedMedia(data);
|
|
262
|
+
}),
|
|
263
|
+
};
|
|
264
|
+
this.waitlist = {
|
|
265
|
+
join: (_a) => __awaiter(this, [_a], void 0, function* ({ email }) {
|
|
266
|
+
const { data } = yield this.waitlistApi.waitlistPost({ email });
|
|
267
|
+
return data;
|
|
268
|
+
}),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.UseSocialsClient = UseSocialsClient;
|
|
273
|
+
function createUseSocialsClient(options) {
|
|
274
|
+
return new UseSocialsClient(options);
|
|
275
|
+
}
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* use-socials API
|
|
3
|
+
* Social media publishing API as a service. Allows app builders to let their users post to YouTube, TikTok, Instagram, and Pinterest.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from "./configuration";
|
|
13
|
+
import type { RequestArgs } from "./base";
|
|
14
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
|
+
export declare const DUMMY_BASE_URL = "https://example.com";
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @throws {RequiredError}
|
|
19
|
+
*/
|
|
20
|
+
export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
|
|
21
|
+
export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
|
|
22
|
+
export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
|
|
23
|
+
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
|
|
24
|
+
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
|
|
25
|
+
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
|
|
28
|
+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
|
|
29
|
+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
|
|
30
|
+
*/
|
|
31
|
+
export declare const replaceWithSerializableTypeIfNeeded: (key: string, value: any) => any;
|
|
32
|
+
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
|
|
33
|
+
export declare const toPathString: (url: URL) => string;
|
|
34
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|