pha-hermes 1.0.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/apiClient.d.ts +18 -0
- package/dist/api/auth/auth.d.ts +10 -0
- package/dist/api/practitioner/practitionerClient.d.ts +7 -0
- package/dist/api/timesheet/timesheetClient.d.ts +10 -0
- package/dist/hermes.cjs.development.js +786 -0
- package/dist/hermes.cjs.development.js.map +1 -0
- package/dist/hermes.cjs.production.min.js +2 -0
- package/dist/hermes.cjs.production.min.js.map +1 -0
- package/dist/hermes.esm.js +777 -0
- package/dist/hermes.esm.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/models/index.d.ts +12 -0
- package/dist/models/practitioner.d.ts +7 -0
- package/dist/models/timesheet.d.ts +17 -0
- package/package.json +31 -0
- package/src/api/apiClient.ts +82 -0
- package/src/api/auth/auth.ts +48 -0
- package/src/api/practitioner/practitionerClient.ts +42 -0
- package/src/api/timesheet/timesheetClient.ts +98 -0
- package/src/index.ts +3 -0
- package/src/models/index.ts +14 -0
- package/src/models/practitioner.ts +7 -0
- package/src/models/timesheet.ts +21 -0
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
|
|
4
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
5
|
+
try {
|
|
6
|
+
var i = n[a](c),
|
|
7
|
+
u = i.value;
|
|
8
|
+
} catch (n) {
|
|
9
|
+
return void e(n);
|
|
10
|
+
}
|
|
11
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
12
|
+
}
|
|
13
|
+
function _asyncToGenerator(n) {
|
|
14
|
+
return function () {
|
|
15
|
+
var t = this,
|
|
16
|
+
e = arguments;
|
|
17
|
+
return new Promise(function (r, o) {
|
|
18
|
+
var a = n.apply(t, e);
|
|
19
|
+
function _next(n) {
|
|
20
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
21
|
+
}
|
|
22
|
+
function _throw(n) {
|
|
23
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
24
|
+
}
|
|
25
|
+
_next(void 0);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function _regeneratorRuntime() {
|
|
30
|
+
_regeneratorRuntime = function () {
|
|
31
|
+
return e;
|
|
32
|
+
};
|
|
33
|
+
var t,
|
|
34
|
+
e = {},
|
|
35
|
+
r = Object.prototype,
|
|
36
|
+
n = r.hasOwnProperty,
|
|
37
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
38
|
+
t[e] = r.value;
|
|
39
|
+
},
|
|
40
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
41
|
+
a = i.iterator || "@@iterator",
|
|
42
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
43
|
+
u = i.toStringTag || "@@toStringTag";
|
|
44
|
+
function define(t, e, r) {
|
|
45
|
+
return Object.defineProperty(t, e, {
|
|
46
|
+
value: r,
|
|
47
|
+
enumerable: !0,
|
|
48
|
+
configurable: !0,
|
|
49
|
+
writable: !0
|
|
50
|
+
}), t[e];
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
define({}, "");
|
|
54
|
+
} catch (t) {
|
|
55
|
+
define = function (t, e, r) {
|
|
56
|
+
return t[e] = r;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function wrap(t, e, r, n) {
|
|
60
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
61
|
+
a = Object.create(i.prototype),
|
|
62
|
+
c = new Context(n || []);
|
|
63
|
+
return o(a, "_invoke", {
|
|
64
|
+
value: makeInvokeMethod(t, r, c)
|
|
65
|
+
}), a;
|
|
66
|
+
}
|
|
67
|
+
function tryCatch(t, e, r) {
|
|
68
|
+
try {
|
|
69
|
+
return {
|
|
70
|
+
type: "normal",
|
|
71
|
+
arg: t.call(e, r)
|
|
72
|
+
};
|
|
73
|
+
} catch (t) {
|
|
74
|
+
return {
|
|
75
|
+
type: "throw",
|
|
76
|
+
arg: t
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
e.wrap = wrap;
|
|
81
|
+
var h = "suspendedStart",
|
|
82
|
+
l = "suspendedYield",
|
|
83
|
+
f = "executing",
|
|
84
|
+
s = "completed",
|
|
85
|
+
y = {};
|
|
86
|
+
function Generator() {}
|
|
87
|
+
function GeneratorFunction() {}
|
|
88
|
+
function GeneratorFunctionPrototype() {}
|
|
89
|
+
var p = {};
|
|
90
|
+
define(p, a, function () {
|
|
91
|
+
return this;
|
|
92
|
+
});
|
|
93
|
+
var d = Object.getPrototypeOf,
|
|
94
|
+
v = d && d(d(values([])));
|
|
95
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
96
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
97
|
+
function defineIteratorMethods(t) {
|
|
98
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
99
|
+
define(t, e, function (t) {
|
|
100
|
+
return this._invoke(e, t);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function AsyncIterator(t, e) {
|
|
105
|
+
function invoke(r, o, i, a) {
|
|
106
|
+
var c = tryCatch(t[r], t, o);
|
|
107
|
+
if ("throw" !== c.type) {
|
|
108
|
+
var u = c.arg,
|
|
109
|
+
h = u.value;
|
|
110
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
111
|
+
invoke("next", t, i, a);
|
|
112
|
+
}, function (t) {
|
|
113
|
+
invoke("throw", t, i, a);
|
|
114
|
+
}) : e.resolve(h).then(function (t) {
|
|
115
|
+
u.value = t, i(u);
|
|
116
|
+
}, function (t) {
|
|
117
|
+
return invoke("throw", t, i, a);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
a(c.arg);
|
|
121
|
+
}
|
|
122
|
+
var r;
|
|
123
|
+
o(this, "_invoke", {
|
|
124
|
+
value: function (t, n) {
|
|
125
|
+
function callInvokeWithMethodAndArg() {
|
|
126
|
+
return new e(function (e, r) {
|
|
127
|
+
invoke(t, n, e, r);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function makeInvokeMethod(e, r, n) {
|
|
135
|
+
var o = h;
|
|
136
|
+
return function (i, a) {
|
|
137
|
+
if (o === f) throw Error("Generator is already running");
|
|
138
|
+
if (o === s) {
|
|
139
|
+
if ("throw" === i) throw a;
|
|
140
|
+
return {
|
|
141
|
+
value: t,
|
|
142
|
+
done: !0
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
for (n.method = i, n.arg = a;;) {
|
|
146
|
+
var c = n.delegate;
|
|
147
|
+
if (c) {
|
|
148
|
+
var u = maybeInvokeDelegate(c, n);
|
|
149
|
+
if (u) {
|
|
150
|
+
if (u === y) continue;
|
|
151
|
+
return u;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
155
|
+
if (o === h) throw o = s, n.arg;
|
|
156
|
+
n.dispatchException(n.arg);
|
|
157
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
158
|
+
o = f;
|
|
159
|
+
var p = tryCatch(e, r, n);
|
|
160
|
+
if ("normal" === p.type) {
|
|
161
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
162
|
+
return {
|
|
163
|
+
value: p.arg,
|
|
164
|
+
done: n.done
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function maybeInvokeDelegate(e, r) {
|
|
172
|
+
var n = r.method,
|
|
173
|
+
o = e.iterator[n];
|
|
174
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
175
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
176
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
177
|
+
var a = i.arg;
|
|
178
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
179
|
+
}
|
|
180
|
+
function pushTryEntry(t) {
|
|
181
|
+
var e = {
|
|
182
|
+
tryLoc: t[0]
|
|
183
|
+
};
|
|
184
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
185
|
+
}
|
|
186
|
+
function resetTryEntry(t) {
|
|
187
|
+
var e = t.completion || {};
|
|
188
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
189
|
+
}
|
|
190
|
+
function Context(t) {
|
|
191
|
+
this.tryEntries = [{
|
|
192
|
+
tryLoc: "root"
|
|
193
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
194
|
+
}
|
|
195
|
+
function values(e) {
|
|
196
|
+
if (e || "" === e) {
|
|
197
|
+
var r = e[a];
|
|
198
|
+
if (r) return r.call(e);
|
|
199
|
+
if ("function" == typeof e.next) return e;
|
|
200
|
+
if (!isNaN(e.length)) {
|
|
201
|
+
var o = -1,
|
|
202
|
+
i = function next() {
|
|
203
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
204
|
+
return next.value = t, next.done = !0, next;
|
|
205
|
+
};
|
|
206
|
+
return i.next = i;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
210
|
+
}
|
|
211
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
212
|
+
value: GeneratorFunctionPrototype,
|
|
213
|
+
configurable: !0
|
|
214
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
215
|
+
value: GeneratorFunction,
|
|
216
|
+
configurable: !0
|
|
217
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
218
|
+
var e = "function" == typeof t && t.constructor;
|
|
219
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
220
|
+
}, e.mark = function (t) {
|
|
221
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
222
|
+
}, e.awrap = function (t) {
|
|
223
|
+
return {
|
|
224
|
+
__await: t
|
|
225
|
+
};
|
|
226
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
227
|
+
return this;
|
|
228
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
229
|
+
void 0 === i && (i = Promise);
|
|
230
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
231
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
232
|
+
return t.done ? t.value : a.next();
|
|
233
|
+
});
|
|
234
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
235
|
+
return this;
|
|
236
|
+
}), define(g, "toString", function () {
|
|
237
|
+
return "[object Generator]";
|
|
238
|
+
}), e.keys = function (t) {
|
|
239
|
+
var e = Object(t),
|
|
240
|
+
r = [];
|
|
241
|
+
for (var n in e) r.push(n);
|
|
242
|
+
return r.reverse(), function next() {
|
|
243
|
+
for (; r.length;) {
|
|
244
|
+
var t = r.pop();
|
|
245
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
246
|
+
}
|
|
247
|
+
return next.done = !0, next;
|
|
248
|
+
};
|
|
249
|
+
}, e.values = values, Context.prototype = {
|
|
250
|
+
constructor: Context,
|
|
251
|
+
reset: function (e) {
|
|
252
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
253
|
+
},
|
|
254
|
+
stop: function () {
|
|
255
|
+
this.done = !0;
|
|
256
|
+
var t = this.tryEntries[0].completion;
|
|
257
|
+
if ("throw" === t.type) throw t.arg;
|
|
258
|
+
return this.rval;
|
|
259
|
+
},
|
|
260
|
+
dispatchException: function (e) {
|
|
261
|
+
if (this.done) throw e;
|
|
262
|
+
var r = this;
|
|
263
|
+
function handle(n, o) {
|
|
264
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
265
|
+
}
|
|
266
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
267
|
+
var i = this.tryEntries[o],
|
|
268
|
+
a = i.completion;
|
|
269
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
270
|
+
if (i.tryLoc <= this.prev) {
|
|
271
|
+
var c = n.call(i, "catchLoc"),
|
|
272
|
+
u = n.call(i, "finallyLoc");
|
|
273
|
+
if (c && u) {
|
|
274
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
275
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
276
|
+
} else if (c) {
|
|
277
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
278
|
+
} else {
|
|
279
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
280
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
abrupt: function (t, e) {
|
|
286
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
287
|
+
var o = this.tryEntries[r];
|
|
288
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
289
|
+
var i = o;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
294
|
+
var a = i ? i.completion : {};
|
|
295
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
296
|
+
},
|
|
297
|
+
complete: function (t, e) {
|
|
298
|
+
if ("throw" === t.type) throw t.arg;
|
|
299
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
300
|
+
},
|
|
301
|
+
finish: function (t) {
|
|
302
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
303
|
+
var r = this.tryEntries[e];
|
|
304
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
catch: function (t) {
|
|
308
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
309
|
+
var r = this.tryEntries[e];
|
|
310
|
+
if (r.tryLoc === t) {
|
|
311
|
+
var n = r.completion;
|
|
312
|
+
if ("throw" === n.type) {
|
|
313
|
+
var o = n.arg;
|
|
314
|
+
resetTryEntry(r);
|
|
315
|
+
}
|
|
316
|
+
return o;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
throw Error("illegal catch attempt");
|
|
320
|
+
},
|
|
321
|
+
delegateYield: function (e, r, n) {
|
|
322
|
+
return this.delegate = {
|
|
323
|
+
iterator: values(e),
|
|
324
|
+
resultName: r,
|
|
325
|
+
nextLoc: n
|
|
326
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
327
|
+
}
|
|
328
|
+
}, e;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
var SFAuthenticator = /*#__PURE__*/function () {
|
|
332
|
+
function SFAuthenticator(authenticatedAxiosInstance, baseUrl) {
|
|
333
|
+
this.axiosTokenInstance = axios.create();
|
|
334
|
+
this.token = undefined;
|
|
335
|
+
this.refreshToken = undefined;
|
|
336
|
+
this.axiosTokenInstance.defaults.baseURL = baseUrl != null ? baseUrl : 'https://do0000000d247eaa--phealth.sandbox.my.salesforce.com';
|
|
337
|
+
this.authenticatedAxiosInstance = authenticatedAxiosInstance;
|
|
338
|
+
}
|
|
339
|
+
var _proto = SFAuthenticator.prototype;
|
|
340
|
+
_proto.initializeAuth = /*#__PURE__*/function () {
|
|
341
|
+
var _initializeAuth = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(clientId, clientSecret) {
|
|
342
|
+
var token;
|
|
343
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
344
|
+
while (1) switch (_context.prev = _context.next) {
|
|
345
|
+
case 0:
|
|
346
|
+
_context.next = 2;
|
|
347
|
+
return this.postToken(clientId, clientSecret);
|
|
348
|
+
case 2:
|
|
349
|
+
token = _context.sent;
|
|
350
|
+
this.authenticatedAxiosInstance.defaults.headers.common['Authorization'] = "Bearer " + token;
|
|
351
|
+
case 4:
|
|
352
|
+
case "end":
|
|
353
|
+
return _context.stop();
|
|
354
|
+
}
|
|
355
|
+
}, _callee, this);
|
|
356
|
+
}));
|
|
357
|
+
function initializeAuth(_x, _x2) {
|
|
358
|
+
return _initializeAuth.apply(this, arguments);
|
|
359
|
+
}
|
|
360
|
+
return initializeAuth;
|
|
361
|
+
}();
|
|
362
|
+
_proto.postToken = /*#__PURE__*/function () {
|
|
363
|
+
var _postToken = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(clientId, clientSecret) {
|
|
364
|
+
var _response$data;
|
|
365
|
+
var tokenFormRequestBody, response;
|
|
366
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
367
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
368
|
+
case 0:
|
|
369
|
+
tokenFormRequestBody = new FormData();
|
|
370
|
+
if (!this.refreshToken) {
|
|
371
|
+
_context2.next = 6;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
tokenFormRequestBody.append('refresh_token', this.refreshToken);
|
|
375
|
+
tokenFormRequestBody.append('grant_type', 'refresh_token');
|
|
376
|
+
_context2.next = 13;
|
|
377
|
+
break;
|
|
378
|
+
case 6:
|
|
379
|
+
if (!(clientId && clientSecret)) {
|
|
380
|
+
_context2.next = 12;
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
tokenFormRequestBody.append('client_id', clientId);
|
|
384
|
+
tokenFormRequestBody.append('client_secret', clientSecret);
|
|
385
|
+
tokenFormRequestBody.append('grant_type', 'client_credentials');
|
|
386
|
+
_context2.next = 13;
|
|
387
|
+
break;
|
|
388
|
+
case 12:
|
|
389
|
+
throw new Error('Authentication failed, either the RefreshToken, or ClientId and ClientSecret need to be provided');
|
|
390
|
+
case 13:
|
|
391
|
+
_context2.next = 15;
|
|
392
|
+
return this.axiosTokenInstance.post('/services/oauth2/token', tokenFormRequestBody, {
|
|
393
|
+
headers: tokenFormRequestBody.getHeaders()
|
|
394
|
+
});
|
|
395
|
+
case 15:
|
|
396
|
+
response = _context2.sent;
|
|
397
|
+
this.token = response == null || (_response$data = response.data) == null ? void 0 : _response$data['access_token'];
|
|
398
|
+
if (this.token) {
|
|
399
|
+
_context2.next = 19;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
throw new Error('Authentication failed, could not get the access token');
|
|
403
|
+
case 19:
|
|
404
|
+
return _context2.abrupt("return", this.token);
|
|
405
|
+
case 20:
|
|
406
|
+
case "end":
|
|
407
|
+
return _context2.stop();
|
|
408
|
+
}
|
|
409
|
+
}, _callee2, this);
|
|
410
|
+
}));
|
|
411
|
+
function postToken(_x3, _x4) {
|
|
412
|
+
return _postToken.apply(this, arguments);
|
|
413
|
+
}
|
|
414
|
+
return postToken;
|
|
415
|
+
}();
|
|
416
|
+
return SFAuthenticator;
|
|
417
|
+
}();
|
|
418
|
+
|
|
419
|
+
var SFTimesheetClient = /*#__PURE__*/function () {
|
|
420
|
+
function SFTimesheetClient(axiosInstance) {
|
|
421
|
+
this.axiosInstance = axiosInstance;
|
|
422
|
+
}
|
|
423
|
+
var _proto = SFTimesheetClient.prototype;
|
|
424
|
+
_proto.updateTimesheetHour = /*#__PURE__*/function () {
|
|
425
|
+
var _updateTimesheetHour = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(timesheetHourId, timesheet) {
|
|
426
|
+
var url, response;
|
|
427
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
428
|
+
while (1) switch (_context.prev = _context.next) {
|
|
429
|
+
case 0:
|
|
430
|
+
_context.prev = 0;
|
|
431
|
+
url = "/services/data/" + SF_API_VERSION + "/sobjects/TimeSheetHour__c/" + timesheetHourId;
|
|
432
|
+
_context.next = 4;
|
|
433
|
+
return this.axiosInstance.patch(url, {
|
|
434
|
+
Callback__c: timesheet.callbackHours,
|
|
435
|
+
HoursEBAdjusted__c: timesheet.regularHours,
|
|
436
|
+
Misc__c: timesheet.miscHours,
|
|
437
|
+
OT1__c: timesheet.overtime1Hours,
|
|
438
|
+
OT2__c: timesheet.overtime2Hours,
|
|
439
|
+
OnCall__c: timesheet.onCallHours,
|
|
440
|
+
Misc1__c: timesheet.misc1HoursA,
|
|
441
|
+
Misc_1_Hours__c: timesheet.misc1HoursB,
|
|
442
|
+
Misc_2_Hours__c: timesheet.misc2Hours,
|
|
443
|
+
Misc_3_Hours__c: timesheet.misc3Hours,
|
|
444
|
+
Misc_4_Hours__c: timesheet.misc4Hours,
|
|
445
|
+
Stat1__c: timesheet.stat1Hours,
|
|
446
|
+
Stat2__c: timesheet.stat2Hours,
|
|
447
|
+
In_Charge__c: timesheet.inChargeHours,
|
|
448
|
+
Shift_Travel_Stipend__c: timesheet.shiftTravelPerDiemHours
|
|
449
|
+
});
|
|
450
|
+
case 4:
|
|
451
|
+
response = _context.sent;
|
|
452
|
+
if ([200, 204, 304].includes(response.status)) {
|
|
453
|
+
_context.next = 7;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
throw new Error("got error status code " + response.status);
|
|
457
|
+
case 7:
|
|
458
|
+
_context.next = 12;
|
|
459
|
+
break;
|
|
460
|
+
case 9:
|
|
461
|
+
_context.prev = 9;
|
|
462
|
+
_context.t0 = _context["catch"](0);
|
|
463
|
+
console.error('Error Updating Timesheet Hour: ', _context.t0.message);
|
|
464
|
+
case 12:
|
|
465
|
+
case "end":
|
|
466
|
+
return _context.stop();
|
|
467
|
+
}
|
|
468
|
+
}, _callee, this, [[0, 9]]);
|
|
469
|
+
}));
|
|
470
|
+
function updateTimesheetHour(_x, _x2) {
|
|
471
|
+
return _updateTimesheetHour.apply(this, arguments);
|
|
472
|
+
}
|
|
473
|
+
return updateTimesheetHour;
|
|
474
|
+
}();
|
|
475
|
+
_proto.getTimesheetId = /*#__PURE__*/function () {
|
|
476
|
+
var _getTimesheetId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(workorderId) {
|
|
477
|
+
var url, query, _yield$this$axiosInst, records;
|
|
478
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
479
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
480
|
+
case 0:
|
|
481
|
+
// First we find the correct timesheet id
|
|
482
|
+
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
483
|
+
query = "SELECT Id FROM Timesheet__c WHERE WorkOrder__c = '" + workorderId + "' LIMIT 1";
|
|
484
|
+
_context2.next = 4;
|
|
485
|
+
return this.axiosInstance.get(url, {
|
|
486
|
+
params: {
|
|
487
|
+
q: query
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
case 4:
|
|
491
|
+
_yield$this$axiosInst = _context2.sent;
|
|
492
|
+
records = _yield$this$axiosInst.data.records;
|
|
493
|
+
return _context2.abrupt("return", records[0].Id);
|
|
494
|
+
case 7:
|
|
495
|
+
case "end":
|
|
496
|
+
return _context2.stop();
|
|
497
|
+
}
|
|
498
|
+
}, _callee2, this);
|
|
499
|
+
}));
|
|
500
|
+
function getTimesheetId(_x3) {
|
|
501
|
+
return _getTimesheetId.apply(this, arguments);
|
|
502
|
+
}
|
|
503
|
+
return getTimesheetId;
|
|
504
|
+
}();
|
|
505
|
+
_proto.getTimesheetHoursIds = /*#__PURE__*/function () {
|
|
506
|
+
var _getTimesheetHoursIds = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(workorderId) {
|
|
507
|
+
var timesheetId, url, query, _yield$this$axiosInst2, records;
|
|
508
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
509
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
510
|
+
case 0:
|
|
511
|
+
_context3.next = 2;
|
|
512
|
+
return this.getTimesheetId(workorderId);
|
|
513
|
+
case 2:
|
|
514
|
+
timesheetId = _context3.sent;
|
|
515
|
+
// First we find the correct timesheet hours id
|
|
516
|
+
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
517
|
+
query = "SELECT Id FROM TimesheetHour__c WHERE Timesheet__c = '" + timesheetId + "'";
|
|
518
|
+
_context3.next = 7;
|
|
519
|
+
return this.axiosInstance.get(url, {
|
|
520
|
+
params: {
|
|
521
|
+
q: query
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
case 7:
|
|
525
|
+
_yield$this$axiosInst2 = _context3.sent;
|
|
526
|
+
records = _yield$this$axiosInst2.data.records;
|
|
527
|
+
return _context3.abrupt("return", records.map(function (_ref) {
|
|
528
|
+
var Id = _ref.Id;
|
|
529
|
+
return Id;
|
|
530
|
+
}));
|
|
531
|
+
case 10:
|
|
532
|
+
case "end":
|
|
533
|
+
return _context3.stop();
|
|
534
|
+
}
|
|
535
|
+
}, _callee3, this);
|
|
536
|
+
}));
|
|
537
|
+
function getTimesheetHoursIds(_x4) {
|
|
538
|
+
return _getTimesheetHoursIds.apply(this, arguments);
|
|
539
|
+
}
|
|
540
|
+
return getTimesheetHoursIds;
|
|
541
|
+
}();
|
|
542
|
+
_proto.getTimesheetHours = /*#__PURE__*/function () {
|
|
543
|
+
var _getTimesheetHours = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(workorderId) {
|
|
544
|
+
var _this = this;
|
|
545
|
+
var timesheetHourIds;
|
|
546
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
547
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
548
|
+
case 0:
|
|
549
|
+
_context5.next = 2;
|
|
550
|
+
return this.getTimesheetHoursIds(workorderId);
|
|
551
|
+
case 2:
|
|
552
|
+
timesheetHourIds = _context5.sent;
|
|
553
|
+
return _context5.abrupt("return", Promise.all(timesheetHourIds.map(/*#__PURE__*/function () {
|
|
554
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id) {
|
|
555
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
556
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
557
|
+
case 0:
|
|
558
|
+
return _context4.abrupt("return", _this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/sobjects/TimeSheetHour__c/" + id).then(function (res) {
|
|
559
|
+
return res.data;
|
|
560
|
+
}).then(toTimesheetDayEntry));
|
|
561
|
+
case 1:
|
|
562
|
+
case "end":
|
|
563
|
+
return _context4.stop();
|
|
564
|
+
}
|
|
565
|
+
}, _callee4);
|
|
566
|
+
}));
|
|
567
|
+
return function (_x6) {
|
|
568
|
+
return _ref2.apply(this, arguments);
|
|
569
|
+
};
|
|
570
|
+
}())));
|
|
571
|
+
case 4:
|
|
572
|
+
case "end":
|
|
573
|
+
return _context5.stop();
|
|
574
|
+
}
|
|
575
|
+
}, _callee5, this);
|
|
576
|
+
}));
|
|
577
|
+
function getTimesheetHours(_x5) {
|
|
578
|
+
return _getTimesheetHours.apply(this, arguments);
|
|
579
|
+
}
|
|
580
|
+
return getTimesheetHours;
|
|
581
|
+
}();
|
|
582
|
+
return SFTimesheetClient;
|
|
583
|
+
}();
|
|
584
|
+
function toTimesheetDayEntry(raw) {
|
|
585
|
+
return {
|
|
586
|
+
callbackHours: raw.Callback__c,
|
|
587
|
+
regularHours: raw.HoursEBAdjusted__c,
|
|
588
|
+
miscHours: raw.Misc__c,
|
|
589
|
+
overtime1Hours: raw.OT1__c,
|
|
590
|
+
overtime2Hours: raw.OT2__c,
|
|
591
|
+
onCallHours: raw.OnCall__c,
|
|
592
|
+
misc1HoursA: raw.Misc1__c,
|
|
593
|
+
misc1HoursB: raw.Misc_1_Hours__c,
|
|
594
|
+
misc2Hours: raw.Misc_2_Hours__c,
|
|
595
|
+
misc3Hours: raw.Misc_3_Hours__c,
|
|
596
|
+
misc4Hours: raw.Misc_4_Hours__c,
|
|
597
|
+
stat1Hours: raw.Stat1__c,
|
|
598
|
+
stat2Hours: raw.Stat2__c,
|
|
599
|
+
inChargeHours: raw.In_Charge__c,
|
|
600
|
+
shiftTravelPerDiemHours: raw.Shift_Travel_Stipend__c
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
var SFPractitionerClient = /*#__PURE__*/function () {
|
|
605
|
+
function SFPractitionerClient(axiosInstance) {
|
|
606
|
+
this.axiosInstance = axiosInstance;
|
|
607
|
+
}
|
|
608
|
+
var _proto = SFPractitionerClient.prototype;
|
|
609
|
+
_proto.fetchPractitioners = /*#__PURE__*/function () {
|
|
610
|
+
var _fetchPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
611
|
+
var url, query, _yield$this$axiosInst, records;
|
|
612
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
613
|
+
while (1) switch (_context.prev = _context.next) {
|
|
614
|
+
case 0:
|
|
615
|
+
_context.prev = 0;
|
|
616
|
+
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
617
|
+
query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c\n FROM Personnel__c\n WHERE Status__c = 'Active'\n ";
|
|
618
|
+
_context.next = 5;
|
|
619
|
+
return this.axiosInstance.get(url, {
|
|
620
|
+
params: {
|
|
621
|
+
q: query
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
case 5:
|
|
625
|
+
_yield$this$axiosInst = _context.sent;
|
|
626
|
+
records = _yield$this$axiosInst.data.records;
|
|
627
|
+
return _context.abrupt("return", records.map(toPractitioner));
|
|
628
|
+
case 10:
|
|
629
|
+
_context.prev = 10;
|
|
630
|
+
_context.t0 = _context["catch"](0);
|
|
631
|
+
console.error('Error fetching practitioners: ', _context.t0.message);
|
|
632
|
+
throw _context.t0;
|
|
633
|
+
case 14:
|
|
634
|
+
case "end":
|
|
635
|
+
return _context.stop();
|
|
636
|
+
}
|
|
637
|
+
}, _callee, this, [[0, 10]]);
|
|
638
|
+
}));
|
|
639
|
+
function fetchPractitioners() {
|
|
640
|
+
return _fetchPractitioners.apply(this, arguments);
|
|
641
|
+
}
|
|
642
|
+
return fetchPractitioners;
|
|
643
|
+
}();
|
|
644
|
+
return SFPractitionerClient;
|
|
645
|
+
}();
|
|
646
|
+
function toPractitioner(raw) {
|
|
647
|
+
return {
|
|
648
|
+
id: raw.Id,
|
|
649
|
+
firstName: raw.FirstName__c,
|
|
650
|
+
lastName: raw.LastName__c,
|
|
651
|
+
email: raw.Email__c,
|
|
652
|
+
staffId: raw.StaffID__c
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
var SF_API_VERSION = 'v57.0';
|
|
657
|
+
var SFApiClient = /*#__PURE__*/function () {
|
|
658
|
+
function SFApiClient(baseUrl) {
|
|
659
|
+
this.instance = undefined;
|
|
660
|
+
this.axiosInstance = axios.create();
|
|
661
|
+
this.baseUrl = baseUrl;
|
|
662
|
+
this.axiosInstance.defaults.baseURL = baseUrl != null ? baseUrl : 'https://do0000000d247eaa--phealth.sandbox.my.salesforce.com';
|
|
663
|
+
this.authenticator = new SFAuthenticator(this.axiosInstance, this.baseUrl);
|
|
664
|
+
this.timesheetClient = new SFTimesheetClient(this.axiosInstance);
|
|
665
|
+
this.practitionerClient = new SFPractitionerClient(this.axiosInstance);
|
|
666
|
+
}
|
|
667
|
+
var _proto = SFApiClient.prototype;
|
|
668
|
+
_proto.init = /*#__PURE__*/function () {
|
|
669
|
+
var _init = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(sfClientId, sfClientSecret) {
|
|
670
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
671
|
+
while (1) switch (_context.prev = _context.next) {
|
|
672
|
+
case 0:
|
|
673
|
+
_context.next = 2;
|
|
674
|
+
return this.authenticator.initializeAuth(sfClientId, sfClientSecret);
|
|
675
|
+
case 2:
|
|
676
|
+
case "end":
|
|
677
|
+
return _context.stop();
|
|
678
|
+
}
|
|
679
|
+
}, _callee, this);
|
|
680
|
+
}));
|
|
681
|
+
function init(_x, _x2) {
|
|
682
|
+
return _init.apply(this, arguments);
|
|
683
|
+
}
|
|
684
|
+
return init;
|
|
685
|
+
}();
|
|
686
|
+
_proto.setInstance = function setInstance(instance) {
|
|
687
|
+
this.instance = instance;
|
|
688
|
+
};
|
|
689
|
+
_proto.getInstance = function getInstance() {
|
|
690
|
+
return this.instance;
|
|
691
|
+
};
|
|
692
|
+
_proto.fetchWorkOrders = /*#__PURE__*/function () {
|
|
693
|
+
var _fetchWorkOrders = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(assignedStaffId) {
|
|
694
|
+
var url, query;
|
|
695
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
696
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
697
|
+
case 0:
|
|
698
|
+
_context2.prev = 0;
|
|
699
|
+
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
700
|
+
query = assignedStaffId ? "SELECT Id, HospitalID__c, HospitalName__c, ProfessionalDesignation__c FROM WorkOrder__c WHERE Personnel__c = '" + assignedStaffId + "'" : "SELECT Id, HospitalID__c, HospitalName__c, ProfessionalDesignation__c FROM WorkOrder__c";
|
|
701
|
+
_context2.next = 5;
|
|
702
|
+
return this.axiosInstance.get(url, {
|
|
703
|
+
params: {
|
|
704
|
+
q: query
|
|
705
|
+
}
|
|
706
|
+
}).then(function (_ref) {
|
|
707
|
+
var records = _ref.data.records;
|
|
708
|
+
return records.map(function (record) {
|
|
709
|
+
return {
|
|
710
|
+
id: record.Id,
|
|
711
|
+
establishmentId: record.HospitalID__c,
|
|
712
|
+
establishmentName: record.HospitalName__c,
|
|
713
|
+
role: record.ProfessionalDesignation__c
|
|
714
|
+
};
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
case 5:
|
|
718
|
+
return _context2.abrupt("return", _context2.sent);
|
|
719
|
+
case 8:
|
|
720
|
+
_context2.prev = 8;
|
|
721
|
+
_context2.t0 = _context2["catch"](0);
|
|
722
|
+
console.error('Error fetching work orders: ', _context2.t0.message);
|
|
723
|
+
throw _context2.t0;
|
|
724
|
+
case 12:
|
|
725
|
+
case "end":
|
|
726
|
+
return _context2.stop();
|
|
727
|
+
}
|
|
728
|
+
}, _callee2, this, [[0, 8]]);
|
|
729
|
+
}));
|
|
730
|
+
function fetchWorkOrders(_x3) {
|
|
731
|
+
return _fetchWorkOrders.apply(this, arguments);
|
|
732
|
+
}
|
|
733
|
+
return fetchWorkOrders;
|
|
734
|
+
}();
|
|
735
|
+
_proto.fetchRoles = /*#__PURE__*/function () {
|
|
736
|
+
var _fetchRoles = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
737
|
+
var url, query;
|
|
738
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
739
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
740
|
+
case 0:
|
|
741
|
+
_context3.prev = 0;
|
|
742
|
+
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
743
|
+
query = "SELECT Label, Value FROM PicklistValueInfo WHERE EntityParticle.EntityDefinition.QualifiedApiName = 'WorkOrder__c' AND EntityParticle.QualifiedApiName = 'ProfessionalDesignation__c' AND isActive = true";
|
|
744
|
+
return _context3.abrupt("return", this.axiosInstance.get(url, {
|
|
745
|
+
params: {
|
|
746
|
+
q: query
|
|
747
|
+
}
|
|
748
|
+
}).then(function (_ref2) {
|
|
749
|
+
var records = _ref2.data.records;
|
|
750
|
+
return records.map(function (record) {
|
|
751
|
+
return {
|
|
752
|
+
label: record.Label,
|
|
753
|
+
value: record.Value
|
|
754
|
+
};
|
|
755
|
+
});
|
|
756
|
+
}));
|
|
757
|
+
case 6:
|
|
758
|
+
_context3.prev = 6;
|
|
759
|
+
_context3.t0 = _context3["catch"](0);
|
|
760
|
+
console.error('Error fetching roles: ', _context3.t0.message);
|
|
761
|
+
throw _context3.t0;
|
|
762
|
+
case 10:
|
|
763
|
+
case "end":
|
|
764
|
+
return _context3.stop();
|
|
765
|
+
}
|
|
766
|
+
}, _callee3, this, [[0, 6]]);
|
|
767
|
+
}));
|
|
768
|
+
function fetchRoles() {
|
|
769
|
+
return _fetchRoles.apply(this, arguments);
|
|
770
|
+
}
|
|
771
|
+
return fetchRoles;
|
|
772
|
+
}();
|
|
773
|
+
return SFApiClient;
|
|
774
|
+
}();
|
|
775
|
+
|
|
776
|
+
export { SFApiClient, SFAuthenticator, SFTimesheetClient, SF_API_VERSION };
|
|
777
|
+
//# sourceMappingURL=hermes.esm.js.map
|