Skip to content

Commit

Permalink
correct type import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Jul 1, 2023
1 parent 1c66beb commit af7a85c
Show file tree
Hide file tree
Showing 48 changed files with 220 additions and 221 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"@types/qs": "^6.9.6",
"@types/random-string": "^0.0.28",
"@types/ratelimiter": "^3.4.1",
"@types/redlock": "^4.0.1",
"@types/sinon": "^10.0.2",
"@types/supertest": "^2.0.11",
"@types/ultron": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/AuthRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AuthRegistry {
}

/**
* @param {import('./models').User} user
* @param {import('./models/index.js').User} user
*/
async createAuthToken(user) {
const token = (await randomBytes(64)).toString('hex');
Expand Down
4 changes: 2 additions & 2 deletions src/HttpApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function defaultCreatePasswordResetEmail({ token, requestUrl }) {
*/

/**
* @param {import('./Uwave').Boot} uw
* @param {import('./Uwave.js').Boot} uw
* @param {HttpApiOptions} options
*/
async function httpApi(uw, options) {
Expand Down Expand Up @@ -158,7 +158,7 @@ async function httpApi(uw, options) {
}

/**
* @param {import('./Uwave').Boot} uw
* @param {import('./Uwave.js').Boot} uw
*/
async function errorHandling(uw) {
uw.logger.debug({ ns: 'uwave:http-api' }, 'setup HTTP error handling');
Expand Down
16 changes: 8 additions & 8 deletions src/SocketServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { serializeUser } from './utils/serialize.js';
const { debounce, isEmpty } = lodash;

/**
* @typedef {import('./models').User} User
* @typedef {import('./models/index.js').User} User
*/

/**
Expand Down Expand Up @@ -59,7 +59,7 @@ function has(object, property) {

class SocketServer {
/**
* @param {import('./Uwave').Boot} uw
* @param {import('./Uwave.js').Boot} uw
* @param {{ secret: Buffer|string }} options
*/
static async plugin(uw, options) {
Expand Down Expand Up @@ -114,14 +114,14 @@ class SocketServer {
/**
* Handlers for commands that come in from the server side.
*
* @type {import('./redisMessages').ServerActions}
* @type {import('./redisMessages.js').ServerActions}
*/
#serverActions;

/**
* Create a socket server.
*
* @param {import('./Uwave').default} uw üWave Core instance.
* @param {import('./Uwave.js').default} uw üWave Core instance.
* @param {object} options Socket server options.
* @param {number} [options.timeout] Time in seconds to wait for disconnected
* users to reconnect before removing them.
Expand All @@ -143,7 +143,7 @@ class SocketServer {
this.#redisSubscription = uw.redis.duplicate();

this.options = {
/** @type {(_socket: import('ws') | undefined, err: Error) => void} */
/** @type {(_socket: import('ws').WebSocket | undefined, err: Error) => void} */
onError: (_socket, err) => {
throw err;
},
Expand Down Expand Up @@ -453,7 +453,7 @@ class SocketServer {
}

/**
* @param {import('ws')} socket
* @param {import('ws').WebSocket} socket
* @param {import('http').IncomingMessage} request
* @private
*/
Expand All @@ -467,7 +467,7 @@ class SocketServer {
}

/**
* @param {import('ws')} socket
* @param {import('ws').WebSocket} socket
* @param {Error} error
* @private
*/
Expand Down Expand Up @@ -502,7 +502,7 @@ class SocketServer {
/**
* Create a connection instance for an unauthenticated user.
*
* @param {import('ws')} socket
* @param {import('ws').WebSocket} socket
* @private
*/
createGuestConnection(socket) {
Expand Down
10 changes: 5 additions & 5 deletions src/Source.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SourceNoImportError } from './errors/index.js';

/**
* @typedef {import('./models').User} User
* @typedef {import('./models').Playlist} Playlist
* @typedef {import('./plugins/playlists').PlaylistItemDesc} PlaylistItemDesc
* @typedef {import('./models/index.js').User} User
* @typedef {import('./models/index.js').Playlist} Playlist
* @typedef {import('./plugins/playlists.js').PlaylistItemDesc} PlaylistItemDesc
*/

/**
Expand Down Expand Up @@ -34,7 +34,7 @@ import { SourceNoImportError } from './errors/index.js';
*/
class SourceContext {
/**
* @param {import('./Uwave').default} uw
* @param {import('./Uwave.js').default} uw
* @param {Source} source
* @param {User} user
*/
Expand Down Expand Up @@ -79,7 +79,7 @@ class ImportContext extends SourceContext {
*/
class Source {
/**
* @param {import('./Uwave').default} uw
* @param {import('./Uwave.js').default} uw
* @param {string} sourceType
* @param {SourcePlugin} sourcePlugin
*/
Expand Down
40 changes: 20 additions & 20 deletions src/Uwave.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DEFAULT_MONGO_URL = 'mongodb://localhost:27017/uwave';
const DEFAULT_REDIS_URL = 'redis://localhost:6379';

/**
* @typedef {import('./Source').SourcePlugin} SourcePlugin
* @typedef {import('./Source.js').SourcePlugin} SourcePlugin
*/

/**
Expand All @@ -40,7 +40,7 @@ const DEFAULT_REDIS_URL = 'redis://localhost:6379';
* mongo?: string,
* redis?: string | RedisOptions,
* logger?: import('pino').LoggerOptions,
* } & import('./HttpApi').HttpApiOptions} Options
* } & import('./HttpApi.js').HttpApiOptions} Options
*/

class UwaveServer extends EventEmitter {
Expand All @@ -55,66 +55,66 @@ class UwaveServer extends EventEmitter {
// @ts-expect-error TS2564 Definitely assigned in a plugin
express;

/** @type {import('./models').Models} */
/** @type {import('./models/index.js').Models} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
models;

/** @type {import('./plugins/acl').Acl} */
/** @type {import('./plugins/acl.js').Acl} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
acl;

/** @type {import('./plugins/bans').Bans} */
/** @type {import('./plugins/bans.js').Bans} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
bans;

/** @type {import('./plugins/booth').Booth} */
/** @type {import('./plugins/booth.js').Booth} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
booth;

/** @type {import('./plugins/chat').Chat} */
/** @type {import('./plugins/chat.js').Chat} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
chat;

/** @type {import('./plugins/configStore').ConfigStore} */
/** @type {import('./plugins/configStore.js').ConfigStore} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
config;

/** @type {import('./plugins/emotes').Emotes|null} */
/** @type {import('./plugins/emotes.js').Emotes|null} */
emotes = null;

/** @type {import('./plugins/history').HistoryRepository} */
/** @type {import('./plugins/history.js').HistoryRepository} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
history;

/** @type {import('./plugins/migrations').Migrate} */
/** @type {import('./plugins/migrations.js').Migrate} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
migrate;

/** @type {import('./plugins/motd').MOTD} */
/** @type {import('./plugins/motd.js').MOTD} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
motd;

/** @type {import('./plugins/passport').Passport} */
/** @type {import('./plugins/passport.js').Passport} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
passport;

/** @type {import('./plugins/playlists').PlaylistsRepository} */
/** @type {import('./plugins/playlists.js').PlaylistsRepository} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
playlists;

/** @type {import('./plugins/users').UsersRepository} */
/** @type {import('./plugins/users.js').UsersRepository} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
users;

/** @type {import('./plugins/waitlist').Waitlist} */
/** @type {import('./plugins/waitlist.js').Waitlist} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
waitlist;

/** @type {import('./HttpApi').HttpApi} */
/** @type {import('./HttpApi.js').HttpApi} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
httpApi;

/** @type {import('./SocketServer').default} */
/** @type {import('./SocketServer.js').default} */
// @ts-expect-error TS2564 Definitely assigned in a plugin
socketServer;

Expand Down Expand Up @@ -304,9 +304,9 @@ class UwaveServer extends EventEmitter {
/**
* Publish an event to the üWave channel.
*
* @template {keyof import('./redisMessages').ServerActionParameters} CommandName
* @template {keyof import('./redisMessages.js').ServerActionParameters} CommandName
* @param {CommandName} command
* @param {import('./redisMessages').ServerActionParameters[CommandName]} data
* @param {import('./redisMessages.js').ServerActionParameters[CommandName]} data
*/
publish(command, data) {
this.redis.publish('uwave', JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion src/auth/JWTStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Strategy } from 'passport';
import jwt from 'jsonwebtoken';
import { BannedError } from '../errors/index.js';

/** @typedef {import('../models').User} User */
/** @typedef {import('../models/index.js').User} User */

/**
* @param {Record<string, string>} cookies
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/acl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import toItemResponse from '../utils/toItemResponse.js';

/**
* @type {import('../types').AuthenticatedController}
* @type {import('../types.js').AuthenticatedController}
*/
async function list(req) {
const { acl } = req.uwave;
Expand All @@ -22,7 +22,7 @@ async function list(req) {
*/

/**
* @type {import('../types').AuthenticatedController<CreateRoleParams, {}, CreateRoleBody>}
* @type {import('../types.js').AuthenticatedController<CreateRoleParams, {}, CreateRoleBody>}
*/
async function createRole(req, res) {
const { name } = req.params;
Expand All @@ -38,7 +38,7 @@ async function createRole(req, res) {
}

/**
* @type {import('../types').AuthenticatedController}
* @type {import('../types.js').AuthenticatedController}
*/
async function deleteRole(req) {
const { name } = req.params;
Expand Down
Loading

0 comments on commit af7a85c

Please sign in to comment.