@fabriktor/fx 0.0.69 → 0.0.71

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.
@@ -3,10 +3,10 @@
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 { LocationTypePersistent, Pending, Started, OwnerIDKey, Terminated, ZeroID, } from "@fabriktor/schema";
6
+ import { LocationTypePersistent, Pending, Started, Terminated, ZeroID, } from "@fabriktor/schema";
7
7
  import { errRequired, errResolveFailed, errValidation, } from "../core/err.js";
8
8
  import { requiredOperationID, resolvedID } from "../core/id.js";
9
- import { runSearch } from "../core/search.js";
9
+ import { runOwnerSearch, runSearch, } from "../core/search.js";
10
10
  const msgJobIDRequired = "Job ID is required.";
11
11
  const msgLocationIDRequired = "Location ID is required.";
12
12
  const msgMemberIDRequired = "Member ID is required.";
@@ -31,6 +31,8 @@ const msgCreatedJobIDMissing = "Created job response did not contain an ID.";
31
31
  const msgLocationMissing = "Location could not be resolved after the mutation.";
32
32
  const msgJobProgramMissing = "Job program could not be resolved after the mutation.";
33
33
  const msgJobMissing = "Job could not be resolved after the mutation.";
34
+ const msgJobNotActive = "Job must be active before it can be started.";
35
+ const msgJobTerminated = "Terminated jobs cannot be started.";
34
36
  export const JobProgramCreateMode = {
35
37
  Scheduled: "scheduled",
36
38
  Immediate: "immediate",
@@ -47,19 +49,33 @@ export class JobsFX {
47
49
  const id = requiredOperationID(out, msgCreatedLocationIDMissing);
48
50
  return await this.findLocation(id);
49
51
  }
52
+ async createOperationalLocation(opts) {
53
+ const persistent = opts.in.type === LocationTypePersistent;
54
+ return await this.createLocation({
55
+ in: {
56
+ ...opts.in,
57
+ status: persistent ? Started : Pending,
58
+ is_active: persistent,
59
+ auto_start: persistent ? true : opts.in.auto_start,
60
+ all_members: [],
61
+ current_members: normalizeIDs(opts.in.current_members),
62
+ },
63
+ });
64
+ }
50
65
  async replaceLocation(opts) {
51
66
  await this.jobs.replaceOneLocation(opts);
52
67
  return await this.findLocation(opts.id);
53
68
  }
54
69
  async searchLocations(opts) {
55
- return await runSearch({
70
+ return await runOwnerSearch({
71
+ ...opts,
56
72
  search: (searchOpts) => this.jobs.searchManyLocations(searchOpts),
57
- query: {
58
- [OwnerIDKey]: opts.owner_id,
59
- },
60
- q: opts.q,
61
- page: opts.page,
62
- per_page: opts.per_page,
73
+ });
74
+ }
75
+ async searchAccessibleLocations(opts = {}) {
76
+ return await runSearch({
77
+ ...opts,
78
+ search: (searchOpts) => this.jobs.searchMineLocations(searchOpts),
63
79
  });
64
80
  }
65
81
  async replaceJobProgram(opts) {
@@ -67,14 +83,9 @@ export class JobsFX {
67
83
  return await this.findJobProgram(opts.id);
68
84
  }
69
85
  async searchJobPrograms(opts) {
70
- return await runSearch({
86
+ return await runOwnerSearch({
87
+ ...opts,
71
88
  search: (searchOpts) => this.jobs.searchManyJobPrograms(searchOpts),
72
- query: {
73
- [OwnerIDKey]: opts.owner_id,
74
- },
75
- q: opts.q,
76
- page: opts.page,
77
- per_page: opts.per_page,
78
89
  });
79
90
  }
80
91
  async replaceJob(opts) {
@@ -82,14 +93,15 @@ export class JobsFX {
82
93
  return await this.findJob(opts.id);
83
94
  }
84
95
  async searchJobs(opts) {
85
- return await runSearch({
96
+ return await runOwnerSearch({
97
+ ...opts,
86
98
  search: (searchOpts) => this.jobs.searchManyJobs(searchOpts),
87
- query: {
88
- [OwnerIDKey]: opts.owner_id,
89
- },
90
- q: opts.q,
91
- page: opts.page,
92
- per_page: opts.per_page,
99
+ });
100
+ }
101
+ async searchAccessibleJobs(opts = {}) {
102
+ return await runSearch({
103
+ ...opts,
104
+ search: (searchOpts) => this.jobs.searchMineJobs(searchOpts),
93
105
  });
94
106
  }
95
107
  async createJob(opts) {
@@ -279,6 +291,83 @@ export class JobsFX {
279
291
  },
280
292
  });
281
293
  }
294
+ async setJobMembers(opts) {
295
+ const id = requiredID(opts.job.id, "job", msgJobIDRequired);
296
+ const location_id = requiredID(opts.location.id, "location", msgLocationIDRequired);
297
+ if (opts.job.location_id.trim() !== location_id) {
298
+ throw errValidation({
299
+ field: "job",
300
+ msg: msgJobLocationMismatch,
301
+ });
302
+ }
303
+ const foremen = normalizeIDs(opts.foremen);
304
+ const current_members = unionIDs(opts.current_members, foremen);
305
+ validateLocationMembers({
306
+ members: current_members,
307
+ location: opts.location,
308
+ field: "current_members",
309
+ msg: msgJobMembersOutsideLocation,
310
+ });
311
+ return await this.jobs.replaceOneJob({
312
+ id,
313
+ in: {
314
+ current_members,
315
+ foremen,
316
+ },
317
+ });
318
+ }
319
+ jobLifecycleControls(opts) {
320
+ const actor_id = requiredID(opts.actor_id, "actor_id", msgMemberIDRequired);
321
+ const can_manage = opts.job.owner_id === actor_id ||
322
+ normalizeIDs(opts.job.foremen).includes(actor_id);
323
+ const terminated = opts.job.status === Terminated;
324
+ return {
325
+ can_start: can_manage &&
326
+ opts.job.is_active &&
327
+ opts.job.status === Pending &&
328
+ !terminated,
329
+ can_terminate: can_manage && !terminated,
330
+ };
331
+ }
332
+ async startJob(opts) {
333
+ const id = requiredID(opts.job.id, "job", msgJobIDRequired);
334
+ if (opts.job.status === Terminated) {
335
+ throw errValidation({
336
+ field: "job",
337
+ msg: msgJobTerminated,
338
+ });
339
+ }
340
+ if (opts.job.status === Started) {
341
+ return opts.job;
342
+ }
343
+ if (!opts.job.is_active) {
344
+ throw errValidation({
345
+ field: "job",
346
+ msg: msgJobNotActive,
347
+ });
348
+ }
349
+ await this.jobs.replaceOneJob({
350
+ id,
351
+ in: {
352
+ status: Started,
353
+ },
354
+ });
355
+ return await this.findJob(id);
356
+ }
357
+ async terminateJob(opts) {
358
+ const id = requiredID(opts.job.id, "job", msgJobIDRequired);
359
+ if (opts.job.status === Terminated) {
360
+ return opts.job;
361
+ }
362
+ await this.jobs.replaceOneJob({
363
+ id,
364
+ in: {
365
+ status: Terminated,
366
+ is_active: false,
367
+ },
368
+ });
369
+ return await this.findJob(id);
370
+ }
282
371
  async findLocation(id) {
283
372
  const out = await this.jobs.findOneLocation({
284
373
  id,
@@ -1,7 +1,7 @@
1
1
  import type { MarketplaceOperator, OperationResultOf } from "@fabriktor/client";
2
2
  import { type MarketplaceFavorite, type MarketplacePost, type RPMarketplacePull } from "@fabriktor/schema";
3
3
  import { type PullSession, type PullSessionErrorHandler } from "../core/pull.js";
4
- import { type SearchPage } from "../core/search.js";
4
+ import { type OwnerSearchOptions, type SearchPage } from "../core/search.js";
5
5
  type MarketplacePostInsertOptions = Parameters<MarketplaceOperator["insertOneMarketplacePost"]>[0];
6
6
  type MarketplacePostReplaceOptions = Parameters<MarketplaceOperator["replaceOneMarketplacePost"]>[0];
7
7
  type MarketplaceFavoriteInsertOptions = Parameters<MarketplaceOperator["insertOneMarketplaceFavorite"]>[0];
@@ -11,12 +11,7 @@ export type CreateMarketplacePostOptions = MarketplacePostInsertOptions;
11
11
  export type ReplaceMarketplacePostOptions = MarketplacePostReplaceOptions;
12
12
  export type CreateMarketplaceFavoriteOptions = MarketplaceFavoriteInsertOptions;
13
13
  export type ReplaceMarketplaceFavoriteOptions = MarketplaceFavoriteReplaceOptions;
14
- export type SearchMarketplacePostsOptions = {
15
- owner_id: string;
16
- q?: string;
17
- page?: number;
18
- per_page?: number;
19
- };
14
+ export type SearchMarketplacePostsOptions = OwnerSearchOptions;
20
15
  export type SearchMarketplacePostsPage = SearchPage<MarketplacePost>;
21
16
  export type MarketplacePullContext = Pick<MarketplacePullOptions, "pull_type" | "entity_id" | "research" | "research_user_type">;
22
17
  export type MarketplacePullResult = OperationResultOf<RPMarketplacePull>;
@@ -3,11 +3,11 @@
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 { OwnerIDKey, PullTypeBatch, PullTypeKeepAlive, PullTypeResearch, } from "@fabriktor/schema";
6
+ import { PullTypeBatch, PullTypeKeepAlive, PullTypeResearch, } from "@fabriktor/schema";
7
7
  import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
8
8
  import { requiredOperationID } from "../core/id.js";
9
9
  import { newPullSession, } from "../core/pull.js";
10
- import { runSearch } from "../core/search.js";
10
+ import { runOwnerSearch, } from "../core/search.js";
11
11
  const newMarketplaceSessionToken = "";
12
12
  const resourceMarketplaceSessionToken = "marketplace_session_token";
13
13
  const resourceMarketplacePost = "marketplace_post";
@@ -42,14 +42,9 @@ export class MarketplaceFX {
42
42
  return await this.findMarketplacePost(opts.id);
43
43
  }
44
44
  async searchMarketplacePosts(opts) {
45
- return await runSearch({
45
+ return await runOwnerSearch({
46
+ ...opts,
46
47
  search: (searchOpts) => this.marketplace.searchManyMarketplacePosts(searchOpts),
47
- query: {
48
- [OwnerIDKey]: opts.owner_id,
49
- },
50
- q: opts.q,
51
- page: opts.page,
52
- per_page: opts.per_page,
53
48
  });
54
49
  }
55
50
  async createMarketplaceFavorite(opts) {
@@ -1,6 +1,6 @@
1
1
  import type { MemosOperator } from "@fabriktor/client";
2
- import { type Memo, type MemoFolder } from "@fabriktor/schema";
3
- import { type SearchPage } from "../core/search.js";
2
+ import type { Memo, MemoFolder } from "@fabriktor/schema";
3
+ import { type OwnerSearchOptions, type SearchPage } from "../core/search.js";
4
4
  type MemoInsertOptions = Parameters<MemosOperator["insertOneMemo"]>[0];
5
5
  type MemoReplaceOptions = Parameters<MemosOperator["replaceOneMemo"]>[0];
6
6
  type MemoFolderInsertOptions = Parameters<MemosOperator["insertOneMemoFolder"]>[0];
@@ -9,18 +9,8 @@ export type CreateMemoOptions = MemoInsertOptions;
9
9
  export type ReplaceMemoOptions = MemoReplaceOptions;
10
10
  export type CreateMemoFolderOptions = MemoFolderInsertOptions;
11
11
  export type ReplaceMemoFolderOptions = MemoFolderReplaceOptions;
12
- export type SearchMemosOptions = {
13
- owner_id: string;
14
- q?: string;
15
- page?: number;
16
- per_page?: number;
17
- };
18
- export type SearchMemoFoldersOptions = {
19
- owner_id: string;
20
- q?: string;
21
- page?: number;
22
- per_page?: number;
23
- };
12
+ export type SearchMemosOptions = OwnerSearchOptions;
13
+ export type SearchMemoFoldersOptions = OwnerSearchOptions;
24
14
  export type SearchMemosPage = SearchPage<Memo>;
25
15
  export type SearchMemoFoldersPage = SearchPage<MemoFolder>;
26
16
  export interface MemosFXOperator {
@@ -3,10 +3,9 @@
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 { OwnerIDKey } from "@fabriktor/schema";
7
6
  import { errResolveFailed } from "../core/err.js";
8
7
  import { requiredOperationID } from "../core/id.js";
9
- import { runSearch } from "../core/search.js";
8
+ import { runOwnerSearch, } from "../core/search.js";
10
9
  const resourceMemo = "memo";
11
10
  const resourceMemoFolder = "memo_folder";
12
11
  const msgCreatedMemoIDMissing = "Created memo response did not contain an ID.";
@@ -37,25 +36,15 @@ export class MemosFX {
37
36
  return await this.findMemoFolder(opts.id);
38
37
  }
39
38
  async searchMemos(opts) {
40
- return await runSearch({
39
+ return await runOwnerSearch({
40
+ ...opts,
41
41
  search: (searchOpts) => this.memos.searchManyMemos(searchOpts),
42
- query: {
43
- [OwnerIDKey]: opts.owner_id,
44
- },
45
- q: opts.q,
46
- page: opts.page,
47
- per_page: opts.per_page,
48
42
  });
49
43
  }
50
44
  async searchMemoFolders(opts) {
51
- return await runSearch({
45
+ return await runOwnerSearch({
46
+ ...opts,
52
47
  search: (searchOpts) => this.memos.searchManyMemoFolders(searchOpts),
53
- query: {
54
- [OwnerIDKey]: opts.owner_id,
55
- },
56
- q: opts.q,
57
- page: opts.page,
58
- per_page: opts.per_page,
59
48
  });
60
49
  }
61
50
  async findMemo(id) {
@@ -1,6 +1,6 @@
1
1
  import { type CreditLedgerEntry, type Payment, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund } from "@fabriktor/schema";
2
2
  import type { PaymentsOperator } from "@fabriktor/client";
3
- import { type SearchPage } from "../core/search.js";
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];
6
6
  type PaymentFromPublicSessionPayload = Parameters<PaymentsOperator["paymentFromPublicSession"]>[0];
@@ -21,45 +21,39 @@ type PmtPublicSessionInsertOptions = Parameters<PaymentsOperator["insertOnePmtPu
21
21
  type PmtPublicSessionReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtPublicSession"]>[0];
22
22
  type CreditLedgerEntryInsertOptions = Parameters<PaymentsOperator["insertOneCreditLedgerEntry"]>[0];
23
23
  type CreditLedgerEntryReplaceOptions = Parameters<PaymentsOperator["replaceOneCreditLedgerEntry"]>[0];
24
- type SearchPaymentRecordsOptions = {
25
- owner_id: string;
26
- q?: string;
27
- page?: number;
28
- per_page?: number;
29
- };
30
24
  export type CreatePaymentOptions = PaymentInsertOptions;
31
25
  export type ReplacePaymentOptions = PaymentReplaceOptions;
32
- export type SearchPaymentsOptions = SearchPaymentRecordsOptions;
26
+ export type SearchPaymentsOptions = OwnerSearchOptions;
33
27
  export type SearchPaymentsPage = SearchPage<Payment>;
34
28
  export type CreatePmtAccountOptions = PmtAccountInsertOptions;
35
29
  export type ContinuePmtAccountOnboardingOptions = PmtAccountOnboardingOptions;
36
30
  export type ContinuePmtAccountOnboardingResult = string;
37
31
  export type ReplacePmtAccountOptions = PmtAccountReplaceOptions;
38
- export type SearchPmtAccountsOptions = SearchPaymentRecordsOptions;
32
+ export type SearchPmtAccountsOptions = OwnerSearchOptions;
39
33
  export type SearchPmtAccountsPage = SearchPage<PmtAccount>;
40
34
  export type CreatePmtBankAccountOptions = PmtBankAccountInsertOptions;
41
35
  export type ReplacePmtBankAccountOptions = PmtBankAccountReplaceOptions;
42
- export type SearchPmtBankAccountsOptions = SearchPaymentRecordsOptions;
36
+ export type SearchPmtBankAccountsOptions = OwnerSearchOptions;
43
37
  export type SearchPmtBankAccountsPage = SearchPage<PmtBankAccount>;
44
38
  export type CreatePmtCardOptions = PmtCardInsertOptions;
45
39
  export type ReplacePmtCardOptions = PmtCardReplaceOptions;
46
- export type SearchPmtCardsOptions = SearchPaymentRecordsOptions;
40
+ export type SearchPmtCardsOptions = OwnerSearchOptions;
47
41
  export type SearchPmtCardsPage = SearchPage<PmtCard>;
48
42
  export type CreatePmtRefundOptions = PmtRefundInsertOptions;
49
43
  export type ReplacePmtRefundOptions = PmtRefundReplaceOptions;
50
- export type SearchPmtRefundsOptions = SearchPaymentRecordsOptions;
44
+ export type SearchPmtRefundsOptions = OwnerSearchOptions;
51
45
  export type SearchPmtRefundsPage = SearchPage<PmtRefund>;
52
46
  export type CreatePmtCustomerOptions = PmtCustomerInsertOptions;
53
47
  export type ReplacePmtCustomerOptions = PmtCustomerReplaceOptions;
54
- export type SearchPmtCustomersOptions = SearchPaymentRecordsOptions;
48
+ export type SearchPmtCustomersOptions = OwnerSearchOptions;
55
49
  export type SearchPmtCustomersPage = SearchPage<PmtCustomer>;
56
50
  export type CreatePmtPublicSessionOptions = PmtPublicSessionInsertOptions;
57
51
  export type ReplacePmtPublicSessionOptions = PmtPublicSessionReplaceOptions;
58
- export type SearchPmtPublicSessionsOptions = SearchPaymentRecordsOptions;
52
+ export type SearchPmtPublicSessionsOptions = OwnerSearchOptions;
59
53
  export type SearchPmtPublicSessionsPage = SearchPage<PmtPublicSession>;
60
54
  export type CreateCreditLedgerEntryOptions = CreditLedgerEntryInsertOptions;
61
55
  export type ReplaceCreditLedgerEntryOptions = CreditLedgerEntryReplaceOptions;
62
- export type SearchCreditLedgerOptions = SearchPaymentRecordsOptions;
56
+ export type SearchCreditLedgerOptions = OwnerSearchOptions;
63
57
  export type SearchCreditLedgerPage = SearchPage<CreditLedgerEntry>;
64
58
  export declare const PmtAccountAccessStatus: {
65
59
  readonly Missing: "missing";
@@ -3,10 +3,10 @@
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 { CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, OwnerIDKey, ZeroID, } from "@fabriktor/schema";
6
+ import { CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, ZeroID, } from "@fabriktor/schema";
7
7
  import { errResolveFailed, errValidation } from "../core/err.js";
8
8
  import { requiredOperationID, resolvedID } from "../core/id.js";
9
- import { runSearch } from "../core/search.js";
9
+ import { runOwnerSearch, } from "../core/search.js";
10
10
  const publicAmountPattern = /^\d+$/;
11
11
  const resourcePayment = "payment";
12
12
  const resourcePmtAccount = "pmt_account";
@@ -110,14 +110,9 @@ export class PaymentsFX {
110
110
  return await this.findPayment(opts.id);
111
111
  }
112
112
  async searchPayments(opts) {
113
- return await runSearch({
113
+ return await runOwnerSearch({
114
+ ...opts,
114
115
  search: (searchOpts) => this.payments.searchManyPayments(searchOpts),
115
- query: {
116
- [OwnerIDKey]: opts.owner_id,
117
- },
118
- q: opts.q,
119
- page: opts.page,
120
- per_page: opts.per_page,
121
116
  });
122
117
  }
123
118
  async createPmtAccount(opts) {
@@ -150,14 +145,9 @@ export class PaymentsFX {
150
145
  return await this.findPmtAccount(opts.id);
151
146
  }
152
147
  async searchPmtAccounts(opts) {
153
- return await runSearch({
148
+ return await runOwnerSearch({
149
+ ...opts,
154
150
  search: (searchOpts) => this.payments.searchManyPmtAccounts(searchOpts),
155
- query: {
156
- [OwnerIDKey]: opts.owner_id,
157
- },
158
- q: opts.q,
159
- page: opts.page,
160
- per_page: opts.per_page,
161
151
  });
162
152
  }
163
153
  async getPmtAccountAccess(opts) {
@@ -186,14 +176,9 @@ export class PaymentsFX {
186
176
  return await this.findPmtBankAccount(opts.id);
187
177
  }
188
178
  async searchPmtBankAccounts(opts) {
189
- return await runSearch({
179
+ return await runOwnerSearch({
180
+ ...opts,
190
181
  search: (searchOpts) => this.payments.searchManyPmtBankAccounts(searchOpts),
191
- query: {
192
- [OwnerIDKey]: opts.owner_id,
193
- },
194
- q: opts.q,
195
- page: opts.page,
196
- per_page: opts.per_page,
197
182
  });
198
183
  }
199
184
  async createPmtCard(opts) {
@@ -206,14 +191,9 @@ export class PaymentsFX {
206
191
  return await this.findPmtCard(opts.id);
207
192
  }
208
193
  async searchPmtCards(opts) {
209
- return await runSearch({
194
+ return await runOwnerSearch({
195
+ ...opts,
210
196
  search: (searchOpts) => this.payments.searchManyPmtCards(searchOpts),
211
- query: {
212
- [OwnerIDKey]: opts.owner_id,
213
- },
214
- q: opts.q,
215
- page: opts.page,
216
- per_page: opts.per_page,
217
197
  });
218
198
  }
219
199
  async createPmtRefund(opts) {
@@ -226,14 +206,9 @@ export class PaymentsFX {
226
206
  return await this.findPmtRefund(opts.id);
227
207
  }
228
208
  async searchPmtRefunds(opts) {
229
- return await runSearch({
209
+ return await runOwnerSearch({
210
+ ...opts,
230
211
  search: (searchOpts) => this.payments.searchManyPmtRefunds(searchOpts),
231
- query: {
232
- [OwnerIDKey]: opts.owner_id,
233
- },
234
- q: opts.q,
235
- page: opts.page,
236
- per_page: opts.per_page,
237
212
  });
238
213
  }
239
214
  async createPmtCustomer(opts) {
@@ -246,14 +221,9 @@ export class PaymentsFX {
246
221
  return await this.findPmtCustomer(opts.id);
247
222
  }
248
223
  async searchPmtCustomers(opts) {
249
- return await runSearch({
224
+ return await runOwnerSearch({
225
+ ...opts,
250
226
  search: (searchOpts) => this.payments.searchManyPmtCustomers(searchOpts),
251
- query: {
252
- [OwnerIDKey]: opts.owner_id,
253
- },
254
- q: opts.q,
255
- page: opts.page,
256
- per_page: opts.per_page,
257
227
  });
258
228
  }
259
229
  async createPmtPublicSession(opts) {
@@ -266,14 +236,9 @@ export class PaymentsFX {
266
236
  return await this.findPmtPublicSession(opts.id);
267
237
  }
268
238
  async searchPmtPublicSessions(opts) {
269
- return await runSearch({
239
+ return await runOwnerSearch({
240
+ ...opts,
270
241
  search: (searchOpts) => this.payments.searchManyPmtPublicSessions(searchOpts),
271
- query: {
272
- [OwnerIDKey]: opts.owner_id,
273
- },
274
- q: opts.q,
275
- page: opts.page,
276
- per_page: opts.per_page,
277
242
  });
278
243
  }
279
244
  async createCreditLedgerEntry(opts) {
@@ -286,14 +251,9 @@ export class PaymentsFX {
286
251
  return await this.findCreditLedgerEntry(opts.id);
287
252
  }
288
253
  async searchCreditLedger(opts) {
289
- return await runSearch({
254
+ return await runOwnerSearch({
255
+ ...opts,
290
256
  search: (searchOpts) => this.payments.searchManyCreditLedger(searchOpts),
291
- query: {
292
- [OwnerIDKey]: opts.owner_id,
293
- },
294
- q: opts.q,
295
- page: opts.page,
296
- per_page: opts.per_page,
297
257
  });
298
258
  }
299
259
  async purchaseAppleCredits(opts) {
@@ -1,6 +1,6 @@
1
1
  import type { PayrollsOperator } from "@fabriktor/client";
2
- import { type Payable, type Payroll, type PayConfig, type HourBank, type Adjustment, type AdjustmentFolder, type AdjustmentRecord, type AdjustmentAggregate, type EmployeePayConfig, type PayrollProgram } from "@fabriktor/schema";
3
- import { type SearchPage } from "../core/search.js";
2
+ import type { Payable, Payroll, PayConfig, HourBank, Adjustment, AdjustmentFolder, AdjustmentRecord, AdjustmentAggregate, EmployeePayConfig, PayrollProgram } from "@fabriktor/schema";
3
+ import { type OwnerSearchOptions, type SearchPage } from "../core/search.js";
4
4
  type PayableInsertOptions = Parameters<PayrollsOperator["insertOnePayable"]>[0];
5
5
  type PayableReplaceOptions = Parameters<PayrollsOperator["replaceOnePayable"]>[0];
6
6
  type PayrollInsertOptions = Parameters<PayrollsOperator["insertOnePayroll"]>[0];
@@ -21,51 +21,45 @@ type EmployeePayConfigInsertOptions = Parameters<PayrollsOperator["insertOneEmpl
21
21
  type EmployeePayConfigReplaceOptions = Parameters<PayrollsOperator["replaceOneEmployeePayConfig"]>[0];
22
22
  type PayrollProgramInsertOptions = Parameters<PayrollsOperator["insertOnePayrollProgram"]>[0];
23
23
  type PayrollProgramReplaceOptions = Parameters<PayrollsOperator["replaceOnePayrollProgram"]>[0];
24
- type SearchPayrollRecordsOptions = {
25
- owner_id: string;
26
- q?: string;
27
- page?: number;
28
- per_page?: number;
29
- };
30
24
  export type CreatePayableOptions = PayableInsertOptions;
31
25
  export type ReplacePayableOptions = PayableReplaceOptions;
32
- export type SearchPayablesOptions = SearchPayrollRecordsOptions;
26
+ export type SearchPayablesOptions = OwnerSearchOptions;
33
27
  export type SearchPayablesPage = SearchPage<Payable>;
34
28
  export type CreatePayrollOptions = PayrollInsertOptions;
35
29
  export type ReplacePayrollOptions = PayrollReplaceOptions;
36
- export type SearchPayrollsOptions = SearchPayrollRecordsOptions;
30
+ export type SearchPayrollsOptions = OwnerSearchOptions;
37
31
  export type SearchPayrollsPage = SearchPage<Payroll>;
38
32
  export type CreatePayConfigOptions = PayConfigInsertOptions;
39
33
  export type ReplacePayConfigOptions = PayConfigReplaceOptions;
40
- export type SearchPayConfigsOptions = SearchPayrollRecordsOptions;
34
+ export type SearchPayConfigsOptions = OwnerSearchOptions;
41
35
  export type SearchPayConfigsPage = SearchPage<PayConfig>;
42
36
  export type CreateHourBankOptions = HourBankInsertOptions;
43
37
  export type ReplaceHourBankOptions = HourBankReplaceOptions;
44
- export type SearchHourBanksOptions = SearchPayrollRecordsOptions;
38
+ export type SearchHourBanksOptions = OwnerSearchOptions;
45
39
  export type SearchHourBanksPage = SearchPage<HourBank>;
46
40
  export type CreateAdjustmentOptions = AdjustmentInsertOptions;
47
41
  export type ReplaceAdjustmentOptions = AdjustmentReplaceOptions;
48
- export type SearchAdjustmentsOptions = SearchPayrollRecordsOptions;
42
+ export type SearchAdjustmentsOptions = OwnerSearchOptions;
49
43
  export type SearchAdjustmentsPage = SearchPage<Adjustment>;
50
44
  export type CreateAdjustmentFolderOptions = AdjustmentFolderInsertOptions;
51
45
  export type ReplaceAdjustmentFolderOptions = AdjustmentFolderReplaceOptions;
52
- export type SearchAdjustmentFoldersOptions = SearchPayrollRecordsOptions;
46
+ export type SearchAdjustmentFoldersOptions = OwnerSearchOptions;
53
47
  export type SearchAdjustmentFoldersPage = SearchPage<AdjustmentFolder>;
54
48
  export type CreateAdjustmentRecordOptions = AdjustmentRecordInsertOptions;
55
49
  export type ReplaceAdjustmentRecordOptions = AdjustmentRecordReplaceOptions;
56
- export type SearchAdjustmentRecordsOptions = SearchPayrollRecordsOptions;
50
+ export type SearchAdjustmentRecordsOptions = OwnerSearchOptions;
57
51
  export type SearchAdjustmentRecordsPage = SearchPage<AdjustmentRecord>;
58
52
  export type CreateAdjustmentAggregateOptions = AdjustmentAggregateInsertOptions;
59
53
  export type ReplaceAdjustmentAggregateOptions = AdjustmentAggregateReplaceOptions;
60
- export type SearchAdjustmentAggregatesOptions = SearchPayrollRecordsOptions;
54
+ export type SearchAdjustmentAggregatesOptions = OwnerSearchOptions;
61
55
  export type SearchAdjustmentAggregatesPage = SearchPage<AdjustmentAggregate>;
62
56
  export type CreateEmployeePayConfigOptions = EmployeePayConfigInsertOptions;
63
57
  export type ReplaceEmployeePayConfigOptions = EmployeePayConfigReplaceOptions;
64
- export type SearchEmployeePayConfigsOptions = SearchPayrollRecordsOptions;
58
+ export type SearchEmployeePayConfigsOptions = OwnerSearchOptions;
65
59
  export type SearchEmployeePayConfigsPage = SearchPage<EmployeePayConfig>;
66
60
  export type CreatePayrollProgramOptions = PayrollProgramInsertOptions;
67
61
  export type ReplacePayrollProgramOptions = PayrollProgramReplaceOptions;
68
- export type SearchPayrollProgramsOptions = SearchPayrollRecordsOptions;
62
+ export type SearchPayrollProgramsOptions = OwnerSearchOptions;
69
63
  export type SearchPayrollProgramsPage = SearchPage<PayrollProgram>;
70
64
  export type SetAdjustmentArchivedOptions = {
71
65
  id: AdjustmentReplaceOptions["id"];