@openstax/ts-utils 1.43.2 → 1.44.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 (230) hide show
  1. package/dist/cjs/aws/ssmService.js +2 -2
  2. package/dist/cjs/config/awsParameterConfig.d.ts +1 -1
  3. package/dist/cjs/config/awsParameterConfig.js +7 -7
  4. package/dist/cjs/config/envConfig.d.ts +1 -1
  5. package/dist/cjs/config/envConfig.js +2 -2
  6. package/dist/cjs/config/index.d.ts +5 -5
  7. package/dist/cjs/config/index.js +5 -5
  8. package/dist/cjs/config/lambdaParameterConfig.d.ts +1 -1
  9. package/dist/cjs/config/lambdaParameterConfig.js +10 -10
  10. package/dist/cjs/config/replaceConfig.d.ts +1 -1
  11. package/dist/cjs/config/replaceConfig.js +3 -3
  12. package/dist/cjs/config/resolveConfigValue.d.ts +1 -1
  13. package/dist/cjs/errors/index.d.ts +1 -1
  14. package/dist/cjs/fetch/fetchStatusRetry.d.ts +2 -2
  15. package/dist/cjs/fetch/fetchStatusRetry.js +2 -2
  16. package/dist/cjs/fetch/index.d.ts +1 -1
  17. package/dist/cjs/index.d.ts +5 -4
  18. package/dist/cjs/index.js +5 -4
  19. package/dist/cjs/middleware/apiErrorHandler.d.ts +3 -3
  20. package/dist/cjs/middleware/apiErrorHandler.js +12 -12
  21. package/dist/cjs/middleware/apiSlowResponseMiddleware.d.ts +3 -3
  22. package/dist/cjs/middleware/apiSlowResponseMiddleware.js +9 -9
  23. package/dist/cjs/middleware/index.d.ts +1 -1
  24. package/dist/cjs/middleware/lambdaCorsResponseMiddleware.d.ts +2 -2
  25. package/dist/cjs/middleware/lambdaCorsResponseMiddleware.js +5 -5
  26. package/dist/cjs/middleware/throwNotFoundMiddleware.js +2 -2
  27. package/dist/cjs/misc/helpers.d.ts +1 -1
  28. package/dist/cjs/misc/jwks.js +3 -3
  29. package/dist/cjs/misc/merge.d.ts +1 -1
  30. package/dist/cjs/misc/merge.js +2 -2
  31. package/dist/cjs/misc/timingSafeCompareStrings.d.ts +5 -0
  32. package/dist/cjs/misc/timingSafeCompareStrings.js +15 -0
  33. package/dist/cjs/pagination/index.d.ts +1 -1
  34. package/dist/cjs/pagination/index.js +10 -10
  35. package/dist/cjs/routing/helpers.d.ts +1 -1
  36. package/dist/cjs/routing/helpers.js +7 -7
  37. package/dist/cjs/routing/index.d.ts +2 -2
  38. package/dist/cjs/routing/index.js +6 -6
  39. package/dist/cjs/routing/lambdaBatchRequestHandler.d.ts +2 -2
  40. package/dist/cjs/routing/lambdaBatchRequestHandler.js +6 -6
  41. package/dist/cjs/routing/validators/zod.js +2 -2
  42. package/dist/cjs/services/accountsGateway/index.d.ts +5 -5
  43. package/dist/cjs/services/accountsGateway/index.js +18 -18
  44. package/dist/cjs/services/apiGateway/index.d.ts +5 -5
  45. package/dist/cjs/services/apiGateway/index.js +12 -12
  46. package/dist/cjs/services/authProvider/browser.d.ts +4 -4
  47. package/dist/cjs/services/authProvider/browser.js +13 -13
  48. package/dist/cjs/services/authProvider/decryption.d.ts +3 -3
  49. package/dist/cjs/services/authProvider/decryption.js +17 -17
  50. package/dist/cjs/services/authProvider/index.d.ts +3 -3
  51. package/dist/cjs/services/authProvider/index.js +7 -7
  52. package/dist/cjs/services/authProvider/launchToken.d.ts +4 -4
  53. package/dist/cjs/services/authProvider/launchToken.js +6 -6
  54. package/dist/cjs/services/authProvider/subrequest.d.ts +3 -3
  55. package/dist/cjs/services/authProvider/subrequest.js +12 -12
  56. package/dist/cjs/services/authProvider/utils/decryptAndVerify.d.ts +1 -1
  57. package/dist/cjs/services/authProvider/utils/decryptAndVerify.js +3 -3
  58. package/dist/cjs/services/authProvider/utils/embeddedAuthProvider.d.ts +2 -2
  59. package/dist/cjs/services/authProvider/utils/userRoleValidator.d.ts +3 -3
  60. package/dist/cjs/services/authProvider/utils/userRoleValidator.js +7 -7
  61. package/dist/cjs/services/authProvider/utils/userSubrequest.d.ts +2 -2
  62. package/dist/cjs/services/documentStore/dynamoEncoding.d.ts +1 -1
  63. package/dist/cjs/services/documentStore/dynamoEncoding.js +2 -2
  64. package/dist/cjs/services/documentStore/unversioned/dynamodb.d.ts +2 -2
  65. package/dist/cjs/services/documentStore/unversioned/dynamodb.js +30 -30
  66. package/dist/cjs/services/documentStore/unversioned/file-system.d.ts +2 -2
  67. package/dist/cjs/services/documentStore/unversioned/file-system.js +13 -13
  68. package/dist/cjs/services/documentStore/unversioned/index.d.ts +1 -1
  69. package/dist/cjs/services/documentStore/versioned/dynamodb.d.ts +3 -3
  70. package/dist/cjs/services/documentStore/versioned/dynamodb.js +17 -17
  71. package/dist/cjs/services/documentStore/versioned/file-system.d.ts +3 -3
  72. package/dist/cjs/services/documentStore/versioned/file-system.js +2 -2
  73. package/dist/cjs/services/documentStore/versioned/index.d.ts +2 -2
  74. package/dist/cjs/services/exercisesGateway/index.d.ts +2 -2
  75. package/dist/cjs/services/exercisesGateway/index.js +14 -14
  76. package/dist/cjs/services/fileServer/index.js +3 -3
  77. package/dist/cjs/services/fileServer/localFileServer.d.ts +2 -2
  78. package/dist/cjs/services/fileServer/localFileServer.js +11 -11
  79. package/dist/cjs/services/fileServer/s3FileServer.d.ts +2 -2
  80. package/dist/cjs/services/fileServer/s3FileServer.js +13 -13
  81. package/dist/cjs/services/httpMessageVerifier/index.d.ts +1 -1
  82. package/dist/cjs/services/httpMessageVerifier/index.js +19 -19
  83. package/dist/cjs/services/launchParams/index.d.ts +2 -2
  84. package/dist/cjs/services/launchParams/index.js +4 -4
  85. package/dist/cjs/services/launchParams/signer.d.ts +2 -2
  86. package/dist/cjs/services/launchParams/signer.js +9 -9
  87. package/dist/cjs/services/launchParams/verifier.d.ts +1 -1
  88. package/dist/cjs/services/launchParams/verifier.js +11 -11
  89. package/dist/cjs/services/logger/console.d.ts +1 -1
  90. package/dist/cjs/services/logger/console.js +2 -2
  91. package/dist/cjs/services/logger/index.d.ts +1 -1
  92. package/dist/cjs/services/lrsGateway/addStatementDefaultFields.d.ts +1 -1
  93. package/dist/cjs/services/lrsGateway/attempt-utils.d.ts +7 -7
  94. package/dist/cjs/services/lrsGateway/batching.d.ts +2 -2
  95. package/dist/cjs/services/lrsGateway/batching.js +2 -2
  96. package/dist/cjs/services/lrsGateway/file-system.d.ts +3 -3
  97. package/dist/cjs/services/lrsGateway/file-system.js +10 -10
  98. package/dist/cjs/services/lrsGateway/index.d.ts +5 -5
  99. package/dist/cjs/services/lrsGateway/index.js +23 -23
  100. package/dist/cjs/services/lrsGateway/xapiUtils.d.ts +4 -4
  101. package/dist/cjs/services/lrsGateway/xapiUtils.js +8 -8
  102. package/dist/cjs/services/postgresConnection/index.d.ts +2 -2
  103. package/dist/cjs/services/postgresConnection/index.js +14 -14
  104. package/dist/cjs/services/queueProvider/local.d.ts +2 -2
  105. package/dist/cjs/services/queueProvider/local.js +6 -6
  106. package/dist/cjs/services/queueProvider/sqs.d.ts +2 -2
  107. package/dist/cjs/services/queueProvider/sqs.js +7 -7
  108. package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +1 -1
  109. package/dist/cjs/services/searchProvider/memorySearchTheBadWay.js +9 -9
  110. package/dist/cjs/services/searchProvider/openSearch.d.ts +2 -2
  111. package/dist/cjs/services/searchProvider/openSearch.js +8 -8
  112. package/dist/cjs/services/searchProvider/streamIndexer.d.ts +2 -2
  113. package/dist/cjs/services/searchProvider/streamIndexer.js +3 -3
  114. package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
  115. package/dist/esm/aws/ssmService.js +1 -1
  116. package/dist/esm/config/awsParameterConfig.d.ts +1 -1
  117. package/dist/esm/config/awsParameterConfig.js +3 -3
  118. package/dist/esm/config/envConfig.d.ts +1 -1
  119. package/dist/esm/config/envConfig.js +1 -1
  120. package/dist/esm/config/index.d.ts +5 -5
  121. package/dist/esm/config/index.js +5 -5
  122. package/dist/esm/config/lambdaParameterConfig.d.ts +1 -1
  123. package/dist/esm/config/lambdaParameterConfig.js +4 -4
  124. package/dist/esm/config/replaceConfig.d.ts +1 -1
  125. package/dist/esm/config/replaceConfig.js +1 -1
  126. package/dist/esm/config/resolveConfigValue.d.ts +1 -1
  127. package/dist/esm/errors/index.d.ts +1 -1
  128. package/dist/esm/fetch/fetchStatusRetry.d.ts +2 -2
  129. package/dist/esm/fetch/fetchStatusRetry.js +1 -1
  130. package/dist/esm/fetch/index.d.ts +1 -1
  131. package/dist/esm/index.d.ts +5 -4
  132. package/dist/esm/index.js +5 -4
  133. package/dist/esm/middleware/apiErrorHandler.d.ts +3 -3
  134. package/dist/esm/middleware/apiErrorHandler.js +3 -3
  135. package/dist/esm/middleware/apiSlowResponseMiddleware.d.ts +3 -3
  136. package/dist/esm/middleware/apiSlowResponseMiddleware.js +4 -4
  137. package/dist/esm/middleware/index.d.ts +1 -1
  138. package/dist/esm/middleware/lambdaCorsResponseMiddleware.d.ts +2 -2
  139. package/dist/esm/middleware/lambdaCorsResponseMiddleware.js +3 -3
  140. package/dist/esm/middleware/throwNotFoundMiddleware.js +1 -1
  141. package/dist/esm/misc/helpers.d.ts +1 -1
  142. package/dist/esm/misc/jwks.js +1 -1
  143. package/dist/esm/misc/merge.d.ts +1 -1
  144. package/dist/esm/misc/merge.js +1 -1
  145. package/dist/esm/misc/timingSafeCompareStrings.d.ts +5 -0
  146. package/dist/esm/misc/timingSafeCompareStrings.js +11 -0
  147. package/dist/esm/pagination/index.d.ts +1 -1
  148. package/dist/esm/pagination/index.js +3 -3
  149. package/dist/esm/routing/helpers.d.ts +1 -1
  150. package/dist/esm/routing/helpers.js +3 -3
  151. package/dist/esm/routing/index.d.ts +2 -2
  152. package/dist/esm/routing/index.js +3 -3
  153. package/dist/esm/routing/lambdaBatchRequestHandler.d.ts +2 -2
  154. package/dist/esm/routing/lambdaBatchRequestHandler.js +3 -3
  155. package/dist/esm/routing/validators/zod.js +1 -1
  156. package/dist/esm/services/accountsGateway/index.d.ts +5 -5
  157. package/dist/esm/services/accountsGateway/index.js +5 -5
  158. package/dist/esm/services/apiGateway/index.d.ts +5 -5
  159. package/dist/esm/services/apiGateway/index.js +5 -5
  160. package/dist/esm/services/authProvider/browser.d.ts +4 -4
  161. package/dist/esm/services/authProvider/browser.js +5 -5
  162. package/dist/esm/services/authProvider/decryption.d.ts +3 -3
  163. package/dist/esm/services/authProvider/decryption.js +7 -7
  164. package/dist/esm/services/authProvider/index.d.ts +3 -3
  165. package/dist/esm/services/authProvider/index.js +2 -2
  166. package/dist/esm/services/authProvider/launchToken.d.ts +4 -4
  167. package/dist/esm/services/authProvider/launchToken.js +2 -2
  168. package/dist/esm/services/authProvider/subrequest.d.ts +3 -3
  169. package/dist/esm/services/authProvider/subrequest.js +5 -5
  170. package/dist/esm/services/authProvider/utils/decryptAndVerify.d.ts +1 -1
  171. package/dist/esm/services/authProvider/utils/decryptAndVerify.js +1 -1
  172. package/dist/esm/services/authProvider/utils/embeddedAuthProvider.d.ts +2 -2
  173. package/dist/esm/services/authProvider/utils/userRoleValidator.d.ts +3 -3
  174. package/dist/esm/services/authProvider/utils/userRoleValidator.js +4 -4
  175. package/dist/esm/services/authProvider/utils/userSubrequest.d.ts +2 -2
  176. package/dist/esm/services/documentStore/dynamoEncoding.d.ts +1 -1
  177. package/dist/esm/services/documentStore/dynamoEncoding.js +1 -1
  178. package/dist/esm/services/documentStore/unversioned/dynamodb.d.ts +2 -2
  179. package/dist/esm/services/documentStore/unversioned/dynamodb.js +5 -5
  180. package/dist/esm/services/documentStore/unversioned/file-system.d.ts +2 -2
  181. package/dist/esm/services/documentStore/unversioned/file-system.js +4 -4
  182. package/dist/esm/services/documentStore/unversioned/index.d.ts +1 -1
  183. package/dist/esm/services/documentStore/versioned/dynamodb.d.ts +3 -3
  184. package/dist/esm/services/documentStore/versioned/dynamodb.js +4 -4
  185. package/dist/esm/services/documentStore/versioned/file-system.d.ts +3 -3
  186. package/dist/esm/services/documentStore/versioned/file-system.js +1 -1
  187. package/dist/esm/services/documentStore/versioned/index.d.ts +2 -2
  188. package/dist/esm/services/exercisesGateway/index.d.ts +2 -2
  189. package/dist/esm/services/exercisesGateway/index.js +5 -5
  190. package/dist/esm/services/fileServer/index.js +1 -1
  191. package/dist/esm/services/fileServer/localFileServer.d.ts +2 -2
  192. package/dist/esm/services/fileServer/localFileServer.js +4 -4
  193. package/dist/esm/services/fileServer/s3FileServer.d.ts +2 -2
  194. package/dist/esm/services/fileServer/s3FileServer.js +4 -4
  195. package/dist/esm/services/httpMessageVerifier/index.d.ts +1 -1
  196. package/dist/esm/services/httpMessageVerifier/index.js +5 -5
  197. package/dist/esm/services/launchParams/index.d.ts +2 -2
  198. package/dist/esm/services/launchParams/index.js +2 -2
  199. package/dist/esm/services/launchParams/signer.d.ts +2 -2
  200. package/dist/esm/services/launchParams/signer.js +3 -3
  201. package/dist/esm/services/launchParams/verifier.d.ts +1 -1
  202. package/dist/esm/services/launchParams/verifier.js +5 -5
  203. package/dist/esm/services/logger/console.d.ts +1 -1
  204. package/dist/esm/services/logger/console.js +1 -1
  205. package/dist/esm/services/logger/index.d.ts +1 -1
  206. package/dist/esm/services/lrsGateway/addStatementDefaultFields.d.ts +1 -1
  207. package/dist/esm/services/lrsGateway/attempt-utils.d.ts +7 -7
  208. package/dist/esm/services/lrsGateway/batching.d.ts +2 -2
  209. package/dist/esm/services/lrsGateway/batching.js +1 -1
  210. package/dist/esm/services/lrsGateway/file-system.d.ts +3 -3
  211. package/dist/esm/services/lrsGateway/file-system.js +5 -5
  212. package/dist/esm/services/lrsGateway/index.d.ts +5 -5
  213. package/dist/esm/services/lrsGateway/index.js +10 -10
  214. package/dist/esm/services/lrsGateway/xapiUtils.d.ts +4 -4
  215. package/dist/esm/services/lrsGateway/xapiUtils.js +2 -2
  216. package/dist/esm/services/postgresConnection/index.d.ts +2 -2
  217. package/dist/esm/services/postgresConnection/index.js +4 -4
  218. package/dist/esm/services/queueProvider/local.d.ts +2 -2
  219. package/dist/esm/services/queueProvider/local.js +3 -3
  220. package/dist/esm/services/queueProvider/sqs.d.ts +2 -2
  221. package/dist/esm/services/queueProvider/sqs.js +3 -3
  222. package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +1 -1
  223. package/dist/esm/services/searchProvider/memorySearchTheBadWay.js +3 -3
  224. package/dist/esm/services/searchProvider/openSearch.d.ts +2 -2
  225. package/dist/esm/services/searchProvider/openSearch.js +3 -3
  226. package/dist/esm/services/searchProvider/streamIndexer.d.ts +2 -2
  227. package/dist/esm/services/searchProvider/streamIndexer.js +1 -1
  228. package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
  229. package/package.json +1 -1
  230. package/script/bin/.init-params-script.bash.swp +0 -0
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.subrequestAuthProvider = void 0;
4
- const index_js_1 = require("../../index.js");
5
- const index_js_2 = require("../../config/index.js");
6
- const index_js_3 = require("../../guards/index.js");
7
- const userSubrequest_js_1 = require("./utils/userSubrequest.js");
8
- const index_js_4 = require("./index.js");
4
+ const __1 = require("../..");
5
+ const config_1 = require("../../config");
6
+ const guards_1 = require("../../guards");
7
+ const userSubrequest_1 = require("./utils/userSubrequest");
8
+ const _1 = require(".");
9
9
  const subrequestAuthProvider = (initializer) => (configProvider) => {
10
- const config = configProvider[(0, index_js_3.ifDefined)(initializer.configSpace, 'subrequest')];
11
- const cookieName = (0, index_js_1.once)(() => (0, index_js_2.resolveConfigValue)(config.cookieName));
12
- const accountsBase = (0, index_js_1.once)(() => (0, index_js_2.resolveConfigValue)(config.accountsBase));
10
+ const config = configProvider[(0, guards_1.ifDefined)(initializer.configSpace, 'subrequest')];
11
+ const cookieName = (0, __1.once)(() => (0, config_1.resolveConfigValue)(config.cookieName));
12
+ const accountsBase = (0, __1.once)(() => (0, config_1.resolveConfigValue)(config.accountsBase));
13
13
  return ({ request, logger }) => {
14
14
  let user;
15
- const getAuthToken = async () => (0, index_js_4.getAuthTokenOrCookie)(request, await cookieName())[0];
15
+ const getAuthToken = async () => (0, _1.getAuthTokenOrCookie)(request, await cookieName())[0];
16
16
  const getAuthorizedFetchConfig = async () => {
17
- const [token, headers] = (0, index_js_4.getAuthTokenOrCookie)(request, await cookieName());
17
+ const [token, headers] = (0, _1.getAuthTokenOrCookie)(request, await cookieName());
18
18
  if (!token) {
19
19
  return {};
20
20
  }
@@ -22,11 +22,11 @@ const subrequestAuthProvider = (initializer) => (configProvider) => {
22
22
  };
23
23
  const loadUser = async () => {
24
24
  const resolvedCookieName = await cookieName();
25
- const [token] = (0, index_js_4.getAuthTokenOrCookie)(request, resolvedCookieName);
25
+ const [token] = (0, _1.getAuthTokenOrCookie)(request, resolvedCookieName);
26
26
  if (!token) {
27
27
  return undefined;
28
28
  }
29
- const user = await (0, userSubrequest_js_1.loadUserData)(initializer.fetch, await accountsBase(), resolvedCookieName, token);
29
+ const user = await (0, userSubrequest_1.loadUserData)(initializer.fetch, await accountsBase(), resolvedCookieName, token);
30
30
  if (user) {
31
31
  logger.setContext({ user: user.uuid });
32
32
  return user;
@@ -1,4 +1,4 @@
1
- import type { User } from '../index.js';
1
+ import type { User } from '..';
2
2
  export declare const decryptJwe: (jwe: string, encryptionPrivateKey: Buffer | string) => string | undefined;
3
3
  type MaybeAccountsSSOToken = {
4
4
  iss?: string;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decryptAndVerify = exports.verifyJws = exports.decryptJwe = void 0;
4
4
  const crypto_1 = require("crypto");
5
- const index_js_1 = require("../../../guards/index.js");
5
+ const guards_1 = require("../../../guards");
6
6
  const decryptJwe = (jwe, encryptionPrivateKey) => {
7
7
  const jweParts = jwe.split('.', 6);
8
8
  if (jweParts.length !== 5 || jweParts[1]) {
@@ -73,8 +73,8 @@ const decryptAndVerify = (token, encryptionPrivateKey, signaturePublicKey) => {
73
73
  const payload = (0, exports.verifyJws)(jws, signaturePublicKey);
74
74
  // Ensure payload contains all the claims we expect
75
75
  // Normally "sub" would be a string but Accounts uses an object for it instead
76
- if (!(0, index_js_1.isPlainObject)(payload) ||
77
- !(0, index_js_1.isPlainObject)(payload.sub) || !payload.sub.uuid ||
76
+ if (!(0, guards_1.isPlainObject)(payload) ||
77
+ !(0, guards_1.isPlainObject)(payload.sub) || !payload.sub.uuid ||
78
78
  payload.iss !== issuer ||
79
79
  payload.aud !== audience ||
80
80
  !payload.exp ||
@@ -1,5 +1,5 @@
1
- import { User } from '../index.js';
2
- import { Window } from '../browser.js';
1
+ import { User } from '..';
2
+ import { Window } from '../browser';
3
3
  export type UserData<T = User> = {
4
4
  user?: T;
5
5
  token: string | null;
@@ -1,6 +1,6 @@
1
- import { AuthProvider } from '../index.js';
2
- import { AssertionFailed } from '../../../assertions/index.js';
3
- import { ConfigProviderForConfig } from '../../../config/index.js';
1
+ import { AuthProvider } from '..';
2
+ import { AssertionFailed } from '../../../assertions';
3
+ import { ConfigProviderForConfig } from '../../../config';
4
4
  type Config = {
5
5
  application: string;
6
6
  };
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createUserRoleValidator = void 0;
4
- const index_js_1 = require("../../../assertions/index.js");
5
- const resolveConfigValue_js_1 = require("../../../config/resolveConfigValue.js");
6
- const index_js_2 = require("../../../errors/index.js");
7
- const helpers_js_1 = require("../../../misc/helpers.js");
4
+ const assertions_1 = require("../../../assertions");
5
+ const resolveConfigValue_1 = require("../../../config/resolveConfigValue");
6
+ const errors_1 = require("../../../errors");
7
+ const helpers_1 = require("../../../misc/helpers");
8
8
  const createUserRoleValidator = (auth, config) => {
9
- const application = (0, helpers_js_1.once)(() => (0, resolveConfigValue_js_1.resolveConfigValue)(config.application));
9
+ const application = (0, helpers_1.once)(() => (0, resolveConfigValue_1.resolveConfigValue)(config.application));
10
10
  const getUserRoles = async () => {
11
11
  var _a;
12
12
  const user = await auth.loadUserData();
@@ -23,9 +23,9 @@ const createUserRoleValidator = (auth, config) => {
23
23
  }
24
24
  return true;
25
25
  };
26
- const assertUserRole = async (role, fail = new index_js_2.UnauthorizedError()) => {
26
+ const assertUserRole = async (role, fail = new errors_1.UnauthorizedError()) => {
27
27
  if (!await userHasRole(role)) {
28
- return (0, index_js_1.doThrow)(fail);
28
+ return (0, assertions_1.doThrow)(fail);
29
29
  }
30
30
  };
31
31
  return {
@@ -1,3 +1,3 @@
1
- import { ApiUser } from '../index.js';
2
- import { GenericFetch } from '../../../fetch/index.js';
1
+ import { ApiUser } from '..';
2
+ import { GenericFetch } from '../../../fetch';
3
3
  export declare const loadUserData: (fetch: GenericFetch, accountsBase: string, cookieName: string, token: string) => Promise<ApiUser | undefined>;
@@ -1,5 +1,5 @@
1
1
  import { AttributeValue } from '@aws-sdk/client-dynamodb';
2
- import { DocumentBaseType, DocumentBaseValueTypes } from './index.js';
2
+ import { DocumentBaseType, DocumentBaseValueTypes } from '.';
3
3
  export declare const encodeDynamoAttribute: (value: DocumentBaseValueTypes) => AttributeValue;
4
4
  export declare const encodeDynamoDocument: (base: DocumentBaseType) => {
5
5
  [k: string]: AttributeValue;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decodeDynamoDocument = exports.decodeDynamoAttribute = exports.encodeDynamoDocument = exports.encodeDynamoAttribute = void 0;
4
- const index_js_1 = require("../../guards/index.js");
4
+ const guards_1 = require("../../guards");
5
5
  const encodeDynamoAttribute = (value) => {
6
6
  if (typeof value === 'string') {
7
7
  return { S: value };
@@ -18,7 +18,7 @@ const encodeDynamoAttribute = (value) => {
18
18
  if (Array.isArray(value)) {
19
19
  return { L: value.map(exports.encodeDynamoAttribute) };
20
20
  }
21
- if ((0, index_js_1.isPlainObject)(value)) {
21
+ if ((0, guards_1.isPlainObject)(value)) {
22
22
  return { M: (0, exports.encodeDynamoDocument)(value) };
23
23
  }
24
24
  throw new Error(`unknown attribute type ${typeof value} with value ${value}.`);
@@ -1,6 +1,6 @@
1
1
  import { DynamoDB } from '@aws-sdk/client-dynamodb';
2
- import { Config, TDocument } from '../index.js';
3
- import { ConfigProviderForConfig } from '../../../config/index.js';
2
+ import { Config, TDocument } from '..';
3
+ import { ConfigProviderForConfig } from '../../../config';
4
4
  interface Initializer<C> {
5
5
  configSpace?: C;
6
6
  dynamoClient?: DynamoDB;
@@ -6,23 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.dynamoUnversionedDocumentStore = void 0;
7
7
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
8
8
  const tiny_async_pool_1 = __importDefault(require("tiny-async-pool"));
9
- const index_js_1 = require("../../../index.js");
10
- const index_js_2 = require("../../../config/index.js");
11
- const index_js_3 = require("../../../errors/index.js");
12
- const index_js_4 = require("../../../guards/index.js");
13
- const dynamoEncoding_js_1 = require("../dynamoEncoding.js");
9
+ const __1 = require("../../..");
10
+ const config_1 = require("../../../config");
11
+ const errors_1 = require("../../../errors");
12
+ const guards_1 = require("../../../guards");
13
+ const dynamoEncoding_1 = require("../dynamoEncoding");
14
14
  const dynamoUnversionedDocumentStore = (initializer) => {
15
- const init = (0, index_js_4.ifDefined)(initializer, {});
16
- const dynamodb = (0, index_js_1.once)(() => { var _a; return (_a = init.dynamoClient) !== null && _a !== void 0 ? _a : new client_dynamodb_1.DynamoDB({ apiVersion: '2012-08-10' }); });
15
+ const init = (0, guards_1.ifDefined)(initializer, {});
16
+ const dynamodb = (0, __1.once)(() => { var _a; return (_a = init.dynamoClient) !== null && _a !== void 0 ? _a : new client_dynamodb_1.DynamoDB({ apiVersion: '2012-08-10' }); });
17
17
  return () => (configProvider) => (_, hashKey, options) => {
18
- const tableName = (0, index_js_1.once)(() => (0, index_js_2.resolveConfigValue)(configProvider[(0, index_js_4.ifDefined)(init.configSpace, 'dynamodb')].tableName));
18
+ const tableName = (0, __1.once)(() => (0, config_1.resolveConfigValue)(configProvider[(0, guards_1.ifDefined)(init.configSpace, 'dynamodb')].tableName));
19
19
  return {
20
20
  loadAllDocumentsTheBadWay: async () => {
21
21
  const loadAllResults = async (ExclusiveStartKey) => {
22
22
  var _a, _b;
23
23
  const cmd = new client_dynamodb_1.ScanCommand({ TableName: await tableName(), ExclusiveStartKey });
24
24
  const result = await dynamodb().send(cmd);
25
- const resultItems = (_b = (_a = result.Items) === null || _a === void 0 ? void 0 : _a.map((item) => (0, dynamoEncoding_js_1.decodeDynamoDocument)(item))) !== null && _b !== void 0 ? _b : [];
25
+ const resultItems = (_b = (_a = result.Items) === null || _a === void 0 ? void 0 : _a.map((item) => (0, dynamoEncoding_1.decodeDynamoDocument)(item))) !== null && _b !== void 0 ? _b : [];
26
26
  if (result.LastEvaluatedKey) {
27
27
  return [...resultItems, ...await loadAllResults(result.LastEvaluatedKey)];
28
28
  }
@@ -45,14 +45,14 @@ const dynamoUnversionedDocumentStore = (initializer) => {
45
45
  ExclusiveStartKey,
46
46
  KeyConditionExpression: '#hk = :hkv',
47
47
  ExpressionAttributeValues: {
48
- ':hkv': (0, dynamoEncoding_js_1.encodeDynamoAttribute)(value),
48
+ ':hkv': (0, dynamoEncoding_1.encodeDynamoAttribute)(value),
49
49
  },
50
50
  ExpressionAttributeNames: {
51
51
  '#hk': key.toString(),
52
52
  },
53
53
  });
54
54
  const response = await dynamodb().send(cmd);
55
- const items = (_b = (_a = response.Items) === null || _a === void 0 ? void 0 : _a.map((item) => (0, dynamoEncoding_js_1.decodeDynamoDocument)(item))) !== null && _b !== void 0 ? _b : [];
55
+ const items = (_b = (_a = response.Items) === null || _a === void 0 ? void 0 : _a.map((item) => (0, dynamoEncoding_1.decodeDynamoDocument)(item))) !== null && _b !== void 0 ? _b : [];
56
56
  const nextPageToken = response.LastEvaluatedKey;
57
57
  return {
58
58
  items,
@@ -66,28 +66,28 @@ const dynamoUnversionedDocumentStore = (initializer) => {
66
66
  const key = hashKey.toString();
67
67
  const getBatches = async (requestItems) => {
68
68
  const cmd = new client_dynamodb_1.BatchGetItemCommand({
69
- RequestItems: requestItems !== null && requestItems !== void 0 ? requestItems : { [table]: { Keys: ids.map((id) => ({ [key]: (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id) })) } },
69
+ RequestItems: requestItems !== null && requestItems !== void 0 ? requestItems : { [table]: { Keys: ids.map((id) => ({ [key]: (0, dynamoEncoding_1.encodeDynamoAttribute)(id) })) } },
70
70
  });
71
71
  const response = await dynamodb().send(cmd);
72
72
  const currentResponses = response.Responses ?
73
- response.Responses[table].map(response => (0, dynamoEncoding_js_1.decodeDynamoDocument)(response)) : [];
73
+ response.Responses[table].map(response => (0, dynamoEncoding_1.decodeDynamoDocument)(response)) : [];
74
74
  return currentResponses.concat(response.UnprocessedKeys ? await getBatches(response.UnprocessedKeys) : []);
75
75
  };
76
76
  return getBatches();
77
77
  },
78
78
  getItem: async (id) => {
79
79
  const cmd = new client_dynamodb_1.GetItemCommand({
80
- Key: { [hashKey.toString()]: (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id) },
80
+ Key: { [hashKey.toString()]: (0, dynamoEncoding_1.encodeDynamoAttribute)(id) },
81
81
  TableName: await tableName(),
82
82
  });
83
- return dynamodb().send(cmd).then(result => result.Item ? (0, dynamoEncoding_js_1.decodeDynamoDocument)(result.Item) : undefined);
83
+ return dynamodb().send(cmd).then(result => result.Item ? (0, dynamoEncoding_1.decodeDynamoDocument)(result.Item) : undefined);
84
84
  },
85
85
  /* atomically increments the given item attribute by 1 */
86
86
  incrementItemAttribute: async (id, attribute) => {
87
87
  const key = hashKey.toString();
88
88
  const field = attribute.toString();
89
89
  const cmd = new client_dynamodb_1.UpdateItemCommand({
90
- Key: { [key]: (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id) },
90
+ Key: { [key]: (0, dynamoEncoding_1.encodeDynamoAttribute)(id) },
91
91
  TableName: await tableName(),
92
92
  UpdateExpression: 'ADD #f :one',
93
93
  ConditionExpression: 'attribute_exists(#k)',
@@ -99,17 +99,17 @@ const dynamoUnversionedDocumentStore = (initializer) => {
99
99
  var _a, _b, _c;
100
100
  const result = (_b = (_a = item.Attributes) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b['N'];
101
101
  if (!item.Attributes) {
102
- throw new index_js_3.NotFoundError(`Item with ${key} "${id}" does not exist`);
102
+ throw new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`);
103
103
  }
104
104
  if (!result) {
105
- throw new index_js_3.NotFoundError(`Item with ${key} "${id}" did not produce field "${field}"`);
105
+ throw new errors_1.NotFoundError(`Item with ${key} "${id}" did not produce field "${field}"`);
106
106
  }
107
- const updatedDoc = (0, dynamoEncoding_js_1.decodeDynamoDocument)(item.Attributes);
107
+ const updatedDoc = (0, dynamoEncoding_1.decodeDynamoDocument)(item.Attributes);
108
108
  await ((_c = options === null || options === void 0 ? void 0 : options.afterWrite) === null || _c === void 0 ? void 0 : _c.call(options, updatedDoc));
109
109
  return parseFloat(result);
110
110
  }).catch((error) => {
111
111
  throw error.name === 'ConditionalCheckFailedException' ?
112
- new index_js_3.NotFoundError(`Item with ${key} "${id}" does not exist`) : error;
112
+ new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`) : error;
113
113
  });
114
114
  },
115
115
  /* replaces only specified attributes with the given data */
@@ -129,10 +129,10 @@ const dynamoUnversionedDocumentStore = (initializer) => {
129
129
  entries.forEach(([field, value], index) => {
130
130
  updates.push(`#f${index} = :f${index}`);
131
131
  expressionAttributeNames[`#f${index}`] = field;
132
- expressionAttributeValues[`:f${index}`] = (0, dynamoEncoding_js_1.encodeDynamoAttribute)(value);
132
+ expressionAttributeValues[`:f${index}`] = (0, dynamoEncoding_1.encodeDynamoAttribute)(value);
133
133
  });
134
134
  const cmd = new client_dynamodb_1.UpdateItemCommand({
135
- Key: { [key]: (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id) },
135
+ Key: { [key]: (0, dynamoEncoding_1.encodeDynamoAttribute)(id) },
136
136
  TableName: await tableName(),
137
137
  UpdateExpression: `SET ${updates.join(', ')}`,
138
138
  ConditionExpression: 'attribute_exists(#k)',
@@ -143,14 +143,14 @@ const dynamoUnversionedDocumentStore = (initializer) => {
143
143
  return dynamodb().send(cmd).then(async (item) => {
144
144
  var _a;
145
145
  if (!item.Attributes) {
146
- throw new index_js_3.NotFoundError(`Item with ${key} "${id}" does not exist`);
146
+ throw new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`);
147
147
  }
148
- const updatedDoc = (0, dynamoEncoding_js_1.decodeDynamoDocument)(item.Attributes);
148
+ const updatedDoc = (0, dynamoEncoding_1.decodeDynamoDocument)(item.Attributes);
149
149
  await ((_a = options === null || options === void 0 ? void 0 : options.afterWrite) === null || _a === void 0 ? void 0 : _a.call(options, updatedDoc));
150
150
  return updatedDoc;
151
151
  }).catch((error) => {
152
152
  throw error.name === 'ConditionalCheckFailedException' ?
153
- new index_js_3.NotFoundError(`Item with ${key} "${id}" does not exist`) : error;
153
+ new errors_1.NotFoundError(`Item with ${key} "${id}" does not exist`) : error;
154
154
  });
155
155
  },
156
156
  /* replaces the entire document with the given data */
@@ -158,7 +158,7 @@ const dynamoUnversionedDocumentStore = (initializer) => {
158
158
  var _a;
159
159
  const cmd = new client_dynamodb_1.PutItemCommand({
160
160
  TableName: await tableName(),
161
- Item: (0, dynamoEncoding_js_1.encodeDynamoDocument)(item),
161
+ Item: (0, dynamoEncoding_1.encodeDynamoDocument)(item),
162
162
  });
163
163
  const updatedDoc = await dynamodb().send(cmd).then(() => item);
164
164
  await ((_a = options === null || options === void 0 ? void 0 : options.afterWrite) === null || _a === void 0 ? void 0 : _a.call(options, updatedDoc));
@@ -168,7 +168,7 @@ const dynamoUnversionedDocumentStore = (initializer) => {
168
168
  createItem: async (item) => {
169
169
  const cmd = new client_dynamodb_1.PutItemCommand({
170
170
  TableName: await tableName(),
171
- Item: (0, dynamoEncoding_js_1.encodeDynamoDocument)(item),
171
+ Item: (0, dynamoEncoding_1.encodeDynamoDocument)(item),
172
172
  ConditionExpression: 'attribute_not_exists(#k)',
173
173
  ExpressionAttributeNames: {
174
174
  '#k': hashKey.toString(),
@@ -176,7 +176,7 @@ const dynamoUnversionedDocumentStore = (initializer) => {
176
176
  });
177
177
  return await dynamodb().send(cmd).then(() => item).catch((error) => {
178
178
  throw error.name === 'ConditionalCheckFailedException' ?
179
- new index_js_3.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`) : error;
179
+ new errors_1.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`) : error;
180
180
  }).then(async (createdDoc) => {
181
181
  var _a;
182
182
  await ((_a = options === null || options === void 0 ? void 0 : options.afterWrite) === null || _a === void 0 ? void 0 : _a.call(options, createdDoc));
@@ -195,7 +195,7 @@ const dynamoUnversionedDocumentStore = (initializer) => {
195
195
  try {
196
196
  const cmd = new client_dynamodb_1.PutItemCommand({
197
197
  TableName: await tableName(),
198
- Item: (0, dynamoEncoding_js_1.encodeDynamoDocument)(item),
198
+ Item: (0, dynamoEncoding_1.encodeDynamoDocument)(item),
199
199
  ConditionExpression: 'attribute_not_exists(#k)',
200
200
  ExpressionAttributeNames: {
201
201
  '#k': hashKey.toString(),
@@ -210,7 +210,7 @@ const dynamoUnversionedDocumentStore = (initializer) => {
210
210
  }
211
211
  catch (error) {
212
212
  const processedError = error.name === 'ConditionalCheckFailedException' ?
213
- new index_js_3.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`) : error;
213
+ new errors_1.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`) : error;
214
214
  return { success: false, item, error: processedError };
215
215
  }
216
216
  })) {
@@ -1,5 +1,5 @@
1
- import { Config, TDocument } from '../index.js';
2
- import { ConfigProviderForConfig } from '../../../config/index.js';
1
+ import { Config, TDocument } from '..';
2
+ import { ConfigProviderForConfig } from '../../../config';
3
3
  interface Initializer<C> {
4
4
  dataDir: string;
5
5
  fs?: Pick<typeof import('fs'), 'mkdir' | 'readdir' | 'readFile' | 'writeFile'>;
@@ -39,16 +39,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.fileSystemUnversionedDocumentStore = void 0;
40
40
  const fsModule = __importStar(require("fs"));
41
41
  const path_1 = __importDefault(require("path"));
42
- const index_js_1 = require("../../../index.js");
43
- const index_js_2 = require("../../../config/index.js");
44
- const index_js_3 = require("../../../errors/index.js");
45
- const index_js_4 = require("../../../guards/index.js");
42
+ const __1 = require("../../..");
43
+ const config_1 = require("../../../config");
44
+ const errors_1 = require("../../../errors");
45
+ const guards_1 = require("../../../guards");
46
46
  const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey, options) => {
47
- const tableName = (0, index_js_2.resolveConfigValue)(configProvider[initializer.configSpace || 'fileSystem'].tableName);
47
+ const tableName = (0, config_1.resolveConfigValue)(configProvider[initializer.configSpace || 'fileSystem'].tableName);
48
48
  const tablePath = tableName.then((table) => path_1.default.join(initializer.dataDir, table));
49
- const { mkdir, readdir, readFile, writeFile } = (0, index_js_4.ifDefined)(initializer.fs, fsModule);
49
+ const { mkdir, readdir, readFile, writeFile } = (0, guards_1.ifDefined)(initializer.fs, fsModule);
50
50
  const mkTableDir = new Promise((resolve, reject) => tablePath.then((path) => mkdir(path, { recursive: true }, (err) => err && err.code !== 'EEXIST' ? reject(err) : resolve())));
51
- const hashFilename = (value) => `${(0, index_js_1.hashValue)(value)}.json`;
51
+ const hashFilename = (value) => `${(0, __1.hashValue)(value)}.json`;
52
52
  const filePath = async (filename) => path_1.default.join(await tablePath, filename);
53
53
  const load = async (filename) => {
54
54
  const path = await filePath(filename);
@@ -76,7 +76,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
76
76
  return new Promise((resolve, reject) => readdir(path, (err, files) => err ?
77
77
  reject(err) :
78
78
  Promise.all(files.map((file) => load(file)))
79
- .then((allData) => resolve(allData.filter(index_js_4.isDefined)), (err) => reject(err))));
79
+ .then((allData) => resolve(allData.filter(guards_1.isDefined)), (err) => reject(err))));
80
80
  };
81
81
  return {
82
82
  loadAllDocumentsTheBadWay,
@@ -95,7 +95,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
95
95
  const items = await Promise.all(ids.map((id) => {
96
96
  return load(hashFilename(id));
97
97
  }));
98
- return items.filter(index_js_4.isDefined);
98
+ return items.filter(guards_1.isDefined);
99
99
  },
100
100
  getItem: (id) => {
101
101
  return load(hashFilename(id));
@@ -106,7 +106,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
106
106
  await mkTableDir;
107
107
  const data = await load(filename);
108
108
  if (!data) {
109
- throw new index_js_3.NotFoundError(`Item with ${hashKey.toString()} "${id}" does not exist`);
109
+ throw new errors_1.NotFoundError(`Item with ${hashKey.toString()} "${id}" does not exist`);
110
110
  }
111
111
  const newValue = typeof data[attribute] === 'number' ? data[attribute] + 1 : 1;
112
112
  const newItem = { ...data, [hashKey]: id, [attribute]: newValue };
@@ -128,7 +128,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
128
128
  await mkTableDir;
129
129
  const data = await load(filename);
130
130
  if (!data) {
131
- throw new index_js_3.NotFoundError(`Item with ${hashKey.toString()} "${id}" does not exist`);
131
+ throw new errors_1.NotFoundError(`Item with ${hashKey.toString()} "${id}" does not exist`);
132
132
  }
133
133
  const newItem = { ...data, ...item };
134
134
  return new Promise((resolve, reject) => {
@@ -146,7 +146,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
146
146
  const hashed = hashFilename(item[hashKey]);
147
147
  const existingItem = await load(hashed);
148
148
  if (existingItem) {
149
- throw new index_js_3.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`);
149
+ throw new errors_1.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`);
150
150
  }
151
151
  const path = await filePath(hashed);
152
152
  await mkTableDir;
@@ -167,7 +167,7 @@ const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvide
167
167
  const hashed = hashFilename(item[hashKey]);
168
168
  const existingItem = await load(hashed);
169
169
  if (existingItem) {
170
- throw new index_js_3.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`);
170
+ throw new errors_1.ConflictError(`Item with ${String(hashKey)} "${item[hashKey]}" already exists`);
171
171
  }
172
172
  const path = await filePath(hashed);
173
173
  await mkTableDir;
@@ -1,2 +1,2 @@
1
- import { dynamoUnversionedDocumentStore } from './dynamodb.js';
1
+ import { dynamoUnversionedDocumentStore } from './dynamodb';
2
2
  export type UnversionedDocumentStoreCreator = typeof dynamoUnversionedDocumentStore;
@@ -1,7 +1,7 @@
1
1
  import { DynamoDB } from '@aws-sdk/client-dynamodb';
2
- import { Config } from '../index.js';
3
- import { ConfigProviderForConfig } from '../../../config/index.js';
4
- import { VersionedDocumentAuthor, VersionedTDocument } from './index.js';
2
+ import { Config } from '..';
3
+ import { ConfigProviderForConfig } from '../../../config';
4
+ import { VersionedDocumentAuthor, VersionedTDocument } from '.';
5
5
  interface Initializer<C> {
6
6
  configSpace?: C;
7
7
  dynamoClient?: DynamoDB;
@@ -2,23 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dynamoVersionedDocumentStore = void 0;
4
4
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
5
- const index_js_1 = require("../../../index.js");
6
- const index_js_2 = require("../../../config/index.js");
7
- const index_js_3 = require("../../../guards/index.js");
8
- const dynamoEncoding_js_1 = require("../dynamoEncoding.js");
5
+ const __1 = require("../../..");
6
+ const config_1 = require("../../../config");
7
+ const guards_1 = require("../../../guards");
8
+ const dynamoEncoding_1 = require("../dynamoEncoding");
9
9
  // i'm not really excited about getAuthor being required, but ts is getting confused about the type when unspecified
10
10
  const dynamoVersionedDocumentStore = (initializer) => {
11
- const init = (0, index_js_3.ifDefined)(initializer, {});
12
- const dynamodb = (0, index_js_1.once)(() => { var _a; return (_a = init.dynamoClient) !== null && _a !== void 0 ? _a : new client_dynamodb_1.DynamoDB({ apiVersion: '2012-08-10' }); });
11
+ const init = (0, guards_1.ifDefined)(initializer, {});
12
+ const dynamodb = (0, __1.once)(() => { var _a; return (_a = init.dynamoClient) !== null && _a !== void 0 ? _a : new client_dynamodb_1.DynamoDB({ apiVersion: '2012-08-10' }); });
13
13
  return () => (configProvider) => (_, hashKey, options) => {
14
- const tableName = (0, index_js_1.once)(() => (0, index_js_2.resolveConfigValue)(configProvider[(0, index_js_3.ifDefined)(init.configSpace, 'dynamodb')].tableName));
14
+ const tableName = (0, __1.once)(() => (0, config_1.resolveConfigValue)(configProvider[(0, guards_1.ifDefined)(init.configSpace, 'dynamodb')].tableName));
15
15
  return {
16
16
  loadAllDocumentsTheBadWay: async () => {
17
17
  const loadAllResults = async (ExclusiveStartKey) => {
18
18
  var _a;
19
19
  const cmd = new client_dynamodb_1.ScanCommand({ TableName: await tableName(), ExclusiveStartKey });
20
20
  const result = await dynamodb().send(cmd);
21
- const resultItems = ((_a = result.Items) === null || _a === void 0 ? void 0 : _a.map(dynamoEncoding_js_1.decodeDynamoDocument)) || [];
21
+ const resultItems = ((_a = result.Items) === null || _a === void 0 ? void 0 : _a.map(dynamoEncoding_1.decodeDynamoDocument)) || [];
22
22
  if (result.LastEvaluatedKey) {
23
23
  return [...resultItems, ...await loadAllResults(result.LastEvaluatedKey)];
24
24
  }
@@ -38,14 +38,14 @@ const dynamoVersionedDocumentStore = (initializer) => {
38
38
  TableName: await tableName(),
39
39
  KeyConditionExpression: '#hk = :hkv',
40
40
  ExpressionAttributeValues: {
41
- ':hkv': (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id)
41
+ ':hkv': (0, dynamoEncoding_1.encodeDynamoAttribute)(id)
42
42
  },
43
43
  ExpressionAttributeNames: {
44
44
  '#hk': hashKey.toString()
45
45
  },
46
46
  ...(startVersion
47
47
  ? { ExclusiveStartKey: {
48
- [hashKey]: (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id),
48
+ [hashKey]: (0, dynamoEncoding_1.encodeDynamoAttribute)(id),
49
49
  timestamp: { N: startVersion.toString() }
50
50
  } }
51
51
  : {}),
@@ -53,13 +53,13 @@ const dynamoVersionedDocumentStore = (initializer) => {
53
53
  });
54
54
  return dynamodb().send(cmd).then(result => {
55
55
  var _a;
56
- const items = (_a = result.Items) === null || _a === void 0 ? void 0 : _a.map(dynamoEncoding_js_1.decodeDynamoDocument);
56
+ const items = (_a = result.Items) === null || _a === void 0 ? void 0 : _a.map(dynamoEncoding_1.decodeDynamoDocument);
57
57
  if (!items || items.length === 0) {
58
58
  return undefined;
59
59
  }
60
60
  return {
61
61
  items,
62
- nextPageToken: result.LastEvaluatedKey ? (0, dynamoEncoding_js_1.decodeDynamoDocument)(result.LastEvaluatedKey).timestamp : undefined
62
+ nextPageToken: result.LastEvaluatedKey ? (0, dynamoEncoding_1.decodeDynamoDocument)(result.LastEvaluatedKey).timestamp : undefined
63
63
  };
64
64
  });
65
65
  },
@@ -69,12 +69,12 @@ const dynamoVersionedDocumentStore = (initializer) => {
69
69
  '#hk': hashKey.toString()
70
70
  };
71
71
  const expressionAttributeValues = {
72
- ':hkv': (0, dynamoEncoding_js_1.encodeDynamoAttribute)(id)
72
+ ':hkv': (0, dynamoEncoding_1.encodeDynamoAttribute)(id)
73
73
  };
74
74
  if (timestamp) {
75
75
  keyConditionExpression += ' and #ts = :tsv';
76
76
  expressionAttributeNames['#ts'] = 'timestamp';
77
- expressionAttributeValues[':tsv'] = (0, dynamoEncoding_js_1.encodeDynamoAttribute)(timestamp);
77
+ expressionAttributeValues[':tsv'] = (0, dynamoEncoding_1.encodeDynamoAttribute)(timestamp);
78
78
  }
79
79
  const cmd = new client_dynamodb_1.QueryCommand({
80
80
  TableName: await tableName(),
@@ -86,7 +86,7 @@ const dynamoVersionedDocumentStore = (initializer) => {
86
86
  });
87
87
  return dynamodb().send(cmd).then(result => {
88
88
  var _a;
89
- return (_a = result.Items) === null || _a === void 0 ? void 0 : _a.map(dynamoEncoding_js_1.decodeDynamoDocument)[0];
89
+ return (_a = result.Items) === null || _a === void 0 ? void 0 : _a.map(dynamoEncoding_1.decodeDynamoDocument)[0];
90
90
  });
91
91
  },
92
92
  /* prepares a new version of a document with the given data, then allows some additional
@@ -109,7 +109,7 @@ const dynamoVersionedDocumentStore = (initializer) => {
109
109
  };
110
110
  const cmd = new client_dynamodb_1.PutItemCommand({
111
111
  TableName: await tableName(),
112
- Item: (0, dynamoEncoding_js_1.encodeDynamoDocument)(document),
112
+ Item: (0, dynamoEncoding_1.encodeDynamoDocument)(document),
113
113
  });
114
114
  const updatedDoc = await dynamodb().send(cmd)
115
115
  .then(() => document);
@@ -130,7 +130,7 @@ const dynamoVersionedDocumentStore = (initializer) => {
130
130
  };
131
131
  const cmd = new client_dynamodb_1.PutItemCommand({
132
132
  TableName: await tableName(),
133
- Item: (0, dynamoEncoding_js_1.encodeDynamoDocument)(document),
133
+ Item: (0, dynamoEncoding_1.encodeDynamoDocument)(document),
134
134
  });
135
135
  const updatedDoc = await dynamodb().send(cmd)
136
136
  .then(() => document);
@@ -1,6 +1,6 @@
1
- import { Config } from '../index.js';
2
- import { ConfigProviderForConfig } from '../../../config/index.js';
3
- import { VersionedDocumentAuthor, VersionedTDocument } from './index.js';
1
+ import { Config } from '..';
2
+ import { ConfigProviderForConfig } from '../../../config';
3
+ import { VersionedDocumentAuthor, VersionedTDocument } from '.';
4
4
  interface Initializer<C> {
5
5
  dataDir: string;
6
6
  fs?: Pick<typeof import('fs'), 'mkdir' | 'readdir' | 'readFile' | 'writeFile'>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fileSystemVersionedDocumentStore = void 0;
4
- const file_system_js_1 = require("../unversioned/file-system.js");
4
+ const file_system_1 = require("../unversioned/file-system");
5
5
  const PAGE_LIMIT = 5;
6
6
  const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey, options) => {
7
- const unversionedDocuments = (0, file_system_js_1.fileSystemUnversionedDocumentStore)(initializer)()(configProvider)({}, 'id');
7
+ const unversionedDocuments = (0, file_system_1.fileSystemUnversionedDocumentStore)(initializer)()(configProvider)({}, 'id');
8
8
  return {
9
9
  loadAllDocumentsTheBadWay: () => {
10
10
  return unversionedDocuments.loadAllDocumentsTheBadWay().then(documents => documents.map(document => {
@@ -1,5 +1,5 @@
1
- import { TDocument } from '../index.js';
2
- import { dynamoVersionedDocumentStore } from './dynamodb.js';
1
+ import { TDocument } from '..';
2
+ import { dynamoVersionedDocumentStore } from './dynamodb';
3
3
  export type VersionedDocumentAuthor = {
4
4
  type: 'user';
5
5
  uuid: string;
@@ -1,5 +1,5 @@
1
- import { ConfigProviderForConfig } from '../../config/index.js';
2
- import { GenericFetch } from '../../fetch/index.js';
1
+ import { ConfigProviderForConfig } from '../../config';
2
+ import { GenericFetch } from '../../fetch';
3
3
  export type Config = {
4
4
  defaultCorrectness?: string;
5
5
  exercisesHost: string;