Skip to content

Commit 64baf1e

Browse files
fix: support for RequestParser in the latest admin-bro release
1 parent c63d420 commit 64baf1e

File tree

4 files changed

+48
-41
lines changed

4 files changed

+48
-41
lines changed

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,28 @@
2626
}
2727
},
2828
"devDependencies": {
29+
"@commitlint/cli": "^8.3.5",
30+
"@commitlint/config-conventional": "^8.3.4",
31+
"@semantic-release/git": "^9.0.0",
32+
"@types/mocha": "^7.0.2",
2933
"admin-bro": "^2.2.0",
3034
"chai": "^4.2.0",
3135
"eslint": "^5.10.0",
3236
"eslint-config-airbnb-base": "^13.1.0",
3337
"eslint-plugin-import": "^2.14.0",
3438
"factory-girl": "^5.0.4",
39+
"husky": "^4.2.5",
3540
"lodash": "^4.17.11",
3641
"mocha": "^5.2.0",
3742
"mongoose": "^5.3.15",
3843
"nyc": "^12.0.2",
3944
"pg": "^7.7.1",
45+
"semantic-release": "^17.0.7",
46+
"semantic-release-jira-releases-sb": "^0.7.2",
4047
"sequelize": "^4.42.0",
4148
"sequelize-cli": "^5.4.0",
4249
"sinon": "^7.1.1",
43-
"sinon-chai": "^3.3.0",
44-
"husky": "^4.2.5",
45-
"@commitlint/cli": "^8.3.5",
46-
"@commitlint/config-conventional": "^8.3.4",
47-
"semantic-release": "^17.0.7",
48-
"semantic-release-jira-releases-sb": "^0.7.2",
49-
"@semantic-release/git": "^9.0.0"
50+
"sinon-chai": "^3.3.0"
5051
},
5152
"dependencies": {
5253
"escape-regexp": "0.0.1",

spec/resource.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ describe('Resource', function () {
5959
it('returns given property', function () {
6060
expect(this.resource.property('email')).to.be.an.instanceOf(Property)
6161
})
62+
63+
it('returns null when property doesn\'t exit', function () {
64+
expect(this.resource.property('some.imagine.property')).to.be.null
65+
})
66+
67+
it('returns nested property for array field', function () {
68+
const property = this.resource.property('arrayed.1')
69+
70+
expect(property).to.be.an.instanceOf(Property)
71+
expect(property.type()).to.equal('string')
72+
})
6273
})
6374

6475
describe('#findMany', function () {

src/resource.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ class Resource extends BaseResource {
5050
}
5151

5252
property(path) {
53+
const nested = path.split('.')
54+
55+
// if property is an array return the array property
56+
if (nested.length > 1 && this.rawAttributes()[nested[0]]) {
57+
return new Property(this.rawAttributes()[nested[0]])
58+
}
59+
60+
if (!this.rawAttributes()[path]) {
61+
return null
62+
}
5363
return new Property(this.rawAttributes()[path])
5464
}
5565

yarn.lock

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,11 @@
16581658
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
16591659
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
16601660

1661+
"@types/mocha@^7.0.2":
1662+
version "7.0.2"
1663+
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-7.0.2.tgz#b17f16cf933597e10d6d78eae3251e692ce8b0ce"
1664+
integrity sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==
1665+
16611666
"@types/node@*", "@types/node@^10.11.7":
16621667
version "10.12.15"
16631668
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.15.tgz#20e85651b62fd86656e57c9c9bc771ab1570bc59"
@@ -3086,7 +3091,7 @@ debug@^4.0.1:
30863091
dependencies:
30873092
ms "^2.1.1"
30883093

3089-
debuglog@*, debuglog@^1.0.1:
3094+
debuglog@^1.0.1:
30903095
version "1.0.1"
30913096
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
30923097
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -3910,6 +3915,13 @@ flat@^4.1.0:
39103915
dependencies:
39113916
is-buffer "~2.0.3"
39123917

3918+
flat@^5.0.0:
3919+
version "5.0.0"
3920+
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.0.tgz#dab7d71d60413becb0ac2de9bf4304495e3af6af"
3921+
integrity sha512-6KSMM+cHHzXC/hpldXApL2S8Uz+QZv+tq5o/L0KQYleoG+GcwrnIJhTWC7tCOiKQp8D/fIvryINU1OZCCwevjA==
3922+
dependencies:
3923+
is-buffer "~2.0.4"
3924+
39133925
flush-write-stream@^1.0.0:
39143926
version "1.1.1"
39153927
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"
@@ -4558,7 +4570,7 @@ import-lazy@^2.1.0:
45584570
resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43"
45594571
integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=
45604572

4561-
imurmurhash@*, imurmurhash@^0.1.4:
4573+
imurmurhash@^0.1.4:
45624574
version "0.1.4"
45634575
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
45644576

@@ -4698,6 +4710,11 @@ is-buffer@^2.0.2, is-buffer@~2.0.3:
46984710
version "2.0.3"
46994711
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725"
47004712

4713+
is-buffer@~2.0.4:
4714+
version "2.0.4"
4715+
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623"
4716+
integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==
4717+
47014718
is-builtin-module@^1.0.0:
47024719
version "1.0.0"
47034720
resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe"
@@ -5479,11 +5496,6 @@ lockfile@^1.0.4:
54795496
dependencies:
54805497
signal-exit "^3.0.2"
54815498

5482-
lodash._baseindexof@*:
5483-
version "3.1.0"
5484-
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
5485-
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
5486-
54875499
lodash._baseuniq@~4.6.0:
54885500
version "4.6.0"
54895501
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -5492,33 +5504,11 @@ lodash._baseuniq@~4.6.0:
54925504
lodash._createset "~4.0.0"
54935505
lodash._root "~3.0.0"
54945506

5495-
lodash._bindcallback@*:
5496-
version "3.0.1"
5497-
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
5498-
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
5499-
5500-
lodash._cacheindexof@*:
5501-
version "3.0.2"
5502-
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
5503-
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
5504-
5505-
lodash._createcache@*:
5506-
version "3.1.2"
5507-
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
5508-
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
5509-
dependencies:
5510-
lodash._getnative "^3.0.0"
5511-
55125507
lodash._createset@~4.0.0:
55135508
version "4.0.3"
55145509
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
55155510
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
55165511

5517-
lodash._getnative@*, lodash._getnative@^3.0.0:
5518-
version "3.9.1"
5519-
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
5520-
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
5521-
55225512
lodash._reinterpolate@^3.0.0:
55235513
version "3.0.0"
55245514
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -5563,11 +5553,6 @@ lodash.isstring@^4.0.1:
55635553
resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"
55645554
integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=
55655555

5566-
lodash.restparam@*:
5567-
version "3.6.1"
5568-
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
5569-
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
5570-
55715556
lodash.template@^4.0.2:
55725557
version "4.5.0"
55735558
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab"

0 commit comments

Comments
 (0)