1
- const { getNumericId } = require ( 'wikibase-sdk' )
2
- const getTimeObject = require ( './get_time_object' )
3
- const { parseQuantity } = require ( './quantity' )
1
+ import { getNumericId } from 'wikibase-sdk'
2
+ import getTimeObject from './get_time_object.js'
3
+ import { parseQuantity } from './quantity.js'
4
4
5
5
// The difference in builders are due to the different expectations of the Wikibase API
6
6
7
- const singleClaimBuilders = {
7
+ export const singleClaimBuilders = {
8
8
string : str => `"${ str } "` ,
9
9
entity : entityId => JSON . stringify ( buildEntity ( entityId ) ) ,
10
10
time : value => JSON . stringify ( getTimeObject ( value ) ) ,
11
11
// Property type specific builders
12
12
monolingualtext : valueObj => JSON . stringify ( valueObj ) ,
13
13
quantity : ( amount , instance ) => JSON . stringify ( parseQuantity ( amount , instance ) ) ,
14
- globecoordinate : obj => JSON . stringify ( obj )
14
+ globecoordinate : obj => JSON . stringify ( obj ) ,
15
15
}
16
16
17
- const entityEditBuilders = {
17
+ export const entityEditBuilders = {
18
18
string : ( pid , value ) => valueStatementBase ( pid , 'string' , value ) ,
19
19
entity : ( pid , value ) => {
20
20
return valueStatementBase ( pid , 'wikibase-entityid' , buildEntity ( value ) )
@@ -25,7 +25,7 @@ const entityEditBuilders = {
25
25
time : ( pid , value ) => valueStatementBase ( pid , 'time' , getTimeObject ( value ) ) ,
26
26
quantity : ( pid , value , instance ) => valueStatementBase ( pid , 'quantity' , parseQuantity ( value , instance ) ) ,
27
27
globecoordinate : ( pid , value ) => valueStatementBase ( pid , 'globecoordinate' , value ) ,
28
- specialSnaktype : ( pid , snaktype ) => statementBase ( pid , snaktype )
28
+ specialSnaktype : ( pid , snaktype ) => statementBase ( pid , snaktype ) ,
29
29
}
30
30
31
31
const buildEntity = entityId => {
@@ -41,8 +41,8 @@ const statementBase = (pid, snaktype, value) => {
41
41
type : 'statement' ,
42
42
mainsnak : {
43
43
property : pid ,
44
- snaktype
45
- }
44
+ snaktype,
45
+ } ,
46
46
}
47
47
}
48
48
@@ -51,5 +51,3 @@ const valueStatementBase = (pid, type, value) => {
51
51
statement . mainsnak . datavalue = { type, value }
52
52
return statement
53
53
}
54
-
55
- module . exports = { singleClaimBuilders, entityEditBuilders }
0 commit comments