0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor: use silverhand slonik

This commit is contained in:
Gao Sun 2024-03-16 19:04:55 +08:00
parent 54c2b1d1e3
commit fbbe767867
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
211 changed files with 395 additions and 281 deletions

View file

@ -65,7 +65,7 @@
"pg-protocol": "^1.6.0",
"roarr": "^7.11.0",
"semver": "^7.3.8",
"slonik": "30.4.0",
"@silverhand/slonik": "31.0.0-beta.0",
"slonik-interceptor-preset": "^1.2.10",
"slonik-sql-tag-raw": "^1.1.4",
"tar": "^6.1.11",

View file

@ -1,6 +1,6 @@
import { createMockUtils } from '@logto/shared/esm';
import { createMockPool } from '@silverhand/slonik';
import Sinon from 'sinon';
import { createMockPool } from 'slonik';
import { chooseAlterationsByVersion } from './version.js';

View file

@ -1,7 +1,7 @@
import type { AlterationScript } from '@logto/schemas/lib/types/alteration.js';
import { conditionalString } from '@silverhand/essentials';
import type { DatabasePool } from '@silverhand/slonik';
import chalk from 'chalk';
import type { DatabasePool } from 'slonik';
import type { CommandModule } from 'yargs';
import { createPoolFromConfig } from '../../../database.js';

View file

@ -9,8 +9,8 @@ import {
} from '@logto/schemas';
import { GlobalValues } from '@logto/shared';
import { appendPath } from '@silverhand/essentials';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { insertInto } from '../../../database.js';
import { consoleLog } from '../../../utils.js';

View file

@ -1,4 +1,4 @@
import type { DatabasePool } from 'slonik';
import type { DatabasePool } from '@silverhand/slonik';
import type { CommandModule } from 'yargs';
import { createPoolAndDatabaseIfNeeded } from '../../../database.js';

View file

@ -4,8 +4,8 @@ import type { LogtoOidcConfigType } from '@logto/schemas';
import { LogtoOidcConfigKey, logtoConfigGuards } from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import { getEnvAsStringArray } from '@silverhand/essentials';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import chalk from 'chalk';
import type { DatabaseTransactionConnection } from 'slonik';
import { z } from 'zod';
import { getRowsByKeys, updateValueByKey } from '../../../queries/logto-config.js';

View file

