diff --git a/apps/metamigo-api/src/app/plugins/hapi-nextauth.ts b/apps/metamigo-api/src/app/plugins/hapi-nextauth.ts index cdd989c..0df40d7 100644 --- a/apps/metamigo-api/src/app/plugins/hapi-nextauth.ts +++ b/apps/metamigo-api/src/app/plugins/hapi-nextauth.ts @@ -1,24 +1,13 @@ import type * as Hapi from "@hapi/hapi"; -import NextAuthPlugin, { AdapterFactory } from "@digiresilience/hapi-nextauth"; +import NextAuthPlugin from "@digiresilience/hapi-nextauth"; import { NextAuthAdapter } from "@digiresilience/metamigo-common"; -import type { - SavedUser, - UnsavedUser, - SavedSession, -} from "@digiresilience/metamigo-common"; import { IAppConfig } from "@digiresilience/metamigo-config"; export const registerNextAuth = async ( server: Hapi.Server, config: IAppConfig ): Promise => { - // I'm not sure why I need to be so explicit with the generic types here - // I thought ts could figure out the generics based on the concrete params, but apparently not - const nextAuthAdapterFactory: AdapterFactory< - SavedUser, - UnsavedUser, - SavedSession - > = (request: Hapi.Request) => new NextAuthAdapter(request.db()); + const nextAuthAdapterFactory: any = (request: Hapi.Request) => new NextAuthAdapter(request.db()); await server.register({ plugin: NextAuthPlugin, diff --git a/apps/metamigo-frontend/components/layout/Menu.tsx b/apps/metamigo-frontend/components/layout/Menu.tsx index 5ddf3fd..13526ca 100644 --- a/apps/metamigo-frontend/components/layout/Menu.tsx +++ b/apps/metamigo-frontend/components/layout/Menu.tsx @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import { FC, useState } from "react"; -import { useSelector } from "react-redux"; +// import { useSelector } from "react-redux"; import SecurityIcon from "@mui/icons-material/Security"; import VoiceIcon from "@mui/icons-material/PhoneInTalk"; import { Box } from "@mui/material"; diff --git a/package-lock.json b/package-lock.json index 8461789..496fdd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2654,6 +2654,11 @@ "react": ">=16.x" } }, + "node_modules/@graphile-contrib/pg-many-to-many": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@graphile-contrib/pg-many-to-many/-/pg-many-to-many-1.0.2.tgz", + "integrity": "sha512-ChSaSU7/n99Crdlink62cCGqlEYmjUJKizz2Nx0tdGgqSMkf6KTk00D3ILGybScywMcJGjJE2cc6FXYIHVlxCg==" + }, "node_modules/@graphile-contrib/pg-simplify-inflector": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/@graphile-contrib/pg-simplify-inflector/-/pg-simplify-inflector-6.1.0.tgz", @@ -21496,6 +21501,7 @@ "dependencies": { "@digiresilience/metamigo-common": "*", "@digiresilience/metamigo-config": "^0.2.0", + "@graphile-contrib/pg-many-to-many": "^1.0.2", "graphile-migrate": "^1.4.1", "graphql": "16.6.0", "postgraphile": "4.13.0" diff --git a/packages/hapi-nextauth/src/index.ts b/packages/hapi-nextauth/src/index.ts index 16ee33c..02b516a 100644 --- a/packages/hapi-nextauth/src/index.ts +++ b/packages/hapi-nextauth/src/index.ts @@ -58,16 +58,16 @@ const validateAuth = (sharedSecret) => (request, username, password) => { return { isValid, credentials }; }; -const register = async ( +const register = async ( server: Hapi.Server, - pluginOpts?: NextAuthPluginOptions + pluginOpts?: any ): Promise => { - const options: NextAuthPluginOptions = + const options: any = Hoek.applyToDefaults( // a little type gymnastics here to workaround poor typing - defaultOptions as unknown, + defaultOptions as any, pluginOpts - ) as NextAuthPluginOptions; + ) as any; if (!options.nextAuthAdapterFactory) { throw new Error( diff --git a/packages/hapi-nextauth/src/routes.ts b/packages/hapi-nextauth/src/routes.ts index f860269..082499a 100644 --- a/packages/hapi-nextauth/src/routes.ts +++ b/packages/hapi-nextauth/src/routes.ts @@ -1,7 +1,6 @@ /* eslint-disable unicorn/no-null */ import * as Joi from "joi"; import * as Hapi from "@hapi/hapi"; -import { NextAuthPluginOptions } from "./types"; import { ResponseToolkit, ResponseObject } from "@hapi/hapi"; export interface LinkAccountPayload { @@ -14,9 +13,9 @@ export interface LinkAccountPayload { accessTokenExpires?: null; } -export const register = async ( +export const register = async ( server: Hapi.Server, - opts: NextAuthPluginOptions, + opts: any, auth?: string ): Promise => { const { tags, basePath, validators } = opts; diff --git a/packages/hapi-nextauth/src/types.ts b/packages/hapi-nextauth/src/types.ts index 03027cb..8a96c3d 100644 --- a/packages/hapi-nextauth/src/types.ts +++ b/packages/hapi-nextauth/src/types.ts @@ -1,14 +1,13 @@ -// @ts-nocheck -import type { AdapterInstance } from "next-auth/adapters"; +import type { Adapter } from "next-auth/adapters"; import type { NumberSchema, StringSchema, ObjectSchema } from "joi"; import type { Request } from "@hapi/hapi"; -export type AdapterFactory = ( +export type AdapterFactory = ( request: Request -) => AdapterInstance; +) => Adapter; -export interface NextAuthPluginOptions { - nextAuthAdapterFactory: AdapterFactory; +export interface NextAuthPluginOptions { + nextAuthAdapterFactory: Adapter; validators?: { profile: ObjectSchema; diff --git a/packages/metamigo-cli/src/metamigo-postgraphile.ts b/packages/metamigo-cli/src/metamigo-postgraphile.ts index d7b7a2b..9e72a15 100644 --- a/packages/metamigo-cli/src/metamigo-postgraphile.ts +++ b/packages/metamigo-cli/src/metamigo-postgraphile.ts @@ -1,4 +1,3 @@ -// @ts-nocheck import { writeFileSync } from "node:fs"; import { getIntrospectionQuery, @@ -27,7 +26,7 @@ export const exportGraphqlSchema = async (): Promise => { getPostGraphileOptions() )) as unknown as GraphQLSchema; const sorted = lexicographicSortSchema(schema); - const json = graphqlSync(schema, getIntrospectionQuery()); + const json = graphqlSync({ schema, source: getIntrospectionQuery() }); writeFileSync(exportSchema, printSchema(sorted)); writeFileSync(exportJson, JSON.stringify(json)); diff --git a/packages/metamigo-common/src/controllers/nextauth-adapter.ts b/packages/metamigo-common/src/controllers/nextauth-adapter.ts index bdafebf..8ad51a2 100644 --- a/packages/metamigo-common/src/controllers/nextauth-adapter.ts +++ b/packages/metamigo-common/src/controllers/nextauth-adapter.ts @@ -1,7 +1,5 @@ /* eslint-disable unicorn/no-null,max-params */ -// @ts-nocheck import { createHash, randomBytes } from "node:crypto"; -import type { AdapterInstance } from "next-auth/adapters"; import omit from "lodash/omit"; import type { IMetamigoRepositories } from "../records"; import type { UnsavedAccount } from "../records/account"; @@ -20,9 +18,7 @@ const getCompoundId = (providerId: any, providerAccountId: any) => const randomToken = () => randomBytes(32).toString("hex"); -export class NextAuthAdapter - implements AdapterInstance -{ +export class NextAuthAdapter { constructor( private repos: TRepositories, private readonly sessionMaxAge = defaultSessionMaxAge, diff --git a/packages/metamigo-db/package.json b/packages/metamigo-db/package.json index cc7cd72..0400773 100644 --- a/packages/metamigo-db/package.json +++ b/packages/metamigo-db/package.json @@ -8,6 +8,7 @@ "dependencies": { "@digiresilience/metamigo-common": "*", "@digiresilience/metamigo-config": "^0.2.0", + "@graphile-contrib/pg-many-to-many": "^1.0.2", "graphile-migrate": "^1.4.1", "graphql": "16.6.0", "postgraphile": "4.13.0" diff --git a/packages/metamigo-db/src/index.ts b/packages/metamigo-db/src/index.ts index 0ed1d4c..a8bf95d 100644 --- a/packages/metamigo-db/src/index.ts +++ b/packages/metamigo-db/src/index.ts @@ -1,10 +1,9 @@ -// @ts-nocheck import type { IAppConfig } from "@digiresilience/metamigo-config"; import camelcaseKeys from "camelcase-keys"; import PgSimplifyInflectorPlugin from "@graphile-contrib/pg-simplify-inflector"; -// import PgManyToManyPlugin from "@graphile-contrib/pg-many-to-many"; +import PgManyToManyPlugin from "@graphile-contrib/pg-many-to-many"; import * as ConnectionFilterPlugin from "postgraphile-plugin-connection-filter"; -import type { PostGraphileCoreOptions } from "postgraphile-core"; +import type { PostGraphileOptions } from "postgraphile"; import { UserRecordRepository, @@ -52,7 +51,6 @@ export const dbInitOptions = ( // Extending the database protocol with our custom repositories; // API: http://vitaly-t.github.io/pg-promise/global.html#event:extend - // eslint-disable-next-line @typescript-eslint/no-explicit-any extend(obj: any, _dc) { // AppDatase was obj type // Database Context (_dc) is mainly needed for extending multiple databases with different access API. @@ -74,14 +72,13 @@ export const dbInitOptions = ( }, }); -export const getPostGraphileOptions = (): PostGraphileCoreOptions => ({ +export const getPostGraphileOptions = (): PostGraphileOptions => ({ ignoreRBAC: false, dynamicJson: true, ignoreIndexes: false, appendPlugins: [ PgSimplifyInflectorPlugin, - // PgManyToManyPlugin, - // eslint-disable-next-line @typescript-eslint/no-explicit-any + PgManyToManyPlugin, ConnectionFilterPlugin as any, ], }); diff --git a/packages/montar/src/proxy.ts b/packages/montar/src/proxy.ts index de365a6..ba0aa17 100644 --- a/packages/montar/src/proxy.ts +++ b/packages/montar/src/proxy.ts @@ -1,5 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-nocheck /* eslint-disable no-new,no-useless-call */ // mutableProxyFactory from https://stackoverflow.com/a/54460544 // (C) Alex Hall https://stackoverflow.com/users/2482744/alex-hall @@ -11,7 +9,6 @@ export class PProxyHandler implements ProxyHandler { return Reflect.getPrototypeOf(target); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any setPrototypeOf?(target: T, v: any): boolean { return Reflect.setPrototypeOf(target, v); } @@ -35,12 +32,10 @@ export class PProxyHandler implements ProxyHandler { return Reflect.has(target, p); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any get?(target: T, p: PropertyKey, receiver: any): any { return Reflect.get(target, p, receiver); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any set?(target: T, p: PropertyKey, value: any, receiver: any): boolean { return Reflect.set(target, p, value, receiver); } @@ -61,16 +56,15 @@ export class PProxyHandler implements ProxyHandler { return Reflect.ownKeys(target); } + // @ts-expect-error ownKeys?(target: T): PropertyKey[] { return Reflect.ownKeys(target); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any apply?(target: T, thisArg: any, argArray?: any): any { return Reflect.apply(target as Function, thisArg, argArray); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any construct?(target: T, argArray: any, newTarget?: any): object { return Reflect.construct(target as Function, argArray, newTarget); } @@ -88,27 +82,28 @@ export function mutableProxyFactory( mutableTarget: T, mutableHandler?: ProxyHandler ): MutableProxy { - if (!mutableHandler) mutableHandler = new PProxyHandler(); + if (!mutableHandler) mutableHandler = new PProxyHandler() as any; return { setTarget(target: T): void { new Proxy(target, {}); // test target validity mutableTarget = target; }, setHandler(handler: PProxyHandler): void { - new Proxy({}, handler); // test handler validity + new Proxy({}, handler as any); // test handler validity Object.keys(handler).forEach((key) => { const value = handler[key]; if (Reflect[key] && typeof value !== "function") { throw new Error(`Trap "${key}: ${value}" is not a function`); } }); - mutableHandler = handler; + mutableHandler = handler as any; }, getTarget(): T { return mutableTarget; }, + // @ts-expect-error getHandler(): PProxyHandler { - return mutableHandler; + return mutableHandler as any; }, proxy: new Proxy( mutableTarget,