lemmy-js-client 1.0.0-error-status-code.0 → 1.0.0-errors-array.2

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 (43) hide show
  1. package/dist/http.d.ts +1 -2
  2. package/dist/http.js +3 -5
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +3 -0
  5. package/dist/types/AdminAllowInstance.d.ts +1 -1
  6. package/dist/types/AdminAllowInstanceParams.d.ts +1 -1
  7. package/dist/types/AdminBan.d.ts +1 -1
  8. package/dist/types/AdminBlockInstance.d.ts +1 -1
  9. package/dist/types/AdminBlockInstanceParams.d.ts +1 -1
  10. package/dist/types/AdminPurgeComment.d.ts +1 -1
  11. package/dist/types/AdminPurgeCommunity.d.ts +1 -1
  12. package/dist/types/AdminPurgePerson.d.ts +1 -1
  13. package/dist/types/AdminPurgePost.d.ts +1 -1
  14. package/dist/types/AdminRemoveCommunity.d.ts +1 -1
  15. package/dist/types/AllLemmyErrors.d.ts +1 -0
  16. package/dist/types/AllLemmyErrors.js +119 -0
  17. package/dist/types/BanFromCommunity.d.ts +1 -1
  18. package/dist/types/BanPerson.d.ts +1 -1
  19. package/dist/types/CreateSite.d.ts +1 -0
  20. package/dist/types/EditSite.d.ts +4 -0
  21. package/dist/types/HideCommunity.d.ts +1 -1
  22. package/dist/types/LemmyErrorType.d.ts +0 -2
  23. package/dist/types/LocalSite.d.ts +4 -0
  24. package/dist/types/LocalUser.d.ts +9 -9
  25. package/dist/types/LockComment.d.ts +1 -4
  26. package/dist/types/LockPost.d.ts +1 -1
  27. package/dist/types/ModBanFromCommunity.d.ts +1 -1
  28. package/dist/types/ModLockComment.d.ts +5 -5
  29. package/dist/types/ModLockCommentView.d.ts +0 -2
  30. package/dist/types/ModLockPost.d.ts +1 -1
  31. package/dist/types/ModRemoveComment.d.ts +1 -1
  32. package/dist/types/ModRemovePost.d.ts +1 -1
  33. package/dist/types/Post.d.ts +0 -2
  34. package/dist/types/PostOrCommentOrPrivateMessage.d.ts +7 -7
  35. package/dist/types/PurgeComment.d.ts +1 -1
  36. package/dist/types/PurgeCommunity.d.ts +1 -1
  37. package/dist/types/PurgePerson.d.ts +1 -1
  38. package/dist/types/PurgePost.d.ts +1 -1
  39. package/dist/types/RemoveComment.d.ts +1 -1
  40. package/dist/types/RemoveCommunity.d.ts +1 -1
  41. package/dist/types/RemovePost.d.ts +1 -1
  42. package/dist/types/SaveUserSettings.d.ts +1 -1
  43. package/package.json +2 -2
