| 154 | }; |
| 155 | |
| 156 | static Result<Value> getJsModuleWithSchema( |
| 157 | Runtime* runtime, |
| 158 | const std::shared_ptr<snap::valdi_core::JSRuntimeNativeObjectsManager>& nativeObjectsManager, |
| 159 | ValueSchemaRegistry* registry, |
| 160 | std::string_view moduleName, |
| 161 | const ValueSchema& schema) { |
| 162 | auto resolvedSchema = schema; |
| 163 | if (registry != nullptr) { |
| 164 | ValueSchemaTypeResolver typeResolver(registry); |
| 165 | auto schemaResult = typeResolver.resolveTypeReferences(schema); |
| 166 | if (!schemaResult) { |
| 167 | return schemaResult.moveError(); |
| 168 | } |
| 169 | resolvedSchema = schemaResult.moveValue(); |
| 170 | } |
| 171 | |
| 172 | Valdi::SimpleExceptionTracker exceptionTracker; |
| 173 | Valdi::Marshaller marshaller(exceptionTracker); |
| 174 | |
| 175 | marshaller.setCurrentSchema(resolvedSchema); |
| 176 | |
| 177 | auto moduleIndex = runtime->getJavaScriptRuntime()->pushModuleToMarshaller( |
| 178 | nativeObjectsManager, StringCache::getGlobal().makeString(moduleName), marshaller); |
| 179 | if (!exceptionTracker) { |
| 180 | return Error(STRING_FORMAT("Couldn't resolve module '{}'", moduleName)); |
| 181 | } |
| 182 | |
| 183 | return marshaller.get(moduleIndex); |
| 184 | } |
| 185 | |
| 186 | static Result<Value> getJsModulePropertyWithSchema( |
| 187 | Runtime* runtime, |
no test coverage detected