chore: replace .d.ts type imports with .js imports, as .d.ts imports break usage checks in the IDE

This commit is contained in:
Alessio Gravili
2024-03-07 16:08:49 -05:00
parent b4434a369b
commit 50c7269315
562 changed files with 916 additions and 924 deletions

View File

@@ -7,7 +7,7 @@ import { numeric, timestamp, varchar } from 'drizzle-orm/pg-core'
import { Pool } from 'pg'
import prompts from 'prompts'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
const connectWithReconnect = async function ({
adapter,

View File

@@ -2,7 +2,7 @@ import type { Create } from 'payload/database'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -3,7 +3,7 @@ import type { PayloadRequest, TypeWithID } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -6,7 +6,7 @@ import { sql } from 'drizzle-orm'
import { buildVersionGlobalFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -5,7 +5,7 @@ import type { CreateMigration } from 'payload/database'
import fs from 'fs'
import prompts from 'prompts'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
const migrationTemplate = (
upSQL?: string,

View File

@@ -5,7 +5,7 @@ import { sql } from 'drizzle-orm'
import { buildVersionCollectionFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -4,7 +4,7 @@ import type { PayloadRequest } from 'payload/types'
import { inArray } from 'drizzle-orm'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -3,7 +3,7 @@ import type { PayloadRequest } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { buildFindManyArgs } from './find/buildFindManyArgs.js'
import buildQuery from './queries/buildQuery.js'

View File

@@ -5,7 +5,7 @@ import { inArray } from 'drizzle-orm'
import { buildVersionCollectionFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -1,6 +1,6 @@
import type { Destroy } from 'payload/database'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
export const destroy: Destroy = async function destroy(this: PostgresAdapter) {
// TODO: this hangs test suite for some reason

View File

@@ -3,7 +3,7 @@ import type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -1,7 +1,7 @@
import type { DBQueryConfig } from 'drizzle-orm'
import type { Field } from 'payload/types'
import type { PostgresAdapter } from '../types.d.ts'
import type { PostgresAdapter } from '../types.js'
import { traverseFields } from './traverseFields.js'

View File

@@ -3,8 +3,8 @@ import type { Field, PayloadRequest, TypeWithID } from 'payload/types'
import { inArray, sql } from 'drizzle-orm'
import type { PostgresAdapter } from '../types.d.ts'
import type { ChainedMethods } from './chainMethods.d.ts'
import type { PostgresAdapter } from '../types.js'
import type { ChainedMethods } from './chainMethods.js'
import buildQuery from '../queries/buildQuery.js'
import { transform } from '../transform/read/index.js'

View File

@@ -4,8 +4,8 @@ import type { Field } from 'payload/types'
import { fieldAffectsData, tabHasName } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from '../types.d.ts'
import type { Result } from './buildFindManyArgs.d.ts'
import type { PostgresAdapter } from '../types.js'
import type { Result } from './buildFindManyArgs.js'
type TraverseFieldArgs = {
_locales: Record<string, unknown>

View File

@@ -2,7 +2,7 @@ import type { FindGlobal } from 'payload/database'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -4,7 +4,7 @@ import type { PayloadRequest, SanitizedGlobalConfig } from 'payload/types'
import { buildVersionGlobalFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -3,7 +3,7 @@ import type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payl
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -4,7 +4,7 @@ import type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'
import { buildVersionCollectionFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { findMany } from './find/findMany.js'

View File

@@ -5,7 +5,7 @@ import fs from 'fs'
import path from 'path'
import { createDatabaseAdapter } from 'payload/database'
import type { Args, PostgresAdapter } from './types.d.ts'
import type { Args, PostgresAdapter } from './types.js'
import { connect } from './connect.js'
import { create } from './create.js'
@@ -38,7 +38,7 @@ import { updateGlobal } from './updateGlobal.js'
import { updateGlobalVersion } from './updateGlobalVersion.js'
import { updateVersion } from './updateVersion.js'
export type { MigrateDownArgs, MigrateUpArgs } from './types.d.ts'
export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
export function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {
function adapter({ payload }: { payload: Payload }) {

View File

@@ -6,7 +6,7 @@ import { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'
import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { buildTable } from './schema/build.js'

View File

@@ -11,7 +11,7 @@ import {
} from 'payload/database'
import prompts from 'prompts'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { createMigrationTable } from './utilities/createMigrationTable.js'
import { migrationTableExists } from './utilities/migrationTableExists.js'

View File

@@ -9,7 +9,7 @@ import {
readMigrationFiles,
} from 'payload/database'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { migrationTableExists } from './utilities/migrationTableExists.js'
import { parseError } from './utilities/parseError.js'

View File

@@ -9,7 +9,7 @@ import {
} from 'payload/database'
import prompts from 'prompts'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { parseError } from './utilities/parseError.js'

View File

@@ -9,7 +9,7 @@ import {
readMigrationFiles,
} from 'payload/database'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { migrationTableExists } from './utilities/migrationTableExists.js'
import { parseError } from './utilities/parseError.js'

View File

@@ -9,7 +9,7 @@ import {
readMigrationFiles,
} from 'payload/database'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { migrationTableExists } from './utilities/migrationTableExists.js'

View File

@@ -1,7 +1,7 @@
import { Table } from 'console-table-printer'
import { getMigrations, readMigrationFiles } from 'payload/database'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { migrationTableExists } from './utilities/migrationTableExists.js'

View File

@@ -1,8 +1,8 @@
import type { SQL } from 'drizzle-orm'
import type { Field, Where } from 'payload/types'
import type { GenericColumn, PostgresAdapter } from '../types.d.ts'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.d.ts'
import type { GenericColumn, PostgresAdapter } from '../types.js'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'
import { parseParams } from './parseParams.js'

View File

@@ -4,7 +4,7 @@ import type { Field, Where } from 'payload/types'
import { asc, desc } from 'drizzle-orm'
import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.d.ts'
import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'
import { getTableColumnFromPath } from './getTableColumnFromPath.js'
import { parseParams } from './parseParams.js'

View File

@@ -11,8 +11,8 @@ import { flattenTopLevelFields } from 'payload/utilities'
import toSnakeCase from 'to-snake-case'
import { v4 as uuid } from 'uuid'
import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.d.ts'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.d.ts'
import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'
type Constraint = {
columnName: string

View File

@@ -6,8 +6,8 @@ import { and, ilike, isNotNull, isNull, ne, notInArray, or, sql } from 'drizzle-
import { QueryError } from 'payload/errors'
import { validOperators } from 'payload/types'
import type { GenericColumn, PostgresAdapter } from '../types.d.ts'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.d.ts'
import type { GenericColumn, PostgresAdapter } from '../types.js'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'
import { buildAndOrConditions } from './buildAndOrConditions.js'
import { createJSONQuery } from './createJSONQuery/index.js'

View File

@@ -2,7 +2,7 @@ import { APIError } from 'payload/errors'
import { type Field, type TabAsField, fieldAffectsData } from 'payload/types'
import { createArrayFromCommaDelineated } from 'payload/utilities'
import type { PostgresAdapter } from '../types.d.ts'
import type { PostgresAdapter } from '../types.js'
type SanitizeQueryValueArgs = {
adapter: PostgresAdapter

View File

@@ -13,7 +13,7 @@ import { index, integer, numeric, serial, timestamp, unique, varchar } from 'dri
import { fieldAffectsData } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.d.ts'
import type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.js'
import { parentIDColumnMap } from './parentIDColumnMap.js'
import { setColumnID } from './setColumnID.js'

View File

@@ -1,7 +1,7 @@
/* eslint-disable no-param-reassign */
import { index, uniqueIndex } from 'drizzle-orm/pg-core'
import type { GenericColumn } from '../types.d.ts'
import type { GenericColumn } from '../types.js'
type CreateIndexArgs = {
columnName: string

View File

@@ -1,6 +1,6 @@
import { integer, numeric, uuid, varchar } from 'drizzle-orm/pg-core'
import type { IDType } from '../types.d.ts'
import type { IDType } from '../types.js'
export const parentIDColumnMap: Record<
IDType,

View File

@@ -4,7 +4,7 @@ import { numeric, serial, uuid, varchar } from 'drizzle-orm/pg-core'
import { type Field, fieldAffectsData } from 'payload/types'
import { flattenTopLevelFields } from 'payload/utilities'
import type { IDType, PostgresAdapter } from '../types.d.ts'
import type { IDType, PostgresAdapter } from '../types.js'
type Args = { adapter: PostgresAdapter; columns: Record<string, PgColumnBuilder>; fields: Field[] }
export const setColumnID = ({ adapter, columns, fields }: Args): IDType => {

View File

@@ -22,7 +22,7 @@ import { InvalidConfiguration } from 'payload/errors'
import { fieldAffectsData, optionIsObject } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { GenericColumns, IDType, PostgresAdapter } from '../types.d.ts'
import type { GenericColumns, IDType, PostgresAdapter } from '../types.js'
import { hasLocalesTable } from '../utilities/hasLocalesTable.js'
import { buildTable } from './build.js'

View File

@@ -3,7 +3,7 @@ import type { Block, Field } from 'payload/types'
import { InvalidConfiguration } from 'payload/errors'
import { fieldAffectsData, fieldHasSubFields, tabHasName } from 'payload/types'
import type { GenericTable } from '../types.d.ts'
import type { GenericTable } from '../types.js'
type Args = {
block: Block

View File

@@ -2,7 +2,7 @@ import type { BeginTransaction } from 'payload/database'
import { v4 as uuid } from 'uuid'
import type { DrizzleTransaction, PostgresAdapter } from '../types.d.ts'
import type { DrizzleTransaction, PostgresAdapter } from '../types.js'
export const beginTransaction: BeginTransaction = async function beginTransaction(
this: PostgresAdapter,

View File

@@ -4,7 +4,7 @@ import type { Field, TabAsField } from 'payload/types'
import { fieldAffectsData } from 'payload/types'
import type { BlocksMap } from '../../utilities/createBlocksMap.d.ts'
import type { BlocksMap } from '../../utilities/createBlocksMap.js'
import { transformHasManyNumber } from './hasManyNumber.js'
import { transformHasManyText } from './hasManyText.js'

View File

@@ -1,8 +1,8 @@
/* eslint-disable no-param-reassign */
import type { ArrayField } from 'payload/types'
import type { PostgresAdapter } from '../../types.d.ts'
import type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.d.ts'
import type { PostgresAdapter } from '../../types.js'
import type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js'
import { traverseFields } from './traverseFields.js'

View File

@@ -3,8 +3,8 @@ import type { BlockField } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from '../../types.d.ts'
import type { BlockRowToInsert, RelationshipToDelete } from './types.d.ts'
import type { PostgresAdapter } from '../../types.js'
import type { BlockRowToInsert, RelationshipToDelete } from './types.js'
import { traverseFields } from './traverseFields.js'

View File

@@ -1,8 +1,8 @@
/* eslint-disable no-param-reassign */
import type { Field } from 'payload/types'
import type { PostgresAdapter } from '../../types.d.ts'
import type { RowToInsert } from './types.d.ts'
import type { PostgresAdapter } from '../../types.js'
import type { RowToInsert } from './types.js'
import { traverseFields } from './traverseFields.js'

View File

@@ -4,8 +4,8 @@ import type { Field } from 'payload/types'
import { fieldAffectsData } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from '../../types.d.ts'
import type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.d.ts'
import type { PostgresAdapter } from '../../types.js'
import type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js'
import { transformArray } from './array.js'

View File

@@ -2,8 +2,8 @@ import type { UpdateOne } from 'payload/database'
import toSnakeCase from 'to-snake-case'
import type { ChainedMethods } from './find/chainMethods.d.ts'
import type { PostgresAdapter } from './types.d.ts'
import type { ChainedMethods } from './find/chainMethods.js'
import type { PostgresAdapter } from './types.js'
import { chainMethods } from './find/chainMethods.js'
import buildQuery from './queries/buildQuery.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -3,7 +3,7 @@ import type { PayloadRequest, TypeWithID } from 'payload/types'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -4,7 +4,7 @@ import type { PayloadRequest, SanitizedGlobalConfig, TypeWithID } from 'payload/
import { buildVersionGlobalFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import buildQuery from './queries/buildQuery.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -4,7 +4,7 @@ import type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payl
import { buildVersionCollectionFields } from 'payload/versions'
import toSnakeCase from 'to-snake-case'
import type { PostgresAdapter } from './types.d.ts'
import type { PostgresAdapter } from './types.js'
import buildQuery from './queries/buildQuery.js'
import { upsertRow } from './upsertRow/index.js'

View File

@@ -1,6 +1,6 @@
import { and, eq } from 'drizzle-orm'
import type { DrizzleDB, PostgresAdapter } from '../types.d.ts'
import type { DrizzleDB, PostgresAdapter } from '../types.js'
type Args = {
adapter: PostgresAdapter

View File

@@ -1,6 +1,6 @@
import { and, eq, inArray } from 'drizzle-orm'
import type { DrizzleDB, PostgresAdapter } from '../types.d.ts'
import type { DrizzleDB, PostgresAdapter } from '../types.js'
type Args = {
adapter: PostgresAdapter

View File

@@ -4,8 +4,8 @@ import type { TypeWithID } from 'payload/types'
import { eq } from 'drizzle-orm'
import { ValidationError } from 'payload/errors'
import type { BlockRowToInsert } from '../transform/write/types.d.ts'
import type { Args } from './types.d.ts'
import type { BlockRowToInsert } from '../transform/write/types.js'
import type { Args } from './types.js'
import { buildFindManyArgs } from '../find/buildFindManyArgs.js'
import { transform } from '../transform/read/index.js'

View File

@@ -1,6 +1,6 @@
/* eslint-disable no-param-reassign */
import type { ArrayRowToInsert } from '../transform/write/types.d.ts'
import type { DrizzleDB, PostgresAdapter } from '../types.d.ts'
import type { ArrayRowToInsert } from '../transform/write/types.js'
import type { DrizzleDB, PostgresAdapter } from '../types.js'
type Args = {
adapter: PostgresAdapter

View File

@@ -1,7 +1,7 @@
import type { SQL } from 'drizzle-orm'
import type { Field, PayloadRequest } from 'payload/types'
import type { DrizzleDB, GenericColumn, PostgresAdapter } from '../types.d.ts'
import type { DrizzleDB, GenericColumn, PostgresAdapter } from '../types.js'
type BaseArgs = {
adapter: PostgresAdapter

View File

@@ -1,6 +1,6 @@
import { sql } from 'drizzle-orm'
import type { PostgresAdapter } from '../types.d.ts'
import type { PostgresAdapter } from '../types.js'
export const createMigrationTable = async (adapter: PostgresAdapter): Promise<void> => {
const prependSchema = adapter.schemaName ? `"${adapter.schemaName}".` : ''

View File

@@ -1,6 +1,6 @@
import { sql } from 'drizzle-orm'
import type { DrizzleDB } from '../types.d.ts'
import type { DrizzleDB } from '../types.js'
export const migrationTableExists = async (db: DrizzleDB): Promise<boolean> => {
const queryRes = await db.execute(sql`SELECT to_regclass('public.payload_migrations');`)