@karmaniverous/entity-manager 6.4.9 → 6.5.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.
- package/dist/cjs/ParsedConfig.js +37 -12
- package/dist/cjs/index.js +0 -9
- package/dist/cjs/rehydratePageKeyMap.js +2 -1
- package/dist/cjs/unwrapIndex.js +1 -1
- package/dist/index.d.ts +62 -53
- package/dist/mjs/ParsedConfig.js +37 -12
- package/dist/mjs/index.js +0 -1
- package/dist/mjs/rehydratePageKeyMap.js +2 -1
- package/dist/mjs/unwrapIndex.js +1 -1
- package/package.json +12 -12
package/dist/cjs/ParsedConfig.js
CHANGED
|
@@ -23,6 +23,10 @@ const validateKeyExclusive = (key, label, ref, ctx) => {
|
|
|
23
23
|
message: `${label} '${key}' is not exclusive`,
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
+
const componentArray = zod.z
|
|
27
|
+
.array(zod.z.string().min(1))
|
|
28
|
+
.nonempty()
|
|
29
|
+
.superRefine(validateArrayUnique);
|
|
26
30
|
const configSchema = zod.z
|
|
27
31
|
.object({
|
|
28
32
|
entities: zod.z
|
|
@@ -46,10 +50,7 @@ const configSchema = zod.z
|
|
|
46
50
|
.record(zod.z
|
|
47
51
|
.object({
|
|
48
52
|
atomic: zod.z.boolean().optional().default(false),
|
|
49
|
-
elements:
|
|
50
|
-
.array(zod.z.string().min(1))
|
|
51
|
-
.nonempty()
|
|
52
|
-
.superRefine(validateArrayUnique),
|
|
53
|
+
elements: componentArray,
|
|
53
54
|
sharded: zod.z.boolean().optional().default(false),
|
|
54
55
|
})
|
|
55
56
|
.optional())
|
|
@@ -57,10 +58,10 @@ const configSchema = zod.z
|
|
|
57
58
|
.default({}),
|
|
58
59
|
elementTranscodes: zod.z.record(zod.z.string()).optional().default({}),
|
|
59
60
|
indexes: zod.z
|
|
60
|
-
.record(zod.z
|
|
61
|
-
|
|
62
|
-
.
|
|
63
|
-
|
|
61
|
+
.record(zod.z.object({
|
|
62
|
+
components: componentArray,
|
|
63
|
+
projections: componentArray.optional(),
|
|
64
|
+
}))
|
|
64
65
|
.optional()
|
|
65
66
|
.default({}),
|
|
66
67
|
shardBumps: zod.z
|
|
@@ -209,18 +210,42 @@ const configSchema = zod.z
|
|
|
209
210
|
],
|
|
210
211
|
received: element,
|
|
211
212
|
});
|
|
212
|
-
// validate
|
|
213
|
+
// validate indexes.
|
|
213
214
|
const generatedProperties = Object.keys(entity.generated);
|
|
214
|
-
for (const [indexKey, index] of Object.entries(entity.indexes))
|
|
215
|
-
|
|
215
|
+
for (const [indexKey, index] of Object.entries(entity.indexes)) {
|
|
216
|
+
// validate all ungenerated entity index components have a corresponding entity element type
|
|
217
|
+
for (const component of index.components)
|
|
216
218
|
if (![data.hashKey, data.rangeKey, ...generatedProperties].includes(component) &&
|
|
217
219
|
!typedElements.includes(component))
|
|
218
220
|
ctx.addIssue({
|
|
219
221
|
code: zod.z.ZodIssueCode.invalid_enum_value,
|
|
220
222
|
options: typedElements,
|
|
221
|
-
path: [
|
|
223
|
+
path: [
|
|
224
|
+
'entities',
|
|
225
|
+
entityToken,
|
|
226
|
+
'indexes',
|
|
227
|
+
indexKey,
|
|
228
|
+
'components',
|
|
229
|
+
],
|
|
222
230
|
received: component,
|
|
223
231
|
});
|
|
232
|
+
// validate no index projections are index components, hashKey, or rangeKey
|
|
233
|
+
if (index.projections)
|
|
234
|
+
for (const projection of index.projections) {
|
|
235
|
+
if ([data.hashKey, data.rangeKey, ...index.components].includes(projection))
|
|
236
|
+
ctx.addIssue({
|
|
237
|
+
code: zod.z.ZodIssueCode.custom,
|
|
238
|
+
message: 'index projection is an index component, hash key, or range key',
|
|
239
|
+
path: [
|
|
240
|
+
'entities',
|
|
241
|
+
entityToken,
|
|
242
|
+
'indexes',
|
|
243
|
+
indexKey,
|
|
244
|
+
'projections',
|
|
245
|
+
],
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
224
249
|
}
|
|
225
250
|
});
|
|
226
251
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,17 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var conditionalize = require('./conditionalize.js');
|
|
4
4
|
var EntityManager = require('./EntityManager.js');
|
|
5
|
-
var entityTools = require('@karmaniverous/entity-tools');
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
exports.conditionalize = conditionalize.conditionalize;
|
|
10
9
|
exports.EntityManager = EntityManager.EntityManager;
|
|
11
|
-
Object.defineProperty(exports, "defaultTranscodes", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return entityTools.defaultTranscodes; }
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(exports, "isNil", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return entityTools.isNil; }
|
|
18
|
-
});
|
|
@@ -51,7 +51,8 @@ function rehydratePageKeyMap(entityManager, dehydrated, entityToken, indexTokens
|
|
|
51
51
|
...rehydrateIndexItem.rehydrateIndexItem(entityManager, dehydratedIndexPageKeyMaps[i], entityToken, index, [entityManager.config.hashKey]),
|
|
52
52
|
};
|
|
53
53
|
item = updateItemRangeKey.updateItemRangeKey(entityManager, item, entityToken);
|
|
54
|
-
return radash.zipToObject(entityManager.config.entities[entityToken].indexes[index]
|
|
54
|
+
return radash.zipToObject(entityManager.config.entities[entityToken].indexes[index]
|
|
55
|
+
.components, (component) => entityManager.config.entities[entityToken].generated[component]
|
|
55
56
|
? encodeGeneratedProperty.encodeGeneratedProperty(entityManager, item, entityToken, component)
|
|
56
57
|
: item[component]);
|
|
57
58
|
}));
|
package/dist/cjs/unwrapIndex.js
CHANGED
|
@@ -21,7 +21,7 @@ function unwrapIndex(entityManager, entityToken, indexToken) {
|
|
|
21
21
|
validateEntityIndexToken.validateEntityIndexToken(entityManager, entityToken, indexToken);
|
|
22
22
|
const generated = entityManager.config.entities[entityToken].generated;
|
|
23
23
|
const generatedKeys = Object.keys(radash.shake(generated));
|
|
24
|
-
return entityManager.config.entities[entityToken].indexes[indexToken]
|
|
24
|
+
return entityManager.config.entities[entityToken].indexes[indexToken].components
|
|
25
25
|
.map((component) => component === entityManager.config.hashKey
|
|
26
26
|
? entityManager.config.hashKey
|
|
27
27
|
: component === entityManager.config.rangeKey
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Entity, Exactify, TranscodeMap, PropertiesOfType, TranscodableProperties, Transcodes, DefaultTranscodeMap, SortOrder } from '@karmaniverous/entity-tools';
|
|
2
|
-
export { DefaultTranscodeMap, Entity, Exactify, Nil, PartialTranscodable, PropertiesNotOfType, PropertiesOfType, SortOrder, TranscodableProperties, TranscodeMap, Transcodes, defaultTranscodes, isNil } from '@karmaniverous/entity-tools';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -81,6 +80,19 @@ interface ShardBump {
|
|
|
81
80
|
*/
|
|
82
81
|
chars: number;
|
|
83
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns a Config entity index components type.
|
|
85
|
+
*
|
|
86
|
+
* @typeParam EntityToken - The {@link Entity | `Entity`} token.
|
|
87
|
+
* @typeParam M - The {@link EntityMap | `EntityMap`}.
|
|
88
|
+
* @typeParam HashKey - The property used across the configuration to store an {@link Entity | `Entity`}'s sharded hash key. Should be configured as the table hash key. Must not conflict with any {@link Entity | `Entity`} property.
|
|
89
|
+
* @typeParam RangeKey - The property used across the configuration to store an {@link Entity | `Entity`}'s range key. Should be configured as the table range key. Must not conflict with any {@link Entity | `Entity`} property.
|
|
90
|
+
* @typeParam T - The {@link TranscodeMap | `TranscodeMap`} identifying transcodable property types. Only {@link Entity | `Entity`} properties of these types can be components of an {@link ConfigEntity.indexes | index} or a {@link ConfigEntityGenerated | generated property}.
|
|
91
|
+
|
|
92
|
+
* @category Config
|
|
93
|
+
* @protected
|
|
94
|
+
*/
|
|
95
|
+
type ConfigEntityIndexComponents<EntityToken extends keyof Exactify<M>, M extends EntityMap, HashKey extends string, RangeKey extends string, T extends TranscodeMap> = (TranscodableProperties<M[EntityToken], T> | PropertiesOfType<M[EntityToken], never> | HashKey | RangeKey)[];
|
|
84
96
|
/**
|
|
85
97
|
* Returns a Config entity type.
|
|
86
98
|
*
|
|
@@ -176,7 +188,10 @@ type ConfigEntity<EntityToken extends keyof Exactify<M>, M extends EntityMap, Ha
|
|
|
176
188
|
*
|
|
177
189
|
* Related property types must be align with the {@link Config | `Config`} `T` type parameter. Note tha all {@link ConfigEntityGenerated | generated property} types are transcodable by definition.
|
|
178
190
|
*/
|
|
179
|
-
indexes?: Record<string,
|
|
191
|
+
indexes?: Record<string, {
|
|
192
|
+
components: ConfigEntityIndexComponents<EntityToken, M, HashKey, RangeKey, T>;
|
|
193
|
+
projections?: (keyof M[EntityToken])[];
|
|
194
|
+
}>;
|
|
180
195
|
/**
|
|
181
196
|
* An array of {@link ShardBump | `ShardBump`} objects representing the {@link Entity | `Entity`}'s sharding strategy.
|
|
182
197
|
*
|
|
@@ -357,9 +372,7 @@ type ItemMap<M extends EntityMap, HashKey extends string = 'hashKey', RangeKey e
|
|
|
357
372
|
[P in keyof Exactify<M[EntityToken]>]: [
|
|
358
373
|
NonNullable<M[EntityToken][P]>
|
|
359
374
|
] extends [never] ? string : M[EntityToken][P];
|
|
360
|
-
} &
|
|
361
|
-
[P in HashKey | RangeKey]?: string;
|
|
362
|
-
}>;
|
|
375
|
+
} & Partial<Record<HashKey | RangeKey, string>>>;
|
|
363
376
|
};
|
|
364
377
|
|
|
365
378
|
declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
@@ -380,7 +393,16 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
380
393
|
sharded?: boolean | undefined;
|
|
381
394
|
}>>>>>;
|
|
382
395
|
elementTranscodes: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
383
|
-
indexes: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
396
|
+
indexes: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
397
|
+
components: z.ZodEffects<z.ZodArray<z.ZodString, "atleastone">, [string, ...string[]], [string, ...string[]]>;
|
|
398
|
+
projections: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "atleastone">, [string, ...string[]], [string, ...string[]]>>;
|
|
399
|
+
}, "strip", z.ZodTypeAny, {
|
|
400
|
+
components: [string, ...string[]];
|
|
401
|
+
projections?: [string, ...string[]] | undefined;
|
|
402
|
+
}, {
|
|
403
|
+
components: [string, ...string[]];
|
|
404
|
+
projections?: [string, ...string[]] | undefined;
|
|
405
|
+
}>>>>;
|
|
384
406
|
shardBumps: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
385
407
|
timestamp: z.ZodNumber;
|
|
386
408
|
charBits: z.ZodNumber;
|
|
@@ -424,7 +446,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
424
446
|
defaultLimit: number;
|
|
425
447
|
defaultPageSize: number;
|
|
426
448
|
elementTranscodes: Record<string, string>;
|
|
427
|
-
indexes: Record<string,
|
|
449
|
+
indexes: Record<string, {
|
|
450
|
+
components: [string, ...string[]];
|
|
451
|
+
projections?: [string, ...string[]] | undefined;
|
|
452
|
+
}>;
|
|
428
453
|
shardBumps: {
|
|
429
454
|
timestamp: number;
|
|
430
455
|
charBits: number;
|
|
@@ -443,7 +468,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
443
468
|
defaultLimit?: number | undefined;
|
|
444
469
|
defaultPageSize?: number | undefined;
|
|
445
470
|
elementTranscodes?: Record<string, string> | undefined;
|
|
446
|
-
indexes?: Record<string,
|
|
471
|
+
indexes?: Record<string, {
|
|
472
|
+
components: [string, ...string[]];
|
|
473
|
+
projections?: [string, ...string[]] | undefined;
|
|
474
|
+
}> | undefined;
|
|
447
475
|
shardBumps?: {
|
|
448
476
|
timestamp: number;
|
|
449
477
|
charBits: number;
|
|
@@ -458,7 +486,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
458
486
|
defaultLimit: number;
|
|
459
487
|
defaultPageSize: number;
|
|
460
488
|
elementTranscodes: Record<string, string>;
|
|
461
|
-
indexes: Record<string,
|
|
489
|
+
indexes: Record<string, {
|
|
490
|
+
components: [string, ...string[]];
|
|
491
|
+
projections?: [string, ...string[]] | undefined;
|
|
492
|
+
}>;
|
|
462
493
|
shardBumps: {
|
|
463
494
|
timestamp: number;
|
|
464
495
|
charBits: number;
|
|
@@ -477,7 +508,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
477
508
|
defaultLimit?: number | undefined;
|
|
478
509
|
defaultPageSize?: number | undefined;
|
|
479
510
|
elementTranscodes?: Record<string, string> | undefined;
|
|
480
|
-
indexes?: Record<string,
|
|
511
|
+
indexes?: Record<string, {
|
|
512
|
+
components: [string, ...string[]];
|
|
513
|
+
projections?: [string, ...string[]] | undefined;
|
|
514
|
+
}> | undefined;
|
|
481
515
|
shardBumps?: {
|
|
482
516
|
timestamp: number;
|
|
483
517
|
charBits: number;
|
|
@@ -512,7 +546,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
512
546
|
defaultLimit: number;
|
|
513
547
|
defaultPageSize: number;
|
|
514
548
|
elementTranscodes: Record<string, string>;
|
|
515
|
-
indexes: Record<string,
|
|
549
|
+
indexes: Record<string, {
|
|
550
|
+
components: [string, ...string[]];
|
|
551
|
+
projections?: [string, ...string[]] | undefined;
|
|
552
|
+
}>;
|
|
516
553
|
shardBumps: {
|
|
517
554
|
timestamp: number;
|
|
518
555
|
charBits: number;
|
|
@@ -543,7 +580,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
543
580
|
defaultLimit?: number | undefined;
|
|
544
581
|
defaultPageSize?: number | undefined;
|
|
545
582
|
elementTranscodes?: Record<string, string> | undefined;
|
|
546
|
-
indexes?: Record<string,
|
|
583
|
+
indexes?: Record<string, {
|
|
584
|
+
components: [string, ...string[]];
|
|
585
|
+
projections?: [string, ...string[]] | undefined;
|
|
586
|
+
}> | undefined;
|
|
547
587
|
shardBumps?: {
|
|
548
588
|
timestamp: number;
|
|
549
589
|
charBits: number;
|
|
@@ -570,7 +610,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
570
610
|
defaultLimit: number;
|
|
571
611
|
defaultPageSize: number;
|
|
572
612
|
elementTranscodes: Record<string, string>;
|
|
573
|
-
indexes: Record<string,
|
|
613
|
+
indexes: Record<string, {
|
|
614
|
+
components: [string, ...string[]];
|
|
615
|
+
projections?: [string, ...string[]] | undefined;
|
|
616
|
+
}>;
|
|
574
617
|
shardBumps: {
|
|
575
618
|
timestamp: number;
|
|
576
619
|
charBits: number;
|
|
@@ -601,7 +644,10 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
601
644
|
defaultLimit?: number | undefined;
|
|
602
645
|
defaultPageSize?: number | undefined;
|
|
603
646
|
elementTranscodes?: Record<string, string> | undefined;
|
|
604
|
-
indexes?: Record<string,
|
|
647
|
+
indexes?: Record<string, {
|
|
648
|
+
components: [string, ...string[]];
|
|
649
|
+
projections?: [string, ...string[]] | undefined;
|
|
650
|
+
}> | undefined;
|
|
605
651
|
shardBumps?: {
|
|
606
652
|
timestamp: number;
|
|
607
653
|
charBits: number;
|
|
@@ -623,7 +669,7 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
623
669
|
}> | undefined;
|
|
624
670
|
}>;
|
|
625
671
|
/**
|
|
626
|
-
*
|
|
672
|
+
* Simplified type taken on by a {@link Config | `Config`} object after parsing in the {@link EntityManager | `EntityManager`} constructor.
|
|
627
673
|
*
|
|
628
674
|
* @category Config
|
|
629
675
|
*/
|
|
@@ -831,41 +877,4 @@ declare class EntityManager<M extends EntityMap, HashKey extends string, RangeKe
|
|
|
831
877
|
query<Item extends ItemMap<M, HashKey, RangeKey>[EntityToken], EntityToken extends keyof Exactify<M> & string>(options: QueryOptions<Item, EntityToken, M, HashKey, RangeKey>): Promise<QueryResult<Item, EntityToken, M, HashKey, RangeKey>>;
|
|
832
878
|
}
|
|
833
879
|
|
|
834
|
-
|
|
835
|
-
* Generic logger endpoint type.
|
|
836
|
-
*
|
|
837
|
-
* @category Logger
|
|
838
|
-
*/
|
|
839
|
-
type LoggerEndpoint = (...args: unknown[]) => void;
|
|
840
|
-
/**
|
|
841
|
-
* Logger interface.
|
|
842
|
-
*
|
|
843
|
-
* @category Logger
|
|
844
|
-
*/
|
|
845
|
-
interface Logger {
|
|
846
|
-
debug: LoggerEndpoint;
|
|
847
|
-
error: LoggerEndpoint;
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Logger options.
|
|
851
|
-
*
|
|
852
|
-
* @category Logger
|
|
853
|
-
*/
|
|
854
|
-
interface LoggerOptions {
|
|
855
|
-
/** Logger to use for internal logging. Must support the `debug` & `error` methods. Defaults to `console`. */
|
|
856
|
-
logger?: Logger;
|
|
857
|
-
/** Enables internal logging when `true`. */
|
|
858
|
-
logInternals?: boolean;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* Returns an object type with specific properties rendered required and non-nullable.
|
|
863
|
-
*
|
|
864
|
-
* @typeParam T - The object type to modify.
|
|
865
|
-
* @typeParam K - Union of keys of `T` to render required and non-nullable.
|
|
866
|
-
*/
|
|
867
|
-
type WithRequiredAndNonNullable<T, K extends keyof T> = T & {
|
|
868
|
-
[P in K]-?: NonNullable<T[P]>;
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
export { type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigKeys, type ConfigTranscodes, EntityManager, type EntityMap, type ExclusiveKey, type ItemMap, type Logger, type LoggerEndpoint, type LoggerOptions, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryResult, type Unwrap, type WithRequiredAndNonNullable, conditionalize };
|
|
880
|
+
export { type Config, type ConfigEntities, type ConfigEntity, type ConfigEntityGenerated, type ConfigEntityIndexComponents, type ConfigKeys, type ConfigTranscodes, EntityManager, type EntityMap, type ExclusiveKey, type ItemMap, type ParsedConfig, type QueryOptions, type QueryResult, type ShardBump, type ShardQueryFunction, type ShardQueryMap, type ShardQueryResult, type Unwrap, conditionalize };
|
package/dist/mjs/ParsedConfig.js
CHANGED
|
@@ -21,6 +21,10 @@ const validateKeyExclusive = (key, label, ref, ctx) => {
|
|
|
21
21
|
message: `${label} '${key}' is not exclusive`,
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
+
const componentArray = z
|
|
25
|
+
.array(z.string().min(1))
|
|
26
|
+
.nonempty()
|
|
27
|
+
.superRefine(validateArrayUnique);
|
|
24
28
|
const configSchema = z
|
|
25
29
|
.object({
|
|
26
30
|
entities: z
|
|
@@ -44,10 +48,7 @@ const configSchema = z
|
|
|
44
48
|
.record(z
|
|
45
49
|
.object({
|
|
46
50
|
atomic: z.boolean().optional().default(false),
|
|
47
|
-
elements:
|
|
48
|
-
.array(z.string().min(1))
|
|
49
|
-
.nonempty()
|
|
50
|
-
.superRefine(validateArrayUnique),
|
|
51
|
+
elements: componentArray,
|
|
51
52
|
sharded: z.boolean().optional().default(false),
|
|
52
53
|
})
|
|
53
54
|
.optional())
|
|
@@ -55,10 +56,10 @@ const configSchema = z
|
|
|
55
56
|
.default({}),
|
|
56
57
|
elementTranscodes: z.record(z.string()).optional().default({}),
|
|
57
58
|
indexes: z
|
|
58
|
-
.record(z
|
|
59
|
-
|
|
60
|
-
.
|
|
61
|
-
|
|
59
|
+
.record(z.object({
|
|
60
|
+
components: componentArray,
|
|
61
|
+
projections: componentArray.optional(),
|
|
62
|
+
}))
|
|
62
63
|
.optional()
|
|
63
64
|
.default({}),
|
|
64
65
|
shardBumps: z
|
|
@@ -207,18 +208,42 @@ const configSchema = z
|
|
|
207
208
|
],
|
|
208
209
|
received: element,
|
|
209
210
|
});
|
|
210
|
-
// validate
|
|
211
|
+
// validate indexes.
|
|
211
212
|
const generatedProperties = Object.keys(entity.generated);
|
|
212
|
-
for (const [indexKey, index] of Object.entries(entity.indexes))
|
|
213
|
-
|
|
213
|
+
for (const [indexKey, index] of Object.entries(entity.indexes)) {
|
|
214
|
+
// validate all ungenerated entity index components have a corresponding entity element type
|
|
215
|
+
for (const component of index.components)
|
|
214
216
|
if (![data.hashKey, data.rangeKey, ...generatedProperties].includes(component) &&
|
|
215
217
|
!typedElements.includes(component))
|
|
216
218
|
ctx.addIssue({
|
|
217
219
|
code: z.ZodIssueCode.invalid_enum_value,
|
|
218
220
|
options: typedElements,
|
|
219
|
-
path: [
|
|
221
|
+
path: [
|
|
222
|
+
'entities',
|
|
223
|
+
entityToken,
|
|
224
|
+
'indexes',
|
|
225
|
+
indexKey,
|
|
226
|
+
'components',
|
|
227
|
+
],
|
|
220
228
|
received: component,
|
|
221
229
|
});
|
|
230
|
+
// validate no index projections are index components, hashKey, or rangeKey
|
|
231
|
+
if (index.projections)
|
|
232
|
+
for (const projection of index.projections) {
|
|
233
|
+
if ([data.hashKey, data.rangeKey, ...index.components].includes(projection))
|
|
234
|
+
ctx.addIssue({
|
|
235
|
+
code: z.ZodIssueCode.custom,
|
|
236
|
+
message: 'index projection is an index component, hash key, or range key',
|
|
237
|
+
path: [
|
|
238
|
+
'entities',
|
|
239
|
+
entityToken,
|
|
240
|
+
'indexes',
|
|
241
|
+
indexKey,
|
|
242
|
+
'projections',
|
|
243
|
+
],
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
222
247
|
}
|
|
223
248
|
});
|
|
224
249
|
|
package/dist/mjs/index.js
CHANGED
|
@@ -49,7 +49,8 @@ function rehydratePageKeyMap(entityManager, dehydrated, entityToken, indexTokens
|
|
|
49
49
|
...rehydrateIndexItem(entityManager, dehydratedIndexPageKeyMaps[i], entityToken, index, [entityManager.config.hashKey]),
|
|
50
50
|
};
|
|
51
51
|
item = updateItemRangeKey(entityManager, item, entityToken);
|
|
52
|
-
return zipToObject(entityManager.config.entities[entityToken].indexes[index]
|
|
52
|
+
return zipToObject(entityManager.config.entities[entityToken].indexes[index]
|
|
53
|
+
.components, (component) => entityManager.config.entities[entityToken].generated[component]
|
|
53
54
|
? encodeGeneratedProperty(entityManager, item, entityToken, component)
|
|
54
55
|
: item[component]);
|
|
55
56
|
}));
|
package/dist/mjs/unwrapIndex.js
CHANGED
|
@@ -19,7 +19,7 @@ function unwrapIndex(entityManager, entityToken, indexToken) {
|
|
|
19
19
|
validateEntityIndexToken(entityManager, entityToken, indexToken);
|
|
20
20
|
const generated = entityManager.config.entities[entityToken].generated;
|
|
21
21
|
const generatedKeys = Object.keys(shake(generated));
|
|
22
|
-
return entityManager.config.entities[entityToken].indexes[indexToken]
|
|
22
|
+
return entityManager.config.entities[entityToken].indexes[indexToken].components
|
|
23
23
|
.map((component) => component === entityManager.config.hashKey
|
|
24
24
|
? entityManager.config.hashKey
|
|
25
25
|
: component === entityManager.config.rangeKey
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/karmaniverous/entity-manager/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@karmaniverous/entity-tools": "^0.
|
|
7
|
+
"@karmaniverous/entity-tools": "^0.4.0",
|
|
8
8
|
"@karmaniverous/string-utilities": "^0.2.1",
|
|
9
9
|
"jsonschema": "^1.4.1",
|
|
10
10
|
"lz-string": "^1.5.0",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
},
|
|
15
15
|
"description": "Rational indexing & cross-shard querying at scale in your NoSQL database so you can focus on your application logic.",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@dotenvx/dotenvx": "^1.
|
|
17
|
+
"@dotenvx/dotenvx": "^1.21.0",
|
|
18
18
|
"@eslint/js": "^9.13.0",
|
|
19
|
-
"@faker-js/faker": "^9.0
|
|
19
|
+
"@faker-js/faker": "^9.1.0",
|
|
20
20
|
"@karmaniverous/mock-db": "^0.3.3",
|
|
21
21
|
"@rollup/plugin-alias": "^5.1.1",
|
|
22
22
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
25
25
|
"@rollup/plugin-strip": "^3.0.4",
|
|
26
26
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
27
|
-
"@types/chai": "^5.0.
|
|
27
|
+
"@types/chai": "^5.0.1",
|
|
28
28
|
"@types/eslint__js": "^8.42.3",
|
|
29
29
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
30
30
|
"@types/eslint-plugin-mocha": "^10.4.0",
|
|
31
31
|
"@types/mocha": "^10.0.9",
|
|
32
|
-
"@types/node": "^22.
|
|
32
|
+
"@types/node": "^22.8.2",
|
|
33
33
|
"@types/string-hash": "^1.1.3",
|
|
34
34
|
"auto-changelog": "^2.5.0",
|
|
35
|
-
"chai": "^5.1.
|
|
35
|
+
"chai": "^5.1.2",
|
|
36
36
|
"cross-env": "^7.0.3",
|
|
37
37
|
"eslint": "^9.13.0",
|
|
38
38
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -40,24 +40,24 @@
|
|
|
40
40
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
41
41
|
"eslint-plugin-tsdoc": "^0.3.0",
|
|
42
42
|
"jsdom-global": "^3.0.2",
|
|
43
|
-
"knip": "^5.
|
|
44
|
-
"lefthook": "^1.
|
|
43
|
+
"knip": "^5.34.2",
|
|
44
|
+
"lefthook": "^1.8.2",
|
|
45
45
|
"mocha": "^10.7.3",
|
|
46
46
|
"nyc": "^17.1.0",
|
|
47
47
|
"prettier": "^3.3.3",
|
|
48
48
|
"release-it": "^17.10.0",
|
|
49
49
|
"rimraf": "^6.0.1",
|
|
50
|
-
"rollup": "^4.24.
|
|
50
|
+
"rollup": "^4.24.2",
|
|
51
51
|
"rollup-plugin-dts": "^6.1.1",
|
|
52
52
|
"source-map-support": "^0.5.21",
|
|
53
53
|
"ts-node": "^10.9.2",
|
|
54
54
|
"tslib": "^2.8.0",
|
|
55
55
|
"typedoc": "^0.26.10",
|
|
56
|
-
"typedoc-plugin-mdn-links": "^3.3.
|
|
56
|
+
"typedoc-plugin-mdn-links": "^3.3.5",
|
|
57
57
|
"typedoc-plugin-replace-text": "^4.0.0",
|
|
58
58
|
"typedoc-plugin-zod": "^1.2.1",
|
|
59
59
|
"typescript": "^5.6.3",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
60
|
+
"typescript-eslint": "^8.12.1"
|
|
61
61
|
},
|
|
62
62
|
"exports": {
|
|
63
63
|
".": {
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
},
|
|
133
133
|
"type": "module",
|
|
134
134
|
"types": "dist/index.d.ts",
|
|
135
|
-
"version": "6.
|
|
135
|
+
"version": "6.5.0"
|
|
136
136
|
}
|