Skip to content

Commit

Permalink
Feat(TS): Change typescript compiler module (#238)
Browse files Browse the repository at this point in the history
* Change module and moduleResoulution in ts compiler

* Add explicit file extensions in imports
  • Loading branch information
GoldenJaden authored Mar 27, 2024
1 parent 4ace00c commit 39093c8
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/domain/entities/editorTools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type User from './user';
import type User from './user.js';

/**
* Plugin that connects to the editor based on user settings
Expand Down
2 changes: 1 addition & 1 deletion src/domain/entities/notePublic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Note } from '@domain/entities/note';
import type { Note } from '@domain/entities/note.js';

type NotePublicProperties = 'content' | 'createdAt' | 'updatedAt'| 'creatorId';

Expand Down
2 changes: 1 addition & 1 deletion src/domain/entities/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type EditorTool from './editorTools';
import type EditorTool from './editorTools.js';

/**
* User entity
Expand Down
2 changes: 1 addition & 1 deletion src/domain/service/ai.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type AIRepository from '@repository/ai.repository';
import type AIRepository from '@repository/ai.repository.js';

/**
* AI service
Expand Down
4 changes: 2 additions & 2 deletions src/domain/service/noteList.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type NoteRepository from '@repository/note.repository';
import type { NoteList } from '@domain/entities/noteList';
import type NoteRepository from '@repository/note.repository.js';
import type { NoteList } from '@domain/entities/noteList.js';

/**
* Note list service
Expand Down
4 changes: 2 additions & 2 deletions src/domain/service/noteVisits.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NoteInternalId } from '@domain/entities/note';
import type { NoteInternalId } from '@domain/entities/note.js';
import type User from '@domain/entities/user.js';
import type NoteVisit from '@domain/entities/noteVisit.js';
import type NoteVisitsRepository from '@repository/noteVisits.repository';
import type NoteVisitsRepository from '@repository/noteVisits.repository.js';

/**
* Note Visits service, which will store latest note visit
Expand Down
2 changes: 1 addition & 1 deletion src/domain/service/shared/editorTools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type EditorTool from '@domain/entities/editorTools';
import type EditorTool from '@domain/entities/editorTools.js';

/**
* Which methods of Domain can be used by other domains
Expand Down
4 changes: 2 additions & 2 deletions src/domain/service/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type EditorToolsServiceSharedMethods from './editorTools';
import type NoteServiceSharedMethods from './note';
import type EditorToolsServiceSharedMethods from './editorTools.js';
import type NoteServiceSharedMethods from './note.js';

export type SharedDomainMethods = {
editorTools: EditorToolsServiceSharedMethods;
Expand Down
2 changes: 1 addition & 1 deletion src/domain/service/shared/note.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NoteInternalId } from '@domain/entities/note';
import type { NoteInternalId } from '@domain/entities/note.js';

/**
* Which methods of Domain can be used by other domains
Expand Down
2 changes: 1 addition & 1 deletion src/domain/service/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type UserRepository from '@repository/user.repository.js';
import { Provider } from '@repository/user.repository.js';
import type User from '@domain/entities/user.js';
import type EditorTool from '@domain/entities/editorTools';
import type EditorTool from '@domain/entities/editorTools.js';
import type { SharedDomainMethods } from './shared/index.js';
import { DomainError } from '@domain/entities/DomainError.js';

Expand Down
2 changes: 1 addition & 1 deletion src/presentation/api.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DomainServices } from '@domain/index';
import type { DomainServices } from '@domain/index.js';
import type * as http from 'http';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/http/http-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fastify from 'fastify';
import type Api from '@presentation/api.interface.js';
import type { DomainServices } from '@domain/index.js';
import cors from '@fastify/cors';
import fastifyOauth2 from '@fastify/oauth2';
import { fastifyOauth2 } from '@fastify/oauth2';
import fastifySwagger from '@fastify/swagger';
import fastifySwaggerUI from '@fastify/swagger-ui';
import addUserIdResolver from '@presentation/http/middlewares/common/userIdResolver.js';
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/http/router/ai.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type AIService from '@domain/service/ai';
import type AIService from '@domain/service/ai.js';
import type { FastifyPluginCallback } from 'fastify';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/http/router/noteList.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type User from '@domain/entities/user';
import type User from '@domain/entities/user.js';
import { describe, test, expect, beforeEach } from 'vitest';

let accessToken = '';
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/http/router/noteList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FastifyPluginCallback } from 'fastify';
import type NoteListService from '@domain/service/noteList.js';
import { definePublicNote, type NotePublic } from '@domain/entities/notePublic.js';
import type { NoteListPublic } from '@domain/entities/noteList';
import type { NoteListPublic } from '@domain/entities/noteList.js';


/**
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/http/router/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FastifyPluginCallback } from 'fastify';
import type UserService from '@domain/service/user.js';
import type User from '@domain/entities/user.js';
import type EditorToolsService from '@domain/service/editorTools';
import type EditorToolsService from '@domain/service/editorTools.js';

/**
* Interface for the user router
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/http/types/PolicyContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DomainServices } from '@domain/index';
import type { DomainServices } from '@domain/index.js';
import type { FastifyRequest, FastifyReply } from 'fastify';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/repository/ai.repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { notEmpty } from '@infrastructure/utils/empty.js';
import type OpenAIApi from './transport/openai-api';
import type { GetCompletionResponsePayload } from './transport/openai-api/types/GetCompletionResponsePayload';
import type OpenAIApi from './transport/openai-api/index.js';
import type { GetCompletionResponsePayload } from './transport/openai-api/types/GetCompletionResponsePayload.js';

/**
* Repository that establishes access to data from business logic
Expand Down
4 changes: 2 additions & 2 deletions src/repository/storage/postgres/orm/sequelize/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { DataTypes, Model } from 'sequelize';
import type Orm from '@repository/storage/postgres/orm/sequelize/index.js';
import type { Note, NoteCreationAttributes, NoteInternalId, NotePublicId } from '@domain/entities/note.js';
import { UserModel } from '@repository/storage/postgres/orm/sequelize/user.js';
import type { NoteSettingsModel } from './noteSettings';
import { NoteList } from '@domain/entities/noteList';
import type { NoteSettingsModel } from './noteSettings.js';
import { NoteList } from '@domain/entities/noteList.js';

/* eslint-disable @typescript-eslint/naming-convention */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Op } from 'sequelize';
import { NoteModel } from '@repository/storage/postgres/orm/sequelize/note.js';
import type Orm from '@repository/storage/postgres/orm/sequelize/index.js';
import type { NoteInternalId } from '@domain/entities/note.js';
import type { Note } from '@domain/entities/note';
import type { Note } from '@domain/entities/note.js';
import { Model, DataTypes } from 'sequelize';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/repository/storage/postgres/orm/sequelize/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { literal } from 'sequelize';
import { Model, DataTypes } from 'sequelize';
import type Orm from '@repository/storage/postgres/orm/sequelize/index.js';
import type User from '@domain/entities/user.js';
import type EditorTool from '@domain/entities/editorTools';
import type EditorTool from '@domain/entities/editorTools.js';

/**
* Query options for getting user
Expand Down
4 changes: 2 additions & 2 deletions src/repository/team.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type TeamStorage from '@repository/storage/team.storage.js';
import type { Team, TeamMember, TeamMemberCreationAttributes, MemberRole } from '@domain/entities/team.js';
import type { NoteInternalId } from '@domain/entities/note';
import type User from '@domain/entities/user';
import type { NoteInternalId } from '@domain/entities/note.js';
import type User from '@domain/entities/user.js';

/**
* Repository allows accessing data from business-logic (domain) level
Expand Down
2 changes: 1 addition & 1 deletion src/repository/transport/openai-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Transport from '@repository/transport/index.js';
import appConfig from '@infrastructure/config/index.js'; // @todo get rid of import from infrastructure
import type { ApiResponse } from '../google-api/types/ApiResponse';
import type { ApiResponse } from '../google-api/types/ApiResponse.js';

/**
* OpenAI transport
Expand Down
2 changes: 1 addition & 1 deletion src/repository/transport/openai-api/types/ApiResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GetCompletionResponsePayload } from './GetCompletionResponsePayload';
import type { GetCompletionResponsePayload } from './GetCompletionResponsePayload.js';

/**
* Payload of the OpenAI API responses
Expand Down
4 changes: 2 additions & 2 deletions src/repository/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type User from '@domain/entities/user.js';
import type UserStorage from '@repository/storage/user.storage.js';
import type GoogleApiTransport from '@repository/transport/google-api/index.js';
import type GetUserInfoResponsePayload from '@repository/transport/google-api/types/GetUserInfoResponsePayload.js';
import type { AddUserToolOptions } from '@repository/storage/postgres/orm/sequelize/user';
import type EditorTool from '@domain/entities/editorTools';
import type { AddUserToolOptions } from '@repository/storage/postgres/orm/sequelize/user.js';
import type EditorTool from '@domain/entities/editorTools.js';

/**
* OAuth provider
Expand Down
4 changes: 2 additions & 2 deletions src/tests/utils/database-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createInvitationHash } from '@infrastructure/utils/invitationHash';
import { createPublicId } from '@infrastructure/utils/id';
import { createInvitationHash } from '@infrastructure/utils/invitationHash.js';
import { createPublicId } from '@infrastructure/utils/id.js';
import { QueryTypes } from 'sequelize';
import type User from '@domain/entities/user.ts';
import type { Note } from '@domain/entities/note.ts';
Expand Down
6 changes: 3 additions & 3 deletions src/tests/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import path from 'path';
import type { StartedPostgreSqlContainer } from '@testcontainers/postgresql';
import { PostgreSqlContainer } from '@testcontainers/postgresql';

import { insertData } from './insert-data';
import { insertData } from './insert-data.js';
import { initORM, init as initRepositories } from '@repository/index.js';
import { init as initDomainServices } from '@domain/index.js';
import config from '@infrastructure/config/index.js';
import { runTenantMigrations } from '@repository/storage/postgres/migrations/migrate';
import { runTenantMigrations } from '@repository/storage/postgres/migrations/migrate.js';
import API from '@presentation/index.js';

import { beforeAll, afterAll } from 'vitest';
import type Api from '@presentation/api.interface';
import type Api from '@presentation/api.interface.js';

import DatabaseHelpers from './database-helpers.js';

Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"compilerOptions": {
"baseUrl": "./src" ,
"target": "es2022",
"module": "es2022",
"moduleResolution": "node",
"module": "node16",
"moduleResolution": "node16",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down

0 comments on commit 39093c8

Please sign in to comment.