@pgds/api-interface 1.6.2 → 1.6.4
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/api/notes/createNoteEndpoint.d.ts +8 -0
- package/api/notes/getNoteByIdEndpoint.d.ts +7 -0
- package/api/notes/getNotesByReferenceIdEndpoint.d.ts +7 -0
- package/api/notes/removeNoteEndpoint.d.ts +7 -0
- package/api/notes/updateNoteEndpoint.d.ts +7 -0
- package/api/prescriptions/createPrescriptionEndpoint.d.ts +7 -0
- package/api/prescriptions/getAllPrescriptionsByOrganizationIdEndpoint.d.ts +7 -0
- package/api/prescriptions/getAllPrescriptionsEndpoint.d.ts +7 -0
- package/api/prescriptions/getPrescriptionByIdEndpoint.d.ts +7 -0
- package/api/prescriptions/removePrescriptionEndpoint.d.ts +7 -0
- package/api/prescriptions/updatePrescriptionEndpoint.d.ts +7 -0
- package/api/productTypes/createProductTypeEndpoint.d.ts +7 -0
- package/api/productTypes/customization/getThingProductTypeCustomizationEndpoint.d.ts +7 -0
- package/api/productTypes/customization/updateOrganizationIdForProductTypeCustomizationsEndpoint.d.ts +7 -0
- package/api/productTypes/customization/upsertProductTypeCustomizationEndpoint.d.ts +7 -0
- package/api/productTypes/getAvailableProductTypesEndpoint.d.ts +7 -0
- package/api/productTypes/getProductTypeByIdOrCodeEndpoint.d.ts +7 -0
- package/api/productTypes/getProductTypeByThingIdEndpoint.d.ts +7 -0
- package/api/productTypes/getProductTypesEndpoint.d.ts +7 -0
- package/api/productTypes/internal/deleteProductTypeCustomizationsByQueryEndpoint.d.ts +7 -0
- package/api/productTypes/internal/getProductTypesAndCustomizationsEndpoint.d.ts +7 -0
- package/api/productTypes/removeProductTypeEndpoint.d.ts +7 -0
- package/api/productTypes/sharing/createProductTypeSharingEndpoint.d.ts +7 -0
- package/api/productTypes/sharing/getAllProductTypeSharingEndpoint.d.ts +7 -0
- package/api/productTypes/sharing/getProductTypeAclsByShareIdEndpoint.d.ts +7 -0
- package/api/productTypes/sharing/getProductTypeSharingByIdEndpoint.d.ts +7 -0
- package/api/productTypes/sharing/removeProductTypeSharingEndpoint.d.ts +7 -0
- package/api/productTypes/updateProductTypeCapabilitiesEndpoint.d.ts +7 -0
- package/api/productTypes/updateProductTypeEndpoint.d.ts +7 -0
- package/api/routes.d.ts +1 -0
- package/api/schemas/notes/createNoteSchema.d.ts +28 -0
- package/api/schemas/notes/getNotesByReferenceIdSchema.d.ts +36 -0
- package/api/schemas/notes/getNotesByUserIdSchema.d.ts +40 -0
- package/api/schemas/notes/notesSchemasShared.d.ts +5 -0
- package/api/schemas/notes/updateNoteSchema.d.ts +12 -0
- package/api/schemas/notes/updateOrganizationIdRequestSchema.d.ts +15 -0
- package/api/schemas/prescriptions/createPrescriptionSchema.d.ts +36 -0
- package/api/schemas/prescriptions/prescriptionIdSchema.d.ts +11 -0
- package/api/schemas/prescriptions/updatePrescriptionSchema.d.ts +39 -0
- package/api/schemas/productTypes/createProductTypeSchema.d.ts +63 -0
- package/api/schemas/productTypes/createProductTypeSharingSchema.d.ts +31 -0
- package/api/schemas/productTypes/customization/productTypeCustomizationSchema.d.ts +59 -0
- package/api/schemas/productTypes/customization/updateOrganizationIdSchema.d.ts +15 -0
- package/api/schemas/productTypes/customization/upsertProductTypeCustomizationSchema.d.ts +68 -0
- package/api/schemas/productTypes/productTypesSchemasShared.d.ts +84 -0
- package/api/schemas/productTypes/updateCapabilitiesSchema.d.ts +344 -0
- package/api/schemas/productTypes/updateProductTypeSchema.d.ts +60 -0
- package/api/schemas/schemasShared.d.ts +9 -0
- package/lib/generator/index.d.ts +19 -0
- package/lib/generator/index.js +165 -0
- package/lib/generator/index.js.map +1 -0
- package/lib/generator/utils/generatorUtils.d.ts +11 -0
- package/lib/generator/utils/generatorUtils.js +135 -0
- package/lib/generator/utils/generatorUtils.js.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/repositories/organizationHierarchyRepo.d.ts +8 -2
- package/lib/repositories/organizationHierarchyRepo.js +42 -26
- package/lib/repositories/organizationHierarchyRepo.js.map +1 -1
- package/lib/server/server.js +14 -7
- package/lib/server/server.js.map +1 -1
- package/lib/utils/utils.d.ts +12 -0
- package/lib/utils/utils.js +127 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.performFatalShutdown = performFatalShutdown;
|
|
43
|
+
exports.setupHealthChecks = setupHealthChecks;
|
|
44
|
+
var restify_errors_1 = require("restify-errors");
|
|
45
|
+
var __1 = require("..");
|
|
46
|
+
var organizationHierarchyRepo_1 = __importDefault(require("../repositories/organizationHierarchyRepo"));
|
|
47
|
+
var server_1 = require("../server/server");
|
|
48
|
+
var logger_1 = require("./logger");
|
|
49
|
+
var util_1 = require("util");
|
|
50
|
+
/**
|
|
51
|
+
* Attempts a server shut down and exits process if shut down fails.
|
|
52
|
+
* Only to be used for fatal errors (e.g. Redis errors)
|
|
53
|
+
* @param err The error that caused the fatal shutdown
|
|
54
|
+
* @returns Never returns, always throws the original error after attempting shutdown
|
|
55
|
+
* @throws The original error passed as parameter
|
|
56
|
+
*/
|
|
57
|
+
function performFatalShutdown(err) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var logger, inspectedError, err_1;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
try {
|
|
64
|
+
logger = (0, logger_1.getLogger)();
|
|
65
|
+
}
|
|
66
|
+
catch (_b) {
|
|
67
|
+
/* If error happens before logger is set up, we will get an error while using getLogger, so fallback to console.error */
|
|
68
|
+
logger = console;
|
|
69
|
+
}
|
|
70
|
+
inspectedError = (0, util_1.inspect)(err);
|
|
71
|
+
_a.label = 1;
|
|
72
|
+
case 1:
|
|
73
|
+
_a.trys.push([1, 3, , 4]);
|
|
74
|
+
logger.error("Redis Client Error: ".concat(err.message), inspectedError);
|
|
75
|
+
return [4 /*yield*/, (0, server_1.closeServer)()];
|
|
76
|
+
case 2:
|
|
77
|
+
_a.sent();
|
|
78
|
+
return [3 /*break*/, 4];
|
|
79
|
+
case 3:
|
|
80
|
+
err_1 = _a.sent();
|
|
81
|
+
logger.error("Error while closing server after Redis error: ".concat(err_1.message), inspectedError);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
return [3 /*break*/, 4];
|
|
84
|
+
case 4:
|
|
85
|
+
/* Will never reach this point, but to satisfy TypeScript's "never" return type */
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Currently supports redis healthchecks
|
|
93
|
+
*/
|
|
94
|
+
function setupHealthChecks() {
|
|
95
|
+
var _this = this;
|
|
96
|
+
/* Restify incorrectly throws an error if next is not a parameter, even if the function is async (and can't use it without trigger the next function twice) */
|
|
97
|
+
server_1.server.use(function (req, _res, _next) { return __awaiter(_this, void 0, void 0, function () {
|
|
98
|
+
var healthPaths;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
healthPaths = ["/".concat((0, __1.getApiOptions)().apiVersion, "/healthz"), "/".concat((0, __1.getApiOptions)().apiVersion, "/readyz")];
|
|
103
|
+
if (!healthPaths.includes(req.getPath())) return [3 /*break*/, 2];
|
|
104
|
+
return [4 /*yield*/, redisHealthCheck()];
|
|
105
|
+
case 1:
|
|
106
|
+
_a.sent();
|
|
107
|
+
_a.label = 2;
|
|
108
|
+
case 2: return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); });
|
|
112
|
+
}
|
|
113
|
+
function redisHealthCheck() {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0: return [4 /*yield*/, organizationHierarchyRepo_1.default.isHealthy()];
|
|
118
|
+
case 1:
|
|
119
|
+
if (!(_a.sent())) {
|
|
120
|
+
throw new restify_errors_1.InternalServerError("Redis health check failed");
|
|
121
|
+
}
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,oDAuBC;AAKD,8CASC;AApDD,iDAAqD;AACrD,wBAAmC;AACnC,wGAAkF;AAClF,2CAAuD;AACvD,mCAAqC;AACrC,6BAA+B;AAG/B;;;;;;GAMG;AACH,SAAsB,oBAAoB,CAAC,GAAQ;;;;;;oBAGjD,IAAI,CAAC;wBACH,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;oBACvB,CAAC;o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
"authors": "Florry",
|
|
5
|
-
"version": "1.6.
|
|
5
|
+
"version": "1.6.4",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "types/",
|
|
8
8
|
"scripts": {
|
|
@@ -102,4 +102,4 @@
|
|
|
102
102
|
"**/*.js.map"
|
|
103
103
|
]
|
|
104
104
|
}
|
|
105
|
-
}
|
|
105
|
+
}
|