ropegeo-common 1.2.5 → 1.2.6

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
@@ -11,6 +11,7 @@ export type { RopewikiImageView } from './types/api/getRopewikiPageView/ropewiki
11
11
  export type { RopewikiBetaSectionView } from './types/api/getRopewikiPageView/ropewikiBetaSectionView';
12
12
  export type { RopewikiPageView } from './types/api/getRopewikiPageView/ropewikiPageView';
13
13
  export { Cursor, CursorType } from './types/cursors/cursor';
14
+ export { CursorPaginationParams } from './types/params/cursorPaginationParams';
14
15
  export { SearchCursor } from './types/cursors/searchCursor';
15
16
  export type { SearchCursorType } from './types/cursors/searchCursor';
16
17
  export { SearchParams } from './types/api/search/searchParams';
@@ -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,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AE,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.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.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");
@@ -28,6 +28,8 @@ Object.defineProperty(exports, "RoutesParams", { enumerable: true, get: function
28
28
  var cursor_1 = require("./types/cursors/cursor");
29
29
  Object.defineProperty(exports, "Cursor", { enumerable: true, get: function () { return cursor_1.Cursor; } });
30
30
  Object.defineProperty(exports, "CursorType", { enumerable: true, get: function () { return cursor_1.CursorType; } });
31
+ var cursorPaginationParams_1 = require("./types/params/cursorPaginationParams");
32
+ Object.defineProperty(exports, "CursorPaginationParams", { enumerable: true, get: function () { return cursorPaginationParams_1.CursorPaginationParams; } });
31
33
  var searchCursor_1 = require("./types/cursors/searchCursor");
32
34
  Object.defineProperty(exports, "SearchCursor", { enumerable: true, get: function () { return searchCursor_1.SearchCursor; } });
33
35
  var searchParams_1 = require("./types/api/search/searchParams");
@@ -1,18 +1,13 @@
1
+ import { CursorPaginationParams } from '../../params/cursorPaginationParams';
1
2
  import { RegionImagesCursor } from '../../cursors/regionImagesCursor';
2
3
  /**
3
4
  * Validated params for getRopewikiRegionImages (GET /ropewiki/region/{id}/images).
4
5
  * Cursor is stored decoded (RegionImagesCursor | null).
5
6
  * The constructor accepts an encoded cursor string and decodes it.
6
7
  */
7
- export declare class RopewikiRegionImagesParams {
8
- readonly limit: number;
9
- readonly cursor: RegionImagesCursor | null;
10
- constructor(limit: number, cursorEncoded: string | null);
11
- /**
12
- * Returns an object suitable for use as query string parameters.
13
- * Cursor is encoded for the query string.
14
- */
15
- toQueryStringParams(): Record<string, string>;
8
+ export declare class RopewikiRegionImagesParams extends CursorPaginationParams<RegionImagesCursor> {
9
+ constructor(limit: number, cursorEncoded?: string);
10
+ withCursor(cursorEncoded: string | null): RopewikiRegionImagesParams;
16
11
  /**
17
12
  * Parses query string parameters and returns validated params.
18
13
  * Validation is performed by the constructor.
@@ -1 +1 @@
1
- {"version":3,"file":"ropewikiRegionImagesParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/ropewikiRegionImagesParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAItE;;;;GAIG;AACH,qBAAa,0BAA0B;IACnC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;gBAEtC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IA0BvD;;;OAGG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAU7C;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,0BAA0B;CAOhC"}
1
+ {"version":3,"file":"ropewikiRegionImagesParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionImages/ropewikiRegionImagesParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAItE;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,sBAAsB,CAAC,kBAAkB,CAAC;gBAC1E,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM;IAsBjD,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,0BAA0B;IAOpE;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,0BAA0B;CAOhC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RopewikiRegionImagesParams = void 0;
4
+ const cursorPaginationParams_1 = require("../../params/cursorPaginationParams");
4
5
  const regionImagesCursor_1 = require("../../cursors/regionImagesCursor");
5
6
  const DEFAULT_LIMIT = 20;
6
7
  /**
@@ -8,7 +9,7 @@ const DEFAULT_LIMIT = 20;
8
9
  * Cursor is stored decoded (RegionImagesCursor | null).
9
10
  * The constructor accepts an encoded cursor string and decodes it.
10
11
  */
11
- class RopewikiRegionImagesParams {
12
+ class RopewikiRegionImagesParams extends cursorPaginationParams_1.CursorPaginationParams {
12
13
  constructor(limit, cursorEncoded) {
13
14
  const limitNum = Number(limit);
14
15
  if (Number.isNaN(limitNum) ||
@@ -16,31 +17,17 @@ class RopewikiRegionImagesParams {
16
17
  limitNum < 1) {
17
18
  throw new Error('Query parameter "limit" must be a whole number greater than 0');
18
19
  }
19
- this.limit = limit;
20
- if (cursorEncoded === null || cursorEncoded === '') {
21
- this.cursor = null;
22
- }
23
- else {
24
- try {
25
- this.cursor = regionImagesCursor_1.RegionImagesCursor.decodeBase64(cursorEncoded);
26
- }
27
- catch {
28
- throw new Error('Invalid or malformed query parameter: cursor');
29
- }
20
+ const cursorNorm = cursorEncoded === undefined || cursorEncoded === null || cursorEncoded === ''
21
+ ? null
22
+ : cursorEncoded;
23
+ let cursor = null;
24
+ if (cursorNorm !== null) {
25
+ cursor = regionImagesCursor_1.RegionImagesCursor.decodeBase64(cursorNorm);
30
26
  }
27
+ super(limitNum, cursor);
31
28
  }
32
- /**
33
- * Returns an object suitable for use as query string parameters.
34
- * Cursor is encoded for the query string.
35
- */
36
- toQueryStringParams() {
37
- const params = {
38
- limit: String(this.limit),
39
- };
40
- if (this.cursor !== null) {
41
- params.cursor = this.cursor.encodeBase64();
42
- }
43
- return params;
29
+ withCursor(cursorEncoded) {
30
+ return new RopewikiRegionImagesParams(this.limit, cursorEncoded === null || cursorEncoded === '' ? undefined : cursorEncoded);
44
31
  }
45
32
  /**
46
33
  * Parses query string parameters and returns validated params.
@@ -50,7 +37,7 @@ class RopewikiRegionImagesParams {
50
37
  const limitParam = q.limit ?? q.Limit ?? '';
51
38
  const limit = limitParam === '' ? DEFAULT_LIMIT : Number(limitParam);
52
39
  const cursorRaw = (q.cursor ?? q.Cursor ?? '').trim();
53
- const cursorEncoded = cursorRaw === '' ? null : cursorRaw;
40
+ const cursorEncoded = cursorRaw === '' ? undefined : cursorRaw;
54
41
  return new RopewikiRegionImagesParams(limit, cursorEncoded);
55
42
  }
56
43
  }
@@ -1,18 +1,13 @@
1
+ import { CursorPaginationParams } from '../../params/cursorPaginationParams';
1
2
  import { RegionPreviewsCursor } from '../../cursors/regionPreviewsCursor';
2
3
  /**
3
4
  * Validated params for getRopewikiRegionPreviews (GET /ropewiki/region/{id}/previews).
4
5
  * Cursor is stored decoded (RegionPreviewsCursor | null).
5
6
  * The constructor accepts an encoded cursor string and decodes it.
6
7
  */
7
- export declare class RopewikiRegionPreviewsParams {
8
- readonly limit: number;
9
- readonly cursor: RegionPreviewsCursor | null;
10
- constructor(limit: number, cursorEncoded: string | null);
11
- /**
12
- * Returns an object suitable for use as query string parameters.
13
- * Cursor is encoded for the query string.
14
- */
15
- toQueryStringParams(): Record<string, string>;
8
+ export declare class RopewikiRegionPreviewsParams extends CursorPaginationParams<RegionPreviewsCursor> {
9
+ constructor(limit: number, cursorEncoded?: string);
10
+ withCursor(cursorEncoded: string | null): RopewikiRegionPreviewsParams;
16
11
  /**
17
12
  * Parses query string parameters and returns validated params.
18
13
  * Validation is performed by the constructor.
@@ -1 +1 @@
1
- {"version":3,"file":"ropewikiRegionPreviewsParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAI1E;;;;GAIG;AACH,qBAAa,4BAA4B;IACrC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;gBAExC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IA0BvD;;;OAGG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAU7C;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,4BAA4B;CAOlC"}
1
+ {"version":3,"file":"ropewikiRegionPreviewsParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAI1E;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,sBAAsB,CAAC,oBAAoB,CAAC;gBAC9E,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM;IAsBjD,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,4BAA4B;IAOtE;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,4BAA4B;CAOlC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RopewikiRegionPreviewsParams = void 0;
4
+ const cursorPaginationParams_1 = require("../../params/cursorPaginationParams");
4
5
  const regionPreviewsCursor_1 = require("../../cursors/regionPreviewsCursor");
5
6
  const DEFAULT_LIMIT = 20;
6
7
  /**
@@ -8,7 +9,7 @@ const DEFAULT_LIMIT = 20;
8
9
  * Cursor is stored decoded (RegionPreviewsCursor | null).
9
10
  * The constructor accepts an encoded cursor string and decodes it.
10
11
  */
11
- class RopewikiRegionPreviewsParams {
12
+ class RopewikiRegionPreviewsParams extends cursorPaginationParams_1.CursorPaginationParams {
12
13
  constructor(limit, cursorEncoded) {
13
14
  const limitNum = Number(limit);
14
15
  if (Number.isNaN(limitNum) ||
@@ -16,31 +17,17 @@ class RopewikiRegionPreviewsParams {
16
17
  limitNum < 1) {
17
18
  throw new Error('Query parameter "limit" must be a whole number greater than 0');
18
19
  }
19
- this.limit = limit;
20
- if (cursorEncoded === null || cursorEncoded === '') {
21
- this.cursor = null;
22
- }
23
- else {
24
- try {
25
- this.cursor = regionPreviewsCursor_1.RegionPreviewsCursor.decodeBase64(cursorEncoded);
26
- }
27
- catch {
28
- throw new Error('Invalid or malformed query parameter: cursor');
29
- }
20
+ const cursorNorm = cursorEncoded === undefined || cursorEncoded === null || cursorEncoded === ''
21
+ ? null
22
+ : cursorEncoded;
23
+ let cursor = null;
24
+ if (cursorNorm !== null) {
25
+ cursor = regionPreviewsCursor_1.RegionPreviewsCursor.decodeBase64(cursorNorm);
30
26
  }
27
+ super(limitNum, cursor);
31
28
  }
32
- /**
33
- * Returns an object suitable for use as query string parameters.
34
- * Cursor is encoded for the query string.
35
- */
36
- toQueryStringParams() {
37
- const params = {
38
- limit: String(this.limit),
39
- };
40
- if (this.cursor !== null) {
41
- params.cursor = this.cursor.encodeBase64();
42
- }
43
- return params;
29
+ withCursor(cursorEncoded) {
30
+ return new RopewikiRegionPreviewsParams(this.limit, cursorEncoded === null || cursorEncoded === '' ? undefined : cursorEncoded);
44
31
  }
45
32
  /**
46
33
  * Parses query string parameters and returns validated params.
@@ -50,7 +37,7 @@ class RopewikiRegionPreviewsParams {
50
37
  const limitParam = q.limit ?? q.Limit ?? '';
51
38
  const limit = limitParam === '' ? DEFAULT_LIMIT : Number(limitParam);
52
39
  const cursorRaw = (q.cursor ?? q.Cursor ?? '').trim();
53
- const cursorEncoded = cursorRaw === '' ? null : cursorRaw;
40
+ const cursorEncoded = cursorRaw === '' ? undefined : cursorRaw;
54
41
  return new RopewikiRegionPreviewsParams(limit, cursorEncoded);
55
42
  }
56
43
  }
@@ -11,9 +11,9 @@ export declare class RoutesParams {
11
11
  } | null;
12
12
  constructor(source: PageDataSource | undefined, regionId: string | undefined);
13
13
  /**
14
- * Returns an object suitable for use as query string parameters.
14
+ * Returns a URL-encoded query string.
15
15
  */
16
- toQueryStringParams(): Record<string, string>;
16
+ toQueryString(): string;
17
17
  /**
18
18
  * Parses query string parameters and returns validated params.
19
19
  * Validation is performed by the constructor.
@@ -1 +1 @@
1
- {"version":3,"file":"routesParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRoutes/routesParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,YAAY;IACrB,sEAAsE;IACtE,SAAgB,MAAM,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;gBAE1D,MAAM,EAAE,cAAc,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS;IAiB5E;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAU7C;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,YAAY;IAWf,OAAO,CAAC,MAAM,CAAC,WAAW;CAQ7B"}
1
+ {"version":3,"file":"routesParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRoutes/routesParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,YAAY;IACrB,sEAAsE;IACtE,SAAgB,MAAM,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;gBAE1D,MAAM,EAAE,cAAc,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS;IAiB5E;;OAEG;IACH,aAAa,IAAI,MAAM;IAUvB;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,YAAY;IAWf,OAAO,CAAC,MAAM,CAAC,WAAW;CAQ7B"}
@@ -21,16 +21,16 @@ class RoutesParams {
21
21
  : null;
22
22
  }
23
23
  /**
24
- * Returns an object suitable for use as query string parameters.
24
+ * Returns a URL-encoded query string.
25
25
  */
26
- toQueryStringParams() {
26
+ toQueryString() {
27
27
  if (this.region === null) {
28
- return {};
28
+ return '';
29
29
  }
30
- return {
30
+ return new URLSearchParams({
31
31
  source: this.region.source,
32
32
  region: this.region.id,
33
- };
33
+ }).toString();
34
34
  }
35
35
  /**
36
36
  * Parses query string parameters and returns validated params.
@@ -1,10 +1,11 @@
1
+ import { CursorPaginationParams } from '../../params/cursorPaginationParams';
1
2
  import { SearchCursor } from '../../cursors/searchCursor';
2
3
  export type SearchOrder = 'similarity' | 'quality';
3
4
  /**
4
5
  * Validated search parameters. Cursor is stored decoded (SearchCursor | null).
5
6
  * The constructor accepts an encoded cursor string and decodes it.
6
7
  */
7
- export declare class SearchParams {
8
+ export declare class SearchParams extends CursorPaginationParams<SearchCursor> {
8
9
  readonly name: string;
9
10
  readonly similarityThreshold: number;
10
11
  readonly includePages: boolean;
@@ -12,14 +13,12 @@ export declare class SearchParams {
12
13
  readonly includeAka: boolean;
13
14
  readonly regionId: string | null;
14
15
  readonly order: SearchOrder;
15
- readonly limit: number;
16
- readonly cursor: SearchCursor | null;
17
- constructor(name: string, similarityThreshold: number, includePages: boolean, includeRegions: boolean, includeAka: boolean, regionId: string | null, order: SearchOrder, limit: number, cursorEncoded: string | null);
16
+ constructor(name: string, similarityThreshold: number, includePages: boolean, includeRegions: boolean, includeAka: boolean, regionId: string | null, order: SearchOrder, limit: number, cursorEncoded?: string);
18
17
  /**
19
- * Returns an object suitable for use as query string parameters.
20
- * Cursor is encoded for the query string.
18
+ * Returns a URL-encoded query string. Cursor is encoded for the query string.
21
19
  */
22
- toQueryStringParams(): Record<string, string>;
20
+ toQueryString(): string;
21
+ withCursor(cursorEncoded: string | null): SearchParams;
23
22
  /**
24
23
  * Parses query string parameters and returns validated params.
25
24
  * Validation is performed by the constructor.
@@ -1 +1 @@
1
- {"version":3,"file":"searchParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/search/searchParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,CAAC;AAOnD;;;GAGG;AACH,qBAAa,YAAY;IACrB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,mBAAmB,EAAE,MAAM,CAAC;IAC5C,SAAgB,YAAY,EAAE,OAAO,CAAC;IACtC,SAAgB,cAAc,EAAE,OAAO,CAAC;IACxC,SAAgB,UAAU,EAAE,OAAO,CAAC;IACpC,SAAgB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;gBAGxC,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,EAC3B,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,EACvB,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GAAG,IAAI;IAqEhC;;;OAGG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAmB7C;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,YAAY;IA2Cf;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;CAY9B"}
1
+ {"version":3,"file":"searchParams.d.ts","sourceRoot":"","sources":["../../../../src/types/api/search/searchParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,CAAC;AAOnD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,sBAAsB,CAAC,YAAY,CAAC;IAClE,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,mBAAmB,EAAE,MAAM,CAAC;IAC5C,SAAgB,YAAY,EAAE,OAAO,CAAC;IACtC,SAAgB,cAAc,EAAE,OAAO,CAAC;IACxC,SAAgB,UAAU,EAAE,OAAO,CAAC;IACpC,SAAgB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAgB,KAAK,EAAE,WAAW,CAAC;gBAG/B,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,EAC3B,YAAY,EAAE,OAAO,EACrB,cAAc,EAAE,OAAO,EACvB,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM;IAkE1B;;OAEG;IACH,aAAa,IAAI,MAAM;IAmBvB,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY;IActD;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CACxB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,YAAY;IA2Cf;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;CAY9B"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SearchParams = void 0;
4
+ const cursorPaginationParams_1 = require("../../params/cursorPaginationParams");
4
5
  const searchCursor_1 = require("../../cursors/searchCursor");
5
6
  const DEFAULT_LIMIT = 20;
6
7
  /** UUID v4 format: 8-4-4-4-12 hex digits */
@@ -9,7 +10,7 @@ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12
9
10
  * Validated search parameters. Cursor is stored decoded (SearchCursor | null).
10
11
  * The constructor accepts an encoded cursor string and decodes it.
11
12
  */
12
- class SearchParams {
13
+ class SearchParams extends cursorPaginationParams_1.CursorPaginationParams {
13
14
  constructor(name, similarityThreshold, includePages, includeRegions, includeAka, regionId, order, limit, cursorEncoded) {
14
15
  if (typeof name !== 'string' || name.trim() === '') {
15
16
  throw new Error('Missing or empty required query parameter: name');
@@ -39,6 +40,14 @@ class SearchParams {
39
40
  if (trimmedRegionId !== null && !UUID_REGEX.test(trimmedRegionId)) {
40
41
  throw new Error('Query parameter "region" must be a valid UUID');
41
42
  }
43
+ const cursorNorm = cursorEncoded === undefined || cursorEncoded === null || cursorEncoded === ''
44
+ ? null
45
+ : cursorEncoded;
46
+ let cursor = null;
47
+ if (cursorNorm !== null) {
48
+ cursor = searchCursor_1.SearchCursor.decodeBase64(cursorNorm);
49
+ }
50
+ super(limitNum, cursor);
42
51
  this.name = name;
43
52
  this.similarityThreshold = similarityThreshold;
44
53
  this.includePages = includePages;
@@ -46,24 +55,11 @@ class SearchParams {
46
55
  this.includeAka = includeAka;
47
56
  this.regionId = trimmedRegionId;
48
57
  this.order = order;
49
- this.limit = limit;
50
- if (cursorEncoded === null || cursorEncoded === '') {
51
- this.cursor = null;
52
- }
53
- else {
54
- try {
55
- this.cursor = searchCursor_1.SearchCursor.decodeBase64(cursorEncoded);
56
- }
57
- catch {
58
- throw new Error('Invalid or malformed query parameter: cursor');
59
- }
60
- }
61
58
  }
62
59
  /**
63
- * Returns an object suitable for use as query string parameters.
64
- * Cursor is encoded for the query string.
60
+ * Returns a URL-encoded query string. Cursor is encoded for the query string.
65
61
  */
66
- toQueryStringParams() {
62
+ toQueryString() {
67
63
  const params = {
68
64
  name: this.name,
69
65
  similarity: String(this.similarityThreshold),
@@ -79,7 +75,10 @@ class SearchParams {
79
75
  if (this.cursor !== null) {
80
76
  params.cursor = this.cursor.encodeBase64();
81
77
  }
82
- return params;
78
+ return new URLSearchParams(params).toString();
79
+ }
80
+ withCursor(cursorEncoded) {
81
+ return new SearchParams(this.name, this.similarityThreshold, this.includePages, this.includeRegions, this.includeAka, this.regionId, this.order, this.limit, cursorEncoded === null || cursorEncoded === '' ? undefined : cursorEncoded);
83
82
  }
84
83
  /**
85
84
  * Parses query string parameters and returns validated params.
@@ -90,7 +89,7 @@ class SearchParams {
90
89
  const limitParam = q.limit ?? q.Limit ?? '';
91
90
  const limit = limitParam === '' ? DEFAULT_LIMIT : Number(limitParam);
92
91
  const cursorRaw = (q.cursor ?? q.Cursor ?? '').trim();
93
- const cursorEncoded = cursorRaw === '' ? null : cursorRaw;
92
+ const cursorEncoded = cursorRaw === '' ? undefined : cursorRaw;
94
93
  const similarityParam = q.similarity ?? q.Similarity ?? '';
95
94
  const similarity = similarityParam === '' ? 0.5 : Number(similarityParam);
96
95
  const orderParam = (q.order ?? q.Order ?? '').trim().toLowerCase();
@@ -0,0 +1,21 @@
1
+ import { Cursor } from '../cursors/cursor';
2
+ /**
3
+ * Abstract base for params that paginate with a limit and an optional cursor.
4
+ * Subclasses specify their own cursor type via the generic.
5
+ */
6
+ export declare abstract class CursorPaginationParams<C extends Cursor = Cursor> {
7
+ readonly limit: number;
8
+ readonly cursor: C | null;
9
+ constructor(limit: number, cursor: C | null);
10
+ /**
11
+ * Returns a URL-encoded query string (e.g. "limit=10" or "limit=10&cursor=...").
12
+ * Default implementation uses limit and cursor; subclasses with extra params override.
13
+ */
14
+ toQueryString(): string;
15
+ /**
16
+ * Returns a new params instance with the given cursor (for the next page).
17
+ * Each subclass implements this.
18
+ */
19
+ abstract withCursor(cursorEncoded: string | null): CursorPaginationParams;
20
+ }
21
+ //# sourceMappingURL=cursorPaginationParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursorPaginationParams.d.ts","sourceRoot":"","sources":["../../../src/types/params/cursorPaginationParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,8BAAsB,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;aAE9C,KAAK,EAAE,MAAM;aACb,MAAM,EAAE,CAAC,GAAG,IAAI;gBADhB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,GAAG,IAAI;IAGpC;;;OAGG;IACH,aAAa,IAAI,MAAM;IAUvB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,sBAAsB;CAC5E"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CursorPaginationParams = void 0;
4
+ /**
5
+ * Abstract base for params that paginate with a limit and an optional cursor.
6
+ * Subclasses specify their own cursor type via the generic.
7
+ */
8
+ class CursorPaginationParams {
9
+ constructor(limit, cursor) {
10
+ this.limit = limit;
11
+ this.cursor = cursor;
12
+ }
13
+ /**
14
+ * Returns a URL-encoded query string (e.g. "limit=10" or "limit=10&cursor=...").
15
+ * Default implementation uses limit and cursor; subclasses with extra params override.
16
+ */
17
+ toQueryString() {
18
+ const params = {
19
+ limit: String(this.limit),
20
+ };
21
+ if (this.cursor != null) {
22
+ params.cursor = this.cursor.encodeBase64();
23
+ }
24
+ return new URLSearchParams(params).toString();
25
+ }
26
+ }
27
+ exports.CursorPaginationParams = CursorPaginationParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ropegeo-common",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Shared types and utilities for RopeGeo and WebScraper",
5
5
  "license": "ISC",
6
6
  "repository": {