pha-hermes 1.13.0 → 1.14.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/liphe1.0/auth/authClient.d.ts +13 -0
- package/dist/api/liphe1.0/practitioner/practitionerClient.d.ts +13 -0
- package/dist/api/lipheApiClient.d.ts +13 -0
- package/dist/api/timesheet/timesheetClient.d.ts +24 -4
- package/dist/api/workorder/workorderClient.d.ts +5 -1
- package/dist/index.d.ts +3 -0
- package/dist/pha-hermes.cjs.development.js +340 -155
- 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 +338 -156
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/liphe1.0/auth/authClient.ts +76 -0
- package/src/api/liphe1.0/practitioner/practitionerClient.ts +49 -0
- package/src/api/lipheApiClient.ts +38 -0
- package/src/api/timesheet/timesheetClient.ts +54 -50
- package/src/api/workorder/workorderClient.ts +24 -6
- package/src/index.ts +3 -0
package/dist/pha-hermes.esm.js
CHANGED
|
@@ -569,37 +569,44 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
569
569
|
}
|
|
570
570
|
return updateTimesheetHour;
|
|
571
571
|
}();
|
|
572
|
-
_proto.
|
|
573
|
-
var
|
|
572
|
+
_proto.getTimesheetIds = /*#__PURE__*/function () {
|
|
573
|
+
var _getTimesheetIds = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(workorderId, periodStartDate, periodEndDate) {
|
|
574
574
|
var url, query, _yield$this$axiosInst, records;
|
|
575
575
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
576
576
|
while (1) switch (_context2.prev = _context2.next) {
|
|
577
577
|
case 0:
|
|
578
578
|
// Find all timesheet Ids that belong to this WO
|
|
579
579
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
580
|
-
query = "SELECT Id\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderId + "'
|
|
581
|
-
|
|
580
|
+
query = "SELECT Id\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderId + "'";
|
|
581
|
+
try {
|
|
582
|
+
if (periodStartDate && periodEndDate) {
|
|
583
|
+
query += "\n AND PayPeriodStartDate__c <= " + new Date(periodStartDate).toISOString().substring(0, 10) + "\n AND PayPeriodEndDate__c >= " + new Date(periodEndDate).toISOString().substring(0, 10) + "\n ";
|
|
584
|
+
}
|
|
585
|
+
} catch (error) {
|
|
586
|
+
console.error('Invalid period dates', error);
|
|
587
|
+
}
|
|
588
|
+
_context2.next = 5;
|
|
582
589
|
return this.axiosInstance.get(url, {
|
|
583
590
|
params: {
|
|
584
591
|
q: query
|
|
585
592
|
}
|
|
586
593
|
});
|
|
587
|
-
case
|
|
594
|
+
case 5:
|
|
588
595
|
_yield$this$axiosInst = _context2.sent;
|
|
589
596
|
records = _yield$this$axiosInst.data.records;
|
|
590
597
|
return _context2.abrupt("return", records.map(function (record) {
|
|
591
598
|
return record.Id;
|
|
592
599
|
}));
|
|
593
|
-
case
|
|
600
|
+
case 8:
|
|
594
601
|
case "end":
|
|
595
602
|
return _context2.stop();
|
|
596
603
|
}
|
|
597
604
|
}, _callee2, this);
|
|
598
605
|
}));
|
|
599
|
-
function
|
|
600
|
-
return
|
|
606
|
+
function getTimesheetIds(_x3, _x4, _x5) {
|
|
607
|
+
return _getTimesheetIds.apply(this, arguments);
|
|
601
608
|
}
|
|
602
|
-
return
|
|
609
|
+
return getTimesheetIds;
|
|
603
610
|
}();
|
|
604
611
|
_proto.getTimesheetsForPractitioner = /*#__PURE__*/function () {
|
|
605
612
|
var _getTimesheetsForPractitioner = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(personnelID) {
|
|
@@ -633,162 +640,83 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
633
640
|
}
|
|
634
641
|
}, _callee3, this);
|
|
635
642
|
}));
|
|
636
|
-
function getTimesheetsForPractitioner(
|
|
643
|
+
function getTimesheetsForPractitioner(_x6) {
|
|
637
644
|
return _getTimesheetsForPractitioner.apply(this, arguments);
|
|
638
645
|
}
|
|
639
646
|
return getTimesheetsForPractitioner;
|
|
640
647
|
}();
|
|
641
|
-
_proto.
|
|
642
|
-
var
|
|
643
|
-
var timesheetIds,
|
|
648
|
+
_proto.getTimesheetHours = /*#__PURE__*/function () {
|
|
649
|
+
var _getTimesheetHours = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(workorderId, fields, periodStartDate, periodEndDate) {
|
|
650
|
+
var timesheetIds, allHours, url, _iterator2, _step2, timesheetId, query, _yield$this$axiosInst2, records;
|
|
644
651
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
645
652
|
while (1) switch (_context4.prev = _context4.next) {
|
|
646
653
|
case 0:
|
|
647
654
|
_context4.next = 2;
|
|
648
|
-
return this.
|
|
655
|
+
return this.getTimesheetIds(workorderId, periodStartDate, periodEndDate);
|
|
649
656
|
case 2:
|
|
650
657
|
timesheetIds = _context4.sent;
|
|
651
|
-
|
|
652
|
-
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
653
|
-
query = "SELECT Id\n FROM TimesheetHour__c\n WHERE Timesheet__c = '" + timesheetId + "'";
|
|
654
|
-
_context4.next = 8;
|
|
655
|
-
return this.axiosInstance.get(url, {
|
|
656
|
-
params: {
|
|
657
|
-
q: query
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
case 8:
|
|
661
|
-
_yield$this$axiosInst2 = _context4.sent;
|
|
662
|
-
records = _yield$this$axiosInst2.data.records;
|
|
663
|
-
return _context4.abrupt("return", records.map(function (_ref) {
|
|
664
|
-
var Id = _ref.Id;
|
|
665
|
-
return Id;
|
|
666
|
-
}));
|
|
667
|
-
case 11:
|
|
668
|
-
case "end":
|
|
669
|
-
return _context4.stop();
|
|
670
|
-
}
|
|
671
|
-
}, _callee4, this);
|
|
672
|
-
}));
|
|
673
|
-
function getTimesheetHoursIds(_x5) {
|
|
674
|
-
return _getTimesheetHoursIds.apply(this, arguments);
|
|
675
|
-
}
|
|
676
|
-
return getTimesheetHoursIds;
|
|
677
|
-
}();
|
|
678
|
-
_proto.getTimesheetHoursId = /*#__PURE__*/function () {
|
|
679
|
-
var _getTimesheetHoursId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(workorderId, timesheetDate) {
|
|
680
|
-
var timesheetIds, formattedDate, allHourIds, url, _iterator2, _step2, timesheetId, query, _yield$this$axiosInst3, records, ids;
|
|
681
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
682
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
683
|
-
case 0:
|
|
684
|
-
_context5.next = 2;
|
|
685
|
-
return this.getTimesheetId(workorderId);
|
|
686
|
-
case 2:
|
|
687
|
-
timesheetIds = _context5.sent;
|
|
688
|
-
formattedDate = timesheetDate.toISOString().split('T')[0];
|
|
689
|
-
allHourIds = [];
|
|
658
|
+
allHours = [];
|
|
690
659
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
691
660
|
_iterator2 = _createForOfIteratorHelperLoose(timesheetIds);
|
|
692
|
-
case
|
|
661
|
+
case 6:
|
|
693
662
|
if ((_step2 = _iterator2()).done) {
|
|
694
|
-
|
|
663
|
+
_context4.next = 23;
|
|
695
664
|
break;
|
|
696
665
|
}
|
|
697
666
|
timesheetId = _step2.value;
|
|
698
|
-
query = "\n
|
|
699
|
-
|
|
700
|
-
|
|
667
|
+
query = "\n SELECT " + ((fields == null ? void 0 : fields.join(',')) || 'FIELDS(STANDARD)') + "\n FROM TimesheetHour__c\n WHERE Timesheet__c = '" + timesheetId + "'";
|
|
668
|
+
_context4.prev = 9;
|
|
669
|
+
if (fields != null && fields.length) {
|
|
670
|
+
query += "\n AND Date__c >= " + new Date(periodStartDate).toISOString().substring(0, 10) + "\n AND Date__c <= " + new Date(periodEndDate).toISOString().substring(0, 10);
|
|
671
|
+
}
|
|
672
|
+
_context4.next = 13;
|
|
701
673
|
return this.axiosInstance.get(url, {
|
|
702
674
|
params: {
|
|
703
675
|
q: query
|
|
704
676
|
}
|
|
705
677
|
});
|
|
706
678
|
case 13:
|
|
707
|
-
_yield$this$
|
|
708
|
-
records = _yield$this$
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
});
|
|
712
|
-
allHourIds.push.apply(allHourIds, ids);
|
|
713
|
-
_context5.next = 23;
|
|
679
|
+
_yield$this$axiosInst2 = _context4.sent;
|
|
680
|
+
records = _yield$this$axiosInst2.data.records;
|
|
681
|
+
allHours.push.apply(allHours, records);
|
|
682
|
+
_context4.next = 21;
|
|
714
683
|
break;
|
|
715
|
-
case
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
console.error("Failed to fetch",
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
_context5.next = 7;
|
|
684
|
+
case 18:
|
|
685
|
+
_context4.prev = 18;
|
|
686
|
+
_context4.t0 = _context4["catch"](9);
|
|
687
|
+
console.error("Failed to fetch", _context4.t0);
|
|
688
|
+
case 21:
|
|
689
|
+
_context4.next = 6;
|
|
722
690
|
break;
|
|
723
|
-
case
|
|
724
|
-
return
|
|
725
|
-
case
|
|
726
|
-
case "end":
|
|
727
|
-
return _context5.stop();
|
|
728
|
-
}
|
|
729
|
-
}, _callee5, this, [[10, 19]]);
|
|
730
|
-
}));
|
|
731
|
-
function getTimesheetHoursId(_x6, _x7) {
|
|
732
|
-
return _getTimesheetHoursId.apply(this, arguments);
|
|
733
|
-
}
|
|
734
|
-
return getTimesheetHoursId;
|
|
735
|
-
}();
|
|
736
|
-
_proto.getTimesheetHours = /*#__PURE__*/function () {
|
|
737
|
-
var _getTimesheetHours = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(workorderId) {
|
|
738
|
-
var _this = this;
|
|
739
|
-
var timesheetHourIds;
|
|
740
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
741
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
742
|
-
case 0:
|
|
743
|
-
_context7.next = 2;
|
|
744
|
-
return this.getTimesheetHoursIds(workorderId);
|
|
745
|
-
case 2:
|
|
746
|
-
timesheetHourIds = _context7.sent;
|
|
747
|
-
return _context7.abrupt("return", Promise.all(timesheetHourIds.map(/*#__PURE__*/function () {
|
|
748
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
749
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
750
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
751
|
-
case 0:
|
|
752
|
-
return _context6.abrupt("return", _this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/sobjects/TimeSheetHour__c/" + id).then(function (res) {
|
|
753
|
-
return res.data;
|
|
754
|
-
}).then(toTimesheetDayEntry));
|
|
755
|
-
case 1:
|
|
756
|
-
case "end":
|
|
757
|
-
return _context6.stop();
|
|
758
|
-
}
|
|
759
|
-
}, _callee6);
|
|
760
|
-
}));
|
|
761
|
-
return function (_x9) {
|
|
762
|
-
return _ref2.apply(this, arguments);
|
|
763
|
-
};
|
|
764
|
-
}())));
|
|
765
|
-
case 4:
|
|
691
|
+
case 23:
|
|
692
|
+
return _context4.abrupt("return", allHours.map(toTimesheetDayEntry));
|
|
693
|
+
case 24:
|
|
766
694
|
case "end":
|
|
767
|
-
return
|
|
695
|
+
return _context4.stop();
|
|
768
696
|
}
|
|
769
|
-
},
|
|
697
|
+
}, _callee4, this, [[9, 18]]);
|
|
770
698
|
}));
|
|
771
|
-
function getTimesheetHours(_x8) {
|
|
699
|
+
function getTimesheetHours(_x7, _x8, _x9, _x10) {
|
|
772
700
|
return _getTimesheetHours.apply(this, arguments);
|
|
773
701
|
}
|
|
774
702
|
return getTimesheetHours;
|
|
775
703
|
}();
|
|
776
704
|
_proto.getPayPeriods = /*#__PURE__*/function () {
|
|
777
|
-
var _getPayPeriods = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
705
|
+
var _getPayPeriods = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
778
706
|
var url, query, data, payPeriods, _iterator3, _step3, payPeriod;
|
|
779
|
-
return _regeneratorRuntime().wrap(function
|
|
780
|
-
while (1) switch (
|
|
707
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
708
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
781
709
|
case 0:
|
|
782
710
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
783
711
|
query = "SELECT Name,\n StartDate__c,\n EndDate__c\n FROM PayPeriod__c";
|
|
784
|
-
|
|
712
|
+
_context5.next = 4;
|
|
785
713
|
return this.axiosInstance.get(url, {
|
|
786
714
|
params: {
|
|
787
715
|
q: query
|
|
788
716
|
}
|
|
789
717
|
});
|
|
790
718
|
case 4:
|
|
791
|
-
data =
|
|
719
|
+
data = _context5.sent;
|
|
792
720
|
payPeriods = [];
|
|
793
721
|
for (_iterator3 = _createForOfIteratorHelperLoose(data.data.records); !(_step3 = _iterator3()).done;) {
|
|
794
722
|
payPeriod = _step3.value;
|
|
@@ -798,12 +726,12 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
798
726
|
endDate: payPeriod.EndDate__c
|
|
799
727
|
});
|
|
800
728
|
}
|
|
801
|
-
return
|
|
729
|
+
return _context5.abrupt("return", payPeriods);
|
|
802
730
|
case 8:
|
|
803
731
|
case "end":
|
|
804
|
-
return
|
|
732
|
+
return _context5.stop();
|
|
805
733
|
}
|
|
806
|
-
},
|
|
734
|
+
}, _callee5, this);
|
|
807
735
|
}));
|
|
808
736
|
function getPayPeriods() {
|
|
809
737
|
return _getPayPeriods.apply(this, arguments);
|
|
@@ -811,12 +739,12 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
811
739
|
return getPayPeriods;
|
|
812
740
|
}();
|
|
813
741
|
_proto.uploadImageToTimesheet = /*#__PURE__*/function () {
|
|
814
|
-
var _uploadImageToTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
815
|
-
var form, uploadRes, versionId, _yield$this$
|
|
816
|
-
return _regeneratorRuntime().wrap(function
|
|
817
|
-
while (1) switch (
|
|
742
|
+
var _uploadImageToTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(file, filename, timesheetId) {
|
|
743
|
+
var form, uploadRes, versionId, _yield$this$axiosInst3, data, contentDocumentId, _err$response;
|
|
744
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
745
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
818
746
|
case 0:
|
|
819
|
-
|
|
747
|
+
_context6.prev = 0;
|
|
820
748
|
form = new FormData();
|
|
821
749
|
form.append('entity_content', JSON.stringify({
|
|
822
750
|
Title: filename,
|
|
@@ -828,24 +756,24 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
828
756
|
filename: filename,
|
|
829
757
|
contentType: 'application/octet-stream'
|
|
830
758
|
});
|
|
831
|
-
|
|
759
|
+
_context6.next = 6;
|
|
832
760
|
return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentVersion", form, {
|
|
833
761
|
headers: form.getHeaders()
|
|
834
762
|
});
|
|
835
763
|
case 6:
|
|
836
|
-
uploadRes =
|
|
764
|
+
uploadRes = _context6.sent;
|
|
837
765
|
versionId = uploadRes.data.id; //get ContentDocumentId
|
|
838
|
-
|
|
766
|
+
_context6.next = 10;
|
|
839
767
|
return this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/query", {
|
|
840
768
|
params: {
|
|
841
769
|
q: "SELECT ContentDocumentId FROM ContentVersion WHERE Id = '" + versionId + "'"
|
|
842
770
|
}
|
|
843
771
|
});
|
|
844
772
|
case 10:
|
|
845
|
-
_yield$this$
|
|
846
|
-
data = _yield$this$
|
|
773
|
+
_yield$this$axiosInst3 = _context6.sent;
|
|
774
|
+
data = _yield$this$axiosInst3.data;
|
|
847
775
|
contentDocumentId = data.records[0].ContentDocumentId;
|
|
848
|
-
|
|
776
|
+
_context6.next = 15;
|
|
849
777
|
return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentDocumentLink", {
|
|
850
778
|
ContentDocumentId: contentDocumentId,
|
|
851
779
|
LinkedEntityId: timesheetId,
|
|
@@ -853,20 +781,20 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
853
781
|
Visibility: 'AllUsers'
|
|
854
782
|
});
|
|
855
783
|
case 15:
|
|
856
|
-
|
|
784
|
+
_context6.next = 21;
|
|
857
785
|
break;
|
|
858
786
|
case 17:
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
console.error('Salesforce error response:',
|
|
862
|
-
console.error('Error uploading and linking image:',
|
|
787
|
+
_context6.prev = 17;
|
|
788
|
+
_context6.t0 = _context6["catch"](0);
|
|
789
|
+
console.error('Salesforce error response:', _context6.t0 == null || (_err$response = _context6.t0.response) == null ? void 0 : _err$response.data);
|
|
790
|
+
console.error('Error uploading and linking image:', _context6.t0 == null ? void 0 : _context6.t0.message);
|
|
863
791
|
case 21:
|
|
864
792
|
case "end":
|
|
865
|
-
return
|
|
793
|
+
return _context6.stop();
|
|
866
794
|
}
|
|
867
|
-
},
|
|
795
|
+
}, _callee6, this, [[0, 17]]);
|
|
868
796
|
}));
|
|
869
|
-
function uploadImageToTimesheet(
|
|
797
|
+
function uploadImageToTimesheet(_x11, _x12, _x13) {
|
|
870
798
|
return _uploadImageToTimesheet.apply(this, arguments);
|
|
871
799
|
}
|
|
872
800
|
return uploadImageToTimesheet;
|
|
@@ -995,15 +923,34 @@ var SFWorkorderClient = /*#__PURE__*/function () {
|
|
|
995
923
|
}
|
|
996
924
|
var _proto = SFWorkorderClient.prototype;
|
|
997
925
|
_proto.getWorkordersForPractitioner = /*#__PURE__*/function () {
|
|
998
|
-
var _getWorkordersForPractitioner = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(practitionerId) {
|
|
999
|
-
var url, query;
|
|
926
|
+
var _getWorkordersForPractitioner = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(practitionerId, options) {
|
|
927
|
+
var _options$provinces, filters, isoStart, isoEnd, _options$provinces2, provincesList, whereClause, url, query;
|
|
1000
928
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1001
929
|
while (1) switch (_context.prev = _context.next) {
|
|
1002
930
|
case 0:
|
|
1003
931
|
_context.prev = 0;
|
|
932
|
+
filters = [];
|
|
933
|
+
if (practitionerId) {
|
|
934
|
+
filters.push("Personnel__c = '" + practitionerId + "'");
|
|
935
|
+
}
|
|
936
|
+
if (options != null && options.startDate) {
|
|
937
|
+
isoStart = options.startDate.toISOString().split('T')[0];
|
|
938
|
+
filters.push("EndDate__c >= " + isoStart);
|
|
939
|
+
}
|
|
940
|
+
if (options != null && options.endDate) {
|
|
941
|
+
isoEnd = options.endDate.toISOString().split('T')[0];
|
|
942
|
+
filters.push("startdate__c <= " + isoEnd);
|
|
943
|
+
}
|
|
944
|
+
if (options != null && (_options$provinces = options.provinces) != null && _options$provinces.length) {
|
|
945
|
+
provincesList = options == null || (_options$provinces2 = options.provinces) == null ? void 0 : _options$provinces2.map(function (p) {
|
|
946
|
+
return "'" + p + "'";
|
|
947
|
+
}).join(', ');
|
|
948
|
+
filters.push("Region__c IN (" + provincesList + ")");
|
|
949
|
+
}
|
|
950
|
+
whereClause = filters.length ? "WHERE " + filters.join(' AND ') : '';
|
|
1004
951
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
1005
|
-
query =
|
|
1006
|
-
_context.next =
|
|
952
|
+
query = "SELECT Id, Region__c, Name, HospitalID__c, HospitalName__c, ProfessionalDesignation__c, Personnel__c, startdate__c, EndDate__c, CreatedDate, LastModifiedDate FROM WorkOrder__c " + whereClause;
|
|
953
|
+
_context.next = 11;
|
|
1007
954
|
return this.axiosInstance.get(url, {
|
|
1008
955
|
params: {
|
|
1009
956
|
q: query
|
|
@@ -1026,20 +973,20 @@ var SFWorkorderClient = /*#__PURE__*/function () {
|
|
|
1026
973
|
};
|
|
1027
974
|
});
|
|
1028
975
|
});
|
|
1029
|
-
case
|
|
976
|
+
case 11:
|
|
1030
977
|
return _context.abrupt("return", _context.sent);
|
|
1031
|
-
case
|
|
1032
|
-
_context.prev =
|
|
978
|
+
case 14:
|
|
979
|
+
_context.prev = 14;
|
|
1033
980
|
_context.t0 = _context["catch"](0);
|
|
1034
981
|
console.error('Error fetching work orders: ', _context.t0.message);
|
|
1035
982
|
throw _context.t0;
|
|
1036
|
-
case
|
|
983
|
+
case 18:
|
|
1037
984
|
case "end":
|
|
1038
985
|
return _context.stop();
|
|
1039
986
|
}
|
|
1040
|
-
}, _callee, this, [[0,
|
|
987
|
+
}, _callee, this, [[0, 14]]);
|
|
1041
988
|
}));
|
|
1042
|
-
function getWorkordersForPractitioner(_x) {
|
|
989
|
+
function getWorkordersForPractitioner(_x, _x2) {
|
|
1043
990
|
return _getWorkordersForPractitioner.apply(this, arguments);
|
|
1044
991
|
}
|
|
1045
992
|
return getWorkordersForPractitioner;
|
|
@@ -1210,5 +1157,240 @@ var SFApiClient = /*#__PURE__*/function () {
|
|
|
1210
1157
|
return SFApiClient;
|
|
1211
1158
|
}();
|
|
1212
1159
|
|
|
1213
|
-
|
|
1160
|
+
var LipheAuthenticator = /*#__PURE__*/function () {
|
|
1161
|
+
function LipheAuthenticator(authenticatedAxiosInstance, baseUrl, email, password, type) {
|
|
1162
|
+
if (type === void 0) {
|
|
1163
|
+
type = 'user';
|
|
1164
|
+
}
|
|
1165
|
+
this.axiosTokenInstance = axios.create();
|
|
1166
|
+
this.token = undefined;
|
|
1167
|
+
this.tokenRefreshPromise = null;
|
|
1168
|
+
this.authenticatedAxiosInstance = authenticatedAxiosInstance;
|
|
1169
|
+
this.email = email;
|
|
1170
|
+
this.password = password;
|
|
1171
|
+
this.type = type;
|
|
1172
|
+
this.axiosTokenInstance.defaults.baseURL = baseUrl;
|
|
1173
|
+
}
|
|
1174
|
+
var _proto = LipheAuthenticator.prototype;
|
|
1175
|
+
_proto.initializeAuth = /*#__PURE__*/function () {
|
|
1176
|
+
var _initializeAuth = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1177
|
+
var _this = this;
|
|
1178
|
+
var token;
|
|
1179
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1180
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1181
|
+
case 0:
|
|
1182
|
+
_context2.next = 2;
|
|
1183
|
+
return this.login();
|
|
1184
|
+
case 2:
|
|
1185
|
+
token = _context2.sent;
|
|
1186
|
+
this.authenticatedAxiosInstance.defaults.headers.common['X-Auth-Token'] = token;
|
|
1187
|
+
this.authenticatedAxiosInstance.interceptors.response.use(function (response) {
|
|
1188
|
+
return response;
|
|
1189
|
+
}, /*#__PURE__*/function () {
|
|
1190
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(error) {
|
|
1191
|
+
var _error$response;
|
|
1192
|
+
var originalRequest, newToken;
|
|
1193
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1194
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1195
|
+
case 0:
|
|
1196
|
+
originalRequest = error.config;
|
|
1197
|
+
originalRequest._retryCount = originalRequest._retryCount || 0;
|
|
1198
|
+
if (!(((_error$response = error.response) == null ? void 0 : _error$response.status) === 401 && originalRequest._retryCount < 1)) {
|
|
1199
|
+
_context.next = 20;
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
originalRequest._retryCount++;
|
|
1203
|
+
_context.prev = 4;
|
|
1204
|
+
if (!_this.tokenRefreshPromise) {
|
|
1205
|
+
_this.tokenRefreshPromise = _this.login();
|
|
1206
|
+
}
|
|
1207
|
+
_context.next = 8;
|
|
1208
|
+
return _this.tokenRefreshPromise;
|
|
1209
|
+
case 8:
|
|
1210
|
+
newToken = _context.sent;
|
|
1211
|
+
_this.tokenRefreshPromise = null;
|
|
1212
|
+
_this.authenticatedAxiosInstance.defaults.headers.common['X-Auth-Token'] = newToken;
|
|
1213
|
+
_context.next = 13;
|
|
1214
|
+
return _this.authenticatedAxiosInstance(originalRequest);
|
|
1215
|
+
case 13:
|
|
1216
|
+
return _context.abrupt("return", _context.sent);
|
|
1217
|
+
case 16:
|
|
1218
|
+
_context.prev = 16;
|
|
1219
|
+
_context.t0 = _context["catch"](4);
|
|
1220
|
+
_this.tokenRefreshPromise = null;
|
|
1221
|
+
return _context.abrupt("return", Promise.reject(_context.t0));
|
|
1222
|
+
case 20:
|
|
1223
|
+
return _context.abrupt("return", Promise.reject(error));
|
|
1224
|
+
case 21:
|
|
1225
|
+
case "end":
|
|
1226
|
+
return _context.stop();
|
|
1227
|
+
}
|
|
1228
|
+
}, _callee, null, [[4, 16]]);
|
|
1229
|
+
}));
|
|
1230
|
+
return function (_x) {
|
|
1231
|
+
return _ref.apply(this, arguments);
|
|
1232
|
+
};
|
|
1233
|
+
}());
|
|
1234
|
+
case 5:
|
|
1235
|
+
case "end":
|
|
1236
|
+
return _context2.stop();
|
|
1237
|
+
}
|
|
1238
|
+
}, _callee2, this);
|
|
1239
|
+
}));
|
|
1240
|
+
function initializeAuth() {
|
|
1241
|
+
return _initializeAuth.apply(this, arguments);
|
|
1242
|
+
}
|
|
1243
|
+
return initializeAuth;
|
|
1244
|
+
}();
|
|
1245
|
+
_proto.login = /*#__PURE__*/function () {
|
|
1246
|
+
var _login = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1247
|
+
var _response$data;
|
|
1248
|
+
var form, response, token;
|
|
1249
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1250
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1251
|
+
case 0:
|
|
1252
|
+
form = new FormData();
|
|
1253
|
+
form.append('email', this.email);
|
|
1254
|
+
form.append('password', this.password);
|
|
1255
|
+
form.append('type', this.type);
|
|
1256
|
+
_context3.next = 6;
|
|
1257
|
+
return this.axiosTokenInstance.post('/v2/signin', form, {
|
|
1258
|
+
headers: form.getHeaders()
|
|
1259
|
+
});
|
|
1260
|
+
case 6:
|
|
1261
|
+
response = _context3.sent;
|
|
1262
|
+
token = response == null || (_response$data = response.data) == null || (_response$data = _response$data.data) == null ? void 0 : _response$data.token;
|
|
1263
|
+
if (token) {
|
|
1264
|
+
_context3.next = 10;
|
|
1265
|
+
break;
|
|
1266
|
+
}
|
|
1267
|
+
throw new Error('Authentication failed: no token return');
|
|
1268
|
+
case 10:
|
|
1269
|
+
this.token = token;
|
|
1270
|
+
return _context3.abrupt("return", token);
|
|
1271
|
+
case 12:
|
|
1272
|
+
case "end":
|
|
1273
|
+
return _context3.stop();
|
|
1274
|
+
}
|
|
1275
|
+
}, _callee3, this);
|
|
1276
|
+
}));
|
|
1277
|
+
function login() {
|
|
1278
|
+
return _login.apply(this, arguments);
|
|
1279
|
+
}
|
|
1280
|
+
return login;
|
|
1281
|
+
}();
|
|
1282
|
+
return LipheAuthenticator;
|
|
1283
|
+
}();
|
|
1284
|
+
|
|
1285
|
+
var LiphePractitionerClient = /*#__PURE__*/function () {
|
|
1286
|
+
function LiphePractitionerClient(axiosInstance) {
|
|
1287
|
+
this.axios = axiosInstance;
|
|
1288
|
+
}
|
|
1289
|
+
var _proto = LiphePractitionerClient.prototype;
|
|
1290
|
+
_proto.fetchAllPractitioners = /*#__PURE__*/function () {
|
|
1291
|
+
var _fetchAllPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(agencyId) {
|
|
1292
|
+
var practitioners, page, nextPage, _response$data, response, data, pagePractitioners;
|
|
1293
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1294
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1295
|
+
case 0:
|
|
1296
|
+
if (agencyId === void 0) {
|
|
1297
|
+
agencyId = 1;
|
|
1298
|
+
}
|
|
1299
|
+
practitioners = [];
|
|
1300
|
+
page = 1;
|
|
1301
|
+
nextPage = true;
|
|
1302
|
+
case 4:
|
|
1303
|
+
if (!nextPage) {
|
|
1304
|
+
_context.next = 17;
|
|
1305
|
+
break;
|
|
1306
|
+
}
|
|
1307
|
+
_context.next = 7;
|
|
1308
|
+
return this.axios.get('/v2/employees', {
|
|
1309
|
+
params: {
|
|
1310
|
+
agency_id: agencyId,
|
|
1311
|
+
page: page
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
case 7:
|
|
1315
|
+
response = _context.sent;
|
|
1316
|
+
data = response == null || (_response$data = response.data) == null ? void 0 : _response$data.data;
|
|
1317
|
+
if (!(!(data != null && data.data) || !Array.isArray(data.data))) {
|
|
1318
|
+
_context.next = 11;
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
throw new Error('Unexpected responses.');
|
|
1322
|
+
case 11:
|
|
1323
|
+
pagePractitioners = data.data.map(function (p) {
|
|
1324
|
+
return {
|
|
1325
|
+
id: p.id,
|
|
1326
|
+
firstname: p.firstname,
|
|
1327
|
+
lastname: p.lastname,
|
|
1328
|
+
email: p.email,
|
|
1329
|
+
communicationMode: p.communicationMode
|
|
1330
|
+
};
|
|
1331
|
+
});
|
|
1332
|
+
practitioners.push.apply(practitioners, pagePractitioners);
|
|
1333
|
+
nextPage = Boolean(data.next_page_url);
|
|
1334
|
+
page++;
|
|
1335
|
+
_context.next = 4;
|
|
1336
|
+
break;
|
|
1337
|
+
case 17:
|
|
1338
|
+
return _context.abrupt("return", practitioners);
|
|
1339
|
+
case 18:
|
|
1340
|
+
case "end":
|
|
1341
|
+
return _context.stop();
|
|
1342
|
+
}
|
|
1343
|
+
}, _callee, this);
|
|
1344
|
+
}));
|
|
1345
|
+
function fetchAllPractitioners(_x) {
|
|
1346
|
+
return _fetchAllPractitioners.apply(this, arguments);
|
|
1347
|
+
}
|
|
1348
|
+
return fetchAllPractitioners;
|
|
1349
|
+
}();
|
|
1350
|
+
return LiphePractitionerClient;
|
|
1351
|
+
}();
|
|
1352
|
+
|
|
1353
|
+
var LipheApiClient = /*#__PURE__*/function () {
|
|
1354
|
+
function LipheApiClient(baseUrl, email, password, type) {
|
|
1355
|
+
if (type === void 0) {
|
|
1356
|
+
type = 'user';
|
|
1357
|
+
}
|
|
1358
|
+
this.instance = undefined;
|
|
1359
|
+
this.axiosInstance = axios.create();
|
|
1360
|
+
this.axiosInstance.defaults.baseURL = baseUrl;
|
|
1361
|
+
this.authenticator = new LipheAuthenticator(this.axiosInstance, baseUrl, email, password, type);
|
|
1362
|
+
this.practitionerClient = new LiphePractitionerClient(this.axiosInstance);
|
|
1363
|
+
}
|
|
1364
|
+
var _proto = LipheApiClient.prototype;
|
|
1365
|
+
_proto.init = /*#__PURE__*/function () {
|
|
1366
|
+
var _init = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1367
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1368
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1369
|
+
case 0:
|
|
1370
|
+
_context.next = 2;
|
|
1371
|
+
return this.authenticator.initializeAuth();
|
|
1372
|
+
case 2:
|
|
1373
|
+
case "end":
|
|
1374
|
+
return _context.stop();
|
|
1375
|
+
}
|
|
1376
|
+
}, _callee, this);
|
|
1377
|
+
}));
|
|
1378
|
+
function init() {
|
|
1379
|
+
return _init.apply(this, arguments);
|
|
1380
|
+
}
|
|
1381
|
+
return init;
|
|
1382
|
+
}();
|
|
1383
|
+
_proto.setInstance = function setInstance(instance) {
|
|
1384
|
+
this.instance = instance;
|
|
1385
|
+
};
|
|
1386
|
+
_proto.getInstance = function getInstance() {
|
|
1387
|
+
return this.instance;
|
|
1388
|
+
};
|
|
1389
|
+
_proto.getAxiosInstance = function getAxiosInstance() {
|
|
1390
|
+
return this.axiosInstance;
|
|
1391
|
+
};
|
|
1392
|
+
return LipheApiClient;
|
|
1393
|
+
}();
|
|
1394
|
+
|
|
1395
|
+
export { LipheApiClient, LipheAuthenticator, LiphePractitionerClient, SFApiClient, SFAuthenticator, SFPractitionerClient, SFTimesheetClient };
|
|
1214
1396
|
//# sourceMappingURL=pha-hermes.esm.js.map
|