Skip to content

Commit

Permalink
chore: use export type
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Mar 4, 2024
1 parent 1ca97e6 commit 449eb90
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 185 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = defineConfig({
'error',
{ default: 'array-simple', readonly: 'generic' },
],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/naming-convention': [
Expand Down
160 changes: 21 additions & 139 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { Migration } from './migration';
import {
export { Migration } from './migration';
export type {
AlterDomain,
CreateDomain,
DomainOptionsAlter,
DomainOptionsCreate,
DropDomain,
RenameDomain,
} from './operations/domainsTypes';
import {
export type {
CreateExtension,
CreateExtensionOptions,
DropExtension,
Extension,
} from './operations/extensionsTypes';
import {
export type {
CreateFunction,
DropFunction,
FunctionOptions,
FunctionParam,
RenameFunction,
} from './operations/functionsTypes';
import {
export type {
CascadeOption,
DropOptions,
IfExistsOption,
Expand All @@ -30,13 +30,13 @@ import {
Type,
Value,
} from './operations/generalTypes';
import {
export type {
CreateIndex,
CreateIndexOptions,
DropIndex,
DropIndexOptions,
} from './operations/indexesTypes';
import {
export type {
AddToOperatorFamily,
CreateOperator,
CreateOperatorClass,
Expand All @@ -52,38 +52,38 @@ import {
RenameOperatorClass,
RenameOperatorFamily,
} from './operations/operatorsTypes';
import { Sql } from './operations/othersTypes';
import PgLiteral from './operations/PgLiteral';
import {
export type { Sql } from './operations/othersTypes';
export { default as PgLiteral } from './operations/PgLiteral';
export type {
AlterPolicy,
CreatePolicy,
CreatePolicyOptions,
DropPolicy,
PolicyOptions,
RenamePolicy,
} from './operations/policiesTypes';
import {
export type {
AlterRole,
CreateRole,
DropRole,
RenameRole,
RoleOptions,
} from './operations/rolesTypes';
import {
export type {
CreateSchema,
CreateSchemaOptions,
DropSchema,
RenameSchema,
} from './operations/schemasTypes';
import {
export type {
AlterSequence,
CreateSequence,
DropSequence,
RenameSequence,
SequenceOptionsAlter,
SequenceOptionsCreate,
} from './operations/sequencesTypes';
import {
export type {
AddColumns,
AlterColumn,
AlterColumnOptions,
Expand All @@ -102,13 +102,13 @@ import {
RenameTable,
TableOptions,
} from './operations/tablesTypes';
import {
export type {
CreateTrigger,
DropTrigger,
RenameTrigger,
TriggerOptions,
} from './operations/triggersTypes';
import {
export type {
AddTypeAttribute,
AddTypeValue,
AddTypeValueOptions,
Expand All @@ -120,7 +120,7 @@ import {
RenameTypeValue,
SetTypeAttribute,
} from './operations/typesTypes';
import {
export type {
AlterMaterializedView,
AlterMaterializedViewOptions,
CreateMaterializedView,
Expand All @@ -131,7 +131,7 @@ import {
RenameMaterializedView,
RenameMaterializedViewColumn,
} from './operations/viewsMaterializedTypes';
import {
export type {
AlterView,
AlterViewColumn,
AlterViewColumnOptions,
Expand All @@ -141,126 +141,8 @@ import {
DropView,
RenameView,
} from './operations/viewsTypes';
import runner from './runner';
import { MigrationBuilder, PgType, RunnerOption } from './types';

export {
PgLiteral,
Migration,
PgType,
MigrationBuilder,
RunnerOption,
PgLiteralValue,
Value,
Name,
Type,
IfExistsOption,
IfNotExistsOption,
CascadeOption,
DropOptions,
CreateTable,
DropTable,
AlterTable,
RenameTable,
AddColumns,
DropColumns,
AlterColumn,
RenameColumn,
CreateConstraint,
DropConstraint,
RenameConstraint,
ColumnDefinition,
ColumnDefinitions,
TableOptions,
AlterTableOptions,
AlterColumnOptions,
ConstraintOptions,
CreateDomain,
DropDomain,
AlterDomain,
RenameDomain,
DomainOptionsCreate,
DomainOptionsAlter,
CreateExtension,
DropExtension,
Extension,
CreateExtensionOptions,
CreateFunction,
DropFunction,
RenameFunction,
FunctionParam,
FunctionOptions,
DropIndex,
CreateIndex,
CreateIndexOptions,
DropIndexOptions,
CreateOperator,
DropOperator,
CreateOperatorClass,
DropOperatorClass,
RenameOperatorClass,
CreateOperatorFamily,
DropOperatorFamily,
AddToOperatorFamily,
RenameOperatorFamily,
RemoveFromOperatorFamily,
CreateOperatorOptions,
DropOperatorOptions,
OperatorListDefinition,
CreateOperatorClassOptions,
Sql,
CreatePolicy,
DropPolicy,
AlterPolicy,
RenamePolicy,
CreatePolicyOptions,
PolicyOptions,
CreateRole,
DropRole,
AlterRole,
RenameRole,
RoleOptions,
CreateSequence,
DropSequence,
AlterSequence,
RenameSequence,
SequenceOptionsCreate,
SequenceOptionsAlter,
CreateSchema,
DropSchema,
RenameSchema,
CreateSchemaOptions,
CreateTrigger,
DropTrigger,
RenameTrigger,
TriggerOptions,
CreateType,
DropType,
RenameType,
AddTypeAttribute,
DropTypeAttribute,
SetTypeAttribute,
AddTypeValue,
RenameTypeAttribute,
RenameTypeValue,
AddTypeValueOptions,
CreateView,
DropView,
AlterView,
AlterViewColumn,
RenameView,
CreateViewOptions,
AlterViewOptions,
AlterViewColumnOptions,
CreateMaterializedView,
DropMaterializedView,
AlterMaterializedView,
RenameMaterializedView,
RenameMaterializedViewColumn,
RefreshMaterializedView,
CreateMaterializedViewOptions,
AlterMaterializedViewOptions,
RefreshMaterializedViewOptions,
};
export { PgType } from './types';
export type { MigrationBuilder, RunnerOption } from './types';

import runner from './runner';
export default runner;
4 changes: 2 additions & 2 deletions src/operations/domains.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MigrationOptions } from '../types';
import { applyType, escapeValue } from '../utils';
import {
import type {
AlterDomain,
CreateDomain,
DropDomain,
RenameDomain,
} from './domainsTypes';

export { CreateDomain, DropDomain, AlterDomain, RenameDomain };
export type { CreateDomain, DropDomain, AlterDomain, RenameDomain };

export function dropDomain(mOptions: MigrationOptions): DropDomain {
const _drop: DropDomain = (domainName, options = {}) => {
Expand Down
4 changes: 2 additions & 2 deletions src/operations/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MigrationOptions } from '../types';
import { CreateExtension, DropExtension } from './extensionsTypes';
import type { CreateExtension, DropExtension } from './extensionsTypes';

export { CreateExtension, DropExtension };
export type { CreateExtension, DropExtension };

export function dropExtension(mOptions: MigrationOptions): DropExtension {
const _drop: DropExtension = (_extensions, options = {}) => {
Expand Down
8 changes: 6 additions & 2 deletions src/operations/functions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type { MigrationOptions } from '../types';
import { escapeValue, formatParams } from '../utils';
import { CreateFunction, DropFunction, RenameFunction } from './functionsTypes';
import type {
CreateFunction,
DropFunction,
RenameFunction,
} from './functionsTypes';

export { CreateFunction, DropFunction, RenameFunction };
export type { CreateFunction, DropFunction, RenameFunction };

export function dropFunction(mOptions: MigrationOptions): DropFunction {
const _drop: DropFunction = (
Expand Down
5 changes: 3 additions & 2 deletions src/operations/indexes.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { Literal, MigrationOptions } from '../types';
import type { Name } from './generalTypes';
import type {
CreateIndex,
CreateIndexOptions,
DropIndex,
DropIndexOptions,
IndexColumn,
} from './indexesTypes';
import { CreateIndex, DropIndex } from './indexesTypes';

export { CreateIndex, DropIndex };
export type { CreateIndex, DropIndex };

function generateIndexName(
table: Name,
Expand Down
6 changes: 3 additions & 3 deletions src/operations/operators.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { MigrationOptions } from '../types';
import { applyType, formatParams } from '../utils';
import type { OperatorListDefinition } from './operatorsTypes';
import {
import type {
AddToOperatorFamily,
CreateOperator,
CreateOperatorClass,
CreateOperatorFamily,
DropOperator,
DropOperatorClass,
DropOperatorFamily,
OperatorListDefinition,
RemoveFromOperatorFamily,
RenameOperatorClass,
RenameOperatorFamily,
} from './operatorsTypes';

export {
export type {
CreateOperator,
DropOperator,
CreateOperatorClass,
Expand Down
4 changes: 2 additions & 2 deletions src/operations/other.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { MigrationOptions } from '../types';
import { createTransformer } from '../utils';
import { Sql } from './othersTypes';
import type { Sql } from './othersTypes';

export { Sql };
export type { Sql };

export function sql(mOptions: MigrationOptions): Sql {
const t = createTransformer(mOptions.literal);
Expand Down
6 changes: 3 additions & 3 deletions src/operations/policies.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MigrationOptions } from '../types';
import type { PolicyOptions } from './policiesTypes';
import {
import type {
AlterPolicy,
CreatePolicy,
DropPolicy,
PolicyOptions,
RenamePolicy,
} from './policiesTypes';

export { CreatePolicy, DropPolicy, AlterPolicy, RenamePolicy };
export type { CreatePolicy, DropPolicy, AlterPolicy, RenamePolicy };

const makeClauses = ({ role, using, check }: PolicyOptions) => {
const roles = (Array.isArray(role) ? role : [role]).join(', ');
Expand Down
13 changes: 9 additions & 4 deletions src/operations/roles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type { MigrationOptions } from '../types';
import { escapeValue } from '../utils';
import type { RoleOptions } from './rolesTypes';
import { AlterRole, CreateRole, DropRole, RenameRole } from './rolesTypes';

export { CreateRole, DropRole, AlterRole, RenameRole };
import type {
AlterRole,
CreateRole,
DropRole,
RenameRole,
RoleOptions,
} from './rolesTypes';

export type { CreateRole, DropRole, AlterRole, RenameRole };

const formatRoleOptions = (roleOptions: RoleOptions = {}) => {
const options = [];
Expand Down
Loading

0 comments on commit 449eb90

Please sign in to comment.