package/dist/http.d.ts CHANGED
@@ -781,7 +781,6 @@ export declare class LemmyHttp extends Controller {
781
781
  * The msg is either an empty string, or extra non-translatable info.
782
782
  */
783
783
  export declare class LemmyError extends Error {
784
- status: number;
785
- constructor(name: string, status: number, msg?: string);
784
+ constructor(name: string, msg?: string);
786
785
  }
787
786
  export {};
package/dist/http.js CHANGED
@@ -1015,11 +1015,10 @@ _LemmyHttp_wrapper = async function _LemmyHttp_wrapper(type_, endpoint, form, op
1015
1015
  json = await response.json();
1016
1016
  }
1017
1017
  catch {
1018
- throw new LemmyError(response.statusText, response.status);
1018
+ throw new LemmyError(response.statusText);
1019
1019
  }
1020
1020
  if (!response.ok) {
1021
- console.error(`Request error while calling ${type_} ${endpoint} with ${form}`);
1022
- let err = new LemmyError(json.error ?? response.statusText, response.status, json.message);
1021
+ let err = new LemmyError(json.error ?? response.statusText, json.message);
1023
1022
  throw err;
1024
1023
  }
1025
1024
  else {
@@ -2114,10 +2113,9 @@ function createFormData(image) {
2114
2113
  * The msg is either an empty string, or extra non-translatable info.
2115
2114
  */
2116
2115
  class LemmyError extends Error {
2117
- constructor(name, status, msg) {
2116
+ constructor(name, msg) {
2118
2117
  super(msg ?? "");
2119
2118
  this.name = name;
2120
- this.status = status;
2121
2119
  // Set the prototype explicitly.
2122
2120
  Object.setPrototypeOf(this, LemmyError.prototype);
2123
2121
  }
package/dist/index.d.ts CHANGED
@@ -36,6 +36,7 @@ export { AdminPurgePostView } from "./types/AdminPurgePostView";
36
36
  export { AdminRemoveCommunity } from "./types/AdminRemoveCommunity";
37
37
  export { AdminRemoveCommunityId } from "./types/AdminRemoveCommunityId";
38
38
  export { AdminRemoveCommunityView } from "./types/AdminRemoveCommunityView";
39
+ export { AllLemmyErrors } from "./types/AllLemmyErrors";
39
40
  export { ApproveCommunityPendingFollower } from "./types/ApproveCommunityPendingFollower";
40
41
  export { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication";
41
42
  export { AuthenticateWithOauth } from "./types/AuthenticateWithOauth";
package/dist/index.js CHANGED
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.AllLemmyErrors = void 0;
17
18
  __exportStar(require("./http"), exports);
19
+ var AllLemmyErrors_1 = require("./types/AllLemmyErrors");
20
+ Object.defineProperty(exports, "AllLemmyErrors", { enumerable: true, get: function () { return AllLemmyErrors_1.AllLemmyErrors; } });
@@ -6,6 +6,6 @@ export type AdminAllowInstance = {
6
6
  instance_id: InstanceId;
7
7
  admin_person_id: PersonId;
8
8
  allowed: boolean;
9
- reason: string;
9
+ reason?: string;
10
10
  published_at: string;
11
11
  };
@@ -1,5 +1,5 @@
1
1
  export type AdminAllowInstanceParams = {
2
2
  instance: string;
3
3
  allow: boolean;
4
- reason: string;
4
+ reason?: string;
5
5
  };
@@ -8,7 +8,7 @@ export type AdminBan = {
8
8
  id: AdminBanId;
9
9
  mod_person_id: PersonId;
10
10
  other_person_id: PersonId;
11
- reason: string;
11
+ reason?: string;
12
12
  banned: boolean;
13
13
  expires_at?: string;
14
14
  published_at: string;
@@ -6,7 +6,7 @@ export type AdminBlockInstance = {
6
6
  instance_id: InstanceId;
7
7
  admin_person_id: PersonId;
8
8
  blocked: boolean;
9
- reason: string;
9
+ reason?: string;
10
10
  expires_at?: string;
11
11
  published_at: string;
12
12
  };
@@ -1,6 +1,6 @@
1
1
  export type AdminBlockInstanceParams = {
2
2
  instance: string;
3
3
  block: boolean;
4
- reason: string;
4
+ reason?: string;
5
5
  expires_at?: string;
6
6
  };
@@ -8,6 +8,6 @@ export type AdminPurgeComment = {
8
8
  id: AdminPurgeCommentId;
9
9
  admin_person_id: PersonId;
10
10
  post_id: PostId;
11
- reason: string;
11
+ reason?: string;
12
12
  published_at: string;
13
13
  };
@@ -6,6 +6,6 @@ import type { PersonId } from "./PersonId";
6
6
  export type AdminPurgeCommunity = {
7
7
  id: AdminPurgeCommunityId;
8
8
  admin_person_id: PersonId;
9
- reason: string;
9
+ reason?: string;
10
10
  published_at: string;
11
11
  };
@@ -6,6 +6,6 @@ import type { PersonId } from "./PersonId";
6
6
  export type AdminPurgePerson = {
7
7
  id: AdminPurgePersonId;
8
8
  admin_person_id: PersonId;
9
- reason: string;
9
+ reason?: string;
10
10
  published_at: string;
11
11
  };
@@ -8,6 +8,6 @@ export type AdminPurgePost = {
8
8
  id: AdminPurgePostId;
9
9
  admin_person_id: PersonId;
10
10
  community_id: CommunityId;
11
- reason: string;
11
+ reason?: string;
12
12
  published_at: string;
13
13
  };
@@ -8,7 +8,7 @@ export type AdminRemoveCommunity = {
8
8
  id: AdminRemoveCommunityId;
9
9
  mod_person_id: PersonId;
10
10
  community_id: CommunityId;
11
- reason: string;
11
+ reason?: string;
12
12
  removed: boolean;
13
13
  published_at: string;
14
14
  };
@@ -0,0 +1 @@
1
+ export declare let AllLemmyErrors: string[];
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AllLemmyErrors = void 0;
4
+ exports.AllLemmyErrors = [
5
+ "block_keyword_too_short",
6
+ "block_keyword_too_long",
7
+ "couldnt_update",
8
+ "couldnt_create",
9
+ "report_reason_required",
10
+ "report_too_long",
11
+ "not_a_moderator",
12
+ "not_an_admin",
13
+ "cant_block_yourself",
14
+ "cant_note_yourself",
15
+ "cant_block_admin",
16
+ "passwords_do_not_match",
17
+ "email_not_verified",
18
+ "email_required",
19
+ "cannot_leave_admin",
20
+ "cannot_leave_admin",
21
+ "cannot_leave_admin",
22
+ "image_url_missing_path_segments",
23
+ "image_url_missing_last_path_segment",
24
+ "pictrs_api_key_not_provided",
25
+ "no_content_type_header",
26
+ "not_an_image_type",
27
+ "invalid_image_upload",
28
+ "image_upload_disabled",
29
+ "not_a_mod_or_admin",
30
+ "not_top_mod",
31
+ "not_logged_in",
32
+ "not_higher_mod",
33
+ "not_higher_admin",
34
+ "site_ban",
35
+ "deleted",
36
+ "person_is_blocked",
37
+ "community_is_blocked",
38
+ "instance_is_blocked",
39
+ "instance_is_private",
40
+ "invalid_password",
41
+ "site_description_length_overflow",
42
+ "honeypot_failed",
43
+ "registration_application_is_pending",
44
+ "locked",
45
+ "max_comment_depth_reached",
46
+ "no_comment_edit_allowed",
47
+ "only_admins_can_create_communities",
48
+ "already_exists",
49
+ "language_not_allowed",
50
+ "no_post_edit_allowed",
51
+ "nsfw_not_allowed",
52
+ "edit_private_message_not_allowed",
53
+ "application_question_required",
54
+ "invalid_default_post_listing_type",
55
+ "registration_closed",
56
+ "registration_application_answer_required",
57
+ "registration_username_required",
58
+ "email_already_taken",
59
+ "username_already_taken",
60
+ "person_is_banned_from_community",
61
+ "no_id_given",
62
+ "incorrect_login",
63
+ "no_email_setup",
64
+ "local_site_not_setup",
65
+ "local_site_not_setup",
66
+ "invalid_name",
67
+ "invalid_code_verifier",
68
+ "invalid_display_name",
69
+ "invalid_matrix_id",
70
+ "invalid_post_title",
71
+ "invalid_body_field",
72
+ "bio_length_overflow",
73
+ "alt_text_length_overflow",
74
+ "couldnt_parse_totp_secret",
75
+ "couldnt_generate_totp",
76
+ "missing_totp_token",
77
+ "missing_totp_secret",
78
+ "incorrect_totp_token",
79
+ "totp_already_enabled",
80
+ "blocked_url",
81
+ "invalid_url",
82
+ "email_send_failed",
83
+ "slurs",
84
+ "slurs",
85
+ "site_name_required",
86
+ "site_name_length_overflow",
87
+ "permissive_regex",
88
+ "invalid_regex",
89
+ "captcha_incorrect",
90
+ "couldnt_create_audio_captcha",
91
+ "couldnt_create_image_captcha",
92
+ "invalid_url_scheme",
93
+ "couldnt_send_webmention",
94
+ "contradicting_filters",
95
+ "too_many_items",
96
+ "ban_expiration_in_past",
97
+ "invalid_unix_time",
98
+ "invalid_bot_action",
99
+ "tag_not_in_community",
100
+ "cant_block_local_instance",
101
+ "cant_block_local_instance",
102
+ "url_length_overflow",
103
+ "oauth_authorization_invalid",
104
+ "oauth_login_failed",
105
+ "oauth_registration_closed",
106
+ "not_found",
107
+ "community_has_no_followers",
108
+ "post_schedule_time_must_be_in_future",
109
+ "too_many_scheduled_posts",
110
+ "cannot_combine_federation_blocklist_and_allowlist",
111
+ "cannot_combine_federation_blocklist_and_allowlist",
112
+ "couldnt_parse_pagination_token",
113
+ "couldnt_parse_pagination_token",
114
+ "invalid_fetch_limit",
115
+ "email_notifications_disabled",
116
+ "multi_community_update_wrong_user",
117
+ "cannot_combine_community_id_and_multi_community_id",
118
+ "multi_community_entry_limit_reached",
119
+ ];
@@ -12,7 +12,7 @@ export type BanFromCommunity = {
12
12
  * If ban is true, then this means remove. If ban is false, it means restore.
13
13
  */
14
14
  remove_or_restore_data?: boolean;
15
- reason: string;
15
+ reason?: string;
16
16
  /**
17
17
  * A time that the ban will expire, in unix epoch seconds.
18
18
  *
@@ -10,7 +10,7 @@ export type BanPerson = {
10
10
  * If ban is true, then this means remove. If ban is false, it means restore.
11
11
  */
12
12
  remove_or_restore_data?: boolean;
13
- reason: string;
13
+ reason?: string;
14
14
  /**
15
15
  * A time that the ban will expire, in unix epoch seconds.
16
16
  *
@@ -27,6 +27,7 @@ export type CreateSite = {
27
27
  application_email_admins?: boolean;
28
28
  discussion_languages?: Array<LanguageId>;
29
29
  slur_filter_regex?: string;
30
+ actor_name_max_length?: number;
30
31
  rate_limit_message_max_requests?: number;
31
32
  rate_limit_message_interval_seconds?: number;
32
33
  rate_limit_post_max_requests?: number;
@@ -79,6 +79,10 @@ export type EditSite = {
79
79
  * A regex string of items to filter.
80
80
  */
81
81
  slur_filter_regex?: string;
82
+ /**
83
+ * The max length of actor names.
84
+ */
85
+ actor_name_max_length?: number;
82
86
  /**
83
87
  * The number of messages allowed in a given time frame.
84
88
  */
@@ -5,5 +5,5 @@ import type { CommunityId } from "./CommunityId";
5
5
  export type HideCommunity = {
6
6
  community_id: CommunityId;
7
7
  hidden: boolean;
8
- reason: string;
8
+ reason?: string;
9
9
  };
@@ -29,8 +29,6 @@ export type LemmyErrorType = {
29
29
  error: "email_required";
30
30
  } | {
31
31
  error: "cannot_leave_admin";
32
- } | {
33
- error: "cannot_leave_mod";
34
32
  } | {
35
33
  error: "pictrs_response_error";
36
34
  message: string;
@@ -51,6 +51,10 @@ export type LocalSite = {
51
51
  * An optional regex to filter words.
52
52
  */
53
53
  slur_filter_regex?: string;
54
+ /**
55
+ * The max actor name length.
56
+ */
57
+ actor_name_max_length: number;
54
58
  /**
55
59
  * Whether federation is enabled.
56
60
  */
@@ -72,24 +72,24 @@ export type LocalUser = {
72
72
  * should be paused
73
73
  */
74
74
  enable_animated_images: boolean;
75
- /**
76
- * Whether to auto-collapse bot comments.
77
- */
78
- collapse_bot_comments: boolean;
79
- /**
80
- * The last time a donation request was shown to this user. If this is more than a year ago,
81
- * a new notification request should be shown.
82
- */
83
- last_donation_notification_at: string;
84
75
  /**
85
76
  * Whether a user can send / receive private messages
86
77
  */
87
78
  enable_private_messages: boolean;
79
+ /**
80
+ * Whether to auto-collapse bot comments.
81
+ */
82
+ collapse_bot_comments: boolean;
88
83
  default_comment_sort_type: CommentSortType;
89
84
  /**
90
85
  * Whether to automatically mark fetched posts as read.
91
86
  */
92
87
  auto_mark_fetched_posts_as_read: boolean;
88
+ /**
89
+ * The last time a donation request was shown to this user. If this is more than a year ago,
90
+ * a new notification request should be shown.
91
+ */
92
+ last_donation_notification_at: string;
93
93
  /**
94
94
  * Whether to hide posts containing images/videos
95
95
  */
@@ -1,9 +1,6 @@
1
1
  import type { CommentId } from "./CommentId";
2
- /**
3
- * Locks a comment and its children, IE prevents new replies.
4
- */
5
2
  export type LockComment = {
6
3
  comment_id: CommentId;
7
4
  locked: boolean;
8
- reason: string;
5
+ reason?: string;
9
6
  };
@@ -5,5 +5,5 @@ import type { PostId } from "./PostId";
5
5
  export type LockPost = {
6
6
  post_id: PostId;
7
7
  locked: boolean;
8
- reason: string;
8
+ reason?: string;
9
9
  };
@@ -9,7 +9,7 @@ export type ModBanFromCommunity = {
9
9
  mod_person_id: PersonId;
10
10
  other_person_id: PersonId;
11
11
  community_id: CommunityId;
12
- reason: string;
12
+ reason?: string;
13
13
  banned: boolean;
14
14
  expires_at?: string;
15
15
  published_at: string;
@@ -1,14 +1,14 @@
1
- import type { CommentId } from "./CommentId";
2
- import type { ModLockCommentId } from "./ModLockCommentId";
1
+ import type { ModLockPostId } from "./ModLockPostId";
3
2
  import type { PersonId } from "./PersonId";
3
+ import type { PostId } from "./PostId";
4
4
  /**
5
5
  * When a moderator locks a comment (prevents new replies to a comment or its children).
6
6
  */
7
7
  export type ModLockComment = {
8
- id: ModLockCommentId;
8
+ id: ModLockPostId;
9
9
  mod_person_id: PersonId;
10
- comment_id: CommentId;
10
+ comment_id: PostId;
11
11
  locked: boolean;
12
- reason: string;
12
+ reason?: string;
13
13
  published_at: string;
14
14
  };
@@ -2,7 +2,6 @@ import type { Comment } from "./Comment";
2
2
  import type { Community } from "./Community";
3
3
  import type { ModLockComment } from "./ModLockComment";
4
4
  import type { Person } from "./Person";
5
- import type { Post } from "./Post";
6
5
  /**
7
6
  * When a moderator locks a comment (prevents replies to it or its children).
8
7
  */
@@ -11,6 +10,5 @@ export type ModLockCommentView = {
11
10
  moderator?: Person;
12
11
  other_person: Person;
13
12
  comment: Comment;
14
- post: Post;
15
13
  community: Community;
16
14
  };
@@ -10,5 +10,5 @@ export type ModLockPost = {
10
10
  post_id: PostId;
11
11
  locked: boolean;
12
12
  published_at: string;
13
- reason: string;
13
+ reason?: string;
14
14
  };
@@ -8,7 +8,7 @@ export type ModRemoveComment = {
8
8
  id: ModRemoveCommentId;
9
9
  mod_person_id: PersonId;
10
10
  comment_id: CommentId;
11
- reason: string;
11
+ reason?: string;
12
12
  removed: boolean;
13
13
  published_at: string;
14
14
  };
@@ -8,7 +8,7 @@ export type ModRemovePost = {
8
8
  id: ModRemovePostId;
9
9
  mod_person_id: PersonId;
10
10
  post_id: PostId;
11
- reason: string;
11
+ reason?: string;
12
12
  removed: boolean;
13
13
  published_at: string;
14
14
  };
@@ -94,6 +94,4 @@ export type Post = {
94
94
  * accepted by the community (by receiving it back via federation).
95
95
  */
96
96
  federation_pending: boolean;
97
- embed_video_width?: number;
98
- embed_video_height?: number;
99
97
  };
@@ -1,10 +1,10 @@
1
1
  import type { Comment } from "./Comment";
2
2
  import type { Post } from "./Post";
3
3
  import type { PrivateMessage } from "./PrivateMessage";
4
- export type PostOrCommentOrPrivateMessage = ({
5
- type_: "Post";
6
- } & Post) | ({
7
- type_: "Comment";
8
- } & Comment) | ({
9
- type_: "PrivateMessage";
10
- } & PrivateMessage);
4
+ export type PostOrCommentOrPrivateMessage = {
5
+ Post: Post;
6
+ } | {
7
+ Comment: Comment;
8
+ } | {
9
+ PrivateMessage: PrivateMessage;
10
+ };
@@ -4,5 +4,5 @@ import type { CommentId } from "./CommentId";
4
4
  */
5
5
  export type PurgeComment = {
6
6
  comment_id: CommentId;
7
- reason: string;
7
+ reason?: string;
8
8
  };
@@ -4,5 +4,5 @@ import type { CommunityId } from "./CommunityId";
4
4
  */
5
5
  export type PurgeCommunity = {
6
6
  community_id: CommunityId;
7
- reason: string;
7
+ reason?: string;
8
8
  };
@@ -4,5 +4,5 @@ import type { PersonId } from "./PersonId";
4
4
  */
5
5
  export type PurgePerson = {
6
6
  person_id: PersonId;
7
- reason: string;
7
+ reason?: string;
8
8
  };
@@ -4,5 +4,5 @@ import type { PostId } from "./PostId";
4
4
  */
5
5
  export type PurgePost = {
6
6
  post_id: PostId;
7
- reason: string;
7
+ reason?: string;
8
8
  };
@@ -5,5 +5,5 @@ import type { CommentId } from "./CommentId";
5
5
  export type RemoveComment = {
6
6
  comment_id: CommentId;
7
7
  removed: boolean;
8
- reason: string;
8
+ reason?: string;
9
9
  };
@@ -5,5 +5,5 @@ import type { CommunityId } from "./CommunityId";
5
5
  export type RemoveCommunity = {
6
6
  community_id: CommunityId;
7
7
  removed: boolean;
8
- reason: string;
8
+ reason?: string;
9
9
  };
@@ -5,5 +5,5 @@ import type { PostId } from "./PostId";
5
5
  export type RemovePost = {
6
6
  post_id: PostId;
7
7
  removed: boolean;
8
- reason: string;
8
+ reason?: string;
9
9
  };
@@ -118,7 +118,7 @@ export type SaveUserSettings = {
118
118
  /**
119
119
  * Some vote display mode settings
120
120
  */
121
- show_score?: boolean;
121
+ show_scores?: boolean;
122
122
  show_upvotes?: boolean;
123
123
  show_downvotes?: VoteShow;
124
124
  show_upvote_percentage?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lemmy-js-client",
3
3
  "description": "A javascript / typescript client for Lemmy",
4
- "version": "1.0.0-error-status-code.0",
4
+ "version": "1.0.0-errors-array.2",
5
5
  "author": "Dessalines",
6
6
  "license": "AGPL-3.0",
7
7
  "main": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "typescript": "^5.5.4",
45
45
  "typescript-eslint": "^8.7.0"
46
46
  },
47
- "packageManager": "pnpm@10.16.1",
47
+ "packageManager": "pnpm@10.15.1",
48
48
  "types": "./dist/index.d.ts",
49
49
  "lint-staged": {
50
50
  "*.{ts,tsx,js}": [