ad2app-lib 1.0.4 → 1.0.6
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/ad2app-lib.code-workspace +10 -0
- package/dist/api/apiDriver.d.ts +20 -25
- package/dist/api/apiDriver.js +53 -20
- package/dist/api/index.d.ts +2 -2
- package/dist/types/I_Item.d.ts +2 -2
- package/dist/types/I_Item.js +7 -7
- package/dist/types/I_Publish.d.ts +12 -0
- package/dist/types/I_Publish.js +2 -0
- package/dist/types/I_ResponseMessage.d.ts +1 -1
- package/dist/types/I_ResponseMessage.js +2 -2
- package/dist/types/I_SocialAccount.d.ts +24 -0
- package/dist/types/I_SocialAccount.js +58 -0
- package/dist/types/I_User.d.ts +3 -3
- package/dist/types/index.d.ts +35 -33
- package/dist/types/index.js +2 -0
- package/package.json +1 -1
- package/src/api/apiDriver.ts +74 -36
- package/src/api/index.ts +2 -2
- package/src/types/I_Item.ts +9 -9
- package/src/types/I_Publish.ts +14 -0
- package/src/types/I_ResponseMessage.ts +3 -3
- package/src/types/I_SocialAccount.ts +56 -0
- package/src/types/I_User.ts +7 -7
- package/src/types/index.ts +35 -33
- package/dist/api/apiUtils.d.ts +0 -0
- package/dist/api/apiUtils.js +0 -31
- package/dist/types/I_Report.d.ts +0 -11
- package/dist/types/I_Report.js +0 -14
package/dist/api/apiDriver.d.ts
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
import { FetchParams } from
|
|
2
|
-
type HttpMethod =
|
|
1
|
+
import { FetchParams } from "../types";
|
|
2
|
+
type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
3
3
|
interface DriverConfig {
|
|
4
4
|
apiUrl: string;
|
|
5
5
|
getHeaders?: () => HeadersInit;
|
|
6
6
|
}
|
|
7
7
|
export declare function configureApiDriver(config: DriverConfig): void;
|
|
8
|
-
type FetchCallArgs<Q> =
|
|
9
|
-
path
|
|
10
|
-
params?: FetchParams<Q
|
|
11
|
-
method?: HttpMethod
|
|
12
|
-
headers?: HeadersInit
|
|
8
|
+
type FetchCallArgs<Q> = {
|
|
9
|
+
path?: string;
|
|
10
|
+
params?: FetchParams<Q>;
|
|
11
|
+
method?: HttpMethod;
|
|
12
|
+
headers?: HeadersInit;
|
|
13
13
|
transformers?: {
|
|
14
14
|
body?: (body: any) => BodyInit;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function fetchCall<T, Q>(args: FetchCallArgs<Q>): Promise<T>;
|
|
19
|
+
type MethodCallArgs<Q> = [
|
|
20
|
+
path: string,
|
|
21
|
+
options: Omit<FetchCallArgs<Q>, "path" | "method">
|
|
16
22
|
];
|
|
17
|
-
export declare function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
body?: (body: any) => BodyInit;
|
|
24
|
-
}) => Promise<T>;
|
|
25
|
-
put: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
26
|
-
body?: (body: any) => BodyInit;
|
|
27
|
-
}) => Promise<T>;
|
|
28
|
-
patch: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
29
|
-
body?: (body: any) => BodyInit;
|
|
30
|
-
}) => Promise<T>;
|
|
31
|
-
delete: <T, Q>(path: string, params?: FetchParams<Q>, method?: HttpMethod, headers?: HeadersInit, transformers?: {
|
|
32
|
-
body?: (body: any) => BodyInit;
|
|
33
|
-
}) => Promise<T>;
|
|
23
|
+
export declare function apiDriver(baseUrl?: string): {
|
|
24
|
+
get: <T, Q>(path: string, options: Omit<FetchCallArgs<Q>, "path" | "method">) => Promise<T>;
|
|
25
|
+
post: <T, Q>(path: string, options: Omit<FetchCallArgs<Q>, "path" | "method">) => Promise<T>;
|
|
26
|
+
put: <T, Q>(path: string, options: Omit<FetchCallArgs<Q>, "path" | "method">) => Promise<T>;
|
|
27
|
+
patch: <T, Q>(path: string, options: Omit<FetchCallArgs<Q>, "path" | "method">) => Promise<T>;
|
|
28
|
+
delete: <T, Q>(path: string, options: Omit<FetchCallArgs<Q>, "path" | "method">) => Promise<T>;
|
|
34
29
|
};
|
|
35
30
|
export {};
|
package/dist/api/apiDriver.js
CHANGED
|
@@ -8,41 +8,74 @@ let CONFIG;
|
|
|
8
8
|
function configureApiDriver(config) {
|
|
9
9
|
CONFIG = config;
|
|
10
10
|
}
|
|
11
|
-
async function fetchCall(
|
|
12
|
-
let
|
|
11
|
+
async function fetchCall(args) {
|
|
12
|
+
let { path, params, method, headers, baseUrl, transformers } = args;
|
|
13
13
|
headers = {
|
|
14
|
-
...CONFIG
|
|
14
|
+
...CONFIG?.getHeaders?.(),
|
|
15
15
|
...headers,
|
|
16
16
|
};
|
|
17
17
|
const query = {};
|
|
18
|
-
Object.entries(
|
|
18
|
+
Object.entries(params?.query || {}).forEach(([key, val]) => {
|
|
19
19
|
query[key] = Array.isArray(val) ? JSON.stringify(val) : val;
|
|
20
20
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const apiUrl = baseUrl ?? CONFIG.apiUrl;
|
|
22
|
+
const queryString = (0, utils_1.createQueryString)({ ...params, query });
|
|
23
|
+
const fullPath = (0, utils_1.insertParams)((0, utils_1.concatApiPaths)(apiUrl, path) + queryString, params?.params);
|
|
23
24
|
const init = {
|
|
24
25
|
method,
|
|
25
26
|
headers,
|
|
26
27
|
};
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if (params?.body) {
|
|
29
|
+
if (transformers?.body) {
|
|
30
|
+
init.body = transformers.body(params.body);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
init.body = JSON.stringify(params.body);
|
|
34
|
+
}
|
|
35
|
+
if (!headers["Content-Type"]) {
|
|
36
|
+
headers["Content-Type"] = "application/json";
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
const res = await fetch(fullPath, init);
|
|
36
40
|
if (!res.ok)
|
|
37
41
|
throw new Error(JSON.stringify(await res.json()));
|
|
38
|
-
|
|
42
|
+
try {
|
|
43
|
+
return res.json();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return res.text();
|
|
47
|
+
}
|
|
39
48
|
}
|
|
40
|
-
function apiDriver() {
|
|
49
|
+
function apiDriver(baseUrl) {
|
|
41
50
|
return {
|
|
42
|
-
get: (...args) => fetchCall(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
get: (...args) => fetchCall({
|
|
52
|
+
...args[1],
|
|
53
|
+
path: args[0],
|
|
54
|
+
method: "get",
|
|
55
|
+
baseUrl,
|
|
56
|
+
}),
|
|
57
|
+
post: (...args) => fetchCall({
|
|
58
|
+
...args[1],
|
|
59
|
+
path: args[0],
|
|
60
|
+
method: "post",
|
|
61
|
+
baseUrl,
|
|
62
|
+
}),
|
|
63
|
+
put: (...args) => fetchCall({
|
|
64
|
+
...args[1],
|
|
65
|
+
path: args[0],
|
|
66
|
+
method: "put",
|
|
67
|
+
}),
|
|
68
|
+
patch: (...args) => fetchCall({
|
|
69
|
+
...args[1],
|
|
70
|
+
path: args[0],
|
|
71
|
+
method: "patch",
|
|
72
|
+
baseUrl,
|
|
73
|
+
}),
|
|
74
|
+
delete: (...args) => fetchCall({
|
|
75
|
+
...args[1],
|
|
76
|
+
path: args[0],
|
|
77
|
+
method: "delete",
|
|
78
|
+
baseUrl,
|
|
79
|
+
}),
|
|
47
80
|
};
|
|
48
81
|
}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./apiDriver";
|
|
2
|
+
export * from "./utils";
|
package/dist/types/I_Item.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I_ResponseMessage } from
|
|
2
|
-
import { T_FetchStatus } from
|
|
1
|
+
import { I_ResponseMessage } from "./I_ResponseMessage";
|
|
2
|
+
import { T_FetchStatus } from "./T_FetchStatus";
|
|
3
3
|
export declare class I_Item<T> implements I_ResponseMessage {
|
|
4
4
|
data: T;
|
|
5
5
|
status: T_FetchStatus;
|
package/dist/types/I_Item.js
CHANGED
|
@@ -4,25 +4,25 @@ exports.itemFailed = exports.itemIsResolving = exports.itemIsLoading = exports.I
|
|
|
4
4
|
class I_Item {
|
|
5
5
|
constructor(data) {
|
|
6
6
|
this.data = data?.data || null;
|
|
7
|
-
this.status = data?.status ||
|
|
8
|
-
this.message = data?.message ||
|
|
7
|
+
this.status = data?.status || "succeeded";
|
|
8
|
+
this.message = data?.message || "";
|
|
9
9
|
}
|
|
10
10
|
succeed(data, message) {
|
|
11
|
-
this.status =
|
|
11
|
+
this.status = "succeeded";
|
|
12
12
|
this.data = data;
|
|
13
13
|
this.message = message;
|
|
14
14
|
return this;
|
|
15
15
|
}
|
|
16
16
|
fail(message) {
|
|
17
|
-
this.status =
|
|
17
|
+
this.status = "failed";
|
|
18
18
|
this.message = message;
|
|
19
19
|
return this;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
exports.I_Item = I_Item;
|
|
23
|
-
const itemIsLoading = (item) => item.status ===
|
|
23
|
+
const itemIsLoading = (item) => item.status === "loading";
|
|
24
24
|
exports.itemIsLoading = itemIsLoading;
|
|
25
|
-
const itemIsResolving = (item) => item.status ===
|
|
25
|
+
const itemIsResolving = (item) => item.status === "initial" || item.status === "loading";
|
|
26
26
|
exports.itemIsResolving = itemIsResolving;
|
|
27
|
-
const itemFailed = (item) => item.status ===
|
|
27
|
+
const itemFailed = (item) => item.status === "failed";
|
|
28
28
|
exports.itemFailed = itemFailed;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.I_ResponseMessage = void 0;
|
|
4
4
|
class I_ResponseMessage {
|
|
5
5
|
constructor(data) {
|
|
6
|
-
this.status = data?.status ||
|
|
7
|
-
this.message = data?.message ||
|
|
6
|
+
this.status = data?.status || "initial";
|
|
7
|
+
this.message = data?.message || "";
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.I_ResponseMessage = I_ResponseMessage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum SocialProvider {
|
|
2
|
+
TIKTOK = "tiktok",
|
|
3
|
+
FACEBOOK = "facebook",
|
|
4
|
+
INSTAGRAM = "instagram",
|
|
5
|
+
YOUTUBE = "youtube"
|
|
6
|
+
}
|
|
7
|
+
export declare class I_SocialSignInDTO {
|
|
8
|
+
provider: SocialProvider;
|
|
9
|
+
provider_user_id: string;
|
|
10
|
+
access_token: string;
|
|
11
|
+
refresh_token?: string;
|
|
12
|
+
expires_at?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class I_TikTokUserPayload {
|
|
15
|
+
id: string;
|
|
16
|
+
role: string;
|
|
17
|
+
email?: string | null;
|
|
18
|
+
accessToken: string;
|
|
19
|
+
refreshToken: string;
|
|
20
|
+
influencer?: {
|
|
21
|
+
handle_tt: string;
|
|
22
|
+
};
|
|
23
|
+
constructor(data: I_TikTokUserPayload);
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.I_TikTokUserPayload = exports.I_SocialSignInDTO = exports.SocialProvider = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
var SocialProvider;
|
|
15
|
+
(function (SocialProvider) {
|
|
16
|
+
SocialProvider["TIKTOK"] = "tiktok";
|
|
17
|
+
SocialProvider["FACEBOOK"] = "facebook";
|
|
18
|
+
SocialProvider["INSTAGRAM"] = "instagram";
|
|
19
|
+
SocialProvider["YOUTUBE"] = "youtube";
|
|
20
|
+
})(SocialProvider || (exports.SocialProvider = SocialProvider = {}));
|
|
21
|
+
class I_SocialSignInDTO {
|
|
22
|
+
}
|
|
23
|
+
exports.I_SocialSignInDTO = I_SocialSignInDTO;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, class_validator_1.IsEnum)(SocialProvider),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], I_SocialSignInDTO.prototype, "provider", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
30
|
+
(0, class_validator_1.IsString)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], I_SocialSignInDTO.prototype, "provider_user_id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
35
|
+
(0, class_validator_1.IsString)(),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], I_SocialSignInDTO.prototype, "access_token", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, class_validator_1.IsOptional)(),
|
|
40
|
+
(0, class_validator_1.IsString)(),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], I_SocialSignInDTO.prototype, "refresh_token", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, class_validator_1.IsOptional)(),
|
|
45
|
+
(0, class_validator_1.IsISO8601)(),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], I_SocialSignInDTO.prototype, "expires_at", void 0);
|
|
48
|
+
class I_TikTokUserPayload {
|
|
49
|
+
constructor(data) {
|
|
50
|
+
this.id = data.id;
|
|
51
|
+
this.role = data.role;
|
|
52
|
+
this.email = data.email;
|
|
53
|
+
this.accessToken = data.accessToken;
|
|
54
|
+
this.refreshToken = data.refreshToken;
|
|
55
|
+
this.influencer = data.influencer;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.I_TikTokUserPayload = I_TikTokUserPayload;
|
package/dist/types/I_User.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { I_Influencer } from
|
|
1
|
+
import { I_Influencer } from './I_Influencer';
|
|
2
2
|
export declare class I_User {
|
|
3
3
|
id: string;
|
|
4
|
-
email
|
|
5
|
-
password
|
|
4
|
+
email?: string;
|
|
5
|
+
password?: string;
|
|
6
6
|
role: UserRoles;
|
|
7
7
|
influencer?: I_Influencer;
|
|
8
8
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
32
|
-
export * from
|
|
33
|
-
export * from
|
|
1
|
+
export * from "./I_TikTokUser";
|
|
2
|
+
export * from "./I_Queue";
|
|
3
|
+
export * from "./I_Campaign";
|
|
4
|
+
export * from "./I_Influencer";
|
|
5
|
+
export * from "./I_InfluencersLists";
|
|
6
|
+
export * from "./I_InfluencersCategories";
|
|
7
|
+
export * from "./I_InfluencersProperties";
|
|
8
|
+
export * from "./I_Item";
|
|
9
|
+
export * from "./I_List";
|
|
10
|
+
export * from "./I_PaginatedList";
|
|
11
|
+
export * from "./I_Pagination";
|
|
12
|
+
export * from "./I_TIkTokRaports";
|
|
13
|
+
export * from "./I_Tag";
|
|
14
|
+
export * from "./I_TikTokPost";
|
|
15
|
+
export * from "./I_User";
|
|
16
|
+
export * from "./I_UserTikTokStatistic";
|
|
17
|
+
export * from "./I_ScrappingAccount";
|
|
18
|
+
export * from "./global";
|
|
19
|
+
export * from "./I_Scrappers";
|
|
20
|
+
export * from "./I_ScrappingServiceMessages";
|
|
21
|
+
export * from "./I_ScrappingMachine";
|
|
22
|
+
export * from "./I_ScrappingMachineProcess";
|
|
23
|
+
export * from "./T_FetchStatus";
|
|
24
|
+
export * from "./I_ResponseMessage";
|
|
25
|
+
export * from "./I_ScrapperLog";
|
|
26
|
+
export * from "./I_CampaignGoal";
|
|
27
|
+
export * from "./I_CampaignCollaborationMethod";
|
|
28
|
+
export * from "./I_TikTokReport";
|
|
29
|
+
export * from "./I_Offer";
|
|
30
|
+
export * from "./I_CampaignDeadline";
|
|
31
|
+
export * from "./I_Agency";
|
|
32
|
+
export * from "./I_Media";
|
|
33
|
+
export * from "./I_SocialAccount";
|
|
34
|
+
export * from "./I_Collaboration";
|
|
35
|
+
export * from "./I_Publish";
|
package/dist/types/index.js
CHANGED
|
@@ -46,4 +46,6 @@ __exportStar(require("./I_Offer"), exports);
|
|
|
46
46
|
__exportStar(require("./I_CampaignDeadline"), exports);
|
|
47
47
|
__exportStar(require("./I_Agency"), exports);
|
|
48
48
|
__exportStar(require("./I_Media"), exports);
|
|
49
|
+
__exportStar(require("./I_SocialAccount"), exports);
|
|
49
50
|
__exportStar(require("./I_Collaboration"), exports);
|
|
51
|
+
__exportStar(require("./I_Publish"), exports);
|
package/package.json
CHANGED
package/src/api/apiDriver.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FetchParams } from
|
|
2
|
-
import { concatApiPaths, createQueryString, insertParams } from
|
|
1
|
+
import { FetchParams } from "../types";
|
|
2
|
+
import { concatApiPaths, createQueryString, insertParams } from "./utils";
|
|
3
3
|
|
|
4
|
-
type HttpMethod =
|
|
4
|
+
type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
5
5
|
|
|
6
6
|
interface DriverConfig {
|
|
7
7
|
apiUrl: string;
|
|
@@ -14,33 +14,36 @@ export function configureApiDriver(config: DriverConfig) {
|
|
|
14
14
|
CONFIG = config;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
type FetchCallArgs<Q> =
|
|
18
|
-
path
|
|
19
|
-
params?: FetchParams<Q
|
|
20
|
-
method?: HttpMethod
|
|
21
|
-
headers?: HeadersInit
|
|
17
|
+
type FetchCallArgs<Q> = {
|
|
18
|
+
path?: string;
|
|
19
|
+
params?: FetchParams<Q>;
|
|
20
|
+
method?: HttpMethod;
|
|
21
|
+
headers?: HeadersInit;
|
|
22
22
|
transformers?: {
|
|
23
23
|
body?: (body: any) => BodyInit;
|
|
24
|
-
}
|
|
25
|
-
|
|
24
|
+
};
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
};
|
|
26
27
|
|
|
27
|
-
export async function fetchCall<T, Q>(
|
|
28
|
-
let
|
|
28
|
+
export async function fetchCall<T, Q>(args: FetchCallArgs<Q>): Promise<T> {
|
|
29
|
+
let { path, params, method, headers, baseUrl, transformers } = args;
|
|
29
30
|
|
|
30
31
|
headers = {
|
|
31
|
-
...CONFIG
|
|
32
|
+
...CONFIG?.getHeaders?.(),
|
|
32
33
|
...headers,
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const query: Q = {} as Q;
|
|
36
|
-
Object.entries(
|
|
37
|
+
Object.entries(params?.query || {}).forEach(([key, val]) => {
|
|
37
38
|
query[key] = Array.isArray(val) ? JSON.stringify(val) : val;
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
+
const apiUrl = baseUrl ?? CONFIG.apiUrl;
|
|
42
|
+
|
|
43
|
+
const queryString = createQueryString({ ...params, query });
|
|
41
44
|
const fullPath = insertParams(
|
|
42
|
-
concatApiPaths(
|
|
43
|
-
|
|
45
|
+
concatApiPaths(apiUrl, path) + queryString,
|
|
46
|
+
params?.params
|
|
44
47
|
);
|
|
45
48
|
|
|
46
49
|
const init: RequestInit = {
|
|
@@ -48,34 +51,69 @@ export async function fetchCall<T, Q>(...args: FetchCallArgs<Q>): Promise<T> {
|
|
|
48
51
|
headers,
|
|
49
52
|
};
|
|
50
53
|
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (params?.body) {
|
|
55
|
+
if (transformers?.body) {
|
|
56
|
+
init.body = transformers.body(params.body);
|
|
57
|
+
} else {
|
|
58
|
+
init.body = JSON.stringify(params.body);
|
|
59
|
+
}
|
|
57
60
|
|
|
58
|
-
headers[
|
|
61
|
+
if (!headers["Content-Type"]) {
|
|
62
|
+
headers["Content-Type"] = "application/json";
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
const res = await fetch(fullPath, init);
|
|
62
67
|
|
|
63
68
|
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
|
|
64
69
|
|
|
65
|
-
|
|
70
|
+
try {
|
|
71
|
+
return res.json() as Promise<T>;
|
|
72
|
+
} catch {
|
|
73
|
+
return res.text() as Promise<T>;
|
|
74
|
+
}
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
|
|
77
|
+
type MethodCallArgs<Q> = [
|
|
78
|
+
path: string,
|
|
79
|
+
options: Omit<FetchCallArgs<Q>, "path" | "method">
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
export function apiDriver(baseUrl?: string) {
|
|
69
83
|
return {
|
|
70
|
-
get: <T, Q>(...args:
|
|
71
|
-
fetchCall<T, Q>(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
get: <T, Q>(...args: MethodCallArgs<Q>) =>
|
|
85
|
+
fetchCall<T, Q>({
|
|
86
|
+
...args[1],
|
|
87
|
+
path: args[0],
|
|
88
|
+
method: "get",
|
|
89
|
+
baseUrl,
|
|
90
|
+
}),
|
|
91
|
+
post: <T, Q>(...args: MethodCallArgs<Q>) =>
|
|
92
|
+
fetchCall<T, Q>({
|
|
93
|
+
...args[1],
|
|
94
|
+
path: args[0],
|
|
95
|
+
method: "post",
|
|
96
|
+
baseUrl,
|
|
97
|
+
}),
|
|
98
|
+
put: <T, Q>(...args: MethodCallArgs<Q>) =>
|
|
99
|
+
fetchCall<T, Q>({
|
|
100
|
+
...args[1],
|
|
101
|
+
path: args[0],
|
|
102
|
+
method: "put",
|
|
103
|
+
}),
|
|
104
|
+
patch: <T, Q>(...args: MethodCallArgs<Q>) =>
|
|
105
|
+
fetchCall<T, Q>({
|
|
106
|
+
...args[1],
|
|
107
|
+
path: args[0],
|
|
108
|
+
method: "patch",
|
|
109
|
+
baseUrl,
|
|
110
|
+
}),
|
|
111
|
+
delete: <T, Q>(...args: MethodCallArgs<Q>) =>
|
|
112
|
+
fetchCall<T, Q>({
|
|
113
|
+
...args[1],
|
|
114
|
+
path: args[0],
|
|
115
|
+
method: "delete",
|
|
116
|
+
baseUrl,
|
|
117
|
+
}),
|
|
80
118
|
};
|
|
81
119
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./apiDriver";
|
|
2
|
+
export * from "./utils";
|
package/src/types/I_Item.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I_ResponseMessage } from
|
|
2
|
-
import { T_FetchStatus } from
|
|
1
|
+
import { I_ResponseMessage } from "./I_ResponseMessage";
|
|
2
|
+
import { T_FetchStatus } from "./T_FetchStatus";
|
|
3
3
|
|
|
4
4
|
export class I_Item<T> implements I_ResponseMessage {
|
|
5
5
|
data: T;
|
|
@@ -8,12 +8,12 @@ export class I_Item<T> implements I_ResponseMessage {
|
|
|
8
8
|
|
|
9
9
|
constructor(data?: Partial<I_Item<T>>) {
|
|
10
10
|
this.data = data?.data || null;
|
|
11
|
-
this.status = data?.status ||
|
|
12
|
-
this.message = data?.message ||
|
|
11
|
+
this.status = data?.status || "succeeded";
|
|
12
|
+
this.message = data?.message || "";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
succeed?(data: T, message?: string): this {
|
|
16
|
-
this.status =
|
|
16
|
+
this.status = "succeeded";
|
|
17
17
|
this.data = data;
|
|
18
18
|
this.message = message;
|
|
19
19
|
|
|
@@ -21,14 +21,14 @@ export class I_Item<T> implements I_ResponseMessage {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
fail?(message: string): this {
|
|
24
|
-
this.status =
|
|
24
|
+
this.status = "failed";
|
|
25
25
|
this.message = message;
|
|
26
26
|
|
|
27
27
|
return this;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const itemIsLoading = (item: I_Item<any>) => item.status ===
|
|
31
|
+
export const itemIsLoading = (item: I_Item<any>) => item.status === "loading";
|
|
32
32
|
export const itemIsResolving = (item: I_Item<any>) =>
|
|
33
|
-
item.status ===
|
|
34
|
-
export const itemFailed = (item: I_Item<any>) => item.status ===
|
|
33
|
+
item.status === "initial" || item.status === "loading";
|
|
34
|
+
export const itemFailed = (item: I_Item<any>) => item.status === "failed";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type I_CrossPostContentDTO = {
|
|
2
|
+
file: File;
|
|
3
|
+
description: string;
|
|
4
|
+
refreshToken: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type I_GetPublishStatusDTO = {
|
|
8
|
+
publishId: string;
|
|
9
|
+
refreshToken: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type I_PublishStatus = {
|
|
13
|
+
status: string;
|
|
14
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { T_FetchStatus } from
|
|
1
|
+
import { T_FetchStatus } from "./T_FetchStatus";
|
|
2
2
|
|
|
3
3
|
export class I_ResponseMessage {
|
|
4
4
|
status: T_FetchStatus;
|
|
5
5
|
message?: string;
|
|
6
6
|
|
|
7
7
|
constructor(data?: Partial<I_ResponseMessage>) {
|
|
8
|
-
this.status = data?.status ||
|
|
9
|
-
this.message = data?.message ||
|
|
8
|
+
this.status = data?.status || "initial";
|
|
9
|
+
this.message = data?.message || "";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IsNotEmpty,
|
|
3
|
+
IsOptional,
|
|
4
|
+
IsEnum,
|
|
5
|
+
IsISO8601,
|
|
6
|
+
IsString,
|
|
7
|
+
} from "class-validator";
|
|
8
|
+
|
|
9
|
+
export enum SocialProvider {
|
|
10
|
+
TIKTOK = "tiktok",
|
|
11
|
+
FACEBOOK = "facebook",
|
|
12
|
+
INSTAGRAM = "instagram",
|
|
13
|
+
YOUTUBE = "youtube",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class I_SocialSignInDTO {
|
|
17
|
+
// @IsNotEmpty()
|
|
18
|
+
// userId: string;
|
|
19
|
+
|
|
20
|
+
@IsEnum(SocialProvider)
|
|
21
|
+
provider: SocialProvider;
|
|
22
|
+
|
|
23
|
+
@IsNotEmpty()
|
|
24
|
+
@IsString()
|
|
25
|
+
provider_user_id: string;
|
|
26
|
+
|
|
27
|
+
@IsNotEmpty()
|
|
28
|
+
@IsString()
|
|
29
|
+
access_token: string;
|
|
30
|
+
|
|
31
|
+
@IsOptional()
|
|
32
|
+
@IsString()
|
|
33
|
+
refresh_token?: string;
|
|
34
|
+
|
|
35
|
+
@IsOptional()
|
|
36
|
+
@IsISO8601()
|
|
37
|
+
expires_at?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class I_TikTokUserPayload {
|
|
41
|
+
id: string;
|
|
42
|
+
role: string;
|
|
43
|
+
email?: string | null;
|
|
44
|
+
accessToken: string;
|
|
45
|
+
refreshToken: string;
|
|
46
|
+
influencer?: { handle_tt: string };
|
|
47
|
+
|
|
48
|
+
constructor(data: I_TikTokUserPayload) {
|
|
49
|
+
this.id = data.id;
|
|
50
|
+
this.role = data.role;
|
|
51
|
+
this.email = data.email;
|
|
52
|
+
this.accessToken = data.accessToken;
|
|
53
|
+
this.refreshToken = data.refreshToken;
|
|
54
|
+
this.influencer = data.influencer;
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/types/I_User.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IsNotEmpty } from
|
|
2
|
-
import { I_Influencer } from
|
|
1
|
+
import { IsNotEmpty } from 'class-validator';
|
|
2
|
+
import { I_Influencer } from './I_Influencer';
|
|
3
3
|
|
|
4
4
|
export class I_User {
|
|
5
5
|
id: string;
|
|
6
|
-
email
|
|
7
|
-
password
|
|
6
|
+
email?: string;
|
|
7
|
+
password?: string;
|
|
8
8
|
role: UserRoles;
|
|
9
9
|
influencer?: I_Influencer;
|
|
10
10
|
}
|
|
@@ -14,9 +14,9 @@ export class I_SignedUser extends I_User {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export enum UserRoles {
|
|
17
|
-
ADMIN =
|
|
18
|
-
INFLUENCER =
|
|
19
|
-
AGENT =
|
|
17
|
+
ADMIN = 'ADMIN',
|
|
18
|
+
INFLUENCER = 'INFLUENCER',
|
|
19
|
+
AGENT = 'AGENT',
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class I_UserCreateDTO {
|
package/src/types/index.ts
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
32
|
-
export * from
|
|
33
|
-
export * from
|
|
1
|
+
export * from "./I_TikTokUser";
|
|
2
|
+
export * from "./I_Queue";
|
|
3
|
+
export * from "./I_Campaign";
|
|
4
|
+
export * from "./I_Influencer";
|
|
5
|
+
export * from "./I_InfluencersLists";
|
|
6
|
+
export * from "./I_InfluencersCategories";
|
|
7
|
+
export * from "./I_InfluencersProperties";
|
|
8
|
+
export * from "./I_Item";
|
|
9
|
+
export * from "./I_List";
|
|
10
|
+
export * from "./I_PaginatedList";
|
|
11
|
+
export * from "./I_Pagination";
|
|
12
|
+
export * from "./I_TIkTokRaports";
|
|
13
|
+
export * from "./I_Tag";
|
|
14
|
+
export * from "./I_TikTokPost";
|
|
15
|
+
export * from "./I_User";
|
|
16
|
+
export * from "./I_UserTikTokStatistic";
|
|
17
|
+
export * from "./I_ScrappingAccount";
|
|
18
|
+
export * from "./global";
|
|
19
|
+
export * from "./I_Scrappers";
|
|
20
|
+
export * from "./I_ScrappingServiceMessages";
|
|
21
|
+
export * from "./I_ScrappingMachine";
|
|
22
|
+
export * from "./I_ScrappingMachineProcess";
|
|
23
|
+
export * from "./T_FetchStatus";
|
|
24
|
+
export * from "./I_ResponseMessage";
|
|
25
|
+
export * from "./I_ScrapperLog";
|
|
26
|
+
export * from "./I_CampaignGoal";
|
|
27
|
+
export * from "./I_CampaignCollaborationMethod";
|
|
28
|
+
export * from "./I_TikTokReport";
|
|
29
|
+
export * from "./I_Offer";
|
|
30
|
+
export * from "./I_CampaignDeadline";
|
|
31
|
+
export * from "./I_Agency";
|
|
32
|
+
export * from "./I_Media";
|
|
33
|
+
export * from "./I_SocialAccount";
|
|
34
|
+
export * from "./I_Collaboration";
|
|
35
|
+
export * from "./I_Publish";
|
package/dist/api/apiUtils.d.ts
DELETED
|
File without changes
|
package/dist/api/apiUtils.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// import { FetchParams } from "./apiDriver";
|
|
2
|
-
// const apiUrl = process.env.REACT_APP_API_URL;
|
|
3
|
-
// export const concatApiPaths = (endpoint: string) => apiUrl + "/" + endpoint;
|
|
4
|
-
// export const createQueryString = <T>(fetchParams?: FetchParams<T>) => {
|
|
5
|
-
// return fetchParams?.query
|
|
6
|
-
// ? "?" + new URLSearchParams(fetchParams.query as URLSearchParams).toString()
|
|
7
|
-
// : "";
|
|
8
|
-
// };
|
|
9
|
-
// export const extractParams = (path: string): string[] => {
|
|
10
|
-
// return path
|
|
11
|
-
// .split("/")
|
|
12
|
-
// .filter((segment) => segment.startsWith(":"))
|
|
13
|
-
// .map((segment) => segment.substring(1));
|
|
14
|
-
// };
|
|
15
|
-
// export const insertParams = (
|
|
16
|
-
// path: string,
|
|
17
|
-
// params?: { [key: string]: string | number }
|
|
18
|
-
// ): string => {
|
|
19
|
-
// if (!params) {
|
|
20
|
-
// return path;
|
|
21
|
-
// }
|
|
22
|
-
// const paramNames = extractParams(path);
|
|
23
|
-
// paramNames.forEach((paramName) => {
|
|
24
|
-
// if (params[paramName] !== undefined) {
|
|
25
|
-
// path = path.replace(`:${paramName}`, String(params[paramName]));
|
|
26
|
-
// } else {
|
|
27
|
-
// throw new Error(`Missing value for parameter: ${paramName}`);
|
|
28
|
-
// }
|
|
29
|
-
// });
|
|
30
|
-
// return path;
|
|
31
|
-
// };
|
package/dist/types/I_Report.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { I_Influencer } from "./I_Influencer";
|
|
2
|
-
import { I_TikTokPost } from "./I_TikTokPost";
|
|
3
|
-
export declare class I_Report {
|
|
4
|
-
influencerId: number;
|
|
5
|
-
data: I_TikTokPost[];
|
|
6
|
-
ad_mean_views: number;
|
|
7
|
-
mean_views: number;
|
|
8
|
-
updatedAt: Date;
|
|
9
|
-
influencer: I_Influencer;
|
|
10
|
-
constructor(data?: I_Report);
|
|
11
|
-
}
|
package/dist/types/I_Report.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.I_Report = void 0;
|
|
4
|
-
class I_Report {
|
|
5
|
-
constructor(data) {
|
|
6
|
-
this.influencerId = data?.influencerId ?? null;
|
|
7
|
-
this.data = data?.data ?? [];
|
|
8
|
-
this.ad_mean_views = data?.ad_mean_views ?? null;
|
|
9
|
-
this.mean_views = data?.mean_views ?? null;
|
|
10
|
-
this.updatedAt = data?.updatedAt ?? null;
|
|
11
|
-
this.influencer = data?.influencer ?? null;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.I_Report = I_Report;
|