@ -29,8 +29,8 @@ import {
import { getTenantRole } from '@logto/schemas';
import { Tenants } from '@logto/schemas/models';
import { generateStandardId } from '@logto/shared';
import type { DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { raw } from 'slonik-sql-tag-raw';
import { insertInto } from '../../../database.js';

View file

@ -12,7 +12,7 @@ import {
getTenantOrganizationCreateData,
Organizations,
} from '@logto/schemas';
import type { DatabaseTransactionConnection } from 'slonik';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import { insertInto } from '../../../database.js';
import { consoleLog } from '../../../utils.js';

View file

@ -17,8 +17,8 @@ import {
} from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import { assert } from '@silverhand/essentials';
import type { CommonQueryMethods, DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods, DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { raw } from 'slonik-sql-tag-raw';
import { insertInto } from '../../../database.js';

View file

@ -1,8 +1,8 @@
import type { SchemaLike } from '@logto/schemas';
import { assert } from '@silverhand/essentials';
import { createPool, parseDsn, sql, stringifyDsn } from '@silverhand/slonik';
import decamelize from 'decamelize';
import { DatabaseError } from 'pg-protocol';
import { createPool, parseDsn, sql, stringifyDsn } from 'slonik';
import { createInterceptors } from 'slonik-interceptor-preset';
import { convertToPrimitiveOrSql } from './sql.js';

View file

@ -1,5 +1,5 @@
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
export const getDatabaseName = async (pool: CommonQueryMethods, normalized = false) => {
const { currentDatabase } = await pool.one<{ currentDatabase: string }>(sql`

View file

@ -1,8 +1,8 @@
import type { LogtoConfig, LogtoConfigKey, logtoConfigGuards } from '@logto/schemas';
import { LogtoConfigs } from '@logto/schemas';
import type { Nullable } from '@silverhand/essentials';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { z } from 'zod';
import { convertToIdentifiers } from '../sql.js';

View file

@ -1,6 +1,6 @@
import { AlterationStateKey, Systems } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { DatabaseError } from 'pg-protocol';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { convertToIdentifiers } from '../sql.js';
import type { QueryType } from '../test-utils.js';

View file

@ -1,9 +1,9 @@
import type { AlterationState, System, SystemKey } from '@logto/schemas';
import { systemGuards, Systems, AlterationStateKey } from '@logto/schemas';
import type { Nullable } from '@silverhand/essentials';
import type { CommonQueryMethods, DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { DatabaseError } from 'pg-protocol';
import type { CommonQueryMethods, DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { z } from 'zod';
import { convertToIdentifiers } from '../sql.js';

View file

@ -8,7 +8,7 @@
*/
import { type SchemaValue, type SchemaValuePrimitive, type Table } from '@logto/shared';
import { type IdentifierSqlToken, type SqlToken, sql } from 'slonik';
import { type IdentifierSqlToken, type SqlToken, sql } from '@silverhand/slonik';
/**
* Note `undefined` is removed from the acceptable list,

View file

@ -1,7 +1,7 @@
// Copied from core
import type { QueryResult, QueryResultRow } from 'slonik';
import type { PrimitiveValueExpression } from 'slonik/dist/src/types.js';
import type { QueryResult, QueryResultRow } from '@silverhand/slonik';
import type { PrimitiveValueExpression } from '@silverhand/slonik/dist/src/types.js';
export type QueryType = (
sql: string,

View file

@ -85,7 +85,7 @@
"roarr": "^7.11.0",
"samlify": "2.8.10",
"semver": "^7.3.8",
"slonik": "30.4.0",
"@silverhand/slonik": "31.0.0-beta.0",
"slonik-interceptor-preset": "^1.2.10",
"slonik-sql-tag-raw": "^1.1.4",
"snake-case": "^3.0.4",

View file

@ -1,4 +1,4 @@
import { type CommonQueryMethods, sql } from 'slonik';
import { type CommonQueryMethods, sql } from '@silverhand/slonik';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,5 +1,5 @@
import { type GeneratedSchema, type SchemaLike } from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { conditionalSql, convertToIdentifiers, manyRows } from '#src/utils/sql.js';

View file

@ -1,6 +1,6 @@
import type { SchemaLike, GeneratedSchema } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql, NotFoundError } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql, NotFoundError } from '@silverhand/slonik';
import RequestError from '#src/errors/RequestError/index.js';
import assertThat from '#src/utils/assert-that.js';

View file

@ -1,7 +1,7 @@
import type { GeneratedSchema, SchemaLike } from '@logto/schemas';
import { has } from '@silverhand/essentials';
import type { CommonQueryMethods, IdentifierSqlToken } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods, IdentifierSqlToken } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { InsertionError } from '#src/errors/SlonikError/index.js';
import assertThat from '#src/utils/assert-that.js';

View file

@ -1,7 +1,7 @@
import { type GeneratedSchema } from '@logto/schemas';
import { type SchemaLike } from '@logto/shared';
import type { CommonQueryMethods, IdentifierSqlToken } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods, IdentifierSqlToken } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { type SearchOptions, buildSearchSql } from './utils.js';

View file

@ -2,8 +2,8 @@ import type { SchemaLike, GeneratedSchema, SchemaValue } from '@logto/schemas';
import type { UpdateWhereData } from '@logto/shared';
import type { Truthy } from '@silverhand/essentials';
import { notFalsy } from '@silverhand/essentials';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { UpdateError } from '#src/errors/SlonikError/index.js';
import assertThat from '#src/utils/assert-that.js';

View file

@ -1,6 +1,6 @@
import { type GeneratedSchema } from '@logto/schemas';
import { type SchemaLike, type Table } from '@logto/shared';
import { type SqlSqlToken, sql } from 'slonik';
import { type SqlSqlToken, sql } from '@silverhand/slonik';
import { conditionalSql, convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,6 +1,6 @@
import { getAvailableAlterations } from '@logto/cli/lib/commands/database/alteration/index.js';
import type { DatabasePool } from '@silverhand/slonik';
import chalk from 'chalk';
import type { DatabasePool } from 'slonik';
import { consoleLog } from '#src/utils/console.js';

View file

@ -1,5 +1,5 @@
import { assert } from '@silverhand/essentials';
import { createMockPool, createMockQueryResult, createPool, parseDsn } from 'slonik';
import { createMockPool, createMockQueryResult, createPool, parseDsn } from '@silverhand/slonik';
import { createInterceptors } from 'slonik-interceptor-preset';
const createPoolByEnv = async (

View file

@ -1,7 +1,7 @@
import { GlobalValues } from '@logto/shared';
import type { Optional } from '@silverhand/essentials';
import { appendPath } from '@silverhand/essentials';
import type { DatabasePool } from 'slonik';
import type { DatabasePool } from '@silverhand/slonik';
import { createLogtoConfigLibrary } from '#src/libraries/logto-config.js';
import { createLogtoConfigQueries } from '#src/queries/logto-config.js';

View file

@ -1,6 +1,6 @@
import type { SchemaLike, GeneratedSchema } from '@logto/schemas';
import type { UpdateWhereData } from '@logto/shared';
import { SlonikError } from 'slonik';
import { SlonikError } from '@silverhand/slonik';
import { type OmitAutoSetFields } from '#src/utils/sql.js';

View file

@ -1,4 +1,4 @@
import { SlonikError } from 'slonik';
import { SlonikError } from '@silverhand/slonik';
import { DeletionError } from './index.js';

View file

@ -1,5 +1,5 @@
declare module 'slonik-interceptor-preset' {
import type { Interceptor } from 'slonik';
import type { Interceptor } from '@silverhand/slonik';
export const createInterceptors: (config?: {
benchmarkQueries: boolean;

View file

@ -8,8 +8,8 @@ import {
LogtoConfigs,
} from '@logto/schemas';
import { appendPath } from '@silverhand/essentials';
import { sql } from '@silverhand/slonik';
import type { JWK } from 'jose';
import { sql } from 'slonik';
import { EnvSet, getTenantEndpoint } from '#src/env-set/index.js';
import { exportJWK } from '#src/utils/jwks.js';

View file

@ -1,5 +1,9 @@
import { Users } from '@logto/schemas';
import { NotFoundError, SlonikError, UniqueIntegrityConstraintViolationError } from 'slonik';
import {
NotFoundError,
SlonikError,
UniqueIntegrityConstraintViolationError,
} from '@silverhand/slonik';
import RequestError from '#src/errors/RequestError/index.js';
import { DeletionError, InsertionError, UpdateError } from '#src/errors/SlonikError/index.js';

View file

@ -1,12 +1,12 @@
import type { SchemaLike } from '@logto/schemas';
import type { Middleware } from 'koa';
import {
SlonikError,
NotFoundError,
InvalidInputError,
CheckIntegrityConstraintViolationError,
UniqueIntegrityConstraintViolationError,
} from 'slonik';
} from '@silverhand/slonik';
import type { Middleware } from 'koa';
import RequestError from '#src/errors/RequestError/index.js';
import { DeletionError, InsertionError, UpdateError } from '#src/errors/SlonikError/index.js';

View file

@ -1,5 +1,5 @@
import { ApplicationSignInExperiences, type ApplicationSignInExperience } from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { buildUpdateWhereWithPool } from '#src/database/update-where.js';

View file

@ -4,7 +4,7 @@ import {
Organizations,
Users,
} from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import RelationQueries from '#src/utils/RelationQueries.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -7,7 +7,7 @@ import {
OrganizationScopes,
Scopes,
} from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,5 +1,5 @@
import { Applications } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { snakeCase } from 'snake-case';
import { mockApplication } from '#src/__mocks__/index.js';

View file

@ -1,7 +1,7 @@
import type { Application, CreateApplication } from '@logto/schemas';
import { ApplicationType, Applications, SearchJointMode } from '@logto/schemas';
import type { CommonQueryMethods, SqlSqlToken } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods, SqlSqlToken } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -1,8 +1,8 @@
import type { ApplicationsRole, CreateApplicationsRole, Role } from '@logto/schemas';
import { Roles, ApplicationsRoles, RolesScopes } from '@logto/schemas';
import { type Nullable } from '@silverhand/essentials';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { DeletionError } from '#src/errors/SlonikError/index.js';
import { convertToIdentifiers, conditionalSql } from '#src/utils/sql.js';

View file

@ -1,5 +1,5 @@
import { Connectors } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { mockConnector } from '#src/__mocks__/index.js';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,7 +1,7 @@
import type { Connector } from '@logto/schemas';
import { Connectors } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { type WellKnownCache } from '#src/caches/well-known.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -1,8 +1,8 @@
import type { CustomPhrase, Translation } from '@logto/schemas';
import { CustomPhrases } from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { type WellKnownCache } from '#src/caches/well-known.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -1,5 +1,5 @@
import { DailyActiveUsers } from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,7 +1,7 @@
import { DailyTokenUsage } from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { getUtcStartOfTheDay } from '#src/oidc/utils.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,6 +1,6 @@
import { type CreateDomain, type Domain, DomainStatus, Domains } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -1,7 +1,7 @@
import type { CreateHook } from '@logto/schemas';
import { Hooks } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildFindAllEntitiesWithPool } from '#src/database/find-all-entities.js';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';

View file

@ -8,9 +8,9 @@ import {
type LogKeyUnknown,
} from '@logto/schemas';
import { conditional, conditionalArray } from '@silverhand/essentials';
import { sql } from '@silverhand/slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { subDays } from 'date-fns';
import { sql } from 'slonik';
import type { CommonQueryMethods } from 'slonik';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -4,7 +4,7 @@ import {
LogtoOidcConfigKey,
LogtoTenantConfigKey,
} from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { convertToIdentifiers } from '#src/utils/sql.js';
import { expectSqlAssert, type QueryType } from '#src/utils/test-utils.js';

View file

@ -9,8 +9,8 @@ import {
type OidcConfigKey,
type LogtoJwtTokenKey,
} from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { type z } from 'zod';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,6 +1,6 @@
import type { CreateOidcModelInstance } from '@logto/schemas';
import { OidcModelInstances } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { convertToIdentifiers } from '#src/utils/sql.js';
import type { QueryType } from '#src/utils/test-utils.js';

View file

@ -2,9 +2,9 @@ import type { OidcModelInstance, OidcModelInstancePayload } from '@logto/schemas
import { OidcModelInstances } from '@logto/schemas';
import type { Nullable } from '@silverhand/essentials';
import { conditional } from '@silverhand/essentials';
import type { CommonQueryMethods, ValueExpression } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { addSeconds, isBefore } from 'date-fns';
import type { CommonQueryMethods, ValueExpression } from 'slonik';
import { sql } from 'slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { convertToIdentifiers, convertToTimestamp } from '#src/utils/sql.js';

View file

@ -18,7 +18,7 @@ import {
OrganizationInvitationRoleRelations,
OrganizationInvitationStatus,
} from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { type SearchOptions, buildSearchSql } from '#src/database/utils.js';
import { TwoRelationsQueries } from '#src/utils/RelationQueries.js';

View file

@ -11,7 +11,7 @@ import {
type FeaturedUser,
type OrganizationScopeEntity,
} from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { type SearchOptions, buildSearchSql, expandFields } from '#src/database/utils.js';
import RelationQueries, {

View file

@ -1,6 +1,6 @@
import { TemplateType } from '@logto/connector-kit';
import { Passcodes } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { snakeCase } from 'snake-case';
import { mockPasscode } from '#src/__mocks__/index.js';

View file

@ -1,8 +1,8 @@
import type { TemplateType } from '@logto/connector-kit';
import type { Passcode, RequestVerificationCodePayload } from '@logto/schemas';
import { Passcodes } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,5 +1,5 @@
import { Resources } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { mockResource } from '#src/__mocks__/index.js';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,7 +1,7 @@
import type { Resource, CreateResource } from '@logto/schemas';
import { Resources } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildFindAllEntitiesWithPool } from '#src/database/find-all-entities.js';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';

View file

@ -1,7 +1,7 @@
import type { CreateRolesScope, RolesScope } from '@logto/schemas';
import { RolesScopes } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { DeletionError } from '#src/errors/SlonikError/index.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,5 +1,5 @@
import { Roles } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import { mockAdminUserRole } from '#src/__mocks__/index.js';
import { DeletionError } from '#src/errors/SlonikError/index.js';

View file

@ -1,7 +1,7 @@
import type { CreateRole, Role, RoleType } from '@logto/schemas';
import { internalRolePrefix, SearchJointMode, Roles } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -1,7 +1,7 @@
import type { CreateScope, Scope } from '@logto/schemas';
import { Resources, Scopes } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';

View file

@ -1,4 +1,4 @@
import { createMockPool, createMockQueryResult } from 'slonik';
import { createMockPool, createMockQueryResult } from '@silverhand/slonik';
import { mockSignInExperience } from '#src/__mocks__/index.js';
import { MockWellKnownCache } from '#src/test-utils/tenant.js';

View file

@ -1,6 +1,6 @@
import type { CreateSignInExperience } from '@logto/schemas';
import { SignInExperiences } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { type WellKnownCache } from '#src/caches/well-known.js';
import { buildFindEntityByIdWithPool } from '#src/database/find-entity-by-id.js';

View file

@ -4,7 +4,7 @@ import {
type SsoConnectorKeys,
SsoConnectors,
} from '@logto/schemas';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import SchemaQueries from '#src/utils/SchemaQueries.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,6 +1,6 @@
import { type SystemKey, Systems } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,5 +1,5 @@
import { Tenants, type TenantModel } from '@logto/schemas/models';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -5,7 +5,7 @@ import {
UserSsoIdentities,
} from '@logto/schemas';
import { type Nullable } from '@silverhand/essentials';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import SchemaQueries from '#src/utils/SchemaQueries.js';
import { manyRows } from '#src/utils/sql.js';

View file

@ -1,6 +1,6 @@
import { Users } from '@logto/schemas';
import { createMockPool, createMockQueryResult, sql } from '@silverhand/slonik';
import Sinon from 'sinon';
import { createMockPool, createMockQueryResult, sql } from 'slonik';
import { mockUser } from '#src/__mocks__/index.js';
import { EnvSet } from '#src/env-set/index.js';

View file

@ -1,8 +1,8 @@
import type { User, CreateUser } from '@logto/schemas';
import { Users } from '@logto/schemas';
import { conditionalArray, pick } from '@silverhand/essentials';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildUpdateWhereWithPool } from '#src/database/update-where.js';
import { EnvSet } from '#src/env-set/index.js';

View file

@ -1,7 +1,7 @@
import type { CreateUsersRole, UsersRole } from '@logto/schemas';
import { UsersRoles } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { DeletionError } from '#src/errors/SlonikError/index.js';
import { conditionalSql, convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,7 +1,7 @@
import type { VerificationStatus } from '@logto/schemas';
import { VerificationStatuses } from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,7 +1,7 @@
import {
ForeignKeyIntegrityConstraintViolationError,
UniqueIntegrityConstraintViolationError,
} from 'slonik';
} from '@silverhand/slonik';
import RequestError from '#src/errors/RequestError/index.js';

View file

@ -10,8 +10,8 @@ import {
} from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import { type Nullable } from '@silverhand/essentials';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import { addMinutes } from 'date-fns';
import { sql, type CommonQueryMethods } from 'slonik';
import { buildInsertIntoWithPool } from '#src/database/insert-into.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

View file

@ -1,4 +1,4 @@
import type { CommonQueryMethods } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { type WellKnownCache } from '#src/caches/well-known.js';
import createApplicationSignInExperienceQueries from '#src/queries/application-sign-in-experience.js';

View file

@ -1,6 +1,6 @@
import { CloudflareKey, StorageProviderKey } from '@logto/schemas';
import { createMockUtils, pickDefault } from '@logto/shared/esm';
import { createMockPool } from 'slonik';
import { createMockPool } from '@silverhand/slonik';
import { mockHostnameProviderData, mockStorageProviderData } from '#src/__mocks__/system.js';

View file

@ -9,7 +9,7 @@ import {
type ProtectedAppConfigProviderData,
protectedAppConfigProviderDataGuard,
} from '@logto/schemas';
import type { CommonQueryMethods } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { type ZodType } from 'zod';
import { createSystemsQuery } from '#src/queries/system.js';

View file

@ -2,8 +2,8 @@ import { ServiceLogs, Systems } from '@logto/schemas';
import { Tenants } from '@logto/schemas/models';
import { isKeyInObject } from '@logto/shared';
import { conditional, conditionalString } from '@silverhand/essentials';
import type { CommonQueryMethods } from 'slonik';
import { parseDsn, sql, stringifyDsn } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { parseDsn, sql, stringifyDsn } from '@silverhand/slonik';
import { z } from 'zod';
import { EnvSet } from '#src/env-set/index.js';

View file

@ -1,6 +1,6 @@
import { type Sentinel } from '@logto/schemas';
import { TtlCache } from '@logto/shared';
import { createMockPool, createMockQueryResult } from 'slonik';
import { createMockPool, createMockQueryResult } from '@silverhand/slonik';
import { WellKnownCache } from '#src/caches/well-known.js';
import type { CloudConnectionLibrary } from '#src/libraries/cloud-connection.js';

View file

@ -1,6 +1,6 @@
import { type Table } from '@logto/shared';
import { type SchemaLike, type Table } from '@logto/shared';
import { type KeysToCamelCase } from '@silverhand/essentials';
import { sql, type CommonQueryMethods } from 'slonik';
import { sql, type CommonQueryMethods } from '@silverhand/slonik';
import snakecaseKeys from 'snakecase-keys';
import { type z } from 'zod';
@ -15,7 +15,7 @@ type TableInfo<
TableName extends string,
TableSingular extends string,
Key extends string,
Schema,
Schema extends SchemaLike<string>,
> = Table<Key, TableName> & {
tableSingular: TableSingular;
guard: z.ZodType<Schema, z.ZodTypeDef, unknown>;
@ -74,7 +74,7 @@ export type GetEntitiesOptions = {
* group with the id `group-id-1`.
*/
export default class RelationQueries<
Schemas extends Array<TableInfo<string, string, string, unknown>>,
Schemas extends Array<TableInfo<string, string, string, SchemaLike<string>>>,
Length = AtLeast2<Schemas>['length'],
> {
protected get table() {
@ -267,8 +267,8 @@ export default class RelationQueries<
* @see {@link RelationQueries} for more information.
*/
export class TwoRelationsQueries<
Schema1 extends TableInfo<string, string, string, unknown>,
Schema2 extends TableInfo<string, string, string, unknown>,
Schema1 extends TableInfo<string, string, string, SchemaLike<string>>,
Schema2 extends TableInfo<string, string, string, SchemaLike<string>>,
> extends RelationQueries<[Schema1, Schema2]> {
/**
* Replace all relations for a specific `Schema1` entity with the given `Schema2` entities.

View file

@ -1,6 +1,6 @@
import { type GeneratedSchema } from '@logto/schemas';
import { type UpdateWhereData, type SchemaLike } from '@logto/shared';
import { type CommonQueryMethods } from 'slonik';
import { type CommonQueryMethods } from '@silverhand/slonik';
import { buildDeleteByIdWithPool } from '#src/database/delete-by-id.js';
import { buildFindAllEntitiesWithPool } from '#src/database/find-all-entities.js';

View file

@ -1,6 +1,6 @@
import { SearchJointMode, SearchMatchMode } from '@logto/schemas';
import type { ListSqlToken, TaggedTemplateLiteralInvocation } from 'slonik';
import { sql } from 'slonik';
import type { ListSqlToken, TaggedTemplateLiteralInvocation } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
// Will add `params` to the exception list

View file

@ -1,7 +1,7 @@
import { SearchJointMode, SearchMatchMode } from '@logto/schemas';
import type { Nullable, Optional } from '@silverhand/essentials';
import { yes, conditionalString, cond } from '@silverhand/essentials';
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import { snakeCase } from 'snake-case';
import { type SearchOptions } from '#src/database/utils.js';

View file

@ -1,6 +1,6 @@
import type { Table } from '@logto/shared';
import { sql } from 'slonik';
import { SqlToken } from 'slonik/dist/src/tokens.js';
import { sql } from '@silverhand/slonik';
import { SqlToken } from '@silverhand/slonik/dist/src/tokens.js';
import {
excludeAutoSetFields,

View file

@ -1,8 +1,8 @@
import type { SchemaValue, SchemaValuePrimitive, Table } from '@logto/shared';
import type { Falsy } from '@silverhand/essentials';
import { notFalsy } from '@silverhand/essentials';
import type { SqlSqlToken, SqlToken, IdentifierSqlToken, QueryResult } from 'slonik';
import { sql } from 'slonik';
import type { SqlSqlToken, SqlToken, IdentifierSqlToken, QueryResult } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
export const conditionalSql = <T>(value: T, buildSql: (value: Exclude<T, Falsy>) => SqlSqlToken) =>
notFalsy(value) ? buildSql(value) : sql``;

View file

@ -1,7 +1,7 @@
import { adminTenantId, defaultTenantId } from '@logto/schemas';
import { type UrlSet } from '@logto/shared';
import { conditionalString, trySafe } from '@silverhand/essentials';
import { type CommonQueryMethods } from 'slonik';
import { type CommonQueryMethods } from '@silverhand/slonik';
import { redisCache } from '#src/caches/index.js';
import { EnvSet, getTenantEndpoint } from '#src/env-set/index.js';

View file

@ -1,13 +1,13 @@
import type { QueryResult, QueryResultRow } from '@silverhand/slonik';
import { createMockPool, createMockQueryResult } from '@silverhand/slonik';
import type {
PrimitiveValueExpression,
TaggedTemplateLiteralInvocation,
} from '@silverhand/slonik/dist/src/types.js';
import type { MiddlewareType, Context, Middleware } from 'koa';
import Koa from 'koa';
import type { IRouterParamContext } from 'koa-router';
import Router from 'koa-router';
import type { QueryResult, QueryResultRow } from 'slonik';
import { createMockPool, createMockQueryResult } from 'slonik';
import type {
PrimitiveValueExpression,
TaggedTemplateLiteralInvocation,
} from 'slonik/dist/src/types.js';
import request from 'supertest';
import type { AuthedRouter, AnonymousRouter } from '#src/routes/types.js';

View file

@ -1,5 +1,5 @@
import type { DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,6 +1,6 @@
import { generateStandardId } from '@logto/shared/universal';
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import { generateStandardId } from '@logto/shared/universal';
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,4 +1,4 @@
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import type { DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,4 +1,4 @@
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import { generateStandardId } from '@logto/shared/universal';
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,4 +1,4 @@
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import type { CommonQueryMethods } from 'slonik';
import { sql } from 'slonik';
import type { CommonQueryMethods } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import type { DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,5 +1,5 @@
import type { DatabaseTransactionConnection } from 'slonik';
import { sql } from 'slonik';
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

View file

@ -1,4 +1,4 @@
import { sql } from 'slonik';
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';

Some files were not shown because too many files have changed in this diff Show more