-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
global.d.ts
167 lines (149 loc) · 5.29 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import { ResumeSchemaLegacy as _ResumeSchemaLegacy } from './jsonresume.schema.legacy';
import { ResumeSchemaStable as _ResumeSchemaStable, ResumeSchemaBeyondSpec as _ResumeSchemaBeyondSpec } from './jsonresume.schema.latest';
declare global {
interface GenObj {
[k: string]: any;
}
// LI Types
/**
* Uniform Resource Name (URN) - very common throughout LinkedIn APIs
* @example urn:li:collectionResponse:acb123...
* @see https://docs.microsoft.com/en-us/linkedin/shared/api-guide/concepts/urns
*/
type LiUrn = string;
/**
* These are used throughout LI APIs, also referred to as "recipes" or "recipeTypes"
* @example com.linkedin.voyager.identity.profile.Profile
*/
type LiTypeStr = `com.linkedin.${string}`;
interface LiPaging {
count: number;
start: number;
total?: number;
$recipeTypes?: LiTypeStr[];
// I've never actually seen this property populated...
// This is probably actually `Array<com.linkedin.restli.common.Link>`
links?: string[];
}
interface LiEntity {
$type: LiTypeStr;
entityUrn: LiUrn;
objectUrn?: LiUrn;
[key: string]: any;
paging?: LiPaging;
}
interface LiResponse {
data: {
$type: LiTypeStr;
paging?: LiPaging;
// This is kind of a ToC, where each string corresponds to an entityUrn ID of an entity in `included`
'*elements'?: string[];
// Any number of fields can be included, especially if this is a "flat" response (when `included` is empty, and all entity data is directly in `data`)
[k: string]: GenObj | string | boolean;
} & Partial<LiEntity>;
included: LiEntity[];
meta?: {
microSchema?: {
isGraphQL: boolean;
types: {
[key: string]: {
baseType: LiTypeStr;
fields: GenObj;
};
};
};
};
}
interface LiSupportedLocale {
country: string;
language: string;
$type: LiTypeStr;
}
/**
* ! WARNING ! - Month and day are *not* zero-indexed. E.g. "Feb" is represented as `2`, not `1`
*/
interface LiDate {
month?: number;
day?: number;
year?: number;
}
interface LiPhoneNum {
number: string;
type: 'MOBILE' | 'WORK' | 'HOME' | string;
}
interface LiWebsite {
url: string;
type: {
$type: LiTypeStr;
category: string;
};
$type: LiTypeStr;
}
type TocValModifier = (tocVal: string | string[]) => string | string[];
interface InternalDb {
tableOfContents: LiResponse['data'];
entitiesByUrn: {
[k: string]: LiEntity & { key: LiUrn };
};
entities: Array<LiEntity & { key: LiUrn }>;
// Methods
getElementKeys: () => string[];
getElements: () => Array<LiEntity & { key: LiUrn }>;
getValueByKey: (key: string | string[]) => LiEntity | undefined;
getValuesByKey: (key: LiUrn | LiUrn[], optTocValModifier?: TocValModifier) => LiEntity[];
getElementsByType: (typeStr: string | string[]) => LiEntity[];
getElementByUrn: (urn: string) => LiEntity | undefined;
/**
* Get multiple elements by URNs
* - Allows passing a single URN, for convenience if unsure if you have an array
*/
getElementsByUrns: (urns: string[] | string) => LiEntity[];
}
interface LiProfileContactInfoResponse extends LiResponse {
data: LiResponse['data'] &
Partial<LiEntity> & {
$type: 'com.linkedin.voyager.identity.profile.ProfileContactInfo';
address: string;
birthDateOn: LiDate;
birthdayVisibilitySetting: any;
connectedAt: null | number;
emailAddress: null | string;
ims: any;
interests: any;
phoneNumbers: null | LiPhoneNum[];
primaryTwitterHandle: null | string;
twitterHandles: any[];
weChatContactInfo: any;
websites: null | LiWebsite[];
};
}
/**
* LI2JR Types
*/
type CaptureResult = 'success' | 'fail' | 'incomplete' | 'empty';
interface ParseProfileSchemaResultSummary {
liResponse: LiResponse;
profileInfoObj?: LiEntity;
profileSrc: 'profileView' | 'dashFullProfileWithEntities';
pageUrl: string;
localeStr?: string;
parseSuccess: boolean;
sections: {
basics: CaptureResult;
languages: CaptureResult;
attachments: CaptureResult;
education: CaptureResult;
work: CaptureResult;
volunteer: CaptureResult;
certificates: CaptureResult;
skills: CaptureResult;
projects: CaptureResult;
awards: CaptureResult;
publications: CaptureResult;
};
}
type SchemaVersion = 'legacy' | 'stable' | 'beta';
type ResumeSchemaLegacy = _ResumeSchemaLegacy;
type ResumeSchemaStable = _ResumeSchemaStable;
type ResumeSchemaBeyondSpec = _ResumeSchemaBeyondSpec;
}