diff --git a/apps/skolplattformen-app/components/calendar.component.tsx b/apps/skolplattformen-app/components/calendar.component.tsx index b3c5f147..6651e312 100644 --- a/apps/skolplattformen-app/components/calendar.component.tsx +++ b/apps/skolplattformen-app/components/calendar.component.tsx @@ -1,4 +1,4 @@ -import { CalendarItem } from '@skolplattformen/api-skolplattformen' +import { CalendarItem } from '@skolplattformen/api' import { useCalendar } from '@skolplattformen/hooks' import { Divider, diff --git a/apps/skolplattformen-app/components/childContext.component.tsx b/apps/skolplattformen-app/components/childContext.component.tsx index 555c4852..d4bbc51b 100644 --- a/apps/skolplattformen-app/components/childContext.component.tsx +++ b/apps/skolplattformen-app/components/childContext.component.tsx @@ -1,4 +1,4 @@ -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import React, { createContext, useContext } from 'react' interface ChildProviderProps { diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx index bac10817..d8fb3491 100644 --- a/apps/skolplattformen-app/components/childListItem.component.tsx +++ b/apps/skolplattformen-app/components/childListItem.component.tsx @@ -1,7 +1,7 @@ /* eslint-disable react-native-a11y/has-accessibility-hint */ import { useNavigation } from '@react-navigation/native' import { StackNavigationProp } from '@react-navigation/stack' -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import { useCalendar, useClassmates, diff --git a/apps/skolplattformen-app/components/children.component.tsx b/apps/skolplattformen-app/components/children.component.tsx index 7fe185c3..1e2a6acc 100644 --- a/apps/skolplattformen-app/components/children.component.tsx +++ b/apps/skolplattformen-app/components/children.component.tsx @@ -1,5 +1,5 @@ import { useNavigation } from '@react-navigation/core' -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import { useApi, useChildList } from '@skolplattformen/hooks' import { Button, diff --git a/apps/skolplattformen-app/components/classmates.component.tsx b/apps/skolplattformen-app/components/classmates.component.tsx index 5d85dd58..5bf142db 100644 --- a/apps/skolplattformen-app/components/classmates.component.tsx +++ b/apps/skolplattformen-app/components/classmates.component.tsx @@ -1,4 +1,4 @@ -import { Classmate } from '@skolplattformen/api-skolplattformen' +import { Classmate } from '@skolplattformen/api' import { useClassmates } from '@skolplattformen/hooks' import { Divider, diff --git a/apps/skolplattformen-app/components/contactMenu.component.tsx b/apps/skolplattformen-app/components/contactMenu.component.tsx index 3b287431..6421291a 100644 --- a/apps/skolplattformen-app/components/contactMenu.component.tsx +++ b/apps/skolplattformen-app/components/contactMenu.component.tsx @@ -1,5 +1,5 @@ /* eslint-disable react-native-a11y/has-accessibility-hint */ -import { Classmate } from '@skolplattformen/api-skolplattformen' +import { Classmate } from '@skolplattformen/api' import { Button, MenuGroup, diff --git a/apps/skolplattformen-app/components/daySummary.component.tsx b/apps/skolplattformen-app/components/daySummary.component.tsx index 592ac975..8c908c09 100644 --- a/apps/skolplattformen-app/components/daySummary.component.tsx +++ b/apps/skolplattformen-app/components/daySummary.component.tsx @@ -1,4 +1,4 @@ -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import { useTimetable } from '@skolplattformen/hooks' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import moment, { Moment } from 'moment' diff --git a/apps/skolplattformen-app/components/image.component.tsx b/apps/skolplattformen-app/components/image.component.tsx index 2b17b1eb..86595485 100644 --- a/apps/skolplattformen-app/components/image.component.tsx +++ b/apps/skolplattformen-app/components/image.component.tsx @@ -31,7 +31,7 @@ export const Image = ({ resizeMode = 'contain', }: ImageProps) => { const { api } = useApi() - const [headers, setHeaders] = useState() + const [headers, setHeaders] = useState<{ [index: string]: string }>() const { width: windowWidth } = useWindowDimensions() const [dimensions, setDimensions] = useState({ width: 0, height: 0 }) @@ -40,7 +40,7 @@ export const Image = ({ const prefetchImageInformation = useCallback( async (url: string) => { if (!url) return - const { headers: newHeaders } = await api.getSession(url) + const newHeaders = await api.getSessionHeaders(url) console.log('[IMAGE] Getting image dimensions with headers', { debugImageName, diff --git a/apps/skolplattformen-app/components/menu.component.tsx b/apps/skolplattformen-app/components/menu.component.tsx index b1f18842..970060ee 100644 --- a/apps/skolplattformen-app/components/menu.component.tsx +++ b/apps/skolplattformen-app/components/menu.component.tsx @@ -1,4 +1,4 @@ -import { MenuItem } from '@skolplattformen/api-skolplattformen' +import { MenuItem } from '@skolplattformen/api' import { useMenu } from '@skolplattformen/hooks' import { Divider, diff --git a/apps/skolplattformen-app/components/menuListItem.component.tsx b/apps/skolplattformen-app/components/menuListItem.component.tsx index 77556007..235d9c92 100644 --- a/apps/skolplattformen-app/components/menuListItem.component.tsx +++ b/apps/skolplattformen-app/components/menuListItem.component.tsx @@ -1,4 +1,4 @@ -import { MenuItem } from '@skolplattformen/api-skolplattformen' +import { MenuItem } from '@skolplattformen/api' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import React from 'react' import { View } from 'react-native' diff --git a/apps/skolplattformen-app/components/modalWebView.component.tsx b/apps/skolplattformen-app/components/modalWebView.component.tsx index 6a07b923..ab4fa26f 100644 --- a/apps/skolplattformen-app/components/modalWebView.component.tsx +++ b/apps/skolplattformen-app/components/modalWebView.component.tsx @@ -20,12 +20,12 @@ export const ModalWebView = ({ const [modalVisible, setModalVisible] = React.useState(true) const { api } = useApi() const [title, setTitle] = React.useState('...') - const [headers, setHeaders] = useState() + const [headers, setHeaders] = useState<{ [index: string]: string }>() useEffect(() => { const getHeaders = async (urlToGetSessionFor: string) => { if (sharedCookiesEnabled) return - const { headers: newHeaders } = await api.getSession(urlToGetSessionFor) + const newHeaders = await api.getSessionHeaders(urlToGetSessionFor) setHeaders(newHeaders) } diff --git a/apps/skolplattformen-app/components/navigation.component.tsx b/apps/skolplattformen-app/components/navigation.component.tsx index 412c6083..ec70d41d 100644 --- a/apps/skolplattformen-app/components/navigation.component.tsx +++ b/apps/skolplattformen-app/components/navigation.component.tsx @@ -2,7 +2,7 @@ import { NavigationContainer } from '@react-navigation/native' import { Child as ChildType, NewsItem as NewsItemType, -} from '@skolplattformen/api-skolplattformen' +} from '@skolplattformen/api' import { useApi } from '@skolplattformen/hooks' import { useTheme } from '@ui-kitten/components' import { Library } from 'libraries.json' diff --git a/apps/skolplattformen-app/components/newsListItem.component.tsx b/apps/skolplattformen-app/components/newsListItem.component.tsx index 226d6686..1b917043 100644 --- a/apps/skolplattformen-app/components/newsListItem.component.tsx +++ b/apps/skolplattformen-app/components/newsListItem.component.tsx @@ -1,6 +1,6 @@ import { useNavigation } from '@react-navigation/native' import { StackNavigationProp } from '@react-navigation/stack' -import { NewsItem } from '@skolplattformen/api-skolplattformen' +import { NewsItem } from '@skolplattformen/api' import { StyleService, useStyleSheet } from '@ui-kitten/components' import moment from 'moment' import React, { ReactNode } from 'react' diff --git a/apps/skolplattformen-app/components/notification.component.tsx b/apps/skolplattformen-app/components/notification.component.tsx index 5c7a0354..e859d026 100644 --- a/apps/skolplattformen-app/components/notification.component.tsx +++ b/apps/skolplattformen-app/components/notification.component.tsx @@ -1,4 +1,4 @@ -import { Notification as NotificationType } from '@skolplattformen/api-skolplattformen' +import { Notification as NotificationType } from '@skolplattformen/api' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import moment from 'moment' import React from 'react' diff --git a/apps/skolplattformen-app/components/saveToCalendar.component.tsx b/apps/skolplattformen-app/components/saveToCalendar.component.tsx index 39118fe6..ff2491e6 100644 --- a/apps/skolplattformen-app/components/saveToCalendar.component.tsx +++ b/apps/skolplattformen-app/components/saveToCalendar.component.tsx @@ -1,4 +1,4 @@ -import { CalendarItem } from '@skolplattformen/api-skolplattformen' +import { CalendarItem } from '@skolplattformen/api' import { Button, MenuItem, OverflowMenu, Text } from '@ui-kitten/components' import React from 'react' import RNCalendarEvents from 'react-native-calendar-events' diff --git a/apps/skolplattformen-app/components/week.component.tsx b/apps/skolplattformen-app/components/week.component.tsx index 8be3925f..3eab8ee2 100644 --- a/apps/skolplattformen-app/components/week.component.tsx +++ b/apps/skolplattformen-app/components/week.component.tsx @@ -1,8 +1,4 @@ -import { - Child, - MenuItem, - TimetableEntry, -} from '@skolplattformen/api-skolplattformen' +import { Child, MenuItem, TimetableEntry } from '@skolplattformen/api' import { useMenu, useTimetable } from '@skolplattformen/hooks' import { List, diff --git a/apps/skolplattformen-app/context/feature/featureContext.tsx b/apps/skolplattformen-app/context/feature/featureContext.tsx index 82ae6762..250f7c96 100644 --- a/apps/skolplattformen-app/context/feature/featureContext.tsx +++ b/apps/skolplattformen-app/context/feature/featureContext.tsx @@ -2,8 +2,9 @@ import { Features, FeatureType } from '@skolplattformen/api' import React from 'react' export const FeatureFlagsContext = React.createContext({ - LOGIN_BANK_ID_SAME_DEVICE: false, + LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID: true, FOOD_MENU: false, + CLASS_LIST: true, }) interface Props { diff --git a/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx b/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx index e223ec41..5baece05 100644 --- a/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx +++ b/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx @@ -16,7 +16,7 @@ export const SchoolPlatformProvider: React.FC = ({ children }) => { 'currentSchoolPlatform' ) - const changeSchoolPlatform = (platform: string) => { + const changeSchoolPlatform = (platform) => { setCurrentSchoolPlatform(platform) } diff --git a/apps/skolplattformen-app/data/schoolPlatforms.ts b/apps/skolplattformen-app/data/schoolPlatforms.ts index 70f66019..d0d84536 100644 --- a/apps/skolplattformen-app/data/schoolPlatforms.ts +++ b/apps/skolplattformen-app/data/schoolPlatforms.ts @@ -10,13 +10,13 @@ export const schoolPlatforms = [ { id: 'stockholm-skolplattformen', displayName: 'Stockholm stad (Skolplattformen)', - api: initSkolplattformen(fetch, CookieManager), + api: initSkolplattformen(fetch as any, CookieManager), features: featuresSkolPlattformen, }, { id: 'goteborg-hjarntorget', displayName: 'Göteborg stad (Hjärntorget)', - api: initHjarntorget(fetch, CookieManager), + api: initHjarntorget(fetch as any, CookieManager), features: featuresHjarntorget, }, ] diff --git a/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts b/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts index 4fbb2df4..754f7fde 100644 --- a/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts +++ b/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts @@ -1,5 +1,5 @@ import AsyncStorage from '@react-native-async-storage/async-storage' -import { User } from '@skolplattformen/api-skolplattformen' +import { User } from '@skolplattformen/api' import { act, renderHook } from '@testing-library/react-hooks' import usePersonalStorage from '../usePersonalStorage' diff --git a/apps/skolplattformen-app/ios/Podfile.lock b/apps/skolplattformen-app/ios/Podfile.lock index fda48c7f..fef1aa99 100644 --- a/apps/skolplattformen-app/ios/Podfile.lock +++ b/apps/skolplattformen-app/ios/Podfile.lock @@ -669,4 +669,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 85f5a2dfa1de342b427eecb6e9652410ad153247 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 diff --git a/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts b/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts index 08946f82..230e017a 100644 --- a/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts +++ b/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts @@ -1,5 +1,5 @@ import AsyncStorage from '@react-native-async-storage/async-storage' -import { User } from '@skolplattformen/api-skolplattformen' +import { User } from '@skolplattformen/api' import AppStorage from '../appStorage' beforeEach(() => { diff --git a/apps/skolplattformen-app/services/appStorage.ts b/apps/skolplattformen-app/services/appStorage.ts index bbe2a6a4..c881e11e 100644 --- a/apps/skolplattformen-app/services/appStorage.ts +++ b/apps/skolplattformen-app/services/appStorage.ts @@ -1,5 +1,5 @@ import AsyncStorage from '@react-native-async-storage/async-storage' -import { User } from '@skolplattformen/api-skolplattformen' +import { User } from '@skolplattformen/api' export default class AppStorage { static settingsStorageKeyPrefix = 'appsetting_' diff --git a/apps/skolplattformen-app/utils/peopleHelpers.ts b/apps/skolplattformen-app/utils/peopleHelpers.ts index f44d34a1..32ec3639 100644 --- a/apps/skolplattformen-app/utils/peopleHelpers.ts +++ b/apps/skolplattformen-app/utils/peopleHelpers.ts @@ -1,4 +1,4 @@ -import { Guardian } from '@skolplattformen/api-skolplattformen' +import { Guardian } from '@skolplattformen/api' export const studentName = (name?: string) => name?.replace(/\s?\(\w+\)$/, '') diff --git a/apps/skolplattformen-app/utils/search.tsx b/apps/skolplattformen-app/utils/search.tsx index 2752ef98..defa5ba6 100644 --- a/apps/skolplattformen-app/utils/search.tsx +++ b/apps/skolplattformen-app/utils/search.tsx @@ -1,4 +1,4 @@ -import { NewsItem } from '@skolplattformen/api-skolplattformen' +import { NewsItem } from '@skolplattformen/api' import { useNews } from '@skolplattformen/hooks' import { MatchData, Searcher } from 'fast-fuzzy' import React, { ReactNode, useMemo } from 'react' diff --git a/apps/skolplattformen-app/utils/testHelpers.tsx b/apps/skolplattformen-app/utils/testHelpers.tsx index c915d566..37899527 100644 --- a/apps/skolplattformen-app/utils/testHelpers.tsx +++ b/apps/skolplattformen-app/utils/testHelpers.tsx @@ -5,6 +5,7 @@ import { EvaIconsPack } from '@ui-kitten/eva-icons' import React, { ReactElement } from 'react' import { LanguageProvider } from '../context/language/languageContext' import { translations } from './translation' +import { lightTheme } from '../design/themes' export const render = ( ui: ReactElement, @@ -14,7 +15,7 @@ export const render = ( return ( <> - + { + const cookie = await this.cookieManager.getCookieString(url) + return { + cookie, + } + } + async setSessionCookie(sessionCookie: string): Promise { await this.fetch('login-cookie', hjarntorgetUrl, { headers: { @@ -490,13 +498,13 @@ export class ApiHjarntorget extends EventEmitter implements Api { if((beginLoginRedirectResponse as any).url.endsWith("startPage.do")) { // already logged in! - const emitter = new EventEmitter() + const emitter = new DummyStatusChecker() setTimeout(() => { this.isLoggedIn = true emitter.emit('OK') this.emit('login') }, 50) - return emitter; + return emitter as LoginStatusChecker; } console.log('prepping??? shibboleth') diff --git a/libs/api-hjarntorget/lib/fake/calendars.ts b/libs/api-hjarntorget/lib/fake/calendars.ts index fc7cbf7f..1657cee3 100644 --- a/libs/api-hjarntorget/lib/fake/calendars.ts +++ b/libs/api-hjarntorget/lib/fake/calendars.ts @@ -1,17 +1,17 @@ +import { Response } from '@skolplattformen/api'; /* eslint-disable no-useless-escape */ export const calendars = () => ({ "url": "https://hjarntorget.goteborg.se/pp/system/calendar/cal_events.jsp", "headers": { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36", - "cookie": "REMOVED" + "cookie": "REMOVED" }, "status": 200, "statusText": "200", "text": () => Promise.resolve("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe PING PONG Calendar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t
\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\n\t\n\n\n\n\t\t\n\n\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t

Make a selection

\n\n\t\t\t\t

Here you get an overview of your calendars. Choose from which calendars you wish to see events. Choose if you want to search for a word. Click Show to see the result.

\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Show calendar events for the checked calendars
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\n\n
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
Group the events per calendar\n\t\t\t\t\t\t\t\t\t
Don't group\n\t\t\t\t\t\t\t\t\t
From - to:\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
Search for
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t
\n\t\t\t
\n\n\t\t\t

Calendar events

\n\n\t\t\t\t\n\t\t\t\t

\n\t\t\t\t\t No events was found \n\t\t\t\t\t\n\t\t\t\t

\n\t\t\t\t\n\n\t\t\t
\n\t\t
\n\t
\n\n\n\n\n") }) as any as Response -export const calendar_14241345 = () => { - return { +export const calendar_14241345 = () => ({ "url": "https://hjarntorget.goteborg.se/pp/system/calendar/cal_events.jsp?order_by=start_date&show_cal_ids=14241345&mode=separate&filter_start_date=2021-11-09&filter_end_date=2021-12-09&search_for=", "headers": { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36", @@ -19,6 +19,8 @@ export const calendar_14241345 = () => { }, "status": 200, "statusText": "200", + "json": null, + "ok": true, "text": () => { const now = new Date() const dateYearMonth = `${now.getFullYear()}-${now.getMonth() + 1}` @@ -27,7 +29,6 @@ export const calendar_14241345 = () => { const result = ` \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe PING PONG Calendar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t
\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\n\t\n\n\n\n\t\t\n\n\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t

Make a selection

\n\n\t\t\t\t

Here you get an overview of your calendars. Choose from which calendars you wish to see events. Choose if you want to search for a word. Click Show to see the result.

\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Show calendar events for the checked calendars
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\n\n
removed checkbox
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
Group the events per calendar\n\t\t\t\t\t\t\t\t\t
Don't group\n\t\t\t\t\t\t\t\t\t
From - to:\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
Search for
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t
\n\t\t\t
\n\n\t\t\t

Calendar events

\n\n\t\t\t\t\n\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\t\t\tTitle\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tDates\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tTimes\n\n\t\t\t\t\t\t\t
138JÄTS Provschema år 8
\"\"
\nProv/komplettering franska ${dateYearMonth}-0113:00-14:00
\"\"
\nTyska läxförhör${dateYearMonth}-0113:00-13:30\"The
\"\"
\nLäxa i franska${dateYearMonth}-0309:40-10:20\"The
\"\"
\nSpanskaprov Repasamos 1- 4${dateYearMonth}-0310:00-11:00
\"\"
\nTyska läxförhör${dateYearMonth}-0813:00-13:30\"The
\"\"
\nLäxa i franska${dateYearMonth}-1009:40-10:20\"The
\"\"
\nDeadline engelska - Postcard from Great Britain${dateYearMonth}-1115:00-16:00\"The
\"\"
\nLäxa engelska${dateYearMonth}-1408:00-09:00\"The
\"\"
\nTyska läxförhör${dateYearMonth}-1513:00-13:30\"The
\"\"
\nLäxa i franska${dateYearMonth}-1709:40-10:20\"The
\"\"
\nLäxa engelska${dateYearMonth}-1908:00-09:00\"The
\"\"
\nProv franska åk 7${dateYearMonth}-2012:00-13:00
\"\"
\nLäxa i franska${dateYearMonth}-2209:40-10:20\"The
\"\"
\nLäxa engelska${nextMonth}-0108:00-09:00\"The
\n\n\t\t\t\t\n\n\t\t\t
\n\t\t
\n\t
\n\n\n\n\n ` - return Promise.resolve(result as any as Response) + return Promise.resolve(result) } - } -} \ No newline at end of file + }) as any as Response diff --git a/libs/api-hjarntorget/lib/fake/fakeFetcher.ts b/libs/api-hjarntorget/lib/fake/fakeFetcher.ts index 87595ba3..d9a9e6f5 100644 --- a/libs/api-hjarntorget/lib/fake/fakeFetcher.ts +++ b/libs/api-hjarntorget/lib/fake/fakeFetcher.ts @@ -28,10 +28,9 @@ const fetchMappings: { [name:string]: () => Response} = { 'event-role-members-24-821': eventRoleMembers24, 'calendars': calendars, 'calendar-14241345': calendar_14241345, - } export const fakeFetcher: Fetcher = (name: string, url: string, init?: any): Promise => { const responder = fetchMappings[name] ?? (() => {throw new Error("Request not faked for name: " + name)}) return Promise.resolve(responder()); -} +} diff --git a/libs/api-hjarntorget/lib/loginStatus.ts b/libs/api-hjarntorget/lib/loginStatus.ts index aeeeda68..c96665f2 100644 --- a/libs/api-hjarntorget/lib/loginStatus.ts +++ b/libs/api-hjarntorget/lib/loginStatus.ts @@ -10,7 +10,7 @@ import { pollStatusUrl, } from './routes' -export class HjarntorgetChecker extends EventEmitter { +export class HjarntorgetChecker extends EventEmitter implements LoginStatusChecker { private fetcher: Fetcher private basePollingUrl: string @@ -120,3 +120,10 @@ export const checkStatus = ( fetch: Fetcher, basePollingUrl: string ): LoginStatusChecker => new HjarntorgetChecker(fetch, basePollingUrl) + +export class DummyStatusChecker extends EventEmitter implements LoginStatusChecker { + token = "" + async cancel(): Promise { + // do nothing + } +} diff --git a/libs/api-skolplattformen/README.md b/libs/api-skolplattformen/README.md index 85053458..37c23583 100644 --- a/libs/api-skolplattformen/README.md +++ b/libs/api-skolplattformen/README.md @@ -16,7 +16,7 @@ the concrete implementation of fetch and cookie handler must be injected. #### react-native ```javascript -import init from '@skolplattformen/api-skolplattformen' +import init from '@skolplattformen/api' import CookieManager from '@react-native-cookies/cookies' const api = init(fetch, () => CookieManager.clearAll()) @@ -25,7 +25,7 @@ const api = init(fetch, () => CookieManager.clearAll()) #### node ```javascript -import init from '@skolplattformen/api-skolplattformen' +import init from '@skolplattformen/api' import nodeFetch from 'node-fetch' import fetchCookie from 'fetch-cookie/node-fetch' import { CookieJar } from 'tough-cookie' diff --git a/libs/api-skolplattformen/lib/api.ts b/libs/api-skolplattformen/lib/api.ts index 66d94ced..4774804f 100644 --- a/libs/api-skolplattformen/lib/api.ts +++ b/libs/api-skolplattformen/lib/api.ts @@ -28,7 +28,7 @@ import { decode } from 'he' import { DateTime } from 'luxon' import * as html from 'node-html-parser' import * as fake from './fakeData' -import { checkStatus } from './loginStatusChecker' +import { checkStatus, DummyStatusChecker } from './loginStatusChecker' import * as parse from './parse/index' import * as routes from './routes' @@ -94,6 +94,16 @@ export class ApiSkolplattformen extends EventEmitter implements Api { } } + public async getSessionHeaders(url: string): Promise<{ [index: string]: string }> { + const init = this.getRequestInit() + const cookie = await this.cookieManager.getCookieString(url) + return { + ...init.headers, + cookie, + } + } + + public async getSession( url: string, options?: RequestInit @@ -203,8 +213,7 @@ export class ApiSkolplattformen extends EventEmitter implements Api { this.emit('login') }, 50) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const emitter: any = new EventEmitter() + const emitter = new DummyStatusChecker() emitter.token = 'fake' return emitter } diff --git a/libs/api-skolplattformen/lib/loginStatusChecker.ts b/libs/api-skolplattformen/lib/loginStatusChecker.ts index a2fab185..0cdb4593 100644 --- a/libs/api-skolplattformen/lib/loginStatusChecker.ts +++ b/libs/api-skolplattformen/lib/loginStatusChecker.ts @@ -2,7 +2,7 @@ import { EventEmitter } from 'events'; import { loginStatus } from './routes'; import { AuthTicket, Fetcher, LoginStatusChecker } from '@skolplattformen/api'; -export class Checker extends EventEmitter { +export class Checker extends EventEmitter implements LoginStatusChecker { public token: string; private fetcher: Fetcher; @@ -41,3 +41,10 @@ export const checkStatus = ( fetch: Fetcher, ticket: AuthTicket ): LoginStatusChecker => new Checker(fetch, ticket) + +export class DummyStatusChecker extends EventEmitter implements LoginStatusChecker { + token = "" + async cancel(): Promise { + // do nothing + } +} diff --git a/libs/api/lib/api.ts b/libs/api/lib/api.ts index 890176b4..4ba711a1 100644 --- a/libs/api/lib/api.ts +++ b/libs/api/lib/api.ts @@ -21,6 +21,7 @@ export interface Api extends EventEmitter { getPersonalNumber(): string | undefined login(personalNumber?: string): Promise setSessionCookie(sessionCookie: string): Promise + getSessionHeaders(url: string): Promise<{ [index: string]: string }> getUser(): Promise getChildren(): Promise getCalendar(child: EtjanstChild): Promise diff --git a/libs/hooks/README.md b/libs/hooks/README.md index 16f570fc..2ec4bd52 100644 --- a/libs/hooks/README.md +++ b/libs/hooks/README.md @@ -18,7 +18,7 @@ In order to use api hooks, you must wrap your app in an ApiProvider ```javascript import React from 'react' import { ApiProvider } from '@skolplattformen/hooks' -import init from '@skolplattformen/api-skolplattformen' +import init from '@skolplattformen/api-skolplattformet' import { CookieManager } from '@react-native-cookies/cookies' import AsyncStorage from '@react-native-async-storage/async-storage' import { RootComponent } from './components/root' diff --git a/libs/hooks/src/hooks.ts b/libs/hooks/src/hooks.ts index 594a0cbe..d3bbef7a 100644 --- a/libs/hooks/src/hooks.ts +++ b/libs/hooks/src/hooks.ts @@ -107,7 +107,7 @@ const hook = ( if (newState.error) { const description = `Error getting ${entityName} from API` - reporter.error(newState.error, description) + reporter.error && reporter.error(newState.error, description) } } }