Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
70bb27f
expanded the types
wvanderp Nov 14, 2020
e6c685f
removed white space and fixed capitalization
wvanderp Nov 15, 2020
3e4dd65
made the snak generic type more generic
wvanderp Nov 15, 2020
e3c3c27
added a Novalue test
wvanderp Nov 18, 2020
166384c
made my suggested changes
wvanderp Dec 6, 2020
fcb4734
fixed spelling errors
wvanderp Dec 6, 2020
58979fa
syntax cleanup
wvanderp Dec 14, 2020
9e597e6
found a difference in the api response and the Concept URI response
wvanderp Dec 14, 2020
5945c02
added a list of languages
wvanderp Dec 28, 2020
e729fe4
added the WikibasePropertySnak and tests
wvanderp Dec 28, 2020
b05bcae
made site link url optional and added tests
wvanderp Dec 30, 2020
8f1d281
added more precise types
wvanderp Jan 22, 2021
ca4ff11
the hash is optional when setting the hash
wvanderp Feb 7, 2021
ec2d131
keeping with the times
wvanderp Aug 31, 2021
72c4bb8
also including necessary files
wvanderp Aug 31, 2021
61bf4e0
added necessary exports
wvanderp Aug 31, 2021
434b8a2
export a needed interface
wvanderp Aug 31, 2021
3825ad7
made a type explicit
wvanderp Nov 2, 2021
d4caf3f
added some flexibility into the model
wvanderp Nov 21, 2021
1b2a497
added wiki commons entities
wvanderp Feb 9, 2022
410c7b8
Add new Snaks
wvanderp Nov 29, 2024
b52ce8a
Update project infrastructure and add new language codes
wvanderp Aug 27, 2026
37184d7
Add Property interface and GeoLineSnak type
wvanderp Aug 27, 2026
d7c7a78
Update dependencies, test configuration, and package settings
wvanderp Sep 5, 2026
ec05950
Update project structure and add language type definitions
wvanderp Sep 5, 2026
b7ad20e
Clarify package description and update version to 1.0.0
wvanderp Sep 5, 2026
7778040
Remove outdated first-publication instructions from PUBLISHING.md and…
wvanderp Sep 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module.exports = {
extends: [
'@wmde/wikimedia-typescript',
],
}
};
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Test
run: pnpm test
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish to npm

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v6
with:
# Node 24 includes an npm version that supports trusted publishing.
node-version: 24
registry-url: https://registry.npmjs.org/
package-manager-cache: false

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Publish
run: npm publish --access public
17 changes: 0 additions & 17 deletions .github/workflows/push.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules/
dist/
dist-tmp/

24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"cSpell.words": [
"calendarmodel",
"datavalue",
"entityid",
"globecoordinate",
"lastrevid",
"mainsnak",
"monolingualtext",
"novalue",
"pageid",
"sitelinks",
"snaks",
"Snaks",
"snaktype",
"somevalue",
"wbeditentity",
"wbgetentities",
"wikibase",
"Wikibase",
"wikidata"
],
"editor.formatOnSave": true
}
108 changes: 108 additions & 0 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Publishing to npm

This package is published publicly as
`@wvanderp/wikibase-datamodel-types`. It is a declaration-only package: the
published artifact contains `dist/index.d.ts`, not runtime JavaScript.

## Authentication model

Use npm trusted publishing for routine releases. It lets the GitHub Actions
workflow authenticate with a short-lived OpenID Connect (OIDC) credential, so
the repository does not need an `NPM_TOKEN` secret.

npm requires one of the following for a direct publish:

- an account with two-factor authentication (2FA), for an interactive publish;
- a granular access token with read/write package permission and **Bypass 2FA**
enabled, for non-interactive token-based publishing; or
- a configured trusted publisher, for supported CI/CD systems.

Only granular access tokens are supported. Prefer OIDC over storing a write
token. Never commit an npm token or put it in a checked-in `.npmrc` file.

Trusted publishing requires npm 11.5.1 or newer and Node.js 22.14.0 or newer.
The repository's publish workflow uses Node.js 24 and has the required
`id-token: write` permission.

