ropegeo-common 1.0.2 → 1.0.3
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.
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { PageDataSource } from './types/pageDataSource';
|
|
2
|
-
export { Difficulty, DifficultyRisk, DifficultyTechnical, DifficultyTime, DifficultyWater, PagePreview, } from './types/api/getRoutePreview/pagePreview';
|
|
2
|
+
export { Difficulty, DifficultyRisk, DifficultyTechnical, DifficultyTime, DifficultyWater, GetRopewikiPagePreviewRow, PagePreview, } from './types/api/getRoutePreview/pagePreview';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACH,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,WAAW,GACd,MAAM,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACH,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,yBAAyB,EACzB,WAAW,GACd,MAAM,yCAAyC,CAAC"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { PageDataSource } from '../../pageDataSource';
|
|
2
|
+
/**
|
|
3
|
+
* Row shape returned by the getRopewikiPagePreview query.
|
|
4
|
+
* Used when building a PagePreview from Ropewiki data via PagePreview.fromDbRow.
|
|
5
|
+
*/
|
|
6
|
+
export interface GetRopewikiPagePreviewRow {
|
|
7
|
+
pageId: string;
|
|
8
|
+
title: string;
|
|
9
|
+
quality: number | null;
|
|
10
|
+
userVotes: number | null;
|
|
11
|
+
technicalRating: string | null;
|
|
12
|
+
timeRating: string | null;
|
|
13
|
+
waterRating: string | null;
|
|
14
|
+
riskRating: string | null;
|
|
15
|
+
regionId: string;
|
|
16
|
+
regionName: string;
|
|
17
|
+
bannerFileUrl: string | null;
|
|
18
|
+
url: string | null;
|
|
19
|
+
}
|
|
2
20
|
/** Technical difficulty: 1–4 */
|
|
3
21
|
export declare enum DifficultyTechnical {
|
|
4
22
|
One = "1",
|
|
@@ -66,12 +84,20 @@ export declare class PagePreview {
|
|
|
66
84
|
title: string;
|
|
67
85
|
/** Region names (not ids) */
|
|
68
86
|
regions: string[];
|
|
69
|
-
/** Difficulty ratings (technical, water, time, risk); always present
|
|
87
|
+
/** Difficulty ratings (technical, water, time, risk); always present. risk is set to effective risk when built via fromDbRow. */
|
|
70
88
|
difficulty: Difficulty;
|
|
71
89
|
/** Map data id for the page route, or null if none */
|
|
72
90
|
mapData: string | null;
|
|
73
91
|
/** External link to the page (e.g. Ropewiki page URL) */
|
|
74
92
|
externalLink: string | null;
|
|
75
93
|
constructor(id: string, source: PageDataSource, imageUrl: string | null, rating: number | null, ratingCount: number | null, title: string, regions: string[], difficulty: Difficulty, mapData: string | null, externalLink: string | null);
|
|
94
|
+
/**
|
|
95
|
+
* Builds a PagePreview from a getRopewikiPagePreview query row.
|
|
96
|
+
* Sets difficulty.risk to the effective risk (derived from technical when risk is not set).
|
|
97
|
+
*/
|
|
98
|
+
static fromDbRow(row: GetRopewikiPagePreviewRow, mapData: string | null, regions?: string[]): PagePreview;
|
|
99
|
+
private static readonly RISK_ORDER;
|
|
100
|
+
private static getDefaultRisk;
|
|
101
|
+
private static getEffectiveRisk;
|
|
76
102
|
}
|
|
77
103
|
//# sourceMappingURL=pagePreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagePreview.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRoutePreview/pageP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M,GAAG,IAAI,CAAC;IACxB,iDAAiD;IACjD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oDAAoD;IACpD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"pagePreview.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRoutePreview/pagePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,gCAAgC;AAChC,oBAAY,mBAAmB;IAC3B,GAAG,MAAM;IACT,GAAG,MAAM;IACT,KAAK,MAAM;IACX,IAAI,MAAM;CACb;AAED,0CAA0C;AAC1C,oBAAY,eAAe;IACvB,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;IACP,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;CACZ;AAED,6CAA6C;AAC7C,oBAAY,cAAc;IACtB,CAAC,MAAM;IACP,EAAE,OAAO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AM,EACV,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,YAAY,EAAE,MAAM,GAAG,IAAI;IAc/B;;;OAGG;IACH,MAAM,CAAC,SAAS,CACZ,GAAG,EAAE,yBAAyB,EAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,CAAC,EAAE,MAAM,EAAE,GACnB,WAAW;IAsBd,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAOhC;IAEF,OAAO,CAAC,MAAM,CAAC,cAAc;IAS7B,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAUlC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PagePreview = exports.Difficulty = exports.DifficultyRisk = exports.DifficultyTime = exports.DifficultyWater = exports.DifficultyTechnical = void 0;
|
|
4
|
+
const pageDataSource_1 = require("../../pageDataSource");
|
|
4
5
|
/** Technical difficulty: 1–4 */
|
|
5
6
|
var DifficultyTechnical;
|
|
6
7
|
(function (DifficultyTechnical) {
|
|
@@ -80,5 +81,42 @@ class PagePreview {
|
|
|
80
81
|
this.mapData = mapData;
|
|
81
82
|
this.externalLink = externalLink;
|
|
82
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Builds a PagePreview from a getRopewikiPagePreview query row.
|
|
86
|
+
* Sets difficulty.risk to the effective risk (derived from technical when risk is not set).
|
|
87
|
+
*/
|
|
88
|
+
static fromDbRow(row, mapData, regions) {
|
|
89
|
+
const difficulty = new Difficulty(row.technicalRating, row.waterRating, row.timeRating, row.riskRating);
|
|
90
|
+
difficulty.risk = PagePreview.getEffectiveRisk(difficulty);
|
|
91
|
+
return new PagePreview(row.pageId, pageDataSource_1.PageDataSource.Ropewiki, row.bannerFileUrl ?? null, row.quality != null ? Number(row.quality) : null, row.userVotes ?? null, row.title, regions ?? [row.regionName], difficulty, mapData, row.url ?? null);
|
|
92
|
+
}
|
|
93
|
+
static getDefaultRisk(difficulty) {
|
|
94
|
+
if (difficulty.technical === DifficultyTechnical.One)
|
|
95
|
+
return DifficultyRisk.G;
|
|
96
|
+
if (difficulty.technical === DifficultyTechnical.Two)
|
|
97
|
+
return DifficultyRisk.PG;
|
|
98
|
+
if (difficulty.technical === DifficultyTechnical.Three || difficulty.technical === DifficultyTechnical.Four) {
|
|
99
|
+
return DifficultyRisk.PG13;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
static getEffectiveRisk(difficulty) {
|
|
104
|
+
const defaultRisk = PagePreview.getDefaultRisk(difficulty);
|
|
105
|
+
if (difficulty.risk != null) {
|
|
106
|
+
return defaultRisk != null &&
|
|
107
|
+
PagePreview.RISK_ORDER[difficulty.risk] < PagePreview.RISK_ORDER[defaultRisk]
|
|
108
|
+
? defaultRisk
|
|
109
|
+
: difficulty.risk;
|
|
110
|
+
}
|
|
111
|
+
return defaultRisk;
|
|
112
|
+
}
|
|
83
113
|
}
|
|
84
114
|
exports.PagePreview = PagePreview;
|
|
115
|
+
PagePreview.RISK_ORDER = {
|
|
116
|
+
[DifficultyRisk.G]: 0,
|
|
117
|
+
[DifficultyRisk.PG]: 1,
|
|
118
|
+
[DifficultyRisk.PG13]: 2,
|
|
119
|
+
[DifficultyRisk.R]: 3,
|
|
120
|
+
[DifficultyRisk.X]: 4,
|
|
121
|
+
[DifficultyRisk.XX]: 5,
|
|
122
|
+
};
|