@ai-matrx/messaging 0.15.1 → 0.15.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — `@ai-matrx/messaging`
2
2
 
3
+ ## 0.15.2
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/messaging/v0.15.1..npm/messaging/v0.15.2 -- apps/shared/messaging`).
7
+ No source changes intended and no consumer action required.
8
+
3
9
  ## 0.15.1
4
10
  ### Unreleased
5
11
 
@@ -858,3 +864,4 @@ consumer):
858
864
  - This package supersedes host code that talks to `communication.dm_*` directly. Anything still
859
865
  reading those tables outside the package should be moved onto it or deleted.
860
866
 
867
+
package/dist/index.cjs CHANGED
@@ -1979,10 +1979,23 @@ function createMessagingRepository(options) {
1979
1979
  });
1980
1980
  return found;
1981
1981
  }
1982
+ const conversationOrganizations = /* @__PURE__ */ new Map();
1982
1983
  async function organizationOfExisting(conversationId) {
1983
- if (org !== null) return org;
1984
- const conversation = await repository.getConversation(conversationId);
1985
- return conversation.organizationId;
1984
+ const known = conversationOrganizations.get(conversationId);
1985
+ if (known !== void 0) return known;
1986
+ const operation = "organizationOfExisting";
1987
+ const { data, error } = await withSessionRetry(
1988
+ operation,
1989
+ async () => db().from(TABLES.conversations).select("organization_id").eq("id", conversationId).single()
1990
+ );
1991
+ if (error !== null) throw normalizeMessagingError(error, operation);
1992
+ const own = data?.["organization_id"];
1993
+ if (typeof own !== "string" || own.length === 0) {
1994
+ throw invalidResponse(operation, `conversation ${conversationId} has no organization`);
1995
+ }
1996
+ const organization = own;
1997
+ conversationOrganizations.set(conversationId, organization);
1998
+ return organization;
1986
1999
  }
1987
2000
  const repository = {
1988
2001
  organizationId: org,