ropegeo-common 1.2.1 → 1.2.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/types/api/getRopewikiRegionImages/regionImagesCursor.d.ts +7 -5
- package/dist/types/api/getRopewikiRegionImages/regionImagesCursor.d.ts.map +1 -1
- package/dist/types/api/getRopewikiRegionImages/regionImagesCursor.js +29 -9
- package/dist/types/api/getRopewikiRegionPreviews/regionPreviewsCursor.d.ts +7 -5
- package/dist/types/api/getRopewikiRegionPreviews/regionPreviewsCursor.d.ts.map +1 -1
- package/dist/types/api/getRopewikiRegionPreviews/regionPreviewsCursor.js +29 -9
- package/package.json +1 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Cursor logic will be implemented in Webscraper.
|
|
2
|
+
* Cursor for region images pagination. Encodes to base64url for the nextCursor string.
|
|
4
3
|
*/
|
|
5
4
|
export declare class RegionImagesCursor {
|
|
6
|
-
readonly
|
|
7
|
-
|
|
5
|
+
readonly sortKey: number;
|
|
6
|
+
readonly pageId: string;
|
|
7
|
+
readonly imageId: string;
|
|
8
|
+
constructor(sortKey: number, pageId: string, imageId: string);
|
|
8
9
|
encodeBase64(): string;
|
|
9
10
|
/**
|
|
10
|
-
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
11
|
+
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
12
|
+
* or does not represent a valid RegionImagesCursor shape.
|
|
11
13
|
*/
|
|
12
14
|
static decodeBase64(encoded: string): RegionImagesCursor;
|
|
13
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regionImagesCursor.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/regionImagesCursor.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"regionImagesCursor.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/regionImagesCursor.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,qBAAa,kBAAkB;aAEP,OAAO,EAAE,MAAM;aACf,MAAM,EAAE,MAAM;aACd,OAAO,EAAE,MAAM;gBAFf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM;IAGnC,YAAY,IAAI,MAAM;IAWtB;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB;CA0C3D"}
|
|
@@ -5,18 +5,24 @@ exports.RegionImagesCursor = void 0;
|
|
|
5
5
|
const ENCODING = 'utf8';
|
|
6
6
|
const BASE64URL = 'base64url';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Cursor logic will be implemented in Webscraper.
|
|
8
|
+
* Cursor for region images pagination. Encodes to base64url for the nextCursor string.
|
|
10
9
|
*/
|
|
11
10
|
class RegionImagesCursor {
|
|
12
|
-
constructor(
|
|
13
|
-
this.
|
|
11
|
+
constructor(sortKey, pageId, imageId) {
|
|
12
|
+
this.sortKey = sortKey;
|
|
13
|
+
this.pageId = pageId;
|
|
14
|
+
this.imageId = imageId;
|
|
14
15
|
}
|
|
15
16
|
encodeBase64() {
|
|
16
|
-
return Buffer.from(JSON.stringify({
|
|
17
|
+
return Buffer.from(JSON.stringify({
|
|
18
|
+
sortKey: this.sortKey,
|
|
19
|
+
pageId: this.pageId,
|
|
20
|
+
imageId: this.imageId,
|
|
21
|
+
}), ENCODING).toString(BASE64URL);
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
|
-
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
24
|
+
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
25
|
+
* or does not represent a valid RegionImagesCursor shape.
|
|
20
26
|
*/
|
|
21
27
|
static decodeBase64(encoded) {
|
|
22
28
|
if (typeof encoded !== 'string' || encoded === '') {
|
|
@@ -31,11 +37,25 @@ class RegionImagesCursor {
|
|
|
31
37
|
const message = err instanceof Error ? err.message : String(err);
|
|
32
38
|
throw new Error(`Invalid region images cursor encoding: ${message}`);
|
|
33
39
|
}
|
|
34
|
-
if (decoded == null ||
|
|
35
|
-
|
|
40
|
+
if (decoded == null ||
|
|
41
|
+
typeof decoded !== 'object' ||
|
|
42
|
+
!('sortKey' in decoded) ||
|
|
43
|
+
!('pageId' in decoded) ||
|
|
44
|
+
!('imageId' in decoded)) {
|
|
45
|
+
throw new Error('Region images cursor must be an object with sortKey, pageId, and imageId');
|
|
36
46
|
}
|
|
37
47
|
const obj = decoded;
|
|
38
|
-
|
|
48
|
+
const sortKey = Number(obj.sortKey);
|
|
49
|
+
if (Number.isNaN(sortKey)) {
|
|
50
|
+
throw new Error(`Region images cursor sortKey must be a number, got: ${JSON.stringify(obj.sortKey)}`);
|
|
51
|
+
}
|
|
52
|
+
if (typeof obj.pageId !== 'string') {
|
|
53
|
+
throw new Error(`Region images cursor pageId must be a string, got: ${typeof obj.pageId}`);
|
|
54
|
+
}
|
|
55
|
+
if (typeof obj.imageId !== 'string') {
|
|
56
|
+
throw new Error(`Region images cursor imageId must be a string, got: ${typeof obj.imageId}`);
|
|
57
|
+
}
|
|
58
|
+
return new RegionImagesCursor(sortKey, obj.pageId, obj.imageId);
|
|
39
59
|
}
|
|
40
60
|
}
|
|
41
61
|
exports.RegionImagesCursor = RegionImagesCursor;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Cursor logic will be implemented in Webscraper.
|
|
2
|
+
* Cursor for region previews pagination. Encodes to base64url for the nextCursor string.
|
|
4
3
|
*/
|
|
5
4
|
export declare class RegionPreviewsCursor {
|
|
6
|
-
readonly
|
|
7
|
-
|
|
5
|
+
readonly sortKey: number;
|
|
6
|
+
readonly type: string;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
constructor(sortKey: number, type: string, id: string);
|
|
8
9
|
encodeBase64(): string;
|
|
9
10
|
/**
|
|
10
|
-
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
11
|
+
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
12
|
+
* or does not represent a valid RegionPreviewsCursor shape.
|
|
11
13
|
*/
|
|
12
14
|
static decodeBase64(encoded: string): RegionPreviewsCursor;
|
|
13
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regionPreviewsCursor.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionPreviews/regionPreviewsCursor.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"regionPreviewsCursor.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionPreviews/regionPreviewsCursor.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,qBAAa,oBAAoB;aAET,OAAO,EAAE,MAAM;aACf,IAAI,EAAE,MAAM;aACZ,EAAE,EAAE,MAAM;gBAFV,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM;IAG9B,YAAY,IAAI,MAAM;IAWtB;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;CA0C7D"}
|
|
@@ -5,18 +5,24 @@ exports.RegionPreviewsCursor = void 0;
|
|
|
5
5
|
const ENCODING = 'utf8';
|
|
6
6
|
const BASE64URL = 'base64url';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Cursor logic will be implemented in Webscraper.
|
|
8
|
+
* Cursor for region previews pagination. Encodes to base64url for the nextCursor string.
|
|
10
9
|
*/
|
|
11
10
|
class RegionPreviewsCursor {
|
|
12
|
-
constructor(
|
|
13
|
-
this.
|
|
11
|
+
constructor(sortKey, type, id) {
|
|
12
|
+
this.sortKey = sortKey;
|
|
13
|
+
this.type = type;
|
|
14
|
+
this.id = id;
|
|
14
15
|
}
|
|
15
16
|
encodeBase64() {
|
|
16
|
-
return Buffer.from(JSON.stringify({
|
|
17
|
+
return Buffer.from(JSON.stringify({
|
|
18
|
+
sortKey: this.sortKey,
|
|
19
|
+
type: this.type,
|
|
20
|
+
id: this.id,
|
|
21
|
+
}), ENCODING).toString(BASE64URL);
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
|
-
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
24
|
+
* Decodes a base64url-encoded cursor string. Throws if the string is invalid
|
|
25
|
+
* or does not represent a valid RegionPreviewsCursor shape.
|
|
20
26
|
*/
|
|
21
27
|
static decodeBase64(encoded) {
|
|
22
28
|
if (typeof encoded !== 'string' || encoded === '') {
|
|
@@ -31,11 +37,25 @@ class RegionPreviewsCursor {
|
|
|
31
37
|
const message = err instanceof Error ? err.message : String(err);
|
|
32
38
|
throw new Error(`Invalid region previews cursor encoding: ${message}`);
|
|
33
39
|
}
|
|
34
|
-
if (decoded == null ||
|
|
35
|
-
|
|
40
|
+
if (decoded == null ||
|
|
41
|
+
typeof decoded !== 'object' ||
|
|
42
|
+
!('sortKey' in decoded) ||
|
|
43
|
+
!('type' in decoded) ||
|
|
44
|
+
!('id' in decoded)) {
|
|
45
|
+
throw new Error('Region previews cursor must be an object with sortKey, type, and id');
|
|
36
46
|
}
|
|
37
47
|
const obj = decoded;
|
|
38
|
-
|
|
48
|
+
const sortKey = Number(obj.sortKey);
|
|
49
|
+
if (Number.isNaN(sortKey)) {
|
|
50
|
+
throw new Error(`Region previews cursor sortKey must be a number, got: ${JSON.stringify(obj.sortKey)}`);
|
|
51
|
+
}
|
|
52
|
+
if (typeof obj.type !== 'string') {
|
|
53
|
+
throw new Error(`Region previews cursor type must be a string, got: ${typeof obj.type}`);
|
|
54
|
+
}
|
|
55
|
+
if (typeof obj.id !== 'string') {
|
|
56
|
+
throw new Error(`Region previews cursor id must be a string, got: ${typeof obj.id}`);
|
|
57
|
+
}
|
|
58
|
+
return new RegionPreviewsCursor(sortKey, obj.type, obj.id);
|
|
39
59
|
}
|
|
40
60
|
}
|
|
41
61
|
exports.RegionPreviewsCursor = RegionPreviewsCursor;
|