@pgds/api-interface 1.2.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.
Files changed (65) hide show
  1. package/README.md +410 -0
  2. package/client/FairtrailClient.d.ts +38 -0
  3. package/client/FairtrailClient.js +219 -0
  4. package/client/FairtrailClient.js.map +1 -0
  5. package/client/HttpClient.d.ts +36 -0
  6. package/client/HttpClient.js +360 -0
  7. package/client/HttpClient.js.map +1 -0
  8. package/client/index.d.ts +3 -0
  9. package/client/index.js +8 -0
  10. package/client/index.js.map +1 -0
  11. package/constants/index.d.ts +8 -0
  12. package/constants/index.js +13 -0
  13. package/constants/index.js.map +1 -0
  14. package/errors/index.d.ts +1 -0
  15. package/errors/index.js +72 -0
  16. package/errors/index.js.map +1 -0
  17. package/index.d.ts +7 -0
  18. package/index.js +23 -0
  19. package/lib/auth/mustbeConfig.d.ts +13 -0
  20. package/lib/auth/mustbeConfig.js +167 -0
  21. package/lib/auth/mustbeConfig.js.map +1 -0
  22. package/lib/constants/constants.d.ts +3 -0
  23. package/lib/constants/constants.js +8 -0
  24. package/lib/constants/constants.js.map +1 -0
  25. package/lib/index.d.ts +255 -0
  26. package/lib/index.js +462 -0
  27. package/lib/index.js.map +1 -0
  28. package/lib/models/Http.d.ts +62 -0
  29. package/lib/models/Http.js +3 -0
  30. package/lib/models/Http.js.map +1 -0
  31. package/lib/models/ReqUser.d.ts +10 -0
  32. package/lib/models/ReqUser.js +3 -0
  33. package/lib/models/ReqUser.js.map +1 -0
  34. package/lib/server/server.d.ts +13 -0
  35. package/lib/server/server.js +154 -0
  36. package/lib/server/server.js.map +1 -0
  37. package/lib/utils/asyncHooks.d.ts +28 -0
  38. package/lib/utils/asyncHooks.js +99 -0
  39. package/lib/utils/asyncHooks.js.map +1 -0
  40. package/lib/utils/jsonSchemaUtils.d.ts +14 -0
  41. package/lib/utils/jsonSchemaUtils.js +187 -0
  42. package/lib/utils/jsonSchemaUtils.js.map +1 -0
  43. package/lib/utils/logger.d.ts +5 -0
  44. package/lib/utils/logger.js +33 -0
  45. package/lib/utils/logger.js.map +1 -0
  46. package/lib/utils/urlUtils.d.ts +1 -0
  47. package/lib/utils/urlUtils.js +14 -0
  48. package/lib/utils/urlUtils.js.map +1 -0
  49. package/package.json +104 -0
  50. package/types/hiot.d.ts +368 -0
  51. package/types/mustbe/config/activities.d.ts +11 -0
  52. package/types/mustbe/config/index.d.ts +77 -0
  53. package/types/mustbe/config/parameter-map.d.ts +8 -0
  54. package/types/mustbe/config/route-helpers.d.ts +17 -0
  55. package/types/mustbe/config/user-identity.d.ts +7 -0
  56. package/types/mustbe/core.d.ts +23 -0
  57. package/types/mustbe/identities/userIdentity.d.ts +10 -0
  58. package/types/mustbe/index.d.ts +6 -0
  59. package/types/mustbe/principals/index.d.ts +10 -0
  60. package/types/mustbe/registry.d.ts +11 -0
  61. package/types/mustbe/routeHelpers/index.d.ts +20 -0
  62. package/types/mustbe/verifier/index.d.ts +10 -0
  63. package/utils/index.d.ts +13 -0
  64. package/utils/index.js +32 -0
  65. package/utils/index.js.map +1 -0
