@dromney/mapthis 0.1.0 → 0.2.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.
- package/README.md +108 -27
- package/dist/ai/index.cjs +105 -1
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +9 -9
- package/dist/ai/index.d.ts +9 -9
- package/dist/ai/index.js +101 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/{domain-Dc1wSTkf.d.cts → domain-CL4ro2YW.d.cts} +1 -1
- package/dist/{domain-CZ-L-ntu.d.ts → domain-Dh8cPBVp.d.ts} +1 -1
- package/dist/generate/index.cjs +1 -1
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +4 -4
- package/dist/generate/index.d.ts +4 -4
- package/dist/generate/index.js +1 -1
- package/dist/generate/index.js.map +1 -1
- package/dist/geocoding/index.d.cts +3 -3
- package/dist/geocoding/index.d.ts +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parser-CrG1A6dD.d.ts +176 -0
- package/dist/parser-DsIwIsHK.d.cts +176 -0
- package/dist/react/index.d.cts +197 -0
- package/dist/react/index.d.ts +197 -0
- package/dist/{schemas-Dy5coqXo.d.cts → schemas-CZao45EU.d.cts} +1 -1
- package/dist/{schemas-Dy5coqXo.d.ts → schemas-CZao45EU.d.ts} +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/{types-BhqKlq0k.d.ts → types-BhPqZwOj.d.ts} +2 -2
- package/dist/{types-rFjK5YcJ.d.cts → types-C-xqh9Sh.d.cts} +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +10 -6
- package/dist/parser-CzXzpmVv.d.cts +0 -111
- package/dist/parser-N7-fNxeu.d.ts +0 -111
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
4
|
+
import { h as PlaceMap, f as Place, g as PlaceGroup } from '../domain-CL4ro2YW.cjs';
|
|
5
|
+
import { c as ProviderAutocompletePlace } from '../schemas-CZao45EU.cjs';
|
|
6
|
+
import 'zod';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pure autofit math. Given a viewport size and a list of mappable places,
|
|
10
|
+
* compute a `{ center, zoom }` pair that frames all the places inside the
|
|
11
|
+
* viewport with a small pin-height margin at the top.
|
|
12
|
+
*
|
|
13
|
+
* Adapted from the Stack Overflow solution for "Google Maps v3: how to
|
|
14
|
+
* calculate the zoom level for a given bounds" — see
|
|
15
|
+
* https://stackoverflow.com/questions/6048975 — because Google Maps'
|
|
16
|
+
* `map.fitBounds` has never been consistently reliable for us.
|
|
17
|
+
*/
|
|
18
|
+
interface CenterZoomAutofit {
|
|
19
|
+
center: google.maps.LatLngLiteral;
|
|
20
|
+
zoom: number;
|
|
21
|
+
}
|
|
22
|
+
interface ContainerDims {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}
|
|
26
|
+
interface MappablePlace {
|
|
27
|
+
lat: number;
|
|
28
|
+
lon: number;
|
|
29
|
+
}
|
|
30
|
+
declare const DEFAULT_CENTER_ZOOM: CenterZoomAutofit;
|
|
31
|
+
/**
|
|
32
|
+
* Compute center and zoom for an autofit of the given places inside a
|
|
33
|
+
* container of the given size.
|
|
34
|
+
*
|
|
35
|
+
* - Zero places → {@link DEFAULT_CENTER_ZOOM}.
|
|
36
|
+
* - One place → centered on that place at zoom 10.
|
|
37
|
+
* - Multiple places → tight bounding box with a pin-sized margin at top.
|
|
38
|
+
*/
|
|
39
|
+
declare function autofitCenterZoom(dims: ContainerDims, places: MappablePlace[]): CenterZoomAutofit;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The full context value exposed by {@link MapProvider}. Includes the three
|
|
43
|
+
* data arrays, selection state, and a small set of click handlers derived
|
|
44
|
+
* from them.
|
|
45
|
+
*
|
|
46
|
+
* This is deliberately data-only — no mutations, no network calls. The
|
|
47
|
+
* consumer owns the data (typically via their own query layer) and passes it
|
|
48
|
+
* to {@link MapProvider} as props. All mutation/persistence concerns stay in
|
|
49
|
+
* the consumer's app.
|
|
50
|
+
*/
|
|
51
|
+
interface MapContextValue {
|
|
52
|
+
map: PlaceMap | null;
|
|
53
|
+
places: Place[];
|
|
54
|
+
groups: PlaceGroup[];
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
isError: boolean;
|
|
57
|
+
isEditable: boolean;
|
|
58
|
+
selectedPlaceId: string | null;
|
|
59
|
+
setSelectedPlaceId: (id: string | null) => void;
|
|
60
|
+
selectedGroupId: string | null;
|
|
61
|
+
setSelectedGroupId: (id: string | null) => void;
|
|
62
|
+
/**
|
|
63
|
+
* ID of the place whose info window is currently open, or null if none.
|
|
64
|
+
* Only one info window is shown at a time.
|
|
65
|
+
*/
|
|
66
|
+
infoWindowPlaceId: string | null;
|
|
67
|
+
setInfoWindowPlaceId: (id: string | null) => void;
|
|
68
|
+
hideAllInfoWindows: () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Select a place and toggle its info window. Typically wired to marker
|
|
71
|
+
* clicks.
|
|
72
|
+
*/
|
|
73
|
+
handleMarkerClick: (placeId: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Select a place and force its info window open. Typically wired to list
|
|
76
|
+
* item clicks.
|
|
77
|
+
*/
|
|
78
|
+
handleListClick: (placeId: string) => void;
|
|
79
|
+
}
|
|
80
|
+
declare const MapContext: react.Context<MapContextValue>;
|
|
81
|
+
declare const useMap: () => MapContextValue;
|
|
82
|
+
/**
|
|
83
|
+
* Look up a single place by id from the current {@link MapProvider} context.
|
|
84
|
+
* Returns `null` if the id is not in the list.
|
|
85
|
+
*/
|
|
86
|
+
declare function usePlace(id: string | null | undefined): Place | null;
|
|
87
|
+
interface MapProviderProps {
|
|
88
|
+
/** The current map entity, or null if none is loaded. */
|
|
89
|
+
map: PlaceMap | null;
|
|
90
|
+
/** Places belonging to this map. Order is preserved as render order. */
|
|
91
|
+
places: Place[];
|
|
92
|
+
/** Groups belonging to this map. */
|
|
93
|
+
groups: PlaceGroup[];
|
|
94
|
+
/** Whether any of the data is still loading. Defaults to false. */
|
|
95
|
+
isLoading?: boolean;
|
|
96
|
+
/** Whether any of the data failed to load. Defaults to false. */
|
|
97
|
+
isError?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the current viewer should be allowed to edit the map. This
|
|
100
|
+
* package does not perform any auth — the consumer decides.
|
|
101
|
+
*/
|
|
102
|
+
isEditable?: boolean;
|
|
103
|
+
children: ReactNode;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Provide map data and selection state to descendants. Use in conjunction
|
|
107
|
+
* with {@link GoogleMapsViewer} and {@link PlaceMarker}, or with your own
|
|
108
|
+
* components that call {@link useMap} / {@link usePlace}.
|
|
109
|
+
*/
|
|
110
|
+
declare function MapProvider({ map, places, groups, isLoading, isError, isEditable, children, }: MapProviderProps): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Return the display name for a place, falling back through the common
|
|
114
|
+
* sources: provider-resolved `name`, the raw `query` used at creation time,
|
|
115
|
+
* the first segment of `address`, and finally an empty string.
|
|
116
|
+
*/
|
|
117
|
+
declare function getPlaceDisplayName(place: Place | null | undefined): string;
|
|
118
|
+
interface PlaceMarkerProps {
|
|
119
|
+
place: Place;
|
|
120
|
+
/**
|
|
121
|
+
* Custom info window content. Receives the place and its group (if any).
|
|
122
|
+
* When omitted, a basic "name + description" block is rendered.
|
|
123
|
+
*/
|
|
124
|
+
renderContent?: (place: Place, group: PlaceGroup | null) => ReactNode;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A single marker + info window pair driven by a {@link Place}. Reads
|
|
128
|
+
* selection / info window state from {@link useMap}.
|
|
129
|
+
*
|
|
130
|
+
* This component renders nothing if the place is missing coordinates, has a
|
|
131
|
+
* geocoding error, or belongs to a hidden group — consumers don't need to
|
|
132
|
+
* filter before passing it in.
|
|
133
|
+
*/
|
|
134
|
+
declare function PlaceMarker({ place, renderContent }: PlaceMarkerProps): react_jsx_runtime.JSX.Element | null;
|
|
135
|
+
|
|
136
|
+
interface GoogleMapsViewerProps {
|
|
137
|
+
/** Google Maps JS API key. */
|
|
138
|
+
apiKey: string;
|
|
139
|
+
/**
|
|
140
|
+
* Optional Google Map ID (from your Google Cloud console). Required if
|
|
141
|
+
* you want custom styles or {@link AdvancedMarker} to work correctly.
|
|
142
|
+
*/
|
|
143
|
+
mapId?: string;
|
|
144
|
+
/** Starting center if no places are loaded. Defaults to Washington, DC. */
|
|
145
|
+
defaultCenter?: google.maps.LatLngLiteral;
|
|
146
|
+
/** Starting zoom if no places are loaded. Defaults to 4. */
|
|
147
|
+
defaultZoom?: number;
|
|
148
|
+
/** Applied to the outer container `div`. */
|
|
149
|
+
className?: string;
|
|
150
|
+
/** Applied to the outer container `div`. Defaults to full width/height. */
|
|
151
|
+
style?: CSSProperties;
|
|
152
|
+
/** Content rendered while the Google Maps SDK is loading. */
|
|
153
|
+
loadingContent?: ReactNode;
|
|
154
|
+
/**
|
|
155
|
+
* Forwarded to `@vis.gl/react-google-maps`'s `<Map>`. Use this to enable
|
|
156
|
+
* satellite/terrain views.
|
|
157
|
+
*/
|
|
158
|
+
mapTypeId?: google.maps.MapTypeId;
|
|
159
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
160
|
+
streetViewControl?: boolean;
|
|
161
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
162
|
+
zoomControl?: boolean;
|
|
163
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
164
|
+
mapTypeControl?: boolean;
|
|
165
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
166
|
+
fullscreenControl?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Render prop for customizing the info window body for every marker.
|
|
169
|
+
* Forwarded to {@link PlaceMarker}. When omitted, a basic default is used.
|
|
170
|
+
*/
|
|
171
|
+
renderMarkerContent?: (place: Place, group: PlaceGroup | null) => ReactNode;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Data-driven Google Maps viewer. Must be rendered inside a
|
|
175
|
+
* {@link MapProvider}.
|
|
176
|
+
*
|
|
177
|
+
* Pans and zooms automatically whenever the list of places in context
|
|
178
|
+
* changes (via a ResizeObserver-measured container and the pure
|
|
179
|
+
* {@link autofitCenterZoom} helper).
|
|
180
|
+
*/
|
|
181
|
+
declare function GoogleMapsViewer({ apiKey, mapId, defaultCenter, defaultZoom, className, style, loadingContent, mapTypeId, streetViewControl, zoomControl, mapTypeControl, fullscreenControl, renderMarkerContent, }: GoogleMapsViewerProps): react_jsx_runtime.JSX.Element;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Given a Google Autocomplete prediction (from an input-backed autocomplete
|
|
185
|
+
* session), fetch the full place details from the browser-side Places API
|
|
186
|
+
* and normalize into a {@link ProviderAutocompletePlace}.
|
|
187
|
+
*
|
|
188
|
+
* This function requires the Google Maps JS API with the `places` library to
|
|
189
|
+
* be loaded in the browser (i.e. `google.maps.places.PlacesService` must
|
|
190
|
+
* exist). Typical usage is in a React component that also renders
|
|
191
|
+
* {@link GoogleMapsViewer}, which itself loads the API via `<APIProvider>`.
|
|
192
|
+
*
|
|
193
|
+
* Rejects if the Places call fails or the result lacks geometry/address.
|
|
194
|
+
*/
|
|
195
|
+
declare function getPlaceDetailsFromGoogleAutocompleteSuggestion(query: string, sug: google.maps.places.AutocompletePrediction): Promise<ProviderAutocompletePlace>;
|
|
196
|
+
|
|
197
|
+
export { type CenterZoomAutofit, type ContainerDims, DEFAULT_CENTER_ZOOM, GoogleMapsViewer, type GoogleMapsViewerProps, MapContext, type MapContextValue, MapProvider, type MapProviderProps, type MappablePlace, PlaceMarker, type PlaceMarkerProps, autofitCenterZoom, getPlaceDetailsFromGoogleAutocompleteSuggestion, getPlaceDisplayName, useMap, usePlace };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
4
|
+
import { h as PlaceMap, f as Place, g as PlaceGroup } from '../domain-Dh8cPBVp.js';
|
|
5
|
+
import { c as ProviderAutocompletePlace } from '../schemas-CZao45EU.js';
|
|
6
|
+
import 'zod';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pure autofit math. Given a viewport size and a list of mappable places,
|
|
10
|
+
* compute a `{ center, zoom }` pair that frames all the places inside the
|
|
11
|
+
* viewport with a small pin-height margin at the top.
|
|
12
|
+
*
|
|
13
|
+
* Adapted from the Stack Overflow solution for "Google Maps v3: how to
|
|
14
|
+
* calculate the zoom level for a given bounds" — see
|
|
15
|
+
* https://stackoverflow.com/questions/6048975 — because Google Maps'
|
|
16
|
+
* `map.fitBounds` has never been consistently reliable for us.
|
|
17
|
+
*/
|
|
18
|
+
interface CenterZoomAutofit {
|
|
19
|
+
center: google.maps.LatLngLiteral;
|
|
20
|
+
zoom: number;
|
|
21
|
+
}
|
|
22
|
+
interface ContainerDims {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}
|
|
26
|
+
interface MappablePlace {
|
|
27
|
+
lat: number;
|
|
28
|
+
lon: number;
|
|
29
|
+
}
|
|
30
|
+
declare const DEFAULT_CENTER_ZOOM: CenterZoomAutofit;
|
|
31
|
+
/**
|
|
32
|
+
* Compute center and zoom for an autofit of the given places inside a
|
|
33
|
+
* container of the given size.
|
|
34
|
+
*
|
|
35
|
+
* - Zero places → {@link DEFAULT_CENTER_ZOOM}.
|
|
36
|
+
* - One place → centered on that place at zoom 10.
|
|
37
|
+
* - Multiple places → tight bounding box with a pin-sized margin at top.
|
|
38
|
+
*/
|
|
39
|
+
declare function autofitCenterZoom(dims: ContainerDims, places: MappablePlace[]): CenterZoomAutofit;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The full context value exposed by {@link MapProvider}. Includes the three
|
|
43
|
+
* data arrays, selection state, and a small set of click handlers derived
|
|
44
|
+
* from them.
|
|
45
|
+
*
|
|
46
|
+
* This is deliberately data-only — no mutations, no network calls. The
|
|
47
|
+
* consumer owns the data (typically via their own query layer) and passes it
|
|
48
|
+
* to {@link MapProvider} as props. All mutation/persistence concerns stay in
|
|
49
|
+
* the consumer's app.
|
|
50
|
+
*/
|
|
51
|
+
interface MapContextValue {
|
|
52
|
+
map: PlaceMap | null;
|
|
53
|
+
places: Place[];
|
|
54
|
+
groups: PlaceGroup[];
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
isError: boolean;
|
|
57
|
+
isEditable: boolean;
|
|
58
|
+
selectedPlaceId: string | null;
|
|
59
|
+
setSelectedPlaceId: (id: string | null) => void;
|
|
60
|
+
selectedGroupId: string | null;
|
|
61
|
+
setSelectedGroupId: (id: string | null) => void;
|
|
62
|
+
/**
|
|
63
|
+
* ID of the place whose info window is currently open, or null if none.
|
|
64
|
+
* Only one info window is shown at a time.
|
|
65
|
+
*/
|
|
66
|
+
infoWindowPlaceId: string | null;
|
|
67
|
+
setInfoWindowPlaceId: (id: string | null) => void;
|
|
68
|
+
hideAllInfoWindows: () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Select a place and toggle its info window. Typically wired to marker
|
|
71
|
+
* clicks.
|
|
72
|
+
*/
|
|
73
|
+
handleMarkerClick: (placeId: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Select a place and force its info window open. Typically wired to list
|
|
76
|
+
* item clicks.
|
|
77
|
+
*/
|
|
78
|
+
handleListClick: (placeId: string) => void;
|
|
79
|
+
}
|
|
80
|
+
declare const MapContext: react.Context<MapContextValue>;
|
|
81
|
+
declare const useMap: () => MapContextValue;
|
|
82
|
+
/**
|
|
83
|
+
* Look up a single place by id from the current {@link MapProvider} context.
|
|
84
|
+
* Returns `null` if the id is not in the list.
|
|
85
|
+
*/
|
|
86
|
+
declare function usePlace(id: string | null | undefined): Place | null;
|
|
87
|
+
interface MapProviderProps {
|
|
88
|
+
/** The current map entity, or null if none is loaded. */
|
|
89
|
+
map: PlaceMap | null;
|
|
90
|
+
/** Places belonging to this map. Order is preserved as render order. */
|
|
91
|
+
places: Place[];
|
|
92
|
+
/** Groups belonging to this map. */
|
|
93
|
+
groups: PlaceGroup[];
|
|
94
|
+
/** Whether any of the data is still loading. Defaults to false. */
|
|
95
|
+
isLoading?: boolean;
|
|
96
|
+
/** Whether any of the data failed to load. Defaults to false. */
|
|
97
|
+
isError?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the current viewer should be allowed to edit the map. This
|
|
100
|
+
* package does not perform any auth — the consumer decides.
|
|
101
|
+
*/
|
|
102
|
+
isEditable?: boolean;
|
|
103
|
+
children: ReactNode;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Provide map data and selection state to descendants. Use in conjunction
|
|
107
|
+
* with {@link GoogleMapsViewer} and {@link PlaceMarker}, or with your own
|
|
108
|
+
* components that call {@link useMap} / {@link usePlace}.
|
|
109
|
+
*/
|
|
110
|
+
declare function MapProvider({ map, places, groups, isLoading, isError, isEditable, children, }: MapProviderProps): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Return the display name for a place, falling back through the common
|
|
114
|
+
* sources: provider-resolved `name`, the raw `query` used at creation time,
|
|
115
|
+
* the first segment of `address`, and finally an empty string.
|
|
116
|
+
*/
|
|
117
|
+
declare function getPlaceDisplayName(place: Place | null | undefined): string;
|
|
118
|
+
interface PlaceMarkerProps {
|
|
119
|
+
place: Place;
|
|
120
|
+
/**
|
|
121
|
+
* Custom info window content. Receives the place and its group (if any).
|
|
122
|
+
* When omitted, a basic "name + description" block is rendered.
|
|
123
|
+
*/
|
|
124
|
+
renderContent?: (place: Place, group: PlaceGroup | null) => ReactNode;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A single marker + info window pair driven by a {@link Place}. Reads
|
|
128
|
+
* selection / info window state from {@link useMap}.
|
|
129
|
+
*
|
|
130
|
+
* This component renders nothing if the place is missing coordinates, has a
|
|
131
|
+
* geocoding error, or belongs to a hidden group — consumers don't need to
|
|
132
|
+
* filter before passing it in.
|
|
133
|
+
*/
|
|
134
|
+
declare function PlaceMarker({ place, renderContent }: PlaceMarkerProps): react_jsx_runtime.JSX.Element | null;
|
|
135
|
+
|
|
136
|
+
interface GoogleMapsViewerProps {
|
|
137
|
+
/** Google Maps JS API key. */
|
|
138
|
+
apiKey: string;
|
|
139
|
+
/**
|
|
140
|
+
* Optional Google Map ID (from your Google Cloud console). Required if
|
|
141
|
+
* you want custom styles or {@link AdvancedMarker} to work correctly.
|
|
142
|
+
*/
|
|
143
|
+
mapId?: string;
|
|
144
|
+
/** Starting center if no places are loaded. Defaults to Washington, DC. */
|
|
145
|
+
defaultCenter?: google.maps.LatLngLiteral;
|
|
146
|
+
/** Starting zoom if no places are loaded. Defaults to 4. */
|
|
147
|
+
defaultZoom?: number;
|
|
148
|
+
/** Applied to the outer container `div`. */
|
|
149
|
+
className?: string;
|
|
150
|
+
/** Applied to the outer container `div`. Defaults to full width/height. */
|
|
151
|
+
style?: CSSProperties;
|
|
152
|
+
/** Content rendered while the Google Maps SDK is loading. */
|
|
153
|
+
loadingContent?: ReactNode;
|
|
154
|
+
/**
|
|
155
|
+
* Forwarded to `@vis.gl/react-google-maps`'s `<Map>`. Use this to enable
|
|
156
|
+
* satellite/terrain views.
|
|
157
|
+
*/
|
|
158
|
+
mapTypeId?: google.maps.MapTypeId;
|
|
159
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
160
|
+
streetViewControl?: boolean;
|
|
161
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
162
|
+
zoomControl?: boolean;
|
|
163
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
164
|
+
mapTypeControl?: boolean;
|
|
165
|
+
/** Control visibility flags forwarded to `<Map>`. */
|
|
166
|
+
fullscreenControl?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Render prop for customizing the info window body for every marker.
|
|
169
|
+
* Forwarded to {@link PlaceMarker}. When omitted, a basic default is used.
|
|
170
|
+
*/
|
|
171
|
+
renderMarkerContent?: (place: Place, group: PlaceGroup | null) => ReactNode;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Data-driven Google Maps viewer. Must be rendered inside a
|
|
175
|
+
* {@link MapProvider}.
|
|
176
|
+
*
|
|
177
|
+
* Pans and zooms automatically whenever the list of places in context
|
|
178
|
+
* changes (via a ResizeObserver-measured container and the pure
|
|
179
|
+
* {@link autofitCenterZoom} helper).
|
|
180
|
+
*/
|
|
181
|
+
declare function GoogleMapsViewer({ apiKey, mapId, defaultCenter, defaultZoom, className, style, loadingContent, mapTypeId, streetViewControl, zoomControl, mapTypeControl, fullscreenControl, renderMarkerContent, }: GoogleMapsViewerProps): react_jsx_runtime.JSX.Element;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Given a Google Autocomplete prediction (from an input-backed autocomplete
|
|
185
|
+
* session), fetch the full place details from the browser-side Places API
|
|
186
|
+
* and normalize into a {@link ProviderAutocompletePlace}.
|
|
187
|
+
*
|
|
188
|
+
* This function requires the Google Maps JS API with the `places` library to
|
|
189
|
+
* be loaded in the browser (i.e. `google.maps.places.PlacesService` must
|
|
190
|
+
* exist). Typical usage is in a React component that also renders
|
|
191
|
+
* {@link GoogleMapsViewer}, which itself loads the API via `<APIProvider>`.
|
|
192
|
+
*
|
|
193
|
+
* Rejects if the Places call fails or the result lacks geometry/address.
|
|
194
|
+
*/
|
|
195
|
+
declare function getPlaceDetailsFromGoogleAutocompleteSuggestion(query: string, sug: google.maps.places.AutocompletePrediction): Promise<ProviderAutocompletePlace>;
|
|
196
|
+
|
|
197
|
+
export { type CenterZoomAutofit, type ContainerDims, DEFAULT_CENTER_ZOOM, GoogleMapsViewer, type GoogleMapsViewerProps, MapContext, type MapContextValue, MapProvider, type MapProviderProps, type MappablePlace, PlaceMarker, type PlaceMarkerProps, autofitCenterZoom, getPlaceDetailsFromGoogleAutocompleteSuggestion, getPlaceDisplayName, useMap, usePlace };
|
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
* mapthis data. They are intentionally framework-agnostic — no Prisma, no
|
|
8
8
|
* Next.js, no auth assumptions.
|
|
9
9
|
*/
|
|
10
|
-
declare const llmProvider: z.ZodLiteral<"openai">;
|
|
10
|
+
declare const llmProvider: z.ZodUnion<[z.ZodLiteral<"openai">, z.ZodLiteral<"anthropic">]>;
|
|
11
11
|
type LlmProvider = z.infer<typeof llmProvider>;
|
|
12
12
|
declare const placeProvider: z.ZodUnion<[z.ZodLiteral<"google">, z.ZodLiteral<"locationiq">]>;
|
|
13
13
|
type PlaceProvider = z.infer<typeof placeProvider>;
|
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
* mapthis data. They are intentionally framework-agnostic — no Prisma, no
|
|
8
8
|
* Next.js, no auth assumptions.
|
|
9
9
|
*/
|
|
10
|
-
declare const llmProvider: z.ZodLiteral<"openai">;
|
|
10
|
+
declare const llmProvider: z.ZodUnion<[z.ZodLiteral<"openai">, z.ZodLiteral<"anthropic">]>;
|
|
11
11
|
type LlmProvider = z.infer<typeof llmProvider>;
|
|
12
12
|
declare const placeProvider: z.ZodUnion<[z.ZodLiteral<"google">, z.ZodLiteral<"locationiq">]>;
|
|
13
13
|
type PlaceProvider = z.infer<typeof placeProvider>;
|
package/dist/types/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
5
|
// src/types/schemas.ts
|
|
6
|
-
var llmProvider = zod.z.literal("openai");
|
|
6
|
+
var llmProvider = zod.z.union([zod.z.literal("openai"), zod.z.literal("anthropic")]);
|
|
7
7
|
var placeProvider = zod.z.union([zod.z.literal("google"), zod.z.literal("locationiq")]);
|
|
8
8
|
var generationSourceType = zod.z.union([
|
|
9
9
|
zod.z.literal("blank"),
|
package/dist/types/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/schemas.ts","../../src/types/errors.ts"],"names":["z"],"mappings":";;;;;AAYO,IAAM,WAAA,GAAcA,KAAA,CAAE,OAAA,CAAQ,QAAQ;AAGtC,IAAM,aAAA,GAAgBA,KAAA,CAAE,KAAA,CAAM,CAACA,KAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA,EAAGA,KAAA,CAAE,OAAA,CAAQ,YAAY,CAAC,CAAC;AAG5E,IAAM,oBAAA,GAAuBA,MAAE,KAAA,CAAM;AAAA,EACxCA,KAAA,CAAE,QAAQ,OAAO,CAAA;AAAA,EACjBA,KAAA,CAAE,QAAQ,cAAc,CAAA;AAAA,EACxBA,KAAA,CAAE,QAAQ,KAAK,CAAA;AAAA,EACfA,KAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,EAChBA,KAAA,CAAE,QAAQ,MAAM;AACpB,CAAC;AAKM,IAAM,QAAA,GAAWA,KAAA,CAAE,MAAA,CAAO,MAAA,EAAO,CAAE,GAAA,CAAI,GAAA,EAAK,qBAAqB,CAAA,CAAE,GAAA,CAAI,EAAA,EAAI,oBAAoB;AAC/F,IAAM,SAAA,GAAYA,KAAA,CAAE,MAAA,CAAO,MAAA,EAAO,CAAE,GAAA,CAAI,IAAA,EAAM,uBAAuB,CAAA,CAAE,GAAA,CAAI,GAAA,EAAK,sBAAsB;AAEtG,IAAM,WAAA,GAAcA,MAAE,MAAA,CAAO;AAAA,EAChC,GAAA,EAAK,QA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,MAAE,MAAA;AAChB,CAAC;AAGM,IAAM,iBAAA,GAAoB,UAAU,MAAA,CAAO;AAAA,EAC9C,GAAA,EAAKA,MAAE,MAAA,EAAO;AAAA,EACd,GAAA,EAAKA,MAAE,MAAA,EAAO;AAAA,EACd,KAAA,EAAOA,MAAE,IAAA;AACb,CAAC;AAOM,SAAS,sBACZ,MAAA,EACmB;AACnB,EAAA,MAAM,OAA4B,EAAC;AACnC,EAAA,KAAA,MAAW,KAAK,MAAA,EAAQ;AACpB,IAAA,MAAM,MAAA,GAAS,iBAAA,CAAkB,SAAA,CAAU,CAAC,CAAA;AAC5C,IAAA,IAAI,MAAA,CAAO,OAAA,EAAS,IAAA,CAAK,IAAA,CAAK,OAAO,IAAI,CAAA;AAAA,EAC7C;AACA,EAAA,OAAO,IAAA;AACX;;;ACnPO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACpC,WAAA,CAAY,SAAkB,OAAA,EAAwB;AAClD,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EAChB;AACJ","file":"index.cjs","sourcesContent":["import { z } from \"zod\"\n\n/**\n * Runtime validation schemas and their inferred types.\n *\n * These schemas define the public contract between producers and consumers of\n * mapthis data. They are intentionally framework-agnostic — no Prisma, no\n * Next.js, no auth assumptions.\n */\n\n// --- Providers & source types ------------------------------------------------\n\nexport const llmProvider = z.literal(\"openai\") // TODO: add other LLM support\nexport type LlmProvider = z.infer<typeof llmProvider>\n\nexport const placeProvider = z.union([z.literal(\"google\"), z.literal(\"locationiq\")])\nexport type PlaceProvider = z.infer<typeof placeProvider>\n\nexport const generationSourceType = z.union([\n z.literal(\"blank\"),\n z.literal(\"autocomplete\"),\n z.literal(\"url\"),\n z.literal(\"text\"),\n z.literal(\"list\"),\n])\nexport type GenerationSourceType = z.infer<typeof generationSourceType>\n\n// --- Geographic primitives ---------------------------------------------------\n\nexport const latitude = z.coerce.number().min(-90, \"Min latitude is -90\").max(90, \"Max latitude is 90\")\nexport const longitude = z.coerce.number().min(-180, \"Min longitude is -180\").max(180, \"Max longitude is 180\")\n\nexport const coordinates = z.object({\n lat: latitude,\n lng: longitude,\n})\nexport type Coordinates = z.infer<typeof coordinates>\n\n// --- Input schemas (freeform sources) ----------------------------------------\n\nexport const placesFromUrl = z.string().url({ message: \"Invalid url\" }).min(6).max(2048)\n\nexport const placesFromList = z\n .preprocess(\n (v) =>\n String(v)\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => !!line)\n .join(\"\\n\"),\n z.string().min(6, \"Must be at least 6 characters\").max(1000, \"List too long\"),\n )\n .refine(\n (v) => !v.split(\"\\n\").find((line) => line.length < 2),\n \"All lines must be at least 2 characters\",\n )\n\nexport const placesFromText = z\n .string()\n .min(6, \"Must be at least 6 characters\")\n .max(2000, \"Over character limit\")\n\n// --- Map field schemas -------------------------------------------------------\n\nexport const mapExternalId = z.string().min(6).max(100)\nexport const mapTitle = z\n .string()\n .min(3, { message: \"Title must be at least 3 characters\" })\n .max(100, { message: \"Title must be at most 100 characters\" })\nexport const mapDescription = z.string().max(1000, { message: \"Limit is 1000 characters\" })\nexport const mapCreationQuery = z\n .string()\n .min(10, \"Minimum 10 characters for search\")\n .max(200, \"Maximum 200 characters\")\n\n// --- Group field schemas -----------------------------------------------------\n\nexport const groupName = z\n .string()\n .min(3, { message: \"Name must be at least 3 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const groupDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\nexport const groupColor = z.string().startsWith(\"#\").length(7)\n\n// --- Place field schemas -----------------------------------------------------\n\nexport const placeName = z\n .string()\n .min(2, { message: \"Name must be at least 2 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const placeDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\n\n// --- Map creation composites -------------------------------------------------\n\nexport const createMapBase = z.object({\n title: mapTitle.optional(),\n description: mapDescription.optional(),\n externalId: mapExternalId.optional(),\n})\n\nexport const createMapSchema = createMapBase.extend({\n sourceType: generationSourceType,\n source: z.string().optional(),\n})\n\nexport const createBlankMapSchema = createMapBase\n\nexport const createMapFromUrlSchema = createMapBase.extend({\n url: placesFromUrl,\n})\nexport const createMapFromListSchema = createMapBase.extend({\n list: placesFromList,\n})\nexport const createMapFromTextSchema = createMapBase.extend({\n text: placesFromText,\n})\nexport const createMapFromQueryOrUrlSchema = createMapBase.extend({\n queryOrUrl: z.union([mapCreationQuery, placesFromUrl]),\n})\n\n// --- Adding places -----------------------------------------------------------\n\nexport const addPlacesBaseSchema = z.object({\n sourceType: generationSourceType,\n source: z.string(),\n})\n\nexport const addPlacesFromSourceSchema = addPlacesBaseSchema.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\nexport const addPlacesFromUrlSchema = z.object({\n url: placesFromUrl,\n})\nexport const addPlacesFromListSchema = z.object({\n list: placesFromList,\n})\nexport const addPlacesFromTextSchema = z.object({\n text: placesFromText,\n})\n\nexport const providerAutocompletePlace = z.object({\n query: z.string(),\n provider: z.literal(\"google\"),\n providerId: z.string(),\n name: z.string(),\n description: z.string().optional(),\n address: z.string(),\n lat: z.number().min(-90).max(90),\n lng: z.number().min(-180).max(180),\n})\nexport type ProviderAutocompletePlace = z.infer<typeof providerAutocompletePlace>\n\nexport const addPlacesFromClientAutocompleteSchema = providerAutocompletePlace.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\n// --- Updates -----------------------------------------------------------------\n\nexport const updateMapSchema = z.object({\n title: mapTitle,\n description: mapDescription.optional(),\n userPublic: z.boolean().optional(),\n partnerPublic: z.boolean().optional(),\n url: z.string().url().nullable().optional(),\n})\n\nexport const reorderMapSchema = z.object({\n groups: z.array(\n z.object({\n id: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n places: z.array(\n z.object({\n id: z.string(),\n groupId: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n})\n\nexport const updatePlaceFormSchema = z.object({\n id: z.string(),\n name: placeName,\n description: placeDescription.optional(),\n hidden: z.boolean(),\n})\n\nexport const searchSchema = z.object({\n query: mapCreationQuery,\n})\n\nexport const createGroupSchema = z.object({\n name: groupName,\n description: groupDescription.optional(),\n parentGroupId: z.string().optional(),\n color: groupColor.optional(),\n})\n\nexport const editGroupSchema = z.object({\n id: z.string().uuid(),\n color: groupColor.nullable(),\n hidden: z.boolean(),\n name: groupName,\n description: groupDescription.optional(),\n})\n\n// --- Place metadata (lightweight projections) --------------------------------\n\nexport const placeMeta = z.object({\n id: z.string(),\n updatedAt: z.coerce.date(),\n groupId: z.string().nullable(),\n position: z.number().nullable(),\n error: z.string().nullable(),\n lat: z.number().nullable(),\n lon: z.number().nullable(),\n name: z.string().nullable(),\n})\nexport type PlaceMeta = z.infer<typeof placeMeta>\n\nexport const positionedPlaceMeta = placeMeta.extend({\n position: z.number(),\n})\nexport type PositionedPlaceMeta = z.infer<typeof positionedPlaceMeta>\n\nexport const mappablePlaceMeta = placeMeta.extend({\n lat: z.number(),\n lon: z.number(),\n error: z.null(),\n})\nexport type MappablePlaceMeta = z.infer<typeof mappablePlaceMeta>\n\n/**\n * Filter a list of place projections down to those that are mappable\n * (have coordinates and no error).\n */\nexport function getMappablePlaceMetas(\n places: (PlaceMeta | null | undefined)[],\n): MappablePlaceMeta[] {\n const good: MappablePlaceMeta[] = []\n for (const p of places) {\n const parsed = mappablePlaceMeta.safeParse(p)\n if (parsed.success) good.push(parsed.data)\n }\n return good\n}\n","/**\n * Base error class for every error thrown by the mapthis package.\n *\n * All feature-specific error classes (scrape, search, ai, geocoding) extend\n * this, so consumers can do `catch (e) { if (e instanceof MapthisError) ... }`\n * to distinguish library errors from other exceptions.\n */\nexport class MapthisError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"MapthisError\"\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/schemas.ts","../../src/types/errors.ts"],"names":["z"],"mappings":";;;;;AAY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AACpB,IAAA,MAAM,MAAA,GAAS,iBAAA,CAAkB,SAAA,CAAU,CAAC,CAAA;AAC5C,IAAA,IAAI,MAAA,CAAO,OAAA,EAAS,IAAA,CAAK,IAAA,CAAK,OAAO,IAAI,CAAA;AAAA,EAC7C;AACA,EAAA,OAAO,IAAA;AACX;;;ACnPO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACpC,WAAA,CAAY,SAAkB,OAAA,EAAwB;AAClD,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EAChB;AACJ","file":"index.cjs","sourcesContent":["import { z } from \"zod\"\n\n/**\n * Runtime validation schemas and their inferred types.\n *\n * These schemas define the public contract between producers and consumers of\n * mapthis data. They are intentionally framework-agnostic — no Prisma, no\n * Next.js, no auth assumptions.\n */\n\n// --- Providers & source types ------------------------------------------------\n\nexport const llmProvider = z.union([z.literal(\"openai\"), z.literal(\"anthropic\")])\nexport type LlmProvider = z.infer<typeof llmProvider>\n\nexport const placeProvider = z.union([z.literal(\"google\"), z.literal(\"locationiq\")])\nexport type PlaceProvider = z.infer<typeof placeProvider>\n\nexport const generationSourceType = z.union([\n z.literal(\"blank\"),\n z.literal(\"autocomplete\"),\n z.literal(\"url\"),\n z.literal(\"text\"),\n z.literal(\"list\"),\n])\nexport type GenerationSourceType = z.infer<typeof generationSourceType>\n\n// --- Geographic primitives ---------------------------------------------------\n\nexport const latitude = z.coerce.number().min(-90, \"Min latitude is -90\").max(90, \"Max latitude is 90\")\nexport const longitude = z.coerce.number().min(-180, \"Min longitude is -180\").max(180, \"Max longitude is 180\")\n\nexport const coordinates = z.object({\n lat: latitude,\n lng: longitude,\n})\nexport type Coordinates = z.infer<typeof coordinates>\n\n// --- Input schemas (freeform sources) ----------------------------------------\n\nexport const placesFromUrl = z.string().url({ message: \"Invalid url\" }).min(6).max(2048)\n\nexport const placesFromList = z\n .preprocess(\n (v) =>\n String(v)\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => !!line)\n .join(\"\\n\"),\n z.string().min(6, \"Must be at least 6 characters\").max(1000, \"List too long\"),\n )\n .refine(\n (v) => !v.split(\"\\n\").find((line) => line.length < 2),\n \"All lines must be at least 2 characters\",\n )\n\nexport const placesFromText = z\n .string()\n .min(6, \"Must be at least 6 characters\")\n .max(2000, \"Over character limit\")\n\n// --- Map field schemas -------------------------------------------------------\n\nexport const mapExternalId = z.string().min(6).max(100)\nexport const mapTitle = z\n .string()\n .min(3, { message: \"Title must be at least 3 characters\" })\n .max(100, { message: \"Title must be at most 100 characters\" })\nexport const mapDescription = z.string().max(1000, { message: \"Limit is 1000 characters\" })\nexport const mapCreationQuery = z\n .string()\n .min(10, \"Minimum 10 characters for search\")\n .max(200, \"Maximum 200 characters\")\n\n// --- Group field schemas -----------------------------------------------------\n\nexport const groupName = z\n .string()\n .min(3, { message: \"Name must be at least 3 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const groupDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\nexport const groupColor = z.string().startsWith(\"#\").length(7)\n\n// --- Place field schemas -----------------------------------------------------\n\nexport const placeName = z\n .string()\n .min(2, { message: \"Name must be at least 2 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const placeDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\n\n// --- Map creation composites -------------------------------------------------\n\nexport const createMapBase = z.object({\n title: mapTitle.optional(),\n description: mapDescription.optional(),\n externalId: mapExternalId.optional(),\n})\n\nexport const createMapSchema = createMapBase.extend({\n sourceType: generationSourceType,\n source: z.string().optional(),\n})\n\nexport const createBlankMapSchema = createMapBase\n\nexport const createMapFromUrlSchema = createMapBase.extend({\n url: placesFromUrl,\n})\nexport const createMapFromListSchema = createMapBase.extend({\n list: placesFromList,\n})\nexport const createMapFromTextSchema = createMapBase.extend({\n text: placesFromText,\n})\nexport const createMapFromQueryOrUrlSchema = createMapBase.extend({\n queryOrUrl: z.union([mapCreationQuery, placesFromUrl]),\n})\n\n// --- Adding places -----------------------------------------------------------\n\nexport const addPlacesBaseSchema = z.object({\n sourceType: generationSourceType,\n source: z.string(),\n})\n\nexport const addPlacesFromSourceSchema = addPlacesBaseSchema.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\nexport const addPlacesFromUrlSchema = z.object({\n url: placesFromUrl,\n})\nexport const addPlacesFromListSchema = z.object({\n list: placesFromList,\n})\nexport const addPlacesFromTextSchema = z.object({\n text: placesFromText,\n})\n\nexport const providerAutocompletePlace = z.object({\n query: z.string(),\n provider: z.literal(\"google\"),\n providerId: z.string(),\n name: z.string(),\n description: z.string().optional(),\n address: z.string(),\n lat: z.number().min(-90).max(90),\n lng: z.number().min(-180).max(180),\n})\nexport type ProviderAutocompletePlace = z.infer<typeof providerAutocompletePlace>\n\nexport const addPlacesFromClientAutocompleteSchema = providerAutocompletePlace.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\n// --- Updates -----------------------------------------------------------------\n\nexport const updateMapSchema = z.object({\n title: mapTitle,\n description: mapDescription.optional(),\n userPublic: z.boolean().optional(),\n partnerPublic: z.boolean().optional(),\n url: z.string().url().nullable().optional(),\n})\n\nexport const reorderMapSchema = z.object({\n groups: z.array(\n z.object({\n id: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n places: z.array(\n z.object({\n id: z.string(),\n groupId: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n})\n\nexport const updatePlaceFormSchema = z.object({\n id: z.string(),\n name: placeName,\n description: placeDescription.optional(),\n hidden: z.boolean(),\n})\n\nexport const searchSchema = z.object({\n query: mapCreationQuery,\n})\n\nexport const createGroupSchema = z.object({\n name: groupName,\n description: groupDescription.optional(),\n parentGroupId: z.string().optional(),\n color: groupColor.optional(),\n})\n\nexport const editGroupSchema = z.object({\n id: z.string().uuid(),\n color: groupColor.nullable(),\n hidden: z.boolean(),\n name: groupName,\n description: groupDescription.optional(),\n})\n\n// --- Place metadata (lightweight projections) --------------------------------\n\nexport const placeMeta = z.object({\n id: z.string(),\n updatedAt: z.coerce.date(),\n groupId: z.string().nullable(),\n position: z.number().nullable(),\n error: z.string().nullable(),\n lat: z.number().nullable(),\n lon: z.number().nullable(),\n name: z.string().nullable(),\n})\nexport type PlaceMeta = z.infer<typeof placeMeta>\n\nexport const positionedPlaceMeta = placeMeta.extend({\n position: z.number(),\n})\nexport type PositionedPlaceMeta = z.infer<typeof positionedPlaceMeta>\n\nexport const mappablePlaceMeta = placeMeta.extend({\n lat: z.number(),\n lon: z.number(),\n error: z.null(),\n})\nexport type MappablePlaceMeta = z.infer<typeof mappablePlaceMeta>\n\n/**\n * Filter a list of place projections down to those that are mappable\n * (have coordinates and no error).\n */\nexport function getMappablePlaceMetas(\n places: (PlaceMeta | null | undefined)[],\n): MappablePlaceMeta[] {\n const good: MappablePlaceMeta[] = []\n for (const p of places) {\n const parsed = mappablePlaceMeta.safeParse(p)\n if (parsed.success) good.push(parsed.data)\n }\n return good\n}\n","/**\n * Base error class for every error thrown by the mapthis package.\n *\n * All feature-specific error classes (scrape, search, ai, geocoding) extend\n * this, so consumers can do `catch (e) { if (e instanceof MapthisError) ... }`\n * to distinguish library errors from other exceptions.\n */\nexport class MapthisError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"MapthisError\"\n }\n}\n"]}
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as Coordinates, G as GenerationSourceType, L as LlmProvider, M as MappablePlaceMeta, P as PlaceMeta, a as PlaceProvider, b as PositionedPlaceMeta, c as ProviderAutocompletePlace, d as addPlacesBaseSchema, e as addPlacesFromClientAutocompleteSchema, f as addPlacesFromListSchema, g as addPlacesFromSourceSchema, h as addPlacesFromTextSchema, i as addPlacesFromUrlSchema, j as coordinates, k as createBlankMapSchema, l as createGroupSchema, m as createMapBase, n as createMapFromListSchema, o as createMapFromQueryOrUrlSchema, p as createMapFromTextSchema, q as createMapFromUrlSchema, r as createMapSchema, s as editGroupSchema, t as generationSourceType, u as getMappablePlaceMetas, v as groupColor, w as groupDescription, x as groupName, y as latitude, z as llmProvider, A as longitude, B as mapCreationQuery, D as mapDescription, E as mapExternalId, F as mapTitle, H as mappablePlaceMeta, I as placeDescription, J as placeMeta, K as placeName, N as placeProvider, O as placesFromList, Q as placesFromText, R as placesFromUrl, S as positionedPlaceMeta, T as providerAutocompletePlace, U as reorderMapSchema, V as searchSchema, W as updateMapSchema, X as updatePlaceFormSchema } from '../schemas-
|
|
2
|
-
export { A as Audited, D as DefaultPlaceMap, P as ParsedLocation, a as ParsedLocations, b as Partner, c as PartnerUrl, d as PartnerUser, e as PartnerUserRole, f as Place, g as PlaceGroup, h as PlaceMap, i as PlaceQueryResult, j as PopulatedPlaceMap, k as PositionedPlaceGroup, T as Timestamped } from '../domain-
|
|
1
|
+
export { C as Coordinates, G as GenerationSourceType, L as LlmProvider, M as MappablePlaceMeta, P as PlaceMeta, a as PlaceProvider, b as PositionedPlaceMeta, c as ProviderAutocompletePlace, d as addPlacesBaseSchema, e as addPlacesFromClientAutocompleteSchema, f as addPlacesFromListSchema, g as addPlacesFromSourceSchema, h as addPlacesFromTextSchema, i as addPlacesFromUrlSchema, j as coordinates, k as createBlankMapSchema, l as createGroupSchema, m as createMapBase, n as createMapFromListSchema, o as createMapFromQueryOrUrlSchema, p as createMapFromTextSchema, q as createMapFromUrlSchema, r as createMapSchema, s as editGroupSchema, t as generationSourceType, u as getMappablePlaceMetas, v as groupColor, w as groupDescription, x as groupName, y as latitude, z as llmProvider, A as longitude, B as mapCreationQuery, D as mapDescription, E as mapExternalId, F as mapTitle, H as mappablePlaceMeta, I as placeDescription, J as placeMeta, K as placeName, N as placeProvider, O as placesFromList, Q as placesFromText, R as placesFromUrl, S as positionedPlaceMeta, T as providerAutocompletePlace, U as reorderMapSchema, V as searchSchema, W as updateMapSchema, X as updatePlaceFormSchema } from '../schemas-CZao45EU.cjs';
|
|
2
|
+
export { A as Audited, D as DefaultPlaceMap, P as ParsedLocation, a as ParsedLocations, b as Partner, c as PartnerUrl, d as PartnerUser, e as PartnerUserRole, f as Place, g as PlaceGroup, h as PlaceMap, i as PlaceQueryResult, j as PopulatedPlaceMap, k as PositionedPlaceGroup, T as Timestamped } from '../domain-CL4ro2YW.cjs';
|
|
3
3
|
export { M as MapthisError } from '../errors-Bw97z_4m.cjs';
|
|
4
4
|
import 'zod';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as Coordinates, G as GenerationSourceType, L as LlmProvider, M as MappablePlaceMeta, P as PlaceMeta, a as PlaceProvider, b as PositionedPlaceMeta, c as ProviderAutocompletePlace, d as addPlacesBaseSchema, e as addPlacesFromClientAutocompleteSchema, f as addPlacesFromListSchema, g as addPlacesFromSourceSchema, h as addPlacesFromTextSchema, i as addPlacesFromUrlSchema, j as coordinates, k as createBlankMapSchema, l as createGroupSchema, m as createMapBase, n as createMapFromListSchema, o as createMapFromQueryOrUrlSchema, p as createMapFromTextSchema, q as createMapFromUrlSchema, r as createMapSchema, s as editGroupSchema, t as generationSourceType, u as getMappablePlaceMetas, v as groupColor, w as groupDescription, x as groupName, y as latitude, z as llmProvider, A as longitude, B as mapCreationQuery, D as mapDescription, E as mapExternalId, F as mapTitle, H as mappablePlaceMeta, I as placeDescription, J as placeMeta, K as placeName, N as placeProvider, O as placesFromList, Q as placesFromText, R as placesFromUrl, S as positionedPlaceMeta, T as providerAutocompletePlace, U as reorderMapSchema, V as searchSchema, W as updateMapSchema, X as updatePlaceFormSchema } from '../schemas-
|
|
2
|
-
export { A as Audited, D as DefaultPlaceMap, P as ParsedLocation, a as ParsedLocations, b as Partner, c as PartnerUrl, d as PartnerUser, e as PartnerUserRole, f as Place, g as PlaceGroup, h as PlaceMap, i as PlaceQueryResult, j as PopulatedPlaceMap, k as PositionedPlaceGroup, T as Timestamped } from '../domain-
|
|
1
|
+
export { C as Coordinates, G as GenerationSourceType, L as LlmProvider, M as MappablePlaceMeta, P as PlaceMeta, a as PlaceProvider, b as PositionedPlaceMeta, c as ProviderAutocompletePlace, d as addPlacesBaseSchema, e as addPlacesFromClientAutocompleteSchema, f as addPlacesFromListSchema, g as addPlacesFromSourceSchema, h as addPlacesFromTextSchema, i as addPlacesFromUrlSchema, j as coordinates, k as createBlankMapSchema, l as createGroupSchema, m as createMapBase, n as createMapFromListSchema, o as createMapFromQueryOrUrlSchema, p as createMapFromTextSchema, q as createMapFromUrlSchema, r as createMapSchema, s as editGroupSchema, t as generationSourceType, u as getMappablePlaceMetas, v as groupColor, w as groupDescription, x as groupName, y as latitude, z as llmProvider, A as longitude, B as mapCreationQuery, D as mapDescription, E as mapExternalId, F as mapTitle, H as mappablePlaceMeta, I as placeDescription, J as placeMeta, K as placeName, N as placeProvider, O as placesFromList, Q as placesFromText, R as placesFromUrl, S as positionedPlaceMeta, T as providerAutocompletePlace, U as reorderMapSchema, V as searchSchema, W as updateMapSchema, X as updatePlaceFormSchema } from '../schemas-CZao45EU.js';
|
|
2
|
+
export { A as Audited, D as DefaultPlaceMap, P as ParsedLocation, a as ParsedLocations, b as Partner, c as PartnerUrl, d as PartnerUser, e as PartnerUserRole, f as Place, g as PlaceGroup, h as PlaceMap, i as PlaceQueryResult, j as PopulatedPlaceMap, k as PositionedPlaceGroup, T as Timestamped } from '../domain-Dh8cPBVp.js';
|
|
3
3
|
export { M as MapthisError } from '../errors-Bw97z_4m.js';
|
|
4
4
|
import 'zod';
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
// src/types/schemas.ts
|
|
4
|
-
var llmProvider = z.literal("openai");
|
|
4
|
+
var llmProvider = z.union([z.literal("openai"), z.literal("anthropic")]);
|
|
5
5
|
var placeProvider = z.union([z.literal("google"), z.literal("locationiq")]);
|
|
6
6
|
var generationSourceType = z.union([
|
|
7
7
|
z.literal("blank"),
|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AU,CAAC,CAAA;AAC5C,IAAA,IAAI,MAAA,CAAO,OAAA,EAAS,IAAA,CAAK,IAAA,CAAK,OAAO,IAAI,CAAA;AAAA,EAC7C;AACA,EAAA,OAAO,IAAA;AACX;;;ACnPO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACpC,WAAA,CAAY,SAAkB,OAAA,EAAwB;AAClD,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EAChB;AACJ","file":"index.js","sourcesContent":["import { z } from \"zod\"\n\n/**\n * Runtime validation schemas and their inferred types.\n *\n * These schemas define the public contract between producers and consumers of\n * mapthis data. They are intentionally framework-agnostic — no Prisma, no\n * Next.js, no auth assumptions.\n */\n\n// --- Providers & source types ------------------------------------------------\n\nexport const llmProvider = z.literal(\"openai\") // TODO: add other LLM support\nexport type LlmProvider = z.infer<typeof llmProvider>\n\nexport const placeProvider = z.union([z.literal(\"google\"), z.literal(\"locationiq\")])\nexport type PlaceProvider = z.infer<typeof placeProvider>\n\nexport const generationSourceType = z.union([\n z.literal(\"blank\"),\n z.literal(\"autocomplete\"),\n z.literal(\"url\"),\n z.literal(\"text\"),\n z.literal(\"list\"),\n])\nexport type GenerationSourceType = z.infer<typeof generationSourceType>\n\n// --- Geographic primitives ---------------------------------------------------\n\nexport const latitude = z.coerce.number().min(-90, \"Min latitude is -90\").max(90, \"Max latitude is 90\")\nexport const longitude = z.coerce.number().min(-180, \"Min longitude is -180\").max(180, \"Max longitude is 180\")\n\nexport const coordinates = z.object({\n lat: latitude,\n lng: longitude,\n})\nexport type Coordinates = z.infer<typeof coordinates>\n\n// --- Input schemas (freeform sources) ----------------------------------------\n\nexport const placesFromUrl = z.string().url({ message: \"Invalid url\" }).min(6).max(2048)\n\nexport const placesFromList = z\n .preprocess(\n (v) =>\n String(v)\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => !!line)\n .join(\"\\n\"),\n z.string().min(6, \"Must be at least 6 characters\").max(1000, \"List too long\"),\n )\n .refine(\n (v) => !v.split(\"\\n\").find((line) => line.length < 2),\n \"All lines must be at least 2 characters\",\n )\n\nexport const placesFromText = z\n .string()\n .min(6, \"Must be at least 6 characters\")\n .max(2000, \"Over character limit\")\n\n// --- Map field schemas -------------------------------------------------------\n\nexport const mapExternalId = z.string().min(6).max(100)\nexport const mapTitle = z\n .string()\n .min(3, { message: \"Title must be at least 3 characters\" })\n .max(100, { message: \"Title must be at most 100 characters\" })\nexport const mapDescription = z.string().max(1000, { message: \"Limit is 1000 characters\" })\nexport const mapCreationQuery = z\n .string()\n .min(10, \"Minimum 10 characters for search\")\n .max(200, \"Maximum 200 characters\")\n\n// --- Group field schemas -----------------------------------------------------\n\nexport const groupName = z\n .string()\n .min(3, { message: \"Name must be at least 3 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const groupDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\nexport const groupColor = z.string().startsWith(\"#\").length(7)\n\n// --- Place field schemas -----------------------------------------------------\n\nexport const placeName = z\n .string()\n .min(2, { message: \"Name must be at least 2 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const placeDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\n\n// --- Map creation composites -------------------------------------------------\n\nexport const createMapBase = z.object({\n title: mapTitle.optional(),\n description: mapDescription.optional(),\n externalId: mapExternalId.optional(),\n})\n\nexport const createMapSchema = createMapBase.extend({\n sourceType: generationSourceType,\n source: z.string().optional(),\n})\n\nexport const createBlankMapSchema = createMapBase\n\nexport const createMapFromUrlSchema = createMapBase.extend({\n url: placesFromUrl,\n})\nexport const createMapFromListSchema = createMapBase.extend({\n list: placesFromList,\n})\nexport const createMapFromTextSchema = createMapBase.extend({\n text: placesFromText,\n})\nexport const createMapFromQueryOrUrlSchema = createMapBase.extend({\n queryOrUrl: z.union([mapCreationQuery, placesFromUrl]),\n})\n\n// --- Adding places -----------------------------------------------------------\n\nexport const addPlacesBaseSchema = z.object({\n sourceType: generationSourceType,\n source: z.string(),\n})\n\nexport const addPlacesFromSourceSchema = addPlacesBaseSchema.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\nexport const addPlacesFromUrlSchema = z.object({\n url: placesFromUrl,\n})\nexport const addPlacesFromListSchema = z.object({\n list: placesFromList,\n})\nexport const addPlacesFromTextSchema = z.object({\n text: placesFromText,\n})\n\nexport const providerAutocompletePlace = z.object({\n query: z.string(),\n provider: z.literal(\"google\"),\n providerId: z.string(),\n name: z.string(),\n description: z.string().optional(),\n address: z.string(),\n lat: z.number().min(-90).max(90),\n lng: z.number().min(-180).max(180),\n})\nexport type ProviderAutocompletePlace = z.infer<typeof providerAutocompletePlace>\n\nexport const addPlacesFromClientAutocompleteSchema = providerAutocompletePlace.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\n// --- Updates -----------------------------------------------------------------\n\nexport const updateMapSchema = z.object({\n title: mapTitle,\n description: mapDescription.optional(),\n userPublic: z.boolean().optional(),\n partnerPublic: z.boolean().optional(),\n url: z.string().url().nullable().optional(),\n})\n\nexport const reorderMapSchema = z.object({\n groups: z.array(\n z.object({\n id: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n places: z.array(\n z.object({\n id: z.string(),\n groupId: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n})\n\nexport const updatePlaceFormSchema = z.object({\n id: z.string(),\n name: placeName,\n description: placeDescription.optional(),\n hidden: z.boolean(),\n})\n\nexport const searchSchema = z.object({\n query: mapCreationQuery,\n})\n\nexport const createGroupSchema = z.object({\n name: groupName,\n description: groupDescription.optional(),\n parentGroupId: z.string().optional(),\n color: groupColor.optional(),\n})\n\nexport const editGroupSchema = z.object({\n id: z.string().uuid(),\n color: groupColor.nullable(),\n hidden: z.boolean(),\n name: groupName,\n description: groupDescription.optional(),\n})\n\n// --- Place metadata (lightweight projections) --------------------------------\n\nexport const placeMeta = z.object({\n id: z.string(),\n updatedAt: z.coerce.date(),\n groupId: z.string().nullable(),\n position: z.number().nullable(),\n error: z.string().nullable(),\n lat: z.number().nullable(),\n lon: z.number().nullable(),\n name: z.string().nullable(),\n})\nexport type PlaceMeta = z.infer<typeof placeMeta>\n\nexport const positionedPlaceMeta = placeMeta.extend({\n position: z.number(),\n})\nexport type PositionedPlaceMeta = z.infer<typeof positionedPlaceMeta>\n\nexport const mappablePlaceMeta = placeMeta.extend({\n lat: z.number(),\n lon: z.number(),\n error: z.null(),\n})\nexport type MappablePlaceMeta = z.infer<typeof mappablePlaceMeta>\n\n/**\n * Filter a list of place projections down to those that are mappable\n * (have coordinates and no error).\n */\nexport function getMappablePlaceMetas(\n places: (PlaceMeta | null | undefined)[],\n): MappablePlaceMeta[] {\n const good: MappablePlaceMeta[] = []\n for (const p of places) {\n const parsed = mappablePlaceMeta.safeParse(p)\n if (parsed.success) good.push(parsed.data)\n }\n return good\n}\n","/**\n * Base error class for every error thrown by the mapthis package.\n *\n * All feature-specific error classes (scrape, search, ai, geocoding) extend\n * this, so consumers can do `catch (e) { if (e instanceof MapthisError) ... }`\n * to distinguish library errors from other exceptions.\n */\nexport class MapthisError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"MapthisError\"\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/schemas.ts","../../src/types/errors.ts"],"names":[],"mappings":";;;AAYO,IAAM,WAAA,GAAc,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA,EAAG,CAAA,CAAE,OAAA,CAAQ,WAAW,CAAC,CAAC;AAGzE,IAAM,aAAA,GAAgB,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA,EAAG,CAAA,CAAE,OAAA,CAAQ,YAAY,CAAC,CAAC;AAG5E,IAAM,oBAAA,GAAuB,EAAE,KAAA,CAAM;AAAA,EACxC,CAAA,CAAE,QAAQ,OAAO,CAA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* These schemas define the public contract between producers and consumers of\n * mapthis data. They are intentionally framework-agnostic — no Prisma, no\n * Next.js, no auth assumptions.\n */\n\n// --- Providers & source types ------------------------------------------------\n\nexport const llmProvider = z.union([z.literal(\"openai\"), z.literal(\"anthropic\")])\nexport type LlmProvider = z.infer<typeof llmProvider>\n\nexport const placeProvider = z.union([z.literal(\"google\"), z.literal(\"locationiq\")])\nexport type PlaceProvider = z.infer<typeof placeProvider>\n\nexport const generationSourceType = z.union([\n z.literal(\"blank\"),\n z.literal(\"autocomplete\"),\n z.literal(\"url\"),\n z.literal(\"text\"),\n z.literal(\"list\"),\n])\nexport type GenerationSourceType = z.infer<typeof generationSourceType>\n\n// --- Geographic primitives ---------------------------------------------------\n\nexport const latitude = z.coerce.number().min(-90, \"Min latitude is -90\").max(90, \"Max latitude is 90\")\nexport const longitude = z.coerce.number().min(-180, \"Min longitude is -180\").max(180, \"Max longitude is 180\")\n\nexport const coordinates = z.object({\n lat: latitude,\n lng: longitude,\n})\nexport type Coordinates = z.infer<typeof coordinates>\n\n// --- Input schemas (freeform sources) ----------------------------------------\n\nexport const placesFromUrl = z.string().url({ message: \"Invalid url\" }).min(6).max(2048)\n\nexport const placesFromList = z\n .preprocess(\n (v) =>\n String(v)\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => !!line)\n .join(\"\\n\"),\n z.string().min(6, \"Must be at least 6 characters\").max(1000, \"List too long\"),\n )\n .refine(\n (v) => !v.split(\"\\n\").find((line) => line.length < 2),\n \"All lines must be at least 2 characters\",\n )\n\nexport const placesFromText = z\n .string()\n .min(6, \"Must be at least 6 characters\")\n .max(2000, \"Over character limit\")\n\n// --- Map field schemas -------------------------------------------------------\n\nexport const mapExternalId = z.string().min(6).max(100)\nexport const mapTitle = z\n .string()\n .min(3, { message: \"Title must be at least 3 characters\" })\n .max(100, { message: \"Title must be at most 100 characters\" })\nexport const mapDescription = z.string().max(1000, { message: \"Limit is 1000 characters\" })\nexport const mapCreationQuery = z\n .string()\n .min(10, \"Minimum 10 characters for search\")\n .max(200, \"Maximum 200 characters\")\n\n// --- Group field schemas -----------------------------------------------------\n\nexport const groupName = z\n .string()\n .min(3, { message: \"Name must be at least 3 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const groupDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\nexport const groupColor = z.string().startsWith(\"#\").length(7)\n\n// --- Place field schemas -----------------------------------------------------\n\nexport const placeName = z\n .string()\n .min(2, { message: \"Name must be at least 2 characters\" })\n .max(200, { message: \"Name must be at most 200 characters\" })\nexport const placeDescription = z.string().max(400, { message: \"Limit is 400 characters\" })\n\n// --- Map creation composites -------------------------------------------------\n\nexport const createMapBase = z.object({\n title: mapTitle.optional(),\n description: mapDescription.optional(),\n externalId: mapExternalId.optional(),\n})\n\nexport const createMapSchema = createMapBase.extend({\n sourceType: generationSourceType,\n source: z.string().optional(),\n})\n\nexport const createBlankMapSchema = createMapBase\n\nexport const createMapFromUrlSchema = createMapBase.extend({\n url: placesFromUrl,\n})\nexport const createMapFromListSchema = createMapBase.extend({\n list: placesFromList,\n})\nexport const createMapFromTextSchema = createMapBase.extend({\n text: placesFromText,\n})\nexport const createMapFromQueryOrUrlSchema = createMapBase.extend({\n queryOrUrl: z.union([mapCreationQuery, placesFromUrl]),\n})\n\n// --- Adding places -----------------------------------------------------------\n\nexport const addPlacesBaseSchema = z.object({\n sourceType: generationSourceType,\n source: z.string(),\n})\n\nexport const addPlacesFromSourceSchema = addPlacesBaseSchema.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\nexport const addPlacesFromUrlSchema = z.object({\n url: placesFromUrl,\n})\nexport const addPlacesFromListSchema = z.object({\n list: placesFromList,\n})\nexport const addPlacesFromTextSchema = z.object({\n text: placesFromText,\n})\n\nexport const providerAutocompletePlace = z.object({\n query: z.string(),\n provider: z.literal(\"google\"),\n providerId: z.string(),\n name: z.string(),\n description: z.string().optional(),\n address: z.string(),\n lat: z.number().min(-90).max(90),\n lng: z.number().min(-180).max(180),\n})\nexport type ProviderAutocompletePlace = z.infer<typeof providerAutocompletePlace>\n\nexport const addPlacesFromClientAutocompleteSchema = providerAutocompletePlace.extend({\n mapId: z.string(),\n groupId: z.string().optional(),\n})\n\n// --- Updates -----------------------------------------------------------------\n\nexport const updateMapSchema = z.object({\n title: mapTitle,\n description: mapDescription.optional(),\n userPublic: z.boolean().optional(),\n partnerPublic: z.boolean().optional(),\n url: z.string().url().nullable().optional(),\n})\n\nexport const reorderMapSchema = z.object({\n groups: z.array(\n z.object({\n id: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n places: z.array(\n z.object({\n id: z.string(),\n groupId: z.string().uuid().nullable(),\n position: z.number(),\n }),\n ),\n})\n\nexport const updatePlaceFormSchema = z.object({\n id: z.string(),\n name: placeName,\n description: placeDescription.optional(),\n hidden: z.boolean(),\n})\n\nexport const searchSchema = z.object({\n query: mapCreationQuery,\n})\n\nexport const createGroupSchema = z.object({\n name: groupName,\n description: groupDescription.optional(),\n parentGroupId: z.string().optional(),\n color: groupColor.optional(),\n})\n\nexport const editGroupSchema = z.object({\n id: z.string().uuid(),\n color: groupColor.nullable(),\n hidden: z.boolean(),\n name: groupName,\n description: groupDescription.optional(),\n})\n\n// --- Place metadata (lightweight projections) --------------------------------\n\nexport const placeMeta = z.object({\n id: z.string(),\n updatedAt: z.coerce.date(),\n groupId: z.string().nullable(),\n position: z.number().nullable(),\n error: z.string().nullable(),\n lat: z.number().nullable(),\n lon: z.number().nullable(),\n name: z.string().nullable(),\n})\nexport type PlaceMeta = z.infer<typeof placeMeta>\n\nexport const positionedPlaceMeta = placeMeta.extend({\n position: z.number(),\n})\nexport type PositionedPlaceMeta = z.infer<typeof positionedPlaceMeta>\n\nexport const mappablePlaceMeta = placeMeta.extend({\n lat: z.number(),\n lon: z.number(),\n error: z.null(),\n})\nexport type MappablePlaceMeta = z.infer<typeof mappablePlaceMeta>\n\n/**\n * Filter a list of place projections down to those that are mappable\n * (have coordinates and no error).\n */\nexport function getMappablePlaceMetas(\n places: (PlaceMeta | null | undefined)[],\n): MappablePlaceMeta[] {\n const good: MappablePlaceMeta[] = []\n for (const p of places) {\n const parsed = mappablePlaceMeta.safeParse(p)\n if (parsed.success) good.push(parsed.data)\n }\n return good\n}\n","/**\n * Base error class for every error thrown by the mapthis package.\n *\n * All feature-specific error classes (scrape, search, ai, geocoding) extend\n * this, so consumers can do `catch (e) { if (e instanceof MapthisError) ... }`\n * to distinguish library errors from other exceptions.\n */\nexport class MapthisError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"MapthisError\"\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ParsedLocation, i as PlaceQueryResult } from './domain-
|
|
2
|
-
import { a as PlaceProvider } from './schemas-
|
|
1
|
+
import { P as ParsedLocation, i as PlaceQueryResult } from './domain-Dh8cPBVp.js';
|
|
2
|
+
import { a as PlaceProvider } from './schemas-CZao45EU.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Abstract geocoding provider. Implementations translate a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ParsedLocation, i as PlaceQueryResult } from './domain-
|
|
2
|
-
import { a as PlaceProvider } from './schemas-
|
|
1
|
+
import { P as ParsedLocation, i as PlaceQueryResult } from './domain-CL4ro2YW.cjs';
|
|
2
|
+
import { a as PlaceProvider } from './schemas-CZao45EU.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Abstract geocoding provider. Implementations translate a
|
package/dist/utils/index.d.cts
CHANGED
package/dist/utils/index.d.ts
CHANGED