ad2app-lib 1.0.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.
Files changed (140) hide show
  1. package/README.md +37 -0
  2. package/dist/api/apiDriver.d.ts +16 -0
  3. package/dist/api/apiDriver.js +40 -0
  4. package/dist/api/apiUtils.d.ts +0 -0
  5. package/dist/api/apiUtils.js +31 -0
  6. package/dist/api/index.d.ts +2 -0
  7. package/dist/api/index.js +18 -0
  8. package/dist/api/utils.d.ts +7 -0
  9. package/dist/api/utils.js +34 -0
  10. package/dist/types/I_Agency.d.ts +9 -0
  11. package/dist/types/I_Agency.js +12 -0
  12. package/dist/types/I_Campaign.d.ts +76 -0
  13. package/dist/types/I_Campaign.js +176 -0
  14. package/dist/types/I_CampaignCollaborationMethod.d.ts +11 -0
  15. package/dist/types/I_CampaignCollaborationMethod.js +30 -0
  16. package/dist/types/I_CampaignDeadline.d.ts +29 -0
  17. package/dist/types/I_CampaignDeadline.js +80 -0
  18. package/dist/types/I_CampaignGoal.d.ts +11 -0
  19. package/dist/types/I_CampaignGoal.js +30 -0
  20. package/dist/types/I_Influencer.d.ts +37 -0
  21. package/dist/types/I_Influencer.js +87 -0
  22. package/dist/types/I_InfluencersCategories.d.ts +26 -0
  23. package/dist/types/I_InfluencersCategories.js +72 -0
  24. package/dist/types/I_InfluencersLists.d.ts +68 -0
  25. package/dist/types/I_InfluencersLists.js +95 -0
  26. package/dist/types/I_InfluencersProperties.d.ts +40 -0
  27. package/dist/types/I_InfluencersProperties.js +95 -0
  28. package/dist/types/I_Item.d.ts +11 -0
  29. package/dist/types/I_Item.js +17 -0
  30. package/dist/types/I_List.d.ts +8 -0
  31. package/dist/types/I_List.js +11 -0
  32. package/dist/types/I_Offer.d.ts +63 -0
  33. package/dist/types/I_Offer.js +79 -0
  34. package/dist/types/I_PaginatedList.d.ts +10 -0
  35. package/dist/types/I_PaginatedList.js +13 -0
  36. package/dist/types/I_Pagination.d.ts +7 -0
  37. package/dist/types/I_Pagination.js +12 -0
  38. package/dist/types/I_Queue.d.ts +25 -0
  39. package/dist/types/I_Queue.js +54 -0
  40. package/dist/types/I_Report.d.ts +11 -0
  41. package/dist/types/I_Report.js +14 -0
  42. package/dist/types/I_ResponseMessage.d.ts +6 -0
  43. package/dist/types/I_ResponseMessage.js +10 -0
  44. package/dist/types/I_SM_Platform.d.ts +4 -0
  45. package/dist/types/I_SM_Platform.js +8 -0
  46. package/dist/types/I_ScrapperLog.d.ts +15 -0
  47. package/dist/types/I_ScrapperLog.js +9 -0
  48. package/dist/types/I_Scrappers.d.ts +35 -0
  49. package/dist/types/I_Scrappers.js +11 -0
  50. package/dist/types/I_ScrappingAccount.d.ts +10 -0
  51. package/dist/types/I_ScrappingAccount.js +6 -0
  52. package/dist/types/I_ScrappingMachine.d.ts +29 -0
  53. package/dist/types/I_ScrappingMachine.js +46 -0
  54. package/dist/types/I_ScrappingMachineProcess.d.ts +22 -0
  55. package/dist/types/I_ScrappingMachineProcess.js +46 -0
  56. package/dist/types/I_ScrappingServiceMessages.d.ts +31 -0
  57. package/dist/types/I_ScrappingServiceMessages.js +2 -0
  58. package/dist/types/I_TIkTokRaports.d.ts +8 -0
  59. package/dist/types/I_TIkTokRaports.js +38 -0
  60. package/dist/types/I_Tag.d.ts +10 -0
  61. package/dist/types/I_Tag.js +12 -0
  62. package/dist/types/I_TikTokPost.d.ts +45 -0
  63. package/dist/types/I_TikTokPost.js +47 -0
  64. package/dist/types/I_TikTokReport.d.ts +11 -0
  65. package/dist/types/I_TikTokReport.js +14 -0
  66. package/dist/types/I_TikTokUser.d.ts +53 -0
  67. package/dist/types/I_TikTokUser.js +97 -0
  68. package/dist/types/I_User.d.ts +35 -0
  69. package/dist/types/I_User.js +76 -0
  70. package/dist/types/I_UserTikTokStatistic.d.ts +13 -0
  71. package/dist/types/I_UserTikTokStatistic.js +16 -0
  72. package/dist/types/T_FetchStatus.d.ts +1 -0
  73. package/dist/types/T_FetchStatus.js +2 -0
  74. package/dist/types/global.d.ts +9 -0
  75. package/dist/types/global.js +2 -0
  76. package/dist/types/index.d.ts +31 -0
  77. package/dist/types/index.js +47 -0
  78. package/dist/utils/array.d.ts +3 -0
  79. package/dist/utils/array.js +12 -0
  80. package/dist/utils/cookies.d.ts +0 -0
  81. package/dist/utils/cookies.js +13 -0
  82. package/dist/utils/date.d.ts +5 -0
  83. package/dist/utils/date.js +19 -0
  84. package/dist/utils/index.d.ts +6 -0
  85. package/dist/utils/index.js +22 -0
  86. package/dist/utils/promise.d.ts +1 -0
  87. package/dist/utils/promise.js +6 -0
  88. package/dist/utils/string.d.ts +1 -0
  89. package/dist/utils/string.js +5 -0
  90. package/dist/utils/types.d.ts +5 -0
  91. package/dist/utils/types.js +2 -0
  92. package/dist/utils/variable.d.ts +2 -0
  93. package/dist/utils/variable.js +11 -0
  94. package/index.ts +5 -0
  95. package/package.json +41 -0
  96. package/src/api/apiDriver.ts +65 -0
  97. package/src/api/index.ts +2 -0
  98. package/src/api/utils.ts +38 -0
  99. package/src/types/I_Agency.ts +16 -0
  100. package/src/types/I_Campaign.ts +171 -0
  101. package/src/types/I_CampaignCollaborationMethod.ts +20 -0
  102. package/src/types/I_CampaignDeadline.ts +65 -0
  103. package/src/types/I_CampaignGoal.ts +20 -0
  104. package/src/types/I_Influencer.ts +93 -0
  105. package/src/types/I_InfluencersCategories.ts +52 -0
  106. package/src/types/I_InfluencersLists.ts +104 -0
  107. package/src/types/I_InfluencersProperties.ts +83 -0
  108. package/src/types/I_Item.ts +19 -0
  109. package/src/types/I_List.ts +14 -0
  110. package/src/types/I_Offer.ts +105 -0
  111. package/src/types/I_PaginatedList.ts +17 -0
  112. package/src/types/I_Pagination.ts +13 -0
  113. package/src/types/I_Queue.ts +40 -0
  114. package/src/types/I_ResponseMessage.ts +11 -0
  115. package/src/types/I_SM_Platform.ts +4 -0
  116. package/src/types/I_ScrapperLog.ts +17 -0
  117. package/src/types/I_Scrappers.ts +34 -0
  118. package/src/types/I_ScrappingAccount.ts +11 -0
  119. package/src/types/I_ScrappingMachine.ts +47 -0
  120. package/src/types/I_ScrappingMachineProcess.ts +36 -0
  121. package/src/types/I_ScrappingServiceMessages.ts +38 -0
  122. package/src/types/I_TIkTokRaports.ts +20 -0
  123. package/src/types/I_Tag.ts +12 -0
  124. package/src/types/I_TikTokPost.ts +64 -0
  125. package/src/types/I_TikTokReport.ts +20 -0
  126. package/src/types/I_TikTokUser.ts +108 -0
  127. package/src/types/I_User.ts +57 -0
  128. package/src/types/I_UserTikTokStatistic.ts +25 -0
  129. package/src/types/T_FetchStatus.ts +1 -0
  130. package/src/types/global.ts +10 -0
  131. package/src/types/index.ts +31 -0
  132. package/src/utils/array.ts +15 -0
  133. package/src/utils/cookies.ts +16 -0
  134. package/src/utils/date.ts +14 -0
  135. package/src/utils/index.ts +6 -0
  136. package/src/utils/promise.ts +3 -0
  137. package/src/utils/string.ts +1 -0
  138. package/src/utils/types.ts +9 -0
  139. package/src/utils/variable.ts +7 -0
  140. package/tsconfig.json +14 -0
