@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.
- package/dist/src/billable/billable.d.ts +14 -20
- package/dist/src/billable/billable.js +25 -86
- package/dist/src/chat/chat.d.ts +4 -13
- package/dist/src/core/search.d.ts +19 -4
- package/dist/src/core/search.js +11 -1
- package/dist/src/feed/feed.d.ts +2 -6
- package/dist/src/feed/feed.js +1 -1
- package/dist/src/fulfillments/fulfillments.d.ts +3 -8
- package/dist/src/fulfillments/fulfillments.js +3 -9
- package/dist/src/jobs/jobs.d.ts +40 -10
- package/dist/src/jobs/jobs.js +112 -23
- package/dist/src/marketplace/marketplace.d.ts +2 -7
- package/dist/src/marketplace/marketplace.js +4 -9
- package/dist/src/memos/memos.d.ts +4 -14
- package/dist/src/memos/memos.js +5 -16
- package/dist/src/payments/payments.d.ts +9 -15
- package/dist/src/payments/payments.js +18 -58
- package/dist/src/payrolls/payrolls.d.ts +12 -18
- package/dist/src/payrolls/payrolls.js +21 -72
- package/dist/src/routes/routes.d.ts +4 -10
- package/dist/src/routes/routes.js +5 -16
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BillableOperator, OperationResultOf } from "@fabriktor/client";
|
|
2
|
-
import {
|
|
3
|
-
import { type SearchPage } from "../core/search.js";
|
|
2
|
+
import type { OperationResult, RPBillablePeriodsFromDates, YearSpan, Bill, BillableFolder, Charge, Equipment, Item, LaborRate, MeterReading, Quantifier, Tax, TmpBillNumber, VendorInvoice, Warehouse } from "@fabriktor/schema";
|
|
3
|
+
import { type OwnerSearchOptions, type SearchPage } from "../core/search.js";
|
|
4
4
|
type GenerateBillPayload = Parameters<BillableOperator["generateBill"]>[0];
|
|
5
5
|
type BillInsertOptions = Parameters<BillableOperator["insertOneBill"]>[0];
|
|
6
6
|
type BillReplaceOptions = Parameters<BillableOperator["replaceOneBill"]>[0];
|
|
@@ -26,59 +26,53 @@ type VendorInvoiceInsertOptions = Parameters<BillableOperator["insertOneVendorIn
|
|
|
26
26
|
type VendorInvoiceReplaceOptions = Parameters<BillableOperator["replaceOneVendorInvoice"]>[0];
|
|
27
27
|
type WarehouseInsertOptions = Parameters<BillableOperator["insertOneWarehouse"]>[0];
|
|
28
28
|
type WarehouseReplaceOptions = Parameters<BillableOperator["replaceOneWarehouse"]>[0];
|
|
29
|
-
type SearchBillableOptions = {
|
|
30
|
-
owner_id: string;
|
|
31
|
-
q?: string;
|
|
32
|
-
page?: number;
|
|
33
|
-
per_page?: number;
|
|
34
|
-
};
|
|
35
29
|
export type CreateBillOptions = BillInsertOptions;
|
|
36
30
|
export type ReplaceBillOptions = BillReplaceOptions;
|
|
37
|
-
export type SearchBillsOptions =
|
|
31
|
+
export type SearchBillsOptions = OwnerSearchOptions;
|
|
38
32
|
export type SearchBillsPage = SearchPage<Bill>;
|
|
39
33
|
export type CreateBillableFolderOptions = BillableFolderInsertOptions;
|
|
40
34
|
export type ReplaceBillableFolderOptions = BillableFolderReplaceOptions;
|
|
41
|
-
export type SearchBillableFoldersOptions =
|
|
35
|
+
export type SearchBillableFoldersOptions = OwnerSearchOptions;
|
|
42
36
|
export type SearchBillableFoldersPage = SearchPage<BillableFolder>;
|
|
43
37
|
export type CreateChargeOptions = ChargeInsertOptions;
|
|
44
38
|
export type ReplaceChargeOptions = ChargeReplaceOptions;
|
|
45
|
-
export type SearchChargesOptions =
|
|
39
|
+
export type SearchChargesOptions = OwnerSearchOptions;
|
|
46
40
|
export type SearchChargesPage = SearchPage<Charge>;
|
|
47
41
|
export type CreateEquipmentOptions = EquipmentInsertOptions;
|
|
48
42
|
export type ReplaceEquipmentOptions = EquipmentReplaceOptions;
|
|
49
|
-
export type SearchEquipmentsOptions =
|
|
43
|
+
export type SearchEquipmentsOptions = OwnerSearchOptions;
|
|
50
44
|
export type SearchEquipmentsPage = SearchPage<Equipment>;
|
|
51
45
|
export type CreateItemOptions = ItemInsertOptions;
|
|
52
46
|
export type ReplaceItemOptions = ItemReplaceOptions;
|
|
53
|
-
export type SearchItemsOptions =
|
|
47
|
+
export type SearchItemsOptions = OwnerSearchOptions;
|
|
54
48
|
export type SearchItemsPage = SearchPage<Item>;
|
|
55
49
|
export type CreateLaborRateOptions = LaborRateInsertOptions;
|
|
56
50
|
export type ReplaceLaborRateOptions = LaborRateReplaceOptions;
|
|
57
|
-
export type SearchLaborRatesOptions =
|
|
51
|
+
export type SearchLaborRatesOptions = OwnerSearchOptions;
|
|
58
52
|
export type SearchLaborRatesPage = SearchPage<LaborRate>;
|
|
59
53
|
export type CreateMeterReadingOptions = MeterReadingInsertOptions;
|
|
60
54
|
export type ReplaceMeterReadingOptions = MeterReadingReplaceOptions;
|
|
61
|
-
export type SearchMeterReadingsOptions =
|
|
55
|
+
export type SearchMeterReadingsOptions = OwnerSearchOptions;
|
|
62
56
|
export type SearchMeterReadingsPage = SearchPage<MeterReading>;
|
|
63
57
|
export type CreateQuantifierOptions = QuantifierInsertOptions;
|
|
64
58
|
export type ReplaceQuantifierOptions = QuantifierReplaceOptions;
|
|
65
|
-
export type SearchQuantifiersOptions =
|
|
59
|
+
export type SearchQuantifiersOptions = OwnerSearchOptions;
|
|
66
60
|
export type SearchQuantifiersPage = SearchPage<Quantifier>;
|
|
67
61
|
export type CreateTaxOptions = TaxInsertOptions;
|
|
68
62
|
export type ReplaceTaxOptions = TaxReplaceOptions;
|
|
69
|
-
export type SearchTaxesOptions =
|
|
63
|
+
export type SearchTaxesOptions = OwnerSearchOptions;
|
|
70
64
|
export type SearchTaxesPage = SearchPage<Tax>;
|
|
71
65
|
export type CreateTmpBillNumberOptions = TmpBillNumberInsertOptions;
|
|
72
66
|
export type ReplaceTmpBillNumberOptions = TmpBillNumberReplaceOptions;
|
|
73
|
-
export type SearchTmpBillNumbersOptions =
|
|
67
|
+
export type SearchTmpBillNumbersOptions = OwnerSearchOptions;
|
|
74
68
|
export type SearchTmpBillNumbersPage = SearchPage<TmpBillNumber>;
|
|
75
69
|
export type CreateVendorInvoiceOptions = VendorInvoiceInsertOptions;
|
|
76
70
|
export type ReplaceVendorInvoiceOptions = VendorInvoiceReplaceOptions;
|
|
77
|
-
export type SearchVendorInvoicesOptions =
|
|
71
|
+
export type SearchVendorInvoicesOptions = OwnerSearchOptions;
|
|
78
72
|
export type SearchVendorInvoicesPage = SearchPage<VendorInvoice>;
|
|
79
73
|
export type CreateWarehouseOptions = WarehouseInsertOptions;
|
|
80
74
|
export type ReplaceWarehouseOptions = WarehouseReplaceOptions;
|
|
81
|
-
export type SearchWarehousesOptions =
|
|
75
|
+
export type SearchWarehousesOptions = OwnerSearchOptions;
|
|
82
76
|
export type SearchWarehousesPage = SearchPage<Warehouse>;
|
|
83
77
|
export type BillableFXOptions = {
|
|
84
78
|
billable: BillableOperator;
|
|
@@ -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 {
|
|
8
|
+
import { runOwnerSearch, } from "../core/search.js";
|
|
10
9
|
const billTypeFixed = "fixed";
|
|
11
10
|
const billTypeDynamic = "dynamic";
|
|
12
11
|
const resourceBill = "bill";
|
|
@@ -60,14 +59,9 @@ export class BillableFX {
|
|
|
60
59
|
return await this.findBill(opts.id);
|
|
61
60
|
}
|
|
62
61
|
async searchBills(opts) {
|
|
63
|
-
return await
|
|
62
|
+
return await runOwnerSearch({
|
|
63
|
+
...opts,
|
|
64
64
|
search: (searchOpts) => this.billable.searchManyBills(searchOpts),
|
|
65
|
-
query: {
|
|
66
|
-
[OwnerIDKey]: opts.owner_id,
|
|
67
|
-
},
|
|
68
|
-
q: opts.q,
|
|
69
|
-
page: opts.page,
|
|
70
|
-
per_page: opts.per_page,
|
|
71
65
|
});
|
|
72
66
|
}
|
|
73
67
|
async createBillableFolder(opts) {
|
|
@@ -80,14 +74,9 @@ export class BillableFX {
|
|
|
80
74
|
return await this.findBillableFolder(opts.id);
|
|
81
75
|
}
|
|
82
76
|
async searchBillableFolders(opts) {
|
|
83
|
-
return await
|
|
77
|
+
return await runOwnerSearch({
|
|
78
|
+
...opts,
|
|
84
79
|
search: (searchOpts) => this.billable.searchManyBillableFolders(searchOpts),
|
|
85
|
-
query: {
|
|
86
|
-
[OwnerIDKey]: opts.owner_id,
|
|
87
|
-
},
|
|
88
|
-
q: opts.q,
|
|
89
|
-
page: opts.page,
|
|
90
|
-
per_page: opts.per_page,
|
|
91
80
|
});
|
|
92
81
|
}
|
|
93
82
|
async createCharge(opts) {
|
|
@@ -100,14 +89,9 @@ export class BillableFX {
|
|
|
100
89
|
return await this.findCharge(opts.id);
|
|
101
90
|
}
|
|
102
91
|
async searchCharges(opts) {
|
|
103
|
-
return await
|
|
92
|
+
return await runOwnerSearch({
|
|
93
|
+
...opts,
|
|
104
94
|
search: (searchOpts) => this.billable.searchManyCharges(searchOpts),
|
|
105
|
-
query: {
|
|
106
|
-
[OwnerIDKey]: opts.owner_id,
|
|
107
|
-
},
|
|
108
|
-
q: opts.q,
|
|
109
|
-
page: opts.page,
|
|
110
|
-
per_page: opts.per_page,
|
|
111
95
|
});
|
|
112
96
|
}
|
|
113
97
|
async createEquipment(opts) {
|
|
@@ -120,14 +104,9 @@ export class BillableFX {
|
|
|
120
104
|
return await this.findEquipment(opts.id);
|
|
121
105
|
}
|
|
122
106
|
async searchEquipments(opts) {
|
|
123
|
-
return await
|
|
107
|
+
return await runOwnerSearch({
|
|
108
|
+
...opts,
|
|
124
109
|
search: (searchOpts) => this.billable.searchManyEquipments(searchOpts),
|
|
125
|
-
query: {
|
|
126
|
-
[OwnerIDKey]: opts.owner_id,
|
|
127
|
-
},
|
|
128
|
-
q: opts.q,
|
|
129
|
-
page: opts.page,
|
|
130
|
-
per_page: opts.per_page,
|
|
131
110
|
});
|
|
132
111
|
}
|
|
133
112
|
async createItem(opts) {
|
|
@@ -140,14 +119,9 @@ export class BillableFX {
|
|
|
140
119
|
return await this.findItem(opts.id);
|
|
141
120
|
}
|
|
142
121
|
async searchItems(opts) {
|
|
143
|
-
return await
|
|
122
|
+
return await runOwnerSearch({
|
|
123
|
+
...opts,
|
|
144
124
|
search: (searchOpts) => this.billable.searchManyItems(searchOpts),
|
|
145
|
-
query: {
|
|
146
|
-
[OwnerIDKey]: opts.owner_id,
|
|
147
|
-
},
|
|
148
|
-
q: opts.q,
|
|
149
|
-
page: opts.page,
|
|
150
|
-
per_page: opts.per_page,
|
|
151
125
|
});
|
|
152
126
|
}
|
|
153
127
|
async createLaborRate(opts) {
|
|
@@ -160,14 +134,9 @@ export class BillableFX {
|
|
|
160
134
|
return await this.findLaborRate(opts.id);
|
|
161
135
|
}
|
|
162
136
|
async searchLaborRates(opts) {
|
|
163
|
-
return await
|
|
137
|
+
return await runOwnerSearch({
|
|
138
|
+
...opts,
|
|
164
139
|
search: (searchOpts) => this.billable.searchManyLaborRates(searchOpts),
|
|
165
|
-
query: {
|
|
166
|
-
[OwnerIDKey]: opts.owner_id,
|
|
167
|
-
},
|
|
168
|
-
q: opts.q,
|
|
169
|
-
page: opts.page,
|
|
170
|
-
per_page: opts.per_page,
|
|
171
140
|
});
|
|
172
141
|
}
|
|
173
142
|
async createMeterReading(opts) {
|
|
@@ -180,14 +149,9 @@ export class BillableFX {
|
|
|
180
149
|
return await this.findMeterReading(opts.id);
|
|
181
150
|
}
|
|
182
151
|
async searchMeterReadings(opts) {
|
|
183
|
-
return await
|
|
152
|
+
return await runOwnerSearch({
|
|
153
|
+
...opts,
|
|
184
154
|
search: (searchOpts) => this.billable.searchManyMeterReadings(searchOpts),
|
|
185
|
-
query: {
|
|
186
|
-
[OwnerIDKey]: opts.owner_id,
|
|
187
|
-
},
|
|
188
|
-
q: opts.q,
|
|
189
|
-
page: opts.page,
|
|
190
|
-
per_page: opts.per_page,
|
|
191
155
|
});
|
|
192
156
|
}
|
|
193
157
|
async createQuantifier(opts) {
|
|
@@ -200,14 +164,9 @@ export class BillableFX {
|
|
|
200
164
|
return await this.findQuantifier(opts.id);
|
|
201
165
|
}
|
|
202
166
|
async searchQuantifiers(opts) {
|
|
203
|
-
return await
|
|
167
|
+
return await runOwnerSearch({
|
|
168
|
+
...opts,
|
|
204
169
|
search: (searchOpts) => this.billable.searchManyQuantifiers(searchOpts),
|
|
205
|
-
query: {
|
|
206
|
-
[OwnerIDKey]: opts.owner_id,
|
|
207
|
-
},
|
|
208
|
-
q: opts.q,
|
|
209
|
-
page: opts.page,
|
|
210
|
-
per_page: opts.per_page,
|
|
211
170
|
});
|
|
212
171
|
}
|
|
213
172
|
async createTax(opts) {
|
|
@@ -220,14 +179,9 @@ export class BillableFX {
|
|
|
220
179
|
return await this.findTax(opts.id);
|
|
221
180
|
}
|
|
222
181
|
async searchTaxes(opts) {
|
|
223
|
-
return await
|
|
182
|
+
return await runOwnerSearch({
|
|
183
|
+
...opts,
|
|
224
184
|
search: (searchOpts) => this.billable.searchManyTaxes(searchOpts),
|
|
225
|
-
query: {
|
|
226
|
-
[OwnerIDKey]: opts.owner_id,
|
|
227
|
-
},
|
|
228
|
-
q: opts.q,
|
|
229
|
-
page: opts.page,
|
|
230
|
-
per_page: opts.per_page,
|
|
231
185
|
});
|
|
232
186
|
}
|
|
233
187
|
async createTmpBillNumber(opts) {
|
|
@@ -240,14 +194,9 @@ export class BillableFX {
|
|
|
240
194
|
return await this.findTmpBillNumber(opts.id);
|
|
241
195
|
}
|
|
242
196
|
async searchTmpBillNumbers(opts) {
|
|
243
|
-
return await
|
|
197
|
+
return await runOwnerSearch({
|
|
198
|
+
...opts,
|
|
244
199
|
search: (searchOpts) => this.billable.searchManyTmpBillNumbers(searchOpts),
|
|
245
|
-
query: {
|
|
246
|
-
[OwnerIDKey]: opts.owner_id,
|
|
247
|
-
},
|
|
248
|
-
q: opts.q,
|
|
249
|
-
page: opts.page,
|
|
250
|
-
per_page: opts.per_page,
|
|
251
200
|
});
|
|
252
201
|
}
|
|
253
202
|
async createVendorInvoice(opts) {
|
|
@@ -260,14 +209,9 @@ export class BillableFX {
|
|
|
260
209
|
return await this.findVendorInvoice(opts.id);
|
|
261
210
|
}
|
|
262
211
|
async searchVendorInvoices(opts) {
|
|
263
|
-
return await
|
|
212
|
+
return await runOwnerSearch({
|
|
213
|
+
...opts,
|
|
264
214
|
search: (searchOpts) => this.billable.searchManyVendorInvoices(searchOpts),
|
|
265
|
-
query: {
|
|
266
|
-
[OwnerIDKey]: opts.owner_id,
|
|
267
|
-
},
|
|
268
|
-
q: opts.q,
|
|
269
|
-
page: opts.page,
|
|
270
|
-
per_page: opts.per_page,
|
|
271
215
|
});
|
|
272
216
|
}
|
|
273
217
|
async createWarehouse(opts) {
|
|
@@ -280,14 +224,9 @@ export class BillableFX {
|
|
|
280
224
|
return await this.findWarehouse(opts.id);
|
|
281
225
|
}
|
|
282
226
|
async searchWarehouses(opts) {
|
|
283
|
-
return await
|
|
227
|
+
return await runOwnerSearch({
|
|
228
|
+
...opts,
|
|
284
229
|
search: (searchOpts) => this.billable.searchManyWarehouses(searchOpts),
|
|
285
|
-
query: {
|
|
286
|
-
[OwnerIDKey]: opts.owner_id,
|
|
287
|
-
},
|
|
288
|
-
q: opts.q,
|
|
289
|
-
page: opts.page,
|
|
290
|
-
per_page: opts.per_page,
|
|
291
230
|
});
|
|
292
231
|
}
|
|
293
232
|
async generateFixedEstimate(opts) {
|
package/dist/src/chat/chat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChatOperator, UsersOperator, WSCloseHandler, WSConnection, WSErrorHandler, WSMessageHandler } from "@fabriktor/client";
|
|
2
2
|
import { type Chat, type ChatRoom, type ChatRoomMember, type User } from "@fabriktor/schema";
|
|
3
|
-
import { type SearchPage } from "../core/search.js";
|
|
3
|
+
import { type RequiredSearchOptions, type SearchOptions, type SearchPage, type SearchPaginationOptions } from "../core/search.js";
|
|
4
4
|
type ChatInsertOptions = Parameters<ChatOperator["insertOneChat"]>[0];
|
|
5
5
|
type ChatReplaceOptions = Parameters<ChatOperator["replaceOneChat"]>[0];
|
|
6
6
|
export type CreateChatOptions = ChatInsertOptions;
|
|
@@ -23,16 +23,10 @@ type SearchChatsScope = {
|
|
|
23
23
|
chat_room_id?: string;
|
|
24
24
|
owner_id: string;
|
|
25
25
|
};
|
|
26
|
-
export type SearchChatsOptions = SearchChatsScope &
|
|
27
|
-
q: string;
|
|
28
|
-
page?: number;
|
|
29
|
-
per_page?: number;
|
|
30
|
-
};
|
|
26
|
+
export type SearchChatsOptions = SearchChatsScope & RequiredSearchOptions;
|
|
31
27
|
export type SearchChatsPage = SearchPage<Chat>;
|
|
32
|
-
export type LatestChatsOptions = {
|
|
28
|
+
export type LatestChatsOptions = SearchPaginationOptions & {
|
|
33
29
|
chat_room_id: string;
|
|
34
|
-
page?: number;
|
|
35
|
-
per_page?: number;
|
|
36
30
|
};
|
|
37
31
|
export type LatestChatsCursor = {
|
|
38
32
|
chat_room_id: string;
|
|
@@ -52,11 +46,8 @@ export type LatestChatsPage = {
|
|
|
52
46
|
has_more: boolean;
|
|
53
47
|
next_cursor: LatestChatsCursor;
|
|
54
48
|
};
|
|
55
|
-
export type SearchChatRoomMembersOptions = {
|
|
49
|
+
export type SearchChatRoomMembersOptions = SearchOptions & {
|
|
56
50
|
chat_room_id: string;
|
|
57
|
-
q?: string;
|
|
58
|
-
page?: number;
|
|
59
|
-
per_page?: number;
|
|
60
51
|
};
|
|
61
52
|
export type SearchChatRoomMembersPage = SearchPage<ChatRoomMember>;
|
|
62
53
|
export type ChatRoomMembersOptions = {
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import type { OperationResultOf, SearchManyOptionsCRUD, SearchResultOf } from "@fabriktor/client";
|
|
2
2
|
export type SearchQuery = NonNullable<SearchManyOptionsCRUD["query"]>;
|
|
3
|
+
export type SearchPaginationOptions = {
|
|
4
|
+
page?: number;
|
|
5
|
+
per_page?: number;
|
|
6
|
+
};
|
|
7
|
+
export type SearchOptions = SearchPaginationOptions & {
|
|
8
|
+
q?: string;
|
|
9
|
+
};
|
|
10
|
+
export type RequiredSearchOptions = SearchPaginationOptions & {
|
|
11
|
+
q: string;
|
|
12
|
+
};
|
|
13
|
+
export type OwnerSearchOptions = SearchOptions & {
|
|
14
|
+
owner_id: string;
|
|
15
|
+
};
|
|
3
16
|
export type SearchCall<T> = (opts: SearchManyOptionsCRUD) => Promise<OperationResultOf<SearchResultOf<T>>>;
|
|
4
|
-
export type RunSearchOptions<T> = {
|
|
17
|
+
export type RunSearchOptions<T> = SearchOptions & {
|
|
18
|
+
search: SearchCall<T>;
|
|
19
|
+
query?: SearchQuery;
|
|
20
|
+
};
|
|
21
|
+
export type RunOwnerSearchOptions<T> = OwnerSearchOptions & {
|
|
5
22
|
search: SearchCall<T>;
|
|
6
23
|
query?: SearchQuery;
|
|
7
|
-
q?: string;
|
|
8
|
-
page?: number;
|
|
9
|
-
per_page?: number;
|
|
10
24
|
};
|
|
11
25
|
export type SearchPage<T> = {
|
|
12
26
|
results: T[];
|
|
@@ -18,6 +32,7 @@ export type SearchPage<T> = {
|
|
|
18
32
|
next_page: number;
|
|
19
33
|
done: boolean;
|
|
20
34
|
};
|
|
35
|
+
export declare function runOwnerSearch<T>(opts: RunOwnerSearchOptions<T>): Promise<SearchPage<T>>;
|
|
21
36
|
export declare function runSearch<T>(opts: RunSearchOptions<T>): Promise<SearchPage<T>>;
|
|
22
37
|
export declare function normalizeSearchPage(value?: number): number;
|
|
23
38
|
export declare function normalizeSearchPerPage(value?: number): number;
|
package/dist/src/core/search.js
CHANGED
|
@@ -3,9 +3,19 @@
|
|
|
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 { SearchPageKey, SearchPerPageKey, SearchQueryKey, SearchResultResultsKey, } from "@fabriktor/schema";
|
|
6
|
+
import { OwnerIDKey, SearchPageKey, SearchPerPageKey, SearchQueryKey, SearchResultResultsKey, } from "@fabriktor/schema";
|
|
7
7
|
const firstSearchPage = 1;
|
|
8
8
|
const defaultSearchPerPage = 30;
|
|
9
|
+
export async function runOwnerSearch(opts) {
|
|
10
|
+
const { owner_id, query, ...searchOpts } = opts;
|
|
11
|
+
return await runSearch({
|
|
12
|
+
...searchOpts,
|
|
13
|
+
query: {
|
|
14
|
+
...query,
|
|
15
|
+
[OwnerIDKey]: owner_id,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
9
19
|
export async function runSearch(opts) {
|
|
10
20
|
const page = normalizeSearchPage(opts.page);
|
|
11
21
|
const per_page = normalizeSearchPerPage(opts.per_page);
|
package/dist/src/feed/feed.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FeedFavorite, type FeedObject, type FeedPost, type FeedReaction, type OperationResult, type RPFeedPull } from "@fabriktor/schema";
|
|
2
2
|
import type { FeedOperator, OperationResultOf, StorageUploadFile } from "@fabriktor/client";
|
|
3
3
|
import { type PullSession, type PullSessionErrorHandler } from "../core/pull.js";
|
|
4
|
-
import { type SearchPage } from "../core/search.js";
|
|
4
|
+
import { type SearchOptions, type SearchPage } from "../core/search.js";
|
|
5
5
|
import { type StorageFXOperator, type StoragePersonalBoxUploadResult } from "../storage/storage.js";
|
|
6
6
|
type FeedPullOptions = Parameters<FeedOperator["pull"]>[0];
|
|
7
7
|
type FeedPostInsertOptions = Parameters<FeedOperator["insertOneFeedPost"]>[0];
|
|
@@ -36,11 +36,7 @@ export type CreateFeedReactionOptions = FeedReactionInsertOptions;
|
|
|
36
36
|
export type ReplaceFeedReactionOptions = FeedReactionReplaceOptions;
|
|
37
37
|
export type CreateFeedFavoriteOptions = FeedFavoriteInsertOptions;
|
|
38
38
|
export type ReplaceFeedFavoriteOptions = FeedFavoriteReplaceOptions;
|
|
39
|
-
export type SearchFeedPostsOptions =
|
|
40
|
-
q?: string;
|
|
41
|
-
page?: number;
|
|
42
|
-
per_page?: number;
|
|
43
|
-
};
|
|
39
|
+
export type SearchFeedPostsOptions = SearchOptions;
|
|
44
40
|
export type SearchFeedPostsPage = SearchPage<FeedPost>;
|
|
45
41
|
export type FeedPullContext = Pick<FeedPullOptions, "contact_ids" | "pull_type" | "entity_id" | "research">;
|
|
46
42
|
export type FeedTextPostContent = Pick<FeedPostInsert, "text">;
|
package/dist/src/feed/feed.js
CHANGED
|
@@ -7,7 +7,7 @@ import { All, ColStorageFeed, PullTypeKeepAlive, ZeroID, } from "@fabriktor/sche
|
|
|
7
7
|
import { errResolveFailed, errValidation } from "../core/err.js";
|
|
8
8
|
import { requiredOperationID, resolvedID } from "../core/id.js";
|
|
9
9
|
import { newPullSession, } from "../core/pull.js";
|
|
10
|
-
import { runSearch } from "../core/search.js";
|
|
10
|
+
import { runSearch, } from "../core/search.js";
|
|
11
11
|
import { StorageUploadModeration, } from "../storage/storage.js";
|
|
12
12
|
const newFeedSessionToken = "";
|
|
13
13
|
const resourceFeedSessionToken = "feed_session_token";
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { FulfillmentsOperator } from "@fabriktor/client";
|
|
2
|
-
import {
|
|
3
|
-
import { type SearchPage } from "../core/search.js";
|
|
2
|
+
import type { FulfillOrder } from "@fabriktor/schema";
|
|
3
|
+
import { type OwnerSearchOptions, type SearchPage } from "../core/search.js";
|
|
4
4
|
type FulfillOrderInsertOptions = Parameters<FulfillmentsOperator["insertOneFulfillOrder"]>[0];
|
|
5
5
|
type FulfillOrderReplaceOptions = Parameters<FulfillmentsOperator["replaceOneFulfillOrder"]>[0];
|
|
6
6
|
export type CreateFulfillOrderOptions = FulfillOrderInsertOptions;
|
|
7
7
|
export type ReplaceFulfillOrderOptions = FulfillOrderReplaceOptions;
|
|
8
|
-
export type SearchFulfillOrdersOptions =
|
|
9
|
-
owner_id: string;
|
|
10
|
-
q?: string;
|
|
11
|
-
page?: number;
|
|
12
|
-
per_page?: number;
|
|
13
|
-
};
|
|
8
|
+
export type SearchFulfillOrdersOptions = OwnerSearchOptions;
|
|
14
9
|
export type SearchFulfillOrdersPage = SearchPage<FulfillOrder>;
|
|
15
10
|
export type FulfillmentsFXOptions = {
|
|
16
11
|
fulfillments: FulfillmentsOperator;
|
|
@@ -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 {
|
|
8
|
+
import { runOwnerSearch, } from "../core/search.js";
|
|
10
9
|
const resourceFulfillOrder = "fulfill_order";
|
|
11
10
|
const msgCreatedFulfillOrderIDMissing = "Created fulfill order response did not contain an ID.";
|
|
12
11
|
const msgFulfillOrderMissing = "Fulfill order could not be resolved after the mutation.";
|
|
@@ -25,14 +24,9 @@ export class FulfillmentsFX {
|
|
|
25
24
|
return await this.findFulfillOrder(opts.id);
|
|
26
25
|
}
|
|
27
26
|
async searchFulfillOrders(opts) {
|
|
28
|
-
return await
|
|
27
|
+
return await runOwnerSearch({
|
|
28
|
+
...opts,
|
|
29
29
|
search: (searchOpts) => this.fulfillments.searchManyFulfillOrders(searchOpts),
|
|
30
|
-
query: {
|
|
31
|
-
[OwnerIDKey]: opts.owner_id,
|
|
32
|
-
},
|
|
33
|
-
q: opts.q,
|
|
34
|
-
page: opts.page,
|
|
35
|
-
per_page: opts.per_page,
|
|
36
30
|
});
|
|
37
31
|
}
|
|
38
32
|
async findFulfillOrder(id) {
|
package/dist/src/jobs/jobs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Job, type JobProgram, type Location, type OperationResult, type RPJobsFindOverlaps } from "@fabriktor/schema";
|
|
2
2
|
import type { JobsOperator, OperationResultOf } from "@fabriktor/client";
|
|
3
|
-
import { type SearchPage } from "../core/search.js";
|
|
3
|
+
import { type OwnerSearchOptions, type SearchOptions, type SearchPage } from "../core/search.js";
|
|
4
4
|
type JobInsert = Parameters<JobsOperator["insertOneJob"]>[0]["in"];
|
|
5
5
|
type JobProgramInsert = Parameters<JobsOperator["insertOneJobProgram"]>[0]["in"];
|
|
6
6
|
type LocationInsert = Parameters<JobsOperator["insertOneLocation"]>[0]["in"];
|
|
@@ -8,24 +8,24 @@ type LocationInsertOptions = Parameters<JobsOperator["insertOneLocation"]>[0];
|
|
|
8
8
|
type LocationReplaceOptions = Parameters<JobsOperator["replaceOneLocation"]>[0];
|
|
9
9
|
type JobProgramReplaceOptions = Parameters<JobsOperator["replaceOneJobProgram"]>[0];
|
|
10
10
|
type JobReplaceOptions = Parameters<JobsOperator["replaceOneJob"]>[0];
|
|
11
|
-
type SearchJobRecordsOptions = {
|
|
12
|
-
owner_id: string;
|
|
13
|
-
q?: string;
|
|
14
|
-
page?: number;
|
|
15
|
-
per_page?: number;
|
|
16
|
-
};
|
|
17
11
|
export declare const JobProgramCreateMode: {
|
|
18
12
|
readonly Scheduled: "scheduled";
|
|
19
13
|
readonly Immediate: "immediate";
|
|
20
14
|
};
|
|
21
15
|
export type JobProgramCreateMode = (typeof JobProgramCreateMode)[keyof typeof JobProgramCreateMode];
|
|
22
16
|
export type CreateLocationOptions = LocationInsertOptions;
|
|
17
|
+
export type CreateOperationalLocationInput = Omit<LocationInsert, "status" | "is_active" | "all_members">;
|
|
18
|
+
export type CreateOperationalLocationOptions = {
|
|
19
|
+
in: CreateOperationalLocationInput;
|
|
20
|
+
};
|
|
23
21
|
export type ReplaceLocationOptions = LocationReplaceOptions;
|
|
24
22
|
export type ReplaceJobProgramOptions = JobProgramReplaceOptions;
|
|
25
23
|
export type ReplaceJobOptions = JobReplaceOptions;
|
|
26
|
-
export type SearchLocationsOptions =
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
24
|
+
export type SearchLocationsOptions = OwnerSearchOptions;
|
|
25
|
+
export type SearchAccessibleLocationsOptions = SearchOptions;
|
|
26
|
+
export type SearchJobProgramsOptions = OwnerSearchOptions;
|
|
27
|
+
export type SearchJobsOptions = OwnerSearchOptions;
|
|
28
|
+
export type SearchAccessibleJobsOptions = SearchOptions;
|
|
29
29
|
export type SearchLocationsPage = SearchPage<Location>;
|
|
30
30
|
export type SearchJobProgramsPage = SearchPage<JobProgram>;
|
|
31
31
|
export type SearchJobsPage = SearchPage<Job>;
|
|
@@ -78,14 +78,33 @@ export type SetLocationMembersOptions = {
|
|
|
78
78
|
location: Location;
|
|
79
79
|
current_members: string[];
|
|
80
80
|
};
|
|
81
|
+
export type SetJobMembersOptions = {
|
|
82
|
+
job: Job;
|
|
83
|
+
location: Location;
|
|
84
|
+
current_members: string[];
|
|
85
|
+
foremen: string[];
|
|
86
|
+
};
|
|
87
|
+
export type JobLifecycleOptions = {
|
|
88
|
+
job: Job;
|
|
89
|
+
};
|
|
90
|
+
export type JobLifecycleControlsOptions = JobLifecycleOptions & {
|
|
91
|
+
actor_id: string;
|
|
92
|
+
};
|
|
93
|
+
export type JobLifecycleControls = {
|
|
94
|
+
can_start: boolean;
|
|
95
|
+
can_terminate: boolean;
|
|
96
|
+
};
|
|
81
97
|
export interface JobsFXOperator {
|
|
82
98
|
createLocation(opts: CreateLocationOptions): Promise<Location>;
|
|
99
|
+
createOperationalLocation(opts: CreateOperationalLocationOptions): Promise<Location>;
|
|
83
100
|
replaceLocation(opts: ReplaceLocationOptions): Promise<Location>;
|
|
84
101
|
searchLocations(opts: SearchLocationsOptions): Promise<SearchLocationsPage>;
|
|
102
|
+
searchAccessibleLocations(opts?: SearchAccessibleLocationsOptions): Promise<SearchLocationsPage>;
|
|
85
103
|
replaceJobProgram(opts: ReplaceJobProgramOptions): Promise<JobProgram>;
|
|
86
104
|
searchJobPrograms(opts: SearchJobProgramsOptions): Promise<SearchJobProgramsPage>;
|
|
87
105
|
replaceJob(opts: ReplaceJobOptions): Promise<Job>;
|
|
88
106
|
searchJobs(opts: SearchJobsOptions): Promise<SearchJobsPage>;
|
|
107
|
+
searchAccessibleJobs(opts?: SearchAccessibleJobsOptions): Promise<SearchJobsPage>;
|
|
89
108
|
createJob(opts: CreateJobOptions): Promise<Job>;
|
|
90
109
|
createLocationJob(opts: CreateJobOptions): Promise<OperationResult>;
|
|
91
110
|
createJobProgram(opts: CreateJobProgramOptions): Promise<CreateJobProgramResult>;
|
|
@@ -94,18 +113,25 @@ export interface JobsFXOperator {
|
|
|
94
113
|
addJobForeman(opts: AddJobForemanOptions): Promise<OperationResult>;
|
|
95
114
|
removeJobMember(opts: RemoveJobMemberOptions): Promise<OperationResult>;
|
|
96
115
|
setLocationMembers(opts: SetLocationMembersOptions): Promise<OperationResult>;
|
|
116
|
+
setJobMembers(opts: SetJobMembersOptions): Promise<OperationResult>;
|
|
117
|
+
jobLifecycleControls(opts: JobLifecycleControlsOptions): JobLifecycleControls;
|
|
118
|
+
startJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
119
|
+
terminateJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
97
120
|
}
|
|
98
121
|
export declare class JobsFX implements JobsFXOperator {
|
|
99
122
|
private jobs;
|
|
100
123
|
private now;
|
|
101
124
|
constructor(opts: JobsFXOptions);
|
|
102
125
|
createLocation(opts: CreateLocationOptions): Promise<Location>;
|
|
126
|
+
createOperationalLocation(opts: CreateOperationalLocationOptions): Promise<Location>;
|
|
103
127
|
replaceLocation(opts: ReplaceLocationOptions): Promise<Location>;
|
|
104
128
|
searchLocations(opts: SearchLocationsOptions): Promise<SearchLocationsPage>;
|
|
129
|
+
searchAccessibleLocations(opts?: SearchAccessibleLocationsOptions): Promise<SearchLocationsPage>;
|
|
105
130
|
replaceJobProgram(opts: ReplaceJobProgramOptions): Promise<JobProgram>;
|
|
106
131
|
searchJobPrograms(opts: SearchJobProgramsOptions): Promise<SearchJobProgramsPage>;
|
|
107
132
|
replaceJob(opts: ReplaceJobOptions): Promise<Job>;
|
|
108
133
|
searchJobs(opts: SearchJobsOptions): Promise<SearchJobsPage>;
|
|
134
|
+
searchAccessibleJobs(opts?: SearchAccessibleJobsOptions): Promise<SearchJobsPage>;
|
|
109
135
|
createJob(opts: CreateJobOptions): Promise<Job>;
|
|
110
136
|
createLocationJob(opts: CreateJobOptions): Promise<OperationResult>;
|
|
111
137
|
createJobProgram(opts: CreateJobProgramOptions): Promise<CreateJobProgramResult>;
|
|
@@ -114,6 +140,10 @@ export declare class JobsFX implements JobsFXOperator {
|
|
|
114
140
|
addJobForeman(opts: AddJobForemanOptions): Promise<OperationResult>;
|
|
115
141
|
removeJobMember(opts: RemoveJobMemberOptions): Promise<OperationResult>;
|
|
116
142
|
setLocationMembers(opts: SetLocationMembersOptions): Promise<OperationResult>;
|
|
143
|
+
setJobMembers(opts: SetJobMembersOptions): Promise<OperationResult>;
|
|
144
|
+
jobLifecycleControls(opts: JobLifecycleControlsOptions): JobLifecycleControls;
|
|
145
|
+
startJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
146
|
+
terminateJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
117
147
|
private findLocation;
|
|
118
148
|
private findJobProgram;
|
|
119
149
|
private findJob;
|