Page MenuHomePhabricator
Paste P72078

JS code to create properties, one per data type, for testing unique value constraints (T369079)
ActivePublic

Authored by Lucas_Werkmeister_WMDE on Jan 15 2025, 5:48 PM.
mw.loader.using( 'mediawiki.api' ).then( async () => {
let api = new mw.Api();
for ( const dataType of [
'commonsMedia',
'entity-schema',
'external-id',
'wikibase-form',
'globe-coordinate',
'geo-shape',
'wikibase-item',
'wikibase-lexeme',
'math',
'monolingualtext',
'musical-notation',
'time',
'wikibase-property',
'quantity',
'wikibase-sense',
'string',
'tabular-data',
'url',
] ) {
await api.postWithEditToken( {
action: 'wbeditentity',
new: 'property',
data: JSON.stringify( {
type: 'property',
datatype: dataType,
labels: { en: { language: 'en', value: `unique ${dataType} property` } },
aliases: { en: [ { language: 'en', value: `${dataType} unique property` } ] },
} ),
} );
}
} ).catch( console.error );