diff --git a/config/redirects b/config/redirects index f35699d968..542ed5f5cc 100644 --- a/config/redirects +++ b/config/redirects @@ -79,8 +79,8 @@ raw: ${prefix}/node/collections -> ${base}/sdk/node/model-data/data-types/collec raw: ${prefix}/node/create-manage-api-keys -> ${base}/sdk/node/users/manage-user-api-keys/ raw: ${prefix}/node/data-model -> ${base}/sdk/node/realm-files/ raw: ${prefix}/node/database -> ${base}/sdk/node/realm-files/ -raw: ${prefix}/node/electron-cra -> ${base}/sdk/node/integrations/electron-cra/ -raw: ${prefix}/node/electron -> ${base}/sdk/node/integrations/electron/ +raw: ${prefix}/node/electron-cra -> ${base}/sdk/node/ +raw: ${prefix}/node/electron -> ${base}/sdk/node/ raw: ${prefix}/node/embedded-objects -> ${base}/sdk/node/model-data/relationships-and-embedded-objects/ raw: ${prefix}/node/encrypt -> ${base}/sdk/node/realm-files/encrypt/ raw: ${prefix}/node/init-realmclient -> ${base}/sdk/node/app-services/connect-to-app-services-backend/ @@ -1285,3 +1285,9 @@ raw: ${prefix}/sdk/flutter/realm-database/read-and-write-data -> ${base}/sdk/flu # Smartling missing redirect raw: ${prefix}/sdk/react-native/use-realm-react -> ${base}/sdk/react-native/api-reference/realm-provider/ + +# DOCSP-37163 Remove Electron Guides from TOC + +raw: ${prefix}/sdk/node/integrations/electron-cra -> ${base}/sdk/node/ +raw: ${prefix}/sdk/node/integrations/electron -> ${base}/sdk/node/ +raw: ${prefix}/sdk/node/integrations -> ${base}/sdk/node/ \ No newline at end of file diff --git a/docs-release-notes.md b/docs-release-notes.md index 935b0f3939..efea0e6eb6 100644 --- a/docs-release-notes.md +++ b/docs-release-notes.md @@ -1,3 +1,32 @@ +# March 15, 2024 + +## Other + +Throughout Device SDK docs: +- Add deprecation notices to pages with substantial GraphQL content. +- Remove high-level references to our GraphQL API to make the feature less discoverable. + +## Internal + +- Update dependencies in Web SDK test suite. + +# March 8, 2024 + +## Node.js SDK + +- Landing Page: Remove link to outdated Electron guide. +- Integration Guides: Remove outdated Integration Guides section from TOC until we have time to update the guides. + +# March 1, 2024 + +## React Native SDK + +- Model Data/Data Types/Dictionaries: Fix bullet list formatting. + +## Other + +- Realm Query Language: Update RQL reference with information on querying with full-text search. + # February 23, 2024 ## Kotlin SDK diff --git a/examples/cpp/local/crud.cpp b/examples/cpp/local/crud.cpp index 59d1adca6d..07df709e33 100644 --- a/examples/cpp/local/crud.cpp +++ b/examples/cpp/local/crud.cpp @@ -160,8 +160,7 @@ TEST_CASE("Define model example", "[write]") { TEST_CASE("Ignored property example", "[write]") { // :snippet-start: open-db-at-path auto relative_realm_path_directory = "custom_path_directory/"; - std::filesystem::create_directories( - relative_realm_path_directory); // :remove: + std::filesystem::create_directories(relative_realm_path_directory); // Construct a path std::filesystem::path path = std::filesystem::current_path().append(relative_realm_path_directory); diff --git a/examples/dart/bin/models/car.dart b/examples/dart/bin/models/car.dart index 6415dbd32d..a3a44eb57d 100644 --- a/examples/dart/bin/models/car.dart +++ b/examples/dart/bin/models/car.dart @@ -1,6 +1,6 @@ import 'package:realm_dart/realm.dart'; -part 'car.g.dart'; +part 'car.realm.dart'; @RealmModel() class _Car { diff --git a/examples/dart/bin/models/car.g.dart b/examples/dart/bin/models/car.realm.dart similarity index 67% rename from examples/dart/bin/models/car.g.dart rename to examples/dart/bin/models/car.realm.dart index c5a8bc69c2..8734882801 100644 --- a/examples/dart/bin/models/car.g.dart +++ b/examples/dart/bin/models/car.realm.dart @@ -49,15 +49,45 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/bundle_example/lib/realm/schemas.dart b/examples/dart/bundle_example/lib/realm/schemas.dart index 7f52127e4f..a51e7a28e1 100644 --- a/examples/dart/bundle_example/lib/realm/schemas.dart +++ b/examples/dart/bundle_example/lib/realm/schemas.dart @@ -1,6 +1,6 @@ import 'package:realm/realm.dart'; -part 'schemas.g.dart'; +part 'schemas.realm.dart'; @RealmModel() class _Car { diff --git a/examples/dart/bundle_example/lib/realm/schemas.g.dart b/examples/dart/bundle_example/lib/realm/schemas.realm.dart similarity index 100% rename from examples/dart/bundle_example/lib/realm/schemas.g.dart rename to examples/dart/bundle_example/lib/realm/schemas.realm.dart diff --git a/examples/dart/pubspec.lock b/examples/dart/pubspec.lock index 9db4a4fef3..d9a6f89b61 100644 --- a/examples/dart/pubspec.lock +++ b/examples/dart/pubspec.lock @@ -209,6 +209,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.1" + ejson: + dependency: transitive + description: + name: ejson + sha256: "2d69382ea016c5f38c9d966681b464ca23d5f594918d4cb7dfecf0a3dad31395" + url: "https://pub.dev" + source: hosted + version: "0.2.0-pre.1" + ejson_annotation: + dependency: transitive + description: + name: ejson_annotation + sha256: f14948884cf6d91e00c727d5ec6b2395bdcb511541aa7956e4e03b73cd089149 + url: "https://pub.dev" + source: hosted + version: "0.2.0-pre.1" faker: dependency: "direct main" description: @@ -501,26 +517,26 @@ packages: dependency: transitive description: name: realm_common - sha256: "29516a9e43a9e75b2e16226ce24ccd9a549d9377e69be218394d8fb84da11183" + sha256: c4c994217c3f1dafdb3e36b5e3c75c6f4719fd5bd64f64a5acb79a5c962c018f url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "2.0.0" realm_dart: dependency: "direct main" description: name: realm_dart - sha256: "55cf02d26b0775e79570cf0ba6e4036a10c66250b99cb8f1ee41d71057206a7f" + sha256: "861b007dccf19ecfb1e7f47f2b0c246755b82c40e122d61fde18180dbbaf88a3" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "2.0.0" realm_generator: dependency: transitive description: name: realm_generator - sha256: "6d26ca214aad1b49f37a1a86f3216f19a25657d38d82cefb16551a35aa316ec1" + sha256: "3cad739d4491bc5b4ccdd184083fd58f6899e410d0acda7448b60261639e2735" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "2.0.0" rxdart: dependency: transitive description: @@ -689,6 +705,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + type_plus: + dependency: transitive + description: + name: type_plus + sha256: "2e33cfac2e129297d5874567bdf7587502ec359881e9318551e014d91b02f84a" + url: "https://pub.dev" + source: hosted + version: "2.1.0" typed_data: dependency: transitive description: diff --git a/examples/dart/pubspec.yaml b/examples/dart/pubspec.yaml index fb401a24db..f2c6f563f7 100644 --- a/examples/dart/pubspec.yaml +++ b/examples/dart/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: "^3.1.0" dependencies: - realm_dart: ^1.3.0 + realm_dart: ^2.0.0 path: ^1.8.2 dart_jsonwebtoken: ^2.4.2 faker: ^2.0.0 diff --git a/examples/dart/test/add_sync_to_app.dart b/examples/dart/test/add_sync_to_app.dart index e8142fcbbc..7b42f73fac 100644 --- a/examples/dart/test/add_sync_to_app.dart +++ b/examples/dart/test/add_sync_to_app.dart @@ -2,7 +2,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import 'utils.dart'; -part 'add_sync_to_app.g.dart'; +part 'add_sync_to_app.realm.dart'; @RealmModel() class _Car { diff --git a/examples/dart/test/add_sync_to_app.g.dart b/examples/dart/test/add_sync_to_app.realm.dart similarity index 67% rename from examples/dart/test/add_sync_to_app.g.dart rename to examples/dart/test/add_sync_to_app.realm.dart index 889724e145..2ced4f19a6 100644 --- a/examples/dart/test/add_sync_to_app.g.dart +++ b/examples/dart/test/add_sync_to_app.realm.dart @@ -49,16 +49,46 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/backlinks_test.dart b/examples/dart/test/backlinks_test.dart index 9169dcde27..4ccebd88eb 100644 --- a/examples/dart/test/backlinks_test.dart +++ b/examples/dart/test/backlinks_test.dart @@ -3,7 +3,7 @@ import 'package:realm_dart/realm.dart'; import 'schemas.dart'; import 'utils.dart'; -part 'backlinks_test.g.dart'; +part 'backlinks_test.realm.dart'; // :snippet-start: backlink-models @RealmModel() diff --git a/examples/dart/test/backlinks_test.g.dart b/examples/dart/test/backlinks_test.realm.dart similarity index 67% rename from examples/dart/test/backlinks_test.g.dart rename to examples/dart/test/backlinks_test.realm.dart index a1c59adabc..40c66f9fbd 100644 --- a/examples/dart/test/backlinks_test.g.dart +++ b/examples/dart/test/backlinks_test.realm.dart @@ -45,17 +45,44 @@ class User extends _User with RealmEntity, RealmObjectBase, RealmObject { @override User freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'username': username.toEJson(), + 'tasks': tasks.toEJson(), + }; + } + + static EJsonValue _toEJson(User value) => value.toEJson(); + static User _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'username': EJsonValue username, + 'tasks': EJsonValue tasks, + } => + User( + fromEJson(id), + fromEJson(username), + tasks: fromEJson(tasks), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(User._); - return const SchemaObject(ObjectType.realmObject, User, 'User', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, User, 'User', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('username', RealmPropertyType.string), SchemaProperty('tasks', RealmPropertyType.object, linkTarget: 'Task', collectionType: RealmCollectionType.list), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Task extends _Task with RealmEntity, RealmObjectBase, RealmObject { @@ -107,11 +134,37 @@ class Task extends _Task with RealmEntity, RealmObjectBase, RealmObject { @override Task freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'description': description.toEJson(), + 'isComplete': isComplete.toEJson(), + 'linkedUser': linkedUser.toEJson(), + }; + } + + static EJsonValue _toEJson(Task value) => value.toEJson(); + static Task _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'description': EJsonValue description, + 'isComplete': EJsonValue isComplete, + 'linkedUser': EJsonValue linkedUser, + } => + Task( + fromEJson(id), + fromEJson(description), + fromEJson(isComplete), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Task._); - return const SchemaObject(ObjectType.realmObject, Task, 'Task', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Task, 'Task', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('description', RealmPropertyType.string), SchemaProperty('isComplete', RealmPropertyType.bool), @@ -120,5 +173,8 @@ class Task extends _Task with RealmEntity, RealmObjectBase, RealmObject { collectionType: RealmCollectionType.list, linkTarget: 'User'), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/car.dart b/examples/dart/test/car.dart index a1e46b841b..7540ea350b 100644 --- a/examples/dart/test/car.dart +++ b/examples/dart/test/car.dart @@ -1,7 +1,7 @@ // :snippet-start: define-model-dart import 'package:realm_dart/realm.dart'; -part 'car.g.dart'; +part 'car.realm.dart'; @RealmModel() class _Car { diff --git a/examples/dart/test/car.g.dart b/examples/dart/test/car.realm.dart similarity index 67% rename from examples/dart/test/car.g.dart rename to examples/dart/test/car.realm.dart index c5a8bc69c2..8734882801 100644 --- a/examples/dart/test/car.g.dart +++ b/examples/dart/test/car.realm.dart @@ -49,15 +49,45 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/client_reset_test.dart b/examples/dart/test/client_reset_test.dart index 9969d6855a..c7007a6fb8 100644 --- a/examples/dart/test/client_reset_test.dart +++ b/examples/dart/test/client_reset_test.dart @@ -4,7 +4,7 @@ import 'package:realm_dart/realm.dart'; import 'package:test/test.dart'; import 'utils.dart'; -part "client_reset_test.g.dart"; +part "client_reset_test.realm.dart"; @RealmModel() class _Car { diff --git a/examples/dart/test/client_reset_test.g.dart b/examples/dart/test/client_reset_test.realm.dart similarity index 67% rename from examples/dart/test/client_reset_test.g.dart rename to examples/dart/test/client_reset_test.realm.dart index fd6eb68516..cbed39d5c7 100644 --- a/examples/dart/test/client_reset_test.g.dart +++ b/examples/dart/test/client_reset_test.realm.dart @@ -49,16 +49,46 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/data_ingest.test.dart b/examples/dart/test/data_ingest.test.dart index 71fc236adc..765c8b9658 100644 --- a/examples/dart/test/data_ingest.test.dart +++ b/examples/dart/test/data_ingest.test.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import './utils.dart'; -part 'data_ingest.test.g.dart'; +part 'data_ingest.test.realm.dart'; // :snippet-start: asymmetric-sync-object @RealmModel(ObjectType.asymmetricObject) diff --git a/examples/dart/test/data_ingest.test.g.dart b/examples/dart/test/data_ingest.test.realm.dart similarity index 69% rename from examples/dart/test/data_ingest.test.g.dart rename to examples/dart/test/data_ingest.test.realm.dart index a14128040a..7086d8aaf9 100644 --- a/examples/dart/test/data_ingest.test.g.dart +++ b/examples/dart/test/data_ingest.test.realm.dart @@ -66,11 +66,41 @@ class WeatherSensor extends _WeatherSensor @override WeatherSensor freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'deviceId': deviceId.toEJson(), + 'modtemperatureInFahrenheitel': modtemperatureInFahrenheitel.toEJson(), + 'barometricPressureInHg': barometricPressureInHg.toEJson(), + 'windSpeedInMph': windSpeedInMph.toEJson(), + }; + } + + static EJsonValue _toEJson(WeatherSensor value) => value.toEJson(); + static WeatherSensor _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'deviceId': EJsonValue deviceId, + 'modtemperatureInFahrenheitel': EJsonValue modtemperatureInFahrenheitel, + 'barometricPressureInHg': EJsonValue barometricPressureInHg, + 'windSpeedInMph': EJsonValue windSpeedInMph, + } => + WeatherSensor( + fromEJson(id), + fromEJson(deviceId), + fromEJson(modtemperatureInFahrenheitel), + fromEJson(barometricPressureInHg), + fromEJson(windSpeedInMph), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(WeatherSensor._); - return const SchemaObject( + register(_toEJson, _fromEJson); + return SchemaObject( ObjectType.asymmetricObject, WeatherSensor, 'WeatherSensor', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), @@ -79,5 +109,8 @@ class WeatherSensor extends _WeatherSensor SchemaProperty('barometricPressureInHg', RealmPropertyType.double), SchemaProperty('windSpeedInMph', RealmPropertyType.double), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/data_types_test.dart b/examples/dart/test/data_types_test.dart index 6e31a3c6ed..ea8d9bb9ff 100644 --- a/examples/dart/test/data_types_test.dart +++ b/examples/dart/test/data_types_test.dart @@ -8,23 +8,11 @@ import 'utils.dart'; // :snippet-start: data-types-example-model -part 'data_types_test.g.dart'; // :remove: +part 'data_types_test.realm.dart'; // :remove: // :uncomment-start: -// part 'car.g.dart'; +// part 'car.realm.dart'; // :uncomment-end: -@RealmModel() -class _Car { - @PrimaryKey() - late ObjectId id; - - String? licensePlate; - bool isElectric = false; - double milesDriven = 0; - late List attributes; - late _Person? owner; -} - // :snippet-start: embedded-object-model // The generated `Address` class is an embedded object. @RealmModel(ObjectType.embeddedObject) @@ -47,6 +35,17 @@ class _Person { } // :snippet-end: +@RealmModel() +class _Car { + @PrimaryKey() + late ObjectId id; + + String? licensePlate; + bool isElectric = false; + double milesDriven = 0; + late List attributes; + late _Person? owner; +} // :snippet-end: // :snippet-start: uuid-model @@ -140,7 +139,6 @@ class _SomeRealmModel { class _BinaryExample { late String name; late Uint8List requiredBinaryProperty; - var defaultValueBinaryProperty = Uint8List(8); late Uint8List? nullableBinaryProperty; } // :snippet-end: diff --git a/examples/dart/test/data_types_test.g.dart b/examples/dart/test/data_types_test.g.dart deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/dart/test/data_types_test.realm.dart b/examples/dart/test/data_types_test.realm.dart new file mode 100644 index 0000000000..e8468acf63 --- /dev/null +++ b/examples/dart/test/data_types_test.realm.dart @@ -0,0 +1,1024 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'data_types_test.dart'; + +// ************************************************************************** +// RealmObjectGenerator +// ************************************************************************** + +// ignore_for_file: type=lint +class Address extends _Address + with RealmEntity, RealmObjectBase, EmbeddedObject { + Address( + String street, + String city, + String state, + String country, + ) { + RealmObjectBase.set(this, 'street', street); + RealmObjectBase.set(this, 'city', city); + RealmObjectBase.set(this, 'state', state); + RealmObjectBase.set(this, 'country', country); + } + + Address._(); + + @override + String get street => RealmObjectBase.get(this, 'street') as String; + @override + set street(String value) => RealmObjectBase.set(this, 'street', value); + + @override + String get city => RealmObjectBase.get(this, 'city') as String; + @override + set city(String value) => RealmObjectBase.set(this, 'city', value); + + @override + String get state => RealmObjectBase.get(this, 'state') as String; + @override + set state(String value) => RealmObjectBase.set(this, 'state', value); + + @override + String get country => RealmObjectBase.get(this, 'country') as String; + @override + set country(String value) => RealmObjectBase.set(this, 'country', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges
(this); + + @override + Address freeze() => RealmObjectBase.freezeObject
(this); + + EJsonValue toEJson() { + return { + 'street': street.toEJson(), + 'city': city.toEJson(), + 'state': state.toEJson(), + 'country': country.toEJson(), + }; + } + + static EJsonValue _toEJson(Address value) => value.toEJson(); + static Address _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'street': EJsonValue street, + 'city': EJsonValue city, + 'state': EJsonValue state, + 'country': EJsonValue country, + } => + Address( + fromEJson(street), + fromEJson(city), + fromEJson(state), + fromEJson(country), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Address._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.embeddedObject, Address, 'Address', [ + SchemaProperty('street', RealmPropertyType.string), + SchemaProperty('city', RealmPropertyType.string), + SchemaProperty('state', RealmPropertyType.string), + SchemaProperty('country', RealmPropertyType.string), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { + Person( + ObjectId id, + String name, { + Address? address, + }) { + RealmObjectBase.set(this, 'id', id); + RealmObjectBase.set(this, 'name', name); + RealmObjectBase.set(this, 'address', address); + } + + Person._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + String get name => RealmObjectBase.get(this, 'name') as String; + @override + set name(String value) => RealmObjectBase.set(this, 'name', value); + + @override + Address? get address => + RealmObjectBase.get
(this, 'address') as Address?; + @override + set address(covariant Address? value) => + RealmObjectBase.set(this, 'address', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Person freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'address': address.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'address': EJsonValue address, + } => + Person( + fromEJson(id), + fromEJson(name), + address: fromEJson(address), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Person._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + SchemaProperty('name', RealmPropertyType.string), + SchemaProperty('address', RealmPropertyType.object, + optional: true, linkTarget: 'Address'), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { + static var _defaultsSet = false; + + Car( + ObjectId id, { + String? licensePlate, + bool isElectric = false, + double milesDriven = 0, + Iterable attributes = const [], + Person? owner, + }) { + if (!_defaultsSet) { + _defaultsSet = RealmObjectBase.setDefaults({ + 'isElectric': false, + 'milesDriven': 0, + }); + } + RealmObjectBase.set(this, 'id', id); + RealmObjectBase.set(this, 'licensePlate', licensePlate); + RealmObjectBase.set(this, 'isElectric', isElectric); + RealmObjectBase.set(this, 'milesDriven', milesDriven); + RealmObjectBase.set>( + this, 'attributes', RealmList(attributes)); + RealmObjectBase.set(this, 'owner', owner); + } + + Car._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + String? get licensePlate => + RealmObjectBase.get(this, 'licensePlate') as String?; + @override + set licensePlate(String? value) => + RealmObjectBase.set(this, 'licensePlate', value); + + @override + bool get isElectric => RealmObjectBase.get(this, 'isElectric') as bool; + @override + set isElectric(bool value) => RealmObjectBase.set(this, 'isElectric', value); + + @override + double get milesDriven => + RealmObjectBase.get(this, 'milesDriven') as double; + @override + set milesDriven(double value) => + RealmObjectBase.set(this, 'milesDriven', value); + + @override + RealmList get attributes => + RealmObjectBase.get(this, 'attributes') as RealmList; + @override + set attributes(covariant RealmList value) => + throw RealmUnsupportedSetError(); + + @override + Person? get owner => RealmObjectBase.get(this, 'owner') as Person?; + @override + set owner(covariant Person? value) => + RealmObjectBase.set(this, 'owner', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Car freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'licensePlate': licensePlate.toEJson(), + 'isElectric': isElectric.toEJson(), + 'milesDriven': milesDriven.toEJson(), + 'attributes': attributes.toEJson(), + 'owner': owner.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'licensePlate': EJsonValue licensePlate, + 'isElectric': EJsonValue isElectric, + 'milesDriven': EJsonValue milesDriven, + 'attributes': EJsonValue attributes, + 'owner': EJsonValue owner, + } => + Car( + fromEJson(id), + licensePlate: fromEJson(licensePlate), + isElectric: fromEJson(isElectric), + milesDriven: fromEJson(milesDriven), + attributes: fromEJson(attributes), + owner: fromEJson(owner), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Car._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + SchemaProperty('licensePlate', RealmPropertyType.string, optional: true), + SchemaProperty('isElectric', RealmPropertyType.bool), + SchemaProperty('milesDriven', RealmPropertyType.double), + SchemaProperty('attributes', RealmPropertyType.string, + collectionType: RealmCollectionType.list), + SchemaProperty('owner', RealmPropertyType.object, + optional: true, linkTarget: 'Person'), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class UuidPrimaryKey extends _UuidPrimaryKey + with RealmEntity, RealmObjectBase, RealmObject { + UuidPrimaryKey( + Uuid id, + ) { + RealmObjectBase.set(this, 'id', id); + } + + UuidPrimaryKey._(); + + @override + Uuid get id => RealmObjectBase.get(this, 'id') as Uuid; + @override + set id(Uuid value) => RealmObjectBase.set(this, 'id', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + UuidPrimaryKey freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + }; + } + + static EJsonValue _toEJson(UuidPrimaryKey value) => value.toEJson(); + static UuidPrimaryKey _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + } => + UuidPrimaryKey( + fromEJson(id), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(UuidPrimaryKey._); + register(_toEJson, _fromEJson); + return SchemaObject( + ObjectType.realmObject, UuidPrimaryKey, 'UuidPrimaryKey', [ + SchemaProperty('id', RealmPropertyType.uuid, primaryKey: true), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class ObjectIdPrimaryKey extends _ObjectIdPrimaryKey + with RealmEntity, RealmObjectBase, RealmObject { + ObjectIdPrimaryKey( + ObjectId id, + ) { + RealmObjectBase.set(this, 'id', id); + } + + ObjectIdPrimaryKey._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + ObjectIdPrimaryKey freeze() => + RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + }; + } + + static EJsonValue _toEJson(ObjectIdPrimaryKey value) => value.toEJson(); + static ObjectIdPrimaryKey _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + } => + ObjectIdPrimaryKey( + fromEJson(id), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(ObjectIdPrimaryKey._); + register(_toEJson, _fromEJson); + return SchemaObject( + ObjectType.realmObject, ObjectIdPrimaryKey, 'ObjectIdPrimaryKey', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class RealmValueExample extends _RealmValueExample + with RealmEntity, RealmObjectBase, RealmObject { + RealmValueExample({ + RealmValue singleAnyValue = const RealmValue.nullValue(), + Iterable listOfMixedAnyValues = const [], + }) { + RealmObjectBase.set(this, 'singleAnyValue', singleAnyValue); + RealmObjectBase.set>(this, 'listOfMixedAnyValues', + RealmList(listOfMixedAnyValues)); + } + + RealmValueExample._(); + + @override + RealmValue get singleAnyValue => + RealmObjectBase.get(this, 'singleAnyValue') as RealmValue; + @override + set singleAnyValue(RealmValue value) => + RealmObjectBase.set(this, 'singleAnyValue', value); + + @override + RealmList get listOfMixedAnyValues => + RealmObjectBase.get(this, 'listOfMixedAnyValues') + as RealmList; + @override + set listOfMixedAnyValues(covariant RealmList value) => + throw RealmUnsupportedSetError(); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + RealmValueExample freeze() => + RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'singleAnyValue': singleAnyValue.toEJson(), + 'listOfMixedAnyValues': listOfMixedAnyValues.toEJson(), + }; + } + + static EJsonValue _toEJson(RealmValueExample value) => value.toEJson(); + static RealmValueExample _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'singleAnyValue': EJsonValue singleAnyValue, + 'listOfMixedAnyValues': EJsonValue listOfMixedAnyValues, + } => + RealmValueExample( + singleAnyValue: fromEJson(singleAnyValue), + listOfMixedAnyValues: fromEJson(listOfMixedAnyValues), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(RealmValueExample._); + register(_toEJson, _fromEJson); + return SchemaObject( + ObjectType.realmObject, RealmValueExample, 'RealmValueExample', [ + SchemaProperty('singleAnyValue', RealmPropertyType.mixed, + optional: true, indexType: RealmIndexType.regular), + SchemaProperty('listOfMixedAnyValues', RealmPropertyType.mixed, + optional: true, collectionType: RealmCollectionType.list), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class Vehicle extends _Vehicle with RealmEntity, RealmObjectBase, RealmObject { + Vehicle( + ObjectId id, + String nickname, + DateTime dateLastServiced, + ) { + RealmObjectBase.set(this, 'id', id); + RealmObjectBase.set(this, 'nickname', nickname); + RealmObjectBase.set(this, 'dateLastServiced', dateLastServiced); + } + + Vehicle._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + String get nickname => + RealmObjectBase.get(this, 'nickname') as String; + @override + set nickname(String value) => RealmObjectBase.set(this, 'nickname', value); + + @override + DateTime get dateLastServiced => + RealmObjectBase.get(this, 'dateLastServiced') as DateTime; + @override + set dateLastServiced(DateTime value) => + RealmObjectBase.set(this, 'dateLastServiced', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Vehicle freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'nickname': nickname.toEJson(), + 'dateLastServiced': dateLastServiced.toEJson(), + }; + } + + static EJsonValue _toEJson(Vehicle value) => value.toEJson(); + static Vehicle _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'nickname': EJsonValue nickname, + 'dateLastServiced': EJsonValue dateLastServiced, + } => + Vehicle( + fromEJson(id), + fromEJson(nickname), + fromEJson(dateLastServiced), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Vehicle._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Vehicle, 'Vehicle', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + SchemaProperty('nickname', RealmPropertyType.string), + SchemaProperty('dateLastServiced', RealmPropertyType.timestamp), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class Player extends _Player with RealmEntity, RealmObjectBase, RealmObject { + Player( + ObjectId id, + String username, { + Iterable inventory = const [], + Iterable traits = const [], + }) { + RealmObjectBase.set(this, 'id', id); + RealmObjectBase.set(this, 'username', username); + RealmObjectBase.set>( + this, 'inventory', RealmList(inventory)); + RealmObjectBase.set>( + this, 'traits', RealmList(traits)); + } + + Player._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + String get username => + RealmObjectBase.get(this, 'username') as String; + @override + set username(String value) => RealmObjectBase.set(this, 'username', value); + + @override + RealmList get inventory => + RealmObjectBase.get(this, 'inventory') as RealmList; + @override + set inventory(covariant RealmList value) => + throw RealmUnsupportedSetError(); + + @override + RealmList get traits => + RealmObjectBase.get(this, 'traits') as RealmList; + @override + set traits(covariant RealmList value) => + throw RealmUnsupportedSetError(); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Player freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'username': username.toEJson(), + 'inventory': inventory.toEJson(), + 'traits': traits.toEJson(), + }; + } + + static EJsonValue _toEJson(Player value) => value.toEJson(); + static Player _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'username': EJsonValue username, + 'inventory': EJsonValue inventory, + 'traits': EJsonValue traits, + } => + Player( + fromEJson(id), + fromEJson(username), + inventory: fromEJson(inventory), + traits: fromEJson(traits), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Player._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Player, 'Player', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + SchemaProperty('username', RealmPropertyType.string), + SchemaProperty('inventory', RealmPropertyType.object, + linkTarget: 'Item', collectionType: RealmCollectionType.list), + SchemaProperty('traits', RealmPropertyType.string, + collectionType: RealmCollectionType.list), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class Item extends _Item with RealmEntity, RealmObjectBase, RealmObject { + Item( + ObjectId id, + String name, + String description, + ) { + RealmObjectBase.set(this, 'id', id); + RealmObjectBase.set(this, 'name', name); + RealmObjectBase.set(this, 'description', description); + } + + Item._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + String get name => RealmObjectBase.get(this, 'name') as String; + @override + set name(String value) => RealmObjectBase.set(this, 'name', value); + + @override + String get description => + RealmObjectBase.get(this, 'description') as String; + @override + set description(String value) => + RealmObjectBase.set(this, 'description', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Item freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'description': description.toEJson(), + }; + } + + static EJsonValue _toEJson(Item value) => value.toEJson(); + static Item _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'description': EJsonValue description, + } => + Item( + fromEJson(id), + fromEJson(name), + fromEJson(description), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Item._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Item, 'Item', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + SchemaProperty('name', RealmPropertyType.string), + SchemaProperty('description', RealmPropertyType.string), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class RealmSetExample extends _RealmSetExample + with RealmEntity, RealmObjectBase, RealmObject { + RealmSetExample({ + Set primitiveSet = const {}, + Set nullablePrimitiveSet = const {}, + Set realmObjectSet = const {}, + }) { + RealmObjectBase.set>( + this, 'primitiveSet', RealmSet(primitiveSet)); + RealmObjectBase.set>( + this, 'nullablePrimitiveSet', RealmSet(nullablePrimitiveSet)); + RealmObjectBase.set>( + this, 'realmObjectSet', RealmSet(realmObjectSet)); + } + + RealmSetExample._(); + + @override + RealmSet get primitiveSet => + RealmObjectBase.get(this, 'primitiveSet') as RealmSet; + @override + set primitiveSet(covariant RealmSet value) => + throw RealmUnsupportedSetError(); + + @override + RealmSet get nullablePrimitiveSet => + RealmObjectBase.get(this, 'nullablePrimitiveSet') as RealmSet; + @override + set nullablePrimitiveSet(covariant RealmSet value) => + throw RealmUnsupportedSetError(); + + @override + RealmSet get realmObjectSet => + RealmObjectBase.get(this, 'realmObjectSet') + as RealmSet; + @override + set realmObjectSet(covariant RealmSet value) => + throw RealmUnsupportedSetError(); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + RealmSetExample freeze() => + RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'primitiveSet': primitiveSet.toEJson(), + 'nullablePrimitiveSet': nullablePrimitiveSet.toEJson(), + 'realmObjectSet': realmObjectSet.toEJson(), + }; + } + + static EJsonValue _toEJson(RealmSetExample value) => value.toEJson(); + static RealmSetExample _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'primitiveSet': EJsonValue primitiveSet, + 'nullablePrimitiveSet': EJsonValue nullablePrimitiveSet, + 'realmObjectSet': EJsonValue realmObjectSet, + } => + RealmSetExample( + primitiveSet: fromEJson(primitiveSet), + nullablePrimitiveSet: fromEJson(nullablePrimitiveSet), + realmObjectSet: fromEJson(realmObjectSet), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(RealmSetExample._); + register(_toEJson, _fromEJson); + return SchemaObject( + ObjectType.realmObject, RealmSetExample, 'RealmSetExample', [ + SchemaProperty('primitiveSet', RealmPropertyType.string, + collectionType: RealmCollectionType.set), + SchemaProperty('nullablePrimitiveSet', RealmPropertyType.int, + optional: true, collectionType: RealmCollectionType.set), + SchemaProperty('realmObjectSet', RealmPropertyType.object, + linkTarget: 'SomeRealmModel', + collectionType: RealmCollectionType.set), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class SomeRealmModel extends _SomeRealmModel + with RealmEntity, RealmObjectBase, RealmObject { + SomeRealmModel( + ObjectId id, + ) { + RealmObjectBase.set(this, 'id', id); + } + + SomeRealmModel._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + SomeRealmModel freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + }; + } + + static EJsonValue _toEJson(SomeRealmModel value) => value.toEJson(); + static SomeRealmModel _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + } => + SomeRealmModel( + fromEJson(id), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(SomeRealmModel._); + register(_toEJson, _fromEJson); + return SchemaObject( + ObjectType.realmObject, SomeRealmModel, 'SomeRealmModel', [ + SchemaProperty('id', RealmPropertyType.objectid), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class BinaryExample extends _BinaryExample + with RealmEntity, RealmObjectBase, RealmObject { + BinaryExample( + String name, + Uint8List requiredBinaryProperty, { + Uint8List? nullableBinaryProperty, + }) { + RealmObjectBase.set(this, 'name', name); + RealmObjectBase.set(this, 'requiredBinaryProperty', requiredBinaryProperty); + RealmObjectBase.set(this, 'nullableBinaryProperty', nullableBinaryProperty); + } + + BinaryExample._(); + + @override + String get name => RealmObjectBase.get(this, 'name') as String; + @override + set name(String value) => RealmObjectBase.set(this, 'name', value); + + @override + Uint8List get requiredBinaryProperty => + RealmObjectBase.get(this, 'requiredBinaryProperty') + as Uint8List; + @override + set requiredBinaryProperty(Uint8List value) => + RealmObjectBase.set(this, 'requiredBinaryProperty', value); + + @override + Uint8List? get nullableBinaryProperty => + RealmObjectBase.get(this, 'nullableBinaryProperty') + as Uint8List?; + @override + set nullableBinaryProperty(Uint8List? value) => + RealmObjectBase.set(this, 'nullableBinaryProperty', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + BinaryExample freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'name': name.toEJson(), + 'requiredBinaryProperty': requiredBinaryProperty.toEJson(), + 'nullableBinaryProperty': nullableBinaryProperty.toEJson(), + }; + } + + static EJsonValue _toEJson(BinaryExample value) => value.toEJson(); + static BinaryExample _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'name': EJsonValue name, + 'requiredBinaryProperty': EJsonValue requiredBinaryProperty, + 'nullableBinaryProperty': EJsonValue nullableBinaryProperty, + } => + BinaryExample( + fromEJson(name), + fromEJson(requiredBinaryProperty), + nullableBinaryProperty: fromEJson(nullableBinaryProperty), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(BinaryExample._); + register(_toEJson, _fromEJson); + return SchemaObject( + ObjectType.realmObject, BinaryExample, 'BinaryExample', [ + SchemaProperty('name', RealmPropertyType.string), + SchemaProperty('requiredBinaryProperty', RealmPropertyType.binary), + SchemaProperty('nullableBinaryProperty', RealmPropertyType.binary, + optional: true), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} + +class MapExample extends _MapExample + with RealmEntity, RealmObjectBase, RealmObject { + MapExample({ + Map map = const {}, + Map nullableMap = const {}, + }) { + RealmObjectBase.set>(this, 'map', RealmMap(map)); + RealmObjectBase.set>( + this, 'nullableMap', RealmMap(nullableMap)); + } + + MapExample._(); + + @override + RealmMap get map => + RealmObjectBase.get(this, 'map') as RealmMap; + @override + set map(covariant RealmMap value) => throw RealmUnsupportedSetError(); + + @override + RealmMap get nullableMap => + RealmObjectBase.get(this, 'nullableMap') as RealmMap; + @override + set nullableMap(covariant RealmMap value) => + throw RealmUnsupportedSetError(); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + MapExample freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'map': map.toEJson(), + 'nullableMap': nullableMap.toEJson(), + }; + } + + static EJsonValue _toEJson(MapExample value) => value.toEJson(); + static MapExample _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'map': EJsonValue map, + 'nullableMap': EJsonValue nullableMap, + } => + MapExample( + map: fromEJson(map), + nullableMap: fromEJson(nullableMap), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(MapExample._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, MapExample, 'MapExample', [ + SchemaProperty('map', RealmPropertyType.int, + collectionType: RealmCollectionType.map), + SchemaProperty('nullableMap', RealmPropertyType.int, + optional: true, collectionType: RealmCollectionType.map), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} diff --git a/examples/dart/test/define_realm_model_test.dart b/examples/dart/test/define_realm_model_test.dart index 4183836762..62a0a088ef 100644 --- a/examples/dart/test/define_realm_model_test.dart +++ b/examples/dart/test/define_realm_model_test.dart @@ -2,7 +2,7 @@ import 'package:realm_dart/realm.dart'; import 'package:test/expect.dart'; import 'package:test/scaffolding.dart'; -part 'define_realm_model_test.g.dart'; +part 'define_realm_model_test.realm.dart'; @RealmModel() class _Car { diff --git a/examples/dart/test/define_realm_model_test.g.dart b/examples/dart/test/define_realm_model_test.realm.dart similarity index 74% rename from examples/dart/test/define_realm_model_test.g.dart rename to examples/dart/test/define_realm_model_test.realm.dart index 45d691fad9..63e4780c71 100644 --- a/examples/dart/test/define_realm_model_test.g.dart +++ b/examples/dart/test/define_realm_model_test.realm.dart @@ -49,17 +49,47 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @@ -99,16 +129,43 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @override Person freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'firstName': firstName.toEJson(), + 'lastName': lastName.toEJson(), + 'age': age.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'firstName': EJsonValue firstName, + 'lastName': EJsonValue lastName, + 'age': EJsonValue age, + } => + Person( + fromEJson(firstName), + fromEJson(lastName), + fromEJson(age), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Person._); - return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ SchemaProperty('firstName', RealmPropertyType.string), SchemaProperty('lastName', RealmPropertyType.string), SchemaProperty('age', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Boat extends _Boat with RealmEntity, RealmObjectBase, RealmObject { @@ -155,17 +212,47 @@ class Boat extends _Boat with RealmEntity, RealmObjectBase, RealmObject { @override Boat freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'maxKnots': maxKnots.toEJson(), + 'nauticalMiles': nauticalMiles.toEJson(), + }; + } + + static EJsonValue _toEJson(Boat value) => value.toEJson(); + static Boat _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'maxKnots': EJsonValue maxKnots, + 'nauticalMiles': EJsonValue nauticalMiles, + } => + Boat( + fromEJson(id), + fromEJson(name), + maxKnots: fromEJson(maxKnots), + nauticalMiles: fromEJson(nauticalMiles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Boat._); - return const SchemaObject(ObjectType.realmObject, Boat, 'naval_ship', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Boat, 'naval_ship', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('maxKnots', RealmPropertyType.int, optional: true), SchemaProperty('nauticalMiles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class EventLog extends _EventLog diff --git a/examples/dart/test/freeze_test.dart b/examples/dart/test/freeze_test.dart index de16917ade..8450039ccd 100644 --- a/examples/dart/test/freeze_test.dart +++ b/examples/dart/test/freeze_test.dart @@ -2,7 +2,7 @@ import 'package:realm_dart/realm.dart'; import 'package:test/test.dart'; import './utils.dart'; -part 'freeze_test.g.dart'; +part 'freeze_test.realm.dart'; @RealmModel() class _Person { diff --git a/examples/dart/test/freeze_test.g.dart b/examples/dart/test/freeze_test.realm.dart similarity index 66% rename from examples/dart/test/freeze_test.g.dart rename to examples/dart/test/freeze_test.realm.dart index a42b3cd83f..cb48cdc58e 100644 --- a/examples/dart/test/freeze_test.g.dart +++ b/examples/dart/test/freeze_test.realm.dart @@ -54,18 +54,48 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @override Person freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'firstName': firstName.toEJson(), + 'lastName': lastName.toEJson(), + 'attributes': attributes.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'firstName': EJsonValue firstName, + 'lastName': EJsonValue lastName, + 'attributes': EJsonValue attributes, + } => + Person( + fromEJson(id), + fromEJson(firstName), + fromEJson(lastName), + attributes: fromEJson(attributes), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Person._); - return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('firstName', RealmPropertyType.string), SchemaProperty('lastName', RealmPropertyType.string), SchemaProperty('attributes', RealmPropertyType.string, collectionType: RealmCollectionType.list), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Scooter extends _Scooter with RealmEntity, RealmObjectBase, RealmObject { @@ -104,15 +134,42 @@ class Scooter extends _Scooter with RealmEntity, RealmObjectBase, RealmObject { @override Scooter freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'owner': owner.toEJson(), + }; + } + + static EJsonValue _toEJson(Scooter value) => value.toEJson(); + static Scooter _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'owner': EJsonValue owner, + } => + Scooter( + fromEJson(id), + fromEJson(name), + owner: fromEJson(owner), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Scooter._); - return const SchemaObject(ObjectType.realmObject, Scooter, 'Scooter', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Scooter, 'Scooter', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('owner', RealmPropertyType.object, optional: true, linkTarget: 'Person'), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/full_text_search_test.dart b/examples/dart/test/full_text_search_test.dart index b89c25d1b2..950cf2000d 100644 --- a/examples/dart/test/full_text_search_test.dart +++ b/examples/dart/test/full_text_search_test.dart @@ -2,7 +2,7 @@ import 'package:realm_dart/realm.dart'; import 'package:test/test.dart'; import './utils.dart'; -part 'full_text_search_test.g.dart'; +part 'full_text_search_test.realm.dart'; // :snippet-start: flutter-fts-annotation @RealmModel() diff --git a/examples/dart/test/full_text_search_test.g.dart b/examples/dart/test/full_text_search_test.realm.dart similarity index 68% rename from examples/dart/test/full_text_search_test.g.dart rename to examples/dart/test/full_text_search_test.realm.dart index 8200feef13..b130dcdc99 100644 --- a/examples/dart/test/full_text_search_test.g.dart +++ b/examples/dart/test/full_text_search_test.realm.dart @@ -50,11 +50,38 @@ class Rug extends _Rug with RealmEntity, RealmObjectBase, RealmObject { @override Rug freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'pattern': pattern.toEJson(), + 'material': material.toEJson(), + 'softness': softness.toEJson(), + }; + } + + static EJsonValue _toEJson(Rug value) => value.toEJson(); + static Rug _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'pattern': EJsonValue pattern, + 'material': EJsonValue material, + 'softness': EJsonValue softness, + } => + Rug( + fromEJson(id), + fromEJson(pattern), + fromEJson(material), + fromEJson(softness), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Rug._); - return const SchemaObject(ObjectType.realmObject, Rug, 'Rug', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Rug, 'Rug', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('pattern', RealmPropertyType.string, indexType: RealmIndexType.fullText), @@ -62,5 +89,8 @@ class Rug extends _Rug with RealmEntity, RealmObjectBase, RealmObject { indexType: RealmIndexType.fullText), SchemaProperty('softness', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/geospatial_data_test.dart b/examples/dart/test/geospatial_data_test.dart index f167a9f73e..151d373a6d 100644 --- a/examples/dart/test/geospatial_data_test.dart +++ b/examples/dart/test/geospatial_data_test.dart @@ -2,7 +2,7 @@ import 'package:realm_dart/realm.dart'; import 'package:test/test.dart'; import 'utils.dart'; -part 'geospatial_data_test.g.dart'; +part 'geospatial_data_test.realm.dart'; // :snippet-start: define-geopoint-class // To store geospatial data, create an embedded object with this structure. diff --git a/examples/dart/test/geospatial_data_test.g.dart b/examples/dart/test/geospatial_data_test.realm.dart similarity index 63% rename from examples/dart/test/geospatial_data_test.g.dart rename to examples/dart/test/geospatial_data_test.realm.dart index d949270e5a..3da5ff8ffd 100644 --- a/examples/dart/test/geospatial_data_test.g.dart +++ b/examples/dart/test/geospatial_data_test.realm.dart @@ -44,17 +44,40 @@ class MyGeoPoint extends _MyGeoPoint @override MyGeoPoint freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'type': type.toEJson(), + 'coordinates': coordinates.toEJson(), + }; + } + + static EJsonValue _toEJson(MyGeoPoint value) => value.toEJson(); + static MyGeoPoint _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'type': EJsonValue type, + 'coordinates': EJsonValue coordinates, + } => + MyGeoPoint( + type: fromEJson(type), + coordinates: fromEJson(coordinates), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(MyGeoPoint._); - return const SchemaObject( - ObjectType.embeddedObject, MyGeoPoint, 'MyGeoPoint', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.embeddedObject, MyGeoPoint, 'MyGeoPoint', [ SchemaProperty('type', RealmPropertyType.string), SchemaProperty('coordinates', RealmPropertyType.double, collectionType: RealmCollectionType.list), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Company extends _Company with RealmEntity, RealmObjectBase, RealmObject { @@ -87,14 +110,38 @@ class Company extends _Company with RealmEntity, RealmObjectBase, RealmObject { @override Company freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'location': location.toEJson(), + }; + } + + static EJsonValue _toEJson(Company value) => value.toEJson(); + static Company _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'location': EJsonValue location, + } => + Company( + fromEJson(id), + location: fromEJson(location), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Company._); - return const SchemaObject(ObjectType.realmObject, Company, 'Company', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Company, 'Company', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('location', RealmPropertyType.object, optional: true, linkTarget: 'MyGeoPoint'), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/manage_sync_session_test.dart b/examples/dart/test/manage_sync_session_test.dart index f6373aca1d..d806c22d9c 100644 --- a/examples/dart/test/manage_sync_session_test.dart +++ b/examples/dart/test/manage_sync_session_test.dart @@ -4,7 +4,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import './utils.dart'; -part 'manage_sync_session_test.g.dart'; +part 'manage_sync_session_test.realm.dart'; const APP_ID = "flutter-flexible-luccm"; late App app; diff --git a/examples/dart/test/manage_sync_session_test.g.dart b/examples/dart/test/manage_sync_session_test.realm.dart similarity index 67% rename from examples/dart/test/manage_sync_session_test.g.dart rename to examples/dart/test/manage_sync_session_test.realm.dart index 1a3e4fa335..b251d8d7d4 100644 --- a/examples/dart/test/manage_sync_session_test.g.dart +++ b/examples/dart/test/manage_sync_session_test.realm.dart @@ -49,16 +49,46 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/manage_sync_subscription_test.dart b/examples/dart/test/manage_sync_subscription_test.dart index 79fa047e14..729857e9f0 100644 --- a/examples/dart/test/manage_sync_subscription_test.dart +++ b/examples/dart/test/manage_sync_subscription_test.dart @@ -2,7 +2,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import './utils.dart'; -part 'manage_sync_subscription_test.g.dart'; +part 'manage_sync_subscription_test.realm.dart'; @RealmModel() class _Plane { diff --git a/examples/dart/test/manage_sync_subscription_test.g.dart b/examples/dart/test/manage_sync_subscription_test.realm.dart similarity index 62% rename from examples/dart/test/manage_sync_subscription_test.g.dart rename to examples/dart/test/manage_sync_subscription_test.realm.dart index 241a47cb48..7659027ce5 100644 --- a/examples/dart/test/manage_sync_subscription_test.g.dart +++ b/examples/dart/test/manage_sync_subscription_test.realm.dart @@ -42,17 +42,44 @@ class Plane extends _Plane with RealmEntity, RealmObjectBase, RealmObject { @override Plane freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'name': name.toEJson(), + 'numSeats': numSeats.toEJson(), + }; + } + + static EJsonValue _toEJson(Plane value) => value.toEJson(); + static Plane _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'name': EJsonValue name, + 'numSeats': EJsonValue numSeats, + } => + Plane( + fromEJson(id), + fromEJson(name), + fromEJson(numSeats), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Plane._); - return const SchemaObject(ObjectType.realmObject, Plane, 'Plane', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Plane, 'Plane', [ SchemaProperty('id', RealmPropertyType.int, mapTo: '_id', primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('numSeats', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Train extends _Train with RealmEntity, RealmObjectBase, RealmObject { @@ -90,17 +117,44 @@ class Train extends _Train with RealmEntity, RealmObjectBase, RealmObject { @override Train freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'name': name.toEJson(), + 'numCars': numCars.toEJson(), + }; + } + + static EJsonValue _toEJson(Train value) => value.toEJson(); + static Train _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'name': EJsonValue name, + 'numCars': EJsonValue numCars, + } => + Train( + fromEJson(id), + fromEJson(name), + fromEJson(numCars), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Train._); - return const SchemaObject(ObjectType.realmObject, Train, 'Train', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Train, 'Train', [ SchemaProperty('id', RealmPropertyType.int, mapTo: '_id', primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('numCars', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Boat extends _Boat with RealmEntity, RealmObjectBase, RealmObject { @@ -138,15 +192,42 @@ class Boat extends _Boat with RealmEntity, RealmObjectBase, RealmObject { @override Boat freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'name': name.toEJson(), + 'tonnage': tonnage.toEJson(), + }; + } + + static EJsonValue _toEJson(Boat value) => value.toEJson(); + static Boat _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'name': EJsonValue name, + 'tonnage': EJsonValue tonnage, + } => + Boat( + fromEJson(id), + fromEJson(name), + fromEJson(tonnage), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Boat._); - return const SchemaObject(ObjectType.realmObject, Boat, 'Boat', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Boat, 'Boat', [ SchemaProperty('id', RealmPropertyType.int, mapTo: '_id', primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('tonnage', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/migrations_test.dart b/examples/dart/test/migrations_test.dart index 7d5356e59b..99588b738f 100644 --- a/examples/dart/test/migrations_test.dart +++ b/examples/dart/test/migrations_test.dart @@ -2,7 +2,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import './schemas.dart' as Schemas; import './utils.dart'; -part 'migrations_test.g.dart'; +part 'migrations_test.realm.dart'; typedef PersonV1 = Schemas.Person; // old schema version typedef Car = Schemas.Car; diff --git a/examples/dart/test/migrations_test.g.dart b/examples/dart/test/migrations_test.realm.dart similarity index 65% rename from examples/dart/test/migrations_test.g.dart rename to examples/dart/test/migrations_test.realm.dart index f41ff5d560..2de5882731 100644 --- a/examples/dart/test/migrations_test.g.dart +++ b/examples/dart/test/migrations_test.realm.dart @@ -46,14 +46,41 @@ class PersonV2 extends _PersonV2 @override PersonV2 freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'fullName': fullName.toEJson(), + 'yearsSinceBirth': yearsSinceBirth.toEJson(), + }; + } + + static EJsonValue _toEJson(PersonV2 value) => value.toEJson(); + static PersonV2 _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'fullName': EJsonValue fullName, + 'yearsSinceBirth': EJsonValue yearsSinceBirth, + } => + PersonV2( + fromEJson(id), + fromEJson(fullName), + yearsSinceBirth: fromEJson(yearsSinceBirth), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(PersonV2._); - return const SchemaObject(ObjectType.realmObject, PersonV2, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, PersonV2, 'Person', [ SchemaProperty('id', RealmPropertyType.string, primaryKey: true), SchemaProperty('fullName', RealmPropertyType.string), SchemaProperty('yearsSinceBirth', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/open_flexible_sync_realm_test.dart b/examples/dart/test/open_flexible_sync_realm_test.dart index 4e2696fbae..ce7766caf5 100644 --- a/examples/dart/test/open_flexible_sync_realm_test.dart +++ b/examples/dart/test/open_flexible_sync_realm_test.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import './utils.dart'; -part 'open_flexible_sync_realm_test.g.dart'; +part 'open_flexible_sync_realm_test.realm.dart'; @RealmModel() class _Tricycle { diff --git a/examples/dart/test/open_flexible_sync_realm_test.g.dart b/examples/dart/test/open_flexible_sync_realm_test.realm.dart similarity index 64% rename from examples/dart/test/open_flexible_sync_realm_test.g.dart rename to examples/dart/test/open_flexible_sync_realm_test.realm.dart index 3f5bda7be9..d2a66b2463 100644 --- a/examples/dart/test/open_flexible_sync_realm_test.g.dart +++ b/examples/dart/test/open_flexible_sync_realm_test.realm.dart @@ -36,16 +36,40 @@ class Tricycle extends _Tricycle @override Tricycle freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'name': name.toEJson(), + }; + } + + static EJsonValue _toEJson(Tricycle value) => value.toEJson(); + static Tricycle _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'name': EJsonValue name, + } => + Tricycle( + fromEJson(id), + fromEJson(name), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Tricycle._); - return const SchemaObject(ObjectType.realmObject, Tricycle, 'Tricycle', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Tricycle, 'Tricycle', [ SchemaProperty('id', RealmPropertyType.int, mapTo: '_id', primaryKey: true), SchemaProperty('name', RealmPropertyType.string), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @@ -90,16 +114,46 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/quick_start_sync_test.dart b/examples/dart/test/quick_start_sync_test.dart index 4d54c9a023..dde1829f80 100644 --- a/examples/dart/test/quick_start_sync_test.dart +++ b/examples/dart/test/quick_start_sync_test.dart @@ -1,6 +1,6 @@ import 'package:realm_dart/realm.dart'; -part 'quick_start_sync_test.g.dart'; +part 'quick_start_sync_test.realm.dart'; @RealmModel() class _Todo { diff --git a/examples/dart/test/quick_start_sync_test.g.dart b/examples/dart/test/quick_start_sync_test.realm.dart similarity index 69% rename from examples/dart/test/quick_start_sync_test.g.dart rename to examples/dart/test/quick_start_sync_test.realm.dart index bbed83d743..795ca8f70d 100644 --- a/examples/dart/test/quick_start_sync_test.g.dart +++ b/examples/dart/test/quick_start_sync_test.realm.dart @@ -56,16 +56,46 @@ class Todo extends _Todo with RealmEntity, RealmObjectBase, RealmObject { @override Todo freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'isComplete': isComplete.toEJson(), + 'summary': summary.toEJson(), + 'owner_id': ownerId.toEJson(), + }; + } + + static EJsonValue _toEJson(Todo value) => value.toEJson(); + static Todo _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'isComplete': EJsonValue isComplete, + 'summary': EJsonValue summary, + 'owner_id': EJsonValue ownerId, + } => + Todo( + fromEJson(id), + fromEJson(summary), + fromEJson(ownerId), + isComplete: fromEJson(isComplete), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Todo._); - return const SchemaObject(ObjectType.realmObject, Todo, 'Todo', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Todo, 'Todo', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('isComplete', RealmPropertyType.bool), SchemaProperty('summary', RealmPropertyType.string), SchemaProperty('ownerId', RealmPropertyType.string, mapTo: 'owner_id'), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/react_to_changes_test.dart b/examples/dart/test/react_to_changes_test.dart index 3a053e125b..1c27554f08 100644 --- a/examples/dart/test/react_to_changes_test.dart +++ b/examples/dart/test/react_to_changes_test.dart @@ -3,7 +3,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import './utils.dart'; -part 'react_to_changes_test.g.dart'; +part 'react_to_changes_test.realm.dart'; // :snippet-start: sample-data-models @RealmModel() diff --git a/examples/dart/test/react_to_changes_test.g.dart b/examples/dart/test/react_to_changes_test.realm.dart similarity index 66% rename from examples/dart/test/react_to_changes_test.g.dart rename to examples/dart/test/react_to_changes_test.realm.dart index b30e626ed7..6e6fd856bd 100644 --- a/examples/dart/test/react_to_changes_test.g.dart +++ b/examples/dart/test/react_to_changes_test.realm.dart @@ -50,17 +50,47 @@ class Character extends _Character @override Character freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'species': species.toEJson(), + 'age': age.toEJson(), + }; + } + + static EJsonValue _toEJson(Character value) => value.toEJson(); + static Character _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'species': EJsonValue species, + 'age': EJsonValue age, + } => + Character( + fromEJson(id), + fromEJson(name), + fromEJson(species), + fromEJson(age), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Character._); - return const SchemaObject(ObjectType.realmObject, Character, 'Character', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Character, 'Character', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('species', RealmPropertyType.string), SchemaProperty('age', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Fellowship extends _Fellowship @@ -102,16 +132,42 @@ class Fellowship extends _Fellowship @override Fellowship freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'members': members.toEJson(), + }; + } + + static EJsonValue _toEJson(Fellowship value) => value.toEJson(); + static Fellowship _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'members': EJsonValue members, + } => + Fellowship( + fromEJson(id), + fromEJson(name), + members: fromEJson(members), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Fellowship._); - return const SchemaObject( - ObjectType.realmObject, Fellowship, 'Fellowship', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Fellowship, 'Fellowship', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('members', RealmPropertyType.object, linkTarget: 'Character', collectionType: RealmCollectionType.list), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/read_write_data_test.dart b/examples/dart/test/read_write_data_test.dart index c59da93b58..aff7e94c65 100644 --- a/examples/dart/test/read_write_data_test.dart +++ b/examples/dart/test/read_write_data_test.dart @@ -4,7 +4,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import 'utils.dart'; -part 'read_write_data_test.g.dart'; +part 'read_write_data_test.realm.dart'; // :snippet-start: models @RealmModel() diff --git a/examples/dart/test/read_write_data_test.g.dart b/examples/dart/test/read_write_data_test.realm.dart similarity index 80% rename from examples/dart/test/read_write_data_test.g.dart rename to examples/dart/test/read_write_data_test.realm.dart index 8d12a689d4..b1a04434c5 100644 --- a/examples/dart/test/read_write_data_test.g.dart +++ b/examples/dart/test/read_write_data_test.realm.dart @@ -45,17 +45,44 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @override Person freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'hobbies': hobbies.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'hobbies': EJsonValue hobbies, + } => + Person( + fromEJson(id), + fromEJson(name), + hobbies: fromEJson(hobbies), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Person._); - return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('hobbies', RealmPropertyType.string, collectionType: RealmCollectionType.list), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Team extends _Team with RealmEntity, RealmObjectBase, RealmObject { @@ -135,12 +162,16 @@ class Team extends _Team with RealmEntity, RealmObjectBase, RealmObject { static final schema = () { RealmObjectBase.registerFactory(Team._); - return const SchemaObject(ObjectType.realmObject, Team, 'Team', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Team, 'Team', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('crew', RealmPropertyType.object, linkTarget: 'Person', collectionType: RealmCollectionType.list), SchemaProperty('eventLog', RealmPropertyType.mixed, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/schemas.dart b/examples/dart/test/schemas.dart index ce3cda9128..59c7a42155 100644 --- a/examples/dart/test/schemas.dart +++ b/examples/dart/test/schemas.dart @@ -1,7 +1,7 @@ // used in Define Realm Object Schema page import 'package:realm_dart/realm.dart'; // :snippet-start: part-directive -part 'schemas.g.dart'; +part 'schemas.realm.dart'; // :snippet-end: // :snippet-start: create-realm-model diff --git a/examples/dart/test/schemas.g.dart b/examples/dart/test/schemas.realm.dart similarity index 63% rename from examples/dart/test/schemas.g.dart rename to examples/dart/test/schemas.realm.dart index dbd6dcd33f..7e19b08834 100644 --- a/examples/dart/test/schemas.g.dart +++ b/examples/dart/test/schemas.realm.dart @@ -49,17 +49,47 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('make', RealmPropertyType.string), SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class SyncSchema extends _SyncSchema @@ -84,16 +114,36 @@ class SyncSchema extends _SyncSchema @override SyncSchema freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + }; + } + + static EJsonValue _toEJson(SyncSchema value) => value.toEJson(); + static SyncSchema _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + } => + SyncSchema( + fromEJson(id), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(SyncSchema._); - return const SchemaObject( - ObjectType.realmObject, SyncSchema, 'SyncSchema', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, SyncSchema, 'SyncSchema', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Bike extends _Bike with RealmEntity, RealmObjectBase, RealmObject { @@ -132,17 +182,44 @@ class Bike extends _Bike with RealmEntity, RealmObjectBase, RealmObject { @override Bike freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'owner': owner.toEJson(), + }; + } + + static EJsonValue _toEJson(Bike value) => value.toEJson(); + static Bike _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'owner': EJsonValue owner, + } => + Bike( + fromEJson(id), + fromEJson(name), + owner: fromEJson(owner), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Bike._); - return const SchemaObject(ObjectType.realmObject, Bike, 'Bike', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Bike, 'Bike', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('owner', RealmPropertyType.object, optional: true, linkTarget: 'Person'), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @@ -189,17 +266,47 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @override Person freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'firstName': firstName.toEJson(), + 'lastName': lastName.toEJson(), + 'age': age.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'firstName': EJsonValue firstName, + 'lastName': EJsonValue lastName, + 'age': EJsonValue age, + } => + Person( + fromEJson(id), + fromEJson(firstName), + fromEJson(lastName), + age: fromEJson(age), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Person._); - return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('firstName', RealmPropertyType.string), SchemaProperty('lastName', RealmPropertyType.string), SchemaProperty('age', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Scooter extends _Scooter with RealmEntity, RealmObjectBase, RealmObject { @@ -238,17 +345,44 @@ class Scooter extends _Scooter with RealmEntity, RealmObjectBase, RealmObject { @override Scooter freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'owner': owner.toEJson(), + }; + } + + static EJsonValue _toEJson(Scooter value) => value.toEJson(); + static Scooter _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'owner': EJsonValue owner, + } => + Scooter( + fromEJson(id), + fromEJson(name), + owner: fromEJson(owner), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Scooter._); - return const SchemaObject(ObjectType.realmObject, Scooter, 'Scooter', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Scooter, 'Scooter', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('owner', RealmPropertyType.object, optional: true, linkTarget: 'Person'), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class ScooterShop extends _ScooterShop @@ -290,16 +424,42 @@ class ScooterShop extends _ScooterShop @override ScooterShop freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'name': name.toEJson(), + 'scooters': scooters.toEJson(), + }; + } + + static EJsonValue _toEJson(ScooterShop value) => value.toEJson(); + static ScooterShop _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'name': EJsonValue name, + 'scooters': EJsonValue scooters, + } => + ScooterShop( + fromEJson(id), + fromEJson(name), + scooters: fromEJson(scooters), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(ScooterShop._); - return const SchemaObject( - ObjectType.realmObject, ScooterShop, 'ScooterShop', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, ScooterShop, 'ScooterShop', [ SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), SchemaProperty('name', RealmPropertyType.string), SchemaProperty('scooters', RealmPropertyType.object, linkTarget: 'Scooter', collectionType: RealmCollectionType.list), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/sync_multiple_processes_test.dart b/examples/dart/test/sync_multiple_processes_test.dart index f08c7ab958..0203ec9bea 100644 --- a/examples/dart/test/sync_multiple_processes_test.dart +++ b/examples/dart/test/sync_multiple_processes_test.dart @@ -7,7 +7,7 @@ import 'package:path/path.dart' as path; import './utils.dart'; import './open_flexible_sync_realm_test.dart'; -part 'sync_multiple_processes_test.g.dart'; +part 'sync_multiple_processes_test.realm.dart'; late App app; late User currentUser; diff --git a/examples/dart/test/sync_multiple_processes_test.g.dart b/examples/dart/test/sync_multiple_processes_test.realm.dart similarity index 61% rename from examples/dart/test/sync_multiple_processes_test.g.dart rename to examples/dart/test/sync_multiple_processes_test.realm.dart index 2832276768..bef93e3ba4 100644 --- a/examples/dart/test/sync_multiple_processes_test.g.dart +++ b/examples/dart/test/sync_multiple_processes_test.realm.dart @@ -28,12 +28,33 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @override Person freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'name': name.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'name': EJsonValue name, + } => + Person( + fromEJson(name), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Person._); - return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ SchemaProperty('name', RealmPropertyType.string, primaryKey: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/task_project_models_test.dart b/examples/dart/test/task_project_models_test.dart index b89d501ff7..047d7f0979 100644 --- a/examples/dart/test/task_project_models_test.dart +++ b/examples/dart/test/task_project_models_test.dart @@ -2,9 +2,9 @@ import 'package:realm_dart/realm.dart'; // :snippet-start: task-project-models -part 'task_project_models_test.g.dart'; // :remove: +part 'task_project_models_test.realm.dart'; // :remove: // :uncomment-start: -// part 'models.g.dart'; +// part 'models.realm.dart'; // :uncomment-end: @RealmModel() @@ -12,7 +12,7 @@ class _Item { @MapTo("_id") @PrimaryKey() late ObjectId id; - + @Indexed(RealmIndexType.fullText) late String name; bool isComplete = false; String? assignee; diff --git a/examples/dart/test/task_project_models_test.g.dart b/examples/dart/test/task_project_models_test.realm.dart similarity index 66% rename from examples/dart/test/task_project_models_test.g.dart rename to examples/dart/test/task_project_models_test.realm.dart index fe604e3da5..4e58bbca24 100644 --- a/examples/dart/test/task_project_models_test.g.dart +++ b/examples/dart/test/task_project_models_test.realm.dart @@ -75,33 +75,70 @@ class Item extends _Item with RealmEntity, RealmObjectBase, RealmObject { @override Item freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'name': name.toEJson(), + 'isComplete': isComplete.toEJson(), + 'assignee': assignee.toEJson(), + 'priority': priority.toEJson(), + 'progressMinutes': progressMinutes.toEJson(), + }; + } + + static EJsonValue _toEJson(Item value) => value.toEJson(); + static Item _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'name': EJsonValue name, + 'isComplete': EJsonValue isComplete, + 'assignee': EJsonValue assignee, + 'priority': EJsonValue priority, + 'progressMinutes': EJsonValue progressMinutes, + } => + Item( + fromEJson(id), + fromEJson(name), + isComplete: fromEJson(isComplete), + assignee: fromEJson(assignee), + priority: fromEJson(priority), + progressMinutes: fromEJson(progressMinutes), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Item._); - return const SchemaObject(ObjectType.realmObject, Item, 'Item', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Item, 'Item', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), - SchemaProperty('name', RealmPropertyType.string), + SchemaProperty('name', RealmPropertyType.string, + indexType: RealmIndexType.fullText), SchemaProperty('isComplete', RealmPropertyType.bool), SchemaProperty('assignee', RealmPropertyType.string, optional: true), SchemaProperty('priority', RealmPropertyType.int), SchemaProperty('progressMinutes', RealmPropertyType.int), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } class Project extends _Project with RealmEntity, RealmObjectBase, RealmObject { Project( ObjectId id, String name, { - int? quota, Iterable items = const [], + int? quota, }) { RealmObjectBase.set(this, '_id', id); RealmObjectBase.set(this, 'name', name); - RealmObjectBase.set(this, 'quota', quota); RealmObjectBase.set>(this, 'items', RealmList(items)); + RealmObjectBase.set(this, 'quota', quota); } Project._(); @@ -135,11 +172,38 @@ class Project extends _Project with RealmEntity, RealmObjectBase, RealmObject { @override Project freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'name': name.toEJson(), + 'items': items.toEJson(), + 'quota': quota.toEJson(), + }; + } + + static EJsonValue _toEJson(Project value) => value.toEJson(); + static Project _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'name': EJsonValue name, + 'items': EJsonValue items, + 'quota': EJsonValue quota, + } => + Project( + fromEJson(id), + fromEJson(name), + items: fromEJson(items), + quota: fromEJson(quota), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Project._); - return const SchemaObject(ObjectType.realmObject, Project, 'Project', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Project, 'Project', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('name', RealmPropertyType.string), @@ -147,5 +211,8 @@ class Project extends _Project with RealmEntity, RealmObjectBase, RealmObject { linkTarget: 'Item', collectionType: RealmCollectionType.list), SchemaProperty('quota', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/write_copy_test.dart b/examples/dart/test/write_copy_test.dart index 61f46cec4a..a5748e06d0 100644 --- a/examples/dart/test/write_copy_test.dart +++ b/examples/dart/test/write_copy_test.dart @@ -2,7 +2,7 @@ import 'package:test/test.dart'; import 'package:realm_dart/realm.dart'; import 'utils.dart'; import 'dart:math'; -part 'write_copy_test.g.dart'; +part 'write_copy_test.realm.dart'; @RealmModel() class _Person { diff --git a/examples/dart/test/write_copy_test.g.dart b/examples/dart/test/write_copy_test.realm.dart similarity index 60% rename from examples/dart/test/write_copy_test.g.dart rename to examples/dart/test/write_copy_test.realm.dart index b78bcc11b3..aabbe57689 100644 --- a/examples/dart/test/write_copy_test.g.dart +++ b/examples/dart/test/write_copy_test.realm.dart @@ -28,12 +28,33 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject { @override Person freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + 'name': name.toEJson(), + }; + } + + static EJsonValue _toEJson(Person value) => value.toEJson(); + static Person _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'name': EJsonValue name, + } => + Person( + fromEJson(name), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Person._); - return const SchemaObject(ObjectType.realmObject, Person, 'Person', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Person, 'Person', [ SchemaProperty('name', RealmPropertyType.string, primaryKey: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test/write_to_synced_realm_test.dart b/examples/dart/test/write_to_synced_realm_test.dart index cb905855b7..4ea33e5703 100644 --- a/examples/dart/test/write_to_synced_realm_test.dart +++ b/examples/dart/test/write_to_synced_realm_test.dart @@ -3,7 +3,7 @@ import 'package:realm_dart/realm.dart'; import 'utils.dart'; -part 'write_to_synced_realm_test.g.dart'; +part 'write_to_synced_realm_test.realm.dart'; // NOTE: this is a unique App ID from the other Flutter tests // because these examples require unique sync permissions. diff --git a/examples/dart/test/write_to_synced_realm_test.g.dart b/examples/dart/test/write_to_synced_realm_test.realm.dart similarity index 68% rename from examples/dart/test/write_to_synced_realm_test.g.dart rename to examples/dart/test/write_to_synced_realm_test.realm.dart index 6cce17ca6e..586d4d723b 100644 --- a/examples/dart/test/write_to_synced_realm_test.g.dart +++ b/examples/dart/test/write_to_synced_realm_test.realm.dart @@ -56,11 +56,41 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { @override Car freeze() => RealmObjectBase.freezeObject(this); - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'ownerId': ownerId.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'ownerId': EJsonValue ownerId, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(ownerId), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ SchemaProperty('id', RealmPropertyType.objectid, mapTo: '_id', primaryKey: true), SchemaProperty('ownerId', RealmPropertyType.string), @@ -68,5 +98,8 @@ class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { SchemaProperty('model', RealmPropertyType.string, optional: true), SchemaProperty('miles', RealmPropertyType.int, optional: true), ]); - } + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; } diff --git a/examples/dart/test_sdk_example/lib/schema.dart b/examples/dart/test_sdk_example/lib/schema.dart index e4708c1cb9..efcd4d950a 100644 --- a/examples/dart/test_sdk_example/lib/schema.dart +++ b/examples/dart/test_sdk_example/lib/schema.dart @@ -1,6 +1,6 @@ import 'package:realm/realm.dart'; -part 'schema.g.dart'; +part 'schema.realm.dart'; @RealmModel() class _Car { diff --git a/examples/dart/test_sdk_example/lib/schema.g.dart b/examples/dart/test_sdk_example/lib/schema.g.dart deleted file mode 100644 index c5360d58f6..0000000000 --- a/examples/dart/test_sdk_example/lib/schema.g.dart +++ /dev/null @@ -1,63 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'schema.dart'; - -// ************************************************************************** -// RealmObjectGenerator -// ************************************************************************** - -class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { - Car( - ObjectId id, - String make, { - String? model, - int? miles, - }) { - RealmObjectBase.set(this, '_id', id); - RealmObjectBase.set(this, 'make', make); - RealmObjectBase.set(this, 'model', model); - RealmObjectBase.set(this, 'miles', miles); - } - - Car._(); - - @override - ObjectId get id => RealmObjectBase.get(this, '_id') as ObjectId; - @override - set id(ObjectId value) => RealmObjectBase.set(this, '_id', value); - - @override - String get make => RealmObjectBase.get(this, 'make') as String; - @override - set make(String value) => RealmObjectBase.set(this, 'make', value); - - @override - String? get model => RealmObjectBase.get(this, 'model') as String?; - @override - set model(String? value) => RealmObjectBase.set(this, 'model', value); - - @override - int? get miles => RealmObjectBase.get(this, 'miles') as int?; - @override - set miles(int? value) => RealmObjectBase.set(this, 'miles', value); - - @override - Stream> get changes => - RealmObjectBase.getChanges(this); - - @override - Car freeze() => RealmObjectBase.freezeObject(this); - - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { - RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ - SchemaProperty('id', RealmPropertyType.objectid, - mapTo: '_id', primaryKey: true), - SchemaProperty('make', RealmPropertyType.string), - SchemaProperty('model', RealmPropertyType.string, optional: true), - SchemaProperty('miles', RealmPropertyType.int, optional: true), - ]); - } -} diff --git a/examples/dart/test_sdk_example/lib/schema.realm.dart b/examples/dart/test_sdk_example/lib/schema.realm.dart new file mode 100644 index 0000000000..cf2e1f5bcb --- /dev/null +++ b/examples/dart/test_sdk_example/lib/schema.realm.dart @@ -0,0 +1,94 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'schema.dart'; + +// ************************************************************************** +// RealmObjectGenerator +// ************************************************************************** + +// ignore_for_file: type=lint +class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { + Car( + ObjectId id, + String make, { + String? model, + int? miles, + }) { + RealmObjectBase.set(this, '_id', id); + RealmObjectBase.set(this, 'make', make); + RealmObjectBase.set(this, 'model', model); + RealmObjectBase.set(this, 'miles', miles); + } + + Car._(); + + @override + ObjectId get id => RealmObjectBase.get(this, '_id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, '_id', value); + + @override + String get make => RealmObjectBase.get(this, 'make') as String; + @override + set make(String value) => RealmObjectBase.set(this, 'make', value); + + @override + String? get model => RealmObjectBase.get(this, 'model') as String?; + @override + set model(String? value) => RealmObjectBase.set(this, 'model', value); + + @override + int? get miles => RealmObjectBase.get(this, 'miles') as int?; + @override + set miles(int? value) => RealmObjectBase.set(this, 'miles', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Car freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + '_id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + '_id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Car._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ + SchemaProperty('id', RealmPropertyType.objectid, + mapTo: '_id', primaryKey: true), + SchemaProperty('make', RealmPropertyType.string), + SchemaProperty('model', RealmPropertyType.string, optional: true), + SchemaProperty('miles', RealmPropertyType.int, optional: true), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} diff --git a/examples/dart/test_sdk_example/pubspec.lock b/examples/dart/test_sdk_example/pubspec.lock new file mode 100644 index 0000000000..5a5acb86cd --- /dev/null +++ b/examples/dart/test_sdk_example/pubspec.lock @@ -0,0 +1,629 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + url: "https://pub.dev" + source: hosted + version: "64.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_cli_annotations: + dependency: transitive + description: + name: build_cli_annotations + sha256: b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172 + url: "https://pub.dev" + source: hosted + version: "2.1.0" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" + url: "https://pub.dev" + source: hosted + version: "4.0.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: transitive + description: + name: build_runner + sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21" + url: "https://pub.dev" + source: hosted + version: "2.4.8" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799" + url: "https://pub.dev" + source: hosted + version: "7.3.0" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cancellation_token: + dependency: transitive + description: + name: cancellation_token + sha256: ad95acf9d4b2f3563e25dc937f63587e46a70ce534e910b65d10e115490f1027 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + url: "https://pub.dev" + source: hosted + version: "4.10.0" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + url: "https://pub.dev" + source: hosted + version: "2.3.6" + ejson: + dependency: transitive + description: + name: ejson + sha256: "2d69382ea016c5f38c9d966681b464ca23d5f594918d4cb7dfecf0a3dad31395" + url: "https://pub.dev" + source: hosted + version: "0.2.0-pre.1" + ejson_annotation: + dependency: transitive + description: + name: ejson_annotation + sha256: f14948884cf6d91e00c727d5ec6b2395bdcb511541aa7956e4e03b73cd089149 + url: "https://pub.dev" + source: hosted + version: "0.2.0-pre.1" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http: + dependency: transitive + description: + name: http + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba + url: "https://pub.dev" + source: hosted + version: "1.2.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + mime: + dependency: transitive + description: + name: mime + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" + source: hosted + version: "1.0.5" + objectid: + dependency: transitive + description: + name: objectid + sha256: fd4a0b9fe07df25c446948b786e7ab2f363b2f461afa78632cab179d7613b9b3 + url: "https://pub.dev" + source: hosted + version: "3.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + realm: + dependency: "direct main" + description: + name: realm + sha256: b3f8a2c2a362aefaafb65b9551733d15fd804587caac2c8b1fd1abe535918531 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + realm_common: + dependency: transitive + description: + name: realm_common + sha256: c4c994217c3f1dafdb3e36b5e3c75c6f4719fd5bd64f64a5acb79a5c962c018f + url: "https://pub.dev" + source: hosted + version: "2.0.0" + realm_dart: + dependency: transitive + description: + name: realm_dart + sha256: "861b007dccf19ecfb1e7f47f2b0c246755b82c40e122d61fde18180dbbaf88a3" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + realm_generator: + dependency: transitive + description: + name: realm_generator + sha256: "3cad739d4491bc5b4ccdd184083fd58f6899e410d0acda7448b60261639e2735" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + sane_uuid: + dependency: transitive + description: + name: sane_uuid + sha256: "5e83f796a7d19d38d3ba3a940642998fdd8c4a4049be135ed25404e37f76a18c" + url: "https://pub.dev" + source: hosted + version: "1.0.0-alpha.5" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + tar: + dependency: transitive + description: + name: tar + sha256: "1680219f82dfa81c8d0e76e849b7b34ea969c721f55a8ebd294a9a95e740dd42" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + type_plus: + dependency: transitive + description: + name: type_plus + sha256: "2e33cfac2e129297d5874567bdf7587502ec359881e9318551e014d91b02f84a" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.2.0 <4.0.0" + flutter: ">=3.10.0" diff --git a/examples/dart/test_sdk_example/pubspec.yaml b/examples/dart/test_sdk_example/pubspec.yaml index c7a86d21fe..71d81c6d49 100644 --- a/examples/dart/test_sdk_example/pubspec.yaml +++ b/examples/dart/test_sdk_example/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - realm: ^1.5.0 + realm: ^2.0.0 dev_dependencies: flutter_test: diff --git a/examples/dart/test_sdk_example/test/car.dart b/examples/dart/test_sdk_example/test/car.dart index 9e33a3a68d..0b57c6accf 100644 --- a/examples/dart/test_sdk_example/test/car.dart +++ b/examples/dart/test_sdk_example/test/car.dart @@ -1,13 +1,14 @@ // :snippet-start: define-model-flutter import 'package:realm/realm.dart'; -part 'car.g.dart'; +part 'car.realm.dart'; @RealmModel() class _Car { @PrimaryKey() - late final String make; + late ObjectId id; + late String make; late String? model; late int? miles; } diff --git a/examples/dart/test_sdk_example/test/car.g.dart b/examples/dart/test_sdk_example/test/car.g.dart deleted file mode 100644 index 9a77dbec29..0000000000 --- a/examples/dart/test_sdk_example/test/car.g.dart +++ /dev/null @@ -1,54 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'car.dart'; - -// ************************************************************************** -// RealmObjectGenerator -// ************************************************************************** - -class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { - Car( - String make, { - String? model, - int? miles, - }) { - RealmObjectBase.set(this, 'make', make); - RealmObjectBase.set(this, 'model', model); - RealmObjectBase.set(this, 'miles', miles); - } - - Car._(); - - @override - String get make => RealmObjectBase.get(this, 'make') as String; - @override - set make(String value) => throw RealmUnsupportedSetError(); - - @override - String? get model => RealmObjectBase.get(this, 'model') as String?; - @override - set model(String? value) => RealmObjectBase.set(this, 'model', value); - - @override - int? get miles => RealmObjectBase.get(this, 'miles') as int?; - @override - set miles(int? value) => RealmObjectBase.set(this, 'miles', value); - - @override - Stream> get changes => - RealmObjectBase.getChanges(this); - - @override - Car freeze() => RealmObjectBase.freezeObject(this); - - static SchemaObject get schema => _schema ??= _initSchema(); - static SchemaObject? _schema; - static SchemaObject _initSchema() { - RealmObjectBase.registerFactory(Car._); - return const SchemaObject(ObjectType.realmObject, Car, 'Car', [ - SchemaProperty('make', RealmPropertyType.string, primaryKey: true), - SchemaProperty('model', RealmPropertyType.string, optional: true), - SchemaProperty('miles', RealmPropertyType.int, optional: true), - ]); - } -} diff --git a/examples/dart/test_sdk_example/test/car.realm.dart b/examples/dart/test_sdk_example/test/car.realm.dart new file mode 100644 index 0000000000..8734882801 --- /dev/null +++ b/examples/dart/test_sdk_example/test/car.realm.dart @@ -0,0 +1,93 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'car.dart'; + +// ************************************************************************** +// RealmObjectGenerator +// ************************************************************************** + +// ignore_for_file: type=lint +class Car extends _Car with RealmEntity, RealmObjectBase, RealmObject { + Car( + ObjectId id, + String make, { + String? model, + int? miles, + }) { + RealmObjectBase.set(this, 'id', id); + RealmObjectBase.set(this, 'make', make); + RealmObjectBase.set(this, 'model', model); + RealmObjectBase.set(this, 'miles', miles); + } + + Car._(); + + @override + ObjectId get id => RealmObjectBase.get(this, 'id') as ObjectId; + @override + set id(ObjectId value) => RealmObjectBase.set(this, 'id', value); + + @override + String get make => RealmObjectBase.get(this, 'make') as String; + @override + set make(String value) => RealmObjectBase.set(this, 'make', value); + + @override + String? get model => RealmObjectBase.get(this, 'model') as String?; + @override + set model(String? value) => RealmObjectBase.set(this, 'model', value); + + @override + int? get miles => RealmObjectBase.get(this, 'miles') as int?; + @override + set miles(int? value) => RealmObjectBase.set(this, 'miles', value); + + @override + Stream> get changes => + RealmObjectBase.getChanges(this); + + @override + Car freeze() => RealmObjectBase.freezeObject(this); + + EJsonValue toEJson() { + return { + 'id': id.toEJson(), + 'make': make.toEJson(), + 'model': model.toEJson(), + 'miles': miles.toEJson(), + }; + } + + static EJsonValue _toEJson(Car value) => value.toEJson(); + static Car _fromEJson(EJsonValue ejson) { + return switch (ejson) { + { + 'id': EJsonValue id, + 'make': EJsonValue make, + 'model': EJsonValue model, + 'miles': EJsonValue miles, + } => + Car( + fromEJson(id), + fromEJson(make), + model: fromEJson(model), + miles: fromEJson(miles), + ), + _ => raiseInvalidEJson(ejson), + }; + } + + static final schema = () { + RealmObjectBase.registerFactory(Car._); + register(_toEJson, _fromEJson); + return SchemaObject(ObjectType.realmObject, Car, 'Car', [ + SchemaProperty('id', RealmPropertyType.objectid, primaryKey: true), + SchemaProperty('make', RealmPropertyType.string), + SchemaProperty('model', RealmPropertyType.string, optional: true), + SchemaProperty('miles', RealmPropertyType.int, optional: true), + ]); + }(); + + @override + SchemaObject get objectSchema => RealmObjectBase.getSchema(this) ?? schema; +} diff --git a/examples/dotnet/Examples/RqlSchemaExamples.cs b/examples/dotnet/Examples/RqlSchemaExamples.cs index f96eb178e5..07e48efb68 100644 --- a/examples/dotnet/Examples/RqlSchemaExamples.cs +++ b/examples/dotnet/Examples/RqlSchemaExamples.cs @@ -20,6 +20,7 @@ public class RqlTask : RealmObject public ObjectId Id { get; set; } = ObjectId.GenerateNewId(); [MapTo("name")] + [Indexed(IndexType.FullText)] public string Name { get; set; } [MapTo("isComplete")] diff --git a/examples/ios/Examples/MongoDBRemoteAccess.swift b/examples/ios/Examples/MongoDBRemoteAccess.swift index 4e0cb38a37..c6d1349fe7 100644 --- a/examples/ios/Examples/MongoDBRemoteAccess.swift +++ b/examples/ios/Examples/MongoDBRemoteAccess.swift @@ -160,7 +160,7 @@ class MongoDBRemoteAccessTestCase: XCTestCase { } } } - wait(for: [expectation, expectation2, expectation3], timeout: 20) + wait(for: [expectation, expectation2, expectation3], timeout: 30) } // MARK: Find One @@ -320,7 +320,7 @@ class MongoDBRemoteAccessTestCase: XCTestCase { } } } - wait(for: [expectation, expectation2, expectation3], timeout: 20) + wait(for: [expectation, expectation2, expectation3], timeout: 30) } // MARK: Find and Sort Many @@ -856,7 +856,7 @@ class MongoDBRemoteAccessTestCase: XCTestCase { } } } - wait(for: [expectation], timeout: 10) + wait(for: [expectation], timeout: 20) } // MARK: ChangeEventDelegate @@ -1289,7 +1289,7 @@ class MongoDBRemoteAccessTestCaseAsyncAPIs: XCTestCase { print("Received event: \(event.documentValue!)") } } - await fulfillment(of: [openEx], timeout: 5.0) // :remove: + await fulfillment(of: [openEx], timeout: 30.0) // :remove: // Updating a document in the collection triggers a change event. let queryFilter: Document = ["_id": AnyBSON(objectId) ] diff --git a/examples/ios/Examples/MongoDBRemoteAccessAggregate.swift b/examples/ios/Examples/MongoDBRemoteAccessAggregate.swift index 94265ed4c9..fc7281ba2f 100644 --- a/examples/ios/Examples/MongoDBRemoteAccessAggregate.swift +++ b/examples/ios/Examples/MongoDBRemoteAccessAggregate.swift @@ -184,7 +184,7 @@ class MongoDBRemoteAccessAggregationTestCase: XCTestCase { } } } - wait(for: [expectation, expectation2, expectation3, expectation4], timeout: 25) + wait(for: [expectation, expectation2, expectation3, expectation4], timeout: 35) } // MARK: Aggregation Project @@ -276,7 +276,7 @@ class MongoDBRemoteAccessAggregationTestCase: XCTestCase { } } } - wait(for: [expectation, expectation2, expectation3], timeout: 20) + wait(for: [expectation, expectation2, expectation3], timeout: 30) } // MARK: Aggregation Add Fields @@ -361,7 +361,7 @@ class MongoDBRemoteAccessAggregationTestCase: XCTestCase { } } } - wait(for: [expectation, expectation2, expectation3], timeout: 25) + wait(for: [expectation, expectation2, expectation3], timeout: 35) } // MARK: Aggregation Unwind @@ -456,6 +456,6 @@ class MongoDBRemoteAccessAggregationTestCase: XCTestCase { } } } - wait(for: [expectation, expectation2, expectation3], timeout: 25) + wait(for: [expectation, expectation2, expectation3], timeout: 35) } } diff --git a/examples/ios/Examples/Sync.swift b/examples/ios/Examples/Sync.swift index 234ef20285..fc74c8e0ab 100644 --- a/examples/ios/Examples/Sync.swift +++ b/examples/ios/Examples/Sync.swift @@ -161,15 +161,27 @@ class Sync: AnonymouslyLoggedInTestCase { // Leaving this example using Partition-Based Sync // since progress notifications are currently only supported in PBS + // IMPORTANT: this example is also used on the PBS page for opening + // a synced realm, so leave it even after progress notifications + // are supported in Flexible Sync. func testCheckProgress() { + // :snippet-start: open-realm-partition-based-sync let app = App(id: YOUR_APP_SERVICES_APP_ID) + + // Store a configuration that consists of the current user, + // authenticated to this instance of your app. If there is no + // user, your code should log one in. let user = app.currentUser let partitionValue = "some partition value" var configuration = user!.configuration(partitionValue: partitionValue) // :remove-start: configuration.objectTypes = [SyncExamples_Task.self] // :remove-end: + + // Open the database with the user's configuration. let syncedRealm = try! Realm(configuration: configuration) + print("Successfully opened the synced realm: \(syncedRealm)") + // :snippet-end: let expectation = XCTestExpectation(description: "it completes") expectation.assertForOverFulfill = false diff --git a/examples/ios/RealmExamples.xcodeproj/project.pbxproj b/examples/ios/RealmExamples.xcodeproj/project.pbxproj index b85c93803a..154cdfb217 100644 --- a/examples/ios/RealmExamples.xcodeproj/project.pbxproj +++ b/examples/ios/RealmExamples.xcodeproj/project.pbxproj @@ -1477,7 +1477,7 @@ repositoryURL = "https://github.com/realm/realm-swift.git"; requirement = { kind = exactVersion; - version = 10.47.0; + version = 10.48.1; }; }; 917CA79427ECADC200F9BDDC /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */ = { diff --git a/examples/kotlin/settings.gradle.kts b/examples/kotlin/settings.gradle.kts index 1eba2240b9..2dac7eb061 100644 --- a/examples/kotlin/settings.gradle.kts +++ b/examples/kotlin/settings.gradle.kts @@ -9,7 +9,7 @@ pluginManagement { dependencyResolutionManagement { versionCatalogs { create("libs") { - version("realm", "1.13.0") + version("realm", "1.14.0") version("kotlinx-coroutines", "1.7.0") version("kotlinx-serialization", "1.5.0") library("realm-plugin", "io.realm.kotlin", "gradle-plugin").versionRef("realm") @@ -25,4 +25,4 @@ dependencyResolutionManagement { rootProject.name = "RealmKMMApp" include(":androidRealmKMMApp") -include(":shared") \ No newline at end of file +include(":shared") diff --git a/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/AppClientTest.kt b/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/AppClientTest.kt index 00bd8113fc..d2072f0719 100644 --- a/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/AppClientTest.kt +++ b/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/AppClientTest.kt @@ -11,6 +11,7 @@ import io.realm.kotlin.mongodb.exceptions.ConnectionException import io.realm.kotlin.mongodb.exceptions.InvalidCredentialsException import io.realm.kotlin.mongodb.exceptions.ServiceException import kotlinx.coroutines.channels.Channel +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -19,7 +20,6 @@ import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds - class AppClientTest: RealmTest() { @Test fun initializeAndCloseAppClientTest() { @@ -95,8 +95,8 @@ class AppClientTest: RealmTest() { @Test fun encryptAppMetadata() { val myEncryptionKey = getEncryptionKey() - val config = // :snippet-start: encrypted-app-client + val config = AppConfiguration.Builder(YOUR_APP_ID) // Specify the encryption key .encryptionKey(myEncryptionKey) @@ -105,6 +105,17 @@ class AppClientTest: RealmTest() { assertTrue(config.encryptionKey.contentEquals(myEncryptionKey)) } + @Ignore + // Ignored unless there's a way to test this easily... + fun enablePlatformNetworking() { + // :snippet-start: enable-platform-networking + val config = + AppConfiguration.Builder(YOUR_APP_ID) + .usePlatformNetworking(true) + .build() + // :snippet-end: + } + @Test fun setCustomHttpHeadersTest() { val config1 = AppConfiguration.Builder(YOUR_APP_ID) @@ -202,4 +213,4 @@ class AppClientTest: RealmTest() { app.close() } } -} \ No newline at end of file +} diff --git a/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/RQLTest.kt b/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/RQLTest.kt index 32d23a2efb..ce6e87a6d1 100644 --- a/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/RQLTest.kt +++ b/examples/kotlin/shared/src/commonTest/kotlin/com/mongodb/realm/realmkmmapp/RQLTest.kt @@ -4,6 +4,7 @@ import io.realm.kotlin.ext.realmListOf import io.realm.kotlin.types.RealmList import io.realm.kotlin.types.RealmObject import io.realm.kotlin.types.annotations.PrimaryKey +import io.realm.kotlin.types.annotations.FullText import org.mongodb.kbson.ObjectId class RQLTest: RealmTest() { @@ -11,6 +12,7 @@ class RQLTest: RealmTest() { class Item(): RealmObject { @PrimaryKey var _id: ObjectId = ObjectId() + @FullText var name: String = "" var isComplete: Boolean = false var assignee: String? = null diff --git a/examples/node/legacy/Examples/realm-query-language.js b/examples/node/legacy/Examples/realm-query-language.js index 518d09c670..305e8ccab2 100644 --- a/examples/node/legacy/Examples/realm-query-language.js +++ b/examples/node/legacy/Examples/realm-query-language.js @@ -1,6 +1,10 @@ import Realm, { BSON } from "realm"; import { ItemModel, ProjectModel } from "./schemas/rql-data-models"; +// Tests for new RQL operators or updates should be placed in the new +// file compatible with JSv12 and later, located at +// examples/node/v12/__tests__/realm-query-language.test.js + describe("Realm Query Language Reference", () => { let realm; beforeEach(async () => { diff --git a/examples/node/legacy/Examples/schemas/rql-data-models.js b/examples/node/legacy/Examples/schemas/rql-data-models.js index d79c14c093..0e2cd9a02f 100644 --- a/examples/node/legacy/Examples/schemas/rql-data-models.js +++ b/examples/node/legacy/Examples/schemas/rql-data-models.js @@ -3,7 +3,7 @@ const ItemModel = { name: "Item", properties: { id: "objectId", - name: "string", + name: {type: "string", indexed: "full-text"}, isComplete: { type: "bool", default: false }, assignee: "string?", priority: { diff --git a/examples/node/v12/__tests__/models/rql-data-models.ts b/examples/node/v12/__tests__/models/rql-data-models.ts new file mode 100644 index 0000000000..210aaddcdc --- /dev/null +++ b/examples/node/v12/__tests__/models/rql-data-models.ts @@ -0,0 +1,52 @@ +import Realm, { BSON, ObjectSchema } from "realm"; + +export class Item extends Realm.Object { + _id!: BSON.ObjectId; + name!: string; + isComplete!: boolean; + assignee?: string; + priority!: number; + progressMinutes?: number; + + static schema: ObjectSchema = { + name: "Item", + properties: { + _id: "objectId", + name: { type:"string", indexed: "full-text" }, + isComplete: { type: "bool", default: false }, + assignee: "string?", + priority: { + type: "int", + default: 0, + }, + progressMinutes: { + type: "int", + default: 0, + }, + projects: { + type: "linkingObjects", + objectType: "Project", + property: "items", + }, + }, + primaryKey: "_id", + }; +} + +export class Project extends Realm.Object { + _id!: BSON.ObjectId; + name!: string; + items!: Realm.List + quota?: number + + static schema: ObjectSchema = { + name: "Project", + properties: { + _id: "objectId", + name: "string", + items: "Item[]", + quota: "int?", + }, + primaryKey: "_id", + } +}; diff --git a/examples/node/v12/__tests__/realm-query-language.test.js b/examples/node/v12/__tests__/realm-query-language.test.js new file mode 100644 index 0000000000..81a11913c9 --- /dev/null +++ b/examples/node/v12/__tests__/realm-query-language.test.js @@ -0,0 +1,136 @@ +import Realm, { BSON } from "realm"; +import { Item, Project } from "./models/rql-data-models.ts"; + +describe("Realm Query Language Reference", () => { + let realm; + beforeEach(async () => { + realm = await Realm.open({ + schema: [Project, Item], + deleteRealmIfMigrationNeeded: true, + }); + + // populate test objects + realm.write(() => { + realm.create("Project", { + _id: new Realm.BSON.ObjectId(), + name: "New Project", + items: [ + { + _id: new Realm.BSON.ObjectId(), + name: "Write tests", + isComplete: false, + assignee: "Alex", + priority: 5, + progressMinutes: 125, + }, + { + _id: new Realm.BSON.ObjectId(), + name: "Run tests", + isComplete: false, + assignee: "Ali", + priority: 9, + progressMinutes: 10, + }, + { + _id: new Realm.BSON.ObjectId(), + name: "Bluehawk Tests", + isComplete: false, + assignee: null, + priority: 10, + progressMinutes: 55, + }, + ], + }); + const proj1 = realm.create("Project", { + _id: new Realm.BSON.ObjectId(), + name: "Project with High Quota", + quota: 12, + items: [ + { + _id: new Realm.BSON.ObjectId(), + name: "Create a ticket", + isComplete: true, + assignee: "Nick", + priority: 2, + progressMinutes: 8, + }, + { + _id: new Realm.BSON.ObjectId(), + name: "Schedule a meeting", + isComplete: true, + assignee: "Chris", + priority: 9, + progressMinutes: 10, + }, + { + _id: new Realm.BSON.ObjectId(), + name: "Get coffee", + isComplete: false, + assignee: "Dachary", + priority: 11, + progressMinutes: 3, + }, + ], + }); + + const proj2 = realm.create("Project", { + _id: new Realm.BSON.ObjectId(), + name: "Another project", + items: [proj1.items[2]], + }); + + realm.create("Item", { + _id: new Realm.BSON.ObjectId(), + name: "Assign me to a project", + isComplete: false, + assignee: "Nick", + priority: 2, + progressMinutes: 0, + }); + }); + + expect(realm.objects("Project")[0].name).toBe("New Project"); + expect(realm.objects("Item")[0].name).toBe("Write tests"); + }); + + afterEach(() => { + // After the test, delete the objects and close the realm + if (realm && !realm.isClosed) { + realm.write(() => { + realm.deleteAll(); + }); + realm.close(); + } + }); + + test("full-text search", () => { + const items = realm.objects(Item); + + const itemsWithWrite = items.filtered( + // :snippet-start: rql-fts + // Filter for items with 'write' in the name + "name TEXT $0", "write" + + // :remove-start: + ); + + const itemsWithWriteNotTest = items.filtered( + // :remove-end: + // Find items with 'write' but not 'tests' using '-' + "name TEXT $0", "write -tests" + + // :remove-start: + ); + + const itemsStartingWithWri = items.filtered( + // :remove-end: + // Find items starting with 'wri-' using '*' + "name TEXT $0", "wri*" + // :snippet-end: + ); + + expect(itemsWithWrite.length).toBe(1) + expect(itemsWithWriteNotTest.length).toBe(0); + expect(itemsStartingWithWri.length).toBe(1); + }); +}); \ No newline at end of file diff --git a/examples/web/package.json b/examples/web/package.json index a73d6e07b3..6d39c3314b 100644 --- a/examples/web/package.json +++ b/examples/web/package.json @@ -3,17 +3,17 @@ "version": "0.1.0", "private": true, "dependencies": { - "@apollo/client": "^3.5.9", + "@apollo/client": "^3.9.4", "@babel/plugin-syntax-flow": "^7.23.3", "@babel/plugin-transform-react-jsx": "7.23.4", - "@testing-library/jest-dom": "^6.2.0", + "@testing-library/jest-dom": "^6.4.2", "@testing-library/user-event": "^14.5.2", "@testing-library/dom": "^9.3.4", - "@types/jest": "^29.5.11", - "@types/node": "^20.11.16", - "@types/react": "^18.2.55", - "@types/react-dom": "^18.2.18", - "firebase": "^10.7.1", + "@types/jest": "^29.5.12", + "@types/node": "^20.11.17", + "@types/react": "^18.2.56", + "@types/react-dom": "^18.2.19", + "firebase": "^10.8.1", "graphql": "^16.8.1", "graphql-tag": "^2.12.6", "react": "^18.2.0", @@ -21,8 +21,8 @@ "react-scripts": "5.0.1", "react-test-renderer": "^18.2.0", "realm-web": "^2.0.0", - "typescript": "^5.3.3", - "web-vitals": "^3.5.1" + "typescript": "^5.4.2", + "web-vitals": "^3.5.2" }, "scripts": { "start": "react-scripts start", @@ -50,10 +50,10 @@ ] }, "devDependencies": { - "@testing-library/react": "^14.1.2", + "@testing-library/react": "^14.2.1", "bluehawk": "^1.4.0", "lodash": "^4.17.21", "@babel/plugin-transform-private-property-in-object": "^7.23.4", - "@babel/core": "^7.23.7" + "@babel/core": "^7.24.0" } } diff --git a/examples/web/yarn.lock b/examples/web/yarn.lock index 882bcacc39..69182a36b1 100644 --- a/examples/web/yarn.lock +++ b/examples/web/yarn.lock @@ -34,10 +34,10 @@ jsonpointer "^5.0.0" leven "^3.1.0" -"@apollo/client@^3.5.9": - version "3.9.2" - resolved "https://registry.yarnpkg.com/@apollo/client/-/client-3.9.2.tgz#96edf2c212f828bad1ef3d84234fa473c5a27ff8" - integrity sha512-Zw9WvXjqhpbgkvAvnj52vstOWwM0iedKWtn1hSq1cODQyoe1CF2uFwMYFI7l56BrAY9CzLi6MQA0AhxpgJgvxw== +"@apollo/client@^3.9.4": + version "3.9.6" + resolved "https://registry.yarnpkg.com/@apollo/client/-/client-3.9.6.tgz#4292448d9b0a48244a60307b74d2fea7e83dfe70" + integrity sha512-+zpddcnZ4G2VZ0xIEnvIHFsLqeopNOnWuE2ZVbRuetLLpj/biLPNN719B/iofdd1/iHRclKfv0XaAmX6PBhYKA== dependencies: "@graphql-typed-document-node/core" "^3.1.1" "@wry/caches" "^1.0.0" @@ -47,7 +47,7 @@ hoist-non-react-statics "^3.3.2" optimism "^0.18.0" prop-types "^15.7.2" - rehackt "0.0.3" + rehackt "0.0.6" response-iterator "^0.2.6" symbol-observable "^4.0.0" ts-invariant "^0.10.3" @@ -67,7 +67,7 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.23.5.tgz#ffb878728bb6bdcb6f4510aa51b1be9afb8cfd98" integrity sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw== -"@babel/core@^7.1.0", "@babel/core@^7.11.1", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.23.7", "@babel/core@^7.7.2", "@babel/core@^7.8.0": +"@babel/core@^7.1.0", "@babel/core@^7.11.1", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.7.2", "@babel/core@^7.8.0": version "7.23.9" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.23.9.tgz#b028820718000f267870822fec434820e9b1e4d1" integrity sha512-5q0175NOjddqpvvzU+kDiSOAk4PfdO6FvwCWoQ6RO7rTzEe8vlo+4HVfcnAREhD4npMs0e9uZypjTwzZPCf/cw== @@ -88,6 +88,27 @@ json5 "^2.2.3" semver "^6.3.1" +"@babel/core@^7.24.0": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.24.0.tgz#56cbda6b185ae9d9bed369816a8f4423c5f2ff1b" + integrity sha512-fQfkg0Gjkza3nf0c7/w6Xf34BW4YvzNfACRLmmb7XRLa6XHdR+K9AlJlxneFfWYf6uhOzuzZVTjF/8KfndZANw== + dependencies: + "@ampproject/remapping" "^2.2.0" + "@babel/code-frame" "^7.23.5" + "@babel/generator" "^7.23.6" + "@babel/helper-compilation-targets" "^7.23.6" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helpers" "^7.24.0" + "@babel/parser" "^7.24.0" + "@babel/template" "^7.24.0" + "@babel/traverse" "^7.24.0" + "@babel/types" "^7.24.0" + convert-source-map "^2.0.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.3" + semver "^6.3.1" + "@babel/eslint-parser@^7.16.3": version "7.23.10" resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.23.10.tgz#2d4164842d6db798873b40e0c4238827084667a2" @@ -296,6 +317,15 @@ "@babel/traverse" "^7.23.9" "@babel/types" "^7.23.9" +"@babel/helpers@^7.24.0": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.24.0.tgz#a3dd462b41769c95db8091e49cfe019389a9409b" + integrity sha512-ulDZdc0Aj5uLc5nETsa7EPx2L7rM0YJM8r7ck7U73AXi7qOV44IHHRAYZHY6iU1rr3C5N4NtTmMRUJP6kwCWeA== + dependencies: + "@babel/template" "^7.24.0" + "@babel/traverse" "^7.24.0" + "@babel/types" "^7.24.0" + "@babel/highlight@^7.23.4": version "7.23.4" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" @@ -310,6 +340,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.9.tgz#7b903b6149b0f8fa7ad564af646c4c38a77fc44b" integrity sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA== +"@babel/parser@^7.24.0": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.0.tgz#26a3d1ff49031c53a97d03b604375f028746a9ac" + integrity sha512-QuP/FxEAzMSjXygs8v4N9dvdXzEHN4W1oF3PxuWAtPo08UdM17u89RDMgjLn/mlc56iM0HlLmVkO/wgR+rDgHg== + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.23.3": version "7.23.3" resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.23.3.tgz#5cd1c87ba9380d0afb78469292c954fee5d2411a" @@ -1148,6 +1183,15 @@ "@babel/parser" "^7.23.9" "@babel/types" "^7.23.9" +"@babel/template@^7.24.0": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.24.0.tgz#c6a524aa93a4a05d66aaf31654258fae69d87d50" + integrity sha512-Bkf2q8lMB0AFpX0NFEqSbx1OkTHf0f+0j82mkw+ZpzBnkk7e9Ql0891vlfgi+kHwOk8tQjiQHpqh4LaSa0fKEA== + dependencies: + "@babel/code-frame" "^7.23.5" + "@babel/parser" "^7.24.0" + "@babel/types" "^7.24.0" + "@babel/traverse@^7.23.9", "@babel/traverse@^7.7.2": version "7.23.9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.23.9.tgz#2f9d6aead6b564669394c5ce0f9302bb65b9d950" @@ -1164,6 +1208,22 @@ debug "^4.3.1" globals "^11.1.0" +"@babel/traverse@^7.24.0": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.24.0.tgz#4a408fbf364ff73135c714a2ab46a5eab2831b1e" + integrity sha512-HfuJlI8qq3dEDmNU5ChzzpZRWq+oxCZQyMzIMEqLho+AQnhMnKQUzH6ydo3RBl/YjPCuk68Y6s0Gx0AeyULiWw== + dependencies: + "@babel/code-frame" "^7.23.5" + "@babel/generator" "^7.23.6" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-hoist-variables" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/parser" "^7.24.0" + "@babel/types" "^7.24.0" + debug "^4.3.1" + globals "^11.1.0" + "@babel/types@^7.0.0", "@babel/types@^7.12.6", "@babel/types@^7.20.7", "@babel/types@^7.22.15", "@babel/types@^7.22.19", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.4", "@babel/types@^7.23.6", "@babel/types@^7.23.9", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.23.9" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.9.tgz#1dd7b59a9a2b5c87f8b41e52770b5ecbf492e002" @@ -1173,6 +1233,15 @@ "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" +"@babel/types@^7.24.0": + version "7.24.0" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.24.0.tgz#3b951f435a92e7333eba05b7566fd297960ea1bf" + integrity sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w== + dependencies: + "@babel/helper-string-parser" "^7.23.4" + "@babel/helper-validator-identifier" "^7.22.20" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -1412,12 +1481,12 @@ "@firebase/util" "1.9.4" tslib "^2.1.0" -"@firebase/app-compat@0.2.27": - version "0.2.27" - resolved "https://registry.yarnpkg.com/@firebase/app-compat/-/app-compat-0.2.27.tgz#3dcf08e7c6258ef3b56929060db9d6b1a3c35eb7" - integrity sha512-SYlqocfUDKPHR6MSFC8hree0BTiWFu5o8wbf6zFlYXyG41w7TcHp4wJi4H/EL5V6cM4kxwruXTJtqXX/fRAZtw== +"@firebase/app-compat@0.2.28": + version "0.2.28" + resolved "https://registry.yarnpkg.com/@firebase/app-compat/-/app-compat-0.2.28.tgz#7a284d749d5d1ff8d941d346f02e1f02205f6370" + integrity sha512-Mr2NbeM1Oaayuw5unUAMzt+7/MN+e2uklT1l87D+ZLJl2UvhZAZmMt74GjEI9N3sDYKMeszSbszBqtJ1fGVafQ== dependencies: - "@firebase/app" "0.9.27" + "@firebase/app" "0.9.28" "@firebase/component" "0.6.5" "@firebase/logger" "0.4.0" "@firebase/util" "1.9.4" @@ -1428,10 +1497,10 @@ resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.9.0.tgz#35b5c568341e9e263b29b3d2ba0e9cfc9ec7f01e" integrity sha512-AeweANOIo0Mb8GiYm3xhTEBVCmPwTYAu9Hcd2qSkLuga/6+j9b1Jskl5bpiSQWy9eJ/j5pavxj6eYogmnuzm+Q== -"@firebase/app@0.9.27": - version "0.9.27" - resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.9.27.tgz#d50d1f99b88fb6c1358bed9703d204dc81185eb9" - integrity sha512-p2Dvl1ge4kRsyK5+wWcmdAIE9MSwZ0pDKAYB51LZgZuz6wciUZk4E1yAEdkfQlRxuHehn+Ol9WP5Qk2XQZiHGg== +"@firebase/app@0.9.28": + version "0.9.28" + resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.9.28.tgz#16a0d8ec91de429379bedeca42717cee3a2374d2" + integrity sha512-MS0+EtNixrwJbVDs5Bt/lhUhzeWGUtUoP6X+zYZck5GAZwI5g4F91noVA9oIXlFlpn6Q1xIbiaHA2GwGk7/7Ag== dependencies: "@firebase/component" "0.6.5" "@firebase/logger" "0.4.0" @@ -1439,17 +1508,17 @@ idb "7.1.1" tslib "^2.1.0" -"@firebase/auth-compat@0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@firebase/auth-compat/-/auth-compat-0.5.2.tgz#c78249fdfa8ef5d7e9c3d8bc3eb8e99d59f0b5dd" - integrity sha512-pRgje5BPCNR1vXyvGOVXwOHtv88A2WooXfklI8sV7/jWi03ExFqNfpJT26GUo/oD39NoKJ3Kt6rD5gVvdV7lMw== +"@firebase/auth-compat@0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@firebase/auth-compat/-/auth-compat-0.5.3.tgz#fde1b969c57a7216d5bdd36d0c4f4cdbfead231c" + integrity sha512-2pVtVEvu8P7SF6jSPfLPKWUClQFj+StqAZ0fD/uQ6mv8DyWn7AuuANFEu7Pv96JPcaL6Gy9jC5dFqjpptjqSRA== dependencies: - "@firebase/auth" "1.6.0" + "@firebase/auth" "1.6.1" "@firebase/auth-types" "0.12.0" "@firebase/component" "0.6.5" "@firebase/util" "1.9.4" tslib "^2.1.0" - undici "5.26.5" + undici "5.28.3" "@firebase/auth-interop-types@0.2.1": version "0.2.1" @@ -1461,16 +1530,16 @@ resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.12.0.tgz#f28e1b68ac3b208ad02a15854c585be6da3e8e79" integrity sha512-pPwaZt+SPOshK8xNoiQlK5XIrS97kFYc3Rc7xmy373QsOJ9MmqXxLaYssP5Kcds4wd2qK//amx/c+A8O2fVeZA== -"@firebase/auth@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-1.6.0.tgz#4999c5749922593f2a886d07ec69b453447b0d40" - integrity sha512-Qhl35eJTV6BwvuueTPCY6x8kUlYyzALtjp/Ws0X3fw3AnjVVfuVb7oQ3Xh5VPVfMFhaIuUAd1KXwcAuIklkSDw== +"@firebase/auth@1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-1.6.1.tgz#2185f58a52467c0cd8a6ed718758645226caa1b7" + integrity sha512-oOuQVOxtxKr+kTTqEkkI2qXIeGbkNLpA8FzO030LF4KXmMcETqsPaIqw7Aw1Y4Zl82l1qpZtpc4vN4Da2qZdfQ== dependencies: "@firebase/component" "0.6.5" "@firebase/logger" "0.4.0" "@firebase/util" "1.9.4" tslib "^2.1.0" - undici "5.26.5" + undici "5.28.3" "@firebase/component@0.6.5": version "0.6.5" @@ -1513,13 +1582,13 @@ faye-websocket "0.11.4" tslib "^2.1.0" -"@firebase/firestore-compat@0.3.25": - version "0.3.25" - resolved "https://registry.yarnpkg.com/@firebase/firestore-compat/-/firestore-compat-0.3.25.tgz#6f83871314ea7474a084e1840d6b0d4891a1523f" - integrity sha512-+xI7WmsgZCBhMn/+uhDKcg+lsOUJ9FJyt5PGTzkFPbCsozWfeQZ7eVnfPh0rMkUOf0yIQ924RIe04gwvEIbcoQ== +"@firebase/firestore-compat@0.3.26": + version "0.3.26" + resolved "https://registry.yarnpkg.com/@firebase/firestore-compat/-/firestore-compat-0.3.26.tgz#ea6fb3fc46f3457b93759efbc9da3e1bef3f6c38" + integrity sha512-dNrKiH5Cn6ItANV9nJI2Y0msKBj/skO7skDlRo/BUSQE1DKbNzumxpJEz+PK/PV1nTegnRgVvs47gpQeVWXtYQ== dependencies: "@firebase/component" "0.6.5" - "@firebase/firestore" "4.4.2" + "@firebase/firestore" "4.4.3" "@firebase/firestore-types" "3.0.0" "@firebase/util" "1.9.4" tslib "^2.1.0" @@ -1529,10 +1598,10 @@ resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-3.0.0.tgz#f3440d5a1cc2a722d361b24cefb62ca8b3577af3" integrity sha512-Meg4cIezHo9zLamw0ymFYBD4SMjLb+ZXIbuN7T7ddXN6MGoICmOTq3/ltdCGoDCS2u+H1XJs2u/cYp75jsX9Qw== -"@firebase/firestore@4.4.2": - version "4.4.2" - resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-4.4.2.tgz#21c73bf43d008647f16f8247894b3cacc2afaeb1" - integrity sha512-YaX6ypa/RzU6OkxzUQlpSxwhOIWdTraCNz7sMsbaSEjjl/pj/QvX6TqjkdWGzuBYh2S6rz7ErhDO0g39oZZw/g== +"@firebase/firestore@4.4.3": + version "4.4.3" + resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-4.4.3.tgz#1adbb9bcf1248050b558c0ebacb97bb4476397b2" + integrity sha512-Ix61zbeuTsHf0WFbk6+67n89Vzd9M8MMTdnz7c7z+BRE3BS5Vuc3gX5ZcHFjqPkQJ7rpLB1egHsYe4Przp5C2g== dependencies: "@firebase/component" "0.6.5" "@firebase/logger" "0.4.0" @@ -1541,15 +1610,15 @@ "@grpc/grpc-js" "~1.9.0" "@grpc/proto-loader" "^0.7.8" tslib "^2.1.0" - undici "5.26.5" + undici "5.28.3" -"@firebase/functions-compat@0.3.7": - version "0.3.7" - resolved "https://registry.yarnpkg.com/@firebase/functions-compat/-/functions-compat-0.3.7.tgz#a3500b58abe2afcb7a88ca4c07a3a519c9ed5e5f" - integrity sha512-uXe6Kmku5lNogp3OpPBcOJbSvnaCOn+YxS3zlXKNU6Q/NLwcvO3RY1zwYyctCos2RemEw3KEQ7YdzcECXjHWLw== +"@firebase/functions-compat@0.3.8": + version "0.3.8" + resolved "https://registry.yarnpkg.com/@firebase/functions-compat/-/functions-compat-0.3.8.tgz#a83a7ad2788db48483ccc86a80a12f0d824133da" + integrity sha512-VDHSw6UOu8RxfgAY/q8e+Jn+9Fh60Fc28yck0yfMsi2e0BiWgonIMWkFspFGGLgOJebTHl+hc+9v91rhzU6xlg== dependencies: "@firebase/component" "0.6.5" - "@firebase/functions" "0.11.1" + "@firebase/functions" "0.11.2" "@firebase/functions-types" "0.6.0" "@firebase/util" "1.9.4" tslib "^2.1.0" @@ -1559,10 +1628,10 @@ resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.6.0.tgz#ccd7000dc6fc668f5acb4e6a6a042a877a555ef2" integrity sha512-hfEw5VJtgWXIRf92ImLkgENqpL6IWpYaXVYiRkFY1jJ9+6tIhWM7IzzwbevwIIud/jaxKVdRzD7QBWfPmkwCYw== -"@firebase/functions@0.11.1": - version "0.11.1" - resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.11.1.tgz#fdb129b84a1a44bc705d78220adda2e765b295ee" - integrity sha512-3uUa1hB79Gmy6E1gHTfzoHeZolBeHc/I/n3+lOCDe6BOos9AHmzRjKygcFE/7VA2FJjitCE0K+OHI6+OuoY8fQ== +"@firebase/functions@0.11.2": + version "0.11.2" + resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.11.2.tgz#bcd10d7e7fa3cd185a6c3efe1776731b0222c14d" + integrity sha512-2NULTYOZbu0rXczwfYdqQH0w1FmmYrKjTy1YPQSHLCAkMBdfewoKmVm4Lyo2vRn0H9ZndciLY7NszKDFt9MKCQ== dependencies: "@firebase/app-check-interop-types" "0.3.0" "@firebase/auth-interop-types" "0.2.1" @@ -1570,7 +1639,7 @@ "@firebase/messaging-interop-types" "0.2.0" "@firebase/util" "1.9.4" tslib "^2.1.0" - undici "5.26.5" + undici "5.28.3" "@firebase/installations-compat@0.2.5": version "0.2.5" @@ -1688,13 +1757,13 @@ "@firebase/util" "1.9.4" tslib "^2.1.0" -"@firebase/storage-compat@0.3.4": - version "0.3.4" - resolved "https://registry.yarnpkg.com/@firebase/storage-compat/-/storage-compat-0.3.4.tgz#de261a0554747f558584c1465e17e6741da00ec8" - integrity sha512-Y0m5e2gS/wB9Ioth2X/Sgz76vcxvqgQrCmfa9qwhss/N31kxY2Gks6Frv0nrE18AjVfcSmcfDitqUwxcMOTRSg== +"@firebase/storage-compat@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@firebase/storage-compat/-/storage-compat-0.3.5.tgz#4c55531dc5aa7d8b5f6c1ed4b5eeee09190072f1" + integrity sha512-5dJXfY5NxCF5NAk4dLvJqC+m6cgcf0Fr29nrMHwhwI34pBheQq2PdRZqALsqZCES9dnHTuFNlqGQDpLr+Ph4rw== dependencies: "@firebase/component" "0.6.5" - "@firebase/storage" "0.12.1" + "@firebase/storage" "0.12.2" "@firebase/storage-types" "0.8.0" "@firebase/util" "1.9.4" tslib "^2.1.0" @@ -1704,15 +1773,15 @@ resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.8.0.tgz#f1e40a5361d59240b6e84fac7fbbbb622bfaf707" integrity sha512-isRHcGrTs9kITJC0AVehHfpraWFui39MPaU7Eo8QfWlqW7YPymBmRgjDrlOgFdURh6Cdeg07zmkLP5tzTKRSpg== -"@firebase/storage@0.12.1": - version "0.12.1" - resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.12.1.tgz#df0b914ba388d20ef9967682c9c67d79fed01777" - integrity sha512-KJ5NV7FUh54TeTlEjdkTTX60ciCKOp9EqlbLnpdcXUYRJg0Z4810TXbilPc1z7fTIG4iPjtdi95bGE9n4dBX8A== +"@firebase/storage@0.12.2": + version "0.12.2" + resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.12.2.tgz#73b1679fca74ec21a0f183beaa1b0b1a50f7e68b" + integrity sha512-MzanOBcxDx9oOwDaDPMuiYxd6CxcN1xZm+os5uNE3C1itbRKLhM9rzpODDKWzcbnHHFtXk3Q3lsK/d3Xa1WYYw== dependencies: "@firebase/component" "0.6.5" "@firebase/util" "1.9.4" tslib "^2.1.0" - undici "5.26.5" + undici "5.28.3" "@firebase/util@1.9.4": version "1.9.4" @@ -2376,7 +2445,7 @@ lz-string "^1.5.0" pretty-format "^27.0.2" -"@testing-library/jest-dom@^6.2.0": +"@testing-library/jest-dom@^6.4.2": version "6.4.2" resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-6.4.2.tgz#38949f6b63722900e2d75ba3c6d9bf8cffb3300e" integrity sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw== @@ -2390,7 +2459,7 @@ lodash "^4.17.15" redent "^3.0.0" -"@testing-library/react@^14.1.2": +"@testing-library/react@^14.2.1": version "14.2.1" resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-14.2.1.tgz#bf69aa3f71c36133349976a4a2da3687561d8310" integrity sha512-sGdjws32ai5TLerhvzThYFbpnF9XtL65Cjf+gB0Dhr29BGqK+mAeN7SURSdu+eqgET4ANcWoC7FQpkaiGvBr+A== @@ -2571,7 +2640,7 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@^29.5.11": +"@types/jest@^29.5.12": version "29.5.12" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.12.tgz#7f7dc6eb4cf246d2474ed78744b05d06ce025544" integrity sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw== @@ -2606,13 +2675,20 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^20.11.16": +"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0": version "20.11.16" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.16.tgz#4411f79411514eb8e2926f036c86c9f0e4ec6708" integrity sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ== dependencies: undici-types "~5.26.4" +"@types/node@^20.11.17": + version "20.11.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.25.tgz#0f50d62f274e54dd7a49f7704cc16bfbcccaf49f" + integrity sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw== + dependencies: + undici-types "~5.26.4" + "@types/parse-json@^4.0.0": version "4.0.2" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239" @@ -2643,14 +2719,21 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== -"@types/react-dom@^18.0.0", "@types/react-dom@^18.2.18": +"@types/react-dom@^18.0.0": version "18.2.18" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.18.tgz#16946e6cd43971256d874bc3d0a72074bb8571dd" integrity sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw== dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^18.2.55": +"@types/react-dom@^18.2.19": + version "18.2.21" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.21.tgz#b8c81715cebdebb2994378616a8d54ace54f043a" + integrity sha512-gnvBA/21SA4xxqNXEwNiVcP0xSGHh/gi1VhWv9Bl46a0ItbTT5nFY+G9VSQpaG/8N/qdJpJ+vftQ4zflTtnjLw== + dependencies: + "@types/react" "*" + +"@types/react@*": version "18.2.55" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.55.tgz#38141821b7084404b5013742bc4ae08e44da7a67" integrity sha512-Y2Tz5P4yz23brwm2d7jNon39qoAtMMmalOQv6+fEFt1mT+FcM3D841wDpoUvFXhaYenuROCy3FZYqdTjM7qVyA== @@ -2659,6 +2742,15 @@ "@types/scheduler" "*" csstype "^3.0.2" +"@types/react@^18.2.56": + version "18.2.64" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.64.tgz#3700fbb6b2fa60a6868ec1323ae4cbd446a2197d" + integrity sha512-MlmPvHgjj2p3vZaxbQgFUQFvD8QiZwACfGqEdDSWou5yISWxDQ4/74nCAwsUiX7UFLKZz3BbVSPj+YxeoGGCfg== + dependencies: + "@types/prop-types" "*" + "@types/scheduler" "*" + csstype "^3.0.2" + "@types/resolve@1.17.1": version "1.17.1" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" @@ -5300,26 +5392,26 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" -firebase@^10.7.1: - version "10.8.0" - resolved "https://registry.yarnpkg.com/firebase/-/firebase-10.8.0.tgz#764fa98b5699ca40dfb604df21747b836a101fa3" - integrity sha512-UJpC24vw8JFuHEOQyArBGKTUd7+kohLISCzHyn0M/prP0KOTx2io1eyLliEid330QqnWI7FOlPxoU97qecCSfQ== +firebase@^10.8.1: + version "10.8.1" + resolved "https://registry.yarnpkg.com/firebase/-/firebase-10.8.1.tgz#d7eee67129a35fcfabda0c125e6b94abb9c420fb" + integrity sha512-4B2jzhU/aumfKL446MG41/T5+t+9d9urf5XGrjC0HRQUm4Ya/amV48HBchnje69ExaJP5f2WxO9OX3wh9ee4wA== dependencies: "@firebase/analytics" "0.10.1" "@firebase/analytics-compat" "0.2.7" - "@firebase/app" "0.9.27" + "@firebase/app" "0.9.28" "@firebase/app-check" "0.8.2" "@firebase/app-check-compat" "0.3.9" - "@firebase/app-compat" "0.2.27" + "@firebase/app-compat" "0.2.28" "@firebase/app-types" "0.9.0" - "@firebase/auth" "1.6.0" - "@firebase/auth-compat" "0.5.2" + "@firebase/auth" "1.6.1" + "@firebase/auth-compat" "0.5.3" "@firebase/database" "1.0.3" "@firebase/database-compat" "1.0.3" - "@firebase/firestore" "4.4.2" - "@firebase/firestore-compat" "0.3.25" - "@firebase/functions" "0.11.1" - "@firebase/functions-compat" "0.3.7" + "@firebase/firestore" "4.4.3" + "@firebase/firestore-compat" "0.3.26" + "@firebase/functions" "0.11.2" + "@firebase/functions-compat" "0.3.8" "@firebase/installations" "0.6.5" "@firebase/installations-compat" "0.2.5" "@firebase/messaging" "0.12.6" @@ -5328,8 +5420,8 @@ firebase@^10.7.1: "@firebase/performance-compat" "0.2.5" "@firebase/remote-config" "0.4.5" "@firebase/remote-config-compat" "0.2.5" - "@firebase/storage" "0.12.1" - "@firebase/storage-compat" "0.3.4" + "@firebase/storage" "0.12.2" + "@firebase/storage-compat" "0.3.5" "@firebase/util" "1.9.4" flat-cache@^3.0.4: @@ -8824,10 +8916,10 @@ regjsparser@^0.9.1: dependencies: jsesc "~0.5.0" -rehackt@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/rehackt/-/rehackt-0.0.3.tgz#1ea454620d4641db8342e2db44595cf0e7ac6aa0" - integrity sha512-aBRHudKhOWwsTvCbSoinzq+Lej/7R8e8UoPvLZo5HirZIIBLGAgdG7SL9QpdcBoQ7+3QYPi3lRLknAzXBlhZ7g== +rehackt@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/rehackt/-/rehackt-0.0.6.tgz#7a0a2247f2295e7548915417e44fbbf03bf004f4" + integrity sha512-l3WEzkt4ntlEc/IB3/mF6SRgNHA6zfQR7BlGOgBTOmx7IJJXojDASav+NsgXHFjHn+6RmwqsGPFgZpabWpeOdw== relateurl@^0.2.7: version "0.2.7" @@ -9911,10 +10003,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^5.3.3: - version "5.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" - integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== +typescript@^5.4.2: + version "5.4.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.2.tgz#0ae9cebcfae970718474fe0da2c090cad6577372" + integrity sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ== unbox-primitive@^1.0.2: version "1.0.2" @@ -9936,10 +10028,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici@5.26.5: - version "5.26.5" - resolved "https://registry.yarnpkg.com/undici/-/undici-5.26.5.tgz#f6dc8c565e3cad8c4475b187f51a13e505092838" - integrity sha512-cSb4bPFd5qgR7qr2jYAi0hlX9n5YKK2ONKkLFkxl+v/9BvC0sOpZjBHDBSXc5lWAf5ty9oZdRXytBIHzgUcerw== +undici@5.28.3: + version "5.28.3" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.3.tgz#a731e0eff2c3fcfd41c1169a869062be222d1e5b" + integrity sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA== dependencies: "@fastify/busboy" "^2.0.0" @@ -10101,7 +10193,7 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" -web-vitals@^3.5.1: +web-vitals@^3.5.2: version "3.5.2" resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-3.5.2.tgz#5bb58461bbc173c3f00c2ddff8bfe6e680999ca9" integrity sha512-c0rhqNcHXRkY/ogGDJQxZ9Im9D19hDihbzSQJrsioex+KnFgmMzBiy57Z1EjkhX/+OjyBpclDCzz2ITtjokFmg== diff --git a/source/examples/generated/code/start/Sync.snippet.open-realm-partition-based-sync.swift b/source/examples/generated/code/start/Sync.snippet.open-realm-partition-based-sync.swift new file mode 100644 index 0000000000..13658eabef --- /dev/null +++ b/source/examples/generated/code/start/Sync.snippet.open-realm-partition-based-sync.swift @@ -0,0 +1,12 @@ +let app = App(id: YOUR_APP_SERVICES_APP_ID) + +// Store a configuration that consists of the current user, +// authenticated to this instance of your app. If there is no +// user, your code should log one in. +let user = app.currentUser +let partitionValue = "some partition value" +var configuration = user!.configuration(partitionValue: partitionValue) + +// Open the database with the user's configuration. +let syncedRealm = try! Realm(configuration: configuration) +print("Successfully opened the synced realm: \(syncedRealm)") diff --git a/source/examples/generated/cpp/crud.snippet.open-db-at-path.cpp b/source/examples/generated/cpp/crud.snippet.open-db-at-path.cpp index ed2fafb1d4..f22ce4909d 100644 --- a/source/examples/generated/cpp/crud.snippet.open-db-at-path.cpp +++ b/source/examples/generated/cpp/crud.snippet.open-db-at-path.cpp @@ -1,5 +1,5 @@ auto relative_realm_path_directory = "custom_path_directory/"; -std::filesystem::create_directories( +std::filesystem::create_directories(relative_realm_path_directory); // Construct a path std::filesystem::path path = std::filesystem::current_path().append(relative_realm_path_directory); diff --git a/source/examples/generated/dotnet/RqlSchemaExamples.snippet.rql-schema-examples.cs b/source/examples/generated/dotnet/RqlSchemaExamples.snippet.rql-schema-examples.cs index 06cbfa9ba2..5557672270 100644 --- a/source/examples/generated/dotnet/RqlSchemaExamples.snippet.rql-schema-examples.cs +++ b/source/examples/generated/dotnet/RqlSchemaExamples.snippet.rql-schema-examples.cs @@ -5,6 +5,7 @@ public class Item : RealmObject public ObjectId Id { get; set; } = ObjectId.GenerateNewId(); [MapTo("name")] + [Indexed(IndexType.FullText)] public string Name { get; set; } [MapTo("isComplete")] diff --git a/source/examples/generated/flutter/app_services_test.snippet.access-app-by-id.dart b/source/examples/generated/flutter/app_services_test.snippet.access-app-by-id.dart index 81f1b76281..b9862c6d36 100644 --- a/source/examples/generated/flutter/app_services_test.snippet.access-app-by-id.dart +++ b/source/examples/generated/flutter/app_services_test.snippet.access-app-by-id.dart @@ -13,7 +13,7 @@ await Isolate.spawn((List args) async { try { final backgroundApp = App.getById(appId); - // ... Access App users + // ... Access App users final user = backgroundApp?.currentUser!; // Use the App and user as needed. diff --git a/source/examples/generated/flutter/car.snippet.define-model-dart.dart b/source/examples/generated/flutter/car.snippet.define-model-dart.dart index 6415dbd32d..a3a44eb57d 100644 --- a/source/examples/generated/flutter/car.snippet.define-model-dart.dart +++ b/source/examples/generated/flutter/car.snippet.define-model-dart.dart @@ -1,6 +1,6 @@ import 'package:realm_dart/realm.dart'; -part 'car.g.dart'; +part 'car.realm.dart'; @RealmModel() class _Car { diff --git a/source/examples/generated/flutter/car.snippet.define-model-flutter.dart b/source/examples/generated/flutter/car.snippet.define-model-flutter.dart index 3d38765c74..b092c03d74 100644 --- a/source/examples/generated/flutter/car.snippet.define-model-flutter.dart +++ b/source/examples/generated/flutter/car.snippet.define-model-flutter.dart @@ -1,12 +1,13 @@ import 'package:realm/realm.dart'; -part 'car.g.dart'; +part 'car.realm.dart'; @RealmModel() class _Car { @PrimaryKey() - late final String make; + late ObjectId id; + late String make; late String? model; late int? miles; } diff --git a/source/examples/generated/flutter/data_types_test.snippet.binary-model.dart b/source/examples/generated/flutter/data_types_test.snippet.binary-model.dart index 761dd57ec5..686bb766fe 100644 --- a/source/examples/generated/flutter/data_types_test.snippet.binary-model.dart +++ b/source/examples/generated/flutter/data_types_test.snippet.binary-model.dart @@ -2,6 +2,5 @@ class _BinaryExample { late String name; late Uint8List requiredBinaryProperty; - var defaultValueBinaryProperty = Uint8List(8); late Uint8List? nullableBinaryProperty; } diff --git a/source/examples/generated/flutter/data_types_test.snippet.data-types-example-model.dart b/source/examples/generated/flutter/data_types_test.snippet.data-types-example-model.dart index 0e05555c25..826fa16b1c 100644 --- a/source/examples/generated/flutter/data_types_test.snippet.data-types-example-model.dart +++ b/source/examples/generated/flutter/data_types_test.snippet.data-types-example-model.dart @@ -1,17 +1,5 @@ -part 'car.g.dart'; - -@RealmModel() -class _Car { - @PrimaryKey() - late ObjectId id; - - String? licensePlate; - bool isElectric = false; - double milesDriven = 0; - late List attributes; - late _Person? owner; -} +part 'car.realm.dart'; @RealmModel() class _Car { @@ -45,3 +33,14 @@ class _Person { late _Address? address; // Must be nullable } +@RealmModel() +class _Car { + @PrimaryKey() + late ObjectId id; + + String? licensePlate; + bool isElectric = false; + double milesDriven = 0; + late List attributes; + late _Person? owner; +} diff --git a/source/examples/generated/flutter/schemas.snippet.part-directive.dart b/source/examples/generated/flutter/schemas.snippet.part-directive.dart index 1786bc37bb..730fd18b33 100644 --- a/source/examples/generated/flutter/schemas.snippet.part-directive.dart +++ b/source/examples/generated/flutter/schemas.snippet.part-directive.dart @@ -1 +1 @@ -part 'schemas.g.dart'; +part 'schemas.realm.dart'; diff --git a/source/examples/generated/flutter/task_project_models_test.snippet.task-project-models.dart b/source/examples/generated/flutter/task_project_models_test.snippet.task-project-models.dart index 84f3a0bfd1..3e11c3d794 100644 --- a/source/examples/generated/flutter/task_project_models_test.snippet.task-project-models.dart +++ b/source/examples/generated/flutter/task_project_models_test.snippet.task-project-models.dart @@ -1,12 +1,12 @@ -part 'models.g.dart'; +part 'models.realm.dart'; @RealmModel() class _Item { @MapTo("_id") @PrimaryKey() late ObjectId id; - + @Indexed(RealmIndexType.fullText) late String name; bool isComplete = false; String? assignee; diff --git a/source/examples/generated/kotlin/AppClientTest.snippet.enable-platform-networking.kt b/source/examples/generated/kotlin/AppClientTest.snippet.enable-platform-networking.kt new file mode 100644 index 0000000000..52d2b62c42 --- /dev/null +++ b/source/examples/generated/kotlin/AppClientTest.snippet.enable-platform-networking.kt @@ -0,0 +1,4 @@ +val config = + AppConfiguration.Builder(YOUR_APP_ID) + .usePlatformNetworking(true) + .build() diff --git a/source/examples/generated/kotlin/AppClientTest.snippet.encrypted-app-client.kt b/source/examples/generated/kotlin/AppClientTest.snippet.encrypted-app-client.kt index e40c172327..288c75ba46 100644 --- a/source/examples/generated/kotlin/AppClientTest.snippet.encrypted-app-client.kt +++ b/source/examples/generated/kotlin/AppClientTest.snippet.encrypted-app-client.kt @@ -1,4 +1,5 @@ -AppConfiguration.Builder(YOUR_APP_ID) - // Specify the encryption key - .encryptionKey(myEncryptionKey) - .build() +val config = + AppConfiguration.Builder(YOUR_APP_ID) + // Specify the encryption key + .encryptionKey(myEncryptionKey) + .build() diff --git a/source/examples/generated/kotlin/RQLTest.snippet.rql-schema-example.kt b/source/examples/generated/kotlin/RQLTest.snippet.rql-schema-example.kt index 0cc4f50cda..60f9d3db90 100644 --- a/source/examples/generated/kotlin/RQLTest.snippet.rql-schema-example.kt +++ b/source/examples/generated/kotlin/RQLTest.snippet.rql-schema-example.kt @@ -1,6 +1,7 @@ class Item(): RealmObject { @PrimaryKey var _id: ObjectId = ObjectId() + @FullText var name: String = "" var isComplete: Boolean = false var assignee: String? = null diff --git a/source/examples/generated/node/rql-data-models.snippet.rql-data-models.js b/source/examples/generated/node/rql-data-models.snippet.rql-data-models.js index d04685cfe4..704fa3cb01 100644 --- a/source/examples/generated/node/rql-data-models.snippet.rql-data-models.js +++ b/source/examples/generated/node/rql-data-models.snippet.rql-data-models.js @@ -2,7 +2,7 @@ const ItemModel = { name: "Item", properties: { id: "objectId", - name: "string", + name: {type: "string", indexed: "full-text"}, isComplete: { type: "bool", default: false }, assignee: "string?", priority: { diff --git a/source/examples/generated/realm-query-language/realm-query-language.test.snippet.rql-fts.js b/source/examples/generated/realm-query-language/realm-query-language.test.snippet.rql-fts.js new file mode 100644 index 0000000000..1906dc7acf --- /dev/null +++ b/source/examples/generated/realm-query-language/realm-query-language.test.snippet.rql-fts.js @@ -0,0 +1,8 @@ + // Filter for items with 'write' in the name + "name TEXT $0", "write" + + // Find items with 'write' but not 'tests' using '-' + "name TEXT $0", "write -tests" + + // Find items starting with 'wri-' using '*' + "name TEXT $0", "wri*" diff --git a/source/includes/user-access-token.rst b/source/includes/user-access-token.rst index f76cc73e57..cdab82591b 100644 --- a/source/includes/user-access-token.rst +++ b/source/includes/user-access-token.rst @@ -4,9 +4,8 @@ tokens, refreshes them when they expire, and includes a valid access token for the current user with each request. Realm *does not* automatically refresh the refresh token. When the refresh token expires, the user must log in again. -If you send requests outside of the SDK (for -example, through the GraphQL API) then you need to include the user's access -token with each request, and manually refresh the token when it expires. +If you send requests outside of the SDK, you need to include the user's access +token with each request and manually refresh the token when it expires. You can access and refresh a logged in user's access token in the SDK from their ``Realm.User`` object, as in the following example: \ No newline at end of file diff --git a/source/index.txt b/source/index.txt index 0e95e0190c..7b36dab3ae 100644 --- a/source/index.txt +++ b/source/index.txt @@ -46,9 +46,9 @@ Welcome to the Atlas Device SDK Docs The SDKs provide tools to read and write Atlas data from devices. Your app can sync automatically with MongoDB Atlas and other devices using Device Sync. -You can access the MongoDB GraphQL API, or call Atlas Functions from a -device. The device persistence layer is Realm, an embedded, object-oriented -database that lets you build real-time, offline-first applications. +You can call Atlas Functions from a device. The device persistence layer is +Realm, an embedded, object-oriented database that lets you build real-time, +offline-first applications. We provide SDKs for most popular languages, frameworks, and platforms. Each SDK is language-idiomatic and includes: @@ -127,7 +127,7 @@ SDK is language-idiomatic and includes: :icon: /images/icons/web_sdk.svg :icon-alt: Web SDK icon - Build web applications in JavaScript or TypeScript. Access data with GraphQL and MongoDB queries. + Build web applications in JavaScript or TypeScript. Access data with MongoDB queries. .. card:: :headline: Flutter SDK diff --git a/source/introduction.txt b/source/introduction.txt index 2e8dc73936..a0e37470ed 100644 --- a/source/introduction.txt +++ b/source/introduction.txt @@ -22,7 +22,6 @@ on a broad range of devices: - An offline-first object database to persist data on device. - The ability to call Atlas Functions to do work in the cloud. - A client to query MongoDB data sources directly from your app. -- The ability to access the MongoDB GraphQL API from the client. You can use the SDK's object store, Realm, to read, write, and react to changes in your data on device. Add Device Sync, Atlas Functions, @@ -106,8 +105,6 @@ with data from your app: - :ref:`Atlas Triggers ` automatically execute an Atlas Function at a scheduled time or when an event occurs, such as a change to a MongoDB database in Atlas or a user logs in. -- The :ref:`Atlas GraphQL API ` accesses data stored - in a linked MongoDB cluster with a standard GraphQL client. - :ref:`App Services Rules ` control who accesses what data. - :ref:`App Services Values and Secrets ` define global variables and private credentials once and diff --git a/source/realm-query-language.txt b/source/realm-query-language.txt index c425804689..8e09f1eb3f 100644 --- a/source/realm-query-language.txt +++ b/source/realm-query-language.txt @@ -143,6 +143,7 @@ See the schema for these two classes, ``Project`` and ``Item``, below: open class Item(): RealmObject() { var id: ObjectId = new ObjectId() + @FullText lateinit var name: String var isComplete: Boolean = false var assignee: String? = null @@ -163,7 +164,7 @@ See the schema for these two classes, ``Project`` and ``Item``, below: .. literalinclude:: /examples/generated/dotnet/RqlSchemaExamples.snippet.rql-schema-examples.cs :language: csharp - .. tab:: Node.Js SDK + .. tab:: Node.js SDK :tabid: node .. literalinclude:: /examples/generated/node/rql-data-models.snippet.rql-data-models.js @@ -884,6 +885,47 @@ operators interact with lists and comparison operators: - true - 0 and 1 are both less than none of 1 and 2 +.. _rql-fts: + +Full Text Search +---------------- + +You can use RQL to query on properties that have a full-text search (FTS) +annotation. FTS supports boolean match word searches, rather than searches for relevance. +For information on enabling FTS on a property, see the FTS documentation for +your SDK: + +- :ref:`Flutter SDK ` +- :ref:`Kotlin SDK ` +- :ref:`.NET SDK ` +- :ref:`Node.js SDK ` +- :ref:`React Native SDK ` +- Swift SDK does not yet support Full-Text Search. + +To query these properties, use the ``TEXT`` predicate in your query. + +You can search for entire words or phrases, or limit your results with the following characters: + +- Exclude results for a word by placing the ``-`` character in front of the word. +- Specify prefixes by placing the ``*`` character at the end of a prefix. Suffix + searching is not currently supported. + +In the following example, we query the ``Item.name`` property: + +.. literalinclude:: /examples/generated/realm-query-language/realm-query-language.test.snippet.rql-fts.js + :language: js + +Full-Text Search Tokenizer Details +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Full-Text Search (FTS) indexes support: + +- Tokens are diacritics- and case-insensitive. +- Tokens can only consist of characters from ASCII and the Latin-1 supplement (western languages). + All other characters are considered whitespace. +- Words split by a hyphen (-) are split into two tokens. For example, ``full-text`` + splits into ``full`` and ``text``. + .. _rql-geospatial: Geospatial Queries @@ -905,7 +947,7 @@ To query geospatial data: 1. Create an object with a property containing the embedded geospatial data. 2. Define the geospatial shape to set the boundary for the query. -3. Query using the GEOWITHIN RQL operator. +3. Query using the ``geoWithin`` RQL operator. In the following query, we are checking that the coordinates of the embeddeded ``location`` property are contained within the ``GeoCircle`` shape, ``smallCircle``: @@ -919,8 +961,8 @@ see the geospatial documentation for your SDK: - :ref:`Flutter SDK ` - :ref:`Kotlin SDK ` - :ref:`.NET SDK ` -- :ref:`Node.js SDK ` -- :ref:`React Native SDK ` +- :ref:`Node.js SDK ` +- :ref:`React Native SDK ` - :ref:`Swift SDK ` .. _rql-backlinks: diff --git a/source/sdk.txt b/source/sdk.txt index dcef3ec441..0978d770b4 100644 --- a/source/sdk.txt +++ b/source/sdk.txt @@ -73,7 +73,7 @@ and platforms. Each SDK is language-idiomatic and includes: :icon: /images/icons/web_sdk.svg :icon-alt: Web SDK icon - Build web applications in JavaScript or TypeScript. Access data with GraphQL and MongoDB queries. + Build web applications in JavaScript or TypeScript. Access data with MongoDB queries. .. card:: :headline: Flutter SDK diff --git a/source/sdk/cpp/users/authenticate-users.txt b/source/sdk/cpp/users/authenticate-users.txt index 155ddae594..a3a0bb67eb 100644 --- a/source/sdk/cpp/users/authenticate-users.txt +++ b/source/sdk/cpp/users/authenticate-users.txt @@ -133,9 +133,8 @@ The Realm SDK automatically manages access tokens, refreshes them when they expire, and includes a valid access token for the current user with each request. -If you send requests outside of the SDK - for example, through the :ref:`GraphQL -API ` - then you must include the user's access token with -each request. In this scenario, you must manually refresh the token when +If you send requests outside of the SDK then you must include the user's access +token with each request. In this scenario, you must manually refresh the token when it expires. Access tokens expire after 30 minutes. You can call :cpp-sdk:`.refresh_custom_user_data() diff --git a/source/sdk/dotnet/crud/filter.txt b/source/sdk/dotnet/crud/filter.txt index e3054d8343..a0a244fdcc 100644 --- a/source/sdk/dotnet/crud/filter.txt +++ b/source/sdk/dotnet/crud/filter.txt @@ -232,7 +232,7 @@ table. Regex-like wildcards allow more flexibility in search. Full Text Search ~~~~~~~~~~~~~~~~ -You can use LINQ to query on properties that have :ref:`` (FTS) on +You can use LINQ to query on properties that have :ref:`` (FTS) on them. To query these properties, use :dotnet-sdk:`QueryMethods.FullTextSearch `. The following examples query the ``Person.Biography`` field: @@ -331,7 +331,7 @@ The following examples show different ways to aggregate data: Full Text Search ~~~~~~~~~~~~~~~~ -You can use RQL to query on properties that have :ref:`` (FTS) on +You can use RQL to query on properties that have :ref:`` (FTS) on them. To query these properties, use the ``TEXT`` operator. The following example queries the ``Person.Biography`` field: diff --git a/source/sdk/dotnet/model-data/define-object-model.txt b/source/sdk/dotnet/model-data/define-object-model.txt index 8d21557da7..85639f13bf 100644 --- a/source/sdk/dotnet/model-data/define-object-model.txt +++ b/source/sdk/dotnet/model-data/define-object-model.txt @@ -140,7 +140,7 @@ property: and want to improve performance, refer to `Create, View, Drop, and Hide Indexes `__. -.. _fts-indexes: +.. _dotnet-fts-indexes: Full-Text Search Indexes ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/source/sdk/flutter.txt b/source/sdk/flutter.txt index 66d3eb7bcb..78c60d4dce 100644 --- a/source/sdk/flutter.txt +++ b/source/sdk/flutter.txt @@ -175,12 +175,6 @@ other clients. You can :ref:`call serverless Atlas Functions ` that run in an App Services backend from your client application. - Query MongoDB Atlas with GraphQL - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - You can :ref:`query data stored in MongoDB with the Atlas GraphQL API ` - directly from your client application code. - Authenticate Users ~~~~~~~~~~~~~~~~~~ diff --git a/source/sdk/flutter/app-services.txt b/source/sdk/flutter/app-services.txt index fec2208b13..c2d56ee84f 100644 --- a/source/sdk/flutter/app-services.txt +++ b/source/sdk/flutter/app-services.txt @@ -18,6 +18,11 @@ Application Services Overview - Flutter SDK :depth: 2 :class: singlecol +.. banner:: + :variant: warning + + GraphQL is deprecated. :ref:`Learn More `. + Overview -------- diff --git a/source/sdk/flutter/app-services/graphql-api.txt b/source/sdk/flutter/app-services/graphql-api.txt index f24ba690f9..ed764247b2 100644 --- a/source/sdk/flutter/app-services/graphql-api.txt +++ b/source/sdk/flutter/app-services/graphql-api.txt @@ -10,6 +10,11 @@ Atlas GraphQL API :depth: 2 :class: singlecol +.. banner:: + :variant: warning + + GraphQL is deprecated. :ref:`Learn More `. + You can query your data in MongoDB Atlas from your client app using the Atlas GraphQL API and the Realm Flutter SDK. You can use any standard GraphQL client to query the Atlas GraphQL API. diff --git a/source/sdk/flutter/users/access-token.txt b/source/sdk/flutter/users/access-token.txt index bdc0eb897d..a872aee03f 100644 --- a/source/sdk/flutter/users/access-token.txt +++ b/source/sdk/flutter/users/access-token.txt @@ -18,6 +18,11 @@ Get the User Access Token - Flutter SDK :depth: 2 :class: singlecol +.. banner:: + :variant: warning + + GraphQL is deprecated. :ref:`Learn More `. + Every User object contains a JWT token that you can use to access Atlas App Services. You can use the access token to query the Atlas GraphQL API from your client application. diff --git a/source/sdk/kotlin/app-services/connect-to-app-services-backend.txt b/source/sdk/kotlin/app-services/connect-to-app-services-backend.txt index 1d1065be63..318b7a31c5 100644 --- a/source/sdk/kotlin/app-services/connect-to-app-services-backend.txt +++ b/source/sdk/kotlin/app-services/connect-to-app-services-backend.txt @@ -6,7 +6,7 @@ Connect to Atlas App Services - Kotlin SDK .. meta:: :keywords: code example - :description: Initialize your app client and connect to the Atlas App Services backend using the Kotlin SDK. + :description: Initialize your app client and connect to the Atlas App Services backend using the Kotlin SDK. .. facet:: :name: genre @@ -18,27 +18,27 @@ Connect to Atlas App Services - Kotlin SDK :depth: 2 :class: singlecol -This page describes how to initialize your App client and connect to the Atlas +This page describes how to initialize your App client and connect to the Atlas App Services backend using the Kotlin SDK. -The App client is the interface to the App Services backend. It provides +The App client is the interface to the App Services backend. It provides access to App Services functionality, including: - :ref:`Authenticating ` app users -- :ref:`Synchronizing data ` between the Atlas backend and the +- :ref:`Synchronizing data ` between the Atlas backend and the client app using Device Sync - :ref:`Calling Atlas functions ` -Each App client is associated with a single App ID. +Each App client is associated with a single App ID. Prerequisites ------------- -Before you can connect to Atlas App Services, you need an App Services App -with an App ID. To get started, refer to :ref:`Create an App ` +Before you can connect to Atlas App Services, you need an App Services App +with an App ID. To get started, refer to :ref:`Create an App ` in the App Services documentation. -To learn how to find your App ID in the App Services UI, refer to +To learn how to find your App ID in the App Services UI, refer to :ref:`Find Your App ID ` in the App Services documentation. .. _kotlin-access-the-app-client: @@ -46,14 +46,14 @@ To learn how to find your App ID in the App Services UI, refer to Access the App Client --------------------- -The Kotlin SDK uses the +The Kotlin SDK uses the `App <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app/index.html>`__ -interface to access an ``App`` client. +interface to access an ``App`` client. -You can initialize an App with default configuration values using -`App.create() -<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-companion/create.html>`__. -You only need to pass the App ID for your App. +You can initialize an App with default configuration values using +`App.create() +<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-companion/create.html>`__. +You only need to pass the App ID for your App. .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.initialize-app-client.kt :language: kotlin @@ -67,12 +67,12 @@ Configure the App Client ------------------------ You can add optional arguments to the ``AppConfiguration`` for more -granular control of your app connection details, such as custom -request headers and keys for local encryption. +granular control of your app connection details, such as custom +request headers and keys for local encryption. -To control the additional configuration options, use the +To control the additional configuration options, use the `AppConfiguration.Builder -<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/index.html>`__ +<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/index.html>`__ and call the ``.build()`` method to pass a configuration object: .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.configure-app-client.kt @@ -89,32 +89,32 @@ Share Sync Connections .. versionadded:: 1.13.0 -By default, the SDK opens a separate connection to the server for +By default, the SDK opens a separate connection to the server for each synced realm. In Kotlin v1.13.0 and later, you can enable -**session multiplexing**. When enabled, the SDK -shares a connection to the server for all synced realms opened with -a single App Services user. Sharing a connection across multiple -sessions reduces resources and can improve performance. +**session multiplexing**. When enabled, the SDK +shares a connection to the server for all synced realms opened with +a single App Services user. Sharing a connection across multiple +sessions reduces resources and can improve performance. -Multiplexing is disabled by default. You can enable it on the -``AppConfiguration`` using the `.enableSessionMultiplexing() -<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/index.html#-839865185%2FFunctions%2F380376748>`__ -method, which accepts a Boolean value. +Multiplexing is disabled by default. You can enable it on the +``AppConfiguration`` using the `.enableSessionMultiplexing() +<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/index.html#-839865185%2FFunctions%2F380376748>`__ +method, which accepts a Boolean value. .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.enable-multiplexing.kt :language: kotlin When enabled, the shared connection does not immediately close when all sessions are closed. -Instead, it remains open for the ``connectionLingerTime``, which defaults to -30 seconds. You can override this duration by passing a new value to -`SyncTimeoutOptions.connectionLingerTime() -<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-timeout-options/connection-linger-time.html>`__ -on the ``AppConfiguration``. +Instead, it remains open for the ``connectionLingerTime``, which defaults to +30 seconds. You can override this duration by passing a new value to +`SyncTimeoutOptions.connectionLingerTime() +<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-timeout-options/connection-linger-time.html>`__ +on the ``AppConfiguration``. .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.enable-multiplexing-with-timeout.kt :language: kotlin -For more information, refer to the +For more information, refer to the :ref:`kotlin-configure-sync-timeouts` section on this page. .. _kotlin-configure-sync-timeouts: @@ -126,39 +126,39 @@ Configure Sync Timeouts .. versionadded:: 1.13.0 -In Kotlin v1.13.0 and later, you can override the default -timeout settings used when syncing data between the Atlas backend +In Kotlin v1.13.0 and later, you can override the default +timeout settings used when syncing data between the Atlas backend and the client app. -You can set various sync timeout settings on the +You can set various sync timeout settings on the ``AppConfiguration`` using the `.syncTimeouts() -<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/index.html#90306255%2FFunctions%2F380376748>`__ -method. Pass specific timeout property values you want to override. The +<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/index.html#90306255%2FFunctions%2F380376748>`__ +method. Pass specific timeout property values you want to override. The configured timeouts apply to all sync sessions in the app. .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.sync-timeout-configuration.kt :language: kotlin -For a complete list of the available timeout properties and their +For a complete list of the available timeout properties and their definitions, refer to the -`SyncTimeoutOptionsBuilder <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-timeout-options-builder/index.html>`__ +`SyncTimeoutOptionsBuilder <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-timeout-options-builder/index.html>`__ API reference. .. _kotlin-encrypt-app-metadata: -Encrypt App Metadata +Encrypt App Metadata ~~~~~~~~~~~~~~~~~~~~ -When you connect to App Services, Realm creates additional metadata files on -a device. For more information about these metadata files, refer to +When you connect to App Services, Realm creates additional metadata files on +a device. For more information about these metadata files, refer to :ref:``. You can encrypt the metadata that App Services stores on client devices, -similar to how you :ref:``. +similar to how you :ref:``. -To encrypt App metadata, pass your encryption key to the +To encrypt App metadata, pass your encryption key to the `encryptionKey <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/encryption-key.html>`__ -property when you initialize the App: +property when you initialize the App: .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.encrypted-app-client.kt :language: kotlin @@ -168,29 +168,59 @@ Set Custom HTTP Headers .. versionadded:: 1.11.0 -If you use App Services or Device Sync with a proxy setup, you may need to set -custom HTTP headers. The Realm Kotlin SDK supports setting custom HTTP headers -on the App. These headers are appended to every request to the App Services +If you use App Services or Device Sync with a proxy setup, you may need to set +custom HTTP headers. The Kotlin SDK supports setting custom HTTP headers +on the App. These headers are appended to every request to the App Services App, including :ref:`function calls `. -When you initialize the App, you can pass: +When you initialize the App, you can pass: -- the custom `authorizationHeaderName +- the custom `authorizationHeaderName <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/authorization-header-name.html>`__ ``String`` value -- any `customRequestHeaders - <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/custom-request-headers.html>`__ - in a map of ``String`` header keys and values (SDK accepts empty values but +- any `customRequestHeaders + <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/custom-request-headers.html>`__ + in a map of ``String`` header keys and values (SDK accepts empty values but not empty keys) .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.set-custom-http-headers.kt :language: kotlin +.. _kotlin-enable-platform-networking: + +Enable Platform Networking +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.14.0 + +Atlas Device SDK's **platform networking** lets you use your platform's networking +stack instead of the default WebSocket client for Device Sync +traffic. + +When enabled, you can configure applications running on Android and +Java Virtual Machine (JVM) platforms to use managed WebSockets over +:github:`OkHttp `. Managed WebSockets provide advanced +configuration support for proxies and firewalls that require authentication. + +Platform networking is disabled by default. You can enable it on the +``AppConfiguration`` using the +`AppConfiguration.usePlatformNetworking() +<{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app-configuration/-builder/use-platform-networking.html>`__ +method, which accepts a Boolean value. + +.. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.enable-platform-networking.kt + :language: kotlin + +.. note:: Android and JVM platforms only + + This feature is currently only available on Android and Java Virtual + Machine (JVM) platforms. + Close the App Client -------------------- -You can manually close an App instance and release all underlying resources -using the `App.close() +You can manually close an App instance and release all underlying resources +using the `App.close() <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb/-app/close.html>`__ method: .. literalinclude:: /examples/generated/kotlin/AppClientTest.snippet.close-app-client.kt diff --git a/source/sdk/kotlin/users/authenticate-users.txt b/source/sdk/kotlin/users/authenticate-users.txt index fe7b6a673e..4837e92f4f 100644 --- a/source/sdk/kotlin/users/authenticate-users.txt +++ b/source/sdk/kotlin/users/authenticate-users.txt @@ -420,9 +420,8 @@ property: .. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.access-token-get.kt :language: kotlin -If you send requests outside of the SDK (e.g. through the :ref:`GraphQL -API `), then you must include the user's access token with -each request and manually refresh the token when it expires. +If you send requests outside of the SDK, you must include the user's access +token with each request and manually refresh the token when it expires. Access tokens expire 30 minutes after a user logs in. You can get the current refresh token for a logged-in user with the diff --git a/source/sdk/node.txt b/source/sdk/node.txt index b3c1b109df..602be00dd1 100644 --- a/source/sdk/node.txt +++ b/source/sdk/node.txt @@ -25,7 +25,6 @@ Atlas Device SDK for Node.js Atlas App Services Manage Users Sync Data - Integration Guides Logging SDK Telemetry API Reference @@ -170,15 +169,6 @@ Recommended Reading Explore generated reference docs for the Node.js SDK. - .. card:: - :headline: Electron Integration Guide - :cta: Use the SDK with Electron apps - :url: https://www.mongodb.com/docs/realm/sdk/node/integrations/electron/ - :icon: /images/icons/electron_logo.png - :icon-alt: Electron Icon - - Use the Node.js SDK in an Electron desktop application. - Example Projects ---------------- diff --git a/source/sdk/swift/install.txt b/source/sdk/swift/install.txt index bf3aa4a24c..c7d34fe524 100644 --- a/source/sdk/swift/install.txt +++ b/source/sdk/swift/install.txt @@ -439,12 +439,17 @@ Apple's requirements, refer to on the Apple Developer website. Starting in Swift SDK version 10.46.0, the SDK ships with privacy manifests -for ``Realm`` and ``RealmSwift``. +for ``Realm`` and ``RealmSwift``. Each package contains its own privacy manifest +with Apple's required API disclosures and the reasons for using those APIs. -The only privacy-related implementation detail inherent in the SDK is the usage -of file timestamp APIs, which is declared in the privacy manifest. The Swift SDK does -not include analytics code in builds for the App Store. The SDK does not log into -Atlas on its own behalf. +You can view the privacy manifests in each package, or in the ``realm-swift`` +GitHub repository: + +- ``Realm``: `https://github.com/realm/realm-swift/blob/master/Realm/PrivacyInfo.xcprivacy `_ +- ``RealmSwift``: `https://github.com/realm/realm-swift/blob/master/RealmSwift/PrivacyInfo.xcprivacy `_ + +The Swift SDK does not include analytics code in builds for the App Store. +The SDK does not log into Atlas on its own behalf. If you write an app that uses any App Services functionality, such as :ref:`initializing an App client ` to: diff --git a/source/sdk/swift/sync/partition-based-sync.txt b/source/sdk/swift/sync/partition-based-sync.txt index 3b643a747d..047f696867 100644 --- a/source/sdk/swift/sync/partition-based-sync.txt +++ b/source/sdk/swift/sync/partition-based-sync.txt @@ -58,7 +58,7 @@ This enables you to specify a partition value whose data should sync to the real specify download behavior, this opens a realm with data that is on the device, and attempts to sync changes in the background. - .. literalinclude:: /examples/generated/code/start/Sync.snippet.open-synced-realm.swift + .. literalinclude:: /examples/generated/code/start/Sync.snippet.open-realm-partition-based-sync.swift :language: swift .. tab:: diff --git a/source/sdk/swift/sync/write-to-synced-realm.txt b/source/sdk/swift/sync/write-to-synced-realm.txt index e5c2208a47..5adb045b44 100644 --- a/source/sdk/swift/sync/write-to-synced-realm.txt +++ b/source/sdk/swift/sync/write-to-synced-realm.txt @@ -381,7 +381,7 @@ Atlas: - Query Atlas with the :ref:`Realm Swift SDK MongoClient ` - Pass data to an :ref:`App Services Function ` -- Make HTTPS calls with the :ref:`Data API ` or :ref:`GraphQL API ` +- Make HTTPS calls with the :ref:`Data API ` Then, any device that has a network connection is always getting the most up-to-date information, without waiting for the user to open your main app diff --git a/source/sdk/swift/users/authenticate-users.txt b/source/sdk/swift/users/authenticate-users.txt index 23b09be78d..3fb130de8e 100644 --- a/source/sdk/swift/users/authenticate-users.txt +++ b/source/sdk/swift/users/authenticate-users.txt @@ -183,9 +183,8 @@ The Realm SDK automatically manages access tokens, refreshes them when they expire, and includes a valid access token for the current user with each request. -If you send requests outside of the SDK - for example, through the :ref:`GraphQL -API ` - then you must include the user's access token with -each request. In this scenario, you must manually refresh the token when +If you send requests outside of the SDK, you must include the user's access +token with each request. In this scenario, you must manually refresh the token when it expires. Access tokens expire after 30 minutes. You can call :swift-sdk:`.refreshCustomData() diff --git a/source/web.txt b/source/web.txt index 53cbdd6867..f67e4e2ae3 100644 --- a/source/web.txt +++ b/source/web.txt @@ -28,6 +28,11 @@ Atlas Device SDK for the Web Upgrade from Stitch to Realm Release Notes +.. banner:: + :variant: warning + + GraphQL is deprecated. :ref:`Learn More `. + The Atlas Device SDK for the Web lets browser-based applications access data stored in Atlas and interact with App Services services like Functions and authentication. The Web SDK supports both JavaScript and @@ -35,7 +40,6 @@ TypeScript. Web apps built with the SDK can query Atlas using the following methods: -- :ref:`Atlas GraphQL API ` - The standard MongoDB query API with the :ref:`MongoDB client ` - :ref:`Atlas Device Sync ` diff --git a/source/web/api-reference.txt b/source/web/api-reference.txt index c3e6070b95..d17e1a0915 100644 --- a/source/web/api-reference.txt +++ b/source/web/api-reference.txt @@ -17,9 +17,8 @@ However, the reference documentation doesn't differentiate between the subset of classes and namespaces supported by the Web SDK versus those only supported by Node.Js and React Native. The Web SDK doesn't support creating a non-synced database. -Web apps built with the Web SDK use :ref:`GraphQL ` -and the :ref:`Query API ` to query data stored in -Atlas. +Web apps built with the Web SDK use the :ref:`Query API ` to +query data stored in Atlas. Read the :js-sdk:`Realm JavaScript API reference `. diff --git a/source/web/atlas-app-services.txt b/source/web/atlas-app-services.txt index 3d302b2134..aa58de0f5b 100644 --- a/source/web/atlas-app-services.txt +++ b/source/web/atlas-app-services.txt @@ -54,18 +54,6 @@ a user accesses. To learn how to use the MongoDB APIs, see :ref:`Query MongoDB `. -GraphQL API ------------ - -Use the :ref:`Atlas GraphQL API ` with the Realm Web SDK to query -data in MongoDB Atlas. The Atlas GraphQL API generates a schema from your data -in Atlas, which you can extend with custom resolvers. Configure server-side -:ref:`data access rules ` to dynamically determine -read and write permissions for every query. - -To get started using the GraphQL API in a React web app, -see the :ref:`Apollo GraphQL Client (React) integration guide `. - Call Functions -------------- diff --git a/source/web/graphql-apollo-react.txt b/source/web/graphql-apollo-react.txt index 610f832d5a..5d76167f25 100644 --- a/source/web/graphql-apollo-react.txt +++ b/source/web/graphql-apollo-react.txt @@ -10,6 +10,11 @@ Apollo Client (React) - Web SDK :depth: 2 :class: singlecol +.. banner:: + :variant: warning + + GraphQL is deprecated. :ref:`Learn More `. + Overview -------- diff --git a/source/web/nextjs.txt b/source/web/nextjs.txt index eb3c295c63..d332b41cb1 100644 --- a/source/web/nextjs.txt +++ b/source/web/nextjs.txt @@ -10,6 +10,11 @@ Next.js Integration Guide - Web SDK :depth: 1 :class: singlecol +.. banner:: + :variant: warning + + GraphQL is deprecated. :ref:`Learn More `. + The following guide explains how to integrate the Realm Web SDK into a `Next.js `__ application. You can use the Realm Web SDK to access data in MongoDB Atlas from web apps, such as those made with Next.js. diff --git a/source/web/quickstart.txt b/source/web/quickstart.txt index 28183cdbef..22a8c11c8b 100644 --- a/source/web/quickstart.txt +++ b/source/web/quickstart.txt @@ -112,17 +112,3 @@ they were regular JavaScript functions defined on the object. .. literalinclude:: /examples/generated/web/quick-start.test.snippet.call-a-function.js :language: javascript - -.. _web-use-graphql: - -Use the GraphQL API -------------------- - -To execute CRUD operations and call custom resolvers through the :ref:`GraphQL -API `, we recommend that you use a third-party GraphQL library such -as :ref:`Apollo Client `. To authenticate your GraphQL -request, include a valid user token in the Authorization header of the request. - -.. seealso:: - - :doc:`Apollo Client (React) ` - - :ref:`Run GraphQL Operations from a CLI ` diff --git a/source/web/users.txt b/source/web/users.txt index a26d2dac5b..d3ec0189d8 100644 --- a/source/web/users.txt +++ b/source/web/users.txt @@ -35,7 +35,6 @@ Use Realm Web SDK to perform the following authentication and user management ac When you have a logged-in user, SDK methods enable you to: - :ref:`Query MongoDB Atlas ` -- :ref:`Use the Atlas GraphQL API ` - :ref:`Run a backend function ` as the logged-in user .. _web-create-and-delete-users: