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:
parent
2d7918a224
commit
25814d92ef
10 changed files with 35 additions and 123 deletions
|
@ -44,7 +44,7 @@
|
|||
"oidc-provider": "^7.10.0",
|
||||
"p-retry": "^4.6.1",
|
||||
"query-string": "^7.0.1",
|
||||
"slonik": "^23.8.3",
|
||||
"slonik": "^28.0.0",
|
||||
"slonik-interceptor-preset": "^1.2.10",
|
||||
"snakecase-keys": "^5.1.0",
|
||||
"zod": "^3.14.3"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SchemaLike, GeneratedSchema } from '@logto/schemas';
|
||||
import { has } from '@silverhand/essentials';
|
||||
import { IdentifierSqlTokenType, sql } from 'slonik';
|
||||
import { IdentifierSqlToken, sql } from 'slonik';
|
||||
|
||||
import envSet from '@/env-set';
|
||||
import { InsertionError } from '@/errors/SlonikError';
|
||||
|
@ -14,15 +14,15 @@ import {
|
|||
OmitAutoSetFields,
|
||||
} from './utils';
|
||||
|
||||
const setExcluded = (...fields: IdentifierSqlTokenType[]) =>
|
||||
const setExcluded = (...fields: IdentifierSqlToken[]) =>
|
||||
sql.join(
|
||||
fields.map((field) => sql`${field}=excluded.${field}`),
|
||||
sql`, `
|
||||
);
|
||||
|
||||
type OnConflict = {
|
||||
fields: IdentifierSqlTokenType[];
|
||||
setExcludedFields: IdentifierSqlTokenType[];
|
||||
fields: IdentifierSqlToken[];
|
||||
setExcludedFields: IdentifierSqlToken[];
|
||||
};
|
||||
|
||||
type InsertIntoConfigReturning = {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { SchemaLike } from '@logto/schemas';
|
||||
import { IdentifierSqlTokenType } from 'slonik';
|
||||
import { IdentifierSqlToken } from 'slonik';
|
||||
|
||||
export type Table = { table: string; fields: Record<string, string> };
|
||||
export type FieldIdentifiers<Key extends string | number | symbol> = {
|
||||
[key in Key]: IdentifierSqlTokenType;
|
||||
[key in Key]: IdentifierSqlToken;
|
||||
};
|
||||
|
||||
export type OrderDirection = 'asc' | 'desc';
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import { SchemaValuePrimitive, SchemaValue } from '@logto/schemas';
|
||||
import { Falsy, notFalsy } from '@silverhand/essentials';
|
||||
import dayjs from 'dayjs';
|
||||
import { sql, SqlSqlTokenType, SqlTokenType, IdentifierSqlTokenType } from 'slonik';
|
||||
import { sql, SqlSqlToken, SqlToken, IdentifierSqlToken } from 'slonik';
|
||||
|
||||
import envSet from '@/env-set';
|
||||
|
||||
import { FieldIdentifiers, Table } from './types';
|
||||
|
||||
export const conditionalSql = <T>(
|
||||
value: T,
|
||||
buildSql: (value: Exclude<T, Falsy>) => SqlSqlTokenType
|
||||
) => (notFalsy(value) ? buildSql(value) : sql``);
|
||||
export const conditionalSql = <T>(value: T, buildSql: (value: Exclude<T, Falsy>) => SqlSqlToken) =>
|
||||
notFalsy(value) ? buildSql(value) : sql``;
|
||||
|
||||
export const autoSetFields = Object.freeze(['createdAt', 'updatedAt'] as const);
|
||||
export type OmitAutoSetFields<T> = Omit<T, typeof autoSetFields[number]>;
|
||||
|
@ -36,7 +34,7 @@ export const convertToPrimitiveOrSql = (
|
|||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
value: NonNullable<SchemaValue> | null
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
): NonNullable<SchemaValuePrimitive> | SqlTokenType | null => {
|
||||
): NonNullable<SchemaValuePrimitive> | SqlToken | null => {
|
||||
if (value === 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 getTotalRowCount = async (table: IdentifierSqlTokenType) =>
|
||||
export const getTotalRowCount = async (table: IdentifierSqlToken) =>
|
||||
envSet.pool.one<{ count: number }>(sql`
|
||||
select count(*)
|
||||
from ${table}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { getEnv, Optional } from '@silverhand/essentials';
|
||||
import { DatabasePoolType } from 'slonik';
|
||||
import { DatabasePool } from 'slonik';
|
||||
|
||||
import createPoolByEnv from './create-pool-by-env';
|
||||
import loadOidcValues from './oidc';
|
||||
|
@ -38,7 +38,7 @@ const throwNotLoadedError = () => {
|
|||
/* eslint-disable @silverhand/fp/no-let, @silverhand/fp/no-mutation */
|
||||
function createEnvSet() {
|
||||
let values: Optional<Awaited<ReturnType<typeof loadEnvValues>>>;
|
||||
let pool: Optional<DatabasePoolType>;
|
||||
let pool: Optional<DatabasePool>;
|
||||
|
||||
return {
|
||||
get values() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
declare module 'slonik-interceptor-preset' {
|
||||
import { InterceptorType } from 'slonik';
|
||||
import { Interceptor } from 'slonik';
|
||||
|
||||
export const createInterceptors: (config?: {
|
||||
benchmarkQueries: boolean;
|
||||
logQueries: boolean;
|
||||
normaliseQueries: boolean;
|
||||
transformFieldNames: boolean;
|
||||
}) => readonly InterceptorType[];
|
||||
}) => readonly Interceptor[];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 envSet from '@/env-set';
|
||||
|
@ -64,7 +64,7 @@ describe('connector queries', () => {
|
|||
});
|
||||
|
||||
it('insertConnector', async () => {
|
||||
const connector: CreateConnector & QueryResultRowType = {
|
||||
const connector: CreateConnector & QueryResultRow = {
|
||||
id: 'foo',
|
||||
type: ConnectorType.Social,
|
||||
enabled: true,
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
OidcModelInstances,
|
||||
} from '@logto/schemas';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import { sql, ValueExpressionType } from 'slonik';
|
||||
import { sql, ValueExpression } from 'slonik';
|
||||
|
||||
import { buildInsertInto } from '@/database/insert-into';
|
||||
import { convertToIdentifiers, convertToTimestamp } from '@/database/utils';
|
||||
|
@ -49,7 +49,7 @@ export const findPayloadById = async (modelName: string, id: string) => {
|
|||
};
|
||||
|
||||
export const findPayloadByPayloadField = async <
|
||||
T extends ValueExpressionType,
|
||||
T extends ValueExpression,
|
||||
Field extends keyof OidcModelInstancePayload
|
||||
>(
|
||||
modelName: string,
|
||||
|
|
|
@ -2,8 +2,8 @@ import { createMockContext, Options } from '@shopify/jest-koa-mocks';
|
|||
import Koa, { MiddlewareType, Context, Middleware } from 'koa';
|
||||
import Router, { IRouterParamContext } from 'koa-router';
|
||||
import { Provider } from 'oidc-provider';
|
||||
import { createMockPool, createMockQueryResult, QueryResultType, QueryResultRowType } from 'slonik';
|
||||
import { PrimitiveValueExpressionType } from 'slonik/dist/src/types.d';
|
||||
import { createMockPool, createMockQueryResult, QueryResult, QueryResultRow } from 'slonik';
|
||||
import { PrimitiveValueExpression } from 'slonik/dist/src/types.d';
|
||||
import request from 'supertest';
|
||||
|
||||
import { AuthedRouter, AnonymousRouter } from '@/routes/types';
|
||||
|
@ -27,12 +27,12 @@ export const expectSqlAssert = (sql: string, expectSql: string) => {
|
|||
|
||||
export type QueryType = (
|
||||
sql: string,
|
||||
values: readonly PrimitiveValueExpressionType[]
|
||||
) => Promise<QueryResultType<QueryResultRowType>>;
|
||||
values: readonly PrimitiveValueExpression[]
|
||||
) => Promise<QueryResult<QueryResultRow>>;
|
||||
|
||||
export const createTestPool = <T extends QueryResultRowType>(
|
||||
export const createTestPool = <T extends QueryResultRow>(
|
||||
expectSql?: string,
|
||||
returning?: T | ((sql: string, values: readonly PrimitiveValueExpressionType[]) => T)
|
||||
returning?: T | ((sql: string, values: readonly PrimitiveValueExpression[]) => T)
|
||||
) =>
|
||||
createMockPool({
|
||||
query: async (sql, values) => {
|
||||
|
|
104
pnpm-lock.yaml
104
pnpm-lock.yaml
|
@ -203,7 +203,7 @@ importers:
|
|||
p-retry: ^4.6.1
|
||||
prettier: ^2.3.2
|
||||
query-string: ^7.0.1
|
||||
slonik: ^23.8.3
|
||||
slonik: ^28.0.0
|
||||
slonik-interceptor-preset: ^1.2.10
|
||||
snake-case: ^3.0.4
|
||||
snakecase-keys: ^5.1.0
|
||||
|
@ -237,7 +237,7 @@ importers:
|
|||
oidc-provider: 7.10.4
|
||||
p-retry: 4.6.1
|
||||
query-string: 7.0.1
|
||||
slonik: 23.9.0
|
||||
slonik: 28.1.0
|
||||
slonik-interceptor-preset: 1.2.10
|
||||
snakecase-keys: 5.1.2
|
||||
zod: 3.14.3
|
||||
|
@ -6822,6 +6822,7 @@ packages:
|
|||
|
||||
/asap/2.0.6:
|
||||
resolution: {integrity: sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=}
|
||||
dev: true
|
||||
|
||||
/asn1/0.2.6:
|
||||
resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==}
|
||||
|
@ -8653,11 +8654,6 @@ packages:
|
|||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/delay/5.0.0:
|
||||
resolution: {integrity: sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==}
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/delayed-stream/1.0.0:
|
||||
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
@ -11278,9 +11274,11 @@ packages:
|
|||
ci-info: 2.0.0
|
||||
dev: true
|
||||
|
||||
/is-circular/1.0.2:
|
||||
resolution: {integrity: sha512-YttjnrswnUYRVJvxCvu8z+PGMUSzC2JttP0OEXezlAEdp3EXzhf7IZ3j0gRAybJBQupedIZFhY61Tga6E0qASA==}
|
||||
dev: false
|
||||
/is-core-module/2.8.0:
|
||||
resolution: {integrity: sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==}
|
||||
dependencies:
|
||||
has: 1.0.3
|
||||
dev: true
|
||||
|
||||
/is-core-module/2.8.1:
|
||||
resolution: {integrity: sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==}
|
||||
|
@ -14840,14 +14838,6 @@ packages:
|
|||
obuf: 1.1.2
|
||||
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:
|
||||
resolution: {integrity: sha512-vmjXRMD4jZK/oHaaYk6clTypgHNlzCCAqyLCO5d/UeI42egJVE5H4ZfZWACub3jzkHUXXyvibH207zAJg9iBOw==}
|
||||
peerDependencies:
|
||||
|
@ -14874,14 +14864,6 @@ packages:
|
|||
engines: {node: '>=4'}
|
||||
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:
|
||||
resolution: {integrity: sha512-6iCR0wVrro6OOHFsyavV+i6KYL4lVNyYAB9RD18w66xSzN+d8b66HiwuP30Gp1SH5O9T82fckkzsRjlrhD0ioQ==}
|
||||
peerDependencies:
|
||||
|
@ -14917,24 +14899,6 @@ packages:
|
|||
postgres-interval: 1.2.0
|
||||
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:
|
||||
resolution: {integrity: sha512-HPmH4GH4H3AOprDJOazoIcpI49XFsHCe8xlrjHkWiapdbHK+HLtbm/GQzXYAZwmPju/kzKhjaSfMACG+8cgJcw==}
|
||||
engines: {node: '>= 8.0.0'}
|
||||
|
@ -15908,11 +15872,6 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/postgres-interval/3.0.0:
|
||||
resolution: {integrity: sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/postgres-interval/4.0.0:
|
||||
resolution: {integrity: sha512-OWeL7kyEKJiY7mCmVY+c7/6uhAlt/colA/Nl/Mgls/M3jssrQzFra04iNWnD/qAmG7TsCSgWAASCyiaoBOP/sg==}
|
||||
engines: {node: '>=12'}
|
||||
|
@ -16032,13 +15991,6 @@ packages:
|
|||
engines: {node: '>= 0.6.0'}
|
||||
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:
|
||||
resolution: {integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=}
|
||||
dev: true
|
||||
|
@ -16055,6 +16007,7 @@ packages:
|
|||
resolution: {integrity: sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==}
|
||||
dependencies:
|
||||
asap: 2.0.6
|
||||
dev: true
|
||||
|
||||
/prompts/2.4.2:
|
||||
resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==}
|
||||
|
@ -17227,19 +17180,6 @@ packages:
|
|||
semver-compare: 1.0.0
|
||||
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:
|
||||
resolution: {integrity: sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==}
|
||||
dev: true
|
||||
|
@ -17724,32 +17664,6 @@ packages:
|
|||
- pg-native
|
||||
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:
|
||||
resolution: {integrity: sha512-0VpQXQv+2Nkf30FHMjMC9oeuzMtr7098m7kMSpPi9EWtclPIxluG3jjWREg5tYrXsjCRwWTEwUKhyUyzq/N1mw==}
|
||||
engines: {node: '>=10.0'}
|
||||
|
|
Loading…
Reference in a new issue