From 2e23839db7a753452e55c56b381bb0a2c40e7976 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Wed, 6 Mar 2024 08:44:46 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com> --- CHANGELOG.md | 9 +++++---- packages/realm/src/Logger.ts | 8 ++++++-- packages/realm/src/Realm.ts | 9 +++------ packages/realm/src/app-services/Sync.ts | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 409b439984..6181d9a198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## vNext (TBD) -NOTE: This version bumps the Realm file format to version 24. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v6.0.0, might not be upgradeable. Only Realm Studio 15.0.0 or later will be able to open the new file format. +> [!NOTE] +> This version bumps the Realm file format to version 24. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v6.0.0, might not be upgradeable. **Only Realm Studio 15.0.0 or later** will be able to open the new file format. ### Deprecations * None @@ -17,13 +18,13 @@ NOTE: This version bumps the Realm file format to version 24. It is not possible * Added support for using aggregate operations on Mixed properties in queries. ([realm/realm-core#7398](https://github.com/realm/realm-core/pull/7398)) ### Fixed -* Align dictionaries to Lists and Sets when they get cleared. ([#6205](https://github.com/realm/realm-core/issues/6205), since v10.3.0-rc.1) +* Aligned Dictionaries to Lists and Sets when they get cleared. ([#6205](https://github.com/realm/realm-core/issues/6205), since v10.3.0-rc.1) * Fixed equality queries on a `Mixed` property with an index possibly returning the wrong result if values of different types happened to have the same StringIndex hash. ([realm/realm-core#6407](https://github.com/realm/realm-core/issues/6407), since v10.5.0-beta.1) -* `@count`/`@size` not supported for `Mixed` properties. ([realm/realm-core#7280](https://github.com/realm/realm-core/issues/7280), since v10.0.0) +* `@count`/`@size` is now supported for `Mixed` properties. ([realm/realm-core#7280](https://github.com/realm/realm-core/issues/7280), since v10.0.0) * Fixed queries like `indexed_property == NONE {x}` which mistakenly matched on only `x` instead of not `x`. This only applies when an indexed property with equality (`==`, or `IN`) matches with `NONE` on a list of one item. If the constant list contained more than one value then it was working correctly. ([realm/realm-java#7862](https://github.com/realm/realm-java/issues/7862), since v10.20.0) * Uploading the changesets recovered during an automatic client reset recovery may lead to `Bad server version` errors and a new client reset. ([realm/realm-core#7279](https://github.com/realm/realm-core/issues/7279), since v12.5.0) * Fixed crash in full text index using prefix search with no matches ([realm/realm-core#7309](https://github.com/realm/realm-core/issues/7309), since v12.2.0) -* Fix a race condition when backing up Realm files before a client reset which could have lead to overwriting an existing file. ([realm/realm-core#7341](https://github.com/realm/realm-core/pull/7341)). +* Fixed a race condition when backing up Realm files before a client reset which could have lead to overwriting an existing file. ([realm/realm-core#7341](https://github.com/realm/realm-core/pull/7341)). ### Compatibility * React Native >= v0.71.4 diff --git a/packages/realm/src/Logger.ts b/packages/realm/src/Logger.ts index 56c96536d6..515da09884 100644 --- a/packages/realm/src/Logger.ts +++ b/packages/realm/src/Logger.ts @@ -168,7 +168,7 @@ export type LogOptions = { export type Logger = (level: NumericLogLevel, message: string) => void; /** - * A callback passed to `Realm.setLogger`. + * A callback to be used as the logger. * @param level - The level of the log entry. * @param message - The message of the log entry. * @since 12.0.0 @@ -195,10 +195,14 @@ export type LogEntry = { }; /** - * A callback passed to `Realm.setLogger`. Arguments are passed as an object. + * A callback to be used as the logger. * @since 12.7.0 */ export type LoggerCallback2 = (entry: LogEntry) => void; +/** + * A callback to be used as the logger. + * @since 12.7.0 + */ export type LoggerCallback = LoggerCallback1 | LoggerCallback2; /** @internal */ diff --git a/packages/realm/src/Realm.ts b/packages/realm/src/Realm.ts index 2103385aec..6880b7f3f6 100644 --- a/packages/realm/src/Realm.ts +++ b/packages/realm/src/Realm.ts @@ -129,7 +129,6 @@ export class Realm { * Realm.setLogLevel({ category: LogCategory.Realm, level: "all" }); */ static setLogLevel(options: LogOptions): void; - static setLogLevel(arg: LogLevel | LogOptions) { const setLevel = (level: LogLevel, category = LogCategory.Realm) => { assert(Object.values(LogCategory).includes(category), `Unexpected log category: '${category}'`); @@ -147,7 +146,7 @@ export class Realm { /** * Sets the logger callback. * @param loggerCallback - The callback invoked by the logger. The default callback uses `console.log`, `console.warn` and `console.error`, depending on the level of the message. - * @note The logger callback needs to be setup before opening the first Realm. + * @note The logger callback needs to be set up before opening the first Realm. * @since 12.0.0 * @deprecated Pass a callback taking a single object argument instead. * @example @@ -156,11 +155,10 @@ export class Realm { * }); */ static setLogger(loggerCallback: LoggerCallback1): void; - /** * Sets the logger callback. * @param loggerCallback - The callback invoked by the logger. The default callback uses `console.log`, `console.warn` and `console.error`, depending on the level of the message. - * @note The logger callback needs to be setup before opening the first Realm. + * @note The logger callback needs to be set up before opening the first Realm. * @since 12.0.0 * @example * Realm.setLogger(({ category, level, message }) => { @@ -168,11 +166,10 @@ export class Realm { * }); */ static setLogger(loggerCallback: LoggerCallback2): void; - /** * Sets the logger callback. * @param loggerCallback - The callback invoked by the logger. The default callback uses `console.log`, `console.warn` and `console.error`, depending on the level of the message. - * @note The logger callback needs to be setup before opening the first Realm. + * @note The logger callback needs to be set up before opening the first Realm. * @since 12.0.0 * @example * Realm.setLogger(({ category, level, message }) => { diff --git a/packages/realm/src/app-services/Sync.ts b/packages/realm/src/app-services/Sync.ts index 6f180cba2b..f8ecc51a73 100644 --- a/packages/realm/src/app-services/Sync.ts +++ b/packages/realm/src/app-services/Sync.ts @@ -46,7 +46,7 @@ export class Sync { /** @deprecated Will be removed in v13.0.0. Please use {@link Realm.setLogger}. */ static setLogger(app: App, logger: Logger) { - const factory = binding.Helpers.makeLoggerFactory((category, level, message) => { + const factory = binding.Helpers.makeLoggerFactory((_, level, message) => { logger(fromBindingLoggerLevelToNumericLogLevel(level), message); }); app.internal.syncManager.setLoggerFactory(factory);