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.
- package/README.md +37 -0
- package/dist/api/apiDriver.d.ts +16 -0
- package/dist/api/apiDriver.js +40 -0
- package/dist/api/apiUtils.d.ts +0 -0
- package/dist/api/apiUtils.js +31 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +18 -0
- package/dist/api/utils.d.ts +7 -0
- package/dist/api/utils.js +34 -0
- package/dist/types/I_Agency.d.ts +9 -0
- package/dist/types/I_Agency.js +12 -0
- package/dist/types/I_Campaign.d.ts +76 -0
- package/dist/types/I_Campaign.js +176 -0
- package/dist/types/I_CampaignCollaborationMethod.d.ts +11 -0
- package/dist/types/I_CampaignCollaborationMethod.js +30 -0
- package/dist/types/I_CampaignDeadline.d.ts +29 -0
- package/dist/types/I_CampaignDeadline.js +80 -0
- package/dist/types/I_CampaignGoal.d.ts +11 -0
- package/dist/types/I_CampaignGoal.js +30 -0
- package/dist/types/I_Influencer.d.ts +37 -0
- package/dist/types/I_Influencer.js +87 -0
- package/dist/types/I_InfluencersCategories.d.ts +26 -0
- package/dist/types/I_InfluencersCategories.js +72 -0
- package/dist/types/I_InfluencersLists.d.ts +68 -0
- package/dist/types/I_InfluencersLists.js +95 -0
- package/dist/types/I_InfluencersProperties.d.ts +40 -0
- package/dist/types/I_InfluencersProperties.js +95 -0
- package/dist/types/I_Item.d.ts +11 -0
- package/dist/types/I_Item.js +17 -0
- package/dist/types/I_List.d.ts +8 -0
- package/dist/types/I_List.js +11 -0
- package/dist/types/I_Offer.d.ts +63 -0
- package/dist/types/I_Offer.js +79 -0
- package/dist/types/I_PaginatedList.d.ts +10 -0
- package/dist/types/I_PaginatedList.js +13 -0
- package/dist/types/I_Pagination.d.ts +7 -0
- package/dist/types/I_Pagination.js +12 -0
- package/dist/types/I_Queue.d.ts +25 -0
- package/dist/types/I_Queue.js +54 -0
- package/dist/types/I_Report.d.ts +11 -0
- package/dist/types/I_Report.js +14 -0
- package/dist/types/I_ResponseMessage.d.ts +6 -0
- package/dist/types/I_ResponseMessage.js +10 -0
- package/dist/types/I_SM_Platform.d.ts +4 -0
- package/dist/types/I_SM_Platform.js +8 -0
- package/dist/types/I_ScrapperLog.d.ts +15 -0
- package/dist/types/I_ScrapperLog.js +9 -0
- package/dist/types/I_Scrappers.d.ts +35 -0
- package/dist/types/I_Scrappers.js +11 -0
- package/dist/types/I_ScrappingAccount.d.ts +10 -0
- package/dist/types/I_ScrappingAccount.js +6 -0
- package/dist/types/I_ScrappingMachine.d.ts +29 -0
- package/dist/types/I_ScrappingMachine.js +46 -0
- package/dist/types/I_ScrappingMachineProcess.d.ts +22 -0
- package/dist/types/I_ScrappingMachineProcess.js +46 -0
- package/dist/types/I_ScrappingServiceMessages.d.ts +31 -0
- package/dist/types/I_ScrappingServiceMessages.js +2 -0
- package/dist/types/I_TIkTokRaports.d.ts +8 -0
- package/dist/types/I_TIkTokRaports.js +38 -0
- package/dist/types/I_Tag.d.ts +10 -0
- package/dist/types/I_Tag.js +12 -0
- package/dist/types/I_TikTokPost.d.ts +45 -0
- package/dist/types/I_TikTokPost.js +47 -0
- package/dist/types/I_TikTokReport.d.ts +11 -0
- package/dist/types/I_TikTokReport.js +14 -0
- package/dist/types/I_TikTokUser.d.ts +53 -0
- package/dist/types/I_TikTokUser.js +97 -0
- package/dist/types/I_User.d.ts +35 -0
- package/dist/types/I_User.js +76 -0
- package/dist/types/I_UserTikTokStatistic.d.ts +13 -0
- package/dist/types/I_UserTikTokStatistic.js +16 -0
- package/dist/types/T_FetchStatus.d.ts +1 -0
- package/dist/types/T_FetchStatus.js +2 -0
- package/dist/types/global.d.ts +9 -0
- package/dist/types/global.js +2 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.js +47 -0
- package/dist/utils/array.d.ts +3 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/cookies.d.ts +0 -0
- package/dist/utils/cookies.js +13 -0
- package/dist/utils/date.d.ts +5 -0
- package/dist/utils/date.js +19 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/promise.d.ts +1 -0
- package/dist/utils/promise.js +6 -0
- package/dist/utils/string.d.ts +1 -0
- package/dist/utils/string.js +5 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/variable.d.ts +2 -0
- package/dist/utils/variable.js +11 -0
- package/index.ts +5 -0
- package/package.json +41 -0
- package/src/api/apiDriver.ts +65 -0
- package/src/api/index.ts +2 -0
- package/src/api/utils.ts +38 -0
- package/src/types/I_Agency.ts +16 -0
- package/src/types/I_Campaign.ts +171 -0
- package/src/types/I_CampaignCollaborationMethod.ts +20 -0
- package/src/types/I_CampaignDeadline.ts +65 -0
- package/src/types/I_CampaignGoal.ts +20 -0
- package/src/types/I_Influencer.ts +93 -0
- package/src/types/I_InfluencersCategories.ts +52 -0
- package/src/types/I_InfluencersLists.ts +104 -0
- package/src/types/I_InfluencersProperties.ts +83 -0
- package/src/types/I_Item.ts +19 -0
- package/src/types/I_List.ts +14 -0
- package/src/types/I_Offer.ts +105 -0
- package/src/types/I_PaginatedList.ts +17 -0
- package/src/types/I_Pagination.ts +13 -0
- package/src/types/I_Queue.ts +40 -0
- package/src/types/I_ResponseMessage.ts +11 -0
- package/src/types/I_SM_Platform.ts +4 -0
- package/src/types/I_ScrapperLog.ts +17 -0
- package/src/types/I_Scrappers.ts +34 -0
- package/src/types/I_ScrappingAccount.ts +11 -0
- package/src/types/I_ScrappingMachine.ts +47 -0
- package/src/types/I_ScrappingMachineProcess.ts +36 -0
- package/src/types/I_ScrappingServiceMessages.ts +38 -0
- package/src/types/I_TIkTokRaports.ts +20 -0
- package/src/types/I_Tag.ts +12 -0
- package/src/types/I_TikTokPost.ts +64 -0
- package/src/types/I_TikTokReport.ts +20 -0
- package/src/types/I_TikTokUser.ts +108 -0
- package/src/types/I_User.ts +57 -0
- package/src/types/I_UserTikTokStatistic.ts +25 -0
- package/src/types/T_FetchStatus.ts +1 -0
- package/src/types/global.ts +10 -0
- package/src/types/index.ts +31 -0
- package/src/utils/array.ts +15 -0
- package/src/utils/cookies.ts +16 -0
- package/src/utils/date.ts +14 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/promise.ts +3 -0
- package/src/utils/string.ts +1 -0
- package/src/utils/types.ts +9 -0
- package/src/utils/variable.ts +7 -0
- 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,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 @@
|
|
|
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];
|
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
|
+
}
|