@openstax/ts-utils 1.21.11 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/dist/cjs/assertions/index.d.ts +85 -0
  2. package/dist/cjs/assertions/index.js +157 -0
  3. package/dist/cjs/aws/ssmService.d.ts +5 -0
  4. package/dist/cjs/aws/ssmService.js +9 -0
  5. package/dist/cjs/config/awsParameterConfig.d.ts +10 -0
  6. package/dist/cjs/config/awsParameterConfig.js +26 -0
  7. package/dist/cjs/config/envConfig.d.ts +24 -0
  8. package/dist/cjs/config/envConfig.js +57 -0
  9. package/dist/cjs/config/index.d.ts +48 -0
  10. package/dist/cjs/config/index.js +35 -0
  11. package/dist/cjs/config/lambdaParameterConfig.d.ts +12 -0
  12. package/dist/cjs/config/lambdaParameterConfig.js +45 -0
  13. package/dist/cjs/config/replaceConfig.d.ts +14 -0
  14. package/dist/cjs/config/replaceConfig.js +22 -0
  15. package/dist/cjs/config/resolveConfigValue.d.ts +5 -0
  16. package/dist/cjs/config/resolveConfigValue.js +12 -0
  17. package/dist/cjs/errors/index.d.ts +77 -0
  18. package/dist/cjs/errors/index.js +109 -0
  19. package/dist/cjs/fetch/fetchStatusRetry.d.ts +7 -0
  20. package/dist/cjs/fetch/fetchStatusRetry.js +16 -0
  21. package/dist/cjs/fetch/index.d.ts +64 -0
  22. package/dist/cjs/fetch/index.js +55 -0
  23. package/dist/cjs/guards/index.d.ts +30 -0
  24. package/dist/cjs/guards/index.js +35 -0
  25. package/dist/cjs/index.d.ts +4 -0
  26. package/dist/cjs/index.js +20 -0
  27. package/dist/cjs/middleware/apiErrorHandler.d.ts +24 -0
  28. package/dist/cjs/middleware/apiErrorHandler.js +41 -0
  29. package/dist/cjs/middleware/apiSlowResponseMiddleware.d.ts +23 -0
  30. package/dist/cjs/middleware/apiSlowResponseMiddleware.js +54 -0
  31. package/dist/cjs/middleware/index.d.ts +47 -0
  32. package/dist/cjs/middleware/index.js +48 -0
  33. package/dist/cjs/middleware/lambdaCorsResponseMiddleware.d.ts +20 -0
  34. package/dist/cjs/middleware/lambdaCorsResponseMiddleware.js +42 -0
  35. package/dist/cjs/middleware/throwNotFoundMiddleware.d.ts +4 -0
  36. package/dist/cjs/middleware/throwNotFoundMiddleware.js +14 -0
  37. package/dist/cjs/misc/hashValue.d.ts +10 -0
  38. package/dist/cjs/misc/hashValue.js +17 -0
  39. package/dist/cjs/misc/helpers.d.ts +124 -0
  40. package/dist/cjs/misc/helpers.js +214 -0
  41. package/dist/cjs/misc/merge.d.ts +21 -0
  42. package/dist/cjs/misc/merge.js +45 -0
  43. package/dist/cjs/misc/partitionSequence.d.ts +35 -0
  44. package/dist/cjs/misc/partitionSequence.js +55 -0
  45. package/dist/cjs/pagination/index.d.ts +91 -0
  46. package/dist/cjs/pagination/index.js +83 -0
  47. package/dist/cjs/routing/helpers.d.ts +57 -0
  48. package/dist/cjs/routing/helpers.js +90 -0
  49. package/dist/cjs/routing/index.d.ts +272 -0
  50. package/dist/cjs/routing/index.js +270 -0
  51. package/dist/cjs/routing/validators/zod.d.ts +4 -0
  52. package/dist/cjs/routing/validators/zod.js +12 -0
  53. package/dist/cjs/services/accountsGateway/index.d.ts +85 -0
  54. package/dist/cjs/services/accountsGateway/index.js +118 -0
  55. package/dist/cjs/services/apiGateway/index.d.ts +63 -0
  56. package/dist/cjs/services/apiGateway/index.js +108 -0
  57. package/dist/cjs/services/authProvider/browser.d.ts +74 -0
  58. package/dist/cjs/services/authProvider/browser.js +154 -0
  59. package/dist/cjs/services/authProvider/decryption.d.ts +19 -0
  60. package/dist/cjs/services/authProvider/decryption.js +61 -0
  61. package/dist/cjs/services/authProvider/index.d.ts +61 -0
  62. package/dist/cjs/services/authProvider/index.js +26 -0
  63. package/dist/cjs/services/authProvider/subrequest.d.ts +16 -0
  64. package/dist/cjs/services/authProvider/subrequest.js +50 -0
  65. package/dist/cjs/services/authProvider/utils/decryptAndVerify.d.ts +29 -0
  66. package/dist/cjs/services/authProvider/utils/decryptAndVerify.js +91 -0
  67. package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.d.ts +26 -0
  68. package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.js +47 -0
  69. package/dist/cjs/services/authProvider/utils/userRoleValidator.d.ts +13 -0
  70. package/dist/cjs/services/authProvider/utils/userRoleValidator.js +37 -0
  71. package/dist/cjs/services/documentStore/dynamoEncoding.d.ts +10 -0
  72. package/dist/cjs/services/documentStore/dynamoEncoding.js +52 -0
  73. package/dist/cjs/services/documentStore/index.d.ts +14 -0
  74. package/dist/cjs/services/documentStore/index.js +2 -0
  75. package/dist/cjs/services/documentStore/unversioned/dynamodb.d.ts +16 -0
  76. package/dist/cjs/services/documentStore/unversioned/dynamodb.js +122 -0
  77. package/dist/cjs/services/documentStore/unversioned/file-system.d.ts +18 -0
  78. package/dist/cjs/services/documentStore/unversioned/file-system.js +121 -0
  79. package/dist/cjs/services/documentStore/unversioned/index.d.ts +2 -0
  80. package/dist/cjs/services/documentStore/unversioned/index.js +2 -0
  81. package/dist/cjs/services/documentStore/versioned/dynamodb.d.ts +22 -0
  82. package/dist/cjs/services/documentStore/versioned/dynamodb.js +135 -0
  83. package/dist/cjs/services/documentStore/versioned/file-system.d.ts +24 -0
  84. package/dist/cjs/services/documentStore/versioned/file-system.js +62 -0
  85. package/dist/cjs/services/documentStore/versioned/index.d.ts +17 -0
  86. package/dist/cjs/services/documentStore/versioned/index.js +2 -0
  87. package/dist/cjs/services/exercisesGateway/index.d.ts +71 -0
  88. package/dist/cjs/services/exercisesGateway/index.js +97 -0
  89. package/dist/cjs/services/fileServer/index.d.ts +17 -0
  90. package/dist/cjs/services/fileServer/index.js +19 -0
  91. package/dist/cjs/services/fileServer/localFileServer.d.ts +13 -0
  92. package/dist/cjs/services/fileServer/localFileServer.js +23 -0
  93. package/dist/cjs/services/fileServer/s3FileServer.d.ts +16 -0
  94. package/dist/cjs/services/fileServer/s3FileServer.js +25 -0
  95. package/dist/cjs/services/launchParams/index.d.ts +2 -0
  96. package/dist/cjs/services/launchParams/index.js +7 -0
  97. package/dist/cjs/services/launchParams/signer.d.ts +27 -0
  98. package/dist/cjs/services/launchParams/signer.js +58 -0
  99. package/dist/cjs/services/launchParams/verifier.d.ts +22 -0
  100. package/dist/cjs/services/launchParams/verifier.js +94 -0
  101. package/dist/cjs/services/logger/console.d.ts +4 -0
  102. package/dist/cjs/services/logger/console.js +12 -0
  103. package/dist/cjs/services/logger/index.d.ts +39 -0
  104. package/dist/cjs/services/logger/index.js +31 -0
  105. package/dist/cjs/services/lrsGateway/addStatementDefaultFields.d.ts +5 -0
  106. package/dist/cjs/services/lrsGateway/addStatementDefaultFields.js +21 -0
  107. package/dist/cjs/services/lrsGateway/attempt-utils.d.ts +70 -0
  108. package/dist/cjs/services/lrsGateway/attempt-utils.js +258 -0
  109. package/dist/cjs/services/lrsGateway/file-system.d.ts +17 -0
  110. package/dist/cjs/services/lrsGateway/file-system.js +140 -0
  111. package/dist/cjs/services/lrsGateway/index.d.ts +125 -0
  112. package/dist/cjs/services/lrsGateway/index.js +138 -0
  113. package/dist/cjs/services/lrsGateway/xapiUtils.d.ts +61 -0
  114. package/dist/cjs/services/lrsGateway/xapiUtils.js +94 -0
  115. package/dist/cjs/services/postgresConnection/index.d.ts +35 -0
  116. package/dist/cjs/services/postgresConnection/index.js +63 -0
  117. package/dist/cjs/services/searchProvider/index.d.ts +31 -0
  118. package/dist/cjs/services/searchProvider/index.js +2 -0
  119. package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +14 -0
  120. package/dist/cjs/services/searchProvider/memorySearchTheBadWay.js +89 -0
  121. package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -0
  122. package/dist/cjs/types.d.ts +31 -0
  123. package/dist/cjs/types.js +2 -0
  124. package/dist/esm/assertions/index.d.ts +85 -0
  125. package/dist/esm/assertions/index.js +146 -0
  126. package/dist/esm/aws/ssmService.d.ts +5 -0
  127. package/dist/esm/aws/ssmService.js +6 -0
  128. package/dist/esm/config/awsParameterConfig.d.ts +10 -0
  129. package/dist/esm/config/awsParameterConfig.js +22 -0
  130. package/dist/esm/config/envConfig.d.ts +24 -0
  131. package/dist/esm/config/envConfig.js +53 -0
  132. package/dist/esm/config/index.d.ts +48 -0
  133. package/dist/esm/config/index.js +17 -0
  134. package/dist/esm/config/lambdaParameterConfig.d.ts +12 -0
  135. package/dist/esm/config/lambdaParameterConfig.js +38 -0
  136. package/dist/esm/config/replaceConfig.d.ts +14 -0
  137. package/dist/esm/config/replaceConfig.js +18 -0
  138. package/dist/esm/config/resolveConfigValue.d.ts +5 -0
  139. package/dist/esm/config/resolveConfigValue.js +8 -0
  140. package/dist/esm/errors/index.d.ts +77 -0
  141. package/dist/esm/errors/index.js +99 -0
  142. package/dist/esm/fetch/fetchStatusRetry.d.ts +7 -0
  143. package/dist/esm/fetch/fetchStatusRetry.js +12 -0
  144. package/dist/esm/fetch/index.d.ts +64 -0
  145. package/dist/esm/fetch/index.js +46 -0
  146. package/dist/esm/guards/index.d.ts +30 -0
  147. package/dist/esm/guards/index.js +28 -0
  148. package/dist/esm/index.d.ts +4 -0
  149. package/dist/esm/index.js +4 -0
  150. package/dist/esm/middleware/apiErrorHandler.d.ts +24 -0
  151. package/dist/esm/middleware/apiErrorHandler.js +37 -0
  152. package/dist/esm/middleware/apiSlowResponseMiddleware.d.ts +23 -0
  153. package/dist/esm/middleware/apiSlowResponseMiddleware.js +50 -0
  154. package/dist/esm/middleware/index.d.ts +47 -0
  155. package/dist/esm/middleware/index.js +44 -0
  156. package/dist/esm/middleware/lambdaCorsResponseMiddleware.d.ts +20 -0
  157. package/dist/esm/middleware/lambdaCorsResponseMiddleware.js +38 -0
  158. package/dist/esm/middleware/throwNotFoundMiddleware.d.ts +4 -0
  159. package/dist/esm/middleware/throwNotFoundMiddleware.js +10 -0
  160. package/dist/esm/misc/hashValue.d.ts +10 -0
  161. package/dist/esm/misc/hashValue.js +13 -0
  162. package/dist/esm/misc/helpers.d.ts +124 -0
  163. package/dist/esm/misc/helpers.js +199 -0
  164. package/dist/esm/misc/merge.d.ts +21 -0
  165. package/dist/esm/misc/merge.js +40 -0
  166. package/dist/esm/misc/partitionSequence.d.ts +35 -0
  167. package/dist/esm/misc/partitionSequence.js +48 -0
  168. package/dist/esm/pagination/index.d.ts +91 -0
  169. package/dist/esm/pagination/index.js +77 -0
  170. package/dist/esm/routing/helpers.d.ts +57 -0
  171. package/dist/esm/routing/helpers.js +83 -0
  172. package/dist/esm/routing/index.d.ts +272 -0
  173. package/dist/esm/routing/index.js +232 -0
  174. package/dist/esm/routing/validators/zod.d.ts +4 -0
  175. package/dist/esm/routing/validators/zod.js +8 -0
  176. package/dist/esm/services/accountsGateway/index.d.ts +85 -0
  177. package/dist/esm/services/accountsGateway/index.js +111 -0
  178. package/dist/esm/services/apiGateway/index.d.ts +63 -0
  179. package/dist/esm/services/apiGateway/index.js +77 -0
  180. package/dist/esm/services/authProvider/browser.d.ts +74 -0
  181. package/dist/esm/services/authProvider/browser.js +150 -0
  182. package/dist/esm/services/authProvider/decryption.d.ts +19 -0
  183. package/dist/esm/services/authProvider/decryption.js +57 -0
  184. package/dist/esm/services/authProvider/index.d.ts +61 -0
  185. package/dist/esm/services/authProvider/index.js +18 -0
  186. package/dist/esm/services/authProvider/subrequest.d.ts +16 -0
  187. package/dist/esm/services/authProvider/subrequest.js +43 -0
  188. package/dist/esm/services/authProvider/utils/decryptAndVerify.d.ts +29 -0
  189. package/dist/esm/services/authProvider/utils/decryptAndVerify.js +85 -0
  190. package/dist/esm/services/authProvider/utils/embeddedAuthProvider.d.ts +26 -0
  191. package/dist/esm/services/authProvider/utils/embeddedAuthProvider.js +40 -0
  192. package/dist/esm/services/authProvider/utils/userRoleValidator.d.ts +13 -0
  193. package/dist/esm/services/authProvider/utils/userRoleValidator.js +33 -0
  194. package/dist/esm/services/documentStore/dynamoEncoding.d.ts +10 -0
  195. package/dist/esm/services/documentStore/dynamoEncoding.js +45 -0
  196. package/dist/esm/services/documentStore/index.d.ts +14 -0
  197. package/dist/esm/services/documentStore/index.js +1 -0
  198. package/dist/esm/services/documentStore/unversioned/dynamodb.d.ts +16 -0
  199. package/dist/esm/services/documentStore/unversioned/dynamodb.js +118 -0
  200. package/dist/esm/services/documentStore/unversioned/file-system.d.ts +18 -0
  201. package/dist/esm/services/documentStore/unversioned/file-system.js +91 -0
  202. package/dist/esm/services/documentStore/unversioned/index.d.ts +2 -0
  203. package/dist/esm/services/documentStore/unversioned/index.js +1 -0
  204. package/dist/esm/services/documentStore/versioned/dynamodb.d.ts +22 -0
  205. package/dist/esm/services/documentStore/versioned/dynamodb.js +131 -0
  206. package/dist/esm/services/documentStore/versioned/file-system.d.ts +24 -0
  207. package/dist/esm/services/documentStore/versioned/file-system.js +58 -0
  208. package/dist/esm/services/documentStore/versioned/index.d.ts +17 -0
  209. package/dist/esm/services/documentStore/versioned/index.js +1 -0
  210. package/dist/esm/services/exercisesGateway/index.d.ts +71 -0
  211. package/dist/esm/services/exercisesGateway/index.js +70 -0
  212. package/dist/esm/services/fileServer/index.d.ts +17 -0
  213. package/dist/esm/services/fileServer/index.js +13 -0
  214. package/dist/esm/services/fileServer/localFileServer.d.ts +13 -0
  215. package/dist/esm/services/fileServer/localFileServer.js +16 -0
  216. package/dist/esm/services/fileServer/s3FileServer.d.ts +16 -0
  217. package/dist/esm/services/fileServer/s3FileServer.js +21 -0
  218. package/dist/esm/services/launchParams/index.d.ts +2 -0
  219. package/dist/esm/services/launchParams/index.js +2 -0
  220. package/dist/esm/services/launchParams/signer.d.ts +27 -0
  221. package/dist/esm/services/launchParams/signer.js +51 -0
  222. package/dist/esm/services/launchParams/verifier.d.ts +22 -0
  223. package/dist/esm/services/launchParams/verifier.js +67 -0
  224. package/dist/esm/services/logger/console.d.ts +4 -0
  225. package/dist/esm/services/logger/console.js +8 -0
  226. package/dist/esm/services/logger/index.d.ts +39 -0
  227. package/dist/esm/services/logger/index.js +27 -0
  228. package/dist/esm/services/lrsGateway/addStatementDefaultFields.d.ts +5 -0
  229. package/dist/esm/services/lrsGateway/addStatementDefaultFields.js +14 -0
  230. package/dist/esm/services/lrsGateway/attempt-utils.d.ts +70 -0
  231. package/dist/esm/services/lrsGateway/attempt-utils.js +236 -0
  232. package/dist/esm/services/lrsGateway/file-system.d.ts +17 -0
  233. package/dist/esm/services/lrsGateway/file-system.js +110 -0
  234. package/dist/esm/services/lrsGateway/index.d.ts +125 -0
  235. package/dist/esm/services/lrsGateway/index.js +111 -0
  236. package/dist/esm/services/lrsGateway/xapiUtils.d.ts +61 -0
  237. package/dist/esm/services/lrsGateway/xapiUtils.js +84 -0
  238. package/dist/esm/services/postgresConnection/index.d.ts +35 -0
  239. package/dist/esm/services/postgresConnection/index.js +56 -0
  240. package/dist/esm/services/searchProvider/index.d.ts +31 -0
  241. package/dist/esm/services/searchProvider/index.js +1 -0
  242. package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +14 -0
  243. package/dist/esm/services/searchProvider/memorySearchTheBadWay.js +85 -0
  244. package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -0
  245. package/dist/esm/types.d.ts +31 -0
  246. package/dist/esm/types.js +1 -0
  247. package/package.json +16 -16
  248. package/script/bin/deploy.bash +8 -0
  249. package/script/bin/get-env-param.bash +3 -3
  250. package/script/bin/init-params-script.bash +10 -1
  251. package/script/bin/upload-params.bash +3 -3
  252. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,85 @@
