forked from parse-community/parse-server
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for parse-community#1840, Strip operations from results, forwards…
… delete operations to SDKs (parse-community#1946) * Adding a test demonstrating issue parse-community#1840. * Fixes parse-community#1840 * Adds failing test with other use case - That test fails on parse.com as well * Bumps parse to 1.9.0 * exclude pg db * Exclude pg on other test * Adds clientSDK compatibility check for forward deletion - Mark js1.9.0 as compatible * Strips all operations from result - fix for parse-community#1606
- Loading branch information
1 parent
517b203
commit 7eb83dc
Showing
7 changed files
with
216 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var ClientSDK = require('../src/ClientSDK'); | ||
|
||
describe('ClientSDK', () => { | ||
it('should properly parse the SDK versions', () => { | ||
let clientSDKFromVersion = ClientSDK.fromString; | ||
expect(clientSDKFromVersion('i1.1.1')).toEqual({ | ||
sdk: 'i', | ||
version: '1.1.1' | ||
}); | ||
expect(clientSDKFromVersion('i1')).toEqual({ | ||
sdk: 'i', | ||
version: '1' | ||
}); | ||
expect(clientSDKFromVersion('apple-tv1.13.0')).toEqual({ | ||
sdk: 'apple-tv', | ||
version: '1.13.0' | ||
}); | ||
expect(clientSDKFromVersion('js1.9.0')).toEqual({ | ||
sdk: 'js', | ||
version: '1.9.0' | ||
}); | ||
}); | ||
|
||
it('should properly sastisfy', () => { | ||
expect(ClientSDK.compatible({ | ||
js: '>=1.9.0' | ||
})("js1.9.0")).toBe(true); | ||
|
||
expect(ClientSDK.compatible({ | ||
js: '>=1.9.0' | ||
})("js2.0.0")).toBe(true); | ||
|
||
expect(ClientSDK.compatible({ | ||
js: '>=1.9.0' | ||
})("js1.8.0")).toBe(false); | ||
|
||
expect(ClientSDK.compatible({ | ||
js: '>=1.9.0' | ||
})(undefined)).toBe(true); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var semver = require('semver'); | ||
|
||
function compatible(compatibleSDK) { | ||
return function(clientSDK) { | ||
if (typeof clientSDK === 'string') { | ||
clientSDK = fromString(clientSDK); | ||
} | ||
// REST API, or custom SDK | ||
if (!clientSDK) { | ||
return true; | ||
} | ||
let clientVersion = clientSDK.version; | ||
let compatiblityVersion = compatibleSDK[clientSDK.sdk]; | ||
return semver.satisfies(clientVersion, compatiblityVersion); | ||
} | ||
} | ||
|
||
function supportsForwardDelete(clientSDK) { | ||
return compatible({ | ||
js: '>=1.9.0' | ||
})(clientSDK); | ||
} | ||
|
||
function fromString(version) { | ||
let versionRE = /([-a-zA-Z]+)([0-9\.]+)/; | ||
let match = version.toLowerCase().match(versionRE); | ||
if (match && match.length === 3) { | ||
return { | ||
sdk: match[1], | ||
version: match[2] | ||
} | ||
} | ||
return undefined; | ||
} | ||
|
||
module.exports = { | ||
compatible, | ||
supportsForwardDelete, | ||
fromString | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters