volunteer-contributions-fetch 3.1.1 → 3.1.2

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.
@@ -13,15 +13,19 @@ jobs:
13
13
  id-token: write
14
14
  issues: write
15
15
  steps:
16
- - uses: actions/checkout@v4
17
- - uses: actions/setup-node@v4
16
+ - name: Checkout
17
+ uses: actions/checkout@v5
18
+ - name: Setup Node
19
+ uses: actions/setup-node@v6
18
20
  with:
19
- node-version: 20
20
- - run: npm ci
21
- - run: npm run eslint
22
- - run: npm test
21
+ node-version: 24
22
+ - name: Install dependencies
23
+ run: npm ci
24
+ - name: Lint
25
+ run: npm run eslint
26
+ - name: Test
27
+ run: npm test
23
28
  - name: Release
24
29
  env:
25
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26
30
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27
31
  run: npx semantic-release
@@ -6,11 +6,12 @@ jobs:
6
6
  test:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v4
10
- - name: Use Node.js 20
11
- uses: actions/setup-node@v4
9
+ - name: Checkout
10
+ uses: actions/checkout@v5
11
+ - name: Setup Node
12
+ uses: actions/setup-node@v6
12
13
  with:
13
- node-version: 20
14
+ node-version: 24
14
15
  - name: Install Dependencies
15
16
  run: npm ci
16
17
  - name: Linting
package/.husky/pre-commit CHANGED
@@ -1 +1,2 @@
1
1
  npm test
2
+ npm run eslint
package/README.md CHANGED
@@ -245,7 +245,6 @@ npm ci
245
245
  ### Tests
246
246
 
247
247
  ```bash
248
- npm run eslint
249
248
  npm test
250
249
  ```
251
250
 
@@ -259,6 +258,14 @@ cp .env.example .env
259
258
 
260
259
  You then can use `npm run example` which uses `fetchAll` if you would like to test changes within this project. The configuration for this can be adjusted in `example/index.js`. A full sample config can be found in the configuration section above. Please make sure to not include testing config file changes when committing! The file is not ignored to make it so that new checkouts do not have to copy around a file first.
261
260
 
261
+ ### Linting
262
+
263
+ ```bash
264
+ npm run eslint
265
+ ```
266
+
267
+ Note that due to the AirBnB config we are still using ESLint 8.
268
+
262
269
  ### Deployments
263
270
 
264
271
  Please use [Angular Commit Message Conventions](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) when contributing to this project, as depending on the commit message the GitHub Action will directly publish a new version of the package.
package/lib/bugzilla.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import Debug from 'debug';
2
+ import { z } from 'zod';
2
3
 
3
4
  import { getPadded } from './utils.js';
4
5
 
@@ -13,25 +14,18 @@ const TYPE_COMMENTED = 'Commented on a Bug Report';
13
14
  const RESULTS_PER_PAGE = 500;
14
15
  const FETCH_TIMEOUT = 120000;
15
16
 
16
- export function validate(config) {
17
- debug('Validating Bugzilla config');
18
-
19
- if (!config) {
20
- return;
21
- }
22
-
23
- if (config && config.enabled && !config.baseUrl) {
24
- throw new Error('Bugzilla: baseUrl is required');
25
- }
26
-
27
- if (config && config.enabled && !config.username) {
28
- throw new Error('Bugzilla: username is required');
29
- }
30
-
31
- if (config && config.enabled && !config.stopDate) {
32
- throw new Error('Bugzilla: stopDate is required');
33
- }
34
- }
17
+ export const bugzillaSchema = z.object({
18
+ enabled: z.boolean(),
19
+ baseUrl: z.string().min(1),
20
+ username: z.string().min(1),
21
+ stopDate: z.string(),
22
+ types: z
23
+ .object({
24
+ createdType: z.string().optional(),
25
+ commentedType: z.string().optional(),
26
+ })
27
+ .optional(),
28
+ });
35
29
 
