n_a_types 3.0.28 → 3.1.0

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.
Files changed (3) hide show
  1. package/index.ts +311 -1
  2. package/package.json +6 -3
  3. package/V3.ts +0 -284
package/index.ts CHANGED
@@ -1 +1,311 @@
1
- export * as V3 from './V3'
1
+ import z from "zod";
2
+
3
+ export type ZodSatisfies<T> = z.ZodObject<{
4
+ [K in keyof T]: K extends keyof T ? z.ZodType<T[K]> : never;
5
+ }>;
6
+
7
+ export type ApiError = { error: string } | { message: string };
8
+
9
+ export const API_VERSION = 3;
10
+
11
+ const coordSchema = z.object({ x: z.number(), y: z.number() })
12
+ export type Coord = z.infer<typeof coordSchema>
13
+
14
+ import { GeoJSONFeatureSchema, GeoJSONMultiPolygonSchema, type GeoJSONFeature } from "zod-geojson";
15
+ export type GeojsonFeaturePolygon = GeoJSONFeature;
16
+
17
+ export const climbTypeSchema = z.enum(['TRAD', 'SPORT', 'BOULDER', 'ICE', 'TOPROPE'])
18
+ export type ClimbType = z.infer<typeof climbTypeSchema>;
19
+
20
+ export const starRatingSchema = z.enum(['ONE', 'TWO', 'THREE', 'FOUR'])
21
+ export type StarRating = z.infer<typeof starRatingSchema>;
22
+
23
+ export const climbLogAttemptTypeSchema = z.enum(['FLASH', 'REDPOINT', 'ONSIGHT', 'ATTEMPT'])
24
+ export type ClimbLogAttemptType = z.infer<typeof climbLogAttemptTypeSchema>;
25
+
26
+ export const mapInfoAreaTypeSchema = z.enum(['PRIVATE_LAND', 'PUBLIC_LAND', 'OTHER_ACCESS_CONCERN'])
27
+ export type MapInfoAreaType = z.infer<typeof mapInfoAreaTypeSchema>;
28
+
29
+ export const gradeFeedbackTagEnum = z.enum(['SOFT', 'SOLID', 'SANDBAG']);
30
+ export type GradeFeedbackTag = z.infer<typeof gradeFeedbackTagEnum>;
31
+
32
+
33
+ export const latLongSchema = z.object({ latitude: z.number(), longitude: z.number() });
34
+ export type LatLong = z.infer<typeof latLongSchema>;
35
+ export type TrailPolyline = LatLong[];
36
+ const areaSwipeDirectionSchema = z.enum(['LEFT_TO_RIGHT', 'RIGHT_TO_LEFT']);
37
+ export type AreaSwipeDirection = z.infer<typeof areaSwipeDirectionSchema>;
38
+
39
+ export const imageSchema = z.object({
40
+ s3URL: z.string(),
41
+ s3Key: z.string(),
42
+ guidebookId: z.number().nullable(),
43
+ description: z.string().nullable(),
44
+ naturalHeight: z.number(),
45
+ naturalWidth: z.number(),
46
+ blurhash: z.string().nullable(),
47
+ climbId: z.number().nullable(),
48
+ })
49
+ export type Image = z.infer<typeof imageSchema>
50
+
51
+ export const climbPathSchema = z.object({
52
+ id: z.number(),
53
+ climbId: z.number().nullable(),
54
+ climbImageGroupId: z.number().nullable(),
55
+ climbVariation: z.number(),
56
+ climbTopoImageSVGPathCoords: z.array(coordSchema),
57
+ })
58
+
59
+ export const climbImageGroupClimbPathSchema = climbPathSchema.extend({
60
+ climb: z.object({
61
+ id: z.number(),
62
+ areaClimbNumber: z.number(),
63
+ climbType: climbTypeSchema.nullable(),
64
+ grade: z.string().nullable(),
65
+ }).nullable(),
66
+ });
67
+
68
+ export const climbImageGroupSchema = z.object({
69
+ climbPaths: z.array(climbImageGroupClimbPathSchema),
70
+ climbs: z.array(z.object({
71
+ id: z.number(),
72
+ areaClimbNumber: z.number(),
73
+ })),
74
+ id: z.number(),
75
+ image: z.string(),
76
+ areaId: z.number().nullable(),
77
+ areaName: z.string(),
78
+ sortOrder: z.number(),
79
+ anchors: z.array(coordSchema),
80
+ imageNew: imageSchema,
81
+ imageS3Key: z.string(),
82
+ })
83
+ export type ClimbImageGroup = z.infer<typeof climbImageGroupSchema>
84
+
85
+
86
+ const poiSchema = z.object({
87
+ id: z.string(),
88
+ image: z.string().nullable(),
89
+ description: z.string(),
90
+ latitude: z.number(),
91
+ longitude: z.number(),
92
+ guidebookId: z.number().nullable(),
93
+ })
94
+ export type POI = z.infer<typeof poiSchema>
95
+
96
+
97
+ const guidebookProductDataSchema = z.object({
98
+ guidebooks: z.array(z.object({
99
+ additionalImages: z.array(imageSchema),
100
+ digitalVersionPublished: z.boolean(),
101
+ id: z.number(),
102
+ title: z.string(),
103
+ author: z.string(),
104
+ coverImage: z.string(),
105
+ description: z.string(),
106
+ isFreeSampleGuidebook: z.boolean(),
107
+ version: z.number(),
108
+ heroImage: z.string(),
109
+ state: z.string(),
110
+ accessTrailPolylines: z.array(z.array(latLongSchema)),
111
+ digitalGuidePrice: z.number(),
112
+ coverImageNew: imageSchema.nullable(),
113
+ heroImageNew: imageSchema.nullable(),
114
+ coverImageS3Key: z.string().nullable(),
115
+ heroImageS3Key: z.string().nullable(),
116
+ latitude: z.number().nullable(),
117
+ longitude: z.number().nullable(),
118
+ swipeDirection: areaSwipeDirectionSchema,
119
+ longDescription: z.string().nullable(),
120
+ })),
121
+ apiVersion: z.number(),
122
+ })
123
+ export type GuidebookProductData = z.infer<typeof guidebookProductDataSchema>
124
+
125
+
126
+ export const climbMapGroupSchema = z.object({
127
+ id: z.string(),
128
+ areaId: z.number(),
129
+ climbs: z.array(z.object({ id: z.number() })),
130
+ geojsonMultiPolygon: GeoJSONMultiPolygonSchema.nullable(),
131
+ });
132
+ export type ClimbMapGroup = z.infer<typeof climbMapGroupSchema>
133
+
134
+
135
+ const climbLogPrimaryCIGSchema = z.object({
136
+ climbPaths: z.array(climbPathSchema),
137
+ id: z.number(),
138
+ image: z.string(),
139
+ areaId: z.number().nullable(),
140
+ areaName: z.string(),
141
+ sortOrder: z.number(),
142
+ anchors: z.array(coordSchema),
143
+ imageNew: imageSchema,
144
+ imageS3Key: z.string(),
145
+ })
146
+
147
+ export const climbLogSchema = z.object({
148
+ id: z.string(),
149
+ attemptDate: z.string(),
150
+ createdAt: z.string(),
151
+ attemptType: climbLogAttemptTypeSchema,
152
+ userId: z.string(),
153
+ climbId: z.number(),
154
+ climbLogBodyText: z.string().nullable(),
155
+ climb: z.object({
156
+ id: z.number(),
157
+ climbName: z.string(),
158
+ grade: z.string().nullable(),
159
+ primaryClimbImageGroup: climbLogPrimaryCIGSchema.nullable(),
160
+ }),
161
+ userStarRating: z.number().nullable(),
162
+ numberOfAttempts: z.number().nullable(),
163
+ locationString: z.string(),
164
+ User: z.object({ publicDisplayName: z.string().nullable() }),
165
+ isPrivate: z.boolean(),
166
+ notes: z.string().nullable(),
167
+ })
168
+ export type ClimbLog = z.infer<typeof climbLogSchema>
169
+
170
+
171
+ const climbSchema = z.object({
172
+ primaryClimbImageGroup: climbLogPrimaryCIGSchema.nullable(),
173
+ primaryClimbImageGroupid: z.number().nullable(),
174
+ climbImageGroups: z.array(climbLogPrimaryCIGSchema),
175
+ id: z.number(),
176
+ climbName: z.string(),
177
+ areaClimbNumber: z.number(),
178
+ description: z.string().nullable(),
179
+ firstAscent: z.string().nullable(),
180
+ height: z.string().nullable(),
181
+ areaId: z.number().nullable(),
182
+ starRating: starRatingSchema.nullable(),
183
+ areaName: z.string(),
184
+ climbType: climbTypeSchema.nullable(),
185
+ grade: z.string().nullable(),
186
+ beta: z.string().nullable(),
187
+ extras: z.string().nullable(),
188
+ descent: z.string().nullable(),
189
+ approach: z.string().nullable(),
190
+ pitches: z.string().nullable(),
191
+ variations: z.string().nullable(),
192
+ protection: z.string().nullable(),
193
+ guidebookId: z.number().nullable(),
194
+ topo3DUrl: z.string().nullable(),
195
+ overviewImageURL: z.string().nullable(),
196
+ additionalImages: z.array(imageSchema),
197
+ latitude: z.number().nullable(),
198
+ longitude: z.number().nullable(),
199
+ climbMapGroupId: z.string().nullable(),
200
+ })
201
+ export type Climb = z.infer<typeof climbSchema>
202
+
203
+
204
+ const climbFeedbackSchema = z.object({
205
+ climbId: z.number(),
206
+ userId: z.string(),
207
+ userStarRating: z.number().or(z.null()),
208
+ gradeFeedbackTag: gradeFeedbackTagEnum.nullable()
209
+ })
210
+ export type ClimbFeedback = z.infer<typeof climbFeedbackSchema>
211
+
212
+
213
+ export const ClimbFeedbackInputSchema = z.object({
214
+ climbId: z.number(),
215
+ userId: z.string(),
216
+ userStarRating: z.number().min(0).max(4).nullable(),
217
+ gradeFeedbackTag: gradeFeedbackTagEnum.nullable()
218
+ })
219
+ export type ClimbFeedbackInput = z.infer<typeof ClimbFeedbackInputSchema>
220
+
221
+
222
+ export const climbFeedbackAggregateDataSchema = z.object({
223
+ climbId: z.number(),
224
+ tags: z.record(gradeFeedbackTagEnum, z.number()),
225
+ averageUserStarRating: z.object({
226
+ rating: z.number().nullable(),
227
+ count: z.number(),
228
+ }),
229
+ });
230
+ export type ClimbFeedbackAggregateData = z.infer<typeof climbFeedbackAggregateDataSchema>;
231
+
232
+
233
+ const areaSchema = z.object({
234
+ climbImageGroups: z.array(climbImageGroupSchema),
235
+ climbMapGroups: z.array(climbMapGroupSchema),
236
+ climbs: z.array(climbSchema),
237
+ areaName: z.string(),
238
+ sectionAreaNumber: z.number(),
239
+ sectionName: z.string(),
240
+ id: z.number(),
241
+ sectionId: z.number().nullable(),
242
+ guidebookId: z.number(),
243
+ pano: z.string(),
244
+ panoNew: imageSchema.nullable(),
245
+ latitude: z.number().nullable(),
246
+ longitude: z.number().nullable(),
247
+ overview: z.string().nullable(),
248
+ directions: z.string().nullable(),
249
+ approach: z.string().nullable(),
250
+ aspect: z.string().nullable(),
251
+ swipeDirection: areaSwipeDirectionSchema,
252
+ accessClosureDescription: z.string().nullable(),
253
+ imageS3Key: z.string().nullable(),
254
+ geojsonFeaturePolygon: GeoJSONFeatureSchema.nullable(),
255
+ })
256
+ export type Area = z.infer<typeof areaSchema>
257
+
258
+
259
+ const sectionSchema = z.object({
260
+ areas: z.array(areaSchema),
261
+ sectionName: z.string(),
262
+ guidebookId: z.number().nullable(),
263
+ bookSectionNumber: z.number(),
264
+ swipeDirection: areaSwipeDirectionSchema,
265
+ id: z.number(),
266
+ });
267
+ export type Section = z.infer<typeof sectionSchema>
268
+
269
+
270
+ const mapInfoAreaSchema = z.object({
271
+ id: z.string(),
272
+ mapLabel: z.string(),
273
+ infoSheetTitle: z.string(),
274
+ infoSheetBody: z.string(),
275
+ infoExternalWebLink: z.string().nullable(),
276
+ guidebookId: z.number().nullable(),
277
+ mapInfoAreaType: mapInfoAreaTypeSchema,
278
+ boundaryPolyline: z.array(latLongSchema),
279
+ });
280
+ export type MapInfoArea = z.infer<typeof mapInfoAreaSchema>
281
+
282
+
283
+ const guidebookSchema = z.object({
284
+ digitalVersionPublished: z.boolean(),
285
+ apiVersion: z.number(),
286
+ images: z.array(z.string()),
287
+ sections: z.array(sectionSchema),
288
+ id: z.number(),
289
+ title: z.string(),
290
+ author: z.string(),
291
+ coverImage: z.string(),
292
+ coverImageNew: imageSchema.nullable(),
293
+ description: z.string(),
294
+ isFreeSampleGuidebook: z.boolean(),
295
+ latitude: z.number().nullable(),
296
+ longitude: z.number().nullable(),
297
+ version: z.number(),
298
+ heroImage: z.string(),
299
+ heroImageNew: imageSchema.nullable(),
300
+ state: z.string(),
301
+ additionalImages: z.array(imageSchema),
302
+ accessTrailPolylines: z.array(z.array(latLongSchema)),
303
+ parkingInfo: z.array(poiSchema),
304
+ digitalGuidePrice: z.number(),
305
+ coverImageS3Key: z.string().nullable(),
306
+ heroImageS3Key: z.string().nullable(),
307
+ swipeDirection: areaSwipeDirectionSchema,
308
+ longDescription: z.string().nullable(),
309
+ mapInfoAreas: z.array(mapInfoAreaSchema),
310
+ })
311
+ export type Guidebook = z.infer<typeof guidebookSchema>
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "n_a_types",
3
- "version": "3.0.28",
3
+ "version": "3.1.0",
4
4
  "description": "types",
