@geowiki/core 0.15.1-dev.0 → 0.16.0-dev.1
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.mts +52 -63
- package/dist/index.d.ts +52 -63
- package/dist/index.js +83 -0
- package/dist/index.mjs +78 -0
- package/package.json +6 -8
package/dist/index.d.mts
CHANGED
|
@@ -6,13 +6,13 @@ import * as _geowiki_api_proxy from '@geowiki/api-proxy';
|
|
|
6
6
|
import { ApplicationConfigurationDto, ResourceFilterInput, CurrentUserDto, EmailSettingsDto, GetFeatureListResultDto, GetPermissionListResultDto, ProfileDto, CountryDto, FileDto, FarmerClusterNewsDto, LocationDto } from '@geowiki/api-proxy';
|
|
7
7
|
import * as _geowiki_cms_proxy from '@geowiki/cms-proxy';
|
|
8
8
|
import { ClusterFilterSettingsItemDto, ConfigSettingsItemDto, GeoWikiSettingsItemDto, IntroTourSettingsItemDto, PublicationSettingsItemDto, MapSettingsItemDto, FundingSettingsItemDto, FooterSettingsItemDto, MenuItemDto, MapMenuItemItemDto, LayerItemDto, PageItemDto } from '@geowiki/cms-proxy';
|
|
9
|
-
import { MutableRefObject } from 'react';
|
|
9
|
+
import React$1, { MutableRefObject } from 'react';
|
|
10
10
|
import GeoJSON from 'geojson';
|
|
11
11
|
import * as zustand from 'zustand';
|
|
12
12
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
13
13
|
import { I18n } from 'next-localization';
|
|
14
14
|
import { GetServerSidePropsContext } from 'next';
|
|
15
|
-
import
|
|
15
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
16
|
|
|
17
17
|
declare const easing: number[];
|
|
18
18
|
declare const listVariants: {
|
|
@@ -1149,6 +1149,35 @@ declare const getPageProps: (ctx: GetServerSidePropsContext) => Promise<{
|
|
|
1149
1149
|
};
|
|
1150
1150
|
}>;
|
|
1151
1151
|
|
|
1152
|
+
interface ClientSession {
|
|
1153
|
+
accessToken: string;
|
|
1154
|
+
idToken: string;
|
|
1155
|
+
userRole: string | string[];
|
|
1156
|
+
user: {
|
|
1157
|
+
name?: string | null;
|
|
1158
|
+
email?: string | null;
|
|
1159
|
+
image?: string | null;
|
|
1160
|
+
};
|
|
1161
|
+
expires: string;
|
|
1162
|
+
error?: string;
|
|
1163
|
+
}
|
|
1164
|
+
type SessionStatus = "loading" | "authenticated" | "unauthenticated";
|
|
1165
|
+
interface SessionContextValue {
|
|
1166
|
+
data: ClientSession | null;
|
|
1167
|
+
status: SessionStatus;
|
|
1168
|
+
update: () => void;
|
|
1169
|
+
}
|
|
1170
|
+
declare const SESSION_QUERY_KEY: readonly ["geowiki-session"];
|
|
1171
|
+
declare function SessionProvider({ children, session: initialSession, onSessionChange, }: {
|
|
1172
|
+
children: React$1.ReactNode;
|
|
1173
|
+
session?: ClientSession | null;
|
|
1174
|
+
onSessionChange?: (session: ClientSession | null) => void;
|
|
1175
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1176
|
+
declare function useSession(): SessionContextValue;
|
|
1177
|
+
|
|
1178
|
+
declare function signIn(_provider?: string, _options?: Record<string, unknown>, params?: Record<string, string>): void;
|
|
1179
|
+
declare function signOut(): void;
|
|
1180
|
+
|
|
1152
1181
|
/**
|
|
1153
1182
|
* Analytics utilities for tracking user interactions with Umami
|
|
1154
1183
|
*
|
|
@@ -1183,9 +1212,7 @@ declare global {
|
|
|
1183
1212
|
* @param eventData - Additional data to include with the event
|
|
1184
1213
|
* @param session - Optional session object containing user information
|
|
1185
1214
|
*/
|
|
1186
|
-
declare const trackUmamiEvent: (eventName: string, eventData?: Record<string, any>, session?:
|
|
1187
|
-
accessToken?: string;
|
|
1188
|
-
}) => void;
|
|
1215
|
+
declare const trackUmamiEvent: (eventName: string, eventData?: Record<string, any>, session?: ClientSession) => void;
|
|
1189
1216
|
/**
|
|
1190
1217
|
* Track download-related events with consistent data structure
|
|
1191
1218
|
*/
|
|
@@ -1193,27 +1220,19 @@ declare const trackDownloadEvent: {
|
|
|
1193
1220
|
/**
|
|
1194
1221
|
* Track download attempt
|
|
1195
1222
|
*/
|
|
1196
|
-
attempt: (format: string, country: string, version: string, purpose: string, session?:
|
|
1197
|
-
accessToken?: string;
|
|
1198
|
-
}) => void;
|
|
1223
|
+
attempt: (format: string, country: string, version: string, purpose: string, session?: ClientSession) => void;
|
|
1199
1224
|
/**
|
|
1200
1225
|
* Track successful download
|
|
1201
1226
|
*/
|
|
1202
|
-
success: (filename: string, purpose: string, session?:
|
|
1203
|
-
accessToken?: string;
|
|
1204
|
-
}) => void;
|
|
1227
|
+
success: (filename: string, purpose: string, session?: ClientSession) => void;
|
|
1205
1228
|
/**
|
|
1206
1229
|
* Track download failure
|
|
1207
1230
|
*/
|
|
1208
|
-
failure: (error: string, purpose: string, session?:
|
|
1209
|
-
accessToken?: string;
|
|
1210
|
-
}) => void;
|
|
1231
|
+
failure: (error: string, purpose: string, session?: ClientSession) => void;
|
|
1211
1232
|
/**
|
|
1212
1233
|
* Track login attempt for download access
|
|
1213
1234
|
*/
|
|
1214
|
-
loginAttempt: (session?:
|
|
1215
|
-
accessToken?: string;
|
|
1216
|
-
}) => void;
|
|
1235
|
+
loginAttempt: (session?: ClientSession) => void;
|
|
1217
1236
|
};
|
|
1218
1237
|
/**
|
|
1219
1238
|
* Track authentication-related events
|
|
@@ -1222,21 +1241,15 @@ declare const trackAuthEvent: {
|
|
|
1222
1241
|
/**
|
|
1223
1242
|
* Track login attempt
|
|
1224
1243
|
*/
|
|
1225
|
-
loginAttempt: (provider: string, session?:
|
|
1226
|
-
accessToken?: string;
|
|
1227
|
-
}) => void;
|
|
1244
|
+
loginAttempt: (provider: string, session?: ClientSession) => void;
|
|
1228
1245
|
/**
|
|
1229
1246
|
* Track successful login
|
|
1230
1247
|
*/
|
|
1231
|
-
loginSuccess: (provider: string, session?:
|
|
1232
|
-
accessToken?: string;
|
|
1233
|
-
}) => void;
|
|
1248
|
+
loginSuccess: (provider: string, session?: ClientSession) => void;
|
|
1234
1249
|
/**
|
|
1235
1250
|
* Track logout
|
|
1236
1251
|
*/
|
|
1237
|
-
logout: (session?:
|
|
1238
|
-
accessToken?: string;
|
|
1239
|
-
}) => void;
|
|
1252
|
+
logout: (session?: ClientSession) => void;
|
|
1240
1253
|
};
|
|
1241
1254
|
/**
|
|
1242
1255
|
* Track general user interaction events
|
|
@@ -1245,27 +1258,19 @@ declare const trackUserEvent: {
|
|
|
1245
1258
|
/**
|
|
1246
1259
|
* Track page view
|
|
1247
1260
|
*/
|
|
1248
|
-
pageView: (page: string, session?:
|
|
1249
|
-
accessToken?: string;
|
|
1250
|
-
}) => void;
|
|
1261
|
+
pageView: (page: string, session?: ClientSession) => void;
|
|
1251
1262
|
/**
|
|
1252
1263
|
* Track button click
|
|
1253
1264
|
*/
|
|
1254
|
-
buttonClick: (buttonName: string, context?: string, session?:
|
|
1255
|
-
accessToken?: string;
|
|
1256
|
-
}) => void;
|
|
1265
|
+
buttonClick: (buttonName: string, context?: string, session?: ClientSession) => void;
|
|
1257
1266
|
/**
|
|
1258
1267
|
* Track form submission
|
|
1259
1268
|
*/
|
|
1260
|
-
formSubmit: (formName: string, session?:
|
|
1261
|
-
accessToken?: string;
|
|
1262
|
-
}) => void;
|
|
1269
|
+
formSubmit: (formName: string, session?: ClientSession) => void;
|
|
1263
1270
|
/**
|
|
1264
1271
|
* Track map control button click with specific context
|
|
1265
1272
|
*/
|
|
1266
|
-
mapControlClick: (controlName: string, action?: string, session?:
|
|
1267
|
-
accessToken?: string;
|
|
1268
|
-
}) => void;
|
|
1273
|
+
mapControlClick: (controlName: string, action?: string, session?: ClientSession) => void;
|
|
1269
1274
|
};
|
|
1270
1275
|
/**
|
|
1271
1276
|
* Track map control events
|
|
@@ -1274,51 +1279,35 @@ declare const trackMapEvent: {
|
|
|
1274
1279
|
/**
|
|
1275
1280
|
* Track layer toggle
|
|
1276
1281
|
*/
|
|
1277
|
-
layerToggle: (layerName: string, action: "add" | "remove", session?:
|
|
1278
|
-
accessToken?: string;
|
|
1279
|
-
}) => void;
|
|
1282
|
+
layerToggle: (layerName: string, action: "add" | "remove", session?: ClientSession) => void;
|
|
1280
1283
|
/**
|
|
1281
1284
|
* Track base layer change
|
|
1282
1285
|
*/
|
|
1283
|
-
baseLayerChange: (baseLayerName: string, session?:
|
|
1284
|
-
accessToken?: string;
|
|
1285
|
-
}) => void;
|
|
1286
|
+
baseLayerChange: (baseLayerName: string, session?: ClientSession) => void;
|
|
1286
1287
|
/**
|
|
1287
1288
|
* Track layer opacity change
|
|
1288
1289
|
*/
|
|
1289
|
-
layerOpacityChange: (layerName: string, opacity: number, session?:
|
|
1290
|
-
accessToken?: string;
|
|
1291
|
-
}) => void;
|
|
1290
|
+
layerOpacityChange: (layerName: string, opacity: number, session?: ClientSession) => void;
|
|
1292
1291
|
/**
|
|
1293
1292
|
* Track layer reorder
|
|
1294
1293
|
*/
|
|
1295
|
-
layerReorder: (layerName: string, newPosition: number, session?:
|
|
1296
|
-
accessToken?: string;
|
|
1297
|
-
}) => void;
|
|
1294
|
+
layerReorder: (layerName: string, newPosition: number, session?: ClientSession) => void;
|
|
1298
1295
|
/**
|
|
1299
1296
|
* Track layer info view
|
|
1300
1297
|
*/
|
|
1301
|
-
layerInfoView: (layerName: string, session?:
|
|
1302
|
-
accessToken?: string;
|
|
1303
|
-
}) => void;
|
|
1298
|
+
layerInfoView: (layerName: string, session?: ClientSession) => void;
|
|
1304
1299
|
/**
|
|
1305
1300
|
* Track measurement tool usage
|
|
1306
1301
|
*/
|
|
1307
|
-
measurementTool: (action: "start" | "stop" | "clear", session?:
|
|
1308
|
-
accessToken?: string;
|
|
1309
|
-
}) => void;
|
|
1302
|
+
measurementTool: (action: "start" | "stop" | "clear", session?: ClientSession) => void;
|
|
1310
1303
|
/**
|
|
1311
1304
|
* Track zoom control usage
|
|
1312
1305
|
*/
|
|
1313
|
-
zoomControl: (action: "zoom_in" | "zoom_out" | "reset", session?:
|
|
1314
|
-
accessToken?: string;
|
|
1315
|
-
}) => void;
|
|
1306
|
+
zoomControl: (action: "zoom_in" | "zoom_out" | "reset", session?: ClientSession) => void;
|
|
1316
1307
|
/**
|
|
1317
1308
|
* Track legend interaction
|
|
1318
1309
|
*/
|
|
1319
|
-
legendInteraction: (action: "open" | "close" | "reorder", session?:
|
|
1320
|
-
accessToken?: string;
|
|
1321
|
-
}) => void;
|
|
1310
|
+
legendInteraction: (action: "open" | "close" | "reorder", session?: ClientSession) => void;
|
|
1322
1311
|
};
|
|
1323
1312
|
|
|
1324
1313
|
/**
|
|
@@ -1401,4 +1390,4 @@ declare const QueryNames: {
|
|
|
1401
1390
|
GetHosts: string;
|
|
1402
1391
|
};
|
|
1403
1392
|
|
|
1404
|
-
export { ActivityStatus, AdminMenus, type Alert, AnnotationRequired, type BaseProp, type BasfLayerItem, type BingNewsItem, CLUSTER_ACTIVITY_STATUS, type ClusterDto, ClusterFunding, ColorArray, ColorArrayCSSClass, type Colormap, type Column, Config, DOTS, type DefaultSettings, type DisplayItem, type Entry, FarmingSystem, Features, type FluffyThumbnail, type Font, type FooterSettings, type FundingSettings, type GlobalSettings, type Graphic, type HostInfo, HostService, HostType, HuntingManagement, ImageError, IsTokenExpired, type LabelPlacement, type Legend, type LegendInfo, type Line, type LinkWithNewTab, LiveStock, type LocationTasks, LookUps, MainAgriculturalAreas, MainCrops, type MainMenu, type MapLayer, type MapSettings, type Menu, type MenuItem, NewsDefaultImage, type NewsResult, OtherLandscapeElements, Permission, PermissionProvider, type Point, type Policy, type Polygon, type Provider, type ProviderImage, type PurpleThumbnail, QueryConstants, type QueryContext, QueryNames, QuestionnaireType, type Raster, ResourcesMenu, Responsive, type Rule, type Sort, StyleType, type SubMenu, type Symbolizer, TaskEventType, TaskState, TaskStatus, TaskStatusColor, type Text, USER_ROLE, type UtmResult, type ValueImage, ViewStatus, classNames, configStore, delayedSlideInUp, downloadData, downloadJSON, easing, findHostInfo, formatUnixDate, getButtonAppearance, getCmsUrlForHost, getContentWithSlug, getContentWithTypeAndDisplayName, getContentsWithType, getDefaultSettings, getGeoWikiSettings, getHostData, getHostFromRequest, getHtmlElementFromReactNode, getMediaUrl, getMenus, getPageContent, getPageProps, getTenantIdForHost, i18n, imageMaxDimension, imageMinDimension, itemVariants, keyStr, listVariants, rgbDataURL, routes, scrollToFirstErrorElement, settingsStore, shimmer, showIntroTour, slideInLeft, slideInRight, slideInUp, spring, toBase64, tokenData, trackAuthEvent, trackDownloadEvent, trackMapEvent, trackUmamiEvent, trackUserEvent, triplet, useAllNewsFromAllClusters, useApiImage, useApiUrl, useAppConfig, useAssignProjectToUser, useAssignableRoles, useAudience, useBasfStore, useBreadCrumbStore, useCluster, useClusterAllNews, useClusterDescription, useClusterDetails, useClusterFilterSettings, useClusterGetJoinRequests, useClusterGetNews, useClusterGetNewsNextPreviousStatus, useClusterImages, useClusterImagesAndVideos, useClusterLinks, useClusterMapInfo, useClusterNews, useClusterNewsWithId, useClusterOverview, useClusters, useCmsContentWithType, useCmsImage, useCmsUrl, useConfigSettings, useContractStatisticsByUser, useCountries, useCreateHost, useCurrentUser, useDefaultSettings, useDeleteHost, useDimensions, useEmailing, useEvolandBands, useEvolandLabels, useEvolandWmsLayers, useFeature, useFeatures, useFileUpload, useFileUrl, useFilterClusters, useGeoWikiSettings, useGetUserProject, useGrantedPolicies, useGroupsInProject, useHost, useHosts, useImageUrl, useIntroTourSettings, useIsAdmin, useIsAuthenticated, useIsInRole, useLanguages, useLatestTaskOnLocation, useLayerInfo, useLayerStore, useLocation, useLocationBulkUpload, useLocationsForProject, useLockBodyScroll, useLookUp, useMapMenuItems, useNews, useNewsFromAllClusters, usePagination, usePanelStore, usePermission, usePermissions, useProfile, useProjectDetails, useProjectResultSet, useProjectStatisticsByUser, useProjectUsers, useProjects, useProjectsPointsDownload, usePublicationSettings, useQuestionnaire, useRandomTasksPerLocation, useRenderInfo, useResource, useResourceFilter, useResourceType, useReviewTaskBulkUpload, useRoles, useTaskAnnotation, useTaskAnswers, useTaskBulkUpload, useTaskComments, useTaskDelete, useTaskMultipleAnnotations, useTaskSavedAnnotations, useTaskStatusList, useTasksPerLocation, useTenants, useTopic, useUpdateActiveGroupInProject, useUpdateHost, useUpdateUserDetail, useUserProfileGet, useUserRoles, useUsers };
|
|
1393
|
+
export { ActivityStatus, AdminMenus, type Alert, AnnotationRequired, type BaseProp, type BasfLayerItem, type BingNewsItem, CLUSTER_ACTIVITY_STATUS, type ClientSession, type ClusterDto, ClusterFunding, ColorArray, ColorArrayCSSClass, type Colormap, type Column, Config, DOTS, type DefaultSettings, type DisplayItem, type Entry, FarmingSystem, Features, type FluffyThumbnail, type Font, type FooterSettings, type FundingSettings, type GlobalSettings, type Graphic, type HostInfo, HostService, HostType, HuntingManagement, ImageError, IsTokenExpired, type LabelPlacement, type Legend, type LegendInfo, type Line, type LinkWithNewTab, LiveStock, type LocationTasks, LookUps, MainAgriculturalAreas, MainCrops, type MainMenu, type MapLayer, type MapSettings, type Menu, type MenuItem, NewsDefaultImage, type NewsResult, OtherLandscapeElements, Permission, PermissionProvider, type Point, type Policy, type Polygon, type Provider, type ProviderImage, type PurpleThumbnail, QueryConstants, type QueryContext, QueryNames, QuestionnaireType, type Raster, ResourcesMenu, Responsive, type Rule, SESSION_QUERY_KEY, SessionProvider, type SessionStatus, type Sort, StyleType, type SubMenu, type Symbolizer, TaskEventType, TaskState, TaskStatus, TaskStatusColor, type Text, USER_ROLE, type UtmResult, type ValueImage, ViewStatus, classNames, configStore, delayedSlideInUp, downloadData, downloadJSON, easing, findHostInfo, formatUnixDate, getButtonAppearance, getCmsUrlForHost, getContentWithSlug, getContentWithTypeAndDisplayName, getContentsWithType, getDefaultSettings, getGeoWikiSettings, getHostData, getHostFromRequest, getHtmlElementFromReactNode, getMediaUrl, getMenus, getPageContent, getPageProps, getTenantIdForHost, i18n, imageMaxDimension, imageMinDimension, itemVariants, keyStr, listVariants, rgbDataURL, routes, scrollToFirstErrorElement, settingsStore, shimmer, showIntroTour, signIn, signOut, slideInLeft, slideInRight, slideInUp, spring, toBase64, tokenData, trackAuthEvent, trackDownloadEvent, trackMapEvent, trackUmamiEvent, trackUserEvent, triplet, useAllNewsFromAllClusters, useApiImage, useApiUrl, useAppConfig, useAssignProjectToUser, useAssignableRoles, useAudience, useBasfStore, useBreadCrumbStore, useCluster, useClusterAllNews, useClusterDescription, useClusterDetails, useClusterFilterSettings, useClusterGetJoinRequests, useClusterGetNews, useClusterGetNewsNextPreviousStatus, useClusterImages, useClusterImagesAndVideos, useClusterLinks, useClusterMapInfo, useClusterNews, useClusterNewsWithId, useClusterOverview, useClusters, useCmsContentWithType, useCmsImage, useCmsUrl, useConfigSettings, useContractStatisticsByUser, useCountries, useCreateHost, useCurrentUser, useDefaultSettings, useDeleteHost, useDimensions, useEmailing, useEvolandBands, useEvolandLabels, useEvolandWmsLayers, useFeature, useFeatures, useFileUpload, useFileUrl, useFilterClusters, useGeoWikiSettings, useGetUserProject, useGrantedPolicies, useGroupsInProject, useHost, useHosts, useImageUrl, useIntroTourSettings, useIsAdmin, useIsAuthenticated, useIsInRole, useLanguages, useLatestTaskOnLocation, useLayerInfo, useLayerStore, useLocation, useLocationBulkUpload, useLocationsForProject, useLockBodyScroll, useLookUp, useMapMenuItems, useNews, useNewsFromAllClusters, usePagination, usePanelStore, usePermission, usePermissions, useProfile, useProjectDetails, useProjectResultSet, useProjectStatisticsByUser, useProjectUsers, useProjects, useProjectsPointsDownload, usePublicationSettings, useQuestionnaire, useRandomTasksPerLocation, useRenderInfo, useResource, useResourceFilter, useResourceType, useReviewTaskBulkUpload, useRoles, useSession, useTaskAnnotation, useTaskAnswers, useTaskBulkUpload, useTaskComments, useTaskDelete, useTaskMultipleAnnotations, useTaskSavedAnnotations, useTaskStatusList, useTasksPerLocation, useTenants, useTopic, useUpdateActiveGroupInProject, useUpdateHost, useUpdateUserDetail, useUserProfileGet, useUserRoles, useUsers };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,13 +6,13 @@ import * as _geowiki_api_proxy from '@geowiki/api-proxy';
|
|
|
6
6
|
import { ApplicationConfigurationDto, ResourceFilterInput, CurrentUserDto, EmailSettingsDto, GetFeatureListResultDto, GetPermissionListResultDto, ProfileDto, CountryDto, FileDto, FarmerClusterNewsDto, LocationDto } from '@geowiki/api-proxy';
|
|
7
7
|
import * as _geowiki_cms_proxy from '@geowiki/cms-proxy';
|
|
8
8
|
import { ClusterFilterSettingsItemDto, ConfigSettingsItemDto, GeoWikiSettingsItemDto, IntroTourSettingsItemDto, PublicationSettingsItemDto, MapSettingsItemDto, FundingSettingsItemDto, FooterSettingsItemDto, MenuItemDto, MapMenuItemItemDto, LayerItemDto, PageItemDto } from '@geowiki/cms-proxy';
|
|
9
|
-
import { MutableRefObject } from 'react';
|
|
9
|
+
import React$1, { MutableRefObject } from 'react';
|
|
10
10
|
import GeoJSON from 'geojson';
|
|
11
11
|
import * as zustand from 'zustand';
|
|
12
12
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
13
13
|
import { I18n } from 'next-localization';
|
|
14
14
|
import { GetServerSidePropsContext } from 'next';
|
|
15
|
-
import
|
|
15
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
16
|
|
|
17
17
|
declare const easing: number[];
|
|
18
18
|
declare const listVariants: {
|
|
@@ -1149,6 +1149,35 @@ declare const getPageProps: (ctx: GetServerSidePropsContext) => Promise<{
|
|
|
1149
1149
|
};
|
|
1150
1150
|
}>;
|
|
1151
1151
|
|
|
1152
|
+
interface ClientSession {
|
|
1153
|
+
accessToken: string;
|
|
1154
|
+
idToken: string;
|
|
1155
|
+
userRole: string | string[];
|
|
1156
|
+
user: {
|
|
1157
|
+
name?: string | null;
|
|
1158
|
+
email?: string | null;
|
|
1159
|
+
image?: string | null;
|
|
1160
|
+
};
|
|
1161
|
+
expires: string;
|
|
1162
|
+
error?: string;
|
|
1163
|
+
}
|
|
1164
|
+
type SessionStatus = "loading" | "authenticated" | "unauthenticated";
|
|
1165
|
+
interface SessionContextValue {
|
|
1166
|
+
data: ClientSession | null;
|
|
1167
|
+
status: SessionStatus;
|
|
1168
|
+
update: () => void;
|
|
1169
|
+
}
|
|
1170
|
+
declare const SESSION_QUERY_KEY: readonly ["geowiki-session"];
|
|
1171
|
+
declare function SessionProvider({ children, session: initialSession, onSessionChange, }: {
|
|
1172
|
+
children: React$1.ReactNode;
|
|
1173
|
+
session?: ClientSession | null;
|
|
1174
|
+
onSessionChange?: (session: ClientSession | null) => void;
|
|
1175
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1176
|
+
declare function useSession(): SessionContextValue;
|
|
1177
|
+
|
|
1178
|
+
declare function signIn(_provider?: string, _options?: Record<string, unknown>, params?: Record<string, string>): void;
|
|
1179
|
+
declare function signOut(): void;
|
|
1180
|
+
|
|
1152
1181
|
/**
|
|
1153
1182
|
* Analytics utilities for tracking user interactions with Umami
|
|
1154
1183
|
*
|
|
@@ -1183,9 +1212,7 @@ declare global {
|
|
|
1183
1212
|
* @param eventData - Additional data to include with the event
|
|
1184
1213
|
* @param session - Optional session object containing user information
|
|
1185
1214
|
*/
|
|
1186
|
-
declare const trackUmamiEvent: (eventName: string, eventData?: Record<string, any>, session?:
|
|
1187
|
-
accessToken?: string;
|
|
1188
|
-
}) => void;
|
|
1215
|
+
declare const trackUmamiEvent: (eventName: string, eventData?: Record<string, any>, session?: ClientSession) => void;
|
|
1189
1216
|
/**
|
|
1190
1217
|
* Track download-related events with consistent data structure
|
|
1191
1218
|
*/
|
|
@@ -1193,27 +1220,19 @@ declare const trackDownloadEvent: {
|
|
|
1193
1220
|
/**
|
|
1194
1221
|
* Track download attempt
|
|
1195
1222
|
*/
|
|
1196
|
-
attempt: (format: string, country: string, version: string, purpose: string, session?:
|
|
1197
|
-
accessToken?: string;
|
|
1198
|
-
}) => void;
|
|
1223
|
+
attempt: (format: string, country: string, version: string, purpose: string, session?: ClientSession) => void;
|
|
1199
1224
|
/**
|
|
1200
1225
|
* Track successful download
|
|
1201
1226
|
*/
|
|
1202
|
-
success: (filename: string, purpose: string, session?:
|
|
1203
|
-
accessToken?: string;
|
|
1204
|
-
}) => void;
|
|
1227
|
+
success: (filename: string, purpose: string, session?: ClientSession) => void;
|
|
1205
1228
|
/**
|
|
1206
1229
|
* Track download failure
|
|
1207
1230
|
*/
|
|
1208
|
-
failure: (error: string, purpose: string, session?:
|
|
1209
|
-
accessToken?: string;
|
|
1210
|
-
}) => void;
|
|
1231
|
+
failure: (error: string, purpose: string, session?: ClientSession) => void;
|
|
1211
1232
|
/**
|
|
1212
1233
|
* Track login attempt for download access
|
|
1213
1234
|
*/
|
|
1214
|
-
loginAttempt: (session?:
|
|
1215
|
-
accessToken?: string;
|
|
1216
|
-
}) => void;
|
|
1235
|
+
loginAttempt: (session?: ClientSession) => void;
|
|
1217
1236
|
};
|
|
1218
1237
|
/**
|
|
1219
1238
|
* Track authentication-related events
|
|
@@ -1222,21 +1241,15 @@ declare const trackAuthEvent: {
|
|
|
1222
1241
|
/**
|
|
1223
1242
|
* Track login attempt
|
|
1224
1243
|
*/
|
|
1225
|
-
loginAttempt: (provider: string, session?:
|
|
1226
|
-
accessToken?: string;
|
|
1227
|
-
}) => void;
|
|
1244
|
+
loginAttempt: (provider: string, session?: ClientSession) => void;
|
|
1228
1245
|
/**
|
|
1229
1246
|
* Track successful login
|
|
1230
1247
|
*/
|
|
1231
|
-
loginSuccess: (provider: string, session?:
|
|
1232
|
-
accessToken?: string;
|
|
1233
|
-
}) => void;
|
|
1248
|
+
loginSuccess: (provider: string, session?: ClientSession) => void;
|
|
1234
1249
|
/**
|
|
1235
1250
|
* Track logout
|
|
1236
1251
|
*/
|
|
1237
|
-
logout: (session?:
|
|
1238
|
-
accessToken?: string;
|
|
1239
|
-
}) => void;
|
|
1252
|
+
logout: (session?: ClientSession) => void;
|
|
1240
1253
|
};
|
|
1241
1254
|
/**
|
|
1242
1255
|
* Track general user interaction events
|
|
@@ -1245,27 +1258,19 @@ declare const trackUserEvent: {
|
|
|
1245
1258
|
/**
|
|
1246
1259
|
* Track page view
|
|
1247
1260
|
*/
|
|
1248
|
-
pageView: (page: string, session?:
|
|
1249
|
-
accessToken?: string;
|
|
1250
|
-
}) => void;
|
|
1261
|
+
pageView: (page: string, session?: ClientSession) => void;
|
|
1251
1262
|
/**
|
|
1252
1263
|
* Track button click
|
|
1253
1264
|
*/
|
|
1254
|
-
buttonClick: (buttonName: string, context?: string, session?:
|
|
1255
|
-
accessToken?: string;
|
|
1256
|
-
}) => void;
|
|
1265
|
+
buttonClick: (buttonName: string, context?: string, session?: ClientSession) => void;
|
|
1257
1266
|
/**
|
|
1258
1267
|
* Track form submission
|
|
1259
1268
|
*/
|
|
1260
|
-
formSubmit: (formName: string, session?:
|
|
1261
|
-
accessToken?: string;
|
|
1262
|
-
}) => void;
|
|
1269
|
+
formSubmit: (formName: string, session?: ClientSession) => void;
|
|
1263
1270
|
/**
|
|
1264
1271
|
* Track map control button click with specific context
|
|
1265
1272
|
*/
|
|
1266
|
-
mapControlClick: (controlName: string, action?: string, session?:
|
|
1267
|
-
accessToken?: string;
|
|
1268
|
-
}) => void;
|
|
1273
|
+
mapControlClick: (controlName: string, action?: string, session?: ClientSession) => void;
|
|
1269
1274
|
};
|
|
1270
1275
|
/**
|
|
1271
1276
|
* Track map control events
|
|
@@ -1274,51 +1279,35 @@ declare const trackMapEvent: {
|
|
|
1274
1279
|
/**
|
|
1275
1280
|
* Track layer toggle
|
|
1276
1281
|
*/
|
|
1277
|
-
layerToggle: (layerName: string, action: "add" | "remove", session?:
|
|
1278
|
-
accessToken?: string;
|
|
1279
|
-
}) => void;
|
|
1282
|
+
layerToggle: (layerName: string, action: "add" | "remove", session?: ClientSession) => void;
|
|
1280
1283
|
/**
|
|
1281
1284
|
* Track base layer change
|
|
1282
1285
|
*/
|
|
1283
|
-
baseLayerChange: (baseLayerName: string, session?:
|
|
1284
|
-
accessToken?: string;
|
|
1285
|
-
}) => void;
|
|
1286
|
+
baseLayerChange: (baseLayerName: string, session?: ClientSession) => void;
|
|
1286
1287
|
/**
|
|
1287
1288
|
* Track layer opacity change
|
|
1288
1289
|
*/
|
|
1289
|
-
layerOpacityChange: (layerName: string, opacity: number, session?:
|
|
1290
|
-
accessToken?: string;
|
|
1291
|
-
}) => void;
|
|
1290
|
+
layerOpacityChange: (layerName: string, opacity: number, session?: ClientSession) => void;
|
|
1292
1291
|
/**
|
|
1293
1292
|
* Track layer reorder
|
|
1294
1293
|
*/
|
|
1295
|
-
layerReorder: (layerName: string, newPosition: number, session?:
|
|
1296
|
-
accessToken?: string;
|
|
1297
|
-
}) => void;
|
|
1294
|
+
layerReorder: (layerName: string, newPosition: number, session?: ClientSession) => void;
|
|
1298
1295
|
/**
|
|
1299
1296
|
* Track layer info view
|
|
1300
1297
|
*/
|
|
1301
|
-
layerInfoView: (layerName: string, session?:
|
|
1302
|
-
accessToken?: string;
|
|
1303
|
-
}) => void;
|
|
1298
|
+
layerInfoView: (layerName: string, session?: ClientSession) => void;
|
|
1304
1299
|
/**
|
|
1305
1300
|
* Track measurement tool usage
|
|
1306
1301
|
*/
|
|
1307
|
-
measurementTool: (action: "start" | "stop" | "clear", session?:
|
|
1308
|
-
accessToken?: string;
|
|
1309
|
-
}) => void;
|
|
1302
|
+
measurementTool: (action: "start" | "stop" | "clear", session?: ClientSession) => void;
|
|
1310
1303
|
/**
|
|
1311
1304
|
* Track zoom control usage
|
|
1312
1305
|
*/
|
|
1313
|
-
zoomControl: (action: "zoom_in" | "zoom_out" | "reset", session?:
|
|
1314
|
-
accessToken?: string;
|
|
1315
|
-
}) => void;
|
|
1306
|
+
zoomControl: (action: "zoom_in" | "zoom_out" | "reset", session?: ClientSession) => void;
|
|
1316
1307
|
/**
|
|
1317
1308
|
* Track legend interaction
|
|
1318
1309
|
*/
|
|
1319
|
-
legendInteraction: (action: "open" | "close" | "reorder", session?:
|
|
1320
|
-
accessToken?: string;
|
|
1321
|
-
}) => void;
|
|
1310
|
+
legendInteraction: (action: "open" | "close" | "reorder", session?: ClientSession) => void;
|
|
1322
1311
|
};
|
|
1323
1312
|
|
|
1324
1313
|
/**
|
|
@@ -1401,4 +1390,4 @@ declare const QueryNames: {
|
|
|
1401
1390
|
GetHosts: string;
|
|
1402
1391
|
};
|
|
1403
1392
|
|
|
1404
|
-
export { ActivityStatus, AdminMenus, type Alert, AnnotationRequired, type BaseProp, type BasfLayerItem, type BingNewsItem, CLUSTER_ACTIVITY_STATUS, type ClusterDto, ClusterFunding, ColorArray, ColorArrayCSSClass, type Colormap, type Column, Config, DOTS, type DefaultSettings, type DisplayItem, type Entry, FarmingSystem, Features, type FluffyThumbnail, type Font, type FooterSettings, type FundingSettings, type GlobalSettings, type Graphic, type HostInfo, HostService, HostType, HuntingManagement, ImageError, IsTokenExpired, type LabelPlacement, type Legend, type LegendInfo, type Line, type LinkWithNewTab, LiveStock, type LocationTasks, LookUps, MainAgriculturalAreas, MainCrops, type MainMenu, type MapLayer, type MapSettings, type Menu, type MenuItem, NewsDefaultImage, type NewsResult, OtherLandscapeElements, Permission, PermissionProvider, type Point, type Policy, type Polygon, type Provider, type ProviderImage, type PurpleThumbnail, QueryConstants, type QueryContext, QueryNames, QuestionnaireType, type Raster, ResourcesMenu, Responsive, type Rule, type Sort, StyleType, type SubMenu, type Symbolizer, TaskEventType, TaskState, TaskStatus, TaskStatusColor, type Text, USER_ROLE, type UtmResult, type ValueImage, ViewStatus, classNames, configStore, delayedSlideInUp, downloadData, downloadJSON, easing, findHostInfo, formatUnixDate, getButtonAppearance, getCmsUrlForHost, getContentWithSlug, getContentWithTypeAndDisplayName, getContentsWithType, getDefaultSettings, getGeoWikiSettings, getHostData, getHostFromRequest, getHtmlElementFromReactNode, getMediaUrl, getMenus, getPageContent, getPageProps, getTenantIdForHost, i18n, imageMaxDimension, imageMinDimension, itemVariants, keyStr, listVariants, rgbDataURL, routes, scrollToFirstErrorElement, settingsStore, shimmer, showIntroTour, slideInLeft, slideInRight, slideInUp, spring, toBase64, tokenData, trackAuthEvent, trackDownloadEvent, trackMapEvent, trackUmamiEvent, trackUserEvent, triplet, useAllNewsFromAllClusters, useApiImage, useApiUrl, useAppConfig, useAssignProjectToUser, useAssignableRoles, useAudience, useBasfStore, useBreadCrumbStore, useCluster, useClusterAllNews, useClusterDescription, useClusterDetails, useClusterFilterSettings, useClusterGetJoinRequests, useClusterGetNews, useClusterGetNewsNextPreviousStatus, useClusterImages, useClusterImagesAndVideos, useClusterLinks, useClusterMapInfo, useClusterNews, useClusterNewsWithId, useClusterOverview, useClusters, useCmsContentWithType, useCmsImage, useCmsUrl, useConfigSettings, useContractStatisticsByUser, useCountries, useCreateHost, useCurrentUser, useDefaultSettings, useDeleteHost, useDimensions, useEmailing, useEvolandBands, useEvolandLabels, useEvolandWmsLayers, useFeature, useFeatures, useFileUpload, useFileUrl, useFilterClusters, useGeoWikiSettings, useGetUserProject, useGrantedPolicies, useGroupsInProject, useHost, useHosts, useImageUrl, useIntroTourSettings, useIsAdmin, useIsAuthenticated, useIsInRole, useLanguages, useLatestTaskOnLocation, useLayerInfo, useLayerStore, useLocation, useLocationBulkUpload, useLocationsForProject, useLockBodyScroll, useLookUp, useMapMenuItems, useNews, useNewsFromAllClusters, usePagination, usePanelStore, usePermission, usePermissions, useProfile, useProjectDetails, useProjectResultSet, useProjectStatisticsByUser, useProjectUsers, useProjects, useProjectsPointsDownload, usePublicationSettings, useQuestionnaire, useRandomTasksPerLocation, useRenderInfo, useResource, useResourceFilter, useResourceType, useReviewTaskBulkUpload, useRoles, useTaskAnnotation, useTaskAnswers, useTaskBulkUpload, useTaskComments, useTaskDelete, useTaskMultipleAnnotations, useTaskSavedAnnotations, useTaskStatusList, useTasksPerLocation, useTenants, useTopic, useUpdateActiveGroupInProject, useUpdateHost, useUpdateUserDetail, useUserProfileGet, useUserRoles, useUsers };
|
|
1393
|
+
export { ActivityStatus, AdminMenus, type Alert, AnnotationRequired, type BaseProp, type BasfLayerItem, type BingNewsItem, CLUSTER_ACTIVITY_STATUS, type ClientSession, type ClusterDto, ClusterFunding, ColorArray, ColorArrayCSSClass, type Colormap, type Column, Config, DOTS, type DefaultSettings, type DisplayItem, type Entry, FarmingSystem, Features, type FluffyThumbnail, type Font, type FooterSettings, type FundingSettings, type GlobalSettings, type Graphic, type HostInfo, HostService, HostType, HuntingManagement, ImageError, IsTokenExpired, type LabelPlacement, type Legend, type LegendInfo, type Line, type LinkWithNewTab, LiveStock, type LocationTasks, LookUps, MainAgriculturalAreas, MainCrops, type MainMenu, type MapLayer, type MapSettings, type Menu, type MenuItem, NewsDefaultImage, type NewsResult, OtherLandscapeElements, Permission, PermissionProvider, type Point, type Policy, type Polygon, type Provider, type ProviderImage, type PurpleThumbnail, QueryConstants, type QueryContext, QueryNames, QuestionnaireType, type Raster, ResourcesMenu, Responsive, type Rule, SESSION_QUERY_KEY, SessionProvider, type SessionStatus, type Sort, StyleType, type SubMenu, type Symbolizer, TaskEventType, TaskState, TaskStatus, TaskStatusColor, type Text, USER_ROLE, type UtmResult, type ValueImage, ViewStatus, classNames, configStore, delayedSlideInUp, downloadData, downloadJSON, easing, findHostInfo, formatUnixDate, getButtonAppearance, getCmsUrlForHost, getContentWithSlug, getContentWithTypeAndDisplayName, getContentsWithType, getDefaultSettings, getGeoWikiSettings, getHostData, getHostFromRequest, getHtmlElementFromReactNode, getMediaUrl, getMenus, getPageContent, getPageProps, getTenantIdForHost, i18n, imageMaxDimension, imageMinDimension, itemVariants, keyStr, listVariants, rgbDataURL, routes, scrollToFirstErrorElement, settingsStore, shimmer, showIntroTour, signIn, signOut, slideInLeft, slideInRight, slideInUp, spring, toBase64, tokenData, trackAuthEvent, trackDownloadEvent, trackMapEvent, trackUmamiEvent, trackUserEvent, triplet, useAllNewsFromAllClusters, useApiImage, useApiUrl, useAppConfig, useAssignProjectToUser, useAssignableRoles, useAudience, useBasfStore, useBreadCrumbStore, useCluster, useClusterAllNews, useClusterDescription, useClusterDetails, useClusterFilterSettings, useClusterGetJoinRequests, useClusterGetNews, useClusterGetNewsNextPreviousStatus, useClusterImages, useClusterImagesAndVideos, useClusterLinks, useClusterMapInfo, useClusterNews, useClusterNewsWithId, useClusterOverview, useClusters, useCmsContentWithType, useCmsImage, useCmsUrl, useConfigSettings, useContractStatisticsByUser, useCountries, useCreateHost, useCurrentUser, useDefaultSettings, useDeleteHost, useDimensions, useEmailing, useEvolandBands, useEvolandLabels, useEvolandWmsLayers, useFeature, useFeatures, useFileUpload, useFileUrl, useFilterClusters, useGeoWikiSettings, useGetUserProject, useGrantedPolicies, useGroupsInProject, useHost, useHosts, useImageUrl, useIntroTourSettings, useIsAdmin, useIsAuthenticated, useIsInRole, useLanguages, useLatestTaskOnLocation, useLayerInfo, useLayerStore, useLocation, useLocationBulkUpload, useLocationsForProject, useLockBodyScroll, useLookUp, useMapMenuItems, useNews, useNewsFromAllClusters, usePagination, usePanelStore, usePermission, usePermissions, useProfile, useProjectDetails, useProjectResultSet, useProjectStatisticsByUser, useProjectUsers, useProjects, useProjectsPointsDownload, usePublicationSettings, useQuestionnaire, useRandomTasksPerLocation, useRenderInfo, useResource, useResourceFilter, useResourceType, useReviewTaskBulkUpload, useRoles, useSession, useTaskAnnotation, useTaskAnswers, useTaskBulkUpload, useTaskComments, useTaskDelete, useTaskMultipleAnnotations, useTaskSavedAnnotations, useTaskStatusList, useTasksPerLocation, useTenants, useTopic, useUpdateActiveGroupInProject, useUpdateHost, useUpdateUserDetail, useUserProfileGet, useUserRoles, useUsers };
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,8 @@ __export(src_exports, {
|
|
|
108
108
|
QuestionnaireType: () => QuestionnaireType,
|
|
109
109
|
ResourcesMenu: () => ResourcesMenu,
|
|
110
110
|
Responsive: () => Responsive,
|
|
111
|
+
SESSION_QUERY_KEY: () => SESSION_QUERY_KEY,
|
|
112
|
+
SessionProvider: () => SessionProvider,
|
|
111
113
|
StyleType: () => StyleType,
|
|
112
114
|
TaskEventType: () => TaskEventType,
|
|
113
115
|
TaskState: () => TaskState,
|
|
@@ -150,6 +152,8 @@ __export(src_exports, {
|
|
|
150
152
|
settingsStore: () => settingsStore,
|
|
151
153
|
shimmer: () => shimmer,
|
|
152
154
|
showIntroTour: () => showIntroTour,
|
|
155
|
+
signIn: () => signIn,
|
|
156
|
+
signOut: () => signOut,
|
|
153
157
|
slideInLeft: () => slideInLeft,
|
|
154
158
|
slideInRight: () => slideInRight,
|
|
155
159
|
slideInUp: () => slideInUp,
|
|
@@ -250,6 +254,7 @@ __export(src_exports, {
|
|
|
250
254
|
useResourceType: () => useResourceType,
|
|
251
255
|
useReviewTaskBulkUpload: () => useReviewTaskBulkUpload,
|
|
252
256
|
useRoles: () => useRoles,
|
|
257
|
+
useSession: () => useSession,
|
|
253
258
|
useTaskAnnotation: () => useTaskAnnotation,
|
|
254
259
|
useTaskAnswers: () => useTaskAnswers,
|
|
255
260
|
useTaskBulkUpload: () => useTaskBulkUpload,
|
|
@@ -3254,6 +3259,79 @@ var trackMapEvent = {
|
|
|
3254
3259
|
trackUmamiEvent("map_legend_interaction", { action }, session);
|
|
3255
3260
|
}
|
|
3256
3261
|
};
|
|
3262
|
+
|
|
3263
|
+
// src/auth/AuthContext.tsx
|
|
3264
|
+
var import_react7 = require("react");
|
|
3265
|
+
var import_react_query58 = require("@tanstack/react-query");
|
|
3266
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3267
|
+
var SESSION_QUERY_KEY = ["geowiki-session"];
|
|
3268
|
+
var SessionContext = (0, import_react7.createContext)({
|
|
3269
|
+
data: null,
|
|
3270
|
+
status: "loading",
|
|
3271
|
+
update: () => {
|
|
3272
|
+
}
|
|
3273
|
+
});
|
|
3274
|
+
function fetchSession() {
|
|
3275
|
+
return __async(this, null, function* () {
|
|
3276
|
+
try {
|
|
3277
|
+
const res = yield fetch("/api/auth/session");
|
|
3278
|
+
const json = yield res.json();
|
|
3279
|
+
if (json.accessToken) {
|
|
3280
|
+
return json;
|
|
3281
|
+
}
|
|
3282
|
+
return null;
|
|
3283
|
+
} catch (e) {
|
|
3284
|
+
return null;
|
|
3285
|
+
}
|
|
3286
|
+
});
|
|
3287
|
+
}
|
|
3288
|
+
function SessionProvider({
|
|
3289
|
+
children,
|
|
3290
|
+
session: initialSession,
|
|
3291
|
+
onSessionChange
|
|
3292
|
+
}) {
|
|
3293
|
+
const queryClient = (0, import_react_query58.useQueryClient)();
|
|
3294
|
+
const { data, isLoading } = (0, import_react_query58.useQuery)({
|
|
3295
|
+
queryKey: SESSION_QUERY_KEY,
|
|
3296
|
+
queryFn: fetchSession,
|
|
3297
|
+
initialData: initialSession != null ? initialSession : void 0,
|
|
3298
|
+
staleTime: 5 * 60 * 1e3,
|
|
3299
|
+
refetchOnWindowFocus: true,
|
|
3300
|
+
refetchInterval: 4 * 60 * 1e3
|
|
3301
|
+
});
|
|
3302
|
+
(0, import_react7.useEffect)(() => {
|
|
3303
|
+
onSessionChange == null ? void 0 : onSessionChange(data != null ? data : null);
|
|
3304
|
+
}, [data, onSessionChange]);
|
|
3305
|
+
const status = isLoading ? "loading" : data ? "authenticated" : "unauthenticated";
|
|
3306
|
+
const update = (0, import_react7.useMemo)(
|
|
3307
|
+
() => () => queryClient.invalidateQueries({ queryKey: SESSION_QUERY_KEY }),
|
|
3308
|
+
[queryClient]
|
|
3309
|
+
);
|
|
3310
|
+
const value = (0, import_react7.useMemo)(
|
|
3311
|
+
() => ({ data: data != null ? data : null, status, update }),
|
|
3312
|
+
[data, status, update]
|
|
3313
|
+
);
|
|
3314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SessionContext.Provider, { value, children });
|
|
3315
|
+
}
|
|
3316
|
+
function useSession() {
|
|
3317
|
+
return (0, import_react7.useContext)(SessionContext);
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
// src/auth/actions.ts
|
|
3321
|
+
function signIn(_provider, _options, params) {
|
|
3322
|
+
const url = new URL("/api/auth/login", window.location.origin);
|
|
3323
|
+
const currentPath = window.location.pathname;
|
|
3324
|
+
if (currentPath !== "/" && currentPath !== "/login") {
|
|
3325
|
+
url.searchParams.set("returnTo", currentPath);
|
|
3326
|
+
}
|
|
3327
|
+
if (params) {
|
|
3328
|
+
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
3329
|
+
}
|
|
3330
|
+
window.location.href = url.toString();
|
|
3331
|
+
}
|
|
3332
|
+
function signOut() {
|
|
3333
|
+
window.location.href = "/api/auth/logout";
|
|
3334
|
+
}
|
|
3257
3335
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3258
3336
|
0 && (module.exports = {
|
|
3259
3337
|
ActivityStatus,
|
|
@@ -3285,6 +3363,8 @@ var trackMapEvent = {
|
|
|
3285
3363
|
QuestionnaireType,
|
|
3286
3364
|
ResourcesMenu,
|
|
3287
3365
|
Responsive,
|
|
3366
|
+
SESSION_QUERY_KEY,
|
|
3367
|
+
SessionProvider,
|
|
3288
3368
|
StyleType,
|
|
3289
3369
|
TaskEventType,
|
|
3290
3370
|
TaskState,
|
|
@@ -3327,6 +3407,8 @@ var trackMapEvent = {
|
|
|
3327
3407
|
settingsStore,
|
|
3328
3408
|
shimmer,
|
|
3329
3409
|
showIntroTour,
|
|
3410
|
+
signIn,
|
|
3411
|
+
signOut,
|
|
3330
3412
|
slideInLeft,
|
|
3331
3413
|
slideInRight,
|
|
3332
3414
|
slideInUp,
|
|
@@ -3427,6 +3509,7 @@ var trackMapEvent = {
|
|
|
3427
3509
|
useResourceType,
|
|
3428
3510
|
useReviewTaskBulkUpload,
|
|
3429
3511
|
useRoles,
|
|
3512
|
+
useSession,
|
|
3430
3513
|
useTaskAnnotation,
|
|
3431
3514
|
useTaskAnswers,
|
|
3432
3515
|
useTaskBulkUpload,
|
package/dist/index.mjs
CHANGED
|
@@ -3051,6 +3051,79 @@ var trackMapEvent = {
|
|
|
3051
3051
|
trackUmamiEvent("map_legend_interaction", { action }, session);
|
|
3052
3052
|
}
|
|
3053
3053
|
};
|
|
3054
|
+
|
|
3055
|
+
// src/auth/AuthContext.tsx
|
|
3056
|
+
import { createContext, useContext, useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
3057
|
+
import { useQuery as useQuery57, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
3058
|
+
import { jsx } from "react/jsx-runtime";
|
|
3059
|
+
var SESSION_QUERY_KEY = ["geowiki-session"];
|
|
3060
|
+
var SessionContext = createContext({
|
|
3061
|
+
data: null,
|
|
3062
|
+
status: "loading",
|
|
3063
|
+
update: () => {
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
function fetchSession() {
|
|
3067
|
+
return __async(this, null, function* () {
|
|
3068
|
+
try {
|
|
3069
|
+
const res = yield fetch("/api/auth/session");
|
|
3070
|
+
const json = yield res.json();
|
|
3071
|
+
if (json.accessToken) {
|
|
3072
|
+
return json;
|
|
3073
|
+
}
|
|
3074
|
+
return null;
|
|
3075
|
+
} catch (e) {
|
|
3076
|
+
return null;
|
|
3077
|
+
}
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
function SessionProvider({
|
|
3081
|
+
children,
|
|
3082
|
+
session: initialSession,
|
|
3083
|
+
onSessionChange
|
|
3084
|
+
}) {
|
|
3085
|
+
const queryClient = useQueryClient2();
|
|
3086
|
+
const { data, isLoading } = useQuery57({
|
|
3087
|
+
queryKey: SESSION_QUERY_KEY,
|
|
3088
|
+
queryFn: fetchSession,
|
|
3089
|
+
initialData: initialSession != null ? initialSession : void 0,
|
|
3090
|
+
staleTime: 5 * 60 * 1e3,
|
|
3091
|
+
refetchOnWindowFocus: true,
|
|
3092
|
+
refetchInterval: 4 * 60 * 1e3
|
|
3093
|
+
});
|
|
3094
|
+
useEffect4(() => {
|
|
3095
|
+
onSessionChange == null ? void 0 : onSessionChange(data != null ? data : null);
|
|
3096
|
+
}, [data, onSessionChange]);
|
|
3097
|
+
const status = isLoading ? "loading" : data ? "authenticated" : "unauthenticated";
|
|
3098
|
+
const update = useMemo2(
|
|
3099
|
+
() => () => queryClient.invalidateQueries({ queryKey: SESSION_QUERY_KEY }),
|
|
3100
|
+
[queryClient]
|
|
3101
|
+
);
|
|
3102
|
+
const value = useMemo2(
|
|
3103
|
+
() => ({ data: data != null ? data : null, status, update }),
|
|
3104
|
+
[data, status, update]
|
|
3105
|
+
);
|
|
3106
|
+
return /* @__PURE__ */ jsx(SessionContext.Provider, { value, children });
|
|
3107
|
+
}
|
|
3108
|
+
function useSession() {
|
|
3109
|
+
return useContext(SessionContext);
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
// src/auth/actions.ts
|
|
3113
|
+
function signIn(_provider, _options, params) {
|
|
3114
|
+
const url = new URL("/api/auth/login", window.location.origin);
|
|
3115
|
+
const currentPath = window.location.pathname;
|
|
3116
|
+
if (currentPath !== "/" && currentPath !== "/login") {
|
|
3117
|
+
url.searchParams.set("returnTo", currentPath);
|
|
3118
|
+
}
|
|
3119
|
+
if (params) {
|
|
3120
|
+
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
3121
|
+
}
|
|
3122
|
+
window.location.href = url.toString();
|
|
3123
|
+
}
|
|
3124
|
+
function signOut() {
|
|
3125
|
+
window.location.href = "/api/auth/logout";
|
|
3126
|
+
}
|
|
3054
3127
|
export {
|
|
3055
3128
|
ActivityStatus,
|
|
3056
3129
|
AdminMenus,
|
|
@@ -3081,6 +3154,8 @@ export {
|
|
|
3081
3154
|
QuestionnaireType,
|
|
3082
3155
|
ResourcesMenu,
|
|
3083
3156
|
Responsive,
|
|
3157
|
+
SESSION_QUERY_KEY,
|
|
3158
|
+
SessionProvider,
|
|
3084
3159
|
StyleType,
|
|
3085
3160
|
TaskEventType,
|
|
3086
3161
|
TaskState,
|
|
@@ -3123,6 +3198,8 @@ export {
|
|
|
3123
3198
|
settingsStore,
|
|
3124
3199
|
shimmer,
|
|
3125
3200
|
showIntroTour,
|
|
3201
|
+
signIn,
|
|
3202
|
+
signOut,
|
|
3126
3203
|
slideInLeft,
|
|
3127
3204
|
slideInRight,
|
|
3128
3205
|
slideInUp,
|
|
@@ -3223,6 +3300,7 @@ export {
|
|
|
3223
3300
|
useResourceType,
|
|
3224
3301
|
useReviewTaskBulkUpload,
|
|
3225
3302
|
useRoles,
|
|
3303
|
+
useSession,
|
|
3226
3304
|
useTaskAnnotation,
|
|
3227
3305
|
useTaskAnswers,
|
|
3228
3306
|
useTaskBulkUpload,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geowiki/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-dev.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
"@types/react": "^18.2.0",
|
|
19
19
|
"@types/react-dom": "^18.2.7",
|
|
20
20
|
"eslint": "^8.56.0",
|
|
21
|
-
"next-auth": "4.24.6",
|
|
22
21
|
"tsup": "^8.0.2",
|
|
23
22
|
"typescript": "5.4.2",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
23
|
+
"eslint-config-custom": "0.0.0",
|
|
24
|
+
"tsconfig": "0.0.0"
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"cookies-next": "^4.1.1",
|
|
@@ -31,16 +30,15 @@
|
|
|
31
30
|
"geotiff": "^2.1.3",
|
|
32
31
|
"xlsx": "^0.18.5",
|
|
33
32
|
"zustand": "4.5.1",
|
|
34
|
-
"@geowiki/api-proxy": "0.
|
|
35
|
-
"@geowiki/cms-proxy": "0.
|
|
36
|
-
"@geowiki/evoland-api-proxy": "0.
|
|
33
|
+
"@geowiki/api-proxy": "0.16.0-dev.1",
|
|
34
|
+
"@geowiki/cms-proxy": "0.16.0-dev.1",
|
|
35
|
+
"@geowiki/evoland-api-proxy": "0.16.0-dev.1"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
38
|
"@react-leaflet/core": "^2.1.0",
|
|
40
39
|
"@tanstack/react-query": "^5.22.2",
|
|
41
40
|
"leaflet": "^1.9.4",
|
|
42
41
|
"next": "15.5.3",
|
|
43
|
-
"next-auth": "^4.24.6",
|
|
44
42
|
"next-localization": "^0.12.0",
|
|
45
43
|
"@heroicons/react": "^2.1.1",
|
|
46
44
|
"react": "^18.2.0",
|