wikibase-sdk
Advanced tools
Comparing version 9.1.3 to 9.2.0
@@ -1,2 +0,2 @@ | ||
import type { EntityId, EntityPageTitle, Guid, NonNestedEntityId, NumericId, PropertyClaimsId } from '../types/entity.js'; | ||
import type { EntityId, EntityPageTitle, Guid, GuidAltSyntax, NonNestedEntityId, NumericId, PropertyClaimsId } from '../types/entity.js'; | ||
import type { Url } from '../types/options.js'; | ||
@@ -12,3 +12,3 @@ export declare const isNumericId: (id: string) => id is `${number}`; | ||
export declare const isMediaInfoId: (id: string) => id is `M${number}`; | ||
export declare const isGuid: (id: string) => id is string; | ||
export declare const isGuid: (id: string) => id is `Q${number}$${string}` | `P${number}$${string}` | `L${number}$${string}` | `M${number}$${string}` | `L${number}-F${number}$${string}` | `L${number}-S${number}$${string}` | `q${Lowercase<`${number}`>}$${string}` | `p${Lowercase<`${number}`>}$${string}` | `l${Lowercase<`${number}`>}$${string}` | `m${Lowercase<`${number}`>}$${string}` | `l${Lowercase<`${number}`>}-f${Lowercase<`${number}`>}$${string}` | `l${Lowercase<`${number}`>}-s${Lowercase<`${number}`>}$${string}`; | ||
export declare const isHash: (id: string) => id is string; | ||
@@ -21,3 +21,3 @@ export declare const isRevisionId: (id: string) => id is `${number}`; | ||
export declare function getImageUrl(filename: string, width?: number): Url; | ||
export declare function getEntityIdFromGuid(guid: Guid): EntityId; | ||
export declare function getEntityIdFromGuid(guid: Guid | GuidAltSyntax): EntityId; | ||
//# sourceMappingURL=helpers.d.ts.map |
@@ -22,3 +22,3 @@ import { uniq } from '../utils/utils.js'; | ||
return []; | ||
const { keepNonTruthy, keepNonDeprecated, areSubSnaks } = options; | ||
const { keepNonTruthy, keepNonDeprecated, areSubSnaks } = parseKeepOptions(options); | ||
if (keepNonDeprecated) { | ||
@@ -161,3 +161,3 @@ propertySnaks = nonDeprecatedPropertyClaims(propertySnaks); | ||
const keepOptions = ['keepQualifiers', 'keepReferences', 'keepIds', 'keepHashes', 'keepTypes', 'keepSnaktypes', 'keepRanks', 'keepRichValues']; | ||
const parseKeepOptions = options => { | ||
const parseKeepOptions = (options = {}) => { | ||
if (options.keepAll) { | ||
@@ -164,0 +164,0 @@ keepOptions.forEach(optionName => { |
@@ -11,2 +11,3 @@ import { simplifyClaims } from './simplify_claims.js'; | ||
claims: simplifyClaims, | ||
statements: simplifyClaims, | ||
sitelinks: simplifySitelinks, | ||
@@ -46,2 +47,7 @@ lemmas: simplifyLemmas, | ||
} | ||
else if (type === 'mediainfo') { | ||
simplifyIfDefined(entity, simplified, 'labels'); | ||
simplifyIfDefined(entity, simplified, 'descriptions'); | ||
simplifyIfDefined(entity, simplified, 'statements', options); | ||
} | ||
return simplified; | ||
@@ -48,0 +54,0 @@ }; |
@@ -24,4 +24,5 @@ import { WBK } from './wikibase-sdk.js'; | ||
export * from './types/sitelinks.js'; | ||
export * from './types/snakvalue.js'; | ||
export * from './types/sparql.js'; | ||
export * from './types/terms.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -26,2 +26,3 @@ import { WBK } from './wikibase-sdk.js'; | ||
export * from './types/sitelinks.js'; | ||
export * from './types/snakvalue.js'; | ||
export * from './types/sparql.js'; | ||
@@ -28,0 +29,0 @@ export * from './types/terms.js'; |
import type { PropertyId } from './entity.js'; | ||
import type { SnakValue } from './snakvalue.js'; | ||
import type { parsers } from '../helpers/parse_claim.js'; | ||
@@ -10,5 +11,5 @@ export type Rank = 'normal' | 'preferred' | 'deprecated'; | ||
rank: Rank; | ||
type: DataType; | ||
type: 'statement'; | ||
qualifiers?: Qualifiers; | ||
'qualifiers-order'?: string[]; | ||
'qualifiers-order'?: PropertyId[]; | ||
references?: Reference[]; | ||
@@ -21,60 +22,18 @@ } | ||
export interface Snak { | ||
id?: string; | ||
datatype: string; | ||
datatype: DataType; | ||
datavalue?: SnakValue; | ||
hash: string; | ||
property: string; | ||
property: PropertyId; | ||
snaktype: SnakType; | ||
} | ||
export interface SnakValue { | ||
type: DataType; | ||
value: unknown; | ||
} | ||
export interface ClaimSnakTimeValue extends SnakValue { | ||
type: 'time'; | ||
value: { | ||
after: number; | ||
before: number; | ||
calendermodel: string; | ||
precision: number; | ||
time: string; | ||
timezone: number; | ||
}; | ||
} | ||
export interface ClaimSnakQuantity extends SnakValue { | ||
type: 'quantity'; | ||
value: { | ||
amount: string; | ||
unit: string; | ||
upperBound?: string; | ||
lowerBound?: string; | ||
}; | ||
} | ||
export interface ClaimSnakString extends SnakValue { | ||
type: 'string'; | ||
value: string; | ||
} | ||
export interface SnakEntityValue extends SnakValue { | ||
type: 'wikibase-entityid'; | ||
value: { | ||
id: string; | ||
'numeric-id': number; | ||
'entity-type': string; | ||
}; | ||
} | ||
export type ClaimSnakWikibaseItem = SnakEntityValue; | ||
export interface Qualifier extends Snak { | ||
id: string; | ||
} | ||
export type Qualifier = Snak; | ||
export type PropertyQualifiers = Qualifier[]; | ||
export type Qualifiers = Record<PropertyId, PropertyQualifiers>; | ||
export interface ReferenceSnak extends Snak { | ||
id: string; | ||
} | ||
export type ReferenceSnak = Snak; | ||
export interface Reference { | ||
hash: string; | ||
snaks: Record<PropertyId, ReferenceSnak[]>; | ||
'snaks-order': string[]; | ||
'snaks-order': PropertyId[]; | ||
} | ||
export type References = Reference[]; | ||
//# sourceMappingURL=claim.d.ts.map |
@@ -21,5 +21,9 @@ import type { Claims, DataType } from './claim.js'; | ||
export type NamespacedEntityId = `Item:${ItemId}` | `Lexeme:${LexemeId}` | `Property:${PropertyId}`; | ||
export type Guid = string; | ||
export type Guid = `${EntityId | Lowercase<EntityId>}$${string}`; | ||
/** | ||
* A more shell-friendly GUID syntax, with a "-" instead of a "$" | ||
*/ | ||
export type GuidAltSyntax = `${EntityId | Lowercase<EntityId>}-${string}`; | ||
export type Hash = string; | ||
export type Entity = (Property | Item | Lexeme); | ||
export type Entity = (Property | Item | Lexeme | MediaInfo); | ||
export type EntityPageTitle = NamespacedEntityId | ItemId; | ||
@@ -55,2 +59,9 @@ export type Entities = Record<EntityId, Entity>; | ||
} | ||
export interface MediaInfo extends EntityInfo { | ||
id: MediaInfo; | ||
type: 'mediainfo'; | ||
labels?: Labels; | ||
descriptions?: Descriptions; | ||
statements?: Claims; | ||
} | ||
export interface EntityInfo { | ||
@@ -57,0 +68,0 @@ pageid?: number; |
@@ -43,3 +43,3 @@ import * as helpers from './helpers/helpers.js'; | ||
readonly isMediaInfoId: (id: string) => id is `M${number}`; | ||
readonly isGuid: (id: string) => id is string; | ||
readonly isGuid: (id: string) => id is `Q${number}$${string}` | `P${number}$${string}` | `L${number}$${string}` | `M${number}$${string}` | `L${number}-F${number}$${string}` | `L${number}-S${number}$${string}` | `q${Lowercase<`${number}`>}$${string}` | `p${Lowercase<`${number}`>}$${string}` | `l${Lowercase<`${number}`>}$${string}` | `m${Lowercase<`${number}`>}$${string}` | `l${Lowercase<`${number}`>}-f${Lowercase<`${number}`>}$${string}` | `l${Lowercase<`${number}`>}-s${Lowercase<`${number}`>}$${string}`; | ||
readonly isHash: (id: string) => id is string; | ||
@@ -46,0 +46,0 @@ readonly isRevisionId: (id: string) => id is `${number}`; |
{ | ||
"name": "wikibase-sdk", | ||
"version": "9.1.3", | ||
"version": "9.2.0", | ||
"type": "module", | ||
@@ -19,3 +19,4 @@ "description": "utils functions to query a Wikibase instance and simplify its results", | ||
"files": [ | ||
"dist/src" | ||
"dist/src", | ||
"CHANGELOG.md" | ||
], | ||
@@ -22,0 +23,0 @@ "directories": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
265725
176
3501