@fabriktor/fx 0.0.38 → 0.0.40
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 +164 -1
- package/dist/src/billable/billable.js +436 -0
- package/dist/src/calls/calls.d.ts +11 -0
- package/dist/src/calls/calls.js +26 -0
- package/dist/src/chat/chat.d.ts +41 -2
- package/dist/src/chat/chat.js +293 -28
- package/dist/src/contacts/contacts.d.ts +12 -2
- package/dist/src/contacts/contacts.js +33 -7
- package/dist/src/core/id.d.ts +3 -0
- package/dist/src/core/id.js +24 -0
- package/dist/src/feed/feed.d.ts +39 -3
- package/dist/src/feed/feed.js +85 -7
- package/dist/src/fulfillments/fulfillments.d.ts +32 -0
- package/dist/src/fulfillments/fulfillments.js +54 -0
- package/dist/src/fx.d.ts +5 -1
- package/dist/src/fx.js +11 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/jobs/jobs.d.ts +52 -4
- package/dist/src/jobs/jobs.js +120 -9
- package/dist/src/marketplace/marketplace.d.ts +29 -1
- package/dist/src/marketplace/marketplace.js +64 -1
- package/dist/src/memos/memos.js +4 -28
- package/dist/src/payments/payments.d.ts +112 -1
- package/dist/src/payments/payments.js +291 -15
- package/dist/src/payrolls/payrolls.d.ts +134 -1
- package/dist/src/payrolls/payrolls.js +364 -0
- package/dist/src/preferences/preferences.d.ts +83 -1
- package/dist/src/preferences/preferences.js +227 -0
- package/dist/src/privacy/privacy.d.ts +21 -2
- package/dist/src/privacy/privacy.js +56 -5
- package/dist/src/routes/routes.d.ts +63 -3
- package/dist/src/routes/routes.js +151 -1
- package/dist/src/timesheets/timesheets.d.ts +11 -1
- package/dist/src/timesheets/timesheets.js +39 -1
- package/package.json +2 -2
|
@@ -1,6 +1,85 @@
|
|
|
1
|
-
import type { OperationResult, RPBillablePeriodsFromDates, YearSpan } from "@fabriktor/schema";
|
|
2
1
|
import type { BillableOperator, OperationResultOf } from "@fabriktor/client";
|
|
2
|
+
import { type OperationResult, type RPBillablePeriodsFromDates, type YearSpan, type Bill, type BillableFolder, type Charge, type Equipment, type Item, type LaborRate, type MeterReading, type Quantifier, type Tax, type TmpBillNumber, type VendorInvoice, type Warehouse } from "@fabriktor/schema";
|
|
3
|
+
import { type SearchPage } from "../core/search.js";
|
|
3
4
|
type GenerateBillPayload = Parameters<BillableOperator["generateBill"]>[0];
|
|
5
|
+
type BillInsertOptions = Parameters<BillableOperator["insertOneBill"]>[0];
|
|
6
|
+
type BillReplaceOptions = Parameters<BillableOperator["replaceOneBill"]>[0];
|
|
7
|
+
type BillableFolderInsertOptions = Parameters<BillableOperator["insertOneBillableFolder"]>[0];
|
|
8
|
+
type BillableFolderReplaceOptions = Parameters<BillableOperator["replaceOneBillableFolder"]>[0];
|
|
9
|
+
type ChargeInsertOptions = Parameters<BillableOperator["insertOneCharge"]>[0];
|
|
10
|
+
type ChargeReplaceOptions = Parameters<BillableOperator["replaceOneCharge"]>[0];
|
|
11
|
+
type EquipmentInsertOptions = Parameters<BillableOperator["insertOneEquipment"]>[0];
|
|
12
|
+
type EquipmentReplaceOptions = Parameters<BillableOperator["replaceOneEquipment"]>[0];
|
|
13
|
+
type ItemInsertOptions = Parameters<BillableOperator["insertOneItem"]>[0];
|
|
14
|
+
type ItemReplaceOptions = Parameters<BillableOperator["replaceOneItem"]>[0];
|
|
15
|
+
type LaborRateInsertOptions = Parameters<BillableOperator["insertOneLaborRate"]>[0];
|
|
16
|
+
type LaborRateReplaceOptions = Parameters<BillableOperator["replaceOneLaborRate"]>[0];
|
|
17
|
+
type MeterReadingInsertOptions = Parameters<BillableOperator["insertOneMeterReading"]>[0];
|
|
18
|
+
type MeterReadingReplaceOptions = Parameters<BillableOperator["replaceOneMeterReading"]>[0];
|
|
19
|
+
type QuantifierInsertOptions = Parameters<BillableOperator["insertOneQuantifier"]>[0];
|
|
20
|
+
type QuantifierReplaceOptions = Parameters<BillableOperator["replaceOneQuantifier"]>[0];
|
|
21
|
+
type TaxInsertOptions = Parameters<BillableOperator["insertOneTax"]>[0];
|
|
22
|
+
type TaxReplaceOptions = Parameters<BillableOperator["replaceOneTax"]>[0];
|
|
23
|
+
type TmpBillNumberInsertOptions = Parameters<BillableOperator["insertOneTmpBillNumber"]>[0];
|
|
24
|
+
type TmpBillNumberReplaceOptions = Parameters<BillableOperator["replaceOneTmpBillNumber"]>[0];
|
|
25
|
+
type VendorInvoiceInsertOptions = Parameters<BillableOperator["insertOneVendorInvoice"]>[0];
|
|
26
|
+
type VendorInvoiceReplaceOptions = Parameters<BillableOperator["replaceOneVendorInvoice"]>[0];
|
|
27
|
+
type WarehouseInsertOptions = Parameters<BillableOperator["insertOneWarehouse"]>[0];
|
|
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
|
+
export type CreateBillOptions = BillInsertOptions;
|
|
36
|
+
export type ReplaceBillOptions = BillReplaceOptions;
|
|
37
|
+
export type SearchBillsOptions = SearchBillableOptions;
|
|
38
|
+
export type SearchBillsPage = SearchPage<Bill>;
|
|
39
|
+
export type CreateBillableFolderOptions = BillableFolderInsertOptions;
|
|
40
|
+
export type ReplaceBillableFolderOptions = BillableFolderReplaceOptions;
|
|
41
|
+
export type SearchBillableFoldersOptions = SearchBillableOptions;
|
|
42
|
+
export type SearchBillableFoldersPage = SearchPage<BillableFolder>;
|
|
43
|
+
export type CreateChargeOptions = ChargeInsertOptions;
|
|
44
|
+
export type ReplaceChargeOptions = ChargeReplaceOptions;
|
|
45
|
+
export type SearchChargesOptions = SearchBillableOptions;
|
|
46
|
+
export type SearchChargesPage = SearchPage<Charge>;
|
|
47
|
+
export type CreateEquipmentOptions = EquipmentInsertOptions;
|
|
48
|
+
export type ReplaceEquipmentOptions = EquipmentReplaceOptions;
|
|
49
|
+
export type SearchEquipmentsOptions = SearchBillableOptions;
|
|
50
|
+
export type SearchEquipmentsPage = SearchPage<Equipment>;
|
|
51
|
+
export type CreateItemOptions = ItemInsertOptions;
|
|
52
|
+
export type ReplaceItemOptions = ItemReplaceOptions;
|
|
53
|
+
export type SearchItemsOptions = SearchBillableOptions;
|
|
54
|
+
export type SearchItemsPage = SearchPage<Item>;
|
|
55
|
+
export type CreateLaborRateOptions = LaborRateInsertOptions;
|
|
56
|
+
export type ReplaceLaborRateOptions = LaborRateReplaceOptions;
|
|
57
|
+
export type SearchLaborRatesOptions = SearchBillableOptions;
|
|
58
|
+
export type SearchLaborRatesPage = SearchPage<LaborRate>;
|
|
59
|
+
export type CreateMeterReadingOptions = MeterReadingInsertOptions;
|
|
60
|
+
export type ReplaceMeterReadingOptions = MeterReadingReplaceOptions;
|
|
61
|
+
export type SearchMeterReadingsOptions = SearchBillableOptions;
|
|
62
|
+
export type SearchMeterReadingsPage = SearchPage<MeterReading>;
|
|
63
|
+
export type CreateQuantifierOptions = QuantifierInsertOptions;
|
|
64
|
+
export type ReplaceQuantifierOptions = QuantifierReplaceOptions;
|
|
65
|
+
export type SearchQuantifiersOptions = SearchBillableOptions;
|
|
66
|
+
export type SearchQuantifiersPage = SearchPage<Quantifier>;
|
|
67
|
+
export type CreateTaxOptions = TaxInsertOptions;
|
|
68
|
+
export type ReplaceTaxOptions = TaxReplaceOptions;
|
|
69
|
+
export type SearchTaxesOptions = SearchBillableOptions;
|
|
70
|
+
export type SearchTaxesPage = SearchPage<Tax>;
|
|
71
|
+
export type CreateTmpBillNumberOptions = TmpBillNumberInsertOptions;
|
|
72
|
+
export type ReplaceTmpBillNumberOptions = TmpBillNumberReplaceOptions;
|
|
73
|
+
export type SearchTmpBillNumbersOptions = SearchBillableOptions;
|
|
74
|
+
export type SearchTmpBillNumbersPage = SearchPage<TmpBillNumber>;
|
|
75
|
+
export type CreateVendorInvoiceOptions = VendorInvoiceInsertOptions;
|
|
76
|
+
export type ReplaceVendorInvoiceOptions = VendorInvoiceReplaceOptions;
|
|
77
|
+
export type SearchVendorInvoicesOptions = SearchBillableOptions;
|
|
78
|
+
export type SearchVendorInvoicesPage = SearchPage<VendorInvoice>;
|
|
79
|
+
export type CreateWarehouseOptions = WarehouseInsertOptions;
|
|
80
|
+
export type ReplaceWarehouseOptions = WarehouseReplaceOptions;
|
|
81
|
+
export type SearchWarehousesOptions = SearchBillableOptions;
|
|
82
|
+
export type SearchWarehousesPage = SearchPage<Warehouse>;
|
|
4
83
|
export type BillableFXOptions = {
|
|
5
84
|
billable: BillableOperator;
|
|
6
85
|
};
|
|
@@ -25,6 +104,42 @@ export type PeriodsFromDatesOptions = Parameters<BillableOperator["periodsFromDa
|
|
|
25
104
|
export type VendorInvoiceFromBillOptions = Parameters<BillableOperator["vendorInvoiceFromBill"]>[0];
|
|
26
105
|
export type SetItemQuantityOptions = Parameters<BillableOperator["setItemQuantity"]>[0];
|
|
27
106
|
export interface BillableFXOperator {
|
|
107
|
+
createBill(opts: CreateBillOptions): Promise<Bill>;
|
|
108
|
+
replaceBill(opts: ReplaceBillOptions): Promise<Bill>;
|
|
109
|
+
searchBills(opts: SearchBillsOptions): Promise<SearchBillsPage>;
|
|
110
|
+
createBillableFolder(opts: CreateBillableFolderOptions): Promise<BillableFolder>;
|
|
111
|
+
replaceBillableFolder(opts: ReplaceBillableFolderOptions): Promise<BillableFolder>;
|
|
112
|
+
searchBillableFolders(opts: SearchBillableFoldersOptions): Promise<SearchBillableFoldersPage>;
|
|
113
|
+
createCharge(opts: CreateChargeOptions): Promise<Charge>;
|
|
114
|
+
replaceCharge(opts: ReplaceChargeOptions): Promise<Charge>;
|
|
115
|
+
searchCharges(opts: SearchChargesOptions): Promise<SearchChargesPage>;
|
|
116
|
+
createEquipment(opts: CreateEquipmentOptions): Promise<Equipment>;
|
|
117
|
+
replaceEquipment(opts: ReplaceEquipmentOptions): Promise<Equipment>;
|
|
118
|
+
searchEquipments(opts: SearchEquipmentsOptions): Promise<SearchEquipmentsPage>;
|
|
119
|
+
createItem(opts: CreateItemOptions): Promise<Item>;
|
|
120
|
+
replaceItem(opts: ReplaceItemOptions): Promise<Item>;
|
|
121
|
+
searchItems(opts: SearchItemsOptions): Promise<SearchItemsPage>;
|
|
122
|
+
createLaborRate(opts: CreateLaborRateOptions): Promise<LaborRate>;
|
|
123
|
+
replaceLaborRate(opts: ReplaceLaborRateOptions): Promise<LaborRate>;
|
|
124
|
+
searchLaborRates(opts: SearchLaborRatesOptions): Promise<SearchLaborRatesPage>;
|
|
125
|
+
createMeterReading(opts: CreateMeterReadingOptions): Promise<MeterReading>;
|
|
126
|
+
replaceMeterReading(opts: ReplaceMeterReadingOptions): Promise<MeterReading>;
|
|
127
|
+
searchMeterReadings(opts: SearchMeterReadingsOptions): Promise<SearchMeterReadingsPage>;
|
|
128
|
+
createQuantifier(opts: CreateQuantifierOptions): Promise<Quantifier>;
|
|
129
|
+
replaceQuantifier(opts: ReplaceQuantifierOptions): Promise<Quantifier>;
|
|
130
|
+
searchQuantifiers(opts: SearchQuantifiersOptions): Promise<SearchQuantifiersPage>;
|
|
131
|
+
createTax(opts: CreateTaxOptions): Promise<Tax>;
|
|
132
|
+
replaceTax(opts: ReplaceTaxOptions): Promise<Tax>;
|
|
133
|
+
searchTaxes(opts: SearchTaxesOptions): Promise<SearchTaxesPage>;
|
|
134
|
+
createTmpBillNumber(opts: CreateTmpBillNumberOptions): Promise<TmpBillNumber>;
|
|
135
|
+
replaceTmpBillNumber(opts: ReplaceTmpBillNumberOptions): Promise<TmpBillNumber>;
|
|
136
|
+
searchTmpBillNumbers(opts: SearchTmpBillNumbersOptions): Promise<SearchTmpBillNumbersPage>;
|
|
137
|
+
createVendorInvoice(opts: CreateVendorInvoiceOptions): Promise<VendorInvoice>;
|
|
138
|
+
replaceVendorInvoice(opts: ReplaceVendorInvoiceOptions): Promise<VendorInvoice>;
|
|
139
|
+
searchVendorInvoices(opts: SearchVendorInvoicesOptions): Promise<SearchVendorInvoicesPage>;
|
|
140
|
+
createWarehouse(opts: CreateWarehouseOptions): Promise<Warehouse>;
|
|
141
|
+
replaceWarehouse(opts: ReplaceWarehouseOptions): Promise<Warehouse>;
|
|
142
|
+
searchWarehouses(opts: SearchWarehousesOptions): Promise<SearchWarehousesPage>;
|
|
28
143
|
generateFixedEstimate(opts: GenerateFixedEstimateOptions): Promise<OperationResult>;
|
|
29
144
|
acceptFixedEstimate(opts: AcceptFixedEstimateOptions): Promise<OperationResult>;
|
|
30
145
|
generateDynamicEstimate(opts: GenerateDynamicEstimateOptions): Promise<OperationResult>;
|
|
@@ -38,6 +153,42 @@ export interface BillableFXOperator {
|
|
|
38
153
|
export declare class BillableFX implements BillableFXOperator {
|
|
39
154
|
private billable;
|
|
40
155
|
constructor(opts: BillableFXOptions);
|
|
156
|
+
createBill(opts: CreateBillOptions): Promise<Bill>;
|
|
157
|
+
replaceBill(opts: ReplaceBillOptions): Promise<Bill>;
|
|
158
|
+
searchBills(opts: SearchBillsOptions): Promise<SearchBillsPage>;
|
|
159
|
+
createBillableFolder(opts: CreateBillableFolderOptions): Promise<BillableFolder>;
|
|
160
|
+
replaceBillableFolder(opts: ReplaceBillableFolderOptions): Promise<BillableFolder>;
|
|
161
|
+
searchBillableFolders(opts: SearchBillableFoldersOptions): Promise<SearchBillableFoldersPage>;
|
|
162
|
+
createCharge(opts: CreateChargeOptions): Promise<Charge>;
|
|
163
|
+
replaceCharge(opts: ReplaceChargeOptions): Promise<Charge>;
|
|
164
|
+
searchCharges(opts: SearchChargesOptions): Promise<SearchChargesPage>;
|
|
165
|
+
createEquipment(opts: CreateEquipmentOptions): Promise<Equipment>;
|
|
166
|
+
replaceEquipment(opts: ReplaceEquipmentOptions): Promise<Equipment>;
|
|
167
|
+
searchEquipments(opts: SearchEquipmentsOptions): Promise<SearchEquipmentsPage>;
|
|
168
|
+
createItem(opts: CreateItemOptions): Promise<Item>;
|
|
169
|
+
replaceItem(opts: ReplaceItemOptions): Promise<Item>;
|
|
170
|
+
searchItems(opts: SearchItemsOptions): Promise<SearchItemsPage>;
|
|
171
|
+
createLaborRate(opts: CreateLaborRateOptions): Promise<LaborRate>;
|
|
172
|
+
replaceLaborRate(opts: ReplaceLaborRateOptions): Promise<LaborRate>;
|
|
173
|
+
searchLaborRates(opts: SearchLaborRatesOptions): Promise<SearchLaborRatesPage>;
|
|
174
|
+
createMeterReading(opts: CreateMeterReadingOptions): Promise<MeterReading>;
|
|
175
|
+
replaceMeterReading(opts: ReplaceMeterReadingOptions): Promise<MeterReading>;
|
|
176
|
+
searchMeterReadings(opts: SearchMeterReadingsOptions): Promise<SearchMeterReadingsPage>;
|
|
177
|
+
createQuantifier(opts: CreateQuantifierOptions): Promise<Quantifier>;
|
|
178
|
+
replaceQuantifier(opts: ReplaceQuantifierOptions): Promise<Quantifier>;
|
|
179
|
+
searchQuantifiers(opts: SearchQuantifiersOptions): Promise<SearchQuantifiersPage>;
|
|
180
|
+
createTax(opts: CreateTaxOptions): Promise<Tax>;
|
|
181
|
+
replaceTax(opts: ReplaceTaxOptions): Promise<Tax>;
|
|
182
|
+
searchTaxes(opts: SearchTaxesOptions): Promise<SearchTaxesPage>;
|
|
183
|
+
createTmpBillNumber(opts: CreateTmpBillNumberOptions): Promise<TmpBillNumber>;
|
|
184
|
+
replaceTmpBillNumber(opts: ReplaceTmpBillNumberOptions): Promise<TmpBillNumber>;
|
|
185
|
+
searchTmpBillNumbers(opts: SearchTmpBillNumbersOptions): Promise<SearchTmpBillNumbersPage>;
|
|
186
|
+
createVendorInvoice(opts: CreateVendorInvoiceOptions): Promise<VendorInvoice>;
|
|
187
|
+
replaceVendorInvoice(opts: ReplaceVendorInvoiceOptions): Promise<VendorInvoice>;
|
|
188
|
+
searchVendorInvoices(opts: SearchVendorInvoicesOptions): Promise<SearchVendorInvoicesPage>;
|
|
189
|
+
createWarehouse(opts: CreateWarehouseOptions): Promise<Warehouse>;
|
|
190
|
+
replaceWarehouse(opts: ReplaceWarehouseOptions): Promise<Warehouse>;
|
|
191
|
+
searchWarehouses(opts: SearchWarehousesOptions): Promise<SearchWarehousesPage>;
|
|
41
192
|
generateFixedEstimate(opts: GenerateFixedEstimateOptions): Promise<OperationResult>;
|
|
42
193
|
acceptFixedEstimate(opts: AcceptFixedEstimateOptions): Promise<OperationResult>;
|
|
43
194
|
generateDynamicEstimate(opts: GenerateDynamicEstimateOptions): Promise<OperationResult>;
|
|
@@ -47,6 +198,18 @@ export declare class BillableFX implements BillableFXOperator {
|
|
|
47
198
|
periodsFromDates(opts: PeriodsFromDatesOptions): Promise<OperationResultOf<RPBillablePeriodsFromDates>>;
|
|
48
199
|
vendorInvoiceFromBill(opts: VendorInvoiceFromBillOptions): Promise<OperationResult>;
|
|
49
200
|
setItemQuantity(opts: SetItemQuantityOptions): Promise<void>;
|
|
201
|
+
private findBill;
|
|
202
|
+
private findBillableFolder;
|
|
203
|
+
private findCharge;
|
|
204
|
+
private findEquipment;
|
|
205
|
+
private findItem;
|
|
206
|
+
private findLaborRate;
|
|
207
|
+
private findMeterReading;
|
|
208
|
+
private findQuantifier;
|
|
209
|
+
private findTax;
|
|
210
|
+
private findTmpBillNumber;
|
|
211
|
+
private findVendorInvoice;
|
|
212
|
+
private findWarehouse;
|
|
50
213
|
}
|
|
51
214
|
export declare function newBillableFX(opts: BillableFXOptions): BillableFX;
|
|
52
215
|
export {};
|
|
@@ -3,13 +3,293 @@
|
|
|
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
|
+
import { errResolveFailed } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID } from "../core/id.js";
|
|
9
|
+
import { runSearch } from "../core/search.js";
|
|
6
10
|
const billTypeFixed = "fixed";
|
|
7
11
|
const billTypeDynamic = "dynamic";
|
|
12
|
+
const resourceBill = "bill";
|
|
13
|
+
const msgCreatedBillIDMissing = "Created bill response did not contain an ID.";
|
|
14
|
+
const msgBillMissing = "Bill could not be resolved after the mutation.";
|
|
15
|
+
const resourceBillableFolder = "billable_folder";
|
|
16
|
+
const msgCreatedBillableFolderIDMissing = "Created billable folder response did not contain an ID.";
|
|
17
|
+
const msgBillableFolderMissing = "Billable folder could not be resolved after the mutation.";
|
|
18
|
+
const resourceCharge = "charge";
|
|
19
|
+
const msgCreatedChargeIDMissing = "Created charge response did not contain an ID.";
|
|
20
|
+
const msgChargeMissing = "Charge could not be resolved after the mutation.";
|
|
21
|
+
const resourceEquipment = "equipment";
|
|
22
|
+
const msgCreatedEquipmentIDMissing = "Created equipment response did not contain an ID.";
|
|
23
|
+
const msgEquipmentMissing = "Equipment could not be resolved after the mutation.";
|
|
24
|
+
const resourceItem = "item";
|
|
25
|
+
const msgCreatedItemIDMissing = "Created item response did not contain an ID.";
|
|
26
|
+
const msgItemMissing = "Item could not be resolved after the mutation.";
|
|
27
|
+
const resourceLaborRate = "labor_rate";
|
|
28
|
+
const msgCreatedLaborRateIDMissing = "Created labor rate response did not contain an ID.";
|
|
29
|
+
const msgLaborRateMissing = "Labor rate could not be resolved after the mutation.";
|
|
30
|
+
const resourceMeterReading = "meter_reading";
|
|
31
|
+
const msgCreatedMeterReadingIDMissing = "Created meter reading response did not contain an ID.";
|
|
32
|
+
const msgMeterReadingMissing = "Meter reading could not be resolved after the mutation.";
|
|
33
|
+
const resourceQuantifier = "quantifier";
|
|
34
|
+
const msgCreatedQuantifierIDMissing = "Created quantifier response did not contain an ID.";
|
|
35
|
+
const msgQuantifierMissing = "Quantifier could not be resolved after the mutation.";
|
|
36
|
+
const resourceTax = "tax";
|
|
37
|
+
const msgCreatedTaxIDMissing = "Created tax response did not contain an ID.";
|
|
38
|
+
const msgTaxMissing = "Tax could not be resolved after the mutation.";
|
|
39
|
+
const resourceTmpBillNumber = "tmp_bill_number";
|
|
40
|
+
const msgCreatedTmpBillNumberIDMissing = "Created tmp bill number response did not contain an ID.";
|
|
41
|
+
const msgTmpBillNumberMissing = "Tmp bill number could not be resolved after the mutation.";
|
|
42
|
+
const resourceVendorInvoice = "vendor_invoice";
|
|
43
|
+
const msgCreatedVendorInvoiceIDMissing = "Created vendor invoice response did not contain an ID.";
|
|
44
|
+
const msgVendorInvoiceMissing = "Vendor invoice could not be resolved after the mutation.";
|
|
45
|
+
const resourceWarehouse = "warehouse";
|
|
46
|
+
const msgCreatedWarehouseIDMissing = "Created warehouse response did not contain an ID.";
|
|
47
|
+
const msgWarehouseMissing = "Warehouse could not be resolved after the mutation.";
|
|
8
48
|
export class BillableFX {
|
|
9
49
|
billable;
|
|
10
50
|
constructor(opts) {
|
|
11
51
|
this.billable = opts.billable;
|
|
12
52
|
}
|
|
53
|
+
async createBill(opts) {
|
|
54
|
+
const out = await this.billable.insertOneBill(opts);
|
|
55
|
+
const id = requiredOperationID(out, msgCreatedBillIDMissing);
|
|
56
|
+
return await this.findBill(id);
|
|
57
|
+
}
|
|
58
|
+
async replaceBill(opts) {
|
|
59
|
+
await this.billable.replaceOneBill(opts);
|
|
60
|
+
return await this.findBill(opts.id);
|
|
61
|
+
}
|
|
62
|
+
async searchBills(opts) {
|
|
63
|
+
return await runSearch({
|
|
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
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async createBillableFolder(opts) {
|
|
74
|
+
const out = await this.billable.insertOneBillableFolder(opts);
|
|
75
|
+
const id = requiredOperationID(out, msgCreatedBillableFolderIDMissing);
|
|
76
|
+
return await this.findBillableFolder(id);
|
|
77
|
+
}
|
|
78
|
+
async replaceBillableFolder(opts) {
|
|
79
|
+
await this.billable.replaceOneBillableFolder(opts);
|
|
80
|
+
return await this.findBillableFolder(opts.id);
|
|
81
|
+
}
|
|
82
|
+
async searchBillableFolders(opts) {
|
|
83
|
+
return await runSearch({
|
|
84
|
+
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
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async createCharge(opts) {
|
|
94
|
+
const out = await this.billable.insertOneCharge(opts);
|
|
95
|
+
const id = requiredOperationID(out, msgCreatedChargeIDMissing);
|
|
96
|
+
return await this.findCharge(id);
|
|
97
|
+
}
|
|
98
|
+
async replaceCharge(opts) {
|
|
99
|
+
await this.billable.replaceOneCharge(opts);
|
|
100
|
+
return await this.findCharge(opts.id);
|
|
101
|
+
}
|
|
102
|
+
async searchCharges(opts) {
|
|
103
|
+
return await runSearch({
|
|
104
|
+
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
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async createEquipment(opts) {
|
|
114
|
+
const out = await this.billable.insertOneEquipment(opts);
|
|
115
|
+
const id = requiredOperationID(out, msgCreatedEquipmentIDMissing);
|
|
116
|
+
return await this.findEquipment(id);
|
|
117
|
+
}
|
|
118
|
+
async replaceEquipment(opts) {
|
|
119
|
+
await this.billable.replaceOneEquipment(opts);
|
|
120
|
+
return await this.findEquipment(opts.id);
|
|
121
|
+
}
|
|
122
|
+
async searchEquipments(opts) {
|
|
123
|
+
return await runSearch({
|
|
124
|
+
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
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async createItem(opts) {
|
|
134
|
+
const out = await this.billable.insertOneItem(opts);
|
|
135
|
+
const id = requiredOperationID(out, msgCreatedItemIDMissing);
|
|
136
|
+
return await this.findItem(id);
|
|
137
|
+
}
|
|
138
|
+
async replaceItem(opts) {
|
|
139
|
+
await this.billable.replaceOneItem(opts);
|
|
140
|
+
return await this.findItem(opts.id);
|
|
141
|
+
}
|
|
142
|
+
async searchItems(opts) {
|
|
143
|
+
return await runSearch({
|
|
144
|
+
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
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async createLaborRate(opts) {
|
|
154
|
+
const out = await this.billable.insertOneLaborRate(opts);
|
|
155
|
+
const id = requiredOperationID(out, msgCreatedLaborRateIDMissing);
|
|
156
|
+
return await this.findLaborRate(id);
|
|
157
|
+
}
|
|
158
|
+
async replaceLaborRate(opts) {
|
|
159
|
+
await this.billable.replaceOneLaborRate(opts);
|
|
160
|
+
return await this.findLaborRate(opts.id);
|
|
161
|
+
}
|
|
162
|
+
async searchLaborRates(opts) {
|
|
163
|
+
return await runSearch({
|
|
164
|
+
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
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async createMeterReading(opts) {
|
|
174
|
+
const out = await this.billable.insertOneMeterReading(opts);
|
|
175
|
+
const id = requiredOperationID(out, msgCreatedMeterReadingIDMissing);
|
|
176
|
+
return await this.findMeterReading(id);
|
|
177
|
+
}
|
|
178
|
+
async replaceMeterReading(opts) {
|
|
179
|
+
await this.billable.replaceOneMeterReading(opts);
|
|
180
|
+
return await this.findMeterReading(opts.id);
|
|
181
|
+
}
|
|
182
|
+
async searchMeterReadings(opts) {
|
|
183
|
+
return await runSearch({
|
|
184
|
+
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
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async createQuantifier(opts) {
|
|
194
|
+
const out = await this.billable.insertOneQuantifier(opts);
|
|
195
|
+
const id = requiredOperationID(out, msgCreatedQuantifierIDMissing);
|
|
196
|
+
return await this.findQuantifier(id);
|
|
197
|
+
}
|
|
198
|
+
async replaceQuantifier(opts) {
|
|
199
|
+
await this.billable.replaceOneQuantifier(opts);
|
|
200
|
+
return await this.findQuantifier(opts.id);
|
|
201
|
+
}
|
|
202
|
+
async searchQuantifiers(opts) {
|
|
203
|
+
return await runSearch({
|
|
204
|
+
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
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async createTax(opts) {
|
|
214
|
+
const out = await this.billable.insertOneTax(opts);
|
|
215
|
+
const id = requiredOperationID(out, msgCreatedTaxIDMissing);
|
|
216
|
+
return await this.findTax(id);
|
|
217
|
+
}
|
|
218
|
+
async replaceTax(opts) {
|
|
219
|
+
await this.billable.replaceOneTax(opts);
|
|
220
|
+
return await this.findTax(opts.id);
|
|
221
|
+
}
|
|
222
|
+
async searchTaxes(opts) {
|
|
223
|
+
return await runSearch({
|
|
224
|
+
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
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async createTmpBillNumber(opts) {
|
|
234
|
+
const out = await this.billable.insertOneTmpBillNumber(opts);
|
|
235
|
+
const id = requiredOperationID(out, msgCreatedTmpBillNumberIDMissing);
|
|
236
|
+
return await this.findTmpBillNumber(id);
|
|
237
|
+
}
|
|
238
|
+
async replaceTmpBillNumber(opts) {
|
|
239
|
+
await this.billable.replaceOneTmpBillNumber(opts);
|
|
240
|
+
return await this.findTmpBillNumber(opts.id);
|
|
241
|
+
}
|
|
242
|
+
async searchTmpBillNumbers(opts) {
|
|
243
|
+
return await runSearch({
|
|
244
|
+
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
|
+
});
|
|
252
|
+
}
|
|
253
|
+
async createVendorInvoice(opts) {
|
|
254
|
+
const out = await this.billable.insertOneVendorInvoice(opts);
|
|
255
|
+
const id = requiredOperationID(out, msgCreatedVendorInvoiceIDMissing);
|
|
256
|
+
return await this.findVendorInvoice(id);
|
|
257
|
+
}
|
|
258
|
+
async replaceVendorInvoice(opts) {
|
|
259
|
+
await this.billable.replaceOneVendorInvoice(opts);
|
|
260
|
+
return await this.findVendorInvoice(opts.id);
|
|
261
|
+
}
|
|
262
|
+
async searchVendorInvoices(opts) {
|
|
263
|
+
return await runSearch({
|
|
264
|
+
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
|
+
});
|
|
272
|
+
}
|
|
273
|
+
async createWarehouse(opts) {
|
|
274
|
+
const out = await this.billable.insertOneWarehouse(opts);
|
|
275
|
+
const id = requiredOperationID(out, msgCreatedWarehouseIDMissing);
|
|
276
|
+
return await this.findWarehouse(id);
|
|
277
|
+
}
|
|
278
|
+
async replaceWarehouse(opts) {
|
|
279
|
+
await this.billable.replaceOneWarehouse(opts);
|
|
280
|
+
return await this.findWarehouse(opts.id);
|
|
281
|
+
}
|
|
282
|
+
async searchWarehouses(opts) {
|
|
283
|
+
return await runSearch({
|
|
284
|
+
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
|
+
});
|
|
292
|
+
}
|
|
13
293
|
async generateFixedEstimate(opts) {
|
|
14
294
|
return await this.billable.generateBill(billWith(opts.in, {
|
|
15
295
|
type: billTypeFixed,
|
|
@@ -52,6 +332,162 @@ export class BillableFX {
|
|
|
52
332
|
async setItemQuantity(opts) {
|
|
53
333
|
await this.billable.setItemQuantity(opts);
|
|
54
334
|
}
|
|
335
|
+
async findBill(id) {
|
|
336
|
+
const out = await this.billable.findOneBill({
|
|
337
|
+
id,
|
|
338
|
+
});
|
|
339
|
+
const value = out.value;
|
|
340
|
+
if (value === undefined) {
|
|
341
|
+
throw errResolveFailed({
|
|
342
|
+
resource: resourceBill,
|
|
343
|
+
msg: msgBillMissing,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return value;
|
|
347
|
+
}
|
|
348
|
+
async findBillableFolder(id) {
|
|
349
|
+
const out = await this.billable.findOneBillableFolder({
|
|
350
|
+
id,
|
|
351
|
+
});
|
|
352
|
+
const value = out.value;
|
|
353
|
+
if (value === undefined) {
|
|
354
|
+
throw errResolveFailed({
|
|
355
|
+
resource: resourceBillableFolder,
|
|
356
|
+
msg: msgBillableFolderMissing,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
return value;
|
|
360
|
+
}
|
|
361
|
+
async findCharge(id) {
|
|
362
|
+
const out = await this.billable.findOneCharge({
|
|
363
|
+
id,
|
|
364
|
+
});
|
|
365
|
+
const value = out.value;
|
|
366
|
+
if (value === undefined) {
|
|
367
|
+
throw errResolveFailed({
|
|
368
|
+
resource: resourceCharge,
|
|
369
|
+
msg: msgChargeMissing,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return value;
|
|
373
|
+
}
|
|
374
|
+
async findEquipment(id) {
|
|
375
|
+
const out = await this.billable.findOneEquipment({
|
|
376
|
+
id,
|
|
377
|
+
});
|
|
378
|
+
const value = out.value;
|
|
379
|
+
if (value === undefined) {
|
|
380
|
+
throw errResolveFailed({
|
|
381
|
+
resource: resourceEquipment,
|
|
382
|
+
msg: msgEquipmentMissing,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return value;
|
|
386
|
+
}
|
|
387
|
+
async findItem(id) {
|
|
388
|
+
const out = await this.billable.findOneItem({
|
|
389
|
+
id,
|
|
390
|
+
});
|
|
391
|
+
const value = out.value;
|
|
392
|
+
if (value === undefined) {
|
|
393
|
+
throw errResolveFailed({
|
|
394
|
+
resource: resourceItem,
|
|
395
|
+
msg: msgItemMissing,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
return value;
|
|
399
|
+
}
|
|
400
|
+
async findLaborRate(id) {
|
|
401
|
+
const out = await this.billable.findOneLaborRate({
|
|
402
|
+
id,
|
|
403
|
+
});
|
|
404
|
+
const value = out.value;
|
|
405
|
+
if (value === undefined) {
|
|
406
|
+
throw errResolveFailed({
|
|
407
|
+
resource: resourceLaborRate,
|
|
408
|
+
msg: msgLaborRateMissing,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return value;
|
|
412
|
+
}
|
|
413
|
+
async findMeterReading(id) {
|
|
414
|
+
const out = await this.billable.findOneMeterReading({
|
|
415
|
+
id,
|
|
416
|
+
});
|
|
417
|
+
const value = out.value;
|
|
418
|
+
if (value === undefined) {
|
|
419
|
+
throw errResolveFailed({
|
|
420
|
+
resource: resourceMeterReading,
|
|
421
|
+
msg: msgMeterReadingMissing,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
return value;
|
|
425
|
+
}
|
|
426
|
+
async findQuantifier(id) {
|
|
427
|
+
const out = await this.billable.findOneQuantifier({
|
|
428
|
+
id,
|
|
429
|
+
});
|
|
430
|
+
const value = out.value;
|
|
431
|
+
if (value === undefined) {
|
|
432
|
+
throw errResolveFailed({
|
|
433
|
+
resource: resourceQuantifier,
|
|
434
|
+
msg: msgQuantifierMissing,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return value;
|
|
438
|
+
}
|
|
439
|
+
async findTax(id) {
|
|
440
|
+
const out = await this.billable.findOneTax({
|
|
441
|
+
id,
|
|
442
|
+
});
|
|
443
|
+
const value = out.value;
|
|
444
|
+
if (value === undefined) {
|
|
445
|
+
throw errResolveFailed({
|
|
446
|
+
resource: resourceTax,
|
|
447
|
+
msg: msgTaxMissing,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
return value;
|
|
451
|
+
}
|
|
452
|
+
async findTmpBillNumber(id) {
|
|
453
|
+
const out = await this.billable.findOneTmpBillNumber({
|
|
454
|
+
id,
|
|
455
|
+
});
|
|
456
|
+
const value = out.value;
|
|
457
|
+
if (value === undefined) {
|
|
458
|
+
throw errResolveFailed({
|
|
459
|
+
resource: resourceTmpBillNumber,
|
|
460
|
+
msg: msgTmpBillNumberMissing,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return value;
|
|
464
|
+
}
|
|
465
|
+
async findVendorInvoice(id) {
|
|
466
|
+
const out = await this.billable.findOneVendorInvoice({
|
|
467
|
+
id,
|
|
468
|
+
});
|
|
469
|
+
const value = out.value;
|
|
470
|
+
if (value === undefined) {
|
|
471
|
+
throw errResolveFailed({
|
|
472
|
+
resource: resourceVendorInvoice,
|
|
473
|
+
msg: msgVendorInvoiceMissing,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return value;
|
|
477
|
+
}
|
|
478
|
+
async findWarehouse(id) {
|
|
479
|
+
const out = await this.billable.findOneWarehouse({
|
|
480
|
+
id,
|
|
481
|
+
});
|
|
482
|
+
const value = out.value;
|
|
483
|
+
if (value === undefined) {
|
|
484
|
+
throw errResolveFailed({
|
|
485
|
+
resource: resourceWarehouse,
|
|
486
|
+
msg: msgWarehouseMissing,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return value;
|
|
490
|
+
}
|
|
55
491
|
}
|
|
56
492
|
export function newBillableFX(opts) {
|
|
57
493
|
return new BillableFX(opts);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { CallsOperator, NotificationsOperator } from "@fabriktor/client";
|
|
2
|
+
import type { Event } from "@fabriktor/schema";
|
|
3
|
+
type EventInsertOptions = Parameters<CallsOperator["insertOneEvent"]>[0];
|
|
4
|
+
type EventReplaceOptions = Parameters<CallsOperator["replaceOneEvent"]>[0];
|
|
5
|
+
export type CreateEventOptions = EventInsertOptions;
|
|
6
|
+
export type ReplaceEventOptions = EventReplaceOptions;
|
|
2
7
|
export type MintVideoTokenOptions = Parameters<CallsOperator["mintVideoToken"]>[0];
|
|
3
8
|
export type RelayNotificationOptions = Parameters<NotificationsOperator["relayNotification"]>[0];
|
|
4
9
|
export type StartCallOptions = {
|
|
@@ -17,6 +22,8 @@ export type CallsFXOptions = {
|
|
|
17
22
|
notifications: NotificationsOperator;
|
|
18
23
|
};
|
|
19
24
|
export interface CallsFXOperator {
|
|
25
|
+
createEvent(opts: CreateEventOptions): Promise<Event>;
|
|
26
|
+
replaceEvent(opts: ReplaceEventOptions): Promise<Event>;
|
|
20
27
|
startCall(opts: StartCallOptions): Promise<string>;
|
|
21
28
|
answerCall(opts: AnswerCallOptions): Promise<string>;
|
|
22
29
|
cancelCall(opts: CancelCallOptions): Promise<void>;
|
|
@@ -25,9 +32,13 @@ export declare class CallsFX implements CallsFXOperator {
|
|
|
25
32
|
private calls;
|
|
26
33
|
private notifications;
|
|
27
34
|
constructor(opts: CallsFXOptions);
|
|
35
|
+
createEvent(opts: CreateEventOptions): Promise<Event>;
|
|
36
|
+
replaceEvent(opts: ReplaceEventOptions): Promise<Event>;
|
|
28
37
|
startCall(opts: StartCallOptions): Promise<string>;
|
|
29
38
|
answerCall(opts: AnswerCallOptions): Promise<string>;
|
|
30
39
|
cancelCall(opts: CancelCallOptions): Promise<void>;
|
|
40
|
+
private findEvent;
|
|
31
41
|
private requireVideoToken;
|
|
32
42
|
}
|
|
33
43
|
export declare function newCallsFX(opts: CallsFXOptions): CallsFX;
|
|
44
|
+
export {};
|