From 2e9f04c298d940e721a2cc5f2f90af56b480fb45 Mon Sep 17 00:00:00 2001 From: Iacami Gevaerd Date: Mon, 13 Nov 2023 15:25:09 -0300 Subject: [PATCH] Revert "refactor: remove .js ext from ALL local imports across the codebase (#361)" (#363) This reverts commit db3b348cba6755546d8df2ee633517e48c1e5642. --- .github/workflows/nodejs.yml | 24 +++++++-------- jest.config.cjs | 8 ++--- package.json | 2 +- src/GradeUtils.ts | 2 +- src/__tests__/areas.ts | 12 ++++---- src/__tests__/gradeUtils.ts | 12 ++------ src/__tests__/history.ts | 14 ++++----- src/__tests__/organizations.ts | 14 ++++----- src/__tests__/ticks.ts | 12 ++++---- src/auth/index.ts | 4 +-- src/auth/middleware.ts | 6 ++-- src/auth/permissions.ts | 2 +- src/auth/rules.ts | 4 +-- src/auth/util.ts | 2 +- src/db/AreaSchema.ts | 8 ++--- src/db/AreaTypes.ts | 10 +++---- src/db/ChangeLogSchema.ts | 4 +-- src/db/ChangeLogType.ts | 6 ++-- src/db/ClimbHistorySchema.ts | 8 ++--- src/db/ClimbSchema.ts | 6 ++-- src/db/ClimbTypes.ts | 4 +-- src/db/MediaObjectSchema.ts | 4 +-- src/db/OrganizationSchema.ts | 4 +-- src/db/OrganizationTypes.ts | 2 +- src/db/PostSchema.ts | 4 +-- src/db/TagSchema.ts | 2 +- src/db/UserSchema.ts | 2 +- src/db/UserTypes.ts | 2 +- src/db/XMediaSchema.ts | 2 +- src/db/edit/streamListener.ts | 16 +++++----- src/db/export/Typesense/Client.ts | 16 +++++----- src/db/export/Typesense/Typesense.ts | 18 +++++------ src/db/export/Typesense/transformers.ts | 8 ++--- src/db/export/common/index.ts | 2 +- src/db/export/json/area.resolver.ts | 2 +- src/db/export/json/async-file.processor.ts | 4 +-- src/db/export/json/index.ts | 8 ++--- src/db/export/queries/get-all-areas.ts | 8 ++--- src/db/export/queries/get-all-climbs.ts | 6 ++-- src/db/import/ClimbTransformer.ts | 4 +-- src/db/import/usa/AreaTransformer.ts | 6 ++-- src/db/import/usa/AreaTree.ts | 2 +- src/db/import/usa/LinkClimbsWithCrags.ts | 4 +-- src/db/import/usa/SeedState.ts | 18 +++++------ src/db/import/usa/USADay0Seed.ts | 8 ++--- src/db/import/usa/__tests__/Utils.test.ts | 2 +- src/db/index.ts | 22 +++++++------- src/db/utils/Aggregate.ts | 8 ++--- src/db/utils/jobs/AddCountriesJob.ts | 8 ++--- src/db/utils/jobs/CragUpdater.ts | 10 +++---- src/db/utils/jobs/TreeUpdater.ts | 6 ++-- src/db/utils/jobs/UpdateStatsJob.ts | 8 ++--- .../migration/CreateMediaMetaCollection.ts | 10 +++---- .../jobs/migration/CreateUsersCollection.ts | 8 ++--- src/graphql/area/AreaMutations.ts | 6 ++-- src/graphql/area/index.ts | 4 +-- src/graphql/climb/ClimbMutations.ts | 2 +- src/graphql/climb/index.ts | 2 +- src/graphql/common/MuuidScalar.ts | 2 +- src/graphql/common/index.ts | 4 +-- src/graphql/common/resolvers.ts | 4 +-- src/graphql/history/HistoryFieldResolvers.ts | 6 ++-- src/graphql/history/HistoryQueries.ts | 4 +-- src/graphql/history/index.ts | 4 +-- src/graphql/media/MediaResolvers.ts | 6 ++-- src/graphql/media/index.ts | 6 ++-- src/graphql/media/mutations.ts | 4 +-- src/graphql/media/queries.ts | 4 +-- .../organization/OrganizationMutations.ts | 4 +-- src/graphql/organization/index.ts | 4 +-- src/graphql/posts/index.ts | 6 ++-- src/graphql/posts/mutations.ts | 2 +- src/graphql/posts/queries.ts | 2 +- src/graphql/resolvers.ts | 30 +++++++++---------- src/graphql/tag/index.ts | 4 +-- src/graphql/tag/queries.ts | 4 +-- src/graphql/tick/index.ts | 4 +-- src/graphql/user/UserMutations.ts | 4 +-- src/graphql/user/UserQueries.ts | 4 +-- src/graphql/user/UserResolvers.ts | 2 +- src/graphql/user/index.ts | 6 ++-- src/graphql/xmedia/index.ts | 6 ++-- src/graphql/xmedia/mutations.ts | 2 +- src/graphql/xmedia/queries.ts | 4 +-- src/main.ts | 6 ++-- src/model/AreaDataSource.ts | 8 ++--- src/model/AreaHistoryDatasource.ts | 4 +-- src/model/ChangeLogDataSource.ts | 8 ++--- src/model/ClimbDataSource.ts | 6 ++-- src/model/ExperimentalUserDataSource.ts | 4 +-- src/model/MediaDataSource.ts | 6 ++-- src/model/MutableAreaDataSource.ts | 28 ++++++++--------- src/model/MutableClimbDataSource.ts | 16 +++++----- src/model/MutableMediaDataSource.ts | 6 ++-- src/model/MutableOrganizationDataSource.ts | 14 ++++----- src/model/OrganizationDataSource.ts | 6 ++-- src/model/OrganizationHistoryDatasource.ts | 4 +-- src/model/PostDataSource.ts | 2 +- src/model/TickDataSource.ts | 2 +- src/model/UserDataSource.ts | 8 ++--- src/model/XMediaDataSource.ts | 2 +- src/model/__tests__/AreaHistoryDataSource.ts | 12 ++++---- src/model/__tests__/ChangeLogDS.ts | 10 +++---- src/model/__tests__/MediaDataSource.ts | 8 ++--- src/model/__tests__/MutableClimbDataSource.ts | 18 +++++------ .../MutableOrganizationDataSource.ts | 12 ++++---- src/model/__tests__/UserDataSource.ts | 6 ++-- src/model/__tests__/ticks.ts | 10 +++---- src/model/__tests__/updateAreas.ts | 8 ++--- src/server.ts | 24 +++++++-------- src/types.ts | 20 ++++++------- src/utils/inMemoryDB.ts | 4 +-- src/utils/testUtils.ts | 6 ++-- tsconfig.json | 2 +- tsconfig.release.json | 2 +- 115 files changed, 400 insertions(+), 416 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index f3e416ce..88cde9a8 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -4,29 +4,25 @@ on: push: branches: - develop - - test pull_request: jobs: build: runs-on: 'ubuntu-latest' - steps: - - name: 'Checkout Project' - uses: 'actions/checkout@v4' - - name: Setup Node.js environment uses: actions/setup-node@v3 with: node-version: '16.15' - cache: 'yarn' - - name: Install dependencies - run: yarn install --immutable + - name: 'Checkout Project' + uses: 'actions/checkout@v3' + with: + fetch-depth: 1 - - name: Lint code - run: yarn lint + - name: Install Dependencies and lint code + run: yarn install && yarn lint - name: Start MongoDB uses: supercharge/mongodb-github-action@1.8.0 @@ -48,8 +44,8 @@ jobs: run: | docker container restart mongodb - - name: Run tests - run: yarn test --ci + - name: Build and run tests + run: yarn test + env: + NODE_OPTIONS: --experimental-vm-modules - - name: Build files/check types - run: yarn build-release --noEmit diff --git a/jest.config.cjs b/jest.config.cjs index 0b7ac430..ea6b6706 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -1,11 +1,7 @@ module.exports = { - transform: { - '^.+\\.tsx?$': 'ts-jest' - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + preset: 'ts-jest', testEnvironment: 'node', - testPathIgnorePatterns: ['/node_modules/', './build/'], testMatch: [ - '/**/__tests__/*.ts' + '/build/**/__tests__/*.js' ] } diff --git a/package.json b/package.json index 5a2483ef..fbbfcbde 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "scripts": { "lint": "yarn ts-standard", "fix": "yarn ts-standard --fix", - "test": "jest --runInBand", + "test": "yarn build && cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --runInBand", "build": "tsc -p tsconfig.json", "build-release": "tsc -p tsconfig.release.json", "clean": "tsc -b --clean && rm -rf build/*", diff --git a/src/GradeUtils.ts b/src/GradeUtils.ts index ade53cb9..42dab36c 100644 --- a/src/GradeUtils.ts +++ b/src/GradeUtils.ts @@ -1,6 +1,6 @@ import { getScale, GradeScales, GradeScalesTypes } from '@openbeta/sandbag' import isoCountries from 'i18n-iso-countries' -import { DisciplineType, ClimbGradeContextType } from './db/ClimbTypes' +import { DisciplineType, ClimbGradeContextType } from './db/ClimbTypes.js' /** * Grade systems have minor variations between countries. gradeContext is a diff --git a/src/__tests__/areas.ts b/src/__tests__/areas.ts index a2dc15bc..6a9c64e9 100644 --- a/src/__tests__/areas.ts +++ b/src/__tests__/areas.ts @@ -1,12 +1,12 @@ import { ApolloServer } from 'apollo-server' import muuid from 'uuid-mongodb' import { jest } from '@jest/globals' -import MutableAreaDataSource from '../model/MutableAreaDataSource' -import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource' -import { AreaType } from '../db/AreaTypes' -import { OrgType, OrganizationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes' -import { queryAPI, setUpServer } from '../utils/testUtils' -import { muuidToString } from '../utils/helpers' +import MutableAreaDataSource from '../model/MutableAreaDataSource.js' +import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource.js' +import { AreaType } from '../db/AreaTypes.js' +import { OrgType, OrganizationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes.js' +import { queryAPI, setUpServer } from '../utils/testUtils.js' +import { muuidToString } from '../utils/helpers.js' jest.setTimeout(60000) diff --git a/src/__tests__/gradeUtils.ts b/src/__tests__/gradeUtils.ts index 88de1014..94c8fffe 100644 --- a/src/__tests__/gradeUtils.ts +++ b/src/__tests__/gradeUtils.ts @@ -1,13 +1,5 @@ -import { DisciplineType } from '../db/ClimbTypes' -import { sanitizeDisciplines, createGradeObject, gradeContextToGradeScales } from '../GradeUtils' - -beforeAll(() => { - console.warn = jest.fn() -}) - -afterAll(() => { - jest.mocked(console.warn).mockReset() -}) +import { DisciplineType } from '../db/ClimbTypes.js' +import { sanitizeDisciplines, createGradeObject, gradeContextToGradeScales } from '../GradeUtils.js' describe('Test grade utilities', () => { it('sanitizes bad discipline object', () => { diff --git a/src/__tests__/history.ts b/src/__tests__/history.ts index 1688f32c..202747b2 100644 --- a/src/__tests__/history.ts +++ b/src/__tests__/history.ts @@ -1,13 +1,13 @@ import { ApolloServer } from 'apollo-server' import muuid from 'uuid-mongodb' import { jest } from '@jest/globals' -import MutableAreaDataSource from '../model/MutableAreaDataSource' -import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource' -import MutableClimbDataSource from '../model/MutableClimbDataSource' -import { AreaType } from '../db/AreaTypes' -import { OrgType, OrganizationType } from '../db/OrganizationTypes' -import { muuidToString } from '../utils/helpers' -import { queryAPI, setUpServer } from '../utils/testUtils' +import MutableAreaDataSource from '../model/MutableAreaDataSource.js' +import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource.js' +import MutableClimbDataSource from '../model/MutableClimbDataSource.js' +import { AreaType } from '../db/AreaTypes.js' +import { OrgType, OrganizationType } from '../db/OrganizationTypes.js' +import { muuidToString } from '../utils/helpers.js' +import { queryAPI, setUpServer } from '../utils/testUtils.js' jest.setTimeout(60000) diff --git a/src/__tests__/organizations.ts b/src/__tests__/organizations.ts index 8494980c..448df19b 100644 --- a/src/__tests__/organizations.ts +++ b/src/__tests__/organizations.ts @@ -1,13 +1,13 @@ import { ApolloServer } from 'apollo-server' import muuid from 'uuid-mongodb' import { jest } from '@jest/globals' -import MutableAreaDataSource from '../model/MutableAreaDataSource' -import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource' -import { AreaType } from '../db/AreaTypes' -import { OrgType, OrganizationType, OperationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes' -import { changelogDataSource } from '../model/ChangeLogDataSource' -import { queryAPI, setUpServer } from '../utils/testUtils' -import { muuidToString } from '../utils/helpers' +import MutableAreaDataSource from '../model/MutableAreaDataSource.js' +import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource.js' +import { AreaType } from '../db/AreaTypes.js' +import { OrgType, OrganizationType, OperationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes.js' +import { changelogDataSource } from '../model/ChangeLogDataSource.js' +import { queryAPI, setUpServer } from '../utils/testUtils.js' +import { muuidToString } from '../utils/helpers.js' import { validate as validateMuuid } from 'uuid' jest.setTimeout(60000) diff --git a/src/__tests__/ticks.ts b/src/__tests__/ticks.ts index f0e63167..1db3e2b2 100644 --- a/src/__tests__/ticks.ts +++ b/src/__tests__/ticks.ts @@ -1,12 +1,12 @@ import { ApolloServer } from 'apollo-server' import muuid from 'uuid-mongodb' import { jest } from '@jest/globals' -import { queryAPI, setUpServer } from '../utils/testUtils' -import { muuidToString } from '../utils/helpers' -import { TickInput } from '../db/TickTypes' -import TickDataSource from '../model/TickDataSource' -import UserDataSource from '../model/UserDataSource' -import { UpdateProfileGQLInput } from '../db/UserTypes' +import { queryAPI, setUpServer } from '../utils/testUtils.js' +import { muuidToString } from '../utils/helpers.js' +import { TickInput } from '../db/TickTypes.js' +import TickDataSource from '../model/TickDataSource.js' +import UserDataSource from '../model/UserDataSource.js' +import { UpdateProfileGQLInput } from '../db/UserTypes.js' jest.setTimeout(60000) diff --git a/src/auth/index.ts b/src/auth/index.ts index ffcc6d1a..1601888e 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -1,3 +1,3 @@ -import permissions from './permissions' -import { createContext } from './middleware' +import permissions from './permissions.js' +import { createContext } from './middleware.js' export { permissions, createContext } diff --git a/src/auth/middleware.ts b/src/auth/middleware.ts index 835b2a93..af81045c 100644 --- a/src/auth/middleware.ts +++ b/src/auth/middleware.ts @@ -1,7 +1,7 @@ import muid from 'uuid-mongodb' -import { AuthUserType } from '../types' -import { verifyJWT } from './util' -import { logger } from '../logger' +import { AuthUserType } from '../types.js' +import { verifyJWT } from './util.js' +import { logger } from '../logger.js' /** * Create a middleware context for Apollo server diff --git a/src/auth/permissions.ts b/src/auth/permissions.ts index fd2d7c0f..59e2925e 100644 --- a/src/auth/permissions.ts +++ b/src/auth/permissions.ts @@ -1,5 +1,5 @@ import { shield, allow, and, or } from 'graphql-shield' -import { isEditor, isUserAdmin, isOwner, isValidEmail, isMediaOwner } from './rules' +import { isEditor, isUserAdmin, isOwner, isValidEmail, isMediaOwner } from './rules.js' const permissions = shield({ Query: { diff --git a/src/auth/rules.ts b/src/auth/rules.ts index 89217db4..f5ecdafe 100644 --- a/src/auth/rules.ts +++ b/src/auth/rules.ts @@ -1,7 +1,7 @@ import { rule, inputRule } from 'graphql-shield' -import MediaDataSource from '../model/MutableMediaDataSource' -import { MediaObjectGQLInput } from '../db/MediaObjectTypes' +import MediaDataSource from '../model/MutableMediaDataSource.js' +import { MediaObjectGQLInput } from '../db/MediaObjectTypes.js' export const isEditor = rule()(async (parent, args, ctx, info) => { return _hasUserUuid(ctx) && ctx.user.roles.includes('editor') diff --git a/src/auth/util.ts b/src/auth/util.ts index d8f3d1e1..2329c00c 100644 --- a/src/auth/util.ts +++ b/src/auth/util.ts @@ -1,7 +1,7 @@ import jwksClient from 'jwks-rsa' import jwt from 'jsonwebtoken' -import { checkVar } from '../db/index' +import { checkVar } from '../db/index.js' const auth0Domain = checkVar('AUTH0_DOMAIN') const auth0Kid = checkVar('AUTH0_KID') diff --git a/src/db/AreaSchema.ts b/src/db/AreaSchema.ts index c0ed707a..e27ded05 100644 --- a/src/db/AreaSchema.ts +++ b/src/db/AreaSchema.ts @@ -1,10 +1,10 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import { AreaType, IAreaContent, IAreaMetadata, AggregateType, CountByGroupType, CountByDisciplineType, CountByGradeBandType, DisciplineStatsType, OperationType } from './AreaTypes' -import { PointSchema } from './ClimbSchema' -import { ChangeRecordMetadataType } from './ChangeLogType' -import { GradeContexts } from '../GradeUtils' +import { AreaType, IAreaContent, IAreaMetadata, AggregateType, CountByGroupType, CountByDisciplineType, CountByGradeBandType, DisciplineStatsType, OperationType } from './AreaTypes.js' +import { PointSchema } from './ClimbSchema.js' +import { ChangeRecordMetadataType } from './ChangeLogType.js' +import { GradeContexts } from '../GradeUtils.js' const { Schema, connection } = mongoose diff --git a/src/db/AreaTypes.ts b/src/db/AreaTypes.ts index 1ad914fa..36fc5c15 100644 --- a/src/db/AreaTypes.ts +++ b/src/db/AreaTypes.ts @@ -2,11 +2,11 @@ import mongoose from 'mongoose' import { MUUID } from 'uuid-mongodb' import { BBox, Point } from '@turf/helpers' -import { ClimbType } from './ClimbTypes' -import { ChangeRecordMetadataType } from './ChangeLogType' -import { GradeContexts } from '../GradeUtils' -import { ExperimentalAuthorType } from './UserTypes' -import { AuthorMetadata } from '../types' +import { ClimbType } from './ClimbTypes.js' +import { ChangeRecordMetadataType } from './ChangeLogType.js' +import { GradeContexts } from '../GradeUtils.js' +import { ExperimentalAuthorType } from './UserTypes.js' +import { AuthorMetadata } from '../types.js' /** * Areas are a grouping mechanism in the OpenBeta data model that allow diff --git a/src/db/ChangeLogSchema.ts b/src/db/ChangeLogSchema.ts index be244128..052a3859 100644 --- a/src/db/ChangeLogSchema.ts +++ b/src/db/ChangeLogSchema.ts @@ -1,7 +1,7 @@ import mongoose from 'mongoose' -import { ChangeLogType, SupportedCollectionTypes } from './ChangeLogType' -import { OperationType } from './AreaTypes' +import { ChangeLogType, SupportedCollectionTypes } from './ChangeLogType.js' +import { OperationType } from './AreaTypes.js' const { Schema, connection } = mongoose diff --git a/src/db/ChangeLogType.ts b/src/db/ChangeLogType.ts index 1d305743..8a57b894 100644 --- a/src/db/ChangeLogType.ts +++ b/src/db/ChangeLogType.ts @@ -1,9 +1,9 @@ import mongose from 'mongoose' import { MUUID } from 'uuid-mongodb' -import { OperationType as AreaOpType, AreaType } from './AreaTypes' -import { ClimbEditOperationType, ClimbType } from './ClimbTypes' -import { OperationType as OrganizationOpType, OrganizationType } from './OrganizationTypes' +import { OperationType as AreaOpType, AreaType } from './AreaTypes.js' +import { ClimbEditOperationType, ClimbType } from './ClimbTypes.js' +import { OperationType as OrganizationOpType, OrganizationType } from './OrganizationTypes.js' export type DBOperation = 'insert' | 'update' | 'delete' export enum DocumentKind { diff --git a/src/db/ClimbHistorySchema.ts b/src/db/ClimbHistorySchema.ts index 64a4c009..46895fb4 100644 --- a/src/db/ClimbHistorySchema.ts +++ b/src/db/ClimbHistorySchema.ts @@ -1,9 +1,9 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import { ClimbSchema } from './ClimbSchema' -import { AreaSchema } from './AreaSchema' -import ClimbHistoryType, { AreaHistoryType } from './ClimbHistoryType' -import ChangeEventType from './ChangeEventType' +import { ClimbSchema } from './ClimbSchema.js' +import { AreaSchema } from './AreaSchema.js' +import ClimbHistoryType, { AreaHistoryType } from './ClimbHistoryType.js' +import ChangeEventType from './ChangeEventType.js' import { ClimbType } from './ClimbTypes' import { AreaType } from './AreaTypes' diff --git a/src/db/ClimbSchema.ts b/src/db/ClimbSchema.ts index 161fd696..29cab777 100644 --- a/src/db/ClimbSchema.ts +++ b/src/db/ClimbSchema.ts @@ -3,9 +3,9 @@ import muuid from 'uuid-mongodb' import { Point } from '@turf/helpers' import { GradeScalesTypes } from '@openbeta/sandbag' -import { ClimbType, IClimbMetadata, IClimbContent, SafetyType, ClimbEditOperationType } from './ClimbTypes' -import { GradeContexts } from '../GradeUtils' -import { ChangeRecordMetadataType } from './ChangeLogType' +import { ClimbType, IClimbMetadata, IClimbContent, SafetyType, ClimbEditOperationType } from './ClimbTypes.js' +import { GradeContexts } from '../GradeUtils.js' +import { ChangeRecordMetadataType } from './ChangeLogType.js' const { Schema } = mongoose diff --git a/src/db/ClimbTypes.ts b/src/db/ClimbTypes.ts index 49ec4456..e27c6923 100644 --- a/src/db/ClimbTypes.ts +++ b/src/db/ClimbTypes.ts @@ -3,8 +3,8 @@ import { Point } from '@turf/helpers' import { GradeScalesTypes } from '@openbeta/sandbag' import { ChangeRecordMetadataType } from './ChangeLogType' -import { GradeContexts } from '../GradeUtils' -import { AreaType } from './AreaTypes' +import { GradeContexts } from '../GradeUtils.js' +import { AreaType } from './AreaTypes.js' // For search climb by id queries // Additional fields allow client to build breadcrumbs diff --git a/src/db/MediaObjectSchema.ts b/src/db/MediaObjectSchema.ts index 21402837..84a2fa0b 100644 --- a/src/db/MediaObjectSchema.ts +++ b/src/db/MediaObjectSchema.ts @@ -1,7 +1,7 @@ import mongoose from 'mongoose' -import { MediaObject, EntityTag } from './MediaObjectTypes' -import { PointSchema } from './ClimbSchema' +import { MediaObject, EntityTag } from './MediaObjectTypes.js' +import { PointSchema } from './ClimbSchema.js' const { Schema } = mongoose diff --git a/src/db/OrganizationSchema.ts b/src/db/OrganizationSchema.ts index 12a851c8..be95caa2 100644 --- a/src/db/OrganizationSchema.ts +++ b/src/db/OrganizationSchema.ts @@ -1,8 +1,8 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import { OrganizationType, OrgType, IOrganizationContent, OperationType } from './OrganizationTypes' -import { ChangeRecordMetadataType } from './ChangeLogType' +import { OrganizationType, OrgType, IOrganizationContent, OperationType } from './OrganizationTypes.js' +import { ChangeRecordMetadataType } from './ChangeLogType.js' const { Schema, connection } = mongoose diff --git a/src/db/OrganizationTypes.ts b/src/db/OrganizationTypes.ts index 97703231..84a7b899 100644 --- a/src/db/OrganizationTypes.ts +++ b/src/db/OrganizationTypes.ts @@ -1,7 +1,7 @@ import mongoose from 'mongoose' import { MUUID } from 'uuid-mongodb' -import { ChangeRecordMetadataType } from './ChangeLogType' +import { ChangeRecordMetadataType } from './ChangeLogType.js' /** * Organizations are OpenBeta accounts that are owned by organizations diff --git a/src/db/PostSchema.ts b/src/db/PostSchema.ts index 647caf47..0340b219 100644 --- a/src/db/PostSchema.ts +++ b/src/db/PostSchema.ts @@ -1,8 +1,8 @@ import mongoose from 'mongoose' import mongooseLeanVirtuals from 'mongoose-lean-virtuals' import muuid from 'uuid-mongodb' -import { PostType } from './PostTypes' -import { XMediaSchema } from './XMediaSchema' +import { PostType } from './PostTypes.js' +import { XMediaSchema } from './XMediaSchema.js' const { Schema } = mongoose diff --git a/src/db/TagSchema.ts b/src/db/TagSchema.ts index 9531e352..fe89a167 100644 --- a/src/db/TagSchema.ts +++ b/src/db/TagSchema.ts @@ -2,7 +2,7 @@ import mongoose from 'mongoose' import mongooseLeanVirtuals from 'mongoose-lean-virtuals' import muuid from 'uuid-mongodb' -import { TagType, RefModelType } from './TagTypes' +import { TagType, RefModelType } from './TagTypes.js' const { Schema } = mongoose diff --git a/src/db/UserSchema.ts b/src/db/UserSchema.ts index 6b45e463..a305d3a7 100644 --- a/src/db/UserSchema.ts +++ b/src/db/UserSchema.ts @@ -1,7 +1,7 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import { ExperimentalUserType, User, UsernameInfo } from './UserTypes' +import { ExperimentalUserType, User, UsernameInfo } from './UserTypes.js' const { Schema } = mongoose diff --git a/src/db/UserTypes.ts b/src/db/UserTypes.ts index 3a1ac23f..a60c06ae 100644 --- a/src/db/UserTypes.ts +++ b/src/db/UserTypes.ts @@ -1,5 +1,5 @@ import { MUUID } from 'uuid-mongodb' -import { UserMedia } from './MediaObjectTypes' +import { UserMedia } from './MediaObjectTypes.js' export interface ExperimentalUserType { _id: MUUID displayName: string diff --git a/src/db/XMediaSchema.ts b/src/db/XMediaSchema.ts index 37e0fab3..92617ad9 100644 --- a/src/db/XMediaSchema.ts +++ b/src/db/XMediaSchema.ts @@ -2,7 +2,7 @@ import mongoose from 'mongoose' import mongooseLeanVirtuals from 'mongoose-lean-virtuals' import muuid from 'uuid-mongodb' -import { XMediaType } from './XMediaTypes' +import { XMediaType } from './XMediaTypes.js' const { Schema } = mongoose diff --git a/src/db/edit/streamListener.ts b/src/db/edit/streamListener.ts index e4a964b6..aff9b11f 100644 --- a/src/db/edit/streamListener.ts +++ b/src/db/edit/streamListener.ts @@ -2,14 +2,14 @@ import mongoose from 'mongoose' import { ChangeStream, ChangeStreamDocument, ChangeStreamUpdateDocument } from 'mongodb' import dot from 'dot-object' -import { changelogDataSource } from '../../model/ChangeLogDataSource' -import { logger } from '../../logger' -import { BaseChangeRecordType, ResumeToken, UpdateDescription, DBOperation, SupportedCollectionTypes, DocumentKind } from '../ChangeLogType' -import { checkVar } from '../index' -import { updateAreaIndex, updateClimbIndex } from '../export/Typesense/Client' -import { AreaType } from '../AreaTypes' -import { exhaustiveCheck } from '../../utils/helpers' -import { ClimbType } from '../ClimbTypes' +import { changelogDataSource } from '../../model/ChangeLogDataSource.js' +import { logger } from '../../logger.js' +import { BaseChangeRecordType, ResumeToken, UpdateDescription, DBOperation, SupportedCollectionTypes, DocumentKind } from '../ChangeLogType.js' +import { checkVar } from '../index.js' +import { updateAreaIndex, updateClimbIndex } from '../export/Typesense/Client.js' +import { AreaType } from '../AreaTypes.js' +import { exhaustiveCheck } from '../../utils/helpers.js' +import { ClimbType } from '../ClimbTypes.js' /** * Start a new stream listener to track changes diff --git a/src/db/export/Typesense/Client.ts b/src/db/export/Typesense/Client.ts index 7198d151..b2c357a4 100644 --- a/src/db/export/Typesense/Client.ts +++ b/src/db/export/Typesense/Client.ts @@ -1,13 +1,13 @@ import Typesense, { Client } from 'typesense' -import { areaSchema, climbSchema } from './TypesenseSchemas' -import { mongoAreaToTypeSense, mongoClimbToTypeSense } from './transformers' -import { logger } from '../../../logger' -import { AreaType } from '../../AreaTypes' -import { DBOperation } from '../../ChangeLogType' -import Config from '../../../Config' -import { ClimbExtType, ClimbType } from '../../ClimbTypes' -import MutableAreaDataSource from '../../../model/MutableAreaDataSource' +import { areaSchema, climbSchema } from './TypesenseSchemas.js' +import { mongoAreaToTypeSense, mongoClimbToTypeSense } from './transformers.js' +import { logger } from '../../../logger.js' +import { AreaType } from '../../AreaTypes.js' +import { DBOperation } from '../../ChangeLogType.js' +import Config from '../../../Config.js' +import { ClimbExtType, ClimbType } from '../../ClimbTypes.js' +import MutableAreaDataSource from '../../../model/MutableAreaDataSource.js' /** * Return a Typesense client. diff --git a/src/db/export/Typesense/Typesense.ts b/src/db/export/Typesense/Typesense.ts index 41ca5505..7c5746d3 100644 --- a/src/db/export/Typesense/Typesense.ts +++ b/src/db/export/Typesense/Typesense.ts @@ -1,15 +1,15 @@ import { Client } from 'typesense' -import typesenseClient from './Client' -import { connectDB, gracefulExit } from '../../index' -import { ClimbExtType } from '../../ClimbTypes' -import { logger } from '../../../logger' -import { areaSchema, AreaTypeSenseItem, climbSchema, ClimbTypeSenseItem } from './TypesenseSchemas' +import typesenseClient from './Client.js' +import { connectDB, gracefulExit } from '../../index.js' +import { ClimbExtType } from '../../ClimbTypes.js' +import { logger } from '../../../logger.js' +import { areaSchema, AreaTypeSenseItem, climbSchema, ClimbTypeSenseItem } from './TypesenseSchemas.js' import { CollectionCreateSchema } from 'typesense/lib/Typesense/Collections.js' -import { AreaType } from '../../AreaTypes' -import { mongoAreaToTypeSense, mongoClimbToTypeSense } from './transformers' -import { processMongoCollection } from '../common/index' -import { getAllAreas, getAllClimbs } from '../queries/index' +import { AreaType } from '../../AreaTypes.js' +import { mongoAreaToTypeSense, mongoClimbToTypeSense } from './transformers.js' +import { processMongoCollection } from '../common/index.js' +import { getAllAreas, getAllClimbs } from '../queries/index.js' /** * For a given collection that might exist in typesense, drop it (if it exists) diff --git a/src/db/export/Typesense/transformers.ts b/src/db/export/Typesense/transformers.ts index 8006087c..7bc17511 100644 --- a/src/db/export/Typesense/transformers.ts +++ b/src/db/export/Typesense/transformers.ts @@ -1,7 +1,7 @@ -import { AreaTypeSenseItem, ClimbTypeSenseItem } from './TypesenseSchemas' -import { AreaType } from '../../AreaTypes' -import { disciplinesToArray, geoToLatLng } from './Utils' -import { ClimbExtType, SafetyType } from '../../ClimbTypes' +import { AreaTypeSenseItem, ClimbTypeSenseItem } from './TypesenseSchemas.js' +import { AreaType } from '../../AreaTypes.js' +import { disciplinesToArray, geoToLatLng } from './Utils.js' +import { ClimbExtType, SafetyType } from '../../ClimbTypes.js' /** * Convert an Area object to a Typesense object diff --git a/src/db/export/common/index.ts b/src/db/export/common/index.ts index 135dc449..1b0e5a7b 100644 --- a/src/db/export/common/index.ts +++ b/src/db/export/common/index.ts @@ -1,4 +1,4 @@ export { MongoCollectionProcessorOptions, processMongoCollection -} from './processor' +} from './processor.js' diff --git a/src/db/export/json/area.resolver.ts b/src/db/export/json/area.resolver.ts index f4d53f24..3bcfb7be 100644 --- a/src/db/export/json/area.resolver.ts +++ b/src/db/export/json/area.resolver.ts @@ -1,4 +1,4 @@ -import { AreaType } from '../../AreaTypes' +import { AreaType } from '../../AreaTypes.js' import path from 'path' export function resolveAreaFileName (area: Partial): string { diff --git a/src/db/export/json/async-file.processor.ts b/src/db/export/json/async-file.processor.ts index 136f6cf6..4418e7c5 100644 --- a/src/db/export/json/async-file.processor.ts +++ b/src/db/export/json/async-file.processor.ts @@ -1,7 +1,7 @@ import { promises } from 'fs' -import { Processor } from '../common/processor' +import { Processor } from '../common/processor.js' import path, { dirname } from 'path' -import { logger } from '../../../logger' +import { logger } from '../../../logger.js' export type Writer = (data: string, path: string) => Promise export type PathResolver = (data: T) => string diff --git a/src/db/export/json/index.ts b/src/db/export/json/index.ts index 48235e24..e938b4d0 100644 --- a/src/db/export/json/index.ts +++ b/src/db/export/json/index.ts @@ -1,8 +1,8 @@ -import { connectDB, gracefulExit } from '../../index' -import { logger } from '../../../logger' -import { processMongoCollection, Processor } from '../common/processor' +import { connectDB, gracefulExit } from '../../index.js' +import { logger } from '../../../logger.js' +import { processMongoCollection, Processor } from '../common/processor.js' import { getAllAreas } from '../queries/get-all-areas.js' -import { AreaType } from '../../AreaTypes' +import { AreaType } from '../../AreaTypes.js' import { asyncFileProcessor } from './async-file.processor.js' import { fileURLToPath } from 'url' diff --git a/src/db/export/queries/get-all-areas.ts b/src/db/export/queries/get-all-areas.ts index be7f2da7..252405f6 100644 --- a/src/db/export/queries/get-all-areas.ts +++ b/src/db/export/queries/get-all-areas.ts @@ -1,7 +1,7 @@ -import { AreaType } from '../../AreaTypes' -import { getAreaModel } from '../../AreaSchema' -import { DEFAULT_CHUNK_SIZE } from './defaults' -import { getClimbModel } from '../../ClimbSchema' +import { AreaType } from '../../AreaTypes.js' +import { getAreaModel } from '../../AreaSchema.js' +import { DEFAULT_CHUNK_SIZE } from './defaults.js' +import { getClimbModel } from '../../ClimbSchema.js' export async function * getAllAreas (chunkSize: number = DEFAULT_CHUNK_SIZE): AsyncGenerator { let pageNum = 0 diff --git a/src/db/export/queries/get-all-climbs.ts b/src/db/export/queries/get-all-climbs.ts index fa6658d5..8798e88c 100644 --- a/src/db/export/queries/get-all-climbs.ts +++ b/src/db/export/queries/get-all-climbs.ts @@ -1,6 +1,6 @@ -import { ClimbExtType } from '../../ClimbTypes' -import { getClimbModel } from '../../ClimbSchema' -import { DEFAULT_CHUNK_SIZE } from './defaults' +import { ClimbExtType } from '../../ClimbTypes.js' +import { getClimbModel } from '../../ClimbSchema.js' +import { DEFAULT_CHUNK_SIZE } from './defaults.js' /** * SQL equivalent: diff --git a/src/db/import/ClimbTransformer.ts b/src/db/import/ClimbTransformer.ts index 2764e9b2..b90092e1 100644 --- a/src/db/import/ClimbTransformer.ts +++ b/src/db/import/ClimbTransformer.ts @@ -2,8 +2,8 @@ import { geometry, Point } from '@turf/helpers' import muuid from 'uuid-mongodb' import { v5 as uuidv5, NIL } from 'uuid' -import { ClimbType } from '../ClimbTypes' -import { defaultDisciplines, sanitizeDisciplines } from '../../GradeUtils' +import { ClimbType } from '../ClimbTypes.js' +import { defaultDisciplines, sanitizeDisciplines } from '../../GradeUtils.js' const transformClimbRecord = (row: any): ClimbType => { /* eslint-disable-next-line */ diff --git a/src/db/import/usa/AreaTransformer.ts b/src/db/import/usa/AreaTransformer.ts index ff5dbdf3..aa5e38c7 100644 --- a/src/db/import/usa/AreaTransformer.ts +++ b/src/db/import/usa/AreaTransformer.ts @@ -1,11 +1,11 @@ import mongoose from 'mongoose' import { geometry, Point } from '@turf/helpers' import isoCountries from 'i18n-iso-countries' -import enJson from 'i18n-iso-countries/langs/en.json' +import enJson from 'i18n-iso-countries/langs/en.json' assert { type: 'json' } -import { getAreaModel } from '../../AreaSchema' +import { getAreaModel } from '../../AreaSchema.js' import { AreaType } from '../../AreaTypes' -import { Tree, AreaNode, createRootNode } from './AreaTree' +import { Tree, AreaNode, createRootNode } from './AreaTree.js' import { MUUID } from 'uuid-mongodb' isoCountries.registerLocale(enJson) diff --git a/src/db/import/usa/AreaTree.ts b/src/db/import/usa/AreaTree.ts index 0e340a4d..1855e85f 100644 --- a/src/db/import/usa/AreaTree.ts +++ b/src/db/import/usa/AreaTree.ts @@ -2,7 +2,7 @@ import assert from 'node:assert' import mongoose from 'mongoose' import muuid, { MUUID } from 'uuid-mongodb' import { v5 as uuidv5, NIL } from 'uuid' -import { getCountriesDefaultGradeContext, GradeContexts } from '../../../GradeUtils' +import { getCountriesDefaultGradeContext, GradeContexts } from '../../../GradeUtils.js' /** * A tree-like data structure for storing area hierarchy during raw json files progressing. diff --git a/src/db/import/usa/LinkClimbsWithCrags.ts b/src/db/import/usa/LinkClimbsWithCrags.ts index 97b290e1..fa3e9ba5 100644 --- a/src/db/import/usa/LinkClimbsWithCrags.ts +++ b/src/db/import/usa/LinkClimbsWithCrags.ts @@ -1,6 +1,6 @@ import mongoose from 'mongoose' -import { AreaType } from '../../AreaTypes' -import { ClimbType } from '../../ClimbTypes' +import { AreaType } from '../../AreaTypes.js' +import { ClimbType } from '../../ClimbTypes.js' /** * Add climb IDs to Area.climbs[] aka link climbs to their corresponding crags. diff --git a/src/db/import/usa/SeedState.ts b/src/db/import/usa/SeedState.ts index 4dd9050c..3c09f94b 100644 --- a/src/db/import/usa/SeedState.ts +++ b/src/db/import/usa/SeedState.ts @@ -2,15 +2,15 @@ import mongoose from 'mongoose' import readline from 'node:readline' import fs from 'node:fs' -import { getAreaModel } from '../../index' -import { AreaType } from '../../AreaTypes' -import { linkClimbsWithAreas } from './LinkClimbsWithCrags' -import { getClimbModel } from '../../ClimbSchema' -import { ClimbType } from '../../ClimbTypes' -import transformClimbRecord from '../ClimbTransformer' -import { createAreas } from './AreaTransformer' -import { AreaNode } from './AreaTree' -import { logger } from '../../../logger' +import { getAreaModel } from '../../index.js' +import { AreaType } from '../../AreaTypes.js' +import { linkClimbsWithAreas } from './LinkClimbsWithCrags.js' +import { getClimbModel } from '../../ClimbSchema.js' +import { ClimbType } from '../../ClimbTypes.js' +import transformClimbRecord from '../ClimbTransformer.js' +import { createAreas } from './AreaTransformer.js' +import { AreaNode } from './AreaTree.js' +import { logger } from '../../../logger.js' export interface JobStats { state: string diff --git a/src/db/import/usa/USADay0Seed.ts b/src/db/import/usa/USADay0Seed.ts index 76ecc476..6db80222 100644 --- a/src/db/import/usa/USADay0Seed.ts +++ b/src/db/import/usa/USADay0Seed.ts @@ -1,11 +1,11 @@ import fs from 'node:fs' import pLimit from 'p-limit' -import { connectDB, gracefulExit, createIndexes } from '../../index' -import { createRoot } from './AreaTransformer' +import { connectDB, gracefulExit, createIndexes } from '../../index.js' +import { createRoot } from './AreaTransformer.js' import US_STATES from './us-states.js' -import { seedState, dropCollection, JobStats } from './SeedState' -import { logger } from '../../../logger' +import { seedState, dropCollection, JobStats } from './SeedState.js' +import { logger } from '../../../logger.js' const contentDir: string = process.env.CONTENT_BASEDIR ?? '' diff --git a/src/db/import/usa/__tests__/Utils.test.ts b/src/db/import/usa/__tests__/Utils.test.ts index fe428f83..371fe006 100644 --- a/src/db/import/usa/__tests__/Utils.test.ts +++ b/src/db/import/usa/__tests__/Utils.test.ts @@ -1,4 +1,4 @@ -import { extractMpId } from '../AreaTransformer' +import { extractMpId } from '../AreaTransformer.js' test('Verify area url parser', () => { expect(extractMpId('/area/117795688/foo-bar')).toEqual('117795688') diff --git a/src/db/index.ts b/src/db/index.ts index db5a62a5..58bbe87b 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -3,17 +3,17 @@ import { ChangeStream } from 'mongodb' import { config } from 'dotenv' import { enableAllPlugins } from 'immer' -import { getAreaModel } from './AreaSchema' -import { getClimbModel } from './ClimbSchema' -import { getMediaObjectModel } from './MediaObjectSchema' -import { getOrganizationModel } from './OrganizationSchema' -import { getTickModel } from './TickSchema' -import { getXMediaModel } from './XMediaSchema' -import { getPostModel } from './PostSchema' -import { getChangeLogModel } from './ChangeLogSchema' -import { getExperimentalUserModel, getUserModel } from './UserSchema' -import { logger } from '../logger' -import streamListener from './edit/streamListener' +import { getAreaModel } from './AreaSchema.js' +import { getClimbModel } from './ClimbSchema.js' +import { getMediaObjectModel } from './MediaObjectSchema.js' +import { getOrganizationModel } from './OrganizationSchema.js' +import { getTickModel } from './TickSchema.js' +import { getXMediaModel } from './XMediaSchema.js' +import { getPostModel } from './PostSchema.js' +import { getChangeLogModel } from './ChangeLogSchema.js' +import { getExperimentalUserModel, getUserModel } from './UserSchema.js' +import { logger } from '../logger.js' +import streamListener from './edit/streamListener.js' config() enableAllPlugins() diff --git a/src/db/utils/Aggregate.ts b/src/db/utils/Aggregate.ts index d961d383..9f490fe8 100644 --- a/src/db/utils/Aggregate.ts +++ b/src/db/utils/Aggregate.ts @@ -1,9 +1,9 @@ import _ from 'underscore' -import { CountByGroupType, CountByDisciplineType, AggregateType, DisciplineStatsType, CountByGradeBandType, AreaType } from '../AreaTypes' -import { gradeContextToGradeScales } from '../../GradeUtils' -import { ClimbType, ClimbGradeContextType } from '../ClimbTypes' +import { CountByGroupType, CountByDisciplineType, AggregateType, DisciplineStatsType, CountByGradeBandType, AreaType } from '../AreaTypes.js' +import { gradeContextToGradeScales } from '../../GradeUtils.js' +import { ClimbType, ClimbGradeContextType } from '../ClimbTypes.js' import { getScale, GradeBands, GradeBandTypes, GradeScalesTypes, isVScale } from '@openbeta/sandbag' -import { logger } from '../../logger' +import { logger } from '../../logger.js' export const mergeAggregates = (lhs: AggregateType, rhs: AggregateType): AggregateType => { return { diff --git a/src/db/utils/jobs/AddCountriesJob.ts b/src/db/utils/jobs/AddCountriesJob.ts index 32c08b60..272f8528 100644 --- a/src/db/utils/jobs/AddCountriesJob.ts +++ b/src/db/utils/jobs/AddCountriesJob.ts @@ -1,9 +1,9 @@ import mongoose from 'mongoose' -import enJson from 'i18n-iso-countries/langs/en.json' +import enJson from 'i18n-iso-countries/langs/en.json' assert { type: 'json' } -import { connectDB, gracefulExit } from '../../index' -import MutableAreaDataSource from '../../../model/MutableAreaDataSource' -import { logger } from '../../../logger' +import { connectDB, gracefulExit } from '../../index.js' +import MutableAreaDataSource from '../../../model/MutableAreaDataSource.js' +import { logger } from '../../../logger.js' const onConnected = async (): Promise => { logger.info('Adding all countries (except USA)') diff --git a/src/db/utils/jobs/CragUpdater.ts b/src/db/utils/jobs/CragUpdater.ts index 61615fd6..41590e14 100644 --- a/src/db/utils/jobs/CragUpdater.ts +++ b/src/db/utils/jobs/CragUpdater.ts @@ -1,9 +1,9 @@ import mongoose from 'mongoose' -import { getAreaModel } from '../../AreaSchema' -import { getClimbModel } from '../../ClimbSchema' -import { AreaType } from '../../AreaTypes' -import { ClimbType } from '../../ClimbTypes' -import { aggregateCragStats } from '../Aggregate' +import { getAreaModel } from '../../AreaSchema.js' +import { getClimbModel } from '../../ClimbSchema.js' +import { AreaType } from '../../AreaTypes.js' +import { ClimbType } from '../../ClimbTypes.js' +import { aggregateCragStats } from '../Aggregate.js' import { bboxFrom } from '../../../geo-utils.js' type AreaMongoType = mongoose.Document & AreaType diff --git a/src/db/utils/jobs/TreeUpdater.ts b/src/db/utils/jobs/TreeUpdater.ts index 52b287f2..f393b349 100644 --- a/src/db/utils/jobs/TreeUpdater.ts +++ b/src/db/utils/jobs/TreeUpdater.ts @@ -3,10 +3,10 @@ import { feature, geometry, featureCollection, Feature, BBox, Point } from '@tur import centroid from '@turf/centroid' import pLimit from 'p-limit' -import { getAreaModel } from '../../AreaSchema' -import { AreaType, AggregateType } from '../../AreaTypes' +import { getAreaModel } from '../../AreaSchema.js' +import { AreaType, AggregateType } from '../../AreaTypes.js' import { bboxFromList, areaDensity } from '../../../geo-utils.js' -import { mergeAggregates } from '../Aggregate' +import { mergeAggregates } from '../Aggregate.js' const limiter = pLimit(1000) diff --git a/src/db/utils/jobs/UpdateStatsJob.ts b/src/db/utils/jobs/UpdateStatsJob.ts index 7d57a98f..e4fb853f 100644 --- a/src/db/utils/jobs/UpdateStatsJob.ts +++ b/src/db/utils/jobs/UpdateStatsJob.ts @@ -1,7 +1,7 @@ -import { connectDB, gracefulExit } from '../../index' -import { visitAllAreas } from './TreeUpdater' -import { visitAllCrags } from './CragUpdater' -import { logger } from '../../../logger' +import { connectDB, gracefulExit } from '../../index.js' +import { visitAllAreas } from './TreeUpdater.js' +import { visitAllCrags } from './CragUpdater.js' +import { logger } from '../../../logger.js' const onConnected = async (): Promise => { logger.info('Initializing database') diff --git a/src/db/utils/jobs/migration/CreateMediaMetaCollection.ts b/src/db/utils/jobs/migration/CreateMediaMetaCollection.ts index d67ca74f..abc19342 100644 --- a/src/db/utils/jobs/migration/CreateMediaMetaCollection.ts +++ b/src/db/utils/jobs/migration/CreateMediaMetaCollection.ts @@ -3,11 +3,11 @@ import { glob } from 'glob' import { validate as uuidValidate } from 'uuid' import muuid from 'uuid-mongodb' -import { connectDB, gracefulExit } from '../../../index' -import { logger } from '../../../../logger' -import { MediaObject } from '../../../MediaObjectTypes' -import { getMediaObjectModel } from '../../../MediaObjectSchema' -import { getFileInfo } from './SirvClient' +import { connectDB, gracefulExit } from '../../../index.js' +import { logger } from '../../../../logger.js' +import { MediaObject } from '../../../MediaObjectTypes.js' +import { getMediaObjectModel } from '../../../MediaObjectSchema.js' +import { getFileInfo } from './SirvClient.js' const LOCAL_MEDIA_DIR = process.env.LOCAL_MEDIA_DIR diff --git a/src/db/utils/jobs/migration/CreateUsersCollection.ts b/src/db/utils/jobs/migration/CreateUsersCollection.ts index 9c7026b4..3f19854e 100644 --- a/src/db/utils/jobs/migration/CreateUsersCollection.ts +++ b/src/db/utils/jobs/migration/CreateUsersCollection.ts @@ -5,10 +5,10 @@ import fs from 'fs' import { ManagementClient as Auth0MgmtClient } from 'auth0' import type { User as Auth0User } from 'auth0' -import { connectDB, gracefulExit, getUserModel } from '../../../index' -import { logger } from '../../../../logger' -import { User, UpdateProfileGQLInput } from '../../../UserTypes' -import { canonicalizeUsername } from '../../../../utils/helpers' +import { connectDB, gracefulExit, getUserModel } from '../../../index.js' +import { logger } from '../../../../logger.js' +import { User, UpdateProfileGQLInput } from '../../../UserTypes.js' +import { canonicalizeUsername } from '../../../../utils/helpers.js' const LOCAL_MEDIA_DIR_UID = process.env.LOCAL_MEDIA_DIR_UID diff --git a/src/graphql/area/AreaMutations.ts b/src/graphql/area/AreaMutations.ts index 024009ac..6c62de5a 100644 --- a/src/graphql/area/AreaMutations.ts +++ b/src/graphql/area/AreaMutations.ts @@ -1,8 +1,8 @@ import muuid from 'uuid-mongodb' -import { AreaType } from '../../db/AreaTypes' -import { ContextWithAuth } from '../../types' -import type MutableAreaDataSource from '../../model/MutableAreaDataSource' +import { AreaType } from '../../db/AreaTypes.js' +import { ContextWithAuth } from '../../types.js' +import type MutableAreaDataSource from '../../model/MutableAreaDataSource.js' const AreaMutations = { diff --git a/src/graphql/area/index.ts b/src/graphql/area/index.ts index af58b9a7..a16dc280 100644 --- a/src/graphql/area/index.ts +++ b/src/graphql/area/index.ts @@ -1,4 +1,4 @@ -import AreaQueries from './AreaQueries' -import AreaMutations from './AreaMutations' +import AreaQueries from './AreaQueries.js' +import AreaMutations from './AreaMutations.js' export { AreaQueries, AreaMutations } diff --git a/src/graphql/climb/ClimbMutations.ts b/src/graphql/climb/ClimbMutations.ts index e975a059..f3168da4 100644 --- a/src/graphql/climb/ClimbMutations.ts +++ b/src/graphql/climb/ClimbMutations.ts @@ -1,5 +1,5 @@ import muid, { MUUID } from 'uuid-mongodb' -import { ContextWithAuth } from '../../types' +import { ContextWithAuth } from '../../types.js' const ClimbMutations = { updateClimbs: async (_, { input }, { dataSources, user }: ContextWithAuth): Promise => { diff --git a/src/graphql/climb/index.ts b/src/graphql/climb/index.ts index 7acd5e91..09420eeb 100644 --- a/src/graphql/climb/index.ts +++ b/src/graphql/climb/index.ts @@ -1,3 +1,3 @@ -import ClimbMutations from './ClimbMutations' +import ClimbMutations from './ClimbMutations.js' export { ClimbMutations } diff --git a/src/graphql/common/MuuidScalar.ts b/src/graphql/common/MuuidScalar.ts index bce783cf..ff2086b2 100644 --- a/src/graphql/common/MuuidScalar.ts +++ b/src/graphql/common/MuuidScalar.ts @@ -1,6 +1,6 @@ import { GraphQLScalarType, Kind } from 'graphql' import muid, { MUUID } from 'uuid-mongodb' -import { muuidToString } from '../../utils/helpers' +import { muuidToString } from '../../utils/helpers.js' // Not yet possible to use scalars on the client. See https://github.com/apollographql/apollo-client/issues/8857 const fromString = (s: string): MUUID => muid.from(s) diff --git a/src/graphql/common/index.ts b/src/graphql/common/index.ts index 8879af7e..9e6fb764 100644 --- a/src/graphql/common/index.ts +++ b/src/graphql/common/index.ts @@ -1,4 +1,4 @@ -import resolvers from './resolvers' -import typeDef from './typeDef' +import resolvers from './resolvers.js' +import typeDef from './typeDef.js' export { resolvers as CommonResolvers, typeDef as CommonTypeDef } diff --git a/src/graphql/common/resolvers.ts b/src/graphql/common/resolvers.ts index 23965f04..04275c9b 100644 --- a/src/graphql/common/resolvers.ts +++ b/src/graphql/common/resolvers.ts @@ -1,5 +1,5 @@ -import dateScalar from './DateScalar' -import MuuidScalar from './MuuidScalar' +import dateScalar from './DateScalar.js' +import MuuidScalar from './MuuidScalar.js' const resolvers = { Date: dateScalar, diff --git a/src/graphql/history/HistoryFieldResolvers.ts b/src/graphql/history/HistoryFieldResolvers.ts index 23a2fffb..ee6d2014 100644 --- a/src/graphql/history/HistoryFieldResolvers.ts +++ b/src/graphql/history/HistoryFieldResolvers.ts @@ -1,6 +1,6 @@ -import { ChangeLogType, BaseChangeRecordType, SupportedCollectionTypes, DocumentKind } from '../../db/ChangeLogType' -import { AuthorMetadata, DataSourcesType } from '../../types' -import { exhaustiveCheck } from '../../utils/helpers' +import { ChangeLogType, BaseChangeRecordType, SupportedCollectionTypes, DocumentKind } from '../../db/ChangeLogType.js' +import { AuthorMetadata, DataSourcesType } from '../../types.js' +import { exhaustiveCheck } from '../../utils/helpers.js' /** * History schama field resolvers diff --git a/src/graphql/history/HistoryQueries.ts b/src/graphql/history/HistoryQueries.ts index 52d217a2..ff7a9525 100644 --- a/src/graphql/history/HistoryQueries.ts +++ b/src/graphql/history/HistoryQueries.ts @@ -4,8 +4,8 @@ import { GetHistoryInputFilterType, GetAreaHistoryInputFilterType, GetOrganizationHistoryInputFilterType -} from '../../db/ChangeLogType' -import { Context } from '../../types' +} from '../../db/ChangeLogType.js' +import { Context } from '../../types.js' const HistoryQueries = { getChangeHistory: async (_, { filter }, { dataSources }: Context): Promise => { diff --git a/src/graphql/history/index.ts b/src/graphql/history/index.ts index be4cd0f1..16e60c16 100644 --- a/src/graphql/history/index.ts +++ b/src/graphql/history/index.ts @@ -1,3 +1,3 @@ -import HistoryQueries from './HistoryQueries' -import HistoryFieldResolvers from './HistoryFieldResolvers' +import HistoryQueries from './HistoryQueries.js' +import HistoryFieldResolvers from './HistoryFieldResolvers.js' export { HistoryQueries, HistoryFieldResolvers } diff --git a/src/graphql/media/MediaResolvers.ts b/src/graphql/media/MediaResolvers.ts index ed4bda12..c2f16837 100644 --- a/src/graphql/media/MediaResolvers.ts +++ b/src/graphql/media/MediaResolvers.ts @@ -1,6 +1,6 @@ -import { EntityTag, MediaByUsers, MediaObject, TagByUser } from '../../db/MediaObjectTypes' -import { geojsonPointToLatitude, geojsonPointToLongitude } from '../../utils/helpers' -import { DataSourcesType } from '../../types' +import { EntityTag, MediaByUsers, MediaObject, TagByUser } from '../../db/MediaObjectTypes.js' +import { geojsonPointToLatitude, geojsonPointToLongitude } from '../../utils/helpers.js' +import { DataSourcesType } from '../../types.js' const MediaResolvers = { diff --git a/src/graphql/media/index.ts b/src/graphql/media/index.ts index 7511173e..5a56d3f1 100644 --- a/src/graphql/media/index.ts +++ b/src/graphql/media/index.ts @@ -1,5 +1,5 @@ -import MediaQueries from './queries' -import MediaMutations from './mutations' -import MediaResolvers from './MediaResolvers' +import MediaQueries from './queries.js' +import MediaMutations from './mutations.js' +import MediaResolvers from './MediaResolvers.js' export { MediaQueries, MediaMutations, MediaResolvers } diff --git a/src/graphql/media/mutations.ts b/src/graphql/media/mutations.ts index 3ca4f8fe..b180e371 100644 --- a/src/graphql/media/mutations.ts +++ b/src/graphql/media/mutations.ts @@ -1,7 +1,7 @@ import muid from 'uuid-mongodb' import mongoose from 'mongoose' -import { Context } from '../../types' -import { EntityTag, EntityTagDeleteGQLInput, AddEntityTagGQLInput, MediaObject, MediaObjectGQLInput, DeleteMediaGQLInput } from '../../db/MediaObjectTypes' +import { Context } from '../../types.js' +import { EntityTag, EntityTagDeleteGQLInput, AddEntityTagGQLInput, MediaObject, MediaObjectGQLInput, DeleteMediaGQLInput } from '../../db/MediaObjectTypes.js' const MediaMutations = { addMediaObjects: async (_: any, args, { dataSources }: Context): Promise => { diff --git a/src/graphql/media/queries.ts b/src/graphql/media/queries.ts index 4a661ef7..d86037f5 100644 --- a/src/graphql/media/queries.ts +++ b/src/graphql/media/queries.ts @@ -1,7 +1,7 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import { TagsLeaderboardType, MediaObject, MediaByUsers, UserMediaGQLQueryInput, MediaForFeedInput } from '../../db/MediaObjectTypes' -import { Context } from '../../types' +import { TagsLeaderboardType, MediaObject, MediaByUsers, UserMediaGQLQueryInput, MediaForFeedInput } from '../../db/MediaObjectTypes.js' +import { Context } from '../../types.js' const MediaQueries = { diff --git a/src/graphql/organization/OrganizationMutations.ts b/src/graphql/organization/OrganizationMutations.ts index 348877fb..4a488fb7 100644 --- a/src/graphql/organization/OrganizationMutations.ts +++ b/src/graphql/organization/OrganizationMutations.ts @@ -1,5 +1,5 @@ -import { OrganizationType } from '../../db/OrganizationTypes' -import { ContextWithAuth } from '../../types' +import { OrganizationType } from '../../db/OrganizationTypes.js' +import { ContextWithAuth } from '../../types.js' const OrganizationMutations = { diff --git a/src/graphql/organization/index.ts b/src/graphql/organization/index.ts index 0b23d0ad..7cf7b3e6 100644 --- a/src/graphql/organization/index.ts +++ b/src/graphql/organization/index.ts @@ -1,4 +1,4 @@ -import OrganizationMutations from './OrganizationMutations' -import OrganizationQueries from './OrganizationQueries' +import OrganizationMutations from './OrganizationMutations.js' +import OrganizationQueries from './OrganizationQueries.js' export { OrganizationMutations, OrganizationQueries } diff --git a/src/graphql/posts/index.ts b/src/graphql/posts/index.ts index ffc60d08..9b4aee96 100644 --- a/src/graphql/posts/index.ts +++ b/src/graphql/posts/index.ts @@ -1,5 +1,5 @@ -import PostQueries from './queries' -import PostMutations from './mutations' -import PostResolvers from './PostResolvers' +import PostQueries from './queries.js' +import PostMutations from './mutations.js' +import PostResolvers from './PostResolvers.js' export { PostQueries, PostMutations, PostResolvers } diff --git a/src/graphql/posts/mutations.ts b/src/graphql/posts/mutations.ts index fc66d58e..d49c6e29 100644 --- a/src/graphql/posts/mutations.ts +++ b/src/graphql/posts/mutations.ts @@ -1,5 +1,5 @@ import { AddPostInputType, RemovePostInputType } from '../../db/PostTypes' -import { getPostModel } from '../../db/PostSchema' +import { getPostModel } from '../../db/PostSchema.js' import { Context } from '../../types' import muid from 'uuid-mongodb' import { XMediaType } from '../../db/XMediaTypes' diff --git a/src/graphql/posts/queries.ts b/src/graphql/posts/queries.ts index 39f1269c..9f70e174 100644 --- a/src/graphql/posts/queries.ts +++ b/src/graphql/posts/queries.ts @@ -1,4 +1,4 @@ -import { getPostModel } from '../../db/PostSchema' +import { getPostModel } from '../../db/PostSchema.js' import { GetPostsInputType } from '../../db/PostTypes' const PostQueries = { diff --git a/src/graphql/resolvers.ts b/src/graphql/resolvers.ts index 1c85de7f..c3c81347 100644 --- a/src/graphql/resolvers.ts +++ b/src/graphql/resolvers.ts @@ -4,22 +4,22 @@ import fs from 'fs' import { gql } from 'apollo-server' import { DocumentNode } from 'graphql' -import { CommonResolvers, CommonTypeDef } from './common/index' -import { HistoryQueries, HistoryFieldResolvers } from '../graphql/history/index' +import { CommonResolvers, CommonTypeDef } from './common/index.js' +import { HistoryQueries, HistoryFieldResolvers } from '../graphql/history/index.js' import { QueryByIdType, GQLFilter, Sort, Context } from '../types' -import { AreaType, CountByDisciplineType } from '../db/AreaTypes' -import { ClimbGQLQueryType, ClimbType } from '../db/ClimbTypes' -import AreaDataSource from '../model/AreaDataSource' -import { MediaMutations, MediaQueries, MediaResolvers } from './media/index' -import { PostMutations, PostQueries, PostResolvers } from './posts/index' -import { XMediaMutations, XMediaQueries, XMediaResolvers } from './xmedia/index' -import { AreaQueries, AreaMutations } from './area/index' -import { ClimbMutations } from './climb/index' -import { OrganizationMutations, OrganizationQueries } from './organization/index' -import { TickMutations, TickQueries } from './tick/index' -import { UserQueries, UserMutations, UserResolvers } from './user/index' -import { getAuthorMetadataFromBaseNode } from '../db/utils/index' -import { geojsonPointToLatitude, geojsonPointToLongitude } from '../utils/helpers' +import { AreaType, CountByDisciplineType } from '../db/AreaTypes.js' +import { ClimbGQLQueryType, ClimbType } from '../db/ClimbTypes.js' +import AreaDataSource from '../model/AreaDataSource.js' +import { MediaMutations, MediaQueries, MediaResolvers } from './media/index.js' +import { PostMutations, PostQueries, PostResolvers } from './posts/index.js' +import { XMediaMutations, XMediaQueries, XMediaResolvers } from './xmedia/index.js' +import { AreaQueries, AreaMutations } from './area/index.js' +import { ClimbMutations } from './climb/index.js' +import { OrganizationMutations, OrganizationQueries } from './organization/index.js' +import { TickMutations, TickQueries } from './tick/index.js' +import { UserQueries, UserMutations, UserResolvers } from './user/index.js' +import { getAuthorMetadataFromBaseNode } from '../db/utils/index.js' +import { geojsonPointToLatitude, geojsonPointToLongitude } from '../utils/helpers.js' /** * It takes a file name as an argument, reads the file, and returns a GraphQL DocumentNode. diff --git a/src/graphql/tag/index.ts b/src/graphql/tag/index.ts index 17d23a1e..8714e1d2 100644 --- a/src/graphql/tag/index.ts +++ b/src/graphql/tag/index.ts @@ -1,4 +1,4 @@ -import TagQueries from './queries' -import TagResolvers from './TagResolvers' +import TagQueries from './queries.js' +import TagResolvers from './TagResolvers.js' export { TagQueries, TagResolvers } diff --git a/src/graphql/tag/queries.ts b/src/graphql/tag/queries.ts index 26709c62..97f8ef7b 100644 --- a/src/graphql/tag/queries.ts +++ b/src/graphql/tag/queries.ts @@ -1,5 +1,5 @@ -import { getTagModel } from '../../db/TagSchema' -import { GetTagsInputType } from '../../db/TagTypes' +import { getTagModel } from '../../db/TagSchema.js' +import { GetTagsInputType } from '../../db/TagTypes.js' const TagQueries = { // Given a list of TagIds, return a list of Tag documents. diff --git a/src/graphql/tick/index.ts b/src/graphql/tick/index.ts index f412f42f..234ac9d8 100644 --- a/src/graphql/tick/index.ts +++ b/src/graphql/tick/index.ts @@ -1,4 +1,4 @@ -import TickMutations from './TickMutations' -import TickQueries from './TickQueries' +import TickMutations from './TickMutations.js' +import TickQueries from './TickQueries.js' export { TickMutations, TickQueries } diff --git a/src/graphql/user/UserMutations.ts b/src/graphql/user/UserMutations.ts index 2e9fc389..9697d043 100644 --- a/src/graphql/user/UserMutations.ts +++ b/src/graphql/user/UserMutations.ts @@ -1,5 +1,5 @@ -import { DataSourcesType, ContextWithAuth } from '../../types' -import { UpdateProfileGQLInput } from '../../db/UserTypes' +import { DataSourcesType, ContextWithAuth } from '../../types.js' +import { UpdateProfileGQLInput } from '../../db/UserTypes.js' const UserMutations = { updateUserProfile: async (_: any, { input }, { dataSources, user: authenticatedUser }: ContextWithAuth) => { diff --git a/src/graphql/user/UserQueries.ts b/src/graphql/user/UserQueries.ts index eafcbaac..ef5d57d3 100644 --- a/src/graphql/user/UserQueries.ts +++ b/src/graphql/user/UserQueries.ts @@ -1,8 +1,8 @@ import muuid from 'uuid-mongodb' import { GraphQLError } from 'graphql' -import { DataSourcesType, ContextWithAuth, Context } from '../../types' -import { GetUsernameReturn, UserPublicProfile, UserPublicPage } from '../../db/UserTypes' +import { DataSourcesType, ContextWithAuth, Context } from '../../types.js' +import { GetUsernameReturn, UserPublicProfile, UserPublicPage } from '../../db/UserTypes.js' const UserQueries = { diff --git a/src/graphql/user/UserResolvers.ts b/src/graphql/user/UserResolvers.ts index ffde27cd..8bbe8549 100644 --- a/src/graphql/user/UserResolvers.ts +++ b/src/graphql/user/UserResolvers.ts @@ -1,4 +1,4 @@ -import { GetUsernameReturn, UserPublicProfile } from '../../db/UserTypes' +import { GetUsernameReturn, UserPublicProfile } from '../../db/UserTypes.js' const UserResolvers: object = { diff --git a/src/graphql/user/index.ts b/src/graphql/user/index.ts index b2584508..6de941cb 100644 --- a/src/graphql/user/index.ts +++ b/src/graphql/user/index.ts @@ -1,5 +1,5 @@ -import UserQueries from './UserQueries' -import UserMutations from './UserMutations' -import UserResolvers from './UserResolvers' +import UserQueries from './UserQueries.js' +import UserMutations from './UserMutations.js' +import UserResolvers from './UserResolvers.js' export { UserQueries, UserMutations, UserResolvers } diff --git a/src/graphql/xmedia/index.ts b/src/graphql/xmedia/index.ts index 165c14c7..5fbf9429 100644 --- a/src/graphql/xmedia/index.ts +++ b/src/graphql/xmedia/index.ts @@ -1,5 +1,5 @@ -import XMediaQueries from './queries' -import XMediaMutations from './mutations' -import XMediaResolvers from './XMediaResolvers' +import XMediaQueries from './queries.js' +import XMediaMutations from './mutations.js' +import XMediaResolvers from './XMediaResolvers.js' export { XMediaQueries, XMediaMutations, XMediaResolvers } diff --git a/src/graphql/xmedia/mutations.ts b/src/graphql/xmedia/mutations.ts index cfd53312..fc79f2ad 100644 --- a/src/graphql/xmedia/mutations.ts +++ b/src/graphql/xmedia/mutations.ts @@ -1,5 +1,5 @@ import { XMediaType, RemoveXMediaInputType } from '../../db/XMediaTypes' -import { getXMediaModel } from '../../db/XMediaSchema' +import { getXMediaModel } from '../../db/XMediaSchema.js' import { Context } from '../../types' const XMediaMutations = { diff --git a/src/graphql/xmedia/queries.ts b/src/graphql/xmedia/queries.ts index d4b1f5a9..ac9bcdf6 100644 --- a/src/graphql/xmedia/queries.ts +++ b/src/graphql/xmedia/queries.ts @@ -1,5 +1,5 @@ -import { getXMediaModel } from '../../db/XMediaSchema' -import { GetXMediaInputType } from '../../db/XMediaTypes' +import { getXMediaModel } from '../../db/XMediaSchema.js' +import { GetXMediaInputType } from '../../db/XMediaTypes.js' const XMediaQueries = { // Given a list of xMediaIds, return a list of xMedia documents. diff --git a/src/main.ts b/src/main.ts index 84c7b12c..2af67fe9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ -import { logger } from './logger' -import { connectDB, defaultPostConnect } from './db/index' -import { createServer } from './server' +import { logger } from './logger.js' +import { connectDB, defaultPostConnect } from './db/index.js' +import { createServer } from './server.js' const port = 4000 const server = await createServer() diff --git a/src/model/AreaDataSource.ts b/src/model/AreaDataSource.ts index def5585a..2f4f3839 100644 --- a/src/model/AreaDataSource.ts +++ b/src/model/AreaDataSource.ts @@ -3,12 +3,12 @@ import { Filter } from 'mongodb' import muuid from 'uuid-mongodb' import bboxPolygon from '@turf/bbox-polygon' -import { getAreaModel, getMediaObjectModel } from '../db/index' +import { getAreaModel, getMediaObjectModel } from '../db/index.js' import { AreaType } from '../db/AreaTypes' import { GQLFilter, AreaFilterParams, PathTokenParams, LeafStatusParams, ComparisonFilterParams, StatisticsType, CragsNear, BBoxType } from '../types' -import { getClimbModel } from '../db/ClimbSchema' -import { ClimbGQLQueryType } from '../db/ClimbTypes' -import { logger } from '../logger' +import { getClimbModel } from '../db/ClimbSchema.js' +import { ClimbGQLQueryType } from '../db/ClimbTypes.js' +import { logger } from '../logger.js' export default class AreaDataSource extends MongoDataSource { areaModel = getAreaModel() diff --git a/src/model/AreaHistoryDatasource.ts b/src/model/AreaHistoryDatasource.ts index c620597c..be02ddeb 100644 --- a/src/model/AreaHistoryDatasource.ts +++ b/src/model/AreaHistoryDatasource.ts @@ -1,7 +1,7 @@ import { MongoDataSource } from 'apollo-datasource-mongodb' import { MUUID } from 'uuid-mongodb' -import { AreaChangeLogType } from '../db/ChangeLogType' -import { getChangeLogModel } from '../db/index' +import { AreaChangeLogType } from '../db/ChangeLogType.js' +import { getChangeLogModel } from '../db/index.js' export class AreaHistoryDataSource extends MongoDataSource { changelogModel = getChangeLogModel() diff --git a/src/model/ChangeLogDataSource.ts b/src/model/ChangeLogDataSource.ts index 9d45de38..267a6215 100644 --- a/src/model/ChangeLogDataSource.ts +++ b/src/model/ChangeLogDataSource.ts @@ -2,11 +2,11 @@ import mongoose, { ClientSession } from 'mongoose' import { MongoDataSource } from 'apollo-datasource-mongodb' import { MUUID } from 'uuid-mongodb' -import { getChangeLogModel } from '../db/index' +import { getChangeLogModel } from '../db/index.js' import { ChangeLogType, OpType, BaseChangeRecordType, AreaChangeLogType, ClimbChangeLogType, OrganizationChangeLogType } from '../db/ChangeLogType' -import { logger } from '../logger' -import { areaHistoryDataSource } from './AreaHistoryDatasource' -import { organizationHistoryDataSource } from './OrganizationHistoryDatasource' +import { logger } from '../logger.js' +import { areaHistoryDataSource } from './AreaHistoryDatasource.js' +import { organizationHistoryDataSource } from './OrganizationHistoryDatasource.js' export default class ChangeLogDataSource extends MongoDataSource { changeLogModel = getChangeLogModel() diff --git a/src/model/ClimbDataSource.ts b/src/model/ClimbDataSource.ts index 8eb585f6..61ce714d 100644 --- a/src/model/ClimbDataSource.ts +++ b/src/model/ClimbDataSource.ts @@ -1,8 +1,8 @@ import { MongoDataSource } from 'apollo-datasource-mongodb' import { MUUID } from 'uuid-mongodb' -import { getAreaModel } from '../db/AreaSchema' -import { getClimbModel } from '../db/ClimbSchema' -import { ClimbType } from '../db/ClimbTypes' +import { getAreaModel } from '../db/AreaSchema.js' +import { getClimbModel } from '../db/ClimbSchema.js' +import { ClimbType } from '../db/ClimbTypes.js' // TODO move climb helper functions from AreaDataSource here export default class ClimbDataSource extends MongoDataSource { diff --git a/src/model/ExperimentalUserDataSource.ts b/src/model/ExperimentalUserDataSource.ts index ba55be3c..2aabb818 100644 --- a/src/model/ExperimentalUserDataSource.ts +++ b/src/model/ExperimentalUserDataSource.ts @@ -3,8 +3,8 @@ import mongoose, { ClientSession } from 'mongoose' import muuid, { MUUID } from 'uuid-mongodb' import { v5 as uuidv5, NIL } from 'uuid' -import { getExperimentalUserModel } from '../db/index' -import { ExperimentalUserType } from '../db/UserTypes' +import { getExperimentalUserModel } from '../db/index.js' +import { ExperimentalUserType } from '../db/UserTypes.js' export default class MediaDataSource extends MongoDataSource { experimentUserModel = getExperimentalUserModel() diff --git a/src/model/MediaDataSource.ts b/src/model/MediaDataSource.ts index 09a0940d..8e34c726 100644 --- a/src/model/MediaDataSource.ts +++ b/src/model/MediaDataSource.ts @@ -1,9 +1,9 @@ import { MongoDataSource } from 'apollo-datasource-mongodb' import muid, { MUUID } from 'uuid-mongodb' import mongoose from 'mongoose' -import { logger } from '../logger' -import { getMediaObjectModel } from '../db/index' -import { TagsLeaderboardType, UserMediaQueryInput, AllTimeTagStats, MediaByUsers, MediaForFeedInput, MediaObject, UserMedia } from '../db/MediaObjectTypes' +import { logger } from '../logger.js' +import { getMediaObjectModel } from '../db/index.js' +import { TagsLeaderboardType, UserMediaQueryInput, AllTimeTagStats, MediaByUsers, MediaForFeedInput, MediaObject, UserMedia } from '../db/MediaObjectTypes.js' const HARD_MAX_FILES = 1000 const HARD_MAX_USERS = 100 diff --git a/src/model/MutableAreaDataSource.ts b/src/model/MutableAreaDataSource.ts index c5f30cd7..bdd67b08 100644 --- a/src/model/MutableAreaDataSource.ts +++ b/src/model/MutableAreaDataSource.ts @@ -5,20 +5,20 @@ import mongoose, { ClientSession } from 'mongoose' import { produce } from 'immer' import { UserInputError } from 'apollo-server' import isoCountries from 'i18n-iso-countries' -import enJson from 'i18n-iso-countries/langs/en.json' - -import { AreaType, AreaEditableFieldsType, OperationType, UpdateSortingOrderType } from '../db/AreaTypes' -import AreaDataSource from './AreaDataSource' -import { createRootNode } from '../db/import/usa/AreaTree' -import { makeDBArea } from '../db/import/usa/AreaTransformer' -import { changelogDataSource } from './ChangeLogDataSource' -import { ChangeRecordMetadataType } from '../db/ChangeLogType' -import CountriesLngLat from '../data/countries-with-lnglat.json' -import { logger } from '../logger' -import { GradeContexts } from '../GradeUtils' -import { sanitizeStrict } from '../utils/sanitize' -import { ExperimentalAuthorType } from '../db/UserTypes' -import { createInstance as createExperimentalUserDataSource } from '../model/ExperimentalUserDataSource' +import enJson from 'i18n-iso-countries/langs/en.json' assert { type: 'json' } + +import { AreaType, AreaEditableFieldsType, OperationType, UpdateSortingOrderType } from '../db/AreaTypes.js' +import AreaDataSource from './AreaDataSource.js' +import { createRootNode } from '../db/import/usa/AreaTree.js' +import { makeDBArea } from '../db/import/usa/AreaTransformer.js' +import { changelogDataSource } from './ChangeLogDataSource.js' +import { ChangeRecordMetadataType } from '../db/ChangeLogType.js' +import CountriesLngLat from '../data/countries-with-lnglat.json' assert { type: 'json' } +import { logger } from '../logger.js' +import { GradeContexts } from '../GradeUtils.js' +import { sanitizeStrict } from '../utils/sanitize.js' +import { ExperimentalAuthorType } from '../db/UserTypes.js' +import { createInstance as createExperimentalUserDataSource } from '../model/ExperimentalUserDataSource.js' isoCountries.registerLocale(enJson) diff --git a/src/model/MutableClimbDataSource.ts b/src/model/MutableClimbDataSource.ts index 2fbba27d..10375dd8 100644 --- a/src/model/MutableClimbDataSource.ts +++ b/src/model/MutableClimbDataSource.ts @@ -2,14 +2,14 @@ import muid, { MUUID } from 'uuid-mongodb' import { UserInputError } from 'apollo-server' import { ClientSession } from 'mongoose' -import { ClimbChangeDocType, ClimbChangeInputType, ClimbEditOperationType, IPitch } from '../db/ClimbTypes' -import ClimbDataSource from './ClimbDataSource' -import { createInstance as createExperimentalUserDataSource } from './ExperimentalUserDataSource' -import { sanitizeDisciplines, gradeContextToGradeScales, createGradeObject } from '../GradeUtils' -import { getClimbModel } from '../db/ClimbSchema' -import { ChangeRecordMetadataType } from '../db/ChangeLogType' -import { changelogDataSource } from './ChangeLogDataSource' -import { sanitize, sanitizeStrict } from '../utils/sanitize' +import { ClimbChangeDocType, ClimbChangeInputType, ClimbEditOperationType, IPitch } from '../db/ClimbTypes.js' +import ClimbDataSource from './ClimbDataSource.js' +import { createInstance as createExperimentalUserDataSource } from './ExperimentalUserDataSource.js' +import { sanitizeDisciplines, gradeContextToGradeScales, createGradeObject } from '../GradeUtils.js' +import { getClimbModel } from '../db/ClimbSchema.js' +import { ChangeRecordMetadataType } from '../db/ChangeLogType.js' +import { changelogDataSource } from './ChangeLogDataSource.js' +import { sanitize, sanitizeStrict } from '../utils/sanitize.js' export default class MutableClimbDataSource extends ClimbDataSource { experimentalUserDataSource = createExperimentalUserDataSource() diff --git a/src/model/MutableMediaDataSource.ts b/src/model/MutableMediaDataSource.ts index 700d2664..75cdef29 100644 --- a/src/model/MutableMediaDataSource.ts +++ b/src/model/MutableMediaDataSource.ts @@ -2,9 +2,9 @@ import { UserInputError } from 'apollo-server' import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import MediaDataSource from './MediaDataSource' -import { EntityTag, EntityTagDeleteInput, MediaObject, MediaObjectGQLInput, AddTagEntityInput, NewMediaObjectDoc } from '../db/MediaObjectTypes' -import MutableAreaDataSource from './MutableAreaDataSource' +import MediaDataSource from './MediaDataSource.js' +import { EntityTag, EntityTagDeleteInput, MediaObject, MediaObjectGQLInput, AddTagEntityInput, NewMediaObjectDoc } from '../db/MediaObjectTypes.js' +import MutableAreaDataSource from './MutableAreaDataSource.js' export default class MutableMediaDataSource extends MediaDataSource { areaDS = MutableAreaDataSource.getInstance() diff --git a/src/model/MutableOrganizationDataSource.ts b/src/model/MutableOrganizationDataSource.ts index ecb349a3..06a79688 100644 --- a/src/model/MutableOrganizationDataSource.ts +++ b/src/model/MutableOrganizationDataSource.ts @@ -2,13 +2,13 @@ import mongoose, { ClientSession } from 'mongoose' import muuid, { MUUID } from 'uuid-mongodb' import { produce } from 'immer' -import { OrganizationType, OperationType, OrgType, OrganizationEditableFieldsType } from '../db/OrganizationTypes' -import OrganizationDataSource from './OrganizationDataSource' -import { changelogDataSource } from './ChangeLogDataSource' -import { ChangeRecordMetadataType } from '../db/ChangeLogType' -import { sanitize, sanitizeStrict } from '../utils/sanitize' -import { muuidToString } from '../utils/helpers' -import { getAreaModel } from '../db/AreaSchema' +import { OrganizationType, OperationType, OrgType, OrganizationEditableFieldsType } from '../db/OrganizationTypes.js' +import OrganizationDataSource from './OrganizationDataSource.js' +import { changelogDataSource } from './ChangeLogDataSource.js' +import { ChangeRecordMetadataType } from '../db/ChangeLogType.js' +import { sanitize, sanitizeStrict } from '../utils/sanitize.js' +import { muuidToString } from '../utils/helpers.js' +import { getAreaModel } from '../db/AreaSchema.js' export default class MutableOrganizationDataSource extends OrganizationDataSource { /** diff --git a/src/model/OrganizationDataSource.ts b/src/model/OrganizationDataSource.ts index 7a4596cd..f89a6add 100644 --- a/src/model/OrganizationDataSource.ts +++ b/src/model/OrganizationDataSource.ts @@ -3,10 +3,10 @@ import { Filter } from 'mongodb' import type { FindCursor, WithId } from 'mongodb' import muuid from 'uuid-mongodb' -import { getOrganizationModel } from '../db/index' +import { getOrganizationModel } from '../db/index.js' import { AssociatedAreaIdsFilterParams, DisplayNameFilterParams, ExcludedAreaIdsFilterParams, OrganizationGQLFilter } from '../types' -import { OrganizationType } from '../db/OrganizationTypes' -import { muuidToString } from '../utils/helpers' +import { OrganizationType } from '../db/OrganizationTypes.js' +import { muuidToString } from '../utils/helpers.js' export default class OrganizationDataSource extends MongoDataSource { organizationModel = getOrganizationModel() diff --git a/src/model/OrganizationHistoryDatasource.ts b/src/model/OrganizationHistoryDatasource.ts index 28645b4a..25252231 100644 --- a/src/model/OrganizationHistoryDatasource.ts +++ b/src/model/OrganizationHistoryDatasource.ts @@ -1,7 +1,7 @@ import { MongoDataSource } from 'apollo-datasource-mongodb' import { MUUID } from 'uuid-mongodb' -import { OrganizationChangeLogType } from '../db/ChangeLogType' -import { getChangeLogModel } from '../db/index' +import { OrganizationChangeLogType } from '../db/ChangeLogType.js' +import { getChangeLogModel } from '../db/index.js' export class OrganizationHistoryDataSource extends MongoDataSource { changelogModel = getChangeLogModel() diff --git a/src/model/PostDataSource.ts b/src/model/PostDataSource.ts index 4deb9723..07c8310b 100644 --- a/src/model/PostDataSource.ts +++ b/src/model/PostDataSource.ts @@ -1,6 +1,6 @@ import { MongoDataSource } from 'apollo-datasource-mongodb' import { PostType } from '../db/PostTypes' -import { getPostModel } from '../db/index' +import { getPostModel } from '../db/index.js' /** * Not being used at the moment diff --git a/src/model/TickDataSource.ts b/src/model/TickDataSource.ts index f55213cf..b546ebd4 100644 --- a/src/model/TickDataSource.ts +++ b/src/model/TickDataSource.ts @@ -3,7 +3,7 @@ import type { DeleteResult } from 'mongodb' import mongoose from 'mongoose' import { TickEditFilterType, TickInput, TickType, TickUserSelectors } from '../db/TickTypes' -import { getTickModel, getUserModel } from '../db/index' +import { getTickModel, getUserModel } from '../db/index.js' import type { User } from '../db/UserTypes' export default class TickDataSource extends MongoDataSource { diff --git a/src/model/UserDataSource.ts b/src/model/UserDataSource.ts index 29757a17..aa5f4bc8 100644 --- a/src/model/UserDataSource.ts +++ b/src/model/UserDataSource.ts @@ -3,16 +3,16 @@ import muid, { MUUID } from 'uuid-mongodb' import mongoose from 'mongoose' import differenceInDays from 'date-fns/differenceInDays/index.js' -import { getUserModel } from '../db/index' +import { getUserModel } from '../db/index.js' import { User, UpdateProfileGQLInput, UsernameInfo, GetUsernameReturn, UserPublicProfile -} from '../db/UserTypes' -import { trimToNull } from '../utils/sanitize' -import { canonicalizeUsername } from '../utils/helpers' +} from '../db/UserTypes.js' +import { trimToNull } from '../utils/sanitize.js' +import { canonicalizeUsername } from '../utils/helpers.js' const USERNAME_UPDATE_WAITING_IN_DAYS = 14 diff --git a/src/model/XMediaDataSource.ts b/src/model/XMediaDataSource.ts index 4c8bd1de..d14bbdce 100644 --- a/src/model/XMediaDataSource.ts +++ b/src/model/XMediaDataSource.ts @@ -1,6 +1,6 @@ import { MongoDataSource } from 'apollo-datasource-mongodb' import { XMediaType } from '../db/XMediaTypes' -import { getXMediaModel } from '../db/index' +import { getXMediaModel } from '../db/index.js' /** * Not being used at the moment diff --git a/src/model/__tests__/AreaHistoryDataSource.ts b/src/model/__tests__/AreaHistoryDataSource.ts index e30588fa..171433b3 100644 --- a/src/model/__tests__/AreaHistoryDataSource.ts +++ b/src/model/__tests__/AreaHistoryDataSource.ts @@ -3,12 +3,12 @@ import { ChangeStream } from 'mongodb' import { jest } from '@jest/globals' import muuid from 'uuid-mongodb' -import MutableAreaDataSource from '../MutableAreaDataSource' -import { connectDB, createIndexes, getAreaModel } from '../../db/index' -import streamListener from '../../db/edit/streamListener' -import { logger } from '../../logger' -import { changelogDataSource } from '../ChangeLogDataSource' -import { OperationType } from '../../db/AreaTypes' +import MutableAreaDataSource from '../MutableAreaDataSource.js' +import { connectDB, createIndexes, getAreaModel } from '../../db/index.js' +import streamListener from '../../db/edit/streamListener.js' +import { logger } from '../../logger.js' +import { changelogDataSource } from '../ChangeLogDataSource.js' +import { OperationType } from '../../db/AreaTypes.js' jest.setTimeout(120000) diff --git a/src/model/__tests__/ChangeLogDS.ts b/src/model/__tests__/ChangeLogDS.ts index c1b7a734..4edfa5fb 100644 --- a/src/model/__tests__/ChangeLogDS.ts +++ b/src/model/__tests__/ChangeLogDS.ts @@ -1,12 +1,12 @@ import mongoose from 'mongoose' import { jest } from '@jest/globals' import muuid from 'uuid-mongodb' -import { connectDB, getChangeLogModel, getAreaModel } from '../../db/index' -import ChangeLogDataSource from '../ChangeLogDataSource' -import { OpType } from '../../db/ChangeLogType' -import { OperationType } from '../../db/AreaTypes' +import { connectDB, getChangeLogModel, getAreaModel } from '../../db/index.js' +import ChangeLogDataSource from '../ChangeLogDataSource.js' +import { OpType } from '../../db/ChangeLogType.js' +import { OperationType } from '../../db/AreaTypes.js' -import { logger } from '../../logger' +import { logger } from '../../logger.js' jest.setTimeout(10000) diff --git a/src/model/__tests__/MediaDataSource.ts b/src/model/__tests__/MediaDataSource.ts index ef2a20fe..83a65c7c 100644 --- a/src/model/__tests__/MediaDataSource.ts +++ b/src/model/__tests__/MediaDataSource.ts @@ -4,10 +4,10 @@ import MutableMediaDataSource from '../MutableMediaDataSource' import AreaDataSource from '../MutableAreaDataSource' import ClimbDataSource from '../MutableClimbDataSource' -import { connectDB, createIndexes } from '../../db/index' -import { AreaType } from '../../db/AreaTypes' -import { EntityTag, MediaObject, MediaObjectGQLInput, AddTagEntityInput, UserMediaQueryInput, UserMedia } from '../../db/MediaObjectTypes' -import { newSportClimb1 } from './MutableClimbDataSource' +import { connectDB, createIndexes } from '../../db/index.js' +import { AreaType } from '../../db/AreaTypes.js' +import { EntityTag, MediaObject, MediaObjectGQLInput, AddTagEntityInput, UserMediaQueryInput, UserMedia } from '../../db/MediaObjectTypes.js' +import { newSportClimb1 } from './MutableClimbDataSource.js' const TEST_MEDIA: MediaObjectGQLInput = { userUuid: 'a2eb6353-65d1-445f-912c-53c6301404bd', diff --git a/src/model/__tests__/MutableClimbDataSource.ts b/src/model/__tests__/MutableClimbDataSource.ts index ab5058dc..911ab721 100644 --- a/src/model/__tests__/MutableClimbDataSource.ts +++ b/src/model/__tests__/MutableClimbDataSource.ts @@ -2,15 +2,15 @@ import mongoose from 'mongoose' import muid from 'uuid-mongodb' import { ChangeStream } from 'mongodb' -import MutableClimbDataSource from '../MutableClimbDataSource' -import MutableAreaDataSource from '../MutableAreaDataSource' - -import { connectDB, createIndexes, getAreaModel, getClimbModel } from '../../db/index' -import { logger } from '../../logger' -import { ClimbType, ClimbChangeInputType } from '../../db/ClimbTypes' -import { sanitizeDisciplines } from '../../GradeUtils' -import streamListener from '../../db/edit/streamListener' -import { changelogDataSource } from '../ChangeLogDataSource' +import MutableClimbDataSource from '../MutableClimbDataSource.js' +import MutableAreaDataSource from '../MutableAreaDataSource.js' + +import { connectDB, createIndexes, getAreaModel, getClimbModel } from '../../db/index.js' +import { logger } from '../../logger.js' +import { ClimbType, ClimbChangeInputType } from '../../db/ClimbTypes.js' +import { sanitizeDisciplines } from '../../GradeUtils.js' +import streamListener from '../../db/edit/streamListener.js' +import { changelogDataSource } from '../ChangeLogDataSource.js' export const newSportClimb1: ClimbChangeInputType = { name: 'Cool route 1', diff --git a/src/model/__tests__/MutableOrganizationDataSource.ts b/src/model/__tests__/MutableOrganizationDataSource.ts index 8bb38025..e2f06cca 100644 --- a/src/model/__tests__/MutableOrganizationDataSource.ts +++ b/src/model/__tests__/MutableOrganizationDataSource.ts @@ -1,12 +1,12 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' -import MutableOrganizationDataSource from '../MutableOrganizationDataSource' -import MutableAreaDataSource from '../MutableAreaDataSource' -import { connectDB, createIndexes, getAreaModel, getOrganizationModel } from '../../db/index' -import { OrganizationEditableFieldsType, OrgType } from '../../db/OrganizationTypes' -import { AreaType } from '../../db/AreaTypes' -import { muuidToString } from '../../utils/helpers' +import MutableOrganizationDataSource from '../MutableOrganizationDataSource.js' +import MutableAreaDataSource from '../MutableAreaDataSource.js' +import { connectDB, createIndexes, getAreaModel, getOrganizationModel } from '../../db/index.js' +import { OrganizationEditableFieldsType, OrgType } from '../../db/OrganizationTypes.js' +import { AreaType } from '../../db/AreaTypes.js' +import { muuidToString } from '../../utils/helpers.js' describe('Organization', () => { let organizations: MutableOrganizationDataSource diff --git a/src/model/__tests__/UserDataSource.ts b/src/model/__tests__/UserDataSource.ts index 1b2c3aa7..2921b247 100644 --- a/src/model/__tests__/UserDataSource.ts +++ b/src/model/__tests__/UserDataSource.ts @@ -2,9 +2,9 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' import { jest } from '@jest/globals' -import { connectDB, getUserModel } from '../../db/index' -import UserDataSource from '../UserDataSource' -import { UpdateProfileGQLInput } from '../../db/UserTypes' +import { connectDB, getUserModel } from '../../db/index.js' +import UserDataSource from '../UserDataSource.js' +import { UpdateProfileGQLInput } from '../../db/UserTypes.js' describe('UserDataSource', () => { let users: UserDataSource diff --git a/src/model/__tests__/ticks.ts b/src/model/__tests__/ticks.ts index b6487ca1..5325f34c 100644 --- a/src/model/__tests__/ticks.ts +++ b/src/model/__tests__/ticks.ts @@ -1,11 +1,11 @@ import mongoose from 'mongoose' import { produce } from 'immer' -import TickDataSource from '../TickDataSource' -import { connectDB, getTickModel, getUserModel } from '../../db/index' -import { TickInput } from '../../db/TickTypes' +import TickDataSource from '../TickDataSource.js' +import { connectDB, getTickModel, getUserModel } from '../../db/index.js' +import { TickInput } from '../../db/TickTypes.js' import muuid from 'uuid-mongodb' -import UserDataSource from '../UserDataSource' -import { UpdateProfileGQLInput } from '../../db/UserTypes' +import UserDataSource from '../UserDataSource.js' +import { UpdateProfileGQLInput } from '../../db/UserTypes.js' const userId = muuid.v4() diff --git a/src/model/__tests__/updateAreas.ts b/src/model/__tests__/updateAreas.ts index c320c012..693edc68 100644 --- a/src/model/__tests__/updateAreas.ts +++ b/src/model/__tests__/updateAreas.ts @@ -2,10 +2,10 @@ import mongoose from 'mongoose' import muuid from 'uuid-mongodb' import { geometry } from '@turf/helpers' -import MutableAreaDataSource from '../MutableAreaDataSource' -import MutableClimbDataSource from '../MutableClimbDataSource' -import { connectDB, createIndexes, getAreaModel, getClimbModel } from '../../db/index' -import { AreaEditableFieldsType, UpdateSortingOrderType } from '../../db/AreaTypes' +import MutableAreaDataSource from '../MutableAreaDataSource.js' +import MutableClimbDataSource from '../MutableClimbDataSource.js' +import { connectDB, createIndexes, getAreaModel, getClimbModel } from '../../db/index.js' +import { AreaEditableFieldsType, UpdateSortingOrderType } from '../../db/AreaTypes.js' describe('Areas', () => { let areas: MutableAreaDataSource diff --git a/src/server.ts b/src/server.ts index 714a7337..b7c98621 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,20 +1,20 @@ import { ApolloServer } from 'apollo-server' import mongoose from 'mongoose' import { applyMiddleware } from 'graphql-middleware' -import { graphqlSchema } from './graphql/resolvers' +import { graphqlSchema } from './graphql/resolvers.js' -import MutableAreaDataSource from './model/MutableAreaDataSource' -import ChangeLogDataSource from './model/ChangeLogDataSource' -import MutableMediaDataSource from './model/MutableMediaDataSource' -import MutableClimbDataSource from './model/MutableClimbDataSource' -import TickDataSource from './model/TickDataSource' -import { createContext, permissions } from './auth/index' -import XMediaDataSource from './model/XMediaDataSource' -import PostDataSource from './model/PostDataSource' -import MutableOrgDS from './model/MutableOrganizationDataSource' -import type { Context } from './types' +import MutableAreaDataSource from './model/MutableAreaDataSource.js' +import ChangeLogDataSource from './model/ChangeLogDataSource.js' +import MutableMediaDataSource from './model/MutableMediaDataSource.js' +import MutableClimbDataSource from './model/MutableClimbDataSource.js' +import TickDataSource from './model/TickDataSource.js' +import { createContext, permissions } from './auth/index.js' +import XMediaDataSource from './model/XMediaDataSource.js' +import PostDataSource from './model/PostDataSource.js' +import MutableOrgDS from './model/MutableOrganizationDataSource.js' +import type { Context } from './types.js' import type { DataSources } from 'apollo-server-core/dist/graphqlOptions' -import UserDataSource from './model/UserDataSource' +import UserDataSource from './model/UserDataSource.js' export async function createServer (): Promise { const schema = applyMiddleware( diff --git a/src/types.ts b/src/types.ts index 6cd70ceb..79bc66b8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,16 +1,16 @@ import { BBox } from '@turf/helpers' import { MUUID } from 'uuid-mongodb' -import { AreaType } from './db/AreaTypes' -import type MutableAreaDataSource from './model/MutableAreaDataSource' -import type TickDataSource from './model/TickDataSource' -import type HistoryDataSouce from './model/ChangeLogDataSource' -import type MutableMediaDataSource from './model/MutableMediaDataSource' -import MutableClimbDataSource from './model/MutableClimbDataSource' -import XMediaDataSource from './model/XMediaDataSource' -import PostDataSource from './model/PostDataSource' -import MutableOrganizationDataSource from './model/MutableOrganizationDataSource' -import type UserDataSource from './model/UserDataSource' +import { AreaType } from './db/AreaTypes.js' +import type MutableAreaDataSource from './model/MutableAreaDataSource.js' +import type TickDataSource from './model/TickDataSource.js' +import type HistoryDataSouce from './model/ChangeLogDataSource.js' +import type MutableMediaDataSource from './model/MutableMediaDataSource.js' +import MutableClimbDataSource from './model/MutableClimbDataSource.js' +import XMediaDataSource from './model/XMediaDataSource.js' +import PostDataSource from './model/PostDataSource.js' +import MutableOrganizationDataSource from './model/MutableOrganizationDataSource.js' +import type UserDataSource from './model/UserDataSource.js' export enum SortDirection { ASC = 1, diff --git a/src/utils/inMemoryDB.ts b/src/utils/inMemoryDB.ts index f2c58e3b..567bdd46 100644 --- a/src/utils/inMemoryDB.ts +++ b/src/utils/inMemoryDB.ts @@ -1,8 +1,8 @@ import mongoose, { ConnectOptions } from 'mongoose' import { ChangeStream, MongoClient } from 'mongodb' import { MongoMemoryReplSet } from 'mongodb-memory-server' -import { defaultPostConnect, checkVar } from '../db/index' -import { logger } from '../logger' +import { defaultPostConnect, checkVar } from '../db/index.js' +import { logger } from '../logger.js' /** * In-memory Mongo replset used for testing. diff --git a/src/utils/testUtils.ts b/src/utils/testUtils.ts index b53d03a7..7013f5a0 100644 --- a/src/utils/testUtils.ts +++ b/src/utils/testUtils.ts @@ -1,9 +1,9 @@ import jwt from 'jsonwebtoken' import { jest } from '@jest/globals' import request from 'supertest' -import inMemoryDB from './inMemoryDB' -import type { InMemoryDB } from './inMemoryDB' -import { createServer } from '../server' +import inMemoryDB from './inMemoryDB.js' +import type { InMemoryDB } from './inMemoryDB.js' +import { createServer } from '../server.js' import { ApolloServer } from 'apollo-server' const PORT = 4000 diff --git a/tsconfig.json b/tsconfig.json index 1d67eeea..871ed609 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,4 +21,4 @@ "include": [ "src/**/*.ts", ] -} +} \ No newline at end of file diff --git a/tsconfig.release.json b/tsconfig.release.json index 2d41042a..96e646f3 100644 --- a/tsconfig.release.json +++ b/tsconfig.release.json @@ -5,4 +5,4 @@ "**/__mocks__/*", "**/__tests__/*" ] -} +} \ No newline at end of file