Skip to content

The new core#55

Open
jadrubio wants to merge 43 commits intomainfrom
the-new-core
Open

The new core#55
jadrubio wants to merge 43 commits intomainfrom
the-new-core

Conversation

@jadrubio
Copy link
Copy Markdown
Collaborator

@jadrubio jadrubio commented Dec 1, 2025

Description

Related Jira Tickets

Comments

Please ensure all items are complete before requesting a review:

  • Code Completed: All code for the feature or bugfix has been implemented.
  • Unit Tests Added: Unit tests are written for all new functionality, covering edge cases where applicable.
  • Integration Tests (where necessary): Integration tests are added for interactions between modules or components.
  • All Tests Passing: All unit and integration tests are passing.
  • Type Safety Checked: Ensure TypeScript types are correctly defined and used. Avoid any types without proper justification.
  • Typedoc Comments Added: Ensure all functions, classes, interfaces, and types are documented using TypeDoc syntax.
  • Code Formatting: All code files are formatted according to the project’s standards (e.g., Prettier, ESLint) and no linting errors remain.
  • No Console Logs: Remove any console.log or other debugging output from the code.
  • Documentation Updated: Update relevant project documentation (e.g., README, configuration guides) if necessary.

@jadrubio jadrubio requested review from numerator and peiyaoh December 1, 2025 18:39
Comment thread src/__tests__/README.md Outdated
@@ -0,0 +1,273 @@
# Testing Philosophy & Practices for @just-in/core
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I love this! I'll need to spend more time with it to wrap my head around the parts about mocking and spying and/or if those parts might need a bit more, but overall the philosophy and approach is great and I love that you put in the effort to get this document off the ground!

Comment thread src/logger/global.ts
}
}

let _globalMinLevel: string = (process.env.LOG_LEVEL as string) ?? 'DEBUG';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Non blocking] Is it correct to understand it as the default min level that will be applied if nothing is specified? In other words, it is the default value that can be used globally across an application.

import { NO_ID } from '../data-manager.constants';
import { createLogger } from '../../logger/logger';

const Log = createLogger({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's very exciting/lovely to see we can declare logger with context to scope it. Very easy to use and understand.

collectionName: string,
changeType: CollectionChangeType
): void {
public removeChangeListener(collectionName: string, changeType: CollectionChangeType): void {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[For the body] It takes some time for me to understand why we need a custom cleanup for/before destruction, but now I can appreciate the thinking behind it.

* @param {string} storeName - The collection/table name.
* @param {Array<{name?: string; key: unknown; unique?: boolean; partialFilterExpression?: unknown}>} indexes
*/
public async ensureIndexes(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Love the support of index! It will be super useful.

throw new Error('MongoDB is the only supported DB type');
}
await this.db.init();
this.isInitialized = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was wondering whether we actually need isInitialized in data-manager, instead of letting the db (mongo-manager in this case) provide that status. It seems that the status is entirely dependent on the underlying DB's status. In that case, would it be better to have a single source of truth if no additional initialization is required?

Comment on lines 140 to 141
if (collectionName === USERS) {
this.emit('userAdded', newItem);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we standardize it so that it could in theory work for any collections that need these events?

Something like

const eventCollection = [USERS];

 if (collectionName in eventCollection) {
        this.emit('${collectionName}-addItem', newItem);
}

public async findItemsInCollection<T>(
collectionName: string,
criteria: Record<string, any>
criteria: Record<string, any>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Update the comment to reflect Record<string, any>

(document: { fullDocument: object; updateDescription?: object }): Promise<void>;
};

export type CollectionChangeNotifier = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I cannot find how we used it. If that is the case, consider remove it?

_users.clear();
const userDocs =
(await dm.getAllInCollection<JUser>(USERS)) || [];
const userDocs = (await dm.getAllInCollection<JUser>(USERS)) || [];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is minor. It's a bit strange that we are getting what is supposed to be JUser and then still have to transform it into JUser below. Isn't the transformation already provided by the database manager (through mongo-manager)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was wondering about your current thoughts on the input validation for different methods in this module. Should it be done differently? We discussed this before, and I contributed some, if not most, of them. Now that I looked at it a second time, it seems a lot. It would be great to hear your thoughts.

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