Official references:

- [Trusted publishing for npm packages](https://docs.npmjs.com/trusted-publishers/)
- [Publishing scoped public packages](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages/)
- [npm publishing and 2FA](https://docs.npmjs.com/requiring-2fa-for-package-publishing-and-settings-modification/)
- [Creating granular access tokens](https://docs.npmjs.com/creating-and-viewing-access-tokens/)

## Configure trusted publishing

On npmjs.com, open the package, then **Settings → Trusted Publisher**. Add a
GitHub Actions publisher with these exact values:

| Setting | Value |
| --- | --- |
| Organization or user | `wvanderp` |
| Repository | `WikibaseDataModelTypes` |
| Workflow filename | `publish.yml` |
| Environment | leave blank |
| Allowed action | allow direct `npm publish` |

Enter only `publish.yml`, not `.github/workflows/publish.yml`. npm does not
validate these values when they are saved, and matching is exact. The
`repository.url` in `package.json` must also continue to point to this GitHub
repository.

After one OIDC release succeeds, set the package's publishing access to
**Require two-factor authentication and disallow tokens**. Revoke any granular
write token that was created for publishing. The current workflow does not use
an `NPM_TOKEN` GitHub secret.

## Routine release checklist

1. Pull the latest `master` and make sure CI is green.
2. Choose the next semantic version and update it, for example:

```sh
npm version patch --no-git-tag-version
pnpm install --lockfile-only
```

3. Run the release checks and inspect the artifact:

```sh
pnpm test
pnpm build
npm pack --dry-run
git diff --check
git status --short
```

4. Commit the version change and push it. Create and publish a GitHub release
whose tag points to that exact commit. A tag such as `v0.2.1` should match
version `0.2.1` in `package.json`.
5. Publishing the GitHub release triggers `.github/workflows/publish.yml`.
Check that the workflow succeeds, then verify the registry:

```sh
npm view @wvanderp/wikibase-datamodel-types version
```

The workflow can also be started manually with `workflow_dispatch`. Use that
only to retry a failed release from a commit whose `package.json` version has
not already been published. npm versions are immutable: an existing version
cannot be overwritten.

## Token fallback

If trusted publishing is temporarily unavailable, create a granular token on
npmjs.com with read/write access limited to this package, the shortest practical
expiry, and **Bypass 2FA** enabled. Store it as a GitHub Actions secret named
`NPM_TOKEN`, and temporarily pass it to the publish step as `NODE_AUTH_TOKEN`:

```yaml
- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```

Remove the workflow mapping and revoke the token immediately after migrating
back to trusted publishing. A token without Bypass 2FA cannot complete a
non-interactive direct publish when npm requires a second factor.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
# WikibaseDataModelTypes

Typescript definitions for the Wikibase DataModel expressed as flat JS objects,
as returned and accepted by Wikibase APIs like wbgetentities or wbeditentity.
TypeScript type definitions for the JSON entity data returned and accepted by Wikibase APIs such as `wbgetentities` and `wbeditentity`.
The package models Wikidata items and properties—including statements, snaks, qualifiers, references, labels, descriptions, aliases, and sitelinks—and provides partial support for Wikimedia Commons MediaInfo entities.

## Installation

```sh
npm install @wvanderp/wikibase-datamodel-types
# or
pnpm add @wvanderp/wikibase-datamodel-types
```

## Usage

```ts
import type {
Item,
Statement,
LabelLanguages,
} from "@wvanderp/wikibase-datamodel-types";
```

## Scope

For now, the definitions in this repository are very limited.
Feel free to send pull requests for other data (value) types.
- It supports all the features of wikidata items and properties
- It has partial support for commons structured data
- Additional information returned by the Wikimedia API is not modelled

This is a declaration-only package. Use `import type`; it does not provide
runtime JavaScript exports.

## Maintainers

See the
[publishing guide](https://github.com/wvanderp/WikibaseDataModelTypes/blob/master/PUBLISHING.md)
for the release checklist and npm authentication setup.
71 changes: 0 additions & 71 deletions index.d.ts

This file was deleted.

Loading