Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 0d4f7d6

Browse files
[RND-84] validate equality constraints (#279)
* [RND-84] validate equality constraints * [RND-84] e2e tests * [RND-86] all tests in * [RND-84] PR suggestions --------- Co-authored-by: Stephen Fuqua <[email protected]>
1 parent 1531348 commit 0d4f7d6

25 files changed

+903
-84
lines changed

Meadowlark-js/backends/meadowlark-elasticsearch-backend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"dependencies": {
2222
"@edfi/meadowlark-core": "^v0.3.6-pre-36",
2323
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
24-
"@edfi/metaed-core": "^4.1.2-dev.20",
2524
"@elastic/elasticsearch": "^8.8.1",
2625
"@elastic/transport": "^8.3.2"
2726
},

Meadowlark-js/backends/meadowlark-elasticsearch-backend/src/repository/QueryElasticsearch.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { Client } from '@elastic/elasticsearch';
77
import { QueryRequest, QueryResult, ResourceInfo } from '@edfi/meadowlark-core';
88
import { isDebugEnabled, Logger } from '@edfi/meadowlark-utilities';
9-
import { normalizeDescriptorSuffix } from '@edfi/metaed-core';
109
import { handleElasticSearchError } from './ElasticSearchException';
1110

1211
const moduleName = 'elasticsearch.repository.QueryElasticsearch';
@@ -15,11 +14,7 @@ const moduleName = 'elasticsearch.repository.QueryElasticsearch';
1514
* Returns ElasticSearch index name from the given ResourceInfo.
1615
*/
1716
export function indexFromResourceInfo(resourceInfo: ResourceInfo): string {
18-
const adjustedResourceName = resourceInfo.isDescriptor
19-
? normalizeDescriptorSuffix(resourceInfo.resourceName)
20-
: resourceInfo.resourceName;
21-
22-
return `${resourceInfo.projectName}$${resourceInfo.resourceVersion}$${adjustedResourceName}`
17+
return `${resourceInfo.projectName}$${resourceInfo.resourceVersion}$${resourceInfo.resourceName}`
2318
.toLowerCase()
2419
.replace(/\./g, '-');
2520
}

Meadowlark-js/backends/meadowlark-opensearch-backend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"dependencies": {
2222
"@edfi/meadowlark-core": "^v0.3.6-pre-36",
2323
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
24-
"@edfi/metaed-core": "^4.1.2-dev.20",
2524
"@opensearch-project/opensearch": "^2.2.1"
2625
},
2726
"devDependencies": {

Meadowlark-js/backends/meadowlark-opensearch-backend/src/repository/QueryOpensearch.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { Client } from '@opensearch-project/opensearch';
77
import { QueryRequest, QueryResult, ResourceInfo } from '@edfi/meadowlark-core';
88
import { isDebugEnabled, Logger } from '@edfi/meadowlark-utilities';
9-
import { normalizeDescriptorSuffix } from '@edfi/metaed-core';
109
import { handleOpenSearchError } from './OpenSearchException';
1110

1211
const moduleName = 'opensearch.repository.QueryOpensearch';
@@ -17,11 +16,7 @@ const moduleName = 'opensearch.repository.QueryOpensearch';
1716
* OpenSearch indexes are required to be lowercase only, with no pound signs or periods.
1817
*/
1918
export function indexFromResourceInfo(resourceInfo: ResourceInfo): string {
20-
const adjustedResourceName = resourceInfo.isDescriptor
21-
? normalizeDescriptorSuffix(resourceInfo.resourceName)
22-
: resourceInfo.resourceName;
23-
24-
return `${resourceInfo.projectName}$${resourceInfo.resourceVersion}$${adjustedResourceName}`
19+
return `${resourceInfo.projectName}$${resourceInfo.resourceVersion}$${resourceInfo.resourceName}`
2520
.toLowerCase()
2621
.replace(/\./g, '-');
2722
}

Meadowlark-js/package-lock.json

Lines changed: 24 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Meadowlark-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"scripts": {
4444
"build": "lerna run build --stream",
4545
"build:clean": "lerna run build:clean --stream",
46-
"test": "npm run test:lint && npm run test:unit && npm run test:integration && npm run test:e2e",
46+
"test": "npm run test:lint && npm run test:unit && npm run test:integration",
4747
"test:lint": "npm run test:lint:ts && npm run test:lint:eslint",
4848
"test:lint:eslint": "eslint --max-warnings 0 --ext .js,.ts .",
4949
"test:lint:ts": "tsc -p . --noEmit",

Meadowlark-js/packages/meadowlark-core/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"@edfi/ed-fi-model-3.1": "3.0.1",
1818
"@edfi/ed-fi-model-3.3b": "3.0.1",
1919
"@edfi/meadowlark-utilities": "^v0.3.6-pre-36",
20-
"@edfi/metaed-core": "^4.1.2-dev.20",
21-
"@edfi/metaed-plugin-edfi-api-schema": "^4.1.2-dev.20",
22-
"@edfi/metaed-plugin-edfi-unified": "^4.1.2-dev.20",
20+
"@edfi/metaed-core": "^4.2.2-dev.2",
21+
"@edfi/metaed-plugin-edfi-api-schema": "^4.2.2-dev.2",
22+
"@edfi/metaed-plugin-edfi-unified": "^4.2.2-dev.2",
2323
"@isaacs/ttlcache": "^1.4.1",
2424
"ajv": "^8.12.0",
2525
"ajv-formats": "^2.1.1",
@@ -31,6 +31,7 @@
3131
"fast-memoize": "^2.5.2",
3232
"fs-extra": "^10.1.0",
3333
"inquirer": "^9.1.5",
34+
"jsonpath-plus": "^7.2.0",
3435
"njwt": "^1.2.0",
3536
"ramda": "0.27.2",
3637
"secure-random": "^1.1.2",

Meadowlark-js/packages/meadowlark-core/src/extraction/DescriptorValueExtractor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { DocumentReference } from '../model/DocumentReference';
1515

1616
// TODO: The behavior of calculating the body names of descriptors for an entity can be pushed into a
17-
// new MetaEd enhancer, and entity.data.edfiApiSchema.apiMapping.descriptorCollectedProperties
17+
// new MetaEd enhancer, and entity.data.edfiApiSchema.apiMapping.descriptorCollectedApiProperties
1818
// can be replaced with an array structure with the resolved name, isCollection flag, metaEdType and metaEdName,
1919
// named something like entity.data.edfiApiSchema.apiMapping.descriptorPropertyBodyNames
2020

@@ -83,9 +83,9 @@ function extractDescriptorValuesFromBody(
8383
*/
8484
export function extractDescriptorValues(entity: TopLevelEntity, body: object): DocumentReference[] {
8585
const result: DocumentReference[] = [];
86-
const { descriptorCollectedProperties } = (entity.data.edfiApiSchema as EntityApiSchemaData).apiMapping;
86+
const { descriptorCollectedApiProperties } = (entity.data.edfiApiSchema as EntityApiSchemaData).apiMapping;
8787

88-
descriptorCollectedProperties.forEach((collectedProperty: CollectedProperty) => {
88+
descriptorCollectedApiProperties.forEach((collectedProperty: CollectedProperty) => {
8989
const topLevelName = topLevelApiNameOnEntity(entity, collectedProperty.property);
9090
result.push(...extractDescriptorValuesFromBody(collectedProperty, body, topLevelName));
9191
});

Meadowlark-js/packages/meadowlark-core/src/handler/FrontendFacade.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { documentInfoExtraction } from '../middleware/ExtractDocumentInfoMiddlew
2424
import { metaEdModelFinding } from '../middleware/FindMetaEdModelMiddleware';
2525
import { logRequestBody } from '../middleware/RequestLoggingMiddleware';
2626
import { logTheResponse } from '../middleware/ResponseLoggingMiddleware';
27+
import { equalityConstraintValidation } from '../middleware/ValidateEqualityConstraintMiddleware';
2728

2829
type MiddlewareStack = (model: MiddlewareModel) => Promise<MiddlewareModel>;
2930

@@ -48,6 +49,7 @@ function postStack(): MiddlewareStack {
4849
R.andThen(resourceValidation),
4950
R.andThen(metaEdModelFinding),
5051
R.andThen(documentValidation),
52+
R.andThen(equalityConstraintValidation),
5153
R.andThen(documentInfoExtraction),
5254
R.andThen(getDocumentStore().securityMiddleware),
5355
R.andThen(logTheResponse),
@@ -66,6 +68,7 @@ function putStack(): MiddlewareStack {
6668
R.andThen(resourceValidation),
6769
R.andThen(metaEdModelFinding),
6870
R.andThen(documentUpdateValidation),
71+
R.andThen(equalityConstraintValidation),
6972
R.andThen(documentInfoExtraction),
7073
R.andThen(getDocumentStore().securityMiddleware),
7174
R.andThen(logTheResponse),

Meadowlark-js/packages/meadowlark-core/src/metaed/MetaEdValidation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import didYouMean from 'didyoumean2';
1111
import memoize from 'fast-memoize';
1212
import { MetaEdEnvironment, TopLevelEntity, NoTopLevelEntity } from '@edfi/metaed-core';
1313
import { getBooleanFromEnvironment } from '@edfi/meadowlark-utilities';
14-
import { ResourceMatchResult } from '../model/ResourceMatchResult';
14+
import type { ResourceMatchResult } from '../model/ResourceMatchResult';
1515
import { getMetaEdModelForResourceName, getResourceNamesForProject } from './ResourceNameMapping';
16-
import { FrontendQueryParameters } from '../handler/FrontendRequest';
16+
import type { FrontendQueryParameters } from '../handler/FrontendRequest';
1717

1818
function getAjv(): Ajv {
1919
const coerceTypes = getBooleanFromEnvironment('ALLOW_TYPE_COERCION', false);

0 commit comments

Comments
 (0)