Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RND-623] initial matchup to MetaEd api-schema plugin #300

Merged
merged 37 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8563ce6
[RND-623] initial matchup to MetaEd api-schema plugin
bradbanister Aug 29, 2023
154d3d8
[RND-623] implement new identity and reference extraction
bradbanister Sep 25, 2023
5ae9a2f
[RND-623] ready for test updates
bradbanister Sep 27, 2023
acc8db7
[RND-623] more tests working
bradbanister Sep 28, 2023
3b12a18
[RND-623] more test fixes
bradbanister Sep 29, 2023
fc23e27
[RND-623] back on track
bradbanister Oct 5, 2023
cf482e5
[RND-623] need to transform arrays of references - split and merge cr…
bradbanister Oct 11, 2023
613e3fd
[RND-623] fix reference collection issue
bradbanister Oct 11, 2023
e4f3722
more tests
bradbanister Oct 13, 2023
86c1c32
lockfile update
bradbanister Oct 13, 2023
e650075
update metaed
bradbanister Oct 13, 2023
393e134
[RND-623] update identity extraction, revert prettier upgrade - jest …
bradbanister Oct 16, 2023
6d27ad7
split out api schema loading
bradbanister Oct 17, 2023
969cecb
[RND-623] test fixup
bradbanister Oct 18, 2023
9372f40
[RND-623] updated apischema
bradbanister Oct 22, 2023
6bb6b4a
sync
bradbanister Oct 22, 2023
ef52527
[RND-623] fix test
bradbanister Oct 23, 2023
3f3c2c5
more test fixup
bradbanister Oct 23, 2023
dee7df7
unit tests passing
bradbanister Oct 23, 2023
73c049b
[RND-623] mongo test updates
bradbanister Oct 25, 2023
5b0d654
[RND-623] fix postgres integration
bradbanister Oct 25, 2023
176e9e2
update ds
bradbanister Oct 27, 2023
010d3e2
fastify debug config
bradbanister Oct 27, 2023
8dd5b00
[RND-623] ignore optional descriptor references that aren't there
bradbanister Oct 28, 2023
7f77375
simplify identity structure
bradbanister Oct 28, 2023
f91751f
[RND-623] update api schema
bradbanister Oct 30, 2023
a621571
[RND-623] fix superclass info extractor bug
bradbanister Oct 30, 2023
46e8d36
[RND-623] use abstract resource info
bradbanister Nov 1, 2023
fe2104b
[RND-623] Update DS
bradbanister Nov 1, 2023
b024216
setup for merge with RND-651
bradbanister Nov 1, 2023
19018f5
[RND-623] with abstract resource info, with overposting disabled
bradbanister Nov 1, 2023
04884e1
update api schema
bradbanister Nov 1, 2023
ce4f21c
test fixup
bradbanister Nov 2, 2023
32785eb
remove one e2e, skip other
bradbanister Nov 3, 2023
ca07400
remove test credentials
bradbanister Nov 3, 2023
4a3cd53
lint fixup
bradbanister Nov 6, 2023
b942c70
fixup commented out tests
bradbanister Nov 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Meadowlark-js/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ MONGODB_MAX_NUMBER_OF_RETRIES=1
#### Environment variables for security
OWN_OAUTH_CLIENT_ID_FOR_CLIENT_AUTH=meadowlark_verify-only_key_1
OWN_OAUTH_CLIENT_SECRET_FOR_CLIENT_AUTH=meadowlark_verify-only_secret_1
## URLs may need to be 127.0.0.1 instead of localhost depending on Node version
OAUTH_SERVER_ENDPOINT_FOR_OWN_TOKEN_REQUEST=http://localhost:3000/local/oauth/token
OAUTH_SERVER_ENDPOINT_FOR_TOKEN_VERIFICATION=http://localhost:3000/local/oauth/verify

LOG_PRETTY_PRINT=true


