ropegeo-common 1.2.6 → 1.2.7
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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/types/api/getRopewikiRegionImages/ropewikiRegionImageView.d.ts +6 -0
- package/dist/types/api/getRopewikiRegionImages/ropewikiRegionImageView.d.ts.map +1 -1
- package/dist/types/api/getRopewikiRegionImages/ropewikiRegionImageView.js +31 -0
- package/dist/types/api/getRopewikiRegionImages/ropewikiRegionImagesResult.d.ts +9 -5
- package/dist/types/api/getRopewikiRegionImages/ropewikiRegionImagesResult.d.ts.map +1 -1
- package/dist/types/api/getRopewikiRegionImages/ropewikiRegionImagesResult.js +22 -3
- package/dist/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsResult.d.ts +8 -4
- package/dist/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsResult.d.ts.map +1 -1
- package/dist/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsResult.js +22 -3
- package/dist/types/api/search/searchResults.d.ts +8 -4
- package/dist/types/api/search/searchResults.d.ts.map +1 -1
- package/dist/types/api/search/searchResults.js +20 -3
- package/dist/types/previews/pagePreview.d.ts +12 -0
- package/dist/types/previews/pagePreview.d.ts.map +1 -1
- package/dist/types/previews/pagePreview.js +97 -0
- package/dist/types/previews/preview.d.ts +7 -2
- package/dist/types/previews/preview.d.ts.map +1 -1
- package/dist/types/previews/preview.js +20 -0
- package/dist/types/previews/regionPreview.d.ts +9 -0
- package/dist/types/previews/regionPreview.d.ts.map +1 -1
- package/dist/types/previews/regionPreview.js +54 -0
- package/dist/types/results/cursorPaginationResults.d.ts +34 -0
- package/dist/types/results/cursorPaginationResults.d.ts.map +1 -0
- package/dist/types/results/cursorPaginationResults.js +76 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type { RopewikiBetaSectionView } from './types/api/getRopewikiPageView/ro
|
|
|
12
12
|
export type { RopewikiPageView } from './types/api/getRopewikiPageView/ropewikiPageView';
|
|
13
13
|
export { Cursor, CursorType } from './types/cursors/cursor';
|
|
14
14
|
export { CursorPaginationParams } from './types/params/cursorPaginationParams';
|
|
15
|
+
export { CursorPaginationResults, type CursorPaginationResponseParsed, ResultType, } from './types/results/cursorPaginationResults';
|
|
15
16
|
export { SearchCursor } from './types/cursors/searchCursor';
|
|
16
17
|
export type { SearchCursorType } from './types/cursors/searchCursor';
|
|
17
18
|
export { SearchParams } from './types/api/search/searchParams';
|
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,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAC3F,YAAY,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AACvG,YAAY,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE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AAE,uBAAuB,EAAE,MAAM,6DAA6D,CAAC;AACtG,YAAY,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,MAAM,gEAAgE,CAAC;AAC5G,OAAO,EAAE,0BAA0B,EAAE,MAAM,gEAAgE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RopewikiRegionImagesResult = exports.RopewikiRegionImagesParams = exports.RopewikiRegionImageView = exports.RegionImagesCursor = exports.RopewikiRegionPreviewsResult = exports.RopewikiRegionPreviewsParams = exports.RegionPreviewsCursor = exports.RopewikiRegionView = exports.SearchResults = exports.SearchParams = exports.SearchCursor = exports.CursorPaginationParams = exports.CursorType = exports.Cursor = exports.RoutesParams = exports.RoutesGeojson = exports.RouteType = exports.Route = exports.RegionPreview = exports.PagePreview = exports.PreviewType = exports.Preview = exports.PermitStatus = exports.DifficultyWater = exports.DifficultyTime = exports.DifficultyTechnical = exports.DifficultyRisk = exports.Difficulty = exports.PageDataSource = void 0;
|
|
3
|
+
exports.RopewikiRegionImagesResult = exports.RopewikiRegionImagesParams = exports.RopewikiRegionImageView = exports.RegionImagesCursor = exports.RopewikiRegionPreviewsResult = exports.RopewikiRegionPreviewsParams = exports.RegionPreviewsCursor = exports.RopewikiRegionView = exports.SearchResults = exports.SearchParams = exports.SearchCursor = exports.ResultType = exports.CursorPaginationResults = exports.CursorPaginationParams = exports.CursorType = exports.Cursor = exports.RoutesParams = exports.RoutesGeojson = exports.RouteType = exports.Route = exports.RegionPreview = exports.PagePreview = exports.PreviewType = exports.Preview = exports.PermitStatus = exports.DifficultyWater = exports.DifficultyTime = exports.DifficultyTechnical = exports.DifficultyRisk = exports.Difficulty = exports.PageDataSource = void 0;
|
|
4
4
|
var pageDataSource_1 = require("./types/pageDataSource");
|
|
5
5
|
Object.defineProperty(exports, "PageDataSource", { enumerable: true, get: function () { return pageDataSource_1.PageDataSource; } });
|
|
6
6
|
var difficulty_1 = require("./types/difficulty");
|
|
@@ -30,6 +30,9 @@ Object.defineProperty(exports, "Cursor", { enumerable: true, get: function () {
|
|
|
30
30
|
Object.defineProperty(exports, "CursorType", { enumerable: true, get: function () { return cursor_1.CursorType; } });
|
|
31
31
|
var cursorPaginationParams_1 = require("./types/params/cursorPaginationParams");
|
|
32
32
|
Object.defineProperty(exports, "CursorPaginationParams", { enumerable: true, get: function () { return cursorPaginationParams_1.CursorPaginationParams; } });
|
|
33
|
+
var cursorPaginationResults_1 = require("./types/results/cursorPaginationResults");
|
|
34
|
+
Object.defineProperty(exports, "CursorPaginationResults", { enumerable: true, get: function () { return cursorPaginationResults_1.CursorPaginationResults; } });
|
|
35
|
+
Object.defineProperty(exports, "ResultType", { enumerable: true, get: function () { return cursorPaginationResults_1.ResultType; } });
|
|
33
36
|
var searchCursor_1 = require("./types/cursors/searchCursor");
|
|
34
37
|
Object.defineProperty(exports, "SearchCursor", { enumerable: true, get: function () { return searchCursor_1.SearchCursor; } });
|
|
35
38
|
var searchParams_1 = require("./types/api/search/searchParams");
|
|
@@ -21,5 +21,11 @@ export declare class RopewikiRegionImageView {
|
|
|
21
21
|
externalLink: string;
|
|
22
22
|
caption: string | undefined;
|
|
23
23
|
constructor(row: RopewikiRegionImageViewRow);
|
|
24
|
+
/**
|
|
25
|
+
* Validates result has image view fields and applies RopewikiRegionImageView.prototype.
|
|
26
|
+
*/
|
|
27
|
+
static fromResult(result: unknown): RopewikiRegionImageView;
|
|
28
|
+
private static assertString;
|
|
29
|
+
private static assertOptionalString;
|
|
24
30
|
}
|
|
25
31
|
//# sourceMappingURL=ropewikiRegionImageView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ropewikiRegionImageView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/ropewikiRegionImageView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEhB,GAAG,EAAE,0BAA0B;
|
|
1
|
+
{"version":3,"file":"ropewikiRegionImageView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/ropewikiRegionImageView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEhB,GAAG,EAAE,0BAA0B;IAS3C;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,uBAAuB;IAe3D,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAYtC"}
|
|
@@ -13,5 +13,36 @@ class RopewikiRegionImageView {
|
|
|
13
13
|
this.externalLink = row.linkUrl;
|
|
14
14
|
this.caption = row.caption ?? undefined;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Validates result has image view fields and applies RopewikiRegionImageView.prototype.
|
|
18
|
+
*/
|
|
19
|
+
static fromResult(result) {
|
|
20
|
+
if (result == null || typeof result !== 'object') {
|
|
21
|
+
throw new Error('RopewikiRegionImageView result must be an object');
|
|
22
|
+
}
|
|
23
|
+
const r = result;
|
|
24
|
+
RopewikiRegionImageView.assertString(r, 'id');
|
|
25
|
+
RopewikiRegionImageView.assertString(r, 'pageId');
|
|
26
|
+
RopewikiRegionImageView.assertString(r, 'pageName');
|
|
27
|
+
RopewikiRegionImageView.assertString(r, 'url');
|
|
28
|
+
RopewikiRegionImageView.assertString(r, 'externalLink');
|
|
29
|
+
RopewikiRegionImageView.assertOptionalString(r, 'caption');
|
|
30
|
+
Object.setPrototypeOf(r, RopewikiRegionImageView.prototype);
|
|
31
|
+
return r;
|
|
32
|
+
}
|
|
33
|
+
static assertString(obj, key) {
|
|
34
|
+
const v = obj[key];
|
|
35
|
+
if (typeof v !== 'string') {
|
|
36
|
+
throw new Error(`RopewikiRegionImageView.${key} must be a string, got: ${typeof v}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
static assertOptionalString(obj, key) {
|
|
40
|
+
const v = obj[key];
|
|
41
|
+
if (v !== null &&
|
|
42
|
+
v !== undefined &&
|
|
43
|
+
typeof v !== 'string') {
|
|
44
|
+
throw new Error(`RopewikiRegionImageView.${key} must be string or undefined, got: ${typeof v}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
16
47
|
}
|
|
17
48
|
exports.RopewikiRegionImageView = RopewikiRegionImageView;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RopewikiRegionImageView } from './ropewikiRegionImageView';
|
|
2
2
|
import { RegionImagesCursor } from '../../cursors/regionImagesCursor';
|
|
3
|
+
import { CursorPaginationResults, type CursorPaginationResponseParsed } from '../../results/cursorPaginationResults';
|
|
3
4
|
/**
|
|
4
5
|
* Result of getRopewikiRegionImages (GET /ropewiki/region/{id}/images).
|
|
5
6
|
*/
|
|
6
|
-
export declare class RopewikiRegionImagesResult {
|
|
7
|
-
results: RopewikiRegionImageView[];
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare class RopewikiRegionImagesResult extends CursorPaginationResults<RopewikiRegionImageView> {
|
|
8
|
+
constructor(results: RopewikiRegionImageView[], nextCursor: RegionImagesCursor | string | null);
|
|
9
|
+
/**
|
|
10
|
+
* Build from validated { results, nextCursor }. Decodes nextCursor to ensure valid.
|
|
11
|
+
* Each result is validated via RopewikiRegionImageView.fromResult.
|
|
12
|
+
*/
|
|
13
|
+
static fromResponseBody(body: CursorPaginationResponseParsed): RopewikiRegionImagesResult;
|
|
10
14
|
}
|
|
11
15
|
//# sourceMappingURL=ropewikiRegionImagesResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ropewikiRegionImagesResult.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/ropewikiRegionImagesResult.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ropewikiRegionImagesResult.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/ropewikiRegionImagesResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EACH,uBAAuB,EACvB,KAAK,8BAA8B,EAEtC,MAAM,uCAAuC,CAAC;AAE/C;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,uBAAuB,CAAC,uBAAuB,CAAC;gBAExF,OAAO,EAAE,uBAAuB,EAAE,EAClC,UAAU,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI;IAWlD;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CACnB,IAAI,EAAE,8BAA8B,GACrC,0BAA0B;CAQhC"}
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RopewikiRegionImagesResult = void 0;
|
|
4
|
+
const ropewikiRegionImageView_1 = require("./ropewikiRegionImageView");
|
|
5
|
+
const regionImagesCursor_1 = require("../../cursors/regionImagesCursor");
|
|
6
|
+
const cursorPaginationResults_1 = require("../../results/cursorPaginationResults");
|
|
4
7
|
/**
|
|
5
8
|
* Result of getRopewikiRegionImages (GET /ropewiki/region/{id}/images).
|
|
6
9
|
*/
|
|
7
|
-
class RopewikiRegionImagesResult {
|
|
10
|
+
class RopewikiRegionImagesResult extends cursorPaginationResults_1.CursorPaginationResults {
|
|
8
11
|
constructor(results, nextCursor) {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const nextCursorStr = nextCursor === null
|
|
13
|
+
? null
|
|
14
|
+
: typeof nextCursor === 'string'
|
|
15
|
+
? nextCursor
|
|
16
|
+
: nextCursor.encodeBase64();
|
|
17
|
+
super(results, nextCursorStr, cursorPaginationResults_1.ResultType.RopewikiRegionImages);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build from validated { results, nextCursor }. Decodes nextCursor to ensure valid.
|
|
21
|
+
* Each result is validated via RopewikiRegionImageView.fromResult.
|
|
22
|
+
*/
|
|
23
|
+
static fromResponseBody(body) {
|
|
24
|
+
const { results: resultsRaw, nextCursor } = body;
|
|
25
|
+
if (nextCursor != null) {
|
|
26
|
+
regionImagesCursor_1.RegionImagesCursor.decodeBase64(nextCursor);
|
|
27
|
+
}
|
|
28
|
+
const results = resultsRaw.map((r) => ropewikiRegionImageView_1.RopewikiRegionImageView.fromResult(r));
|
|
29
|
+
return new RopewikiRegionImagesResult(results, nextCursor);
|
|
11
30
|
}
|
|
12
31
|
}
|
|
13
32
|
exports.RopewikiRegionImagesResult = RopewikiRegionImagesResult;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Preview } from '../../previews/preview';
|
|
2
2
|
import { RegionPreviewsCursor } from '../../cursors/regionPreviewsCursor';
|
|
3
|
+
import { CursorPaginationResults, type CursorPaginationResponseParsed } from '../../results/cursorPaginationResults';
|
|
3
4
|
/**
|
|
4
5
|
* Result of getRopewikiRegionPreviews (GET /ropewiki/region/{id}/previews).
|
|
5
6
|
*/
|
|
6
|
-
export declare class RopewikiRegionPreviewsResult {
|
|
7
|
-
results: Preview[];
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare class RopewikiRegionPreviewsResult extends CursorPaginationResults<Preview> {
|
|
8
|
+
constructor(results: Preview[], nextCursor: RegionPreviewsCursor | string | null);
|
|
9
|
+
/**
|
|
10
|
+
* Build from validated { results, nextCursor }. Decodes nextCursor to ensure valid.
|
|
11
|
+
* Each result is validated via Preview.fromResult.
|
|
12
|
+
*/
|
|
13
|
+
static fromResponseBody(body: CursorPaginationResponseParsed): RopewikiRegionPreviewsResult;
|
|
10
14
|
}
|
|
11
15
|
//# sourceMappingURL=ropewikiRegionPreviewsResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ropewikiRegionPreviewsResult.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"ropewikiRegionPreviewsResult.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACH,uBAAuB,EACvB,KAAK,8BAA8B,EAEtC,MAAM,uCAAuC,CAAC;AAE/C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB,CAAC,OAAO,CAAC;gBAE1E,OAAO,EAAE,OAAO,EAAE,EAClB,UAAU,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI;IAWpD;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CACnB,IAAI,EAAE,8BAA8B,GACrC,4BAA4B;CAQlC"}
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RopewikiRegionPreviewsResult = void 0;
|
|
4
|
+
const preview_1 = require("../../previews/preview");
|
|
5
|
+
const regionPreviewsCursor_1 = require("../../cursors/regionPreviewsCursor");
|
|
6
|
+
const cursorPaginationResults_1 = require("../../results/cursorPaginationResults");
|
|
4
7
|
/**
|
|
5
8
|
* Result of getRopewikiRegionPreviews (GET /ropewiki/region/{id}/previews).
|
|
6
9
|
*/
|
|
7
|
-
class RopewikiRegionPreviewsResult {
|
|
10
|
+
class RopewikiRegionPreviewsResult extends cursorPaginationResults_1.CursorPaginationResults {
|
|
8
11
|
constructor(results, nextCursor) {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const nextCursorStr = nextCursor === null
|
|
13
|
+
? null
|
|
14
|
+
: typeof nextCursor === 'string'
|
|
15
|
+
? nextCursor
|
|
16
|
+
: nextCursor.encodeBase64();
|
|
17
|
+
super(results, nextCursorStr, cursorPaginationResults_1.ResultType.RopewikiRegionPreviews);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build from validated { results, nextCursor }. Decodes nextCursor to ensure valid.
|
|
21
|
+
* Each result is validated via Preview.fromResult.
|
|
22
|
+
*/
|
|
23
|
+
static fromResponseBody(body) {
|
|
24
|
+
const { results: resultsRaw, nextCursor } = body;
|
|
25
|
+
if (nextCursor != null) {
|
|
26
|
+
regionPreviewsCursor_1.RegionPreviewsCursor.decodeBase64(nextCursor);
|
|
27
|
+
}
|
|
28
|
+
const results = resultsRaw.map((r) => preview_1.Preview.fromResult(r));
|
|
29
|
+
return new RopewikiRegionPreviewsResult(results, nextCursor);
|
|
11
30
|
}
|
|
12
31
|
}
|
|
13
32
|
exports.RopewikiRegionPreviewsResult = RopewikiRegionPreviewsResult;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Preview } from '../../previews/preview';
|
|
2
2
|
import { SearchCursor } from '../../cursors/searchCursor';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
nextCursor: string | null;
|
|
6
|
-
|
|
3
|
+
import { CursorPaginationResults, type CursorPaginationResponseParsed } from '../../results/cursorPaginationResults';
|
|
4
|
+
export declare class SearchResults extends CursorPaginationResults<Preview> {
|
|
5
|
+
constructor(results: Preview[], nextCursor: SearchCursor | string | null);
|
|
6
|
+
/**
|
|
7
|
+
* Build from validated { results, nextCursor }. Decodes nextCursor to ensure valid.
|
|
8
|
+
* Each result is validated via Preview.fromResult.
|
|
9
|
+
*/
|
|
10
|
+
static fromResponseBody(body: CursorPaginationResponseParsed): SearchResults;
|
|
7
11
|
}
|
|
8
12
|
//# sourceMappingURL=searchResults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchResults.d.ts","sourceRoot":"","sources":["../../../../src/types/api/search/searchResults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"searchResults.d.ts","sourceRoot":"","sources":["../../../../src/types/api/search/searchResults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACH,uBAAuB,EACvB,KAAK,8BAA8B,EAEtC,MAAM,uCAAuC,CAAC;AAE/C,qBAAa,aAAc,SAAQ,uBAAuB,CAAC,OAAO,CAAC;gBACnD,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI;IAQxE;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,8BAA8B,GAAG,aAAa;CAQ/E"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SearchResults = void 0;
|
|
4
|
-
|
|
4
|
+
const preview_1 = require("../../previews/preview");
|
|
5
|
+
const searchCursor_1 = require("../../cursors/searchCursor");
|
|
6
|
+
const cursorPaginationResults_1 = require("../../results/cursorPaginationResults");
|
|
7
|
+
class SearchResults extends cursorPaginationResults_1.CursorPaginationResults {
|
|
5
8
|
constructor(results, nextCursor) {
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
const nextCursorStr = nextCursor === null || typeof nextCursor === 'string'
|
|
10
|
+
? nextCursor
|
|
11
|
+
: nextCursor.encodeBase64();
|
|
12
|
+
super(results, nextCursorStr, cursorPaginationResults_1.ResultType.Search);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build from validated { results, nextCursor }. Decodes nextCursor to ensure valid.
|
|
16
|
+
* Each result is validated via Preview.fromResult.
|
|
17
|
+
*/
|
|
18
|
+
static fromResponseBody(body) {
|
|
19
|
+
const { results: resultsRaw, nextCursor } = body;
|
|
20
|
+
if (nextCursor != null) {
|
|
21
|
+
searchCursor_1.SearchCursor.decodeBase64(nextCursor);
|
|
22
|
+
}
|
|
23
|
+
const results = resultsRaw.map((r) => preview_1.Preview.fromResult(r));
|
|
24
|
+
return new SearchResults(results, nextCursor);
|
|
8
25
|
}
|
|
9
26
|
}
|
|
10
27
|
exports.SearchResults = SearchResults;
|
|
@@ -57,6 +57,18 @@ export declare class PagePreview extends Preview {
|
|
|
57
57
|
* Builds a PagePreview from a getRopewikiPagePreview query row.
|
|
58
58
|
*/
|
|
59
59
|
static fromDbRow(row: GetRopewikiPagePreviewRow, mapData: string | null, regions?: string[], aka?: string[]): PagePreview;
|
|
60
|
+
/**
|
|
61
|
+
* Validates result has page preview fields and applies PagePreview.prototype.
|
|
62
|
+
* Expects difficulty as plain object with technical, water, time, risk (optional).
|
|
63
|
+
*/
|
|
64
|
+
static fromResult(result: unknown): PagePreview;
|
|
65
|
+
private static assertString;
|
|
66
|
+
private static assertNullableString;
|
|
67
|
+
private static assertNullableNumber;
|
|
68
|
+
private static assertSource;
|
|
69
|
+
private static assertStringArray;
|
|
70
|
+
private static assertDifficulty;
|
|
71
|
+
private static assertPermit;
|
|
60
72
|
private static parsePermit;
|
|
61
73
|
}
|
|
62
74
|
//# sourceMappingURL=pagePreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagePreview.d.ts","sourceRoot":"","sources":["../../../src/types/previews/pagePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEjD;;;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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,EAAE,GACf,WAAW;IAuBd;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW;IA4B/C,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAOnC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAOnC,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAYhC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAoC/B,OAAO,CAAC,MAAM,CAAC,YAAY;IAU3B,OAAO,CAAC,MAAM,CAAC,WAAW;CAK7B"}
|
|
@@ -34,6 +34,103 @@ class PagePreview extends preview_1.Preview {
|
|
|
34
34
|
const difficulty = new difficulty_1.Difficulty(row.technicalRating, row.waterRating, row.timeRating, row.riskRating);
|
|
35
35
|
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], aka ?? [], difficulty, mapData, row.url ?? null, PagePreview.parsePermit(row.permits));
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Validates result has page preview fields and applies PagePreview.prototype.
|
|
39
|
+
* Expects difficulty as plain object with technical, water, time, risk (optional).
|
|
40
|
+
*/
|
|
41
|
+
static fromResult(result) {
|
|
42
|
+
if (result == null || typeof result !== 'object') {
|
|
43
|
+
throw new Error('PagePreview result must be an object');
|
|
44
|
+
}
|
|
45
|
+
const r = result;
|
|
46
|
+
PagePreview.assertString(r, 'id');
|
|
47
|
+
PagePreview.assertString(r, 'title');
|
|
48
|
+
PagePreview.assertSource(r, 'source');
|
|
49
|
+
PagePreview.assertStringArray(r, 'regions');
|
|
50
|
+
PagePreview.assertStringArray(r, 'aka');
|
|
51
|
+
PagePreview.assertDifficulty(r, 'difficulty');
|
|
52
|
+
PagePreview.assertNullableString(r, 'mapData');
|
|
53
|
+
PagePreview.assertNullableString(r, 'externalLink');
|
|
54
|
+
PagePreview.assertNullableString(r, 'imageUrl');
|
|
55
|
+
PagePreview.assertNullableNumber(r, 'rating');
|
|
56
|
+
PagePreview.assertNullableNumber(r, 'ratingCount');
|
|
57
|
+
PagePreview.assertPermit(r, 'permit');
|
|
58
|
+
const diff = r.difficulty;
|
|
59
|
+
r.difficulty = new difficulty_1.Difficulty(diff.technical, diff.water, diff.time, diff.risk);
|
|
60
|
+
Object.setPrototypeOf(r, PagePreview.prototype);
|
|
61
|
+
return r;
|
|
62
|
+
}
|
|
63
|
+
static assertString(obj, key) {
|
|
64
|
+
const v = obj[key];
|
|
65
|
+
if (typeof v !== 'string') {
|
|
66
|
+
throw new Error(`PagePreview.${key} must be a string, got: ${typeof v}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static assertNullableString(obj, key) {
|
|
70
|
+
const v = obj[key];
|
|
71
|
+
if (v !== null && v !== undefined && typeof v !== 'string') {
|
|
72
|
+
throw new Error(`PagePreview.${key} must be string or null, got: ${typeof v}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
static assertNullableNumber(obj, key) {
|
|
76
|
+
const v = obj[key];
|
|
77
|
+
if (v !== null && v !== undefined && (typeof v !== 'number' || Number.isNaN(v))) {
|
|
78
|
+
throw new Error(`PagePreview.${key} must be number or null, got: ${typeof v}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
static assertSource(obj, key) {
|
|
82
|
+
const v = obj[key];
|
|
83
|
+
if (v !== pageDataSource_1.PageDataSource.Ropewiki) {
|
|
84
|
+
throw new Error(`PagePreview.${key} must be PageDataSource, got: ${JSON.stringify(v)}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
static assertStringArray(obj, key) {
|
|
88
|
+
const v = obj[key];
|
|
89
|
+
if (!Array.isArray(v)) {
|
|
90
|
+
throw new Error(`PagePreview.${key} must be an array, got: ${typeof v}`);
|
|
91
|
+
}
|
|
92
|
+
for (let i = 0; i < v.length; i++) {
|
|
93
|
+
if (typeof v[i] !== 'string') {
|
|
94
|
+
throw new Error(`PagePreview.${key}[${i}] must be a string`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
static assertDifficulty(obj, key) {
|
|
99
|
+
const v = obj[key];
|
|
100
|
+
if (v == null || typeof v !== 'object') {
|
|
101
|
+
throw new Error(`PagePreview.${key} must be an object`);
|
|
102
|
+
}
|
|
103
|
+
const d = v;
|
|
104
|
+
if (d.technical !== undefined &&
|
|
105
|
+
d.technical !== null &&
|
|
106
|
+
typeof d.technical !== 'string') {
|
|
107
|
+
throw new Error('PagePreview.difficulty.technical must be string or null');
|
|
108
|
+
}
|
|
109
|
+
if (d.water !== undefined &&
|
|
110
|
+
d.water !== null &&
|
|
111
|
+
typeof d.water !== 'string') {
|
|
112
|
+
throw new Error('PagePreview.difficulty.water must be string or null');
|
|
113
|
+
}
|
|
114
|
+
if (d.time !== undefined &&
|
|
115
|
+
d.time !== null &&
|
|
116
|
+
typeof d.time !== 'string') {
|
|
117
|
+
throw new Error('PagePreview.difficulty.time must be string or null');
|
|
118
|
+
}
|
|
119
|
+
if (d.risk !== undefined &&
|
|
120
|
+
d.risk !== null &&
|
|
121
|
+
typeof d.risk !== 'string') {
|
|
122
|
+
throw new Error('PagePreview.difficulty.risk must be string or null');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
static assertPermit(obj, key) {
|
|
126
|
+
const v = obj[key];
|
|
127
|
+
if (v !== null && v !== undefined && typeof v !== 'string') {
|
|
128
|
+
throw new Error(`PagePreview.${key} must be string or null, got: ${typeof v}`);
|
|
129
|
+
}
|
|
130
|
+
if (v != null && !Object.values(permitStatus_1.PermitStatus).includes(v)) {
|
|
131
|
+
throw new Error(`PagePreview.${key} must be PermitStatus or null, got: ${JSON.stringify(v)}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
37
134
|
static parsePermit(value) {
|
|
38
135
|
if (value == null || value === '')
|
|
39
136
|
return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PagePreview } from './pagePreview';
|
|
2
|
-
import { RegionPreview } from './regionPreview';
|
|
1
|
+
import type { PagePreview } from './pagePreview';
|
|
2
|
+
import type { RegionPreview } from './regionPreview';
|
|
3
3
|
export declare enum PreviewType {
|
|
4
4
|
Page = "page",
|
|
5
5
|
Region = "region"
|
|
@@ -13,5 +13,10 @@ export declare abstract class Preview {
|
|
|
13
13
|
isPagePreview(): this is PagePreview;
|
|
14
14
|
/** Type guard: narrows this to RegionPreview. */
|
|
15
15
|
isRegionPreview(): this is RegionPreview;
|
|
16
|
+
/**
|
|
17
|
+
* Validates result has previewType and delegates to PagePreview.fromResult or
|
|
18
|
+
* RegionPreview.fromResult. Returns the same object with the appropriate prototype.
|
|
19
|
+
*/
|
|
20
|
+
static fromResult(result: unknown): Preview;
|
|
16
21
|
}
|
|
17
22
|
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/types/previews/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/types/previews/preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,oBAAY,WAAW;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,8BAAsB,OAAO;IACzB,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAE3C,+CAA+C;IAC/C,aAAa,IAAI,IAAI,IAAI,WAAW;IAIpC,iDAAiD;IACjD,eAAe,IAAI,IAAI,IAAI,aAAa;IAIxC;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;CAkB9C"}
|
|
@@ -18,5 +18,25 @@ class Preview {
|
|
|
18
18
|
isRegionPreview() {
|
|
19
19
|
return this.previewType === PreviewType.Region;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Validates result has previewType and delegates to PagePreview.fromResult or
|
|
23
|
+
* RegionPreview.fromResult. Returns the same object with the appropriate prototype.
|
|
24
|
+
*/
|
|
25
|
+
static fromResult(result) {
|
|
26
|
+
if (result == null || typeof result !== 'object') {
|
|
27
|
+
throw new Error('Preview result must be an object');
|
|
28
|
+
}
|
|
29
|
+
const obj = result;
|
|
30
|
+
const previewType = obj.previewType;
|
|
31
|
+
if (previewType !== PreviewType.Page && previewType !== PreviewType.Region) {
|
|
32
|
+
throw new Error(`Preview result must have previewType "page" or "region", got: ${JSON.stringify(previewType)}`);
|
|
33
|
+
}
|
|
34
|
+
if (previewType === PreviewType.Page) {
|
|
35
|
+
const { PagePreview: PagePreviewClass } = require('./pagePreview');
|
|
36
|
+
return PagePreviewClass.fromResult(result);
|
|
37
|
+
}
|
|
38
|
+
const { RegionPreview: RegionPreviewClass } = require('./regionPreview');
|
|
39
|
+
return RegionPreviewClass.fromResult(result);
|
|
40
|
+
}
|
|
21
41
|
}
|
|
22
42
|
exports.Preview = Preview;
|
|
@@ -10,5 +10,14 @@ export declare class RegionPreview extends Preview {
|
|
|
10
10
|
imageUrl: string | null;
|
|
11
11
|
source: PageDataSource;
|
|
12
12
|
constructor(id: string, name: string, parents: string[], pageCount: number, regionCount: number, imageUrl: string | null, source: PageDataSource);
|
|
13
|
+
/**
|
|
14
|
+
* Validates result has region preview fields and applies RegionPreview.prototype.
|
|
15
|
+
*/
|
|
16
|
+
static fromResult(result: unknown): RegionPreview;
|
|
17
|
+
private static assertString;
|
|
18
|
+
private static assertNullableString;
|
|
19
|
+
private static assertNumber;
|
|
20
|
+
private static assertStringArray;
|
|
21
|
+
private static assertSource;
|
|
13
22
|
}
|
|
14
23
|
//# sourceMappingURL=regionPreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regionPreview.d.ts","sourceRoot":"","sources":["../../../src/types/previews/regionPreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEjD,qBAAa,aAAc,SAAQ,OAAO;IACtC,QAAQ,CAAC,WAAW,sBAAsB;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;gBAGnB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"regionPreview.d.ts","sourceRoot":"","sources":["../../../src/types/previews/regionPreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEjD,qBAAa,aAAc,SAAQ,OAAO;IACtC,QAAQ,CAAC,WAAW,sBAAsB;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;gBAGnB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,cAAc;IAY1B;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa;IAgBjD,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAOnC,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAYhC,OAAO,CAAC,MAAM,CAAC,YAAY;CAQ9B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RegionPreview = void 0;
|
|
4
|
+
const pageDataSource_1 = require("../pageDataSource");
|
|
4
5
|
const preview_1 = require("./preview");
|
|
5
6
|
class RegionPreview extends preview_1.Preview {
|
|
6
7
|
constructor(id, name, parents, pageCount, regionCount, imageUrl, source) {
|
|
@@ -14,5 +15,58 @@ class RegionPreview extends preview_1.Preview {
|
|
|
14
15
|
this.imageUrl = imageUrl;
|
|
15
16
|
this.source = source;
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates result has region preview fields and applies RegionPreview.prototype.
|
|
20
|
+
*/
|
|
21
|
+
static fromResult(result) {
|
|
22
|
+
if (result == null || typeof result !== 'object') {
|
|
23
|
+
throw new Error('RegionPreview result must be an object');
|
|
24
|
+
}
|
|
25
|
+
const r = result;
|
|
26
|
+
RegionPreview.assertString(r, 'id');
|
|
27
|
+
RegionPreview.assertString(r, 'name');
|
|
28
|
+
RegionPreview.assertStringArray(r, 'parents');
|
|
29
|
+
RegionPreview.assertNumber(r, 'pageCount');
|
|
30
|
+
RegionPreview.assertNumber(r, 'regionCount');
|
|
31
|
+
RegionPreview.assertNullableString(r, 'imageUrl');
|
|
32
|
+
RegionPreview.assertSource(r, 'source');
|
|
33
|
+
Object.setPrototypeOf(r, RegionPreview.prototype);
|
|
34
|
+
return r;
|
|
35
|
+
}
|
|
36
|
+
static assertString(obj, key) {
|
|
37
|
+
const v = obj[key];
|
|
38
|
+
if (typeof v !== 'string') {
|
|
39
|
+
throw new Error(`RegionPreview.${key} must be a string, got: ${typeof v}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
static assertNullableString(obj, key) {
|
|
43
|
+
const v = obj[key];
|
|
44
|
+
if (v !== null && v !== undefined && typeof v !== 'string') {
|
|
45
|
+
throw new Error(`RegionPreview.${key} must be string or null, got: ${typeof v}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
static assertNumber(obj, key) {
|
|
49
|
+
const v = obj[key];
|
|
50
|
+
if (typeof v !== 'number' || Number.isNaN(v)) {
|
|
51
|
+
throw new Error(`RegionPreview.${key} must be a number, got: ${typeof v}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static assertStringArray(obj, key) {
|
|
55
|
+
const v = obj[key];
|
|
56
|
+
if (!Array.isArray(v)) {
|
|
57
|
+
throw new Error(`RegionPreview.${key} must be an array, got: ${typeof v}`);
|
|
58
|
+
}
|
|
59
|
+
for (let i = 0; i < v.length; i++) {
|
|
60
|
+
if (typeof v[i] !== 'string') {
|
|
61
|
+
throw new Error(`RegionPreview.${key}[${i}] must be a string`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
static assertSource(obj, key) {
|
|
66
|
+
const v = obj[key];
|
|
67
|
+
if (v !== pageDataSource_1.PageDataSource.Ropewiki) {
|
|
68
|
+
throw new Error(`RegionPreview.${key} must be PageDataSource, got: ${JSON.stringify(v)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
17
71
|
}
|
|
18
72
|
exports.RegionPreview = RegionPreview;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminator for cursor-paginated result types. Used in response body so
|
|
3
|
+
* CursorPaginationResults.fromResponseBody can route to the correct parser.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ResultType {
|
|
6
|
+
Search = "search",
|
|
7
|
+
RopewikiRegionImages = "ropewikiRegionImages",
|
|
8
|
+
RopewikiRegionPreviews = "ropewikiRegionPreviews"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validated shape (results + nextCursor) passed to specific Result class's fromResponseBody
|
|
12
|
+
* after CursorPaginationResults.fromResponseBody has validated the full body.
|
|
13
|
+
*/
|
|
14
|
+
export type CursorPaginationResponseParsed = {
|
|
15
|
+
results: unknown[];
|
|
16
|
+
nextCursor: string | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Base type for cursor-paginated API results (results array + nextCursor + resultType).
|
|
20
|
+
* fromResponseBody validates body (resultType, results, nextCursor) then delegates to
|
|
21
|
+
* the corresponding Result class's fromResponseBody with the validated shape.
|
|
22
|
+
*/
|
|
23
|
+
export declare abstract class CursorPaginationResults<R = unknown> {
|
|
24
|
+
readonly results: R[];
|
|
25
|
+
readonly nextCursor: string | null;
|
|
26
|
+
readonly resultType: ResultType;
|
|
27
|
+
constructor(results: R[], nextCursor: string | null, resultType: ResultType);
|
|
28
|
+
/**
|
|
29
|
+
* Validates body (object, resultType, results array, nextCursor), then delegates to
|
|
30
|
+
* the corresponding Result class's fromResponseBody with { results, nextCursor }.
|
|
31
|
+
*/
|
|
32
|
+
static fromResponseBody(body: unknown): CursorPaginationResults;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=cursorPaginationResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursorPaginationResults.d.ts","sourceRoot":"","sources":["../../../src/types/results/cursorPaginationResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,oBAAoB,yBAAyB;IAC7C,sBAAsB,2BAA2B;CACpD;AAED;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG;IACzC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,8BAAsB,uBAAuB,CAAC,CAAC,GAAG,OAAO;aAEjC,OAAO,EAAE,CAAC,EAAE;aACZ,UAAU,EAAE,MAAM,GAAG,IAAI;aACzB,UAAU,EAAE,UAAU;gBAFtB,OAAO,EAAE,CAAC,EAAE,EACZ,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,UAAU,EAAE,UAAU;IAG1C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,uBAAuB;CAgDlE"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CursorPaginationResults = exports.ResultType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Discriminator for cursor-paginated result types. Used in response body so
|
|
6
|
+
* CursorPaginationResults.fromResponseBody can route to the correct parser.
|
|
7
|
+
*/
|
|
8
|
+
var ResultType;
|
|
9
|
+
(function (ResultType) {
|
|
10
|
+
ResultType["Search"] = "search";
|
|
11
|
+
ResultType["RopewikiRegionImages"] = "ropewikiRegionImages";
|
|
12
|
+
ResultType["RopewikiRegionPreviews"] = "ropewikiRegionPreviews";
|
|
13
|
+
})(ResultType || (exports.ResultType = ResultType = {}));
|
|
14
|
+
/**
|
|
15
|
+
* Base type for cursor-paginated API results (results array + nextCursor + resultType).
|
|
16
|
+
* fromResponseBody validates body (resultType, results, nextCursor) then delegates to
|
|
17
|
+
* the corresponding Result class's fromResponseBody with the validated shape.
|
|
18
|
+
*/
|
|
19
|
+
class CursorPaginationResults {
|
|
20
|
+
constructor(results, nextCursor, resultType) {
|
|
21
|
+
this.results = results;
|
|
22
|
+
this.nextCursor = nextCursor;
|
|
23
|
+
this.resultType = resultType;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validates body (object, resultType, results array, nextCursor), then delegates to
|
|
27
|
+
* the corresponding Result class's fromResponseBody with { results, nextCursor }.
|
|
28
|
+
*/
|
|
29
|
+
static fromResponseBody(body) {
|
|
30
|
+
if (body == null || typeof body !== 'object') {
|
|
31
|
+
throw new Error('Response body must be an object');
|
|
32
|
+
}
|
|
33
|
+
const b = body;
|
|
34
|
+
if (!('resultType' in b)) {
|
|
35
|
+
throw new Error('Response body must have resultType');
|
|
36
|
+
}
|
|
37
|
+
const resultType = b.resultType;
|
|
38
|
+
const valid = Object.values(ResultType);
|
|
39
|
+
if (typeof resultType !== 'string' || !valid.includes(resultType)) {
|
|
40
|
+
throw new Error(`Response body.resultType must be one of [${valid.join(', ')}], got: ${JSON.stringify(resultType)}`);
|
|
41
|
+
}
|
|
42
|
+
if (!('results' in b)) {
|
|
43
|
+
throw new Error('Response body must have results');
|
|
44
|
+
}
|
|
45
|
+
const resultsRaw = b.results;
|
|
46
|
+
if (!Array.isArray(resultsRaw)) {
|
|
47
|
+
throw new Error('Response body.results must be an array');
|
|
48
|
+
}
|
|
49
|
+
let nextCursor = null;
|
|
50
|
+
if ('nextCursor' in b && b.nextCursor != null) {
|
|
51
|
+
if (typeof b.nextCursor !== 'string') {
|
|
52
|
+
throw new Error('Response body.nextCursor must be a string or null');
|
|
53
|
+
}
|
|
54
|
+
nextCursor = b.nextCursor;
|
|
55
|
+
}
|
|
56
|
+
const validated = {
|
|
57
|
+
results: resultsRaw,
|
|
58
|
+
nextCursor,
|
|
59
|
+
};
|
|
60
|
+
switch (resultType) {
|
|
61
|
+
case ResultType.Search: {
|
|
62
|
+
const { SearchResults } = require('../api/search/searchResults');
|
|
63
|
+
return SearchResults.fromResponseBody(validated);
|
|
64
|
+
}
|
|
65
|
+
case ResultType.RopewikiRegionPreviews: {
|
|
66
|
+
const { RopewikiRegionPreviewsResult } = require('../api/getRopewikiRegionPreviews/ropewikiRegionPreviewsResult');
|
|
67
|
+
return RopewikiRegionPreviewsResult.fromResponseBody(validated);
|
|
68
|
+
}
|
|
69
|
+
case ResultType.RopewikiRegionImages: {
|
|
70
|
+
const { RopewikiRegionImagesResult } = require('../api/getRopewikiRegionImages/ropewikiRegionImagesResult');
|
|
71
|
+
return RopewikiRegionImagesResult.fromResponseBody(validated);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.CursorPaginationResults = CursorPaginationResults;
|