wiki-entity 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +18 -0
  2. package/lib/index.js +129 -126
  3. package/lib/request.js +37 -19
  4. package/lib/simpleEntity/convertToSimpleEntity.js +53 -53
  5. package/lib/simpleEntity/getEntityCountry.js +25 -25
  6. package/lib/simpleEntity/getEntityData.js +27 -27
  7. package/lib/simpleEntity/getEntityInstanceType.js +32 -32
  8. package/lib/simpleEntity/getEntityType.js +62 -62
  9. package/lib/simpleEntity/getEntityTypeByExtract.js +28 -28
  10. package/lib/simpleEntity/index.js +7 -7
  11. package/lib/simpleEntity/simpleEntity.js +20 -20
  12. package/lib/types.js +13 -13
  13. package/lib/utils.js +15 -15
  14. package/lib/wikidata/api.js +106 -106
  15. package/lib/wikidata/get_entity_types.js +60 -60
  16. package/lib/wikidata/index.js +112 -112
  17. package/lib/wikidata/simplify_claims.js +100 -100
  18. package/lib/wikidata/simplify_entity.js +76 -76
  19. package/lib/wikipedia/api.js +146 -146
  20. package/package.json +1 -1
  21. package/types/index.d.ts +9 -8
  22. package/types/request.d.ts +5 -3
  23. package/types/simpleEntity/convertToSimpleEntity.d.ts +6 -6
  24. package/types/simpleEntity/getEntityCountry.d.ts +2 -2
  25. package/types/simpleEntity/getEntityData.d.ts +3 -3
  26. package/types/simpleEntity/getEntityInstanceType.d.ts +3 -3
  27. package/types/simpleEntity/getEntityType.d.ts +3 -3
  28. package/types/simpleEntity/getEntityTypeByExtract.d.ts +2 -2
  29. package/types/simpleEntity/index.d.ts +2 -2
  30. package/types/simpleEntity/simpleEntity.d.ts +29 -29
  31. package/types/types.d.ts +68 -68
  32. package/types/utils.d.ts +8 -8
  33. package/types/wikidata/api.d.ts +4 -4
  34. package/types/wikidata/get_entity_types.d.ts +1 -1
  35. package/types/wikidata/index.d.ts +3 -3
  36. package/types/wikidata/simplify_claims.d.ts +4 -4
  37. package/types/wikidata/simplify_entity.d.ts +21 -21
  38. package/types/wikipedia/api.d.ts +31 -31
@@ -1,146 +1,146 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getRedirects = exports.getExtract = exports.getExtracts = exports.Api = void 0;
13
- const request_1 = require("../request");
14
- const API_URL = "https://$lang.wikipedia.org/w/api.php";
15
- class Api {
16
- constructor(qs = { action: "query", format: "json" }, httpTimeout) {
17
- this.qs = qs;
18
- this.httpTimeout = httpTimeout;
19
- this.qs.action = this.qs.action || "query";
20
- this.qs.format = "json";
21
- this.httpTimeout = httpTimeout || 10 * 1000;
22
- }
23
- query(lang, qs) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- if (qs)
26
- this.qs = Object.assign({}, this.qs, qs);
27
- const data = yield (0, request_1.default)(API_URL.replace("$lang", lang), {
28
- params: this.qs,
29
- timeout: this.httpTimeout
30
- });
31
- if (hasError(data))
32
- throw getError(data);
33
- if (data && data.query && data.query.pages) {
34
- return Object.keys(data.query.pages)
35
- .map((id) => data.query.pages[id])
36
- .map((page) => {
37
- const item = {
38
- pageid: page.pageid,
39
- title: page.title
40
- };
41
- if (page["categories"]) {
42
- item.categories = page["categories"].map((it) => it.title);
43
- }
44
- if (page["redirects"]) {
45
- item.redirects = page["redirects"].map((it) => it.title);
46
- }
47
- if (page["extract"]) {
48
- item.extract = page["extract"];
49
- }
50
- return item;
51
- });
52
- }
53
- return [];
54
- });
55
- }
56
- redirects() {
57
- this.qs["rdlimit"] = "max";
58
- this.addField("prop", "redirects");
59
- return this;
60
- }
61
- categories() {
62
- this.qs["cllimit"] = "max";
63
- this.qs["clshow"] = "!hidden";
64
- this.addField("prop", "categories");
65
- return this;
66
- }
67
- extract(sentences = 3) {
68
- this.qs["exsentences"] = sentences.toString();
69
- this.qs["explaintext"] = "true";
70
- this.addField("prop", "extracts");
71
- return this;
72
- }
73
- addField(name, value) {
74
- const vals = (this.qs[name] || "").split("|").filter((item) => !!item);
75
- vals.push(value);
76
- this.qs[name] = vals.join("|");
77
- return this;
78
- }
79
- }
80
- exports.Api = Api;
81
- function getExtracts(params) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const qs = {
84
- action: "query",
85
- titles: params.titles && params.titles.join("|"),
86
- exsentences: params.sentences || 3,
87
- prop: "extracts",
88
- explaintext: true,
89
- exintro: true,
90
- exlimit: "max",
91
- exsectionformat: "plain",
92
- format: "json"
93
- };
94
- const data = yield (0, request_1.default)(API_URL.replace("$lang", params.lang), {
95
- params: qs
96
- });
97
- if (hasError(data))
98
- throw getError(data);
99
- if (data && data.query && data.query.pages) {
100
- return Object.keys(data.query.pages).map((id) => data.query.pages[id]);
101
- }
102
- return [];
103
- });
104
- }
105
- exports.getExtracts = getExtracts;
106
- const getExtract = (lang, title, sentences) => getExtracts({
107
- lang: lang,
108
- titles: [title],
109
- sentences: sentences
110
- }).then(function (extracts) {
111
- if (extracts.length) {
112
- return extracts[0];
113
- }
114
- return null;
115
- });
116
- exports.getExtract = getExtract;
117
- function getRedirects(lang, title) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const qs = {
120
- action: "query",
121
- generator: "redirects",
122
- titles: title,
123
- grdlimit: "max",
124
- format: "json"
125
- };
126
- const data = yield (0, request_1.default)(API_URL.replace("$lang", lang), {
127
- params: qs
128
- });
129
- if (hasError(data))
130
- throw getError(data);
131
- if (data && data.query && data.query.pages) {
132
- return Object.keys(data.query.pages).map((id) => data.query.pages[id].title);
133
- }
134
- return [];
135
- });
136
- }
137
- exports.getRedirects = getRedirects;
138
- function getError(data) {
139
- return ((data &&
140
- data.error &&
141
- new Error(data.error.info || "Wikidata Api Error")) ||
142
- new Error("NO error"));
143
- }
144
- function hasError(data) {
145
- return !!data.error;
146
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getRedirects = exports.getExtract = exports.getExtracts = exports.Api = void 0;
13
+ const request_1 = require("../request");
14
+ const API_URL = "https://$lang.wikipedia.org/w/api.php";
15
+ class Api {
16
+ constructor(qs = { action: "query", format: "json" }, httpTimeout) {
17
+ this.qs = qs;
18
+ this.httpTimeout = httpTimeout;
19
+ this.qs.action = this.qs.action || "query";
20
+ this.qs.format = "json";
21
+ this.httpTimeout = httpTimeout || 10 * 1000;
22
+ }
23
+ query(lang, qs) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (qs)
26
+ this.qs = Object.assign({}, this.qs, qs);
27
+ const data = yield (0, request_1.default)(API_URL.replace("$lang", lang), {
28
+ params: this.qs,
29
+ timeout: this.httpTimeout
30
+ });
31
+ if (hasError(data))
32
+ throw getError(data);
33
+ if (data && data.query && data.query.pages) {
34
+ return Object.keys(data.query.pages)
35
+ .map((id) => data.query.pages[id])
36
+ .map((page) => {
37
+ const item = {
38
+ pageid: page.pageid,
39
+ title: page.title
40
+ };
41
+ if (page["categories"]) {
42
+ item.categories = page["categories"].map((it) => it.title);
43
+ }
44
+ if (page["redirects"]) {
45
+ item.redirects = page["redirects"].map((it) => it.title);
46
+ }
47
+ if (page["extract"]) {
48
+ item.extract = page["extract"];
49
+ }
50
+ return item;
51
+ });
52
+ }
53
+ return [];
54
+ });
55
+ }
56
+ redirects() {
57
+ this.qs["rdlimit"] = "max";
58
+ this.addField("prop", "redirects");
59
+ return this;
60
+ }
61
+ categories() {
62
+ this.qs["cllimit"] = "max";
63
+ this.qs["clshow"] = "!hidden";
64
+ this.addField("prop", "categories");
65
+ return this;
66
+ }
67
+ extract(sentences = 3) {
68
+ this.qs["exsentences"] = sentences.toString();
69
+ this.qs["explaintext"] = "true";
70
+ this.addField("prop", "extracts");
71
+ return this;
72
+ }
73
+ addField(name, value) {
74
+ const vals = (this.qs[name] || "").split("|").filter((item) => !!item);
75
+ vals.push(value);
76
+ this.qs[name] = vals.join("|");
77
+ return this;
78
+ }
79
+ }
80
+ exports.Api = Api;
81
+ function getExtracts(params) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const qs = {
84
+ action: "query",
85
+ titles: params.titles && params.titles.join("|"),
86
+ exsentences: params.sentences || 3,
87
+ prop: "extracts",
88
+ explaintext: true,
89
+ exintro: true,
90
+ exlimit: "max",
91
+ exsectionformat: "plain",
92
+ format: "json"
93
+ };
94
+ const data = yield (0, request_1.default)(API_URL.replace("$lang", params.lang), {
95
+ params: qs
96
+ });
97
+ if (hasError(data))
98
+ throw getError(data);
99
+ if (data && data.query && data.query.pages) {
100
+ return Object.keys(data.query.pages).map((id) => data.query.pages[id]);
101
+ }
102
+ return [];
103
+ });
104
+ }
105
+ exports.getExtracts = getExtracts;
106
+ const getExtract = (lang, title, sentences) => getExtracts({
107
+ lang: lang,
108
+ titles: [title],
109
+ sentences: sentences
110
+ }).then(function (extracts) {
111
+ if (extracts.length) {
112
+ return extracts[0];
113
+ }
114
+ return null;
115
+ });
116
+ exports.getExtract = getExtract;
117
+ function getRedirects(lang, title) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const qs = {
120
+ action: "query",
121
+ generator: "redirects",
122
+ titles: title,
123
+ grdlimit: "max",
124
+ format: "json"
125
+ };
126
+ const data = yield (0, request_1.default)(API_URL.replace("$lang", lang), {
127
+ params: qs
128
+ });
129
+ if (hasError(data))
130
+ throw getError(data);
131
+ if (data && data.query && data.query.pages) {
132
+ return Object.keys(data.query.pages).map((id) => data.query.pages[id].title);
133
+ }
134
+ return [];
135
+ });
136
+ }
137
+ exports.getRedirects = getRedirects;
138
+ function getError(data) {
139
+ return ((data &&
140
+ data.error &&
141
+ new Error(data.error.info || "Wikidata Api Error")) ||
142
+ new Error("NO error"));
143
+ }
144
+ function hasError(data) {
145
+ return !!data.error;
146
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-entity",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Wiki entity fetcher",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { WikiEntity, WikiEntitiesParams } from "./types";
2
- import { Api as WikipediaApi } from "./wikipedia/api";
3
- export { simplifyEntity } from "./wikidata/simplify_entity";
4
- export { WikipediaApi };
5
- export * from "./simpleEntity";
6
- export * from "./types";
7
- export declare function getEntities(params: WikiEntitiesParams): Promise<WikiEntity[]>;
8
- export declare function mapRedirects(titles: string[], lang: string): Promise<Record<string, string>>;
1
+ import { WikiEntity, WikiEntitiesParams } from "./types";
2
+ import { Api as WikipediaApi } from "./wikipedia/api";
3
+ export { simplifyEntity } from "./wikidata/simplify_entity";
4
+ export { setUserAgent, getUserAgent } from "./request";
5
+ export { WikipediaApi };
6
+ export * from "./simpleEntity";
7
+ export * from "./types";
8
+ export declare function getEntities(params: WikiEntitiesParams): Promise<WikiEntity[]>;
9
+ export declare function mapRedirects(titles: string[], lang: string): Promise<Record<string, string>>;
@@ -1,3 +1,5 @@
1
- import { AxiosRequestConfig } from "axios";
2
- export declare type RequestOptions = AxiosRequestConfig;
3
- export default function <T>(url: string, options: RequestOptions): Promise<T>;
1
+ import { AxiosRequestConfig } from "axios";
2
+ export declare type RequestOptions = AxiosRequestConfig;
3
+ export declare function setUserAgent(ua: string): void;
4
+ export declare function getUserAgent(): string;
5
+ export default function request<T>(url: string, options: RequestOptions): Promise<T>;
@@ -1,6 +1,6 @@
1
- import { SimpleEntityType, SimpleEntity } from "./simpleEntity";
2
- import { WikiEntity } from "../types";
3
- export declare type WikiEntityToEntityOptions = {
4
- defaultType?: SimpleEntityType;
5
- };
6
- export declare function convertToSimpleEntity(wikiEntity: WikiEntity, lang: string, options?: WikiEntityToEntityOptions): SimpleEntity;
1
+ import { SimpleEntityType, SimpleEntity } from "./simpleEntity";
2
+ import { WikiEntity } from "../types";
3
+ export declare type WikiEntityToEntityOptions = {
4
+ defaultType?: SimpleEntityType;
5
+ };
6
+ export declare function convertToSimpleEntity(wikiEntity: WikiEntity, lang: string, options?: WikiEntityToEntityOptions): SimpleEntity;
@@ -1,2 +1,2 @@
1
- import { WikiEntity } from "../types";
2
- export declare function getEntityCountryCode(wikiEntity: WikiEntity): string[];
1
+ import { WikiEntity } from "../types";
2
+ export declare function getEntityCountryCode(wikiEntity: WikiEntity): string[];
@@ -1,3 +1,3 @@
1
- import { SimpleEntityData } from "./simpleEntity";
2
- import { WikiEntity } from "../types";
3
- export declare function getEntityData(wikiEntity: WikiEntity): SimpleEntityData;
1
+ import { SimpleEntityData } from "./simpleEntity";
2
+ import { WikiEntity } from "../types";
3
+ export declare function getEntityData(wikiEntity: WikiEntity): SimpleEntityData;
@@ -1,3 +1,3 @@
1
- import { WikiEntity } from '../types';
2
- import { SimpleEntityType } from './simpleEntity';
3
- export declare function getEntityType(wikiEntity: WikiEntity): SimpleEntityType;
1
+ import { WikiEntity } from '../types';
2
+ import { SimpleEntityType } from './simpleEntity';
3
+ export declare function getEntityType(wikiEntity: WikiEntity): SimpleEntityType;
@@ -1,3 +1,3 @@
1
- import { SimpleEntityType } from './simpleEntity';
2
- import { WikiEntity } from '../types';
3
- export declare function getEntityType(wikiEntity: WikiEntity): SimpleEntityType;
1
+ import { SimpleEntityType } from './simpleEntity';
2
+ import { WikiEntity } from '../types';
3
+ export declare function getEntityType(wikiEntity: WikiEntity): SimpleEntityType;
@@ -1,2 +1,2 @@
1
- import { SimpleEntityType } from './simpleEntity';
2
- export declare function getEntityTypeByExtract(extract: string, lang: string): SimpleEntityType;
1
+ import { SimpleEntityType } from './simpleEntity';
2
+ export declare function getEntityTypeByExtract(extract: string, lang: string): SimpleEntityType;
@@ -1,2 +1,2 @@
1
- export { SimpleEntity, SimpleEntityData, SimpleEntityType } from './simpleEntity';
2
- export { convertToSimpleEntity } from './convertToSimpleEntity';
1
+ export { SimpleEntity, SimpleEntityData, SimpleEntityType } from './simpleEntity';
2
+ export { convertToSimpleEntity } from './convertToSimpleEntity';
@@ -1,29 +1,29 @@
1
- export declare enum SimpleEntityType {
2
- EVENT = "E",
3
- ORG = "O",
4
- PERSON = "H",
5
- PLACE = "P",
6
- PRODUCT = "R",
7
- WORK = "W"
8
- }
9
- export declare const SIMPLE_ENTITY_TYPES: SimpleEntityType[];
10
- export declare type SimpleEntityData = {
11
- [prop: string]: string[];
12
- };
13
- export declare type SimpleEntity = {
14
- lang?: string;
15
- wikiDataId?: string;
16
- name?: string;
17
- abbr?: string;
18
- description?: string;
19
- about?: string;
20
- wikiPageId?: number;
21
- wikiPageTitle?: string;
22
- type?: SimpleEntityType;
23
- types?: string[];
24
- countryCodes?: string[];
25
- data?: SimpleEntityData;
26
- categories?: string[];
27
- redirectsToId?: string;
28
- redirectsFromId?: string;
29
- };
1
+ export declare enum SimpleEntityType {
2
+ EVENT = "E",
3
+ ORG = "O",
4
+ PERSON = "H",
5
+ PLACE = "P",
6
+ PRODUCT = "R",
7
+ WORK = "W"
8
+ }
9
+ export declare const SIMPLE_ENTITY_TYPES: SimpleEntityType[];
10
+ export declare type SimpleEntityData = {
11
+ [prop: string]: string[];
12
+ };
13
+ export declare type SimpleEntity = {
14
+ lang?: string;
15
+ wikiDataId?: string;
16
+ name?: string;
17
+ abbr?: string;
18
+ description?: string;
19
+ about?: string;
20
+ wikiPageId?: number;
21
+ wikiPageTitle?: string;
22
+ type?: SimpleEntityType;
23
+ types?: string[];
24
+ countryCodes?: string[];
25
+ data?: SimpleEntityData;
26
+ categories?: string[];
27
+ redirectsToId?: string;
28
+ redirectsFromId?: string;
29
+ };
package/types/types.d.ts CHANGED
@@ -1,68 +1,68 @@
1
- export declare type PlainObject<T> = {
2
- [index: string]: T;
3
- };
4
- export declare type AnyPlainObject = PlainObject<any>;
5
- export declare type StringPlainObject = PlainObject<string>;
6
- export interface WikidataPropertyValue {
7
- datatype: string;
8
- value: any;
9
- pageid?: number;
10
- value_string?: string;
11
- label?: string;
12
- description?: string;
13
- qualifiers?: WikidataEntityClaims | null;
14
- }
15
- export interface WikidataBaseEntity {
16
- id: string;
17
- label?: string;
18
- description?: string;
19
- [index: string]: any;
20
- }
21
- export interface WikidataProperty extends WikidataBaseEntity {
22
- values: WikidataPropertyValue[];
23
- }
24
- export declare type WikidataEntityClaims = PlainObject<WikidataProperty>;
25
- export interface WikidataEntity extends WikidataBaseEntity {
26
- pageid?: number;
27
- aliases?: string[];
28
- sitelinks?: PlainObject<string>;
29
- claims?: WikidataEntityClaims;
30
- labels?: PlainObject<string>;
31
- }
32
- export declare type WikidataEntities = PlainObject<WikidataEntity>;
33
- export interface WikiEntity extends WikidataEntity {
34
- extract?: string;
35
- types?: string[];
36
- redirects?: string[];
37
- categories?: string[];
38
- redirectsToId?: string;
39
- redirectsFromId?: string;
40
- }
41
- export declare type WikiEntities = PlainObject<WikiEntity>;
42
- export declare type ParamClaimsType = "none" | "all" | "item" | "property";
43
- export interface WikidataEntitiesParams {
44
- ids?: string[];
45
- titles?: string[];
46
- props?: WikidataPropsParam[];
47
- language?: string;
48
- redirect?: string;
49
- claims?: ParamClaimsType;
50
- httpTimeout?: number;
51
- languages?: string[];
52
- }
53
- export declare enum WikidataPropsParam {
54
- info = "info",
55
- sitelinks = "sitelinks",
56
- aliases = "aliases",
57
- labels = "labels",
58
- descriptions = "descriptions",
59
- claims = "claims",
60
- datatype = "datatype"
61
- }
62
- export interface WikiEntitiesParams extends WikidataEntitiesParams {
63
- extract?: number;
64
- types?: boolean | string[];
65
- redirects?: boolean;
66
- categories?: boolean;
67
- wikiPageId?: boolean;
68
- }
1
+ export declare type PlainObject<T> = {
2
+ [index: string]: T;
3
+ };
4
+ export declare type AnyPlainObject = PlainObject<any>;
5
+ export declare type StringPlainObject = PlainObject<string>;
6
+ export interface WikidataPropertyValue {
7
+ datatype: string;
8
+ value: any;
9
+ pageid?: number;
10
+ value_string?: string;
11
+ label?: string;
12
+ description?: string;
13
+ qualifiers?: WikidataEntityClaims | null;
14
+ }
15
+ export interface WikidataBaseEntity {
16
+ id: string;
17
+ label?: string;
18
+ description?: string;
19
+ [index: string]: any;
20
+ }
21
+ export interface WikidataProperty extends WikidataBaseEntity {
22
+ values: WikidataPropertyValue[];
23
+ }
24
+ export declare type WikidataEntityClaims = PlainObject<WikidataProperty>;
25
+ export interface WikidataEntity extends WikidataBaseEntity {
26
+ pageid?: number;
27
+ aliases?: string[];
28
+ sitelinks?: PlainObject<string>;
29
+ claims?: WikidataEntityClaims;
30
+ labels?: PlainObject<string>;
31
+ }
32
+ export declare type WikidataEntities = PlainObject<WikidataEntity>;
33
+ export interface WikiEntity extends WikidataEntity {
34
+ extract?: string;
35
+ types?: string[];
36
+ redirects?: string[];
37
+ categories?: string[];
38
+ redirectsToId?: string;
39
+ redirectsFromId?: string;
40
+ }
41
+ export declare type WikiEntities = PlainObject<WikiEntity>;
42
+ export declare type ParamClaimsType = "none" | "all" | "item" | "property";
43
+ export interface WikidataEntitiesParams {
44
+ ids?: string[];
45
+ titles?: string[];
46
+ props?: WikidataPropsParam[];
47
+ language?: string;
48
+ redirect?: string;
49
+ claims?: ParamClaimsType;
50
+ httpTimeout?: number;
51
+ languages?: string[];
52
+ }
53
+ export declare enum WikidataPropsParam {
54
+ info = "info",
55
+ sitelinks = "sitelinks",
56
+ aliases = "aliases",
57
+ labels = "labels",
58
+ descriptions = "descriptions",
59
+ claims = "claims",
60
+ datatype = "datatype"
61
+ }
62
+ export interface WikiEntitiesParams extends WikidataEntitiesParams {
63
+ extract?: number;
64
+ types?: boolean | string[];
65
+ redirects?: boolean;
66
+ categories?: boolean;
67
+ wikiPageId?: boolean;
68
+ }
package/types/utils.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export declare type PlainObject<T> = {
2
- [index: string]: T;
3
- };
4
- export declare type AnyPlainObject = PlainObject<any>;
5
- export declare type StringPlainObject = PlainObject<string>;
6
- export declare function eachSeries<T>(arr: any[], iteratorFn: (item: any) => Promise<T>): any;
7
- export declare function uniq<T>(items: T[]): T[];
8
- export declare function isValidWikiId(id: string): boolean;
1
+ export declare type PlainObject<T> = {
2
+ [index: string]: T;
3
+ };
4
+ export declare type AnyPlainObject = PlainObject<any>;
5
+ export declare type StringPlainObject = PlainObject<string>;
6
+ export declare function eachSeries<T>(arr: any[], iteratorFn: (item: any) => Promise<T>): any;
7
+ export declare function uniq<T>(items: T[]): T[];
8
+ export declare function isValidWikiId(id: string): boolean;
@@ -1,4 +1,4 @@
1
- import { WikidataEntities, WikidataEntitiesParams } from "../types";
2
- export declare function getEntities(params: WikidataEntitiesParams): Promise<WikidataEntities>;
3
- export declare function getManyEntities(params: WikidataEntitiesParams): Promise<WikidataEntities>;
4
- export declare function validateParams(params: WikidataEntitiesParams): void;
1
+ import { WikidataEntities, WikidataEntitiesParams } from "../types";
2
+ export declare function getEntities(params: WikidataEntitiesParams): Promise<WikidataEntities>;
3
+ export declare function getManyEntities(params: WikidataEntitiesParams): Promise<WikidataEntities>;
4
+ export declare function validateParams(params: WikidataEntitiesParams): void;
@@ -1 +1 @@
1
- export declare function getEntityTypesByName(name: string, prefixes?: string[]): Promise<string[]>;
1
+ export declare function getEntityTypesByName(name: string, prefixes?: string[]): Promise<string[]>;
@@ -1,3 +1,3 @@
1
- import { WikidataEntities, WikidataEntitiesParams, WikidataEntityClaims } from "../types";
2
- export declare function getEntities(params: WikidataEntitiesParams): Promise<WikidataEntities>;
3
- export declare function exploreEntityClaims(claims: WikidataEntityClaims, params: WikidataEntitiesParams): Promise<void>;
1
+ import { WikidataEntities, WikidataEntitiesParams, WikidataEntityClaims } from "../types";
2
+ export declare function getEntities(params: WikidataEntitiesParams): Promise<WikidataEntities>;
3
+ export declare function exploreEntityClaims(claims: WikidataEntityClaims, params: WikidataEntitiesParams): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { WikidataEntityClaims, WikidataProperty, WikidataPropertyValue } from "../types";
2
- export declare function simplifyClaims(claims: any): WikidataEntityClaims;
3
- export declare function simplifyPropertyClaims(propClaims: any[], id: string): WikidataProperty;
4
- export declare function simplifyClaim(claim: any): WikidataPropertyValue;
1
+ import { WikidataEntityClaims, WikidataProperty, WikidataPropertyValue } from "../types";
2
+ export declare function simplifyClaims(claims: any): WikidataEntityClaims;
3
+ export declare function simplifyPropertyClaims(propClaims: any[], id: string): WikidataProperty;
4
+ export declare function simplifyClaim(claim: any): WikidataPropertyValue;