@sublay/js 7.1.0 → 7.2.0

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 (31) hide show
  1. package/dist/index.d.mts +95 -24
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +36 -10
  4. package/dist/index.mjs +36 -10
  5. package/dist/interfaces/Conversation.d.ts +2 -0
  6. package/dist/interfaces/SpaceReputation.d.ts +62 -0
  7. package/dist/interfaces/User.d.ts +7 -0
  8. package/dist/modules/chat/getMessage.d.ts +2 -1
  9. package/dist/modules/chat/listMembers.d.ts +2 -1
  10. package/dist/modules/chat/listMessages.d.ts +2 -1
  11. package/dist/modules/chat/listReactions.d.ts +2 -1
  12. package/dist/modules/chat/sendMessage.d.ts +2 -1
  13. package/dist/modules/comments/fetchComment.d.ts +2 -1
  14. package/dist/modules/comments/fetchManyComments.d.ts +2 -1
  15. package/dist/modules/comments/fetchReactions.d.ts +2 -1
  16. package/dist/modules/entities/fetchEntity.d.ts +2 -1
  17. package/dist/modules/entities/fetchManyEntities.d.ts +2 -1
  18. package/dist/modules/entities/fetchReactions.d.ts +2 -1
  19. package/dist/modules/reports/fetchModeratedReports.d.ts +2 -1
  20. package/dist/modules/search/askContent.d.ts +2 -1
  21. package/dist/modules/search/searchContent.d.ts +2 -1
  22. package/dist/modules/spaces/fetchSpaceMembers.d.ts +2 -1
  23. package/dist/modules/spaces/fetchSpaceTeam.d.ts +2 -1
  24. package/dist/modules/users/fetchConnectionsByUserId.d.ts +2 -1
  25. package/dist/modules/users/fetchFollowersByUserId.d.ts +2 -1
  26. package/dist/modules/users/fetchFollowingByUserId.d.ts +2 -1
  27. package/dist/modules/users/fetchUserByForeignId.d.ts +2 -1
  28. package/dist/modules/users/fetchUserById.d.ts +2 -1
  29. package/dist/modules/users/fetchUserByUsername.d.ts +2 -1
  30. package/dist/modules/users/fetchUserSuggestions.d.ts +2 -1
  31. package/package.json +8 -2
package/dist/index.d.mts CHANGED
@@ -127,6 +127,13 @@ type UserFull = {
127
127
  metadata: Record<string, any>;
128
128
  secureMetadata: Record<string, any>;
129
129
  reputation: number;
130
+ /**
131
+ * Space-scoped reputation, present only when the request opted in via
132
+ * `spaceReputationId` (and the project has the reputation bundle). It is the
133
+ * user's reputation within the requested space context — see
134
+ * {@link SpaceReputationContextParams} / {@link SpaceReputationUserParams}.
135
+ */
136
+ spaceReputation?: number;
130
137
  isVerified: boolean;
131
138
  isActive: boolean;
132
139
  lastActive: string;
@@ -293,25 +300,88 @@ declare namespace Auth {
293
300
  export { Auth_changePassword as changePassword, Auth_confirmAccountDeletion as confirmAccountDeletion, Auth_requestAccountDeletion as requestAccountDeletion, Auth_requestNewAccessToken as requestNewAccessToken, Auth_requestPasswordReset as requestPasswordReset, Auth_resetPassword as resetPassword, Auth_sendVerificationEmail as sendVerificationEmail, Auth_signIn as signIn, Auth_signOut as signOut, Auth_signUp as signUp, Auth_verifyEmail as verifyEmail, Auth_verifyExternalUser as verifyExternalUser };
294
301
  }
295
302
 
296
- interface FetchUserByIdProps {
303
+ /**
304
+ * Shared optional params for opting a request into space-scoped reputation
305
+ * enrichment. When set, users embedded in the response carry a
306
+ * `spaceReputation` field (see {@link import("./User").UserFull}).
307
+ *
308
+ * Two variants exist because the server accepts a different value set per
309
+ * endpoint class:
310
+ * - {@link SpaceReputationContextParams} — context endpoints (entities,
311
+ * comments, chat, spaces, search, reports). Accept `<uuid> | "none" |
312
+ * "context"`.
313
+ * - {@link SpaceReputationUserParams} — user-direct endpoints (the `users`
314
+ * module). Accept `<uuid> | "none"` only; `"context"` is rejected by the
315
+ * server (400).
316
+ *
317
+ * Both classes share the same param names and types — only the accepted
318
+ * `spaceReputationId` value set (documented in JSDoc) differs.
319
+ */
320
+ /**
321
+ * Space-reputation params for **context** endpoints.
322
+ */
323
+ interface SpaceReputationContextParams {
324
+ /**
325
+ * Opt into space-scoped reputation enrichment. Accepted forms:
326
+ * - a space `<uuid>` — reputation within that specific space;
327
+ * - `"none"` — no space context (global reputation only);
328
+ * - `"context"` — derive the space from each record's own context
329
+ * (e.g. a feed enriches each row's author with reputation in that row's
330
+ * space).
331
+ *
332
+ * Plain `string` — a `string | "none" | "context"` union adds no safety
333
+ * since a uuid is already a string.
334
+ */
335
+ spaceReputationId?: string;
336
+ /**
337
+ * Whether to include descendant spaces when computing space-scoped
338
+ * reputation. Only honored with an explicit space `<uuid>` (ignored for
339
+ * `"none"` / `"context"`).
340
+ */
341
+ spaceReputationDescendants?: boolean;
342
+ }
343
+ /**
344
+ * Space-reputation params for **user-direct** endpoints (the `users` module).
345
+ */
346
+ interface SpaceReputationUserParams {
347
+ /**
348
+ * Opt into space-scoped reputation enrichment. Accepted forms:
349
+ * - a space `<uuid>` — reputation within that specific space;
350
+ * - `"none"` — no space context (global reputation only).
351
+ *
352
+ * `"context"` is **rejected by the server (400)** on user-direct endpoints —
353
+ * there is no per-record context to derive a space from.
354
+ *
355
+ * Plain `string` — a `string | "none"` union adds no safety since a uuid is
356
+ * already a string.
357
+ */
358
+ spaceReputationId?: string;
359
+ /**
360
+ * Whether to include descendant spaces when computing space-scoped
361
+ * reputation. Only honored with an explicit space `<uuid>`.
362
+ */
363
+ spaceReputationDescendants?: boolean;
364
+ }
365
+
366
+ interface FetchUserByIdProps extends SpaceReputationUserParams {
297
367
  userId: string;
298
368
  include?: string;
299
369
  }
300
370
  declare function fetchUserById(client: SublayHttpClient, data: FetchUserByIdProps): Promise<User>;
301
371
 
302
- interface FetchUserByForeignIdProps {
372
+ interface FetchUserByForeignIdProps extends SpaceReputationUserParams {
303
373
  foreignId: string;
304
374
  include?: string;
305
375
  }
306
376
  declare function fetchUserByForeignId(client: SublayHttpClient, data: FetchUserByForeignIdProps): Promise<User>;
307
377
 
308
- interface FetchUserByUsernameProps {
378
+ interface FetchUserByUsernameProps extends SpaceReputationUserParams {
309
379
  username: string;
310
380
  include?: string;
311
381
  }
312
382
  declare function fetchUserByUsername(client: SublayHttpClient, data: FetchUserByUsernameProps): Promise<User>;
313
383
 
314
- interface FetchUserSuggestionsProps {
384
+ interface FetchUserSuggestionsProps extends SpaceReputationUserParams {
315
385
  query: string;
316
386
  }
317
387
  declare function fetchUserSuggestions(client: SublayHttpClient, data: FetchUserSuggestionsProps): Promise<User[]>;
@@ -447,7 +517,7 @@ interface PaginatedResponse<T> {
447
517
  pagination: PaginationMetadata;
448
518
  }
449
519
 
450
- interface FetchFollowersByUserIdProps {
520
+ interface FetchFollowersByUserIdProps extends SpaceReputationUserParams {
451
521
  userId: string;
452
522
  page?: number;
453
523
  limit?: number;
@@ -462,7 +532,7 @@ interface FollowersCountResponse$1 {
462
532
  }
463
533
  declare function fetchFollowersCountByUserId(client: SublayHttpClient, data: FetchFollowersCountByUserIdProps): Promise<FollowersCountResponse$1>;
464
534
 
465
- interface FetchFollowingByUserIdProps {
535
+ interface FetchFollowingByUserIdProps extends SpaceReputationUserParams {
466
536
  userId: string;
467
537
  page?: number;
468
538
  limit?: number;
@@ -536,7 +606,7 @@ interface ConnectionStatusDeclined {
536
606
  }
537
607
  type ConnectionStatusResponse = ConnectionStatusNone | ConnectionStatusPending | ConnectionStatusConnected | ConnectionStatusDeclined;
538
608
 
539
- interface FetchConnectionsByUserIdProps {
609
+ interface FetchConnectionsByUserIdProps extends SpaceReputationUserParams {
540
610
  userId: string;
541
611
  page?: number;
542
612
  limit?: number;
@@ -868,7 +938,7 @@ interface CreateEntityProps {
868
938
  }
869
939
  declare function createEntity(client: SublayHttpClient, data: CreateEntityProps): Promise<Entity>;
870
940
 
871
- interface FetchEntityProps {
941
+ interface FetchEntityProps extends SpaceReputationContextParams {
872
942
  entityId: string;
873
943
  include?: string;
874
944
  }
@@ -917,7 +987,7 @@ interface LocationFilters {
917
987
  longitude: string;
918
988
  radius: string;
919
989
  }
920
- interface FetchManyEntitiesProps {
990
+ interface FetchManyEntitiesProps extends SpaceReputationContextParams {
921
991
  sourceId?: string;
922
992
  spaceId?: string;
923
993
  sortBy?: "new" | "hot" | "top" | "controversial" | (string & {});
@@ -993,7 +1063,7 @@ interface RemoveEntityReactionProps {
993
1063
  }
994
1064
  declare function removeReaction$1(client: SublayHttpClient, data: RemoveEntityReactionProps): Promise<Entity>;
995
1065
 
996
- interface FetchEntityReactionsProps {
1066
+ interface FetchEntityReactionsProps extends SpaceReputationContextParams {
997
1067
  entityId: string;
998
1068
  reactionType?: ReactionType;
999
1069
  page?: number;
@@ -1093,7 +1163,7 @@ interface CreateCommentProps {
1093
1163
  }
1094
1164
  declare function createComment(client: SublayHttpClient, data: CreateCommentProps): Promise<Comment>;
1095
1165
 
1096
- interface FetchCommentProps {
1166
+ interface FetchCommentProps extends SpaceReputationContextParams {
1097
1167
  commentId: string;
1098
1168
  include?: string;
1099
1169
  }
@@ -1116,7 +1186,7 @@ interface DeleteCommentProps {
1116
1186
  }
1117
1187
  declare function deleteComment(client: SublayHttpClient, data: DeleteCommentProps): Promise<void>;
1118
1188
 
1119
- interface FetchManyCommentsProps {
1189
+ interface FetchManyCommentsProps extends SpaceReputationContextParams {
1120
1190
  entityId?: string;
1121
1191
  userId?: string;
1122
1192
  parentId?: string;
@@ -1139,7 +1209,7 @@ interface RemoveCommentReactionProps {
1139
1209
  }
1140
1210
  declare function removeReaction(client: SublayHttpClient, data: RemoveCommentReactionProps): Promise<Comment>;
1141
1211
 
1142
- interface FetchCommentReactionsProps {
1212
+ interface FetchCommentReactionsProps extends SpaceReputationContextParams {
1143
1213
  commentId: string;
1144
1214
  reactionType?: ReactionType;
1145
1215
  page?: number;
@@ -1305,7 +1375,7 @@ interface SpaceTeamResponse {
1305
1375
  data: SpaceMemberWithUser[];
1306
1376
  }
1307
1377
 
1308
- interface FetchSpaceMembersProps {
1378
+ interface FetchSpaceMembersProps extends SpaceReputationContextParams {
1309
1379
  spaceId: string;
1310
1380
  page?: number;
1311
1381
  limit?: number;
@@ -1314,7 +1384,7 @@ interface FetchSpaceMembersProps {
1314
1384
  }
1315
1385
  declare function fetchSpaceMembers(client: SublayHttpClient, data: FetchSpaceMembersProps): Promise<SpaceMembersResponse>;
1316
1386
 
1317
- interface FetchSpaceTeamProps {
1387
+ interface FetchSpaceTeamProps extends SpaceReputationContextParams {
1318
1388
  spaceId: string;
1319
1389
  }
1320
1390
  declare function fetchSpaceTeam(client: SublayHttpClient, data: FetchSpaceTeamProps): Promise<SpaceTeamResponse>;
@@ -1556,6 +1626,7 @@ interface Conversation {
1556
1626
  interface ConversationPreview extends Conversation {
1557
1627
  unreadCount: number;
1558
1628
  lastMessage: ChatMessage | null;
1629
+ otherMembers?: Pick<User, "id" | "name" | "username" | "avatar">[];
1559
1630
  }
1560
1631
 
1561
1632
  interface GetSpaceConversationProps {
@@ -2112,7 +2183,7 @@ interface CreateReportProps {
2112
2183
  }
2113
2184
  declare function createReport(client: SublayHttpClient, data: CreateReportProps): Promise<CreateReportResponse>;
2114
2185
 
2115
- interface FetchModeratedReportsProps {
2186
+ interface FetchModeratedReportsProps extends SpaceReputationContextParams {
2116
2187
  spaceId?: string;
2117
2188
  targetType?: ReportTargetType;
2118
2189
  status?: ReportStatus;
@@ -2128,7 +2199,7 @@ declare namespace Reports {
2128
2199
  export { Reports_createReport as createReport, Reports_fetchModeratedReports as fetchModeratedReports };
2129
2200
  }
2130
2201
 
2131
- interface SearchContentProps {
2202
+ interface SearchContentProps extends SpaceReputationContextParams {
2132
2203
  query: string;
2133
2204
  sourceTypes?: ("entity" | "comment" | "message")[];
2134
2205
  spaceId?: string;
@@ -2162,7 +2233,7 @@ interface SpaceSearchResult {
2162
2233
  }
2163
2234
  declare function searchSpaces(client: SublayHttpClient, data: SearchSpacesProps): Promise<SpaceSearchResult[]>;
2164
2235
 
2165
- interface AskContentProps {
2236
+ interface AskContentProps extends SpaceReputationContextParams {
2166
2237
  query: string;
2167
2238
  sourceTypes?: ("entity" | "comment" | "message")[];
2168
2239
  spaceId?: string;
@@ -2472,7 +2543,7 @@ interface UnreadCountResponse {
2472
2543
  }
2473
2544
  declare function getUnreadCount(client: SublayHttpClient): Promise<UnreadCountResponse>;
2474
2545
 
2475
- interface ListMembersProps {
2546
+ interface ListMembersProps extends SpaceReputationContextParams {
2476
2547
  conversationId: string;
2477
2548
  page?: number;
2478
2549
  limit?: number;
@@ -2519,7 +2590,7 @@ interface MessageFilters {
2519
2590
  */
2520
2591
  hasReplies?: boolean;
2521
2592
  }
2522
- interface ListMessagesProps {
2593
+ interface ListMessagesProps extends SpaceReputationContextParams {
2523
2594
  conversationId: string;
2524
2595
  /** Restrict to replies of this message (thread view). */
2525
2596
  parentId?: string;
@@ -2549,7 +2620,7 @@ interface ListMessagesResponse {
2549
2620
  }
2550
2621
  declare function listMessages(client: SublayHttpClient, data: ListMessagesProps): Promise<ListMessagesResponse>;
2551
2622
 
2552
- interface SendMessageProps {
2623
+ interface SendMessageProps extends SpaceReputationContextParams {
2553
2624
  conversationId: string;
2554
2625
  content?: string;
2555
2626
  gif?: GifData | null;
@@ -2567,7 +2638,7 @@ interface SendMessageProps {
2567
2638
  }
2568
2639
  declare function sendMessage(client: SublayHttpClient, data: SendMessageProps): Promise<ChatMessage>;
2569
2640
 
2570
- interface GetMessageProps {
2641
+ interface GetMessageProps extends SpaceReputationContextParams {
2571
2642
  conversationId: string;
2572
2643
  messageId: string;
2573
2644
  }
@@ -2611,7 +2682,7 @@ interface ToggleReactionResponse {
2611
2682
  }
2612
2683
  declare function toggleReaction(client: SublayHttpClient, data: ToggleReactionProps): Promise<ToggleReactionResponse>;
2613
2684
 
2614
- interface ListReactionsProps {
2685
+ interface ListReactionsProps extends SpaceReputationContextParams {
2615
2686
  conversationId: string;
2616
2687
  messageId: string;
2617
2688
  /** The reaction emoji to list reactors for (required). */
@@ -2772,4 +2843,4 @@ declare class SublayClient {
2772
2843
  clearTokens(): void;
2773
2844
  }
2774
2845
 
2775
- export { type AuthTokens, type BulkDeleteProps, type BulkDeleteResult, type ClientConfig, type DbFilter, type DbFilterOperator, type DeleteResult, type PaginatedResponse, type PaginationMetadata, SublayClient, type TableAccessor, type TableQuery, type TableRow };
2846
+ export { type AuthTokens, type BulkDeleteProps, type BulkDeleteResult, type ClientConfig, type DbFilter, type DbFilterOperator, type DeleteResult, type PaginatedResponse, type PaginationMetadata, type SpaceReputationContextParams, type SpaceReputationUserParams, SublayClient, type TableAccessor, type TableQuery, type TableRow };
package/dist/index.d.ts CHANGED
@@ -48,4 +48,5 @@ export declare class SublayClient {
48
48
  }
49
49
  export type { ClientConfig, AuthTokens } from "./core/client";
50
50
  export type { PaginatedResponse, PaginationMetadata, } from "./interfaces/IPaginatedResponse";
51
+ export type { SpaceReputationContextParams, SpaceReputationUserParams, } from "./interfaces/SpaceReputation";
51
52
  export type { TableAccessor, TableRow, TableQuery, DbFilter, DbFilterOperator, BulkDeleteProps, DeleteResult, BulkDeleteResult, } from "./interfaces/Table";
package/dist/index.js CHANGED
@@ -963,9 +963,10 @@ async function fetchSpaceMembers(client, data) {
963
963
 
964
964
  // src/modules/spaces/fetchSpaceTeam.ts
965
965
  async function fetchSpaceTeam(client, data) {
966
- const { spaceId } = data;
966
+ const { spaceId, ...params } = data;
967
967
  const response = await client.projectInstance.get(
968
- `/spaces/${spaceId}/team`
968
+ `/spaces/${spaceId}/team`,
969
+ { params }
969
970
  );
970
971
  return response.data;
971
972
  }
@@ -1435,9 +1436,11 @@ __export(search_exports, {
1435
1436
 
1436
1437
  // src/modules/search/searchContent.ts
1437
1438
  async function searchContent(client, data) {
1439
+ const { spaceReputationId, spaceReputationDescendants, ...body } = data;
1438
1440
  const response = await client.projectInstance.post(
1439
1441
  "/search/content",
1440
- data
1442
+ body,
1443
+ { params: { spaceReputationId, spaceReputationDescendants } }
1441
1444
  );
1442
1445
  return response.data;
1443
1446
  }
@@ -1494,14 +1497,24 @@ function parseSseBlock(block) {
1494
1497
  }
1495
1498
  }
1496
1499
  async function* askContent(client, data) {
1497
- const { signal, ...body } = data;
1500
+ const { signal, spaceReputationId, spaceReputationDescendants, ...body } = data;
1498
1501
  const baseURL = client.projectInstance.defaults.baseURL ?? "";
1499
1502
  const authHeader = await client.getAuthHeader();
1500
1503
  const headers = {
1501
1504
  "Content-Type": "application/json"
1502
1505
  };
1503
1506
  if (authHeader) headers.Authorization = authHeader;
1504
- const response = await fetch(`${baseURL}/search/ask`, {
1507
+ const search = new URLSearchParams();
1508
+ if (spaceReputationId != null)
1509
+ search.set("spaceReputationId", spaceReputationId);
1510
+ if (spaceReputationDescendants != null)
1511
+ search.set(
1512
+ "spaceReputationDescendants",
1513
+ String(spaceReputationDescendants)
1514
+ );
1515
+ const queryString = search.toString();
1516
+ const url = `${baseURL}/search/ask${queryString ? `?${queryString}` : ""}`;
1517
+ const response = await fetch(url, {
1505
1518
  method: "POST",
1506
1519
  headers,
1507
1520
  body: JSON.stringify(body),
@@ -1783,8 +1796,17 @@ async function listMessages(client, data) {
1783
1796
 
1784
1797
  // src/modules/chat/sendMessage.ts
1785
1798
  async function sendMessage(client, data) {
1786
- const { conversationId, files, ...body } = data;
1799
+ const {
1800
+ conversationId,
1801
+ files,
1802
+ // The server reads these from `req.query`, not the body, so they are
1803
+ // forwarded as query params (in both the JSON and multipart branches).
1804
+ spaceReputationId,
1805
+ spaceReputationDescendants,
1806
+ ...body
1807
+ } = data;
1787
1808
  const path = `/chat/conversations/${conversationId}/messages`;
1809
+ const params = { spaceReputationId, spaceReputationDescendants };
1788
1810
  if (files && files.length > 0) {
1789
1811
  const formData = new FormData();
1790
1812
  for (const file of files) {
@@ -1793,19 +1815,23 @@ async function sendMessage(client, data) {
1793
1815
  appendFields(formData, body);
1794
1816
  const response2 = await client.projectInstance.post(
1795
1817
  path,
1796
- formData
1818
+ formData,
1819
+ { params }
1797
1820
  );
1798
1821
  return response2.data;
1799
1822
  }
1800
- const response = await client.projectInstance.post(path, body);
1823
+ const response = await client.projectInstance.post(path, body, {
1824
+ params
1825
+ });
1801
1826
  return response.data;
1802
1827
  }
1803
1828
 
1804
1829
  // src/modules/chat/getMessage.ts
1805
1830
  async function getMessage(client, data) {
1806
- const { conversationId, messageId } = data;
1831
+ const { conversationId, messageId, ...params } = data;
1807
1832
  const response = await client.projectInstance.get(
1808
- `/chat/conversations/${conversationId}/messages/${messageId}`
1833
+ `/chat/conversations/${conversationId}/messages/${messageId}`,
1834
+ { params }
1809
1835
  );
1810
1836
  return response.data;
1811
1837
  }
package/dist/index.mjs CHANGED
@@ -933,9 +933,10 @@ async function fetchSpaceMembers(client, data) {
933
933
 
934
934
  // src/modules/spaces/fetchSpaceTeam.ts
935
935
  async function fetchSpaceTeam(client, data) {
936
- const { spaceId } = data;
936
+ const { spaceId, ...params } = data;
937
937
  const response = await client.projectInstance.get(
938
- `/spaces/${spaceId}/team`
938
+ `/spaces/${spaceId}/team`,
939
+ { params }
939
940
  );
940
941
  return response.data;
941
942
  }
@@ -1405,9 +1406,11 @@ __export(search_exports, {
1405
1406
 
1406
1407
  // src/modules/search/searchContent.ts
1407
1408
  async function searchContent(client, data) {
1409
+ const { spaceReputationId, spaceReputationDescendants, ...body } = data;
1408
1410
  const response = await client.projectInstance.post(
1409
1411
  "/search/content",
1410
- data
1412
+ body,
1413
+ { params: { spaceReputationId, spaceReputationDescendants } }
1411
1414
  );
1412
1415
  return response.data;
1413
1416
  }
@@ -1464,14 +1467,24 @@ function parseSseBlock(block) {
1464
1467
  }
1465
1468
  }
1466
1469
  async function* askContent(client, data) {
1467
- const { signal, ...body } = data;
1470
+ const { signal, spaceReputationId, spaceReputationDescendants, ...body } = data;
1468
1471
  const baseURL = client.projectInstance.defaults.baseURL ?? "";
1469
1472
  const authHeader = await client.getAuthHeader();
1470
1473
  const headers = {
1471
1474
  "Content-Type": "application/json"
1472
1475
  };
1473
1476
  if (authHeader) headers.Authorization = authHeader;
1474
- const response = await fetch(`${baseURL}/search/ask`, {
1477
+ const search = new URLSearchParams();
1478
+ if (spaceReputationId != null)
1479
+ search.set("spaceReputationId", spaceReputationId);
1480
+ if (spaceReputationDescendants != null)
1481
+ search.set(
1482
+ "spaceReputationDescendants",
1483
+ String(spaceReputationDescendants)
1484
+ );
1485
+ const queryString = search.toString();
1486
+ const url = `${baseURL}/search/ask${queryString ? `?${queryString}` : ""}`;
1487
+ const response = await fetch(url, {
1475
1488
  method: "POST",
1476
1489
  headers,
1477
1490
  body: JSON.stringify(body),
@@ -1753,8 +1766,17 @@ async function listMessages(client, data) {
1753
1766
 
1754
1767
  // src/modules/chat/sendMessage.ts
1755
1768
  async function sendMessage(client, data) {
1756
- const { conversationId, files, ...body } = data;
1769
+ const {
1770
+ conversationId,
1771
+ files,
1772
+ // The server reads these from `req.query`, not the body, so they are
1773
+ // forwarded as query params (in both the JSON and multipart branches).
1774
+ spaceReputationId,
1775
+ spaceReputationDescendants,
1776
+ ...body
1777
+ } = data;
1757
1778
  const path = `/chat/conversations/${conversationId}/messages`;
1779
+ const params = { spaceReputationId, spaceReputationDescendants };
1758
1780
  if (files && files.length > 0) {
1759
1781
  const formData = new FormData();
1760
1782
  for (const file of files) {
@@ -1763,19 +1785,23 @@ async function sendMessage(client, data) {
1763
1785
  appendFields(formData, body);
1764
1786
  const response2 = await client.projectInstance.post(
1765
1787
  path,
1766
- formData
1788
+ formData,
1789
+ { params }
1767
1790
  );
1768
1791
  return response2.data;
1769
1792
  }
1770
- const response = await client.projectInstance.post(path, body);
1793
+ const response = await client.projectInstance.post(path, body, {
1794
+ params
1795
+ });
1771
1796
  return response.data;
1772
1797
  }
1773
1798
 
1774
1799
  // src/modules/chat/getMessage.ts
1775
1800
  async function getMessage(client, data) {
1776
- const { conversationId, messageId } = data;
1801
+ const { conversationId, messageId, ...params } = data;
1777
1802
  const response = await client.projectInstance.get(
1778
- `/chat/conversations/${conversationId}/messages/${messageId}`
1803
+ `/chat/conversations/${conversationId}/messages/${messageId}`,
1804
+ { params }
1779
1805
  );
1780
1806
  return response.data;
1781
1807
  }
@@ -1,6 +1,7 @@
1
1
  import { File } from "./File";
2
2
  import { ChatMessage } from "./ChatMessage";
3
3
  import { ConversationMember } from "./ConversationMember";
4
+ import { User } from "./User";
4
5
  export interface Conversation {
5
6
  id: string;
6
7
  projectId: string;
@@ -22,4 +23,5 @@ export interface Conversation {
22
23
  export interface ConversationPreview extends Conversation {
23
24
  unreadCount: number;
24
25
  lastMessage: ChatMessage | null;
26
+ otherMembers?: Pick<User, "id" | "name" | "username" | "avatar">[];
25
27
  }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Shared optional params for opting a request into space-scoped reputation
3
+ * enrichment. When set, users embedded in the response carry a
4
+ * `spaceReputation` field (see {@link import("./User").UserFull}).
5
+ *
6
+ * Two variants exist because the server accepts a different value set per
7
+ * endpoint class:
8
+ * - {@link SpaceReputationContextParams} — context endpoints (entities,
9
+ * comments, chat, spaces, search, reports). Accept `<uuid> | "none" |
10
+ * "context"`.
11
+ * - {@link SpaceReputationUserParams} — user-direct endpoints (the `users`
12
+ * module). Accept `<uuid> | "none"` only; `"context"` is rejected by the
13
+ * server (400).
14
+ *
15
+ * Both classes share the same param names and types — only the accepted
16
+ * `spaceReputationId` value set (documented in JSDoc) differs.
17
+ */
18
+ /**
19
+ * Space-reputation params for **context** endpoints.
20
+ */
21
+ export interface SpaceReputationContextParams {
22
+ /**
23
+ * Opt into space-scoped reputation enrichment. Accepted forms:
24
+ * - a space `<uuid>` — reputation within that specific space;
25
+ * - `"none"` — no space context (global reputation only);
26
+ * - `"context"` — derive the space from each record's own context
27
+ * (e.g. a feed enriches each row's author with reputation in that row's
28
+ * space).
29
+ *
30
+ * Plain `string` — a `string | "none" | "context"` union adds no safety
31
+ * since a uuid is already a string.
32
+ */
33
+ spaceReputationId?: string;
34
+ /**
35
+ * Whether to include descendant spaces when computing space-scoped
36
+ * reputation. Only honored with an explicit space `<uuid>` (ignored for
37
+ * `"none"` / `"context"`).
38
+ */
39
+ spaceReputationDescendants?: boolean;
40
+ }
41
+ /**
42
+ * Space-reputation params for **user-direct** endpoints (the `users` module).
43
+ */
44
+ export interface SpaceReputationUserParams {
45
+ /**
46
+ * Opt into space-scoped reputation enrichment. Accepted forms:
47
+ * - a space `<uuid>` — reputation within that specific space;
48
+ * - `"none"` — no space context (global reputation only).
49
+ *
50
+ * `"context"` is **rejected by the server (400)** on user-direct endpoints —
51
+ * there is no per-record context to derive a space from.
52
+ *
53
+ * Plain `string` — a `string | "none"` union adds no safety since a uuid is
54
+ * already a string.
55
+ */
56
+ spaceReputationId?: string;
57
+ /**
58
+ * Whether to include descendant spaces when computing space-scoped
59
+ * reputation. Only honored with an explicit space `<uuid>`.
60
+ */
61
+ spaceReputationDescendants?: boolean;
62
+ }
@@ -22,6 +22,13 @@ export type UserFull = {
22
22
  metadata: Record<string, any>;
23
23
  secureMetadata: Record<string, any>;
24
24
  reputation: number;
25
+ /**
26
+ * Space-scoped reputation, present only when the request opted in via
27
+ * `spaceReputationId` (and the project has the reputation bundle). It is the
28
+ * user's reputation within the requested space context — see
29
+ * {@link SpaceReputationContextParams} / {@link SpaceReputationUserParams}.
30
+ */
31
+ spaceReputation?: number;
25
32
  isVerified: boolean;
26
33
  isActive: boolean;
27
34
  lastActive: string;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { ChatMessage } from "../../interfaces/ChatMessage";
3
- export interface GetMessageProps {
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
+ export interface GetMessageProps extends SpaceReputationContextParams {
4
5
  conversationId: string;
5
6
  messageId: string;
6
7
  }
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { ConversationMember } from "../../interfaces/ConversationMember";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
- export interface ListMembersProps {
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
5
+ export interface ListMembersProps extends SpaceReputationContextParams {
5
6
  conversationId: string;
6
7
  page?: number;
7
8
  limit?: number;
@@ -1,5 +1,6 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { ChatMessage } from "../../interfaces/ChatMessage";
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
3
4
  export interface MessageFilters {
4
5
  /**
5
6
  * Filter to messages that have thread replies (not quotings). `true` returns
@@ -8,7 +9,7 @@ export interface MessageFilters {
8
9
  */
9
10
  hasReplies?: boolean;
10
11
  }
11
- export interface ListMessagesProps {
12
+ export interface ListMessagesProps extends SpaceReputationContextParams {
12
13
  conversationId: string;
13
14
  /** Restrict to replies of this message (thread view). */
14
15
  parentId?: string;
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { User } from "../../interfaces/User";
3
3
  import { PaginationMetadata } from "../../interfaces/IPaginatedResponse";
4
- export interface ListReactionsProps {
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
5
+ export interface ListReactionsProps extends SpaceReputationContextParams {
5
6
  conversationId: string;
6
7
  messageId: string;
7
8
  /** The reaction emoji to list reactors for (required). */
@@ -2,7 +2,8 @@ import { SublayHttpClient } from "../../core/client";
2
2
  import { ChatMessage } from "../../interfaces/ChatMessage";
3
3
  import { GifData } from "../../interfaces/Comment";
4
4
  import { Mention } from "../../interfaces/Mention";
5
- export interface SendMessageProps {
5
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
6
+ export interface SendMessageProps extends SpaceReputationContextParams {
6
7
  conversationId: string;
7
8
  content?: string;
8
9
  gif?: GifData | null;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Comment } from "../../interfaces/Comment";
3
- export interface FetchCommentProps {
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchCommentProps extends SpaceReputationContextParams {
4
5
  commentId: string;
5
6
  include?: string;
6
7
  }
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Comment } from "../../interfaces/Comment";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchManyCommentsProps {
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchManyCommentsProps extends SpaceReputationContextParams {
5
6
  entityId?: string;
6
7
  userId?: string;
7
8
  parentId?: string;
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Reaction, ReactionType } from "../../interfaces/Reaction";
3
3
  import { PaginationMetadata } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchCommentReactionsProps {
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchCommentReactionsProps extends SpaceReputationContextParams {
5
6
  commentId: string;
6
7
  reactionType?: ReactionType;
7
8
  page?: number;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Entity } from "../../interfaces/Entity";
3
- export interface FetchEntityProps {
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchEntityProps extends SpaceReputationContextParams {
4
5
  entityId: string;
5
6
  include?: string;
6
7
  }
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Entity } from "../../interfaces/Entity";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
5
  export interface KeywordsFilters {
5
6
  includes?: string[];
6
7
  doesNotInclude?: string[];
@@ -31,7 +32,7 @@ export interface LocationFilters {
31
32
  longitude: string;
32
33
  radius: string;
33
34
  }
34
- export interface FetchManyEntitiesProps {
35
+ export interface FetchManyEntitiesProps extends SpaceReputationContextParams {
35
36
  sourceId?: string;
36
37
  spaceId?: string;
37
38
  sortBy?: "new" | "hot" | "top" | "controversial" | (string & {});
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Reaction, ReactionType } from "../../interfaces/Reaction";
3
3
  import { PaginationMetadata } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchEntityReactionsProps {
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchEntityReactionsProps extends SpaceReputationContextParams {
5
6
  entityId: string;
6
7
  reactionType?: ReactionType;
7
8
  page?: number;
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { Report, ReportStatus, ReportTargetType } from "../../interfaces/Report";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchModeratedReportsProps {
4
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchModeratedReportsProps extends SpaceReputationContextParams {
5
6
  spaceId?: string;
6
7
  targetType?: ReportTargetType;
7
8
  status?: ReportStatus;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { ContentSearchResult } from "./searchContent";
3
- export interface AskContentProps {
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
+ export interface AskContentProps extends SpaceReputationContextParams {
4
5
  query: string;
5
6
  sourceTypes?: ("entity" | "comment" | "message")[];
6
7
  spaceId?: string;
@@ -2,7 +2,8 @@ import { SublayHttpClient } from "../../core/client";
2
2
  import { Entity } from "../../interfaces/Entity";
3
3
  import { Comment } from "../../interfaces/Comment";
4
4
  import { ChatMessage } from "../../interfaces/ChatMessage";
5
- export interface SearchContentProps {
5
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
6
+ export interface SearchContentProps extends SpaceReputationContextParams {
6
7
  query: string;
7
8
  sourceTypes?: ("entity" | "comment" | "message")[];
8
9
  spaceId?: string;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { SpaceMembersResponse } from "../../interfaces/SpaceMember";
3
- export interface FetchSpaceMembersProps {
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchSpaceMembersProps extends SpaceReputationContextParams {
4
5
  spaceId: string;
5
6
  page?: number;
6
7
  limit?: number;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { SpaceTeamResponse } from "../../interfaces/SpaceMember";
3
- export interface FetchSpaceTeamProps {
3
+ import { SpaceReputationContextParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchSpaceTeamProps extends SpaceReputationContextParams {
4
5
  spaceId: string;
5
6
  }
6
7
  export declare function fetchSpaceTeam(client: SublayHttpClient, data: FetchSpaceTeamProps): Promise<SpaceTeamResponse>;
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { EstablishedConnection } from "../../interfaces/Connection";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchConnectionsByUserIdProps {
4
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchConnectionsByUserIdProps extends SpaceReputationUserParams {
5
6
  userId: string;
6
7
  page?: number;
7
8
  limit?: number;
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { FollowListItem } from "../../interfaces/Follow";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchFollowersByUserIdProps {
4
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchFollowersByUserIdProps extends SpaceReputationUserParams {
5
6
  userId: string;
6
7
  page?: number;
7
8
  limit?: number;
@@ -1,7 +1,8 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { FollowListItem } from "../../interfaces/Follow";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
- export interface FetchFollowingByUserIdProps {
4
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
5
+ export interface FetchFollowingByUserIdProps extends SpaceReputationUserParams {
5
6
  userId: string;
6
7
  page?: number;
7
8
  limit?: number;
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { User } from "../../interfaces/User";
3
- export interface FetchUserByForeignIdProps {
3
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchUserByForeignIdProps extends SpaceReputationUserParams {
4
5
  foreignId: string;
5
6
  include?: string;
6
7
  }
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { User } from "../../interfaces/User";
3
- export interface FetchUserByIdProps {
3
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchUserByIdProps extends SpaceReputationUserParams {
4
5
  userId: string;
5
6
  include?: string;
6
7
  }
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { User } from "../../interfaces/User";
3
- export interface FetchUserByUsernameProps {
3
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchUserByUsernameProps extends SpaceReputationUserParams {
4
5
  username: string;
5
6
  include?: string;
6
7
  }
@@ -1,6 +1,7 @@
1
1
  import { SublayHttpClient } from "../../core/client";
2
2
  import { User } from "../../interfaces/User";
3
- export interface FetchUserSuggestionsProps {
3
+ import { SpaceReputationUserParams } from "../../interfaces/SpaceReputation";
4
+ export interface FetchUserSuggestionsProps extends SpaceReputationUserParams {
4
5
  query: string;
5
6
  }
6
7
  export declare function fetchUserSuggestions(client: SublayHttpClient, data: FetchUserSuggestionsProps): Promise<User[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sublay/js",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -34,7 +34,13 @@
34
34
  "build": "tsup src/index.ts --dts --format cjs,esm",
35
35
  "build:types": "tsc --emitDeclarationOnly",
36
36
  "test": "jest",
37
+ "version:patch": "pnpm version patch --no-git-tag-version --no-git-checks",
38
+ "version:minor": "pnpm version minor --no-git-tag-version --no-git-checks",
37
39
  "publish-beta": "pnpm publish --tag beta --no-git-checks",
38
- "publish-prod": "pnpm publish --no-git-checks"
40
+ "publish-prod": "pnpm publish --no-git-checks",
41
+ "publish-beta:patch": "pnpm version:patch && pnpm publish-beta",
42
+ "publish-beta:minor": "pnpm version:minor && pnpm publish-beta",
43
+ "publish-prod:patch": "pnpm version:patch && pnpm publish-prod",
44
+ "publish-prod:minor": "pnpm version:minor && pnpm publish-prod"
39
45
  }
40
46
  }