@outfoxx/sunday 1.0.8 → 1.0.10

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 (234) hide show
  1. package/LICENSE.txt +203 -0
  2. package/README.md +36 -2
  3. package/build/date-time-types.d.ts +35 -0
  4. package/build/date-time-types.js +699 -0
  5. package/build/date-time-types.js.map +1 -0
  6. package/build/event-parser.d.ts +17 -0
  7. package/build/event-parser.js +151 -0
  8. package/build/event-parser.js.map +1 -0
  9. package/build/fetch-event-source.d.ts +66 -0
  10. package/build/fetch-event-source.js +365 -0
  11. package/build/fetch-event-source.js.map +1 -0
  12. package/build/fetch-request-factory.d.ts +32 -0
  13. package/build/fetch-request-factory.js +316 -0
  14. package/build/fetch-request-factory.js.map +1 -0
  15. package/build/fetch.d.ts +9 -0
  16. package/build/fetch.js +140 -0
  17. package/build/fetch.js.map +1 -0
  18. package/build/header-parameters.d.ts +3 -0
  19. package/build/header-parameters.js +82 -0
  20. package/build/header-parameters.js.map +1 -0
  21. package/build/index.d.ts +26 -0
  22. package/build/index.js +41 -0
  23. package/build/index.js.map +1 -0
  24. package/{dist → build}/logger.d.ts +9 -0
  25. package/build/logger.js +36 -0
  26. package/build/logger.js.map +1 -0
  27. package/build/media-type-codecs/any-text-decoder.d.ts +7 -0
  28. package/build/media-type-codecs/any-text-decoder.js +29 -0
  29. package/build/media-type-codecs/any-text-decoder.js.map +1 -0
  30. package/build/media-type-codecs/any-text-encoder.d.ts +6 -0
  31. package/build/media-type-codecs/any-text-encoder.js +27 -0
  32. package/build/media-type-codecs/any-text-encoder.js.map +1 -0
  33. package/build/media-type-codecs/binary-decoder.d.ts +7 -0
  34. package/build/media-type-codecs/binary-decoder.js +33 -0
  35. package/build/media-type-codecs/binary-decoder.js.map +1 -0
  36. package/build/media-type-codecs/binary-encoder.d.ts +6 -0
  37. package/build/media-type-codecs/binary-encoder.js +30 -0
  38. package/build/media-type-codecs/binary-encoder.js.map +1 -0
  39. package/build/media-type-codecs/cbor-decoder.d.ts +13 -0
  40. package/build/media-type-codecs/cbor-decoder.js +38 -0
  41. package/build/media-type-codecs/cbor-decoder.js.map +1 -0
  42. package/build/media-type-codecs/cbor-encoder.d.ts +12 -0
  43. package/build/media-type-codecs/cbor-encoder.js +36 -0
  44. package/build/media-type-codecs/cbor-encoder.js.map +1 -0
  45. package/build/media-type-codecs/cbor-tags.d.ts +6 -0
  46. package/build/media-type-codecs/cbor-tags.js +20 -0
  47. package/build/media-type-codecs/cbor-tags.js.map +1 -0
  48. package/build/media-type-codecs/default-policies.d.ts +3 -0
  49. package/build/media-type-codecs/default-policies.js +33 -0
  50. package/build/media-type-codecs/default-policies.js.map +1 -0
  51. package/build/media-type-codecs/json-decoder.d.ts +14 -0
  52. package/build/media-type-codecs/json-decoder.js +40 -0
  53. package/build/media-type-codecs/json-decoder.js.map +1 -0
  54. package/build/media-type-codecs/json-encoder.d.ts +13 -0
  55. package/build/media-type-codecs/json-encoder.js +43 -0
  56. package/build/media-type-codecs/json-encoder.js.map +1 -0
  57. package/build/media-type-codecs/media-type-decoder.d.ts +14 -0
  58. package/build/media-type-codecs/media-type-decoder.js +18 -0
  59. package/build/media-type-codecs/media-type-decoder.js.map +1 -0
  60. package/build/media-type-codecs/media-type-decoders.d.ts +16 -0
  61. package/build/media-type-codecs/media-type-decoders.js +63 -0
  62. package/build/media-type-codecs/media-type-decoders.js.map +1 -0
  63. package/build/media-type-codecs/media-type-encoder.d.ts +12 -0
  64. package/build/media-type-codecs/media-type-encoder.js +22 -0
  65. package/build/media-type-codecs/media-type-encoder.js.map +1 -0
  66. package/build/media-type-codecs/media-type-encoders.d.ts +16 -0
  67. package/build/media-type-codecs/media-type-encoders.js +65 -0
  68. package/build/media-type-codecs/media-type-encoders.js.map +1 -0
  69. package/build/media-type-codecs/www-form-url-encoder.d.ts +31 -0
  70. package/build/media-type-codecs/www-form-url-encoder.js +281 -0
  71. package/build/media-type-codecs/www-form-url-encoder.js.map +1 -0
  72. package/build/media-type.d.ts +94 -0
  73. package/build/media-type.js +305 -0
  74. package/build/media-type.js.map +1 -0
  75. package/build/problem.d.ts +35 -0
  76. package/build/problem.js +122 -0
  77. package/build/problem.js.map +1 -0
  78. package/build/request-adapters.d.ts +23 -0
  79. package/build/request-adapters.js +53 -0
  80. package/build/request-adapters.js.map +1 -0
  81. package/build/request-factory.d.ts +39 -0
  82. package/build/request-factory.js +15 -0
  83. package/build/request-factory.js.map +1 -0
  84. package/build/result-response.d.ts +4 -0
  85. package/build/result-response.js +15 -0
  86. package/build/result-response.js.map +1 -0
  87. package/build/schema-builtins.d.ts +21 -0
  88. package/build/schema-builtins.js +201 -0
  89. package/build/schema-builtins.js.map +1 -0
  90. package/build/schema-policy.d.ts +31 -0
  91. package/build/schema-policy.js +41 -0
  92. package/build/schema-policy.js.map +1 -0
  93. package/build/schema-runtime.d.ts +25 -0
  94. package/build/schema-runtime.js +77 -0
  95. package/build/schema-runtime.js.map +1 -0
  96. package/build/sunday-error.d.ts +10 -0
  97. package/build/sunday-error.js +36 -0
  98. package/build/sunday-error.js.map +1 -0
  99. package/build/url-template.js +33 -0
  100. package/build/url-template.js.map +1 -0
  101. package/build/util/async-iterables.d.ts +15 -0
  102. package/build/util/async-iterables.js +179 -0
  103. package/build/util/async-iterables.js.map +1 -0
  104. package/build/util/errors.d.ts +2 -0
  105. package/build/util/errors.js +65 -0
  106. package/build/util/errors.js.map +1 -0
  107. package/build/util/nullify.d.ts +5 -0
  108. package/build/util/nullify.js +37 -0
  109. package/build/util/nullify.js.map +1 -0
  110. package/build/util/numbers.d.ts +11 -0
  111. package/build/util/numbers.js +41 -0
  112. package/build/util/numbers.js.map +1 -0
  113. package/build/util/subscriptions.d.ts +16 -0
  114. package/build/util/subscriptions.js +78 -0
  115. package/build/util/subscriptions.js.map +1 -0
  116. package/build/util/unknowns.d.ts +2 -0
  117. package/build/util/unknowns.js +23 -0
  118. package/build/util/unknowns.js.map +1 -0
  119. package/package.json +72 -49
  120. package/dist/any-type.d.ts +0 -2
  121. package/dist/any-type.js +0 -2
  122. package/dist/any-type.js.map +0 -1
  123. package/dist/binary-decoder.d.ts +0 -6
  124. package/dist/binary-decoder.js +0 -16
  125. package/dist/binary-decoder.js.map +0 -1
  126. package/dist/binary-encoder.d.ts +0 -5
  127. package/dist/binary-encoder.js +0 -13
  128. package/dist/binary-encoder.js.map +0 -1
  129. package/dist/cbor-decoder.d.ts +0 -15
  130. package/dist/cbor-decoder.js +0 -126
  131. package/dist/cbor-decoder.js.map +0 -1
  132. package/dist/cbor-encoder.d.ts +0 -29
  133. package/dist/cbor-encoder.js +0 -81
  134. package/dist/cbor-encoder.js.map +0 -1
  135. package/dist/cbor-tags.d.ts +0 -3
  136. package/dist/cbor-tags.js +0 -4
  137. package/dist/cbor-tags.js.map +0 -1
  138. package/dist/class-type.d.ts +0 -2
  139. package/dist/class-type.js +0 -2
  140. package/dist/class-type.js.map +0 -1
  141. package/dist/date-time-types.d.ts +0 -7
  142. package/dist/date-time-types.js +0 -5
  143. package/dist/date-time-types.js.map +0 -1
  144. package/dist/fetch-event-source.d.ts +0 -52
  145. package/dist/fetch-event-source.js +0 -271
  146. package/dist/fetch-event-source.js.map +0 -1
  147. package/dist/fetch-request-factory.d.ts +0 -26
  148. package/dist/fetch-request-factory.js +0 -125
  149. package/dist/fetch-request-factory.js.map +0 -1
  150. package/dist/fetch.d.ts +0 -1
  151. package/dist/fetch.js +0 -19
  152. package/dist/fetch.js.map +0 -1
  153. package/dist/http-error.d.ts +0 -10
  154. package/dist/http-error.js +0 -45
  155. package/dist/http-error.js.map +0 -1
  156. package/dist/index.d.ts +0 -25
  157. package/dist/index.js +0 -26
  158. package/dist/index.js.map +0 -1
  159. package/dist/json-decoder.d.ts +0 -31
  160. package/dist/json-decoder.js +0 -139
  161. package/dist/json-decoder.js.map +0 -1
  162. package/dist/json-encoder.d.ts +0 -35
  163. package/dist/json-encoder.js +0 -116
  164. package/dist/json-encoder.js.map +0 -1
  165. package/dist/logger.js +0 -2
  166. package/dist/logger.js.map +0 -1
  167. package/dist/media-type-decoder.d.ts +0 -4
  168. package/dist/media-type-decoder.js +0 -2
  169. package/dist/media-type-decoder.js.map +0 -1
  170. package/dist/media-type-decoders.d.ts +0 -17
  171. package/dist/media-type-decoders.js +0 -40
  172. package/dist/media-type-decoders.js.map +0 -1
  173. package/dist/media-type-encoder.d.ts +0 -8
  174. package/dist/media-type-encoder.js +0 -6
  175. package/dist/media-type-encoder.js.map +0 -1
  176. package/dist/media-type-encoders.d.ts +0 -17
  177. package/dist/media-type-encoders.js +0 -42
  178. package/dist/media-type-encoders.js.map +0 -1
  179. package/dist/media-type.d.ts +0 -14
  180. package/dist/media-type.js +0 -18
  181. package/dist/media-type.js.map +0 -1
  182. package/dist/problem.d.ts +0 -16
  183. package/dist/problem.js +0 -11
  184. package/dist/problem.js.map +0 -1
  185. package/dist/request-factory.d.ts +0 -38
  186. package/dist/request-factory.js +0 -2
  187. package/dist/request-factory.js.map +0 -1
  188. package/dist/url-encoder.d.ts +0 -59
  189. package/dist/url-encoder.js +0 -141
  190. package/dist/url-encoder.js.map +0 -1
  191. package/dist/url-template.js +0 -18
  192. package/dist/url-template.js.map +0 -1
  193. package/dist/util/base64.d.ts +0 -5
  194. package/dist/util/base64.js +0 -64
  195. package/dist/util/base64.js.map +0 -1
  196. package/dist/util/hex.d.ts +0 -4
  197. package/dist/util/hex.js +0 -18
  198. package/dist/util/hex.js.map +0 -1
  199. package/dist/util/rxjs.d.ts +0 -2
  200. package/dist/util/rxjs.js +0 -14
  201. package/dist/util/rxjs.js.map +0 -1
  202. package/dist/util/stream-rxjs.d.ts +0 -2
  203. package/dist/util/stream-rxjs.js +0 -26
  204. package/dist/util/stream-rxjs.js.map +0 -1
  205. package/src/any-type.ts +0 -4
  206. package/src/binary-decoder.ts +0 -24
  207. package/src/binary-encoder.ts +0 -19
  208. package/src/cbor-decoder.ts +0 -148
  209. package/src/cbor-encoder.ts +0 -95
  210. package/src/cbor-tags.ts +0 -3
  211. package/src/class-type.ts +0 -3
  212. package/src/date-time-types.ts +0 -10
  213. package/src/fetch-event-source.ts +0 -387
  214. package/src/fetch-request-factory.ts +0 -225
  215. package/src/fetch.ts +0 -30
  216. package/src/http-error.ts +0 -55
  217. package/src/index.ts +0 -26
  218. package/src/json-decoder.ts +0 -164
  219. package/src/json-encoder.ts +0 -144
  220. package/src/logger.ts +0 -8
  221. package/src/media-type-decoder.ts +0 -5
  222. package/src/media-type-decoders.ts +0 -59
  223. package/src/media-type-encoder.ts +0 -16
  224. package/src/media-type-encoders.ts +0 -61
  225. package/src/media-type.ts +0 -25
  226. package/src/problem.ts +0 -25
  227. package/src/request-factory.ts +0 -76
  228. package/src/url-encoder.ts +0 -173
  229. package/src/url-template.ts +0 -21
  230. package/src/util/base64.ts +0 -77
  231. package/src/util/hex.ts +0 -15
  232. package/src/util/rxjs.ts +0 -18
  233. package/src/util/stream-rxjs.ts +0 -28
  234. /package/{dist → build}/url-template.d.ts +0 -0
