mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix issues with knex version bump
This commit is contained in:
parent
f0e3b4588a
commit
0a350bef6d
22 changed files with 43 additions and 40 deletions
|
|
@ -7,7 +7,7 @@
|
|||
import { ContextFunction } from 'apollo-server-core'
|
||||
import { ClaimsToSet, ResolverContext } from './resolvers/types'
|
||||
import { SetClaimsRole } from './utils/dictionary'
|
||||
import Knex, { Transaction } from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { ExpressContext } from 'apollo-server-express/dist/ApolloServer'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
import { kx } from './datalayer/knex_config'
|
||||
|
|
@ -48,7 +48,7 @@ const contextFunc: ContextFunction<ExpressContext, ResolverContext> = async ({
|
|||
const claims = await getClaimsByToken(token)
|
||||
|
||||
async function setClaims(
|
||||
tx: Transaction,
|
||||
tx: Knex.Transaction,
|
||||
uuid?: string,
|
||||
userRole?: string
|
||||
): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import { ArticleData, CreateSet, keys as modelKeys, UpdateSet } from './model'
|
||||
import DataModel from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import { logMethod } from '../helpers'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import {
|
||||
ArticleSavingRequestData,
|
||||
CreateSet,
|
||||
keys as modelKeys,
|
||||
UpdateSet,
|
||||
ArticleSavingRequestData,
|
||||
} from './model'
|
||||
import DataModel from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import { logMethod } from '../helpers'
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import DataModel from './model'
|
||||
import Knex, { Transaction } from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import DataLoader from 'dataloader'
|
||||
import { snakeCase } from 'snake-case'
|
||||
import { buildLogger } from '../utils/logger'
|
||||
|
|
@ -14,7 +14,7 @@ import { SetClaimsRole } from '../utils/dictionary'
|
|||
const logger = buildLogger('datalayer')
|
||||
|
||||
export const setClaims = async (
|
||||
tx: Transaction,
|
||||
tx: Knex.Transaction,
|
||||
uuid?: string,
|
||||
userRole?: string
|
||||
): Promise<void> => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import DataModel, { DataModelError, MAX_RECORDS_LIMIT } from '../model'
|
||||
import { CreateSet, HighlightData, keys as modelKeys, UpdateSet } from './model'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { ENABLE_DB_REQUEST_LOGGING, globalCounter } from '../helpers'
|
||||
import DataLoader from 'dataloader'
|
||||
|
||||
|
|
@ -26,7 +26,8 @@ class HighlightModel extends DataModel<HighlightData, CreateSet, UpdateSet> {
|
|||
}
|
||||
|
||||
try {
|
||||
const rows: HighlightData[] = await kx(this.tableName)
|
||||
const rows: HighlightData[] = await kx
|
||||
.table(this.tableName)
|
||||
.select(this.modelKeys)
|
||||
.whereIn('id', keys)
|
||||
.andWhere('deleted', false)
|
||||
|
|
@ -60,7 +61,8 @@ class HighlightModel extends DataModel<HighlightData, CreateSet, UpdateSet> {
|
|||
)
|
||||
}
|
||||
|
||||
const result = await this.kx(Table.HIGHLIGHT)
|
||||
const result = await this.kx
|
||||
.table(Table.HIGHLIGHT)
|
||||
.select(modelKeys)
|
||||
.whereIn('elasticPageId', articleIds)
|
||||
.andWhere('deleted', false)
|
||||
|
|
@ -153,7 +155,8 @@ class HighlightModel extends DataModel<HighlightData, CreateSet, UpdateSet> {
|
|||
userId: string,
|
||||
articleId: string
|
||||
): Promise<HighlightData[]> {
|
||||
const highlights = await this.kx(Table.HIGHLIGHT)
|
||||
const highlights: HighlightData[] = await this.kx
|
||||
.table(Table.HIGHLIGHT)
|
||||
.select(modelKeys)
|
||||
.where('user_id', userId)
|
||||
.andWhere('elastic_page_id', articleId)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { env } from '../env'
|
||||
import Knex from 'knex'
|
||||
import knex from 'knex'
|
||||
import knexStringcase from 'knex-stringcase'
|
||||
|
||||
export const kx = Knex(
|
||||
export const kx = knex(
|
||||
knexStringcase({
|
||||
client: 'pg',
|
||||
connection: {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
UserFeedArticleData,
|
||||
} from './model'
|
||||
import DataModel, { MAX_RECORDS_LIMIT } from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import {
|
||||
Article,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { LinkShareInfo } from '../../generated/graphql'
|
||||
import { DataModels } from '../../resolvers/types'
|
||||
import { getPageByParam } from '../../elastic/pages'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import DataLoader from 'dataloader'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { ENABLE_DB_REQUEST_LOGGING, globalCounter } from './helpers'
|
||||
|
||||
export enum DataModelError {
|
||||
|
|
@ -113,7 +113,7 @@ abstract class DataModel<
|
|||
tx: Knex.Transaction
|
||||
): Promise<ModelData[]> {
|
||||
const rows: ModelData[] = await tx
|
||||
.batchInsert(this.tableName, data)
|
||||
.batchInsert(this.tableName, data as never)
|
||||
.returning('*')
|
||||
for (const row of rows) {
|
||||
this.loader.prime(row.id, row)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import {
|
||||
globalCounter,
|
||||
ENABLE_DB_REQUEST_LOGGING,
|
||||
globalCounter,
|
||||
logMethod,
|
||||
} from './../helpers'
|
||||
import { CreateSet, keys as modelKeys, UpdateSet, ReactionData } from './model'
|
||||
import { CreateSet, keys as modelKeys, ReactionData, UpdateSet } from './model'
|
||||
import DataModel, { DataModelError, MAX_RECORDS_LIMIT } from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
|
||||
import DataLoader from 'dataloader'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
UpdateSet,
|
||||
} from './model'
|
||||
import DataModel, { DataModelError } from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import { logMethod } from '../helpers'
|
||||
import { ArticleData } from '../article/model'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { ReportType } from '../../generated/graphql'
|
||||
|
||||
interface ReportItem {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { CreateSet, keys as modelKeys, UpdateSet, TaskData } from './model'
|
||||
import { CreateSet, keys as modelKeys, TaskData, UpdateSet } from './model'
|
||||
import DataModel from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { logMethod } from '../helpers'
|
||||
|
||||
class TaskModel extends DataModel<TaskData, CreateSet, UpdateSet> {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
UploadFileData,
|
||||
} from './model'
|
||||
import DataModel from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import { logMethod } from '../helpers'
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
UserData,
|
||||
} from './model'
|
||||
import DataModel, { DataModelError, MAX_RECORDS_LIMIT } from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { ENABLE_DB_REQUEST_LOGGING, globalCounter, logMethod } from '../helpers'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import DataLoader from 'dataloader'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
UserFriendData,
|
||||
} from './model'
|
||||
import DataModel, { MAX_RECORDS_LIMIT } from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import { ENABLE_DB_REQUEST_LOGGING, globalCounter, logMethod } from '../helpers'
|
||||
import DataLoader from 'dataloader'
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
UserPersonalizationData,
|
||||
} from './model'
|
||||
import DataModel from '../model'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { Table } from '../../utils/dictionary'
|
||||
import { camelCase } from 'voca'
|
||||
import { logMethod } from '../helpers'
|
||||
|
|
|
|||
2
packages/api/src/graphql.d.ts
vendored
2
packages/api/src/graphql.d.ts
vendored
|
|
@ -8,7 +8,7 @@ declare module '*.graphql' {
|
|||
}
|
||||
|
||||
declare module 'knex-stringcase' {
|
||||
import * as Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
|
||||
type StringCase =
|
||||
| 'camelcase'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import { Context as ApolloContext } from 'apollo-server-core'
|
||||
import winston from 'winston'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import UserModel from '../datalayer/user'
|
||||
import ArticleModel from '../datalayer/article'
|
||||
import UserArticleModel from '../datalayer/links'
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { UserData } from '../../datalayer/user/model'
|
||||
import {
|
||||
User,
|
||||
ResolverFn,
|
||||
SetFollowSuccess,
|
||||
SetFollowError,
|
||||
MutationSetFollowArgs,
|
||||
SetFollowErrorCode,
|
||||
GetFollowersResult,
|
||||
GetFollowingResult,
|
||||
MutationSetFollowArgs,
|
||||
QueryGetFollowersArgs,
|
||||
QueryGetFollowingArgs,
|
||||
ResolverFn,
|
||||
SetFollowError,
|
||||
SetFollowErrorCode,
|
||||
SetFollowSuccess,
|
||||
User,
|
||||
} from '../../generated/graphql'
|
||||
import { userDataToUser, authorized } from '../../utils/helpers'
|
||||
import { authorized, userDataToUser } from '../../utils/helpers'
|
||||
import { DataModels, WithDataSourcesContext } from '../types'
|
||||
|
||||
export const setFollowResolver = authorized<
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { json, urlencoded } from 'body-parser'
|
|||
import cookieParser from 'cookie-parser'
|
||||
import express, { Express } from 'express'
|
||||
import { createServer, Server } from 'http'
|
||||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { env } from './env'
|
||||
import * as Sentry from '@sentry/node'
|
||||
import * as lw from '@google-cloud/logging-winston'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Knex from 'knex'
|
||||
import { Knex } from 'knex'
|
||||
import { PubsubClient } from '../datalayer/pubsub'
|
||||
import { UserData } from '../datalayer/user/model'
|
||||
import { homePageURL } from '../env'
|
||||
|
|
|
|||
Loading…
Reference in a new issue