Skip to content

Commit ffc50c7

Browse files
Adjust typescript module resolution settings (#767)
1 parent 32f8b84 commit ffc50c7

13 files changed

Lines changed: 35 additions & 32 deletions

File tree

‎bin/u-wave-core.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
/* eslint-disable n/no-process-exit */
44
import fs from 'node:fs';
5-
import Ajv from 'ajv';
6-
import addFormats from 'ajv-formats';
5+
import { Ajv } from 'ajv';
6+
import ajvFormats from 'ajv-formats';
77
import ytSource from 'u-wave-source-youtube';
88
import scSource from 'u-wave-source-soundcloud';
99
import announce from 'u-wave-announce';
@@ -26,7 +26,7 @@ const ajv = new Ajv({
2626
hexadecimal: /^[0-9a-fA-F]+$/,
2727
},
2828
});
29-
addFormats(ajv);
29+
ajvFormats.default(ajv);
3030

3131
const envSchema = {
3232
type: 'object',

‎src/SocketServer.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promisify } from 'node:util';
22
import lodash from 'lodash';
33
import { WebSocketServer } from 'ws';
4-
import Ajv from 'ajv';
4+
import { Ajv } from 'ajv';
55
import { stdSerializers } from 'pino';
66
import { ulid, encodeTime } from 'ulid';
77
import { socketVote } from './controllers/booth.js';
@@ -405,7 +405,7 @@ class SocketServer {
405405
const user = await users.getUser(userID);
406406
if (user) {
407407
// TODO this should not be the socket server code's responsibility
408-
const userIDs = /** @type {import('./schema').UserID[] | null} */ (
408+
const userIDs = /** @type {import('./schema.js').UserID[] | null} */ (
409409
await keyv.get(KEY_ACTIVE_SESSIONS)
410410
) ?? [];
411411
userIDs.push(user.id);
@@ -468,7 +468,7 @@ class SocketServer {
468468
*/
469469
async initLostConnections() {
470470
const { db, keyv } = this.#uw;
471-
const userIDs = /** @type {import('./schema').UserID[] | null} */ (
471+
const userIDs = /** @type {import('./schema.js').UserID[] | null} */ (
472472
await keyv.get(KEY_ACTIVE_SESSIONS)
473473
) ?? [];
474474
const disconnectedIDs = userIDs.filter((userID) => !this.connection(userID));

‎src/config/defaultRoles.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const manager = [
3737
'motd.set',
3838
];
3939

40-
/** @typedef {Record<string, import("../schema").Permission[]>} PermissionMap */
40+
/** @typedef {Record<string, import('../schema.js').Permission[]>} PermissionMap */
4141

4242
export default /** @type {PermissionMap} */ (/** @type {Record<string, unknown[]>} */ ({
4343
admin,

‎src/controllers/authenticate.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { t } from '../locale.js';
2222
const { BadRequest } = httpErrors;
2323

2424
/**
25-
* @typedef {import('../schema').UserID} UserID
25+
* @typedef {import('../schema.js').UserID} UserID
2626
* @typedef {import('../schema.js').PasswordResetToken} PasswordResetToken
2727
*/
2828

@@ -65,7 +65,7 @@ async function getAuthStrategies(req) {
6565

6666
/**
6767
* @param {import('../types.js').Request} req
68-
* @param {import('../schema').User} user
68+
* @param {import('../schema.js').User} user
6969
* @param {AuthenticateOptions & { session: 'cookie' | 'token' }} options
7070
*/
7171
async function refreshSession(req, user, options) {

‎src/controllers/bans.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import getOffsetPagination from '../utils/getOffsetPagination.js';
33
import toItemResponse from '../utils/toItemResponse.js';
44
import toPaginatedResponse from '../utils/toPaginatedResponse.js';
55

6-
/** @typedef {import('../schema').UserID} UserID */
6+
/** @typedef {import('../schema.js').UserID} UserID */
77

88
/**
99
* @typedef {object} GetBansQuery

‎src/controllers/booth.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import toPaginatedResponse from '../utils/toPaginatedResponse.js';
1313
import { Permissions } from '../plugins/acl.js';
1414

1515
/**
16-
* @typedef {import('../schema').UserID} UserID
17-
* @typedef {import('../schema').MediaID} MediaID
18-
* @typedef {import('../schema').PlaylistID} PlaylistID
19-
* @typedef {import('../schema').HistoryEntryID} HistoryEntryID
16+
* @typedef {import('../schema.js').UserID} UserID
17+
* @typedef {import('../schema.js').MediaID} MediaID
18+
* @typedef {import('../schema.js').PlaylistID} PlaylistID
19+
* @typedef {import('../schema.js').HistoryEntryID} HistoryEntryID
2020
*/
2121

2222
const KEY_HISTORY_ID = 'booth:historyID';

‎src/controllers/chat.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import toItemResponse from '../utils/toItemResponse.js';
55
import toListResponse from '../utils/toListResponse.js';
66

77
/**
8-
* @typedef {import('../schema').UserID} UserID
8+
* @typedef {import('../schema.js').UserID} UserID
99
* @typedef {import('../redisMessages.js').ServerActionParameters} ServerActionParameters
1010
*/
1111

@@ -164,7 +164,7 @@ async function getBackscroll(req) {
164164
*/
165165

166166
/**
167-
* @type {import('../types').AuthenticatedController<{}, {}, SendMessageBody>}
167+
* @type {import('../types.js').AuthenticatedController<{}, {}, SendMessageBody>}
168168
*/
169169
async function sendMessage(req) {
170170
const { user } = req;

‎src/controllers/playlists.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import toListResponse from '../utils/toListResponse.js';
66
import toPaginatedResponse from '../utils/toPaginatedResponse.js';
77

88
/**
9-
* @typedef {import('../schema').PlaylistID} PlaylistID
10-
* @typedef {import('../schema').PlaylistItemID} PlaylistItemID
11-
* @typedef {import('../schema').MediaID} MediaID
9+
* @typedef {import('../schema.js').PlaylistID} PlaylistID
10+
* @typedef {import('../schema.js').PlaylistItemID} PlaylistItemID
11+
* @typedef {import('../schema.js').MediaID} MediaID
1212
*/
1313

1414
/**
1515
* TODO move to a serializer?
1616
*
1717
* @param {Pick<
18-
* import('../schema').PlaylistItem,
18+
* import('../schema.js').PlaylistItem,
1919
* 'id' | 'artist' | 'title' | 'start' | 'end' | 'createdAt'
2020
* >} playlistItem
2121
* @param {Pick<
22-
* import('../schema').Media,
22+
* import('../schema.js').Media,
2323
* 'id' | 'sourceType' | 'sourceID' | 'sourceData' | 'artist' | 'title' | 'duration' | 'thumbnail'
2424
* >} media
2525
*/

‎src/controllers/users.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { muteUser, unmuteUser } from './chat.js';
1212
import { KEY_ACTIVE_SESSIONS } from '../SocketServer.js';
1313

1414
/**
15-
* @typedef {import('../schema').UserID} UserID
15+
* @typedef {import('../schema.js').UserID} UserID
1616
*/
1717

1818
/**

‎src/middleware/schema.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'node:assert';
22
import fs from 'node:fs';
3-
import Ajv from 'ajv/dist/2019.js';
4-
import addFormats from 'ajv-formats';
3+
import { Ajv2019 as Ajv } from 'ajv/dist/2019.js';
4+
import ajvFormats from 'ajv-formats';
55
import ValidationError from '../errors/ValidationError.js';
66

77
const ajv = new Ajv({
@@ -11,7 +11,7 @@ const ajv = new Ajv({
1111
ownProperties: true,
1212
allErrors: true,
1313
});
14-
addFormats(ajv);
14+
ajvFormats.default(ajv);
1515
ajv.addMetaSchema(JSON.parse(fs.readFileSync(new URL('../../node_modules/ajv/dist/refs/json-schema-draft-07.json', import.meta.url), 'utf8')));
1616
ajv.addSchema(JSON.parse(fs.readFileSync(new URL('../schemas/definitions.json', import.meta.url), 'utf8')));
1717

0 commit comments

Comments
 (0)