@bisondesk/core-sdk 1.0.67 → 1.0.68

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/lib/apis/crm.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Contact, Organization } from '../types/crm';
2
2
  export declare const getCrmOrganization: (tenantId: string, organizationId: string) => Promise<Organization | undefined>;
3
+ export declare const getCrmOrganizationByExternalId: (tenantId: string, externalId: string) => Promise<Organization | undefined>;
3
4
  export declare const listCrmContacts: (tenantId: string, organizationId: string) => Promise<Contact[]>;
4
5
  //# sourceMappingURL=crm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crm.d.ts","sourceRoot":"","sources":["../../src/apis/crm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGrD,eAAO,MAAM,kBAAkB,aACnB,MAAM,kBACA,MAAM,KACrB,QAAQ,YAAY,GAAG,SAAS,CAkBlC,CAAC;AAEF,eAAO,MAAM,eAAe,aAChB,MAAM,kBACA,MAAM,KACrB,QAAQ,OAAO,EAAE,CAkBnB,CAAC"}
1
+ {"version":3,"file":"crm.d.ts","sourceRoot":"","sources":["../../src/apis/crm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGrD,eAAO,MAAM,kBAAkB,aACnB,MAAM,kBACA,MAAM,KACrB,QAAQ,YAAY,GAAG,SAAS,CAkBlC,CAAC;AAEF,eAAO,MAAM,8BAA8B,aAC/B,MAAM,cACJ,MAAM,KACjB,QAAQ,YAAY,GAAG,SAAS,CAkBlC,CAAC;AAEF,eAAO,MAAM,eAAe,aAChB,MAAM,kBACA,MAAM,KACrB,QAAQ,OAAO,EAAE,CAkBnB,CAAC"}
package/lib/apis/crm.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.listCrmContacts = exports.getCrmOrganization = void 0;
6
+ exports.listCrmContacts = exports.getCrmOrganizationByExternalId = exports.getCrmOrganization = void 0;
7
7
  const constants_1 = require("@bisondesk/commons-sdk/lib/constants");
8
8
  const errors_1 = require("@bisondesk/commons/lib/errors");
9
9
  const node_fetch_1 = __importDefault(require("node-fetch"));
@@ -23,6 +23,21 @@ const getCrmOrganization = async (tenantId, organizationId) => {
23
23
  throw new errors_1.XError(response.statusText, { body });
24
24
  };
25
25
  exports.getCrmOrganization = getCrmOrganization;
26
+ const getCrmOrganizationByExternalId = async (tenantId, externalId) => {
27
+ const auth = await utils_1.getAdminAuth();
28
+ const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/api/crm/organizations/external-id/${externalId}`, {
29
+ headers: {
30
+ Authorization: auth,
31
+ [constants_1.TENANT_ID_ADMIN_HEADER]: tenantId,
32
+ },
33
+ });
34
+ if (response.ok) {
35
+ return response.status === 200 ? response.json() : undefined;
36
+ }
37
+ const body = await response.text();
38
+ throw new errors_1.XError(response.statusText, { body });
39
+ };
40
+ exports.getCrmOrganizationByExternalId = getCrmOrganizationByExternalId;
26
41
  const listCrmContacts = async (tenantId, organizationId) => {
27
42
  const auth = await utils_1.getAdminAuth();
28
43
  const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/admin/crm/organizations/${organizationId}/contacts`, {
@@ -1 +1 @@
1
- {"version":3,"file":"crm.js","sourceRoot":"","sources":["../../src/apis/crm.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA8E;AAC9E,0DAAuD;AACvD,4DAA6C;AAE7C,mCAAuC;AAEhC,MAAM,kBAAkB,GAAG,KAAK,EACrC,QAAgB,EAChB,cAAsB,EACa,EAAE;IACrC,MAAM,IAAI,GAAG,MAAM,oBAAY,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAa,MAAM,oBAAK,CACpC,GA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CAAC,CAAC,CAAC,SAAS,CAAC;KAC9D;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,eAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AArBW,QAAA,8BAA8B,kCAqBzC;AAEK,MAAM,eAAe,GAAG,KAAK,EAClC,QAAgB,EAChB,cAAsB,EACF,EAAE;IACtB,MAAM,IAAI,GAAG,MAAM,oBAAY,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAa,MAAM,oBAAK,CACpC,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,4BAA4B,cAAc,WAAW,EACnF;QACE,OAAO,EAAE;YACP,aAAa,EAAE,IAAI;YACnB,CAAC,kCAAsB,CAAC,EAAE,QAAQ;SACnC;KACF,CACF,CAAC;IAEF,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KAC9D;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,eAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AArBW,QAAA,eAAe,mBAqB1B"}
@@ -0,0 +1,6 @@
1
+ import { LeasingConditions, LeasingContract, NewLeasingConditions } from '../types/leasing';
2
+ export declare const getLeasingConditions: (tenantId: string, conditionsId: string) => Promise<LeasingConditions | undefined>;
3
+ export declare const createLeasingConditions: (tenantId: string, conditions: NewLeasingConditions) => Promise<LeasingConditions>;
4
+ export declare const getLeasingContract: (tenantId: string, contractId: string) => Promise<LeasingContract | undefined>;
5
+ export declare const upsertLeasingContract: (tenantId: string, contract: LeasingContract) => Promise<LeasingContract>;
6
+ //# sourceMappingURL=leasing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leasing.d.ts","sourceRoot":"","sources":["../../src/apis/leasing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG5F,eAAO,MAAM,oBAAoB,aACrB,MAAM,gBACF,MAAM,KACnB,QAAQ,iBAAiB,GAAG,SAAS,CAkBvC,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACxB,MAAM,cACJ,oBAAoB,KAC/B,QAAQ,iBAAiB,CAkB3B,CAAC;AAEF,eAAO,MAAM,kBAAkB,aACnB,MAAM,cACJ,MAAM,KACjB,QAAQ,eAAe,GAAG,SAAS,CAkBrC,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,MAAM,YACN,eAAe,KACxB,QAAQ,eAAe,CAkBzB,CAAC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.upsertLeasingContract = exports.getLeasingContract = exports.createLeasingConditions = exports.getLeasingConditions = void 0;
7
+ const constants_1 = require("@bisondesk/commons-sdk/lib/constants");
8
+ const errors_1 = require("@bisondesk/commons/lib/errors");
9
+ const node_fetch_1 = __importDefault(require("node-fetch"));
10
+ const utils_1 = require("./utils");
11
+ const getLeasingConditions = async (tenantId, conditionsId) => {
12
+ const auth = await utils_1.getAdminAuth();
13
+ const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/api/leasing/conditions/${conditionsId}`, {
14
+ headers: {
15
+ Authorization: auth,
16
+ [constants_1.TENANT_ID_ADMIN_HEADER]: tenantId,
17
+ },
18
+ });
19
+ if (response.ok) {
20
+ return response.status === 200 ? response.json() : undefined;
21
+ }
22
+ const body = await response.text();
23
+ throw new errors_1.XError(response.statusText, { body });
24
+ };
25
+ exports.getLeasingConditions = getLeasingConditions;
26
+ const createLeasingConditions = async (tenantId, conditions) => {
27
+ const auth = await utils_1.getAdminAuth();
28
+ const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/api/leasing/conditions`, {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ Authorization: auth,
33
+ [constants_1.TENANT_ID_ADMIN_HEADER]: tenantId,
34
+ },
35
+ body: JSON.stringify(conditions),
36
+ });
37
+ if (response.status === 200) {
38
+ return response.json();
39
+ }
40
+ const body = await response.text();
41
+ throw new errors_1.XError(response.statusText, { body });
42
+ };
43
+ exports.createLeasingConditions = createLeasingConditions;
44
+ const getLeasingContract = async (tenantId, contractId) => {
45
+ const auth = await utils_1.getAdminAuth();
46
+ const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}`, {
47
+ headers: {
48
+ Authorization: auth,
49
+ [constants_1.TENANT_ID_ADMIN_HEADER]: tenantId,
50
+ },
51
+ });
52
+ if (response.ok) {
53
+ return response.status === 200 ? response.json() : undefined;
54
+ }
55
+ const body = await response.text();
56
+ throw new errors_1.XError(response.statusText, { body });
57
+ };
58
+ exports.getLeasingContract = getLeasingContract;
59
+ const upsertLeasingContract = async (tenantId, contract) => {
60
+ const auth = await utils_1.getAdminAuth();
61
+ const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/api/leasing/contracts`, {
62
+ method: 'POST',
63
+ headers: {
64
+ 'Content-Type': 'application/json',
65
+ Authorization: auth,
66
+ [constants_1.TENANT_ID_ADMIN_HEADER]: tenantId,
67
+ },
68
+ body: JSON.stringify(contract),
69
+ });
70
+ if (response.status === 200) {
71
+ return response.json();
72
+ }
73
+ const body = await response.text();
74
+ throw new errors_1.XError(response.statusText, { body });
75
+ };
76
+ exports.upsertLeasingContract = upsertLeasingContract;
77
+ //# sourceMappingURL=leasing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leasing.js","sour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,EAAE,kBAAkB;YAClC,aAAa,EAAE,IAAI;YACnB,CAAC,kCAAsB,CAAC,EAAE,QAAQ;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;KACxB;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,eAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AArBW,QAAA,qBAAqB,yBAqBhC"}
@@ -1,3 +1,4 @@
1
1
  import { Vehicle } from '../types/vehicles';
2
2
  export declare const getVehicle: (tenantId: string, vehicleId: string) => Promise<Vehicle | undefined>;
3
+ export declare const getVehicleByStockNumber: (tenantId: string, stockNumber: string) => Promise<Vehicle | undefined>;
3
4
  //# sourceMappingURL=vehicles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vehicles.d.ts","sourceRoot":"","sources":["../../src/apis/vehicles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,eAAO,MAAM,UAAU,aACX,MAAM,aACL,MAAM,KAChB,QAAQ,OAAO,GAAG,SAAS,CAkB7B,CAAC"}
1
+ {"version":3,"file":"vehicles.d.ts","sourceRoot":"","sources":["../../src/apis/vehicles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,eAAO,MAAM,UAAU,aACX,MAAM,aACL,MAAM,KAChB,QAAQ,OAAO,GAAG,SAAS,CAkB7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACxB,MAAM,eACH,MAAM,KAClB,QAAQ,OAAO,GAAG,SAAS,CAkB7B,CAAC"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getVehicle = void 0;
6
+ exports.getVehicleByStockNumber = exports.getVehicle = void 0;
7
7
  const constants_1 = require("@bisondesk/commons-sdk/lib/constants");
8
8
  const errors_1 = require("@bisondesk/commons/lib/errors");
9
9
  const node_fetch_1 = __importDefault(require("node-fetch"));
@@ -23,4 +23,19 @@ const getVehicle = async (tenantId, vehicleId) => {
23
23
  throw new errors_1.XError(response.statusText, { body });
24
24
  };
25
25
  exports.getVehicle = getVehicle;
26
+ const getVehicleByStockNumber = async (tenantId, stockNumber) => {
27
+ const auth = await utils_1.getAdminAuth();
28
+ const response = await node_fetch_1.default(`${process.env.CORE_API_ORIGIN}/api/vehicles/stock-number/${stockNumber}`, {
29
+ headers: {
30
+ Authorization: auth,
31
+ [constants_1.TENANT_ID_ADMIN_HEADER]: tenantId,
32
+ },
33
+ });
34
+ if (response.ok) {
35
+ return response.status === 200 ? response.json() : undefined;
36
+ }
37
+ const body = await response.text();
38
+ throw new errors_1.XError(response.statusText, { body });
39
+ };
40
+ exports.getVehicleByStockNumber = getVehicleByStockNumber;
26
41
  //# sourceMappingURL=vehicles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vehicles.js","sourceRoot":"","sources":["../../src/apis/vehicles.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA8E;AAC9E,0DAAuD;AACvD,4DAA6C;AAE7C,mCAAuC;AAEhC,MAAM,UAAU,GAAG,KAAK,EAC7B,QAAgB,EAChB,SAAiB,EACa,EAAE;IAChC,MAAM,IAAI,GAAG,MAAM,oBAAY,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAa,MAAM,oBAAK,CACpC,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,iBAAiB,SAAS,EAAE,EAC1D;QACE,OAAO,EAAE;YACP,aAAa,EAAE,IAAI;YACnB,CAAC,kC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AAuB,GAAG,KAAK,EAC1C,QAAgB,EAChB,WAAmB,EACW,EAAE;IAChC,MAAM,IAAI,GAAG,MAAM,oBAAY,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAa,MAAM,oBAAK,CACpC,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,8BAA8B,WAAW,EAAE,EACzE;QACE,OAAO,EAAE;YACP,aAAa,EAAE,IAAI;YACnB,CAAC,kCAAsB,CAAC,EAAE,QAAQ;SACnC;KACF,CACF,CAAC;IAEF,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;KAC9D;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,eAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AArBW,QAAA,uBAAuB,2BAqBlC"}
@@ -23,6 +23,7 @@ export declare type EsDefinition = {
23
23
  fields: {
24
24
  [fieldId: string]: {
25
25
  esMapping: unknown;
26
+ sortKey?: string;
26
27
  };
27
28
  };
28
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/types/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,oBAAY,sBAAsB,GAAG;IACnC,MAAM,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC;IAC3C,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB,CAAC;AAKF,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAA;KA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E;QACN,CAAC,OAAO,EAAE,MAAM,GAAG;YACjB,SAAS,EAAE,OAAO,CAAC;YACnB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,oBAAY,0BAA0B,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AAEtE,oBAAY,wBAAwB,GAAG,WAAW,EAAE,CAAC"}
@@ -0,0 +1,136 @@
1
+ import { Organization } from './crm';
2
+ import { PublicSearchDefinition } from './definitions';
3
+ export declare type LeasingPublicSearchDefinitions = {
4
+ searchLeasingContract: PublicSearchDefinition;
5
+ };
6
+ export declare type LeasingContractEvent = {
7
+ id: string;
8
+ action: 'upsert' | 'delete';
9
+ actionAt: string;
10
+ userId: string;
11
+ tenantId: string;
12
+ };
13
+ export declare type LeasingContractImportEvent = {
14
+ tenantId: string;
15
+ };
16
+ export declare type LeasingConditionEvent = {
17
+ id: string;
18
+ action: 'create';
19
+ actionAt: string;
20
+ userId: string;
21
+ tenantId: string;
22
+ };
23
+ export declare type SearchLeasingContract = {
24
+ contract: LeasingContract;
25
+ conditions: Omit<LeasingConditions, 'cashIn' | 'cashOut'>;
26
+ org: Organization;
27
+ };
28
+ export declare type LeasingContract = {
29
+ id: string;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ contractNumber: string;
33
+ startDate: string;
34
+ accountManager?: string;
35
+ branch?: string;
36
+ client: {
37
+ organizationId: string;
38
+ contactIds: string[];
39
+ };
40
+ vehicle: {
41
+ id: string;
42
+ stockNumber: string;
43
+ administrativeNumber?: string;
44
+ };
45
+ conditions: ConditionsRef[];
46
+ };
47
+ export declare type ConditionsRef = {
48
+ id: string;
49
+ validSince: string;
50
+ };
51
+ export declare type NewLeasingConditions = {
52
+ parameters: {
53
+ yearlyRoadTax: string;
54
+ civilLiability: string;
55
+ oneTimeRoadTax: string;
56
+ specialInsurance: string;
57
+ allRisksPercentage: string;
58
+ allRisksTaxPercentage: string;
59
+ };
60
+ inputs: {
61
+ deposit: string;
62
+ salesPrice: string;
63
+ bankDeposit: string;
64
+ purchasePrice: string;
65
+ residualValue: string;
66
+ insuranceAmount: string;
67
+ durationInMonths: string;
68
+ includesAllRisks: boolean;
69
+ marginPercentage: string;
70
+ bankResidualValue: string;
71
+ bankDurationInMonths: string;
72
+ startupFeePercentage: string;
73
+ includesYearlyRoadTax: boolean;
74
+ includesCivilLiability: boolean;
75
+ includesOneTimeRoadTax: boolean;
76
+ interestRatePercentage: string;
77
+ includesSpecialInsurance: boolean;
78
+ monthlyAdministrationFee: string;
79
+ bankInterestRatePercentage: string;
80
+ };
81
+ outputs: {
82
+ ROI: string;
83
+ ROITarget: string;
84
+ ROIPerYear: string;
85
+ cashDeficit: string;
86
+ totalProfit: string;
87
+ ROIDifference: string;
88
+ leasingAmount: string;
89
+ leasingProfit: string;
90
+ vehicleProfit: string;
91
+ yearlyTaxCost: string;
92
+ monthlyTaxCost: string;
93
+ oneTimeTaxCost: string;
94
+ financingAmount: string;
95
+ bankContractValue: string;
96
+ bankLeasingAmount: string;
97
+ totalMonthlyPayment: string;
98
+ yearlyInsuranceCost: string;
99
+ leasingContractValue: string;
100
+ monthlyInsuranceCost: string;
101
+ yearlyTaxRetailPrice: string;
102
+ monthlyTaxRetailPrice: string;
103
+ allRisksInsuranceAmount: string;
104
+ yearlyInsuranceRetailPrice: string;
105
+ monthlyInsuranceRetailPrice: string;
106
+ monthlyInsuranceAndTaxesRetailPrice: string;
107
+ };
108
+ cashIn: Array<{
109
+ time: string;
110
+ cashIn: string;
111
+ deposit: string;
112
+ startupFee: string;
113
+ taxPayment: string;
114
+ residualValue: string;
115
+ cumulativeCash: string;
116
+ insurancePayment: string;
117
+ monthlyAdministrationFee: string;
118
+ leasingAmountWithoutAdminFee: string;
119
+ }>;
120
+ cashOut: Array<{
121
+ time: string;
122
+ cashOut: string;
123
+ deposit: string;
124
+ taxPayment: string;
125
+ leasingAmount: string;
126
+ residualValue: string;
127
+ cumulativeCash: string;
128
+ insurancePayment: string;
129
+ }>;
130
+ };
131
+ export declare type LeasingConditions = NewLeasingConditions & {
132
+ id: string;
133
+ createdAt: string;
134
+ createdBy: string;
135
+ };
136
+ //# sourceMappingURL=leasing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leasing.d.ts","sourceRoot":"","sources":["../../src/types/leasing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,oBAAY,8BAA8B,GAAG;IAC3C,qBAAqB,EAAE,sBAAsB,CAAC;CAC/C,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,0BAA0B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IAClC,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;IAC1D,GAAG,EAAE,YAAY,CAAC;CACnB,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,EAAE,MAAM,CAAC;IACvB,SAA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M,CAAC;QACjC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;CACJ,CAAC;AAEF,oBAAY,iBAAiB,GAAG,oBAAoB,GAAG;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=leasing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leasing.js","sourceRoot":"","sources":["../../src/types/leasing.ts"],"names":[],"mappings":""}
@@ -9,6 +9,9 @@ export declare type NewUserRequest = {
9
9
  phone: PhoneNumberRawValue;
10
10
  roles: AppRoles[];
11
11
  };
12
+ export declare type UpdateUserRequest = Omit<User, 'phone'> & {
13
+ phone: PhoneNumberRawValue | PhoneNumberValue;
14
+ };
12
15
  export declare type User = {
13
16
  active: boolean;
14
17
  createdAt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/types/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,oBAAY,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MA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CAAC,GAAG;IACpD,KAAK,EAAE,mBAAmB,GAAG,gBAAgB,CAAC;CAC/C,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,oBAAY,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/core-sdk",
3
- "version": "1.0.67",
3
+ "version": "1.0.68",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rm -rf build dist lib *.tsbuildinfo",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "author": "Ivo Anastácio",
13
13
  "dependencies": {
14
- "@bisondesk/commons-sdk": "1.0.67",
14
+ "@bisondesk/commons-sdk": "1.0.68",
15
15
  "joi": "17.4.0",
16
16
  "lru-cache": "6.0.0"
17
17
  },
package/src/apis/crm.ts CHANGED
@@ -27,6 +27,29 @@ export const getCrmOrganization = async (
27
27
  throw new XError(response.statusText, { body });
28
28
  };
29
29
 
30
+ export const getCrmOrganizationByExternalId = async (
31
+ tenantId: string,
32
+ externalId: string
33
+ ): Promise<Organization | undefined> => {
34
+ const auth = await getAdminAuth();
35
+ const response: Response = await fetch(
36
+ `${process.env.CORE_API_ORIGIN}/api/crm/organizations/external-id/${externalId}`,
37
+ {
38
+ headers: {
39
+ Authorization: auth,
40
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
41
+ },
42
+ }
43
+ );
44
+
45
+ if (response.ok) {
46
+ return response.status === 200 ? response.json() : undefined;
47
+ }
48
+
49
+ const body = await response.text();
50
+ throw new XError(response.statusText, { body });
51
+ };
52
+
30
53
  export const listCrmContacts = async (
31
54
  tenantId: string,
32
55
  organizationId: string
@@ -0,0 +1,97 @@
1
+ import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/lib/constants';
2
+ import { XError } from '@bisondesk/commons/lib/errors';
3
+ import fetch, { Response } from 'node-fetch';
4
+ import { LeasingConditions, LeasingContract, NewLeasingConditions } from '../types/leasing';
5
+ import { getAdminAuth } from './utils';
6
+
7
+ export const getLeasingConditions = async (
8
+ tenantId: string,
9
+ conditionsId: string
10
+ ): Promise<LeasingConditions | undefined> => {
11
+ const auth = await getAdminAuth();
12
+ const response: Response = await fetch(
13
+ `${process.env.CORE_API_ORIGIN}/api/leasing/conditions/${conditionsId}`,
14
+ {
15
+ headers: {
16
+ Authorization: auth,
17
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
18
+ },
19
+ }
20
+ );
21
+
22
+ if (response.ok) {
23
+ return response.status === 200 ? response.json() : undefined;
24
+ }
25
+
26
+ const body = await response.text();
27
+ throw new XError(response.statusText, { body });
28
+ };
29
+
30
+ export const createLeasingConditions = async (
31
+ tenantId: string,
32
+ conditions: NewLeasingConditions
33
+ ): Promise<LeasingConditions> => {
34
+ const auth = await getAdminAuth();
35
+ const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/leasing/conditions`, {
36
+ method: 'POST',
37
+ headers: {
38
+ 'Content-Type': 'application/json',
39
+ Authorization: auth,
40
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
41
+ },
42
+ body: JSON.stringify(conditions),
43
+ });
44
+
45
+ if (response.status === 200) {
46
+ return response.json();
47
+ }
48
+
49
+ const body = await response.text();
50
+ throw new XError(response.statusText, { body });
51
+ };
52
+
53
+ export const getLeasingContract = async (
54
+ tenantId: string,
55
+ contractId: string
56
+ ): Promise<LeasingContract | undefined> => {
57
+ const auth = await getAdminAuth();
58
+ const response: Response = await fetch(
59
+ `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}`,
60
+ {
61
+ headers: {
62
+ Authorization: auth,
63
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
64
+ },
65
+ }
66
+ );
67
+
68
+ if (response.ok) {
69
+ return response.status === 200 ? response.json() : undefined;
70
+ }
71
+
72
+ const body = await response.text();
73
+ throw new XError(response.statusText, { body });
74
+ };
75
+
76
+ export const upsertLeasingContract = async (
77
+ tenantId: string,
78
+ contract: LeasingContract
79
+ ): Promise<LeasingContract> => {
80
+ const auth = await getAdminAuth();
81
+ const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/leasing/contracts`, {
82
+ method: 'POST',
83
+ headers: {
84
+ 'Content-Type': 'application/json',
85
+ Authorization: auth,
86
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
87
+ },
88
+ body: JSON.stringify(contract),
89
+ });
90
+
91
+ if (response.status === 200) {
92
+ return response.json();
93
+ }
94
+
95
+ const body = await response.text();
96
+ throw new XError(response.statusText, { body });
97
+ };
@@ -26,3 +26,26 @@ export const getVehicle = async (
26
26
  const body = await response.text();
27
27
  throw new XError(response.statusText, { body });
28
28
  };
29
+
30
+ export const getVehicleByStockNumber = async (
31
+ tenantId: string,
32
+ stockNumber: string
33
+ ): Promise<Vehicle | undefined> => {
34
+ const auth = await getAdminAuth();
35
+ const response: Response = await fetch(
36
+ `${process.env.CORE_API_ORIGIN}/api/vehicles/stock-number/${stockNumber}`,
37
+ {
38
+ headers: {
39
+ Authorization: auth,
40
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
41
+ },
42
+ }
43
+ );
44
+
45
+ if (response.ok) {
46
+ return response.status === 200 ? response.json() : undefined;
47
+ }
48
+
49
+ const body = await response.text();
50
+ throw new XError(response.statusText, { body });
51
+ };
@@ -27,6 +27,7 @@ export type EsDefinition = {
27
27
  fields: {
28
28
  [fieldId: string]: {
29
29
  esMapping: unknown;
30
+ sortKey?: string;
30
31
  };
31
32
  };
32
33
  };
@@ -0,0 +1,153 @@
1
+ import { Organization } from './crm';
2
+ import { PublicSearchDefinition } from './definitions';
3
+
4
+ export type LeasingPublicSearchDefinitions = {
5
+ searchLeasingContract: PublicSearchDefinition;
6
+ };
7
+
8
+ export type LeasingContractEvent = {
9
+ id: string;
10
+ action: 'upsert' | 'delete';
11
+ actionAt: string;
12
+ userId: string;
13
+ tenantId: string;
14
+ };
15
+
16
+ export type LeasingContractImportEvent = {
17
+ tenantId: string;
18
+ };
19
+
20
+ export type LeasingConditionEvent = {
21
+ id: string;
22
+ action: 'create';
23
+ actionAt: string;
24
+ userId: string;
25
+ tenantId: string;
26
+ };
27
+
28
+ export type SearchLeasingContract = {
29
+ contract: LeasingContract;
30
+ conditions: Omit<LeasingConditions, 'cashIn' | 'cashOut'>;
31
+ org: Organization;
32
+ };
33
+
34
+ export type LeasingContract = {
35
+ id: string;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+
39
+ contractNumber: string;
40
+ startDate: string;
41
+
42
+ accountManager?: string;
43
+ branch?: string; // 'MrLease', 'MrLease NL', ...
44
+
45
+ client: {
46
+ organizationId: string;
47
+ contactIds: string[];
48
+ };
49
+
50
+ vehicle: {
51
+ id: string;
52
+ stockNumber: string;
53
+ administrativeNumber?: string;
54
+ };
55
+
56
+ conditions: ConditionsRef[];
57
+ };
58
+
59
+ export type ConditionsRef = {
60
+ id: string;
61
+ validSince: string;
62
+ };
63
+
64
+ export type NewLeasingConditions = {
65
+ parameters: {
66
+ yearlyRoadTax: string;
67
+ civilLiability: string;
68
+ oneTimeRoadTax: string;
69
+ specialInsurance: string;
70
+ allRisksPercentage: string;
71
+ allRisksTaxPercentage: string;
72
+ };
73
+
74
+ inputs: {
75
+ deposit: string;
76
+ salesPrice: string;
77
+ bankDeposit: string;
78
+ purchasePrice: string;
79
+ residualValue: string;
80
+ insuranceAmount: string;
81
+ durationInMonths: string;
82
+ includesAllRisks: boolean;
83
+ marginPercentage: string;
84
+ bankResidualValue: string;
85
+ bankDurationInMonths: string;
86
+ startupFeePercentage: string;
87
+ includesYearlyRoadTax: boolean;
88
+ includesCivilLiability: boolean;
89
+ includesOneTimeRoadTax: boolean;
90
+ interestRatePercentage: string;
91
+ includesSpecialInsurance: boolean;
92
+ monthlyAdministrationFee: string;
93
+ bankInterestRatePercentage: string;
94
+ };
95
+
96
+ outputs: {
97
+ ROI: string;
98
+ ROITarget: string;
99
+ ROIPerYear: string;
100
+ cashDeficit: string;
101
+ totalProfit: string;
102
+ ROIDifference: string;
103
+ leasingAmount: string;
104
+ leasingProfit: string;
105
+ vehicleProfit: string;
106
+ yearlyTaxCost: string;
107
+ monthlyTaxCost: string;
108
+ oneTimeTaxCost: string;
109
+ financingAmount: string;
110
+ bankContractValue: string;
111
+ bankLeasingAmount: string;
112
+ totalMonthlyPayment: string;
113
+ yearlyInsuranceCost: string;
114
+ leasingContractValue: string;
115
+ monthlyInsuranceCost: string;
116
+ yearlyTaxRetailPrice: string;
117
+ monthlyTaxRetailPrice: string;
118
+ allRisksInsuranceAmount: string;
119
+ yearlyInsuranceRetailPrice: string;
120
+ monthlyInsuranceRetailPrice: string;
121
+ monthlyInsuranceAndTaxesRetailPrice: string;
122
+ };
123
+
124
+ cashIn: Array<{
125
+ time: string;
126
+ cashIn: string;
127
+ deposit: string;
128
+ startupFee: string;
129
+ taxPayment: string;
130
+ residualValue: string;
131
+ cumulativeCash: string;
132
+ insurancePayment: string;
133
+ monthlyAdministrationFee: string;
134
+ leasingAmountWithoutAdminFee: string;
135
+ }>;
136
+
137
+ cashOut: Array<{
138
+ time: string;
139
+ cashOut: string;
140
+ deposit: string;
141
+ taxPayment: string;
142
+ leasingAmount: string;
143
+ residualValue: string;
144
+ cumulativeCash: string;
145
+ insurancePayment: string;
146
+ }>;
147
+ };
148
+
149
+ export type LeasingConditions = NewLeasingConditions & {
150
+ id: string;
151
+ createdAt: string;
152
+ createdBy: string;
153
+ };
@@ -11,6 +11,10 @@ export type NewUserRequest = {
11
11
  roles: AppRoles[];
12
12
  };
13
13
 
14
+ export type UpdateUserRequest = Omit<User, 'phone'> & {
15
+ phone: PhoneNumberRawValue | PhoneNumberValue;
16
+ };
17
+
14
18
  export type User = {
15
19
  active: boolean;
16
20
  createdAt: string;
@@ -497,8 +497,8 @@
497
497
  "affectsGlobalScope": false
498
498
  },
499
499
  "./src/types/definitions.ts": {
500
- "version": "657ad243063919f34da721764acc99c240ee99c6a546d0d339268f293702fc94",
501
- "signature": "8c65e0034817c4e04a719d004b9ec2360c01331ee887f5b87fdc45f98d501bff",
500
+ "version": "a64a50adb8f897ae1e6d94fe94ed9c9c44f774ce17372bf88f628942cbf35786",
501
+ "signature": "8cadd33a80bcb2e1b6eca43dd36264930afb33a91dae32dd4cec149bfd18f548",
502
502
  "affectsGlobalScope": false
503
503
  },
504
504
  "./src/types/crm.ts": {
@@ -522,8 +522,18 @@
522
522
  "affectsGlobalScope": false
523
523
  },
524
524
  "./src/apis/crm.ts": {
525
- "version": "99f3d710229f0926bdbbc1ec77108d5ae28438d5a4ce0ee205236e6274c91e0e",
526
- "signature": "5cf7fd3d704f61cc7fd0a6fffac75adb11f800932245feccb8892e33b6a1adc7",
525
+ "version": "3fe086b9f2e55c59614be4d22319307bd40adc7e94c0f04d45abd381cd271a70",
526
+ "signature": "071aec73d311ab19841d34f14fd275329d6d6f0b070e661eae19e4af8825a8e6",
527
+ "affectsGlobalScope": false
528
+ },
529
+ "./src/types/leasing.ts": {
530
+ "version": "7496689db3b9448122af909640b9f44ca84fe9d2ae81f4fee1bbf1a9a094aaa5",
531
+ "signature": "311ccb9252bc1e3eebcfe0842ef5889c1114a2851518df5bd1a1414422180237",
532
+ "affectsGlobalScope": false
533
+ },
534
+ "./src/apis/leasing.ts": {
535
+ "version": "98073a19551ba786ac654303f92f795464e10175894c0ebe760a211857d31527",
536
+ "signature": "3c35852f17450e473e242360b060a5feeba97f3ed1493cf519b6f4a39ce067fd",
527
537
  "affectsGlobalScope": false
528
538
  },
529
539
  "./src/apis/settings.ts": {
@@ -552,8 +562,8 @@
552
562
  "affectsGlobalScope": false
553
563
  },
554
564
  "./src/apis/vehicles.ts": {
555
- "version": "3507afefd99521b63938f3f06375a17bf78b5d6c29ce686fd5eea77d26522a7f",
556
- "signature": "d46b96fc4e5d6adbe1e589ae6cf73487704974ceb086d61cefacebe6d33093d6",
565
+ "version": "60889e93898798b8f79bf3d08dd86248fb5f4ed5f5cde4cb45f072a61674c016",
566
+ "signature": "b715c10ba458f9f3de7c97f3f74122bc1e4e28747a09e966b99bfb1180e58853",
557
567
  "affectsGlobalScope": false
558
568
  },
559
569
  "./src/types/conversations.ts": {
@@ -587,8 +597,8 @@
587
597
  "affectsGlobalScope": false
588
598
  },
589
599
  "./src/types/users.ts": {
590
- "version": "4284a9d44739efad755611cff2503b39eb6f8aabd92c271f48a89d06c5b375cf",
591
- "signature": "3a34050f15e479ebb7f2290c06667ffbfe74b1ee88e4ce3bf0a5fc832ce5ed50",
600
+ "version": "298c5dc641a1f8f48a35ae24988ae2c3fe029dbfbea9af7b5e90775945cab90f",
601
+ "signature": "d2baf1a49b06a57b9ce0e3e2b0a8f046189decfe7c42c890f6ac2aefa4a56983",
592
602
  "affectsGlobalScope": false
593
603
  },
594
604
  "./src/types/utils.ts": {
@@ -2016,6 +2026,13 @@
2016
2026
  "./src/apis/utils.ts",
2017
2027
  "./src/types/crm.ts"
2018
2028
  ],
2029
+ "./src/apis/leasing.ts": [
2030
+ "../../node_modules/@types/node-fetch/index.d.ts",
2031
+ "../commons-sdk/lib/constants.d.ts",
2032
+ "../commons/lib/errors.d.ts",
2033
+ "./src/apis/utils.ts",
2034
+ "./src/types/leasing.ts"
2035
+ ],
2019
2036
  "./src/apis/settings.ts": [
2020
2037
  "../../node_modules/@types/node-fetch/index.d.ts",
2021
2038
  "../commons-sdk/lib/constants.d.ts",
@@ -2057,6 +2074,10 @@
2057
2074
  "./src/types/definitions.ts",
2058
2075
  "./src/types/vehicles.ts"
2059
2076
  ],
2077
+ "./src/types/leasing.ts": [
2078
+ "./src/types/crm.ts",
2079
+ "./src/types/definitions.ts"
2080
+ ],
2060
2081
  "./src/types/picklists.ts": [
2061
2082
  "../commons-sdk/lib/types.d.ts"
2062
2083
  ],
@@ -2872,6 +2893,9 @@
2872
2893
  "./src/apis/crm.ts": [
2873
2894
  "./src/types/crm.ts"
2874
2895
  ],
2896
+ "./src/apis/leasing.ts": [
2897
+ "./src/types/leasing.ts"
2898
+ ],
2875
2899
  "./src/apis/tenants.ts": [
2876
2900
  "./src/types/tenants.ts"
2877
2901
  ],
@@ -2894,6 +2918,10 @@
2894
2918
  "./src/types/definitions.ts",
2895
2919
  "./src/types/vehicles.ts"
2896
2920
  ],
2921
+ "./src/types/leasing.ts": [
2922
+ "./src/types/crm.ts",
2923
+ "./src/types/definitions.ts"
2924
+ ],
2897
2925
  "./src/types/picklists.ts": [
2898
2926
  "../commons-sdk/lib/types.d.ts"
2899
2927
  ],
@@ -3138,6 +3166,7 @@
3138
3166
  "./node_modules/@types/node/worker_threads.d.ts",
3139
3167
  "./node_modules/@types/node/zlib.d.ts",
3140
3168
  "./src/apis/crm.ts",
3169
+ "./src/apis/leasing.ts",
3141
3170
  "./src/apis/settings.ts",
3142
3171
  "./src/apis/tenants.ts",
3143
3172
  "./src/apis/utils.ts",
@@ -3149,6 +3178,7 @@
3149
3178
  "./src/types/events.ts",
3150
3179
  "./src/types/fields.ts",
3151
3180
  "./src/types/leads.ts",
3181
+ "./src/types/leasing.ts",
3152
3182
  "./src/types/picklists.ts",
3153
3183
  "./src/types/search.ts",
3154
3184
  "./src/types/settings.ts",