@outfoxx/sunday 1.1.0-alpha.8 → 1.1.0-beta.1

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 (123) hide show
  1. package/LICENSE.txt +203 -0
  2. package/README.md +6 -7
  3. package/dist/any-type.js +13 -0
  4. package/dist/any-type.js.map +1 -1
  5. package/dist/class-type.js +13 -0
  6. package/dist/class-type.js.map +1 -1
  7. package/dist/date-time-types.js +13 -0
  8. package/dist/date-time-types.js.map +1 -1
  9. package/dist/event-parser.d.ts +1 -1
  10. package/dist/event-parser.js +17 -4
  11. package/dist/event-parser.js.map +1 -1
  12. package/dist/fetch-event-source.d.ts +5 -1
  13. package/dist/fetch-event-source.js +15 -3
  14. package/dist/fetch-event-source.js.map +1 -1
  15. package/dist/fetch-request-factory.d.ts +3 -0
  16. package/dist/fetch-request-factory.js +47 -9
  17. package/dist/fetch-request-factory.js.map +1 -1
  18. package/dist/fetch.js +24 -5
  19. package/dist/fetch.js.map +1 -1
  20. package/dist/header-parameters.js +13 -0
  21. package/dist/header-parameters.js.map +1 -1
  22. package/dist/index.js +13 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/logger.js +13 -0
  25. package/dist/logger.js.map +1 -1
  26. package/dist/media-type-codecs/any-text-decoder.d.ts +7 -0
  27. package/dist/media-type-codecs/any-text-decoder.js +29 -0
  28. package/dist/media-type-codecs/any-text-decoder.js.map +1 -0
  29. package/dist/media-type-codecs/any-text-encoder.d.ts +5 -0
  30. package/dist/media-type-codecs/any-text-encoder.js +23 -0
  31. package/dist/media-type-codecs/any-text-encoder.js.map +1 -0
  32. package/dist/media-type-codecs/binary-decoder.js +13 -0
  33. package/dist/media-type-codecs/binary-decoder.js.map +1 -1
  34. package/dist/media-type-codecs/binary-encoder.js +13 -0
  35. package/dist/media-type-codecs/binary-encoder.js.map +1 -1
  36. package/dist/media-type-codecs/cbor-decoder.js +13 -0
  37. package/dist/media-type-codecs/cbor-decoder.js.map +1 -1
  38. package/dist/media-type-codecs/cbor-encoder.js +13 -0
  39. package/dist/media-type-codecs/cbor-encoder.js.map +1 -1
  40. package/dist/media-type-codecs/cbor-tags.js +13 -0
  41. package/dist/media-type-codecs/cbor-tags.js.map +1 -1
  42. package/dist/media-type-codecs/json-decoder.js +13 -0
  43. package/dist/media-type-codecs/json-decoder.js.map +1 -1
  44. package/dist/media-type-codecs/json-encoder.js +13 -0
  45. package/dist/media-type-codecs/json-encoder.js.map +1 -1
  46. package/dist/media-type-codecs/media-type-decoder.js +13 -0
  47. package/dist/media-type-codecs/media-type-decoder.js.map +1 -1
  48. package/dist/media-type-codecs/media-type-decoders.js +21 -3
  49. package/dist/media-type-codecs/media-type-decoders.js.map +1 -1
  50. package/dist/media-type-codecs/media-type-encoder.js +13 -0
  51. package/dist/media-type-codecs/media-type-encoder.js.map +1 -1
  52. package/dist/media-type-codecs/media-type-encoders.js +21 -3
  53. package/dist/media-type-codecs/media-type-encoders.js.map +1 -1
  54. package/dist/media-type-codecs/www-form-url-encoder.js +56 -6
  55. package/dist/media-type-codecs/www-form-url-encoder.js.map +1 -1
  56. package/dist/media-type.d.ts +4 -2
  57. package/dist/media-type.js +34 -5
  58. package/dist/media-type.js.map +1 -1
  59. package/dist/problem.js +19 -2
  60. package/dist/problem.js.map +1 -1
  61. package/dist/request-factory.d.ts +6 -0
  62. package/dist/request-factory.js +13 -0
  63. package/dist/request-factory.js.map +1 -1
  64. package/dist/result-response.d.ts +4 -0
  65. package/dist/result-response.js +15 -0
  66. package/dist/result-response.js.map +1 -0
  67. package/dist/sunday-error.js +13 -0
  68. package/dist/sunday-error.js.map +1 -1
  69. package/dist/url-template.js +13 -0
  70. package/dist/url-template.js.map +1 -1
  71. package/dist/util/any.js +13 -0
  72. package/dist/util/any.js.map +1 -1
  73. package/dist/util/base64.js +13 -0
  74. package/dist/util/base64.js.map +1 -1
  75. package/dist/util/error.d.ts +2 -0
  76. package/dist/util/error.js +26 -0
  77. package/dist/util/error.js.map +1 -0
  78. package/dist/util/hex.js +13 -0
  79. package/dist/util/hex.js.map +1 -1
  80. package/dist/util/rxjs.js +14 -2
  81. package/dist/util/rxjs.js.map +1 -1
  82. package/dist/util/stream-rxjs.js +13 -0
  83. package/dist/util/stream-rxjs.js.map +1 -1
  84. package/dist/util/temporal.js +13 -0
  85. package/dist/util/temporal.js.map +1 -1
  86. package/package.json +33 -28
  87. package/src/any-type.ts +14 -0
  88. package/src/class-type.ts +16 -2
  89. package/src/date-time-types.ts +14 -0
  90. package/src/event-parser.ts +22 -10
  91. package/src/fetch-event-source.ts +39 -11
  92. package/src/fetch-request-factory.ts +92 -32
  93. package/src/fetch.ts +27 -8
  94. package/src/header-parameters.ts +16 -2
  95. package/src/index.ts +14 -0
  96. package/src/logger.ts +14 -0
  97. package/src/media-type-codecs/any-text-decoder.ts +34 -0
  98. package/src/media-type-codecs/any-text-encoder.ts +26 -0
  99. package/src/media-type-codecs/binary-decoder.ts +16 -2
  100. package/src/media-type-codecs/binary-encoder.ts +15 -1
  101. package/src/media-type-codecs/cbor-decoder.ts +30 -16
  102. package/src/media-type-codecs/cbor-encoder.ts +28 -14
  103. package/src/media-type-codecs/cbor-tags.ts +14 -0
  104. package/src/media-type-codecs/json-decoder.ts +31 -16
  105. package/src/media-type-codecs/json-encoder.ts +21 -7
  106. package/src/media-type-codecs/media-type-decoder.ts +16 -2
  107. package/src/media-type-codecs/media-type-decoders.ts +28 -8
  108. package/src/media-type-codecs/media-type-encoder.ts +19 -5
  109. package/src/media-type-codecs/media-type-encoders.ts +28 -8
  110. package/src/media-type-codecs/www-form-url-encoder.ts +81 -17
  111. package/src/media-type.ts +46 -12
  112. package/src/problem.ts +22 -4
  113. package/src/request-factory.ts +46 -7
  114. package/src/result-response.ts +18 -0
  115. package/src/sunday-error.ts +18 -4
  116. package/src/url-template.ts +15 -1
  117. package/src/util/any.ts +14 -0
  118. package/src/util/base64.ts +15 -1
  119. package/src/util/error.ts +28 -0
  120. package/src/util/hex.ts +14 -0
  121. package/src/util/rxjs.ts +18 -5
  122. package/src/util/stream-rxjs.ts +15 -1
  123. package/src/util/temporal.ts +14 -0
@@ -0,0 +1,26 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export function isError(value) {
15
+ return value instanceof Error;
16
+ }
17
+ export function errorToMessage(value, defMsg) {
18
+ return isError(value) ? value.message : defMsg !== null && defMsg !== void 0 ? defMsg : `${fmtMsg(value)}`;
19
+ }
20
+ function fmtMsg(value) {
21
+ if (value instanceof Object) {
22
+ return JSON.stringify(value);
23
+ }
24
+ return `${value}`;
25
+ }
26
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/util/error.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,MAAe;IAC5D,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,YAAY,MAAM,EAAE;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,KAAK,EAAE,CAAC;AACpB,CAAC"}
package/dist/util/hex.js CHANGED
@@ -1,3 +1,16 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
1
14
  export var Hex;
2
15
  (function (Hex) {
3
16
  function decode(hex) {
@@ -1 +1 @@
1
- {"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/util/hex.ts"],"names":[],"mappings":"AAAA,MAAM,KAAW,GAAG,CAenB;AAfD,WAAiB,GAAG;IAClB,SAAgB,MAAM,CAAC,GAAW;QAChC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9C,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACnC;QACD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CA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AC;IACnE,CAAC;IAPe,UAAM,SAOrB,CAAA;IAED,SAAgB,MAAM,CAAC,MAAmB,EAAE,SAAS,GAAG,EAAE;QACxD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;aACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aACnD,IAAI,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAJe,UAAM,SAIrB,CAAA;AACH,CAAC,EAfgB,GAAG,KAAH,GAAG,QAenB"}
package/dist/util/rxjs.js CHANGED
@@ -1,5 +1,17 @@
1
- import { from, throwError } from 'rxjs';
2
- import { catchError } from 'rxjs/operators';
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { catchError, from, throwError } from 'rxjs';
3
15
  import { Problem } from '../problem';
4
16
  export function nullifyNotFound() {
5
17
  return nullifyResponse([404], []);
@@ -1 +1 @@
1
- {"version":3,"file":"rxjs.js","sourceRoot":"","sources":["../../src/util/rxjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,UAAU,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,UAAU,eAAe;IAG7B,OAAO,eAAe,CAAC,CAAC,G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;YAC1D,IACE,KAAK,YAAY,OAAO;gBACxB,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EACrE;gBACA,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;aACrB;YACD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,16 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
1
14
  import { Observable } from 'rxjs';
2
15
  export function fromStream(stream) {
3
16
  return new Observable((subscriber) => {
@@ -1 +1 @@
1
- {"version":3,"file":"stream-rxjs.js","sourceRoot":"","sources":["../../src/util/stream-rxjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,UAAU,UAAU,CACxB,MAAkC;IAElC,OAAO,IAAI,UAAU,CAAC,CAAC,UAAU,EAAE,EAAE;QACnC,IAAI,MAA+C,CAAC;QACpD,CAAC,KAAK,UAAU,QAAQ;YACtB,IAAI;gBACF,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;gBAC5B,OAAO,IAAI,EAAE;oBACX,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;oBAC5C,IAAI,KAAK,KAAK,SAAS,EAAE;wBACvB,UAAU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,CAAC,CAAC,CAAC;aACrB;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,GAAG,EAAE,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,16 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
1
14
  export function secondsToNumber(seconds, nanos) {
2
15
  if (nanos == 0) {
3
16
  return seconds;
@@ -1 +1 @@
1
- {"version":3,"file":"temporal.js","sourceRoot":"","sources":["../../src/util/temporal.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,KAAa;IAC5D,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,OAAO,UAAU,CAAC,GAAG,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,OAAO,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE;QACjC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACvB;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"temporal.js","sourceRoot":"","sources":["../../src/util/temporal.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,KAAa;IAC5D,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,OAAO,UAAU,CAAC,GAAG,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,OAAO,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE;QACjC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACvB;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outfoxx/sunday",
3
- "version": "1.1.0-alpha.8",
3
+ "version": "1.1.0-beta.1",
4
4
  "description": "Sunday 🙏 The framework of REST for TypeScript/JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,8 +11,9 @@
11
11
  "build": "tsc --build tsconfig.dist.json",
12
12
  "clean": "rimraf build dist",
13
13
  "prepublishOnly": "npm run clean && npm run lint && npm run build && npm run test",
14
- "lint": "eslint src test",
15
- "pretty": "prettier src test"
14
+ "lint": "eslint -f json -o reports/lint.json src test",
15
+ "pretty": "prettier src test",
16
+ "docs": "typedoc --excludeInternal --excludePrivate src/index.ts"
16
17
  },
17
18
  "husky": {
18
19
  "hooks": {
@@ -26,45 +27,49 @@
26
27
  },
27
28
  "keywords": [],
28
29
  "author": "kdubb",
29
- "license": "outfox",
30
+ "license": "Apache-2.0",
30
31
  "dependencies": {
31
- "@js-joda/core": "^3.2.0",
32
- "@outfoxx/cbor-redux": "^0.3.1",
33
- "@outfoxx/jackson-js": "^1.2.22",
34
- "common-tags": "^1.8.0",
35
- "rxjs": "^6.6.3",
36
- "uri-template-lite": "^20.5.0"
32
+ "@js-joda/core": "5.2.x",
33
+ "@outfoxx/cbor-redux": "0.3.x",
34
+ "@outfoxx/jackson-js": "1.4.x",
35
+ "common-tags": "1.8.x",
36
+ "tslib": "2.4.x",
37
+ "uri-template-lite": "^22.9.0"
38
+ },
39
+ "peerDependencies": {
40
+ "rxjs": "7.x"
37
41
  },
38
42
  "devDependencies": {
39
- "@types/common-tags": "^1.8.0",
40
- "@types/eslint": "^7.2.2",
41
- "@types/eslint-plugin-prettier": "^3.1.0",
42
- "@types/jasmine": "^3.5.14",
43
- "@types/uri-template-lite": "^19.12.0",
44
- "@typescript-eslint/eslint-plugin": "^4.25.0",
45
- "@typescript-eslint/parser": "^4.25.0",
46
- "eslint": "^7.27.0",
47
- "eslint-config-prettier": "^6.15.0",
48
- "eslint-plugin-prettier": "^3.4.0",
43
+ "@types/common-tags": "1.8.x",
44
+ "@types/jasmine": "4.0.x",
45
+ "@types/uri-template-lite": "19.12.x",
46
+ "@typescript-eslint/eslint-plugin": "^5.25.0",
47
+ "@typescript-eslint/parser": "^5.25.0",
48
+ "eslint": "^8.15.0",
49
+ "eslint-config-prettier": "^8.5.0",
50
+ "eslint-plugin-header": "^3.1.1",
51
+ "eslint-plugin-prettier": "^4.0.0",
49
52
  "fetch-mock": "^9.11.0",
50
53
  "fsevents": "^2.1.3",
51
54
  "husky": "^4.3.0",
52
55
  "install": "^0.13.0",
53
- "karma": "^6.3.2",
54
- "karma-chrome-launcher": "^3.1.0",
56
+ "karma": "^6.3.20",
57
+ "karma-chrome-launcher": "^3.1.1",
55
58
  "karma-cli": "^2.0.0",
56
- "karma-coverage": "^2.0.3",
57
- "karma-jasmine": "^4.0.1",
59
+ "karma-coverage": "^2.2.0",
60
+ "karma-jasmine": "^5.0.1",
61
+ "karma-junit-reporter": "^2.0.1",
62
+ "karma-sonarqube-unit-reporter": "^0.0.23",
58
63
  "karma-source-map-support": "^1.4.0",
59
64
  "karma-sourcemap-loader": "^0.3.8",
60
- "karma-typescript": "^5.5.1",
61
- "karma-typescript-es6-transform": "^5.5.1",
65
+ "karma-typescript": "^5.5.3",
66
+ "karma-typescript-es6-transform": "^5.5.3",
62
67
  "lint-staged": "^10.4.0",
63
- "npm": "^7.13.0",
64
68
  "prettier": "^2.1.2",
65
69
  "pretty-quick": "^3.0.2",
66
70
  "rimraf": "^3.0.2",
67
- "typescript": "~4.2",
71
+ "typedoc": "^0.22.18",
72
+ "typescript": "~4.4",
68
73
  "web-streams-polyfill": "^3.0.0"
69
74
  },
70
75
  "files": [
package/src/any-type.ts CHANGED
@@ -1,3 +1,17 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
1
15
  import { ClassList, ClassType } from '@outfoxx/jackson-js/dist/@types';
2
16
  import { ConstructableClassType } from './class-type';
3
17
 
package/src/class-type.ts CHANGED
@@ -1,7 +1,21 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
1
15
  export type ClassType<T> =
2
- | (abstract new () => T) // eslint-disable-line prettier/prettier
16
+ | (abstract new () => T)
3
17
  | (abstract new (...args: any[]) => T); // eslint-disable-line @typescript-eslint/no-explicit-any
4
18
 
5
19
  export declare type ConstructableClassType<T> =
6
- | (new () => T) // eslint-disable-line prettier/prettier
20
+ | (new () => T)
7
21
  | (new (...args: any[]) => T); // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -1,3 +1,17 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
1
15
  import {
2
16
  Duration,
3
17
  Instant,
@@ -1,3 +1,17 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
1
15
  export interface EventInfo {
2
16
  id?: string;
3
17
  event?: string;
@@ -11,7 +25,7 @@ export class EventParser {
11
25
 
12
26
  process(
13
27
  buffer: ArrayBuffer,
14
- dispatcher: (eventInfo: EventInfo) => void
28
+ dispatcher: (eventInfo: EventInfo) => void,
15
29
  ): void {
16
30
  const availableBuffer = this.buildAvailableBuffer(buffer);
17
31
  if (!availableBuffer) {
@@ -38,7 +52,7 @@ export class EventParser {
38
52
  }
39
53
 
40
54
  const newBuffer = new Uint8Array(
41
- unprocessedBuffer.byteLength + buffer.byteLength
55
+ unprocessedBuffer.byteLength + buffer.byteLength,
42
56
  );
43
57
  newBuffer.set(new Uint8Array(unprocessedBuffer), 0);
44
58
  newBuffer.set(new Uint8Array(buffer), unprocessedBuffer.byteLength);
@@ -51,7 +65,7 @@ export class EventParser {
51
65
 
52
66
  while (buffer.byteLength) {
53
67
  // Find end of next event separator in buffer, exiting if none found.
54
- const eventSeparator = this.findEventSeparator(buffer);
68
+ const eventSeparator = EventParser.findEventSeparator(buffer);
55
69
  if (!eventSeparator) {
56
70
  // Save unprocessed data
57
71
  this.unprocessedBuffer = buffer;
@@ -73,8 +87,8 @@ export class EventParser {
73
87
  return eventStrings;
74
88
  }
75
89
 
76
- private findEventSeparator(
77
- buffer: ArrayBuffer
90
+ private static findEventSeparator(
91
+ buffer: ArrayBuffer,
78
92
  ): [number, number] | undefined {
79
93
  const bytes = new Uint8Array(buffer);
80
94
 
@@ -114,7 +128,6 @@ export class EventParser {
114
128
  }
115
129
 
116
130
  default:
117
- continue;
118
131
  }
119
132
  }
120
133
  return undefined;
@@ -122,7 +135,7 @@ export class EventParser {
122
135
 
123
136
  private static parseAndDispatchEvents(
124
137
  eventStrings: string[],
125
- dispatcher: (eventInfo: EventInfo) => void
138
+ dispatcher: (eventInfo: EventInfo) => void,
126
139
  ) {
127
140
  for (const eventString of eventStrings) {
128
141
  if (!eventString.length) {
@@ -167,9 +180,8 @@ export class EventParser {
167
180
  break;
168
181
 
169
182
  default: {
170
- (event as Record<string, string>)[key] = EventParser.trimFieldValue(
171
- value
172
- );
183
+ (event as Record<string, string>)[key] =
184
+ EventParser.trimFieldValue(value);
173
185
  }
174
186
  }
175
187
  }
@@ -1,13 +1,41 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { EMPTY, map, Observable, of, Subscription, switchMap, tap } from 'rxjs';
1
16
  import { EventInfo, EventParser } from './event-parser';
2
- import { EMPTY, Observable, of, Subscription } from 'rxjs';
3
- import { map, switchMap, tap } from 'rxjs/operators';
4
- import { unknownSet } from './util/any';
5
17
  import { validate } from './fetch';
6
18
  import { Logger } from './logger';
7
19
  import { MediaType } from './media-type';
8
20
  import { ExtEventSource } from './request-factory';
21
+ import { unknownSet } from './util/any';
9
22
  import { fromStream } from './util/stream-rxjs';
10
23
 
24
+ export interface FetchEventSource {
25
+ addEventListener<K extends keyof EventSourceEventMap>(
26
+ type: K,
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
29
+ options?: boolean | AddEventListenerOptions,
30
+ ): void;
31
+ removeEventListener<K extends keyof EventSourceEventMap>(
32
+ type: K,
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
35
+ options?: boolean | EventListenerOptions,
36
+ ): void;
37
+ }
38
+
11
39
  export class FetchEventSource extends EventTarget implements ExtEventSource {
12
40
  private static LAST_EVENT_ID_HEADER = 'Last-Event-ID';
13
41
  private static MAX_RETRY_TIME_MULTIPLE = 30;
@@ -31,7 +59,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
31
59
 
32
60
  private adapter: (
33
61
  url: string,
34
- requestInit: RequestInit
62
+ requestInit: RequestInit,
35
63
  ) => Observable<Request>;
36
64
  private connectionSubscription?: Subscription;
37
65
  private internalRetryTime = 100;
@@ -45,7 +73,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
45
73
  private eventTimeoutCheckHandle?: number;
46
74
  private lastEventReceivedTime = 0;
47
75
  private eventParser = new EventParser();
48
- private externalAbortController?: AbortController;
76
+ private readonly externalAbortController?: AbortController;
49
77
 
50
78
  constructor(
51
79
  url: string,
@@ -54,7 +82,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
54
82
  eventTimeout?: number;
55
83
  logger?: Logger;
56
84
  abortController?: AbortController;
57
- }
85
+ },
58
86
  ) {
59
87
  super();
60
88
  this.url = url;
@@ -118,7 +146,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
118
146
 
119
147
  return fromStream(body);
120
148
  }),
121
- map((value) => this.receivedData(value))
149
+ map((value) => this.receivedData(value)),
122
150
  )
123
151
  .subscribe({
124
152
  error: (error: unknown) => {
@@ -171,7 +199,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
171
199
 
172
200
  this.eventTimeoutCheckHandle = window.setInterval(
173
201
  () => this.checkEventTimeout(),
174
- FetchEventSource.EVENT_TIMEOUT_CHECK_INTERVAL * 1000
202
+ FetchEventSource.EVENT_TIMEOUT_CHECK_INTERVAL * 1000,
175
203
  );
176
204
  }
177
205
 
@@ -286,7 +314,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
286
314
  const backOffDelay = Math.pow(this.retryAttempt, 2) * this.retryTime;
287
315
  let retryDelay = Math.min(
288
316
  this.retryTime + backOffDelay,
289
- this.retryTime * FetchEventSource.MAX_RETRY_TIME_MULTIPLE
317
+ this.retryTime * FetchEventSource.MAX_RETRY_TIME_MULTIPLE,
290
318
  );
291
319
 
292
320
  // Adjust delay by amount of time last connect
@@ -305,7 +333,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
305
333
 
306
334
  this.reconnectTimeoutHandle = window.setTimeout(
307
335
  () => this.internalConnect(),
308
- retryDelay
336
+ retryDelay,
309
337
  );
310
338
  }
311
339
 
@@ -354,7 +382,7 @@ export class FetchEventSource extends EventTarget implements ExtEventSource {
354
382
  this.lastEventId = eventInfo.id;
355
383
  } else {
356
384
  this.logger?.debug?.(
357
- 'event id contains null, unable to use for last-event-id'
385
+ 'event id contains null, unable to use for last-event-id',
358
386
  );
359
387
  }
360
388
  }