Closed Smolli closed 6 years ago
The fetchedURI
attribute is not filled on templated link.
But you are true, this attribute can be setted on fetch call, good idea.
Le 4 janv. 2018 à 17:35, Christian Smolka notifications@github.com a écrit :
Short
When I query a resource with a templated link like /api/resource/{id} the value for id isn't stored in the resource.
Long
I have this rels-object that functions as dictionary for all my endpoints in the API:
{ "_links": { "self": { "href": "/api/v1/rels.hal" }, "calculation": { "href": "/api/v1/calculation/{id}", "templated": true }, "customer": { "href": "/api/v1/customer/{id}", "templated": true } } }` In my application I fetch a calculation resource like (rels is of type HalResource)
let calculation = rels.links('calculation').fetch({id: 5}) Which works fine. But when I want to update the resource calculation.update() the templated URL isn't resolved with the initial attributes {id: 5}.
After looking through the source code I found the member URI:fetchedURI, but it seems that the value is always empty. Shouldn't it be filled with the resolved URL of the fetched Resource?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/deblockt/hal-rest-client/issues/23, or mute the thread https://github.com/notifications/unsubscribe-auth/AE0PMwy63vrd_wpLc-4ZvJJeaaHEDYQdks5tHP3CgaJpZM4RTQRZ.
I guess this is a successor or maybe even a duplicate of #21...
I can't reproduce this issue on my unit test.
All work fine.
I have try something like this :
arange :
const testNock = nock("http://test.fr/");
const issue = {
"_links": {
"self": {
"href": "/api/v1/rels.hal"
},
"calculation": {
"href": "/api/v1/calculation/{id}",
"templated": true
},
"customer": {
"href": "/api/v1/customer/{id}",
"templated": true
}
}
};
const calculation5 = {
"_links": {
"self": {
"href": "/api/v1/calculation/{id}",
"templated": true
}
}
}
testNock
.get("/issue")
.reply(200, issue);
testNock
.get("/api/v1/calculation/5")
.reply(200, calculation5);
act :
const client = createClient("http://test.fr/");
const resource = await client.fetchResource("/issue");
const fetched = await resource.link("calculation").fetch({id: 5});
assert
t.equals(fetched.uri.fetchedURI, "http://test.fr/api/v1/calculation/5");
try {
await fetched.update()
} catch (e) {
console.log(e)
// I have an error because there are no PATCH http://test.fr/api/v1/calculation/5 mocked
// all work fine
}
Do you do anything more than in this test
what is your hal-rest-client version?
package-lock.json
says that I'm using 0.3.3
. But when I compare the sources, I get confused. The latest Github checkout of hal-resource.ts
compiles to
HalResource.prototype.update = function (serializer) {
var json = this.serialize(this.settedProps, this.settedLinks, serializer);
return this.restClient.update(this.uri.resourceURI, json, false, this.constructor);
};
Which should be right, right?
But the version of hal-resource.js
npm installs says
HalResource.prototype.update = function (serializer) {
var json = this.serialize(this.settedProps, this.settedLinks, serializer);
return this.restClient.update(this.uri.fill(), json, false, this.constructor);
};
Yes, you don't have the right 0.3.3 version.
Have you try to clean node_modules
, your cache, and restart a npm install
?
I did. Result is the same. :(
Content of my package-lock.json
:
"hal-rest-client": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/hal-rest-client/-/hal-rest-client-0.3.3.tgz",
"integrity": "sha1-BLHUN6ON/UPF6Cv4vy/jvicllyU=",
"dev": true,
"requires": {
"axios": "0.15.3",
"reflect-metadata": "0.1.10",
"uri-templates": "0.1.9"
}
}
Content of the included package.json
(partial):
{
"_from": "hal-rest-client",
"_id": "hal-rest-client@0.3.3",
"_inBundle": false,
"_integrity": "sha1-BLHUN6ON/UPF6Cv4vy/jvicllyU=",
"_location": "/hal-rest-client",
"_resolved": "https://registry.npmjs.org/hal-rest-client/-/hal-rest-client-0.3.3.tgz",
"_shasum": "04b1d437a38dfd43c5e82bf8bf2fe3be27259725",
"_spec": "hal-rest-client",
"author": {
"name": "Thomas Deblock",
"email": "deblock.thomas.62@gmail.com"
},
"dependencies": {
"axios": "^0.15.3",
"reflect-metadata": "^0.1.9",
"uri-templates": "^0.1.9"
},
"description": "Hal rest client for typescript",
"devDependencies": {
"@types/nock": "^8.2.0",
"@types/node": "^7.0.5",
"coveralls": "^2.11.16",
"istanbul": "^0.4.5",
"nock": "^9.0.5",
"remap-istanbul": "^0.9.1",
"tap-spec": "^4.1.1",
"tape": "^4.6.3",
"tape-async": "^2.1.1",
"tslint": "^4.5.1",
"typescript": "^2.2.1"
},
"homepage": "https://github.com/deblockt/hal-rest-client#readme",
"main": "dist/index",
"name": "hal-rest-client",
"repository": {
"type": "git",
"url": "git+https://github.com/deblockt/hal-rest-client.git"
},
"typings": "dist/index",
"version": "0.3.3"
}
Content of hal-resource.js
is still the old one.
Is this a thing?
Deploying application
NPM API key format changed recently. If your deployment fails, check your API key in ~/.npmrc.
http://docs.travis-ci.com/user/deployment/npm/
~/.npmrc size: 48
npm ERR! publish Failed PUT 403
npm ERR! Linux 4.9.6-040906-generic
npm ERR! argv "/home/travis/.nvm/versions/node/v6.12.0/bin/node" "/home/travis/.nvm/versions/node/v6.12.0/bin/npm" "publish"
npm ERR! node v6.12.0
npm ERR! npm v3.10.10
npm ERR! code E403
npm ERR! You cannot publish over the previously published version 0.3.3. : hal-rest-client
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/travis/build/deblockt/hal-rest-client/npm-debug.log
Done. Your build exited with 0.
Ho, Bad.
Deployment failed, but build is OK…
I will update the version number.
Le 5 janv. 2018 à 11:43, Christian Smolka notifications@github.com a écrit :
Is this a thing?
Deploying application NPM API key format changed recently. If your deployment fails, check your API key in ~/.npmrc. http://docs.travis-ci.com/user/deployment/npm/ ~/.npmrc size: 48 npm ERR! publish Failed PUT 403 npm ERR! Linux 4.9.6-040906-generic npm ERR! argv "/home/travis/.nvm/versions/node/v6.12.0/bin/node" "/home/travis/.nvm/versions/node/v6.12.0/bin/npm" "publish" npm ERR! node v6.12.0 npm ERR! npm v3.10.10 npm ERR! code E403 npm ERR! You cannot publish over the previously published version 0.3.3. : hal-rest-client npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issues npm ERR! Please include the following file with any support request: npm ERR! /home/travis/build/deblockt/hal-rest-client/npm-debug.log Done. Your build exited with 0. From https://travis-ci.org/deblockt/hal-rest-client https://travis-ci.org/deblockt/hal-rest-client — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/deblockt/hal-rest-client/issues/23#issuecomment-355525318, or mute the thread https://github.com/notifications/unsubscribe-auth/AE0PM1ZETJFhHME3bUm6J8IDPsHzfQjMks5tHfzfgaJpZM4RTQRZ.
can you try with 0.3.4 version?
This works! Thank you!
Short
When I query a resource with a templated link like
/api/resource/{id}
the value forid
isn't stored in the resource.Long
I have this rels-object that functions as dictionary for all my endpoints in the API:
In my application I fetch a calculation resource like (
rels
is of typeHalResource
)Which works fine. But when I want to update the resource
calculation.update()
the templated URL isn't resolved with the initial attributes{id: 5}
.After looking through the source code I found the member
URI:fetchedURI
, but it seems that the value is always empty. Shouldn't it be filled with the resolved URL of the fetched Resource?