5
5
  "main": "index.ts",
6
6
  "author": "",
7
- "license": "ISC"
8
- }
7
+ "license": "ISC",
8
+ "dependencies": {
9
+ "zod": "^4.3.6"
10
+ }
11
+ }
package/V3.ts DELETED
@@ -1,284 +0,0 @@
1
- export const API_VERSION = 3;
2
- export type Coord = { x: number, y: number };
3
- export type LatLong = { latitude: number, longitude: number };
4
- export type TrailPolyline = LatLong[];
5
- export type ClimbType = 'TRAD' | 'SPORT' | 'BOULDER' | 'ICE' | 'TOPROPE';
6
- export type StarRating = "ONE" | "TWO" | "THREE" | "FOUR";
7
- export type AreaSwipeDirection = 'LEFT_TO_RIGHT' | 'RIGHT_TO_LEFT';
8
- import type { GeoJSONFeature, GeoJSONMultiPolygon } from "zod-geojson";
9
- export type GeojsonFeaturePolygon = GeoJSONFeature;
10
- export type ClimbLogAttemptType = 'FLASH' | 'REDPOINT' | 'ONSIGHT' | 'ATTEMPT';
11
- export type GradeFeedbackTag = 'SOFT' | 'SOLID' | 'SANDBAG';
12
- export type MapInfoAreaType = 'PRIVATE_LAND' | 'PUBLIC_LAND' | 'OTHER_ACCESS_CONCERN'
13
-
14
- ///GUIDEBOOK FETCH
15
- export type Guidebook = {
16
- digitalVersionPublished: boolean,
17
- apiVersion: number,
18
- images: string[],
19
- sections: Section[];
20
- id: number;
21
- title: string;
22
- author: string;
23
- coverImage: string;
24
- coverImageNew: Image | null;
25
- description: string;
26
- isFreeSampleGuidebook: boolean;
27
- latitude: number | null;
28
- longitude: number | null;
29
- version: number;
30
- heroImage: string;
31
- heroImageNew: Image | null;
32
- state: string;
33
- additionalImages: Image[];
34
- accessTrailPolylines: TrailPolyline[];
35
- parkingInfo: POI[];
36
- digitalGuidePrice: number;
37
- coverImageS3Key: string | null;
38
- heroImageS3Key: string | null;
39
- swipeDirection: AreaSwipeDirection;
40
- longDescription: string | null;
41
- mapInfoAreas: {
42
- id: string;
43
- mapLabel: string;
44
- infoSheetTitle: string;
45
- infoSheetBody: string;
46
- infoExternalWebLink: string | null;
47
- guidebookId: number | null;
48
- mapInfoAreaType: MapInfoAreaType
49
- boundaryPolyline: LatLong[];
50
- }[]
51
- }
52
-
53
- export type Section = {
54
- areas: Area[];
55
- sectionName: string;
56
- guidebookId: number | null;
57
- bookSectionNumber: number;
58
- swipeDirection: AreaSwipeDirection;
59
- id: number;
60
- }
61
-
62
- export type Area = {
63
- climbImageGroups: ClimbImageGroup[];
64
- climbMapGroups: ClimbMapGroup[];
65
- climbs: Climb[];
66
- areaName: string;
67
- sectionAreaNumber: number;
68
- sectionName: string;
69
- id: number;
70
- sectionId: number | null;
71
- guidebookId: number;
72
- pano: string;
73
- panoNew: Image | null;
74
- latitude: number | null;
75
- longitude: number | null;
76
- overview: string | null;
77
- directions: string | null;
78
- approach: string | null;
79
- aspect: string | null;
80
- swipeDirection: AreaSwipeDirection;
81
- accessClosureDescription: string | null;
82
- imageS3Key: string | null;
83
- geojsonFeaturePolygon: GeojsonFeaturePolygon | null;
84
- }
85
-
86
- export type ClimbImageGroup = {
87
- climbPaths: ({
88
- climb: {
89
- id: number;
90
- areaClimbNumber: number;
91
- climbType: ClimbType | null;
92
- grade: string | null;
93
- } | null;
94
- id: number;
95
- climbId: number | null;
96
- climbImageGroupId: number | null;
97
- climbVariation: number;
98
- climbTopoImageSVGPathCoords: Coord[];
99
- })[];
100
- climbs: {
101
- id: number;
102
- areaClimbNumber: number;
103
- }[];
104
- id: number;
105
- image: string;
106
- areaId: number | null;
107
- areaName: string;
108
- sortOrder: number;
109
- anchors: Coord[];
110
- imageNew: Image;
111
- imageS3Key: string;
112
- }
113
-
114
- export type Climb = {
115
- primaryClimbImageGroup: ({
116
- climbPaths: {
117
- id: number;
118
- climbId: number | null;
119
- climbImageGroupId: number | null;
120
- climbVariation: number;
121
- climbTopoImageSVGPathCoords: Coord[];
122
- }[];
123
- id: number;
124
- image: string;
125
- areaId: number | null;
126
- areaName: string;
127
- sortOrder: number;
128
- anchors: Coord[];
129
- imageNew: Image;
130
- imageS3Key: string;
131
- }) | null,
132
- primaryClimbImageGroupid: number | null,
133
- climbImageGroups: ({
134
- climbPaths: {
135
- id: number;
136
- climbId: number | null;
137
- climbImageGroupId: number | null;
138
- climbVariation: number;
139
- climbTopoImageSVGPathCoords: Coord[];
140
- }[];
141
- id: number;
142
- image: string;
143
- areaId: number | null;
144
- areaName: string;
145
- sortOrder: number;
146
- anchors: Coord[];
147
- imageS3Key: string;
148
- imageNew: Image;
149
- })[];
150
- id: number;
151
- climbName: string;
152
- areaClimbNumber: number;
153
- description: string | null;
154
- firstAscent: string | null;
155
- height: string | null;
156
- areaId: number | null;
157
- starRating: StarRating | null;
158
- areaName: string;
159
- climbType: ClimbType | null;
160
- grade: string | null;
161
- beta: string | null;
162
- extras: string | null;
163
- descent: string | null;
164
- approach: string | null;
165
- pitches: string | null;
166
- variations: string | null;
167
- protection: string | null;
168
- guidebookId: number | null;
169
- topo3DUrl: string | null;
170
- overviewImageURL: string | null;
171
- additionalImages: Image[];
172
- latitude: number | null,
173
- longitude: number | null,
174
- climbMapGroupId: string | null
175
- }
176
-
177
- export type Image = {
178
- s3Key: string;
179
- s3URL: string;
180
- description: string | null;
181
- naturalWidth: number;
182
- naturalHeight: number;
183
- blurhash: string | null;
184
- climbId: number | null;
185
- guidebookId: number | null;
186
-
187
- }
188
-
189
- export type POI = {
190
- id: string;
191
- image: string | null;
192
- description: string;
193
- latitude: number;
194
- longitude: number;
195
- guidebookId: number | null;
196
- }
197
-
198
- ///PRODUCT DATA FETCH
199
- export type GuidebookProductData = {
200
- guidebooks: {
201
- additionalImages: Image[],
202
- digitalVersionPublished: boolean,
203
- id: number;
204
- title: string;
205
- author: string;
206
- coverImage: string;
207
- description: string;
208
- isFreeSampleGuidebook: boolean;
209
- version: number;
210
- heroImage: string;
211
- state: string;
212
- accessTrailPolylines: TrailPolyline[];
213
- digitalGuidePrice: number;
214
- coverImageNew: Image | null;
215
- heroImageNew: Image | null;
216
- coverImageS3Key: string | null;
217
- heroImageS3Key: string | null;
218
- latitude: number | null;
219
- longitude: number | null;
220
- swipeDirection: AreaSwipeDirection;
221
- longDescription: string | null
222
- }[], apiVersion: number;
223
- }
224
-
225
- export type ClimbMapGroup = {
226
- id: string,
227
- areaId: number,
228
- climbs: { id: number }[],
229
- geojsonMultiPolygon: GeoJSONMultiPolygon | null
230
- }
231
-
232
- export type ClimbLog = {
233
- id: string;
234
- attemptDate: string;
235
- createdAt: string;
236
- attemptType: ClimbLogAttemptType;
237
- userId: string;
238
- climbId: number;
239
- climbLogBodyText: string | null;
240
- climb: {
241
- id: number;
242
- climbName: string;
243
- grade: string | null;
244
- primaryClimbImageGroup: ({
245
- climbPaths: {
246
- id: number;
247
- climbId: number | null;
248
- climbImageGroupId: number | null;
249
- climbVariation: number;
250
- climbTopoImageSVGPathCoords: Coord[];
251
- }[];
252
- id: number;
253
- image: string;
254
- areaId: number | null;
255
- areaName: string;
256
- sortOrder: number;
257
- anchors: Coord[];
258
- imageNew: Image;
259
- imageS3Key: string;
260
- }) | null
261
- };
262
- userStarRating: number | null;
263
- numberOfAttempts: number | null;
264
- locationString: string;
265
- User: { publicDisplayName: string | null };
266
- isPrivate: boolean;
267
- notes: string | null;
268
- }
269
-
270
- export type ClimbFeedback = {
271
- climbId: number;
272
- userId: string;
273
- userStarRating: number | null;
274
- gradeFeedbackTag: GradeFeedbackTag | null;
275
- }
276
-
277
- export type ClimbFeedbackAggregateData = {
278
- climbId: number,
279
- tags: Record<GradeFeedbackTag, number>,
280
- averageUserStarRating: {
281
- rating: number | null,
282
- count: number
283
- }
284
- }