ropegeo-common 1.2.9 → 1.2.11

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
@@ -7,9 +7,11 @@ export { RegionPreview } from './types/previews/regionPreview';
7
7
  export { Route, RouteGeoJsonFeature, RouteType } from './types/route';
8
8
  export { RoutesGeojson } from './types/api/getRoutes/routeGeojson';
9
9
  export { RoutesParams } from './types/api/getRoutes/routesParams';
10
- export type { RopewikiImageView } from './types/api/getRopewikiPageView/ropewikiImageView';
11
- export type { RopewikiBetaSectionView } from './types/api/getRopewikiPageView/ropewikiBetaSectionView';
12
- export type { RopewikiPageView } from './types/api/getRopewikiPageView/ropewikiPageView';
10
+ export { BetaSectionImage } from './types/betaSections/betaSectionImage';
11
+ export { BetaSection } from './types/betaSections/betaSection';
12
+ export { RopewikiPageView } from './types/api/getRopewikiPageView/ropewikiPageView';
13
+ export type RopewikiImageView = import('./types/betaSections/betaSectionImage').BetaSectionImage;
14
+ export type RopewikiBetaSectionView = import('./types/betaSections/betaSection').BetaSection;
13
15
  export { Cursor, CursorType } from './types/cursors/cursor';
14
16
  export { CursorPaginationParams } from './types/params/cursorPaginationParams';
15
17
  export { CursorPaginationResults, type CursorPaginationResponseParsed, ResultType, } from './types/results/cursorPaginationResults';
@@ -19,7 +21,6 @@ export { SearchParams } from './types/api/search/searchParams';
19
21
  export type { SearchOrder } from './types/api/search/searchParams';
20
22
  export { SearchResults } from './types/api/search/searchResults';
21
23
  export { RopewikiRegionView } from './types/api/getRopewikiRegionView/ropewikiRegionView';
22
- export type { RopewikiRegionViewRow } from './types/api/getRopewikiRegionView/ropewikiRegionView';
23
24
  export { RegionPreviewsCursor } from './types/cursors/regionPreviewsCursor';
24
25
  export { RopewikiRegionPreviewsParams } from './types/api/getRopewikiRegionPreviews/ropewikiRegionPreviewsParams';
25
26
  export { RopewikiRegionPreviewsResult } from './types/api/getRopewikiRegionPreviews/ropewikiRegionPrevi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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.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;
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.RopewikiPageView = exports.BetaSection = exports.BetaSectionImage = 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");
@@ -25,6 +25,12 @@ var routeGeojson_1 = require("./types/api/getRoutes/routeGeojson");
25
25
  Object.defineProperty(exports, "RoutesGeojson", { enumerable: true, get: function () { return routeGeojson_1.RoutesGeojson; } });
26
26
  var routesParams_1 = require("./types/api/getRoutes/routesParams");
27
27
  Object.defineProperty(exports, "RoutesParams", { enumerable: true, get: function () { return routesParams_1.RoutesParams; } });
28
+ var betaSectionImage_1 = require("./types/betaSections/betaSectionImage");
29
+ Object.defineProperty(exports, "BetaSectionImage", { enumerable: true, get: function () { return betaSectionImage_1.BetaSectionImage; } });
30
+ var betaSection_1 = require("./types/betaSections/betaSection");
31
+ Object.defineProperty(exports, "BetaSection", { enumerable: true, get: function () { return betaSection_1.BetaSection; } });
32
+ var ropewikiPageView_1 = require("./types/api/getRopewikiPageView/ropewikiPageView");
33
+ Object.defineProperty(exports, "RopewikiPageView", { enumerable: true, get: function () { return ropewikiPageView_1.RopewikiPageView; } });
28
34
  var cursor_1 = require("./types/cursors/cursor");
29
35
  Object.defineProperty(exports, "Cursor", { enumerable: true, get: function () { return cursor_1.Cursor; } });
30
36
  Object.defineProperty(exports, "CursorType", { enumerable: true, get: function () { return cursor_1.CursorType; } });
@@ -1,11 +1,15 @@
1
- import type { Difficulty } from '../../difficulty';
2
- import type { PermitStatus } from '../../permitStatus';
3
- import type { RopewikiBetaSectionView } from './ropewikiBetaSectionView';
4
- import type { RopewikiImageView } from './ropewikiImageView';
1
+ import { Difficulty } from '../../difficulty';
2
+ import { PermitStatus } from '../../permitStatus';
3
+ import { BetaSection } from '../../betaSections/betaSection';
4
+ import { BetaSectionImage } from '../../betaSections/betaSectionImage';
5
+ type MinMax = {
6
+ min: number;
7
+ max: number;
8
+ };
5
9
  /**
6
10
  * Response type for GET getRopewikiPageView (full page view).
7
11
  */
