maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
223 stars 24 forks source link

add-reference with snaks not working? #145

Closed gitonthescene closed 3 years ago

gitonthescene commented 3 years ago

I thought this was very close to the example:

$ cat ./reference.js 
// reference.js: a JS file exporting an object
module.exports = function (guid, bioid) {
  const today = new Date().toISOString().split('T')[0]
  return {
    guid,
    snaks: {
      P248: "Q1150348",
      P1157: bioid,
      P813: today
    }
  }
}
$ wd ar ./reference.js 'Q1556541$5230DF22-DF64-4DC8-B651-E1715816C01B' S001191
invalid property id { propertyId: 'Q1556541$5230DF22-DF64-4DC8-B651-E1715816C01B' }
$ wd --version
15.10.1
$  node --version
v12.20.0
$

The following worked, but not with the - delimited guid.

$ cat reference2.js                                                    
// reference.js: a JS file exporting an object
// Q1650417-87A6706C-74E9-416D-A29B-C7B0220F12FF I000027 
module.exports = {
    guid: 'Q1650417$87A6706C-74E9-416D-A29B-C7B0220F12FF',
    snaks: {
      P248: "Q1150348",
      P1157: 'I000027',
      P813: '2021-01-28'
  }
}
$ wd ar ./reference2.js
{"pageinfo":{"lastrevid":1349783068},"success":1,"reference":{"hash":"1f6dcc9371d2c1042f2cd2b228aec381848beaa9","snaks":{"P248":[{"snaktype":"value","property":"P248","hash":"c0e4d74d538fcf20633b6587ef2f345ded63abc3","datavalue":{"value":{"entity-type":"item","numeric-id":1150348,"id":"Q1150348"},"type":"wikibase-entityid"},"datatype":"wikibase-item"}],"P1157":[{"snaktype":"value","property":"P1157","hash":"9fcf9ac962ee72a07b2f1b992b6c8e34f534efad","datavalue":{"value":"I000027","type":"string"},"datatype":"external-id"}],"P813":[{"snaktype":"value","property":"P813","hash":"c86a671b50b0f3f6bb9776680e9ffd2db39c1bc1","datavalue":{"value":{"time":"+2021-01-28T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"},"type":"time"},"datatype":"time"}]},"snaks-order":["P248","P1157","P813"]}}
$ 

Any advice would be appreciated.

Regards,

gitonthescene commented 3 years ago

FWIW, I tried putting a console.log() line to better understand what was happening, but I couldn't get any output, even with --verbose.

maxlath commented 3 years ago

oups, that feature wasn't properly tested, sorry for that: fixed in b3c34b3 and published in v15.10.2

gitonthescene commented 3 years ago

No worries. I updated and it works now. Thanks very much for the quick turnaround!

gitonthescene commented 3 years ago

FWIW, it still requires the $. Should it also accept the - version?

maxlath commented 3 years ago

patched in f585c34, should be fixed in v15.10.3