-
Notifications
You must be signed in to change notification settings - Fork 2
expanded the types to include snaks #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wvanderp
wants to merge
27
commits into
wmde:master
Choose a base branch
from
wvanderp:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
70bb27f
expanded the types
wvanderp e6c685f
removed white space and fixed capitalization
wvanderp 3e4dd65
made the snak generic type more generic
wvanderp e3c3c27
added a Novalue test
wvanderp 166384c
made my suggested changes
wvanderp fcb4734
fixed spelling errors
wvanderp 58979fa
syntax cleanup
wvanderp 9e597e6
found a difference in the api response and the Concept URI response
wvanderp 5945c02
added a list of languages
wvanderp e729fe4
added the WikibasePropertySnak and tests
wvanderp b05bcae
made site link url optional and added tests
wvanderp 8f1d281
added more precise types
wvanderp ca4ff11
the hash is optional when setting the hash
wvanderp ec2d131
keeping with the times
wvanderp 72c4bb8
also including necessary files
wvanderp 61bf4e0
added necessary exports
wvanderp 434b8a2
export a needed interface
wvanderp 3825ad7
made a type explicit
wvanderp d4caf3f
added some flexibility into the model
wvanderp 1b2a497
added wiki commons entities
wvanderp 410c7b8
Add new Snaks
wvanderp b52ce8a
Update project infrastructure and add new language codes
wvanderp 37184d7
Add Property interface and GeoLineSnak type
wvanderp d7c7a78
Update dependencies, test configuration, and package settings
wvanderp ec05950
Update project structure and add language type definitions
wvanderp b7ad20e
Clarify package description and update version to 1.0.0
wvanderp 7778040
Remove outdated first-publication instructions from PUBLISHING.md and…
wvanderp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,257 @@ | ||
| export type DataType = 'string'; | ||
| export interface WikidataResponse { | ||
| entities: { | ||
| [id: string]: Item; | ||
| }; | ||
| } | ||
|
|
||
| export interface Item { | ||
| pageid: number; | ||
| ns: number; | ||
| title: string; | ||
| lastrevid: number; | ||
| modified: string; | ||
| type: string; | ||
| id: string; | ||
| labels: Labels; | ||
| descriptions: Descriptions; | ||
| aliases: Aliases; | ||
| claims: StatementMap; | ||
| sitelinks: Sitelinks; | ||
| } | ||
|
|
||
| export interface Labels { | ||
| [language: string]: LabelAndDiscription; | ||
| } | ||
|
|
||
| export interface Descriptions { | ||
| [language: string]: LabelAndDiscription; | ||
| } | ||
|
|
||
| export type DataValueType = 'string'; | ||
| export interface Aliases { | ||
| [language: string]: LabelAndDiscription[] | null; | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export interface DataValue { | ||
| type: DataValueType; | ||
| export interface LabelAndDiscription { | ||
| language: string; | ||
| value: string; | ||
| } | ||
|
|
||
| export interface StatementMap { | ||
| [propery: string]: (Statement)[] | null; | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export type Snaks = CommonsMediaSnak | ||
| | GlobeCoordinateSnak | ||
| | MonolingualTextSnak | ||
| | QuantitySnak | ||
| | StringSnak | ||
| | TimeSnak | ||
| | URLSnak | ||
| | WikibaseItemSnak | ||
| | ExternalIdentifierSnak | ||
| | GeoShapeSnak | ||
| | MathSnak | ||
| | TabularDataSnak | ||
| | MusicalNotationSnak; | ||
|
|
||
| export interface Statement { | ||
| mainsnak: Snaks; | ||
| type: "statement", | ||
| id?: string; | ||
| rank: "normal" | "deprecated" | "preferred"; | ||
| qualifiers?: Qualifiers; | ||
| "qualifiers-order"?: (string)[] | null; | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| references?: (Reference)[] | null; | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export type Qualifier<T> = T & {hash: string}; | ||
|
|
||
| export type QualifierSnaks = Qualifier<CommonsMediaSnak> | ||
| | Qualifier<GlobeCoordinateSnak> | ||
| | Qualifier<MonolingualTextSnak> | ||
| | Qualifier<QuantitySnak> | ||
| | Qualifier<StringSnak> | ||
| | Qualifier<TimeSnak> | ||
| | Qualifier<URLSnak> | ||
| | Qualifier<WikibaseItemSnak> | ||
| | Qualifier<ExternalIdentifierSnak> | ||
| | Qualifier<GeoShapeSnak> | ||
| | Qualifier<MathSnak> | ||
| | Qualifier<TabularDataSnak> | ||
| | Qualifier<MusicalNotationSnak>; | ||
|
|
||
| export interface Qualifiers { | ||
| [property: string]: QualifierSnaks[] | null | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export interface Reference { | ||
| hash: string; | ||
| snaks: ReferenceSnaks; | ||
| "snaks-order"?: (string)[] | null; | ||
| } | ||
|
|
||
| export interface ReferenceSnaks { | ||
| [properyId: string]: (Snaks)[] | null; | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| export interface Sitelinks { | ||
| [wiki: string]: SiteLink; | ||
| } | ||
|
|
||
| export interface SiteLink { | ||
| site: string; | ||
| title: string; | ||
| badges?: (string)[] | null; | ||
|
wvanderp marked this conversation as resolved.
Outdated
|
||
| url: string; | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| _ | ||
| | | | ||
| ___ _ __ __ _ | | __ ___ | ||
| / __| | '_ \ / _` | | |/ / / __| | ||
| \__ \ | | | | | (_| | | < \__ \ | ||
| |___/ |_| |_| \__,_| |_|\_\ |___/ | ||
|
|
||
|
|
||
| */ | ||
|
|
||
| export type SnakType = 'value' | 'somevalue' | 'novalue'; | ||
|
|
||
| export interface Snak { | ||
| interface Snak { | ||
| snaktype: SnakType; | ||
| property: string; | ||
| datatype: DataType; | ||
| datavalue?: DataValue; // absent for snaktype != 'value' | ||
| hash?: string; | ||
| datavalue?: Record<string, unknown>; | ||
| datatype: string; | ||
| } | ||
|
|
||
| export interface Qualifier extends Snak { | ||
| hash: string; | ||
| export interface StringSnak extends Snak { | ||
| datavalue?: { | ||
| value: string; | ||
| type: string; | ||
| }; | ||
| datatype: "string"; | ||
| } | ||
|
|
||
| export interface QualifierMap { | ||
| [ propertyId: string ]: Qualifier[]; | ||
| export interface URLSnak extends Snak { | ||
| datavalue?: { | ||
| value: string; | ||
| type: string; | ||
| }; | ||
| datatype: "url"; | ||
| } | ||
|
|
||
| export interface SnakMap { | ||
| [ propertyId: string ]: Snak[]; | ||
| export interface WikibaseItemSnak extends Snak { | ||
| datavalue?: { | ||
| value: { | ||
| "entity-type": string; | ||
| "numeric-id": number; | ||
| id: string; | ||
| }; | ||
| type: string; | ||
| } | ||
| datatype: "wikibase-item"; | ||
| } | ||
|
|
||
| export interface Reference { | ||
| hash: string; | ||
| snaks: SnakMap; | ||
| 'snaks-order': string[]; | ||
|
|
||
| export interface TimeSnak extends Snak { | ||
| datavalue?: { | ||
| value: { | ||
| time: string; | ||
| timezone: number; | ||
| before: number; | ||
| after: number; | ||
| precision: number; | ||
| calendarmodel: string; | ||
| }; | ||
| type: "time"; | ||
| }; | ||
| datatype: "time"; | ||
| } | ||
|
|
||
| export type Rank = 'preferred' | 'normal' | 'deprecated'; | ||
| export interface MonolingualTextSnak extends Snak { | ||
| datavalue?: { | ||
| value: { | ||
| text: string; | ||
| language: string; | ||
| }; | ||
| type: "monolingualtext"; | ||
| }; | ||
| datatype: "monolingualtext"; | ||
| } | ||
|
|
||
| export interface Statement { | ||
| id?: string; // absent in newly created statements (fresh ID assigned server-side on save) | ||
| mainsnak: Snak; | ||
| rank: Rank; | ||
| qualifiers?: QualifierMap; // may be absent if empty, to save space | ||
| 'qualifiers-order'?: string[]; // may be absent if empty | ||
| references?: Reference[]; // may be absent if empty | ||
| type: 'statement'; | ||
| export interface ExternalIdentifierSnak extends Snak { | ||
| datavalue?: { | ||
| value: string; | ||
| type: string; | ||
| }; | ||
| datatype: "external-id"; | ||
| } | ||
|
|
||
| export interface StatementMap { | ||
| [ propertyId: string ]: Statement[]; | ||
| export interface QuantitySnak extends Snak { | ||
| datavalue?: { | ||
| value: { | ||
| amount: string | ||
| unit: string | ||
| upperBound?: string; | ||
| lowerBound?: string | ||
| }; | ||
| type: "quantity" | ||
| }; | ||
| datatype: "quantity"; | ||
| } | ||
|
|
||
| export interface Term { | ||
| language: string; | ||
| value: string; | ||
| export interface GlobeCoordinateSnak extends Snak { | ||
| datavalue?: { | ||
| value: { | ||
| latitude: number; | ||
| longitude: number; | ||
| altitude?: null; | ||
| precision: number; | ||
| globe: string; | ||
| }; | ||
| type: "globecoordinate"; | ||
| }; | ||
| datatype: "globe-coordinate"; | ||
| } | ||
|
|
||
| export interface CommonsMediaSnak extends Snak { | ||
| datavalue?: { | ||
| value: string | ||
| type: string | ||
| }; | ||
| datatype: "commonsMedia"; | ||
| } | ||
|
|
||
| export interface GeoShapeSnak extends Snak { | ||
| datavalue?: { | ||
| value: string, | ||
| type: string | ||
| }; | ||
| datatype: "geo-shape"; | ||
| } | ||
|
|
||
| export interface TermList { | ||
| [language: string]: Term; | ||
| export interface MathSnak extends Snak { | ||
| datavalue?: { | ||
| value: string, | ||
| type: string | ||
| }; | ||
| datatype: "math"; | ||
| } | ||
|
|
||
| export interface AliasesList { | ||
| [language: string]: Term[]; | ||
| export interface TabularDataSnak extends Snak { | ||
| datavalue?: { | ||
| value: string, | ||
| type: string | ||
| }; | ||
| datatype: "tabular-data"; | ||
| } | ||
|
|
||
| export interface Fingerprintable { | ||
| labels: TermList; | ||
| descriptions: TermList; | ||
| aliases: AliasesList; | ||
| export interface MusicalNotationSnak extends Snak { | ||
| datavalue?: { | ||
| value: string, | ||
| type: string | ||
| }; | ||
| datatype: "musical-notation"; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.