Expand Down
17 changes: 16 additions & 1 deletion Meadowlark-js/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "node",
"request": "launch",
"runtimeArgs": ["--inspect", "--debug-port=9229"],
"env": {"FASTIFY_NUM_THREADS": "1", "OAUTH_HARD_CODED_CREDENTIALS_ENABLED": "true"},
"env": {"FASTIFY_NUM_THREADS": "1", "FASTIFY_PORT": "3000", "OAUTH_HARD_CODED_CREDENTIALS_ENABLED": "true" },
"program": "${workspaceFolder}/services/meadowlark-fastify/dist/index.js",
"port": 9229,
"console": "integratedTerminal",
Expand All @@ -27,6 +27,21 @@
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"name": "Jest :: File Linux e2e",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"${relativeFile}",
],
"env": {"FASTIFY_PORT": "3000" },
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"type": "node",
"request": "launch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ import {
AuthorizationStrategy,
TraceId,
ResourceInfo,
MetaEdProjectName,
MetaEdResourceName,
SemVer,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More branded strings to avoid getting them confused

} from '@edfi/meadowlark-core';
import { queryDocuments, indexFromResourceInfo } from '../src/repository/QueryElasticsearch';

const mock = new Mock();

const resourceInfo: ResourceInfo = {
projectName: 'ed-fi',
resourceName: 'student',
projectName: 'ed-fi' as MetaEdProjectName,
resourceName: 'student' as MetaEdResourceName,
isDescriptor: false,
resourceVersion: '3.3.1-b',
resourceVersion: '3.3.1-b' as SemVer,
allowIdentityUpdates: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ import {
AuthorizationStrategy,
DeleteRequest,
DeleteResult,
generateDocumentUuid,
DocumentUuid,
MeadowlarkId,
TraceId,
MetaEdProjectName,
MetaEdResourceName,
SemVer,
} from '@edfi/meadowlark-core';
import { DocumentUuid, MeadowlarkId, TraceId } from '@edfi/meadowlark-core/src/model/IdTypes';
import { generateDocumentUuid } from '@edfi/meadowlark-core/src/model/DocumentIdentity';
import { Client } from '@elastic/elasticsearch';
import { queryDocuments } from '../../src/repository/QueryElasticsearch';
import { afterDeleteDocumentById, afterUpsertDocument } from '../../src/repository/UpdateElasticsearch';
Expand All @@ -25,10 +30,10 @@ import { getNewTestClient } from '../setup/ElasticSearchSetupEnvironment';
jest.setTimeout(120_000);

const resourceInfo: ResourceInfo = {
projectName: 'ed-fi',
resourceName: 'student',
projectName: 'ed-fi' as MetaEdProjectName,
resourceName: 'student' as MetaEdResourceName,
isDescriptor: false,
resourceVersion: '3.3.1-b',
resourceVersion: '3.3.1-b' as SemVer,
allowIdentityUpdates: false,
};

Expand Down Expand Up @@ -130,7 +135,7 @@ describe('When querying for documents', () => {
describe('when querying with wrong resource info', () => {
it('should return invalid query', async () => {
const invalidResourceInfo = { ...resourceInfo };
invalidResourceInfo.projectName = 'wrong-project';
invalidResourceInfo.projectName = 'wrong-project' as MetaEdProjectName;
const result = await queryDocuments(setupQueryRequest({}, {}, invalidResourceInfo), client);

expect(result.response).toEqual('QUERY_FAILURE_INDEX_NOT_FOUND');
Expand Down Expand Up @@ -237,10 +242,10 @@ describe('When querying for documents', () => {

describe('when querying for descriptor', () => {
const descriptorResourceInfo: ResourceInfo = {
projectName: 'ed-fi',
resourceName: 'countryDescriptor',
projectName: 'ed-fi' as MetaEdProjectName,
resourceName: 'countryDescriptor' as MetaEdResourceName,
isDescriptor: true,
resourceVersion: '3.3.1-b',
resourceVersion: '3.3.1-b' as SemVer,
allowIdentityUpdates: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import {
DeleteResult,
DocumentUuid,
MeadowlarkId,
MetaEdProjectName,
MetaEdResourceName,
newSecurity,
NoDocumentInfo,
PaginationParameters,
QueryRequest,
ResourceInfo,
SemVer,
TraceId,
UpdateRequest,
UpdateResult,
Expand All @@ -31,10 +34,10 @@ import { getNewTestClient } from '../setup/ElasticSearchSetupEnvironment';
jest.setTimeout(120_000);

const resourceInfo: ResourceInfo = {
projectName: 'ed-fi',
resourceName: 'student',
projectName: 'ed-fi' as MetaEdProjectName,
resourceName: 'student' as MetaEdResourceName,
isDescriptor: false,
resourceVersion: '3.3.1-b',
resourceVersion: '3.3.1-b' as SemVer,
allowIdentityUpdates: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
MeadowlarkId,
ResourceInfo,
DocumentUuid,
MetaEdProjectName,
MetaEdResourceName,
SemVer,
} from '@edfi/meadowlark-core';

export interface MeadowlarkDocumentId {
Expand All @@ -36,19 +39,19 @@ export interface MeadowlarkDocument extends MeadowlarkDocumentId {
/**
* The MetaEd project name the API document resource is defined in e.g. "EdFi" for a data standard entity.
*/
projectName: string;
projectName: MetaEdProjectName;

/**
* The name of the resource. Typically, this is the same as the corresponding MetaEd entity name. However,
* there are exceptions, for example descriptors have a "Descriptor" suffix on their resource name.
*/
resourceName: string;
resourceName: MetaEdResourceName;

/**
* The resource version as a string. This is the same as the MetaEd project version
* the entity is defined in e.g. "3.3.1-b" for a 3.3b data standard entity.
*/
resourceVersion: string;
resourceVersion: SemVer;

/**
* The Ed-Fi ODS/API document itself.
Expand Down Expand Up @@ -96,12 +99,12 @@ export interface MeadowlarkDocument extends MeadowlarkDocumentId {
createdBy: string;

/*
* Creation date as as Unix timestamp, or null if this is a document to be updated and we don't know the create time yet
* Creation date as a Unix timestamp, or null if this is a document to be updated and we don't know the create time yet
*/
createdAt: number | null;

/*
* Last modified date as as Unix timestamp.
* Last modified date as a Unix timestamp.
*/
lastModifiedAt: number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export const setupConfigForIntegration = async () => {
return;
}

const path = join(process.cwd(), '.env');
// First look for .env file paired with this Config.ts file
let path = join(__dirname, '.env');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow for different .envs in each backend rather than force one big .env at root

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this


if (!existsSync(path)) {
path = join(process.cwd(), '.env');
}

if (!existsSync(path)) {
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
MeadowlarkId,
TraceId,
UpsertResult,
MetaEdResourceName,
MetaEdProjectName,
} from '@edfi/meadowlark-core';
import { Collection, MongoClient } from 'mongodb';
import { MeadowlarkDocument } from '../../src/model/MeadowlarkDocument';
Expand Down Expand Up @@ -53,7 +55,7 @@ describe('given the delete of a non-existent document', () => {

const resourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'School',
resourceName: 'School' as MetaEdResourceName,
};

beforeAll(async () => {
Expand Down Expand Up @@ -84,11 +86,11 @@ describe('given the delete of an existing document', () => {

const resourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'School',
resourceName: 'School' as MetaEdResourceName,
};
const documentInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete2' },
documentIdentity: [{ natural: 'delete2' }],
};

beforeAll(async () => {
Expand Down Expand Up @@ -135,12 +137,12 @@ describe('given the delete of a document referenced by an existing document with

const referencedResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'School',
resourceName: 'School' as MetaEdResourceName,
};

const referencedDocumentInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete5' },
documentIdentity: [{ natural: 'delete5' }],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document identity structure changed to enforce ordering

};
const referencedMeadowlarkId = meadowlarkIdForDocumentIdentity(
referencedResourceInfo,
Expand All @@ -156,11 +158,11 @@ describe('given the delete of a document referenced by an existing document with

const documentWithReferencesResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'AcademicWeek',
resourceName: 'AcademicWeek' as MetaEdResourceName,
};
const documentWithReferencesInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete6' },
documentIdentity: [{ natural: 'delete6' }],
documentReferences: [validReference],
};
const documentWithReferencesMeadowlarkId = meadowlarkIdForDocumentIdentity(
Expand Down Expand Up @@ -218,7 +220,7 @@ describe('given the delete of a document referenced by an existing document with
it('should still have the referenced document in the db', async () => {
const collection: Collection<MeadowlarkDocument> = getDocumentCollection(client);
const result: any = await collection.findOne({ _id: referencedMeadowlarkId });
expect(result.documentIdentity.natural).toBe('delete5');
expect(result.documentIdentity[0].natural).toBe('delete5');
});
});

Expand All @@ -229,12 +231,12 @@ describe('given an delete of a document with an outbound reference only, with va

const referencedResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'AcademicWeek',
resourceName: 'AcademicWeek' as MetaEdResourceName,
};

const referencedDocumentInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete15' },
documentIdentity: [{ natural: 'delete15' }],
};
const referencedMeadowlarkId = meadowlarkIdForDocumentIdentity(
referencedResourceInfo,
Expand All @@ -250,11 +252,11 @@ describe('given an delete of a document with an outbound reference only, with va

const documentWithReferencesResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'School',
resourceName: 'School' as MetaEdResourceName,
};
const documentWithReferencesInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete16' },
documentIdentity: [{ natural: 'delete16' }],
documentReferences: [validReference],
};
const documentWithReferencesMeadowlarkId = meadowlarkIdForDocumentIdentity(
Expand Down Expand Up @@ -323,11 +325,11 @@ describe('given the delete of a document referenced by an existing document with

const referencedResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'School',
resourceName: 'School' as MetaEdResourceName,
};
const referencedDocumentInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete5' },
documentIdentity: [{ natural: 'delete5' }],
};
const referencedMeadowlarkId = meadowlarkIdForDocumentIdentity(
referencedResourceInfo,
Expand All @@ -343,11 +345,11 @@ describe('given the delete of a document referenced by an existing document with

const documentWithReferencesResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'AcademicWeek',
resourceName: 'AcademicWeek' as MetaEdResourceName,
};
const documentWithReferencesInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { natural: 'delete6' },
documentIdentity: [{ natural: 'delete6' }],
documentReferences: [validReference],
};
const documentWithReferencesMeadowlarkId = meadowlarkIdForDocumentIdentity(
Expand Down Expand Up @@ -416,20 +418,20 @@ describe('given the delete of a subclass document referenced by an existing docu

const referencedResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'School',
projectName: 'Ed-Fi',
resourceName: 'School' as MetaEdResourceName,
projectName: 'Ed-Fi' as MetaEdProjectName,
};

const superclassInfo: SuperclassInfo = {
...newSuperclassInfo(),
documentIdentity: { educationOrganizationId: '123' },
resourceName: 'EducationOrganization',
projectName: 'Ed-Fi',
documentIdentity: [{ educationOrganizationId: '123' }],
resourceName: 'EducationOrganization' as MetaEdResourceName,
projectName: 'Ed-Fi' as MetaEdProjectName,
};

const referencedDocumentInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { schoolId: '123' },
documentIdentity: [{ schoolId: '123' }],
superclassInfo,
};
const referencedMeadowlarkId = meadowlarkIdForDocumentIdentity(
Expand All @@ -446,11 +448,11 @@ describe('given the delete of a subclass document referenced by an existing docu

const documentWithReferenceResourceInfo: ResourceInfo = {
...newResourceInfo(),
resourceName: 'AcademicWeek',
resourceName: 'AcademicWeek' as MetaEdResourceName,
};
const documentWithReferenceDocumentInfo: DocumentInfo = {
...newDocumentInfo(),
documentIdentity: { week: 'delete6' },
documentIdentity: [{ week: 'delete6' }],
documentReferences: [referenceAsSuperclass],
};
const documentWithReferencesMeadowlarkId = meadowlarkIdForDocumentIdentity(
Expand Down Expand Up @@ -508,6 +510,6 @@ describe('given the delete of a subclass document referenced by an existing docu
it('should still have the referenced document in the db', async () => {
const collection: Collection<MeadowlarkDocument> = getDocumentCollection(client);
const result: any = await collection.findOne({ _id: referencedMeadowlarkId });
expect(result.documentIdentity.schoolId).toBe('123');
expect(result.documentIdentity[0].schoolId).toBe('123');
});
});
Loading
Loading