@@ -0,0 +1,26 @@
1
+ export * from './schema-runtime.js';
2
+ export { ArrayBufferSchema, BooleanSchema, NullSchema, NumberSchema, StringSchema, UnknownSchema, URLSchema, } from './schema-builtins.js';
3
+ export * from './request-factory.js';
4
+ export * from './fetch-request-factory.js';
5
+ export * from './fetch-event-source.js';
6
+ export * from './url-template.js';
7
+ export * from './media-type.js';
8
+ export * from './media-type-codecs/media-type-decoder.js';
9
+ export * from './media-type-codecs/media-type-decoders.js';
10
+ export * from './media-type-codecs/media-type-encoder.js';
11
+ export * from './media-type-codecs/media-type-encoders.js';
12
+ export * from './media-type-codecs/json-decoder.js';
13
+ export * from './media-type-codecs/json-encoder.js';
14
+ export * from './media-type-codecs/cbor-decoder.js';
15
+ export * from './media-type-codecs/cbor-encoder.js';
16
+ export * from './media-type-codecs/binary-decoder.js';
17
+ export * from './media-type-codecs/binary-encoder.js';
18
+ export * from './media-type-codecs/www-form-url-encoder.js';
19
+ export * from './logger.js';
20
+ export * from './sunday-error.js';
21
+ export * from './problem.js';
22
+ export * from './date-time-types.js';
23
+ export * from './result-response.js';
24
+ export * from './request-adapters.js';
25
+ export * from './util/errors.js';
26
+ export * from './util/nullify.js';
package/build/index.js ADDED
@@ -0,0 +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
+ export * from './schema-runtime.js';
15
+ export { ArrayBufferSchema, BooleanSchema, NullSchema, NumberSchema, StringSchema, UnknownSchema, URLSchema, } from './schema-builtins.js';
16
+ export * from './request-factory.js';
17
+ export * from './fetch-request-factory.js';
18
+ export * from './fetch-event-source.js';
19
+ export * from './url-template.js';
20
+ export * from './media-type.js';
21
+ export * from './media-type-codecs/media-type-decoder.js';
22
+ export * from './media-type-codecs/media-type-decoders.js';
23
+ export * from './media-type-codecs/media-type-encoder.js';
24
+ export * from './media-type-codecs/media-type-encoders.js';
25
+ export * from './media-type-codecs/json-decoder.js';
26
+ export * from './media-type-codecs/json-encoder.js';
27
+ export * from './media-type-codecs/cbor-decoder.js';
28
+ export * from './media-type-codecs/cbor-encoder.js';
29
+ export * from './media-type-codecs/binary-decoder.js';
30
+ export * from './media-type-codecs/binary-encoder.js';
31
+ export * from './media-type-codecs/www-form-url-encoder.js';
32
+ export * from './logger.js';
33
+ export * from './sunday-error.js';
34
+ export * from './problem.js';
35
+ export * from './date-time-types.js';
36
+ export * from './result-response.js';
37
+ export * from './request-adapters.js';
38
+ // Select exports from util
39
+ export * from './util/errors.js';
40
+ export * from './util/nullify.js';
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,sBAAsB,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAEtC,2BAA2B;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
@@ -6,3 +6,12 @@ export interface Logger {
6
6
  warn?(...data: unknown[]): void;
7
7
  error?(...data: unknown[]): void;
8
8
  }