8
- export interface RopewikiPageView {
12
+ export declare class RopewikiPageView {
9
13
  pageId: string;
10
14
  name: string;
11
15
  aka: string[];
@@ -18,10 +22,7 @@ export interface RopewikiPageView {
18
22
  }[];
19
23
  difficulty: Difficulty;
20
24
  permit: PermitStatus | null;
21
- rappelCount: {
22
- min: number;
23
- max: number;
24
- } | number | null;
25
+ rappelCount: MinMax | number | null;
25
26
  jumps: number | null;
26
27
  vehicle: string | null;
27
28
  rappelLongest: number | null;
@@ -30,28 +31,38 @@ export interface RopewikiPageView {
30
31
  descentLength: number | null;
31
32
  exitLength: number | null;
32
33
  approachLength: number | null;
33
- overallTime: {
34
- min: number;
35
- max: number;
36
- } | number | null;
37
- approachTime: {
38
- min: number;
39
- max: number;
40
- } | number | null;
41
- descentTime: {
42
- min: number;
43
- max: number;
44
- } | number | null;
45
- exitTime: {
46
- min: number;
47
- max: number;
48
- } | number | null;
34
+ overallTime: MinMax | number | null;
35
+ approachTime: MinMax | number | null;
36
+ descentTime: MinMax | number | null;
37
+ exitTime: MinMax | number | null;
49
38
  approachElevGain: number | null;
50
39
  descentElevGain: number | null;
51
40
  exitElevGain: number | null;
52
41
  months: string[];
53
42
  latestRevisionDate: Date;
54
- bannerImage: RopewikiImageView | null;
55
- betaSections: RopewikiBetaSectionView[];
43
+ bannerImage: BetaSectionImage | null;
44
+ betaSections: BetaSection[];
45
+ constructor(pageId: string, name: string, aka: string[], url: string, quality: number, userVotes: number, regions: {
46
+ name: string;
47
+ id: string;
48
+ }[], difficulty: Difficulty, permit: PermitStatus | null, rappelCount: MinMax | number | null, jumps: number | null, vehicle: string | null, rappelLongest: number | null, shuttleTime: number | null, overallLength: number | null, descentLength: number | null, exitLength: number | null, approachLength: number | null, overallTime: MinMax | number | null, approachTime: MinMax | number | null, descentTime: MinMax | number | null, exitTime: MinMax | number | null, approachElevGain: number | null, descentElevGain: number | null, exitElevGain: number | null, months: string[], latestRevisionDate: Date, bannerImage: BetaSectionImage | null, betaSections: BetaSection[]);
49
+ /**
50
+ * Validates response body has RopewikiPageView fields and returns a RopewikiPageView instance.
51
+ */
52
+ static fromResponseBody(body: unknown): RopewikiPageView;
53
+ private static assertString;
54
+ private static assertNullableString;
55
+ private static assertNumber;
56
+ private static assertNullableNumber;
57
+ private static assertStringArray;
58
+ private static assertRegionsArray;
59
+ private static assertDifficulty;
60
+ private static assertPermit;
61
+ private static assertRappelCount;
62
+ private static assertMinMaxOrNumber;
63
+ private static assertIso8601DateString;
64
+ private static assertNullableBannerImage;
65
+ private static assertBetaSectionsArray;
56
66
  }
67
+ export {};
57
68
  //# sourceMappingURL=ropewikiPageView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ropewikiPageView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiPageView/ropewikiPageView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxC,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;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OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAYnC,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAYnC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAmBhC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA+BjC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyB/B,OAAO,CAAC,MAAM,CAAC,YAAY;IAgB3B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA2BhC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAOnC,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAkBtC,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAexC,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAczC"}
@@ -1,2 +1,223 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RopewikiPageView = void 0;
4
+ const difficulty_1 = require("../../difficulty");
5
+ const permitStatus_1 = require("../../permitStatus");
6
+ const betaSection_1 = require("../../betaSections/betaSection");
7
+ const betaSectionImage_1 = require("../../betaSections/betaSectionImage");
8
+ /**
9
+ * Response type for GET getRopewikiPageView (full page view).
10
+ */
11
+ class RopewikiPageView {
12
+ constructor(pageId, name, aka, url, quality, userVotes, regions, difficulty, permit, rappelCount, jumps, vehicle, rappelLongest, shuttleTime, overallLength, descentLength, exitLength, approachLength, overallTime, approachTime, descentTime, exitTime, approachElevGain, descentElevGain, exitElevGain, months, latestRevisionDate, bannerImage, betaSections) {
13
+ this.pageId = pageId;
14
+ this.name = name;
15
+ this.aka = Array.isArray(aka) ? aka.slice() : [];
16
+ this.url = url;
17
+ this.quality = quality;
18
+ this.userVotes = userVotes;
19
+ this.regions = Array.isArray(regions) ? regions.slice() : [];
20
+ this.difficulty = difficulty;
21
+ this.permit = permit;
22
+ this.rappelCount = rappelCount;
23
+ this.jumps = jumps;
24
+ this.vehicle = vehicle;
25
+ this.rappelLongest = rappelLongest;
26
+ this.shuttleTime = shuttleTime;
27
+ this.overallLength = overallLength;
28
+ this.descentLength = descentLength;
29
+ this.exitLength = exitLength;
30
+ this.approachLength = approachLength;
31
+ this.overallTime = overallTime;
32
+ this.approachTime = approachTime;
33
+ this.descentTime = descentTime;
34
+ this.exitTime = exitTime;
35
+ this.approachElevGain = approachElevGain;
36
+ this.descentElevGain = descentElevGain;
37
+ this.exitElevGain = exitElevGain;
38
+ this.months = Array.isArray(months) ? months.slice() : [];
39
+ this.latestRevisionDate = new Date(latestRevisionDate);
40
+ this.bannerImage = bannerImage;
41
+ this.betaSections = Array.isArray(betaSections) ? betaSections : [];
42
+ }
43
+ /**
44
+ * Validates response body has RopewikiPageView fields and returns a RopewikiPageView instance.
45
+ */
46
+ static fromResponseBody(body) {
47
+ if (body == null || typeof body !== 'object') {
48
+ throw new Error('RopewikiPageView body must be an object');
49
+ }
50
+ const r = body;
51
+ RopewikiPageView.assertString(r, 'pageId');
52
+ RopewikiPageView.assertString(r, 'name');
53
+ RopewikiPageView.assertStringArray(r, 'aka');
54
+ RopewikiPageView.assertString(r, 'url');
55
+ RopewikiPageView.assertNumber(r, 'quality');
56
+ RopewikiPageView.assertNumber(r, 'userVotes');
57
+ RopewikiPageView.assertRegionsArray(r, 'regions');
58
+ RopewikiPageView.assertDifficulty(r, 'difficulty');
59
+ RopewikiPageView.assertPermit(r, 'permit');
60
+ RopewikiPageView.assertRappelCount(r, 'rappelCount');
61
+ RopewikiPageView.assertNullableNumber(r, 'jumps');
62
+ RopewikiPageView.assertNullableString(r, 'vehicle');
63
+ RopewikiPageView.assertNullableNumber(r, 'rappelLongest');
64
+ RopewikiPageView.assertNullableNumber(r, 'shuttleTime');
65
+ RopewikiPageView.assertNullableNumber(r, 'overallLength');
66
+ RopewikiPageView.assertNullableNumber(r, 'descentLength');
67
+ RopewikiPageView.assertNullableNumber(r, 'exitLength');
68
+ RopewikiPageView.assertNullableNumber(r, 'approachLength');
69
+ RopewikiPageView.assertMinMaxOrNumber(r, 'overallTime');
70
+ RopewikiPageView.assertMinMaxOrNumber(r, 'approachTime');
71
+ RopewikiPageView.assertMinMaxOrNumber(r, 'descentTime');
72
+ RopewikiPageView.assertMinMaxOrNumber(r, 'exitTime');
73
+ RopewikiPageView.assertNullableNumber(r, 'approachElevGain');
74
+ RopewikiPageView.assertNullableNumber(r, 'descentElevGain');
75
+ RopewikiPageView.assertNullableNumber(r, 'exitElevGain');
76
+ RopewikiPageView.assertStringArray(r, 'months');
77
+ RopewikiPageView.assertIso8601DateString(r, 'latestRevisionDate');
78
+ RopewikiPageView.assertNullableBannerImage(r, 'bannerImage');
79
+ RopewikiPageView.assertBetaSectionsArray(r, 'betaSections');
80
+ r.latestRevisionDate = new Date(r.latestRevisionDate);
81
+ r.difficulty = new difficulty_1.Difficulty(r.difficulty.technical, r.difficulty.water, r.difficulty.time, r.difficulty.risk);
82
+ Object.setPrototypeOf(r, RopewikiPageView.prototype);
83
+ return r;
84
+ }
85
+ static assertString(obj, key) {
86
+ const v = obj[key];
87
+ if (typeof v !== 'string') {
88
+ throw new Error(`RopewikiPageView.${key} must be a string, got: ${typeof v}`);
89
+ }
90
+ }
91
+ static assertNullableString(obj, key) {
92
+ const v = obj[key];
93
+ if (v !== null && v !== undefined && typeof v !== 'string') {
94
+ throw new Error(`RopewikiPageView.${key} must be string or null, got: ${typeof v}`);
95
+ }
96
+ }
97
+ static assertNumber(obj, key) {
98
+ const v = obj[key];
99
+ if (typeof v !== 'number' || Number.isNaN(v)) {
100
+ throw new Error(`RopewikiPageView.${key} must be a number, got: ${typeof v}`);
101
+ }
102
+ }
103
+ static assertNullableNumber(obj, key) {
104
+ const v = obj[key];
105
+ if (v !== null && v !== undefined && (typeof v !== 'number' || Number.isNaN(v))) {
106
+ throw new Error(`RopewikiPageView.${key} must be a number or null, got: ${typeof v}`);
107
+ }
108
+ }
109
+ static assertStringArray(obj, key) {
110
+ const v = obj[key];
111
+ if (!Array.isArray(v)) {
112
+ throw new Error(`RopewikiPageView.${key} must be an array, got: ${typeof v}`);
113
+ }
114
+ for (let i = 0; i < v.length; i++) {
115
+ if (typeof v[i] !== 'string') {
116
+ throw new Error(`RopewikiPageView.${key}[${i}] must be a string`);
117
+ }
118
+ }
119
+ }
120
+ static assertRegionsArray(obj, key) {
121
+ const v = obj[key];
122
+ if (!Array.isArray(v)) {
123
+ throw new Error(`RopewikiPageView.${key} must be an array, got: ${typeof v}`);
124
+ }
125
+ for (let i = 0; i < v.length; i++) {
126
+ const item = v[i];
127
+ if (item == null || typeof item !== 'object') {
128
+ throw new Error(`RopewikiPageView.${key}[${i}] must be an object with id and name`);
129
+ }
130
+ const o = item;
131
+ if (typeof o.id !== 'string') {
132
+ throw new Error(`RopewikiPageView.${key}[${i}].id must be a string, got: ${typeof o.id}`);
133
+ }
134
+ if (typeof o.name !== 'string') {
135
+ throw new Error(`RopewikiPageView.${key}[${i}].name must be a string, got: ${typeof o.name}`);
136
+ }
137
+ }
138
+ }
139
+ static assertDifficulty(obj, key) {
140
+ const v = obj[key];
141
+ if (v == null || typeof v !== 'object') {
142
+ throw new Error(`RopewikiPageView.${key} must be an object, got: ${typeof v}`);
143
+ }
144
+ const d = v;
145
+ if (d.technical !== null && d.technical !== undefined && typeof d.technical !== 'string') {
146
+ throw new Error(`RopewikiPageView.${key}.technical must be string or null`);
147
+ }
148
+ if (d.water !== null && d.water !== undefined && typeof d.water !== 'string') {
149
+ throw new Error(`RopewikiPageView.${key}.water must be string or null`);
150
+ }
151
+ if (d.time !== null && d.time !== undefined && typeof d.time !== 'string') {
152
+ throw new Error(`RopewikiPageView.${key}.time must be string or null`);
153
+ }
154
+ if (d.risk !== null && d.risk !== undefined && typeof d.risk !== 'string') {
155
+ throw new Error(`RopewikiPageView.${key}.risk must be string or null`);
156
+ }
157
+ }
158
+ static assertPermit(obj, key) {
159
+ const v = obj[key];
160
+ if (v === null || v === undefined)
161
+ return;
162
+ if (typeof v !== 'string') {
163
+ throw new Error(`RopewikiPageView.${key} must be PermitStatus or null, got: ${typeof v}`);
164
+ }
165
+ const values = Object.values(permitStatus_1.PermitStatus);
166
+ if (!values.includes(v)) {
167
+ throw new Error(`RopewikiPageView.${key} must be one of [${values.join(', ')}] or null, got: ${v}`);
168
+ }
169
+ }
170
+ static assertRappelCount(obj, key) {
171
+ const v = obj[key];
172
+ if (v === null || v === undefined)
173
+ return;
174
+ if (typeof v === 'number') {
175
+ if (Number.isNaN(v)) {
176
+ throw new Error(`RopewikiPageView.${key} must be a number or min/max object or null`);
177
+ }
178
+ return;
179
+ }
180
+ if (typeof v === 'object' && v !== null && 'min' in v && 'max' in v) {
181
+ const o = v;
182
+ if (typeof o.min !== 'number' || Number.isNaN(o.min)) {
183
+ throw new Error(`RopewikiPageView.${key}.min must be a number`);
184
+ }
185
+ if (typeof o.max !== 'number' || Number.isNaN(o.max)) {
186
+ throw new Error(`RopewikiPageView.${key}.max must be a number`);
187
+ }
188
+ return;
189
+ }
190
+ throw new Error(`RopewikiPageView.${key} must be number or { min, max } or null, got: ${typeof v}`);
191
+ }
192
+ static assertMinMaxOrNumber(obj, key) {
193
+ RopewikiPageView.assertRappelCount(obj, key);
194
+ }
195
+ static assertIso8601DateString(obj, key) {
196
+ const v = obj[key];
197
+ if (typeof v !== 'string') {
198
+ throw new Error(`RopewikiPageView.${key} must be an ISO 8601 date string, got: ${typeof v}`);
199
+ }
200
+ const date = new Date(v);
201
+ if (Number.isNaN(date.getTime())) {
202
+ throw new Error(`RopewikiPageView.${key} must be a valid ISO 8601 date string, got: ${v}`);
203
+ }
204
+ }
205
+ static assertNullableBannerImage(obj, key) {
206
+ const v = obj[key];
207
+ if (v === null || v === undefined)
208
+ return;
209
+ if (typeof v !== 'object') {
210
+ throw new Error(`RopewikiPageView.${key} must be BetaSectionImage or null, got: ${typeof v}`);
211
+ }
212
+ const parsed = betaSectionImage_1.BetaSectionImage.fromResponseBody(v);
213
+ obj[key] = parsed;
214
+ }
215
+ static assertBetaSectionsArray(obj, key) {
216
+ const v = obj[key];
217
+ if (!Array.isArray(v)) {
218
+ throw new Error(`RopewikiPageView.${key} must be an array, got: ${typeof v}`);
219
+ }
220
+ obj[key] = v.map((item) => betaSection_1.BetaSection.fromResponseBody(item));
221
+ }
222
+ }
223
+ exports.RopewikiPageView = RopewikiPageView;
@@ -1,43 +1,47 @@
1
- /**
2
- * Row shape from the database (or join) for building a RopewikiRegionView.
3
- * Column names match the RopewikiRegion schema; parentRegionId/parentRegionName
4
- * come from a join when loading the parent region.
5
- */
6
- export interface RopewikiRegionViewRow {
7
- name: string;
8
- parentRegionId?: string | null;
9
- parentRegionName?: string | null;
10
- rawPageCount?: number | null;
11
- truePageCount?: number | null;
12
- trueRegionCount?: number | null;
13
- truePageCountWithDescendents?: number | null;
14
- overview?: string | null;
15
- bestMonths?: string[] | null;
16
- isMajorRegion?: boolean | null;
17
- latestRevisionDate: Date;
18
- url: string;
19
- }
1
+ import { BetaSection } from '../../betaSections/betaSection';
20
2
  /**
21
3
  * Region view for getRopewikiRegionView (GET /ropewiki/region/{id}).
22
4
  * Contains all RopewikiRegion info for the region except the region's id.
23
5
  */
24
6
  export declare class RopewikiRegionView {
25
7
  name: string;
26
- parentRegion: {
27
- id: string;
8
+ /** Full lineage of parent regions from immediate parent up to root (same shape as RopewikiPageView.regions). */
9
+ regions: {
28
10
  name: string;
29
- } | null;
11
+ id: string;
12
+ }[];
30
13
  /** Actual number of pages in this region (computed). Default 0. */
31
14
  regionCount: number;
32
15
  /** Pages in this region only (computed). Default 0. */
33
16
  topLevelPageCount: number;
34
17
  /** Raw page count from getRegions API (rawPageCount). Default 0. */
35
18
  pageCount: number;
36
- overview: string | null;
19
+ /** Pages in this region and all descendants (truePageCountWithDescendents). Default 0. */
20
+ totalPageCount: number;
21
+ overview: BetaSection | null;
37
22
  bestMonths: string[];
38
23
  isMajorRegion: boolean;
39
24
  latestRevisionDate: Date;
25
+ /** When the region was last synced (from updatedAt). */
26
+ syncDate: Date;
40
27
  externalLink: string;
41
- constructor(row: RopewikiRegionViewRow);
28
+ constructor(name: string, latestRevisionDate: Date, url: string, updatedAt: Date, regions?: {
29
+ name: string;
30
+ id: string;
31
+ }[], rawPageCount?: number | null, truePageCount?: number | null, trueRegionCount?: number | null, truePageCountWithDescendents?: number | null, overview?: string | null, bestMonths?: string[] | null, isMajorRegion?: boolean | null);
32
+ /**
33
+ * Validates response body has RopewikiRegionView fields and returns a RopewikiRegionView instance.
34
+ * Mutates the body (parses latestRevisionDate to Date) and sets RopewikiRegionView.prototype.
35
+ */
36
+ static fromResponseBody(body: unknown): RopewikiRegionView;
37
+ private static assertString;
38
+ private static assertNullableString;
39
+ private static assertNullableOverview;
40
+ private static assertNonNegativeNumber;
41
+ private static assertRegionsArray;
42
+ private static assertStringArray;
43
+ private static assertBoolean;
44
+ private static assertIso8601DateString;
45
+ private static assertValidUrl;
42
46
  }
43
47
  //# sourceMappingURL=ropewikiRegionView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ropewikiRegionView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionView/ropewikiRegionView.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,kBAAkB,EAAE,IAAI,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAClD,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;gBAET,GAAG,EAAE,qBAAqB;CAezC"}
1
+ {"version":3,"file":"ropewikiRegionView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiRegionView/ropewikiRegionView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,gHAAgH;IAChH,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxC,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,IAAI,CAAC;IACzB,wDAAwD;IACxD,QAAQ,EAAE,IAAI,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;gBAGjB,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,IAAI,EACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,IAAI,EACf,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,EACxC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,EAC/B,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAC5B,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI;IAoBlC;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB;IA6B1D,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAYnC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAarC,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAYtC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA+BjC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAmBhC,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAkBtC,OAAO,CAAC,MAAM,CAAC,cAAc;CAkBhC"}
@@ -1,25 +1,143 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RopewikiRegionView = void 0;
4
+ const betaSection_1 = require("../../betaSections/betaSection");
4
5
  /**
5
6
  * Region view for getRopewikiRegionView (GET /ropewiki/region/{id}).
6
7
  * Contains all RopewikiRegion info for the region except the region's id.
7
8
  */
8
9
  class RopewikiRegionView {
9
- constructor(row) {
10
- this.name = row.name;
11
- this.parentRegion =
12
- row.parentRegionId != null && row.parentRegionName != null
13
- ? { id: row.parentRegionId, name: row.parentRegionName }
10
+ constructor(name, latestRevisionDate, url, updatedAt, regions, rawPageCount, truePageCount, trueRegionCount, truePageCountWithDescendents, overview, bestMonths, isMajorRegion) {
11
+ this.name = name;
12
+ this.regions = Array.isArray(regions) ? regions.slice() : [];
13
+ this.regionCount = trueRegionCount ?? 0;
14
+ this.topLevelPageCount = truePageCount ?? 0;
15
+ this.pageCount = rawPageCount ?? 0;
16
+ this.totalPageCount = truePageCountWithDescendents ?? 0;
17
+ const revDate = new Date(latestRevisionDate);
18
+ this.overview =
19
+ overview != null && overview !== ''
20
+ ? new betaSection_1.BetaSection(1, 'Overview', overview, revDate, [])
14
21
  : null;
15
- this.regionCount = row.trueRegionCount ?? 0;
16
- this.topLevelPageCount = row.truePageCount ?? 0;
17
- this.pageCount = row.rawPageCount ?? 0;
18
- this.overview = row.overview ?? null;
19
- this.bestMonths = Array.isArray(row.bestMonths) ? row.bestMonths : [];
20
- this.isMajorRegion = row.isMajorRegion ?? false;
21
- this.latestRevisionDate = new Date(row.latestRevisionDate);
22
- this.externalLink = row.url;
22
+ this.bestMonths = Array.isArray(bestMonths) ? bestMonths : [];
23
+ this.isMajorRegion = isMajorRegion ?? false;
24
+ this.latestRevisionDate = revDate;
25
+ this.syncDate = new Date(updatedAt);
26
+ this.externalLink = url;
27
+ }
28
+ /**
29
+ * Validates response body has RopewikiRegionView fields and returns a RopewikiRegionView instance.
30
+ * Mutates the body (parses latestRevisionDate to Date) and sets RopewikiRegionView.prototype.
31
+ */
32
+ static fromResponseBody(body) {
33
+ if (body == null || typeof body !== 'object') {
34
+ throw new Error('RopewikiRegionView body must be an object');
35
+ }
36
+ const r = body;
37
+ RopewikiRegionView.assertString(r, 'name');
38
+ RopewikiRegionView.assertRegionsArray(r, 'regions');
39
+ RopewikiRegionView.assertNonNegativeNumber(r, 'regionCount');
40
+ RopewikiRegionView.assertNonNegativeNumber(r, 'topLevelPageCount');
41
+ RopewikiRegionView.assertNonNegativeNumber(r, 'pageCount');
42
+ RopewikiRegionView.assertNonNegativeNumber(r, 'totalPageCount');
43
+ RopewikiRegionView.assertNullableOverview(r, 'overview');
44
+ RopewikiRegionView.assertStringArray(r, 'bestMonths');
45
+ RopewikiRegionView.assertBoolean(r, 'isMajorRegion');
46
+ RopewikiRegionView.assertIso8601DateString(r, 'latestRevisionDate');
47
+ RopewikiRegionView.assertIso8601DateString(r, 'syncDate');
48
+ RopewikiRegionView.assertValidUrl(r, 'externalLink');
49
+ r.latestRevisionDate = new Date(r.latestRevisionDate);
50
+ r.syncDate = new Date(r.syncDate);
51
+ r.overview =
52
+ r.overview == null || r.overview === undefined
53
+ ? null
54
+ : betaSection_1.BetaSection.fromResponseBody(r.overview);
55
+ Object.setPrototypeOf(r, RopewikiRegionView.prototype);
56
+ return r;
57
+ }
58
+ static assertString(obj, key) {
59
+ const v = obj[key];
60
+ if (typeof v !== 'string') {
61
+ throw new Error(`RopewikiRegionView.${key} must be a string, got: ${typeof v}`);
62
+ }
63
+ }
64
+ static assertNullableString(obj, key) {
65
+ const v = obj[key];
66
+ if (v !== null && v !== undefined && typeof v !== 'string') {
67
+ throw new Error(`RopewikiRegionView.${key} must be string or null, got: ${typeof v}`);
68
+ }
69
+ }
70
+ static assertNullableOverview(obj, key) {
71
+ const v = obj[key];
72
+ if (v === null || v === undefined)
73
+ return;
74
+ if (typeof v !== 'object') {
75
+ throw new Error(`RopewikiRegionView.${key} must be BetaSection or null, got: ${typeof v}`);
76
+ }
77
+ }
78
+ static assertNonNegativeNumber(obj, key) {
79
+ const v = obj[key];
80
+ if (typeof v !== 'number' || Number.isNaN(v) || v < 0) {
81
+ throw new Error(`RopewikiRegionView.${key} must be a number >= 0, got: ${typeof v}`);
82
+ }
83
+ }
84
+ static assertRegionsArray(obj, key) {
85
+ const v = obj[key];
86
+ if (!Array.isArray(v)) {
87
+ throw new Error(`RopewikiRegionView.${key} must be an array, got: ${typeof v}`);
88
+ }
89
+ for (let i = 0; i < v.length; i++) {
90
+ const item = v[i];
91
+ if (item == null || typeof item !== 'object') {
92
+ throw new Error(`RopewikiRegionView.${key}[${i}] must be an object with id and name`);
93
+ }
94
+ const o = item;
95
+ if (typeof o.id !== 'string') {
96
+ throw new Error(`RopewikiRegionView.${key}[${i}].id must be a string, got: ${typeof o.id}`);
97
+ }
98
+ if (typeof o.name !== 'string') {
99
+ throw new Error(`RopewikiRegionView.${key}[${i}].name must be a string, got: ${typeof o.name}`);
100
+ }
101
+ }
102
+ }
103
+ static assertStringArray(obj, key) {
104
+ const v = obj[key];
105
+ if (!Array.isArray(v)) {
106
+ throw new Error(`RopewikiRegionView.${key} must be an array, got: ${typeof v}`);
107
+ }
108
+ for (let i = 0; i < v.length; i++) {
109
+ if (typeof v[i] !== 'string') {
110
+ throw new Error(`RopewikiRegionView.${key}[${i}] must be a string`);
111
+ }
112
+ }
113
+ }
114
+ static assertBoolean(obj, key) {
115
+ const v = obj[key];
116
+ if (typeof v !== 'boolean') {
117
+ throw new Error(`RopewikiRegionView.${key} must be a boolean, got: ${typeof v}`);
118
+ }
119
+ }
120
+ static assertIso8601DateString(obj, key) {
121
+ const v = obj[key];
122
+ if (typeof v !== 'string') {
123
+ throw new Error(`RopewikiRegionView.${key} must be an ISO 8601 date string, got: ${typeof v}`);
124
+ }
125
+ const date = new Date(v);
126
+ if (Number.isNaN(date.getTime())) {
127
+ throw new Error(`RopewikiRegionView.${key} must be a valid ISO 8601 date string, got: ${v}`);
128
+ }
129
+ }
130
+ static assertValidUrl(obj, key) {
131
+ const v = obj[key];
132
+ if (typeof v !== 'string') {
133
+ throw new Error(`RopewikiRegionView.${key} must be a string (valid URL), got: ${typeof v}`);
134
+ }
135
+ try {
136
+ new URL(v);
137
+ }
138
+ catch {
139
+ throw new Error(`RopewikiRegionView.${key} must be a valid URL, got: ${v}`);
140
+ }
23
141
  }
24
142
  }
25
143
  exports.RopewikiRegionView = RopewikiRegionView;
@@ -0,0 +1,21 @@
1
+ import { BetaSectionImage } from './betaSectionImage';
2
+ /**
3
+ * Generic beta section (e.g. order, title, text, images, latestRevisionDate).
4
+ */
5
+ export declare class BetaSection {
6
+ order: number;
7
+ title: string;
8
+ text: string;
9
+ images: BetaSectionImage[];
10
+ latestRevisionDate: Date;
11
+ constructor(order: number, title: string, text: string, latestRevisionDate: Date, images?: BetaSectionImage[]);
12
+ /**
13
+ * Validates response body has BetaSection fields and returns a BetaSection instance.
14
+ */
15
+ static fromResponseBody(body: unknown): BetaSection;
16
+ private static assertNumber;
17
+ private static assertString;
18
+ private static assertImagesArray;
19
+ private static assertIso8601DateString;
20
+ }
21
+ //# sourceMappingURL=betaSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"betaSection.d.ts","sourceRoot":"","sources":["../../../src/types/betaSections/betaSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,qBAAa,WAAW;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,kBAAkB,EAAE,IAAI,CAAC;gBAGrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,IAAI,EACxB,MAAM,CAAC,EAAE,gBAAgB,EAAE;IAS/B;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW;IAiBnD,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAehC,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAiBzC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BetaSection = void 0;
4
+ const betaSectionImage_1 = require("./betaSectionImage");
5
+ /**
6
+ * Generic beta section (e.g. order, title, text, images, latestRevisionDate).
7
+ */
8
+ class BetaSection {
9
+ constructor(order, title, text, latestRevisionDate, images) {
10
+ this.order = order;
11
+ this.title = title;
12
+ this.text = text;
13
+ this.images = Array.isArray(images) ? images : [];
14
+ this.latestRevisionDate = new Date(latestRevisionDate);
15
+ }
16
+ /**
17
+ * Validates response body has BetaSection fields and returns a BetaSection instance.
18
+ */
19
+ static fromResponseBody(body) {
20
+ if (body == null || typeof body !== 'object') {
21
+ throw new Error('BetaSection body must be an object');
22
+ }
23
+ const r = body;
24
+ BetaSection.assertNumber(r, 'order');
25
+ BetaSection.assertString(r, 'title');
26
+ BetaSection.assertString(r, 'text');
27
+ BetaSection.assertImagesArray(r, 'images');
28
+ BetaSection.assertIso8601DateString(r, 'latestRevisionDate');
29
+ r.latestRevisionDate = new Date(r.latestRevisionDate);
30
+ Object.setPrototypeOf(r, BetaSection.prototype);
31
+ return r;
32
+ }
33
+ static assertNumber(obj, key) {
34
+ const v = obj[key];
35
+ if (typeof v !== 'number' || Number.isNaN(v)) {
36
+ throw new Error(`BetaSection.${key} must be a number, got: ${typeof v}`);
37
+ }
38
+ }
39
+ static assertString(obj, key) {
40
+ const v = obj[key];
41
+ if (typeof v !== 'string') {
42
+ throw new Error(`BetaSection.${key} must be a string, got: ${typeof v}`);
43
+ }
44
+ }
45
+ static assertImagesArray(obj, key) {
46
+ const v = obj[key];
47
+ if (!Array.isArray(v)) {
48
+ throw new Error(`BetaSection.${key} must be an array, got: ${typeof v}`);
49
+ }
50
+ obj[key] = v.map((item) => betaSectionImage_1.BetaSectionImage.fromResponseBody(item));
51
+ }
52
+ static assertIso8601DateString(obj, key) {
53
+ const v = obj[key];
54
+ if (typeof v !== 'string') {
55
+ throw new Error(`BetaSection.${key} must be an ISO 8601 date string, got: ${typeof v}`);
56
+ }
57
+ const date = new Date(v);
58
+ if (Number.isNaN(date.getTime())) {
59
+ throw new Error(`BetaSection.${key} must be a valid ISO 8601 date string, got: ${v}`);
60
+ }
61
+ }
62
+ }
63
+ exports.BetaSection = BetaSection;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Generic beta section image (e.g. order, url, linkUrl, caption, latestRevisionDate).
3
+ */
4
+ export declare class BetaSectionImage {
5
+ order: number;
6
+ url: string;
7
+ linkUrl: string;
8
+ caption: string;
9
+ latestRevisionDate: Date;
10
+ constructor(order: number, url: string, linkUrl: string, caption: string, latestRevisionDate: Date);
11
+ /**
12
+ * Validates response body has BetaSectionImage fields and returns a BetaSectionImage instance.
13
+ */
14
+ static fromResponseBody(body: unknown): BetaSectionImage;
15
+ private static assertNumber;
16
+ private static assertString;
17
+ private static assertIso8601DateString;
18
+ }
19
+ //# sourceMappingURL=betaSectionImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"betaSectionImage.d.ts","sourceRoot":"","sources":["../../../src/types/betaSections/betaSectionImage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAgB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,IAAI,CAAC;gBAGrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,IAAI;IAS5B;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB;IAiBxD,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,YAAY;IAS3B,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAiBzC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BetaSectionImage = void 0;
4
+ /**
5
+ * Generic beta section image (e.g. order, url, linkUrl, caption, latestRevisionDate).
6
+ */
7
+ class BetaSectionImage {
8
+ constructor(order, url, linkUrl, caption, latestRevisionDate) {
9
+ this.order = order;
10
+ this.url = url;
11
+ this.linkUrl = linkUrl;
12
+ this.caption = caption;
13
+ this.latestRevisionDate = new Date(latestRevisionDate);
14
+ }
15
+ /**
16
+ * Validates response body has BetaSectionImage fields and returns a BetaSectionImage instance.
17
+ */
18
+ static fromResponseBody(body) {
19
+ if (body == null || typeof body !== 'object') {
20
+ throw new Error('BetaSectionImage body must be an object');
21
+ }
22
+ const r = body;
23
+ BetaSectionImage.assertNumber(r, 'order');
24
+ BetaSectionImage.assertString(r, 'url');
25
+ BetaSectionImage.assertString(r, 'linkUrl');
26
+ BetaSectionImage.assertString(r, 'caption');
27
+ BetaSectionImage.assertIso8601DateString(r, 'latestRevisionDate');
28
+ r.latestRevisionDate = new Date(r.latestRevisionDate);
29
+ Object.setPrototypeOf(r, BetaSectionImage.prototype);
30
+ return r;
31
+ }
32
+ static assertNumber(obj, key) {
33
+ const v = obj[key];
34
+ if (typeof v !== 'number' || Number.isNaN(v)) {
35
+ throw new Error(`BetaSectionImage.${key} must be a number, got: ${typeof v}`);
36
+ }
37
+ }
38
+ static assertString(obj, key) {
39
+ const v = obj[key];
40
+ if (typeof v !== 'string') {
41
+ throw new Error(`BetaSectionImage.${key} must be a string, got: ${typeof v}`);
42
+ }
43
+ }
44
+ static assertIso8601DateString(obj, key) {
45
+ const v = obj[key];
46
+ if (typeof v !== 'string') {
47
+ throw new Error(`BetaSectionImage.${key} must be an ISO 8601 date string, got: ${typeof v}`);
48
+ }
49
+ const date = new Date(v);
50
+ if (Number.isNaN(date.getTime())) {
51
+ throw new Error(`BetaSectionImage.${key} must be a valid ISO 8601 date string, got: ${v}`);
52
+ }
53
+ }
54
+ }
55
+ exports.BetaSectionImage = BetaSectionImage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ropegeo-common",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "Shared types and utilities for RopeGeo and WebScraper",
5
5
  "license": "ISC",
6
6
  "repository": {
@@ -1,12 +0,0 @@
1
- import type { RopewikiImageView } from './ropewikiImageView';
2
- /**
3
- * Beta section view for getRopewikiPageView.
4
- */
5
- export interface RopewikiBetaSectionView {
6
- order: number;
7
- title: string;
8
- text: string;
9
- images: RopewikiImageView[];
10
- latestRevisionDate: Date;
11
- }
12
- //# sourceMappingURL=ropewikiBetaSectionView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ropewikiBetaSectionView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiPageView/ropewikiBetaSectionView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,kBAAkB,EAAE,IAAI,CAAC;CAC5B"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- /**
2
- * Image view for getRopewikiPageView (banner or beta-section image).
3
- */
4
- export interface RopewikiImageView {
5
- order: number;
6
- url: string;
7
- linkUrl: string;
8
- caption: string;
9
- latestRevisionDate: Date;
10
- }
11
- //# sourceMappingURL=ropewikiImageView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ropewikiImageView.d.ts","sourceRoot":"","sources":["../../../../src/types/api/getRopewikiPageView/ropewikiImageView.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,IAAI,CAAC;CAC5B"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });