@mountainpass/waycharter 1.0.76 → 2.0.2

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 +18 -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 +13 -0
  7. package/dist/collections/build-first-link.js +30 -19
  8. package/dist/collections/build-first-link.js.map +1 -1
  9. package/dist/collections/build-next-link.d.ts +12 -0
  10. package/dist/collections/build-next-link.js +26 -15
  11. package/dist/collections/build-next-link.js.map +1 -1
  12. package/dist/collections/build-previous-link.d.ts +13 -0
  13. package/dist/collections/build-previous-link.js +52 -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 +76 -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 +62 -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 +73 -0
  61. package/dist/waycharter.js +475 -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
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## <small>2.0.2 (2022-08-04)</small>
2
+
3
+ * fix(collections): fixing nextPage links ([b34587a](https://github.com/mountain-pass/waycharter/commit/b34587a))
4
+
5
+
6
+
7
+ ## <small>2.0.1 (2022-08-03)</small>
8
+
9
+ * feat(collections): added support for non-numberic paging ([7ecead9](https://github.com/mountain-pass/waycharter/commit/7ecead9))
10
+
11
+
12
+
13
+ ## 2.0.0 (2022-06-23)
14
+
15
+ * build(lint): fixing linting issues ([0053c11](https://github.com/mountain-pass/waycharter/commit/0053c11))
16
+
17
+
18
+
1
19
  ## <small>1.0.76 (2021-12-16)</small>
2
20
 
3
21
  * fix(collections): fixed first, next, prev links for templated collections ([3ed681a](https://github.com/mountain-pass/waycharter/commit/3ed681a))
package/README.md CHANGED
@@ -13,7 +13,7 @@ This library is compatible with Node.js 10.x, 12.x and 14.x
13
13
 
14
14
  <!-- [![Quality](https://img.shields.io/codacy/grade/940768d54f7545f7b42f89b26c23c751?logo=codacy)](https://www.codacy.com/gh/mountain-pass/waycharter/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=mountain-pass/waycharter&amp;utm_campaign=Badge_Grade) [![Coverage](https://img.shields.io/codacy/coverage/940768d54f7545f7b42f89b26c23c751?logo=codacy)](https://www.codacy.com/gh/mountain-pass/waycharter/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mountain-pass/waycharter&utm_campaign=Badge_Coverage) -->
15
15
 
16
- [![source code vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/mountain-pass/waycharter?label=source%20code%20vulnerabilities&logo=snyk)](https://snyk.io/test/github/mountain-pass/waycharter) [![npm package vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@mountainpass/waycharter@1.0.76?label=npm%20package%20vulnerabilties&logo=snyk)](https://snyk.io/test/npm/@mountainpass/waycharter/1.0.76)
16
+ [![source code vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/mountain-pass/waycharter?label=source%20code%20vulnerabilities&logo=snyk)](https://snyk.io/test/github/mountain-pass/waycharter) [![npm package vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@mountainpass/waycharter@2.0.2?label=npm%20package%20vulnerabilties&logo=snyk)](https://snyk.io/test/npm/@mountainpass/waycharter/2.0.2)
17
17
 
18
18
 
19
19
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
@@ -0,0 +1,8 @@
1
+ import { ActionMap, ItemActionMap } from './method';
2
+ import { BaseLink } from './link';
3
+ import { ActionHandler } from './handler';
4
+ export declare type Action<ActionResponseBody> = Omit<BaseLink, 'uri' | 'method'> & {
5
+ handler: ActionHandler<ActionResponseBody>;
6
+ } & Record<string, any>;
7
+ export declare type Actions<ActionResponseBody> = ActionMap<Array<Action<ActionResponseBody>>>;
8
+ export declare type ItemActions<CanonicalItemActionResponseBody> = ItemActionMap<Array<Action<CanonicalItemActionResponseBody>>>;
package/dist/action.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { Query } from 'express-serve-static-core';
2
+ /**
3
+ * @param hasMore
4
+ * @param pageInt
5
+ * @param page
6
+ * @param firstPage
7
+ * @param collectionPath
8
+ * @param otherParameters
9
+ */
10
+ export declare function buildFirstLink(collectionPath: string, otherParameters: Query): {
11
+ rel: string;
12
+ uri: string;
13
+ }[];
@@ -1,28 +1,39 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.buildFirstLink = buildFirstLink;
7
-
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.buildFirstLink = void 0;
8
15
  /**
9
16
  * @param hasMore
10
17
  * @param pageInt
18
+ * @param page
19
+ * @param firstPage
11
20
  * @param collectionPath
12
21
  * @param otherParameters
13
22
  */
14
- function buildFirstLink(hasMore, pageInt, collectionPath, otherParameters) {
15
- if (pageInt > 0 || hasMore) {
16
- return Object.keys(otherParameters).length > 0 ? [{
17
- rel: 'first',
18
- uri: `${collectionPath}?${new URLSearchParams({ ...otherParameters
19
- }).toString()}`
20
- }] : [{
21
- rel: 'first',
22
- uri: collectionPath
23
- }];
24
- } else {
25
- return [];
26
- }
23
+ function buildFirstLink(collectionPath, otherParameters) {
24
+ return Object.keys(otherParameters).length > 0
25
+ ? [
26
+ {
27
+ rel: 'first',
28
+ uri: "".concat(collectionPath, "?").concat(new URLSearchParams(__assign({}, otherParameters)).toString())
29
+ }
30
+ ]
31
+ : [
32
+ {
33
+ rel: 'first',
34
+ uri: collectionPath
35
+ }
36
+ ];
27
37
  }
38
+ exports.buildFirstLink = buildFirstLink;
28
39
  //# sourceMappingURL=build-first-link.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/build-first-link.js"],"names":["buildFirstLink","hasMore","pageInt","collectionPath","otherParameters","Object","keys","length","rel","uri","URLSearchParams","toString"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CACLC,OADK,EAELC,OAFK,EAGLC,cAHK,EAILC,eAJK,EAKL;AACA,MAAIF,OAAO,GAAG,CAAV,IAAeD,OAAnB,EAA4B;AAC1B,WAAOI,MAAM,CAACC,IAAP,CAAYF,eAAZ,EAA6BG,MAA7B,GAAsC,CAAtC,GACH,CACE;AACEC,MAAAA,GAAG,EAAE,OADP;AAEEC,MAAAA,GAAG,EAAG,GAAEN,cAAe,IAAG,IAAIO,eAAJ,CAAoB,EAC5C,GAAGN;AADyC,OAApB,EAEvBO,QAFuB,EAEZ;AAJhB,KADF,CADG,GASH,CACE;AACEH,MAAAA,GAAG,EAAE,OADP;AAEEC,MAAAA,GAAG,EAAEN;AAFP,KADF,CATJ;AAeD,GAhBD,MAgBO;AACL,WAAO,EAAP;AACD;AACF","sourcesContent":["/**\n * @param hasMore\n * @param pageInt\n * @param collectionPath\n * @param otherParameters\n */\nexport function buildFirstLink (\n hasMore,\n pageInt,\n collectionPath,\n otherParameters\n) {\n if (pageInt > 0 || hasMore) {\n return Object.keys(otherParameters).length > 0\n ? [\n {\n rel: 'first',\n uri: `${collectionPath}?${new URLSearchParams({\n ...otherParameters\n }).toString()}`\n }\n ]\n : [\n {\n rel: 'first',\n uri: collectionPath\n }\n ]\n } else {\n return []\n }\n}\n"],"file":"build-first-link.js"}
1
+ {"version":3,"file":"build-first-link.js","sourceRoot":"","sources":["../../src/collections/build-first-link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,cAAsB,EACtB,eAAsB;IAEtB,OAAO,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC;QAC5C,CAAC,CAAC;YACA;gBACE,GAAG,EAAE,OAAO;gBACZ,GAAG,EAAE,UAAG,cAAc,cAAI,IAAI,eAAe,cACxC,eAAyC,EAC5C,CAAC,QAAQ,EAAE,CAAE;aAChB;SACF;QACD,CAAC,CAAC;YACA;gBACE,GAAG,EAAE,OAAO;gBACZ,GAAG,EAAE,cAAc;aACpB;SACF,CAAA;AACL,CAAC;AAnBD,wCAmBC"}
@@ -0,0 +1,12 @@
1
+ import { Query } from 'express-serve-static-core';
2
+ /**
3
+ * @param hasMore
4
+ * @param page
5
+ * @param nextPage
6
+ * @param collectionPath
7
+ * @param otherParameters
8
+ */
9
+ export declare function buildNextLink(hasMore: boolean, page: number | string, nextPage: string | undefined, collectionPath: string, otherParameters: Query): {
10
+ rel: string;
11
+ uri: string;
12
+ }[];
@@ -1,23 +1,34 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.buildNextLink = buildNextLink;
7
-
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.buildNextLink = void 0;
8
15
  /**
9
16
  * @param hasMore
10
- * @param pageInt
17
+ * @param page
18
+ * @param nextPage
11
19
  * @param collectionPath
12
20
  * @param otherParameters
13
21
  */
14
- function buildNextLink(hasMore, pageInt, collectionPath, otherParameters) {
15
- return hasMore ? [{
16
- rel: 'next',
17
- uri: `${collectionPath}?${new URLSearchParams({
18
- page: pageInt + 1,
19
- ...otherParameters
20
- }).toString()}`
21
- }] : [];
22
+ function buildNextLink(hasMore, page, nextPage, collectionPath, otherParameters) {
23
+ var nextPageNumber = (nextPage !== null && nextPage !== void 0 ? nextPage : typeof page === 'number') ? (page + 1).toFixed() : undefined;
24
+ return hasMore || nextPage !== undefined
25
+ ? [
26
+ {
27
+ rel: 'next',
28
+ uri: "".concat(collectionPath, "?").concat(new URLSearchParams(__assign({ page: nextPageNumber }, otherParameters)).toString())
29
+ }
30
+ ]
31
+ : [];
22
32
  }
33
+ exports.buildNextLink = buildNextLink;
23
34
  //# sourceMappingURL=build-next-link.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/build-next-link.js"],"names":["buildNextLink","hasMore","pageInt","collectionPath","otherParameters","rel","uri","URLSearchParams","page","toString"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CACLC,OADK,EAELC,OAFK,EAGLC,cAHK,EAILC,eAJK,EAKL;AACA,SAAOH,OAAO,GACV,CACE;AACEI,IAAAA,GAAG,EAAE,MADP;AAEEC,IAAAA,GAAG,EAAG,GAAEH,cAAe,IAAG,IAAII,eAAJ,CAAoB;AAC5CC,MAAAA,IAAI,EAAEN,OAAO,GAAG,CAD4B;AAE5C,SAAGE;AAFyC,KAApB,EAGvBK,QAHuB,EAGZ;AALhB,GADF,CADU,GAUV,EAVJ;AAWD","sourcesContent":["/**\n * @param hasMore\n * @param pageInt\n * @param collectionPath\n * @param otherParameters\n */\nexport function buildNextLink (\n hasMore,\n pageInt,\n collectionPath,\n otherParameters\n) {\n return hasMore\n ? [\n {\n rel: 'next',\n uri: `${collectionPath}?${new URLSearchParams({\n page: pageInt + 1,\n ...otherParameters\n }).toString()}`\n }\n ]\n : []\n}\n"],"file":"build-next-link.js"}
1
+ {"version":3,"file":"build-next-link.js","sourceRoot":"","sources":["../../src/collections/build-next-link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,OAAgB,EAChB,IAAqB,EACrB,QAA4B,EAC5B,cAAsB,EACtB,eAAsB;IAEtB,IAAM,cAAc,GAAG,CAAA,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,IAAI,KAAK,QAAQ,EAAC,CAAC,CAAC,CAAE,IAAe,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IAC1G,OAAO,OAAO,IAAI,QAAQ,KAAK,SAAS;QACtC,CAAC,CAAC;YACA;gBACE,GAAG,EAAE,MAAM;gBACX,GAAG,EAAE,UAAG,cAAc,cAAI,IAAI,eAAe,YAC3C,IAAI,EAAE,cAAc,IACjB,eAAe,EAClB,CAAC,QAAQ,EAAE,CAAE;aAChB;SACF;QACD,CAAC,CAAC,EAAE,CAAA;AACR,CAAC;AAnBD,sCAmBC"}
@@ -0,0 +1,13 @@
1
+ import { Query } from 'express-serve-static-core';
2
+ /**
3
+ * @param pageInt
4
+ * @param page
5
+ * @param prevPage
6
+ * @param previousPage
7
+ * @param collectionPath
8
+ * @param otherParameters
9
+ */
10
+ export declare function buildPreviousLink(page: number | string, previousPage: string | undefined, collectionPath: string, otherParameters: Query): {
11
+ rel: string;
12
+ uri: string;
13
+ }[];
@@ -1,35 +1,60 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.buildPreviousLink = buildPreviousLink;
7
-
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.buildPreviousLink = void 0;
8
15
  /**
9
16
  * @param pageInt
17
+ * @param page
18
+ * @param prevPage
19
+ * @param previousPage
10
20
  * @param collectionPath
11
21
  * @param otherParameters
12
22
  */
13
- function buildPreviousLink(pageInt, collectionPath, otherParameters) {
14
- if (pageInt === 1) {
15
- return Object.keys(otherParameters).length > 0 ? [{
16
- rel: 'prev',
17
- uri: `${collectionPath}?${new URLSearchParams({ ...otherParameters
18
- }).toString()}`
19
- }] : [{
20
- rel: 'prev',
21
- uri: collectionPath
22
- }];
23
- } else if (pageInt > 1) {
24
- return [{
25
- rel: 'prev',
26
- uri: `${collectionPath}?${new URLSearchParams({
27
- page: pageInt - 1,
28
- ...otherParameters
29
- }).toString()}`
30
- }];
31
- } else {
32
- return [];
33
- }
23
+ function buildPreviousLink(page, previousPage, collectionPath, otherParameters) {
24
+ if (page === 1) {
25
+ return Object.keys(otherParameters).length > 0
26
+ ? [
27
+ {
28
+ rel: 'prev',
29
+ uri: "".concat(collectionPath, "?").concat(new URLSearchParams(__assign({}, otherParameters)).toString())
30
+ }
31
+ ]
32
+ : [
33
+ {
34
+ rel: 'prev',
35
+ uri: collectionPath
36
+ }
37
+ ];
38
+ }
39
+ else if (typeof page === 'number' && page > 1) {
40
+ return [
41
+ {
42
+ rel: 'prev',
43
+ uri: "".concat(collectionPath, "?").concat(new URLSearchParams(__assign({ page: (page - 1).toFixed() }, otherParameters)).toString())
44
+ }
45
+ ];
46
+ }
47
+ else if (previousPage !== undefined) {
48
+ return [
49
+ {
50
+ rel: 'prev',
51
+ uri: "".concat(collectionPath, "?").concat(new URLSearchParams(__assign({ page: previousPage }, otherParameters)).toString())
52
+ }
53
+ ];
54
+ }
55
+ else {
56
+ return [];
57
+ }
34
58
  }
59
+ exports.buildPreviousLink = buildPreviousLink;
35
60
  //# sourceMappingURL=build-previous-link.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/build-previous-link.js"],"names":["buildPreviousLink","pageInt","collectionPath","otherParameters","Object","keys","length","rel","uri","URLSearchParams","toString","page"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,CAA4BC,OAA5B,EAAqCC,cAArC,EAAqDC,eAArD,EAAsE;AAC3E,MAAIF,OAAO,KAAK,CAAhB,EAAmB;AACjB,WAAOG,MAAM,CAACC,IAAP,CAAYF,eAAZ,EAA6BG,MAA7B,GAAsC,CAAtC,GACH,CACE;AACEC,MAAAA,GAAG,EAAE,MADP;AAEEC,MAAAA,GAAG,EAAG,GAAEN,cAAe,IAAG,IAAIO,eAAJ,CAAoB,EAC5C,GAAGN;AADyC,OAApB,EAEvBO,QAFuB,EAEZ;AAJhB,KADF,CADG,GASH,CACE;AACEH,MAAAA,GAAG,EAAE,MADP;AAEEC,MAAAA,GAAG,EAAEN;AAFP,KADF,CATJ;AAeD,GAhBD,MAgBO,IAAID,OAAO,GAAG,CAAd,EAAiB;AACtB,WAAO,CACL;AACEM,MAAAA,GAAG,EAAE,MADP;AAEEC,MAAAA,GAAG,EAAG,GAAEN,cAAe,IAAG,IAAIO,eAAJ,CAAoB;AAC5CE,QAAAA,IAAI,EAAEV,OAAO,GAAG,CAD4B;AAE5C,WAAGE;AAFyC,OAApB,EAGvBO,QAHuB,EAGZ;AALhB,KADK,CAAP;AASD,GAVM,MAUA;AACL,WAAO,EAAP;AACD;AACF","sourcesContent":["/**\n * @param pageInt\n * @param collectionPath\n * @param otherParameters\n */\nexport function buildPreviousLink (pageInt, collectionPath, otherParameters) {\n if (pageInt === 1) {\n return Object.keys(otherParameters).length > 0\n ? [\n {\n rel: 'prev',\n uri: `${collectionPath}?${new URLSearchParams({\n ...otherParameters\n }).toString()}`\n }\n ]\n : [\n {\n rel: 'prev',\n uri: collectionPath\n }\n ]\n } else if (pageInt > 1) {\n return [\n {\n rel: 'prev',\n uri: `${collectionPath}?${new URLSearchParams({\n page: pageInt - 1,\n ...otherParameters\n }).toString()}`\n }\n ]\n } else {\n return []\n }\n}\n"],"file":"build-previous-link.js"}
1
+ {"version":3,"file":"build-previous-link.js","sourceRoot":"","sources":["../../src/collections/build-previous-link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,IAAqB,EACrB,YAAgC,EAChC,cAAsB,EACtB,eAAsB;IAEtB,IAAI,IAAI,KAAK,CAAC,EAAE;QACd,OAAO,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC;YAC5C,CAAC,CAAC;gBACA;oBACE,GAAG,EAAE,MAAM;oBACX,GAAG,EAAE,UAAG,cAAc,cAAI,IAAI,eAAe,cACxC,eAAyC,EAC5C,CAAC,QAAQ,EAAE,CAAE;iBAChB;aACF;YACD,CAAC,CAAC;gBACA;oBACE,GAAG,EAAE,MAAM;oBACX,GAAG,EAAE,cAAc;iBACpB;aACF,CAAA;KACJ;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,GAAG,CAAC,EAAE;QAC/C,OAAO;YACL;gBACE,GAAG,EAAE,MAAM;gBACX,GAAG,EAAE,UAAG,cAAc,cAAI,IAAI,eAAe,YAC3C,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,IACvB,eAAe,EAClB,CAAC,QAAQ,EAAE,CAAE;aAChB;SACF,CAAA;KACF;SAAM,IAAI,YAAY,KAAK,SAAS,EAAE;QACrC,OAAO;YACL;gBACE,GAAG,EAAE,MAAM;gBACX,GAAG,EAAE,UAAG,cAAc,cAAI,IAAI,eAAe,YAC3C,IAAI,EAAE,YAAY,IACf,eAAe,EAClB,CAAC,QAAQ,EAAE,CAAE;aAChB;SACF,CAAA;KACF;SAAM;QACL,OAAO,EAAE,CAAA;KACV;AACH,CAAC;AA7CD,8CA6CC"}
@@ -0,0 +1,16 @@
1
+ import { ItemActions } from '../action';
2
+ import { EndPoint } from '../waycharter';
3
+ import { Link } from '../link';
4
+ /**
5
+ * @param array
6
+ * @param arrayPointer
7
+ * @param collectionPointer
8
+ * @param itemEndPoint
9
+ * @param collectionPath
10
+ * @param selfUri
11
+ * @param itemActions
12
+ */
13
+ export declare function builtItemLinks<ItemResponseBody, CanonicalItemActionResponseBody>(collectionPointer: string, itemEndPoint: EndPoint<ItemResponseBody, CanonicalItemActionResponseBody>, selfUri: string, itemActions: ItemActions<CanonicalItemActionResponseBody>): {
14
+ itemLinks: Link[];
15
+ canonicalLinks: Link[];
16
+ };
@@ -1,131 +1,89 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.builtItemLinks = builtItemLinks;
7
-
8
- var _uriTemplateLite = require("uri-template-lite");
9
-
10
- var _methodCanHaveBody = require("../method-can-have-body");
11
-
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 __read = (this && this.__read) || function (o, n) {
25
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26
+ if (!m) return o;
27
+ var i = m.call(o), r, ar = [], e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ }
31
+ catch (error) { e = { error: error }; }
32
+ finally {
33
+ try {
34
+ if (r && !r.done && (m = i["return"])) m.call(i);
35
+ }
36
+ finally { if (e) throw e.error; }
37
+ }
38
+ return ar;
39
+ };
40
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
+ if (ar || !(i in from)) {
43
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
+ ar[i] = from[i];
45
+ }
46
+ }
47
+ return to.concat(ar || Array.prototype.slice.call(from));
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.builtItemLinks = void 0;
51
+ var to_links_1 = require("../to-links");
12
52
  /**
13
53
  * @param array
14
54
  * @param arrayPointer
15
- * @param itemType
55
+ * @param collectionPointer
56
+ * @param itemEndPoint
16
57
  * @param collectionPath
17
58
  * @param selfUri
18
- * @param itemOperations
59
+ * @param itemActions
19
60
  */
20
- function builtItemLinks(array, arrayPointer, itemType, selfUri, itemOperations) {
21
- const itemLinks = [];
22
- const canonicalLinks = [];
23
-
24
- if (array.length === 1) {
25
- itemLinks.push({
26
- rel: 'item',
27
- uri: `${selfUri}#${arrayPointer || ''}/0`
28
- });
29
-
30
- if (itemType) {
31
- canonicalLinks.push({
32
- rel: 'canonical',
33
- uri: itemType.path(array[0]),
34
- anchor: `#${arrayPointer || ''}/0`
35
- });
36
- }
37
-
38
- if (itemOperations) {
39
- for (const relationship in itemOperations) {
40
- const endpoint = itemOperations[relationship];
41
- itemLinks.push(buildLink({
42
- rel: relationship,
43
- uri: endpoint.path(array[0]),
44
- anchor: `#${arrayPointer || ''}/0`,
45
- endpoint,
46
- array,
47
- arrayPointer
48
- }));
49
- }
50
- }
51
- } else if (array.length > 0) {
61
+ function builtItemLinks(collectionPointer, itemEndPoint, selfUri, itemActions) {
62
+ var itemLinks = [];
63
+ var canonicalLinks = [];
52
64
  itemLinks.push({
53
- rel: 'item',
54
- uri: `${selfUri}#${arrayPointer || ''}/{[0..${array.length - 1}]}`
65
+ rel: 'item',
66
+ uri: "#".concat(collectionPointer)
55
67
  });
56
-
57
- if (itemType) {
58
- let pathTemplate = itemType.pathTemplate + '';
59
- const template = new _uriTemplateLite.URI.Template(itemType.pathTemplate);
60
- const parameters = template.match(itemType.pathTemplate);
61
- Object.keys(parameters).forEach(key => {
62
- pathTemplate = pathTemplate.replace(parameters[key], `{this.${key}}`);
63
- });
64
- canonicalLinks.push({
65
- rel: 'canonical',
66
- uri: pathTemplate,
67
- anchor: `#${arrayPointer || ''}/{[0..${array.length - 1}]}`
68
- });
69
- }
70
-
71
- if (itemOperations) {
72
- for (const relationship in itemOperations) {
73
- const endpoint = itemOperations[relationship];
74
- let pathTemplate = endpoint.pathTemplate + '';
75
- const template = new _uriTemplateLite.URI.Template(endpoint.pathTemplate);
76
- const parameters = template.match(endpoint.pathTemplate);
77
- Object.keys(parameters).forEach(key => {
78
- pathTemplate = pathTemplate.replace(parameters[key], `{this.${key}}`);
68
+ if (itemEndPoint) {
69
+ canonicalLinks.push({
70
+ rel: 'canonical',
71
+ uri: itemEndPoint.pathTemplate,
72
+ anchor: "#".concat(collectionPointer)
79
73
  });
80
- itemLinks.push(buildLink({
81
- rel: relationship,
82
- uri: pathTemplate,
83
- anchor: `#${arrayPointer || ''}/{[0..${array.length - 1}]}`,
84
- endpoint,
85
- array,
86
- arrayPointer
87
- }));
88
- }
89
74
  }
90
- }
91
-
92
- return {
93
- itemLinks,
94
- canonicalLinks
95
- };
96
- }
97
- /**
98
- * @param root0
99
- * @param root0.rel
100
- * @param root0.uri
101
- * @param root0.anchor
102
- * @param root0.endpoint
103
- * @param root0.array
104
- * @param root0.arrayPointer
105
- */
106
-
107
-
108
- function buildLink({
109
- rel,
110
- uri,
111
- anchor,
112
- endpoint,
113
- array,
114
- arrayPointer
115
- }) {
116
- return {
117
- rel,
118
- uri,
119
- anchor,
120
- ...(endpoint.method && {
121
- method: endpoint.method
122
- }),
123
- ...((endpoint.parameters || endpoint.bodyParameters) && {
124
- parameters: endpoint.parameters || endpoint.bodyParameters
125
- }),
126
- ...((0, _methodCanHaveBody.methodCanHaveBody)(endpoint.method) && {
127
- accept: ['application/x-www-form-urlencoded', 'application/json', 'multipart/form-data']
128
- })
129
- };
75
+ if (itemActions) {
76
+ itemLinks.push.apply(itemLinks, __spreadArray([], __read((0, to_links_1.toLinks)(itemActions, selfUri, function (action) {
77
+ var anchor = action.anchor, accept = action.accept, other = __rest(action, ["anchor", "accept"]);
78
+ return __assign(__assign({}, other), { anchor: "#".concat(collectionPointer), accept: accept || [
79
+ 'application/json',
80
+ 'application/x-www-form-urlencoded',
81
+ 'multipart/form-data'
82
+ ] // TODO: allow caller to specify accept
83
+ });
84
+ })), false));
85
+ }
86
+ return { itemLinks: itemLinks, canonicalLinks: canonicalLinks };
130
87
  }
88
+ exports.builtItemLinks = builtItemLinks;
131
89
  //# sourceMappingURL=built-item-links.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/built-item-links.js"],"names":["builtItemLinks","array","arrayPointer","itemType","selfUri","itemOperations","itemLinks","canonicalLinks","length","push","rel","uri","path","anchor","relationship","endpoint","buildLink","pathTemplate","template","URI","Template","parameters","match","Object","keys","forEach","key","replace","method","bodyParameters","accept"],"mappings":"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","sourcesContent":["import { URI } from 'uri-template-lite'\nimport { methodCanHaveBody } from '../method-can-have-body'\n\n/**\n * @param array\n * @param arrayPointer\n * @param itemType\n * @param collectionPath\n * @param selfUri\n * @param itemOperations\n */\nexport function builtItemLinks (\n array,\n arrayPointer,\n itemType,\n selfUri,\n itemOperations\n) {\n const itemLinks = []\n const canonicalLinks = []\n if (array.length === 1) {\n itemLinks.push({\n rel: 'item',\n uri: `${selfUri}#${arrayPointer || ''}/0`\n })\n if (itemType) {\n canonicalLinks.push({\n rel: 'canonical',\n uri: itemType.path(array[0]),\n anchor: `#${arrayPointer || ''}/0`\n })\n }\n if (itemOperations) {\n for (const relationship in itemOperations) {\n const endpoint = itemOperations[relationship]\n itemLinks.push(\n buildLink({\n rel: relationship,\n uri: endpoint.path(array[0]),\n anchor: `#${arrayPointer || ''}/0`,\n endpoint,\n array,\n arrayPointer\n })\n )\n }\n }\n } else if (array.length > 0) {\n itemLinks.push({\n rel: 'item',\n uri: `${selfUri}#${arrayPointer || ''}/{[0..${array.length - 1}]}`\n })\n if (itemType) {\n let pathTemplate = itemType.pathTemplate + ''\n const template = new URI.Template(itemType.pathTemplate)\n const parameters = template.match(itemType.pathTemplate)\n Object.keys(parameters).forEach(key => {\n pathTemplate = pathTemplate.replace(parameters[key], `{this.${key}}`)\n })\n canonicalLinks.push({\n rel: 'canonical',\n uri: pathTemplate,\n anchor: `#${arrayPointer || ''}/{[0..${array.length - 1}]}`\n })\n }\n if (itemOperations) {\n for (const relationship in itemOperations) {\n const endpoint = itemOperations[relationship]\n let pathTemplate = endpoint.pathTemplate + ''\n const template = new URI.Template(endpoint.pathTemplate)\n const parameters = template.match(endpoint.pathTemplate)\n Object.keys(parameters).forEach(key => {\n pathTemplate = pathTemplate.replace(parameters[key], `{this.${key}}`)\n })\n itemLinks.push(\n buildLink({\n rel: relationship,\n uri: pathTemplate,\n anchor: `#${arrayPointer || ''}/{[0..${array.length - 1}]}`,\n endpoint,\n array,\n arrayPointer\n })\n )\n }\n }\n }\n return { itemLinks, canonicalLinks }\n}\n/**\n * @param root0\n * @param root0.rel\n * @param root0.uri\n * @param root0.anchor\n * @param root0.endpoint\n * @param root0.array\n * @param root0.arrayPointer\n */\nfunction buildLink ({ rel, uri, anchor, endpoint, array, arrayPointer }) {\n return {\n rel,\n uri,\n anchor,\n ...(endpoint.method && { method: endpoint.method }),\n ...((endpoint.parameters || endpoint.bodyParameters) && {\n parameters: endpoint.parameters || endpoint.bodyParameters\n }),\n ...(methodCanHaveBody(endpoint.method) && {\n accept: [\n 'application/x-www-form-urlencoded',\n 'application/json',\n 'multipart/form-data'\n ]\n })\n }\n}\n"],"file":"built-item-links.js"}
1
+ {"version":3,"file":"built-item-links.js","sourceRoot":"","sources":["../../src/collections/built-item-links.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAAqC;AAKrC;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC5B,iBAAyB,EACzB,YAAyE,EACzE,OAAe,EACf,WAAyD;IAIzD,IAAM,SAAS,GAAG,EAAE,CAAA;IACpB,IAAM,cAAc,GAAG,EAAE,CAAA;IACzB,SAAS,CAAC,IAAI,CAAC;QACb,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,WAAI,iBAAiB,CAAE;KAC7B,CAAC,CAAA;IACF,IAAI,YAAY,EAAE;QAChB,cAAc,CAAC,IAAI,CAAC;YAClB,GAAG,EAAE,WAAW;YAChB,GAAG,EAAE,YAAY,CAAC,YAAY;YAC9B,MAAM,EAAE,WAAI,iBAAiB,CAAE;SAChC,CAAC,CAAA;KACH;IACD,IAAI,WAAW,EAAE;QACf,SAAS,CAAC,IAAI,OAAd,SAAS,2BACJ,IAAA,kBAAO,EAAC,WAAW,EAAE,OAAO,EAAE,UAAA,MAAM;YAC7B,IAAA,MAAM,GAAuB,MAAM,OAA7B,EAAE,MAAM,GAAe,MAAM,OAArB,EAAK,KAAK,UAAK,MAAM,EAArC,oBAA4B,CAAF,CAAW;YAC3C,6BACK,KAAK,KACR,MAAM,EAAE,WAAI,iBAAiB,CAAE,EAC/B,MAAM,EAAE,MAAM,IAAI;oBAChB,kBAAkB;oBAClB,mCAAmC;oBACnC,qBAAqB;iBACtB,CAAC,uCAAuC;gBAC1C;QACH,CAAC,CAAC,WACH;KACF;IACD,OAAO,EAAE,SAAS,WAAA,EAAE,cAAc,gBAAA,EAAE,CAAA;AACtC,CAAC;AAtCD,wCAsCC"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import express from 'express';
3
+ import { Query, ParamsDictionary } from 'express-serve-static-core';
4
+ import { IncomingHttpHeaders } from 'http';
5
+ export declare type HandlerParameters<ResponseBody> = {
6
+ pathParameters: ParamsDictionary;
7
+ queryParameters: Query;
8
+ requestHeaders: IncomingHttpHeaders;
9
+ request: express.Request;
10
+ response: express.Response<ResponseBody>;
11
+ next: express.NextFunction;
12
+ };
13
+ export declare type Handler<ResponseBody> = (parameters: HandlerParameters<ResponseBody>) => Promise<void> | void;
14
+ export declare type CollectionHandlerParameters<ResponseBody> = HandlerParameters<ResponseBody> & {
15
+ page: number | string;
16
+ };
17
+ export declare type CollectionHandler<ResponseBody> = (parameters: CollectionHandlerParameters<ResponseBody>) => Promise<void> | void;
18
+ export declare type ActionHandlerParameters<ResponseBody> = Omit<HandlerParameters<ResponseBody>, 'requestHeaders'> & {
19
+ bodyParameters: Record<string, unknown>;
20
+ };
21
+ export declare type ActionHandler<ResponseBody> = (parameters: ActionHandlerParameters<ResponseBody>) => Promise<void> | void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":""}
package/dist/link.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { Method } from './method';
2
+ export declare type BaseLink = {
3
+ rel: string;
4
+ uri: string;
5
+ anchor?: string;
6
+ hreflang?: string;
7
+ media?: string;
8
+ title?: string;
9
+ 'title*'?: string;
10
+ type?: string;
11
+ parameters?: Array<string> | {
12
+ [key: string]: {};
13
+ };
14
+ accept?: Array<string>;
15
+ method?: Method;
16
+ };
17
+ export declare type Link = BaseLink & Record<string, any>;
package/dist/link.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":""}