@expo/entity 0.53.0 → 0.55.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/build/src/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/src/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/src/EntityDatabaseAdapter.js.map +1 -1
- package/build/src/EntityFieldDefinition.js.map +1 -1
- package/build/src/EntityLoaderUtils.js +14 -18
- package/build/src/EntityLoaderUtils.js.map +1 -1
- package/build/src/GenericEntityCacheAdapter.js.map +1 -1
- package/build/src/GenericSecondaryEntityCache.js.map +1 -1
- package/build/src/entityUtils.js +7 -2
- package/build/src/entityUtils.js.map +1 -1
- package/build/src/errors/EntityCacheAdapterError.d.ts +2 -2
- package/build/src/errors/EntityCacheAdapterError.js +12 -2
- package/build/src/errors/EntityCacheAdapterError.js.map +1 -1
- package/build/src/errors/EntityDatabaseAdapterError.d.ts +24 -24
- package/build/src/errors/EntityDatabaseAdapterError.js +111 -24
- package/build/src/errors/EntityDatabaseAdapterError.js.map +1 -1
- package/build/src/errors/EntityError.d.ts +2 -4
- package/build/src/errors/EntityError.js +5 -8
- package/build/src/errors/EntityError.js.map +1 -1
- package/build/src/errors/EntityInvalidFieldValueError.d.ts +2 -2
- package/build/src/errors/EntityInvalidFieldValueError.js +9 -2
- package/build/src/errors/EntityInvalidFieldValueError.js.map +1 -1
- package/build/src/errors/EntityNotAuthorizedError.d.ts +2 -2
- package/build/src/errors/EntityNotAuthorizedError.js +9 -2
- package/build/src/errors/EntityNotAuthorizedError.js.map +1 -1
- package/build/src/errors/EntityNotFoundError.d.ts +2 -2
- package/build/src/errors/EntityNotFoundError.js +9 -2
- package/build/src/errors/EntityNotFoundError.js.map +1 -1
- package/build/src/index.d.ts +4 -0
- package/build/src/index.js +4 -0
- package/build/src/index.js.map +1 -1
- package/build/src/internal/CompositeFieldHolder.js.map +1 -1
- package/build/src/internal/CompositeFieldValueMap.js.map +1 -1
- package/build/src/internal/SingleFieldHolder.js.map +1 -1
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.d.ts +10 -0
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.js +19 -0
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.js.map +1 -0
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.d.ts +10 -0
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.js +19 -0
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.js.map +1 -0
- package/build/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.d.ts +66 -0
- package/build/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.js +75 -0
- package/build/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.js.map +1 -0
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.d.ts +12 -0
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.js +23 -0
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.js.map +1 -0
- package/build/src/utils/EntityPrivacyUtils.js +34 -15
- package/build/src/utils/EntityPrivacyUtils.js.map +1 -1
- package/package.json +10 -13
- package/src/ComposedEntityCacheAdapter.ts +1 -2
- package/src/ComposedSecondaryEntityCache.ts +4 -3
- package/src/EntityDatabaseAdapter.ts +3 -2
- package/src/EntityFieldDefinition.ts +1 -2
- package/src/EntityLoaderUtils.ts +17 -20
- package/src/GenericEntityCacheAdapter.ts +1 -2
- package/src/GenericSecondaryEntityCache.ts +1 -2
- package/src/__tests__/ComposedCacheAdapter-test.ts +4 -3
- package/src/__tests__/EntityFields-test.ts +2 -8
- package/src/entityUtils.ts +7 -4
- package/src/errors/EntityCacheAdapterError.ts +16 -3
- package/src/errors/EntityDatabaseAdapterError.ts +137 -25
- package/src/errors/EntityError.ts +7 -8
- package/src/errors/EntityInvalidFieldValueError.ts +11 -2
- package/src/errors/EntityNotAuthorizedError.ts +11 -2
- package/src/errors/EntityNotFoundError.ts +11 -2
- package/src/errors/__tests__/EntityDatabaseAdapterError-test.ts +68 -11
- package/src/errors/__tests__/EntityError-test.ts +36 -0
- package/src/index.ts +4 -0
- package/src/internal/CompositeFieldHolder.ts +7 -10
- package/src/internal/CompositeFieldValueMap.ts +1 -2
- package/src/internal/SingleFieldHolder.ts +10 -6
- package/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.ts +47 -0
- package/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.ts +47 -0
- package/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.ts +177 -0
- package/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.ts +46 -0
- package/src/rules/__tests__/AllowIfAllSubRulesAllowPrivacyPolicyRule-test.ts +64 -0
- package/src/rules/__tests__/AllowIfAnySubRuleAllowsPrivacyPolicyRule-test.ts +64 -0
- package/src/rules/__tests__/AllowIfInParentCascadeDeletionPrivacyPolicyRule-test.ts +258 -0
- package/src/rules/__tests__/EvaluateIfEntityFieldPredicatePrivacyPolicyRule-test.ts +47 -0
- package/src/utils/EntityPrivacyUtils.ts +61 -20
- package/src/utils/__testfixtures__/StubCacheAdapter.ts +2 -4
- package/src/utils/__testfixtures__/StubDatabaseAdapter.ts +1 -1
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +295 -0
|
@@ -30,8 +30,7 @@ async function canViewerUpdateAsync(entityClass, sourceEntity, queryContext = so
|
|
|
30
30
|
.getViewerScopedEntityCompanionForClass(entityClass)
|
|
31
31
|
.getQueryContextProvider()
|
|
32
32
|
.getQueryContext()) {
|
|
33
|
-
const result = await canViewerUpdateInternalAsync(entityClass, sourceEntity,
|
|
34
|
-
/* cascadingDeleteCause */ null, queryContext);
|
|
33
|
+
const result = await canViewerUpdateInternalAsync(entityClass, sourceEntity, { previousValue: sourceEntity, cascadingDeleteCause: null }, queryContext);
|
|
35
34
|
return result.allowed;
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
@@ -48,15 +47,14 @@ async function getCanViewerUpdateResultAsync(entityClass, sourceEntity, queryCon
|
|
|
48
47
|
.getViewerScopedEntityCompanionForClass(entityClass)
|
|
49
48
|
.getQueryContextProvider()
|
|
50
49
|
.getQueryContext()) {
|
|
51
|
-
return await canViewerUpdateInternalAsync(entityClass, sourceEntity,
|
|
52
|
-
/* cascadingDeleteCause */ null, queryContext);
|
|
50
|
+
return await canViewerUpdateInternalAsync(entityClass, sourceEntity, { previousValue: sourceEntity, cascadingDeleteCause: null }, queryContext);
|
|
53
51
|
}
|
|
54
|
-
async function canViewerUpdateInternalAsync(entityClass, sourceEntity,
|
|
52
|
+
async function canViewerUpdateInternalAsync(entityClass, sourceEntity, evaluationContext, queryContext) {
|
|
55
53
|
const companion = sourceEntity
|
|
56
54
|
.getViewerContext()
|
|
57
55
|
.getViewerScopedEntityCompanionForClass(entityClass);
|
|
58
56
|
const privacyPolicy = companion.entityCompanion.privacyPolicy;
|
|
59
|
-
const evaluationResult = await (0, results_1.asyncResult)(privacyPolicy.authorizeUpdateAsync(sourceEntity.getViewerContext(), queryContext,
|
|
57
|
+
const evaluationResult = await (0, results_1.asyncResult)(privacyPolicy.authorizeUpdateAsync(sourceEntity.getViewerContext(), queryContext, evaluationContext, sourceEntity, companion.getMetricsAdapter()));
|
|
60
58
|
if (!evaluationResult.ok) {
|
|
61
59
|
if (evaluationResult.reason instanceof EntityNotAuthorizedError_1.EntityNotAuthorizedError) {
|
|
62
60
|
return { allowed: false, authorizationErrors: [evaluationResult.reason] };
|
|
@@ -82,8 +80,7 @@ async function canViewerDeleteAsync(entityClass, sourceEntity, queryContext = so
|
|
|
82
80
|
.getViewerScopedEntityCompanionForClass(entityClass)
|
|
83
81
|
.getQueryContextProvider()
|
|
84
82
|
.getQueryContext()) {
|
|
85
|
-
const result = await canViewerDeleteInternalAsync(entityClass, sourceEntity,
|
|
86
|
-
/* cascadingDeleteCause */ null, queryContext);
|
|
83
|
+
const result = await canViewerDeleteInternalAsync(entityClass, sourceEntity, { previousValue: null, cascadingDeleteCause: null }, queryContext);
|
|
87
84
|
return result.allowed;
|
|
88
85
|
}
|
|
89
86
|
/**
|
|
@@ -100,17 +97,16 @@ async function getCanViewerDeleteResultAsync(entityClass, sourceEntity, queryCon
|
|
|
100
97
|
.getViewerScopedEntityCompanionForClass(entityClass)
|
|
101
98
|
.getQueryContextProvider()
|
|
102
99
|
.getQueryContext()) {
|
|
103
|
-
return await canViewerDeleteInternalAsync(entityClass, sourceEntity,
|
|
104
|
-
/* cascadingDeleteCause */ null, queryContext);
|
|
100
|
+
return await canViewerDeleteInternalAsync(entityClass, sourceEntity, { previousValue: null, cascadingDeleteCause: null }, queryContext);
|
|
105
101
|
}
|
|
106
|
-
async function canViewerDeleteInternalAsync(entityClass, sourceEntity,
|
|
102
|
+
async function canViewerDeleteInternalAsync(entityClass, sourceEntity, evaluationContext, queryContext) {
|
|
107
103
|
const viewerContext = sourceEntity.getViewerContext();
|
|
108
104
|
const entityCompanionProvider = viewerContext.entityCompanionProvider;
|
|
109
105
|
const viewerScopedCompanion = sourceEntity
|
|
110
106
|
.getViewerContext()
|
|
111
107
|
.getViewerScopedEntityCompanionForClass(entityClass);
|
|
112
108
|
const privacyPolicy = viewerScopedCompanion.entityCompanion.privacyPolicy;
|
|
113
|
-
const evaluationResult = await (0, results_1.asyncResult)(privacyPolicy.authorizeDeleteAsync(sourceEntity.getViewerContext(), queryContext,
|
|
109
|
+
const evaluationResult = await (0, results_1.asyncResult)(privacyPolicy.authorizeDeleteAsync(sourceEntity.getViewerContext(), queryContext, evaluationContext, sourceEntity, viewerScopedCompanion.getMetricsAdapter()));
|
|
114
110
|
if (!evaluationResult.ok) {
|
|
115
111
|
if (evaluationResult.reason instanceof EntityNotAuthorizedError_1.EntityNotAuthorizedError) {
|
|
116
112
|
return { allowed: false, authorizationErrors: [evaluationResult.reason] };
|
|
@@ -121,7 +117,7 @@ async function canViewerDeleteInternalAsync(entityClass, sourceEntity, cascading
|
|
|
121
117
|
}
|
|
122
118
|
const newCascadingDeleteCause = {
|
|
123
119
|
entity: sourceEntity,
|
|
124
|
-
cascadingDeleteCause,
|
|
120
|
+
cascadingDeleteCause: evaluationContext.cascadingDeleteCause,
|
|
125
121
|
};
|
|
126
122
|
// Take entity X which is proposed to be deleted, look at inbound edges (entities that reference X).
|
|
127
123
|
// These inbound edges are the entities that will either get deleted or have their references
|
|
@@ -188,7 +184,7 @@ async function canViewerDeleteInternalAsync(entityClass, sourceEntity, cascading
|
|
|
188
184
|
switch (association.edgeDeletionBehavior) {
|
|
189
185
|
case EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE:
|
|
190
186
|
case EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE_ONLY: {
|
|
191
|
-
const canDeleteEvaluationResults = await Promise.all(entitiesForInboundEdge.map((entity) => canViewerDeleteInternalAsync(inboundEdge, entity, newCascadingDeleteCause, queryContext)));
|
|
187
|
+
const canDeleteEvaluationResults = await Promise.all(entitiesForInboundEdge.map((entity) => canViewerDeleteInternalAsync(inboundEdge, entity, { previousValue: null, cascadingDeleteCause: newCascadingDeleteCause }, queryContext)));
|
|
192
188
|
const reducedEvaluationResult = reduceEvaluationResults(canDeleteEvaluationResults);
|
|
193
189
|
if (!reducedEvaluationResult.allowed) {
|
|
194
190
|
return reducedEvaluationResult;
|
|
@@ -197,7 +193,30 @@ async function canViewerDeleteInternalAsync(entityClass, sourceEntity, cascading
|
|
|
197
193
|
}
|
|
198
194
|
case EntityFieldDefinition_1.EntityEdgeDeletionBehavior.SET_NULL:
|
|
199
195
|
case EntityFieldDefinition_1.EntityEdgeDeletionBehavior.SET_NULL_INVALIDATE_CACHE_ONLY: {
|
|
200
|
-
|
|
196
|
+
// create synthetic entities with the reference field set to null to properly evaluate
|
|
197
|
+
// privacy policy as it would be after the cascading SET NULL operation
|
|
198
|
+
const previousAndSyntheticEntitiesForInboundEdge = entitiesForInboundEdge.map((entity) => {
|
|
199
|
+
const entityLoader = viewerContext
|
|
200
|
+
.getViewerScopedEntityCompanionForClass(inboundEdge)
|
|
201
|
+
.getLoaderFactory()
|
|
202
|
+
.forLoad(queryContext, {
|
|
203
|
+
previousValue: entity,
|
|
204
|
+
cascadingDeleteCause: newCascadingDeleteCause,
|
|
205
|
+
});
|
|
206
|
+
const allFields = entity.getAllDatabaseFields();
|
|
207
|
+
const syntheticFields = {
|
|
208
|
+
...allFields,
|
|
209
|
+
[fieldName]: null,
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
previousValue: entity,
|
|
213
|
+
syntheticallyUpdatedValue: entityLoader.utils.constructEntity(syntheticFields),
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
const canUpdateEvaluationResults = await Promise.all(previousAndSyntheticEntitiesForInboundEdge.map(({ previousValue, syntheticallyUpdatedValue }) => canViewerUpdateInternalAsync(inboundEdge, syntheticallyUpdatedValue, {
|
|
217
|
+
previousValue,
|
|
218
|
+
cascadingDeleteCause: newCascadingDeleteCause,
|
|
219
|
+
}, queryContext)));
|
|
201
220
|
const reducedEvaluationResult = reduceEvaluationResults(canUpdateEvaluationResults);
|
|
202
221
|
if (!reducedEvaluationResult.allowed) {
|
|
203
222
|
return reducedEvaluationResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityPrivacyUtils.js","sourceRoot":"","sources":["../../../src/utils/EntityPrivacyUtils.ts"],"names":[],"mappings":";;AA4CA,oDAoCC;AAWD,sEAmCC;
|
|
1
|
+
{"version":3,"file":"EntityPrivacyUtils.js","sourceRoot":"","sources":["../../../src/utils/EntityPrivacyUtils.ts"],"names":[],"mappings":";;AA4CA,oDAoCC;AAWD,sEAmCC;AAmED,oDAoCC;AAWD,sEAmCC;AAnRD,2CAAoD;AAGpD,oEAGkC;AAKlC,gDAA+D;AAC/D,iFAA8E;AAe9E;;;;;;;;;;;;;;;;GAg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C;IAErE,IAAI,cAAc,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK;QACd,mBAAmB,EAAE,cAAc,CAAC,OAAO,CACzC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,mBAAmB,CACrD;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/entity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "A privacy-first data model",
|
|
5
5
|
"files": [
|
|
6
6
|
"build",
|
|
@@ -29,20 +29,17 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/results": "^1.0.0",
|
|
31
31
|
"dataloader": "^2.2.3",
|
|
32
|
-
"es6-error": "^4.1.1",
|
|
33
32
|
"invariant": "^2.2.4"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@jest/globals": "
|
|
37
|
-
"@types/invariant": "
|
|
38
|
-
"@types/lodash": "
|
|
39
|
-
"@types/node": "
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"uuid": "^8.3.0",
|
|
45
|
-
"uuidv7": "^1.0.0"
|
|
35
|
+
"@jest/globals": "30.2.0",
|
|
36
|
+
"@types/invariant": "2.2.37",
|
|
37
|
+
"@types/lodash": "4.17.23",
|
|
38
|
+
"@types/node": "24.10.9",
|
|
39
|
+
"lodash": "4.17.23",
|
|
40
|
+
"ts-mockito": "2.6.1",
|
|
41
|
+
"typescript": "5.9.3",
|
|
42
|
+
"uuid": "13.0.0"
|
|
46
43
|
},
|
|
47
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "de7548680dbffb722fb6f5c92106392319782fef"
|
|
48
45
|
}
|
|
@@ -10,8 +10,7 @@ import { CacheLoadResult, CacheStatus } from './internal/ReadThroughEntityCache'
|
|
|
10
10
|
export class ComposedEntityCacheAdapter<
|
|
11
11
|
TFields extends Record<string, any>,
|
|
12
12
|
TIDField extends keyof TFields,
|
|
13
|
-
> implements IEntityCacheAdapter<TFields, TIDField>
|
|
14
|
-
{
|
|
13
|
+
> implements IEntityCacheAdapter<TFields, TIDField> {
|
|
15
14
|
/**
|
|
16
15
|
* @param cacheAdapters - list of cache adapters to compose in order of precedence.
|
|
17
16
|
* Earlier cache adapters are read from first and written to (including invalidations) last.
|
|
@@ -5,9 +5,10 @@ import { ISecondaryEntityCache } from './EntitySecondaryCacheLoader';
|
|
|
5
5
|
/**
|
|
6
6
|
* A ISecondaryEntityCache that composes other ISecondaryEntityCache instances.
|
|
7
7
|
*/
|
|
8
|
-
export class ComposedSecondaryEntityCache<
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export class ComposedSecondaryEntityCache<
|
|
9
|
+
TLoadParams,
|
|
10
|
+
TFields extends Record<string, any>,
|
|
11
|
+
> implements ISecondaryEntityCache<TFields, TLoadParams> {
|
|
11
12
|
/**
|
|
12
13
|
* @param secondaryEntityCaches - list of caches to compose in order of precedence.
|
|
13
14
|
* Earlier caches are read from first and written to (including invalidations) last.
|
|
@@ -114,8 +114,9 @@ export interface QuerySelectionModifiers<TFields extends Record<string, any>> {
|
|
|
114
114
|
limit?: number;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
export interface QuerySelectionModifiersWithOrderByRaw<
|
|
118
|
-
extends
|
|
117
|
+
export interface QuerySelectionModifiersWithOrderByRaw<
|
|
118
|
+
TFields extends Record<string, any>,
|
|
119
|
+
> extends QuerySelectionModifiers<TFields> {
|
|
119
120
|
/**
|
|
120
121
|
* Order the entities by a raw SQL `ORDER BY` clause.
|
|
121
122
|
*/
|
|
@@ -147,8 +147,7 @@ export interface EntityFieldDefinitionOptionsBase {
|
|
|
147
147
|
association?: EntityAssociationDefinition<any, any, any, any, any, any>;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
export interface EntityFieldDefinitionOptionsExplicitCache
|
|
151
|
-
extends EntityFieldDefinitionOptionsBase {
|
|
150
|
+
export interface EntityFieldDefinitionOptionsExplicitCache extends EntityFieldDefinitionOptionsBase {
|
|
152
151
|
/**
|
|
153
152
|
* Whether or not to cache loaded instances of the entity by this field. The column name is
|
|
154
153
|
* used to derive a cache key for the cache entry. If true, this column must be able uniquely
|
package/src/EntityLoaderUtils.ts
CHANGED
|
@@ -61,29 +61,26 @@ export class EntityLoaderUtils<
|
|
|
61
61
|
objectFields: Readonly<TFields>,
|
|
62
62
|
): readonly LoadPair<TFields, TIDField, any, any, any>[] {
|
|
63
63
|
const keys = Object.keys(objectFields) as (keyof TFields)[];
|
|
64
|
-
const singleFieldKeyValues =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
return [
|
|
64
|
+
const singleFieldKeyValues: LoadPair<TFields, TIDField, any, any, any>[] = [];
|
|
65
|
+
for (const fieldName of keys) {
|
|
66
|
+
const value = objectFields[fieldName];
|
|
67
|
+
if (value !== undefined && value !== null) {
|
|
68
|
+
singleFieldKeyValues.push([
|
|
71
69
|
new SingleFieldHolder<TFields, TIDField, typeof fieldName>(fieldName),
|
|
72
70
|
new SingleFieldValueHolder(value),
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const compositeFieldKeyValues: LoadPair<TFields, TIDField, any, any, any>[] = [];
|
|
76
|
+
for (const compositeFieldHolder of this.entityConfiguration.compositeFieldInfo.getAllCompositeFieldHolders()) {
|
|
77
|
+
const compositeFieldValueHolder =
|
|
78
|
+
compositeFieldHolder.extractCompositeFieldValueHolderFromObjectFields(objectFields);
|
|
79
|
+
if (compositeFieldValueHolder) {
|
|
80
|
+
compositeFieldKeyValues.push([compositeFieldHolder, compositeFieldValueHolder]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
76
83
|
|
|
77
|
-
const compositeFieldKeyValues = this.entityConfiguration.compositeFieldInfo
|
|
78
|
-
.getAllCompositeFieldHolders()
|
|
79
|
-
.map((compositeFieldHolder) => {
|
|
80
|
-
const compositeFieldValueHolder =
|
|
81
|
-
compositeFieldHolder.extractCompositeFieldValueHolderFromObjectFields(objectFields);
|
|
82
|
-
return compositeFieldValueHolder
|
|
83
|
-
? ([compositeFieldHolder, compositeFieldValueHolder] as const)
|
|
84
|
-
: null;
|
|
85
|
-
})
|
|
86
|
-
.filter((kv) => kv !== null);
|
|
87
84
|
return [...singleFieldKeyValues, ...compositeFieldKeyValues];
|
|
88
85
|
}
|
|
89
86
|
|
|
@@ -12,8 +12,7 @@ import { mapKeys } from './utils/collections/maps';
|
|
|
12
12
|
export class GenericEntityCacheAdapter<
|
|
13
13
|
TFields extends Record<string, any>,
|
|
14
14
|
TIDField extends keyof TFields,
|
|
15
|
-
> implements IEntityCacheAdapter<TFields, TIDField>
|
|
16
|
-
{
|
|
15
|
+
> implements IEntityCacheAdapter<TFields, TIDField> {
|
|
17
16
|
constructor(private readonly genericCacher: IEntityGenericCacher<TFields, TIDField>) {}
|
|
18
17
|
|
|
19
18
|
public async loadManyAsync<
|
|
@@ -14,8 +14,7 @@ export abstract class GenericSecondaryEntityCache<
|
|
|
14
14
|
TFields extends Record<string, any>,
|
|
15
15
|
TIDField extends keyof TFields,
|
|
16
16
|
TLoadParams,
|
|
17
|
-
> implements ISecondaryEntityCache<TFields, TLoadParams>
|
|
18
|
-
{
|
|
17
|
+
> implements ISecondaryEntityCache<TFields, TLoadParams> {
|
|
19
18
|
constructor(
|
|
20
19
|
protected readonly cacher: IEntityGenericCacher<TFields, TIDField>,
|
|
21
20
|
protected readonly constructCacheKey: (params: Readonly<TLoadParams>) => string,
|
|
@@ -27,9 +27,10 @@ type LocalMemoryCacheValue<TFields extends Record<string, any>> =
|
|
|
27
27
|
| Readonly<TFields>
|
|
28
28
|
| typeof DOES_NOT_EXIST_LOCAL_MEMORY_CACHE;
|
|
29
29
|
|
|
30
|
-
class TestLocalCacheAdapter<
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
class TestLocalCacheAdapter<
|
|
31
|
+
TFields extends Record<string, any>,
|
|
32
|
+
TIDField extends keyof TFields,
|
|
33
|
+
> implements IEntityCacheAdapter<TFields, TIDField> {
|
|
33
34
|
constructor(
|
|
34
35
|
private readonly entityConfiguration: EntityConfiguration<TFields, TIDField>,
|
|
35
36
|
private readonly cache: Map<string, LocalMemoryCacheValue<TFields>>,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it, test } from '@jest/globals';
|
|
2
|
-
import { v1 as uuidv1, v3 as uuidv3, v4 as uuidv4, v5 as uuidv5 } from 'uuid';
|
|
2
|
+
import { v1 as uuidv1, v3 as uuidv3, v4 as uuidv4, v5 as uuidv5, v7 as uuidv7 } from 'uuid';
|
|
3
3
|
|
|
4
4
|
import { EntityFieldDefinition } from '../EntityFieldDefinition';
|
|
5
5
|
import {
|
|
@@ -58,13 +58,7 @@ describe(EntityFieldDefinition, () => {
|
|
|
58
58
|
describeFieldTestCase(new StringField({ columnName: 'wat' }), ['hello', ''], [1, true, {}, [[]]]);
|
|
59
59
|
describeFieldTestCase(
|
|
60
60
|
new UUIDField({ columnName: 'wat' }),
|
|
61
|
-
[
|
|
62
|
-
uuidv1(),
|
|
63
|
-
uuidv3('wat', uuidv3.DNS),
|
|
64
|
-
uuidv4(),
|
|
65
|
-
uuidv5('wat', uuidv5.DNS),
|
|
66
|
-
/* UUIDv7 */ '018ebfda-dc80-782d-a891-22a0aa057d52',
|
|
67
|
-
],
|
|
61
|
+
[uuidv1(), uuidv3('wat', uuidv3.DNS), uuidv4(), uuidv5('wat', uuidv5.DNS), uuidv7()],
|
|
68
62
|
[uuidv4().replace('-', ''), '', 'hello', uuidv4().toUpperCase()],
|
|
69
63
|
);
|
|
70
64
|
describeFieldTestCase(new DateField({ columnName: 'wat' }), [new Date()], [Date.now()]);
|
package/src/entityUtils.ts
CHANGED
|
@@ -115,8 +115,11 @@ export const pick = <T extends object, U extends keyof T>(
|
|
|
115
115
|
object: T,
|
|
116
116
|
props: readonly U[],
|
|
117
117
|
): Pick<T, U> => {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
const result = {} as Pick<T, U>;
|
|
119
|
+
for (const prop of props) {
|
|
120
|
+
if (object.hasOwnProperty(prop)) {
|
|
121
|
+
result[prop] = object[prop];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
122
125
|
};
|
|
@@ -3,13 +3,26 @@ import { EntityError, EntityErrorCode, EntityErrorState } from './EntityError';
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for errors thrown by the entity cache adapter.
|
|
5
5
|
*/
|
|
6
|
-
export abstract class EntityCacheAdapterError extends EntityError {
|
|
6
|
+
export abstract class EntityCacheAdapterError extends EntityError {
|
|
7
|
+
static {
|
|
8
|
+
this.prototype.name = 'EntityCacheAdapterError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* Error thrown when a transient error occurs in the entity cache adapter.
|
|
10
14
|
* Transient errors may succeed if retried.
|
|
11
15
|
*/
|
|
12
16
|
export class EntityCacheAdapterTransientError extends EntityCacheAdapterError {
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
static {
|
|
18
|
+
this.prototype.name = 'EntityCacheAdapterTransientError';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get state(): EntityErrorState.TRANSIENT {
|
|
22
|
+
return EntityErrorState.TRANSIENT;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get code(): EntityErrorCode.ERR_ENTITY_CACHE_ADAPTER_TRANSIENT {
|
|
26
|
+
return EntityErrorCode.ERR_ENTITY_CACHE_ADAPTER_TRANSIENT;
|
|
27
|
+
}
|
|
15
28
|
}
|
|
@@ -3,15 +3,28 @@ import { EntityError, EntityErrorCode, EntityErrorState } from './EntityError';
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for all errors related to the database adapter.
|
|
5
5
|
*/
|
|
6
|
-
export abstract class EntityDatabaseAdapterError extends EntityError {
|
|
6
|
+
export abstract class EntityDatabaseAdapterError extends EntityError {
|
|
7
|
+
static {
|
|
8
|
+
this.prototype.name = 'EntityDatabaseAdapterError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* Thrown when a transient error occurrs within the database adapter.
|
|
10
14
|
* Transient errors may succeed if retried.
|
|
11
15
|
*/
|
|
12
16
|
export class EntityDatabaseAdapterTransientError extends EntityDatabaseAdapterError {
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
static {
|
|
18
|
+
this.prototype.name = 'EntityDatabaseAdapterTransientError';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get state(): EntityErrorState.TRANSIENT {
|
|
22
|
+
return EntityErrorState.TRANSIENT;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_TRANSIENT {
|
|
26
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_TRANSIENT;
|
|
27
|
+
}
|
|
15
28
|
}
|
|
16
29
|
|
|
17
30
|
/**
|
|
@@ -19,8 +32,17 @@ export class EntityDatabaseAdapterTransientError extends EntityDatabaseAdapterEr
|
|
|
19
32
|
* This is a catch-all error class for DBMS-specific errors that do not fit into other categories.
|
|
20
33
|
*/
|
|
21
34
|
export class EntityDatabaseAdapterUnknownError extends EntityDatabaseAdapterError {
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
static {
|
|
36
|
+
this.prototype.name = 'EntityDatabaseAdapterUnknownError';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get state(): EntityErrorState.UNKNOWN {
|
|
40
|
+
return EntityErrorState.UNKNOWN;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_UNKNOWN {
|
|
44
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_UNKNOWN;
|
|
45
|
+
}
|
|
24
46
|
}
|
|
25
47
|
|
|
26
48
|
/**
|
|
@@ -28,8 +50,17 @@ export class EntityDatabaseAdapterUnknownError extends EntityDatabaseAdapterErro
|
|
|
28
50
|
* This indicates that a value being inserted or updated does not satisfy a defined data integrity constraint.
|
|
29
51
|
*/
|
|
30
52
|
export class EntityDatabaseAdapterCheckConstraintError extends EntityDatabaseAdapterError {
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
static {
|
|
54
|
+
this.prototype.name = 'EntityDatabaseAdapterCheckConstraintError';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get state(): EntityErrorState.PERMANENT {
|
|
58
|
+
return EntityErrorState.PERMANENT;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_CHECK_CONSTRAINT {
|
|
62
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_CHECK_CONSTRAINT;
|
|
63
|
+
}
|
|
33
64
|
}
|
|
34
65
|
|
|
35
66
|
/**
|
|
@@ -37,8 +68,17 @@ export class EntityDatabaseAdapterCheckConstraintError extends EntityDatabaseAda
|
|
|
37
68
|
* This indicates that a value being inserted or updated conflicts with an existing value based on a defined exclusion constraint.
|
|
38
69
|
*/
|
|
39
70
|
export class EntityDatabaseAdapterExclusionConstraintError extends EntityDatabaseAdapterError {
|
|
40
|
-
|
|
41
|
-
|
|
71
|
+
static {
|
|
72
|
+
this.prototype.name = 'EntityDatabaseAdapterExclusionConstraintError';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get state(): EntityErrorState.PERMANENT {
|
|
76
|
+
return EntityErrorState.PERMANENT;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCLUSION_CONSTRAINT {
|
|
80
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCLUSION_CONSTRAINT;
|
|
81
|
+
}
|
|
42
82
|
}
|
|
43
83
|
|
|
44
84
|
/**
|
|
@@ -47,8 +87,17 @@ export class EntityDatabaseAdapterExclusionConstraintError extends EntityDatabas
|
|
|
47
87
|
* or is referenced in a related table.
|
|
48
88
|
*/
|
|
49
89
|
export class EntityDatabaseAdapterForeignKeyConstraintError extends EntityDatabaseAdapterError {
|
|
50
|
-
|
|
51
|
-
|
|
90
|
+
static {
|
|
91
|
+
this.prototype.name = 'EntityDatabaseAdapterForeignKeyConstraintError';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get state(): EntityErrorState.PERMANENT {
|
|
95
|
+
return EntityErrorState.PERMANENT;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_FOREIGN_KEY_CONSTRAINT {
|
|
99
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_FOREIGN_KEY_CONSTRAINT;
|
|
100
|
+
}
|
|
52
101
|
}
|
|
53
102
|
|
|
54
103
|
/**
|
|
@@ -56,8 +105,17 @@ export class EntityDatabaseAdapterForeignKeyConstraintError extends EntityDataba
|
|
|
56
105
|
* This indicates that a null value is being inserted or updated into a column that does not allow null values.
|
|
57
106
|
*/
|
|
58
107
|
export class EntityDatabaseAdapterNotNullConstraintError extends EntityDatabaseAdapterError {
|
|
59
|
-
|
|
60
|
-
|
|
108
|
+
static {
|
|
109
|
+
this.prototype.name = 'EntityDatabaseAdapterNotNullConstraintError';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get state(): EntityErrorState.PERMANENT {
|
|
113
|
+
return EntityErrorState.PERMANENT;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_NOT_NULL_CONSTRAINT {
|
|
117
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_NOT_NULL_CONSTRAINT;
|
|
118
|
+
}
|
|
61
119
|
}
|
|
62
120
|
|
|
63
121
|
/**
|
|
@@ -66,8 +124,17 @@ export class EntityDatabaseAdapterNotNullConstraintError extends EntityDatabaseA
|
|
|
66
124
|
* that require unique values.
|
|
67
125
|
*/
|
|
68
126
|
export class EntityDatabaseAdapterUniqueConstraintError extends EntityDatabaseAdapterError {
|
|
69
|
-
|
|
70
|
-
|
|
127
|
+
static {
|
|
128
|
+
this.prototype.name = 'EntityDatabaseAdapterUniqueConstraintError';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get state(): EntityErrorState.PERMANENT {
|
|
132
|
+
return EntityErrorState.PERMANENT;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_UNIQUE_CONSTRAINT {
|
|
136
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_UNIQUE_CONSTRAINT;
|
|
137
|
+
}
|
|
71
138
|
}
|
|
72
139
|
|
|
73
140
|
/**
|
|
@@ -76,8 +143,17 @@ export class EntityDatabaseAdapterUniqueConstraintError extends EntityDatabaseAd
|
|
|
76
143
|
* triggers or something similar.
|
|
77
144
|
*/
|
|
78
145
|
export class EntityDatabaseAdapterExcessiveInsertResultError extends EntityDatabaseAdapterError {
|
|
79
|
-
|
|
80
|
-
|
|
146
|
+
static {
|
|
147
|
+
this.prototype.name = 'EntityDatabaseAdapterExcessiveInsertResultError';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
get state(): EntityErrorState.PERMANENT {
|
|
151
|
+
return EntityErrorState.PERMANENT;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCESSIVE_INSERT_RESULT {
|
|
155
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCESSIVE_INSERT_RESULT;
|
|
156
|
+
}
|
|
81
157
|
}
|
|
82
158
|
|
|
83
159
|
/**
|
|
@@ -86,8 +162,17 @@ export class EntityDatabaseAdapterExcessiveInsertResultError extends EntityDatab
|
|
|
86
162
|
* triggers or something similar.
|
|
87
163
|
*/
|
|
88
164
|
export class EntityDatabaseAdapterEmptyInsertResultError extends EntityDatabaseAdapterError {
|
|
89
|
-
|
|
90
|
-
|
|
165
|
+
static {
|
|
166
|
+
this.prototype.name = 'EntityDatabaseAdapterEmptyInsertResultError';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get state(): EntityErrorState.PERMANENT {
|
|
170
|
+
return EntityErrorState.PERMANENT;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EMPTY_INSERT_RESULT {
|
|
174
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EMPTY_INSERT_RESULT;
|
|
175
|
+
}
|
|
91
176
|
}
|
|
92
177
|
|
|
93
178
|
/**
|
|
@@ -96,8 +181,17 @@ export class EntityDatabaseAdapterEmptyInsertResultError extends EntityDatabaseA
|
|
|
96
181
|
* primary key column.
|
|
97
182
|
*/
|
|
98
183
|
export class EntityDatabaseAdapterExcessiveUpdateResultError extends EntityDatabaseAdapterError {
|
|
99
|
-
|
|
100
|
-
|
|
184
|
+
static {
|
|
185
|
+
this.prototype.name = 'EntityDatabaseAdapterExcessiveUpdateResultError';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
get state(): EntityErrorState.PERMANENT {
|
|
189
|
+
return EntityErrorState.PERMANENT;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCESSIVE_UPDATE_RESULT {
|
|
193
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCESSIVE_UPDATE_RESULT;
|
|
194
|
+
}
|
|
101
195
|
}
|
|
102
196
|
|
|
103
197
|
/**
|
|
@@ -106,8 +200,17 @@ export class EntityDatabaseAdapterExcessiveUpdateResultError extends EntityDatab
|
|
|
106
200
|
* was deleted by a different process between fetching and updating it in this process.
|
|
107
201
|
*/
|
|
108
202
|
export class EntityDatabaseAdapterEmptyUpdateResultError extends EntityDatabaseAdapterError {
|
|
109
|
-
|
|
110
|
-
|
|
203
|
+
static {
|
|
204
|
+
this.prototype.name = 'EntityDatabaseAdapterEmptyUpdateResultError';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
get state(): EntityErrorState.PERMANENT {
|
|
208
|
+
return EntityErrorState.PERMANENT;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EMPTY_UPDATE_RESULT {
|
|
212
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EMPTY_UPDATE_RESULT;
|
|
213
|
+
}
|
|
111
214
|
}
|
|
112
215
|
|
|
113
216
|
/**
|
|
@@ -116,6 +219,15 @@ export class EntityDatabaseAdapterEmptyUpdateResultError extends EntityDatabaseA
|
|
|
116
219
|
* primary key column.
|
|
117
220
|
*/
|
|
118
221
|
export class EntityDatabaseAdapterExcessiveDeleteResultError extends EntityDatabaseAdapterError {
|
|
119
|
-
|
|
120
|
-
|
|
222
|
+
static {
|
|
223
|
+
this.prototype.name = 'EntityDatabaseAdapterExcessiveDeleteResultError';
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
get state(): EntityErrorState.PERMANENT {
|
|
227
|
+
return EntityErrorState.PERMANENT;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
get code(): EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCESSIVE_DELETE_RESULT {
|
|
231
|
+
return EntityErrorCode.ERR_ENTITY_DATABASE_ADAPTER_EXCESSIVE_DELETE_RESULT;
|
|
232
|
+
}
|
|
121
233
|
}
|