@@ -0,0 +1,64 @@
1
+ import { IsString } from "class-validator";
2
+ import { I_Tag } from "./I_Tag";
3
+
4
+ export class I_TikTokPost {
5
+ url: string;
6
+ description: string;
7
+ likes: number;
8
+ views: number;
9
+ comments: I_TikTokComment[];
10
+ commentsAmount: number;
11
+ commentsSentimentRatio: number;
12
+ shares: number;
13
+ bookmarks: number;
14
+ isAd: number;
15
+ VQScore: number;
16
+ uploadedAt: Date | null;
17
+ tags: I_Tag[];
18
+ bitrateInfo: { QualityType: number; CodecType: string; GearName: string }[];
19
+ pinned: boolean;
20
+ statisticsHistory: {
21
+ date: Date;
22
+ commentsAmount: number;
23
+ views: number;
24
+ likes: number;
25
+ shares: number;
26
+ bookmarks: number;
27
+ }[];
28
+
29
+ constructor(data?: Partial<I_TikTokPost>) {
30
+ this.url = data?.url ?? "";
31
+ this.description = data?.description ?? "";
32
+ this.likes = data?.likes ?? -1;
33
+ this.views = data?.views ?? -1;
34
+ this.comments = data?.comments ?? [];
35
+ this.commentsAmount = data?.commentsAmount ?? -1;
36
+ this.commentsSentimentRatio = data?.commentsSentimentRatio ?? null;
37
+ this.shares = data?.shares ?? 0;
38
+ this.bookmarks = data?.bookmarks ?? -1;
39
+ this.isAd = data?.isAd ?? 0;
40
+ this.VQScore = data?.VQScore ?? 0;
41
+ this.uploadedAt = data?.uploadedAt ? new Date(data.uploadedAt) : null;
42
+ this.tags = data?.tags ?? [];
43
+ this.bitrateInfo = data?.bitrateInfo ?? [];
44
+ this.pinned = data?.pinned ?? false;
45
+ this.statisticsHistory = data?.statisticsHistory ?? [];
46
+ }
47
+ }
48
+
49
+ export class I_TikTokComment {
50
+ comment_language: string;
51
+ text: string;
52
+ create_time: string;
53
+ user: {
54
+ unique_id: string;
55
+ };
56
+ }
57
+ export class I_TikTokUserPostsRaport {
58
+ data: I_TikTokPost[];
59
+ }
60
+
61
+ export class I_GetTikTokPostsDTO {
62
+ @IsString()
63
+ handle: string;
64
+ }
@@ -0,0 +1,20 @@
1
+ import { I_Influencer } from "./I_Influencer";
2
+ import { I_TikTokPost } from "./I_TikTokPost";
3
+
4
+ export class I_TikTokReport {
5
+ influencerId: number;
6
+ data: I_TikTokPost[];
7
+ ad_mean_views: number;
8
+ mean_views: number;
9
+ updatedAt: Date;
10
+ influencer: I_Influencer;
11
+
12
+ constructor(data?: I_TikTokReport) {
13
+ this.influencerId = data?.influencerId ?? null;
14
+ this.data = data?.data ?? [];
15
+ this.ad_mean_views = data?.ad_mean_views ?? null;
16
+ this.mean_views = data?.mean_views ?? null;
17
+ this.updatedAt = data?.updatedAt ?? null;
18
+ this.influencer = data?.influencer ?? null;
19
+ }
20
+ }
@@ -0,0 +1,108 @@
1
+ import { IsNotEmpty, IsOptional, IsString } from "class-validator";
2
+
3
+ import { I_TikTokPost } from "./I_TikTokPost";
4
+
5
+ export class I_TikTokUser {
6
+ avatarUrl?: string;
7
+ handle: string;
8
+ bio: string;
9
+ followerCount: number;
10
+ followingCount: number;
11
+ likes: number;
12
+ languages: string[];
13
+ nationality: string;
14
+ ftc: boolean;
15
+ secret: boolean;
16
+ ttSeller: boolean;
17
+ relation: number;
18
+ openFavorite: boolean;
19
+ isADVirtual: boolean;
20
+ downloadSetting: number;
21
+ commentSetting: number;
22
+ verified: boolean;
23
+ tiktoks: I_TikTokPost[];
24
+ following: I_TikTokUser[];
25
+ followers: I_TikTokUser[];
26
+ updatedAt: Date;
27
+ statisticsHistory: {
28
+ date: Date;
29
+ followerCount: number;
30
+ followingCount: number;
31
+ likes: number;
32
+ }[];
33
+
34
+ constructor(data?: Partial<I_TikTokUser>) {
35
+ this.avatarUrl = data?.avatarUrl ?? "";
36
+ this.handle = data?.handle ?? "";
37
+ this.bio = data?.bio ?? "";
38
+ this.followerCount = data?.followerCount ?? 0;
39
+ this.followingCount = data?.followingCount ?? 0;
40
+ this.likes = data?.likes ?? 0;
41
+ this.languages = data?.languages ?? [];
42
+ this.nationality = data?.nationality ?? "";
43
+ this.ftc = data?.ftc ?? false;
44
+ this.secret = data?.secret ?? false;
45
+ this.ttSeller = data?.ttSeller ?? false;
46
+ this.relation = data?.relation ?? 0;
47
+ this.openFavorite = data?.openFavorite ?? false;
48
+ this.isADVirtual = data?.isADVirtual ?? false;
49
+ this.downloadSetting = data?.downloadSetting ?? 0;
50
+ this.commentSetting = data?.commentSetting ?? 0;
51
+ this.verified = data?.verified ?? false;
52
+ this.tiktoks = data?.tiktoks ?? [];
53
+ this.following = data?.following ?? [];
54
+ this.followers = data?.followers ?? [];
55
+ this.updatedAt = data?.updatedAt ?? new Date();
56
+ this.statisticsHistory = data?.statisticsHistory ?? [];
57
+ }
58
+ }
59
+
60
+ export class I_SearchTikTokUserDTO {
61
+ @IsOptional()
62
+ handle: string;
63
+
64
+ @IsOptional()
65
+ followers_from: number;
66
+
67
+ @IsOptional()
68
+ verified: boolean;
69
+
70
+ @IsString({ each: true })
71
+ @IsOptional()
72
+ languages: string[];
73
+
74
+ constructor(data?: Partial<I_SearchTikTokUserDTO>) {
75
+ this.followers_from = data?.followers_from || 0;
76
+ this.verified = !!data?.verified;
77
+ this.languages = data?.languages || [];
78
+ this.handle = data?.handle || "";
79
+ }
80
+ }
81
+
82
+ export class I_TikTokUserCreateDTO {
83
+ @IsString()
84
+ handle: string;
85
+
86
+ constructor(data?: Partial<I_TikTokUserCreateDTO>) {
87
+ this.handle = data?.handle || "";
88
+ }
89
+ }
90
+
91
+ export class I_TikTokUserGetDTO {
92
+ @IsNotEmpty()
93
+ handle: string;
94
+ }
95
+
96
+ export class I_TikTokUserGetManyDTO {
97
+ @IsNotEmpty()
98
+ handles: string[];
99
+ }
100
+
101
+ export class I_TikTokUserCalculatePostCommentsSentimentDTO {
102
+ @IsNotEmpty()
103
+ handle: string;
104
+
105
+ category?: string;
106
+
107
+ instructions?: string;
108
+ }
@@ -0,0 +1,57 @@
1
+ import { IsNotEmpty } from "class-validator";
2
+ import { I_Influencer } from "./I_Influencer";
3
+
4
+ export class I_User {
5
+ id: string;
6
+ email: string;
7
+ password: string;
8
+ role: UserRoles;
9
+ influencer?: I_Influencer;
10
+ }
11
+
12
+ export class I_SignedUser extends I_User {
13
+ accessToken: string;
14
+ }
15
+
16
+ export enum UserRoles {
17
+ ADMIN = "ADMIN",
18
+ INFLUENCER = "INFLUENCER",
19
+ AGENT = "AGENT",
20
+ }
21
+
22
+ export class I_UserCreateDTO {
23
+ @IsNotEmpty()
24
+ password: string;
25
+
26
+ @IsNotEmpty()
27
+ email: string;
28
+ }
29
+
30
+ export class I_UserSignInDTO {
31
+ @IsNotEmpty()
32
+ password: string;
33
+
34
+ @IsNotEmpty()
35
+ email: string;
36
+ }
37
+
38
+ export class I_UserSignUpDTO {
39
+ @IsNotEmpty()
40
+ username: string;
41
+
42
+ @IsNotEmpty()
43
+ password: string;
44
+
45
+ @IsNotEmpty()
46
+ email: string;
47
+ }
48
+
49
+ export class I_UserFindOneDTO {
50
+ @IsNotEmpty()
51
+ email: string;
52
+ }
53
+
54
+ export class I_UserAuthenticateDTO {
55
+ @IsNotEmpty()
56
+ accessToken: string;
57
+ }
@@ -0,0 +1,25 @@
1
+ export class I_UserTikTokStatistic {
2
+ url: string;
3
+ isAd: number;
4
+ views: number;
5
+ commentsAmount: number;
6
+ likes: number;
7
+ uploadedAt: Date;
8
+ VQScore: number;
9
+ shares: number;
10
+
11
+ constructor(
12
+ data?: Partial<I_UserTikTokStatistic> & {
13
+ isAd?: number;
14
+ }
15
+ ) {
16
+ this.isAd = data?.isAd;
17
+ this.views = data?.views || 0;
18
+ this.likes = data?.likes || 0;
19
+ this.commentsAmount = data?.commentsAmount || 0;
20
+ this.uploadedAt = data?.uploadedAt || new Date();
21
+ this.url = data?.url || "";
22
+ this.VQScore = data?.VQScore || 0;
23
+ this.shares = data?.shares || 0;
24
+ }
25
+ }
@@ -0,0 +1 @@
1
+ export type T_FetchStatus = "initial" | "loading" | "succeeded" | "failed";
@@ -0,0 +1,10 @@
1
+ export type Timespan = {
2
+ from: Date;
3
+ to: Date;
4
+ };
5
+
6
+ export type FetchParams<T> = {
7
+ params?: {};
8
+ query?: T;
9
+ body?: T;
10
+ };
@@ -0,0 +1,31 @@
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";
@@ -0,0 +1,15 @@
1
+ export const safeguardArray = <T>(array: T[]) => [...(array || [])];
2
+
3
+ export const uniqueArray = <T>(array: T[], element: T[]): T[] =>
4
+ Array.from(new Set([...safeguardArray(array), ...safeguardArray(element)]));
5
+
6
+ export const replaceArrayItemBy = <T>(
7
+ array: T[],
8
+ updatedItem: T,
9
+ by: keyof T
10
+ ): T[] => {
11
+ const key = by;
12
+ return safeguardArray(array).map((item) =>
13
+ item?.[key] === updatedItem?.[key] ? updatedItem : item
14
+ );
15
+ };
@@ -0,0 +1,16 @@
1
+ // import Cookies from 'js-cookie';
2
+
3
+ // export const setAuthTokenCookie = (token: string) => {
4
+ // Cookies.remove('authToken');
5
+ // const isSecure = window.location.protocol === 'https:';
6
+
7
+ // Cookies.set('authToken', token, {
8
+ // expires: 7,
9
+ // secure: isSecure,
10
+ // sameSite: isSecure ? 'None' : 'Strict',
11
+ // });
12
+ // };
13
+
14
+ // export const getAuthTokenCookie = () => {
15
+ // return Cookies.get('authToken');
16
+ // };
@@ -0,0 +1,14 @@
1
+ import { format, isBefore } from "date-fns";
2
+
3
+ // TODO: Implement this eveywhere D ate is applied in DB
4
+ export const getTimestampWithMilliseconds = (date: Date = new Date()) => {
5
+ return new Date(format(date, "yyyy-MM-dd HH:mm:ss.SSS"));
6
+ };
7
+
8
+ export function isAtLeastOld(date: Date, maxAge: Date): boolean {
9
+ return isBefore(date, maxAge);
10
+ }
11
+
12
+ export const formatShort = (date: Date) => format(new Date(date), "yyyy-MM-dd");
13
+ export const formatTime = (date: Date) => format(new Date(date), "HH:mm");
14
+ export const formatFull = (date: Date) => format(new Date(date), "PPpp");
@@ -0,0 +1,6 @@
1
+ export * from "./array";
2
+ export * from "./date";
3
+ export * from "./promise";
4
+ export * from "./string";
5
+ export * from "./variable";
6
+ export * from "./types";
@@ -0,0 +1,3 @@
1
+ export async function wait(time = 1000) {
2
+ await new Promise((res) => setTimeout(res, time));
3
+ }
@@ -0,0 +1 @@
1
+ export const hasEmoji = (str: string) => /\p{Emoji}/u.test(str);
@@ -0,0 +1,9 @@
1
+ type Prev = [never, 0, 1, 2, 3, 4, 5];
2
+
3
+ export type DotNestedKeys<T, Depth extends number = 5> = [Depth] extends [never]
4
+ ? never
5
+ : {
6
+ [K in keyof T & string]: T[K] extends object
7
+ ? K | `${K}.${DotNestedKeys<T[K], Prev[Depth]>}`
8
+ : K;
9
+ }[keyof T & string];
@@ -0,0 +1,7 @@
1
+ export const getTargetValueOrNull = <T>(value: unknown, targetValue: T) => {
2
+ return (!!value && targetValue) || undefined;
3
+ };
4
+
5
+ export const getNumberOrUndefined = (value: unknown) => {
6
+ return value ? Number(value) : undefined;
7
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "moduleResolution": "node",
6
+ "declaration": true,
7
+ "emitDecoratorMetadata": true,
8
+ "experimentalDecorators": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "esModuleInterop": true,
11
+ "outDir": "dist"
12
+ },
13
+ "include": ["src/**/*"]
14
+ }