(lib: &mut StandardLibrary<'_, 'heap>)
| 27 | } |
| 28 | |
| 29 | fn define(lib: &mut StandardLibrary<'_, 'heap>) -> ModuleDef<'heap> { |
| 30 | let mut def = ModuleDef::new(); |
| 31 | let heap = lib.heap; |
| 32 | |
| 33 | let mut entity_ty = lib |
| 34 | .manifest::<std_lib::graph::types::knowledge::entity::Entity>() |
| 35 | .expect_newtype(heap.intern_symbol("Entity")); |
| 36 | entity_ty.instantiate(&mut lib.instantiate); |
| 37 | |
| 38 | let versioned_url_ty = lib |
| 39 | .manifest::<std_lib::graph::types::ontology::Ontology>() |
| 40 | .expect_newtype(heap.intern_symbol("VersionedUrl")); |
| 41 | |
| 42 | let json_path_ty = lib |
| 43 | .manifest::<std_lib::core::json::Json>() |
| 44 | .expect_type(heap.intern_symbol("JsonPath")); |
| 45 | |
| 46 | // `is_of_type<T>(entity: Entity<T>, depth: Integer, type: VersionedUrl) -> Boolean` |
| 47 | // see: https://linear.app/hash/issue/H-4741/hashql-support-for-type-guards |
| 48 | // see: https://linear.app/hash/issue/H-4742/hashql-allow-is-of-type-to-be-queried-using-an-entitytype |
| 49 | let decl = decl!(lib; |
| 50 | <T>(entity: lib.ty.apply([(entity_ty.arguments[0].id, T)], entity_ty.id), |
| 51 | depth: lib.ty.integer(), |
| 52 | type: versioned_url_ty.id |
| 53 | ) -> lib.ty.boolean() |
| 54 | ); |
| 55 | |
| 56 | func(lib, &mut def, "::graph::entity::is_of_type", &[], decl); |
| 57 | |
| 58 | // `property<T>(entity: Entity<T>, path: JsonPath) -> Option<?>` |
| 59 | let decl = decl!(lib; |
| 60 | <T>(entity: lib.ty.apply([(entity_ty.arguments[0].id, T)], entity_ty.id), |
| 61 | path: json_path_ty.id |
| 62 | ) -> option(&lib.ty, lib.ty.unknown()) |
| 63 | ); |
| 64 | |
| 65 | func(lib, &mut def, "::graph::entity::property", &[], decl); |
| 66 | |
| 67 | def |
| 68 | } |
| 69 | } |
nothing calls this directly
no test coverage detected