@mountainpass/waycharter 1.0.76 → 2.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/action.d.ts +8 -0
  4. package/dist/action.js +3 -0
  5. package/dist/action.js.map +1 -0
  6. package/dist/collections/build-first-link.d.ts +12 -0
  7. package/dist/collections/build-first-link.js +34 -19
  8. package/dist/collections/build-first-link.js.map +1 -1
  9. package/dist/collections/build-next-link.d.ts +11 -0
  10. package/dist/collections/build-next-link.js +24 -15
  11. package/dist/collections/build-next-link.js.map +1 -1
  12. package/dist/collections/build-previous-link.d.ts +11 -0
  13. package/dist/collections/build-previous-link.js +42 -27
  14. package/dist/collections/build-previous-link.js.map +1 -1
  15. package/dist/collections/built-item-links.d.ts +16 -0
  16. package/dist/collections/built-item-links.js +84 -118
  17. package/dist/collections/built-item-links.js.map +1 -1
  18. package/dist/handler.d.ts +21 -0
  19. package/dist/handler.js +3 -0
  20. package/dist/handler.js.map +1 -0
  21. package/dist/link.d.ts +17 -0
  22. package/dist/link.js +3 -0
  23. package/dist/link.js.map +1 -0
  24. package/dist/method.d.ts +28 -0
  25. package/dist/method.js +41 -0
  26. package/dist/method.js.map +1 -0
  27. package/dist/to-links.d.ts +9 -0
  28. package/dist/to-links.js +77 -0
  29. package/dist/to-links.js.map +1 -0
  30. package/dist/util/array-to-lower-case.d.ts +4 -0
  31. package/dist/util/array-to-lower-case.js +11 -0
  32. package/dist/util/array-to-lower-case.js.map +1 -0
  33. package/dist/util/check-page.d.ts +13 -0
  34. package/dist/util/check-page.js +75 -0
  35. package/dist/util/check-page.js.map +1 -0
  36. package/dist/util/convert-resource-links.d.ts +7 -0
  37. package/dist/util/convert-resource-links.js +73 -0
  38. package/dist/util/convert-resource-links.js.map +1 -0
  39. package/dist/util/extract-path-parameters.d.ts +6 -0
  40. package/dist/util/extract-path-parameters.js +13 -0
  41. package/dist/util/extract-path-parameters.js.map +1 -0
  42. package/dist/util/filter-headers.d.ts +9 -0
  43. package/dist/util/filter-headers.js +22 -0
  44. package/dist/util/filter-headers.js.map +1 -0
  45. package/dist/util/filter-parameters.d.ts +17 -0
  46. package/dist/util/filter-parameters.js +87 -0
  47. package/dist/util/filter-parameters.js.map +1 -0
  48. package/dist/util/method-can-have-body.d.ts +4 -0
  49. package/dist/util/method-can-have-body.js +11 -0
  50. package/dist/util/method-can-have-body.js.map +1 -0
  51. package/dist/util/method-is-cacheable.d.ts +4 -0
  52. package/dist/util/method-is-cacheable.js +11 -0
  53. package/dist/util/method-is-cacheable.js.map +1 -0
  54. package/dist/util/router-to-rfc6570.d.ts +4 -0
  55. package/dist/util/router-to-rfc6570.js +4 -7
  56. package/dist/util/router-to-rfc6570.js.map +1 -1
  57. package/dist/util/unique.d.ts +4 -0
  58. package/dist/util/unique.js +36 -0
  59. package/dist/util/unique.js.map +1 -0
  60. package/dist/waycharter.d.ts +71 -0
  61. package/dist/waycharter.js +473 -306
  62. package/dist/waycharter.js.map +1 -1
  63. package/package.json +18 -39
  64. package/dist/convert-resource-links.js +0 -44
  65. package/dist/convert-resource-links.js.map +0 -1
  66. package/dist/method-can-have-body.js +0 -14
  67. package/dist/method-can-have-body.js.map +0 -1
  68. package/dist/method-is-cacheable.js +0 -14
  69. package/dist/method-is-cacheable.js.map +0 -1
  70. package/dist/util/logger.js +0 -47
  71. package/dist/util/logger.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ export declare type ItemActionMap<V> = {
2
+ POST?: V;
3
+ PUT?: V;
4
+ PATCH?: V;
5
+ CONNECT?: V;
6
+ };
7
+ export declare type ItemActionMethod = keyof ItemActionMap<any>;
8
+ /**
9
+ * @param maybeItemActionMethod
10
+ */
11
+ /**
12
+ * @param maybeItemActionMethod
13
+ */
14
+ export declare function isItemActionMethod(maybeItemActionMethod: unknown): maybeItemActionMethod is ItemActionMethod;
15
+ export declare type ActionMap<V> = ItemActionMap<V> & {
16
+ DELETE?: V;
17
+ OPTIONS?: V;
18
+ TRACE?: V;
19
+ };
20
+ export declare type ActionMethod = keyof ActionMap<any>;
21
+ /**
22
+ * @param maybeActionMethod
23
+ */
24
+ /**
25
+ * @param maybeActionMethod
26
+ */
27
+ export declare function isActionMethod(maybeActionMethod: unknown): maybeActionMethod is ActionMethod;
28
+ export declare type Method = ActionMethod | 'GET' | 'HEAD';
package/dist/method.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isActionMethod = exports.isItemActionMethod = void 0;
4
+ var itemActionMapDictionary = {
5
+ POST: '',
6
+ PUT: '',
7
+ PATCH: '',
8
+ CONNECT: ''
9
+ };
10
+ /**
11
+ * @param maybeItemActionMethod
12
+ */
13
+ /**
14
+ * @param maybeItemActionMethod
15
+ */
16
+ function isItemActionMethod(maybeItemActionMethod) {
17
+ return (typeof maybeItemActionMethod === 'string' &&
18
+ Object.prototype.hasOwnProperty.call(itemActionMapDictionary, maybeItemActionMethod));
19
+ }
20
+ exports.isItemActionMethod = isItemActionMethod;
21
+ var actionMapDictionary = {
22
+ POST: '',
23
+ PUT: '',
24
+ DELETE: '',
25
+ PATCH: '',
26
+ OPTIONS: '',
27
+ CONNECT: '',
28
+ TRACE: ''
29
+ };
30
+ /**
31
+ * @param maybeActionMethod
32
+ */
33
+ /**
34
+ * @param maybeActionMethod
35
+ */
36
+ function isActionMethod(maybeActionMethod) {
37
+ return (typeof maybeActionMethod === 'string' &&
38
+ Object.prototype.hasOwnProperty.call(actionMapDictionary, maybeActionMethod));
39
+ }
40
+ exports.isActionMethod = isActionMethod;
41
+ //# sourceMappingURL=method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.js","sourceRoot":"","sources":["../src/method.ts"],"names":[],"mappings":";;;AAMA,IAAM,uBAAuB,GAAiC;IAC5D,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;CACZ,CAAA;AAGD;;GAEG;AAEH;;GAEG;AACH,SAAgB,kBAAkB,CAChC,qBAA8B;IAE9B,OAAO,CACL,OAAO,qBAAqB,KAAK,QAAQ;QACzC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAClC,uBAAuB,EACvB,qBAAqB,CACtB,CACF,CAAA;AACH,CAAC;AAVD,gDAUC;AAOD,IAAM,mBAAmB,GAA6B;IACpD,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;CACV,CAAA;AAGD;;GAEG;AAEH;;GAEG;AACH,SAAgB,cAAc,CAC5B,iBAA0B;IAE1B,OAAO,CACL,OAAO,iBAAiB,KAAK,QAAQ;QACrC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAC7E,CAAA;AACH,CAAC;AAPD,wCAOC"}
@@ -0,0 +1,9 @@
1
+ import { Link } from './link';
2
+ import { Action, Actions } from './action';
3
+ export declare type ActionTransformer<ActionResponseBody> = (action: Readonly<Action<ActionResponseBody>>) => Action<ActionResponseBody>;
4
+ /**
5
+ * @param actions
6
+ * @param uri
7
+ * @param transform
8
+ */
9
+ export declare function toLinks<ActionResponseBody>(actions: Actions<ActionResponseBody>, uri: string, transform?: ActionTransformer<ActionResponseBody>): Link[];
@@ -0,0 +1,77 @@
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 __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __values = (this && this.__values) || function(o) {
25
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
26
+ if (m) return m.call(o);
27
+ if (o && typeof o.length === "number") return {
28
+ next: function () {
29
+ if (o && i >= o.length) o = void 0;
30
+ return { value: o && o[i++], done: !o };
31
+ }
32
+ };
33
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.toLinks = void 0;
37
+ var method_1 = require("./method");
38
+ /**
39
+ * @param actions
40
+ * @param uri
41
+ * @param transform
42
+ */
43
+ function toLinks(actions, uri, transform) {
44
+ var e_1, _a;
45
+ var links = [];
46
+ for (var method in actions) {
47
+ if ((0, method_1.isActionMethod)(method)) {
48
+ var methodActions = actions[method];
49
+ try {
50
+ for (var methodActions_1 = (e_1 = void 0, __values(methodActions)), methodActions_1_1 = methodActions_1.next(); !methodActions_1_1.done; methodActions_1_1 = methodActions_1.next()) {
51
+ var action = methodActions_1_1.value;
52
+ links.push(toLink(action, uri, method, transform));
53
+ }
54
+ }
55
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
56
+ finally {
57
+ try {
58
+ if (methodActions_1_1 && !methodActions_1_1.done && (_a = methodActions_1.return)) _a.call(methodActions_1);
59
+ }
60
+ finally { if (e_1) throw e_1.error; }
61
+ }
62
+ }
63
+ }
64
+ return links;
65
+ }
66
+ exports.toLinks = toLinks;
67
+ /**
68
+ * @param action
69
+ * @param uri
70
+ * @param method
71
+ * @param transform
72
+ */
73
+ function toLink(action, uri, method, transform) {
74
+ var _a = transform ? transform(action) : action, handler = _a.handler, other = __rest(_a, ["handler"]);
75
+ return __assign(__assign({}, other), { uri: uri, method: method });
76
+ }
77
+ //# sourceMappingURL=to-links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-links.js","sourceRoot":"","sources":["../src/to-links.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAuD;AAMvD;;;;GAIG;AACH,SAAgB,OAAO,CACrB,OAAoC,EACpC,GAAW,EACX,SAAiD;;IAEjD,IAAM,KAAK,GAAG,EAAE,CAAA;IAChB,KAAK,IAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,IAAI,IAAA,uBAAc,EAAC,MAAM,CAAC,EAAE;YAC1B,IAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;;gBACrC,KAAqB,IAAA,iCAAA,SAAA,aAAa,CAAA,CAAA,4CAAA,uEAAE;oBAA/B,IAAM,MAAM,0BAAA;oBACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;iBACnD;;;;;;;;;SACF;KACF;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAfD,0BAeC;AAED;;;;;GAKG;AACH,SAAS,MAAM,CACb,MAAkC,EAClC,GAAW,EACX,MAAoB,EACpB,SAAiD;IAEjD,IAAM,KAAwB,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAA5D,OAAO,aAAA,EAAK,KAAK,cAAnB,WAAqB,CAAyC,CAAA;IACpE,6BACK,KAAK,KACR,GAAG,KAAA,EACH,MAAM,QAAA,IACP;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @param array
3
+ */
4
+ export declare function arrayToLowerCase(array: readonly string[]): string[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.arrayToLowerCase = void 0;
4
+ /**
5
+ * @param array
6
+ */
7
+ function arrayToLowerCase(array) {
8
+ return array ? array.map(function (value) { return value.toLowerCase(); }) : undefined;
9
+ }
10
+ exports.arrayToLowerCase = arrayToLowerCase;
11
+ //# sourceMappingURL=array-to-lower-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-to-lower-case.js","sourceRoot":"","sources":["../../src/util/array-to-lower-case.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,gBAAgB,CAAE,KAAwB;IACxD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,WAAW,EAAE,EAAnB,CAAmB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACpE,CAAC;AAFD,4CAEC"}
@@ -0,0 +1,13 @@
1
+ import { ProblemDocument } from '@mountainpass/problem-document';
2
+ import { EmptyHandlerResponse, HandlerResponse } from '../waycharter';
3
+ /**
4
+ * @param page
5
+ * @param expandedPath
6
+ */
7
+ export declare function checkPage(page: string | import('qs').ParsedQs | string[] | import('qs').ParsedQs[], expandedPath: string): {
8
+ pageInt: number;
9
+ } | {
10
+ pageValidationError: HandlerResponse<ProblemDocument>;
11
+ } | {
12
+ redirect: EmptyHandlerResponse;
13
+ };
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkPage = void 0;
4
+ var problem_document_1 = require("@mountainpass/problem-document");
5
+ /**
6
+ * @param page
7
+ * @param expandedPath
8
+ */
9
+ function checkPage(page, expandedPath) {
10
+ if (page === '0') {
11
+ return {
12
+ redirect: {
13
+ status: 308,
14
+ headers: {
15
+ location: expandedPath
16
+ }
17
+ }
18
+ };
19
+ }
20
+ if (Array.isArray(page)) {
21
+ return {
22
+ pageValidationError: {
23
+ status: 400,
24
+ body: new problem_document_1.ProblemDocument({
25
+ type: 'https://waycharter.io/bad-page',
26
+ title: "Bad Page",
27
+ detail: "We don't understand what page '".concat(page, "' is that you are trying to retrieve"),
28
+ page: page
29
+ }),
30
+ headers: {
31
+ 'content-type': 'application/problem+json'
32
+ }
33
+ }
34
+ };
35
+ }
36
+ // page should be >= 0
37
+ var pageInt = Number.parseInt(page || '0');
38
+ if (Number.isNaN(pageInt)) {
39
+ return {
40
+ pageValidationError: {
41
+ status: 400,
42
+ body: new problem_document_1.ProblemDocument({
43
+ type: 'https://waycharter.io/bad-page',
44
+ title: "Bad Page",
45
+ detail: "We don't understand what page '".concat(page, "' is that you are trying to retrieve"),
46
+ page: page
47
+ }),
48
+ headers: {
49
+ 'content-type': 'application/problem+json'
50
+ }
51
+ }
52
+ };
53
+ }
54
+ if (pageInt < 0) {
55
+ return {
56
+ pageValidationError: {
57
+ status: 400,
58
+ body: new problem_document_1.ProblemDocument({
59
+ type: 'https://waycharter.io/bad-page',
60
+ title: "Bad Page",
61
+ detail: "You've asked for a negative page '".concat(page, "'. We don't know what that means"),
62
+ page: page
63
+ }),
64
+ headers: {
65
+ 'content-type': 'application/problem+json'
66
+ }
67
+ }
68
+ };
69
+ }
70
+ return {
71
+ pageInt: pageInt
72
+ };
73
+ }
74
+ exports.checkPage = checkPage;
75
+ //# sourceMappingURL=check-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-page.js","sourceRoot":"","sources":["../../src/util/check-page.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAGhE;;;GAGG;AACH,SAAgB,SAAS,CACvB,IAAyE,EACzE,YAAoB;IAEpB,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO;YACL,QAAQ,EAAE;gBACR,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE;oBACP,QAAQ,EAAE,YAAY;iBACvB;aACF;SACF,CAAA;KACF;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,OAAO;YACL,mBAAmB,EAAE;gBACnB,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,IAAI,kCAAe,CAAC;oBACxB,IAAI,EAAE,gCAAgC;oBACtC,KAAK,EAAE,UAAU;oBACjB,MAAM,EAAE,yCAAkC,IAAI,yCAAsC;oBACpF,IAAI,MAAA;iBACL,CAAC;gBACF,OAAO,EAAE;oBACP,cAAc,EAAE,0BAA0B;iBAC3C;aACF;SACF,CAAA;KACF;IACD,sBAAsB;IACtB,IAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAE,IAAe,IAAI,GAAG,CAAC,CAAA;IAExD,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACzB,OAAO;YACL,mBAAmB,EAAE;gBACnB,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,IAAI,kCAAe,CAAC;oBACxB,IAAI,EAAE,gCAAgC;oBACtC,KAAK,EAAE,UAAU;oBACjB,MAAM,EAAE,yCAAkC,IAAI,yCAAsC;oBACpF,IAAI,MAAA;iBACL,CAAC;gBACF,OAAO,EAAE;oBACP,cAAc,EAAE,0BAA0B;iBAC3C;aACF;SACF,CAAA;KACF;IACD,IAAI,OAAO,GAAG,CAAC,EAAE;QACf,OAAO;YACL,mBAAmB,EAAE;gBACnB,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,IAAI,kCAAe,CAAC;oBACxB,IAAI,EAAE,gCAAgC;oBACtC,KAAK,EAAE,UAAU;oBACjB,MAAM,EAAE,4CAAqC,IAAI,qCAAkC;oBACnF,IAAI,MAAA;iBACL,CAAC;gBACF,OAAO,EAAE;oBACP,cAAc,EAAE,0BAA0B;iBAC3C;aACF;SACF,CAAA;KACF;IACD,OAAO;QACL,OAAO,SAAA;KACR,CAAA;AACH,CAAC;AArED,8BAqEC"}
@@ -0,0 +1,7 @@
1
+ import LinkHeader from 'http-link-header';
2
+ import { Link } from '../link';
3
+ /**
4
+ * @param resourceLinks
5
+ * @param requestUrl
6
+ */
7
+ export declare function covertResourceLinks(resourceLinks: Array<Link>): LinkHeader;
@@ -0,0 +1,73 @@
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 __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __values = (this && this.__values) || function(o) {
25
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
26
+ if (m) return m.call(o);
27
+ if (o && typeof o.length === "number") return {
28
+ next: function () {
29
+ if (o && i >= o.length) o = void 0;
30
+ return { value: o && o[i++], done: !o };
31
+ }
32
+ };
33
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
34
+ };
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.covertResourceLinks = void 0;
40
+ var http_link_header_1 = __importDefault(require("http-link-header"));
41
+ /**
42
+ * @param resourceLinks
43
+ * @param requestUrl
44
+ */
45
+ function covertResourceLinks(resourceLinks) {
46
+ var e_1, _a;
47
+ var links = new http_link_header_1.default();
48
+ try {
49
+ for (var resourceLinks_1 = __values(resourceLinks), resourceLinks_1_1 = resourceLinks_1.next(); !resourceLinks_1_1.done; resourceLinks_1_1 = resourceLinks_1.next()) {
50
+ var link = resourceLinks_1_1.value;
51
+ var linkParameters = link.parameters, accept = link.accept, uri = link.uri, handler = link.handler, other = __rest(link, ["parameters", "accept", "uri", "handler"]);
52
+ var hasParameters = linkParameters &&
53
+ ((Array.isArray(linkParameters) && linkParameters.length > 0) ||
54
+ (typeof linkParameters === 'object' &&
55
+ Object.keys(linkParameters).length > 0));
56
+ links.set(__assign(__assign(__assign(__assign({}, other), { uri: uri }), (hasParameters && {
57
+ 'params*': { value: JSON.stringify(linkParameters) }
58
+ })), (accept && {
59
+ 'accept*': { value: accept }
60
+ })));
61
+ }
62
+ }
63
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
64
+ finally {
65
+ try {
66
+ if (resourceLinks_1_1 && !resourceLinks_1_1.done && (_a = resourceLinks_1.return)) _a.call(resourceLinks_1);
67
+ }
68
+ finally { if (e_1) throw e_1.error; }
69
+ }
70
+ return links;
71
+ }
72
+ exports.covertResourceLinks = covertResourceLinks;
73
+ //# sourceMappingURL=convert-resource-links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-resource-links.js","sourceRoot":"","sources":["../../src/util/convert-resource-links.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAAyC;AAGzC;;;GAGG;AACH,SAAgB,mBAAmB,CAAE,aAA0B;;IAC7D,IAAM,KAAK,GAAG,IAAI,0BAAU,EAAE,CAAA;;QAC9B,KAAmB,IAAA,kBAAA,SAAA,aAAa,CAAA,4CAAA,uEAAE;YAA7B,IAAM,IAAI,0BAAA;YACL,IAAY,cAAc,GAAqC,IAAI,WAAzC,EAAE,MAAM,GAA6B,IAAI,OAAjC,EAAE,GAAG,GAAwB,IAAI,IAA5B,EAAE,OAAO,GAAe,IAAI,QAAnB,EAAK,KAAK,UAAK,IAAI,EAArE,0CAA8D,CAAF,CAAS;YAC3E,IAAM,aAAa,GACjB,cAAc;gBACd,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC3D,CAAC,OAAO,cAAc,KAAK,QAAQ;wBACjC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;YAE9C,KAAK,CAAC,GAAG,yCACJ,KAAK,KACR,GAAG,KAAA,KACA,CAAC,aAAa,IAAI;gBACnB,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE;aACrD,CAAC,GACC,CAAC,MAAM,IAAI;gBACZ,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;aAC7B,CAAC,EACF,CAAA;SACH;;;;;;;;;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAtBD,kDAsBC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param uriTemplate
3
+ */
4
+ export declare function extractPathParameters(uriTemplate: string): {
5
+ [key: string]: string;
6
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractPathParameters = void 0;
4
+ var uri_template_lite_1 = require("uri-template-lite");
5
+ /**
6
+ * @param uriTemplate
7
+ */
8
+ function extractPathParameters(uriTemplate) {
9
+ var template = new uri_template_lite_1.URI.Template(uriTemplate);
10
+ return template.match(uriTemplate);
11
+ }
12
+ exports.extractPathParameters = extractPathParameters;
13
+ //# sourceMappingURL=extract-path-parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-path-parameters.js","sourceRoot":"","sources":["../../src/util/extract-path-parameters.ts"],"names":[],"mappings":";;;AAAA,uDAAuC;AAEvC;;GAEG;AACH,SAAgB,qBAAqB,CACnC,WAAmB;IAInB,IAAM,QAAQ,GAAG,IAAI,uBAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC9C,OAAO,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AACpC,CAAC;AAPD,sDAOC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import express from 'express';
3
+ import { IncomingHttpHeaders } from 'http';
4
+ /**
5
+ * @param request
6
+ * @param response
7
+ * @param headerParameters
8
+ */
9
+ export declare function filterHeaders(request: express.Request, response: express.Response, headerParameters: string[]): IncomingHttpHeaders;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterHeaders = void 0;
4
+ /**
5
+ * @param request
6
+ * @param response
7
+ * @param headerParameters
8
+ */
9
+ function filterHeaders(request, response, headerParameters) {
10
+ if (headerParameters.length > 0) {
11
+ var filteredHeaders = {};
12
+ for (var headerName in request.headers) {
13
+ if (headerParameters.includes(headerName)) {
14
+ filteredHeaders[headerName] = request.headers[headerName];
15
+ }
16
+ }
17
+ return filteredHeaders;
18
+ }
19
+ return {};
20
+ }
21
+ exports.filterHeaders = filterHeaders;
22
+ //# sourceMappingURL=filter-headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-headers.js","sourceRoot":"","sources":["../../src/util/filter-headers.ts"],"names":[],"mappings":";;;AAGA;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,OAAwB,EACxB,QAA0B,EAC1B,gBAA0B;IAE1B,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,IAAM,eAAe,GAAG,EAAE,CAAA;QAC1B,KAAK,IAAM,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE;YACxC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;gBACzC,eAAe,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;aAC1D;SACF;QACD,OAAO,eAAe,CAAA;KACvB;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAfD,sCAeC"}
@@ -0,0 +1,17 @@
1
+ import { Request } from 'express';
2
+ import { Query } from 'express-serve-static-core';
3
+ /**
4
+ * @param filters
5
+ * @param queryParameters
6
+ */
7
+ export declare function filterParameters(filters: {
8
+ rel: string;
9
+ parameters: Array<string>;
10
+ }[], queryParameters: Query): Query;
11
+ /**
12
+ * @param request
13
+ * @param parameters
14
+ */
15
+ export declare function filterBodyParameters(request: Request, parameters: string[] | {
16
+ [key: string]: {};
17
+ } | undefined): Record<string, unknown>;
@@ -0,0 +1,87 @@
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 __values = (this && this.__values) || function(o) {
14
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
+ if (m) return m.call(o);
16
+ if (o && typeof o.length === "number") return {
17
+ next: function () {
18
+ if (o && i >= o.length) o = void 0;
19
+ return { value: o && o[i++], done: !o };
20
+ }
21
+ };
22
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.filterBodyParameters = exports.filterParameters = void 0;
26
+ var method_can_have_body_1 = require("./method-can-have-body");
27
+ /**
28
+ * @param filters
29
+ * @param queryParameters
30
+ */
31
+ function filterParameters(filters, queryParameters) {
32
+ var e_1, _a, e_2, _b;
33
+ var filteredParameters = {};
34
+ try {
35
+ for (var _c = __values(filters || []), _d = _c.next(); !_d.done; _d = _c.next()) {
36
+ var filter = _d.value;
37
+ try {
38
+ for (var _e = (e_2 = void 0, __values(filter.parameters)), _f = _e.next(); !_f.done; _f = _e.next()) {
39
+ var parameter = _f.value;
40
+ if (queryParameters[parameter] !== undefined) {
41
+ filteredParameters[parameter] = queryParameters[parameter];
42
+ }
43
+ }
44
+ }
45
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
46
+ finally {
47
+ try {
48
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
49
+ }
50
+ finally { if (e_2) throw e_2.error; }
51
+ }
52
+ }
53
+ }
54
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
55
+ finally {
56
+ try {
57
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
58
+ }
59
+ finally { if (e_1) throw e_1.error; }
60
+ }
61
+ return filteredParameters;
62
+ }
63
+ exports.filterParameters = filterParameters;
64
+ /**
65
+ * @param request
66
+ * @param parameters
67
+ */
68
+ function filterBodyParameters(request, parameters) {
69
+ if (parameters) {
70
+ var canHaveBody = (0, method_can_have_body_1.methodCanHaveBody)(request.method);
71
+ if (canHaveBody) {
72
+ return Object.keys(request.body)
73
+ .filter(function (key) {
74
+ return Array.isArray(parameters) ? parameters.includes(key) : parameters[key];
75
+ })
76
+ .reduce(function (previous, current) {
77
+ var _a;
78
+ return __assign(__assign({}, previous), (_a = {}, _a[current] = request.body[current], _a));
79
+ }, {});
80
+ }
81
+ }
82
+ else {
83
+ return {};
84
+ }
85
+ }
86
+ exports.filterBodyParameters = filterBodyParameters;
87
+ //# sourceMappingURL=filter-parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-parameters.js","sourceRoot":"","sources":["../../src/util/filter-parameters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+DAA0D;AAE1D;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,OAAqD,EACrD,eAAsB;;IAEtB,IAAM,kBAAkB,GAAG,EAAE,CAAA;;QAC7B,KAAqB,IAAA,KAAA,SAAA,OAAO,IAAI,EAAE,CAAA,gBAAA,4BAAE;YAA/B,IAAM,MAAM,WAAA;;gBACf,KAAwB,IAAA,oBAAA,SAAA,MAAM,CAAC,UAAU,CAAA,CAAA,gBAAA,4BAAE;oBAAtC,IAAM,SAAS,WAAA;oBAClB,IAAI,eAAe,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE;wBAC5C,kBAAkB,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;qBAC3D;iBACF;;;;;;;;;SACF;;;;;;;;;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC;AAbD,4CAaC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,OAAgB,EAChB,UAAwD;IAExD,IAAI,UAAU,EAAE;QACd,IAAM,WAAW,GAAG,IAAA,wCAAiB,EAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACrD,IAAI,WAAW,EAAE;YACf,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;iBAC7B,MAAM,CAAC,UAAA,GAAG;gBACT,OAAA,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;YAAtE,CAAsE,CACvE;iBACA,MAAM,CAAC,UAAC,QAAQ,EAAE,OAAO;;gBACxB,6BAAY,QAAQ,gBAAG,OAAO,IAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAE;YAC1D,CAAC,EAAE,EAAE,CAAC,CAAA;SACT;KACF;SAAM;QACL,OAAO,EAAE,CAAA;KACV;AACH,CAAC;AAlBD,oDAkBC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @param method
3
+ */
4
+ export function methodCanHaveBody(method: any): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.methodCanHaveBody = void 0;
4
+ /**
5
+ * @param method
6
+ */
7
+ function methodCanHaveBody(method) {
8
+ return !['GET', 'DELETE', 'TRACE', 'OPTIONS', 'HEAD'].includes(method);
9
+ }
10
+ exports.methodCanHaveBody = methodCanHaveBody;
11
+ //# sourceMappingURL=method-can-have-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-can-have-body.js","sourceRoot":"","sources":["../../src/util/method-can-have-body.js"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,iBAAiB,CAAE,MAAM;IACvC,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACxE,CAAC;AAFD,8CAEC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @param method
3
+ */
4
+ export function methodIsCacheable(method: any): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.methodIsCacheable = void 0;
4
+ /**
5
+ * @param method
6
+ */
7
+ function methodIsCacheable(method) {
8
+ return ['GET', 'HEAD'].includes(method);
9
+ }
10
+ exports.methodIsCacheable = methodIsCacheable;
11
+ //# sourceMappingURL=method-is-cacheable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-is-cacheable.js","sourceRoot":"","sources":["../../src/util/method-is-cacheable.js"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,iBAAiB,CAAE,MAAM;IACvC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAFD,8CAEC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @param url
3
+ */
4
+ export function routerToRfc6570(url: any): any;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.routerToRfc6570 = routerToRfc6570;
7
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.routerToRfc6570 = void 0;
8
4
  /**
9
5
  * @param url
10
6
  */
11
7
  function routerToRfc6570(url) {
12
- return url.replace(/:(\w*)/g, '{+$1}');
8
+ return url.replace(/:(\w*)/g, '{+$1}');
13
9
  }
10
+ exports.routerToRfc6570 = routerToRfc6570;
14
11
  //# sourceMappingURL=router-to-rfc6570.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/router-to-rfc6570.js"],"names":["routerToRfc6570","url","replace"],"mappings":";;;;;;;AAAA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,GAA1B,EAA+B;AACpC,SAAOA,GAAG,CAACC,OAAJ,CAAY,SAAZ,EAAuB,OAAvB,CAAP;AACD","sourcesContent":["/**\n * @param url\n */\nexport function routerToRfc6570 (url) {\n return url.replace(/:(\\w*)/g, '{+$1}')\n}\n"],"file":"router-to-rfc6570.js"}
1
+ {"version":3,"file":"router-to-rfc6570.js","sourceRoot":"","sources":["../../src/util/router-to-rfc6570.js"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAG;IACjC,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC;AAFD,0CAEC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @param array
3
+ */
4
+ export declare function unique<T>(array: Array<T>): Array<T>;