kinvey-flex-sdk
Advanced tools
Comparing version 4.0.1 to 4.1.0
## Changelog | ||
### 4.1.0 | ||
* Add login hooks properties | ||
### 3.5.0 | ||
@@ -4,0 +7,0 @@ * Update logged message on error from complete callback |
@@ -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.1", | ||
"version": "4.1.0", | ||
"description": "SDK for creating Kinvey Flex Services", | ||
@@ -21,3 +21,3 @@ "engines": { | ||
"bson": "4.3.0", | ||
"kinvey-code-task-runner": "2.4.0", | ||
"kinvey-code-task-runner": "2.5.0", | ||
"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) => { |
@@ -154,3 +154,3 @@ /** | ||
(requestContext.clientAppVersion.stringValue() === null).should.be.true(); | ||
done(); | ||
done(); | ||
}); | ||
@@ -157,0 +157,0 @@ it('should return null when metadata value is undefined', (done) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
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
688426
15890
11
+ Addedkinvey-code-task-runner@2.5.0(transitive)
- Removedkinvey-code-task-runner@2.4.0(transitive)