Update object store
This commit is contained in:
parent
614c699385
commit
736cbd3ef3
|
@ -49,6 +49,7 @@
|
||||||
"src/object-store/src/index_set.cpp",
|
"src/object-store/src/index_set.cpp",
|
||||||
"src/object-store/src/list.cpp",
|
"src/object-store/src/list.cpp",
|
||||||
"src/object-store/src/object.cpp",
|
"src/object-store/src/object.cpp",
|
||||||
|
"src/object-store/src/placeholder.cpp",
|
||||||
"src/object-store/src/object_schema.cpp",
|
"src/object-store/src/object_schema.cpp",
|
||||||
"src/object-store/src/object_store.cpp",
|
"src/object-store/src/object_store.cpp",
|
||||||
"src/object-store/src/results.cpp",
|
"src/object-store/src/results.cpp",
|
||||||
|
@ -66,6 +67,7 @@
|
||||||
"src/object-store/src/parser/parser.cpp",
|
"src/object-store/src/parser/parser.cpp",
|
||||||
"src/object-store/src/parser/query_builder.cpp",
|
"src/object-store/src/parser/query_builder.cpp",
|
||||||
"src/object-store/src/util/format.cpp",
|
"src/object-store/src/util/format.cpp",
|
||||||
|
"src/object-store/src/util/uuid.cpp",
|
||||||
],
|
],
|
||||||
"conditions": [
|
"conditions": [
|
||||||
["OS=='win'", {
|
["OS=='win'", {
|
||||||
|
|
|
@ -14,6 +14,7 @@ if [ -f object-server-for-testing/node_modules/realm-object-server-developer/pac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
object_server_bundle="realm-object-server-bundled_node_darwin-developer-$REALM_OBJECT_SERVER_VERSION.tar.gz"
|
object_server_bundle="realm-object-server-bundled_node_darwin-developer-$REALM_OBJECT_SERVER_VERSION.tar.gz"
|
||||||
|
echo "Downloading https://static.realm.io/downloads/object-server/$object_server_bundle"
|
||||||
curl -f -L "https://static.realm.io/downloads/object-server/$object_server_bundle" -o "$object_server_bundle"
|
curl -f -L "https://static.realm.io/downloads/object-server/$object_server_bundle" -o "$object_server_bundle"
|
||||||
rm -rf object-server-for-testing
|
rm -rf object-server-for-testing
|
||||||
mkdir object-server-for-testing
|
mkdir object-server-for-testing
|
||||||
|
|
|
@ -89,7 +89,13 @@ Property Schema<T>::parse_property(ContextType ctx, ValueType attributes, std::s
|
||||||
|
|
||||||
ValueType optional_value = Object::get_property(ctx, property_object, optional_string);
|
ValueType optional_value = Object::get_property(ctx, property_object, optional_string);
|
||||||
if (!Value::is_undefined(ctx, optional_value)) {
|
if (!Value::is_undefined(ctx, optional_value)) {
|
||||||
prop.is_nullable = Value::validated_to_boolean(ctx, optional_value, "optional");
|
auto isNullableValue = Value::validated_to_boolean(ctx, optional_value, "optional");
|
||||||
|
if (isNullableValue) {
|
||||||
|
prop.type |= realm::PropertyType::Nullable;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prop.type &= ~realm::PropertyType::Nullable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -135,7 +141,7 @@ Property Schema<T>::parse_property(ContextType ctx, ValueType attributes, std::s
|
||||||
}
|
}
|
||||||
else if (type == "object") {
|
else if (type == "object") {
|
||||||
prop.type = realm::PropertyType::Object;
|
prop.type = realm::PropertyType::Object;
|
||||||
prop.is_nullable = true;
|
prop.type |= realm::PropertyType::Nullable;
|
||||||
|
|
||||||
if (!Value::is_valid(property_object)) {
|
if (!Value::is_valid(property_object)) {
|
||||||
throw std::runtime_error("Object property must specify 'objectType'");
|
throw std::runtime_error("Object property must specify 'objectType'");
|
||||||
|
@ -145,7 +151,7 @@ Property Schema<T>::parse_property(ContextType ctx, ValueType attributes, std::s
|
||||||
else {
|
else {
|
||||||
// The type could be the name of another object type in the same schema.
|
// The type could be the name of another object type in the same schema.
|
||||||
prop.type = realm::PropertyType::Object;
|
prop.type = realm::PropertyType::Object;
|
||||||
prop.is_nullable = true;
|
prop.type |= realm::PropertyType::Nullable;
|
||||||
prop.object_type = type;
|
prop.object_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +314,7 @@ typename T::Object Schema<T>::object_for_property(ContextType ctx, const Propert
|
||||||
}
|
}
|
||||||
|
|
||||||
static const String optional_string = "optional";
|
static const String optional_string = "optional";
|
||||||
if (property.is_nullable) {
|
if (is_nullable(property.type)) {
|
||||||
Object::set_property(ctx, object, optional_string, Value::from_boolean(ctx, true));
|
Object::set_property(ctx, object, optional_string, Value::from_boolean(ctx, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,11 +119,14 @@ void UserClass<T>::is_admin(ContextType ctx, ObjectType object, ReturnValue &ret
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void UserClass<T>::create_user(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) {
|
void UserClass<T>::create_user(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) {
|
||||||
validate_argument_count(argc, 3, 5);
|
validate_argument_count(argc, 3, 5);
|
||||||
|
SyncUserIdentifier userIdentifier {
|
||||||
|
(std::string)Value::validated_to_string(ctx, arguments[1], "identity"),
|
||||||
|
(std::string)Value::validated_to_string(ctx, arguments[0], "authServerUrl")
|
||||||
|
};
|
||||||
SharedUser *user = new SharedUser(SyncManager::shared().get_user(
|
SharedUser *user = new SharedUser(SyncManager::shared().get_user(
|
||||||
Value::validated_to_string(ctx, arguments[1], "identity"),
|
userIdentifier,
|
||||||
Value::validated_to_string(ctx, arguments[2], "refreshToken"),
|
(std::string)Value::validated_to_string(ctx, arguments[2], "refreshToken")
|
||||||
(std::string)Value::validated_to_string(ctx, arguments[0], "authServerUrl"),
|
));
|
||||||
Value::validated_to_boolean(ctx, arguments[3], "isAdminToken") ? SyncUser::TokenType::Admin : SyncUser::TokenType::Normal));
|
|
||||||
|
|
||||||
if (argc == 5) {
|
if (argc == 5) {
|
||||||
(*user)->set_is_admin(Value::validated_to_boolean(ctx, arguments[4], "isAdmin"));
|
(*user)->set_is_admin(Value::validated_to_boolean(ctx, arguments[4], "isAdmin"));
|
||||||
|
@ -432,7 +435,7 @@ void SyncClass<T>::populate_sync_config(ContextType ctx, ObjectType realm_constr
|
||||||
nullptr, util::none,
|
nullptr, util::none,
|
||||||
client_validate_ssl, ssl_trust_certificate_path});
|
client_validate_ssl, ssl_trust_certificate_path});
|
||||||
config.schema_mode = SchemaMode::Additive;
|
config.schema_mode = SchemaMode::Additive;
|
||||||
config.path = realm::SyncManager::shared().path_for_realm(shared_user->identity(), raw_realm_url);
|
config.path = realm::SyncManager::shared().path_for_realm(*shared_user, raw_realm_url);
|
||||||
|
|
||||||
if (!config.encryption_key.empty()) {
|
if (!config.encryption_key.empty()) {
|
||||||
config.sync_config->realm_encryption_key = std::array<char, 64>();
|
config.sync_config->realm_encryption_key = std::array<char, 64>();
|
||||||
|
|
|
@ -352,7 +352,7 @@ REALM_JS_INLINE void set_internal(const typename T::Object &object, typename Cla
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool Value<T>::is_valid_for_property(ContextType context, const ValueType &value, const Property& prop)
|
inline bool Value<T>::is_valid_for_property(ContextType context, const ValueType &value, const Property& prop)
|
||||||
{
|
{
|
||||||
if (prop.is_nullable && (is_null(context, value) || is_undefined(context, value))) {
|
if (is_nullable(prop.type) && (is_null(context, value) || is_undefined(context, value))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue