pha-hermes 1.16.0 → 1.18.0
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/api/expenses/expenseClient.d.ts +1 -1
- package/dist/api/salesforce/apiClient.d.ts +1 -2
- package/dist/api/salesforce/auth/auth.d.ts +1 -1
- package/dist/api/salesforce/practitioner/practitionerClient.d.ts +4 -1
- package/dist/models/user.d.ts +1 -0
- package/dist/pha-hermes.cjs.development.js +38 -27
- package/dist/pha-hermes.cjs.development.js.map +1 -1
- package/dist/pha-hermes.cjs.production.min.js +1 -1
- package/dist/pha-hermes.cjs.production.min.js.map +1 -1
- package/dist/pha-hermes.esm.js +38 -27
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/.env +5 -0
- package/src/api/expenses/expenseClient.ts +1 -1
- package/src/api/salesforce/apiClient.ts +10 -10
- package/src/api/salesforce/auth/auth.ts +2 -5
- package/src/api/salesforce/practitioner/practitionerClient.ts +20 -5
- package/src/models/user.ts +2 -1
|
@@ -3,7 +3,7 @@ import { Expense } from '../../models/expense';
|
|
|
3
3
|
declare type FrontendExpense = {
|
|
4
4
|
workorderPeriodId: string;
|
|
5
5
|
amount: string;
|
|
6
|
-
type: 'Other' | 'Lodging' | 'Transportation' | 'Travel (Hours
|
|
6
|
+
type: 'Other' | 'Lodging' | 'Transportation' | 'Travel (Hours)' | 'Per diem' | 'Meals';
|
|
7
7
|
};
|
|
8
8
|
export declare class SFExpenseClient {
|
|
9
9
|
private axiosInstance;
|
|
@@ -15,8 +15,7 @@ export declare class SFApiClient {
|
|
|
15
15
|
practitionerClient: SFPractitionerClient;
|
|
16
16
|
payPeriodClient: SFPayPeriodClient;
|
|
17
17
|
expenseClient: SFExpenseClient;
|
|
18
|
-
|
|
19
|
-
init(sfClientId: string, sfClientSecret: string, onTokenRefresh?: () => Promise<{
|
|
18
|
+
init(baseUrl: string, sfClientId: string, sfClientSecret: string, onTokenRefresh?: () => Promise<{
|
|
20
19
|
clientId: string;
|
|
21
20
|
clientSecret: string;
|
|
22
21
|
}>): Promise<void>;
|
|
@@ -5,7 +5,7 @@ export declare class SFAuthenticator {
|
|
|
5
5
|
token: string | undefined;
|
|
6
6
|
private refreshToken;
|
|
7
7
|
private tokenRefreshPromise;
|
|
8
|
-
constructor(authenticatedAxiosInstance: AxiosInstance, baseUrl
|
|
8
|
+
constructor(authenticatedAxiosInstance: AxiosInstance, baseUrl: string);
|
|
9
9
|
initializeAuth(clientId: string, clientSecret: string, onTokenRefresh?: () => Promise<{
|
|
10
10
|
clientId: string;
|
|
11
11
|
clientSecret: string;
|
|
@@ -3,6 +3,9 @@ import { Practitioner } from '../../../models';
|
|
|
3
3
|
export declare class SFPractitionerClient {
|
|
4
4
|
private axiosInstance;
|
|
5
5
|
constructor(axiosInstance: AxiosInstance);
|
|
6
|
-
fetchPractitioners(
|
|
6
|
+
fetchPractitioners(options?: {
|
|
7
|
+
createdAt?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
}): Promise<Practitioner[]>;
|
|
7
10
|
fetchPractitionerByEmail(email: string): Promise<Practitioner | null>;
|
|
8
11
|
}
|
package/dist/models/user.d.ts
CHANGED
|
@@ -370,7 +370,7 @@ var SFAuthenticator = /*#__PURE__*/function () {
|
|
|
370
370
|
this.token = undefined;
|
|
371
371
|
this.refreshToken = undefined;
|
|
372
372
|
this.tokenRefreshPromise = null;
|
|
373
|
-
this.axiosTokenInstance.defaults.baseURL = baseUrl
|
|
373
|
+
this.axiosTokenInstance.defaults.baseURL = baseUrl;
|
|
374
374
|
this.authenticatedAxiosInstance = authenticatedAxiosInstance;
|
|
375
375
|
}
|
|
376
376
|
var _proto = SFAuthenticator.prototype;
|
|
@@ -837,36 +837,42 @@ var SFPractitionerClient = /*#__PURE__*/function () {
|
|
|
837
837
|
}
|
|
838
838
|
var _proto = SFPractitionerClient.prototype;
|
|
839
839
|
_proto.fetchPractitioners = /*#__PURE__*/function () {
|
|
840
|
-
var _fetchPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
841
|
-
var url, query, _yield$this$axiosInst, records;
|
|
840
|
+
var _fetchPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
841
|
+
var conditions, whereClause, limitClause, url, query, _yield$this$axiosInst, records;
|
|
842
842
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
843
843
|
while (1) switch (_context.prev = _context.next) {
|
|
844
844
|
case 0:
|
|
845
845
|
_context.prev = 0;
|
|
846
|
+
conditions = ["Status__c = 'Active'"];
|
|
847
|
+
if (options != null && options.createdAt) {
|
|
848
|
+
conditions.push("CreatedDate > " + options.createdAt);
|
|
849
|
+
}
|
|
850
|
+
whereClause = conditions.length ? "WHERE " + conditions.join(' AND ') : '';
|
|
851
|
+
limitClause = typeof (options == null ? void 0 : options.limit) === 'number' && options.limit > 0 ? "LIMIT " + Math.floor(options.limit) : '';
|
|
846
852
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
847
|
-
query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c\n FROM Personnel__c\n
|
|
848
|
-
_context.next =
|
|
853
|
+
query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c, CreatedDate\n FROM Personnel__c\n " + whereClause + "\n ORDER BY CreatedDate ASC, StaffID__c ASC\n " + limitClause + "\n ";
|
|
854
|
+
_context.next = 9;
|
|
849
855
|
return this.axiosInstance.get(url, {
|
|
850
856
|
params: {
|
|
851
857
|
q: query
|
|
852
858
|
}
|
|
853
859
|
});
|
|
854
|
-
case
|
|
860
|
+
case 9:
|
|
855
861
|
_yield$this$axiosInst = _context.sent;
|
|
856
862
|
records = _yield$this$axiosInst.data.records;
|
|
857
863
|
return _context.abrupt("return", records.map(toPractitioner));
|
|
858
|
-
case
|
|
859
|
-
_context.prev =
|
|
864
|
+
case 14:
|
|
865
|
+
_context.prev = 14;
|
|
860
866
|
_context.t0 = _context["catch"](0);
|
|
861
867
|
console.error('Error fetching practitioners: ', _context.t0.message);
|
|
862
868
|
throw _context.t0;
|
|
863
|
-
case
|
|
869
|
+
case 18:
|
|
864
870
|
case "end":
|
|
865
871
|
return _context.stop();
|
|
866
872
|
}
|
|
867
|
-
}, _callee, this, [[0,
|
|
873
|
+
}, _callee, this, [[0, 14]]);
|
|
868
874
|
}));
|
|
869
|
-
function fetchPractitioners() {
|
|
875
|
+
function fetchPractitioners(_x) {
|
|
870
876
|
return _fetchPractitioners.apply(this, arguments);
|
|
871
877
|
}
|
|
872
878
|
return fetchPractitioners;
|
|
@@ -879,7 +885,7 @@ var SFPractitionerClient = /*#__PURE__*/function () {
|
|
|
879
885
|
case 0:
|
|
880
886
|
_context2.prev = 0;
|
|
881
887
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
882
|
-
query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c\n FROM Personnel__c\n WHERE Status__c = 'Active' AND Email__c = '" + email + "'\n ";
|
|
888
|
+
query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c, CreatedDate\n FROM Personnel__c\n WHERE Status__c = 'Active' AND Email__c = '" + email + "'\n ";
|
|
883
889
|
_context2.next = 5;
|
|
884
890
|
return this.axiosInstance.get(url, {
|
|
885
891
|
params: {
|
|
@@ -907,7 +913,7 @@ var SFPractitionerClient = /*#__PURE__*/function () {
|
|
|
907
913
|
}
|
|
908
914
|
}, _callee2, this, [[0, 12]]);
|
|
909
915
|
}));
|
|
910
|
-
function fetchPractitionerByEmail(
|
|
916
|
+
function fetchPractitionerByEmail(_x2) {
|
|
911
917
|
return _fetchPractitionerByEmail.apply(this, arguments);
|
|
912
918
|
}
|
|
913
919
|
return fetchPractitionerByEmail;
|
|
@@ -920,7 +926,8 @@ function toPractitioner(raw) {
|
|
|
920
926
|
firstName: raw.FirstName__c,
|
|
921
927
|
lastName: raw.LastName__c,
|
|
922
928
|
email: raw.Email__c,
|
|
923
|
-
staffId: raw.StaffID__c
|
|
929
|
+
staffId: raw.StaffID__c,
|
|
930
|
+
createdAt: raw.CreatedDate.replace(/\+0000$/, 'Z')
|
|
924
931
|
};
|
|
925
932
|
}
|
|
926
933
|
|
|
@@ -1206,33 +1213,34 @@ function toExpense(raw) {
|
|
|
1206
1213
|
|
|
1207
1214
|
var SF_API_VERSION = 'v57.0';
|
|
1208
1215
|
var SFApiClient = /*#__PURE__*/function () {
|
|
1209
|
-
function SFApiClient(
|
|
1216
|
+
function SFApiClient() {
|
|
1210
1217
|
this.instance = undefined;
|
|
1211
1218
|
this.axiosInstance = axios.create();
|
|
1212
|
-
this.baseUrl = baseUrl;
|
|
1213
|
-
this.axiosInstance.defaults.baseURL = baseUrl != null ? baseUrl : 'https://do0000000d247eaa--phealth.sandbox.my.salesforce.com';
|
|
1214
|
-
this.authenticator = new SFAuthenticator(this.axiosInstance, this.baseUrl);
|
|
1215
|
-
this.timesheetClient = new SFTimesheetClient(this.axiosInstance);
|
|
1216
|
-
this.workorderClient = new SFWorkorderClient(this.axiosInstance);
|
|
1217
|
-
this.practitionerClient = new SFPractitionerClient(this.axiosInstance);
|
|
1218
|
-
this.payPeriodClient = new SFPayPeriodClient(this.axiosInstance);
|
|
1219
|
-
this.expenseClient = new SFExpenseClient(this.axiosInstance);
|
|
1220
1219
|
}
|
|
1221
1220
|
var _proto = SFApiClient.prototype;
|
|
1222
1221
|
_proto.init = /*#__PURE__*/function () {
|
|
1223
|
-
var _init = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(sfClientId, sfClientSecret, onTokenRefresh) {
|
|
1222
|
+
var _init = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(baseUrl, sfClientId, sfClientSecret, onTokenRefresh) {
|
|
1224
1223
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1225
1224
|
while (1) switch (_context.prev = _context.next) {
|
|
1226
1225
|
case 0:
|
|
1227
|
-
|
|
1226
|
+
this.baseUrl = baseUrl;
|
|
1227
|
+
this.axiosInstance.defaults.baseURL = baseUrl;
|
|
1228
|
+
this.authenticator = new SFAuthenticator(this.axiosInstance, this.baseUrl);
|
|
1229
|
+
this.timesheetClient = new SFTimesheetClient(this.axiosInstance);
|
|
1230
|
+
this.workorderClient = new SFWorkorderClient(this.axiosInstance);
|
|
1231
|
+
this.practitionerClient = new SFPractitionerClient(this.axiosInstance);
|
|
1232
|
+
this.payPeriodClient = new SFPayPeriodClient(this.axiosInstance);
|
|
1233
|
+
this.expenseClient = new SFExpenseClient(this.axiosInstance);
|
|
1234
|
+
// creates authenticator and adds token to axios instance
|
|
1235
|
+
_context.next = 10;
|
|
1228
1236
|
return this.authenticator.initializeAuth(sfClientId, sfClientSecret, onTokenRefresh);
|
|
1229
|
-
case
|
|
1237
|
+
case 10:
|
|
1230
1238
|
case "end":
|
|
1231
1239
|
return _context.stop();
|
|
1232
1240
|
}
|
|
1233
1241
|
}, _callee, this);
|
|
1234
1242
|
}));
|
|
1235
|
-
function init(_x, _x2, _x3) {
|
|
1243
|
+
function init(_x, _x2, _x3, _x4) {
|
|
1236
1244
|
return _init.apply(this, arguments);
|
|
1237
1245
|
}
|
|
1238
1246
|
return init;
|
|
@@ -1241,6 +1249,9 @@ var SFApiClient = /*#__PURE__*/function () {
|
|
|
1241
1249
|
this.instance = instance;
|
|
1242
1250
|
};
|
|
1243
1251
|
_proto.getInstance = function getInstance() {
|
|
1252
|
+
if (!this.instance) {
|
|
1253
|
+
throw new Error('Salesforce Api client not initialized');
|
|
1254
|
+
}
|
|
1244
1255
|
return this.instance;
|
|
1245
1256
|
};
|
|
1246
1257
|
_proto.fetchRoles = /*#__PURE__*/function () {
|