1
+ export declare type AssertionFailed = string | Error | (() => never) | undefined;
2
+ export declare const doThrow: (failed: AssertionFailed) => never;
3
+ /**
4
+ * Asserts that the given value is true.
5
+ *
6
+ * @param x The value to assert.
7
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
8
+ * to provide some value for this for traceability. Passing an Error instead of a string
9
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
10
+ * @example const definitelyTrue = assertTrue(randomThing, new Error('thing was not true'));
11
+ * @returns the value that was asserted
12
+ */
13
+ export declare const assertTrue: <X>(x: X, failed?: AssertionFailed) => X & true;
14
+ /**
15
+ * Asserts that the given value is false.
16
+ *
17
+ * @param x The value to assert.
18
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
19
+ * to provide some value for this for traceability. Passing an Error instead of a string
20
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
21
+ * @example const definitelyFalse = assertFalse(randomThing, new Error('thing was not false'));
22
+ * @returns the value that was asserted
23
+ */
24
+ export declare const assertFalse: <X>(x: X, failed?: AssertionFailed) => X & false;
25
+ /**
26
+ * Asserts that the given value is defined.
27
+ *
28
+ * @param x The value to assert.
29
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
30
+ * to provide some value for this for traceability. Passing an Error instead of a string
31
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
32
+ * @example const definitelyDefined = assertDefined(randomThing, new Error('thing was undefined'));
33
+ * @returns the value that was asserted, with a type that excludes undefined
34
+ */
35
+ export declare const assertDefined: <X>(x: X, failed?: AssertionFailed) => Exclude<X, undefined>;
36
+ /**
37
+ * Asserts that the given value is a string.
38
+ *
39
+ * @param x The value to assert.
40
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
41
+ * to provide some value for this for traceability. Passing an Error instead of a string
42
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
43
+ * @example const definitelyAString = assertString(randomThing, new Error('thing is not a string'));
44
+ * @returns the value that was asserted
45
+ */
46
+ export declare const assertString: <X>(x: X, failed?: AssertionFailed) => string;
47
+ /**
48
+ * Asserts that the given value is not `NaN`. Does not assert that the value is a number.
49
+ *
50
+ * @param thing The value to assert.
51
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
52
+ * to provide some value for this for traceability. Passing an Error instead of a string
53
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
54
+ * @example const definitelyNotNotANumber = assertNotNaN(randomThing, new Error('thing was NaN'));
55
+ * @returns the value that was asserted
56
+ */
57
+ export declare const assertNotNaN: <T>(thing: T, failed?: AssertionFailed) => T;
58
+ /**
59
+ * @deprecated use assertNotNaN instead
60
+ */
61
+ export declare const notNaN: <T>(thing: T, failed?: AssertionFailed) => T;
62
+ /**
63
+ * Asserts that the first argument is an instance of the second.
64
+ *
65
+ * @param thing The value to assert.
66
+ * @param constructable The class to check against.
67
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
68
+ * to provide some value for this for traceability. Passing an Error instead of a string
69
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
70
+ * @example const definitelySyntaxError = assertInstanceOf(error, SyntaxError, new Error('argument was not a SyntaxError'));
71
+ * @returns the value that was asserted
72
+ */
73
+ export declare const assertInstanceOf: <T>(thing: any, constructable: Function & (new (...args: any[]) => T), failed?: AssertionFailed) => T;
74
+ /**
75
+ * Asserts that the error in the first argument is an instance of the error given as the
76
+ * second argument
77
+ *
78
+ * @param thing The value to assert.
79
+ * @param constructable The error class to check against.
80
+ * @example const definitelySyntaxError = assertInstanceOf(error, SyntaxError);
81
+ * @returns the value that was asserted
82
+ * @throws the original error if the check fails
83
+ * @see assertInstanceOf
84
+ */
85
+ export declare const assertErrorInstanceOf: <T extends Error>(thing: unknown, constructable: Function & (new (...args: any[]) => T)) => T;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /*
3
+ * all of these assertions take either a string, throw function, or nothing
4
+ * for the second argument. its STRONGLY encouraged to provide some error
5
+ * or message that explains the reason for the assertion
6
+ *
7
+ * eg:
8
+ * assertDefined(user, new UnauthorizedException())
9
+ * assertDefined(thing.otherThing, 'otherThing should be guaranteed to exist, but is missing')
10
+ *
11
+ * passing an Error instead of a string makes the first element of the resulting
12
+ * stack trace more useful, and allows you to use specific error types
13
+ * that might be handled differently.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.assertErrorInstanceOf = exports.assertInstanceOf = exports.notNaN = exports.assertNotNaN = exports.assertString = exports.assertDefined = exports.assertFalse = exports.assertTrue = exports.doThrow = void 0;
17
+ const doThrow = (failed) => {
18
+ if (typeof failed === 'string') {
19
+ throw new Error(failed);
20
+ }
21
+ if (failed instanceof Error) {
22
+ throw failed;
23
+ }
24
+ if (!failed) {
25
+ throw new Error();
26
+ }
27
+ return failed();
28
+ };
29
+ exports.doThrow = doThrow;
30
+ /**
31
+ * Asserts that the given value is true.
32
+ *
33
+ * @param x The value to assert.
34
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
35
+ * to provide some value for this for traceability. Passing an Error instead of a string
36
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
37
+ * @example const definitelyTrue = assertTrue(randomThing, new Error('thing was not true'));
38
+ * @returns the value that was asserted
39
+ */
40
+ const assertTrue = (x, failed) => {
41
+ if (typeof x !== 'boolean' || x !== true) {
42
+ return (0, exports.doThrow)(failed);
43
+ }
44
+ return x;
45
+ };
46
+ exports.assertTrue = assertTrue;
47
+ /**
48
+ * Asserts that the given value is false.
49
+ *
50
+ * @param x The value to assert.
51
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
52
+ * to provide some value for this for traceability. Passing an Error instead of a string
53
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
54
+ * @example const definitelyFalse = assertFalse(randomThing, new Error('thing was not false'));
55
+ * @returns the value that was asserted
56
+ */
57
+ const assertFalse = (x, failed) => {
58
+ if (typeof x !== 'boolean' || x !== false) {
59
+ return (0, exports.doThrow)(failed);
60
+ }
61
+ return x;
62
+ };
63
+ exports.assertFalse = assertFalse;
64
+ /**
65
+ * Asserts that the given value is defined.
66
+ *
67
+ * @param x The value to assert.
68
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
69
+ * to provide some value for this for traceability. Passing an Error instead of a string
70
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
71
+ * @example const definitelyDefined = assertDefined(randomThing, new Error('thing was undefined'));
72
+ * @returns the value that was asserted, with a type that excludes undefined
73
+ */
74
+ const assertDefined = (x, failed) => {
75
+ if (x === undefined) {
76
+ return (0, exports.doThrow)(failed);
77
+ }
78
+ return x;
79
+ };
80
+ exports.assertDefined = assertDefined;
81
+ /**
82
+ * Asserts that the given value is a string.
83
+ *
84
+ * @param x The value to assert.
85
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
86
+ * to provide some value for this for traceability. Passing an Error instead of a string
87
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
88
+ * @example const definitelyAString = assertString(randomThing, new Error('thing is not a string'));
89
+ * @returns the value that was asserted
90
+ */
91
+ const assertString = (x, failed) => {
92
+ if (typeof x !== 'string') {
93
+ return (0, exports.doThrow)(failed);
94
+ }
95
+ return x;
96
+ };
97
+ exports.assertString = assertString;
98
+ /**
99
+ * Asserts that the given value is not `NaN`. Does not assert that the value is a number.
100
+ *
101
+ * @param thing The value to assert.
102
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
103
+ * to provide some value for this for traceability. Passing an Error instead of a string
104
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
105
+ * @example const definitelyNotNotANumber = assertNotNaN(randomThing, new Error('thing was NaN'));
106
+ * @returns the value that was asserted
107
+ */
108
+ const assertNotNaN = (thing, failed) => {
109
+ if (typeof thing === 'number' && isNaN(thing)) {
110
+ return (0, exports.doThrow)(failed);
111
+ }
112
+ return thing;
113
+ };
114
+ exports.assertNotNaN = assertNotNaN;
115
+ /**
116
+ * @deprecated use assertNotNaN instead
117
+ */
118
+ exports.notNaN = exports.assertNotNaN;
119
+ /**
120
+ * Asserts that the first argument is an instance of the second.
121
+ *
122
+ * @param thing The value to assert.
123
+ * @param constructable The class to check against.
124
+ * @param failed The error to throw if the assertion fails. It is STRONGLY encouraged
125
+ * to provide some value for this for traceability. Passing an Error instead of a string
126
+ * makes the stack trace more useful and allows you to handle assertion failures differently.
127
+ * @example const definitelySyntaxError = assertInstanceOf(error, SyntaxError, new Error('argument was not a SyntaxError'));
128
+ * @returns the value that was asserted
129
+ */
130
+ const assertInstanceOf = (thing, constructable, failed) => {
131
+ if (thing instanceof constructable) {
132
+ return thing;
133
+ }
134
+ return (0, exports.doThrow)(failed);
135
+ };
136
+ exports.assertInstanceOf = assertInstanceOf;
137
+ /**
138
+ * Asserts that the error in the first argument is an instance of the error given as the
139
+ * second argument
140
+ *
141
+ * @param thing The value to assert.
142
+ * @param constructable The error class to check against.
143
+ * @example const definitelySyntaxError = assertInstanceOf(error, SyntaxError);
144
+ * @returns the value that was asserted
145
+ * @throws the original error if the check fails
146
+ * @see assertInstanceOf
147
+ */
148
+ const assertErrorInstanceOf = (thing, constructable) => {
149
+ if (thing instanceof Error) {
150
+ return (0, exports.assertInstanceOf)(thing, constructable, thing);
151
+ }
152
+ else {
153
+ // this separate branch prevents an unknown non-Error thing from being passed to the assertion as an AssertionFailed
154
+ throw new Error(`assertErrorInstanceOf received non-Error argument of type "${typeof thing}" and string representation "${thing}"`);
155
+ }
156
+ };
157
+ exports.assertErrorInstanceOf = assertErrorInstanceOf;
@@ -0,0 +1,5 @@
1
+ import { SSM } from '@aws-sdk/client-ssm';
2
+ /**
3
+ * A memoized instance of the AWS SSM client.
4
+ */
5
+ export declare const ssmService: () => SSM;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ssmService = void 0;
4
+ const client_ssm_1 = require("@aws-sdk/client-ssm");
5
+ const __1 = require("..");
6
+ /**
7
+ * A memoized instance of the AWS SSM client.
8
+ */
9
+ exports.ssmService = (0, __1.once)(() => new client_ssm_1.SSM({ apiVersion: '2012-08-10' }));
@@ -0,0 +1,10 @@
1
+ import { ConfigValueProvider } from '.';
2
+ /**
3
+ * Returns a value from the AWS Parameter Store.
4
+ *
5
+ * @param parameterName the name of the parameter; can be a literal name (string) or can itself
6
+ * be accessed via another parameter by giving a configuration value provider.
7
+ * @example const someValue = resolveConfig(awsParameterConfig('some-parameter-name'));
8
+ * @returns the configuration value provider for the value
9
+ */
10
+ export declare const awsParameterConfig: (parameterName: ConfigValueProvider<string>) => ConfigValueProvider<string>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.awsParameterConfig = void 0;
4
+ const client_ssm_1 = require("@aws-sdk/client-ssm");
5
+ const assertions_1 = require("../assertions");
6
+ const ssmService_1 = require("../aws/ssmService");
7
+ const resolveConfigValue_1 = require("./resolveConfigValue");
8
+ /**
9
+ * Returns a value from the AWS Parameter Store.
10
+ *
11
+ * @param parameterName the name of the parameter; can be a literal name (string) or can itself
12
+ * be accessed via another parameter by giving a configuration value provider.
13
+ * @example const someValue = resolveConfig(awsParameterConfig('some-parameter-name'));
14
+ * @returns the configuration value provider for the value
15
+ */
16
+ const awsParameterConfig = (parameterName) => {
17
+ return async () => {
18
+ const command = new client_ssm_1.GetParameterCommand({ Name: await (0, resolveConfigValue_1.resolveConfigValue)(parameterName), WithDecryption: true });
19
+ // send() throws ParameterNotFound if the parameter is missing,
20
+ // so it's not clear what missing Parameter or Value mean
21
+ const response = await (0, ssmService_1.ssmService)().send(command);
22
+ const parameter = (0, assertions_1.assertDefined)(response.Parameter, `aws GetParameter response missing Parameter key for ${parameterName}"`);
23
+ return (0, assertions_1.assertDefined)(parameter.Value, `aws GetParameter response missing Parameter.Value key for ${parameterName}"`);
24
+ };
25
+ };
26
+ exports.awsParameterConfig = awsParameterConfig;
@@ -0,0 +1,24 @@
1
+ import type { ConfigValueProvider } from '.';
2
+ /**
3
+ * A list of environment variables that were requested at build time. Used by webpack to
4
+ * capture build-time environment variables values.
5
+ */
6
+ export declare const ENV_BUILD_CONFIGS: string[];
7
+ /**
8
+ * Returns an environment variable from the process environment. Depending on the `type` in the
9
+ * call to get the variable, the variable's value may be what it was at build time, not at runtime.
10
+ * The return value is not the variable value itself, but rather a provider that has to be called
11
+ * to read the variable value (meaning, this is safe to call even if the variable doesn't exist,
12
+ * because someone else later needs to call the provider to get the value -- that call may explode,
13
+ * but this one won't).
14
+ *
15
+ * @param name The name of the environment variable to retrieve.
16
+ * @param type The mode for accessing the variable. Defaults to `'build'`, i.e. getting the
17
+ * variable as it was set at build time (webpack is connected here to make this possible). This
18
+ * argument can also be `'runtime'` in which case the value at build time is ignored and the
19
+ * variable is pulled live from `process.env`.
20
+ * @param [defaultValue] The default value to use if the variable is not found.
21
+ *
22
+ * @example const config = { configValue: envConfig('environment_variable_name') };
23
+ */
24
+ export declare const envConfig: (name: string, type?: "build" | "runtime" | undefined, defaultValue?: ConfigValueProvider<string> | undefined) => ConfigValueProvider<string>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.envConfig = exports.ENV_BUILD_CONFIGS = void 0;
4
+ const resolveConfigValue_1 = require("./resolveConfigValue");
5
+ /**
6
+ * A list of environment variables that were requested at build time. Used by webpack to
7
+ * capture build-time environment variables values.
8
+ */
9
+ exports.ENV_BUILD_CONFIGS = [];
10
+ /**
11
+ * Returns an environment variable from the process environment. Depending on the `type` in the
12
+ * call to get the variable, the variable's value may be what it was at build time, not at runtime.
13
+ * The return value is not the variable value itself, but rather a provider that has to be called
14
+ * to read the variable value (meaning, this is safe to call even if the variable doesn't exist,
15
+ * because someone else later needs to call the provider to get the value -- that call may explode,
16
+ * but this one won't).
17
+ *
18
+ * @param name The name of the environment variable to retrieve.
19
+ * @param type The mode for accessing the variable. Defaults to `'build'`, i.e. getting the
20
+ * variable as it was set at build time (webpack is connected here to make this possible). This
21
+ * argument can also be `'runtime'` in which case the value at build time is ignored and the
22
+ * variable is pulled live from `process.env`.
23
+ * @param [defaultValue] The default value to use if the variable is not found.
24
+ *
25
+ * @example const config = { configValue: envConfig('environment_variable_name') };
26
+ */
27
+ const envConfig = (name, type, defaultValue) => {
28
+ // this doesn't use a default parameter value because of a:
29
+ // "Regular parameters should not come after default parameters."
30
+ // error that occurs when the defaultValue optional default of `undefined`
31
+ // gets optimized out, causing a problem in cloudfront functions.
32
+ type !== null && type !== void 0 ? type : (type = 'build');
33
+ if (type === 'build') {
34
+ exports.ENV_BUILD_CONFIGS.push(name);
35
+ }
36
+ return () => {
37
+ /*global __PROCESS_ENV*/
38
+ // @ts-ignore - hack to get around the way webpack/define works
39
+ // - https://github.com/webpack/webpack/issues/14800
40
+ // - https://github.com/webpack/webpack/issues/5392
41
+ // also, spread operator not supported in cloudfront functions
42
+ const envs = Object.assign({}, process.env, typeof __PROCESS_ENV !== 'undefined' ? __PROCESS_ENV : {});
43
+ const value = envs[name];
44
+ if (value === undefined) {
45
+ if (defaultValue === undefined) {
46
+ throw new Error(`expected to find environment variable with name: ${name}`);
47
+ }
48
+ else {
49
+ return (0, resolveConfigValue_1.resolveConfigValue)(defaultValue);
50
+ }
51
+ }
52
+ else {
53
+ return value;
54
+ }
55
+ };
56
+ };
57
+ exports.envConfig = envConfig;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A simple type alias for a string that represents a configuration value. Currently only string values are supported to maintain compatibility with environment variables, but this type is future proofing against allowing other types like `number` as possible config values.
3
+ */
4
+ export declare type ConfigValue = string;
5
+ /**
6
+ * A configuration object that may contain nested configuration objects or configuration values.
7
+ */
8
+ export declare type Config = {
9
+ [key: string]: Config | ConfigValue;
10
+ };
11
+ /**
12
+ * Either a function that returns a `ConfigValue` or a `Promise` that resolves to a `ConfigValue`,
13
+ * or just a `ConfigValue`.
14
+ */
15
+ export declare type ConfigValueProvider<V extends ConfigValue = ConfigValue> = (() => Promise<V> | V) | V;
16
+ /**
17
+ * A configuration object that may contain nested configuration objects or configuration value providers.
18
+ */
19
+ export declare type ConfigProvider = {
20
+ [key: string]: ConfigProvider | ConfigValueProvider;
21
+ };
22
+ /**
23
+ * Conditional type that resolves to the type of configuration object for the given configuration
24
+ * provider. Also resolves to a config value type if the given type is a config value.
25
+ */
26
+ export declare type ConfigForConfigProvider<T> = T extends ConfigValue ? T : T extends ConfigProvider ? {
27
+ [key in keyof T]: ConfigForConfigProvider<T[key]>;
28
+ } : T extends ConfigValueProvider<infer R> ? R : never;
29
+ /**
30
+ * Conditional type that resolves to the `ConfigProvider` type for the given configuration
31
+ * type (`ConfigValue` or `Config`). The resulting type is either a `ConfigValueProvider` or
32
+ * a `ConfigProvider`.
33
+ */
34
+ export declare type ConfigProviderForConfig<T> = T extends ConfigValue ? ConfigValueProvider<T> : T extends Config ? {
35
+ [key in keyof T]: ConfigProviderForConfig<T[key]>;
36
+ } : never;
37
+ export * from './resolveConfigValue';
38
+ /**
39
+ * stub, mostly for testing. sometimes it helps please typescript to use this if you have
40
+ * two configs you want to have the same type but one is a fixed string and one is a complicated provider
41
+ *
42
+ * @example const config = { configValue: stubConfig('just-a-string') };
43
+ */
44
+ export declare const stubConfig: <V extends string>(configValue: V) => ConfigValueProvider<V>;
45
+ export * from './envConfig';
46
+ export * from './replaceConfig';
47
+ export * from './awsParameterConfig';
48
+ export * from './lambdaParameterConfig';
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.stubConfig = void 0;
18
+ __exportStar(require("./resolveConfigValue"), exports);
19
+ /*
20
+ * ===========
21
+ * re-usable config providers
22
+ * ===========
23
+ * */
24
+ /**
25
+ * stub, mostly for testing. sometimes it helps please typescript to use this if you have
26
+ * two configs you want to have the same type but one is a fixed string and one is a complicated provider
27
+ *
28
+ * @example const config = { configValue: stubConfig('just-a-string') };
29
+ */
30
+ const stubConfig = (configValue) => configValue;
31
+ exports.stubConfig = stubConfig;
32
+ __exportStar(require("./envConfig"), exports);
33
+ __exportStar(require("./replaceConfig"), exports);
34
+ __exportStar(require("./awsParameterConfig"), exports);
35
+ __exportStar(require("./lambdaParameterConfig"), exports);
@@ -0,0 +1,12 @@
1
+ import { ConfigValueProvider } from '.';
2
+ /**
3
+ * Returns a value from the AWS Parameter Store. Can only be used during in AWS Lambda, and
4
+ * requires that the AWS Parameters and Secrets Lambda Extension Layer be included in the Lambda.
5
+ * This extension has built-in caching for requested parameters.
6
+ *
7
+ * @param parameterName the name of the parameter; can be a literal name (string) or can itself
8
+ * be accessed via another parameter by giving a configuration value provider.
9
+ * @example const someValue = resolveConfig(lambdaParameterConfig('some-parameter-name'));
10
+ * @returns the configuration value provider for the value
11
+ */
12
+ export declare const lambdaParameterConfig: (parameterName: ConfigValueProvider<string>) => ConfigValueProvider<string>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.lambdaParameterConfig = void 0;
7
+ const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const assertions_1 = require("../assertions");
9
+ const helpers_1 = require("../misc/helpers");
10
+ const envConfig_1 = require("./envConfig");
11
+ const _1 = require(".");
12
+ const lambdaExtensionUrl = 'http://localhost:2773';
13
+ let lambdaExtensionReadyPromise;
14
+ /**
15
+ * Returns a value from the AWS Parameter Store. Can only be used during in AWS Lambda, and
16
+ * requires that the AWS Parameters and Secrets Lambda Extension Layer be included in the Lambda.
17
+ * This extension has built-in caching for requested parameters.
18
+ *
19
+ * @param parameterName the name of the parameter; can be a literal name (string) or can itself
20
+ * be accessed via another parameter by giving a configuration value provider.
21
+ * @example const someValue = resolveConfig(lambdaParameterConfig('some-parameter-name'));
22
+ * @returns the configuration value provider for the value
23
+ */
24
+ const lambdaParameterConfig = (parameterName) => async () => {
25
+ const token = await (0, _1.resolveConfigValue)((0, envConfig_1.envConfig)('AWS_SESSION_TOKEN', 'runtime'));
26
+ const name = await (0, _1.resolveConfigValue)(parameterName);
27
+ if (!lambdaExtensionReadyPromise) {
28
+ // This request will return 400 Bad Request,
29
+ // but we only care that it'll block until the extension is ready
30
+ lambdaExtensionReadyPromise = (0, helpers_1.retryWithDelay)(() => (0, node_fetch_1.default)(lambdaExtensionUrl));
31
+ }
32
+ await lambdaExtensionReadyPromise;
33
+ const resp = await (0, helpers_1.retryWithDelay)(() => (0, node_fetch_1.default)(
34
+ // Port 2773 is the default port for the extension
35
+ `${lambdaExtensionUrl}/systemsmanager/parameters/get?name=${name}&withDecryption=true`, { headers: { 'X-Aws-Parameters-Secrets-Token': token } }));
36
+ if (resp.ok) {
37
+ const response = await resp.json();
38
+ const parameter = (0, assertions_1.assertDefined)(response.Parameter, `aws GetParameter response missing Parameter key for ${name}"`);
39
+ return (0, assertions_1.assertDefined)(parameter.Value, `aws GetParameter response missing Parameter.Value key for ${name}"`);
40
+ }
41
+ else {
42
+ throw new Error(`HTTP Error Response ${resp.status} ${resp.statusText} while fetching parameter ${name}`);
43
+ }
44
+ };
45
+ exports.lambdaParameterConfig = lambdaParameterConfig;
@@ -0,0 +1,14 @@
1
+ import { ConfigValueProvider } from '.';
2
+ /**
3
+ * Substitutes configuration values into a provided string.
4
+ * Performs a string substitution using configuration values
5
+ * @param base The string into which substitutions will be made; contains tokens that are
6
+ * referenced in the `replacements` argument.
7
+ * @param replacements A map of tokens to configuration value providers. The providers are
8
+ * resolved and the values are substituted into the `base` string, replacing the tokens.
9
+ * @example replaceConfig('https://[host]', { '[host]': envConfig('HOST') })
10
+ * @returns the string after substitution is complete
11
+ */
12
+ export declare const replaceConfig: (base: ConfigValueProvider<string>, replacements: {
13
+ [token: string]: ConfigValueProvider<string>;
14
+ }) => ConfigValueProvider<string>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceConfig = void 0;
4
+ const resolveConfigValue_1 = require("./resolveConfigValue");
5
+ /**
6
+ * Substitutes configuration values into a provided string.
7
+ * Performs a string substitution using configuration values
8
+ * @param base The string into which substitutions will be made; contains tokens that are
9
+ * referenced in the `replacements` argument.
10
+ * @param replacements A map of tokens to configuration value providers. The providers are
11
+ * resolved and the values are substituted into the `base` string, replacing the tokens.
12
+ * @example replaceConfig('https://[host]', { '[host]': envConfig('HOST') })
13
+ * @returns the string after substitution is complete
14
+ */
15
+ const replaceConfig = (base, replacements) => {
16
+ return async () => {
17
+ const resolved = await Promise.all(Object.entries(replacements)
18
+ .map(async ([token, replacement]) => [token, await (0, resolveConfigValue_1.resolveConfigValue)(replacement)]));
19
+ return resolved.reduce((result, [token, replacement]) => result.replace(token, replacement), await (0, resolveConfigValue_1.resolveConfigValue)(base));
20
+ };
21
+ };
22
+ exports.replaceConfig = replaceConfig;
@@ -0,0 +1,5 @@
1
+ import type { ConfigValueProvider } from '.';
2
+ /**
3
+ * resolves a config value into a string, to be used inside of things that are provided configurations
4
+ */
5
+ export declare const resolveConfigValue: <V extends string>(provider: ConfigValueProvider<V>) => Promise<V>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveConfigValue = void 0;
4
+ /**
5
+ * resolves a config value into a string, to be used inside of things that are provided configurations
6
+ */
7
+ const resolveConfigValue = async (provider) => {
8
+ return typeof provider === 'function'
9
+ ? await provider()
10
+ : provider;
11
+ };
12
+ exports.resolveConfigValue = resolveConfigValue;
@@ -0,0 +1,77 @@
1
+ import type { JsonCompatibleStruct } from '../routing';
2
+ /**
3
+ * Returns true if the error is defined in this library
4
+ */
5
+ export declare const isAppError: (e: any) => e is Error & {
6
+ constructor: {
7
+ TYPE: string;
8
+ };
9
+ };
10
+ /**
11
+ * Invalid request error
12
+ *
13
+ * `InvalidRequestError.matches(error)` is a reliable way to check if an error is an
14
+ * `InvalidRequestError`; `instanceof` checks may not work if code is split into multiple bundles
15
+ */
16
+ export declare class InvalidRequestError extends Error {
17
+ static readonly TYPE = "InvalidRequestError";
18
+ static matches: (e: any) => e is typeof InvalidRequestError;
19
+ constructor(message?: string);
20
+ }
21
+ /**
22
+ * Validation Error
23
+ *
24
+ * `ValidationError.matches(error)` is a reliable way to check if an error is an
25
+ * `ValidationError`; `instanceof` checks may not work if code is split into multiple bundles
26
+ */
27
+ export declare class ValidationError extends Error {
28
+ static readonly TYPE = "ValidationError";
29
+ static matches: (e: any) => e is typeof ValidationError;
30
+ private data;
31
+ constructor(data: JsonCompatibleStruct);
32
+ getData(): JsonCompatibleStruct;
33
+ }
34
+ /**
35
+ * Unauthorized error
36
+ *
37
+ * `UnauthorizedError.matches(error)` is a reliable way to check if an error is an
38
+ * `UnauthorizedError`; `instanceof` checks may not work if code is split into multiple bundles
39
+ */
40
+ export declare class UnauthorizedError extends Error {
41
+ static readonly TYPE = "UnauthorizedError";
42
+ static matches: (e: any) => e is typeof UnauthorizedError;
43
+ constructor(message?: string);
44
+ }
45
+ /**
46
+ * Forbidden error
47
+ *
48
+ * `ForbiddenError.matches(error)` is a reliable way to check if an error is a
49
+ * `ForbiddenError`; `instanceof` checks may not work if code is split into multiple bundles
50
+ */
51
+ export declare class ForbiddenError extends Error {
52
+ static readonly TYPE = "ForbiddenError";
53
+ static matches: (e: any) => e is typeof ForbiddenError;
54
+ constructor(message?: string);
55
+ }
56
+ /**
57
+ * Not found error
58
+ *
59
+ * `NotFoundError.matches(error)` is a reliable way to check if an error is a
60
+ * `NotFoundError`; `instanceof` checks may not work if code is split into multiple bundles
61
+ */
62
+ export declare class NotFoundError extends Error {
63
+ static readonly TYPE = "NotFoundError";
64
+ static matches: (e: any) => e is typeof NotFoundError;
65
+ constructor(message?: string);
66
+ }
67
+ /**
68
+ * Session expired error
69
+ *
70
+ * `SessionExpiredError.matches(error)` is a reliable way to check if an error is a
71
+ * `SessionExpiredError`; `instanceof` checks may not work if code is split into multiple bundles
72
+ */
73
+ export declare class SessionExpiredError extends Error {
74
+ static readonly TYPE = "SessionExpiredError";
75
+ static matches: (e: any) => e is typeof SessionExpiredError;
76
+ constructor(message?: string);
77
+ }