kinvey-flex-sdk
Advanced tools
Comparing version 4.0.0 to 4.0.1-rc1
@@ -44,13 +44,16 @@ /** | ||
const context = {}; | ||
for (const key of ['method', 'username', 'userId', 'entityId', 'loginOptions']) { | ||
if (task.request[key] != null) { | ||
context[key] = task.request[key]; | ||
} | ||
} | ||
const currentContext = task.hookType === 'post' ? task.response : task.request; | ||
context.method = task.request.method; | ||
context.headers = currentContext.headers; | ||
context.username = task.request.username; | ||
context.userId = task.request.userId; | ||
context.objectName = task.request.objectName || task.request.collectionName; | ||
context.hookType = task.hookType; | ||
if (task.request.entityId) { | ||
context.entityId = task.request.entityId; | ||
if (currentContext.status > 399) { | ||
context.status = currentContext.status; | ||
} | ||
@@ -57,0 +60,0 @@ |
{ | ||
"name": "kinvey-flex-sdk", | ||
"version": "4.0.0", | ||
"version": "4.0.1-rc1", | ||
"description": "SDK for creating Kinvey Flex Services", | ||
@@ -21,3 +21,3 @@ "engines": { | ||
"bson": "0.4.23", | ||
"kinvey-code-task-runner": "2.4.0", | ||
"kinvey-code-task-runner": "2.4.1-rc1", | ||
"kinvey-datalink-errors": "0.3.2", | ||
@@ -29,2 +29,3 @@ "moment": "2.22.2", | ||
"devDependencies": { | ||
"@progresskinvey/eslint-config-kinvey-platform": "0.2.1", | ||
"eslint": "5.9.0", | ||
@@ -31,0 +32,0 @@ "eslint-config-kinvey-platform": "kinvey/eslint-kinvey-platform#0.1.3", |
@@ -214,3 +214,86 @@ /** | ||
}); | ||
it('context includes loginOptions if passed', (done) => { | ||
const taskName = quickRandom(); | ||
const task = sampleTask(taskName); | ||
task.request.loginOptions = { type: 'kinvey' }; | ||
functions.register(taskName, (context, complete, modules) => { | ||
context.should.be.an.Object(); | ||
complete.should.be.a.Function(); | ||
modules.should.be.an.Object(); | ||
context.loginOptions.should.eql({ type: 'kinvey' }); | ||
return done(); | ||
}); | ||
functions.process(task, {}, () => {}); | ||
}); | ||
it('context does not includes loginOptions if not passed', (done) => { | ||
const taskName = quickRandom(); | ||
const task = sampleTask(taskName); | ||
functions.register(taskName, (context, complete, modules) => { | ||
context.should.be.an.Object(); | ||
complete.should.be.a.Function(); | ||
modules.should.be.an.Object(); | ||
should.not.exist(context.loginOptions); | ||
return done(); | ||
}); | ||
functions.process(task, {}, () => {}); | ||
}); | ||
it('context includes status of response.status is >399 and hookType is "post"', (done) => { | ||
const taskName = quickRandom(); | ||
const task = sampleTask(taskName); | ||
task.hookType = 'post'; | ||
task.response.status = 401; | ||
functions.register(taskName, (context, complete, modules) => { | ||
context.should.be.an.Object(); | ||
complete.should.be.a.Function(); | ||
modules.should.be.an.Object(); | ||
context.status.should.eql(401); | ||
return done(); | ||
}); | ||
functions.process(task, {}, () => {}); | ||
}); | ||
it('context does not include status of response.status is <399', (done) => { | ||
const taskName = quickRandom(); | ||
const task = sampleTask(taskName); | ||
task.hookType = 'post'; | ||
task.response.status = 200; | ||
functions.register(taskName, (context, complete, modules) => { | ||
context.should.be.an.Object(); | ||
complete.should.be.a.Function(); | ||
modules.should.be.an.Object(); | ||
should.not.exist(context.status); | ||
return done(); | ||
}); | ||
functions.process(task, {}, () => {}); | ||
}); | ||
it('context does not include status of hookType is "pre"', (done) => { | ||
const taskName = quickRandom(); | ||
const task = sampleTask(taskName); | ||
task.hookType = 'pre'; | ||
task.response.status = 401; | ||
functions.register(taskName, (context, complete, modules) => { | ||
context.should.be.an.Object(); | ||
complete.should.be.a.Function(); | ||
modules.should.be.an.Object(); | ||
should.not.exist(context.status); | ||
return done(); | ||
}); | ||
functions.process(task, {}, () => {}); | ||
}); | ||
}); | ||
describe('completion handlers', () => { | ||
@@ -217,0 +300,0 @@ afterEach((done) => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
694942
15890
11
2
3
+ Addedkinvey-code-task-runner@2.4.1-rc1(transitive)
- Removedkinvey-code-task-runner@2.4.0(transitive)