36
30
  export async function gather({ bugzilla }, existingContributions = []) {
37
31
  if (!bugzilla || (bugzilla && !bugzilla.enabled)) {
@@ -1,6 +1,6 @@
1
1
  import { afterEach, beforeEach, expect, test, vi } from 'vitest';
2
2
 
3
- import { gather, validate } from './bugzilla.js';
3
+ import { gather, bugzillaSchema } from './bugzilla.js';
4
4
 
5
5
  const config = {
6
6
  bugzilla: {
@@ -72,43 +72,29 @@ afterEach(() => {
72
72
  vi.restoreAllMocks();
73
73
  });
74
74
 
75
- test('should validate config - undefined', () => {
76
- expect(() => validate(undefined)).not.toThrow();
77
- });
78
-
79
- test('should validate config - missing completely', () => {
80
- const emptyConfig = {};
81
- expect(() => validate(emptyConfig)).not.toThrow();
82
- });
83
-
84
- test('should validate config - missing baseUrl', () => {
85
- const failConfig = {
75
+ test('Bugzilla schema - valid config', () => {
76
+ const validConfig = {
86
77
  enabled: true,
87
- username: 'A',
88
- stopDate: new Date(),
89
- };
90
-
91
- expect(() => validate(failConfig)).toThrow();
92
- });
93
-
94
- test('should validate config - missing username', () => {
95
- const failConfig = {
96
- enabled: true,
97
- baseUrl: 'A',
98
- stopDate: new Date(),
78
+ baseUrl: 'https://bugzilla.test',
79
+ username: 'testuser',
80
+ stopDate: '2023-01-01',
81
+ types: {
82
+ createdType: 'Created a Test Bug',
83
+ commentedType: 'Commented on a Test Bug',
84
+ },
99
85
  };
100
-
101
- expect(() => validate(failConfig)).toThrow();
86
+ const result = bugzillaSchema.parse(validConfig);
87
+ expect(result).toBeDefined();
102
88
  });
103
89
 
104
- test('should validate config - missing stopDate', () => {
105
- const failConfig = {
90
+ test('Bugzilla schema - invalid config', () => {
91
+ const invalidConfig = {
106
92
  enabled: true,
107
- baseUrl: 'A',
108
- username: 'user',
93
+ baseUrl: 'https://example.com',
94
+ username: '',
95
+ stopDate: '2024-01-01',
109
96
  };
110
-
111
- expect(() => validate(failConfig)).toThrow();
97
+ expect(() => bugzillaSchema.parse(invalidConfig)).toThrow();
112
98
  });
113
99
 
114
100
  test('should fetch', async () => {
@@ -1,5 +1,6 @@
1
1
  import Debug from 'debug';
2
2
  import { JSDOM } from 'jsdom';
3
+ import { z } from 'zod';
3
4
 
4
5
  const debug = Debug('contributions:community-portal');
5
6
 
@@ -9,21 +10,13 @@ export const CAMPAIGNS_CATEGORY = 'community-portal-campaigns';
9
10
  const TYPE_PARTICIPATION = 'Participated in an event';
10
11
  const TYPE_CAMPAIGN = 'Participated in a campaign';
11
12
 
12
- export function validate(config) {
13
- debug('Validating Community Portal config');
14
-
15
- if (!config) {
16
- return;
17
- }
18
-
19
- if (config && config.enabled && !config.baseUrl) {
20
- throw new Error('Community Portal: baseUrl is required');
21
- }
22
-
23
- if (config && config.enabled && !config.username) {
24
- throw new Error('Community Portal: username is required');
25
- }
26
- }
13
+ export const communityPortalSchema = z.object({
14
+ enabled: z.boolean(),
15
+ baseUrl: z.string().min(1),
16
+ username: z.string().min(1),
17
+ participationType: z.string().optional(),
18
+ campaignType: z.string().optional(),
19
+ });
27
20
 
28
21
  export async function gather({ communityPortal }) {
29
22
  if (!communityPortal || (communityPortal && !communityPortal.enabled)) {
@@ -2,7 +2,7 @@ import { JSDOM } from 'jsdom';
2
2
  import { afterEach, beforeEach, expect, test, vi } from 'vitest';
3
3
 
4
4
  import * as fixtures from '../fixtures/community-portal.js';
5
- import { gather, validate } from './community-portal.js';
5
+ import { gather, communityPortalSchema } from './community-portal.js';
6
6
 
7
7
  const config = {
8
8
  communityPortal: {
@@ -20,31 +20,25 @@ afterEach(() => {
20
20
  vi.restoreAllMocks();
21
21
  });
22
22
 
23
- test('should validate config - undefined', () => {
24
- expect(() => validate(undefined)).not.toThrow();
25
- });
26
-
27
- test('should validate config - missing completely', () => {
28
- const emptyConfig = {};
29
- expect(() => validate(emptyConfig)).not.toThrow();
30
- });
31
-
32
- test('should validate config - missing baseUrl', () => {
33
- const failConfig = {
23
+ test('Community Portal schema - valid config', () => {
24
+ const validConfig = {
34
25
  enabled: true,
35
- username: 'A',
26
+ baseUrl: 'https://community.mozilla.org',
27
+ username: 'testuser',
28
+ participationType: 'Test Event',
29
+ campaignType: 'Test Campaign',
36
30
  };
37
-
38
- expect(() => validate(failConfig)).toThrow();
31
+ const result = communityPortalSchema.parse(validConfig);
32
+ expect(result).toBeDefined();
39
33
  });
40
34
 
41
- test('should validate config - missing username', () => {
42
- const failConfig = {
35
+ test('Community Portal schema - invalid config', () => {
36
+ const invalidConfig = {
43
37
  enabled: true,
44
- baseUrl: 'A',
38
+ baseUrl: '',
39
+ username: 'testuser',
45
40
  };
46
-
47
- expect(() => validate(failConfig)).toThrow();
41
+ expect(() => communityPortalSchema.parse(invalidConfig));
48
42
  });
49
43
 
50
44
  test('should fetch', async () => {
package/lib/discourse.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import Debug from 'debug';
2
+ import { z } from 'zod';
3
+
2
4
  import { ensureUniqueContributions } from './contributions.js';
3
5
 
4
6
  const debug = Debug('contributions:discourse');
@@ -10,21 +12,14 @@ export const POSTS_CATEGORY = 'discourse-posts';
10
12
  const TYPE_TOPIC = 'Created Discourse Topic';
11
13
  const TYPE_POST = 'Posted on Discourse Topic';
12
14
 
13
- export function validate(config) {
14
- debug('Validating Discourse config');
15
-
16
- if (!config) {
17
- return;
18
- }
19
-
20
- if (config && config.enabled && !config.baseUrl) {
21
- throw new Error('Discourse: baseUrl is required');
22
- }
23
-
24
- if (config && config.enabled && !config.username) {
25
- throw new Error('Discourse: username is required');
26
- }
27
- }
15
+ export const discourseSchema = z.object({
16
+ enabled: z.boolean(),
17
+ baseUrl: z.string().min(1),
18
+ username: z.string().min(1),
19
+ topicType: z.string().optional(),
20
+ postType: z.string().optional(),
21
+ keepDeletedPost: z.boolean().default(false),
22
+ });
28
23
 
29
24
  export async function gather({ discourse }, existingContributions = []) {
30
25
  if (!discourse || (discourse && !discourse.enabled)) {
@@ -1,6 +1,6 @@
1
1
  import { afterEach, beforeEach, expect, test, vi } from 'vitest';
2
2
 
3
- import { gather, validate } from './discourse.js';
3
+ import { gather, discourseSchema } from './discourse.js';
4
4
 
5
5
  const TOPICS = {
6
6
  topic_list: {
@@ -79,27 +79,23 @@ afterEach(() => {
79
79
  vi.resetAllMocks();
80
80
  });
81
81
 
82
- test('should validate config - missing completely', () => {
83
- const emptyConfig = {};
84
- expect(() => validate(emptyConfig)).not.toThrow();
85
- });
86
-
87
- test('should validate config - missing baseUrl', () => {
88
- const failConfig = {
82
+ test('Discourse schema - valid config', () => {
83
+ const validConfig = {
89
84
  enabled: true,
90
- username: 'A',
85
+ baseUrl: 'https://discourse.test',
86
+ username: 'testuser',
91
87
  };
92
-
93
- expect(() => validate(failConfig)).toThrow();
88
+ const result = discourseSchema.parse(validConfig);
89
+ expect(result).toBeDefined();
94
90
  });
95
91
 
96
- test('should validate config - missing username', () => {
97
- const failConfig = {
92
+ test('Discourse schema - invalid config', () => {
93
+ const invalidConfig = {
98
94
  enabled: true,
99
- baseUrl: 'A',
95
+ baseUrl: '',
96
+ username: 'testuser',
100
97
  };
101
-
102
- expect(() => validate(failConfig)).toThrow();
98
+ expect(() => discourseSchema.parse(invalidConfig)).toThrow();
103
99
  });
104
100
 
105
101
  test('should fetch', async () => {
package/lib/github.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import Debug from 'debug';
2
+ import { z } from 'zod';
2
3
  import {
3
4
  listComments,
4
5
  listReviews,
@@ -30,25 +31,30 @@ const TYPE_CHANGES_REQUESTED_PR = 'Requested changes on a Pull Request';
30
31
  const TYPE_REVIEWED_PR = 'Reviewed a Pull Request';
31
32
  const TYPE_COMMENTED = 'Commented on an Issue';
32
33
 
33
- export function validate(config) {
34
- debug('Validating GitHub config');
35
-
36
- if (!config) {
37
- return;
38
- }
39
-
40
- if (config && config.enabled && !config.username) {
41
- throw new Error('GitHub: username is required');
42
- }
43
-
44
- if (config && config.enabled && !config.stopDate) {
45
- throw new Error('GitHub: stopDate is required');
46
- }
47
-
48
- if (config && config.enabled && !config.filter) {
49
- throw new Error('GitHub: filter is required');
50
- }
51
- }
34
+ export const githubSchema = z.object({
35
+ enabled: z.boolean(),
36
+ allowPrivate: z.boolean().default(false),
37
+ commentsEnabled: z.boolean().default(true),
38
+ commitsEnabled: z.boolean().default(true),
39
+ issuesEnabled: z.boolean().default(true),
40
+ reviewsEnabled: z.boolean().default(true),
41
+ username: z.string().min(1),
42
+ stopDate: z.string(),
43
+ filter: z.string(),
44
+ types: z
45
+ .object({
46
+ commit: z.string().optional(),
47
+ privateCommit: z.string().optional(),
48
+ createdPR: z.string().optional(),
49
+ createdIssue: z.string().optional(),
50
+ commentedPR: z.string().optional(),
51
+ approvedPR: z.string().optional(),
52
+ changesRequestedPR: z.string().optional(),
53
+ reviewedPR: z.string().optional(),
54
+ })
55
+ .optional(),
56
+ delayMsPerRequest: z.number().default(2000),
57
+ });
52
58
 
53
59
  export async function gather({ github }, existingContributions = []) {
54
60
  if (!github || (github && !github.enabled)) {
@@ -1,13 +1,13 @@
1
1
  import { afterEach, beforeEach, expect, test, vi } from 'vitest';
2
2
 
3
3
  import * as fetcher from './github-fetcher.js';
4
- import { gather, validate } from './github.js';
4
+ import { gather, githubSchema } from './github.js';
5
5
 
6
6
  const config = {
7
7
  github: {
8
8
  enabled: true,
9
9
  username: 'user',
10
- stopDate: new Date('2022-01-01'),
10
+ stopDate: '2022-01-01',
11
11
  filter: '',
12
12
  delayMsPerRequest: 0,
13
13
  },
@@ -36,9 +36,14 @@ afterEach(() => {
36
36
  vi.restoreAllMocks();
37
37
  });
38
38
 
39
+ test('should validate valid config', () => {
40
+ const result = githubSchema.parse(config.github);
41
+ expect(result).toBeDefined();
42
+ });
43
+
39
44
  test('should validate config - missing completely', () => {
40
45
  const emptyConfig = {};
41
- expect(() => validate(emptyConfig)).not.toThrow();
46
+ expect(() => githubSchema.parse(emptyConfig)).toThrow();
42
47
  });
43
48
 
44
49
  test('should validate config - missing filter', () => {
@@ -48,7 +53,7 @@ test('should validate config - missing filter', () => {
48
53
  stopDate: new Date('2022-01-01'),
49
54
  };
50
55
 
51
- expect(() => validate(failConfig)).toThrow();
56
+ expect(() => githubSchema.parse(failConfig)).toThrow();
52
57
  });
53
58
 
54
59
  test('should validate config - missing username', () => {
@@ -58,7 +63,7 @@ test('should validate config - missing username', () => {
58
63
  filter: '',
59
64
  };
60
65
 
61
- expect(() => validate(failConfig)).toThrow();
66
+ expect(() => githubSchema.parse(failConfig)).toThrow();
62
67
  });
63
68
 
64
69
  test('should validate config - missing stopDate', () => {
@@ -68,7 +73,7 @@ test('should validate config - missing stopDate', () => {
68
73
  filter: '',
69
74
  };
70
75
 
71
- expect(() => validate(failConfig)).toThrow();
76
+ expect(() => githubSchema.parse(failConfig)).toThrow();
72
77
  });
73
78
 
74
79
  test('should not fetch if disabled - by enable property', async () => {
package/lib/osm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import Debug from 'debug';
2
2
  import { parseString } from 'xml2js';
3
3
  import { promisify } from 'util';
4
+ import { z } from 'zod';
4
5
 
5
6
  const debug = Debug('contributions:openstreetmaps');
6
7
  const parseStringAsync = promisify(parseString);
@@ -11,21 +12,11 @@ const TYPE_EDIT = 'OpenStreetMaps Edit';
11
12
 
12
13
  const MAX_EDITS_PER_PAGE = 100;
13
14
 
14
- export function validate(config) {
15
- debug('Validating OSM config');
16
-
17
- if (!config) {
18
- return;
19
- }
20
-
21
- if (config && config.enabled && !config.displayName) {
22
- throw new Error('OSM: displayName is required');
23
- }
24
-
25
- if (config && config.enabled && !config.stopDate) {
26
- throw new Error('OSM: stopDate is required');
27
- }
28
- }
15
+ export const osmSchema = z.object({
16
+ enabled: z.boolean(),
17
+ displayName: z.string().min(1),
18
+ stopDate: z.string(),
19
+ });
29
20
 
30
21
  export async function gather({ osm }) {
31
22
  if (!osm || (osm && !osm.enabled)) {
package/lib/osm.test.js CHANGED
@@ -7,7 +7,7 @@ const config = {
7
7
  osm: {
8
8
  enabled: true,
9
9
  displayName: 'user',
10
- stopDate: new Date('2021-11-01'),
10
+ stopDate: '2021-11-01',
11
11
  },
12
12
  };
13
13
 
@@ -23,9 +23,14 @@ afterEach(() => {
23
23
  vi.restoreAllMocks();
24
24
  });
25
25
 
26
+ test('should validate valid config', () => {
27
+ const result = osm.osmSchema.parse(config.osm);
28
+ expect(result).toBeDefined();
29
+ });
30
+
26
31
  test('should validate config - missing completely', () => {
27
32
  const emptyConfig = {};
28
- expect(() => osm.validate(emptyConfig)).not.toThrow();
33
+ expect(() => osm.osmSchema.parse(emptyConfig)).toThrow();
29
34
  });
30
35
 
31
36
  test('should validate config - missing displayName', () => {
@@ -34,7 +39,7 @@ test('should validate config - missing displayName', () => {
34
39
  stopDate: new Date(),
35
40
  };
36
41
 
37
- expect(() => osm.validate(failConfig)).toThrow();
42
+ expect(() => osm.osmSchema.parse(failConfig)).toThrow();
38
43
  });
39
44
 
40
45
  test('should validate config - missing stopDate', () => {
@@ -43,7 +48,7 @@ test('should validate config - missing stopDate', () => {
43
48
  displayName: 'user',
44
49
  };
45
50
 
46
- expect(() => osm.validate(failConfig)).toThrow();
51
+ expect(() => osm.osmSchema.parse(failConfig)).toThrow();
47
52
  });
48
53
 
49
54
  test('should fetch', async () => {
package/lib/validator.js CHANGED
@@ -1,21 +1,26 @@
1
1
  import Debug from 'debug';
2
+ import { z } from 'zod';
2
3
 
3
- import { validate as validateCommunityPortal } from './community-portal.js';
4
- import { validate as validateDiscourse } from './discourse.js';
5
- import { validate as validateGithub } from './github.js';
6
- import { validate as validateWiki } from './wiki.js';
4
+ import { communityPortalSchema } from './community-portal.js';
5
+ import { discourseSchema } from './discourse.js';
6
+ import { githubSchema } from './github.js';
7
+ import { mediaWikiSchema } from './wiki.js';
8
+ import { bugzillaSchema } from './bugzilla.js';
9
+ import { osmSchema } from './osm.js';
7
10
 
8
11
  const debug = Debug('contributions:validator');
9
12
 
13
+ export const configSchema = z.object({
14
+ outputFile: z.string().optional(),
15
+ communityPortal: communityPortalSchema.optional(),
16
+ discourse: discourseSchema.optional(),
17
+ mediaWiki: mediaWikiSchema.optional(),
18
+ github: githubSchema.optional(),
19
+ bugzilla: bugzillaSchema.optional(),
20
+ osm: osmSchema.optional(),
21
+ });
22
+
10
23
  export function validateConfig(config) {
11
24
  debug('Validating config..');
12
-
13
- if (!config) {
14
- throw new Error('No config passed!');
15
- }
16
-
17
- validateCommunityPortal(config.communityPortal);
18
- validateDiscourse(config.discourse);
19
- validateWiki(config.mediaWiki);
20
- validateGithub(config.github);
25
+ configSchema.parse(config);
21
26
  }
@@ -1,9 +1,4 @@
1
- import { afterEach, beforeEach, expect, test, vi } from 'vitest';
2
-
3
- import * as communityPortal from './community-portal.js';
4
- import * as discourse from './discourse.js';
5
- import * as github from './github.js';
6
- import * as wiki from './wiki.js';
1
+ import { expect, test } from 'vitest';
7
2
 
8
3
  import { validateConfig } from './validator.js';
9
4
 
@@ -11,17 +6,6 @@ const config = {
11
6
  outputFile: 'file',
12
7
  };
13
8
 
14
- beforeEach(() => {
15
- vi.spyOn(communityPortal, 'validate');
16
- vi.spyOn(discourse, 'validate');
17
- vi.spyOn(github, 'validate');
18
- vi.spyOn(wiki, 'validate');
19
- });
20
-
21
- afterEach(() => {
22
- vi.resetAllMocks();
23
- });
24
-
25
9
  test('should validate config - all ok', () => {
26
10
  expect(() => validateConfig(config)).not.toThrow();
27
11
  });
@@ -31,29 +15,36 @@ test('should throw when missing config', () => {
31
15
  });
32
16
 
33
17
  test('should throw when community portal validation fails', () => {
34
- communityPortal.validate.mockImplementation(() => {
35
- throw new Error('oh no');
36
- });
37
- expect(() => validateConfig(config)).toThrow();
18
+ const failConfig = {
19
+ communityPortal: {},
20
+ };
21
+ expect(() => validateConfig(failConfig)).toThrow();
38
22
  });
39
23
 
40
24
  test('should throw when discourse validation fails', () => {
41
- discourse.validate.mockImplementation(() => {
42
- throw new Error('oh no');
43
- });
44
- expect(() => validateConfig(config)).toThrow();
25
+ const failConfig = {
26
+ discourse: {},
27
+ };
28
+ expect(() => validateConfig(failConfig)).toThrow();
45
29
  });
46
30
 
47
31
  test('should throw when github validation fails', () => {
48
- github.validate.mockImplementation(() => {
49
- throw new Error('oh no');
50
- });
51
- expect(() => validateConfig(config)).toThrow();
32
+ const failConfig = {
33
+ github: {},
34
+ };
35
+ expect(() => validateConfig(failConfig)).toThrow();
36
+ });
37
+
38
+ test('should throw when osm validation fails', () => {
39
+ const failConfig = {
40
+ osm: {},
41
+ };
42
+ expect(() => validateConfig(failConfig)).toThrow();
52
43
  });
53
44
 
54
45
  test('should throw when wiki validation fails', () => {
55
- wiki.validate.mockImplementation(() => {
56
- throw new Error('oh no');
57
- });
58
- expect(() => validateConfig(config)).toThrow();
46
+ const failConfig = {
47
+ mediaWiki: {},
48
+ };
49
+ expect(() => validateConfig(failConfig)).toThrow();
59
50
  });
package/lib/wiki.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import Debug from 'debug';
2
2
  import { parseString } from 'xml2js';
3
3
  import { promisify } from 'util';
4
+ import { z } from 'zod';
4
5
 
5
6
  const debug = Debug('contributions:wiki');
6
7
  const parseStringAsync = promisify(parseString);
@@ -9,6 +10,14 @@ export const WIKI_CATEGORY = 'wiki';
9
10
 
10
11
  const TYPE_EDIT = 'Wiki Edit';
11
12
 
13
+ export const mediaWikiSchema = z.object({
14
+ enabled: z.boolean(),
15
+ baseUrl: z.string().min(1),
16
+ username: z.string().min(1),
17
+ editType: z.string(),
18
+ stopDate: z.string(),
19
+ });
20
+
12
21
  export function validate(config) {
13
22
  debug('Validating Wiki config');
14
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volunteer-contributions-fetch",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "Library to fetch volunteer contributions from several sources such as GitHub",
5
5
  "author": "Michael Kohler",
6
6
  "license": "MIT",
@@ -11,23 +11,24 @@
11
11
  "main": "index.js",
12
12
  "type": "module",
13
13
  "dependencies": {
14
- "@octokit/rest": "^21.1.0",
15
- "debug": "^4.3.4",
16
- "jsdom": "^26.0.0",
17
- "xml2js": "^0.6.2"
14
+ "@octokit/rest": "^22.0.0",
15
+ "debug": "^4.4.3",
16
+ "jsdom": "^27.0.0",
17
+ "xml2js": "^0.6.2",
18
+ "zod": "^4.1.12"
18
19
  },
19
20
  "devDependencies": {
20
- "@commitlint/cli": "^19.6.1",
21
- "@commitlint/config-angular": "^19.7.0",
22
- "@vitest/coverage-v8": "^2.1.8",
21
+ "@commitlint/cli": "^20.1.0",
22
+ "@commitlint/config-angular": "^20.0.0",
23
+ "@vitest/coverage-v8": "^3.2.4",
23
24
  "eslint": "^8.47.0",
24
25
  "eslint-config-airbnb-base": "^15.0.0",
25
26
  "eslint-config-prettier": "^9.0.0",
26
- "eslint-plugin-prettier": "^5.2.2",
27
+ "eslint-plugin-prettier": "^5.5.4",
27
28
  "husky": "^9.1.7",
28
- "prettier": "^3.4.2",
29
- "semantic-release": "^24.2.1",
30
- "vitest": "^2.1.8"
29
+ "prettier": "^3.6.2",
30
+ "semantic-release": "^25.0.1-beta.1",
31
+ "vitest": "^3.2.4"
31
32
  },
32
33
  "scripts": {
33
34
  "prepare": "husky",