@karmaniverous/entity-manager 0.0.9 → 0.0.11
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.
- package/README.md +16 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,8 +38,8 @@ The `entity-manager` configuration object describes each entity's structured key
|
|
|
38
38
|
|
|
39
39
|
// These tagged templates are used below to simplify template literals.
|
|
40
40
|
// sn2e - Template literal returns empty string if any expression is nil.
|
|
41
|
-
//
|
|
42
|
-
import { sn2e,
|
|
41
|
+
// sn2n - Template literal returns undefined if any expression is nil.
|
|
42
|
+
import { sn2e, sn2n } from '@karmaniverous/tagged-templates';
|
|
43
43
|
|
|
44
44
|
// Entity config object named export.
|
|
45
45
|
export const config = {
|
|
@@ -57,31 +57,31 @@ export const config = {
|
|
|
57
57
|
|
|
58
58
|
// Table RANGE key.
|
|
59
59
|
entitySK: ({ timestamp, transactionId }) =>
|
|
60
|
-
|
|
60
|
+
sn2n`timestamp#${timestamp}|transactionId#${transactionId}`,
|
|
61
61
|
|
|
62
62
|
// merchants GSI HASH key. Note the optional shardId.
|
|
63
63
|
merchantPK: ({ merchantId, shardId }) =>
|
|
64
|
-
|
|
64
|
+
sn2n`merchantId#${merchantId}|transaction${sn2e`!${shardId}`}`,
|
|
65
65
|
|
|
66
66
|
// merchants GSI RANGE key.
|
|
67
67
|
merchantSK: ({ methodId, timestamp, transactionId }) =>
|
|
68
|
-
|
|
68
|
+
sn2n`timestamp#${timestamp}|methodId#${methodId}|transactionId#${transactionId}`,
|
|
69
69
|
|
|
70
70
|
// methods GSI HASH key. Note the optional shardId.
|
|
71
71
|
methodPK: ({ methodId, shardId }) =>
|
|
72
|
-
|
|
72
|
+
sn2n`method#${methodId}|transaction${sn2e`!${shardId}`}`,
|
|
73
73
|
|
|
74
74
|
// methods GSI RANGE key.
|
|
75
75
|
methodSK: ({ merchantId, timestamp, transactionId }) =>
|
|
76
|
-
|
|
76
|
+
sn2n`timestamp#${timestamp}|merchantId#${merchantId}|transactionId#${transactionId}`,
|
|
77
77
|
|
|
78
78
|
// users GSI HASH key. Note the optional shardId.
|
|
79
79
|
userPK: ({ shardId, userId }) =>
|
|
80
|
-
|
|
80
|
+
sn2n`user#${userId}|transaction${sn2e`!${shardId}`}`,
|
|
81
81
|
|
|
82
82
|
// users GSI RANGE key.
|
|
83
83
|
userSK: ({ merchantId, timestamp, transactionId }) =>
|
|
84
|
-
|
|
84
|
+
sn2n`timestamp#${timestamp}|merchantId#${merchantId}|transactionId#${transactionId}`,
|
|
85
85
|
},
|
|
86
86
|
|
|
87
87
|
// The sharding configuration for this entity.
|
|
@@ -89,10 +89,11 @@ export const config = {
|
|
|
89
89
|
// Default number of shard key characters (0 means no shard key).
|
|
90
90
|
nibbles: 0,
|
|
91
91
|
|
|
92
|
-
// Bits represented by each shard key character
|
|
93
|
-
// shard key
|
|
94
|
-
// yields
|
|
95
|
-
|
|
92
|
+
// Bits represented by each shard key character, so 3 bits means an
|
|
93
|
+
// octal shard key. Running with no shard key produces a single shard.
|
|
94
|
+
// The first shard key character yields another 8 shards, and the second
|
|
95
|
+
// yields an additional 64, for an eventual total of 73.
|
|
96
|
+
nibbleBits: 3,
|
|
96
97
|
|
|
97
98
|
// Scheduled increases in shard key length. Keys are expressed as
|
|
98
99
|
// millisecond UTC timestamps. In production, these should not be
|
|
@@ -110,8 +111,8 @@ export const config = {
|
|
|
110
111
|
},
|
|
111
112
|
},
|
|
112
113
|
},
|
|
113
|
-
// Will be added to every entity object. Pick a value that
|
|
114
|
-
// entity data!
|
|
114
|
+
// Will be added to every entity object as appropriate. Pick a value that
|
|
115
|
+
// won't collide with entity data!
|
|
115
116
|
shardKeyToken: 'shardId',
|
|
116
117
|
};
|
|
117
118
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karmaniverous/entity-manager",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@babel/register": "^7.18.9",
|
|
34
34
|
"@karmaniverous/edge-logger": "^1.0.2",
|
|
35
35
|
"@karmaniverous/get-dotenv": "^0.1.0",
|
|
36
|
-
"@karmaniverous/tagged-templates": "^0.0.
|
|
36
|
+
"@karmaniverous/tagged-templates": "^0.0.4",
|
|
37
37
|
"@types/node": "^18.11.18",
|
|
38
38
|
"babel-plugin-lodash": "^3.3.4",
|
|
39
39
|
"chai": "^4.3.7",
|