Skip to content

Commit

Permalink
Fix Pg array type error, fix ESM imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dankochetov committed Aug 23, 2023
1 parent a84ff4f commit 406bc04
Show file tree
Hide file tree
Showing 268 changed files with 1,973 additions and 1,829 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"better-sqlite3": "^8.4.0",
"bun-types": "^0.6.6",
"concurrently": "^8.1.0",
"cpy": "^10.1.0",
"cpy-cli": "^5.0.0",
"knex": "^2.4.2",
"kysely": "^0.25.0",
Expand All @@ -150,6 +151,7 @@
"rimraf": "^5.0.0",
"rollup": "^3.27.2",
"rollup-plugin-dts": "^5.3.1",
"rollup-plugin-typescript2": "^0.35.0",
"sql.js": "^1.8.0",
"sqlite3": "^5.1.2",
"tslib": "^2.5.2",
Expand Down
1 change: 1 addition & 0 deletions rollup.cjs.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';

import { entries, external } from './rollup.common';

export default defineConfig([
Expand Down
1 change: 1 addition & 0 deletions rollup.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const external = [
'knex',
'kysely',
'mysql2',
'mysql2/promise',
'postgres',
'sqlite3',
'bun:sqlite',
Expand Down
1 change: 1 addition & 0 deletions rollup.esm.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json from '@rollup/plugin-json';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';

import { entries, external } from './rollup.common';

export default defineConfig([
Expand Down
40 changes: 33 additions & 7 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
#!/usr/bin/env -S pnpm tsx
import 'zx/globals';
import concurrently from 'concurrently';
import cpy from 'cpy';

import { entries } from '../rollup.common';

function updateAndCopyPackageJson() {
const pkg = fs.readJSONSync('package.json');

pkg.exports = entries.reduce<Record<string, { import: string; require: string; default: string; types: string }>>(
pkg.exports = entries.reduce<
Record<string, {
import: {
types?: string;
default: string;
};
require: {
types: string;
default: string;
};
default: string;
types: string;
}>
>(
(acc, entry) => {
const exportsEntry = entry === 'index' ? '.' : './' + entry.replace(/\/index$/, '');
const importEntry = `./${entry}.mjs`;
const requireEntry = `./${entry}.cjs`;
const typesEntry = `./${entry}.d.ts`;
acc[exportsEntry] = {
types: typesEntry,
import: importEntry,
require: requireEntry,
import: {
types: `./${entry}.d.mts`,
default: importEntry,
},
require: {
types: `./${entry}.d.cts`,
default: requireEntry,
},
types: `./${entry}.d.ts`,
default: importEntry,
};
return acc;
Expand All @@ -37,13 +56,20 @@ await concurrently([
name: 'esm',
},
{
command:
`rimraf dist-dts && tsc -p tsconfig.dts.json --declaration --outDir dist-dts --emitDeclarationOnly && resolve-tspaths --out dist-dts && cpy 'dist-dts/**/*' dist.new && rimraf dist-dts`,
command: `rimraf dist-dts && tsc -p tsconfig.dts.json && resolve-tspaths -p tsconfig.dts.json --out dist-dts`,
name: 'dts',
},
], {
killOthers: 'failure',
}).result.catch(() => process.exit(1));
await cpy('dist-dts/**/*.d.ts', 'dist.new', {
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'),
});
await cpy('dist-dts/**/*.d.ts', 'dist.new', {
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'),
});
await cpy('dist-dts/**/*.d.ts', 'dist.new');
fs.removeSync('dist-dts');
fs.copySync('../README.md', 'dist.new/README.md');
updateAndCopyPackageJson();
fs.removeSync('dist');
Expand Down
14 changes: 7 additions & 7 deletions src/alias.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { AnyColumn } from './column';
import { Column } from './column';
import { entityKind, is } from './entity';
import type { Relation } from './relations';
import { SQL, sql } from './sql';
import { Table } from './table';
import { type View, ViewBaseConfig } from './view';
import type { AnyColumn } from './column.ts';
import { Column } from './column.ts';
import { entityKind, is } from './entity.ts';
import type { Relation } from './relations.ts';
import { SQL, sql } from './sql/index.ts';
import { Table } from './table.ts';
import { type View, ViewBaseConfig } from './view.ts';

export class ColumnAliasProxyHandler<TColumn extends Column> implements ProxyHandler<TColumn> {
static readonly [entityKind]: string = 'ColumnAliasProxyHandler';
Expand Down
2 changes: 1 addition & 1 deletion src/aws-data-api/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Field } from '@aws-sdk/client-rds-data';
import { TypeHint } from '@aws-sdk/client-rds-data';
import type { QueryTypingsValue } from '~/sql';
import type { QueryTypingsValue } from '~/sql/index.ts';

export function getValueFromDataApi(field: Field) {
if (field.stringValue !== undefined) {
Expand Down
18 changes: 9 additions & 9 deletions src/aws-data-api/pg/driver.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { entityKind } from '~/entity';
import type { Logger } from '~/logger';
import { DefaultLogger } from '~/logger';
import { PgDatabase } from '~/pg-core/db';
import { PgDialect } from '~/pg-core/dialect';
import { entityKind } from '~/entity.ts';
import type { Logger } from '~/logger.ts';
import { DefaultLogger } from '~/logger.ts';
import { PgDatabase } from '~/pg-core/db.ts';
import { PgDialect } from '~/pg-core/dialect.ts';
import {
createTableRelationsHelpers,
extractTablesRelationalConfig,
type RelationalSchemaConfig,
type TablesRelationalConfig,
} from '~/relations';
import { type DrizzleConfig } from '~/utils';
import type { AwsDataApiClient, AwsDataApiPgQueryResultHKT } from './session';
import { AwsDataApiSession } from './session';
} from '~/relations.ts';
import { type DrizzleConfig } from '~/utils.ts';
import type { AwsDataApiClient, AwsDataApiPgQueryResultHKT } from './session.ts';
import { AwsDataApiSession } from './session.ts';

export interface PgDriverOptions {
logger?: Logger;
Expand Down
4 changes: 2 additions & 2 deletions src/aws-data-api/pg/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './driver';
export * from './session';
export * from './driver.ts';
export * from './session.ts';
6 changes: 3 additions & 3 deletions src/aws-data-api/pg/migrator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MigrationConfig } from '~/migrator';
import { readMigrationFiles } from '~/migrator';
import type { AwsDataApiPgDatabase } from './driver';
import type { MigrationConfig } from '~/migrator.ts';
import { readMigrationFiles } from '~/migrator.ts';
import type { AwsDataApiPgDatabase } from './driver.ts';

export async function migrate<TSchema extends Record<string, unknown>>(
db: AwsDataApiPgDatabase<TSchema>,
Expand Down
16 changes: 8 additions & 8 deletions src/aws-data-api/pg/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
ExecuteStatementCommand,
RollbackTransactionCommand,
} from '@aws-sdk/client-rds-data';
import { entityKind } from '~/entity';
import type { Logger } from '~/logger';
import { entityKind } from '~/entity.ts';
import type { Logger } from '~/logger.ts';
import {
type PgDialect,
PgSession,
Expand All @@ -15,12 +15,12 @@ import {
PreparedQuery,
type PreparedQueryConfig,
type QueryResultHKT,
} from '~/pg-core';
import type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types';
import { type RelationalSchemaConfig, type TablesRelationalConfig } from '~/relations';
import { fillPlaceholders, type Query, type QueryTypingsValue, type SQL, sql } from '~/sql';
import { mapResultRow } from '~/utils';
import { getValueFromDataApi, toValueParam } from '../common';
} from '~/pg-core/index.ts';
import type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';
import { type RelationalSchemaConfig, type TablesRelationalConfig } from '~/relations.ts';
import { fillPlaceholders, type Query, type QueryTypingsValue, type SQL, sql } from '~/sql/index.ts';
import { mapResultRow } from '~/utils.ts';
import { getValueFromDataApi, toValueParam } from '../common/index.ts';

export type AwsDataApiClient = RDSDataClient;

Expand Down
12 changes: 6 additions & 6 deletions src/better-sqlite3/driver.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { Database, RunResult } from 'better-sqlite3';
import { DefaultLogger } from '~/logger';
import { DefaultLogger } from '~/logger.ts';
import {
createTableRelationsHelpers,
extractTablesRelationalConfig,
type RelationalSchemaConfig,
type TablesRelationalConfig,
} from '~/relations';
import { BaseSQLiteDatabase } from '~/sqlite-core/db';
import { SQLiteSyncDialect } from '~/sqlite-core/dialect';
import { type DrizzleConfig } from '~/utils';
import { BetterSQLiteSession } from './session';
} from '~/relations.ts';
import { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';
import { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';
import { type DrizzleConfig } from '~/utils.ts';
import { BetterSQLiteSession } from './session.ts';

export type BetterSQLite3Database<
TSchema extends Record<string, unknown> = Record<string, never>,
Expand Down
4 changes: 2 additions & 2 deletions src/better-sqlite3/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './driver';
export * from './session';
export * from './driver.ts';
export * from './session.ts';
6 changes: 3 additions & 3 deletions src/better-sqlite3/migrator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MigrationConfig } from '~/migrator';
import { readMigrationFiles } from '~/migrator';
import type { BetterSQLite3Database } from './driver';
import type { MigrationConfig } from '~/migrator.ts';
import { readMigrationFiles } from '~/migrator.ts';
import type { BetterSQLite3Database } from './driver.ts';

export function migrate<TSchema extends Record<string, unknown>>(
db: BetterSQLite3Database<TSchema>,
Expand Down
20 changes: 10 additions & 10 deletions src/better-sqlite3/session.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { Database, RunResult, Statement } from 'better-sqlite3';
import { entityKind } from '~/entity';
import type { Logger } from '~/logger';
import { NoopLogger } from '~/logger';
import { type RelationalSchemaConfig, type TablesRelationalConfig } from '~/relations';
import { fillPlaceholders, type Query, sql } from '~/sql';
import { SQLiteTransaction } from '~/sqlite-core';
import type { SQLiteSyncDialect } from '~/sqlite-core/dialect';
import type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types';
import { entityKind } from '~/entity.ts';
import type { Logger } from '~/logger.ts';
import { NoopLogger } from '~/logger.ts';
import { type RelationalSchemaConfig, type TablesRelationalConfig } from '~/relations.ts';
import { fillPlaceholders, type Query, sql } from '~/sql/index.ts';
import type { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';
import { SQLiteTransaction } from '~/sqlite-core/index.ts';
import type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types.ts';
import {
PreparedQuery as PreparedQueryBase,
type PreparedQueryConfig as PreparedQueryConfigBase,
type SQLiteExecuteMethod,
SQLiteSession,
type SQLiteTransactionConfig,
} from '~/sqlite-core/session';
import { mapResultRow } from '~/utils';
} from '~/sqlite-core/session.ts';
import { mapResultRow } from '~/utils.ts';

export interface BetterSQLiteSessionOptions {
logger?: Logger;
Expand Down
12 changes: 6 additions & 6 deletions src/bun-sqlite/driver.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/// <reference types="bun-types" />

import type { Database } from 'bun:sqlite';
import { DefaultLogger } from '~/logger';
import { DefaultLogger } from '~/logger.ts';
import {
createTableRelationsHelpers,
extractTablesRelationalConfig,
type RelationalSchemaConfig,
type TablesRelationalConfig,
} from '~/relations';
import { BaseSQLiteDatabase } from '~/sqlite-core/db';
import { SQLiteSyncDialect } from '~/sqlite-core/dialect';
import { type DrizzleConfig } from '~/utils';
import { SQLiteBunSession } from './session';
} from '~/relations.ts';
import { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';
import { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';
import { type DrizzleConfig } from '~/utils.ts';
import { SQLiteBunSession } from './session.ts';

export type BunSQLiteDatabase<
TSchema extends Record<string, unknown> = Record<string, never>,
Expand Down
4 changes: 2 additions & 2 deletions src/bun-sqlite/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './driver';
export * from './session';
export * from './driver.ts';
export * from './session.ts';
6 changes: 3 additions & 3 deletions src/bun-sqlite/migrator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MigrationConfig } from '~/migrator';
import { readMigrationFiles } from '~/migrator';
import type { BunSQLiteDatabase } from './driver';
import type { MigrationConfig } from '~/migrator.ts';
import { readMigrationFiles } from '~/migrator.ts';
import type { BunSQLiteDatabase } from './driver.ts';

export function migrate<TSchema extends Record<string, unknown>>(
db: BunSQLiteDatabase<TSchema>,
Expand Down
22 changes: 11 additions & 11 deletions src/bun-sqlite/session.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/// <reference types="bun-types" />

import type { Database, Statement as BunStatement } from 'bun:sqlite';
import { entityKind } from '~/entity';
import type { Logger } from '~/logger';
import { NoopLogger } from '~/logger';
import { type RelationalSchemaConfig, type TablesRelationalConfig } from '~/relations';
import { fillPlaceholders, type Query, sql } from '~/sql';
import { SQLiteTransaction } from '~/sqlite-core';
import type { SQLiteSyncDialect } from '~/sqlite-core/dialect';
import type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types';
import { entityKind } from '~/entity.ts';
import type { Logger } from '~/logger.ts';
import { NoopLogger } from '~/logger.ts';
import { type RelationalSchemaConfig, type TablesRelationalConfig } from '~/relations.ts';
import { fillPlaceholders, type Query, sql } from '~/sql/index.ts';
import type { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';
import { SQLiteTransaction } from '~/sqlite-core/index.ts';
import type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types.ts';
import type {
PreparedQueryConfig as PreparedQueryConfigBase,
SQLiteExecuteMethod,
SQLiteTransactionConfig,
} from '~/sqlite-core/session';
import { PreparedQuery as PreparedQueryBase, SQLiteSession } from '~/sqlite-core/session';
import { mapResultRow } from '~/utils';
} from '~/sqlite-core/session.ts';
import { PreparedQuery as PreparedQueryBase, SQLiteSession } from '~/sqlite-core/session.ts';
import { mapResultRow } from '~/utils.ts';

export interface SQLiteBunSessionOptions {
logger?: Logger;
Expand Down
Loading

0 comments on commit 406bc04

Please sign in to comment.