0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(deps): update dependency slonik to v28 (#649)

* fix(deps): update dependency slonik to v28

* fix: build

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Gao Sun <gao@silverhand.io>
This commit is contained in:
renovate[bot] 2022-04-24 10:34:18 +00:00 committed by GitHub
parent 2d7918a224
commit 25814d92ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 35 additions and 123 deletions

View file

@ -44,7 +44,7 @@
"oidc-provider": "^7.10.0", "oidc-provider": "^7.10.0",
"p-retry": "^4.6.1", "p-retry": "^4.6.1",
"query-string": "^7.0.1", "query-string": "^7.0.1",
"slonik": "^23.8.3", "slonik": "^28.0.0",
"slonik-interceptor-preset": "^1.2.10", "slonik-interceptor-preset": "^1.2.10",
"snakecase-keys": "^5.1.0", "snakecase-keys": "^5.1.0",
"zod": "^3.14.3" "zod": "^3.14.3"

View file

@ -1,6 +1,6 @@
import { SchemaLike, GeneratedSchema } from '@logto/schemas'; import { SchemaLike, GeneratedSchema } from '@logto/schemas';
import { has } from '@silverhand/essentials'; import { has } from '@silverhand/essentials';
import { IdentifierSqlTokenType, sql } from 'slonik'; import { IdentifierSqlToken, sql } from 'slonik';
import envSet from '@/env-set'; import envSet from '@/env-set';
import { InsertionError } from '@/errors/SlonikError'; import { InsertionError } from '@/errors/SlonikError';
@ -14,15 +14,15 @@ import {
OmitAutoSetFields, OmitAutoSetFields,
} from './utils'; } from './utils';
const setExcluded = (...fields: IdentifierSqlTokenType[]) => const setExcluded = (...fields: IdentifierSqlToken[]) =>
sql.join( sql.join(
fields.map((field) => sql`${field}=excluded.${field}`), fields.map((field) => sql`${field}=excluded.${field}`),
sql`, ` sql`, `
); );
type OnConflict = { type OnConflict = {
fields: IdentifierSqlTokenType[]; fields: IdentifierSqlToken[];
setExcludedFields: IdentifierSqlTokenType[]; setExcludedFields: IdentifierSqlToken[];
}; };
type InsertIntoConfigReturning = { type InsertIntoConfigReturning = {

View file

@ -1,9 +1,9 @@
import { SchemaLike } from '@logto/schemas'; import { SchemaLike } from '@logto/schemas';
import { IdentifierSqlTokenType } from 'slonik'; import { IdentifierSqlToken } from 'slonik';
export type Table = { table: string; fields: Record<string, string> }; export type Table = { table: string; fields: Record<string, string> };
export type FieldIdentifiers<Key extends string | number | symbol> = { export type FieldIdentifiers<Key extends string | number | symbol> = {
[key in Key]: IdentifierSqlTokenType; [key in Key]: IdentifierSqlToken;
}; };
export type OrderDirection = 'asc' | 'desc'; export type OrderDirection = 'asc' | 'desc';

View file

@ -1,16 +1,14 @@
import { SchemaValuePrimitive, SchemaValue } from '@logto/schemas'; import { SchemaValuePrimitive, SchemaValue } from '@logto/schemas';
import { Falsy, notFalsy } from '@silverhand/essentials'; import { Falsy, notFalsy } from '@silverhand/essentials';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { sql, SqlSqlTokenType, SqlTokenType, IdentifierSqlTokenType } from 'slonik'; import { sql, SqlSqlToken, SqlToken, IdentifierSqlToken } from 'slonik';
import envSet from '@/env-set'; import envSet from '@/env-set';
import { FieldIdentifiers, Table } from './types'; import { FieldIdentifiers, Table } from './types';
export const conditionalSql = <T>( export const conditionalSql = <T>(value: T, buildSql: (value: Exclude<T, Falsy>) => SqlSqlToken) =>
value: T, notFalsy(value) ? buildSql(value) : sql``;
buildSql: (value: Exclude<T, Falsy>) => SqlSqlTokenType
) => (notFalsy(value) ? buildSql(value) : sql``);
export const autoSetFields = Object.freeze(['createdAt', 'updatedAt'] as const); export const autoSetFields = Object.freeze(['createdAt', 'updatedAt'] as const);
export type OmitAutoSetFields<T> = Omit<T, typeof autoSetFields[number]>; export type OmitAutoSetFields<T> = Omit<T, typeof autoSetFields[number]>;
@ -36,7 +34,7 @@ export const convertToPrimitiveOrSql = (
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
value: NonNullable<SchemaValue> | null value: NonNullable<SchemaValue> | null
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
): NonNullable<SchemaValuePrimitive> | SqlTokenType | null => { ): NonNullable<SchemaValuePrimitive> | SqlToken | null => {
if (value === null) { if (value === null) {
return null; return null;
} }
@ -73,7 +71,7 @@ export const convertToIdentifiers = <T extends Table>(
export const convertToTimestamp = (time = dayjs()) => sql`to_timestamp(${time.valueOf() / 1000})`; export const convertToTimestamp = (time = dayjs()) => sql`to_timestamp(${time.valueOf() / 1000})`;
export const getTotalRowCount = async (table: IdentifierSqlTokenType) => export const getTotalRowCount = async (table: IdentifierSqlToken) =>
envSet.pool.one<{ count: number }>(sql` envSet.pool.one<{ count: number }>(sql`
select count(*) select count(*)
from ${table} from ${table}

View file

@ -1,5 +1,5 @@
import { getEnv, Optional } from '@silverhand/essentials'; import { getEnv, Optional } from '@silverhand/essentials';
import { DatabasePoolType } from 'slonik'; import { DatabasePool } from 'slonik';
import createPoolByEnv from './create-pool-by-env'; import createPoolByEnv from './create-pool-by-env';
import loadOidcValues from './oidc'; import loadOidcValues from './oidc';
@ -38,7 +38,7 @@ const throwNotLoadedError = () => {
/* eslint-disable @silverhand/fp/no-let, @silverhand/fp/no-mutation */ /* eslint-disable @silverhand/fp/no-let, @silverhand/fp/no-mutation */
function createEnvSet() { function createEnvSet() {
let values: Optional<Awaited<ReturnType<typeof loadEnvValues>>>; let values: Optional<Awaited<ReturnType<typeof loadEnvValues>>>;
let pool: Optional<DatabasePoolType>; let pool: Optional<DatabasePool>;
return { return {
get values() { get values() {

View file

@ -1,10 +1,10 @@
declare module 'slonik-interceptor-preset' { declare module 'slonik-interceptor-preset' {
import { InterceptorType } from 'slonik'; import { Interceptor } from 'slonik';
export const createInterceptors: (config?: { export const createInterceptors: (config?: {
benchmarkQueries: boolean; benchmarkQueries: boolean;
logQueries: boolean; logQueries: boolean;
normaliseQueries: boolean; normaliseQueries: boolean;
transformFieldNames: boolean; transformFieldNames: boolean;
}) => readonly InterceptorType[]; }) => readonly Interceptor[];
} }

View file

@ -1,5 +1,5 @@
import { Connectors, ConnectorType, CreateConnector } from '@logto/schemas'; import { Connectors, ConnectorType, CreateConnector } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql, QueryResultRowType } from 'slonik'; import { createMockPool, createMockQueryResult, sql, QueryResultRow } from 'slonik';
import { convertToIdentifiers } from '@/database/utils'; import { convertToIdentifiers } from '@/database/utils';
import envSet from '@/env-set'; import envSet from '@/env-set';
@ -64,7 +64,7 @@ describe('connector queries', () => {
}); });
it('insertConnector', async () => { it('insertConnector', async () => {
const connector: CreateConnector & QueryResultRowType = { const connector: CreateConnector & QueryResultRow = {
id: 'foo', id: 'foo',
type: ConnectorType.Social, type: ConnectorType.Social,
enabled: true, enabled: true,

View file

@ -5,7 +5,7 @@ import {
OidcModelInstances, OidcModelInstances,
} from '@logto/schemas'; } from '@logto/schemas';
import { conditional } from '@silverhand/essentials'; import { conditional } from '@silverhand/essentials';
import { sql, ValueExpressionType } from 'slonik'; import { sql, ValueExpression } from 'slonik';
import { buildInsertInto } from '@/database/insert-into'; import { buildInsertInto } from '@/database/insert-into';
import { convertToIdentifiers, convertToTimestamp } from '@/database/utils'; import { convertToIdentifiers, convertToTimestamp } from '@/database/utils';
@ -49,7 +49,7 @@ export const findPayloadById = async (modelName: string, id: string) => {
}; };
export const findPayloadByPayloadField = async < export const findPayloadByPayloadField = async <
T extends ValueExpressionType, T extends ValueExpression,
Field extends keyof OidcModelInstancePayload Field extends keyof OidcModelInstancePayload
>( >(
modelName: string, modelName: string,

View file

@ -2,8 +2,8 @@ import { createMockContext, Options } from '@shopify/jest-koa-mocks';
import Koa, { MiddlewareType, Context, Middleware } from 'koa'; import Koa, { MiddlewareType, Context, Middleware } from 'koa';
import Router, { IRouterParamContext } from 'koa-router'; import Router, { IRouterParamContext } from 'koa-router';
import { Provider } from 'oidc-provider'; import { Provider } from 'oidc-provider';
import { createMockPool, createMockQueryResult, QueryResultType, QueryResultRowType } from 'slonik'; import { createMockPool, createMockQueryResult, QueryResult, QueryResultRow } from 'slonik';
import { PrimitiveValueExpressionType } from 'slonik/dist/src/types.d'; import { PrimitiveValueExpression } from 'slonik/dist/src/types.d';
import request from 'supertest'; import request from 'supertest';
import { AuthedRouter, AnonymousRouter } from '@/routes/types'; import { AuthedRouter, AnonymousRouter } from '@/routes/types';
@ -27,12 +27,12 @@ export const expectSqlAssert = (sql: string, expectSql: string) => {
export type QueryType = ( export type QueryType = (
sql: string, sql: string,
values: readonly PrimitiveValueExpressionType[] values: readonly PrimitiveValueExpression[]
) => Promise<QueryResultType<QueryResultRowType>>; ) => Promise<QueryResult<QueryResultRow>>;
export const createTestPool = <T extends QueryResultRowType>( export const createTestPool = <T extends QueryResultRow>(
expectSql?: string, expectSql?: string,
returning?: T | ((sql: string, values: readonly PrimitiveValueExpressionType[]) => T) returning?: T | ((sql: string, values: readonly PrimitiveValueExpression[]) => T)
) => ) =>
createMockPool({ createMockPool({
query: async (sql, values) => { query: async (sql, values) => {

View file

@ -203,7 +203,7 @@ importers:
p-retry: ^4.6.1 p-retry: ^4.6.1
prettier: ^2.3.2 prettier: ^2.3.2
query-string: ^7.0.1 query-string: ^7.0.1
slonik: ^23.8.3 slonik: ^28.0.0
slonik-interceptor-preset: ^1.2.10 slonik-interceptor-preset: ^1.2.10
snake-case: ^3.0.4 snake-case: ^3.0.4
snakecase-keys: ^5.1.0 snakecase-keys: ^5.1.0
@ -237,7 +237,7 @@ importers:
oidc-provider: 7.10.4 oidc-provider: 7.10.4
p-retry: 4.6.1 p-retry: 4.6.1
query-string: 7.0.1 query-string: 7.0.1
slonik: 23.9.0 slonik: 28.1.0
slonik-interceptor-preset: 1.2.10 slonik-interceptor-preset: 1.2.10
snakecase-keys: 5.1.2 snakecase-keys: 5.1.2
zod: 3.14.3 zod: 3.14.3
@ -6822,6 +6822,7 @@ packages:
/asap/2.0.6: /asap/2.0.6:
resolution: {integrity: sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=} resolution: {integrity: sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=}
dev: true
/asn1/0.2.6: /asn1/0.2.6:
resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==} resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==}
@ -8653,11 +8654,6 @@ packages:
engines: {node: '>=6'} engines: {node: '>=6'}
dev: false dev: false
/delay/5.0.0:
resolution: {integrity: sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==}
engines: {node: '>=10'}
dev: false
/delayed-stream/1.0.0: /delayed-stream/1.0.0:
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
engines: {node: '>=0.4.0'} engines: {node: '>=0.4.0'}
@ -11278,9 +11274,11 @@ packages:
ci-info: 2.0.0 ci-info: 2.0.0
dev: true dev: true
/is-circular/1.0.2: /is-core-module/2.8.0:
resolution: {integrity: sha512-YttjnrswnUYRVJvxCvu8z+PGMUSzC2JttP0OEXezlAEdp3EXzhf7IZ3j0gRAybJBQupedIZFhY61Tga6E0qASA==} resolution: {integrity: sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==}
dev: false dependencies:
has: 1.0.3
dev: true
/is-core-module/2.8.1: /is-core-module/2.8.1:
resolution: {integrity: sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==} resolution: {integrity: sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==}
@ -14840,14 +14838,6 @@ packages:
obuf: 1.1.2 obuf: 1.1.2
dev: false dev: false
/pg-cursor/2.7.1_pg@8.7.1:
resolution: {integrity: sha512-dtxtyvx4BcSammddki27KPBVA0sZ8AguLabgs7++gqaefX7dlQ5zaRlk1Gi5mvyO25aCmHFAZyNq9zYtPDwFTA==}
peerDependencies:
pg: ^8
dependencies:
pg: 8.7.1
dev: false
/pg-cursor/2.7.3_pg@8.7.3: /pg-cursor/2.7.3_pg@8.7.3:
resolution: {integrity: sha512-vmjXRMD4jZK/oHaaYk6clTypgHNlzCCAqyLCO5d/UeI42egJVE5H4ZfZWACub3jzkHUXXyvibH207zAJg9iBOw==} resolution: {integrity: sha512-vmjXRMD4jZK/oHaaYk6clTypgHNlzCCAqyLCO5d/UeI42egJVE5H4ZfZWACub3jzkHUXXyvibH207zAJg9iBOw==}
peerDependencies: peerDependencies:
@ -14874,14 +14864,6 @@ packages:
engines: {node: '>=4'} engines: {node: '>=4'}
dev: false dev: false
/pg-pool/3.4.1_pg@8.7.1:
resolution: {integrity: sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ==}
peerDependencies:
pg: '>=8.0'
dependencies:
pg: 8.7.1
dev: false
/pg-pool/3.5.1_pg@8.7.3: /pg-pool/3.5.1_pg@8.7.3:
resolution: {integrity: sha512-6iCR0wVrro6OOHFsyavV+i6KYL4lVNyYAB9RD18w66xSzN+d8b66HiwuP30Gp1SH5O9T82fckkzsRjlrhD0ioQ==} resolution: {integrity: sha512-6iCR0wVrro6OOHFsyavV+i6KYL4lVNyYAB9RD18w66xSzN+d8b66HiwuP30Gp1SH5O9T82fckkzsRjlrhD0ioQ==}
peerDependencies: peerDependencies:
@ -14917,24 +14899,6 @@ packages:
postgres-interval: 1.2.0 postgres-interval: 1.2.0
dev: false dev: false
/pg/8.7.1:
resolution: {integrity: sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA==}
engines: {node: '>= 8.0.0'}
peerDependencies:
pg-native: '>=2.0.0'
peerDependenciesMeta:
pg-native:
optional: true
dependencies:
buffer-writer: 2.0.0
packet-reader: 1.0.0
pg-connection-string: 2.5.0
pg-pool: 3.4.1_pg@8.7.1
pg-protocol: 1.5.0
pg-types: 2.2.0
pgpass: 1.0.4
dev: false
/pg/8.7.3: /pg/8.7.3:
resolution: {integrity: sha512-HPmH4GH4H3AOprDJOazoIcpI49XFsHCe8xlrjHkWiapdbHK+HLtbm/GQzXYAZwmPju/kzKhjaSfMACG+8cgJcw==} resolution: {integrity: sha512-HPmH4GH4H3AOprDJOazoIcpI49XFsHCe8xlrjHkWiapdbHK+HLtbm/GQzXYAZwmPju/kzKhjaSfMACG+8cgJcw==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
@ -15908,11 +15872,6 @@ packages:
engines: {node: '>=8'} engines: {node: '>=8'}
dev: false dev: false
/postgres-interval/3.0.0:
resolution: {integrity: sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==}
engines: {node: '>=12'}
dev: false
/postgres-interval/4.0.0: /postgres-interval/4.0.0:
resolution: {integrity: sha512-OWeL7kyEKJiY7mCmVY+c7/6uhAlt/colA/Nl/Mgls/M3jssrQzFra04iNWnD/qAmG7TsCSgWAASCyiaoBOP/sg==} resolution: {integrity: sha512-OWeL7kyEKJiY7mCmVY+c7/6uhAlt/colA/Nl/Mgls/M3jssrQzFra04iNWnD/qAmG7TsCSgWAASCyiaoBOP/sg==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -16032,13 +15991,6 @@ packages:
engines: {node: '>= 0.6.0'} engines: {node: '>= 0.6.0'}
dev: true dev: true
/promise-deferred/2.0.3:
resolution: {integrity: sha512-n10XaoznCzLfyPFOlEE8iurezHpxrYzyjgq/1eW9Wk1gJwur/N7BdBmjJYJpqMeMcXK4wEbzo2EvZQcqjYcKUQ==}
engines: {node: '>= 0.4'}
dependencies:
promise: 7.3.1
dev: false
/promise-inflight/1.0.1: /promise-inflight/1.0.1:
resolution: {integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=} resolution: {integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=}
dev: true dev: true
@ -16055,6 +16007,7 @@ packages:
resolution: {integrity: sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==} resolution: {integrity: sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==}
dependencies: dependencies:
asap: 2.0.6 asap: 2.0.6
dev: true
/prompts/2.4.2: /prompts/2.4.2:
resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==}
@ -17227,19 +17180,6 @@ packages:
semver-compare: 1.0.0 semver-compare: 1.0.0
dev: false dev: false
/roarr/7.8.0:
resolution: {integrity: sha512-BKPYQkqzoOsKeaJEkx0WWW4hh/SSxOyRqhjnL6SSypMHV3ZmINkKyGIDRvinB4AMXfKBUGiy1J7qtl6teIC5tQ==}
engines: {node: '>=12.0'}
dependencies:
boolean: 3.1.4
fast-json-stringify: 2.7.12
fast-printf: 1.6.9
globalthis: 1.0.2
is-circular: 1.0.2
json-stringify-safe: 5.0.1
semver-compare: 1.0.0
dev: false
/rtl-detect/1.0.4: /rtl-detect/1.0.4:
resolution: {integrity: sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==} resolution: {integrity: sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==}
dev: true dev: true
@ -17724,32 +17664,6 @@ packages:
- pg-native - pg-native
dev: false dev: false
/slonik/23.9.0:
resolution: {integrity: sha512-TETKgFVAy3TcXKTvf7YlUtlMzSCdz7VmGUng5z+i5SfiRNW9SUqGsHmPdead5JAAZbI+eu6vBQXQtXzW6pN9gA==}
engines: {node: '>=10.0'}
dependencies:
concat-stream: 2.0.0
delay: 5.0.0
es6-error: 4.1.1
get-stack-trace: 2.1.1
hyperid: 2.3.1
is-plain-object: 5.0.0
iso8601-duration: 1.3.0
pg: 8.7.1
pg-connection-string: 2.5.0
pg-copy-streams: 5.1.1
pg-copy-streams-binary: 2.2.0
pg-cursor: 2.7.1_pg@8.7.1
postgres-array: 3.0.1
postgres-interval: 3.0.0
promise-deferred: 2.0.3
roarr: 7.8.0
serialize-error: 8.1.0
through2: 4.0.2
transitivePeerDependencies:
- pg-native
dev: false
/slonik/28.1.0: /slonik/28.1.0:
resolution: {integrity: sha512-0VpQXQv+2Nkf30FHMjMC9oeuzMtr7098m7kMSpPi9EWtclPIxluG3jjWREg5tYrXsjCRwWTEwUKhyUyzq/N1mw==} resolution: {integrity: sha512-0VpQXQv+2Nkf30FHMjMC9oeuzMtr7098m7kMSpPi9EWtclPIxluG3jjWREg5tYrXsjCRwWTEwUKhyUyzq/N1mw==}
engines: {node: '>=10.0'} engines: {node: '>=10.0'}