Skip to content

Commit

Permalink
Merge pull request Medable#422 from Medable/release/1.0.68
Browse files Browse the repository at this point in the history
Release/1.0.68
  • Loading branch information
davideaquaro authored Dec 13, 2022
2 parents 4b11d69 + 081a806 commit aa5029d
Show file tree
Hide file tree
Showing 64 changed files with 9,209 additions and 2,550 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "1.0.67",
"version": "1.0.68",
"npmClient": "npm",
"npmClientArgs": [
"--production",
Expand Down
3 changes: 1 addition & 2 deletions packages/mdctl-api-driver/lib/cursor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-param-reassign, max-len, no-restricted-syntax */
const { Transform } = require('stream'),
pump = require('pump'),
streamToIterator = require('stream-to-iterator'),
_ = require('lodash'),
{ privatesAccessor } = require('@medable/mdctl-core-utils/privates'),
{
Expand Down Expand Up @@ -36,7 +35,7 @@ class BaseCursor extends Transform {
}

get iterator() {
return streamToIterator(this)
return this
}

stream(options) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mdctl-api-driver/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions packages/mdctl-api-driver/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@medable/mdctl-api-driver",
"version": "1.0.67",
"version": "1.0.68",
"description": "Medable Developer Client Tools :: Api DB Driver",
"repository": {
"type": "git",
Expand All @@ -25,15 +25,14 @@
"lint": "eslint *.js"
},
"dependencies": {
"@medable/mdctl-api": "^1.0.67",
"@medable/mdctl-core": "^1.0.67",
"@medable/mdctl-core-utils": "^1.0.67",
"@medable/mdctl-api": "^1.0.68",
"@medable/mdctl-core": "^1.0.68",
"@medable/mdctl-core-utils": "^1.0.68",
"async-iter-stream": "^1.2.0",
"inflection": "^1.12.0",
"lodash": "^4.17.21",
"ndjson": "^1.5.0",
"pump": "^3.0.0",
"stream-to-iterator": "^3.0.2-0"
"pump": "^3.0.0"
},
"devDependencies": {
"chai": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/mdctl-api-ws/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/mdctl-api-ws/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@medable/mdctl-api-ws",
"version": "1.0.67",
"version": "1.0.68",
"description": "Medable Developer Client Tools :: Websocket Client",
"repository": {
"type": "git",
Expand All @@ -25,9 +25,9 @@
"author": "Medable, Inc. <[email protected]>",
"license": "MIT",
"dependencies": {
"@medable/mdctl-core": "^1.0.67",
"@medable/mdctl-core-utils": "^1.0.67",
"@medable/mdctl-secrets": "^1.0.67",
"@medable/mdctl-core": "^1.0.68",
"@medable/mdctl-core-utils": "^1.0.68",
"@medable/mdctl-secrets": "^1.0.68",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"primus": "^7.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/mdctl-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/mdctl-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@medable/mdctl-api",
"version": "1.0.67",
"version": "1.0.68",
"description": "Medable Developer Client Tools :: API",
"repository": {
"type": "git",
Expand All @@ -25,8 +25,8 @@
"author": "Medable, Inc. <[email protected]>",
"license": "MIT",
"dependencies": {
"@medable/mdctl-core": "^1.0.67",
"@medable/mdctl-core-utils": "^1.0.67",
"@medable/mdctl-core": "^1.0.68",
"@medable/mdctl-core-utils": "^1.0.68",
"axios": "^0.21.1",
"axios-cookiejar-support": "^0.5.0",
"clone": "^2.1.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/mdctl-axon-tools/__tests__/MIG-11/MIG-11.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ describe('ingestTransform', () => {
global.org = defaultGlobals
})

const docErr = { code: 'kInvalidArgument', errCode: 'cortex.invalidArgument.updateDisabled', reason: 'An eConsent template in this import exists in the target and is not in draft', message: 'Document Key 2222, Document title "title"' }
const docErr = { code: 'kInvalidArgument', errCode: 'cortex.invalidArgument.updateDisabled', reason: 'An eConsent template in this import exists in the target and is not in draft', message: 'Template [title] ([2222]) already exists in the target org and is not in DRAFT status, re-migration is not allowed' }
it.each([
// test, resource, memo, expected
['Draft consents should be imported ', { object: 'ec__document_template', ec__status: 'draft', ec__key: '1111' }, { manifest: {} }, { object: 'ec__document_template', ec__status: 'draft', ec__sites: [], ec__key: '1111' }],
['Published docs not existing in target should be imported', { object: 'ec__document_template', ec__status: 'published', ec__key: '3333', ec__title: 'title' }, { manifest: {} }, { object: 'ec__document_template', ec__status: 'published', ec__sites: [], ec__key: '3333', ec__title: 'title' }],
['Published docs not existing in target should be imported', { object: 'ec__document_template', ec__status: 'published', ec__key: '3333', ec__title: 'title' }, { manifest: {} }, { object: 'ec__document_template', ec__status: 'draft', ec__sites: [], ec__key: '3333', ec__title: 'title' }],
['Published docs existing should throw an error', { object: 'ec__document_template', ec__status: 'draft', ec__key: '2222', ec__title: 'title' }, { manifest: {} }, docErr],
['Published docs no existing should be imported as draft', { object: 'ec__document_template', ec__status: 'published', ec__key: '4444', ec__title: 'title - 2' }, { manifest: {} }, { object: 'ec__document_template', ec__status: 'draft', ec__sites: [], ec__key: '4444', ec__title: 'title - 2' }],
])('%s', (test, resource, memo, expected) => {

let transformedResource
Expand Down
138 changes: 138 additions & 0 deletions packages/mdctl-axon-tools/__tests__/MIG-136/MIG-136.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
const { pick } = require('lodash'),
StudyManifestTools = require('../../lib/StudyManifestTools'),
existingStudy = [{
_id: '1',
c_name: 'Study',
c_key: 'abc'
}],
existingTasks = [{
_id: '1',
c_name: 'Task 1',
c_study: '1',
c_key: '123-456-789'
},
{
_id: '2',
c_name: 'Task 2',
c_study: '1',
ec__key: '234-567-890'
},
{
_id: '3',
c_name: 'Task 3',
c_study: '2',
ec__key: '345-678-901'
}],
existingConsent = [{
_id: '1',
ec__status: 'draft',
ec__title: 'title',
ec__identifier: 'Test Template 1',
ec__study: '2',
ec__key: '456-789-012'
},
{
_id: '2',
ec__status: 'draft',
ec__title: 'title',
ec__identifier: 'Test Template 2',
ec__study: '1',
ec__key: '567-890-123'
}],

org = {
objects: {
c_study: {
find: () => ({
paths: () => ({
toArray: () => existingStudy
})
})
},
c_tasks: {
find: study => ({
limit: () => ({
paths: (...props) => ({
toArray: () => {
const result = existingTasks.filter(t => t.c_study === study.c_study),
res = result ? result.map(item => Object.assign(
...props.map(prop => ({ [prop]: item[prop] }))
)) : []
return res
}
})
})
})
},
ec__document_templates: {
find: study => ({
limit: () => ({
paths: (...props) => ({
toArray: () => {
const result = existingConsent.filter(e => e.ec__study === study.ec__study),
res = result ? result.map(item => Object.assign(
...props.map(prop => ({ [prop]: item[prop] }))
)) : []
return res
}
})
})
})
}
}
}

describe('MIG-136 - Orphan records', () => {

beforeEach(() => {
jest.spyOn(StudyManifestTools.prototype, 'getOrg').mockImplementation(() => org)
})

afterEach(() => {
jest.clearAllMocks()
})

it('Should returns only existing study Assignments', async() => {
const studyManifestTools = new StudyManifestTools(),
tasks = await studyManifestTools.getTasks(),
// eslint-disable-next-line no-underscore-dangle
test = existingTasks.filter(t => t.c_study === existingStudy[0]._id)
.map(t => pick(t, ['c_name']))

expect(tasks).toStrictEqual(test)
})

it('Should returns no Assignments if study does not exists', async() => {
// Overwrite function to return an empty array
org.objects.c_study.find = () => ({ paths: () => ({ toArray: () => [] }) })
const studyManifestTools = new StudyManifestTools(),
tasks = await studyManifestTools.getTasks()

expect(tasks).toStrictEqual([])

// Restoring function to its previous value
org.objects.c_study.find = () => ({ paths: () => ({ toArray: () => existingStudy }) })
})

it('Should returns only existing study eTemplates', async() => {
const studyManifestTools = new StudyManifestTools(),
templates = await studyManifestTools.getConsentTemplates(),
test = pick(existingConsent[1], ['ec__identifier', 'ec__title'])

expect(templates[0]).toStrictEqual(test)

})

it('Should returns no eTemplates if study does not exists', async() => {
// Overwrite function to return an empty array
org.objects.c_study.find = () => ({ paths: () => ({ toArray: () => [] }) })
const studyManifestTools = new StudyManifestTools(),
templates = await studyManifestTools.getConsentTemplates()

expect(templates).toStrictEqual([])

// Restoring function to its previous value
org.objects.c_study.find = () => ({ paths: () => ({ toArray: () => existingStudy }) })
})

})
Loading

0 comments on commit aa5029d

Please sign in to comment.