dce-expresskit 5.0.3 → 5.0.5
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/lib/helpers/visitEndpointOnAnotherServer/index.js +23 -13
- package/lib/helpers/visitEndpointOnAnotherServer/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/visitEndpointOnAnotherServer/index.ts +11 -2
- package/src/index.ts +2 -0
|
@@ -60,22 +60,32 @@ var sendServerToServerRequest_1 = __importDefault(require("./sendServerToServerR
|
|
|
60
60
|
* @returns the body of the response from the other server
|
|
61
61
|
*/
|
|
62
62
|
var visitEndpointOnAnotherServer = function (opts) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
-
var response, body;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
var sanitizedParams, response, body;
|
|
64
|
+
var _a;
|
|
65
|
+
return __generator(this, function (_b) {
|
|
66
|
+
switch (_b.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
sanitizedParams = {};
|
|
69
|
+
Object.keys((_a = opts.params) !== null && _a !== void 0 ? _a : {}).forEach(function (key) {
|
|
70
|
+
var _a;
|
|
71
|
+
var value = (_a = opts.params) === null || _a === void 0 ? void 0 : _a[key];
|
|
72
|
+
if (value !== undefined) {
|
|
73
|
+
sanitizedParams[key] = value;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return [4 /*yield*/, (0, sendServerToServerRequest_1.default)({
|
|
77
|
+
path: opts.path,
|
|
78
|
+
host: opts.host,
|
|
79
|
+
method: opts.method,
|
|
80
|
+
params: sanitizedParams,
|
|
81
|
+
responseType: opts.responseType,
|
|
82
|
+
dceKitCrossServerCredentials: opts.dceKitCrossServerCredentials,
|
|
83
|
+
})];
|
|
74
84
|
case 1:
|
|
75
|
-
response =
|
|
85
|
+
response = _b.sent();
|
|
76
86
|
// Check for failure
|
|
77
87
|
if (!response || !response.body) {
|
|
78
|
-
throw new dce_commonkit_1.ErrorWithCode('We didn\'t get a response from the other server. Please check the network between the two
|
|
88
|
+
throw new dce_commonkit_1.ErrorWithCode('We didn\'t get a response from the other server. Please check the network between the two servers.', dce_commonkit_1.CommonKitErrorCode.NoResponse);
|
|
79
89
|
}
|
|
80
90
|
if (!response.body.success) {
|
|
81
91
|
// Other errors
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/visitEndpointOnAnotherServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,+CAGuB;AAEvB,sBAAsB;AACtB,0FAAoE;AAEpE,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E;;;;;;;;;;;;GAYG;AACH,IAAM,4BAA4B,GAAG,UACnC,IAOC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/visitEndpointOnAnotherServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,+CAGuB;AAEvB,sBAAsB;AACtB,0FAAoE;AAEpE,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E;;;;;;;;;;;;GAYG;AACH,IAAM,4BAA4B,GAAG,UACnC,IAOC;;;;;;gBAGK,eAAe,GAA6B,EAAE,CAAC;gBACrD,MAAM,CAAC,IAAI,CAAC,MAAA,IAAI,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;;oBACzC,IAAM,KAAK,GAAG,MAAA,IAAI,CAAC,MAAM,0CAAG,GAAG,CAAC,CAAC;oBACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBACxB,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;oBAC/B,CAAC;gBACH,CAAC,CAAC,CAAC;gBAGc,qBAAM,IAAA,mCAAyB,EAAC;wBAC/C,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,MAAM,EAAE,IAAI,CAAC,MAAM;wBACnB,MAAM,EAAE,eAAe;wBACvB,YAAY,EAAE,IAAI,CAAC,YAAY;wBAC/B,4BAA4B,EAAE,IAAI,CAAC,4BAA4B;qBAChE,CAAC,EAAA;;gBAPI,QAAQ,GAAG,SAOf;gBAEF,oBAAoB;gBACpB,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAChC,MAAM,IAAI,6BAAa,CACrB,oGAAoG,EACpG,kCAAkB,CAAC,UAAU,CAC9B,CAAC;gBACJ,CAAC;gBACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oBAC3B,eAAe;oBACf,MAAM,IAAI,6BAAa,CACrB,CACE,QAAQ,CAAC,IAAI,CAAC,OAAO;2BAClB,qDAAqD,CACzD,EACD,CACE,QAAQ,CAAC,IAAI,CAAC,IAAI;2BACf,kCAAkB,CAAC,MAAM,CAC7B,CACF,CAAC;gBACJ,CAAC;gBAGO,IAAI,GAAK,QAAQ,CAAC,IAAI,KAAlB,CAAmB;gBAE/B,SAAS;gBACT,sBAAO,IAAI,EAAC;;;KACb,CAAC;AAEF,kBAAe,4BAA4B,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getTimestampFromTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, ErrorWithCode, ParamType } from 'dce-commonkit';
|
|
1
|
+
import { abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getTimestampFromTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, getLocalTimeInfo, genCommaList, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, ErrorWithCode, ParamType, spaceAtCapitals } from 'dce-commonkit';
|
|
2
2
|
import initServer from './helpers/initServer';
|
|
3
3
|
import genRouteHandler from './helpers/genRouteHandler';
|
|
4
4
|
import handleError from './helpers/handleError';
|
|
@@ -7,4 +7,4 @@ import addDBEditorEndpoints from './helpers/addDBEditorEndpoints';
|
|
|
7
7
|
import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
|
|
8
8
|
import initExpressKitCollections, { getLogCollection } from './helpers/initExpressKitCollections';
|
|
9
9
|
import CrossServerCredential from './types/CrossServerCredential';
|
|
10
|
-
export { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getTimestampFromTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, genCommaList, getLocalTimeInfo, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initServer, genRouteHandler, handleError, handleSuccess, initExpressKitCollections, getLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, CrossServerCredential, ParamType, };
|
|
10
|
+
export { ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, getTimestampFromTimeInfoInET, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, extractProp, compareArraysByProp, genCommaList, getLocalTimeInfo, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, spaceAtCapitals, initServer, genRouteHandler, handleError, handleSuccess, initExpressKitCollections, getLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, CrossServerCredential, ParamType, };
|
package/lib/index.js
CHANGED
|
@@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
exports.ParamType = void 0;
|
|
39
|
+
exports.LogAction = exports.LogSource = exports.LogType = exports.DayOfWeek = exports.visitEndpointOnAnotherServer = exports.addDBEditorEndpoints = exports.getLogCollection = exports.initExpressKitCollections = exports.handleSuccess = exports.handleError = exports.genRouteHandler = exports.initServer = exports.spaceAtCapitals = exports.shuffleArray = exports.capitalize = exports.someAsync = exports.mapAsync = exports.forEachAsync = exports.filterAsync = exports.everyAsync = exports.prefixWithAOrAn = exports.getLocalTimeInfo = exports.genCommaList = exports.compareArraysByProp = exports.extractProp = exports.genCSV = exports.getMonthName = exports.parallelLimit = exports.onlyKeepLetters = exports.stringsToHumanReadableList = exports.getPartOfDay = exports.getHumanReadableDate = exports.startMinWait = exports.getTimestampFromTimeInfoInET = exports.getTimeInfoInET = exports.getOrdinal = exports.waitMs = exports.sum = exports.roundToNumDecimals = exports.padZerosLeft = exports.padDecimalZeros = exports.forceNumIntoBounds = exports.floorToNumDecimals = exports.ceilToNumDecimals = exports.avg = exports.abbreviate = exports.DAY_IN_MS = exports.HOUR_IN_MS = exports.MINUTE_IN_MS = exports.ErrorWithCode = void 0;
|
|
40
|
+
exports.ParamType = exports.LogBuiltInMetadata = void 0;
|
|
41
41
|
// Import dce-commonkit
|
|
42
42
|
var dce_commonkit_1 = require("dce-commonkit");
|
|
43
43
|
Object.defineProperty(exports, "abbreviate", { enumerable: true, get: function () { return dce_commonkit_1.abbreviate; } });
|
|
@@ -83,6 +83,7 @@ Object.defineProperty(exports, "HOUR_IN_MS", { enumerable: true, get: function (
|
|
|
83
83
|
Object.defineProperty(exports, "DAY_IN_MS", { enumerable: true, get: function () { return dce_commonkit_1.DAY_IN_MS; } });
|
|
84
84
|
Object.defineProperty(exports, "ErrorWithCode", { enumerable: true, get: function () { return dce_commonkit_1.ErrorWithCode; } });
|
|
85
85
|
Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return dce_commonkit_1.ParamType; } });
|
|
86
|
+
Object.defineProperty(exports, "spaceAtCapitals", { enumerable: true, get: function () { return dce_commonkit_1.spaceAtCapitals; } });
|
|
86
87
|
// Import helpers
|
|
87
88
|
var initServer_1 = __importDefault(require("./helpers/initServer"));
|
|
88
89
|
exports.initServer = initServer_1.default;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,+CAgDuB;AAuBrB,2FAtEA,0BAAU,OAsEA;AACV,oFAtEA,mBAAG,OAsEA;AACH,kGAtEA,iCAAiB,OAsEA;AACjB,mGAtEA,kCAAkB,OAsEA;AAClB,mGAtEA,kCAAkB,OAsEA;AAClB,gGAtEA,+BAAe,OAsEA;AACf,6FAtEA,4BAAY,OAsEA;AACZ,mGAtEA,kCAAkB,OAsEA;AAClB,oFAtEA,mBAAG,OAsEA;AACH,uFAtEA,sBAAM,OAsEA;AACN,2FAtEA,0BAAU,OAsEA;AACV,gGAtEA,+BAAe,OAsEA;AACf,6GAtEA,4CAA4B,OAsEA;AAC5B,6FAtEA,4BAAY,OAsEA;AACZ,qGAtEA,oCAAoB,OAsEA;AACpB,6FAtEA,4BAAY,OAsEA;AACZ,2GAtEA,0CAA0B,OAsEA;AAC1B,gGAtEA,+BAAe,OAsEA;AACf,8FAtEA,6BAAa,OAsEA;AACb,6FAtEA,4BAAY,OAsEA;AACZ,uFAtEA,sBAAM,OAsEA;AACN,4FAtEA,2BAAW,OAsEA;AACX,oGAtEA,mCAAmB,OAsEA;AAEnB,iGAvEA,gCAAgB,OAuEA;AADhB,6FArEA,4BAAY,OAqEA;AAEZ,gGAtEA,+BAAe,OAsEA;AACf,2FAtEA,0BAAU,OAsEA;AACV,4FAtEA,2BAAW,OAsEA;AACX,6FAtEA,4BAAY,OAsEA;AACZ,yFAtEA,wBAAQ,OAsEA;AACR,0FAtEA,yBAAS,OAsEA;AACT,2FAtEA,0BAAU,OAsEA;AACV,6FAtEA,4BAAY,OAsEA;AAYZ,0FAjFA,yBAAS,OAiFA;AAET,wFAjFA,uBAAO,OAiFA;AACP,0FAjFA,yBAAS,OAiFA;AACT,0FAjFA,yBAAS,OAiFA;AACT,mGAjFA,kCAAkB,OAiFA;AArDlB,6FAzBA,4BAAY,OAyBA;AACZ,2FAzBA,0BAAU,OAyBA;AACV,0FAzBA,yBAAS,OAyBA;AAJT,8FApBA,6BAAa,OAoBA;AA4Db,0FA/EA,yBAAS,OA+EA;AArBT,gGAzDA,+BAAe,OAyDA;AAtDjB,iBAAiB;AACjB,oEAA8C;AAuD5C,qBAvDK,oBAAU,CAuDL;AAtDZ,8EAAwD;AAuDtD,0BAvDK,yBAAe,CAuDL;AAtDjB,sEAAgD;AAuD9C,sBAvDK,qBAAW,CAuDL;AAtDb,0EAAoD;AAuDlD,wBAvDK,uBAAa,CAuDL;AAtDf,wFAAkE;AAyDhE,+BAzDK,8BAAoB,CAyDL;AAxDtB,wGAAkF;AAyDhF,uCAzDK,sCAA4B,CAyDL;AAxD9B,+FAAkG;AAqDhG,oCArDK,mCAAyB,CAqDL;AACzB,iGAtDkC,4CAAgB,OAsDlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dce-expresskit",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"description": "Shared functions, helpers, and tools for Harvard DCE Express-based servers",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"Toolkit"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"dce-commonkit": "^5.0.
|
|
23
|
+
"dce-commonkit": "^5.0.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"caccl": "^x.x.x",
|
|
@@ -34,12 +34,21 @@ const visitEndpointOnAnotherServer = async (
|
|
|
34
34
|
dceKitCrossServerCredentials?: string,
|
|
35
35
|
},
|
|
36
36
|
): Promise<any> => {
|
|
37
|
+
// Sanitize params: remove undefined values
|
|
38
|
+
const sanitizedParams: { [key in string]: any } = {};
|
|
39
|
+
Object.keys(opts.params ?? {}).forEach((key) => {
|
|
40
|
+
const value = opts.params?.[key];
|
|
41
|
+
if (value !== undefined) {
|
|
42
|
+
sanitizedParams[key] = value;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
37
46
|
// Send the request
|
|
38
47
|
const response = await sendServerToServerRequest({
|
|
39
48
|
path: opts.path,
|
|
40
49
|
host: opts.host,
|
|
41
50
|
method: opts.method,
|
|
42
|
-
params:
|
|
51
|
+
params: sanitizedParams,
|
|
43
52
|
responseType: opts.responseType,
|
|
44
53
|
dceKitCrossServerCredentials: opts.dceKitCrossServerCredentials,
|
|
45
54
|
});
|
|
@@ -47,7 +56,7 @@ const visitEndpointOnAnotherServer = async (
|
|
|
47
56
|
// Check for failure
|
|
48
57
|
if (!response || !response.body) {
|
|
49
58
|
throw new ErrorWithCode(
|
|
50
|
-
'We didn\'t get a response from the other server. Please check the network between the two
|
|
59
|
+
'We didn\'t get a response from the other server. Please check the network between the two servers.',
|
|
51
60
|
CommonKitErrorCode.NoResponse,
|
|
52
61
|
);
|
|
53
62
|
}
|
package/src/index.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
DAY_IN_MS,
|
|
47
47
|
ErrorWithCode,
|
|
48
48
|
ParamType,
|
|
49
|
+
spaceAtCapitals,
|
|
49
50
|
} from 'dce-commonkit';
|
|
50
51
|
|
|
51
52
|
// Import helpers
|
|
@@ -102,6 +103,7 @@ export {
|
|
|
102
103
|
someAsync,
|
|
103
104
|
capitalize,
|
|
104
105
|
shuffleArray,
|
|
106
|
+
spaceAtCapitals,
|
|
105
107
|
// Server helpers
|
|
106
108
|
initServer,
|
|
107
109
|
genRouteHandler,
|