pha-hermes 1.24.0 → 1.25.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/salesforce/practitioner/practitionerClient.d.ts +8 -1
- package/dist/models/user.d.ts +13 -0
- package/dist/pha-hermes.cjs.development.js +38 -9
- 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 -9
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/salesforce/practitioner/practitionerClient.ts +65 -4
- package/src/models/user.ts +14 -0
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { Practitioner, Role } from '../../../models';
|
|
2
|
+
import { Practitioner, PractitionerExport, Role } from '../../../models';
|
|
3
3
|
export declare class SFPractitionerClient {
|
|
4
|
+
private PRACTITIONER_FIELDS;
|
|
4
5
|
private axiosInstance;
|
|
5
6
|
constructor(axiosInstance: AxiosInstance);
|
|
7
|
+
fetchPractitioners(options: {
|
|
8
|
+
createdAt?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
forExport: true;
|
|
11
|
+
}): Promise<PractitionerExport[]>;
|
|
6
12
|
fetchPractitioners(options?: {
|
|
7
13
|
createdAt?: string;
|
|
8
14
|
limit?: number;
|
|
15
|
+
forExport?: false | undefined;
|
|
9
16
|
}): Promise<Practitioner[]>;
|
|
10
17
|
fetchPractitionerByEmail(email: string): Promise<Practitioner | null>;
|
|
11
18
|
fetchRoles(): Promise<Role[]>;
|
package/dist/models/user.d.ts
CHANGED
|
@@ -6,6 +6,19 @@ export interface Practitioner {
|
|
|
6
6
|
staffId: string;
|
|
7
7
|
createdAt?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface PractitionerExport extends Practitioner {
|
|
10
|
+
phone: string | null;
|
|
11
|
+
status: string | null;
|
|
12
|
+
professionalDesignation: string | null;
|
|
13
|
+
SIN: string | null;
|
|
14
|
+
hiringDate: string | null;
|
|
15
|
+
dateApplied: string | null;
|
|
16
|
+
birthdate: string | null;
|
|
17
|
+
mailingStreetAddress: string | null;
|
|
18
|
+
mailingCity: string | null;
|
|
19
|
+
mailingProvince: string | null;
|
|
20
|
+
mailingZip: string | null;
|
|
21
|
+
}
|
|
9
22
|
export interface Role {
|
|
10
23
|
label: string;
|
|
11
24
|
value: string;
|
|
@@ -55,6 +55,15 @@ function _createForOfIteratorHelperLoose(r, e) {
|
|
|
55
55
|
}
|
|
56
56
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
57
|
}
|
|
58
|
+
function _extends() {
|
|
59
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
60
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
61
|
+
var t = arguments[e];
|
|
62
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
63
|
+
}
|
|
64
|
+
return n;
|
|
65
|
+
}, _extends.apply(null, arguments);
|
|
66
|
+
}
|
|
58
67
|
function _regeneratorRuntime() {
|
|
59
68
|
_regeneratorRuntime = function () {
|
|
60
69
|
return e;
|
|
@@ -833,12 +842,16 @@ function toTimesheetDayEntry(raw) {
|
|
|
833
842
|
|
|
834
843
|
var SFPractitionerClient = /*#__PURE__*/function () {
|
|
835
844
|
function SFPractitionerClient(axiosInstance) {
|
|
845
|
+
this.PRACTITIONER_FIELDS = {
|
|
846
|
+
"default": ['Id', 'FirstName__c', 'LastName__c', 'Email__c', 'StaffID__c', 'CreatedDate'],
|
|
847
|
+
"export": ['Id', 'FirstName__c', 'LastName__c', 'Email__c', 'StaffID__c', 'CreatedDate', 'DaytimePhone__c', 'Status__c', 'ProfessionalDesignation__c', 'CANSocialInsuranceNumber__c', 'Date_of_Hire__c', 'DateApplied__c', 'Birthdate__c', 'MailingStreetAddress__c', 'MailingCity__c', 'MailingStateProvince__c', 'MailingZipPostalCode__c']
|
|
848
|
+
};
|
|
836
849
|
this.axiosInstance = axiosInstance;
|
|
837
850
|
}
|
|
838
851
|
var _proto = SFPractitionerClient.prototype;
|
|
839
852
|
_proto.fetchPractitioners = /*#__PURE__*/function () {
|
|
840
853
|
var _fetchPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
841
|
-
var conditions, whereClause, limitClause, url, query, _yield$this$axiosInst, records;
|
|
854
|
+
var conditions, whereClause, limitClause, url, fields, query, _yield$this$axiosInst, records;
|
|
842
855
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
843
856
|
while (1) switch (_context.prev = _context.next) {
|
|
844
857
|
case 0:
|
|
@@ -850,27 +863,28 @@ var SFPractitionerClient = /*#__PURE__*/function () {
|
|
|
850
863
|
whereClause = conditions.length ? "WHERE " + conditions.join(' AND ') : '';
|
|
851
864
|
limitClause = typeof (options == null ? void 0 : options.limit) === 'number' && options.limit > 0 ? "LIMIT " + Math.floor(options.limit) : '';
|
|
852
865
|
url = "/services/data/" + SF_API_VERSION$1 + "/query";
|
|
853
|
-
|
|
854
|
-
|
|
866
|
+
fields = (options != null && options.forExport ? this.PRACTITIONER_FIELDS["export"] : this.PRACTITIONER_FIELDS["default"]).join(', ');
|
|
867
|
+
query = "\n SELECT " + fields + "\n FROM Personnel__c\n " + whereClause + "\n ORDER BY CreatedDate ASC, StaffID__c ASC\n " + limitClause + "\n ";
|
|
868
|
+
_context.next = 10;
|
|
855
869
|
return this.axiosInstance.get(url, {
|
|
856
870
|
params: {
|
|
857
871
|
q: query
|
|
858
872
|
}
|
|
859
873
|
});
|
|
860
|
-
case
|
|
874
|
+
case 10:
|
|
861
875
|
_yield$this$axiosInst = _context.sent;
|
|
862
876
|
records = _yield$this$axiosInst.data.records;
|
|
863
|
-
return _context.abrupt("return", records.map(toPractitioner));
|
|
864
|
-
case
|
|
865
|
-
_context.prev =
|
|
877
|
+
return _context.abrupt("return", options != null && options.forExport ? records.map(toPractitionerExport) : records.map(toPractitioner));
|
|
878
|
+
case 15:
|
|
879
|
+
_context.prev = 15;
|
|
866
880
|
_context.t0 = _context["catch"](0);
|
|
867
881
|
console.error('Error fetching practitioners: ', _context.t0.message);
|
|
868
882
|
throw _context.t0;
|
|
869
|
-
case
|
|
883
|
+
case 19:
|
|
870
884
|
case "end":
|
|
871
885
|
return _context.stop();
|
|
872
886
|
}
|
|
873
|
-
}, _callee, this, [[0,
|
|
887
|
+
}, _callee, this, [[0, 15]]);
|
|
874
888
|
}));
|
|
875
889
|
function fetchPractitioners(_x) {
|
|
876
890
|
return _fetchPractitioners.apply(this, arguments);
|
|
@@ -971,6 +985,21 @@ function toPractitioner(raw) {
|
|
|
971
985
|
createdAt: raw.CreatedDate ? raw.CreatedDate.replace(/\+0000$/, 'Z') : undefined
|
|
972
986
|
};
|
|
973
987
|
}
|
|
988
|
+
function toPractitionerExport(raw) {
|
|
989
|
+
return _extends({}, toPractitioner(raw), {
|
|
990
|
+
phone: raw.DaytimePhone__c,
|
|
991
|
+
status: raw.Status__c,
|
|
992
|
+
professionalDesignation: raw.ProfessionalDesignation__c,
|
|
993
|
+
SIN: raw.CANSocialInsuranceNumber__c,
|
|
994
|
+
hiringDate: raw.Date_of_Hire__c,
|
|
995
|
+
dateApplied: raw.DateApplied__c,
|
|
996
|
+
birthdate: raw.Birthdate__c,
|
|
997
|
+
mailingStreetAddress: raw.MailingStreetAddress__c,
|
|
998
|
+
mailingCity: raw.MailingCity__c,
|
|
999
|
+
mailingProvince: raw.MailingStateProvince__c,
|
|
1000
|
+
mailingZip: raw.MailingZipPostalCode__c
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
974
1003
|
|
|
975
1004
|
var SFWorkorderClient = /*#__PURE__*/function () {
|
|
976
1005
|
function SFWorkorderClient(axiosInstance) {
|