@wilm-ai/wilma-client 1.7.0 → 1.8.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/dist/client.d.ts CHANGED
@@ -94,6 +94,11 @@ export declare class WilmaClient {
94
94
  };
95
95
  news: {
96
96
  list: () => Promise<NewsItem[]>;
97
+ /**
98
+ * The bulletins, or null when this Wilma doesn't show them to this account: it answers /news with 403 (Helsinki's
99
+ * does, for a guardian) or 404 while the session is alive. Its other pages read as usual.
100
+ */
101
+ listIfShown: () => Promise<NewsItem[] | null>;
97
102
  get: (newsId: number) => Promise<NewsItem>;
98
103
  fetchResource: (newsId: number, resourceId: string, options?: {
99
104
  item?: NewsItem;
package/dist/client.js CHANGED
@@ -241,6 +241,20 @@ export class WilmaClient {
241
241
  }
242
242
  return parseNewsListHtml(text);
243
243
  },
244
+ /**
245
+ * The bulletins, or null when this Wilma doesn't show them to this account: it answers /news with 403 (Helsinki's
246
+ * does, for a guardian) or 404 while the session is alive. Its other pages read as usual.
247
+ */
248
+ listIfShown: async () => {
249
+ try {
250
+ return await this.news.list();
251
+ }
252
+ catch (err) {
253
+ if (err instanceof APIError && (err.status === 403 || err.status === 404))
254
+ return null;
255
+ throw err;
256
+ }
257
+ },
244
258
  get: async (newsId) => {
245
259
  const resp = await this.session.get(`/news/${newsId}`);
246
260
  const contentType = resp.headers.get("content-type")?.toLowerCase() ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wilm-ai/wilma-client",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Unofficial client for Wilma, the Finnish school information system: login (with two-step verification), schedule, homework, exams, messages and news.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "cheerio": "^1.0.0-rc.12",
48
48
  "tough-cookie": "^4.1.4",
49
- "undici": "^6.27.0"
49
+ "undici": "^6.29.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "typescript": "^5.6.3",