wiki-entity 0.5.10 → 0.5.12

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.
@@ -18,6 +18,8 @@ function convertToSimpleEntity(wikiEntity, lang, options) {
18
18
  entity.about = wikiEntity.extract;
19
19
  if (wikiEntity.redirectsToId)
20
20
  entity.redirectsToId = wikiEntity.redirectsToId;
21
+ if (wikiEntity.redirectsFromId)
22
+ entity.redirectsFromId = wikiEntity.redirectsFromId;
21
23
  if (wikiEntity.types) {
22
24
  entity.types = (0, utils_1.uniq)(wikiEntity.types.filter((item) => !/:(Thing|Agent)$/.test(item)));
23
25
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEntityCountryCode = void 0;
4
- const countries = require('../../data/countries.json');
4
+ const countries = require("../../data/countries.json");
5
5
  function getEntityCountryCode(wikiEntity) {
6
- if (!wikiEntity) {
6
+ if (!(wikiEntity === null || wikiEntity === void 0 ? void 0 : wikiEntity.claims)) {
7
7
  return null;
8
8
  }
9
9
  const countryIds = getEntityCountryIds(wikiEntity);
@@ -17,6 +17,9 @@ function getEntityCountryCode(wikiEntity) {
17
17
  }
18
18
  exports.getEntityCountryCode = getEntityCountryCode;
19
19
  function getEntityCountryIds(wikiEntity) {
20
- let prop = wikiEntity.claims.P17 || wikiEntity.claims.P27 || wikiEntity.claims.P495 || wikiEntity.claims.P1532;
21
- return prop && prop.values.map(item => item.value) || [];
20
+ let prop = wikiEntity.claims.P17 ||
21
+ wikiEntity.claims.P27 ||
22
+ wikiEntity.claims.P495 ||
23
+ wikiEntity.claims.P1532;
24
+ return (prop && prop.values.map((item) => item.value)) || [];
22
25
  }
@@ -51,6 +51,8 @@ function getEntities(params) {
51
51
  const entity = entities[id];
52
52
  if (entity.redirects && entity.redirects.to)
53
53
  entity.redirectsToId = entity.redirects.to;
54
+ if (entity.redirects && entity.redirects.from)
55
+ entity.redirectsFromId = entity.redirects.from;
54
56
  if (!(0, utils_1.isValidWikiId)(id) || ~Object.keys(entities[id]).indexOf("missing")) {
55
57
  delete entities[id];
56
58
  }
@@ -8,6 +8,8 @@ function simplifyEntity(lang, data, options = {}) {
8
8
  entity.pageid = data.pageid;
9
9
  if (data.redirectsToId)
10
10
  entity.redirectsToId = data.redirectsToId;
11
+ if (data.redirectsFromId)
12
+ entity.redirectsFromId = data.redirectsFromId;
11
13
  if (options.labels !== false && data.labels) {
12
14
  entity.labels = simplifyLabels(data.labels);
13
15
  entity.label = entity.labels[lang];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-entity",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "description": "Wiki entity fetcher",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./types/index.d.ts",
@@ -41,6 +41,6 @@
41
41
  "typescript": "latest"
42
42
  },
43
43
  "dependencies": {
44
- "axios": "^0.21.1"
44
+ "axios": "^1.6.0"
45
45
  }
46
46
  }
@@ -25,4 +25,5 @@ export declare type SimpleEntity = {
25
25
  data?: SimpleEntityData;
26
26
  categories?: string[];
27
27
  redirectsToId?: string;
28
+ redirectsFromId?: string;
28
29
  };
package/types/types.d.ts CHANGED
@@ -36,6 +36,7 @@ export interface WikiEntity extends WikidataEntity {
36
36
  redirects?: string[];
37
37
  categories?: string[];
38
38
  redirectsToId?: string;
39
+ redirectsFromId?: string;
39
40
  }
40
41
  export declare type WikiEntities = PlainObject<WikiEntity>;
41
42
  export declare type ParamClaimsType = "none" | "all" | "item" | "property";