9
+ export declare enum LogLevel {
10
+ Trace = 4,
11
+ Debug = 3,
12
+ Info = 2,
13
+ Warn = 1,
14
+ Error = 0,
15
+ None = -1
16
+ }
17
+ export declare function levelLogger(level: LogLevel, logger?: Logger): Logger | undefined;
@@ -0,0 +1,36 @@
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 var LogLevel;
15
+ (function (LogLevel) {
16
+ LogLevel[LogLevel["Trace"] = 4] = "Trace";
17
+ LogLevel[LogLevel["Debug"] = 3] = "Debug";
18
+ LogLevel[LogLevel["Info"] = 2] = "Info";
19
+ LogLevel[LogLevel["Warn"] = 1] = "Warn";
20
+ LogLevel[LogLevel["Error"] = 0] = "Error";
21
+ LogLevel[LogLevel["None"] = -1] = "None";
22
+ })(LogLevel || (LogLevel = {}));
23
+ export function levelLogger(level, logger) {
24
+ if (!logger) {
25
+ return undefined;
26
+ }
27
+ return {
28
+ log: logger?.log?.bind(logger),
29
+ trace: level >= LogLevel.Trace ? logger?.trace?.bind(logger) : undefined,
30
+ debug: level >= LogLevel.Debug ? logger?.debug?.bind(logger) : undefined,
31
+ info: level >= LogLevel.Info ? logger?.info?.bind(logger) : undefined,
32
+ warn: level >= LogLevel.Warn ? logger?.warn?.bind(logger) : undefined,
33
+ error: level >= LogLevel.Error ? logger?.error?.bind(logger) : undefined,
34
+ };
35
+ }
36
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.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;AAWjC,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,yCAAS,CAAA;IACT,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,wCAAS,CAAA;AACX,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB;AAED,MAAM,UAAU,WAAW,CACzB,KAAe,EACf,MAAe;IAEf,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,KAAK,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,IAAI,EAAE,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QACrE,IAAI,EAAE,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QACrE,KAAK,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { TextMediaTypeDecoder } from './media-type-decoder.js';
2
+ import { SchemaLike } from '../schema-runtime.js';
3
+ export declare class AnyTextDecoder implements TextMediaTypeDecoder {
4
+ static readonly default: AnyTextDecoder;
5
+ decode<T>(response: Response, type: SchemaLike<T>): Promise<T>;
6
+ decodeText<T>(text: string, schema: SchemaLike<T>): T;
7
+ }
@@ -0,0 +1,29 @@
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 { isSchema } from '../schema-runtime.js';
15
+ export class AnyTextDecoder {
16
+ static default = new AnyTextDecoder();
17
+ async decode(response, type) {
18
+ return this.decodeText(await response.text(), type);
19
+ }
20
+ decodeText(text, schema) {
21
+ if (isSchema(schema)) {
22
+ return schema.parse(text);
23
+ }
24
+ else {
25
+ throw new Error(`Unsupported schema type: ${typeof schema}`);
26
+ }
27
+ }
28
+ }
29
+ //# sourceMappingURL=any-text-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-text-decoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/any-text-decoder.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;AAGjC,OAAO,EAAE,QAAQ,EAAc,MAAM,sBAAsB,CAAC;AAE5D,MAAM,OAAO,cAAc;IACzB,MAAM,CAAU,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IAE/C,KAAK,CAAC,MAAM,CAAI,QAAkB,EAAE,IAAmB;QACrD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,UAAU,CAAI,IAAY,EAAE,MAAqB;QAC/C,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,MAAM,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { MediaTypeEncoder } from './media-type-encoder.js';
2
+ import { SchemaLike } from '../schema-runtime.js';
3
+ export declare class AnyTextEncoder implements MediaTypeEncoder {
4
+ static readonly default: AnyTextEncoder;
5
+ encode<T>(value: T, _?: SchemaLike<T>): BodyInit;
6
+ }
@@ -0,0 +1,27 @@
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 class AnyTextEncoder {
15
+ static default = new AnyTextEncoder();
16
+ encode(value, _) {
17
+ let str;
18
+ if (typeof value == 'string') {
19
+ str = value;
20
+ }
21
+ else {
22
+ throw new TypeError(`Unsupported value type for text encoding: ${typeof value}`);
23
+ }
24
+ return str;
25
+ }
26
+ }
27
+ //# sourceMappingURL=any-text-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-text-encoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/any-text-encoder.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;AAKjC,MAAM,OAAO,cAAc;IACzB,MAAM,CAAU,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IAE/C,MAAM,CAAI,KAAQ,EAAE,CAAiB;QACnC,IAAI,GAAW,CAAC;QAChB,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,GAAG,GAAG,KAAe,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,SAAS,CAAC,6CAA6C,OAAO,KAAK,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { BufferMediaTypeDecoder } from './media-type-decoder.js';
2
+ import { SchemaLike } from '../schema-runtime.js';
3
+ export declare class BinaryDecoder implements BufferMediaTypeDecoder {
4
+ static readonly default: BinaryDecoder;
5
+ decode<T>(response: Response, type: SchemaLike<T>): Promise<T>;
6
+ decodeBuffer<T>(buffer: ArrayBuffer, schema: SchemaLike<T>): T;
7
+ }
@@ -0,0 +1,33 @@
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 { ArrayBufferSchema } from '../schema-builtins.js';
15
+ import { isSchema } from '../schema-runtime.js';
16
+ export class BinaryDecoder {
17
+ static default = new BinaryDecoder();
18
+ async decode(response, type) {
19
+ return this.decodeBuffer(await response.arrayBuffer(), type);
20
+ }
21
+ decodeBuffer(buffer, schema) {
22
+ if (isSchema(schema)) {
23
+ return schema.parse(buffer);
24
+ }
25
+ else if (schema === ArrayBufferSchema) {
26
+ return buffer;
27
+ }
28
+ else {
29
+ throw new Error(`Unsupported schema type: ${typeof schema}`);
30
+ }
31
+ }
32
+ }
33
+ //# sourceMappingURL=binary-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-decoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/binary-decoder.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,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAc,MAAM,sBAAsB,CAAC;AAE5D,MAAM,OAAO,aAAa;IACxB,MAAM,CAAU,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;IAE9C,KAAK,CAAC,MAAM,CAAI,QAAkB,EAAE,IAAmB;QACrD,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY,CAAI,MAAmB,EAAE,MAAqB;QACxD,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;aAAM,IAAI,MAAM,KAAK,iBAAiB,EAAE,CAAC;YACxC,OAAO,MAAsB,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,MAAM,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { MediaTypeEncoder } from './media-type-encoder.js';
2
+ import { SchemaLike } from '../schema-runtime.js';
3
+ export declare class BinaryEncoder implements MediaTypeEncoder {
4
+ static readonly default: BinaryEncoder;
5
+ encode<T>(value: T, _?: SchemaLike<T>): BodyInit;
6
+ }
@@ -0,0 +1,30 @@
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 class BinaryEncoder {
15
+ static default = new BinaryEncoder();
16
+ encode(value, _) {
17
+ let buffer;
18
+ if (value instanceof ArrayBuffer) {
19
+ buffer = value;
20
+ }
21
+ else if (ArrayBuffer.isView(value)) {
22
+ buffer = value;
23
+ }
24
+ else {
25
+ throw new TypeError(`Unsupported value type for binary decoding: ${typeof value}`);
26
+ }
27
+ return buffer;
28
+ }
29
+ }
30
+ //# sourceMappingURL=binary-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-encoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/binary-encoder.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;AAKjC,MAAM,OAAO,aAAa;IACxB,MAAM,CAAU,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;IAE9C,MAAM,CAAI,KAAQ,EAAE,CAAiB;QACnC,IAAI,MAAkD,CAAC;QACvD,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,GAAG,KAAoB,CAAC;QAChC,CAAC;aAAM,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,GAAG,KAAqC,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,SAAS,CAAC,+CAA+C,OAAO,KAAK,EAAE,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { NumericDateDecoding as SchemaNumericDateDecoding, SchemaLike, SchemaPolicy, SchemaRuntime } from '../schema-runtime.js';
2
+ import { BufferMediaTypeDecoder } from './media-type-decoder.js';
3
+ export declare class CBORDecoder implements BufferMediaTypeDecoder {
4
+ readonly runtime: SchemaRuntime;
5
+ static readonly default: CBORDecoder;
6
+ static fromPolicy(policy: Partial<Omit<SchemaPolicy, 'format'>>): CBORDecoder;
7
+ constructor(runtime?: SchemaRuntime);
8
+ decode<T>(response: Response, type: SchemaLike<T>): Promise<T>;
9
+ decodeBuffer<T>(buffer: ArrayBuffer, type: SchemaLike<T>): T;
10
+ }
11
+ export declare namespace CBORDecoder {
12
+ const NumericDateDecoding: typeof SchemaNumericDateDecoding;
13
+ }
@@ -0,0 +1,38 @@
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 { CBOR } from 'cbor-redux';
15
+ import { NumericDateDecoding as SchemaNumericDateDecoding, } from '../schema-runtime.js';
16
+ import { createCBORSchemaRuntime } from './default-policies.js';
17
+ export class CBORDecoder {
18
+ runtime;
19
+ static default = new CBORDecoder();
20
+ static fromPolicy(policy) {
21
+ return new CBORDecoder(createCBORSchemaRuntime(policy));
22
+ }
23
+ constructor(runtime = createCBORSchemaRuntime()) {
24
+ this.runtime = runtime;
25
+ }
26
+ async decode(response, type) {
27
+ const buffer = await response.arrayBuffer();
28
+ return this.decodeBuffer(buffer, type);
29
+ }
30
+ decodeBuffer(buffer, type) {
31
+ const data = CBOR.decode(buffer);
32
+ return this.runtime.resolveSchema(type).decode(data);
33
+ }
34
+ }
35
+ (function (CBORDecoder) {
36
+ CBORDecoder.NumericDateDecoding = SchemaNumericDateDecoding;
37
+ })(CBORDecoder || (CBORDecoder = {}));
38
+ //# sourceMappingURL=cbor-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-decoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/cbor-decoder.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,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,mBAAmB,IAAI,yBAAyB,GAGjD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,OAAO,WAAW;IAOD;IANrB,MAAM,CAAU,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAE5C,MAAM,CAAC,UAAU,CAAC,MAA6C;QAC7D,OAAO,IAAI,WAAW,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,YAAqB,UAAyB,uBAAuB,EAAE;QAAlD,YAAO,GAAP,OAAO,CAA2C;IACvE,CAAC;IAED,KAAK,CAAC,MAAM,CAAI,QAAkB,EAAE,IAAmB;QACrD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,YAAY,CAAI,MAAmB,EAAE,IAAmB;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;;AAGH,WAAiB,WAAW;IACb,+BAAmB,GAAG,yBAAyB,CAAC;AAC/D,CAAC,EAFgB,WAAW,KAAX,WAAW,QAE3B"}
@@ -0,0 +1,12 @@
1
+ import { DateEncoding as SchemaDateEncoding, SchemaLike, SchemaPolicy, SchemaRuntime } from '../schema-runtime.js';
2
+ import { MediaTypeEncoder } from './media-type-encoder.js';
3
+ export declare class CBOREncoder implements MediaTypeEncoder {
4
+ readonly runtime: SchemaRuntime;
5
+ static readonly default: CBOREncoder;
6
+ static fromPolicy(policy: Partial<Omit<SchemaPolicy, 'format'>>): CBOREncoder;
7
+ constructor(runtime?: SchemaRuntime);
8
+ encode<T>(value: T, type?: SchemaLike<T>): ArrayBuffer;
9
+ }
10
+ export declare namespace CBOREncoder {
11
+ const DateEncoding: typeof SchemaDateEncoding;
12
+ }
@@ -0,0 +1,36 @@
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 { CBOR } from 'cbor-redux';
15
+ import { DateEncoding as SchemaDateEncoding, } from '../schema-runtime.js';
16
+ import { createCBORSchemaRuntime } from './default-policies.js';
17
+ export class CBOREncoder {
18
+ runtime;
19
+ static default = new CBOREncoder();
20
+ static fromPolicy(policy) {
21
+ return new CBOREncoder(createCBORSchemaRuntime(policy));
22
+ }
23
+ constructor(runtime = createCBORSchemaRuntime()) {
24
+ this.runtime = runtime;
25
+ }
26
+ encode(value, type) {
27
+ const serialized = type
28
+ ? this.runtime.resolveSchema(type).encode(value)
29
+ : value;
30
+ return CBOR.encode(serialized);
31
+ }
32
+ }
33
+ (function (CBOREncoder) {
34
+ CBOREncoder.DateEncoding = SchemaDateEncoding;
35
+ })(CBOREncoder || (CBOREncoder = {}));
36
+ //# sourceMappingURL=cbor-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-encoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/cbor-encoder.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,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,YAAY,IAAI,kBAAkB,GAGnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,OAAO,WAAW;IAOD;IANrB,MAAM,CAAU,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAE5C,MAAM,CAAC,UAAU,CAAC,MAA6C;QAC7D,OAAO,IAAI,WAAW,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,YAAqB,UAAyB,uBAAuB,EAAE;QAAlD,YAAO,GAAP,OAAO,CAA2C;IACvE,CAAC;IAED,MAAM,CAAI,KAAQ,EAAE,IAAoB;QACtC,MAAM,UAAU,GAAG,IAAI;YACrB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAChD,CAAC,CAAC,KAAK,CAAC;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;;AAGH,WAAiB,WAAW;IACb,wBAAY,GAAG,kBAAkB,CAAC;AACjD,CAAC,EAFgB,WAAW,KAAX,WAAW,QAE3B"}
@@ -0,0 +1,6 @@
1
+ export declare const isoDateTimeTag = 0;
2
+ export declare const epochDateTimeTag = 1;
3
+ export declare const uriTag = 32;
4
+ export declare const base64UrlTag = 33;
5
+ export declare const base64Tag = 34;
6
+ export declare const epochDateTag = 100;
@@ -0,0 +1,20 @@
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 const isoDateTimeTag = 0;
15
+ export const epochDateTimeTag = 1;
16
+ export const uriTag = 32;
17
+ export const base64UrlTag = 33;
18
+ export const base64Tag = 34;
19
+ export const epochDateTag = 100;
20
+ //# sourceMappingURL=cbor-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor-tags.js","sourceRoot":"","sources":["../../src/media-type-codecs/cbor-tags.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,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,CAAC;AACzB,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAC5B,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { SchemaRuntime, SchemaPolicy } from '../schema-runtime.js';
2
+ export declare function createJSONSchemaRuntime(options?: Partial<Omit<SchemaPolicy, 'format'>>): SchemaRuntime;
3
+ export declare function createCBORSchemaRuntime(options?: Partial<Omit<SchemaPolicy, 'format'>>): SchemaRuntime;
@@ -0,0 +1,33 @@
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 { ArrayBufferEncoding, createSchemaRuntime, NumericDateDecoding, DateEncoding, } from '../schema-runtime.js';
15
+ export function createJSONSchemaRuntime(options) {
16
+ return createSchemaRuntime({
17
+ format: 'json',
18
+ dateEncoding: DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH,
19
+ numericDateDecoding: NumericDateDecoding.DECIMAL_SECONDS_SINCE_EPOCH,
20
+ arrayBufferEncoding: ArrayBufferEncoding.BASE64,
21
+ ...options,
22
+ });
23
+ }
24
+ export function createCBORSchemaRuntime(options) {
25
+ return createSchemaRuntime({
26
+ format: 'cbor',
27
+ dateEncoding: DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH,
28
+ numericDateDecoding: NumericDateDecoding.DECIMAL_SECONDS_SINCE_EPOCH,
29
+ arrayBufferEncoding: ArrayBufferEncoding.RAW_BYTES,
30
+ ...options,
31
+ });
32
+ }
33
+ //# sourceMappingURL=default-policies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-policies.js","sourceRoot":"","sources":["../../src/media-type-codecs/default-policies.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,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GAEb,MAAM,sBAAsB,CAAC;AAE9B,MAAM,UAAU,uBAAuB,CAAC,OAA+C;IACrF,OAAO,mBAAmB,CACxB;QACE,MAAM,EAAE,MAAM;QACd,YAAY,EAAE,YAAY,CAAC,2BAA2B;QACtD,mBAAmB,EAAE,mBAAmB,CAAC,2BAA2B;QACpE,mBAAmB,EAAE,mBAAmB,CAAC,MAAM;QAC/C,GAAG,OAAO;KACX,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAA+C;IACrF,OAAO,mBAAmB,CACxB;QACE,MAAM,EAAE,MAAM;QACd,YAAY,EAAE,YAAY,CAAC,2BAA2B;QACtD,mBAAmB,EAAE,mBAAmB,CAAC,2BAA2B;QACpE,mBAAmB,EAAE,mBAAmB,CAAC,SAAS;QAClD,GAAG,OAAO;KACX,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { NumericDateDecoding as SchemaNumericDateDecoding, SchemaLike, SchemaPolicy, SchemaRuntime } from '../schema-runtime.js';
2
+ import { StructuredMediaTypeDecoder, TextMediaTypeDecoder } from './media-type-decoder.js';
3
+ export declare class JSONDecoder implements TextMediaTypeDecoder, StructuredMediaTypeDecoder {
4
+ readonly runtime: SchemaRuntime;
5
+ static readonly default: JSONDecoder;
6
+ static fromPolicy(policy: Partial<Omit<SchemaPolicy, 'format'>>): JSONDecoder;
7
+ constructor(runtime?: SchemaRuntime);
8
+ decode<T>(response: Response, type: SchemaLike<T>): Promise<T>;
9
+ decodeText<T>(text: string, type: SchemaLike<T>): T;
10
+ decodeObject<T>(value: unknown, type: SchemaLike<T>): T;
11
+ }
12
+ export declare namespace JSONDecoder {
13
+ const NumericDateDecoding: typeof SchemaNumericDateDecoding;
14
+ }
@@ -0,0 +1,40 @@
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 { NumericDateDecoding as SchemaNumericDateDecoding, } from '../schema-runtime.js';
15
+ import { createJSONSchemaRuntime } from './default-policies.js';
16
+ export class JSONDecoder {
17
+ runtime;
18
+ static default = new JSONDecoder();
19
+ static fromPolicy(policy) {
20
+ return new JSONDecoder(createJSONSchemaRuntime(policy));
21
+ }
22
+ constructor(runtime = createJSONSchemaRuntime()) {
23
+ this.runtime = runtime;
24
+ }
25
+ async decode(response, type) {
26
+ const data = await response.json();
27
+ return this.decodeObject(data, type);
28
+ }
29
+ decodeText(text, type) {
30
+ const value = JSON.parse(text);
31
+ return this.decodeObject(value, type);
32
+ }
33
+ decodeObject(value, type) {
34
+ return this.runtime.resolveSchema(type).decode(value);
35
+ }
36
+ }
37
+ (function (JSONDecoder) {
38
+ JSONDecoder.NumericDateDecoding = SchemaNumericDateDecoding;
39
+ })(JSONDecoder || (JSONDecoder = {}));
40
+ //# sourceMappingURL=json-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-decoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/json-decoder.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,OAAO,EACL,mBAAmB,IAAI,yBAAyB,GAIjD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMhE,MAAM,OAAO,WAAW;IASD;IANrB,MAAM,CAAU,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAE5C,MAAM,CAAC,UAAU,CAAC,MAA6C;QAC7D,OAAO,IAAI,WAAW,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,YAAqB,UAAyB,uBAAuB,EAAE;QAAlD,YAAO,GAAP,OAAO,CAA2C;IACvE,CAAC;IAED,KAAK,CAAC,MAAM,CAAI,QAAkB,EAAE,IAAmB;QACrD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,UAAU,CAAI,IAAY,EAAE,IAAmB;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,YAAY,CAAI,KAAc,EAAE,IAAmB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;;AAGH,WAAiB,WAAW;IACb,+BAAmB,GAAG,yBAAyB,CAAC;AAC/D,CAAC,EAFgB,WAAW,KAAX,WAAW,QAE3B"}
@@ -0,0 +1,13 @@
1
+ import { DateEncoding as SchemaDateEncoding, SchemaLike, SchemaPolicy, SchemaRuntime } from '../schema-runtime.js';
2
+ import { StructuredMediaTypeEncoder } from './media-type-encoder.js';
3
+ export declare class JSONEncoder implements StructuredMediaTypeEncoder {
4
+ readonly runtime: SchemaRuntime;
5
+ static readonly default: JSONEncoder;
6
+ static fromPolicy(policy: Partial<Omit<SchemaPolicy, 'format'>>): JSONEncoder;
7
+ constructor(runtime?: SchemaRuntime);
8
+ encode<T>(value: T, type?: SchemaLike<T>): string;
9
+ encodeObject<T>(value: T, type?: SchemaLike<T>): Record<string, unknown>;
10
+ }
11
+ export declare namespace JSONEncoder {
12
+ const DateEncoding: typeof SchemaDateEncoding;
13
+ }
@@ -0,0 +1,43 @@
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 { DateEncoding as SchemaDateEncoding, } from '../schema-runtime.js';
15
+ import { createJSONSchemaRuntime } from './default-policies.js';
16
+ import { z } from 'zod';
17
+ const JSON_OBJECT_SCHEMA = z.record(z.string(), z.unknown());
18
+ export class JSONEncoder {
19
+ runtime;
20
+ static default = new JSONEncoder();
21
+ static fromPolicy(policy) {
22
+ return new JSONEncoder(createJSONSchemaRuntime(policy));
23
+ }
24
+ constructor(runtime = createJSONSchemaRuntime()) {
25
+ this.runtime = runtime;
26
+ }
27
+ encode(value, type) {
28
+ const serialized = type
29
+ ? this.runtime.resolveSchema(type).encode(value)
30
+ : value;
31
+ return JSON.stringify(serialized);
32
+ }
33
+ encodeObject(value, type) {
34
+ const serialized = type
35
+ ? this.runtime.resolveSchema(type).encode(value)
36
+ : value;
37
+ return JSON_OBJECT_SCHEMA.parse(serialized);
38
+ }
39
+ }
40
+ (function (JSONEncoder) {
41
+ JSONEncoder.DateEncoding = SchemaDateEncoding;
42
+ })(JSONEncoder || (JSONEncoder = {}));
43
+ //# sourceMappingURL=json-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-encoder.js","sourceRoot":"","sources":["../../src/media-type-codecs/json-encoder.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,OAAO,EACL,YAAY,IAAI,kBAAkB,GAInC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAE7D,MAAM,OAAO,WAAW;IAOD;IANrB,MAAM,CAAU,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAE5C,MAAM,CAAC,UAAU,CAAC,MAA6C;QAC7D,OAAO,IAAI,WAAW,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,YAAqB,UAAyB,uBAAuB,EAAE;QAAlD,YAAO,GAAP,OAAO,CAA2C;IACvE,CAAC;IAED,MAAM,CAAI,KAAQ,EAAE,IAAoB;QACtC,MAAM,UAAU,GAAG,IAAI;YACrB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAChD,CAAC,CAAC,KAAK,CAAC;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,YAAY,CACV,KAAQ,EACR,IAAoB;QAEpB,MAAM,UAAU,GAAG,IAAI;YACrB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAChD,CAAC,CAAC,KAAK,CAAC;QACV,OAAO,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;;AAGH,WAAiB,WAAW;IACb,wBAAY,GAAG,kBAAkB,CAAC;AACjD,CAAC,EAFgB,WAAW,KAAX,WAAW,QAE3B"}