Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: Models(utils) #218

Merged
merged 8 commits into from
Jul 16, 2024
Merged

Conversation

alukach
Copy link
Contributor

@alukach alukach commented Jun 14, 2024

What I'm changing

This PR converts src/api/db/models/utils.js to TypeScript.

How I did it

  • Add types for mongodb-query-parser to get around the following issue:
    Could not find a declaration file for module 'mongodb-query-parser'. '/Users/alukach/Projects/devseed/animl/animl-api/node_modules/mongodb-query-parser/dist/.esm-wrapper.mjs' implicitly has an 'any' type.
      There are types at '/Users/alukach/Projects/devseed/animl/animl-api/node_modules/mongodb-query-parser/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'mongodb-query-parser' library may need to update its package.json or typings. ts(7016)
    
  • Merge src/api/db/models/utils-model.ts into src/api/db/models/utils.ts
  • Schema changes (same as Mark all values in arrays as required #222)
  • Fix src/api/db/models/Camera.ts and src/api/db/models/ImageError.ts as they both had been mistakenly using @hasRole rather than @roleCheck
  • Make additional schema types importable

part of #187

@alukach alukach force-pushed the feature/typescript/models-utils branch from 9bb78db to 915ec33 Compare June 20, 2024 22:59
@alukach alukach mentioned this pull request Jun 20, 2024
8 tasks
@alukach alukach changed the title [IN PROGRESS] TypeScript: Models(utils) TypeScript: Models(utils) Jun 20, 2024
src/api/db/models/utils.ts Outdated Show resolved Hide resolved
@@ -2,7 +2,7 @@ import GraphQLError, { InternalServerError } from '../../errors.js';
import { WRITE_IMAGES_ROLES } from '../../auth/roles.js';
import BatchError, { BatchErrorSchema } from '../schemas/BatchError.js';
import retry from 'async-retry';
import { BaseAuthedModel, GenericResponse, MethodParams, roleCheck } from './utils-model.js';
import { BaseAuthedModel, GenericResponse, MethodParams, roleCheck } from './utils.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of these should now be imported from ./utils.ts?

@nathanielrindlaub nathanielrindlaub merged commit f2a06d4 into main Jul 16, 2024
3 checks passed
@alukach alukach deleted the feature/typescript/models-utils branch July 17, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants