@xapp/stentor-service-fieldroutes 0.0.1
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/LICENSE.md +176 -0
- package/README.md +45 -0
- package/lib/FieldRoutesService.d.ts +82 -0
- package/lib/FieldRoutesService.js +280 -0
- package/lib/FieldRoutesService.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/models.d.ts +100 -0
- package/lib/models.js +4 -0
- package/lib/models.js.map +1 -0
- package/lib/util.d.ts +24 -0
- package/lib/util.js +82 -0
- package/lib/util.js.map +1 -0
- package/package.json +49 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
## @xapp/stentor-service-fieldroutes
|
|
2
|
+
|
|
3
|
+
Implementation of `CrmService` for [FieldRoutes](https://api.fieldroutes.com/index) (formerly PestRoutes) — a field-service management platform for pest control and lawn care.
|
|
4
|
+
|
|
5
|
+
### Status
|
|
6
|
+
|
|
7
|
+
Scaffold. The `CrmService` surface (`send`, `getAvailability`) is implemented, but the FieldRoutes
|
|
8
|
+
API details (endpoint paths, request encoding, response envelope) are modeled from the documented
|
|
9
|
+
conventions and **must be verified against the live API and a real office** before production use.
|
|
10
|
+
Everything HTTP flows through the single `request()` method in `FieldRoutesService`, so confirming
|
|
11
|
+
the transport is a localized change. Search the source for `TODO` and `NOTE:`.
|
|
12
|
+
|
|
13
|
+
### Configuration
|
|
14
|
+
|
|
15
|
+
`FieldRoutesService` is constructed with:
|
|
16
|
+
|
|
17
|
+
- `subdomain` — the office subdomain, e.g. `acmepest` → `https://acmepest.fieldroutes.com/api`
|
|
18
|
+
- `authenticate()` — returns `{ authenticationKey, authenticationToken }` (office-scoped credentials)
|
|
19
|
+
- `appId` — the Studio app id
|
|
20
|
+
- `sourceID` (optional) — FieldRoutes lead source id to stamp on created customers
|
|
21
|
+
- `defaultAppointmentType` (optional) — appointment type id used when one can't be resolved
|
|
22
|
+
|
|
23
|
+
### Behavior
|
|
24
|
+
|
|
25
|
+
`send()`:
|
|
26
|
+
|
|
27
|
+
1. Matches an existing customer by phone/email (`customer/search`).
|
|
28
|
+
2. Updates the match or creates a new customer (`customer/update` / `customer/create`).
|
|
29
|
+
3. If the lead carries a `DATETIME`, books an appointment (`appointment/create`) — non-fatal on failure.
|
|
30
|
+
|
|
31
|
+
### To verify against the FieldRoutes docs
|
|
32
|
+
|
|
33
|
+
- Auth: are `authenticationKey`/`authenticationToken` query params, form fields, or headers?
|
|
34
|
+
- Search: does `customer/search` return `customerIDs`, and is it GET or POST?
|
|
35
|
+
- Create/update: response envelope + the id field name (`customerID`?).
|
|
36
|
+
- Appointment/subscription: the required fields for booking, and appointment-type ids.
|
|
37
|
+
- Availability: whether `getAvailability` should be backed by route capacity / `appointment/search`.
|
|
38
|
+
|
|
39
|
+
### Testing
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn workspace @xapp/stentor-service-fieldroutes local
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Tests mock the HTTP layer with `axios-mock-adapter`; no live credentials required.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*! Copyright (c) 2025, XAPP AI */
|
|
2
|
+
import { FetchService } from "stentor-service-fetch";
|
|
3
|
+
import { BaseService, CrmResponse, CrmService, CrmServiceAvailability, CrmServiceAvailabilityOptions, CrmServiceAvailabilitySettings, DateTimeRange, ExternalLead } from "stentor-models";
|
|
4
|
+
import { CustomerQuery, FieldRoutesAppointment, FieldRoutesCustomer, FieldRoutesResponse } from "./models";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the FieldRoutes credentials for a request.
|
|
7
|
+
*
|
|
8
|
+
* FieldRoutes (formerly PestRoutes) authenticates every call with an office-scoped
|
|
9
|
+
* `authenticationKey` + `authenticationToken` pair.
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.fieldroutes.com/index
|
|
12
|
+
*/
|
|
13
|
+
export interface FieldRoutesAuthenticator {
|
|
14
|
+
(): Promise<{
|
|
15
|
+
authenticationKey: string;
|
|
16
|
+
authenticationToken: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export interface FieldRoutesServiceProps extends BaseService, CrmServiceAvailabilitySettings {
|
|
20
|
+
appId: string;
|
|
21
|
+
/**
|
|
22
|
+
* The office subdomain, e.g. "acmepest" -> https://acmepest.fieldroutes.com/api
|
|
23
|
+
*/
|
|
24
|
+
subdomain: string;
|
|
25
|
+
channel?: string;
|
|
26
|
+
authenticate: FieldRoutesAuthenticator;
|
|
27
|
+
openAI?: {
|
|
28
|
+
apiKey: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* FieldRoutes appointment type id used when we cannot resolve one from the description.
|
|
32
|
+
*/
|
|
33
|
+
defaultAppointmentType?: string;
|
|
34
|
+
/**
|
|
35
|
+
* FieldRoutes lead source id (numeric string) to stamp on created customers.
|
|
36
|
+
*/
|
|
37
|
+
sourceID?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* CrmService implementation for FieldRoutes.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: The FieldRoutes API surface (endpoint paths, request encoding, response envelope) is
|
|
43
|
+
* modeled here from the documented PestRoutes/FieldRoutes conventions and MUST be verified against
|
|
44
|
+
* the live docs at https://api.fieldroutes.com/index and a real office before going to production.
|
|
45
|
+
* The HTTP transport is centralized in {@link FieldRoutesService.request} to keep that easy to adjust.
|
|
46
|
+
*/
|
|
47
|
+
export declare class FieldRoutesService extends FetchService implements CrmService {
|
|
48
|
+
private props;
|
|
49
|
+
constructor(props: FieldRoutesServiceProps);
|
|
50
|
+
private get baseUrl();
|
|
51
|
+
/**
|
|
52
|
+
* getAvailability is not yet wired to FieldRoutes; returns full availability so the scheduler
|
|
53
|
+
* does not block. TODO: back this with appointment/search + route capacity.
|
|
54
|
+
*/
|
|
55
|
+
getAvailability(range: DateTimeRange, _options?: CrmServiceAvailabilityOptions): Promise<CrmServiceAvailability>;
|
|
56
|
+
/**
|
|
57
|
+
* Send a lead to FieldRoutes: match-or-create the customer, then (if a date was provided)
|
|
58
|
+
* create the appointment.
|
|
59
|
+
*/
|
|
60
|
+
send(externalLead: ExternalLead, extras?: Record<string, unknown>): Promise<CrmResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Search for customers by phone or email. Returns the matching FieldRoutes customer ids.
|
|
63
|
+
*/
|
|
64
|
+
getCustomers(query: CustomerQuery): Promise<FieldRoutesResponse<string[]>>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a customer in FieldRoutes. Returns the new customer id in `data`.
|
|
67
|
+
*/
|
|
68
|
+
addCustomer(customer: FieldRoutesCustomer): Promise<FieldRoutesResponse<string>>;
|
|
69
|
+
/**
|
|
70
|
+
* Update an existing customer. `customer.customerID` must be set.
|
|
71
|
+
*/
|
|
72
|
+
updateCustomer(customer: FieldRoutesCustomer): Promise<FieldRoutesResponse<string>>;
|
|
73
|
+
/**
|
|
74
|
+
* Create an appointment in FieldRoutes.
|
|
75
|
+
*/
|
|
76
|
+
addAppointment(appointment: FieldRoutesAppointment): Promise<FieldRoutesResponse<string>>;
|
|
77
|
+
/**
|
|
78
|
+
* Single HTTP chokepoint. Normalizes transport + FieldRoutes' `success`/`errorMessage` envelope
|
|
79
|
+
* into a {@link FieldRoutesResponse}. Adjust here if the live API differs from the assumed shape.
|
|
80
|
+
*/
|
|
81
|
+
private request;
|
|
82
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FieldRoutesService = void 0;
|
|
16
|
+
/*! Copyright (c) 2025, XAPP AI */
|
|
17
|
+
const stentor_service_fetch_1 = require("stentor-service-fetch");
|
|
18
|
+
const stentor_logger_1 = require("stentor-logger");
|
|
19
|
+
const axios_1 = __importDefault(require("axios"));
|
|
20
|
+
const addresser_1 = require("addresser");
|
|
21
|
+
const util_1 = require("./util");
|
|
22
|
+
const CRM_DEBUG = process.env.CRM_DEBUG === "true";
|
|
23
|
+
/**
|
|
24
|
+
* CrmService implementation for FieldRoutes.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: The FieldRoutes API surface (endpoint paths, request encoding, response envelope) is
|
|
27
|
+
* modeled here from the documented PestRoutes/FieldRoutes conventions and MUST be verified against
|
|
28
|
+
* the live docs at https://api.fieldroutes.com/index and a real office before going to production.
|
|
29
|
+
* The HTTP transport is centralized in {@link FieldRoutesService.request} to keep that easy to adjust.
|
|
30
|
+
*/
|
|
31
|
+
class FieldRoutesService extends stentor_service_fetch_1.FetchService {
|
|
32
|
+
constructor(props) {
|
|
33
|
+
super(props);
|
|
34
|
+
this.props = Object.assign({}, props);
|
|
35
|
+
if (!this.props.channel) {
|
|
36
|
+
this.props.channel = "Chat";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get baseUrl() {
|
|
40
|
+
return `https://${this.props.subdomain}.fieldroutes.com/api`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* getAvailability is not yet wired to FieldRoutes; returns full availability so the scheduler
|
|
44
|
+
* does not block. TODO: back this with appointment/search + route capacity.
|
|
45
|
+
*/
|
|
46
|
+
getAvailability(range, _options) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
(0, stentor_logger_1.log)().debug(`${this.constructor.name} getAvailability not implemented, returning full availability.`);
|
|
49
|
+
return { range, unavailabilities: [] };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Send a lead to FieldRoutes: match-or-create the customer, then (if a date was provided)
|
|
54
|
+
* create the appointment.
|
|
55
|
+
*/
|
|
56
|
+
send(externalLead, extras) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
var _a;
|
|
59
|
+
const crmResponse = {
|
|
60
|
+
status: "Failure",
|
|
61
|
+
message: ""
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
const transcript = (0, util_1.leadToTranscript)(externalLead, this.props.appId);
|
|
65
|
+
const names = (0, util_1.getName)(externalLead);
|
|
66
|
+
const field = (name) => { var _a; return (_a = externalLead.fields.find((x) => x.name === name)) === null || _a === void 0 ? void 0 : _a.value; };
|
|
67
|
+
const address = field("ADDRESS");
|
|
68
|
+
const phone = field("PHONE");
|
|
69
|
+
const email = field("EMAIL");
|
|
70
|
+
const message = field("MESSAGE");
|
|
71
|
+
const dateTime = field("DATETIME");
|
|
72
|
+
let parsedAddress;
|
|
73
|
+
if (address) {
|
|
74
|
+
try {
|
|
75
|
+
parsedAddress = (0, addresser_1.parseAddress)(address);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
// Non-fatal: we still capture the lead, just without a structured address.
|
|
79
|
+
(0, stentor_logger_1.log)().warn(`FieldRoutes: Invalid address "${address}": ${err}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const notesParts = [message, transcript].filter(Boolean);
|
|
83
|
+
const crmRequest = {
|
|
84
|
+
fname: names.firstName,
|
|
85
|
+
lname: names.lastName,
|
|
86
|
+
phone1: phone,
|
|
87
|
+
email,
|
|
88
|
+
// FieldRoutes caps the customer notes field at 7500 chars.
|
|
89
|
+
notes: notesParts.join("\n\n").substring(0, 7500),
|
|
90
|
+
sourceID: this.props.sourceID,
|
|
91
|
+
officeID: extras === null || extras === void 0 ? void 0 : extras.officeID
|
|
92
|
+
};
|
|
93
|
+
if (parsedAddress) {
|
|
94
|
+
crmRequest.address = parsedAddress.addressLine1;
|
|
95
|
+
crmRequest.city = parsedAddress.placeName;
|
|
96
|
+
crmRequest.state = parsedAddress.stateAbbreviation;
|
|
97
|
+
crmRequest.zip = parsedAddress.zipCode;
|
|
98
|
+
}
|
|
99
|
+
// Match an existing customer by phone or email.
|
|
100
|
+
const query = {};
|
|
101
|
+
if (phone) {
|
|
102
|
+
query.phone = phone;
|
|
103
|
+
}
|
|
104
|
+
if (email) {
|
|
105
|
+
query.email = email;
|
|
106
|
+
}
|
|
107
|
+
const matches = yield this.getCustomers(query);
|
|
108
|
+
if (matches.status === "Failure") {
|
|
109
|
+
crmResponse.message = matches.error || "Failed to search customers";
|
|
110
|
+
return crmResponse;
|
|
111
|
+
}
|
|
112
|
+
const existingId = (_a = matches.data) === null || _a === void 0 ? void 0 : _a[0];
|
|
113
|
+
let customerId;
|
|
114
|
+
if (existingId) {
|
|
115
|
+
crmRequest.customerID = existingId;
|
|
116
|
+
const updated = yield this.updateCustomer(crmRequest);
|
|
117
|
+
if (updated.status === "Failure") {
|
|
118
|
+
crmResponse.message = updated.error || "Failed to update customer";
|
|
119
|
+
return crmResponse;
|
|
120
|
+
}
|
|
121
|
+
customerId = existingId;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const created = yield this.addCustomer(crmRequest);
|
|
125
|
+
if (created.status === "Failure") {
|
|
126
|
+
crmResponse.message = created.error || "Failed to create customer";
|
|
127
|
+
return crmResponse;
|
|
128
|
+
}
|
|
129
|
+
customerId = created.data;
|
|
130
|
+
}
|
|
131
|
+
// Only book an appointment when we have both a customer and a requested date.
|
|
132
|
+
if (customerId && dateTime) {
|
|
133
|
+
const appt = {
|
|
134
|
+
customerID: customerId,
|
|
135
|
+
type: this.props.defaultAppointmentType,
|
|
136
|
+
date: dateTime.substring(0, 10),
|
|
137
|
+
notes: message
|
|
138
|
+
};
|
|
139
|
+
const booked = yield this.addAppointment(appt);
|
|
140
|
+
if (booked.status === "Failure") {
|
|
141
|
+
// Non-fatal: the lead/customer is already captured.
|
|
142
|
+
(0, stentor_logger_1.log)().warn(`FieldRoutes: customer saved but appointment failed: ${booked.error}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
crmResponse.status = "Success";
|
|
146
|
+
crmResponse.refId = customerId;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
(0, stentor_logger_1.log)().error(`FieldRoutes error send(): ${err}`);
|
|
150
|
+
crmResponse.message = `${err}`;
|
|
151
|
+
}
|
|
152
|
+
return crmResponse;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Search for customers by phone or email. Returns the matching FieldRoutes customer ids.
|
|
157
|
+
*/
|
|
158
|
+
getCustomers(query) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
var _a;
|
|
161
|
+
const auth = yield this.props.authenticate();
|
|
162
|
+
const params = {
|
|
163
|
+
authenticationKey: auth.authenticationKey,
|
|
164
|
+
authenticationToken: auth.authenticationToken
|
|
165
|
+
};
|
|
166
|
+
if (query.email) {
|
|
167
|
+
params.email = query.email;
|
|
168
|
+
}
|
|
169
|
+
else if (query.phone) {
|
|
170
|
+
params.phone = query.phone;
|
|
171
|
+
}
|
|
172
|
+
const config = {
|
|
173
|
+
method: "get",
|
|
174
|
+
url: `${this.baseUrl}/customer/search`,
|
|
175
|
+
params
|
|
176
|
+
};
|
|
177
|
+
const response = yield this.request(config, "customer/search");
|
|
178
|
+
if (response.status === "Failure") {
|
|
179
|
+
return response;
|
|
180
|
+
}
|
|
181
|
+
const ids = (((_a = response.data) === null || _a === void 0 ? void 0 : _a.customerIDs) || []).map((id) => `${id}`);
|
|
182
|
+
return { status: "Success", data: ids };
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Create a customer in FieldRoutes. Returns the new customer id in `data`.
|
|
187
|
+
*/
|
|
188
|
+
addCustomer(customer) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
var _a;
|
|
191
|
+
const auth = yield this.props.authenticate();
|
|
192
|
+
const data = Object.assign({ authenticationKey: auth.authenticationKey, authenticationToken: auth.authenticationToken }, customer);
|
|
193
|
+
const config = {
|
|
194
|
+
method: "post",
|
|
195
|
+
url: `${this.baseUrl}/customer/create`,
|
|
196
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
197
|
+
data: JSON.stringify(data)
|
|
198
|
+
};
|
|
199
|
+
const response = yield this.request(config, "customer/create");
|
|
200
|
+
if (response.status === "Failure") {
|
|
201
|
+
return response;
|
|
202
|
+
}
|
|
203
|
+
return { status: "Success", data: ((_a = response.data) === null || _a === void 0 ? void 0 : _a.customerID) ? `${response.data.customerID}` : undefined };
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Update an existing customer. `customer.customerID` must be set.
|
|
208
|
+
*/
|
|
209
|
+
updateCustomer(customer) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
const auth = yield this.props.authenticate();
|
|
212
|
+
const data = Object.assign({ authenticationKey: auth.authenticationKey, authenticationToken: auth.authenticationToken }, customer);
|
|
213
|
+
const config = {
|
|
214
|
+
method: "post",
|
|
215
|
+
url: `${this.baseUrl}/customer/update`,
|
|
216
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
217
|
+
data: JSON.stringify(data)
|
|
218
|
+
};
|
|
219
|
+
const response = yield this.request(config, "customer/update");
|
|
220
|
+
if (response.status === "Failure") {
|
|
221
|
+
return response;
|
|
222
|
+
}
|
|
223
|
+
return { status: "Success", data: `${customer.customerID}` };
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Create an appointment in FieldRoutes.
|
|
228
|
+
*/
|
|
229
|
+
addAppointment(appointment) {
|
|
230
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
+
var _a;
|
|
232
|
+
const auth = yield this.props.authenticate();
|
|
233
|
+
const data = Object.assign({ authenticationKey: auth.authenticationKey, authenticationToken: auth.authenticationToken }, appointment);
|
|
234
|
+
const config = {
|
|
235
|
+
method: "post",
|
|
236
|
+
url: `${this.baseUrl}/appointment/create`,
|
|
237
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
238
|
+
data: JSON.stringify(data)
|
|
239
|
+
};
|
|
240
|
+
const response = yield this.request(config, "appointment/create");
|
|
241
|
+
if (response.status === "Failure") {
|
|
242
|
+
return response;
|
|
243
|
+
}
|
|
244
|
+
return { status: "Success", data: ((_a = response.data) === null || _a === void 0 ? void 0 : _a.appointmentID) ? `${response.data.appointmentID}` : undefined };
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Single HTTP chokepoint. Normalizes transport + FieldRoutes' `success`/`errorMessage` envelope
|
|
249
|
+
* into a {@link FieldRoutesResponse}. Adjust here if the live API differs from the assumed shape.
|
|
250
|
+
*/
|
|
251
|
+
request(config, apiCall) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
const result = { status: "Failure" };
|
|
254
|
+
try {
|
|
255
|
+
if (CRM_DEBUG) {
|
|
256
|
+
(0, stentor_logger_1.log)().info(`[CRM_DEBUG] FieldRoutes ${apiCall} REQUEST: ${JSON.stringify((0, util_1.redactConfig)(config))}`);
|
|
257
|
+
}
|
|
258
|
+
const response = yield (0, axios_1.default)(config);
|
|
259
|
+
if (CRM_DEBUG) {
|
|
260
|
+
(0, stentor_logger_1.log)().info(`[CRM_DEBUG] FieldRoutes ${apiCall} RESPONSE: ${JSON.stringify(response.data)}`);
|
|
261
|
+
}
|
|
262
|
+
const body = response.data;
|
|
263
|
+
if (body && body.success === false) {
|
|
264
|
+
result.error = `[${apiCall}] ${body.errorMessage || (body.errors || []).join("; ") || "FieldRoutes API error"}`;
|
|
265
|
+
(0, stentor_logger_1.log)().error(`FieldRoutes API Error ${result.error}`);
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
result.status = "Success";
|
|
269
|
+
result.data = response.data;
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
result.error = `[${apiCall}] ${err instanceof Error ? err.message : err}`;
|
|
273
|
+
(0, stentor_logger_1.log)().error(`FieldRoutes: request failed ${result.error}`);
|
|
274
|
+
}
|
|
275
|
+
return result;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
exports.FieldRoutesService = FieldRoutesService;
|
|
280
|
+
//# sourceMappingURL=FieldRoutesService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldRoutesService.js","sourceRoot":"","sources":["../src/FieldRoutesService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kCAAkC;AAClC,iEAAqD;AAWrD,mDAAqC;AACrC,kDAAkD;AAClD,yCAAyD;AAGzD,iCAAiE;AAEjE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,CAAC;AAmCnD;;;;;;;GAOG;AACH,MAAa,kBAAmB,SAAQ,oCAAY;IAGhD,YAAmB,KAA8B;QAC7C,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,qBAAQ,KAAK,CAAE,CAAC;QAE1B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAChC,CAAC;IACL,CAAC;IAED,IAAY,OAAO;QACf,OAAO,WAAW,IAAI,CAAC,KAAK,CAAC,SAAS,sBAAsB,CAAC;IACjE,CAAC;IAED;;;OAGG;IACU,eAAe,CACxB,KAAoB,EACpB,QAAwC;;YAExC,IAAA,oBAAG,GAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,gEAAgE,CAAC,CAAC;YACtG,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC;QAC3C,CAAC;KAAA;IAED;;;OAGG;IACU,IAAI,CAAC,YAA0B,EAAE,MAAgC;;;YAC1E,MAAM,WAAW,GAAgB;gBAC7B,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,EAAE;aACd,CAAC;YAEF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AAC;gBAC1E,IAAA,oBAAG,GAAE,CAAC,KAAK,CAAC,+BAA+B,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YAC/D,CAAC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;KAAA;CACJ;AA3RD,gDA2RC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*! Copyright (c) 2025, XAPP AI */
|
|
18
|
+
__exportStar(require("./FieldRoutesService"), exports);
|
|
19
|
+
__exportStar(require("./models"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kCAAkC;AAClC,uDAAqC;AACrC,2CAAyB"}
|
package/lib/models.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*! Copyright (c) 2025, XAPP AI */
|
|
2
|
+
export interface FieldRoutesExternalLeadExtras {
|
|
3
|
+
/**
|
|
4
|
+
* Typically aligned with the session ID to allow the same customer to have multiple conversations and create multiple leads.
|
|
5
|
+
*/
|
|
6
|
+
externalId?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The URL of the website the lead is on when the lead capture is complete
|
|
9
|
+
*/
|
|
10
|
+
source?: string;
|
|
11
|
+
/**
|
|
12
|
+
* ID of the bot. Pass this in if you aren't using 'bot' or the STUDIO_APP_ID
|
|
13
|
+
*/
|
|
14
|
+
botId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Was the session abandoned i.e. widget was closed (= no more data)?
|
|
17
|
+
*/
|
|
18
|
+
isAbandoned?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A customer in FieldRoutes.
|
|
22
|
+
*
|
|
23
|
+
* Field names follow FieldRoutes' snake_case convention. Verify against the live schema at
|
|
24
|
+
* https://<subdomain>.fieldroutes.com/api/customer before extending.
|
|
25
|
+
*
|
|
26
|
+
* @see https://api.fieldroutes.com/index (Customer entity)
|
|
27
|
+
*/
|
|
28
|
+
export interface FieldRoutesCustomer {
|
|
29
|
+
/**
|
|
30
|
+
* FieldRoutes customer id. Present on existing customers, absent when creating.
|
|
31
|
+
*/
|
|
32
|
+
customerID?: string;
|
|
33
|
+
fname?: string;
|
|
34
|
+
lname?: string;
|
|
35
|
+
companyName?: string;
|
|
36
|
+
/** Street address line 1 */
|
|
37
|
+
address?: string;
|
|
38
|
+
city?: string;
|
|
39
|
+
state?: string;
|
|
40
|
+
zip?: string;
|
|
41
|
+
/** Primary phone. FieldRoutes also exposes phone1/phone2 — map as needed. */
|
|
42
|
+
phone1?: string;
|
|
43
|
+
email?: string;
|
|
44
|
+
/** Free text notes; used to carry the transcript / message. */
|
|
45
|
+
notes?: string;
|
|
46
|
+
/** FieldRoutes lead source id (numeric string). Configured per office. */
|
|
47
|
+
sourceID?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Office (subdomain) the customer belongs to. Only relevant for multi-office keys.
|
|
50
|
+
*/
|
|
51
|
+
officeID?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* An appointment in FieldRoutes.
|
|
55
|
+
*
|
|
56
|
+
* @see https://api.fieldroutes.com/index (Appointment entity)
|
|
57
|
+
*/
|
|
58
|
+
export interface FieldRoutesAppointment {
|
|
59
|
+
appointmentID?: string;
|
|
60
|
+
customerID: string;
|
|
61
|
+
/** FieldRoutes appointment type id (numeric string). Maps from the job description. */
|
|
62
|
+
type?: string;
|
|
63
|
+
/** yyyy-MM-dd of the requested service date. */
|
|
64
|
+
date?: string;
|
|
65
|
+
/** HH:mm start of the arrival window. */
|
|
66
|
+
start?: string;
|
|
67
|
+
/** HH:mm end of the arrival window. */
|
|
68
|
+
end?: string;
|
|
69
|
+
/** Subscription this appointment belongs to, when booking recurring service. */
|
|
70
|
+
subscriptionID?: string;
|
|
71
|
+
notes?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Internal, normalized result wrapper mirroring the pattern used by the other CRM services
|
|
75
|
+
* (ServiceMinder, FieldPulse). `data` holds whatever the caller needs from the FieldRoutes response.
|
|
76
|
+
*/
|
|
77
|
+
export interface FieldRoutesResponse<Data = any> {
|
|
78
|
+
status: "Success" | "Failure";
|
|
79
|
+
error?: string;
|
|
80
|
+
data?: Data;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The raw envelope FieldRoutes returns on every call.
|
|
84
|
+
*
|
|
85
|
+
* TODO: confirm exact field names against the live API. FieldRoutes (formerly PestRoutes) returns
|
|
86
|
+
* `success`, an errors array, and an entity-specific id list (e.g. `customerIDs`) on searches.
|
|
87
|
+
*/
|
|
88
|
+
export interface FieldRoutesApiEnvelope {
|
|
89
|
+
success?: boolean;
|
|
90
|
+
errorMessage?: string;
|
|
91
|
+
errors?: string[];
|
|
92
|
+
/** Search endpoints return an id list, e.g. customerIDs / appointmentIDs. */
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
export interface CustomerQuery {
|
|
96
|
+
ids?: string[];
|
|
97
|
+
name?: string;
|
|
98
|
+
phone?: string;
|
|
99
|
+
email?: string;
|
|
100
|
+
}
|
package/lib/models.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*! Copyright (c) 2025, XAPP AI */
|
|
2
|
+
import { AxiosRequestConfig } from "axios";
|
|
3
|
+
import { ExternalLead } from "stentor-models";
|
|
4
|
+
/**
|
|
5
|
+
* Returns a shallow copy of an Axios config with FieldRoutes credentials masked, for safe logging.
|
|
6
|
+
*
|
|
7
|
+
* Credentials ride in BOTH `params` (search) and the JSON-stringified `data` body (create/update),
|
|
8
|
+
* so both are scrubbed. Anything unparseable is dropped rather than logged raw.
|
|
9
|
+
*/
|
|
10
|
+
export declare function redactConfig(config: AxiosRequestConfig): Record<string, unknown>;
|
|
11
|
+
export interface ParsedName {
|
|
12
|
+
firstName: string;
|
|
13
|
+
lastName: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pull a first/last name out of a lead.
|
|
17
|
+
*
|
|
18
|
+
* Prefers an explicit FIRST_NAME/LAST_NAME pair, otherwise splits a FULL_NAME on the last space.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getName(lead: ExternalLead): ParsedName;
|
|
21
|
+
/**
|
|
22
|
+
* Flatten a lead transcript into a single string, prefixing each turn with user/bot.
|
|
23
|
+
*/
|
|
24
|
+
export declare function leadToTranscript(lead: ExternalLead, appId?: string): string;
|
package/lib/util.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactConfig = redactConfig;
|
|
4
|
+
exports.getName = getName;
|
|
5
|
+
exports.leadToTranscript = leadToTranscript;
|
|
6
|
+
const SECRET_KEYS = ["authenticationKey", "authenticationToken"];
|
|
7
|
+
/**
|
|
8
|
+
* Returns a shallow copy of an Axios config with FieldRoutes credentials masked, for safe logging.
|
|
9
|
+
*
|
|
10
|
+
* Credentials ride in BOTH `params` (search) and the JSON-stringified `data` body (create/update),
|
|
11
|
+
* so both are scrubbed. Anything unparseable is dropped rather than logged raw.
|
|
12
|
+
*/
|
|
13
|
+
function redactConfig(config) {
|
|
14
|
+
const redact = (obj) => {
|
|
15
|
+
const copy = Object.assign({}, obj);
|
|
16
|
+
for (const key of SECRET_KEYS) {
|
|
17
|
+
if (key in copy) {
|
|
18
|
+
copy[key] = "***";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return copy;
|
|
22
|
+
};
|
|
23
|
+
const out = { method: config.method, url: config.url };
|
|
24
|
+
if (config.params) {
|
|
25
|
+
out.params = redact(config.params);
|
|
26
|
+
}
|
|
27
|
+
if (typeof config.data === "string") {
|
|
28
|
+
try {
|
|
29
|
+
out.data = redact(JSON.parse(config.data));
|
|
30
|
+
}
|
|
31
|
+
catch (_a) {
|
|
32
|
+
out.data = "***unserializable***";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (config.data && typeof config.data === "object") {
|
|
36
|
+
out.data = redact(config.data);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Pull a first/last name out of a lead.
|
|
42
|
+
*
|
|
43
|
+
* Prefers an explicit FIRST_NAME/LAST_NAME pair, otherwise splits a FULL_NAME on the last space.
|
|
44
|
+
*/
|
|
45
|
+
function getName(lead) {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
const fields = lead.fields || [];
|
|
48
|
+
const firstNameField = fields.find((field) => field.name === "FIRST_NAME");
|
|
49
|
+
const lastNameField = fields.find((field) => field.name === "LAST_NAME");
|
|
50
|
+
if (firstNameField || lastNameField) {
|
|
51
|
+
return {
|
|
52
|
+
firstName: (_a = firstNameField === null || firstNameField === void 0 ? void 0 : firstNameField.value) !== null && _a !== void 0 ? _a : "",
|
|
53
|
+
lastName: (_b = lastNameField === null || lastNameField === void 0 ? void 0 : lastNameField.value) !== null && _b !== void 0 ? _b : ""
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const fullNameField = fields.find((field) => field.name === "FULL_NAME");
|
|
57
|
+
if (fullNameField && fullNameField.value.trim()) {
|
|
58
|
+
const parts = fullNameField.value.trim().split(/\s+/);
|
|
59
|
+
const lastName = parts.length > 1 ? ((_c = parts.pop()) !== null && _c !== void 0 ? _c : "") : "";
|
|
60
|
+
return {
|
|
61
|
+
firstName: parts.join(" "),
|
|
62
|
+
lastName
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { firstName: "", lastName: "" };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Flatten a lead transcript into a single string, prefixing each turn with user/bot.
|
|
69
|
+
*/
|
|
70
|
+
function leadToTranscript(lead, appId) {
|
|
71
|
+
const botId = appId || process.env["STUDIO_APP_ID"];
|
|
72
|
+
let transcript = "";
|
|
73
|
+
(lead.transcript || []).forEach((x) => {
|
|
74
|
+
var _a;
|
|
75
|
+
const fromId = (_a = x.from) === null || _a === void 0 ? void 0 : _a.id;
|
|
76
|
+
const isBot = fromId === botId || fromId === "bot";
|
|
77
|
+
const prefix = isBot ? `${botId || "bot"}: ` : "user: ";
|
|
78
|
+
transcript += `${prefix}${x.message} \n`;
|
|
79
|
+
});
|
|
80
|
+
return transcript;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=util.js.map
|
package/lib/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAYA,oCA4BC;AAYD,0BAwBC;AAKD,4CAYC;AAzFD,MAAM,WAAW,GAAG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AC,CAAC;IACpD,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;;QAClC,MAAM,MAAM,GAAG,MAAA,CAAC,CAAC,IAAI,0CAAE,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,KAAK,CAAC;QACnD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;QACxD,UAAU,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACtB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xapp/stentor-service-fieldroutes",
|
|
3
|
+
"license": "Apache-2.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.0.1",
|
|
8
|
+
"description": "Service to integrate with FieldRoutes",
|
|
9
|
+
"types": "lib/index",
|
|
10
|
+
"main": "lib/index",
|
|
11
|
+
"files": [
|
|
12
|
+
"lib"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": "^20 || ^22 || ^24"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/chai": "5.2.3",
|
|
19
|
+
"@types/sinon": "4.3.3",
|
|
20
|
+
"@xapp/config": "0.3.0",
|
|
21
|
+
"axios-mock-adapter": "2.1.0",
|
|
22
|
+
"chai": "4.5.0",
|
|
23
|
+
"dotenv": "17.4.2",
|
|
24
|
+
"mocha": "11.7.5",
|
|
25
|
+
"sinon": "21.0.0",
|
|
26
|
+
"stentor-logger": "1.74.0",
|
|
27
|
+
"stentor-models": "1.74.0",
|
|
28
|
+
"stentor-service-fetch": "1.74.0",
|
|
29
|
+
"ts-node": "10.9.2",
|
|
30
|
+
"typescript": "5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"stentor-logger": "1.x",
|
|
34
|
+
"stentor-models": "1.x",
|
|
35
|
+
"stentor-service-fetch": "1.x"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"prepack": "yarn build",
|
|
39
|
+
"build": "tsc -d true -p .",
|
|
40
|
+
"clean": "rm -rf ./lib/*",
|
|
41
|
+
"test": "mocha --recursive --timeout 12000 -r ts-node/register \"./src/**/*.test.ts\"",
|
|
42
|
+
"local": "mocha --recursive --timeout 12000 -r ts-node/register \"./src/**/*.ftest.ts\""
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"addresser": "1.1.20",
|
|
46
|
+
"axios": "1.18.1",
|
|
47
|
+
"date-fns": "4.1.0"
|
|
48
|
+
}
|
|
49
|
+
}
|