@fabriktor/fx 0.0.160 → 0.0.161

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.
@@ -2,6 +2,7 @@ import { type ChatOperator, type UsersOperator, type WSCloseHandler, type WSConn
2
2
  import { type Chat, type ChatRoom, type ChatRoomMember, type User } from "@fabriktor/schema";
3
3
  import { type RequiredSearchOptions, type SearchOptions, type SearchPage, type SearchPaginationOptions } from "../core/search.js";
4
4
  import { ChatSendQueue, type ChatSendQueueOptions } from "./send-queue.js";
5
+ export declare function isChatRecipientUnavailable(error: unknown): boolean;
5
6
  export declare function isChatPublicConversationDisabled(error: unknown): boolean;
6
7
  type ChatInsertOptions = Parameters<ChatOperator["insertOneChat"]>[0];
7
8
  type ChatReplaceOptions = Parameters<ChatOperator["replaceOneChat"]>[0];
@@ -5,7 +5,7 @@
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
6
  import { isHTTPClientErr, queryParam, queryParams, } from "@fabriktor/client";
7
7
  import { ErrCodeChatPublicConversationDisabled, IDKey, OwnerIDKey, } from "@fabriktor/schema";
8
- import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
8
+ import { errRequired, errResolveFailed, errValidation, FXErrKind, isFXErr, } from "../core/err.js";
9
9
  import { requiredOperationID, normalizeIDs } from "../core/id.js";
10
10
  import { normalizeSearchPage, normalizeSearchPerPage, normalizeSearchQuery, runSearch, } from "../core/search.js";
11
11
  import { isFabriktorUser } from "../users/users.js";
@@ -20,8 +20,13 @@ const msgEnsuredChatRoomIDMissing = "Ensured chat room response did not contain
20
20
  const msgChatMissing = "Chat could not be resolved after the mutation.";
21
21
  const msgSearchQueryRequired = "Search query is required.";
22
22
  const msgChatObjectsUploading = "Cannot react to a chat while objects are still uploading.";
23
- const msgChatRecipients = "Chat recipients must have a Fabriktor account. External contacts cannot receive messages or forms.";
23
+ const msgChatRecipients = "One or more selected accounts are unavailable for chat.";
24
24
  const msgParticipantMissing = "Chat room participant could not be resolved.";
25
+ export function isChatRecipientUnavailable(error) {
26
+ return (isFXErr(error) &&
27
+ error.kind === FXErrKind.Validation &&
28
+ error.field === "members");
29
+ }
25
30
  export function isChatPublicConversationDisabled(error) {
26
31
  return (isHTTPClientErr(error) &&
27
32
  error.status === 403 &&
@@ -55,6 +60,7 @@ export class ChatFX {
55
60
  }));
56
61
  if (users.some((user) => !isFabriktorUser(user))) {
57
62
  throw errValidation({
63
+ field: "members",
58
64
  msg: msgChatRecipients,
59
65
  });
60
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.160",
3
+ "version": "0.0.161",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {