@fabriktor/fx 0.0.108 → 0.0.109

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.
@@ -1,4 +1,4 @@
1
- import type { ChatOperator, UsersOperator, WSCloseHandler, WSConnection, WSErrorHandler, WSMessageHandler } from "@fabriktor/client";
1
+ import { type ChatOperator, type UsersOperator, type WSCloseHandler, type WSConnection, type WSErrorHandler, type WSMessageHandler } from "@fabriktor/client";
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";
@@ -26,7 +26,7 @@ type SearchChatsScope = {
26
26
  chat_room_id?: string;
27
27
  owner_id: string;
28
28
  };
29
- export type SearchChatsOptions = SearchChatsScope & RequiredSearchOptions;
29
+ export type SearchChatsOptions = SearchChatsScope & RequiredSearchOptions & Pick<SearchOptions, "signal">;
30
30
  export type SearchChatsPage = SearchPage<Chat>;
31
31
  export type LatestChatsOptions = SearchPaginationOptions & {
32
32
  chat_room_id: string;
@@ -3,7 +3,8 @@
3
3
  // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
4
  // not use this file except in compliance with the License. You may obtain
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- import { IDKey, } from "@fabriktor/schema";
6
+ import { queryParam, queryParams, } from "@fabriktor/client";
7
+ import { IDKey, OwnerIDKey, } from "@fabriktor/schema";
7
8
  import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
8
9
  import { requiredOperationID } from "../core/id.js";
9
10
  import { normalizeSearchPage, normalizeSearchPerPage, normalizeSearchQuery, runSearch, } from "../core/search.js";
@@ -69,13 +70,14 @@ export class ChatFX {
69
70
  }
70
71
  return await runSearch({
71
72
  search: (searchOpts) => this.chat.searchManyChats(searchOpts),
72
- query: {
73
+ query: queryParams({
73
74
  chat_room_id: opts.chat_room_id,
74
- owner_id: opts.owner_id,
75
- },
75
+ [OwnerIDKey]: opts.owner_id,
76
+ }),
76
77
  q,
77
78
  page: opts.page,
78
79
  per_page: opts.per_page,
80
+ signal: opts.signal,
79
81
  });
80
82
  }
81
83
  newLatestChatsCursor(opts) {
@@ -89,9 +91,7 @@ export class ChatFX {
89
91
  async latestChats(opts) {
90
92
  const raw = await runSearch({
91
93
  search: (searchOpts) => this.chat.searchManyChats(searchOpts),
92
- query: {
93
- chat_room_id: opts.chat_room_id,
94
- },
94
+ query: queryParam("chat_room_id", opts.chat_room_id),
95
95
  page: opts.page,
96
96
  per_page: opts.per_page,
97
97
  });
@@ -113,19 +113,16 @@ export class ChatFX {
113
113
  async searchChatRoomMembers(opts) {
114
114
  return await runSearch({
115
115
  search: (searchOpts) => this.chat.searchManyChatRoomMembers(searchOpts),
116
- query: {
117
- chat_room_id: opts.chat_room_id,
118
- },
116
+ query: queryParam("chat_room_id", opts.chat_room_id),
119
117
  q: opts.q,
120
118
  page: opts.page,
121
119
  per_page: opts.per_page,
120
+ signal: opts.signal,
122
121
  });
123
122
  }
124
123
  async chatRoomMembers(opts) {
125
124
  const out = await this.chat.queryChatRoomMembers({
126
- query: {
127
- chat_room_id: opts.chat_room_id,
128
- },
125
+ query: queryParam("chat_room_id", opts.chat_room_id),
129
126
  });
130
127
  return out.value ?? [];
131
128
  }
@@ -135,17 +132,13 @@ export class ChatFX {
135
132
  return [];
136
133
  }
137
134
  const out = await this.chat.queryChatRooms({
138
- query: {
139
- [IDKey]: ids,
140
- },
135
+ query: queryParam(IDKey, ids),
141
136
  });
142
137
  return out.value ?? [];
143
138
  }
144
139
  async myChatRoomMembers(opts) {
145
140
  const out = await this.chat.queryChatRoomMembers({
146
- query: {
147
- owner_id: opts.owner_id,
148
- },
141
+ query: queryParam(OwnerIDKey, opts.owner_id),
149
142
  });
150
143
  return out.value ?? [];
151
144
  }
@@ -1,4 +1,4 @@
1
- import type { ContactsOperator, UsersOperator } from "@fabriktor/client";
1
+ import { type ContactsOperator, type UsersOperator } from "@fabriktor/client";
2
2
  import { Friend, Hired, Manager, Na, OldHire, type Contact, type ID, type OperationResult, type User } from "@fabriktor/schema";
3
3
  type ContactInsertOptions = Parameters<ContactsOperator["insertOneContact"]>[0];
4
4
  type ContactReplaceOptions = Parameters<ContactsOperator["replaceOneContact"]>[0];
@@ -3,6 +3,7 @@
3
3
  // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
4
  // not use this file except in compliance with the License. You may obtain
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ import { queryParam, } from "@fabriktor/client";
6
7
  import { Friend, Hired, IDKey, Na, OldHire, UserTypeEmployee, UserTypeEmployer, } from "@fabriktor/schema";
7
8
  import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
8
9
  import { requiredOperationID } from "../core/id.js";
@@ -250,7 +251,7 @@ export class ContactsFX {
250
251
  }
251
252
  const pages = await Promise.all(chunks(values, employmentUserBatchSize).map((chunk) => runSearch({
252
253
  per_page: chunk.length,
253
- query: { [IDKey]: chunk },
254
+ query: queryParam(IDKey, chunk),
254
255
  search: (searchOpts) => this.users.searchManyUsers({
255
256
  ...searchOpts,
256
257
  uid,
@@ -24,6 +24,7 @@ export declare class SearchController<T extends SearchResultWithID, Options exte
24
24
  replace(selection: Options): Promise<boolean>;
25
25
  loadMore(): Promise<boolean>;
26
26
  retry(): Promise<boolean>;
27
+ updateResult(value: T): void;
27
28
  private load;
28
29
  private emptyState;
29
30
  private publish;
@@ -41,6 +41,16 @@ export class SearchController {
41
41
  async retry() {
42
42
  return await this.load(this.next_page > normalizeSearchPage());
43
43
  }
44
+ // Update a displayed record without changing membership or backend position.
45
+ // Use query replacement when a mutation can affect either of those.
46
+ updateResult(value) {
47
+ if (!this.current.results.some((result) => result.id === value.id))
48
+ return;
49
+ this.publish({
50
+ ...this.current,
51
+ results: this.current.results.map((result) => result.id === value.id ? value : result),
52
+ });
53
+ }
44
54
  async load(append) {
45
55
  if (!this.selection || this.current.loading || this.current.loading_more) {
46
56
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.108",
3
+ "version": "0.0.109",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/client": "0.0.83",
20
+ "@fabriktor/client": "0.0.84",
21
21
  "@fabriktor/fx": "0.0.94",
22
22
  "@fabriktor/schema": "0.0.63"
23
23
  }