@@ -0,0 +1,36 @@
1
+ import axios, { AxiosResponse } from "axios";
2
+ import { Method } from "../lib";
3
+ export type RequestOptions = {
4
+ method: Method;
5
+ path: string;
6
+ body?: any;
7
+ query?: Record<string, string | string[] | number | undefined | boolean>;
8
+ headers?: Record<string, string>;
9
+ /**
10
+ * If true, adds headers from getAuthHeaders() to the request. getAuthHeaders should be implemented in the child class.
11
+ * @default true
12
+ **/
13
+ authenticated?: boolean;
14
+ responseType?: string;
15
+ timeout?: number;
16
+ };
17
+ /**
18
+ * Base class for all types of apis. Provides basic http methods and error handling.
19
+ */
20
+ export declare class HttpClient {
21
+ protected baseURL: string;
22
+ protected timeout: number;
23
+ protected axiosInstance: ReturnType<typeof axios.create>;
24
+ constructor(baseURL: string, timeout?: number);
25
+ protected setTimeout(timeout: number): void;
26
+ protected post({ path, body, query, headers, authenticated, timeout, }: Pick<RequestOptions, "path" | "body" | "query" | "headers" | "authenticated" | "timeout">): Promise<AxiosResponse<any, any>>;
27
+ protected get({ path, query, headers, authenticated, responseType, timeout, }: Pick<RequestOptions, "path" | "query" | "headers" | "authenticated" | "responseType" | "timeout">): Promise<AxiosResponse<any, any>>;
28
+ protected put({ path, body, headers, authenticated, timeout, }: Pick<RequestOptions, "path" | "body" | "headers" | "authenticated" | "timeout">): Promise<AxiosResponse<any, any>>;
29
+ protected patch({ path, body, headers, authenticated, timeout, }: Pick<RequestOptions, "path" | "body" | "headers" | "authenticated" | "timeout">): Promise<AxiosResponse<any, any>>;
30
+ protected delete({ path, query, headers, authenticated, body, timeout, }: Pick<RequestOptions, "path" | "headers" | "authenticated" | "query" | "body" | "timeout">): Promise<AxiosResponse<any, any>>;
31
+ protected doRequest({ method, path, body, query, headers, authenticated, responseType, timeout, }: RequestOptions): Promise<AxiosResponse<any, any>>;
32
+ private tryToParseJSONErr;
33
+ protected getDefaultHeaders(): Promise<Record<string, string>>;
34
+ protected getAuthHeaders(authenticated?: boolean): Promise<Record<string, string>>;
35
+ protected getDefaultQuery(): Promise<Record<string, string>>;
36
+ }
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
47
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
+ return new (P || (P = Promise))(function (resolve, reject) {
49
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
50
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
51
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
52
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
53
+ });
54
+ };
55
+ var __generator = (this && this.__generator) || function (thisArg, body) {
56
+ 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);
57
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
+ function verb(n) { return function (v) { return step([n, v]); }; }
59
+ function step(op) {
60
+ if (f) throw new TypeError("Generator is already executing.");
61
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
62
+ 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;
63
+ if (y = 0, t) op = [op[0] & 2, t.value];
64
+ switch (op[0]) {
65
+ case 0: case 1: t = op; break;
66
+ case 4: _.label++; return { value: op[1], done: false };
67
+ case 5: _.label++; y = op[1]; op = [0]; continue;
68
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
+ default:
70
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
+ if (t[2]) _.ops.pop();
75
+ _.trys.pop(); continue;
76
+ }
77
+ op = body.call(thisArg, _);
78
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
80
+ }
81
+ };
82
+ Object.defineProperty(exports, "__esModule", { value: true });
83
+ exports.HttpClient = void 0;
84
+ var axios_1 = __importStar(require("axios"));
85
+ var constants_1 = require("../constants");
86
+ var lib_1 = require("../lib");
87
+ var asyncHooks_1 = require("../lib/utils/asyncHooks");
88
+ /**
89
+ * Base class for all types of apis. Provides basic http methods and error handling.
90
+ */
91
+ var HttpClient = /** @class */ (function () {
92
+ function HttpClient(baseURL, timeout) {
93
+ if (timeout === void 0) { timeout = 3000; }
94
+ var _a;
95
+ this.baseURL = baseURL;
96
+ this.timeout = timeout;
97
+ this.axiosInstance = (_a = axios_1.default.create) === null || _a === void 0 ? void 0 : _a.call(axios_1.default, {
98
+ baseURL: this.baseURL,
99
+ timeout: this.timeout,
100
+ });
101
+ extractAPIErrorResponse(this.axiosInstance);
102
+ }
103
+ HttpClient.prototype.setTimeout = function (timeout) {
104
+ this.axiosInstance.defaults.timeout = timeout;
105
+ };
106
+ HttpClient.prototype.post = function (_a) {
107
+ return __awaiter(this, arguments, void 0, function (_b) {
108
+ var path = _b.path, body = _b.body, query = _b.query, headers = _b.headers, authenticated = _b.authenticated, timeout = _b.timeout;
109
+ return __generator(this, function (_c) {
110
+ switch (_c.label) {
111
+ case 0: return [4 /*yield*/, this.doRequest({
112
+ method: lib_1.Method.Post,
113
+ path: path,
114
+ body: body,
115
+ query: query,
116
+ headers: headers,
117
+ authenticated: authenticated,
118
+ timeout: timeout,
119
+ })];
120
+ case 1: return [2 /*return*/, _c.sent()];
121
+ }
122
+ });
123
+ });
124
+ };
125
+ HttpClient.prototype.get = function (_a) {
126
+ return __awaiter(this, arguments, void 0, function (_b) {
127
+ var path = _b.path, query = _b.query, headers = _b.headers, authenticated = _b.authenticated, _c = _b.responseType, responseType = _c === void 0 ? "json" : _c, timeout = _b.timeout;
128
+ return __generator(this, function (_d) {
129
+ switch (_d.label) {
130
+ case 0: return [4 /*yield*/, this.doRequest({
131
+ method: lib_1.Method.Get,
132
+ path: path,
133
+ query: query,
134
+ headers: headers,
135
+ authenticated: authenticated,
136
+ responseType: responseType,
137
+ timeout: timeout,
138
+ })];
139
+ case 1: return [2 /*return*/, _d.sent()];
140
+ }
141
+ });
142
+ });
143
+ };
144
+ HttpClient.prototype.put = function (_a) {
145
+ return __awaiter(this, arguments, void 0, function (_b) {
146
+ var path = _b.path, body = _b.body, headers = _b.headers, authenticated = _b.authenticated, timeout = _b.timeout;
147
+ return __generator(this, function (_c) {
148
+ switch (_c.label) {
149
+ case 0: return [4 /*yield*/, this.doRequest({
150
+ method: lib_1.Method.Put,
151
+ path: path,
152
+ body: body,
153
+ headers: headers,
154
+ authenticated: authenticated,
155
+ timeout: timeout,
156
+ })];
157
+ case 1: return [2 /*return*/, _c.sent()];
158
+ }
159
+ });
160
+ });
161
+ };
162
+ HttpClient.prototype.patch = function (_a) {
163
+ return __awaiter(this, arguments, void 0, function (_b) {
164
+ var path = _b.path, body = _b.body, headers = _b.headers, authenticated = _b.authenticated, timeout = _b.timeout;
165
+ return __generator(this, function (_c) {
166
+ switch (_c.label) {
167
+ case 0: return [4 /*yield*/, this.doRequest({
168
+ method: lib_1.Method.Patch,
169
+ path: path,
170
+ body: body,
171
+ headers: headers,
172
+ authenticated: authenticated,
173
+ timeout: timeout,
174
+ })];
175
+ case 1: return [2 /*return*/, _c.sent()];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ HttpClient.prototype.delete = function (_a) {
181
+ return __awaiter(this, arguments, void 0, function (_b) {
182
+ var path = _b.path, query = _b.query, headers = _b.headers, authenticated = _b.authenticated, body = _b.body, timeout = _b.timeout;
183
+ return __generator(this, function (_c) {
184
+ switch (_c.label) {
185
+ case 0: return [4 /*yield*/, this.doRequest({
186
+ method: "DELETE",
187
+ path: path,
188
+ query: query,
189
+ headers: headers,
190
+ authenticated: authenticated,
191
+ body: body,
192
+ timeout: timeout,
193
+ })];
194
+ case 1: return [2 /*return*/, _c.sent()];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ HttpClient.prototype.doRequest = function (_a) {
200
+ return __awaiter(this, arguments, void 0, function (_b) {
201
+ var q, _c, queryString, headersToSend, _d, _e, reqId, err_1, error, parsedErr, messageToUse, statusCode, axiosError;
202
+ var _f, _g, _h, _j, _k;
203
+ var method = _b.method, path = _b.path, body = _b.body, query = _b.query, _l = _b.headers, headers = _l === void 0 ? {} : _l, authenticated = _b.authenticated, responseType = _b.responseType, timeout = _b.timeout;
204
+ return __generator(this, function (_m) {
205
+ switch (_m.label) {
206
+ case 0:
207
+ _c = [__assign({}, (query !== null && query !== void 0 ? query : {}))];
208
+ return [4 /*yield*/, this.getDefaultQuery()];
209
+ case 1:
210
+ q = __assign.apply(void 0, _c.concat([(_m.sent())]));
211
+ queryString = !!Object.keys(q).length ? toQueryString(q) : "";
212
+ _m.label = 2;
213
+ case 2:
214
+ _m.trys.push([2, 6, , 7]);
215
+ if (timeout) {
216
+ this.setTimeout(timeout);
217
+ }
218
+ else {
219
+ this.setTimeout(3000);
220
+ }
221
+ _d = [{}];
222
+ return [4 /*yield*/, this.getDefaultHeaders()];
223
+ case 3:
224
+ _e = [__assign.apply(void 0, _d.concat([(_m.sent())]))];
225
+ return [4 /*yield*/, this.getAuthHeaders(authenticated)];
226
+ case 4:
227
+ headersToSend = __assign.apply(void 0, [__assign.apply(void 0, _e.concat([(_m.sent())])), headers]);
228
+ reqId = (0, asyncHooks_1.useReqStore)().reqId;
229
+ /* Add request id header if it's not already set, so is not to overwrite it */
230
+ if (reqId && headersToSend[constants_1.REQUEST_ID_HEADER] === undefined) {
231
+ headersToSend[constants_1.REQUEST_ID_HEADER] = reqId;
232
+ }
233
+ if (path.includes("?")) {
234
+ printQueryMessage(path);
235
+ }
236
+ return [4 /*yield*/, this.axiosInstance.request({
237
+ method: method,
238
+ url: path + queryString,
239
+ data: body,
240
+ responseType: (responseType !== null && responseType !== void 0 ? responseType : "json"),
241
+ headers: headersToSend,
242
+ })];
243
+ case 5: return [2 /*return*/, _m.sent()];
244
+ case 6:
245
+ err_1 = _m.sent();
246
+ error = err_1;
247
+ if ("toJSON" in err_1) {
248
+ error = err_1.toJSON();
249
+ }
250
+ parsedErr = this.tryToParseJSONErr(error.message);
251
+ if (parsedErr) {
252
+ error.message = parsedErr;
253
+ }
254
+ messageToUse = (_f = error.message) !== null && _f !== void 0 ? _f : err_1.message;
255
+ statusCode = (_g = error.status) !== null && _g !== void 0 ? _g : (_h = err_1.response) === null || _h === void 0 ? void 0 : _h.status;
256
+ if (!messageToUse || ((_j = messageToUse.startsWith) === null || _j === void 0 ? void 0 : _j.call(messageToUse, "Request failed with status code"))) {
257
+ messageToUse = (_k = err_1.response.data) !== null && _k !== void 0 ? _k : error.message;
258
+ }
259
+ axiosError = new axios_1.AxiosError(messageToUse, axios_1.default.HttpStatusCode[statusCode], err_1.config, err_1.response, err_1);
260
+ // @ts-ignore
261
+ axiosError.status = statusCode;
262
+ throw axiosError;
263
+ case 7: return [2 /*return*/];
264
+ }
265
+ });
266
+ });
267
+ };
268
+ HttpClient.prototype.tryToParseJSONErr = function (jsonSErr) {
269
+ try {
270
+ var o = JSON.parse(jsonSErr);
271
+ if (o && typeof o === "object") {
272
+ return o;
273
+ }
274
+ }
275
+ catch (e) {
276
+ // don't care
277
+ }
278
+ return false;
279
+ };
280
+ HttpClient.prototype.getDefaultHeaders = function () {
281
+ return __awaiter(this, void 0, void 0, function () {
282
+ return __generator(this, function (_a) {
283
+ return [2 /*return*/, {}];
284
+ });
285
+ });
286
+ };
287
+ HttpClient.prototype.getAuthHeaders = function () {
288
+ return __awaiter(this, arguments, void 0, function (authenticated) {
289
+ if (authenticated === void 0) { authenticated = true; }
290
+ return __generator(this, function (_a) {
291
+ return [2 /*return*/, {}];
292
+ });
293
+ });
294
+ };
295
+ HttpClient.prototype.getDefaultQuery = function () {
296
+ return __awaiter(this, void 0, void 0, function () {
297
+ return __generator(this, function (_a) {
298
+ return [2 /*return*/, {}];
299
+ });
300
+ });
301
+ };
302
+ return HttpClient;
303
+ }());
304
+ exports.HttpClient = HttpClient;
305
+ /**
306
+ * Whenever error.message is accessed we want to se the full API error message (JSON) if it's present
307
+ * not just some generic http status code + message
308
+ * see https://github.com/axios/axios/issues/960 for context
309
+ */
310
+ function extractAPIErrorResponse(axios) {
311
+ axios.interceptors.response.use(undefined, function (error) {
312
+ error.originalMessage = error.message;
313
+ Object.defineProperty(error, "message", {
314
+ get: function () {
315
+ if (!error.response) {
316
+ return error.originalMessage;
317
+ }
318
+ if (typeof error.response.data === "string") {
319
+ return error.response.data;
320
+ }
321
+ return JSON.stringify(error.response.data);
322
+ },
323
+ });
324
+ if (error.response) {
325
+ error.status = error.response.status;
326
+ }
327
+ return Promise.reject(error);
328
+ });
329
+ }
330
+ function toQueryString(obj) {
331
+ var object = Object.assign({}, obj);
332
+ for (var _i = 0, _a = Object.entries(object); _i < _a.length; _i++) {
333
+ var _b = _a[_i], key = _b[0], value = _b[1];
334
+ if (value === undefined || value === null || value === "") {
335
+ delete object[key];
336
+ }
337
+ else if (Array.isArray(value)) {
338
+ if (value.length === 0) {
339
+ delete object[key];
340
+ }
341
+ else {
342
+ object[key] = value.join(",");
343
+ }
344
+ }
345
+ else {
346
+ object[key] = value;
347
+ }
348
+ }
349
+ var queryString = new URLSearchParams(object).toString();
350
+ if (queryString.length) {
351
+ return "?".concat(queryString);
352
+ }
353
+ else {
354
+ return "";
355
+ }
356
+ }
357
+ function printQueryMessage(path) {
358
+ console.info("\nNOTE: path", path, "contains query params. Use the query object to pass query params more easily. For example:", "\nthis.get({\n// ...\n query: {\n status: \"active\",\n limit: 10,\n },\n// ...\n});\n");
359
+ }
360
+ //# sourceMappingURL=HttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["HttpClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAsF;AACtF,0CAAiD;AACjD,8BAAgC;AAChC,sDAAsD;AAiBtD;;GAEG;AACH;IAGE,oBAAsB,OAAe,EAAY,OAAsB;QAAtB,wBAAA,EAAA,cAAsB;;QAAjD,YAAO,GAAP,OAAO,CAAQ;QAAY,YAAO,GAAP,OAAO,CAAe;QACrE,IAAI,CAAC,aAAa,GAAG,MAAA,eAAK,CAAC,MAAM,gEAAG;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;QAEH,uBAAuB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;IAES,+BAAU,GAApB,UAAqB,OAAe;QAClC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;IAChD,CAAC;IA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AC,KAAK,CAAC,EAAE,CAAC;YAChC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IAED,IAAM,WAAW,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IAE3D,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,WAAI,WAAW,CAAE,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,CAAC,IAAI,CACV,cAAc,EACd,IAAI,EACJ,4FAA4F,EAC5F,gGASH,CACE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { FairtrailClient } from "./FairtrailClient";
2
+ import { HttpClient } from "./HttpClient";
3
+ export { HttpClient, FairtrailClient };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FairtrailClient = exports.HttpClient = void 0;
4
+ var FairtrailClient_1 = require("./FairtrailClient");
5
+ Object.defineProperty(exports, "FairtrailClient", { enumerable: true, get: function () { return FairtrailClient_1.FairtrailClient; } });
6
+ var HttpClient_1 = require("./HttpClient");
7
+ Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return HttpClient_1.HttpClient; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAG/B,gGAHZ,iCAAe,OAGY;AAFpC,2CAA0C;AAEjC,2FAFA,uBAAU,OAEA"}
@@ -0,0 +1,8 @@
1
+ export declare const AUTH_USER_HEADER = "auth-user";
2
+ export declare const AUTH_ORGANIZATION_HEADER = "auth-organization";
3
+ export declare const AUTH_CHILD_ORGANIZATIONS_HEADER = "auth-child-organizations";
4
+ export declare const AUTH_ACTIVITIES_HEADER = "auth-activities";
5
+ export declare const AUTH_ACTIVE_LOGIN_HEADER = "auth-active-login";
6
+ export declare const GLOBAL_ACTIVITY = "global";
7
+ export declare const CAN_MANAGE_ORGANIZATION_ACTIVITY = "canManageOrganization";
8
+ export declare const REQUEST_ID_HEADER = "request-id";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REQUEST_ID_HEADER = exports.CAN_MANAGE_ORGANIZATION_ACTIVITY = exports.GLOBAL_ACTIVITY = exports.AUTH_ACTIVE_LOGIN_HEADER = exports.AUTH_ACTIVITIES_HEADER = exports.AUTH_CHILD_ORGANIZATIONS_HEADER = exports.AUTH_ORGANIZATION_HEADER = exports.AUTH_USER_HEADER = void 0;
4
+ /* Note: These will be exported to the library as @hiotlabs/hiot-api-interface/constants */
5
+ exports.AUTH_USER_HEADER = "auth-user";
6
+ exports.AUTH_ORGANIZATION_HEADER = "auth-organization";
7
+ exports.AUTH_CHILD_ORGANIZATIONS_HEADER = "auth-child-organizations";
8
+ exports.AUTH_ACTIVITIES_HEADER = "auth-activities";
9
+ exports.AUTH_ACTIVE_LOGIN_HEADER = "auth-active-login";
10
+ exports.GLOBAL_ACTIVITY = "global";
11
+ exports.CAN_MANAGE_ORGANIZATION_ACTIVITY = "canManageOrganization";
12
+ exports.REQUEST_ID_HEADER = "request-id";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC9E,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAC/B,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAC/C,QAAA,+BAA+B,GAAG,0BAA0B,CAAC;AAC7D,QAAA,sBAAsB,GAAG,iBAAiB,CAAC;AAC3C,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAE/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,gCAAgC,GAAG,uBAAuB,CAAC;AAE3D,QAAA,iBAAiB,GAAG,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export { BadDigestError, BadGatewayError, BadMethodError, BadRequestError, BandwidthLimitExceededError, ConflictError, DefinedHttpError, DefinedRestError, ExpectationFailedError, FailedDependencyError, ForbiddenError, GatewayTimeoutError, GoneError, HttpError, HttpVersionNotSupportedError, ImATeapotError, InsufficientStorageError, InternalError, InternalServerError, InvalidArgumentError, InvalidContentError, InvalidCredentialsError, InvalidHeaderError, InvalidVersionError, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, MisdirectedRequestError, MissingParameterError, NetworkAuthenticationRequiredError, NotAcceptableError, NotAuthorizedError, NotExtendedError, NotFoundError, NotImplementedError, PayloadTooLargeError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, RequestEntityTooLargeError, RequestExpiredError, RequestHeaderFieldsTooLargeError, RequestThrottledError, RequestTimeoutError, RequesturiTooLargeError, ResourceNotFoundError, RestError, RestifyHttpErrorOptions, RestifyRestErrorOptions, ServiceUnavailableError, TooManyRequestsError, UnauthorizedError, UnavailableForLegalReasonsError, UnorderedCollectionError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, UriTooLongError, VariantAlsoNegotiatesError, WrongAcceptError, bunyanSerializer, makeConstructor, makeErrFromCode, } from "restify-errors";
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestError = exports.ResourceNotFoundError = exports.RequesturiTooLargeError = exports.RequestTimeoutError = exports.RequestThrottledError = exports.RequestHeaderFieldsTooLargeError = exports.RequestExpiredError = exports.RequestEntityTooLargeError = exports.RangeNotSatisfiableError = exports.ProxyAuthenticationRequiredError = exports.PreconditionRequiredError = exports.PreconditionFailedError = exports.PaymentRequiredError = exports.PayloadTooLargeError = exports.NotImplementedError = exports.NotFoundError = exports.NotExtendedError = exports.NotAuthorizedError = exports.NotAcceptableError = exports.NetworkAuthenticationRequiredError = exports.MissingParameterError = exports.MisdirectedRequestError = exports.MethodNotAllowedError = exports.LoopDetectedError = exports.LockedError = exports.LengthRequiredError = exports.InvalidVersionError = exports.InvalidHeaderError = exports.InvalidCredentialsError = exports.InvalidContentError = exports.InvalidArgumentError = exports.InternalServerError = exports.InternalError = exports.InsufficientStorageError = exports.ImATeapotError = exports.HttpVersionNotSupportedError = exports.HttpError = exports.GoneError = exports.GatewayTimeoutError = exports.ForbiddenError = exports.FailedDependencyError = exports.ExpectationFailedError = exports.DefinedRestError = exports.DefinedHttpError = exports.ConflictError = exports.BandwidthLimitExceededError = exports.BadRequestError = exports.BadMethodError = exports.BadGatewayError = exports.BadDigestError = void 0;
4
+ exports.makeErrFromCode = exports.makeConstructor = exports.bunyanSerializer = exports.WrongAcceptError = exports.VariantAlsoNegotiatesError = exports.UriTooLongError = exports.UpgradeRequiredError = exports.UnsupportedMediaTypeError = exports.UnprocessableEntityError = exports.UnorderedCollectionError = exports.UnavailableForLegalReasonsError = exports.UnauthorizedError = exports.TooManyRequestsError = exports.ServiceUnavailableError = void 0;
5
+ /* Note: These will be exported to the library as @hiotlabs/hiot-api-interface/errors */
6
+ /* Brute force export for now, due to issues with * export */
7
+ var restify_errors_1 = require("restify-errors");
8
+ Object.defineProperty(exports, "BadDigestError", { enumerable: true, get: function () { return restify_errors_1.BadDigestError; } });
9
+ Object.defineProperty(exports, "BadGatewayError", { enumerable: true, get: function () { return restify_errors_1.BadGatewayError; } });
10
+ Object.defineProperty(exports, "BadMethodError", { enumerable: true, get: function () { return restify_errors_1.BadMethodError; } });
11
+ Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return restify_errors_1.BadRequestError; } });
12
+ Object.defineProperty(exports, "BandwidthLimitExceededError", { enumerable: true, get: function () { return restify_errors_1.BandwidthLimitExceededError; } });
13
+ Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return restify_errors_1.ConflictError; } });
14
+ Object.defineProperty(exports, "DefinedHttpError", { enumerable: true, get: function () { return restify_errors_1.DefinedHttpError; } });
15
+ Object.defineProperty(exports, "DefinedRestError", { enumerable: true, get: function () { return restify_errors_1.DefinedRestError; } });
16
+ Object.defineProperty(exports, "ExpectationFailedError", { enumerable: true, get: function () { return restify_errors_1.ExpectationFailedError; } });
17
+ Object.defineProperty(exports, "FailedDependencyError", { enumerable: true, get: function () { return restify_errors_1.FailedDependencyError; } });
18
+ Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return restify_errors_1.ForbiddenError; } });
19
+ Object.defineProperty(exports, "GatewayTimeoutError", { enumerable: true, get: function () { return restify_errors_1.GatewayTimeoutError; } });
20
+ Object.defineProperty(exports, "GoneError", { enumerable: true, get: function () { return restify_errors_1.GoneError; } });
21
+ Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return restify_errors_1.HttpError; } });
22
+ Object.defineProperty(exports, "HttpVersionNotSupportedError", { enumerable: true, get: function () { return restify_errors_1.HttpVersionNotSupportedError; } });
23
+ Object.defineProperty(exports, "ImATeapotError", { enumerable: true, get: function () { return restify_errors_1.ImATeapotError; } });
24
+ Object.defineProperty(exports, "InsufficientStorageError", { enumerable: true, get: function () { return restify_errors_1.InsufficientStorageError; } });
25
+ Object.defineProperty(exports, "InternalError", { enumerable: true, get: function () { return restify_errors_1.InternalError; } });
26
+ Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return restify_errors_1.InternalServerError; } });
27
+ Object.defineProperty(exports, "InvalidArgumentError", { enumerable: true, get: function () { return restify_errors_1.InvalidArgumentError; } });
28
+ Object.defineProperty(exports, "InvalidContentError", { enumerable: true, get: function () { return restify_errors_1.InvalidContentError; } });
29
+ Object.defineProperty(exports, "InvalidCredentialsError", { enumerable: true, get: function () { return restify_errors_1.InvalidCredentialsError; } });
30
+ Object.defineProperty(exports, "InvalidHeaderError", { enumerable: true, get: function () { return restify_errors_1.InvalidHeaderError; } });
31
+ Object.defineProperty(exports, "InvalidVersionError", { enumerable: true, get: function () { return restify_errors_1.InvalidVersionError; } });
32
+ Object.defineProperty(exports, "LengthRequiredError", { enumerable: true, get: function () { return restify_errors_1.LengthRequiredError; } });
33
+ Object.defineProperty(exports, "LockedError", { enumerable: true, get: function () { return restify_errors_1.LockedError; } });
34
+ Object.defineProperty(exports, "LoopDetectedError", { enumerable: true, get: function () { return restify_errors_1.LoopDetectedError; } });
35
+ Object.defineProperty(exports, "MethodNotAllowedError", { enumerable: true, get: function () { return restify_errors_1.MethodNotAllowedError; } });
36
+ Object.defineProperty(exports, "MisdirectedRequestError", { enumerable: true, get: function () { return restify_errors_1.MisdirectedRequestError; } });
37
+ Object.defineProperty(exports, "MissingParameterError", { enumerable: true, get: function () { return restify_errors_1.MissingParameterError; } });
38
+ Object.defineProperty(exports, "NetworkAuthenticationRequiredError", { enumerable: true, get: function () { return restify_errors_1.NetworkAuthenticationRequiredError; } });
39
+ Object.defineProperty(exports, "NotAcceptableError", { enumerable: true, get: function () { return restify_errors_1.NotAcceptableError; } });
40
+ Object.defineProperty(exports, "NotAuthorizedError", { enumerable: true, get: function () { return restify_errors_1.NotAuthorizedError; } });
41
+ Object.defineProperty(exports, "NotExtendedError", { enumerable: true, get: function () { return restify_errors_1.NotExtendedError; } });
42
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return restify_errors_1.NotFoundError; } });
43
+ Object.defineProperty(exports, "NotImplementedError", { enumerable: true, get: function () { return restify_errors_1.NotImplementedError; } });
44
+ Object.defineProperty(exports, "PayloadTooLargeError", { enumerable: true, get: function () { return restify_errors_1.PayloadTooLargeError; } });
45
+ Object.defineProperty(exports, "PaymentRequiredError", { enumerable: true, get: function () { return restify_errors_1.PaymentRequiredError; } });
46
+ Object.defineProperty(exports, "PreconditionFailedError", { enumerable: true, get: function () { return restify_errors_1.PreconditionFailedError; } });
47
+ Object.defineProperty(exports, "PreconditionRequiredError", { enumerable: true, get: function () { return restify_errors_1.PreconditionRequiredError; } });
48
+ Object.defineProperty(exports, "ProxyAuthenticationRequiredError", { enumerable: true, get: function () { return restify_errors_1.ProxyAuthenticationRequiredError; } });
49
+ Object.defineProperty(exports, "RangeNotSatisfiableError", { enumerable: true, get: function () { return restify_errors_1.RangeNotSatisfiableError; } });
50
+ Object.defineProperty(exports, "RequestEntityTooLargeError", { enumerable: true, get: function () { return restify_errors_1.RequestEntityTooLargeError; } });
51
+ Object.defineProperty(exports, "RequestExpiredError", { enumerable: true, get: function () { return restify_errors_1.RequestExpiredError; } });
52
+ Object.defineProperty(exports, "RequestHeaderFieldsTooLargeError", { enumerable: true, get: function () { return restify_errors_1.RequestHeaderFieldsTooLargeError; } });
53
+ Object.defineProperty(exports, "RequestThrottledError", { enumerable: true, get: function () { return restify_errors_1.RequestThrottledError; } });
54
+ Object.defineProperty(exports, "RequestTimeoutError", { enumerable: true, get: function () { return restify_errors_1.RequestTimeoutError; } });
55
+ Object.defineProperty(exports, "RequesturiTooLargeError", { enumerable: true, get: function () { return restify_errors_1.RequesturiTooLargeError; } });
56
+ Object.defineProperty(exports, "ResourceNotFoundError", { enumerable: true, get: function () { return restify_errors_1.ResourceNotFoundError; } });
57
+ Object.defineProperty(exports, "RestError", { enumerable: true, get: function () { return restify_errors_1.RestError; } });
58
+ Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return restify_errors_1.ServiceUnavailableError; } });
59
+ Object.defineProperty(exports, "TooManyRequestsError", { enumerable: true, get: function () { return restify_errors_1.TooManyRequestsError; } });
60
+ Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return restify_errors_1.UnauthorizedError; } });
61
+ Object.defineProperty(exports, "UnavailableForLegalReasonsError", { enumerable: true, get: function () { return restify_errors_1.UnavailableForLegalReasonsError; } });
62
+ Object.defineProperty(exports, "UnorderedCollectionError", { enumerable: true, get: function () { return restify_errors_1.UnorderedCollectionError; } });
63
+ Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return restify_errors_1.UnprocessableEntityError; } });
64
+ Object.defineProperty(exports, "UnsupportedMediaTypeError", { enumerable: true, get: function () { return restify_errors_1.UnsupportedMediaTypeError; } });
65
+ Object.defineProperty(exports, "UpgradeRequiredError", { enumerable: true, get: function () { return restify_errors_1.UpgradeRequiredError; } });
66
+ Object.defineProperty(exports, "UriTooLongError", { enumerable: true, get: function () { return restify_errors_1.UriTooLongError; } });
67
+ Object.defineProperty(exports, "VariantAlsoNegotiatesError", { enumerable: true, get: function () { return restify_errors_1.VariantAlsoNegotiatesError; } });
68
+ Object.defineProperty(exports, "WrongAcceptError", { enumerable: true, get: function () { return restify_errors_1.WrongAcceptError; } });
69
+ Object.defineProperty(exports, "bunyanSerializer", { enumerable: true, get: function () { return restify_errors_1.bunyanSerializer; } });
70
+ Object.defineProperty(exports, "makeConstructor", { enumerable: true, get: function () { return restify_errors_1.makeConstructor; } });
71
+ Object.defineProperty(exports, "makeErrFromCode", { enumerable: true, get: function () { return restify_errors_1.makeErrFromCode; } });
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;AAAA,wFAAwF;AACxF,6DAA6D;AAC7D,iDAmEwB;AAlEtB,gHAAA,cAAc,OAAA;AACd,iHAAA,eAAe,OAAA;AACf,gHAAA,cAAc,OAAA;AACd,iHAAA,eAAe,OAAA;AACf,6HAAA,2BAA2B,OAAA;AAC3B,+GAAA,aAAa,OAAA;AACb,kHAAA,gBAAgB,OAAA;AAChB,kHAAA,gBAAgB,OAAA;AAChB,wHAAA,sBAAsB,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,0HAAA,wBAAwB,OAAA;AACxB,0HAAA,wBAAwB,OAAA;AACxB,2HAAA,yBAAyB,OAAA;AACzB,sHAAA,oBAAoB,OAAA;AACpB,iHAAA,eAAe,OAAA;AACf,4HAAA,0BAA0B,OAAA;AAC1B,kHAAA,gBAAgB,OAAA;AAChB,kHAAA,gBAAgB,OAAA;AAChB,iHAAA,eAAe,OAAA;AACf,iHAAA,eAAe,OAAA"}
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { setupApiInterface, setupInterfaceLegacy, JsonResponse, del, endpointMetadata, get, patch, post, put, internal, Method } from "./lib";
2
+ import { routeHelpers } from "./lib/auth/mustbeConfig";
3
+ import { Next, Request, Response } from "./lib/models/Http";
4
+ import { ReqUser } from "./lib/models/ReqUser";
5
+ import { closeServer, server } from "./lib/server/server";
6
+ import { useReqStore, runWithRequestContext } from "./lib/utils/asyncHooks";
7
+ export { setupApiInterface, setupInterfaceLegacy, endpointMetadata, del, get, patch, post, put, internal, JsonResponse, Request, Response, Next, Method, ReqUser, closeServer, server, routeHelpers, useReqStore, runWithRequestContext, };
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runWithRequestContext = exports.useReqStore = exports.routeHelpers = exports.server = exports.closeServer = exports.Method = exports.internal = exports.put = exports.post = exports.patch = exports.get = exports.del = exports.endpointMetadata = exports.setupInterfaceLegacy = exports.setupApiInterface = void 0;
4
+ var lib_1 = require("./lib");
5
+ Object.defineProperty(exports, "setupApiInterface", { enumerable: true, get: function () { return lib_1.setupApiInterface; } });
6
+ Object.defineProperty(exports, "setupInterfaceLegacy", { enumerable: true, get: function () { return lib_1.setupInterfaceLegacy; } });
7
+ Object.defineProperty(exports, "del", { enumerable: true, get: function () { return lib_1.del; } });
8
+ Object.defineProperty(exports, "endpointMetadata", { enumerable: true, get: function () { return lib_1.endpointMetadata; } });
9
+ Object.defineProperty(exports, "get", { enumerable: true, get: function () { return lib_1.get; } });
10
+ Object.defineProperty(exports, "patch", { enumerable: true, get: function () { return lib_1.patch; } });
11
+ Object.defineProperty(exports, "post", { enumerable: true, get: function () { return lib_1.post; } });
12
+ Object.defineProperty(exports, "put", { enumerable: true, get: function () { return lib_1.put; } });
13
+ Object.defineProperty(exports, "internal", { enumerable: true, get: function () { return lib_1.internal; } });
14
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return lib_1.Method; } });
15
+ var mustbeConfig_1 = require("./lib/auth/mustbeConfig");
16
+ Object.defineProperty(exports, "routeHelpers", { enumerable: true, get: function () { return mustbeConfig_1.routeHelpers; } });
17
+ var server_1 = require("./lib/server/server");
18
+ Object.defineProperty(exports, "closeServer", { enumerable: true, get: function () { return server_1.closeServer; } });
19
+ Object.defineProperty(exports, "server", { enumerable: true, get: function () { return server_1.server; } });
20
+ var asyncHooks_1 = require("./lib/utils/asyncHooks");
21
+ Object.defineProperty(exports, "useReqStore", { enumerable: true, get: function () { return asyncHooks_1.useReqStore; } });
22
+ Object.defineProperty(exports, "runWithRequestContext", { enumerable: true, get: function () { return asyncHooks_1.runWithRequestContext; } });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,13 @@
1
+ type Activities = {
2
+ [activity: string]: boolean;
3
+ };
4
+ type MustbeRouteHelpers = () => {
5
+ authorized: (activity: string) => void;
6
+ authenticated: () => void;
7
+ requestSchema: (schema: any) => void;
8
+ };
9
+ /** Only needed if used along side legacy setup */
10
+ declare const routeHelpers: MustbeRouteHelpers;
11
+ export { routeHelpers };
12
+ export declare function configureMustBe(): void;
13
+ export declare function isUserAuthorized(activities: Activities, requiredActivitiesString: string): boolean;