This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
forked from smj-edison/ka-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
1174 lines (1174 loc) · 50.9 KB
/
index.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module "queries/loginQuery" {
export = LOGIN_QUERY;
const LOGIN_QUERY: "mutation loginWithPasswordMutation($identifier: String!, $password: String!) {\n loginWithPassword(identifier: $identifier, password: $password) {\n user {\n id\n kaid\n canAccessDistrictsHomepage\n isTeacher\n hasUnresolvedInvitations\n transferAuthToken\n preferredKaLocale {\n id\n kaLocale\n status\n __typename\n }\n __typename\n }\n isFirstLogin\n error {\n code\n __typename\n }\n __typename\n }\n}\n";
}
declare module "cookies/cookies" {
/**
* Takes in an array of raw cookie headers, and puts them back together into a form sent in requests
*
* Example input: ['cookie1=value1; expires=Wed, 31 Dec 1969 16:00:00 GMT; path=/;',
* 'cookie2=value2; expires=Wed, 31 Dec 1969 16:00:00 GMT; path=/;']
* Example output: cookie1=value1; cookie2=value2
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @returns {string} - Cookie string sent to server
*/
export function cookiesToCookieString(rawCookies: any): string;
/**
* Returns a cookie's value given a list of cookies in the form ["cookie1=value1", "cookie2=value2"]
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} cookieName
*
* @returns {string} - The cookie value requested
*/
export function getCookieValue(cookies: Array<string>, cookieName: string): string;
/**
* Splits a cookie in the form of "cookie=value" into ["cookie", "value"]
*
* @param {string} cookie - a cookie in the form of "cookie=value"
*
* @returns {Array[string, string]} - cookie key and value
*/
export function cookieToKeyValue(cookie: string): any;
/**
* Given a list of two cookie arrays, will override any old cookies with the new cookies,
* and otherwise add them together
*
* @param {Array<string>} oldCookies - old cookies (overridden by any new cookies)
* @param {Array<string>} newCookies - new cookies (to override old cookies)
*/
export function mergeCookies(oldCookies: Array<string>, newCookies: Array<string>): string[];
/**
* Given a list of cookies, will generate the header necessary for an axios request with cookies
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
*/
export function genAxiosCookieHeader(cookies: Array<string>): {
headers: {
Cookie: string;
};
};
}
declare module "auth/session" {
/**
* Load khanacademy.org and return a list of all the cookies
*
* @returns {Array<string>} A list of cookies
**/
export function getSessionCookies(): Array<string>;
}
declare module "auth/generateFKey" {
export = generateFKey;
/**
* Generates a FKey for a khan session
*
* @returns {string} FKey
*/
function generateFKey(): string;
}
declare module "auth/getAuthenticatedHeader" {
export = getAuthenticatedHeader;
/**
* Returns an axios header with all the proper authentication
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)} cookies
* @param {object} customHeaders
*/
function getAuthenticatedHeader(cookies: Array<string>, customHeaders?: object): {
headers: any;
};
}
declare module "auth/login" {
/**
* Logs into Khan Academy given a username and password, and returns the session cookies
*
* @param {string} username
* @param {string} password
*
* @returns session cookies
*/
export function login(username: string, password: string): Promise<string[]>;
}
declare module "request/authenticatedRequest" {
/**
* Make a GET request with the proper authentication on Khan Academy
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} url The url on Khan Academy to make the GET request
* @param {object} customHeaders Object of custom headers
*
* @returns {Promise} A promise that resolves to the response
*/
export function makeAuthenticatedGetRequest(cookies: Array<string>, url: string, customHeaders?: object): Promise<any>;
/**
* Make a POST request with the proper authentication on Khan Academy
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} url The url on Khan Academy to make the POST request
* @param {object} body The JSON body of the POST request
* @param {object} customHeaders Object of custom headers
*
* @returns {Promise} A promise that resolves to the response
*/
export function makeAuthenticatedPostRequest(cookies: Array<string>, url: string, body: object, customHeaders?: object): Promise<any>;
/**
* Make a PUT request with the proper authentication on Khan Academy
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} url The url on Khan Academy to make the PUT request
* @param {object} body The JSON body of the PUT request
* @param {object} customHeaders Object of custom headers
*
* @returns {Promise} A promise that resolves to the response
*
*/
export function makeAuthenticatedPutRequest(cookies: Array<string>, url: string, body: object, customHeaders?: object): Promise<any>;
/**
* Make a DELETE request with the proper authentication on Khan Academy
*
* @param {Object} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} url The resource to delete
* @param {object} customHeaders Object of custom headers
*
* @returns {Promise} A promise that resolves to the response
*
*/
export function makeAuthenticatedDeleteRequest(cookies: any, url: string, customHeaders?: object): Promise<any>;
}
declare module "queries/feedbackQuery" {
export = FEEDBACK_QUERY;
const FEEDBACK_QUERY: "query feedbackQuery($topicId: String!, $focusKind: String!, $cursor: String, $limit: Int, $feedbackType: FeedbackType!, $currentSort: Int) {\n feedback(focusId: $topicId, cursor: $cursor, limit: $limit, feedbackType: $feedbackType, focusKind: $focusKind, sort: $currentSort) {\n feedback {\n replyCount\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n badges {\n name\n icons {\n smallUrl\n __typename\n }\n description\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n focus {\n kind\n id\n translatedTitle\n relativeUrl\n __typename\n }\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n ... on QuestionFeedback {\n hasAnswered\n answers {\n replyCount\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n badges {\n name\n icons {\n smallUrl\n __typename\n }\n description\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n focus {\n kind\n id\n translatedTitle\n relativeUrl\n __typename\n }\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n __typename\n }\n isOld\n __typename\n }\n ... on AnswerFeedback {\n question {\n replyCount\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n badges {\n name\n icons {\n smallUrl\n __typename\n }\n description\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n focus {\n kind\n id\n translatedTitle\n relativeUrl\n __typename\n }\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n __typename\n }\n __typename\n }\n __typename\n }\n cursor\n isComplete\n sortedByDate\n __typename\n }\n}\n";
}
declare module "discussion/feedbackQuery" {
export = feedbackQuery;
/**
*
* @param {Array<string>|null} cookies
* @param {number|string} id The ID of the program
* @param {"QUESTION"|"COMMENT"|"PROJECT_HELP_QUESTION"} [type="COMMENT"] Whether to get comments or questions
* @param {1|2} [sort=1] Sort by 1: Top Voted, 2: Most Recent
* @param {number} [limit=10] The maximum number of comments to return
* @param {string} [cursor] The cursor to start from
* @returns {Promise<FeedbackQuery>}
*/
function feedbackQuery(cookies: Array<string> | null, id: number | string, type?: "QUESTION" | "COMMENT" | "PROJECT_HELP_QUESTION", sort?: 1 | 2, limit?: number, cursor?: string): Promise<FeedbackQuery>;
namespace feedbackQuery {
export { FeedbackQuery, FeedbackQueryFeedback, FeedbackQueryFeedbackFeedback, FeedbackQueryFeedbackFeedbackAuthor, FeedbackQueryError };
}
type FeedbackQuery = {
data: {
feedback: FeedbackQueryFeedback | null;
errors: FeedbackQueryError[] | undefined;
};
};
type FeedbackQueryFeedback = {
__typename: "FeedbackForFocus";
cursor: string;
feedback: FeedbackQueryFeedbackFeedback[];
isComplete: boolean;
sortedByDate: boolean;
};
type FeedbackQueryFeedbackFeedback = {
__typename: "BasicFeedback";
appearsAsDeleted: unknown | null;
author: FeedbackQueryFeedbackFeedbackAuthor | null;
badges: unknown[];
content: string;
date: string;
definitelyNotSpam: boolean;
deleted: unknown | null;
downVoted: boolean;
expandKey: string;
feedbackType: string;
flaggedBy: unknown[];
flaggedByUser: boolean;
flags: unknown[];
focus: {
__typename: "FeedbackFocus";
id: string;
kind: string;
relativeUrl: string;
translatedTitle: string | null;
};
focusUrl: string;
fromVideoAuthor: boolean;
key: string;
lowQualityScore: unknown | null;
notifyOnAnswer: boolean;
permalink: string;
qualityKind: string;
replyCount: number;
replyExpandKeys: unknown | null;
showLowQualityNotice: unknown | null;
sumVotesIncremented: number;
upVoted: boolean;
};
type FeedbackQueryFeedbackFeedbackAuthor = {
__typename: "User";
avatar: {
__typename: "Avatar";
imageSrc: string;
name: string;
};
id: string;
kaid: string;
nickname: string;
};
type FeedbackQueryError = {
extensions: {
code: string;
serviceName: string;
};
message: string;
};
}
declare module "discussion/commentsOnComment" {
/**
* Returns a list of all the sub comments on a comment
*
* @param {string} commentExpandKey - The expand key of the comment
*
* @returns Promise<object> The api response for all the sub comments
*/
export function getCommentsOnComment(commentExpandKey: string): Promise<any>;
/**
* Post a comment on someone else's comment
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} commentExpandKey - The comments' expandKey property
* @param {string} text The text to post
*/
export function commentOnComment(cookies: Array<string>, commentExpandKey: string, text: string): Promise<void>;
}
declare module "discussion/commentsOnProgram" {
/**
* Returns all the comments of type `commentType` on the program
*
* @param {string} programId
* @param {"comments"|"questions"} commentType - Whether to get comments or questions
*
* @returns {object} All the comments on a program
*/
export function getProgramComments(programId: string, commentType?: "comments" | "questions"): object;
/**
* Returns the details of a comment on a program
*
* @param {string} programId - The ID of the program
* @param {string} commentExpandKey - The comment expand key (found in the response of @see getProgramComments)
* @param {"comments"|"questions"} commentType - Whether getting a comment or a question
*
* @returns {object} The comment
*/
export function getProgramCommentDetails(programId: string, commentExpandKey: string, commentType?: "comments" | "questions"): object;
/**
* Adds a comment on the program
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} programId - The ID of the program
* @param {string} text - The content of the comment
* @param {"comments"|"questions"} commentType - Whether adding a comment or a question
*
* @returns {object} The comment
*/
export function commentOnProgram(cookies: Array<string>, programId: string, text: string, commentType?: "comments" | "questions"): object;
/**
* Deletes a comment on a program
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} commentKaencrypted - The kaencrypted id of the comment
*/
export function deleteProgramComment(cookies: Array<string>, commentKaencrypted: string): Promise<any>;
}
declare module "notifications/commentNotifications" {
/**
* Given a comment notification this will return that notification's comment details as well as the thread it's in
*
* @param {object} notificationJson - The raw json from the @see getNotificationsRequest result
* @param {Array<object>} [prerequestedComments] - If the posts request was already made,
* don't make it again by providing the existing request
*
* @returns {object} - A object containing the requested post and the thread it was in
*/
export function getNotificationCommentDetails(notificationJson: object, prerequestedComments?: Array<object>): object;
}
declare module "notifications/notifications" {
/**
* Get the most recent notifications from KA
*
* @param {Array<string>} cookies A list of cookies returned from the server (set-cookie header)
* @param {string} [cursor] The cursor returned from previous getNotificationsRequest calls
*/
export function getNotificationsRequest(cookies: Array<string>, cursor?: string): Promise<any>;
/**
* Will go through the notifications of the profile until checkFunction returns false
*
* @param {Array<string>} cookies - A list of cookies returned from the server (set-cookie header)
* @param {Function} checkFunction - A function that when returns false, it will stop the notification process
* @param {number} [maxDepth=10] - The maximum depth in the notifications the code will request
*/
export function getNotificationsUntil(cookies: Array<string>, checkFunction: Function, maxDepth?: number): Promise<any[]>;
/**
* Will go through the notifications of the profile until a notification isn't brand new
*
* @param {Array<string>} cookies - A list of cookies returned from the server (set-cookie header)
* @param {number} [maxDepth=10] - The maximum depth in the notifications the code will request
*/
export function getAllBrandNewNotifications(cookies: Array<string>, maxDepth?: number): Promise<any[]>;
/**
* Clears all brand new notifications so they aren't performed on twice
*
* @param {Array<string>} cookies - A list of cookies returned from the server (set-cookie header)
*/
export function clearBrandNewNotifications(cookies: Array<string>): Promise<any>;
}
declare module "queries/getFullUserProfileQuery" {
export = GET_FULL_USER_PROFILE_QUERY;
const GET_FULL_USER_PROFILE_QUERY: "query getFullUserProfile($kaid: String, $username: String) {\n user(kaid: $kaid, username: $username) {\n id\n kaid\n key\n userId\n email\n username\n profileRoot\n gaUserId\n qualarooId\n isPhantom\n isDeveloper: hasPermission(name: \"can_do_what_only_admins_can_do\")\n isCurator: hasPermission(name: \"can_curate_tags\", scope: ANY_ON_CURRENT_LOCALE)\n isCreator: hasPermission(name: \"has_creator_role\", scope: ANY_ON_CURRENT_LOCALE)\n isPublisher: hasPermission(name: \"can_publish\", scope: ANY_ON_CURRENT_LOCALE)\n isModerator: hasPermission(name: \"can_moderate_users\", scope: GLOBAL)\n isParent\n isSatStudent\n isTeacher\n isDataCollectible\n isChild\n isOrphan\n isCoachingLoggedInUser\n canModifyCoaches\n nickname\n hideVisual\n joined\n points\n countVideosCompleted\n bio\n profile {\n accessLevel\n __typename\n }\n soundOn\n muteVideos\n showCaptions\n prefersReducedMotion\n noColorInVideos\n autocontinueOn\n newNotificationCount\n canHellban: hasPermission(name: \"can_ban_users\", scope: GLOBAL)\n canMessageUsers: hasPermission(name: \"can_send_moderator_messages\", scope: GLOBAL)\n isSelf: isActor\n hasStudents: hasCoachees\n hasClasses\n hasChildren\n hasCoach\n badgeCounts\n homepageUrl\n isMidsignupPhantom\n includesDistrictOwnedData\n canAccessDistrictsHomepage\n preferredKaLocale {\n id\n kaLocale\n status\n __typename\n }\n underAgeGate {\n parentEmail\n daysUntilCutoff\n approvalGivenAt\n __typename\n }\n authEmails\n signupDataIfUnverified {\n email\n emailBounced\n __typename\n }\n pendingEmailVerifications {\n email\n __typename\n }\n tosAccepted\n shouldShowAgeCheck\n __typename\n }\n actorIsImpersonatingUser\n}\n";
}
declare module "profile/getProfileInfo" {
export = getProfileInfo;
/**
* Get a user's profile information given their username or KAID
*
* @param {Array<string>|null} cookies - A list of cookies returned from the server (set-cookie header)
* @param {string} user - The requested user's username or KAID
*
* @returns {Promise<GetFullUserProfile>} - The user's profile information
*/
function getProfileInfo(cookies: Array<string> | null, user: string): Promise<GetFullUserProfile>;
namespace getProfileInfo {
export { GetFullUserProfile, GetFullUserProfileUser };
}
type GetFullUserProfile = {
data: {
actorIsImpersonatingUser: boolean;
user: GetFullUserProfileUser | null;
};
};
type GetFullUserProfileUser = {
__typename: "User";
authEmails: string | null;
autocontinueOn: boolean | null;
badgeCounts: string | null;
bio: string;
canAccessDistrictsHomepage: boolean;
canHellban: boolean | null;
canMessageUsers: boolean | null;
canModifyCoaches: boolean | null;
countVideosCompleted: number;
email: string | null;
gaUserId: string | null;
hasChildren: boolean | null;
hasClasses: boolean | null;
hasCoach: boolean | null;
hasStudents: boolean | null;
hideVisual: boolean | null;
homepageUrl: string | null;
id: string;
includesDistrictOwnedData: boolean;
isChild: boolean | null;
isCoachingLoggedInUser: boolean;
isCreator: boolean | null;
isCurator: boolean | null;
isDataCollectible: boolean | null;
isDeveloper: boolean | null;
isMidsignupPhantom: boolean;
isModerator: boolean | null;
isOrphan: boolean | null;
isParent: boolean | null;
isPhantom: boolean;
isPublisher: boolean | null;
isSatStudent: boolean | null;
isSelf: boolean;
isTeacher: boolean | null;
joined: string | null;
kaid: string;
key: string | null;
muteVideos: boolean | null;
newNotificationCount: number | null;
nickname: string;
noColorInVideos: boolean | null;
pendingEmailVerifications: unknown[] | null;
points: number;
preferredKaLocale: unknown | null;
prefersReducedMotion: boolean | null;
profile: {
__typename: "Profile";
accessLevel: string;
};
profileRoot: string;
qualarooId: string | null;
shouldShowAgeCheck: boolean | null;
showCaptions: boolean | null;
signupDataIfUnverified: unknown | null;
soundOn: boolean | null;
tosAccepted: boolean | null;
underAgeGate: unknown | null;
userId: string | null;
username: string | null;
};
}
declare module "queries/getProfileWidgets" {
export = GET_PROFILE_WIDGETS_QUERY;
const GET_PROFILE_WIDGETS_QUERY: "query getProfileWidgets($kaid: String!) {\n user(kaid: $kaid) {\n id\n kaid\n badgeCounts\n isChild\n profile {\n programs {\n authorKaid\n authorNickname\n deleted\n displayableSpinoffCount\n imagePath\n key\n sumVotesIncremented\n translatedTitle\n url\n __typename\n }\n __typename\n }\n programsDeprecated(limit: 2) {\n authorKaid\n authorNickname\n displayableSpinoffCount\n imagePath\n key\n sumVotesIncremented\n translatedTitle\n url\n __typename\n }\n __typename\n }\n userSummary(kaid: $kaid) {\n statistics {\n answers\n comments\n flags\n projectanswers\n projectquestions\n questions\n replies\n votes\n __typename\n }\n __typename\n }\n}\n";
}
declare module "profile/getProfileWidgets" {
export = getProfileWidgets;
/**
* Get a user's profile information given their KAID
*
* @param {Array<string>|null} cookies - A list of cookies returned from the server (set-cookie header)
* @param {string} kaid - The requested user's KAID
*
* @returns {Promise<GetProfileWidgets>} - The user's profile information
*/
function getProfileWidgets(cookies: Array<string> | null, kaid: string): Promise<GetProfileWidgets>;
namespace getProfileWidgets {
export { GetProfileWidgets, GetProfileWidgetsData, GetProfileWidgetsUser, GetProfileWidgetsUserSummary, GetFullUserProfileProgram, GetFullUserProfileProgramDeprecated, getProfileWidgetsErrors, getProfileWidgetsErrorsMessage, getProfileWidgetsErrorsMessageExtensions };
}
type GetProfileWidgets = {
data: GetProfileWidgetsData | undefined;
errors: getProfileWidgetsErrors | undefined;
};
type GetProfileWidgetsData = {
user: GetProfileWidgetsUser | null;
userSummary: GetProfileWidgetsUserSummary | null;
};
type GetProfileWidgetsUser = {
__typename: "User";
badgeCounts: string | null;
id: string;
isChild: unknown | null;
kaid: string;
profile: {
__typename: "Profile";
programs: Array<GetFullUserProfileProgram>;
};
programsDeprecated: Array<GetFullUserProfileProgramDeprecated>;
};
type GetProfileWidgetsUserSummary = {
__typename: "UserSummary";
statistics: {
__typename: "UserStatistics";
answers: number;
comments: number;
flags: 0;
projectanswers: number;
projectquestions: number;
questions: number;
replies: number;
votes: number;
};
};
type GetFullUserProfileProgram = {
__typename: "Program";
authorKaid: string | null;
authorNickname: string | null;
deleted: unknown | null;
displayableSpinoffCount: number;
imagePath: string;
key: string;
sumVotesIncremented: number;
translatedTitle: string | null;
url: string;
};
type GetFullUserProfileProgramDeprecated = {
__typename: "Program";
authorKaid: string | null;
authorNickname: string | null;
displayableSpinoffCount: number;
imagePath: string;
key: string;
sumVotesIncremented: number;
translatedTitle: string | null;
url: string;
};
type getProfileWidgetsErrors = Array<getProfileWidgetsErrorsMessage>;
type getProfileWidgetsErrorsMessage = {
message: string;
extensions: string | undefined;
};
type getProfileWidgetsErrorsMessageExtensions = {
code: string;
serviceName: string;
};
}
declare module "queries/avatarDataForProfile" {
export = AVATAR_DATA_FOR_PROFILE_QUERY;
const AVATAR_DATA_FOR_PROFILE_QUERY: "query avatarDataForProfile($kaid: String!) {\n user(kaid: $kaid) {\n id\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n}\n";
}
declare module "profile/avatarDataForProfile" {
export = avatarDataForProfile;
/**
* Get a user's avatar information given their KAID
*
* @param {Array<string>|null} cookies - A list of cookies returned from the server (set-cookie header)
* @param {string} kaid - The requested user's KAID
*
* @returns {Promise<AvatarDataForProfile>} - The user's avatar information
*/
function avatarDataForProfile(cookies: Array<string> | null, kaid: string): Promise<AvatarDataForProfile>;
namespace avatarDataForProfile {
export { AvatarDataForProfile, AvatarDataForProfileUser };
}
type AvatarDataForProfile = {
data: {
user: AvatarDataForProfileUser | null;
};
};
type AvatarDataForProfileUser = {
__typename: "User";
avatar: {
__typename: "Avatar";
imageSrc: string;
name: string;
};
id: string;
/**
* *
*/
kaid: string;
};
}
declare module "programs/sortingType" {
export = SORTING_TYPE;
const SORTING_TYPE: Readonly<{
MOST_VOTES: "MOST_VOTES";
NEWEST: "NEWEST";
}>;
}
declare module "profile/getUserPrograms" {
export type GetUserPrograms = {
cursor: string | undefined;
scratchpads: Array<GetUserProgramsScratchpad>;
complete: boolean;
};
export type GetUserProgramsScratchpad = {
thumb: string;
created: string;
authorKaid: string;
title: string | null;
sumVotesIncremented: number;
flaggedByUser: boolean;
url: string;
key: string;
authorNickname: string;
spinoffCount: number;
translatedTitle: string | null;
};
/**
*
* @param {string} user The user's KAID or username
* @param {SORTING_TYPE} [sortingType=1] The sorting type (default is most votes)
* @param {number} [limit=1e4] The maximum number of programs to retrieve
*
* @returns {Promise<GetUserPrograms>} The JSON
*/
export function getUserPrograms(user: string, sortingType?: Readonly<{
MOST_VOTES: "MOST_VOTES";
NEWEST: "NEWEST";
}>, limit?: number): Promise<GetUserPrograms>;
/**
* Get programs as a logged in user (useful for detecting shadowbanning)
*
* @param {object} cookies The cookies
* @param {string} kaid The user's KAID
* @param {SORTING_TYPE} sortingType The sorting type
* @param {number} limit The maximum number of programs to retrieve
* @returns {Promise<object>} The JSON
*/
export function getUserProgramsAuthenticated(cookies: object, kaid: string, sortingType: Readonly<{
MOST_VOTES: "MOST_VOTES";
NEWEST: "NEWEST";
}>, limit: number): Promise<object>;
}
declare module "programs/defaultProgramJson" {
export const contentKindCode: string;
export const newUrlPath: string;
export const hideFromHotlist: boolean;
export const relativeUrl: string;
export const originScratchpadId: any;
export const forkedFromTopic: string;
export const projectEval: any;
export const height: number;
export const canvasOnly: boolean;
export const originSimilarity: number;
export const id: number;
export const definitelyNotSpam: boolean;
export const editSlug: string;
export const category: any;
export const originRevisionId: any;
export const title: string;
export const translatedProjectEval: any;
export const sendToPeers: boolean;
export const slug: string;
export const isChallenge: boolean;
export const width: number;
export const projectEvalTips: any;
export const youtubeId: any;
export const docsUrlPath: string;
export const contentKind: string;
export const type: string;
export namespace revision {
export const tests: any;
export const code: string;
export const folds: any[];
export const translatedMp3Url: any;
export const mp3Url: any;
export const editorType: string;
export const playback: any;
const youtubeId_1: any;
export { youtubeId_1 as youtubeId };
export const configVersion: number;
export const editor_type: string;
export const image_url: string;
export const config_version: number;
export const topic_slug: string;
}
const tests_1: string;
export { tests_1 as tests };
export const imagePath: string;
export const nodeType: string;
export const description: string;
export const isProject: boolean;
export const tags: any[];
export const translatedDescription: string;
export const byChild: boolean;
export const difficulty: any;
export const originIsProject: boolean;
export const key: string;
export const date: string;
export const nodeSlug: string;
export const spinoffCount: number;
export const kind: string;
export namespace termMap {
const _new: string;
export { _new as new };
export const restart: string;
}
export const created: string;
export const url: string;
export const imageUrl: string;
export const isPublished: boolean;
export const sumVotesIncremented: number;
export const defaultUrlPath: any;
export const flags: any[];
export const isProjectOrFork: boolean;
export const translatedProjectEvalTips: any;
export const userAuthoredContentType: string;
export const kaid: string;
export const translatedTitle: string;
export namespace trustedRevision {
const created_1: string;
export { created_1 as created };
}
}
declare module "programs/getQueryTime" {
export = getQueryTime;
/**
* A helper function that returns the current time formatted for KA's servers
*/
function getQueryTime(): string;
}
declare module "moderation/check-string" {
export = checkString;
function checkString(str: any): boolean;
}
declare module "config" {
export const filterBadwords: boolean;
}
declare module "programs/programs" {
export type GetProgramJSON = {
contentKindCode: string;
newUrlPath: string;
key: string;
relativeUrl: string;
originScratchpadId: number | null;
forkedFromTopic: string;
height: number;
date: string;
originSimilarity: number;
id: number;
description: string;
category: unknown | null;
originRevisionId: number | null;
title: string;
translatedProjectEval: unknown | null;
sendToPeers: boolean;
slug: string;
isChallenge: boolean;
width: number;
youtubeId: unknown | null;
docsUrlPath: string;
contentKind: string;
type: string;
revision: {
tests: unknown | null;
code: string;
created: string;
folds: [number, number][];
translatedMp3Url: unknown | null;
hasAudio: boolean;
mp3Url: unknown | null;
editorType: string;
playback: string;
youtubeId: unknown | null;
configVersion: number;
id: number;
};
imagePath: string;
nodeType: string;
editSlug: string;
isProject: boolean;
tags: unknown[];
translatedDescription: string;
byChild: boolean;
difficulty: unknown | null;
originIsProject: boolean;
hideFromHotlist: boolean;
canvasOnly: boolean;
nodeSlug: string;
spinoffCount: number;
kind: string;
created: string;
url: string;
imageUrl: string;
isPublished: boolean;
sumVotesIncremented: number;
defaultUrlPath: unknown | null;
flags: unknown[];
isProjectOrFork: boolean;
translatedProjectEvalTips: unknown | null;
userAuthoredContentType: string;
kaid: string;
translatedTitle: string;
};
export type ShowScratchpad = {
scratchpad: {
contentKindCode: string;
newUrlPath: string;
key: string;
relativeUrl: string;
originScratchpadId: number | null;
forkedFromTopic: string;
height: number;
date: string;
originSimilarity: number;
id: number;
editSlug: string;
category: unknown | null;
originRevisionId: number | null;
title: string | null;
translatedProjectEval: unknown | null;
sendToPeers: boolean;
nodeSlug: string;
isChallenge: boolean;
width: number;
youtubeId: unknown | null;
docsUrlPath: string;
contentKind: string;
type: string;
revision: {
tests: unknown | null;
code: string;
created: string;
folds: [number, number][];
translatedMp3Url: unknown | null;
hasAudio: boolean;
mp3Url: unknown | null;
editorType: string;
playback: unknown | null;
youtubeId: unknown | null;
configVersion: number;
id: number;
};
imagePath: string;
nodeType: string;
description: string;
isProject: boolean;
tags: unknown[];
translatedDescription: string;
byChild: boolean;
difficulty: unknown | null;
originIsProject: boolean;
hideFromHotlist: boolean;
canvasOnly: boolean;
slug: string;
spinoffCount: number;
kind: string;
created: string;
url: string;
imageUrl: string;
isPublished: boolean;
sumVotesIncremented: number;
defaultUrlPath: unknown | null;
flags: unknown[];
isProjectOrFork: boolean;
translatedProjectEvalTips: unknown | null;
userAuthoredContentType: string;
kaid: string;
translatedTitle: string | null;
};
embedded: boolean;
creatorProfile: {
isSelf: boolean;
countVideosCompleted: number;
isChildAccount: boolean;
hasChangedAvatar: boolean;
soundOn: boolean;
affiliation: unknown | null;
autocontinueOn: boolean;
backgroundSrc: string;
noColorInVideos: boolean;
hideVisual: boolean;
muteVideos: unknown | null;
isDataCollectible: boolean;
avatarName: string;
globalPermissions: any;
affiliation_country_code: unknown | null;
profileRoot: string;
email: string;
username: string;
bio: string;
backgroundName: string;
isOrphan: boolean;
isPublic: boolean;
background: {
translatedDisplayName: string;
imagePath: string;
displayName: string;
name: string;
thumbSrc: string;
translatedRequirements: any;
rewardType: string;
thumbnailSrc: string;
imageSrc: string;
thumbnailPath: string;
thumbPath: string;
};
isPhantom: boolean;
isMidsignupPhantom: boolean;
nickname: string;
kaid: string;
prefersReducedMotion: boolean;
dateJoined: unknown | null;
avatarSrc: string;
userLocation: unknown | null;
points: number;
avatar: {
translatedDisplayName: string;
imagePath: string;
displayName: string;
name: string;
partType: string;
forModel: string;
translatedRequirements: any;
rewardType: string;
thumbnailSrc: string;
imageSrc: string;
thumbnailPath: string;
};
includesUserDataInfo: boolean;
publicBadges: any;
};
discussion: {
showProjectFeedback: boolean;
focusId: string;
isOwner: boolean;
restrictPosting: boolean;
focusKind: string;
canEdit: boolean;
};
upVoted: boolean;
originScratchpad: ShowScratchpadOriginScratchpad | null;
topic: {
curriculumKey: unknown | null;
relativeUrl: string;
userAuthoredContentTypesInfo: {
new: string;
type: string;
};
extendedSlug: string;
currentRevisionKey: string;
renderType: string;
topicPageUrl: string;
alternateSlugs: string[];
hasPeerReviewedProjects: boolean;
id: string;
domainSlug: string;
backgroundImageCaption: string;
userAuthoredContentTypes: string[];
creationDate: string;
hide: boolean;
title: string;
webUrl: string;
nodeSlug: string;
deletedModTime: string;
endorsement: unknown | null;
iconSrc: string;
contentKind: string;
standaloneTitle: string;
translatedStandaloneTitle: string;
twitterUrl: string;
brandingImageUrl: string;
description: string;
tags: any;
deleted: boolean;
hasUserAuthoredContentTypes: boolean;
translatedDescription: string;
inKnowledgeMap: boolean;
gplusUrl: string;
doNotPublish: boolean;
backgroundImageUrl: string;
childData: {
kind: string;
id: string;
};
slug: string;
kind: string;
listedLocales: string[];
contentId: string;
logoImageUrl: string;
kaUrl: string;
sha: string;
facebookUrl: string;
curation: {
blacklist: string[];
modules: {
kind: string;
actions: {
url: string;
text: string;
content_descriptor: string;
};
title: string;
call_to_action: string;
link: string;
description: string;
};
};
translatedTitle: string;
};
flaggedByUser: boolean;
downVoted: boolean;
userScratchpad: {
kind: string;
msWatched: number;
isProject: boolean;
msDuration: unknown | null;
lastMsWatched: number;
challengeStatus: number;
scratchpadKey: string;
fullyWatched: boolean;
isComplete: boolean;
isChallenge: boolean;
difficulty: unknown | null;
points: number;
stashedCode: string;
lastUpdated: string;
key: string;
userKey: string;
id: string;
viewed: boolean;
};
};
export type ShowScratchpadOriginScratchpad = {
category: unknown | null;
imageUrl: string;
url: string;
translatedProjectEval: unknown | null;
sendToPeers: boolean;
translatedDescription: string;
slug: string;
deleted: boolean;
translatedProjectEvalTips: unknown | null;
revision: {
id: number;
};
id: number;
translatedTitle: string | null;
};
/**
* Returns the program info, given the program's ID
*
* @param {number|string} id The program's ID
* @param {Record<string,1,true,Record<string,1,true>>} [projection] The projection to use
*
* @return {Promise<GetProgramJSON>}
*/
export function getProgramJSON(id: number | string, projection?: any): Promise<GetProgramJSON>;
/**