@karmaniverous/entity-manager 6.7.5 → 6.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/BaseEntityClient.js +1 -1
  3. package/dist/cjs/BaseQueryBuilder.js +5 -1
  4. package/dist/cjs/EntityManager.js +18 -9
  5. package/dist/cjs/ParsedConfig.js +143 -113
  6. package/dist/cjs/addKeys.js +6 -6
  7. package/dist/{mjs/decodeEntityElement.js → cjs/decodeElement.js} +10 -12
  8. package/dist/cjs/decodeGeneratedProperty.js +6 -10
  9. package/dist/cjs/dehydrateIndexItem.js +12 -11
  10. package/dist/cjs/dehydratePageKeyMap.js +10 -7
  11. package/dist/{mjs/encodeEntityElement.js → cjs/encodeElement.js} +8 -10
  12. package/dist/cjs/encodeGeneratedProperty.js +14 -18
  13. package/dist/cjs/getHashKeySpace.js +6 -6
  14. package/dist/cjs/getIndexComponents.js +6 -8
  15. package/dist/cjs/getShardBump.js +1 -1
  16. package/dist/cjs/index.js +0 -2
  17. package/dist/cjs/query.js +1 -1
  18. package/dist/cjs/rehydrateIndexItem.js +12 -10
  19. package/dist/cjs/rehydratePageKeyMap.js +18 -11
  20. package/dist/cjs/removeKeys.js +3 -2
  21. package/dist/cjs/unwrapIndex.js +25 -11
  22. package/dist/cjs/updateItemHashKey.js +5 -3
  23. package/dist/cjs/updateItemRangeKey.js +6 -4
  24. package/dist/cjs/validateGeneratedProperty.js +23 -0
  25. package/dist/cjs/validateIndexToken.js +16 -0
  26. package/dist/cjs/validateTranscodedProperty.js +16 -0
  27. package/dist/index.d.ts +265 -538
  28. package/dist/mjs/BaseEntityClient.js +1 -1
  29. package/dist/mjs/BaseQueryBuilder.js +5 -1
  30. package/dist/mjs/EntityManager.js +18 -9
  31. package/dist/mjs/ParsedConfig.js +143 -113
  32. package/dist/mjs/addKeys.js +6 -6
  33. package/dist/{cjs/decodeEntityElement.js → mjs/decodeElement.js} +8 -14
  34. package/dist/mjs/decodeGeneratedProperty.js +6 -10
  35. package/dist/mjs/dehydrateIndexItem.js +12 -11
  36. package/dist/mjs/dehydratePageKeyMap.js +10 -7
  37. package/dist/{cjs/encodeEntityElement.js → mjs/encodeElement.js} +7 -13
  38. package/dist/mjs/encodeGeneratedProperty.js +14 -18
  39. package/dist/mjs/getHashKeySpace.js +6 -6
  40. package/dist/mjs/getIndexComponents.js +6 -8
  41. package/dist/mjs/getShardBump.js +1 -1
  42. package/dist/mjs/index.js +0 -1
  43. package/dist/mjs/query.js +1 -1
  44. package/dist/mjs/rehydrateIndexItem.js +12 -10
  45. package/dist/mjs/rehydratePageKeyMap.js +18 -11
  46. package/dist/mjs/removeKeys.js +3 -2
  47. package/dist/mjs/unwrapIndex.js +26 -12
  48. package/dist/mjs/updateItemHashKey.js +5 -3
  49. package/dist/mjs/updateItemRangeKey.js +6 -4
  50. package/dist/mjs/validateGeneratedProperty.js +21 -0
  51. package/dist/mjs/validateIndexToken.js +14 -0
  52. package/dist/mjs/validateTranscodedProperty.js +14 -0
  53. package/package.json +6 -6
  54. package/dist/cjs/conditionalize.js +0 -25
  55. package/dist/cjs/validateEntityGeneratedProperty.js +0 -29
  56. package/dist/cjs/validateEntityIndexToken.js +0 -22
  57. package/dist/mjs/conditionalize.js +0 -23
  58. package/dist/mjs/validateEntityGeneratedProperty.js +0 -27
  59. package/dist/mjs/validateEntityIndexToken.js +0 -20
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Transforms a function such that it only executes when `condition` is truthy.
5
- *
6
- * @param fn - The function to conditionally execute.
7
- * @param condition - The condition to check before executing `fn`.
8
- *
9
- * @typeParam F - The type of the function to conditionally execute.
10
- *
11
- * @returns The conditionalized function with the same signature as `fn`.
12
- *
13
- */
14
- function conditionalize(fn, condition) {
15
- return (...args) => {
16
- if (condition) {
17
- return fn(...args);
18
- }
19
- else {
20
- return undefined;
21
- }
22
- };
23
- }
24
-
25
- exports.conditionalize = conditionalize;
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- var validateEntityToken = require('./validateEntityToken.js');
4
-
5
- /**
6
- * Validate that an entity generated property is defined in EntityManager
7
- * config.
8
- *
9
- * @param entityManager - {@link EntityManager | `EntityManager`} instance.
10
- * @param entityToken - {@link ConfigKeys.entities | `this.config.entities`} key.
11
- * @param property - {@link ConfigEntityGenerated | `this.config.entities.<entityToken>.generated`} key.
12
- * @param sharded - Whether the generated property is sharded. `undefined` indicates no constraint.
13
- *
14
- * @throws `Error` if `entityToken` is invalid.
15
- * @throws `Error` if `property` is invalid.
16
- * @throws `Error` if `sharded` is specified & does not match `this.config.entities.<entityToken>.generated.<property>.sharded`.
17
- */
18
- function validateEntityGeneratedProperty(entityManager, entityToken, property, sharded) {
19
- validateEntityToken.validateEntityToken(entityManager, entityToken);
20
- const generated = entityManager.config.entities[entityToken].generated[property];
21
- if (!generated && property !== entityManager.config.hashKey)
22
- throw new Error('invalid entity generated property');
23
- if (sharded !== undefined &&
24
- ((generated && sharded !== generated.sharded) ||
25
- (!sharded && property === entityManager.config.hashKey)))
26
- throw new Error(`entity generated property ${sharded ? 'not ' : ''}sharded`);
27
- }
28
-
29
- exports.validateEntityGeneratedProperty = validateEntityGeneratedProperty;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- var validateEntityToken = require('./validateEntityToken.js');
4
-
5
- /**
6
- * Validate that an entity index is defined in EntityManager config.
7
- *
8
- * @param entityManager - {@link EntityManager | `EntityManager`} instance.
9
- * @param entityToken - {@link ConfigKeys.entities | `this.config.entities`} key.
10
- * @param indexToken - {@link ConfigEntity.indexes | `this.config.entities.<entityToken>.indexes`} key.
11
- *
12
- * @throws `Error` if `entityToken` is invalid.
13
- * @throws `Error` if `indexToken` is invalid.
14
- */
15
- function validateEntityIndexToken(entityManager, entityToken, indexToken) {
16
- validateEntityToken.validateEntityToken(entityManager, entityToken);
17
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
18
- if (!entityManager.config.entities[entityToken].indexes[indexToken])
19
- throw new Error('invalid entity index token');
20
- }
21
-
22
- exports.validateEntityIndexToken = validateEntityIndexToken;
@@ -1,23 +0,0 @@
1
- /**
2
- * Transforms a function such that it only executes when `condition` is truthy.
3
- *
4
- * @param fn - The function to conditionally execute.
5
- * @param condition - The condition to check before executing `fn`.
6
- *
7
- * @typeParam F - The type of the function to conditionally execute.
8
- *
9
- * @returns The conditionalized function with the same signature as `fn`.
10
- *
11
- */
12
- function conditionalize(fn, condition) {
13
- return (...args) => {
14
- if (condition) {
15
- return fn(...args);
16
- }
17
- else {
18
- return undefined;
19
- }
20
- };
21
- }
22
-
23
- export { conditionalize };
@@ -1,27 +0,0 @@
1
- import { validateEntityToken } from './validateEntityToken.js';
2
-
3
- /**
4
- * Validate that an entity generated property is defined in EntityManager
5
- * config.
6
- *
7
- * @param entityManager - {@link EntityManager | `EntityManager`} instance.
8
- * @param entityToken - {@link ConfigKeys.entities | `this.config.entities`} key.
9
- * @param property - {@link ConfigEntityGenerated | `this.config.entities.<entityToken>.generated`} key.
10
- * @param sharded - Whether the generated property is sharded. `undefined` indicates no constraint.
11
- *
12
- * @throws `Error` if `entityToken` is invalid.
13
- * @throws `Error` if `property` is invalid.
14
- * @throws `Error` if `sharded` is specified & does not match `this.config.entities.<entityToken>.generated.<property>.sharded`.
15
- */
16
- function validateEntityGeneratedProperty(entityManager, entityToken, property, sharded) {
17
- validateEntityToken(entityManager, entityToken);
18
- const generated = entityManager.config.entities[entityToken].generated[property];
19
- if (!generated && property !== entityManager.config.hashKey)
20
- throw new Error('invalid entity generated property');
21
- if (sharded !== undefined &&
22
- ((generated && sharded !== generated.sharded) ||
23
- (!sharded && property === entityManager.config.hashKey)))
24
- throw new Error(`entity generated property ${sharded ? 'not ' : ''}sharded`);
25
- }
26
-
27
- export { validateEntityGeneratedProperty };
@@ -1,20 +0,0 @@
1
- import { validateEntityToken } from './validateEntityToken.js';
2
-
3
- /**
4
- * Validate that an entity index is defined in EntityManager config.
5
- *
6
- * @param entityManager - {@link EntityManager | `EntityManager`} instance.
7
- * @param entityToken - {@link ConfigKeys.entities | `this.config.entities`} key.
8
- * @param indexToken - {@link ConfigEntity.indexes | `this.config.entities.<entityToken>.indexes`} key.
9
- *
10
- * @throws `Error` if `entityToken` is invalid.
11
- * @throws `Error` if `indexToken` is invalid.
12
- */
13
- function validateEntityIndexToken(entityManager, entityToken, indexToken) {
14
- validateEntityToken(entityManager, entityToken);
15
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
16
- if (!entityManager.config.entities[entityToken].indexes[indexToken])
17
- throw new Error('invalid entity index token');
18
- }
19
-
20
- export { validateEntityIndexToken };