@fabriktor/fx 0.0.106 → 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.
- package/dist/src/chat/chat.d.ts +2 -2
- package/dist/src/chat/chat.js +12 -19
- package/dist/src/contacts/contacts.d.ts +1 -1
- package/dist/src/contacts/contacts.js +2 -1
- package/dist/src/core/search-controller.d.ts +1 -0
- package/dist/src/core/search-controller.js +10 -0
- package/dist/src/payments/payments.d.ts +3 -2
- package/dist/src/payments/payments.js +6 -0
- package/package.json +2 -2
package/dist/src/chat/chat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
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;
|
package/dist/src/chat/chat.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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
|
|
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:
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CreditLedgerEntry, type Payment, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund } from "@fabriktor/schema";
|
|
2
|
-
import type
|
|
2
|
+
import { type PaymentsOperator } from "@fabriktor/client";
|
|
3
3
|
import { type OwnerSearchOptions, type SearchPage } from "../core/search.js";
|
|
4
4
|
type PurchaseCreditsPayload = Parameters<PaymentsOperator["purchaseCredits"]>[0];
|
|
5
5
|
type OpenPublicSessionPayload = Parameters<PaymentsOperator["openPmtPublicSession"]>[0];
|
|
@@ -33,7 +33,7 @@ export type SearchPmtAccountsOptions = OwnerSearchOptions;
|
|
|
33
33
|
export type SearchPmtAccountsPage = SearchPage<PmtAccount>;
|
|
34
34
|
export type CreatePmtBankAccountOptions = PmtBankAccountInsertOptions;
|
|
35
35
|
export type ReplacePmtBankAccountOptions = PmtBankAccountReplaceOptions;
|
|
36
|
-
export type SearchPmtBankAccountsOptions = OwnerSearchOptions
|
|
36
|
+
export type SearchPmtBankAccountsOptions = OwnerSearchOptions & Partial<Pick<PmtBankAccount, "psp_account_psp_id">>;
|
|
37
37
|
export type SearchPmtBankAccountsPage = SearchPage<PmtBankAccount>;
|
|
38
38
|
export type CreatePmtCardOptions = PmtCardInsertOptions;
|
|
39
39
|
export type ReplacePmtCardOptions = PmtCardReplaceOptions;
|
|
@@ -69,6 +69,7 @@ export type PmtAccountAccess = {
|
|
|
69
69
|
};
|
|
70
70
|
export type GetPmtAccountAccessOptions = {
|
|
71
71
|
owner_id: string;
|
|
72
|
+
signal?: AbortSignal;
|
|
72
73
|
};
|
|
73
74
|
export declare function isPmtAccountReady(account: PmtAccount | null): boolean;
|
|
74
75
|
export declare function currentPmtAccount(accounts: readonly PmtAccount[]): PmtAccount | null;
|
|
@@ -4,6 +4,7 @@
|
|
|
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
6
|
import { CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, ZeroID, } from "@fabriktor/schema";
|
|
7
|
+
import { queryParams } from "@fabriktor/client";
|
|
7
8
|
import { errResolveFailed, errValidation } from "../core/err.js";
|
|
8
9
|
import { requiredOperationID, resolvedID } from "../core/id.js";
|
|
9
10
|
import { runOwnerSearch, } from "../core/search.js";
|
|
@@ -154,9 +155,11 @@ export class PaymentsFX {
|
|
|
154
155
|
const accounts = [];
|
|
155
156
|
let page = 1;
|
|
156
157
|
while (true) {
|
|
158
|
+
opts.signal?.throwIfAborted();
|
|
157
159
|
const out = await this.searchPmtAccounts({
|
|
158
160
|
owner_id: opts.owner_id,
|
|
159
161
|
page,
|
|
162
|
+
signal: opts.signal,
|
|
160
163
|
});
|
|
161
164
|
accounts.push(...out.results);
|
|
162
165
|
const account = currentPmtAccount(accounts);
|
|
@@ -178,6 +181,9 @@ export class PaymentsFX {
|
|
|
178
181
|
async searchPmtBankAccounts(opts) {
|
|
179
182
|
return await runOwnerSearch({
|
|
180
183
|
...opts,
|
|
184
|
+
query: queryParams({
|
|
185
|
+
psp_account_psp_id: resolvedID(opts.psp_account_psp_id),
|
|
186
|
+
}),
|
|
181
187
|
search: (searchOpts) => this.payments.searchManyPmtBankAccounts(searchOpts),
|
|
182
188
|
});
|
|
183
189
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabriktor/fx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.109",
|
|
4
4
|
"description": "",
|
|
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.
|
|
20
|
+
"@fabriktor/client": "0.0.84",
|
|
21
21
|
"@fabriktor/fx": "0.0.94",
|
|
22
22
|
"@fabriktor/schema": "0.0.63"
|
|
23
23
|
}
|