diff --git a/.claude/skills/documenting-rust-code/SKILL.md b/.claude/skills/documenting-rust-code/SKILL.md index c9ef1df1bda..3bd302c7aef 100644 --- a/.claude/skills/documenting-rust-code/SKILL.md +++ b/.claude/skills/documenting-rust-code/SKILL.md @@ -116,7 +116,7 @@ Use explicit `# Arguments` section: ### Module Documentation -```rust +````rust //! Entity management functionality. //! //! Main types: @@ -128,11 +128,11 @@ Use explicit `# Arguments` section: //! ``` //! use hash_graph::entity::Entity; //! ``` -``` +```` ### Examples with Error Handling -```rust +````rust /// # Examples /// /// ```rust @@ -140,7 +140,7 @@ Use explicit `# Arguments` section: /// assert_eq!(entities.len(), 2); /// # Ok::<(), Box>(()) /// ``` -``` +```` ## Verification diff --git a/.claude/skills/documenting-rust-code/references/examples-and-links.md b/.claude/skills/documenting-rust-code/references/examples-and-links.md index 231c66ddf5c..953746a7c44 100644 --- a/.claude/skills/documenting-rust-code/references/examples-and-links.md +++ b/.claude/skills/documenting-rust-code/references/examples-and-links.md @@ -79,7 +79,7 @@ With link definition: ### Basic Example Structure -```rust +````rust /// # Examples /// /// ```rust @@ -89,7 +89,7 @@ With link definition: /// assert_eq!(entity.id(), id); /// # Ok::<(), Box>(()) /// ``` -``` +```` ### Example Checklist @@ -105,7 +105,7 @@ With link definition: Use `#` to hide necessary setup from docs display: -```rust +````rust /// # Examples /// /// ```rust @@ -118,7 +118,7 @@ Use `#` to hide necessary setup from docs display: /// # Ok(()) /// # } /// ``` -``` +```` **What renders:** @@ -133,7 +133,7 @@ println!("Found: {}", entity.name); ### Using `?` Operator -```rust +````rust /// # Examples /// /// ```rust @@ -141,18 +141,18 @@ println!("Found: {}", entity.name); /// assert!(result.is_valid()); /// # Ok::<(), Box>(()) /// ``` -``` +```` ### Using `expect` for Infallible Cases -```rust +````rust /// # Examples /// /// ```rust /// let config = Config::default(); /// let value = config.get("key").expect("should have default key"); /// ``` -``` +```` --- @@ -160,7 +160,7 @@ println!("Found: {}", entity.name); Show realistic usage patterns: -```rust +````rust /// # Examples /// /// ```rust @@ -179,7 +179,7 @@ Show realistic usage patterns: /// # Ok(()) /// # } /// ``` -``` +```` --- @@ -187,7 +187,7 @@ Show realistic usage patterns: Use `//!` for module-level docs: -```rust +````rust //! Entity management functionality. //! //! This module provides types and functions for creating, updating, @@ -208,7 +208,7 @@ Use `//!` for module-level docs: //! store.save(&entity)?; //! # Ok::<(), Box>(()) //! ``` -``` +```` --- @@ -234,7 +234,7 @@ Document performance characteristics when relevant: ## Async Documentation -```rust +````rust /// Processes entity asynchronously. /// /// # Concurrency @@ -253,13 +253,13 @@ Document performance characteristics when relevant: /// # } /// ``` pub async fn process_async(&self, entity: Entity) -> Result { -``` +```` --- ## Complete Example -```rust +````rust /// Validates and creates entity with type checking. /// /// Takes `properties` and validates them against the entity's type schema. @@ -311,7 +311,7 @@ pub fn create_entity( properties: Vec<(String, Value)>, web_id: WebId, ) -> Result> { -``` +```` --- diff --git a/.claude/skills/documenting-rust-code/references/function-documentation.md b/.claude/skills/documenting-rust-code/references/function-documentation.md index e5eeda2756e..092dec1fea2 100644 --- a/.claude/skills/documenting-rust-code/references/function-documentation.md +++ b/.claude/skills/documenting-rust-code/references/function-documentation.md @@ -212,7 +212,7 @@ Add `# Performance` sections for performance-critical functions: ## Complete Example -```rust +````rust /// Validates and creates a new entity in the system. /// /// Takes the provided `properties` and validates them against the entity's @@ -265,7 +265,7 @@ pub fn create_entity( web_id: WebId, account: &Account, ) -> Result> { -``` +```` --- diff --git a/.claude/skills/handling-rust-errors/SKILL.md b/.claude/skills/handling-rust-errors/SKILL.md index 69bed0220c3..5caa5522117 100644 --- a/.claude/skills/handling-rust-errors/SKILL.md +++ b/.claude/skills/handling-rust-errors/SKILL.md @@ -55,10 +55,10 @@ Code in `libs/@local/hashql/*` uses the `hashql-diagnostics` crate instead of `e **Which approach to use:** -| Location | Error Handling | -|-----------------------------------------|-----------------------------------------------------------------------------------------------------------| -| `libs/@local/hashql/*` (compiler code) | Use `hashql-diagnostics` → See [writing-hashql-diagnostics](../writing-hashql-diagnostics/SKILL.md) skill | -| Everywhere else | Use `error-stack` patterns from this skill | +| Location | Error Handling | +| -------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `libs/@local/hashql/*` (compiler code) | Use `hashql-diagnostics` → See [writing-hashql-diagnostics](../writing-hashql-diagnostics/SKILL.md) skill | +| Everywhere else | Use `error-stack` patterns from this skill | Traditional `error-stack` patterns still apply for HashQL infrastructure code (CLI, file I/O, configuration) that doesn't involve compiler diagnostics. diff --git a/.claude/skills/handling-rust-errors/references/documenting-errors.md b/.claude/skills/handling-rust-errors/references/documenting-errors.md index ad2ebf59886..a2f7bd613fd 100644 --- a/.claude/skills/handling-rust-errors/references/documenting-errors.md +++ b/.claude/skills/handling-rust-errors/references/documenting-errors.md @@ -33,7 +33,7 @@ pub fn create_web(&mut self) -> Result> { - `# Errors` section header - Bullet point for each error variant -- Intra-doc links using `` [`VariantName`] `` syntax +- Intra-doc links using ``[`VariantName`]`` syntax - Link definitions at the bottom --- @@ -227,7 +227,7 @@ When writing `# Examples` sections for fallible functions: Use `?` for error propagation in examples whenever possible: -```rust +````rust /// Fetches and processes user data. /// /// # Examples @@ -242,7 +242,7 @@ Use `?` for error propagation in examples whenever possible: pub fn fetch_user(id: &str) -> Result> { // Implementation } -``` +```` **Key Points:** @@ -254,7 +254,7 @@ pub fn fetch_user(id: &str) -> Result> { Only use explicit error handling when demonstrating error handling itself: -```rust +````rust /// Validates user input. /// /// # Examples @@ -269,7 +269,7 @@ Only use explicit error handling when demonstrating error handling itself: pub fn validate_input(input: &str) -> Result<(), Report> { // Implementation } -``` +```` --- @@ -298,7 +298,7 @@ pub fn validate_input(input: &str) -> Result<(), Report> { ### Complete Function Documentation -```rust +````rust #[derive(Debug, derive_more::Display)] pub enum RegistrationError { #[display("Email already registered")] @@ -339,7 +339,7 @@ impl Error for RegistrationError {} pub fn register_user(email: &str, password: &str) -> Result> { // Implementation } -``` +```` --- diff --git a/.claude/skills/skill-creator/SKILL.md b/.claude/skills/skill-creator/SKILL.md index d03c97aa848..fbbdfeb4af5 100644 --- a/.claude/skills/skill-creator/SKILL.md +++ b/.claude/skills/skill-creator/SKILL.md @@ -76,14 +76,14 @@ skill-name/ Every SKILL.md must have YAML frontmatter with required and optional fields: -| Field | Required | Description | -| ----- | -------- | ----------- | -| `name` | Yes | Max 64 chars. Lowercase letters, numbers, hyphens only. Must match directory name. | -| `description` | Yes | Max 1024 chars. Describes what the skill does and when to use it. | -| `license` | No | License name or reference to a bundled license file. | -| `compatibility` | No | Max 500 chars. Environment requirements (intended product, system packages, etc.). | -| `metadata` | No | Arbitrary key-value mapping for additional metadata. | -| `allowed-tools` | No | Space-delimited list of pre-approved tools. (Experimental) | +| Field | Required | Description | +| --------------- | -------- | ---------------------------------------------------------------------------------- | +| `name` | Yes | Max 64 chars. Lowercase letters, numbers, hyphens only. Must match directory name. | +| `description` | Yes | Max 1024 chars. Describes what the skill does and when to use it. | +| `license` | No | License name or reference to a bundled license file. | +| `compatibility` | No | Max 500 chars. Environment requirements (intended product, system packages, etc.). | +| `metadata` | No | Arbitrary key-value mapping for additional metadata. | +| `allowed-tools` | No | Space-delimited list of pre-approved tools. (Experimental) | #### Trigger Configuration (metadata.triggers) @@ -92,17 +92,17 @@ Skills can define auto-activation triggers in the `metadata.triggers` field: ```yaml metadata: triggers: - type: domain # "domain" (advisory) or "guardrail" (enforced) - enforcement: suggest # "suggest", "warn", or "block" - priority: high # "critical", "high", "medium", or "low" - keywords: # Exact substring matches (case-insensitive) + type: domain # "domain" (advisory) or "guardrail" (enforced) + enforcement: suggest # "suggest", "warn", or "block" + priority: high # "critical", "high", "medium", or "low" + keywords: # Exact substring matches (case-insensitive) - error - Result - error-stack - intent-patterns: # Regex patterns for intent detection + intent-patterns: # Regex patterns for intent detection - "\\b(handle|create)\\b.*?\\berror\\b" - "\\berror\\b.*?\\bhandling\\b" - files: # Optional: file-based triggers + files: # Optional: file-based triggers include: - "**/src/**/*.rs" exclude: @@ -166,9 +166,11 @@ Keep SKILL.md body under 500 lines. Split content into separate files when appro # PDF Processing ## Quick start + Extract text with pdfplumber: [code example] ## Advanced features + - **Form filling**: See [FORMS.md](references/FORMS.md) for complete guide - **API reference**: See [REFERENCE.md](references/REFERENCE.md) for all methods ``` diff --git a/.claude/skills/skill-creator/assets/SKILL.template.md b/.claude/skills/skill-creator/assets/SKILL.template.md index 157df21559c..c38460d1227 100644 --- a/.claude/skills/skill-creator/assets/SKILL.template.md +++ b/.claude/skills/skill-creator/assets/SKILL.template.md @@ -1,12 +1,12 @@ --- -name: {{skill_name}} +name: "{{skill_name}}" description: "[TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it.]" # license: Apache-2.0 # Uncomment and set license if needed metadata: triggers: - type: domain # "domain" (advisory) or "guardrail" (enforced) - enforcement: suggest # "suggest", "warn", or "block" - priority: medium # "critical", "high", "medium", or "low" + type: domain # "domain" (advisory) or "guardrail" (enforced) + enforcement: suggest # "suggest", "warn", or "block" + priority: medium # "critical", "high", "medium", or "low" keywords: - "[TODO: Add keywords that should trigger this skill]" intent-patterns: diff --git a/.claude/skills/skill-creator/references/output-patterns.md b/.claude/skills/skill-creator/references/output-patterns.md index f2a8b7605cb..3f78aae12b1 100644 --- a/.claude/skills/skill-creator/references/output-patterns.md +++ b/.claude/skills/skill-creator/references/output-patterns.md @@ -16,14 +16,17 @@ ALWAYS use this exact template structure: # [Analysis Title] ## Executive summary + [One-paragraph overview of key findings] ## Key findings + - Finding 1 with supporting data - Finding 2 with supporting data - Finding 3 with supporting data ## Recommendations + 1. Specific actionable recommendation 2. Specific actionable recommendation ``` @@ -38,12 +41,15 @@ Here is a sensible default format, but use your best judgment: # [Analysis Title] ## Executive summary + [Overview] ## Key findings + [Adapt sections based on what you discover] ## Recommendations + [Tailor to the specific context] Adjust sections as needed for the specific analysis type. @@ -67,7 +73,7 @@ feat(auth): implement JWT-based authentication Add login endpoint and token validation middleware -```text +````text **Example 2:** Input: Fixed bug where dates displayed incorrectly in reports @@ -81,6 +87,6 @@ Use UTC timestamps consistently across report generation ```text Follow this style: type(scope): brief description, then detailed explanation. -``` +```` Examples help agents understand the desired style and level of detail more clearly than descriptions alone. diff --git a/.claude/skills/skill-creator/references/troubleshooting.md b/.claude/skills/skill-creator/references/troubleshooting.md index 85cdc2d05b6..5a534b40391 100644 --- a/.claude/skills/skill-creator/references/troubleshooting.md +++ b/.claude/skills/skill-creator/references/troubleshooting.md @@ -40,7 +40,7 @@ keywords: ```yaml intent-patterns: - - "(create|add).*?(database.*?table)" # Too specific + - "(create|add).*?(database.*?table)" # Too specific ``` - "create a database table" → ✅ Matches @@ -50,7 +50,7 @@ intent-patterns: ```yaml intent-patterns: - - "(create|add).*?(table|database)" # Better + - "(create|add).*?(table|database)" # Better ``` ### Name Mismatch @@ -109,7 +109,7 @@ keywords: ```yaml intent-patterns: - - "(create)" # Matches everything with "create" + - "(create)" # Matches everything with "create" ``` **Solution:** Add context: @@ -126,7 +126,7 @@ intent-patterns: ```yaml files: include: - - "src/**" # Matches everything in src/ + - "src/**" # Matches everything in src/ ``` **Solution:** Use narrower patterns: @@ -167,7 +167,7 @@ The `name` field in SKILL.md must exactly match the directory name. ```yaml skill-creator/SKILL.md --- -name: skill-creator # Must match directory name +name: skill-creator # Must match directory name ``` ### "Invalid regex in intent-patterns" diff --git a/.claude/skills/testing-hashql/SKILL.md b/.claude/skills/testing-hashql/SKILL.md index 7e7d753dd23..9c26fc6cdbf 100644 --- a/.claude/skills/testing-hashql/SKILL.md +++ b/.claude/skills/testing-hashql/SKILL.md @@ -26,16 +26,16 @@ HashQL uses three testing approaches. **compiletest is the default** for testing ## Quick Reference -| Scenario | Test Type | Location | -| -------- | --------- | -------- | -| Diagnostics/error messages | compiletest | `tests/ui/` | -| Compiler pipeline phases | compiletest | `tests/ui/` | -| MIR/HIR/AST pass integration | compiletest | `tests/ui/` | -| MIR/HIR/AST pass edge cases | insta | `tests/ui//` | -| MIR pass unit tests | MIR builder | `src/**/tests.rs` | -| Core crate (where needed) | insta | `src/**/snapshots/` | -| Parser fragments (syntax-jexpr) | insta | `src/*/snapshots/` | -| Internal functions/logic | Unit tests | `src/*.rs` | +| Scenario | Test Type | Location | +| ------------------------------- | ----------- | ---------------------- | +| Diagnostics/error messages | compiletest | `tests/ui/` | +| Compiler pipeline phases | compiletest | `tests/ui/` | +| MIR/HIR/AST pass integration | compiletest | `tests/ui/` | +| MIR/HIR/AST pass edge cases | insta | `tests/ui//` | +| MIR pass unit tests | MIR builder | `src/**/tests.rs` | +| Core crate (where needed) | insta | `src/**/snapshots/` | +| Parser fragments (syntax-jexpr) | insta | `src/*/snapshots/` | +| Internal functions/logic | Unit tests | `src/*.rs` | ## compiletest (UI Tests) @@ -66,7 +66,7 @@ cargo run -p hashql-compiletest run --bless # Update expected ```jsonc //@ run: fail //@ description: Tests duplicate field detection -["type", "Bad", {"#struct": {"x": "Int", "x": "String"}}, "_"] +["type", "Bad", { "#struct": { "x": "Int", "x": "String" } }, "_"] //~^ ERROR Field `x` first defined here ``` @@ -115,11 +115,11 @@ cargo test --package hashql- --doc # Doc tests Use `insta` crate for snapshot-based output when compiletest (the preferred method) is infeasible. Three categories exist: -| Category | Crates | Snapshot Location | Rationale | -| -------- | ------ | ----------------- | --------- | -| **Pipeline Crates** | mir, hir, ast | `tests/ui//*.snap` | Colocate with compiletest tests | -| **Core** | hashql-core | Default insta (`src/**/snapshots/`) | Separate from pipeline; prefer unit tests | -| **Syntax** | syntax-jexpr | `src/*/snapshots/` | Macro-based for parser fragments | +| Category | Crates | Snapshot Location | Rationale | +| ------------------- | ------------- | ----------------------------------- | ----------------------------------------- | +| **Pipeline Crates** | mir, hir, ast | `tests/ui//*.snap` | Colocate with compiletest tests | +| **Core** | hashql-core | Default insta (`src/**/snapshots/`) | Separate from pipeline; prefer unit tests | +| **Syntax** | syntax-jexpr | `src/*/snapshots/` | Macro-based for parser fragments | ### Pipeline Crates (mir, hir, ast) diff --git a/.claude/skills/testing-hashql/references/compiletest-guide.md b/.claude/skills/testing-hashql/references/compiletest-guide.md index cb5927edee2..1b2ceac669c 100644 --- a/.claude/skills/testing-hashql/references/compiletest-guide.md +++ b/.claude/skills/testing-hashql/references/compiletest-guide.md @@ -83,13 +83,13 @@ package_name/ ### Test Components -| File | Purpose | Required | -| ---- | ------- | -------- | -| `.jsonc` | J-Expr test code | ✅ Yes | -| `.spec.toml` | Test suite specification | ✅ Yes (in dir or parent) | -| `.stdout` | Expected standard output | Optional (empty if none) | -| `.stderr` | Expected diagnostics | Optional (empty if none) | -| `.aux.` | Auxiliary/secondary output | Suite-dependent | +| File | Purpose | Required | +| ------------ | -------------------------- | ------------------------- | +| `.jsonc` | J-Expr test code | ✅ Yes | +| `.spec.toml` | Test suite specification | ✅ Yes (in dir or parent) | +| `.stdout` | Expected standard output | Optional (empty if none) | +| `.stderr` | Expected diagnostics | Optional (empty if none) | +| `.aux.` | Auxiliary/secondary output | Suite-dependent | The harness searches upward from the test file to find `.spec.toml`, stopping at `tests/ui/`. This allows shared specs at directory roots with overrides for specific subdirectories. @@ -132,7 +132,6 @@ Directives control test behavior. They **must** be at the start of the file, bef //@ run: fail // Test should fail with errors (DEFAULT) //@ run: skip // Skip this test //@ run: skip reason=Not implemented yet - //@ name: custom_test_name // Override the default test name //@ description: Tests that... // Describe test purpose (ENCOURAGED) //@ suite#key: value // Suite-specific directive (TOML value) @@ -140,11 +139,11 @@ Directives control test behavior. They **must** be at the start of the file, bef ### Run Modes -| Mode | Behavior | -| ---- | -------- | -| `pass` | Test must succeed with no errors | +| Mode | Behavior | +| ------ | ------------------------------------------------- | +| `pass` | Test must succeed with no errors | | `fail` | Test must produce errors (**default if omitted**) | -| `skip` | Test is skipped entirely | +| `skip` | Test is skipped entirely | **Important:** If you don't specify `//@ run:`, the test defaults to `fail` mode. Always use `//@ run: pass` explicitly for tests that should succeed. @@ -179,17 +178,17 @@ Annotations verify that specific diagnostics appear at expected locations. ### Line Reference Types -| Syntax | Meaning | Example | -| ------ | ------- | ------- | -| `//~ ERROR msg` | Current line | Error on this exact line | -| `//~^ ERROR msg` | Previous line (1 up) | Error on line above | -| `//~^^ ERROR msg` | 2 lines above | | -| `//~^^^ ERROR msg` | 3 lines above | | -| `//~v ERROR msg` | Next line (1 down) | Error on line below | -| `//~vv ERROR msg` | 2 lines below | | -| `//~vvv ERROR msg` | 3 lines below | | -| `//~\| ERROR msg` | Same line as previous | Multiple errors, same location | -| `//~? ERROR msg` | Unknown/any line | Use sparingly | +| Syntax | Meaning | Example | +| ------------------ | --------------------- | ------------------------------ | +| `//~ ERROR msg` | Current line | Error on this exact line | +| `//~^ ERROR msg` | Previous line (1 up) | Error on line above | +| `//~^^ ERROR msg` | 2 lines above | | +| `//~^^^ ERROR msg` | 3 lines above | | +| `//~v ERROR msg` | Next line (1 down) | Error on line below | +| `//~vv ERROR msg` | 2 lines below | | +| `//~vvv ERROR msg` | 3 lines below | | +| `//~\| ERROR msg` | Same line as previous | Multiple errors, same location | +| `//~? ERROR msg` | Unknown/any line | Use sparingly | ### Error Codes @@ -202,21 +201,23 @@ Include optional error codes in brackets: ### Multi-Annotation Example ```jsonc -["let", "x", //~^ ERROR first error on the let line - ["invalid"] //~ ERROR error on this line -] //~| ERROR another error on same line as previous - //~| NOTE additional context +[ + "let", + "x", //~^ ERROR first error on the let line + ["invalid"], //~ ERROR error on this line +] //~| ERROR another error on same line as previous +//~| NOTE additional context ``` ### Severity Levels -| Level | Use Case | -| ----- | -------- | +| Level | Use Case | +| ---------- | -------------------- | | `CRITICAL` | Unrecoverable errors | -| `ERROR` | Standard errors | -| `WARNING` | Non-fatal warnings | -| `NOTE` | Informational notes | -| `DEBUG` | Debug output | +| `ERROR` | Standard errors | +| `WARNING` | Non-fatal warnings | +| `NOTE` | Informational notes | +| `DEBUG` | Debug output | --- @@ -261,8 +262,11 @@ Create a `.jsonc` file with your test code and directives: //@ description: Verifies that undefined variables produce an error //@ run: fail -["let", "x", {"#literal": 42}, - "undefined_var" //~ ERROR unknown variable +[ + "let", + "x", + { "#literal": 42 }, + "undefined_var", //~ ERROR unknown variable ] ``` diff --git a/.claude/skills/testing-hashql/references/mir-builder-guide.md b/.claude/skills/testing-hashql/references/mir-builder-guide.md index 1967b7e4af7..b15303bf163 100644 --- a/.claude/skills/testing-hashql/references/mir-builder-guide.md +++ b/.claude/skills/testing-hashql/references/mir-builder-guide.md @@ -66,41 +66,41 @@ decl result: Bool; ### Header -| Component | Description | Example | -| --------- | ----------- | ------- | -| `` | Body source type | `fn`, `thunk`, `[ctor expr]`, `intrinsic` | -| `` | DefId (literal or variable) | `0`, `42`, `my_def_id` | -| `` | Number of function arguments | `0`, `1`, `2` | -| `` | Return type | `Int`, `Bool`, `(Int, Bool)` | +| Component | Description | Example | +| --------------- | ---------------------------- | ----------------------------------------- | +| `` | Body source type | `fn`, `thunk`, `[ctor expr]`, `intrinsic` | +| `` | DefId (literal or variable) | `0`, `42`, `my_def_id` | +| `` | Number of function arguments | `0`, `1`, `2` | +| `` | Return type | `Int`, `Bool`, `(Int, Bool)` | The `` can be a numeric literal (`0`, `1`, `42`) or a variable identifier (`callee_id`, `my_def_id`). When using a variable, it must be a `DefId` in scope. **Source types:** -| Syntax | Maps to | Use case | -| ------ | ------- | -------- | -| `fn` | `Source::Closure` | Regular closures/functions | -| `thunk` | `Source::Thunk` | Thunk bodies (zero-arg delayed computations) | -| `[ctor sym::path]` | `Source::Ctor(sym)` | Constructor bodies (always inlined) | -| `[graph::read::filter]` | `Source::GraphReadFilter` | Graph read filter bodies (never inlined) | -| `intrinsic` | `Source::Intrinsic` | Intrinsic bodies (never inlined) | +| Syntax | Maps to | Use case | +| ----------------------- | ------------------------- | -------------------------------------------- | +| `fn` | `Source::Closure` | Regular closures/functions | +| `thunk` | `Source::Thunk` | Thunk bodies (zero-arg delayed computations) | +| `[ctor sym::path]` | `Source::Ctor(sym)` | Constructor bodies (always inlined) | +| `[graph::read::filter]` | `Source::GraphReadFilter` | Graph read filter bodies (never inlined) | +| `intrinsic` | `Source::Intrinsic` | Intrinsic bodies (never inlined) | ### Types -| Syntax | Description | Example | -| ------ | ----------- | ------- | -| `Int` | Integer type | `Int` | -| `Num` | Number (float) type | `Num` | -| `Bool` | Boolean type | `Bool` | -| `Null` | Null type | `Null` | -| `?` | Unknown type (dynamic) | `?` | -| `(T1, T2, ...)` | Tuple types | `(Int, Bool, Int)` | -| `(T,)` | Single-element tuple | `(Int,)` | -| `(a: T1, b: T2)` | Struct types | `(a: Int, b: Bool)` | -| `[List T]` | List type (intrinsic) | `[List Int]`, `[List (Int, Bool)]` | -| `[fn(T1, T2) -> R]` | Closure types | `[fn(Int) -> Int]`, `[fn() -> Bool]` | -| `[Opaque path; T]` | Opaque type with symbol path | `[Opaque sym::path::Entity; ?]` | -| `\|types\| types.custom()` | Custom type expression | `\|t\| t.null()` | +| Syntax | Description | Example | +| -------------------------- | ---------------------------- | ------------------------------------ | +| `Int` | Integer type | `Int` | +| `Num` | Number (float) type | `Num` | +| `Bool` | Boolean type | `Bool` | +| `Null` | Null type | `Null` | +| `?` | Unknown type (dynamic) | `?` | +| `(T1, T2, ...)` | Tuple types | `(Int, Bool, Int)` | +| `(T,)` | Single-element tuple | `(Int,)` | +| `(a: T1, b: T2)` | Struct types | `(a: Int, b: Bool)` | +| `[List T]` | List type (intrinsic) | `[List Int]`, `[List (Int, Bool)]` | +| `[fn(T1, T2) -> R]` | Closure types | `[fn(Int) -> Int]`, `[fn() -> Bool]` | +| `[Opaque path; T]` | Opaque type with symbol path | `[Opaque sym::path::Entity; ?]` | +| `\|types\| types.custom()` | Custom type expression | `\|t\| t.null()` | ### Projections (Optional) @@ -148,44 +148,44 @@ let body = body!(interner, env; [graph::read::filter]@0/2 -> Bool { ### Statements -| Syntax | Description | MIR Equivalent | -| ------ | ----------- | -------------- | -| `let x;` | Mark storage live | `StorageLive(x)` | -| `drop x;` | Mark storage dead | `StorageDead(x)` | -| `x = load ;` | Load value | `Assign(x, Load(operand))` | -| `x = apply ;` | Call with no args | `Assign(x, Apply(func, []))` | -| `x = apply , , ;` | Call with args | `Assign(x, Apply(func, [a1, a2]))` | -| `x = tuple , ;` | Create tuple | `Assign(x, Aggregate(Tuple, [a, b]))` | -| `x = struct a: , b: ;` | Create struct | `Assign(x, Aggregate(Struct, [v1, v2]))` | -| `x = closure ;` | Create closure | `Assign(x, Aggregate(Closure, [def, env]))` | -| `x = bin. ;` | Binary operation | `Assign(x, Binary(lhs, op, rhs))` | -| `x = un. ;` | Unary operation | `Assign(x, Unary(op, operand))` | -| `x = input.load! "name";` | Load required input | `Assign(x, Input(Load { required: true }, "name"))` | -| `x = input.load "name";` | Load optional input | `Assign(x, Input(Load { required: false }, "name"))` | -| `x = input.exists "name";` | Check if input exists | `Assign(x, Input(Exists, "name"))` | +| Syntax | Description | MIR Equivalent | +| ------------------------------- | --------------------- | ---------------------------------------------------- | +| `let x;` | Mark storage live | `StorageLive(x)` | +| `drop x;` | Mark storage dead | `StorageDead(x)` | +| `x = load ;` | Load value | `Assign(x, Load(operand))` | +| `x = apply ;` | Call with no args | `Assign(x, Apply(func, []))` | +| `x = apply , , ;` | Call with args | `Assign(x, Apply(func, [a1, a2]))` | +| `x = tuple , ;` | Create tuple | `Assign(x, Aggregate(Tuple, [a, b]))` | +| `x = struct a: , b: ;` | Create struct | `Assign(x, Aggregate(Struct, [v1, v2]))` | +| `x = closure ;` | Create closure | `Assign(x, Aggregate(Closure, [def, env]))` | +| `x = bin. ;` | Binary operation | `Assign(x, Binary(lhs, op, rhs))` | +| `x = un. ;` | Unary operation | `Assign(x, Unary(op, operand))` | +| `x = input.load! "name";` | Load required input | `Assign(x, Input(Load { required: true }, "name"))` | +| `x = input.load "name";` | Load optional input | `Assign(x, Input(Load { required: false }, "name"))` | +| `x = input.exists "name";` | Check if input exists | `Assign(x, Input(Exists, "name"))` | ### Terminators -| Syntax | Description | -| ------ | ----------- | -| `return ;` | Return from function | -| `goto (...);` | Unconditional jump with args | -| `if then () else ();` | Conditional branch | -| `switch [ => (), ...];` | Switch (no otherwise) | -| `switch [ => (), _ => ()];` | Switch with otherwise | -| `unreachable;` | Mark block as unreachable | +| Syntax | Description | +| ------------------------------------------------------ | ---------------------------- | +| `return ;` | Return from function | +| `goto (...);` | Unconditional jump with args | +| `if then () else ();` | Conditional branch | +| `switch [ => (), ...];` | Switch (no otherwise) | +| `switch [ => (), _ => ()];` | Switch with otherwise | +| `unreachable;` | Mark block as unreachable | ### Operands -| Syntax | Description | -| ------ | ----------- | -| `x`, `cond` | Place (local variable or projection) | -| `42`, `-5` | Integer literal (i64) | -| `3.14` | Float literal (f64) | -| `true`, `false` | Boolean literal | -| `()` | Unit | -| `null` | Null | -| `def_id` | DefId variable (for function pointers) | +| Syntax | Description | +| --------------- | -------------------------------------- | +| `x`, `cond` | Place (local variable or projection) | +| `42`, `-5` | Integer literal (i64) | +| `3.14` | Float literal (f64) | +| `true`, `false` | Boolean literal | +| `()` | Unit | +| `null` | Null | +| `def_id` | DefId variable (for function pointers) | ### Operators @@ -451,7 +451,7 @@ fn assert_pass<'heap>( // Run the pass and capture change status let changed = YourPass::new().run(context, &mut bodies[0]); - + // Include Changed value in snapshot write!( text_format.writer, diff --git a/.claude/skills/testing-hashql/references/mir-fluent-builder.md b/.claude/skills/testing-hashql/references/mir-fluent-builder.md index 307a0c468a2..f2aafdb71b8 100644 --- a/.claude/skills/testing-hashql/references/mir-fluent-builder.md +++ b/.claude/skills/testing-hashql/references/mir-fluent-builder.md @@ -102,19 +102,19 @@ builder.build_block(bb).unreachable(); ## RValue Methods -| Method | Creates | Example | -| ------ | ------- | ------- | -| `load(operand)` | Copy/move | `rv.load(x)` | -| `binary(l, op, r)` | Binary op | `rv.binary(x, op![+], y)` | -| `unary(op, val)` | Unary op | `rv.unary(op![!], cond)` | -| `tuple([...])` | Tuple | `rv.tuple([x, y, z])` | -| `list([...])` | List | `rv.list([a, b, c])` | -| `struct([...])` | Struct | `rv.r#struct([("x", val)])` | -| `closure(def, env)` | Closure | `rv.closure(def_id, env_place)` | -| `dict([...])` | Dict | `rv.dict([(k, v)])` | -| `apply(fn, args)` | Call | `rv.apply(func, [arg1])` | -| `call(fn)` | Call (no args) | `rv.call(func)` | -| `input(op, name)` | Input | `rv.input(InputOp::Load { required: true }, "x")` | +| Method | Creates | Example | +| ------------------- | -------------- | ------------------------------------------------- | +| `load(operand)` | Copy/move | `rv.load(x)` | +| `binary(l, op, r)` | Binary op | `rv.binary(x, op![+], y)` | +| `unary(op, val)` | Unary op | `rv.unary(op![!], cond)` | +| `tuple([...])` | Tuple | `rv.tuple([x, y, z])` | +| `list([...])` | List | `rv.list([a, b, c])` | +| `struct([...])` | Struct | `rv.r#struct([("x", val)])` | +| `closure(def, env)` | Closure | `rv.closure(def_id, env_place)` | +| `dict([...])` | Dict | `rv.dict([(k, v)])` | +| `apply(fn, args)` | Call | `rv.apply(func, [arg1])` | +| `call(fn)` | Call (no args) | `rv.call(func)` | +| `input(op, name)` | Input | `rv.input(InputOp::Load { required: true }, "x")` | ## Places with Projections diff --git a/.claude/skills/testing-hashql/references/testing-strategies.md b/.claude/skills/testing-hashql/references/testing-strategies.md index 015471c6e04..420ad368ac1 100644 --- a/.claude/skills/testing-hashql/references/testing-strategies.md +++ b/.claude/skills/testing-hashql/references/testing-strategies.md @@ -6,16 +6,16 @@ This guide helps you choose the right testing approach for HashQL code. ## Decision Matrix -| Question | compiletest | Unit Tests | insta Snapshots | -| -------- | ----------- | ---------- | --------------- | -| Testing error messages/diagnostics? | ✅ **Best** | ❌ | ⚠️ Possible | -| Testing compiler pipeline stages? | ✅ **Best** | ❌ | ⚠️ Possible | -| Testing internal function logic? | ❌ | ✅ **Best** | ❌ | -| MIR/HIR pass integration (end-to-end)? | ✅ **Best** | ❌ | ❌ | -| MIR/HIR pass edge cases (isolated)? | ⚠️ Noisy | ❌ | ✅ **Best** | -| Testing parser output structure? | ⚠️ Possible | ⚠️ Possible | ✅ **Best** | -| Need to verify exact output format? | ✅ **Best** | ❌ | ✅ **Best** | -| Testing edge cases in isolation? | ❌ | ✅ **Best** | ⚠️ Possible | +| Question | compiletest | Unit Tests | insta Snapshots | +| -------------------------------------- | ----------- | ----------- | --------------- | +| Testing error messages/diagnostics? | ✅ **Best** | ❌ | ⚠️ Possible | +| Testing compiler pipeline stages? | ✅ **Best** | ❌ | ⚠️ Possible | +| Testing internal function logic? | ❌ | ✅ **Best** | ❌ | +| MIR/HIR pass integration (end-to-end)? | ✅ **Best** | ❌ | ❌ | +| MIR/HIR pass edge cases (isolated)? | ⚠️ Noisy | ❌ | ✅ **Best** | +| Testing parser output structure? | ⚠️ Possible | ⚠️ Possible | ✅ **Best** | +| Need to verify exact output format? | ✅ **Best** | ❌ | ✅ **Best** | +| Testing edge cases in isolation? | ❌ | ✅ **Best** | ⚠️ Possible | --- @@ -60,10 +60,10 @@ From `libs/@local/hashql/ast/tests/ui/lowering/type-extractor/definition/duplica "another": "Boolean", //~^ ERROR Field `another` first defined here "another": "Number", - "unique": "String" - } + "unique": "String", + }, }, - "_" + "_", ] ``` @@ -77,13 +77,28 @@ From `libs/@local/hashql/hir/tests/ui/lower/graph-hoisting/hoist.jsonc`: //@ run: pass //@ description: TODO [ - "let", "a", { "#literal": true }, - ["let", "b", { "#literal": true }, - ["::graph::tail::collect", - ["::graph::body::filter", + "let", + "a", + { "#literal": true }, + [ + "let", + "b", + { "#literal": true }, + [ + "::graph::tail::collect", + [ + "::graph::body::filter", ["::graph::head::entities", ["::graph::tmp::decision_time_now"]], - ["fn", { "#tuple": [] }, { "#struct": { "vertex": "_" } }, "_", - ["==", "a", "b"]]]]] + [ + "fn", + { "#tuple": [] }, + { "#struct": { "vertex": "_" } }, + "_", + ["==", "a", "b"], + ], + ], + ], + ], ] ``` @@ -179,11 +194,11 @@ cargo test --package hashql-syntax-jexpr --doc Uses the `insta` crate for snapshot-based output when compiletest is infeasible. **Three categories exist:** -| Category | Crates | Snapshot Location | Rationale | -| -------- | ------ | ----------------- | --------- | -| **Pipeline Crates** | mir, hir, ast | `tests/ui//*.snap` | Colocate with compiletest tests | -| **Core** | hashql-core | Default insta (`src/**/snapshots/`) | Separate from pipeline; prefer unit tests | -| **Syntax** | syntax-jexpr | `src/*/snapshots/` | Macro-based for parser fragments | +| Category | Crates | Snapshot Location | Rationale | +| ------------------- | ------------- | ----------------------------------- | ----------------------------------------- | +| **Pipeline Crates** | mir, hir, ast | `tests/ui//*.snap` | Colocate with compiletest tests | +| **Core** | hashql-core | Default insta (`src/**/snapshots/`) | Separate from pipeline; prefer unit tests | +| **Syntax** | syntax-jexpr | `src/*/snapshots/` | Macro-based for parser fragments | ### Pipeline Crates (mir, hir, ast) @@ -266,7 +281,7 @@ cargo insta reject # Reject all pending ```jsonc //@ run: fail //@ description: Error when using reserved keyword as identifier -["let", "type", {"#literal": 1}, "type"] +["let", "type", { "#literal": 1 }, "type"] //~^ ERROR `type` is a reserved keyword ``` @@ -289,7 +304,7 @@ fn symbol_table_lookup_returns_none_for_undefined() { ```jsonc //@ run: pass //@ description: Tests new optimization pass integrates correctly -["let", "x", {"#literal": 1}, ["add", "x", "x"]] +["let", "x", { "#literal": 1 }, ["add", "x", "x"]] ``` **Use insta for isolated edge cases** — exercising specific scenarios that are rarely hit in normal pipeline tests, or where compiletest would create too much noise: @@ -318,12 +333,12 @@ test_cases!(parse_new_syntax; ## Summary -| Approach | Test Location | Snapshot Location | Update Command | Best For | -| -------- | ------------ | ----------------- | -------------- | -------- | -| compiletest | `tests/ui/*.jsonc` | `tests/ui/*.stdout/stderr` | `--bless` | Diagnostics, pipeline, pass integration | -| Unit tests | `src/*.rs` | N/A | N/A | Isolated logic | -| insta (pipeline) | `src/**/tests.rs` | `tests/ui//` | `cargo insta accept` | Pass edge cases | -| insta (core) | `src/**/tests` | `src/**/snapshots/` | `cargo insta accept` | Core crate | -| insta (syntax-jexpr) | `src/*/tests` | `src/*/snapshots/` | `cargo insta accept` | Parser fragments | +| Approach | Test Location | Snapshot Location | Update Command | Best For | +| -------------------- | ------------------ | -------------------------- | -------------------- | --------------------------------------- | +| compiletest | `tests/ui/*.jsonc` | `tests/ui/*.stdout/stderr` | `--bless` | Diagnostics, pipeline, pass integration | +| Unit tests | `src/*.rs` | N/A | N/A | Isolated logic | +| insta (pipeline) | `src/**/tests.rs` | `tests/ui//` | `cargo insta accept` | Pass edge cases | +| insta (core) | `src/**/tests` | `src/**/snapshots/` | `cargo insta accept` | Core crate | +| insta (syntax-jexpr) | `src/*/tests` | `src/*/snapshots/` | `cargo insta accept` | Parser fragments | **Default choice: compiletest** for end-to-end pipeline testing; **insta** for isolated edge cases where compiletest would be noisy. diff --git a/.claude/skills/writing-hashql-diagnostics/SKILL.md b/.claude/skills/writing-hashql-diagnostics/SKILL.md index 602adf00876..c839d46283b 100644 --- a/.claude/skills/writing-hashql-diagnostics/SKILL.md +++ b/.claude/skills/writing-hashql-diagnostics/SKILL.md @@ -59,13 +59,13 @@ diagnostic.add_message(Message::help("try using a comparison")); ### Severity Levels -| Severity | When to Use | -| ---------- | -------------------------- | -| `Bug` | Internal compiler error | -| `Fatal` | Unrecoverable error | -| `Error` | Must be fixed to compile | -| `Warning` | Suspicious code to review | -| `Note` | Informational context | +| Severity | When to Use | +| --------- | ------------------------- | +| `Bug` | Internal compiler error | +| `Fatal` | Unrecoverable error | +| `Error` | Must be fixed to compile | +| `Warning` | Suspicious code to review | +| `Note` | Informational context | ### Message Style diff --git a/.claude/skills/writing-hashql-diagnostics/references/guidelines.md b/.claude/skills/writing-hashql-diagnostics/references/guidelines.md index feb7ce57215..c44fb8938d5 100644 --- a/.claude/skills/writing-hashql-diagnostics/references/guidelines.md +++ b/.claude/skills/writing-hashql-diagnostics/references/guidelines.md @@ -58,14 +58,14 @@ A complete diagnostic tells a story: ### Core Rules -| Rule | Example | -| --------------------------- | --------------------------------------------------------- | -| Start with lowercase | `"expected semicolon"` not `"Expected semicolon"` | -| No trailing punctuation | `"missing field"` not `"missing field."` | -| Use backticks for code | `"expected \`bool\`, found \`String\`"` | -| Use "invalid" not "illegal" | `"invalid identifier"` not `"illegal identifier"` | -| Be matter-of-fact | `"type mismatch"` not `"sorry, types don't match"` | -| Be specific | `"cannot find variable \`x\`"` not `"variable not found"` | +| Rule | Example | +| --------------------------- | ------------------------------------------------------- | +| Start with lowercase | `"expected semicolon"` not `"Expected semicolon"` | +| No trailing punctuation | `"missing field"` not `"missing field."` | +| Use backticks for code | `"expected \`bool\`, found \`String\`"` | +| Use "invalid" not "illegal" | `"invalid identifier"` not `"illegal identifier"` | +| Be matter-of-fact | `"type mismatch"` not `"sorry, types don't match"` | +| Be specific | `"cannot find variable \`x\`"`not`"variable not found"` | ### Good vs Bad Messages diff --git a/.claude/skills/writing-hashql-jexpr/SKILL.md b/.claude/skills/writing-hashql-jexpr/SKILL.md index 65a32434fbf..cac504ba09d 100644 --- a/.claude/skills/writing-hashql-jexpr/SKILL.md +++ b/.claude/skills/writing-hashql-jexpr/SKILL.md @@ -1,6 +1,6 @@ --- name: writing-hashql-jexpr -description: 'HashQL J-Expr syntax for writing queries. Use when writing J-Expr code, using #literal/#struct/#list constructs, understanding function call syntax, or working with HashQL query files (.jsonc).' +description: "HashQL J-Expr syntax for writing queries. Use when writing J-Expr code, using #literal/#struct/#list constructs, understanding function call syntax, or working with HashQL query files (.jsonc)." license: AGPL-3.0 metadata: triggers: @@ -29,11 +29,11 @@ J-Expr is a JSON-based expression syntax for HashQL. It represents typed express J-Expr has three expression types: -| JSON Type | J-Expr Meaning | -| --------- | -------------- | -| String | Path/identifier/symbol | -| Array | Function call | -| Object | Data constructor (with `#` keys) | +| JSON Type | J-Expr Meaning | +| --------- | -------------------------------- | +| String | Path/identifier/symbol | +| Array | Function call | +| Object | Data constructor (with `#` keys) | ## Paths (Strings) @@ -68,14 +68,14 @@ Arrays represent function calls: `[function, arg1, arg2, ...]` Objects with special `#` keys construct data: -| Key | Purpose | Example | -| --- | ------- | ------- | -| `#literal` | Primitive values | `{"#literal": 42}` | -| `#struct` | Named fields | `{"#struct": {"x": ...}}` | -| `#list` | Variable-size ordered | `{"#list": [...]}` | -| `#tuple` | Fixed-size ordered | `{"#tuple": [...]}` | -| `#dict` | Key-value map | `{"#dict": {"k": ...}}` | -| `#type` | Type annotation | Used with other keys | +| Key | Purpose | Example | +| ---------- | --------------------- | ------------------------- | +| `#literal` | Primitive values | `{"#literal": 42}` | +| `#struct` | Named fields | `{"#struct": {"x": ...}}` | +| `#list` | Variable-size ordered | `{"#list": [...]}` | +| `#tuple` | Fixed-size ordered | `{"#tuple": [...]}` | +| `#dict` | Key-value map | `{"#dict": {"k": ...}}` | +| `#type` | Type annotation | Used with other keys | ### Literals @@ -104,7 +104,7 @@ Objects with special `#` keys construct data: ### Dict ```jsonc -{"#dict": {"key": {"#literal": "value"}}} +{ "#dict": { "key": { "#literal": "value" } } } ``` ## Common Patterns @@ -112,7 +112,7 @@ Objects with special `#` keys construct data: ### Let Binding ```jsonc -["let", "varName", {"#literal": 10}, ["add", "varName", {"#literal": 5}]] +["let", "varName", { "#literal": 10 }, ["add", "varName", { "#literal": 5 }]] ``` ### Function Definition @@ -159,15 +159,23 @@ Objects with special `#` keys construct data: **Filtering with comparison:** ```jsonc -["filter", "entities", - ["fn", {"#tuple": []}, {"#struct": {"entity": "_"}}, "_", - ["==", "entity.draft_id", {"#literal": null}]]] +[ + "filter", + "entities", + [ + "fn", + { "#tuple": [] }, + { "#struct": { "entity": "_" } }, + "_", + ["==", "entity.draft_id", { "#literal": null }], + ], +] ``` **Struct with type:** ```jsonc -{"#struct": {"value": {"#literal": 100}}, "#type": "Amount"} +{ "#struct": { "value": { "#literal": 100 } }, "#type": "Amount" } ``` ## References diff --git a/.claude/skills/writing-hashql-jexpr/references/data-constructors.md b/.claude/skills/writing-hashql-jexpr/references/data-constructors.md index 0b46669f536..28b3c97752d 100644 --- a/.claude/skills/writing-hashql-jexpr/references/data-constructors.md +++ b/.claude/skills/writing-hashql-jexpr/references/data-constructors.md @@ -298,9 +298,17 @@ Empty tuple for type params, struct for named params: ### Entity Filtering ```jsonc -["filter", "entities", - ["fn", {"#tuple": []}, {"#struct": {"e": "_"}}, "_", - ["==", "e.archived", {"#literal": false}]]] +[ + "filter", + "entities", + [ + "fn", + { "#tuple": [] }, + { "#struct": { "e": "_" } }, + "_", + ["==", "e.archived", { "#literal": false }], + ], +] ``` ## Error Handling @@ -311,7 +319,7 @@ Only one primary `#` key allowed: ```jsonc // ✗ Error - duplicate primary key -{"#literal": 42, "#literal": 24} +{ "#literal": 42, "#literal": 24 } ``` ### Empty Object @@ -329,7 +337,7 @@ Regular keys not allowed in special form objects: ```jsonc // ✗ Error - unknown key -{"#literal": 42, "extra": "value"} +{ "#literal": 42, "extra": "value" } ``` ### Invalid Values diff --git a/.claude/skills/writing-hashql-jexpr/references/special-forms.md b/.claude/skills/writing-hashql-jexpr/references/special-forms.md index b941cf33508..d7d92370f05 100644 --- a/.claude/skills/writing-hashql-jexpr/references/special-forms.md +++ b/.claude/skills/writing-hashql-jexpr/references/special-forms.md @@ -6,18 +6,18 @@ Special forms are syntactic constructs with special evaluation semantics. Unlike HashQL has 10 special forms: -| Form | Arity | Purpose | -| ---- | ----- | ------- | -| `if` | 2, 3 | Conditional branching | -| `let` | 3, 4 | Variable binding | -| `fn` | 4 | Function/closure definition | -| `as` | 2 | Type assertion | -| `type` | 3 | Type alias definition | -| `newtype` | 3 | Nominal type wrapper | -| `use` | 3 | Module imports | -| `input` | 2, 3 | Host input declaration | -| `access` | 2 | Field access (alias: `.`) | -| `index` | 2 | Index access (alias: `[]`) | +| Form | Arity | Purpose | +| --------- | ----- | --------------------------- | +| `if` | 2, 3 | Conditional branching | +| `let` | 3, 4 | Variable binding | +| `fn` | 4 | Function/closure definition | +| `as` | 2 | Type assertion | +| `type` | 3 | Type alias definition | +| `newtype` | 3 | Nominal type wrapper | +| `use` | 3 | Module imports | +| `input` | 2, 3 | Host input declaration | +| `access` | 2 | Field access (alias: `.`) | +| `index` | 2 | Index access (alias: `[]`) | ## if - Conditional @@ -352,13 +352,13 @@ Accesses an element by index. Alias: `[]` Special forms bind names in different namespaces: -| Form | Value Namespace | Type Namespace | -| ---- | --------------- | -------------- | -| `let` | ✓ | - | -| `type` | - | ✓ | -| `newtype` | ✓ (constructor) | ✓ (type) | -| `use` | ✓ | ✓ | -| `fn` | ✓ (parameters) | ✓ (generics) | +| Form | Value Namespace | Type Namespace | +| --------- | --------------- | -------------- | +| `let` | ✓ | - | +| `type` | - | ✓ | +| `newtype` | ✓ (constructor) | ✓ (type) | +| `use` | ✓ | ✓ | +| `fn` | ✓ (parameters) | ✓ (generics) | ## Common Patterns @@ -368,15 +368,34 @@ Create sum types by combining newtypes with union types: ```jsonc // Define enum variants as newtypes -["newtype", "None", "Null", - ["newtype", "Some", "T", +[ + "newtype", + "None", + "Null", + [ + "newtype", + "Some", + "T", // Define the Option type as a union - ["type", "Option", "None | Some", + [ + "type", + "Option", + "None | Some", // Use the constructors - ["let", "value", ["Some", {"#literal": 42}], - ["if", ["==", "value", ["None"]], - {"#literal": "empty"}, - {"#literal": "has value"}]]]]] + [ + "let", + "value", + ["Some", { "#literal": 42 }], + [ + "if", + ["==", "value", ["None"]], + { "#literal": "empty" }, + { "#literal": "has value" }, + ], + ], + ], + ], +] ``` ### Status Enum Pattern @@ -392,27 +411,54 @@ Create sum types by combining newtypes with union types: ### Entity Query with Filter ```jsonc -["let", "entities", +[ + "let", + "entities", ["::graph::head::entities", ["::graph::tmp::decision_time_now"]], - ["filter", "entities", - ["fn", {"#tuple": []}, {"#struct": {"e": "_"}}, "_", - ["==", "e.archived", {"#literal": false}]]]] + [ + "filter", + "entities", + [ + "fn", + { "#tuple": [] }, + { "#struct": { "e": "_" } }, + "_", + ["==", "e.archived", { "#literal": false }], + ], + ], +] ``` ### Type-safe Input Processing ```jsonc -["let", "userId", ["input", "userId", "String"], - ["let", "limit", ["input", "limit", "Int", {"#literal": 50}], - ["fetch_user_items", "userId", "limit"]]] +[ + "let", + "userId", + ["input", "userId", "String"], + [ + "let", + "limit", + ["input", "limit", "Int", { "#literal": 50 }], + ["fetch_user_items", "userId", "limit"], + ], +] ``` ### Module Import Pattern ```jsonc -["use", "::graph::head", {"#struct": {"entities": "_"}}, - ["use", "::graph::tmp", {"#struct": {"decision_time_now": "_"}}, - ["entities", ["decision_time_now"]]]] +[ + "use", + "::graph::head", + { "#struct": { "entities": "_" } }, + [ + "use", + "::graph::tmp", + { "#struct": { "decision_time_now": "_" } }, + ["entities", ["decision_time_now"]], + ], +] ``` ## Error Handling @@ -425,7 +471,7 @@ Each special form has specific arity requirements: // ✗ Error - if needs 2 or 3 arguments ["if", "condition"] -// ✗ Error - let needs 3 or 4 arguments +// ✗ Error - let needs 3 or 4 arguments ["let", "x", {"#literal": 1}] // ✗ Error - fn needs exactly 4 arguments @@ -438,7 +484,7 @@ Special forms don't accept labeled arguments: ```jsonc // ✗ Error - labeled argument in special form -["if", {":condition": "x"}, "then", "else"] +["if", { ":condition": "x" }, "then", "else"] ``` ### Binding Name Errors diff --git a/.claude/skills/writing-hashql-jexpr/references/syntax-reference.md b/.claude/skills/writing-hashql-jexpr/references/syntax-reference.md index 6db056653c2..fe46198441b 100644 --- a/.claude/skills/writing-hashql-jexpr/references/syntax-reference.md +++ b/.claude/skills/writing-hashql-jexpr/references/syntax-reference.md @@ -6,11 +6,11 @@ Core syntax reference for J-Expr, the JSON expression syntax for HashQL. J-Expr maps JSON types to expression semantics: -| JSON Type | J-Expr Meaning | -| --------- | ---------------------------------- | -| String | Path/identifier | -| Array | Function call | -| Object | Data constructor (with `#` keys) | +| JSON Type | J-Expr Meaning | +| --------- | -------------------------------- | +| String | Path/identifier | +| Array | Function call | +| Object | Data constructor (with `#` keys) | ## Paths (String Expressions) @@ -73,9 +73,7 @@ Arrays represent function calls: `[function, arg1, arg2, ...]` ### Nested Calls ```jsonc -["add", - ["multiply", {"#literal": 2}, {"#literal": 3}], - {"#literal": 4}] +["add", ["multiply", { "#literal": 2 }, { "#literal": 3 }], { "#literal": 4 }] ``` ### Labeled Arguments @@ -85,13 +83,16 @@ Use `:` prefix for named/labeled arguments. **Object syntax:** ```jsonc -["greet", {":name": {"#literal": "Alice"}, ":greeting": {"#literal": "Hello"}}] +[ + "greet", + { ":name": { "#literal": "Alice" }, ":greeting": { "#literal": "Hello" } }, +] ``` **Shorthand string syntax:** ```jsonc -["func", ":varName"] // References variable "varName" as labeled argument +["func", ":varName"] // References variable "varName" as labeled argument ``` ## Operators @@ -135,9 +136,17 @@ Use `:` prefix for named/labeled arguments. ### Filtering ```jsonc -["filter", "entities", - ["fn", {"#tuple": []}, {"#struct": {"entity": "_"}}, "_", - ["==", "entity.draft_id", {"#literal": null}]]] +[ + "filter", + "entities", + [ + "fn", + { "#tuple": [] }, + { "#struct": { "entity": "_" } }, + "_", + ["==", "entity.draft_id", { "#literal": null }], + ], +] ``` ### Property Access @@ -154,31 +163,59 @@ Use dotted paths: ### Entity Query with Filter ```jsonc -["let", "entities", +[ + "let", + "entities", ["::graph::head::entities", ["::graph::tmp::decision_time_now"]], - ["filter", "entities", - ["fn", {"#tuple": []}, {"#struct": {"e": "_"}}, "_", - ["==", "e.archived", {"#literal": false}]]]] + [ + "filter", + "entities", + [ + "fn", + { "#tuple": [] }, + { "#struct": { "e": "_" } }, + "_", + ["==", "e.archived", { "#literal": false }], + ], + ], +] ``` ### Nested Conditional ```jsonc -["let", "value", {"#literal": 42}, - ["if", [">", "value", {"#literal": 0}], - ["if", ["<", "value", {"#literal": 100}], - {"#literal": "in range"}, - {"#literal": "too high"}], - {"#literal": "too low"}]] +[ + "let", + "value", + { "#literal": 42 }, + [ + "if", + [">", "value", { "#literal": 0 }], + [ + "if", + ["<", "value", { "#literal": 100 }], + { "#literal": "in range" }, + { "#literal": "too high" }, + ], + { "#literal": "too low" }, + ], +] ``` ### Multiple Variable Bindings ```jsonc -["let", "x", {"#literal": 1}, - ["let", "y", {"#literal": 2}, - ["let", "z", ["add", "x", "y"], - ["multiply", "z", {"#literal": 2}]]]] +[ + "let", + "x", + { "#literal": 1 }, + [ + "let", + "y", + { "#literal": 2 }, + ["let", "z", ["add", "x", "y"], ["multiply", "z", { "#literal": 2 }]], + ], +] ``` ## Related References diff --git a/.claude/skills/writing-hashql-jexpr/references/type-dsl.md b/.claude/skills/writing-hashql-jexpr/references/type-dsl.md index 22a3ffafa3c..55a953da56d 100644 --- a/.claude/skills/writing-hashql-jexpr/references/type-dsl.md +++ b/.claude/skills/writing-hashql-jexpr/references/type-dsl.md @@ -197,7 +197,9 @@ Whitespace is allowed around operators and inside structures: ### Complex Entity Types ```jsonc -{"#type": "(id: ID, attrs: (name: String, metadata: (created: Timestamp, modified: Timestamp | Null)))"} +{ + "#type": "(id: ID, attrs: (name: String, metadata: (created: Timestamp, modified: Timestamp | Null)))", +} ``` ### Union and Intersection @@ -237,7 +239,7 @@ Whitespace is allowed around operators and inside structures: Used within function definitions: ```jsonc -["fn", +["fn", {"#tuple": []}, // Type parameters (empty) {"#struct": {"x": "_"}}, // Parameter struct (inferred types) "_", // Return type (inferred) @@ -247,11 +249,13 @@ Used within function definitions: With explicit types: ```jsonc -["fn", - {"#tuple": []}, - {"#struct": {"x": "Int", "y": "Int"}}, // Explicit param types - "Int", // Explicit return type - ["add", "x", "y"]] +[ + "fn", + { "#tuple": [] }, + { "#struct": { "x": "Int", "y": "Int" } }, // Explicit param types + "Int", // Explicit return type + ["add", "x", "y"], +] ``` ## Error Cases @@ -267,7 +271,7 @@ With explicit types: ### Empty Generic Arguments ```jsonc -"Vec<>" // Error - empty generics +"Vec<>" // Error - empty generics ``` ### Missing Elements diff --git a/.config/_examples/vscode/extensions-frontend.json b/.config/_examples/vscode/extensions-frontend.json index a584a705210..30c0b998a82 100644 --- a/.config/_examples/vscode/extensions-frontend.json +++ b/.config/_examples/vscode/extensions-frontend.json @@ -9,6 +9,6 @@ "ms-playwright.playwright", "ms-vscode.vscode-typescript-next", "vitest.explorer", - "biomejs.biome" + "oxc.oxc-vscode" ] } diff --git a/.config/_examples/zed/settings.json b/.config/_examples/zed/settings.json index ed632c3b926..ac07ff67928 100644 --- a/.config/_examples/zed/settings.json +++ b/.config/_examples/zed/settings.json @@ -10,11 +10,11 @@ ] }, "auto_install_extensions": { - "biome": true + "oxc": true }, "formatter": { "language_server": { - "name": "biome" + "name": "oxc" } } } diff --git a/.config/agents/README.md b/.config/agents/README.md index 78ade3d96cc..47128f4b3b7 100644 --- a/.config/agents/README.md +++ b/.config/agents/README.md @@ -1,17 +1,14 @@ -Agent rules and symlinks -======================== +# Agent rules and symlinks This directory defines a single, canonical set of agent rules and then fans them out via symlinks into the various agent-specific locations used in this repo. -Source of truth ---------------- +## Source of truth - Canonical rule files live in: - `.config/agents/rules/*.md` - Each Markdown file in `rules/` represents one logical rule, where the **basename** (e.g. `foo.md` → `foo`) is used as the rule ID. -Frontmatter requirements ------------------------- +## Frontmatter requirements For compatibility across all consumers (Cursor, Augment, Claude, Cline, Windsurf, etc.), **all values in YAML frontmatter must be double-quoted strings**, even when plain YAML would allow unquoted values. @@ -44,8 +41,7 @@ status: experimental Some agents will mis-parse or ignore unquoted values, so always use double quotes. -Where rules are symlinked to ----------------------------- +## Where rules are symlinked to From the `rules/` directory, the `symlink-rules` script creates symlinks into these tool-specific locations: @@ -58,8 +54,7 @@ From the `rules/` directory, the `symlink-rules` script creates symlinks into th The content of each target file is a **symlink** back to the corresponding source file in `.config/agents/rules/`. -Running the sync script ------------------------ +## Running the sync script From the repo root, run: @@ -79,8 +74,7 @@ The script will: - If the expected target path is a **real file or directory**, mark that rule as **disqualified** for that target and skip it (nothing is deleted or overwritten). - For all non-disqualified rules, create a new relative symlink from the target path back to the source rule in `rules/`. -Editing rules -------------- +## Editing rules You can work with rules in two main ways: @@ -95,8 +89,7 @@ Implementation detail: the files in `.cursor/rules/`, `.augment/rules/`, `.claud If you manually create a real (non-symlink) file in a target location where the script expects to place a symlink, that rule will be marked as disqualified for that target and will no longer be auto-synced there. -Summary -------- +## Summary - Put all shared rule content in `.config/agents/rules/*.md`. - Always use **double-quoted YAML frontmatter values**. diff --git a/.config/agents/rules/ark-ui.md b/.config/agents/rules/ark-ui.md index 6752d13a5c3..20b3c58dd27 100644 --- a/.config/agents/rules/ark-ui.md +++ b/.config/agents/rules/ark-ui.md @@ -31,113 +31,113 @@ Headless component library providing accessible, unstyled React primitives for b ## Core Concepts -| Topic | URL | -| --- | --- | -| Getting Started | https://ark-ui.com/react/docs/overview/getting-started | -| Styling (data attributes) | https://ark-ui.com/react/docs/guides/styling | -| Composition (asChild) | https://ark-ui.com/react/docs/guides/composition | -| Component State | https://ark-ui.com/react/docs/guides/component-state | -| Animation | https://ark-ui.com/react/docs/guides/animation | -| Forms Integration | https://ark-ui.com/react/docs/guides/forms | -| Refs | https://ark-ui.com/react/docs/guides/ref | -| Closed Components | https://ark-ui.com/react/docs/guides/closed-components | +| Topic | URL | +| ------------------------- | ------------------------------------------------------ | +| Getting Started | https://ark-ui.com/react/docs/overview/getting-started | +| Styling (data attributes) | https://ark-ui.com/react/docs/guides/styling | +| Composition (asChild) | https://ark-ui.com/react/docs/guides/composition | +| Component State | https://ark-ui.com/react/docs/guides/component-state | +| Animation | https://ark-ui.com/react/docs/guides/animation | +| Forms Integration | https://ark-ui.com/react/docs/guides/forms | +| Refs | https://ark-ui.com/react/docs/guides/ref | +| Closed Components | https://ark-ui.com/react/docs/guides/closed-components | ## Components ### Form Inputs -| Component | URL | -| --- | --- | -| Checkbox | https://ark-ui.com/react/docs/components/checkbox | -| Combobox | https://ark-ui.com/react/docs/components/combobox | -| Color Picker | https://ark-ui.com/react/docs/components/color-picker | -| Date Picker | https://ark-ui.com/react/docs/components/date-picker | -| Editable | https://ark-ui.com/react/docs/components/editable | -| Field | https://ark-ui.com/react/docs/components/field | -| Fieldset | https://ark-ui.com/react/docs/components/fieldset | -| File Upload | https://ark-ui.com/react/docs/components/file-upload | -| Listbox | https://ark-ui.com/react/docs/components/listbox | -| Number Input | https://ark-ui.com/react/docs/components/number-input | +| Component | URL | +| -------------- | ------------------------------------------------------- | +| Checkbox | https://ark-ui.com/react/docs/components/checkbox | +| Combobox | https://ark-ui.com/react/docs/components/combobox | +| Color Picker | https://ark-ui.com/react/docs/components/color-picker | +| Date Picker | https://ark-ui.com/react/docs/components/date-picker | +| Editable | https://ark-ui.com/react/docs/components/editable | +| Field | https://ark-ui.com/react/docs/components/field | +| Fieldset | https://ark-ui.com/react/docs/components/fieldset | +| File Upload | https://ark-ui.com/react/docs/components/file-upload | +| Listbox | https://ark-ui.com/react/docs/components/listbox | +| Number Input | https://ark-ui.com/react/docs/components/number-input | | Password Input | https://ark-ui.com/react/docs/components/password-input | -| Pin Input | https://ark-ui.com/react/docs/components/pin-input | -| Radio Group | https://ark-ui.com/react/docs/components/radio-group | -| Select | https://ark-ui.com/react/docs/components/select | -| Signature Pad | https://ark-ui.com/react/docs/components/signature-pad | -| Slider | https://ark-ui.com/react/docs/components/slider | -| Switch | https://ark-ui.com/react/docs/components/switch | -| Tags Input | https://ark-ui.com/react/docs/components/tags-input | +| Pin Input | https://ark-ui.com/react/docs/components/pin-input | +| Radio Group | https://ark-ui.com/react/docs/components/radio-group | +| Select | https://ark-ui.com/react/docs/components/select | +| Signature Pad | https://ark-ui.com/react/docs/components/signature-pad | +| Slider | https://ark-ui.com/react/docs/components/slider | +| Switch | https://ark-ui.com/react/docs/components/switch | +| Tags Input | https://ark-ui.com/react/docs/components/tags-input | ### Overlays and Popups -| Component | URL | -| --- | --- | -| Dialog | https://ark-ui.com/react/docs/components/dialog | +| Component | URL | +| -------------- | ------------------------------------------------------- | +| Dialog | https://ark-ui.com/react/docs/components/dialog | | Floating Panel | https://ark-ui.com/react/docs/components/floating-panel | -| Hover Card | https://ark-ui.com/react/docs/components/hover-card | -| Menu | https://ark-ui.com/react/docs/components/menu | -| Popover | https://ark-ui.com/react/docs/components/popover | -| Toast | https://ark-ui.com/react/docs/components/toast | -| Tooltip | https://ark-ui.com/react/docs/components/tooltip | -| Tour | https://ark-ui.com/react/docs/components/tour | +| Hover Card | https://ark-ui.com/react/docs/components/hover-card | +| Menu | https://ark-ui.com/react/docs/components/menu | +| Popover | https://ark-ui.com/react/docs/components/popover | +| Toast | https://ark-ui.com/react/docs/components/toast | +| Tooltip | https://ark-ui.com/react/docs/components/tooltip | +| Tour | https://ark-ui.com/react/docs/components/tour | ### Layout and Navigation -| Component | URL | -| --- | --- | -| Accordion | https://ark-ui.com/react/docs/components/accordion | -| Carousel | https://ark-ui.com/react/docs/components/carousel | +| Component | URL | +| ----------- | ---------------------------------------------------- | +| Accordion | https://ark-ui.com/react/docs/components/accordion | +| Carousel | https://ark-ui.com/react/docs/components/carousel | | Collapsible | https://ark-ui.com/react/docs/components/collapsible | -| Pagination | https://ark-ui.com/react/docs/components/pagination | +| Pagination | https://ark-ui.com/react/docs/components/pagination | | Scroll Area | https://ark-ui.com/react/docs/components/scroll-area | -| Splitter | https://ark-ui.com/react/docs/components/splitter | -| Steps | https://ark-ui.com/react/docs/components/steps | -| Tabs | https://ark-ui.com/react/docs/components/tabs | -| Tree View | https://ark-ui.com/react/docs/components/tree-view | +| Splitter | https://ark-ui.com/react/docs/components/splitter | +| Steps | https://ark-ui.com/react/docs/components/steps | +| Tabs | https://ark-ui.com/react/docs/components/tabs | +| Tree View | https://ark-ui.com/react/docs/components/tree-view | ### Display and Feedback -| Component | URL | -| --- | --- | -| Avatar | https://ark-ui.com/react/docs/components/avatar | -| Clipboard | https://ark-ui.com/react/docs/components/clipboard | -| Marquee | https://ark-ui.com/react/docs/components/marquee | +| Component | URL | +| ----------------- | ---------------------------------------------------------- | +| Avatar | https://ark-ui.com/react/docs/components/avatar | +| Clipboard | https://ark-ui.com/react/docs/components/clipboard | +| Marquee | https://ark-ui.com/react/docs/components/marquee | | Progress Circular | https://ark-ui.com/react/docs/components/progress-circular | -| Progress Linear | https://ark-ui.com/react/docs/components/progress-linear | -| QR Code | https://ark-ui.com/react/docs/components/qr-code | -| Rating Group | https://ark-ui.com/react/docs/components/rating-group | -| Timer | https://ark-ui.com/react/docs/components/timer | +| Progress Linear | https://ark-ui.com/react/docs/components/progress-linear | +| QR Code | https://ark-ui.com/react/docs/components/qr-code | +| Rating Group | https://ark-ui.com/react/docs/components/rating-group | +| Timer | https://ark-ui.com/react/docs/components/timer | ### Selection and Toggle -| Component | URL | -| --- | --- | -| Angle Slider | https://ark-ui.com/react/docs/components/angle-slider | +| Component | URL | +| ------------- | ------------------------------------------------------ | +| Angle Slider | https://ark-ui.com/react/docs/components/angle-slider | | Segment Group | https://ark-ui.com/react/docs/components/segment-group | -| Toggle | https://ark-ui.com/react/docs/components/toggle | -| Toggle Group | https://ark-ui.com/react/docs/components/toggle-group | +| Toggle | https://ark-ui.com/react/docs/components/toggle | +| Toggle Group | https://ark-ui.com/react/docs/components/toggle-group | ## Collections -| Collection | URL | -| --- | --- | -| Async List | https://ark-ui.com/react/docs/collections/async-list | +| Collection | URL | +| --------------- | --------------------------------------------------------- | +| Async List | https://ark-ui.com/react/docs/collections/async-list | | List Collection | https://ark-ui.com/react/docs/collections/list-collection | -| List Selection | https://ark-ui.com/react/docs/collections/list-selection | +| List Selection | https://ark-ui.com/react/docs/collections/list-selection | | Tree Collection | https://ark-ui.com/react/docs/collections/tree-collection | ## Utilities -| Utility | URL | -| --- | --- | -| Client Only | https://ark-ui.com/react/docs/utilities/client-only | -| Download Trigger | https://ark-ui.com/react/docs/utilities/download-trigger | -| Environment | https://ark-ui.com/react/docs/utilities/environment | -| Focus Trap | https://ark-ui.com/react/docs/utilities/focus-trap | -| Format Byte | https://ark-ui.com/react/docs/utilities/format-byte | -| Format Number | https://ark-ui.com/react/docs/utilities/format-number | +| Utility | URL | +| -------------------- | ------------------------------------------------------------ | +| Client Only | https://ark-ui.com/react/docs/utilities/client-only | +| Download Trigger | https://ark-ui.com/react/docs/utilities/download-trigger | +| Environment | https://ark-ui.com/react/docs/utilities/environment | +| Focus Trap | https://ark-ui.com/react/docs/utilities/focus-trap | +| Format Byte | https://ark-ui.com/react/docs/utilities/format-byte | +| Format Number | https://ark-ui.com/react/docs/utilities/format-number | | Format Relative Time | https://ark-ui.com/react/docs/utilities/format-relative-time | -| Frame | https://ark-ui.com/react/docs/utilities/frame | -| Highlight | https://ark-ui.com/react/docs/utilities/highlight | -| JSON Tree View | https://ark-ui.com/react/docs/utilities/json-tree-view | -| Locale | https://ark-ui.com/react/docs/utilities/locale | -| Presence | https://ark-ui.com/react/docs/utilities/presence | +| Frame | https://ark-ui.com/react/docs/utilities/frame | +| Highlight | https://ark-ui.com/react/docs/utilities/highlight | +| JSON Tree View | https://ark-ui.com/react/docs/utilities/json-tree-view | +| Locale | https://ark-ui.com/react/docs/utilities/locale | +| Presence | https://ark-ui.com/react/docs/utilities/presence | diff --git a/.config/agents/rules/zod.md b/.config/agents/rules/zod.md index 39d732874e3..2b37ec932a2 100644 --- a/.config/agents/rules/zod.md +++ b/.config/agents/rules/zod.md @@ -32,23 +32,26 @@ Zod v4 stores metadata in registries (primarily `z.globalRegistry`). Use `.meta( ```typescript // ✅ Correct - .meta() at end of chain -z.string().min(1).max(100).meta({ description: "User's full name", label: "Name" }) +z.string() + .min(1) + .max(100) + .meta({ description: "User's full name", label: "Name" }); // ✅ Correct - .describe() shorthand for description only -z.string().email().describe("Primary email address") +z.string().email().describe("Primary email address"); // ❌ Wrong - metadata lost because .optional() creates new instance -z.string().meta({ description: "Lost!" }).optional() +z.string().meta({ description: "Lost!" }).optional(); ``` **Annotating object properties:** ```typescript const userSchema = z.object({ - email: z.string().email().meta({ + email: z.string().email().meta({ description: "Used for login", label: "Email Address", - placeholder: "you@example.com" + placeholder: "you@example.com", }), age: z.number().min(0).describe("User's age in years"), }); diff --git a/.config/mise/config.toml b/.config/mise/config.toml index eeeb8568437..293f4fa7e1f 100644 --- a/.config/mise/config.toml +++ b/.config/mise/config.toml @@ -15,24 +15,22 @@ cargo-binstall = "1.15.1" uv = "0.9.26" # Tools to compile the project -'cargo:wasm-opt' = "0.116.1" -"cargo:wasm-pack" = "0.13.1" -java = "25" -protoc = "32.1" - -# CLI tools -biome = "1.9.5-nightly.ff02a0b" "cargo:cargo-codspeed" = "4.1.0" "cargo:cargo-hack" = "0.6.37" "cargo:cargo-insta" = "1.43.1" "cargo:cargo-llvm-cov" = "0.6.18" "cargo:cargo-nextest" = "0.9.103" +'cargo:wasm-opt' = "0.116.1" +"cargo:wasm-pack" = "0.13.1" +java = "25" just = "1.43.1" markdownlint-cli2 = "0.19.1" "npm:@napi-rs/cli" = "2.18.4" "npm:@redocly/cli" = "2.19.2" "npm:renovate" = "42.39.1" +oxfmt = "0.49.0" "pipx:sqlfluff" = "3.4.2" +protoc = "32.1" sentry-cli = "2.52.0" taplo = "0.10.0" "ubi:terrastruct/d2" = "0.7.1" diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e87fd02cf8d..e506b6ee7c4 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -229,7 +229,7 @@ These apply across all projects: - **Once you have receive a pull request review, please bear the following in mind:** - reviewers may make suggestions for _optional_ changes which are not required to get your code merged. It should be obvious which suggestions are optional, and which are required changes. If it is not obvious, ask for clarification. - please do not resolve comment threads unless you opened them - leave it to the person who raised a comment to decide if any further discussion is required (GitHub will also automatically resolve any code suggestions you click 'commit' on). Comment threads may also be left open so that they can be linked to later. -- **We perform automated linting and formatting checks on pull requests using GitHub Actions.** As part of our Continuous Integration (CI) setup, when a pull request is created or updated, GitHub Actions will run a series of checks. This includes running `ESLint`, `TSC`, `Biome`, `Markdownlint`, `rustfmt`, and a few other tools. Some checks may be skipped depending on the files that have been changed in the pull request. First-time contributors need to wait for a HASH maintainer to manually launch CI checks. +- **We perform automated linting and formatting checks on pull requests using GitHub Actions.** As part of our Continuous Integration (CI) setup, when a pull request is created or updated, GitHub Actions will run a series of checks. This includes running `ESLint`, `TSC`, `Oxfmt`, `Markdownlint`, `rustfmt`, and a few other tools. Some checks may be skipped depending on the files that have been changed in the pull request. First-time contributors need to wait for a HASH maintainer to manually launch CI checks. ### How can I find interesting PRs to work on? diff --git a/.github/actions/clean-up-disk/action.yml b/.github/actions/clean-up-disk/action.yml index f3325b8c629..0030ac6717c 100644 --- a/.github/actions/clean-up-disk/action.yml +++ b/.github/actions/clean-up-disk/action.yml @@ -56,7 +56,6 @@ runs: sudo apt-get autoclean -y echo - - name: Check disk space after cleanup shell: bash run: df -h diff --git a/.github/actions/prune-repository/action.yml b/.github/actions/prune-repository/action.yml index 60302a48942..c3eb46ed7c9 100644 --- a/.github/actions/prune-repository/action.yml +++ b/.github/actions/prune-repository/action.yml @@ -17,7 +17,7 @@ runs: - name: Copy required files shell: bash run: | - cp -R Cargo.toml Cargo.lock rust-toolchain.toml biome.jsonc out/ + cp -R Cargo.toml Cargo.lock rust-toolchain.toml oxfmt.config.ts out/ # Globs are fun, especially in Bash. Covers all dot-files except `.`, `..`, and `.git`. shopt -s extglob diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 53fb2de71ec..5deee6bf03d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -270,18 +270,6 @@ jobs: exit 1 fi - - name: Run yarn lint:package-json - if: ${{ success() || failure() }} - run: | - if ! yarn lint:package-json; then - echo '' - echo '' - echo 'ℹ️ ℹ️ ℹ️' - echo 'Try running `yarn fix:package-json` locally to apply autofixes.' - echo 'ℹ️ ℹ️ ℹ️' - exit 1 - fi - - name: Validate Claude Code skills if: ${{ success() || failure() }} run: | diff --git a/.lefthook.yml b/.lefthook.yml index e4098113472..f5dcdb9b442 100644 --- a/.lefthook.yml +++ b/.lefthook.yml @@ -11,15 +11,15 @@ pre-commit: glob: "*.md" run: markdownlint-cli2 --fix --no-globs {staged_files} || true stage_fixed: true - biome: + oxfmt: tags: [frontend, style] glob: "*.{cjs,css,js,json,md,mdx,mjs,scss,ts,tsx,yml}" - run: biome format --write --staged || true + run: oxfmt --write {staged_files} || true stage_fixed: true yarn: tags: [frontend, style] glob: "{*/package.json, package.json}" - run: yarn fix:constraints && yarn fix:yarn-deduplicate && yarn fix:package-json {staged_files} + run: yarn fix:constraints && yarn fix:yarn-deduplicate stage_fixed: true sqlfluff: tags: [backend, style] diff --git a/.markdownlint-cli2.jsonc b/.markdownlint-cli2.jsonc index 80b13ad117c..7b8c264cd37 100644 --- a/.markdownlint-cli2.jsonc +++ b/.markdownlint-cli2.jsonc @@ -21,7 +21,8 @@ "ol-prefix": { "style": "ordered" }, - "single-title": false + "single-title": false, + "table-column-style": false }, "gitignore": true, "globs": ["*.md", "**/*.md", "**/*.mdc"], diff --git a/AGENTS.md b/AGENTS.md index 62096cc9c5a..0b36b5f5471 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,7 +84,7 @@ For Rust packages, you can add features as needed with `--all-features`, specifi CRITICAL: For the files referenced below, use your Read tool to load it on a need-to-know basis, ONLY when relevant to the SPECIFIC task at hand: -- .config/agents/rules/*.md +- .config/agents/rules/\*.md Instructions: diff --git a/CITATION.cff b/CITATION.cff index 5c038b7b234..aa688ca096c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,13 +1,13 @@ cff-version: 1.2.0 title: HASH type: software -url: 'https://hash.ai/' -repository-code: 'https://github.com/hashintel/hash' +url: "https://hash.ai/" +repository-code: "https://github.com/hashintel/hash" authors: - given-names: Dei family-names: Vilkinsons affiliation: HASH - orcid: 'https://orcid.org/0000-0001-5348-3913' + orcid: "https://orcid.org/0000-0001-5348-3913" - given-names: Ciaran family-names: Morinan affiliation: HASH @@ -15,7 +15,7 @@ authors: family-names: Diekmann affiliation: HASH - name: HASH - website: 'https://hash.ai/' + website: "https://hash.ai/" email: team@hash.ai abstract: >- HASH is an open, multi-tenant type system and @@ -26,4 +26,4 @@ keywords: - graph database - artificial intelligence - world model -message: 'If you this software, please cite it using this metadata.' \ No newline at end of file +message: "If you this software, please cite it using this metadata." diff --git a/LICENSE.md b/LICENSE.md index 14759c832e7..8b1e75f699f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -8,6 +8,7 @@ # License The vast majority of the HASH monorepo contains **open-source code** variously licensed under either: + - the [MIT License] and [Apache License 2.0] dually (default); or - the [GNU Affero General Public License 3.0]. diff --git a/README.md b/README.md index c11f27c97c7..d9153904783 100644 --- a/README.md +++ b/README.md @@ -168,11 +168,10 @@ When you first create an account you may be placed on a waitlist. To jump the qu 9. Log in When the HASH API is started, three users are automatically seeded for development purposes. Their passwords are all `password`. - - `alice@example.com`, `bob@example.com` – regular users - `admin@example.com` – an admin - - Note: seeding only runs when `NODE_ENV=development`, start the Graph API separately using `yarn start:graph` then launch the app using `yarn dev` in a separate terminal to start it in development environment. + +Note: seeding only runs when `NODE_ENV=development`, start the Graph API separately using `yarn start:graph` then launch the app using `yarn dev` in a separate terminal to start it in development environment. ##### Running the browser plugin diff --git a/apps/hash-ai-worker-ts/README.md b/apps/hash-ai-worker-ts/README.md index dcf4c17ad8e..8fe975e1ed6 100644 --- a/apps/hash-ai-worker-ts/README.md +++ b/apps/hash-ai-worker-ts/README.md @@ -18,7 +18,7 @@ The service uses the following environment variables: - `INTERNAL_API_KEY`: The API key used to authenticate with the internal API, required for workflows making use of the `getWebSearchResultsActivity` activity - `HASH_VAULT_HOST`: The host address (including protocol) that the Vault server is running on, e.g. `http://127.0.0.1` - `HASH_VAULT_PORT`: The port that the Vault server is running on, e.g. `8200` -- `HASH_VAULT_ROOT_TOKEN`: The token to authenticate with the Vault server. If not present, login via AWS IAM is attempted instead. +- `HASH_VAULT_ROOT_TOKEN`: The token to authenticate with the Vault server. If not present, login via AWS IAM is attempted instead. - `HASH_VAULT_MOUNT_PATH`: The mount path for the KV secrets engine, e.g. `secret`. - `GOOGLE_CLOUD_HASH_PROJECT_ID`: The projectId for a Google Cloud Platform project, used in document analysis (Vertex AI and Cloud Storage). Note that this is the Project ID, _not_ the Project Number. - `GOOGLE_CLOUD_STORAGE_BUCKET`: The name of the Google Cloud Storage bucket to use for document analysis. diff --git a/apps/hash-ai-worker-ts/docker/Dockerfile b/apps/hash-ai-worker-ts/docker/Dockerfile index 8f5e900799a..42935fd9788 100644 --- a/apps/hash-ai-worker-ts/docker/Dockerfile +++ b/apps/hash-ai-worker-ts/docker/Dockerfile @@ -75,7 +75,7 @@ RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ apt-get install -y --no-install-recommends build-essential && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ - mise install node npm:turbo java biome npm:@redocly/cli cargo-binstall cargo:wasm-pack cargo:wasm-opt protoc && \ + mise install node npm:turbo java oxfmt npm:@redocly/cli cargo-binstall cargo:wasm-pack cargo:wasm-opt protoc && \ yarn install --immutable && \ yarn cache clean diff --git a/apps/hash-ai-worker-ts/scripts/bundle-workflow-code.ts b/apps/hash-ai-worker-ts/scripts/bundle-workflow-code.ts index 9cf2a65542c..df95d5c8b75 100644 --- a/apps/hash-ai-worker-ts/scripts/bundle-workflow-code.ts +++ b/apps/hash-ai-worker-ts/scripts/bundle-workflow-code.ts @@ -14,17 +14,13 @@ async function bundle() { const { code } = await bundleWorkflowCode({ workflowsPath: require.resolve("../src/workflows"), workflowInterceptorModules: [ - require.resolve( - "@local/hash-backend-utils/temporal/interceptors/workflows/sentry", - ), + require.resolve("@local/hash-backend-utils/temporal/interceptors/workflows/sentry"), // OTEL workflow interceptor must be in the bundle: when the // worker boots with `workflowBundle`, the `interceptors.workflowModules` // option on `Worker.create` is ignored. The interceptor is a no-op // when no global TracerProvider is registered, so it's safe to // include unconditionally. - require.resolve( - "@local/hash-backend-utils/temporal/interceptors/workflows/opentelemetry", - ), + require.resolve("@local/hash-backend-utils/temporal/interceptors/workflows/opentelemetry"), ], }); const codePath = path.join(__dirname, "../dist/workflow-bundle.js"); diff --git a/apps/hash-ai-worker-ts/scripts/compare-llm-response.ts b/apps/hash-ai-worker-ts/scripts/compare-llm-response.ts index fd9245af312..1d60e7e67bc 100644 --- a/apps/hash-ai-worker-ts/scripts/compare-llm-response.ts +++ b/apps/hash-ai-worker-ts/scripts/compare-llm-response.ts @@ -2,16 +2,16 @@ import { mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { WebId } from "@blockprotocol/type-system"; - import { getLlmResponse } from "../src/activities/shared/get-llm-response.js"; +import { graphApiClient } from "../src/activities/shared/graph-api-client.js"; +import { getAliceUserAccountId } from "../src/shared/testing-utilities/get-alice-user-account-id.js"; + import type { LlmParams, LlmResponse, } from "../src/activities/shared/get-llm-response/types.js"; -import { graphApiClient } from "../src/activities/shared/graph-api-client.js"; -import { getAliceUserAccountId } from "../src/shared/testing-utilities/get-alice-user-account-id.js"; import type { CompareLlmResponseConfig } from "./compare-llm-response/types.js"; +import type { WebId } from "@blockprotocol/type-system"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/apps/hash-ai-worker-ts/scripts/compare-llm-response/types.ts b/apps/hash-ai-worker-ts/scripts/compare-llm-response/types.ts index e05033b2e4b..ea9ac523de8 100644 --- a/apps/hash-ai-worker-ts/scripts/compare-llm-response/types.ts +++ b/apps/hash-ai-worker-ts/scripts/compare-llm-response/types.ts @@ -1,11 +1,10 @@ -import type { ActorEntityUuid } from "@blockprotocol/type-system"; - import type { AnthropicLlmParams, GoogleAiParams, LlmParams, OpenAiLlmParams, } from "../../src/activities/shared/get-llm-response/types.js"; +import type { ActorEntityUuid } from "@blockprotocol/type-system"; export type CompareLlmResponseConfig = { models: LlmParams["model"][]; diff --git a/apps/hash-ai-worker-ts/scripts/sanitize-html.ts b/apps/hash-ai-worker-ts/scripts/sanitize-html.ts index e9019abc997..3f3b92b9436 100644 --- a/apps/hash-ai-worker-ts/scripts/sanitize-html.ts +++ b/apps/hash-ai-worker-ts/scripts/sanitize-html.ts @@ -2,10 +2,10 @@ import { mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { Url } from "@blockprotocol/type-system"; - import { getWebPageActivity } from "../src/activities/get-web-page-activity.js"; +import type { Url } from "@blockprotocol/type-system"; + /** * @file a script which fetches a web page and sanitizes its HTML content for LLM consumption, * in the same way as is done when passing HTML to LLMs in flows, saving the sanitized HTML to a file. diff --git a/apps/hash-ai-worker-ts/src/activities.ts b/apps/hash-ai-worker-ts/src/activities.ts index 5839c309808..65091c692e2 100644 --- a/apps/hash-ai-worker-ts/src/activities.ts +++ b/apps/hash-ai-worker-ts/src/activities.ts @@ -1,24 +1,5 @@ import { getPropertyTypes } from "@blockprotocol/graph/stdlib"; -import type { - ActorEntityUuid, - BaseUrl, - DataTypeWithMetadata, - EntityId, - EntityTypeWithMetadata, - PropertyObject, - PropertyTypeWithMetadata, - VersionedUrl, -} from "@blockprotocol/type-system"; import { extractBaseUrl } from "@blockprotocol/type-system"; -import type { - Embedding, - EntityEmbedding, - GraphApi, -} from "@local/hash-graph-client"; -import type { - CreateEmbeddingsParams, - CreateEmbeddingsReturn, -} from "@local/hash-graph-sdk/embeddings"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { queryEntityTypeSubgraph } from "@local/hash-graph-sdk/entity-type"; import { @@ -26,8 +7,6 @@ import { generateEntityIdFilter, } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; -import type { OpenAI } from "openai"; import { getAiAssistantAccountIdActivity } from "./activities/get-ai-assistant-account-id-activity.js"; import { getDereferencedEntityTypesActivity } from "./activities/get-dereferenced-entity-types-activity.js"; @@ -43,6 +22,28 @@ import { createPropertyTypeEmbeddings, } from "./activities/shared/embeddings.js"; +import type { + ActorEntityUuid, + BaseUrl, + DataTypeWithMetadata, + EntityId, + EntityTypeWithMetadata, + PropertyObject, + PropertyTypeWithMetadata, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { + Embedding, + EntityEmbedding, + GraphApi, +} from "@local/hash-graph-client"; +import type { + CreateEmbeddingsParams, + CreateEmbeddingsReturn, +} from "@local/hash-graph-sdk/embeddings"; +import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; +import type { OpenAI } from "openai"; + export { createGraphActivities } from "./activities/graph.js"; export const createAiActivities = ({ diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities.ts index 1c7fc4b63da..1f0b2f6c381 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities.ts @@ -1,7 +1,3 @@ -import type { CreateFlowActivities } from "@local/hash-backend-utils/flows"; -import type { VaultClient } from "@local/hash-backend-utils/vault"; -import type { AiFlowActionDefinitionId } from "@local/hash-isomorphic-utils/flows/action-definitions"; - import { answerQuestionAction } from "./flow-activities/answer-question-action.js"; import { generateFlowRunName } from "./flow-activities/generate-flow-run-name-activity.js"; import { generateWebQueriesAction } from "./flow-activities/generate-web-queries-action.js"; @@ -17,6 +13,10 @@ import { researchEntitiesAction } from "./flow-activities/research-entities-acti import { webSearchAction } from "./flow-activities/web-search-action.js"; import { writeGoogleSheetAction } from "./flow-activities/write-google-sheet-action.js"; +import type { CreateFlowActivities } from "@local/hash-backend-utils/flows"; +import type { VaultClient } from "@local/hash-backend-utils/vault"; +import type { AiFlowActionDefinitionId } from "@local/hash-isomorphic-utils/flows/action-definitions"; + export const createFlowActionActivities: CreateFlowActivities< AiFlowActionDefinitionId > = ({ vaultClient }: { vaultClient: VaultClient }) => ({ diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts index df6cc1fdd95..ce691f2d251 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts @@ -1,25 +1,21 @@ +import { Context } from "@temporalio/activity"; +import dedent from "dedent"; +import { CodeInterpreter, Sandbox } from "e2b"; + import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { getStorageProvider, resolvePayloadValue, } from "@local/hash-backend-utils/flows/payload-storage"; import { getSimpleGraph } from "@local/hash-backend-utils/simplified-graph"; import { queryEntitySubgraph } from "@local/hash-graph-sdk/entity"; -import type { AiActionStepOutput } from "@local/hash-isomorphic-utils/flows/action-definitions"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { FormattedText } from "@local/hash-isomorphic-utils/flows/types"; import { textFormats } from "@local/hash-isomorphic-utils/flows/types"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; -import type { Status } from "@local/status"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; -import dedent from "dedent"; -import { CodeInterpreter, Sandbox } from "e2b"; -import type { OpenAI } from "openai"; import { logger } from "../shared/activity-logger.js"; import { getFlowContext } from "../shared/get-flow-context.js"; @@ -29,11 +25,17 @@ import { mapLlmMessageToOpenAiMessages, mapOpenAiMessagesToLlmMessages, } from "../shared/get-llm-response/llm-message.js"; -import type { LlmToolDefinition } from "../shared/get-llm-response/types.js"; import { graphApiClient } from "../shared/graph-api-client.js"; import { mapActionInputEntitiesToEntities } from "../shared/map-action-input-entities-to-entities.js"; import { openAiSeed } from "../shared/open-ai-seed.js"; + +import type { LlmToolDefinition } from "../shared/get-llm-response/types.js"; import type { PermittedOpenAiModel } from "../shared/openai-client.js"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { AiActionStepOutput } from "@local/hash-isomorphic-utils/flows/action-definitions"; +import type { FormattedText } from "@local/hash-isomorphic-utils/flows/types"; +import type { Status } from "@local/status"; +import type { OpenAI } from "openai"; const answerTools: LlmToolDefinition[] = [ { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-flow-run-name-activity.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-flow-run-name-activity.ts index 95ddad44736..8b146f1b2ce 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-flow-run-name-activity.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-flow-run-name-activity.ts @@ -2,12 +2,19 @@ import { automaticBrowserInferenceFlowDefinition, manualBrowserInferenceFlowDefinition, } from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-definitions"; +import { goalFlowDefinitionIds } from "@local/hash-isomorphic-utils/flows/goal-flow-definitions"; + +import { getFlowContext } from "../shared/get-flow-context.js"; +import { getLlmResponse } from "../shared/get-llm-response.js"; +import { getTextContentFromLlmMessage } from "../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../shared/graph-api-client.js"; + +import type { UsageTrackingParams } from "../shared/get-llm-response.js"; import type { AutomaticInferenceTriggerInputName, ManualInferenceTriggerInputName, } from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-types"; import type { GoalFlowTriggerInput } from "@local/hash-isomorphic-utils/flows/goal-flow-definitions"; -import { goalFlowDefinitionIds } from "@local/hash-isomorphic-utils/flows/goal-flow-definitions"; import type { FlowActionDefinitionId, FlowDefinition, @@ -16,12 +23,6 @@ import type { PayloadKindValues, } from "@local/hash-isomorphic-utils/flows/types"; -import { getFlowContext } from "../shared/get-flow-context.js"; -import type { UsageTrackingParams } from "../shared/get-llm-response.js"; -import { getLlmResponse } from "../shared/get-llm-response.js"; -import { getTextContentFromLlmMessage } from "../shared/get-llm-response/llm-message.js"; -import { graphApiClient } from "../shared/graph-api-client.js"; - type GenerateFlowRunNameActivityParams = { flowDefinition: FlowDefinition; flowTrigger: FlowTrigger; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-web-queries-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-web-queries-action.ts index 2ebc05917c9..40f80e9c5ac 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-web-queries-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/generate-web-queries-action.ts @@ -1,16 +1,18 @@ -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import dedent from "dedent"; + import { isInferenceModelName } from "@local/hash-isomorphic-utils/ai-inference-types"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; import { StatusCode } from "@local/status"; -import dedent from "dedent"; import { getFlowContext } from "../shared/get-flow-context.js"; import { getLlmResponse } from "../shared/get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "../shared/get-llm-response/llm-message.js"; -import type { LlmToolDefinition } from "../shared/get-llm-response/types.js"; import { graphApiClient } from "../shared/graph-api-client.js"; import { inferenceModelAliasToSpecificModel } from "../shared/inference-model-alias-to-llm-model.js"; +import type { LlmToolDefinition } from "../shared/get-llm-response/types.js"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; + const webQueriesSystemPrompt = dedent(` You are a Web Search Assistant. The user provides you with a text prompt, from which you create one or more queries diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-file-from-url-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-file-from-url-action.ts index 1be382b6b01..7214a93544c 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-file-from-url-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-file-from-url-action.ts @@ -1,11 +1,13 @@ -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import { Context } from "@temporalio/activity"; + import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; import { logProgress } from "../shared/log-progress.js"; import { createFileEntityFromUrl } from "./shared/create-file-entity-from-url.js"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; + export const getFileFromUrlAction: AiFlowActionActivity< "getFileFromUrl" > = async ({ inputs }) => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-by-url-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-by-url-action.ts index 835d04cb3df..8825ef3943b 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-by-url-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-by-url-action.ts @@ -1,10 +1,11 @@ -import type { Url } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; import { StatusCode } from "@local/status"; import { getWebPageActivity } from "../get-web-page-activity.js"; +import type { Url } from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; + export const getWebPageByUrlAction: AiFlowActionActivity< "getWebPageByUrl" > = async ({ inputs }) => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ai.test.ts index c6ee9547372..23cc441661d 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ai.test.ts @@ -1,12 +1,13 @@ import "../../shared/testing-utilities/mock-get-flow-context.js"; +import { expect, test } from "vitest"; -import type { InputNameForAiFlowAction } from "@local/hash-isomorphic-utils/flows/action-definitions"; import { actionDefinitions } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { StepInput } from "@local/hash-isomorphic-utils/flows/types"; -import { expect, test } from "vitest"; import { getWebPageSummaryAction } from "./get-web-page-summary-action.js"; +import type { InputNameForAiFlowAction } from "@local/hash-isomorphic-utils/flows/action-definitions"; +import type { StepInput } from "@local/hash-isomorphic-utils/flows/types"; + test( "Test getWebPageSummaryAction", async () => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ts index 17064aa2985..0f0b5cfa2e4 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/get-web-page-summary-action.ts @@ -1,9 +1,8 @@ -import type { Url } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import dedent from "dedent"; + import { isInferenceModelName } from "@local/hash-isomorphic-utils/ai-inference-types"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; import { StatusCode } from "@local/status"; -import dedent from "dedent"; import { getWebPageActivity } from "../get-web-page-activity.js"; import { getFlowContext } from "../shared/get-flow-context.js"; @@ -12,6 +11,9 @@ import { getTextContentFromLlmMessage } from "../shared/get-llm-response/llm-mes import { graphApiClient } from "../shared/graph-api-client.js"; import { inferenceModelAliasToSpecificModel } from "../shared/inference-model-alias-to-llm-model.js"; +import type { Url } from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; + const generateSummarizeWebPageSystemPrompt = (params: { numberOfSentences: number; }): string => diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-entities-from-content-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-entities-from-content-action.ts index fd06288f415..85b36e0bda2 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-entities-from-content-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-entities-from-content-action.ts @@ -1,39 +1,40 @@ -import type { - EntityId, - EntityUuid, - OriginProvenance, - PropertyObjectMetadata, - SourceProvenance, - VersionedUrl, -} from "@blockprotocol/type-system"; import { currentTimestamp, entityIdFromComponents, } from "@blockprotocol/type-system"; import { typedKeys } from "@local/advanced-types/typed-entries"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { getStorageProvider, storePayload, } from "@local/hash-backend-utils/flows/payload-storage"; import { isInferenceModelName } from "@local/hash-isomorphic-utils/ai-inference-types"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { StatusCode } from "@local/status"; import { getAiAssistantAccountIdActivity } from "../get-ai-assistant-account-id-activity.js"; import { getDereferencedEntityTypesActivity } from "../get-dereferenced-entity-types-activity.js"; -import type { - DereferencedEntityTypesByTypeId, - InferenceState, -} from "../infer-entities/inference-types.js"; import { inferEntitiesFromWebPageActivity } from "../infer-entities-from-web-page-activity.js"; import { getFlowContext } from "../shared/get-flow-context.js"; import { graphApiClient } from "../shared/graph-api-client.js"; import { inferenceModelAliasToSpecificModel } from "../shared/inference-model-alias-to-llm-model.js"; import { isPermittedOpenAiModel } from "../shared/openai-client.js"; +import type { + DereferencedEntityTypesByTypeId, + InferenceState, +} from "../infer-entities/inference-types.js"; +import type { + EntityId, + EntityUuid, + OriginProvenance, + PropertyObjectMetadata, + SourceProvenance, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; + export const inferEntitiesFromContentAction: AiFlowActionActivity< "inferEntitiesFromContent" > = async ({ inputs }) => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action.ts index 511480e7f9c..e173e011076 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action.ts @@ -1,28 +1,17 @@ -import type { - OriginProvenance, - PropertyProvenance, - ProvidedEntityEditionProvenance, - SourceProvenance, - Url, -} from "@blockprotocol/type-system"; +import { Context } from "@temporalio/activity"; +import PDFParser from "pdf2json"; + import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { getStorageProvider, storePayload, } from "@local/hash-backend-utils/flows/payload-storage"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { PersistedEntityMetadata } from "@local/hash-isomorphic-utils/flows/types"; import { blockProtocolPropertyTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; -import type { Output } from "pdf2json"; -import PDFParser from "pdf2json"; import { getAiAssistantAccountIdActivity } from "../get-ai-assistant-account-id-activity.js"; import { createInferredEntityNotification } from "../shared/create-inferred-entity-notification.js"; @@ -35,6 +24,19 @@ import { generateDocumentPropertyPatches } from "./infer-metadata-from-document- import { generateDocumentProposedEntitiesAndCreateClaims } from "./infer-metadata-from-document-action/generate-proposed-entities-and-claims.js"; import { getLlmAnalysisOfDoc } from "./infer-metadata-from-document-action/get-llm-analysis-of-doc.js"; +import type { + OriginProvenance, + PropertyProvenance, + ProvidedEntityEditionProvenance, + SourceProvenance, + Url, +} from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { PersistedEntityMetadata } from "@local/hash-isomorphic-utils/flows/types"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { Output } from "pdf2json"; + const isFileEntity = (entity: HashEntity): entity is HashEntity => systemPropertyTypes.fileStorageKey.propertyTypeBaseUrl in entity.properties && blockProtocolPropertyTypes.fileUrl.propertyTypeBaseUrl in entity.properties; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/generate-proposed-entities-and-claims.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/generate-proposed-entities-and-claims.ts index c6159f2eeb7..adc1638e314 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/generate-proposed-entities-and-claims.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/generate-proposed-entities-and-claims.ts @@ -1,3 +1,20 @@ +import { Context } from "@temporalio/activity"; + +import { entityIdFromComponents } from "@blockprotocol/type-system"; +import { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; +import { + blockProtocolPropertyTypes, + systemDataTypes, + systemEntityTypes, + systemLinkEntityTypes, +} from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { getFlowContext } from "../../shared/get-flow-context.js"; +import { graphApiClient } from "../../shared/graph-api-client.js"; +import { logProgress } from "../../shared/log-progress.js"; + +import type { DocumentData } from "./get-llm-analysis-of-doc.js"; import type { ActorEntityUuid, EntityId, @@ -7,16 +24,7 @@ import type { ProvidedEntityEditionProvenance, WebId, } from "@blockprotocol/type-system"; -import { entityIdFromComponents } from "@blockprotocol/type-system"; -import { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { - blockProtocolPropertyTypes, - systemDataTypes, - systemEntityTypes, - systemLinkEntityTypes, -} from "@local/hash-isomorphic-utils/ontology-type-ids"; import type { Claim as ClaimEntity, HasObject, @@ -27,12 +35,6 @@ import type { PersonProperties, TextDataTypeMetadata, } from "@local/hash-isomorphic-utils/system-types/shared"; -import { Context } from "@temporalio/activity"; - -import { getFlowContext } from "../../shared/get-flow-context.js"; -import { graphApiClient } from "../../shared/graph-api-client.js"; -import { logProgress } from "../../shared/log-progress.js"; -import type { DocumentData } from "./get-llm-analysis-of-doc.js"; const createClaim = async ({ claimText, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/get-llm-analysis-of-doc.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/get-llm-analysis-of-doc.ts index cbe9a332427..7a522130761 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/get-llm-analysis-of-doc.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/infer-metadata-from-document-action/get-llm-analysis-of-doc.ts @@ -1,16 +1,11 @@ -import { getEntityTypes } from "@blockprotocol/graph/stdlib"; -import type { - EntityId, - PropertyObjectWithMetadata, - PropertyProvenance, - PropertyValue, - PropertyWithMetadata, - Url, - VersionedUrl, -} from "@blockprotocol/type-system"; import { SchemaType } from "@google-cloud/vertexai"; +import dedent from "dedent"; +import get from "lodash/get.js"; +import set from "lodash/set.js"; +import unset from "lodash/unset.js"; + +import { getEntityTypes } from "@blockprotocol/graph/stdlib"; import { sleep } from "@local/hash-backend-utils/utils"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { queryEntityTypeSubgraph } from "@local/hash-graph-sdk/entity-type"; import { almostFullOntologyResolveDepths, @@ -18,11 +13,6 @@ import { } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; -import dedent from "dedent"; -import get from "lodash/get.js"; -import set from "lodash/set.js"; -import unset from "lodash/unset.js"; import { logger } from "../../shared/activity-logger.js"; import { @@ -39,12 +29,24 @@ import { type LlmMessageTextContent, type LlmUserMessage, } from "../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../shared/graph-api-client.js"; +import { judgeAiOutputs } from "../../shared/judge-ai-outputs.js"; + import type { LlmParams, LlmToolDefinition, } from "../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../shared/graph-api-client.js"; -import { judgeAiOutputs } from "../../shared/judge-ai-outputs.js"; +import type { + EntityId, + PropertyObjectWithMetadata, + PropertyProvenance, + PropertyValue, + PropertyWithMetadata, + Url, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; const generateOutputSchema = ( dereferencedDocEntityTypes: DereferencedEntityType[], diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entities-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entities-action.ts index 2db60d0a22d..03b70558a48 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entities-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entities-action.ts @@ -1,5 +1,5 @@ -import type { EntityId } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import { Context } from "@temporalio/activity"; + import { getStorageProvider, resolvePayloadValue, @@ -7,16 +7,18 @@ import { } from "@local/hash-backend-utils/flows/payload-storage"; import { flattenPropertyMetadata } from "@local/hash-graph-sdk/entity"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; +import { StatusCode } from "@local/status"; + +import { getFlowContext } from "../shared/get-flow-context.js"; +import { fileEntityTypeIds, persistEntity } from "./persist-entity-action.js"; + +import type { EntityId } from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import type { FailedEntityProposal, PersistedEntityMetadata, ProposedEntityWithResolvedLinks, } from "@local/hash-isomorphic-utils/flows/types"; -import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; - -import { getFlowContext } from "../shared/get-flow-context.js"; -import { fileEntityTypeIds, persistEntity } from "./persist-entity-action.js"; export const persistEntitiesAction: AiFlowActionActivity< "persistEntities" diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entity-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entity-action.ts index e77ad737921..81f2d583a5e 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entity-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/persist-entity-action.ts @@ -1,31 +1,20 @@ -import type { EntityId, VersionedUrl } from "@blockprotocol/type-system"; +import { Context } from "@temporalio/activity"; +import { backOff } from "exponential-backoff"; + import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { getStorageProvider, resolvePayloadValue, } from "@local/hash-backend-utils/flows/payload-storage"; import { getWebMachineId } from "@local/hash-backend-utils/machine-actors"; -import type { CreateEntityParameters } from "@local/hash-graph-sdk/entity"; import { HashEntity, HashLinkEntity, mergePropertyObjectAndMetadata, } from "@local/hash-graph-sdk/entity"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { - PersistedEntityMetadata, - ProposedEntityWithResolvedLinks, -} from "@local/hash-isomorphic-utils/flows/types"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - HasObject, - HasSubject, -} from "@local/hash-isomorphic-utils/system-types/claim"; -import type { FileProperties } from "@local/hash-isomorphic-utils/system-types/shared"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; -import { backOff } from "exponential-backoff"; import { getAiAssistantAccountIdActivity } from "../get-ai-assistant-account-id-activity.js"; import { extractErrorMessage } from "../infer-entities/shared/extract-validation-failure-details.js"; @@ -37,13 +26,26 @@ import { import { getFlowContext } from "../shared/get-flow-context.js"; import { graphApiClient } from "../shared/graph-api-client.js"; import { logProgress } from "../shared/log-progress.js"; -import type { MatchedEntityUpdate } from "../shared/match-existing-entity.js"; import { createFileEntityFromUrl } from "./shared/create-file-entity-from-url.js"; import { getEntityUpdate, getLatestEntityById, } from "./shared/graph-requests.js"; +import type { MatchedEntityUpdate } from "../shared/match-existing-entity.js"; +import type { EntityId, VersionedUrl } from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { CreateEntityParameters } from "@local/hash-graph-sdk/entity"; +import type { + PersistedEntityMetadata, + ProposedEntityWithResolvedLinks, +} from "@local/hash-isomorphic-utils/flows/types"; +import type { + HasObject, + HasSubject, +} from "@local/hash-isomorphic-utils/system-types/claim"; +import type { FileProperties } from "@local/hash-isomorphic-utils/system-types/shared"; + export const fileEntityTypeIds: VersionedUrl[] = [ systemEntityTypes.file.entityTypeId, systemEntityTypes.imageFile.entityTypeId, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/process-automatic-browsing-settings-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/process-automatic-browsing-settings-action.ts index 1824f728de8..8f06fce761a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/process-automatic-browsing-settings-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/process-automatic-browsing-settings-action.ts @@ -1,16 +1,17 @@ -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { AutomaticInferenceSettings } from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-types"; import { generateVersionedUrlMatchingFilter } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { BrowserPluginSettings } from "@local/hash-isomorphic-utils/system-types/shared"; import { StatusCode } from "@local/status"; import { getEntityByFilter } from "../shared/get-entity-by-filter.js"; import { getFlowContext } from "../shared/get-flow-context.js"; import { graphApiClient } from "../shared/graph-api-client.js"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { AutomaticInferenceSettings } from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-types"; +import type { BrowserPluginSettings } from "@local/hash-isomorphic-utils/system-types/shared"; + export const processAutomaticBrowsingSettingsAction: AiFlowActionActivity< "processAutomaticBrowsingSettings" > = async ({ inputs }) => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ai.test.ts index 8ed3eaaf86e..63988df8e2a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ai.test.ts @@ -1,5 +1,4 @@ import "../../shared/testing-utilities/mock-get-flow-context.js"; - import { existsSync, mkdirSync, @@ -13,6 +12,7 @@ import { fileURLToPath } from "node:url"; import { expect, test } from "vitest"; import { researchEntitiesAction } from "./research-entities-action.js"; + import type { CoordinatingAgentState } from "./research-entities-action/shared/coordinators.js"; const __filename = fileURLToPath(import.meta.url); diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ts index 13cf2d0c442..d8f45c57f9a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action.ts @@ -1,8 +1,3 @@ -import type { - OriginProvenance, - ProvidedEntityEditionProvenance, -} from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { @@ -18,7 +13,13 @@ import { heartbeatAndWaitCancellation, } from "./research-entities-action/checkpoints.js"; import { runCoordinatingAgent } from "./research-entities-action/coordinating-agent.js"; + import type { CoordinatingAgentState } from "./research-entities-action/shared/coordinators.js"; +import type { + OriginProvenance, + ProvidedEntityEditionProvenance, +} from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; /** * An action to research entities of requested types according to the user's research goal. diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/checkpoints.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/checkpoints.ts index 483c57751a0..1d2d40b67c4 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/checkpoints.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/checkpoints.ts @@ -1,17 +1,19 @@ -import { parseHistoryItemPayload } from "@local/hash-backend-utils/temporal/parse-history-item-payload"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { Context } from "@temporalio/activity"; import proto from "@temporalio/proto"; +import { parseHistoryItemPayload } from "@local/hash-backend-utils/temporal/parse-history-item-payload"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; + import { heartbeatTimeoutSeconds } from "../../../shared/heartbeats.js"; -import type { - FlowSignal, - ResearchActionCheckpointState, -} from "../../../shared/signals.js"; import { researchActionCheckpointSignal } from "../../../shared/signals.js"; import { logger } from "../../shared/activity-logger.js"; import { getTemporalClient } from "../../shared/get-flow-context.js"; import { flushLogs, logProgress } from "../../shared/log-progress.js"; + +import type { + FlowSignal, + ResearchActionCheckpointState, +} from "../../../shared/signals.js"; import type { CoordinatingAgentState } from "./shared/coordinators.js"; /** diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent.ts index 305a13ebd81..c136ffb4354 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent.ts @@ -1,10 +1,6 @@ -import type { - EntityUuid, - OriginProvenance, - Url, -} from "@blockprotocol/type-system"; +import { Context } from "@temporalio/activity"; + import { entityIdFromComponents } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; import { getStorageProvider, resolvePayloadValue, @@ -12,16 +8,10 @@ import { } from "@local/hash-backend-utils/flows/payload-storage"; import { flattenPropertyMetadata } from "@local/hash-graph-sdk/entity"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { - ProposedEntity, - StepInput, -} from "@local/hash-isomorphic-utils/flows/types"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { FileProperties } from "@local/hash-isomorphic-utils/system-types/shared"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; import { getDereferencedEntityTypesActivity } from "../../get-dereferenced-entity-types-activity.js"; import { logger } from "../../shared/activity-logger.js"; @@ -37,24 +27,36 @@ import { createCheckpoint } from "./checkpoints.js"; import { createInitialPlan } from "./coordinating-agent/create-initial-plan.js"; import { processCompleteToolCall } from "./coordinating-agent/process-complete-tool-call.js"; import { requestCoordinatorActions } from "./coordinating-agent/request-coordinator-actions.js"; -import type { ExistingEntitySummary } from "./coordinating-agent/summarize-existing-entities.js"; import { summarizeExistingEntities } from "./coordinating-agent/summarize-existing-entities.js"; import { updateStateFromInferredClaims } from "./coordinating-agent/update-state-from-inferred-claims.js"; -import type { - ParsedCoordinatorToolCall, - ParsedCoordinatorToolCallMap, -} from "./shared/coordinator-tools.js"; import { getSomeToolCallResults, handleStopTasksRequests, nullReturns, triggerToolCallsRequests, } from "./shared/coordinator-tools.js"; +import { processCommonStateMutationsFromToolResults } from "./shared/coordinators.js"; + +import type { ExistingEntitySummary } from "./coordinating-agent/summarize-existing-entities.js"; +import type { + ParsedCoordinatorToolCall, + ParsedCoordinatorToolCallMap, +} from "./shared/coordinator-tools.js"; import type { CoordinatingAgentInput, CoordinatingAgentState, } from "./shared/coordinators.js"; -import { processCommonStateMutationsFromToolResults } from "./shared/coordinators.js"; +import type { + EntityUuid, + OriginProvenance, + Url, +} from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { + ProposedEntity, + StepInput, +} from "@local/hash-isomorphic-utils/flows/types"; +import type { FileProperties } from "@local/hash-isomorphic-utils/system-types/shared"; /** * Takes the inputs to the coordinating agent, parses them, and: diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ai.test.ts index f6a1fdd1efe..a613ca17c5c 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ai.test.ts @@ -1,5 +1,4 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; - import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ts index 359bfc74579..f2f577ecc44 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/check-delegated-tasks-agent.ts @@ -1,16 +1,17 @@ import dedent from "dedent"; -import type { JSONSchemaDefinition } from "openai/lib/jsonschema"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; -import type { LlmToolDefinition } from "../../../shared/get-llm-response/types.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { simplifyEntityTypeForLlmConsumption } from "../shared/simplify-for-llm-consumption.js"; + +import type { LlmToolDefinition } from "../../../shared/get-llm-response/types.js"; import type { CoordinatingAgentInput, CoordinatingAgentState, } from "../shared/coordinators.js"; -import { simplifyEntityTypeForLlmConsumption } from "../shared/simplify-for-llm-consumption.js"; +import type { JSONSchemaDefinition } from "openai/lib/jsonschema"; type SubmitVerdictToolCallInput = { [delegatedTaskId: string]: { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/create-initial-plan.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/create-initial-plan.ts index 80fddeee3d9..2c96ef4288a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/create-initial-plan.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/create-initial-plan.ts @@ -3,10 +3,6 @@ import dedent from "dedent"; import { logger } from "../../../shared/activity-logger.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; -import type { - LlmMessage, - LlmUserMessage, -} from "../../../shared/get-llm-response/llm-message.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; import { stringify } from "../../../shared/stringify.js"; @@ -15,16 +11,21 @@ import { type CoordinatorToolCallArguments, generateToolDefinitions, } from "../shared/coordinator-tools.js"; -import type { - CoordinatingAgentInput, - CoordinatingAgentState, -} from "../shared/coordinators.js"; import { coordinatingAgentModel } from "../shared/coordinators.js"; import { generateInitialUserMessage, generateSystemPromptPrefix, } from "./generate-messages.js"; +import type { + LlmMessage, + LlmUserMessage, +} from "../../../shared/get-llm-response/llm-message.js"; +import type { + CoordinatingAgentInput, + CoordinatingAgentState, +} from "../shared/coordinators.js"; + const maximumRetries = 3; export const createInitialPlan = async (params: { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/generate-messages.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/generate-messages.ts index 032b494d759..26511754a8f 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/generate-messages.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/generate-messages.ts @@ -1,16 +1,17 @@ import dedent from "dedent"; -import type { LlmMessageTextContent } from "../../../shared/get-llm-response/llm-message.js"; import { generateOutstandingTasksDescription } from "../shared/coordinator-tools.js"; -import type { - CoordinatingAgentInput, - CoordinatingAgentState, -} from "../shared/coordinators.js"; import { simplifyEntityTypeForLlmConsumption, simplifyProposedEntityForLlmConsumption, } from "../shared/simplify-for-llm-consumption.js"; +import type { LlmMessageTextContent } from "../../../shared/get-llm-response/llm-message.js"; +import type { + CoordinatingAgentInput, + CoordinatingAgentState, +} from "../shared/coordinators.js"; + export const generateProgressReport = (params: { input: CoordinatingAgentInput; state: CoordinatingAgentState; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/process-complete-tool-call.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/process-complete-tool-call.ts index e8068dc98ca..2c39b8cdcf7 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/process-complete-tool-call.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/process-complete-tool-call.ts @@ -1,6 +1,7 @@ import dedent from "dedent"; import { logger } from "../../../shared/activity-logger.js"; + import type { ParsedLlmToolCall } from "../../../shared/get-llm-response/types.js"; import type { ParsedCoordinatorToolCallMap } from "../shared/coordinator-tools.js"; import type { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/request-coordinator-actions.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/request-coordinator-actions.ts index 89ab76621b4..ebfa1dfe814 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/request-coordinator-actions.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/request-coordinator-actions.ts @@ -2,15 +2,9 @@ import dedent from "dedent"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; -import type { LlmMessage } from "../../../shared/get-llm-response/llm-message.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; -import type { ParsedCoordinatorToolCall } from "../shared/coordinator-tools.js"; import { generateToolDefinitions } from "../shared/coordinator-tools.js"; -import type { - CoordinatingAgentInput, - CoordinatingAgentState, -} from "../shared/coordinators.js"; import { coordinatingAgentModel } from "../shared/coordinators.js"; import { mapPreviousCoordinatorCallsToLlmMessages } from "../shared/map-previous-coordinator-calls-to-llm-messages.js"; import { @@ -19,6 +13,13 @@ import { generateSystemPromptPrefix, } from "./generate-messages.js"; +import type { LlmMessage } from "../../../shared/get-llm-response/llm-message.js"; +import type { ParsedCoordinatorToolCall } from "../shared/coordinator-tools.js"; +import type { + CoordinatingAgentInput, + CoordinatingAgentState, +} from "../shared/coordinators.js"; + /** * Given the current state of the coordinating agent, request the next actions to be taken. */ diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ai.test.ts index 07502b51518..1437772fc0f 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ai.test.ts @@ -1,4 +1,5 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; +import { expect, test } from "vitest"; import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; import { queryEntities } from "@local/hash-graph-sdk/entity"; @@ -7,7 +8,6 @@ import { generateVersionedUrlMatchingFilter, } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import { expect, test } from "vitest"; import { graphApiClient } from "../../../shared/graph-api-client.js"; import { summarizeExistingEntities } from "./summarize-existing-entities.js"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ts index e778a250e2f..1f290a9dcc0 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/summarize-existing-entities.ts @@ -1,14 +1,15 @@ -import type { EntityId, VersionedUrl } from "@blockprotocol/type-system"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import dedent from "dedent"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; -import type { LlmToolDefinition } from "../../../shared/get-llm-response/types.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; import { simplifyEntity } from "../../../shared/simplify-entity.js"; +import type { LlmToolDefinition } from "../../../shared/get-llm-response/types.js"; +import type { EntityId, VersionedUrl } from "@blockprotocol/type-system"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; + export type ExistingEntitySummary = { entityId: EntityId; entityTypeIds: [VersionedUrl, ...VersionedUrl[]]; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/update-state-from-inferred-claims.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/update-state-from-inferred-claims.ts index 65f511ef508..48c8484ea7d 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/update-state-from-inferred-claims.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/coordinating-agent/update-state-from-inferred-claims.ts @@ -1,20 +1,21 @@ -import type { EntityId } from "@blockprotocol/type-system"; -import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; import { isNotNullish } from "@local/hash-isomorphic-utils/types"; -import type { Claim } from "../../shared/claims.js"; -import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; import { proposeEntitiesFromClaims } from "../../shared/propose-entities-from-claims.js"; -import type { - CoordinatingAgentInput, - CoordinatingAgentState, -} from "../shared/coordinators.js"; import { deduplicateClaims } from "../shared/deduplicate-claims.js"; import { deduplicateEntities, type DuplicateReport, } from "../shared/deduplicate-entities.js"; +import type { Claim } from "../../shared/claims.js"; +import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; +import type { + CoordinatingAgentInput, + CoordinatingAgentState, +} from "../shared/coordinators.js"; +import type { EntityId } from "@blockprotocol/type-system"; +import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; + const adjustDuplicates = (params: { duplicates: DuplicateReport[]; entityIdsWhichCannotBeDeduplicated: EntityId[]; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ai.test.ts index e604bb7fe23..774f14cc619 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ai.test.ts @@ -1,6 +1,4 @@ import "../../../shared/testing-utilities/mock-get-flow-context.js"; - -import type { Url } from "@blockprotocol/type-system"; import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../get-dereferenced-entity-types-activity.js"; @@ -8,6 +6,8 @@ import { getFlowContext } from "../../shared/get-flow-context.js"; import { graphApiClient } from "../../shared/graph-api-client.js"; import { linkFollowerAgent } from "./link-follower-agent.js"; +import type { Url } from "@blockprotocol/type-system"; + test.skip( "Test linkFollowerAgent for Church Lab members", async () => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ts index 719447bc5cc..48bb5a423a3 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent.ts @@ -1,25 +1,19 @@ -import type { SourceProvenance, Url } from "@blockprotocol/type-system"; -import { currentTimestamp } from "@blockprotocol/type-system"; -import { getStorageProvider } from "@local/hash-backend-utils/flows/payload-storage"; -import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; import { Context } from "@temporalio/activity"; import dedent from "dedent"; import { MetadataMode } from "llamaindex"; +import { currentTimestamp } from "@blockprotocol/type-system"; +import { getStorageProvider } from "@local/hash-backend-utils/flows/payload-storage"; + import { getWebPageActivity } from "../../get-web-page-activity.js"; -import type { DereferencedEntityTypesByTypeId } from "../../infer-entities/inference-types.js"; import { logger } from "../../shared/activity-logger.js"; -import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; import { getFlowContext, getProvidedFileByUrl, } from "../../shared/get-flow-context.js"; import { logProgress } from "../../shared/log-progress.js"; import { stringify } from "../../shared/stringify.js"; -import type { Claim } from "../shared/claims.js"; import { inferSummariesThenClaimsFromText } from "../shared/infer-summaries-then-claims-from-text.js"; -import type { LocalEntitySummary } from "../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import type { Link } from "./link-follower-agent/choose-relevant-links-from-content.js"; import { chooseRelevantLinksFromContent } from "./link-follower-agent/choose-relevant-links-from-content.js"; import { filterAndRankTextChunksAgent } from "./link-follower-agent/filter-and-rank-text-chunks-agent.js"; import { getLinkFollowerNextToolCalls } from "./link-follower-agent/get-link-follower-next-tool-calls.js"; @@ -28,6 +22,14 @@ import { areUrlsEqual } from "./shared/are-urls-equal.js"; import { checkIfWorkerShouldStop } from "./shared/check-if-worker-should-stop.js"; import { deduplicateEntities } from "./shared/deduplicate-entities.js"; +import type { DereferencedEntityTypesByTypeId } from "../../infer-entities/inference-types.js"; +import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; +import type { Claim } from "../shared/claims.js"; +import type { LocalEntitySummary } from "../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; +import type { Link } from "./link-follower-agent/choose-relevant-links-from-content.js"; +import type { SourceProvenance, Url } from "@blockprotocol/type-system"; +import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; + type ResourceToExplore = { url: Url; descriptionOfExpectedContent: string; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.optimize.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.optimize.ai.test.ts index 6293c938aff..eeb561b2dc8 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.optimize.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.optimize.ai.test.ts @@ -1,21 +1,21 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; - import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { Url } from "@blockprotocol/type-system"; import dedent from "dedent"; import { test } from "vitest"; import { getWebPageActivity } from "../../../get-web-page-activity.js"; -import type { LlmParams } from "../../../shared/get-llm-response/types.js"; import { optimizeSystemPrompt } from "../../../shared/optimize-system-prompt.js"; -import type { MetricDefinition } from "../../../shared/optimize-system-prompt/types.js"; import { chooseRelevantLinksFromContent, chooseRelevantLinksFromContentSystemPrompt, } from "./choose-relevant-links-from-content.js"; +import type { LlmParams } from "../../../shared/get-llm-response/types.js"; +import type { MetricDefinition } from "../../../shared/optimize-system-prompt/types.js"; +import type { Url } from "@blockprotocol/type-system"; + const ftse350MetricPrompt = "Find all the FTSE350 stock market constituents."; const ftse350WebPage = await getWebPageActivity({ diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.ts index cd510dbbce5..bede4432b38 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/choose-relevant-links-from-content.ts @@ -4,12 +4,13 @@ import { JSDOM } from "jsdom"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { stripHashFromUrl } from "../shared/are-urls-equal.js"; + import type { LlmParams, LlmToolDefinition, } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; -import { stripHashFromUrl } from "../shared/are-urls-equal.js"; export type Link = { url: string; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/filter-and-rank-text-chunks-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/filter-and-rank-text-chunks-agent.ts index 1813d3eee22..ae2b2b73d62 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/filter-and-rank-text-chunks-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/filter-and-rank-text-chunks-agent.ts @@ -2,16 +2,17 @@ import dedent from "dedent"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; +import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; + import type { LlmMessage, LlmUserMessage, } from "../../../shared/get-llm-response/llm-message.js"; -import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import type { LlmErrorResponse, LlmToolDefinition, } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; const systemPrompt = dedent(` You are an assistant tasked with determining which sections of a PDF file diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/get-link-follower-next-tool-calls.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/get-link-follower-next-tool-calls.ts index 01d0616b9d5..4e7c3e9171a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/get-link-follower-next-tool-calls.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/get-link-follower-next-tool-calls.ts @@ -1,22 +1,24 @@ -import type { Url } from "@blockprotocol/type-system"; -import type { Subtype } from "@local/advanced-types/subtype"; -import { sleep } from "@local/hash-backend-utils/utils"; import dedent from "dedent"; +import { sleep } from "@local/hash-backend-utils/utils"; + import { logger } from "../../../../shared/logger.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; -import type { LlmUserMessage } from "../../../shared/get-llm-response/llm-message.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { simplifyClaimForLlmConsumption } from "../shared/simplify-for-llm-consumption.js"; + +import type { LlmUserMessage } from "../../../shared/get-llm-response/llm-message.js"; import type { LlmParams, LlmToolDefinition, } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; import type { Claim } from "../../shared/claims.js"; import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import { simplifyClaimForLlmConsumption } from "../shared/simplify-for-llm-consumption.js"; import type { Link } from "./choose-relevant-links-from-content.js"; +import type { Url } from "@blockprotocol/type-system"; +import type { Subtype } from "@local/advanced-types/subtype"; const defaultModel: LlmParams["model"] = "gpt-4o-2024-08-06"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/llama-index/index-pdf-file.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/llama-index/index-pdf-file.ts index b637ec97171..4dc64897559 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/llama-index/index-pdf-file.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/link-follower-agent/llama-index/index-pdf-file.ts @@ -2,7 +2,6 @@ import { createWriteStream } from "node:fs"; import fs from "node:fs/promises"; import { Readable } from "node:stream"; import stream from "node:stream/promises"; -import type { ReadableStream } from "node:stream/web"; import { PDFReader } from "@llamaindex/readers/pdf"; import { VectorStoreIndex } from "llamaindex"; @@ -14,6 +13,8 @@ import { persistStorageContext, } from "./simple-storage-context.js"; +import type { ReadableStream } from "node:stream/web"; + const fileExists = async (path: string) => { try { await fs.access(path, fs.constants.F_OK); diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/check-if-worker-should-stop.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/check-if-worker-should-stop.ts index 6c42676474e..c1164c1fce9 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/check-if-worker-should-stop.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/check-if-worker-should-stop.ts @@ -1,16 +1,18 @@ -import { parseHistoryItemPayload } from "@local/hash-backend-utils/temporal/parse-history-item-payload"; -import type { - FlowSignalType, - WorkerIdentifiers, -} from "@local/hash-isomorphic-utils/flows/types"; import { Context } from "@temporalio/activity"; -import type { FlowSignal } from "../../../../shared/signals.js"; +import { parseHistoryItemPayload } from "@local/hash-backend-utils/temporal/parse-history-item-payload"; + import { getTemporalClient, isActivityCancelled, } from "../../../shared/get-flow-context.js"; +import type { FlowSignal } from "../../../../shared/signals.js"; +import type { + FlowSignalType, + WorkerIdentifiers, +} from "@local/hash-isomorphic-utils/flows/types"; + /** * Check if a HASH worker should stop what it is doing and return early. * diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools.ts index 8d83c094fe3..c135076488b 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools.ts @@ -1,13 +1,12 @@ -import type { Subtype } from "@local/advanced-types/subtype"; -import type { - FlowDataSources, - WorkerIdentifiers, -} from "@local/hash-isomorphic-utils/flows/types"; +import dedent from "dedent"; + import { sleep } from "@local/hash-isomorphic-utils/sleep"; import { stringifyError } from "@local/hash-isomorphic-utils/stringify-error"; -import dedent from "dedent"; import { logger } from "../../../shared/activity-logger.js"; +import { getToolCallResults } from "./coordinator-tools/get-tool-call-results.js"; +import { stopWorkers } from "./coordinators.js"; + import type { LlmToolDefinition, ParsedLlmToolCall, @@ -20,14 +19,17 @@ import type { GetCoordinatorToolCallResultsParams, GetSubCoordinatorToolCallResultsParams, } from "./coordinator-tools/get-tool-call-results.js"; -import { getToolCallResults } from "./coordinator-tools/get-tool-call-results.js"; import type { CoordinatingAgentInput, CoordinatingAgentState, OutstandingCoordinatorTask, } from "./coordinators.js"; -import { stopWorkers } from "./coordinators.js"; import type { WebResourceSummary } from "./handle-web-search-tool-call.js"; +import type { Subtype } from "@local/advanced-types/subtype"; +import type { + FlowDataSources, + WorkerIdentifiers, +} from "@local/hash-isomorphic-utils/flows/types"; export const coordinatorToolNames = [ "complete", diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools/get-tool-call-results.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools/get-tool-call-results.ts index 61c83db0ec2..2bd60e5f1d6 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools/get-tool-call-results.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinator-tools/get-tool-call-results.ts @@ -1,5 +1,3 @@ -import type { Url } from "@blockprotocol/type-system"; -import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { logger } from "../../../../shared/activity-logger.js"; @@ -9,6 +7,9 @@ import { stringify } from "../../../../shared/stringify.js"; import { getAnswersFromHuman } from "../../get-answers-from-human.js"; import { linkFollowerAgent } from "../../link-follower-agent.js"; import { runSubCoordinatingAgent } from "../../sub-coordinating-agent.js"; +import { nullReturns } from "../coordinator-tools.js"; +import { handleWebSearchToolCall } from "../handle-web-search-tool-call.js"; + import type { SubCoordinatingAgentInput } from "../../sub-coordinating-agent/input.js"; import type { SubCoordinatingAgentState } from "../../sub-coordinating-agent/state.js"; import type { @@ -20,12 +21,12 @@ import type { ParsedSubCoordinatorToolCallMap, SubCoordinatingAgentToolName, } from "../coordinator-tools.js"; -import { nullReturns } from "../coordinator-tools.js"; import type { CoordinatingAgentInput, CoordinatingAgentState, } from "../coordinators.js"; -import { handleWebSearchToolCall } from "../handle-web-search-tool-call.js"; +import type { Url } from "@blockprotocol/type-system"; +import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; export type GetCoordinatorToolCallResultsParams = { agentType: "coordinator"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinators.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinators.ts index f7695318b73..8a33c2c78f4 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinators.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/coordinators.ts @@ -1,20 +1,16 @@ -import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { - ProposedEntity, - WorkerIdentifiers, -} from "@local/hash-isomorphic-utils/flows/types"; import { Context } from "@temporalio/activity"; import { stopWorkerSignal } from "../../../../shared/signals.js"; +import { getTemporalClient } from "../../../shared/get-flow-context.js"; +import { areUrlsEqual } from "./are-urls-equal.js"; + import type { DereferencedEntityTypesByTypeId } from "../../../infer-entities/inference-types.js"; import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; -import { getTemporalClient } from "../../../shared/get-flow-context.js"; import type { LlmParams } from "../../../shared/get-llm-response/types.js"; import type { Claim } from "../../shared/claims.js"; import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; import type { ExistingEntitySummary } from "../coordinating-agent/summarize-existing-entities.js"; import type { SubCoordinatingAgentState } from "../sub-coordinating-agent/state.js"; -import { areUrlsEqual } from "./are-urls-equal.js"; import type { CompletedCoordinatorToolCall, CoordinatorToolName, @@ -22,6 +18,11 @@ import type { ParsedSubCoordinatorToolCall, } from "./coordinator-tools.js"; import type { WebResourceSummary } from "./handle-web-search-tool-call.js"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { + ProposedEntity, + WorkerIdentifiers, +} from "@local/hash-isomorphic-utils/flows/types"; export const coordinatingAgentModel: LlmParams["model"] = "gpt-4o-2024-08-06"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-claims.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-claims.ts index 9345218ae11..1e6e1f6c94d 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-claims.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-claims.ts @@ -1,21 +1,22 @@ -import type { - BaseUrl, - EntityId, - PropertyPatchOperation, - ProvidedEntityEditionProvenance, -} from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; import { blockProtocolDataTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ClaimProperties } from "@local/hash-isomorphic-utils/system-types/claim"; import { getAiAssistantAccountIdActivity } from "../../../get-ai-assistant-account-id-activity.js"; import { logger } from "../../../shared/activity-logger.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; -import type { Claim } from "../../shared/claims.js"; import { claimTextualContentFromClaim } from "../../shared/claims.js"; +import type { Claim } from "../../shared/claims.js"; +import type { + BaseUrl, + EntityId, + PropertyPatchOperation, + ProvidedEntityEditionProvenance, +} from "@blockprotocol/type-system"; +import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; +import type { ClaimProperties } from "@local/hash-isomorphic-utils/system-types/claim"; + const noObjectEntityIdKey = "no-object-entity-id"; /** diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ai.test.ts index 322e273547e..dbdd5d80692 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ai.test.ts @@ -1,13 +1,14 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; +import { expect, test } from "vitest"; -import type { EntityUuid, WebId } from "@blockprotocol/type-system"; import { entityIdFromComponents } from "@blockprotocol/type-system"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { expect, test } from "vitest"; -import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; import { deduplicateEntities } from "./deduplicate-entities.js"; +import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; +import type { EntityUuid, WebId } from "@blockprotocol/type-system"; + const webId = generateUuid(); const generateEntityId = (entityUuid: string) => diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ts index 3fc69f56410..063bc8af8b4 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/deduplicate-entities.ts @@ -1,21 +1,23 @@ -import type { EntityId } from "@blockprotocol/type-system"; -import { sleep } from "@local/hash-isomorphic-utils/sleep"; import dedent from "dedent"; +import { sleep } from "@local/hash-isomorphic-utils/sleep"; + import { logger } from "../../../shared/activity-logger.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; -import type { PermittedAnthropicModel } from "../../../shared/get-llm-response/anthropic-client.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; + +import type { PermittedAnthropicModel } from "../../../shared/get-llm-response/anthropic-client.js"; import type { LlmParams, LlmToolDefinition, LlmUsage, } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; import type { PermittedOpenAiModel } from "../../../shared/openai-client.js"; import type { LocalEntitySummary } from "../../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; import type { ExistingEntitySummary } from "../coordinating-agent/summarize-existing-entities.js"; +import type { EntityId } from "@blockprotocol/type-system"; /** * @todo diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/handle-web-search-tool-call.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/handle-web-search-tool-call.ts index 906a32987e8..a05a82d128a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/handle-web-search-tool-call.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/handle-web-search-tool-call.ts @@ -1,20 +1,22 @@ +import { Context } from "@temporalio/activity"; + +import { actionDefinitions } from "@local/hash-isomorphic-utils/flows/action-definitions"; +import { StatusCode } from "@local/status"; + +import { logProgress } from "../../../shared/log-progress.js"; +import { getWebPageSummaryAction } from "../../get-web-page-summary-action.js"; +import { webSearchAction } from "../../web-search-action.js"; + +import type { CoordinatorToolCallArguments } from "./coordinator-tools.js"; import type { Url } from "@blockprotocol/type-system"; import type { InputNameForAiFlowAction, OutputNameForAiFlowAction, } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import { actionDefinitions } from "@local/hash-isomorphic-utils/flows/action-definitions"; import type { StepInput, WorkerIdentifiers, } from "@local/hash-isomorphic-utils/flows/types"; -import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; - -import { logProgress } from "../../../shared/log-progress.js"; -import { getWebPageSummaryAction } from "../../get-web-page-summary-action.js"; -import { webSearchAction } from "../../web-search-action.js"; -import type { CoordinatorToolCallArguments } from "./coordinator-tools.js"; export type WebResourceSummary = { url: Url; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ai.test.ts index b4efcc6dd69..0264facdcff 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ai.test.ts @@ -1,5 +1,4 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; - import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ts index f26476c53d3..edc029f3568 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/shared/simplify-for-llm-consumption.ts @@ -1,7 +1,3 @@ -import type { - LocalOrExistingEntityId, - ProposedEntity, -} from "@local/hash-isomorphic-utils/flows/types"; import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; import type { @@ -11,6 +7,10 @@ import type { MinimalPropertyTypeValue, } from "../../../shared/dereference-entity-type.js"; import type { Claim } from "../../shared/claims.js"; +import type { + LocalOrExistingEntityId, + ProposedEntity, +} from "@local/hash-isomorphic-utils/flows/types"; const simplifyMinimalPropertyTypeValueForLlmConsumption = (params: { propertyTypeValue: MinimalPropertyTypeValue; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ai.test.ts index bdefe05386a..aa28d73711c 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ai.test.ts @@ -1,5 +1,4 @@ import "../../../shared/testing-utilities/mock-get-flow-context.js"; - import { existsSync, mkdirSync, @@ -16,6 +15,7 @@ import { getDereferencedEntityTypesActivity } from "../../get-dereferenced-entit import { getFlowContext } from "../../shared/get-flow-context.js"; import { graphApiClient } from "../../shared/graph-api-client.js"; import { runSubCoordinatingAgent } from "./sub-coordinating-agent.js"; + import type { SubCoordinatingAgentState } from "./sub-coordinating-agent/state.js"; const __filename = fileURLToPath(import.meta.url); diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ts index 60ac741423d..ecf61efe157 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent.ts @@ -1,10 +1,8 @@ -import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { Context } from "@temporalio/activity"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; + import { logProgress } from "../../shared/log-progress.js"; -import type { Claim } from "../shared/claims.js"; -import type { LocalEntitySummary } from "../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; import { checkIfWorkerShouldStop } from "./shared/check-if-worker-should-stop.js"; import { getSomeToolCallResults, @@ -18,12 +16,16 @@ import { stopWorkers, } from "./shared/coordinators.js"; import { deduplicateClaims } from "./shared/deduplicate-claims.js"; -import type { DuplicateReport } from "./shared/deduplicate-entities.js"; import { deduplicateEntities } from "./shared/deduplicate-entities.js"; import { createInitialPlan } from "./sub-coordinating-agent/create-initial-plan.js"; -import type { SubCoordinatingAgentInput } from "./sub-coordinating-agent/input.js"; import { requestSubCoordinatorActions } from "./sub-coordinating-agent/request-sub-coordinator-actions.js"; + +import type { Claim } from "../shared/claims.js"; +import type { LocalEntitySummary } from "../shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; +import type { DuplicateReport } from "./shared/deduplicate-entities.js"; +import type { SubCoordinatingAgentInput } from "./sub-coordinating-agent/input.js"; import type { SubCoordinatingAgentState } from "./sub-coordinating-agent/state.js"; +import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; const handleStopReturn = async ( shouldStopStatus: { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/create-initial-plan.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/create-initial-plan.ts index fb34e3f389d..f637fda1e5c 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/create-initial-plan.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/create-initial-plan.ts @@ -4,18 +4,19 @@ import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; -import type { - SubCoordinatingAgentToolCallArguments, - SubCoordinatingAgentToolName, -} from "../shared/coordinator-tools.js"; import { coordinatingAgentModel } from "../shared/coordinators.js"; import { generateInitialUserMessage, generateSystemPromptPrefix, } from "./generate-messages.js"; +import { generateToolDefinitions } from "./sub-coordinator-tools.js"; + +import type { + SubCoordinatingAgentToolCallArguments, + SubCoordinatingAgentToolName, +} from "../shared/coordinator-tools.js"; import type { SubCoordinatingAgentInput } from "./input.js"; import type { SubCoordinatingAgentState } from "./state.js"; -import { generateToolDefinitions } from "./sub-coordinator-tools.js"; export const createInitialPlan = async (params: { input: SubCoordinatingAgentInput; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/generate-messages.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/generate-messages.ts index e52c37809dd..dbbed5c9641 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/generate-messages.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/generate-messages.ts @@ -1,14 +1,15 @@ import dedent from "dedent"; -import type { - LlmMessageTextContent, - LlmUserMessage, -} from "../../../shared/get-llm-response/llm-message.js"; import { generateOutstandingTasksDescription } from "../shared/coordinator-tools.js"; import { simplifyClaimForLlmConsumption, simplifyEntityTypeForLlmConsumption, } from "../shared/simplify-for-llm-consumption.js"; + +import type { + LlmMessageTextContent, + LlmUserMessage, +} from "../../../shared/get-llm-response/llm-message.js"; import type { SubCoordinatingAgentInput } from "./input.js"; import type { SubCoordinatingAgentState } from "./state.js"; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/request-sub-coordinator-actions.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/request-sub-coordinator-actions.ts index b670dffcd28..2ddf94fc061 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/request-sub-coordinator-actions.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/request-sub-coordinator-actions.ts @@ -3,10 +3,8 @@ import dedent from "dedent"; import { logger } from "../../../../shared/logger.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; -import type { LlmMessage } from "../../../shared/get-llm-response/llm-message.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; -import type { ParsedSubCoordinatorToolCall } from "../shared/coordinator-tools.js"; import { coordinatingAgentModel } from "../shared/coordinators.js"; import { mapPreviousCoordinatorCallsToLlmMessages } from "../shared/map-previous-coordinator-calls-to-llm-messages.js"; import { @@ -14,9 +12,12 @@ import { generateProgressReport, generateSystemPromptPrefix, } from "./generate-messages.js"; +import { generateToolDefinitions } from "./sub-coordinator-tools.js"; + +import type { LlmMessage } from "../../../shared/get-llm-response/llm-message.js"; +import type { ParsedSubCoordinatorToolCall } from "../shared/coordinator-tools.js"; import type { SubCoordinatingAgentInput } from "./input.js"; import type { SubCoordinatingAgentState } from "./state.js"; -import { generateToolDefinitions } from "./sub-coordinator-tools.js"; /** * Given the input to and state of the sub-task agent, request the next actions to be taken. diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/sub-coordinator-tools.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/sub-coordinator-tools.ts index d79ef588bae..5f5597110ff 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/sub-coordinator-tools.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/research-entities-action/sub-coordinating-agent/sub-coordinator-tools.ts @@ -1,15 +1,15 @@ -import type { FlowDataSources } from "@local/hash-isomorphic-utils/flows/types"; +import { + generateToolDefinitions as generateCoordinatorToolDefinitions, + subCoordinatorOmittedCoordinatorToolNames, +} from "../shared/coordinator-tools.js"; import type { LlmToolDefinition } from "../../../shared/get-llm-response/types.js"; import type { SubCoordinatingAgentCustomToolName, SubCoordinatingAgentToolName, } from "../shared/coordinator-tools.js"; -import { - generateToolDefinitions as generateCoordinatorToolDefinitions, - subCoordinatorOmittedCoordinatorToolNames, -} from "../shared/coordinator-tools.js"; import type { SubCoordinatingAgentState } from "./state.js"; +import type { FlowDataSources } from "@local/hash-isomorphic-utils/flows/types"; /** * Generate tool definitions for the sub-coordinating agent, to be passed to the LLM. diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/create-file-entity-from-url.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/create-file-entity-from-url.ts index f40cd0847bf..58fd294c2fe 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/create-file-entity-from-url.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/create-file-entity-from-url.ts @@ -11,14 +11,9 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { Readable } from "node:stream"; import { finished } from "node:stream/promises"; -import type { ReadableStream } from "node:stream/web"; -import type { - EntityUuid, - PropertyObjectMetadata, - ProvidedEntityEditionProvenance, - VersionedUrl, -} from "@blockprotocol/type-system"; +import mime from "mime-types"; + import { formatFileUrl, getEntityTypeIdForMimeType, @@ -34,17 +29,24 @@ import { import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { normalizeWhitespace } from "@local/hash-isomorphic-utils/normalize"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - File, - FileProperties, -} from "@local/hash-isomorphic-utils/system-types/shared"; -import mime from "mime-types"; import { getAiAssistantAccountIdActivity } from "../../get-ai-assistant-account-id-activity.js"; import { logger } from "../../shared/activity-logger.js"; import { getFlowContext } from "../../shared/get-flow-context.js"; import { graphApiClient } from "../../shared/graph-api-client.js"; +import type { + EntityUuid, + PropertyObjectMetadata, + ProvidedEntityEditionProvenance, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { + File, + FileProperties, +} from "@local/hash-isomorphic-utils/system-types/shared"; +import type { ReadableStream } from "node:stream/web"; + const baseFilePath = path.join(tmpdir(), "hash-tmp-files"); const downloadFileToFileSystem = async (fileUrl: string) => { diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/graph-requests.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/graph-requests.ts index 61a9a8bfaf3..c3cf62c2552 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/graph-requests.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/graph-requests.ts @@ -1,21 +1,22 @@ -import type { - ActorEntityUuid, - EntityId, - PropertyObjectWithMetadata, - PropertyPatchOperation, -} from "@blockprotocol/type-system"; +import isEqual from "lodash/isEqual.js"; + import { extractDraftIdFromEntityId, splitEntityId, } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { GraphApi } from "@local/hash-graph-client"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { deduplicateSources } from "@local/hash-isomorphic-utils/provenance"; -import isEqual from "lodash/isEqual.js"; import type { ExistingEntityForMatching } from "../../shared/match-existing-entity.js"; +import type { + ActorEntityUuid, + EntityId, + PropertyObjectWithMetadata, + PropertyPatchOperation, +} from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; /** * @todo: move the primitive node helper methods from the Node API into a shared diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text.ts index 5b443459b96..be14daac842 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text.ts @@ -1,13 +1,13 @@ -import type { Url, VersionedUrl } from "@blockprotocol/type-system"; -import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; +import { logger } from "../../shared/activity-logger.js"; +import { getEntitySummariesFromText } from "./infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; +import { inferEntityClaimsFromTextAgent } from "./infer-summaries-then-claims-from-text/infer-entity-claims-from-text-agent.js"; import type { DereferencedEntityTypesByTypeId } from "../../infer-entities/inference-types.js"; -import { logger } from "../../shared/activity-logger.js"; import type { LlmParams } from "../../shared/get-llm-response/types.js"; import type { Claim } from "./claims.js"; import type { LocalEntitySummary } from "./infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import { getEntitySummariesFromText } from "./infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import { inferEntityClaimsFromTextAgent } from "./infer-summaries-then-claims-from-text/infer-entity-claims-from-text-agent.js"; +import type { Url, VersionedUrl } from "@blockprotocol/type-system"; +import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; /** * A two-step process for extracting claims about entities from text: diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ai.test.ts index 888fe5e4894..34a1073311b 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ai.test.ts @@ -1,6 +1,4 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; - -import type { Url } from "@blockprotocol/type-system"; import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; @@ -9,6 +7,8 @@ import { getFlowContext } from "../../../shared/get-flow-context.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; import { getEntitySummariesFromText } from "./get-entity-summaries-from-text.js"; +import type { Url } from "@blockprotocol/type-system"; + /** * @file These are not 'tests' but rather ways of running specific agents, * the results of which can be inspected in the logs saved to the file system under get-llm-response/logs/ diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.optimize.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.optimize.ai.test.ts index 92fad55bc1f..33784fe80dd 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.optimize.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.optimize.ai.test.ts @@ -8,21 +8,21 @@ /// import "../../../../shared/testing-utilities/mock-get-flow-context.js"; - import path from "node:path"; import { fileURLToPath } from "node:url"; import { test } from "vitest"; -import type { LlmParams } from "../../../shared/get-llm-response/types.js"; import { optimizeSystemPrompt } from "../../../shared/optimize-system-prompt.js"; -import type { MetricDefinition } from "../../../shared/optimize-system-prompt/types.js"; import { entitySummariesFromTextSystemPrompt, getEntitySummariesFromText, } from "./get-entity-summaries-from-text.js"; import { testData } from "./get-entity-summaries-from-text.optimize/test-data.js"; +import type { LlmParams } from "../../../shared/get-llm-response/types.js"; +import type { MetricDefinition } from "../../../shared/optimize-system-prompt/types.js"; + const metrics: MetricDefinition[] = testData.map((testItem) => { return { name: testItem.name, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ts index 2a68b528a7c..7830a64cec1 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/get-entity-summaries-from-text.ts @@ -1,21 +1,23 @@ -import type { - EntityId, - EntityUuid, - VersionedUrl, -} from "@blockprotocol/type-system"; +import dedent from "dedent"; + import { entityIdFromComponents } from "@blockprotocol/type-system"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import dedent from "dedent"; -import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; + +import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; import type { LlmParams, LlmToolDefinition, } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; +import type { + EntityId, + EntityUuid, + VersionedUrl, +} from "@blockprotocol/type-system"; export type LocalEntitySummary = { localId: EntityId; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text-agent.ts index 43f55e4c435..9952e7e929a 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text-agent.ts @@ -1,36 +1,38 @@ -import type { - EntityId, - EntityUuid, - ProvidedEntityEditionProvenance, - Url, -} from "@blockprotocol/type-system"; +import dedent from "dedent"; + import { entityIdFromComponents } from "@blockprotocol/type-system"; import { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import type { Claim as ClaimEntity } from "@local/hash-isomorphic-utils/system-types/claim"; -import dedent from "dedent"; import { getAiAssistantAccountIdActivity } from "../../../get-ai-assistant-account-id-activity.js"; import { logger } from "../../../shared/activity-logger.js"; -import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; +import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { stringify } from "../../../shared/stringify.js"; +import { checkIfWorkerShouldStop } from "../../research-entities-action/shared/check-if-worker-should-stop.js"; + +import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; import type { LlmMessage, LlmMessageToolResultContent, LlmUserMessage, } from "../../../shared/get-llm-response/llm-message.js"; -import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import type { LlmParams, LlmToolDefinition, } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; -import { stringify } from "../../../shared/stringify.js"; -import { checkIfWorkerShouldStop } from "../../research-entities-action/shared/check-if-worker-should-stop.js"; import type { Claim } from "../claims.js"; import type { LocalEntitySummary } from "./get-entity-summaries-from-text.js"; +import type { + EntityId, + EntityUuid, + ProvidedEntityEditionProvenance, + Url, +} from "@blockprotocol/type-system"; +import type { WorkerIdentifiers } from "@local/hash-isomorphic-utils/flows/types"; +import type { Claim as ClaimEntity } from "@local/hash-isomorphic-utils/system-types/claim"; const toolNames = ["submitClaims"] as const; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text.ai.test.ts index 1187c7357b0..5d2a94fdbcb 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-entity-claims-from-text.ai.test.ts @@ -1,9 +1,8 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; +import { expect, test } from "vitest"; -import type { EntityUuid, Url, WebId } from "@blockprotocol/type-system"; import { entityIdFromComponents } from "@blockprotocol/type-system"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; import { getWebPageActivity } from "../../../get-web-page-activity.js"; @@ -11,6 +10,8 @@ import { getFlowContext } from "../../../shared/get-flow-context.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; import { inferEntityClaimsFromTextAgent } from "./infer-entity-claims-from-text-agent.js"; +import type { EntityUuid, Url, WebId } from "@blockprotocol/type-system"; + /** * @file These are not 'tests' but rather ways of running specific agents, * the results of which can be inspected in the logs saved to the file system under get-llm-response/logs/ diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-summaries-then-claims-from-text.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-summaries-then-claims-from-text.ai.test.ts index 0321d6a1bd0..3e3ad2eb361 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-summaries-then-claims-from-text.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/infer-summaries-then-claims-from-text/infer-summaries-then-claims-from-text.ai.test.ts @@ -1,13 +1,12 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; - import { readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { EntityUuid, Url, WebId } from "@blockprotocol/type-system"; +import { expect, test } from "vitest"; + import { entityIdFromComponents } from "@blockprotocol/type-system"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; import { @@ -17,7 +16,9 @@ import { import { getFlowContext } from "../../../shared/get-flow-context.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; import { inferSummariesThenClaimsFromText } from "../infer-summaries-then-claims-from-text.js"; + import type { LocalEntitySummary } from "./get-entity-summaries-from-text.js"; +import type { EntityUuid, Url, WebId } from "@blockprotocol/type-system"; /** * @file These are not 'tests' but rather ways of running specific agents, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims.ts index d57d5b53927..abb3ebd7ef3 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims.ts @@ -1,19 +1,19 @@ -import type { BaseUrl } from "@blockprotocol/type-system"; -import type { - ProposedEntity, - WorkerIdentifiers, -} from "@local/hash-isomorphic-utils/flows/types"; - -import type { DereferencedEntityTypesByTypeId } from "../../infer-entities/inference-types.js"; import { logger } from "../../shared/activity-logger.js"; -import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; import { getFlowContext } from "../../shared/get-flow-context.js"; import { logProgress } from "../../shared/log-progress.js"; import { stringify } from "../../shared/stringify.js"; +import { proposeEntityFromClaimsAgent } from "./propose-entities-from-claims/propose-entity-from-claims-agent.js"; + +import type { DereferencedEntityTypesByTypeId } from "../../infer-entities/inference-types.js"; +import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; import type { ExistingEntitySummary } from "../research-entities-action/coordinating-agent/summarize-existing-entities.js"; import type { Claim } from "./claims.js"; import type { LocalEntitySummary } from "./infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import { proposeEntityFromClaimsAgent } from "./propose-entities-from-claims/propose-entity-from-claims-agent.js"; +import type { BaseUrl } from "@blockprotocol/type-system"; +import type { + ProposedEntity, + WorkerIdentifiers, +} from "@local/hash-isomorphic-utils/flows/types"; export const proposeEntitiesFromClaims = async (params: { entitySummaries: LocalEntitySummary[]; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entities-from-claims.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entities-from-claims.ai.test.ts index 8c923f47ff5..16c0742ad1e 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entities-from-claims.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entities-from-claims.ai.test.ts @@ -1,19 +1,20 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; +import { expect, test } from "vitest"; -import type { EntityUuid, Url, WebId } from "@blockprotocol/type-system"; import { currentTimestamp, entityIdFromComponents, } from "@blockprotocol/type-system"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { proposeEntitiesFromClaims } from "../propose-entities-from-claims.js"; + import type { Claim } from "../claims.js"; import type { LocalEntitySummary } from "../infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import { proposeEntitiesFromClaims } from "../propose-entities-from-claims.js"; +import type { EntityUuid, Url, WebId } from "@blockprotocol/type-system"; /** * @file These are not 'tests' but rather ways of running specific agents, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims-agent.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims-agent.ts index 0f92a435c7a..f6a9906eb5b 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims-agent.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims-agent.ts @@ -1,10 +1,5 @@ -import type { - BaseUrl, - EntityUuid, - OriginProvenance, - ProvidedEntityEditionProvenance, - VersionedUrl, -} from "@blockprotocol/type-system"; +import dedent from "dedent"; + import { entityIdFromComponents, mustHaveAtLeastOne, @@ -13,29 +8,36 @@ import { HashEntity, mergePropertyObjectAndMetadata, } from "@local/hash-graph-sdk/entity"; -import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import dedent from "dedent"; -import type { JSONSchemaDefinition } from "openai/lib/jsonschema"; import { extractErrorMessage } from "../../../infer-entities/shared/extract-validation-failure-details.js"; -import type { PropertyValueWithSimplifiedProperties } from "../../../infer-entities/shared/map-simplified-properties-to-properties.js"; import { mapSimplifiedPropertiesToProperties } from "../../../infer-entities/shared/map-simplified-properties-to-properties.js"; import { stripIdsFromDereferencedProperties } from "../../../infer-entities/shared/strip-ids-from-dereferenced-properties.js"; -import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { getLlmResponse } from "../../../shared/get-llm-response.js"; +import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; +import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { stringify } from "../../../shared/stringify.js"; + +import type { PropertyValueWithSimplifiedProperties } from "../../../infer-entities/shared/map-simplified-properties-to-properties.js"; +import type { DereferencedEntityType } from "../../../shared/dereference-entity-type.js"; import type { LlmMessage, LlmUserMessage, } from "../../../shared/get-llm-response/llm-message.js"; -import { getToolCallsFromLlmAssistantMessage } from "../../../shared/get-llm-response/llm-message.js"; import type { LlmToolDefinition } from "../../../shared/get-llm-response/types.js"; -import { graphApiClient } from "../../../shared/graph-api-client.js"; -import { stringify } from "../../../shared/stringify.js"; import type { ExistingEntitySummary } from "../../research-entities-action/coordinating-agent/summarize-existing-entities.js"; import type { Claim } from "../claims.js"; import type { LocalEntitySummary } from "../infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; +import type { + BaseUrl, + EntityUuid, + OriginProvenance, + ProvidedEntityEditionProvenance, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; +import type { JSONSchemaDefinition } from "openai/lib/jsonschema"; const mapPropertiesSchemaToInputPropertiesSchema = (params: { properties: DereferencedEntityType["properties"]; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims.ai.test.ts index 088ecf14cd4..069ae625b49 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/shared/propose-entities-from-claims/propose-entity-from-claims.ai.test.ts @@ -1,24 +1,25 @@ import "../../../../shared/testing-utilities/mock-get-flow-context.js"; +import { expect, test } from "vitest"; -import type { - EntityUuid, - Timestamp, - Url, - WebId, -} from "@blockprotocol/type-system"; import { currentTimestamp, entityIdFromComponents, } from "@blockprotocol/type-system"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { expect, test } from "vitest"; import { getDereferencedEntityTypesActivity } from "../../../get-dereferenced-entity-types-activity.js"; import { getFlowContext } from "../../../shared/get-flow-context.js"; import { graphApiClient } from "../../../shared/graph-api-client.js"; +import { proposeEntityFromClaimsAgent } from "./propose-entity-from-claims-agent.js"; + import type { Claim } from "../claims.js"; import type { LocalEntitySummary } from "../infer-summaries-then-claims-from-text/get-entity-summaries-from-text.js"; -import { proposeEntityFromClaimsAgent } from "./propose-entity-from-claims-agent.js"; +import type { + EntityUuid, + Timestamp, + Url, + WebId, +} from "@blockprotocol/type-system"; /** * @file These are not 'tests' but rather ways of running specific agents, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/web-search-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/web-search-action.ts index 319d779290a..2fcb5649dcf 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/web-search-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/web-search-action.ts @@ -1,13 +1,15 @@ -import type { Url } from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import { backOff } from "exponential-backoff"; + import { internalApiClient } from "@local/hash-backend-utils/internal-api-client"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { GetWebSearchResults200ResponseWebSearchResultsInner } from "@local/internal-api-client"; import { StatusCode } from "@local/status"; -import { backOff } from "exponential-backoff"; import { logger } from "../shared/activity-logger.js"; +import type { Url } from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { GetWebSearchResults200ResponseWebSearchResultsInner } from "@local/internal-api-client"; + export type GetWebSearchResultsResponse = Omit< GetWebSearchResults200ResponseWebSearchResultsInner, "url" diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action.ts index b2d4bfab37a..cc1186273e1 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action.ts @@ -1,8 +1,6 @@ -import type { - OriginProvenance, - ProvidedEntityEditionProvenance, -} from "@blockprotocol/type-system"; -import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import { Context } from "@temporalio/activity"; +import { google } from "googleapis"; + import { getStorageProvider, resolvePayloadValue, @@ -13,13 +11,8 @@ import { getTokensForGoogleAccount, } from "@local/hash-backend-utils/google"; import { getWebMachineId } from "@local/hash-backend-utils/machine-actors"; -import type { VaultClient } from "@local/hash-backend-utils/vault"; import { HashEntity } from "@local/hash-graph-sdk/entity"; import { getSimplifiedAiFlowActionInputs } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import type { - PersistedEntitiesMetadata, - StoredPayloadRef, -} from "@local/hash-isomorphic-utils/flows/types"; import { isStoredPayloadRef } from "@local/hash-isomorphic-utils/flows/types"; import { generateEntityIdFilter } from "@local/hash-isomorphic-utils/graph-queries"; import { @@ -27,14 +20,7 @@ import { systemLinkEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - AssociatedWithAccount, - GoogleSheetsFile, -} from "@local/hash-isomorphic-utils/system-types/google/googlesheetsfile"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; -import type { sheets_v4 } from "googleapis"; -import { google } from "googleapis"; import { getEntityByFilter } from "../shared/get-entity-by-filter.js"; import { getFlowContext } from "../shared/get-flow-context.js"; @@ -45,6 +31,22 @@ import { convertSubgraphToSheetRequests } from "./write-google-sheet-action/conv import { getFilterFromBlockProtocolQueryEntity } from "./write-google-sheet-action/get-filter-from-bp-query-entity.js"; import { getSubgraphFromFilter } from "./write-google-sheet-action/get-subgraph-from-filter.js"; +import type { + OriginProvenance, + ProvidedEntityEditionProvenance, +} from "@blockprotocol/type-system"; +import type { AiFlowActionActivity } from "@local/hash-backend-utils/flows"; +import type { VaultClient } from "@local/hash-backend-utils/vault"; +import type { + PersistedEntitiesMetadata, + StoredPayloadRef, +} from "@local/hash-isomorphic-utils/flows/types"; +import type { + AssociatedWithAccount, + GoogleSheetsFile, +} from "@local/hash-isomorphic-utils/system-types/google/googlesheetsfile"; +import type { sheets_v4 } from "googleapis"; + const createSpreadsheet = async ({ filename, sheetsClient, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-csv-to-sheet-requests.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-csv-to-sheet-requests.ts index 50fd3e7c25d..456a62b4cd0 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-csv-to-sheet-requests.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-csv-to-sheet-requests.ts @@ -1,9 +1,10 @@ -import type { sheets_v4 } from "googleapis"; -import type { ParseResult } from "papaparse"; import Papa from "papaparse"; import { createCellFromValue } from "./shared/create-sheet-data.js"; +import type { sheets_v4 } from "googleapis"; +import type { ParseResult } from "papaparse"; + type SheetOutputFormat = { audience: "user" | "machine"; }; diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-subgraph-to-sheet-requests.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-subgraph-to-sheet-requests.ts index c74eaa317b2..2645510d12c 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-subgraph-to-sheet-requests.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/convert-subgraph-to-sheet-requests.ts @@ -10,13 +10,6 @@ import { getEntityTypeById, getPropertyTypeForEntity, } from "@blockprotocol/graph/stdlib"; -import type { - BaseUrl, - EntityId, - EntityType, - OntologyTypeVersion, - VersionedUrl, -} from "@blockprotocol/type-system"; import { typedEntries, typedKeys, @@ -25,15 +18,23 @@ import { import { isDraftEntity } from "@local/hash-isomorphic-utils/entity-store"; import { generateEntityLabel } from "@local/hash-isomorphic-utils/generate-entity-label"; import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { sheets_v4 } from "googleapis"; -import type { SheetOutputFormat } from "./shared/config.js"; import { createCellFromValue, createHyperlinkCell, } from "./shared/create-sheet-data.js"; import { cellHeaderFormat } from "./shared/format.js"; +import type { SheetOutputFormat } from "./shared/config.js"; +import type { + BaseUrl, + EntityId, + EntityType, + OntologyTypeVersion, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { sheets_v4 } from "googleapis"; + type ColumnsForEntity = { columns: Record< string, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-filter-from-bp-query-entity.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-filter-from-bp-query-entity.ts index 912ace46f58..d148e3e559e 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-filter-from-bp-query-entity.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-filter-from-bp-query-entity.ts @@ -1,13 +1,14 @@ +import { convertBpFilterToGraphFilter } from "@local/hash-graph-sdk/filter"; +import { blockProtocolPropertyTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { getLatestEntityById } from "../shared/graph-requests.js"; + import type { MultiFilter } from "@blockprotocol/graph"; import type { ActorEntityUuid, EntityId } from "@blockprotocol/type-system"; import type { GraphApi } from "@local/hash-graph-client"; import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import { convertBpFilterToGraphFilter } from "@local/hash-graph-sdk/filter"; -import { blockProtocolPropertyTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import type { Query } from "@local/hash-isomorphic-utils/system-types/blockprotocol/query"; -import { getLatestEntityById } from "../shared/graph-requests.js"; - export const getFilterFromBlockProtocolQueryEntity = async ({ authentication, graphApiClient, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-subgraph-from-filter.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-subgraph-from-filter.ts index f927dc6a35c..bf2735ef109 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-subgraph-from-filter.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/get-subgraph-from-filter.ts @@ -1,11 +1,12 @@ +import { queryEntitySubgraph } from "@local/hash-graph-sdk/entity"; +import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; + import type { ActorEntityUuid } from "@blockprotocol/type-system"; import type { EntityTraversalPath, Filter, GraphApi, } from "@local/hash-graph-client"; -import { queryEntitySubgraph } from "@local/hash-graph-sdk/entity"; -import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; export const getSubgraphFromFilter = async ({ authentication, diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/shared/create-sheet-data.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/shared/create-sheet-data.ts index e2a4ef8beb6..6fa88e2b057 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/shared/create-sheet-data.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/write-google-sheet-action/shared/create-sheet-data.ts @@ -1,8 +1,9 @@ import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; -import type { sheets_v4 } from "googleapis"; import { cellHeaderFormat, cellPadding } from "./format.js"; +import type { sheets_v4 } from "googleapis"; + export const createCellFromValue = ({ value, applyDefaultHeaderFormat, diff --git a/apps/hash-ai-worker-ts/src/activities/get-ai-assistant-account-id-activity.ts b/apps/hash-ai-worker-ts/src/activities/get-ai-assistant-account-id-activity.ts index 9f68de2bc3e..4506e34f484 100644 --- a/apps/hash-ai-worker-ts/src/activities/get-ai-assistant-account-id-activity.ts +++ b/apps/hash-ai-worker-ts/src/activities/get-ai-assistant-account-id-activity.ts @@ -1,11 +1,12 @@ -import type { ActorEntityUuid, AiId, WebId } from "@blockprotocol/type-system"; import { getAiIdByIdentifier } from "@local/hash-backend-utils/machine-actors"; -import type { GraphApi } from "@local/hash-graph-client"; import { addActorGroupMember, getActorGroupRole, } from "@local/hash-graph-sdk/principal/actor-group"; +import type { ActorEntityUuid, AiId, WebId } from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; + export const getAiAssistantAccountIdActivity = async (params: { authentication: { actorId: ActorEntityUuid }; grantCreatePermissionForWeb?: WebId; diff --git a/apps/hash-ai-worker-ts/src/activities/get-dereferenced-entity-types-activity.ts b/apps/hash-ai-worker-ts/src/activities/get-dereferenced-entity-types-activity.ts index 718da7cf0e6..1c28e99a5a8 100644 --- a/apps/hash-ai-worker-ts/src/activities/get-dereferenced-entity-types-activity.ts +++ b/apps/hash-ai-worker-ts/src/activities/get-dereferenced-entity-types-activity.ts @@ -1,13 +1,15 @@ -import type { ActorEntityUuid, VersionedUrl } from "@blockprotocol/type-system"; +import { backOff } from "exponential-backoff"; + import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { GraphApi } from "@local/hash-graph-client"; import { queryEntityTypeSubgraph } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; -import { backOff } from "exponential-backoff"; -import type { DereferencedEntityTypesByTypeId } from "./infer-entities/inference-types.js"; import { dereferenceEntityType } from "./shared/dereference-entity-type.js"; +import type { DereferencedEntityTypesByTypeId } from "./infer-entities/inference-types.js"; +import type { ActorEntityUuid, VersionedUrl } from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; + /** * @see {@link dereferenceEntityType} * diff --git a/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ai.test.ts index 2c8ad82118d..c9df13254b8 100644 --- a/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ai.test.ts @@ -1,6 +1,4 @@ import "../shared/testing-utilities/mock-get-flow-context.js"; - -import type { Url } from "@blockprotocol/type-system"; import { expect, test } from "vitest"; import { @@ -8,6 +6,8 @@ import { sanitizeHtmlForLlmConsumption, } from "./get-web-page-activity.js"; +import type { Url } from "@blockprotocol/type-system"; + test.skip( "Test getWebPageActivity with a Wikipedia page", async () => { diff --git a/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ts b/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ts index 9d0cc2de574..e04d8e85dab 100644 --- a/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ts +++ b/apps/hash-ai-worker-ts/src/activities/get-web-page-activity.ts @@ -1,20 +1,22 @@ -import type { Url } from "@blockprotocol/type-system"; -import { validateExternalUrlWithDnsCheck } from "@local/hash-backend-utils/url-validation"; -import type { - FlowInternetAccessSettings, - WebPage, -} from "@local/hash-isomorphic-utils/flows/types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { stringifyError } from "@local/hash-isomorphic-utils/stringify-error"; import { Context } from "@temporalio/activity"; import { JSDOM } from "jsdom"; import puppeteer from "puppeteer-core"; import sanitizeHtml from "sanitize-html"; +import { validateExternalUrlWithDnsCheck } from "@local/hash-backend-utils/url-validation"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; +import { stringifyError } from "@local/hash-isomorphic-utils/stringify-error"; + import { logger } from "./shared/activity-logger.js"; import { getFlowContext } from "./shared/get-flow-context.js"; import { requestExternalInput } from "./shared/request-external-input.js"; +import type { Url } from "@blockprotocol/type-system"; +import type { + FlowInternetAccessSettings, + WebPage, +} from "@local/hash-isomorphic-utils/flows/types"; + const sliceContentForLlmConsumption = (params: { content: string; maximumNumberOfTokens?: number; diff --git a/apps/hash-ai-worker-ts/src/activities/graph.ts b/apps/hash-ai-worker-ts/src/activities/graph.ts index bf48d817874..9d7229b4d9b 100644 --- a/apps/hash-ai-worker-ts/src/activities/graph.ts +++ b/apps/hash-ai-worker-ts/src/activities/graph.ts @@ -4,22 +4,7 @@ import { getEntityTypes, getPropertyTypes, } from "@blockprotocol/graph/stdlib"; -import type { - ActorEntityUuid, - DataTypeWithMetadata, - EntityId, - EntityTypeWithMetadata, - PropertyTypeWithMetadata, -} from "@blockprotocol/type-system"; import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; -import type { - EntityQueryCursor, - GraphApi, - UpdateDataTypeEmbeddingParams, - UpdateEntityTypeEmbeddingParams, - UpdatePropertyTypeEmbeddingParams, -} from "@local/hash-graph-client"; -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; import { queryDataTypes, type QueryDataTypesParams, @@ -29,16 +14,6 @@ import { type SerializedQueryDataTypeSubgraphResponse, serializeQueryDataTypeSubgraphResponse, } from "@local/hash-graph-sdk/data-type"; -import type { - CreateEntityParameters, - QueryEntitiesRequest, - QueryEntitySubgraphRequest, - SerializedEntity, - SerializedEntityRootType, - SerializedQueryEntitiesResponse, - SerializedQueryEntitySubgraphResponse, - SerializedSubgraph, -} from "@local/hash-graph-sdk/entity"; import { HashEntity, queryEntities, @@ -73,6 +48,32 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; +import type { + ActorEntityUuid, + DataTypeWithMetadata, + EntityId, + EntityTypeWithMetadata, + PropertyTypeWithMetadata, +} from "@blockprotocol/type-system"; +import type { + EntityQueryCursor, + GraphApi, + UpdateDataTypeEmbeddingParams, + UpdateEntityTypeEmbeddingParams, + UpdatePropertyTypeEmbeddingParams, +} from "@local/hash-graph-client"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; +import type { + CreateEntityParameters, + QueryEntitiesRequest, + QueryEntitySubgraphRequest, + SerializedEntity, + SerializedEntityRootType, + SerializedQueryEntitiesResponse, + SerializedQueryEntitySubgraphResponse, + SerializedSubgraph, +} from "@local/hash-graph-sdk/entity"; + export type EntityQueryResponse = { subgraph: SerializedSubgraph; cursor?: EntityQueryCursor | null; diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities-from-web-page-activity.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities-from-web-page-activity.ts index a30a6e7d214..caadf26330e 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities-from-web-page-activity.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities-from-web-page-activity.ts @@ -1,19 +1,21 @@ -import type { WebPage } from "@local/hash-isomorphic-utils/flows/types"; -import { StatusCode } from "@local/status"; import dedent from "dedent"; +import { StatusCode } from "@local/status"; + import { inferEntitySummariesFromWebPage } from "./infer-entities/infer-entity-summaries-from-web-page.js"; -import type { - DereferencedEntityTypesByTypeId, - InferenceState, -} from "./infer-entities/inference-types.js"; import { proposeEntities } from "./infer-entities/propose-entities.js"; import { logger } from "./shared/activity-logger.js"; import { getFlowContext } from "./shared/get-flow-context.js"; import { graphApiClient } from "./shared/graph-api-client.js"; -import type { PermittedOpenAiModel } from "./shared/openai-client.js"; import { stringify } from "./shared/stringify.js"; +import type { + DereferencedEntityTypesByTypeId, + InferenceState, +} from "./infer-entities/inference-types.js"; +import type { PermittedOpenAiModel } from "./shared/openai-client.js"; +import type { WebPage } from "@local/hash-isomorphic-utils/flows/types"; + export const inferEntitiesFromWebPageActivity = async (params: { webPage: WebPage | string; relevantEntitiesPrompt?: string; diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries-from-web-page.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries-from-web-page.ts index e86b968ad93..c346eb491f7 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries-from-web-page.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries-from-web-page.ts @@ -1,14 +1,15 @@ -import type { EntityId, UserId, WebId } from "@blockprotocol/type-system"; -import type { GraphApi } from "@local/hash-graph-client"; -import type { WebPage } from "@local/hash-isomorphic-utils/flows/types"; import dedent from "dedent"; -import type { PermittedOpenAiModel } from "../shared/openai-client.js"; import { inferEntitySummaries } from "./infer-entity-summaries.js"; + +import type { PermittedOpenAiModel } from "../shared/openai-client.js"; import type { DereferencedEntityTypesByTypeId, InferenceState, } from "./inference-types.js"; +import type { EntityId, UserId, WebId } from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; +import type { WebPage } from "@local/hash-isomorphic-utils/flows/types"; export const inferEntitySummariesFromWebPage = async (params: { webPage: WebPage | string; diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries.ts index 8b17d99b9e2..26c0e5875ba 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries.ts @@ -1,14 +1,6 @@ -import type { - EntityId, - UserId, - VersionedUrl, - WebId, -} from "@blockprotocol/type-system"; -import type { GraphApi } from "@local/hash-graph-client"; -import type { Status } from "@local/status"; -import { StatusCode } from "@local/status"; import dedent from "dedent"; -import type OpenAI from "openai"; + +import { StatusCode } from "@local/status"; import { logger } from "../shared/activity-logger.js"; import { getFlowContext } from "../shared/get-flow-context.js"; @@ -21,20 +13,30 @@ import { } from "../shared/get-llm-response/llm-message.js"; import { stringify } from "../shared/stringify.js"; import { inferEntitiesSystemPrompt } from "./infer-entities-system-prompt.js"; -import type { - CouldNotInferEntitiesReturn, - ProposedEntitySummariesByType, -} from "./infer-entity-summaries/generate-summary-tools.js"; import { generateSummaryTools, validateEntitySummariesByType, } from "./infer-entity-summaries/generate-summary-tools.js"; + +import type { + CouldNotInferEntitiesReturn, + ProposedEntitySummariesByType, +} from "./infer-entity-summaries/generate-summary-tools.js"; import type { CompletionPayload, DereferencedEntityTypesByTypeId, InferenceState, ProposedEntitySummary, } from "./inference-types.js"; +import type { + EntityId, + UserId, + VersionedUrl, + WebId, +} from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; +import type { Status } from "@local/status"; +import type OpenAI from "openai"; export const inferEntitySummaries = async (params: { completionPayload: CompletionPayload; diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries/generate-summary-tools.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries/generate-summary-tools.ts index a96f4bdbfeb..8a6148ba89b 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries/generate-summary-tools.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/infer-entity-summaries/generate-summary-tools.ts @@ -1,18 +1,19 @@ -import type { JsonObject } from "@blockprotocol/core"; -import type { VersionedUrl } from "@blockprotocol/type-system"; import { validateVersionedUrl } from "@blockprotocol/type-system"; -import type { Subtype } from "@local/advanced-types/subtype"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { JSONSchema } from "openai/lib/jsonschema"; + +import { stringify } from "../../shared/stringify.js"; +import { generateToolLinkFields } from "../shared/generate-propose-entities-tools.js"; import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; import type { LlmToolDefinition } from "../../shared/get-llm-response/types.js"; -import { stringify } from "../../shared/stringify.js"; import type { DereferencedEntityTypesByTypeId, ProposedEntitySummary, } from "../inference-types.js"; -import { generateToolLinkFields } from "../shared/generate-propose-entities-tools.js"; +import type { JsonObject } from "@blockprotocol/core"; +import type { VersionedUrl } from "@blockprotocol/type-system"; +import type { Subtype } from "@local/advanced-types/subtype"; +import type { JSONSchema } from "openai/lib/jsonschema"; type FunctionName = "could_not_infer_entities" | "register_entity_summaries"; diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/inference-types.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/inference-types.ts index 9e02e99f9bb..0627109a847 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/inference-types.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/inference-types.ts @@ -1,3 +1,6 @@ +import type { DereferencedEntityTypeWithSimplifiedKeys } from "../shared/dereference-entity-type.js"; +import type { LlmUsage } from "../shared/get-llm-response/types.js"; +import type { PermittedOpenAiModel } from "../shared/openai-client.js"; import type { VersionedUrl } from "@blockprotocol/type-system"; import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; import type { @@ -6,10 +9,6 @@ import type { } from "@local/hash-isomorphic-utils/ai-inference-types"; import type OpenAI from "openai"; -import type { DereferencedEntityTypeWithSimplifiedKeys } from "../shared/dereference-entity-type.js"; -import type { LlmUsage } from "../shared/get-llm-response/types.js"; -import type { PermittedOpenAiModel } from "../shared/openai-client.js"; - export type CompletionPayload = Omit< OpenAI.ChatCompletionCreateParams, "stream" | "tools" | "model" diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/persist-entities/generate-persist-entities-tools.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/persist-entities/generate-persist-entities-tools.ts index dd80666b04c..0288ac0759b 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/persist-entities/generate-persist-entities-tools.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/persist-entities/generate-persist-entities-tools.ts @@ -1,7 +1,6 @@ -import type { JsonObject } from "@blockprotocol/core"; - import type { ProposedEntityToolCreationsByType } from "../shared/generate-propose-entities-tools.js"; import type { PropertyValueWithSimplifiedProperties } from "../shared/map-simplified-properties-to-properties.js"; +import type { JsonObject } from "@blockprotocol/core"; export type ProposedEntityToolUpdatesByType = Record< string, diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/propose-entities.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/propose-entities.ts index 833c0b9da7f..94bfd16b081 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/propose-entities.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/propose-entities.ts @@ -1,34 +1,36 @@ -import type { EntityUuid, VersionedUrl } from "@blockprotocol/type-system"; +import { Context } from "@temporalio/activity"; +import dedent from "dedent"; + import { entityIdFromComponents } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; import { mergePropertyObjectAndMetadata } from "@local/hash-graph-sdk/entity"; -import type { DeprecatedProposedEntity } from "@local/hash-isomorphic-utils/ai-inference-types"; -import type { Status } from "@local/status"; import { StatusCode } from "@local/status"; -import { Context } from "@temporalio/activity"; -import dedent from "dedent"; import { logger } from "../shared/activity-logger.js"; import { getFlowContext } from "../shared/get-flow-context.js"; import { getLlmResponse } from "../shared/get-llm-response.js"; -import type { - LlmMessage, - LlmUserMessage, -} from "../shared/get-llm-response/llm-message.js"; import { getToolCallsFromLlmAssistantMessage } from "../shared/get-llm-response/llm-message.js"; import { graphApiClient } from "../shared/graph-api-client.js"; import { logProgress } from "../shared/log-progress.js"; import { stringify } from "../shared/stringify.js"; import { inferEntitiesSystemPrompt } from "./infer-entities-system-prompt.js"; +import { validateProposedEntitiesByType } from "./persist-entities/generate-persist-entities-tools.js"; +import { extractErrorMessage } from "./shared/extract-validation-failure-details.js"; +import { generateProposeEntitiesTools } from "./shared/generate-propose-entities-tools.js"; +import { mapSimplifiedPropertiesToProperties } from "./shared/map-simplified-properties-to-properties.js"; + +import type { + LlmMessage, + LlmUserMessage, +} from "../shared/get-llm-response/llm-message.js"; import type { DereferencedEntityTypesByTypeId, InferenceState, } from "./inference-types.js"; -import { validateProposedEntitiesByType } from "./persist-entities/generate-persist-entities-tools.js"; -import { extractErrorMessage } from "./shared/extract-validation-failure-details.js"; import type { ProposedEntityToolCreationsByType } from "./shared/generate-propose-entities-tools.js"; -import { generateProposeEntitiesTools } from "./shared/generate-propose-entities-tools.js"; -import { mapSimplifiedPropertiesToProperties } from "./shared/map-simplified-properties-to-properties.js"; +import type { EntityUuid, VersionedUrl } from "@blockprotocol/type-system"; +import type { DeprecatedProposedEntity } from "@local/hash-isomorphic-utils/ai-inference-types"; +import type { Status } from "@local/status"; /** * This method is used by the 'infer-entities-from-web-page-activity', which is used by the browser plugin inference flow. diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/generate-propose-entities-tools.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/generate-propose-entities-tools.ts index ac220fdd735..42aada01e94 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/generate-propose-entities-tools.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/generate-propose-entities-tools.ts @@ -1,3 +1,9 @@ +import { generateSimplifiedTypeId } from "./generate-simplified-type-id.js"; +import { stripIdsFromDereferencedProperties } from "./strip-ids-from-dereferenced-properties.js"; + +import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; +import type { LlmToolDefinition } from "../../shared/get-llm-response/types.js"; +import type { PropertyValueWithSimplifiedProperties } from "./map-simplified-properties-to-properties.js"; import type { VersionedUrl } from "@blockprotocol/type-system"; import type { DistributiveOmit } from "@local/advanced-types/distribute"; import type { @@ -6,12 +12,6 @@ import type { } from "@local/hash-isomorphic-utils/ai-inference-types"; import type { JSONSchema } from "openai/lib/jsonschema"; -import type { DereferencedEntityType } from "../../shared/dereference-entity-type.js"; -import type { LlmToolDefinition } from "../../shared/get-llm-response/types.js"; -import { generateSimplifiedTypeId } from "./generate-simplified-type-id.js"; -import type { PropertyValueWithSimplifiedProperties } from "./map-simplified-properties-to-properties.js"; -import { stripIdsFromDereferencedProperties } from "./strip-ids-from-dereferenced-properties.js"; - export type ProposeEntitiesToolName = "abandon_entities" | "create_entities"; type ProposedEntityWithSimplifiedProperties = DistributiveOmit< diff --git a/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/strip-ids-from-dereferenced-properties.ts b/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/strip-ids-from-dereferenced-properties.ts index 09460d1b1d2..585fbf2468d 100644 --- a/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/strip-ids-from-dereferenced-properties.ts +++ b/apps/hash-ai-worker-ts/src/activities/infer-entities/shared/strip-ids-from-dereferenced-properties.ts @@ -1,8 +1,7 @@ +import type { DereferencedPropertyType } from "../../shared/dereference-entity-type.js"; import type { PropertyValueArray } from "@blockprotocol/type-system"; import type { JSONSchemaDefinition } from "openai/lib/jsonschema"; -import type { DereferencedPropertyType } from "../../shared/dereference-entity-type.js"; - /** * Strip the `$id` field from the dereferenced property type definitions, * as it confuses Anthropic's model (it opts for using the $id as the diff --git a/apps/hash-ai-worker-ts/src/activities/parse-text-from-file.ts b/apps/hash-ai-worker-ts/src/activities/parse-text-from-file.ts index 152f51ded34..961239b4bc2 100644 --- a/apps/hash-ai-worker-ts/src/activities/parse-text-from-file.ts +++ b/apps/hash-ai-worker-ts/src/activities/parse-text-from-file.ts @@ -1,21 +1,23 @@ -import type { - OriginProvenance, - ProvidedEntityEditionProvenance, - VersionedUrl, -} from "@blockprotocol/type-system"; -import type { GraphApi } from "@local/hash-graph-client"; +import officeParser from "officeparser"; + import { HashEntity } from "@local/hash-graph-sdk/entity"; import { blockProtocolPropertyTypes, systemEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; -import type { TextualContentPropertyValueWithMetadata } from "@local/hash-isomorphic-utils/system-types/shared"; -import officeParser from "officeparser"; import { fetchFileFromUrl } from "./shared/fetch-file-from-url.js"; import { getFlowContext } from "./shared/get-flow-context.js"; +import type { + OriginProvenance, + ProvidedEntityEditionProvenance, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; +import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; +import type { TextualContentPropertyValueWithMetadata } from "@local/hash-isomorphic-utils/system-types/shared"; + type TextParsingFunction = (fileBuffer: Buffer) => Promise; const officeParserTextParsingFunction: TextParsingFunction = async ( diff --git a/apps/hash-ai-worker-ts/src/activities/shared/activity-logger.ts b/apps/hash-ai-worker-ts/src/activities/shared/activity-logger.ts index e37d598c1f5..355944ac57e 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/activity-logger.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/activity-logger.ts @@ -2,9 +2,10 @@ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import { safeStringify } from "@local/hash-backend-utils/logger"; import { Context } from "@temporalio/activity"; +import { safeStringify } from "@local/hash-backend-utils/logger"; + import { logger as baseLogger } from "../../shared/logger.js"; const __filename = fileURLToPath(import.meta.url); diff --git a/apps/hash-ai-worker-ts/src/activities/shared/create-inferred-entity-notification.ts b/apps/hash-ai-worker-ts/src/activities/shared/create-inferred-entity-notification.ts index 54e01c3b37b..988251e5cfb 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/create-inferred-entity-notification.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/create-inferred-entity-notification.ts @@ -1,6 +1,7 @@ -import type { UserId } from "@blockprotocol/type-system"; import { extractDraftIdFromEntityId } from "@blockprotocol/type-system"; import { createGraphChangeNotification } from "@local/hash-backend-utils/notifications"; + +import type { UserId } from "@blockprotocol/type-system"; import type { GraphApi } from "@local/hash-graph-client"; import type { HashEntity } from "@local/hash-graph-sdk/entity"; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.test.ts b/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.test.ts index 3146a6b2510..b70012f26c7 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.test.ts @@ -1,10 +1,12 @@ -import type { Subgraph } from "@blockprotocol/graph"; -import type { Subgraph as ApiClientSubgraph } from "@local/hash-graph-client"; -import { mapGraphApiVerticesToVertices } from "@local/hash-graph-sdk/subgraph"; import { describe, expect, it } from "vitest"; +import { mapGraphApiVerticesToVertices } from "@local/hash-graph-sdk/subgraph"; + import { dereferenceEntityType } from "./dereference-entity-type.js"; +import type { Subgraph } from "@blockprotocol/graph"; +import type { Subgraph as ApiClientSubgraph } from "@local/hash-graph-client"; + const testSubgraph: Pick = { edges: { "https://hash.ai/@test/types/property-type/mixed-array/": { diff --git a/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.ts b/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.ts index 7eb1a724990..4d5d861d382 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/dereference-entity-type.ts @@ -1,9 +1,21 @@ -import type { Subgraph } from "@blockprotocol/graph"; import { getDataTypeById, getEntityTypeAndParentsById, getPropertyTypeById, } from "@blockprotocol/graph/stdlib"; +import { + atLeastOne, + compareOntologyTypeVersions, + componentsFromVersionedUrl, + extractBaseUrl, + extractVersion, +} from "@blockprotocol/type-system"; +import { typedEntries } from "@local/advanced-types/typed-entries"; +import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { generateSimplifiedTypeId } from "../infer-entities/shared/generate-simplified-type-id.js"; + +import type { Subgraph } from "@blockprotocol/graph"; import type { BaseUrl, DataType, @@ -16,18 +28,7 @@ import type { ValueOrArray, VersionedUrl, } from "@blockprotocol/type-system"; -import { - atLeastOne, - compareOntologyTypeVersions, - componentsFromVersionedUrl, - extractBaseUrl, - extractVersion, -} from "@blockprotocol/type-system"; import type { DistributiveOmit } from "@local/advanced-types/distribute"; -import { typedEntries } from "@local/advanced-types/typed-entries"; -import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; - -import { generateSimplifiedTypeId } from "../infer-entities/shared/generate-simplified-type-id.js"; type MinimalDataType = DistributiveOmit; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts b/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts index 321315c6591..82d44e7e0e4 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts @@ -1,3 +1,7 @@ +import OpenAI from "openai"; + +import { extractBaseUrl } from "@blockprotocol/type-system"; + import type { BaseUrl, DataTypeWithMetadata, @@ -8,9 +12,7 @@ import type { PropertyTypeWithMetadata, VersionedUrl, } from "@blockprotocol/type-system"; -import { extractBaseUrl } from "@blockprotocol/type-system"; import type { Embedding } from "@local/hash-graph-client"; -import OpenAI from "openai"; type Usage = OpenAI.CreateEmbeddingResponse.Usage; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/find-existing-entity.ts b/apps/hash-ai-worker-ts/src/activities/shared/find-existing-entity.ts index cbdefd34ca4..662cbcbb422 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/find-existing-entity.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/find-existing-entity.ts @@ -1,23 +1,11 @@ import { getRoots } from "@blockprotocol/graph/stdlib"; -import type { - ActorEntityUuid, - BaseUrl, - LinkData, - WebId, -} from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { - AllFilter, - CosineDistanceFilter, - GraphApi, -} from "@local/hash-graph-client"; import { HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; import { queryEntityTypeSubgraph } from "@local/hash-graph-sdk/entity-type"; -import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, @@ -26,7 +14,6 @@ import { import { deduplicateSources } from "@local/hash-isomorphic-utils/provenance"; import { logger } from "./activity-logger.js"; -import type { DereferencedEntityType } from "./dereference-entity-type.js"; import { dereferenceEntityType } from "./dereference-entity-type.js"; import { createEntityEmbeddings } from "./embeddings.js"; import { @@ -34,6 +21,20 @@ import { matchExistingEntity, } from "./match-existing-entity.js"; +import type { DereferencedEntityType } from "./dereference-entity-type.js"; +import type { + ActorEntityUuid, + BaseUrl, + LinkData, + WebId, +} from "@blockprotocol/type-system"; +import type { + AllFilter, + CosineDistanceFilter, + GraphApi, +} from "@local/hash-graph-client"; +import type { ProposedEntity } from "@local/hash-isomorphic-utils/flows/types"; + export const findExistingEntity = async ({ actorId, dereferencedEntityTypes, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-entity-by-filter.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-entity-by-filter.ts index 89bf43857c8..1f46256a582 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-entity-by-filter.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-entity-by-filter.ts @@ -1,8 +1,9 @@ -import type { ActorEntityUuid } from "@blockprotocol/type-system"; -import type { Filter, GraphApi } from "@local/hash-graph-client"; import { type HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; +import type { ActorEntityUuid } from "@blockprotocol/type-system"; +import type { Filter, GraphApi } from "@local/hash-graph-client"; + export const getEntityByFilter = async ({ actorId, graphApiClient, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-flow-context.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-flow-context.ts index 91e7ce4709d..51012404cba 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-flow-context.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-flow-context.ts @@ -1,4 +1,5 @@ -import type { EntityId, UserId, WebId } from "@blockprotocol/type-system"; +import { Context } from "@temporalio/activity"; + import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, @@ -10,18 +11,19 @@ import { import { createTemporalClient } from "@local/hash-backend-utils/temporal"; import { parseHistoryItemPayload } from "@local/hash-backend-utils/temporal/parse-history-item-payload"; import { type HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; +import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; +import { normalizeWhitespace } from "@local/hash-isomorphic-utils/normalize"; + +import { graphApiClient } from "./graph-api-client.js"; + +import type { EntityId, UserId, WebId } from "@blockprotocol/type-system"; import type { ManualInferenceTriggerInputName } from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-types"; import type { GoalFlowTriggerInput } from "@local/hash-isomorphic-utils/flows/goal-flow-definitions"; import type { RunAiFlowWorkflowParams } from "@local/hash-isomorphic-utils/flows/temporal-types"; import type { FlowDataSources } from "@local/hash-isomorphic-utils/flows/types"; -import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; -import { normalizeWhitespace } from "@local/hash-isomorphic-utils/normalize"; import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; -import { Context } from "@temporalio/activity"; import type { Client as TemporalClient } from "@temporalio/client"; -import { graphApiClient } from "./graph-api-client.js"; - let _temporalClient: TemporalClient | undefined; /** diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ai.test.ts index 72f6bbd8337..891d976d807 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ai.test.ts @@ -1,5 +1,4 @@ import "../../shared/testing-utilities/mock-get-flow-context.js"; - import { expect, test } from "vitest"; import { createAnthropicMessagesWithTools } from "./get-llm-response/anthropic-client.js"; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ts index 2bea1671218..425471821c3 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response.ts @@ -1,10 +1,8 @@ -import type { EntityId, UserId, WebId } from "@blockprotocol/type-system"; -import type { GraphApi } from "@local/hash-graph-client"; -import type { FlowUsageRecordCustomMetadata } from "@local/hash-isomorphic-utils/flows/types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; // import { StatusCode } from "@local/status"; import { backOff } from "exponential-backoff"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; + import { getAiAssistantAccountIdActivity } from "../get-ai-assistant-account-id-activity.js"; import { logger } from "./activity-logger.js"; import { getFlowContext } from "./get-flow-context.js"; @@ -13,15 +11,19 @@ import { getAnthropicResponse } from "./get-llm-response/get-anthropic-response. import { getGoogleAiResponse } from "./get-llm-response/get-google-ai-response.js"; import { getOpenAiResponse } from "./get-llm-response/get-openai-reponse.js"; import { logLlmRequest } from "./get-llm-response/log-llm-request.js"; +import { + isLlmParamsAnthropicLlmParams, + isLlmParamsGoogleAiParams, +} from "./get-llm-response/types.js"; + import type { LlmParams, LlmRequestMetadata, LlmResponse, } from "./get-llm-response/types.js"; -import { - isLlmParamsAnthropicLlmParams, - isLlmParamsGoogleAiParams, -} from "./get-llm-response/types.js"; +import type { EntityId, UserId, WebId } from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; +import type { FlowUsageRecordCustomMetadata } from "@local/hash-isomorphic-utils/flows/types"; export type UsageTrackingParams = { /** diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/anthropic-client.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/anthropic-client.ts index 1e3c63b42ed..7a5b6fc13e8 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/anthropic-client.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/anthropic-client.ts @@ -1,13 +1,15 @@ import { AnthropicBedrock } from "@anthropic-ai/bedrock-sdk"; import Anthropic from "@anthropic-ai/sdk"; +import { Context } from "@temporalio/activity"; + +import { getRequiredEnv } from "@local/hash-backend-utils/environment"; + import type { Message, MessageCreateParamsBase, MessageCreateParamsNonStreaming, ToolUseBlock, } from "@anthropic-ai/sdk/resources/messages"; -import { getRequiredEnv } from "@local/hash-backend-utils/environment"; -import { Context } from "@temporalio/activity"; const anthropicApiKey = getRequiredEnv("ANTHROPIC_API_KEY"); diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/check-web-service-usage-not-exceeded.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/check-web-service-usage-not-exceeded.ts index 6da2a2e78ba..3f3c74625f4 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/check-web-service-usage-not-exceeded.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/check-web-service-usage-not-exceeded.ts @@ -1,11 +1,12 @@ -import type { ActorEntityUuid, WebId } from "@blockprotocol/type-system"; import { generateTimestamp } from "@blockprotocol/type-system"; import { getWebServiceUsage } from "@local/hash-backend-utils/service-usage"; -import type { GraphApi } from "@local/hash-graph-client"; import { isUserHashInstanceAdmin } from "@local/hash-graph-sdk/principal/hash-instance-admins"; -import type { Status } from "@local/status"; import { StatusCode } from "@local/status"; +import type { ActorEntityUuid, WebId } from "@blockprotocol/type-system"; +import type { GraphApi } from "@local/hash-graph-client"; +import type { Status } from "@local/status"; + const usageCostLimit = { admin: { day: 30, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-anthropic-response.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-anthropic-response.ts index 8d0293bd972..68981853c0f 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-anthropic-response.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-anthropic-response.ts @@ -1,16 +1,9 @@ -import type { APIError, RateLimitError } from "@anthropic-ai/sdk/error"; -import type { Tool } from "@anthropic-ai/sdk/resources/messages"; import dedent from "dedent"; import { backOff } from "exponential-backoff"; import { logger } from "../activity-logger.js"; import { isActivityCancelled } from "../get-flow-context.js"; import { stringify } from "../stringify.js"; -import type { - AnthropicApiProvider, - AnthropicMessagesCreateParams, - AnthropicMessagesCreateResponse, -} from "./anthropic-client.js"; import { anthropicMessageModelToMaxOutput, createAnthropicMessagesWithTools, @@ -23,15 +16,25 @@ import { maxRetryCount, serverErrorRetryStartingDelay, } from "./constants.js"; -import type { - LlmMessageToolUseContent, - LlmUserMessage, -} from "./llm-message.js"; import { mapAnthropicMessageToLlmMessage, mapLlmMessageToAnthropicMessage, } from "./llm-message.js"; import { logLlmRequest, logLlmServerError } from "./log-llm-request.js"; +import { + getInputValidationErrors, + sanitizeInputBeforeValidation, +} from "./validation.js"; + +import type { + AnthropicApiProvider, + AnthropicMessagesCreateParams, + AnthropicMessagesCreateResponse, +} from "./anthropic-client.js"; +import type { + LlmMessageToolUseContent, + LlmUserMessage, +} from "./llm-message.js"; import type { AnthropicLlmParams, AnthropicResponse, @@ -42,10 +45,8 @@ import type { LlmUsage, ParsedLlmToolCall, } from "./types.js"; -import { - getInputValidationErrors, - sanitizeInputBeforeValidation, -} from "./validation.js"; +import type { APIError, RateLimitError } from "@anthropic-ai/sdk/error"; +import type { Tool } from "@anthropic-ai/sdk/resources/messages"; const mapLlmToolDefinitionToAnthropicToolDefinition = ( tool: LlmToolDefinition, @@ -135,9 +136,7 @@ const isServerError = (error: unknown): error is APIError => error.status >= 500 && error.status < 600; -const switchProvider = ( - provider: AnthropicApiProvider, -): AnthropicApiProvider => +const switchProvider = (provider: AnthropicApiProvider): AnthropicApiProvider => provider === "anthropic" ? "amazon-bedrock" : "anthropic"; const createAnthropicMessagesWithToolsWithBackoff = async (params: { diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response.ts index 1ab8bc38c4c..b89cf673335 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response.ts @@ -6,8 +6,6 @@ import { type GenerateContentResponse, type Part, } from "@google-cloud/vertexai"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; import { logger } from "../activity-logger.js"; import { isActivityCancelled } from "../get-flow-context.js"; @@ -16,6 +14,7 @@ import { mapLlmContentToGooglePartAndUploadFiles } from "./get-google-ai-respons import { rewriteSchemaForGoogle } from "./get-google-ai-response/rewrite-schema-for-google.js"; import { getVertexAiClient } from "./google-vertex-ai-client.js"; import { type LlmMessage } from "./llm-message.js"; + import type { GoogleAiParams, LlmRequestMetadata, @@ -23,6 +22,8 @@ import type { LlmToolDefinition, LlmUsage, } from "./types.js"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; const mapLlmToolDefinitionToGoogleAiToolDefinition = ( tool: LlmToolDefinition, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/google-cloud-storage.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/google-cloud-storage.ts index c5c18a99be7..a75e4ad5c1a 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/google-cloud-storage.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/google-cloud-storage.ts @@ -1,9 +1,10 @@ import { Storage } from "@google-cloud/storage"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; import { logger } from "../../activity-logger.js"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; + let _googleCloudStorage: Storage | undefined; const storageBucket = process.env.GOOGLE_CLOUD_STORAGE_BUCKET; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-google-messages-to-llm-messages.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-google-messages-to-llm-messages.ts index 6ae2e02295e..a0da9b41a6c 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-google-messages-to-llm-messages.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-google-messages-to-llm-messages.ts @@ -1,10 +1,10 @@ +import { getFileEntityFromGcpStorageUri } from "./google-cloud-storage.js"; + +import type { LlmMessage } from "../llm-message.js"; import type { Content } from "@google-cloud/vertexai"; import type { HashEntity } from "@local/hash-graph-sdk/entity"; import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { LlmMessage } from "../llm-message.js"; -import { getFileEntityFromGcpStorageUri } from "./google-cloud-storage.js"; - export const mapGoogleMessagesToLlmMessages = (params: { messages: Content[]; fileEntities: Pick, "entityId" | "properties">[]; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-parts-and-upload-files.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-parts-and-upload-files.ts index 4f869c24f04..81c0b89df71 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-parts-and-upload-files.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/map-parts-and-upload-files.ts @@ -1,3 +1,7 @@ +import { useFileSystemPathFromEntity } from "../../use-file-system-file-from-url.js"; +import { uploadFileToGcpStorage } from "./google-cloud-storage.js"; + +import type { LlmMessage } from "../llm-message.js"; import type { PropertyValue } from "@blockprotocol/type-system"; import type { FileDataPart, @@ -7,10 +11,6 @@ import type { TextPart, } from "@google-cloud/vertexai"; -import { useFileSystemPathFromEntity } from "../../use-file-system-file-from-url.js"; -import type { LlmMessage } from "../llm-message.js"; -import { uploadFileToGcpStorage } from "./google-cloud-storage.js"; - export const mapLlmContentToGooglePartAndUploadFiles = async ( content: LlmMessage["content"][number], ): Promise => { diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/rewrite-schema-for-google.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/rewrite-schema-for-google.ts index 88ed15ef52e..58bceff0073 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/rewrite-schema-for-google.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-google-ai-response/rewrite-schema-for-google.ts @@ -1,9 +1,10 @@ -import { mustHaveAtLeastOne } from "@blockprotocol/type-system"; -import type { FunctionDeclarationSchema, Schema } from "@google-cloud/vertexai"; import { SchemaType } from "@google-cloud/vertexai"; -import type { JSONSchema } from "openai/lib/jsonschema.mjs"; + +import { mustHaveAtLeastOne } from "@blockprotocol/type-system"; import type { LlmToolDefinition } from "../types.js"; +import type { FunctionDeclarationSchema, Schema } from "@google-cloud/vertexai"; +import type { JSONSchema } from "openai/lib/jsonschema.mjs"; /** * @file diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-openai-reponse.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-openai-reponse.ts index bdb8166d771..0ed07a37879 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-openai-reponse.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/get-openai-reponse.ts @@ -1,9 +1,8 @@ import { Context } from "@temporalio/activity"; import dedent from "dedent"; import { backOff } from "exponential-backoff"; -import type { OpenAI } from "openai"; -import { APIError, RateLimitError } from "openai/error"; import { promptTokensEstimate } from "openai-chat-tokens"; +import { APIError, RateLimitError } from "openai/error"; import { logger } from "../activity-logger.js"; import { isActivityCancelled } from "../get-flow-context.js"; @@ -16,16 +15,21 @@ import { maxRetryCount, serverErrorRetryStartingDelay, } from "./constants.js"; -import type { - LlmAssistantMessage, - LlmMessageToolUseContent, - LlmUserMessage, -} from "./llm-message.js"; import { mapLlmMessageToOpenAiMessages, mapOpenAiMessagesToLlmMessages, } from "./llm-message.js"; import { logLlmRequest, logLlmServerError } from "./log-llm-request.js"; +import { + getInputValidationErrors, + sanitizeInputBeforeValidation, +} from "./validation.js"; + +import type { + LlmAssistantMessage, + LlmMessageToolUseContent, + LlmUserMessage, +} from "./llm-message.js"; import type { LlmRequestMetadata, LlmResponse, @@ -35,10 +39,7 @@ import type { OpenAiLlmParams, ParsedLlmToolCall, } from "./types.js"; -import { - getInputValidationErrors, - sanitizeInputBeforeValidation, -} from "./validation.js"; +import type { OpenAI } from "openai"; const mapLlmToolDefinitionToOpenAiToolDefinition = ( tool: LlmToolDefinition, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/google-vertex-ai-client.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/google-vertex-ai-client.ts index 1f7340b2518..1aebeab08e9 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/google-vertex-ai-client.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/google-vertex-ai-client.ts @@ -1,6 +1,7 @@ -import type { MessageCreateParamsBase } from "@anthropic-ai/sdk/resources/messages.mjs"; import { VertexAI } from "@google-cloud/vertexai"; +import type { MessageCreateParamsBase } from "@anthropic-ai/sdk/resources/messages.mjs"; + const permittedGoogleAiModels = [ "gemini-1.5-pro-002", ] satisfies MessageCreateParamsBase["model"][]; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/log-llm-request.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/log-llm-request.ts index 3d5427ec480..246c30e1f99 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/log-llm-request.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/log-llm-request.ts @@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url"; import { Context } from "@temporalio/activity"; import { logger } from "../activity-logger.js"; + import type { LlmLog, LlmServerErrorLog } from "./types.js"; const __filename = fileURLToPath(import.meta.url); diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/types.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/types.ts index af185cb32fd..bd157334a3a 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/types.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/types.ts @@ -1,8 +1,3 @@ -import type { GenerateContentResponse } from "@google-cloud/vertexai"; -import type { OpenAI } from "openai"; -import type { JSONSchema } from "openai/lib/jsonschema"; - -import type { PermittedOpenAiModel } from "../openai-client.js"; import { type AnthropicApiProvider, type AnthropicMessagesCreateParams, @@ -14,7 +9,12 @@ import { isPermittedGoogleAiModel, type PermittedGoogleAiModel, } from "./google-vertex-ai-client.js"; + +import type { PermittedOpenAiModel } from "../openai-client.js"; import type { LlmAssistantMessage, LlmMessage } from "./llm-message.js"; +import type { GenerateContentResponse } from "@google-cloud/vertexai"; +import type { OpenAI } from "openai"; +import type { JSONSchema } from "openai/lib/jsonschema"; export type LlmToolDefinition = { name: ToolName; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/validation.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/validation.ts index 1d8dbf7f1a6..a06fac84058 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/validation.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/validation.ts @@ -1,10 +1,11 @@ import _Ajv from "ajv"; import _addFormats from "ajv-formats"; -import type { JSONSchema } from "openai/lib/jsonschema"; import { logger } from "../activity-logger.js"; import { stringify } from "../stringify.js"; + import type { LlmToolDefinition } from "./types.js"; +import type { JSONSchema } from "openai/lib/jsonschema"; const Ajv = _Ajv as unknown as typeof _Ajv.default; const addFormats = _addFormats as unknown as typeof _addFormats.default; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/inference-model-alias-to-llm-model.ts b/apps/hash-ai-worker-ts/src/activities/shared/inference-model-alias-to-llm-model.ts index 713ca1d406f..619ab6bf8fe 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/inference-model-alias-to-llm-model.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/inference-model-alias-to-llm-model.ts @@ -1,6 +1,5 @@ -import type { InferenceModelName } from "@local/hash-isomorphic-utils/ai-inference-types"; - import type { LlmParams } from "./get-llm-response/types.js"; +import type { InferenceModelName } from "@local/hash-isomorphic-utils/ai-inference-types"; /** * A map of the API consumer-facing model names to the specific model names used to call the LLM APIs. diff --git a/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output-optimize/judge-test-data.ts b/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output-optimize/judge-test-data.ts index 0eec95abba8..f211ec0dddc 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output-optimize/judge-test-data.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output-optimize/judge-test-data.ts @@ -1,6 +1,5 @@ -import type { EntityId, PropertyValue } from "@blockprotocol/type-system"; - import type { LlmParams } from "../get-llm-response/types.js"; +import type { EntityId, PropertyValue } from "@blockprotocol/type-system"; type CorrectedValue = | { diff --git a/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output.optimize.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output.optimize.ai.test.ts index 8613fbd324e..bb720ad0ffc 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output.optimize.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-output.optimize.ai.test.ts @@ -1,13 +1,12 @@ import "../../shared/testing-utilities/mock-get-flow-context.js"; - import path from "node:path"; import { fileURLToPath } from "node:url"; -import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; import isEqual from "lodash/isEqual.js"; import { test } from "vitest"; -import type { LlmParams } from "./get-llm-response/types.js"; +import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; + import { judgeTestData } from "./judge-ai-output-optimize/judge-test-data.js"; import { judgeAiOutputs, @@ -15,6 +14,8 @@ import { judgeSystemPrompt, } from "./judge-ai-outputs.js"; import { optimizeSystemPrompt } from "./optimize-system-prompt.js"; + +import type { LlmParams } from "./get-llm-response/types.js"; import type { MetricDefinition } from "./optimize-system-prompt/types.js"; const metrics: MetricDefinition[] = judgeTestData.map( diff --git a/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-outputs.ts b/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-outputs.ts index 1921405965b..b9da4de9fcf 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-outputs.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/judge-ai-outputs.ts @@ -1,4 +1,3 @@ -import type { PropertyValue } from "@blockprotocol/type-system"; import get from "lodash/get.js"; import { logger } from "./activity-logger.js"; @@ -9,9 +8,11 @@ import { getToolCallsFromLlmAssistantMessage, type LlmUserMessage, } from "./get-llm-response/llm-message.js"; -import type { LlmParams, LlmToolDefinition } from "./get-llm-response/types.js"; import { graphApiClient } from "./graph-api-client.js"; +import type { LlmParams, LlmToolDefinition } from "./get-llm-response/types.js"; +import type { PropertyValue } from "@blockprotocol/type-system"; + type ExchangeToReview = Required> & Pick; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/log-progress.ts b/apps/hash-ai-worker-ts/src/activities/shared/log-progress.ts index 7ebff8472d0..3c1a443b237 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/log-progress.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/log-progress.ts @@ -1,12 +1,14 @@ -import { createTemporalClient } from "@local/hash-backend-utils/temporal"; -import type { StepProgressLog } from "@local/hash-isomorphic-utils/flows/types"; import { Context } from "@temporalio/activity"; -import type { Client as TemporalClient } from "@temporalio/client"; import debounce from "lodash/debounce.js"; +import { createTemporalClient } from "@local/hash-backend-utils/temporal"; + import { logProgressSignal } from "../../shared/signals.js"; import { logger } from "./activity-logger.js"; +import type { StepProgressLog } from "@local/hash-isomorphic-utils/flows/types"; +import type { Client as TemporalClient } from "@temporalio/client"; + let temporalClient: TemporalClient | undefined; const logQueueByRunId: Map = new Map(); diff --git a/apps/hash-ai-worker-ts/src/activities/shared/map-action-input-entities-to-entities.ts b/apps/hash-ai-worker-ts/src/activities/shared/map-action-input-entities-to-entities.ts index 5ba67f23936..161b5a67b78 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/map-action-input-entities-to-entities.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/map-action-input-entities-to-entities.ts @@ -1,13 +1,14 @@ -import type { ActorEntityUuid, EntityId } from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; +import { HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; +import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; + +import type { ActorEntityUuid, EntityId } from "@blockprotocol/type-system"; import type { GraphApi } from "@local/hash-graph-client"; import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; -import { HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; import type { PersistedEntitiesMetadata, PersistedEntityMetadata, } from "@local/hash-isomorphic-utils/flows/types"; -import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; export const mapActionInputEntitiesToEntities = async (params: { actorId: ActorEntityUuid; diff --git a/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.optimize.ai.test.ts b/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.optimize.ai.test.ts index aceee42d4cb..25efd62d15c 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.optimize.ai.test.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.optimize.ai.test.ts @@ -1,15 +1,9 @@ import "../../shared/testing-utilities/mock-get-flow-context.js"; - import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { - EntityId, - EntityUuid, - PropertyObjectMetadata, - ValueMetadata, - WebId, -} from "@blockprotocol/type-system"; +import { test } from "vitest"; + import { entityIdFromComponents } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; import { brandPropertyObject } from "@local/hash-graph-sdk/entity"; @@ -21,17 +15,24 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; -import type { PersonProperties } from "@local/hash-isomorphic-utils/system-types/shared"; -import { test } from "vitest"; -import type { LlmParams } from "./get-llm-response/types.js"; -import type { MatchExistingEntityParams } from "./match-existing-entity.js"; import { matchExistingEntity, matchExistingEntitySystemPrompt, } from "./match-existing-entity.js"; import { optimizeSystemPrompt } from "./optimize-system-prompt.js"; + +import type { LlmParams } from "./get-llm-response/types.js"; +import type { MatchExistingEntityParams } from "./match-existing-entity.js"; import type { MetricDefinition } from "./optimize-system-prompt/types.js"; +import type { + EntityId, + EntityUuid, + PropertyObjectMetadata, + ValueMetadata, + WebId, +} from "@blockprotocol/type-system"; +import type { PersonProperties } from "@local/hash-isomorphic-utils/system-types/shared"; const emptyMetadataObject: PropertyObjectMetadata = { value: {}, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.ts b/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.ts index 6ef47c93ba0..de3e882c424 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/match-existing-entity.ts @@ -1,25 +1,27 @@ -import type { - EntityId, - PropertyObject, - PropertyObjectMetadata, - SourceProvenance, - VersionedUrl, -} from "@blockprotocol/type-system"; +import dedent from "dedent"; + import { isValueMetadata } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { deduplicateSources } from "@local/hash-isomorphic-utils/provenance"; import { sleep } from "@local/hash-isomorphic-utils/sleep"; import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value"; -import dedent from "dedent"; import { logger } from "./activity-logger.js"; import { getFlowContext } from "./get-flow-context.js"; import { getLlmResponse } from "./get-llm-response.js"; import { getToolCallsFromLlmAssistantMessage } from "./get-llm-response/llm-message.js"; -import type { LlmParams, LlmToolDefinition } from "./get-llm-response/types.js"; import { graphApiClient } from "./graph-api-client.js"; +import type { LlmParams, LlmToolDefinition } from "./get-llm-response/types.js"; +import type { + EntityId, + PropertyObject, + PropertyObjectMetadata, + SourceProvenance, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; + export const matchExistingEntitySystemPrompt = ` You are managing a database of entities, which may be any type of thing. diff --git a/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt.ts b/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt.ts index c3083907349..663d7673e07 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt.ts @@ -1,10 +1,10 @@ import "../../shared/testing-utilities/mock-get-flow-context.js"; - import { existsSync, mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; -import type { LlmParams } from "./get-llm-response/types.js"; import { improveSystemPrompt } from "./optimize-system-prompt/improve-system-prompt.js"; + +import type { LlmParams } from "./get-llm-response/types.js"; import type { MetricDefinition, MetricResultsForModel, diff --git a/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt/improve-system-prompt.ts b/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt/improve-system-prompt.ts index 71ff31fafab..6ef67b5d80f 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt/improve-system-prompt.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/optimize-system-prompt/improve-system-prompt.ts @@ -7,8 +7,9 @@ import { getToolCallsFromLlmAssistantMessage, type LlmUserMessage, } from "../get-llm-response/llm-message.js"; -import type { LlmToolDefinition } from "../get-llm-response/types.js"; import { graphApiClient } from "../graph-api-client.js"; + +import type { LlmToolDefinition } from "../get-llm-response/types.js"; import type { MetricResultsForSystemPrompt } from "./types.js"; const improveSystemPromptSystemPrompt = dedent(` diff --git a/apps/hash-ai-worker-ts/src/activities/shared/request-external-input.ts b/apps/hash-ai-worker-ts/src/activities/shared/request-external-input.ts index 05de7f3b83b..b242a4a68e0 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/request-external-input.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/request-external-input.ts @@ -1,16 +1,18 @@ +import { Context } from "@temporalio/activity"; + import { createTemporalClient } from "@local/hash-backend-utils/temporal"; -import type { - ExternalInputRequestSignal, - ExternalInputResponseSignal, -} from "@local/hash-isomorphic-utils/flows/types"; import { sleep } from "@local/hash-isomorphic-utils/sleep"; -import { Context } from "@temporalio/activity"; -import type { Client as TemporalClient } from "@temporalio/client"; import { getExternalInputResponseQuery } from "../../shared/queries.js"; import { externalInputRequestSignal } from "../../shared/signals.js"; import { logger } from "./activity-logger.js"; +import type { + ExternalInputRequestSignal, + ExternalInputResponseSignal, +} from "@local/hash-isomorphic-utils/flows/types"; +import type { Client as TemporalClient } from "@temporalio/client"; + let temporalClient: TemporalClient | undefined; export const requestExternalInput = async < diff --git a/apps/hash-ai-worker-ts/src/activities/shared/use-file-system-file-from-url.ts b/apps/hash-ai-worker-ts/src/activities/shared/use-file-system-file-from-url.ts index 63c7a709276..506b8757396 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/use-file-system-file-from-url.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/use-file-system-file-from-url.ts @@ -4,15 +4,16 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { Readable } from "node:stream"; import { finished } from "node:stream/promises"; -import type { ReadableStream } from "node:stream/web"; import { getStorageProvider } from "@local/hash-backend-utils/flows/payload-storage"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; import { fetchFileFromUrl } from "./fetch-file-from-url.js"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { ReadableStream } from "node:stream/web"; + const baseFilePath = path.join(tmpdir(), "hash-tmp-files"); export const useFileSystemPathFromEntity = async ( diff --git a/apps/hash-ai-worker-ts/src/instrument.ts b/apps/hash-ai-worker-ts/src/instrument.ts index 05650f8aae1..562834ab7ff 100644 --- a/apps/hash-ai-worker-ts/src/instrument.ts +++ b/apps/hash-ai-worker-ts/src/instrument.ts @@ -1,3 +1,5 @@ +import { GrpcInstrumentation } from "@opentelemetry/instrumentation-grpc"; + /** * OpenTelemetry bootstrap for the AI worker. Imported as the very first * statement of `main.ts` so the auto-instrumentations can patch http @@ -8,7 +10,6 @@ import { createUndiciInstrumentation, registerOpenTelemetry, } from "@local/hash-backend-utils/opentelemetry"; -import { GrpcInstrumentation } from "@opentelemetry/instrumentation-grpc"; /** * Setup handles. `undefined` when no `HASH_OTLP_ENDPOINT` is configured diff --git a/apps/hash-ai-worker-ts/src/main.ts b/apps/hash-ai-worker-ts/src/main.ts index 1f93a495494..db399dd106e 100644 --- a/apps/hash-ai-worker-ts/src/main.ts +++ b/apps/hash-ai-worker-ts/src/main.ts @@ -1,11 +1,11 @@ /* eslint-disable import/first, import/order, simple-import-sort/imports */ +import * as Sentry from "@sentry/node"; + // Must be the first import so OTEL auto-instrumentations can patch // http / grpc / Sentry's own monkey-patches before they apply. import { otelSetup } from "./instrument.js"; -import * as Sentry from "@sentry/node"; - Sentry.init({ dsn: process.env.HASH_TEMPORAL_WORKER_AI_SENTRY_DSN, enabled: !!process.env.HASH_TEMPORAL_WORKER_AI_SENTRY_DSN, @@ -30,19 +30,21 @@ import { createRequire } from "node:module"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import { config } from "dotenv-flow"; +import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin"; + import { createGraphClient } from "@local/hash-backend-utils/create-graph-client"; import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { createCommonFlowActivities } from "@local/hash-backend-utils/flows"; -import type { WorkflowSource } from "@local/hash-backend-utils/temporal/worker-bootstrap"; import { runWorker } from "@local/hash-backend-utils/temporal/worker-bootstrap"; import { createVaultClient } from "@local/hash-backend-utils/vault"; -import { config } from "dotenv-flow"; -import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin"; import { createAiActivities, createGraphActivities } from "./activities.js"; import { createFlowActivities } from "./activities/flow-activities.js"; import { logger } from "./shared/logger.js"; +import type { WorkflowSource } from "@local/hash-backend-utils/temporal/worker-bootstrap"; + const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/apps/hash-ai-worker-ts/src/shared/queries.ts b/apps/hash-ai-worker-ts/src/shared/queries.ts index 63d8e6e5bb2..4fa84e19586 100644 --- a/apps/hash-ai-worker-ts/src/shared/queries.ts +++ b/apps/hash-ai-worker-ts/src/shared/queries.ts @@ -3,9 +3,10 @@ * Queries that need to be sent from outside are in @local/hash-isomorphic-utils/src/flows/queries.ts */ +import { defineQuery } from "@temporalio/workflow"; + import type { ExternalInputResponseSignal } from "@local/hash-isomorphic-utils/flows/types"; import type { QueryDefinition } from "@temporalio/workflow"; -import { defineQuery } from "@temporalio/workflow"; export type ExternalInputQueryRequest = { requestId: string; diff --git a/apps/hash-ai-worker-ts/src/shared/signals.ts b/apps/hash-ai-worker-ts/src/shared/signals.ts index a017793fed1..9b8ce1e71c0 100644 --- a/apps/hash-ai-worker-ts/src/shared/signals.ts +++ b/apps/hash-ai-worker-ts/src/shared/signals.ts @@ -4,15 +4,15 @@ * Code that needs to be accessible from outside the worker is in @local/hash-isomorphic-utils/src/flows/signals.ts */ +import { defineSignal } from "@temporalio/workflow"; + +import type { CoordinatingAgentState } from "../activities/flow-activities/research-entities-action/shared/coordinators.js"; import type { ExternalInputRequestSignal, FlowSignalType, ProgressLogBase, ProgressLogSignal, } from "@local/hash-isomorphic-utils/flows/types"; -import { defineSignal } from "@temporalio/workflow"; - -import type { CoordinatingAgentState } from "../activities/flow-activities/research-entities-action/shared/coordinators.js"; /** Record progress logs from an activity to allow for inspection of work before the activity completes */ export const logProgressSignal = defineSignal<[ProgressLogSignal]>( diff --git a/apps/hash-ai-worker-ts/src/shared/testing-utilities/get-alice-user-account-id.ts b/apps/hash-ai-worker-ts/src/shared/testing-utilities/get-alice-user-account-id.ts index 038e174b0c2..dede3a4b7b6 100644 --- a/apps/hash-ai-worker-ts/src/shared/testing-utilities/get-alice-user-account-id.ts +++ b/apps/hash-ai-worker-ts/src/shared/testing-utilities/get-alice-user-account-id.ts @@ -1,4 +1,3 @@ -import type { UserId } from "@blockprotocol/type-system"; import { extractBaseUrl, extractWebIdFromEntityId, @@ -16,6 +15,8 @@ import { import { graphApiClient } from "../../activities/shared/graph-api-client.js"; +import type { UserId } from "@blockprotocol/type-system"; + export const getAliceUserAccountId = async () => { const { entities: [aliceUserEntity], diff --git a/apps/hash-ai-worker-ts/src/shared/testing-utilities/mock-get-flow-context.ts b/apps/hash-ai-worker-ts/src/shared/testing-utilities/mock-get-flow-context.ts index 8a7ecd53a37..28491f8ea52 100644 --- a/apps/hash-ai-worker-ts/src/shared/testing-utilities/mock-get-flow-context.ts +++ b/apps/hash-ai-worker-ts/src/shared/testing-utilities/mock-get-flow-context.ts @@ -1,22 +1,24 @@ +// eslint-disable-next-line import/no-extraneous-dependencies +import { vi } from "vitest"; + +import { HashEntity } from "@local/hash-graph-sdk/entity"; +import { mapFlowRunToEntityProperties } from "@local/hash-isomorphic-utils/flows/mappings"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; +import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { graphApiClient } from "../../activities/shared/graph-api-client.js"; +import { getAliceUserAccountId } from "./get-alice-user-account-id.js"; + import type { ActorEntityUuid, EntityUuid, WebId, } from "@blockprotocol/type-system"; -import { HashEntity } from "@local/hash-graph-sdk/entity"; import type { AiFlowActionDefinitionId } from "@local/hash-isomorphic-utils/flows/action-definitions"; -import { mapFlowRunToEntityProperties } from "@local/hash-isomorphic-utils/flows/mappings"; import type { RunAiFlowWorkflowParams } from "@local/hash-isomorphic-utils/flows/temporal-types"; import type { FlowDefinition } from "@local/hash-isomorphic-utils/flows/types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import type { FlowRun } from "@local/hash-isomorphic-utils/system-types/shared"; import type { Context } from "@temporalio/activity"; -// eslint-disable-next-line import/no-extraneous-dependencies -import { vi } from "vitest"; - -import { graphApiClient } from "../../activities/shared/graph-api-client.js"; -import { getAliceUserAccountId } from "./get-alice-user-account-id.js"; type DeepPartial = { [P in keyof T]?: T[P] extends Array diff --git a/apps/hash-ai-worker-ts/src/workflows.ts b/apps/hash-ai-worker-ts/src/workflows.ts index c5ac8ee4186..3db30bddf92 100644 --- a/apps/hash-ai-worker-ts/src/workflows.ts +++ b/apps/hash-ai-worker-ts/src/workflows.ts @@ -1,3 +1,22 @@ +import { + ActivityCancellationType, + continueAsNew, + executeChild, + proxyActivities, + workflowInfo, +} from "@temporalio/workflow"; + +import { splitEntityId } from "@blockprotocol/type-system"; +import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; +import { deserializeQueryEntitiesResponse } from "@local/hash-graph-sdk/entity"; +import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { runFlowWorkflow } from "./workflows/run-flow-workflow.js"; + +import type { + createAiActivities, + createGraphActivities, +} from "./activities.js"; import type { ActorEntityUuid, BaseUrl, @@ -7,31 +26,14 @@ import type { MachineId, PropertyTypeWithMetadata, } from "@blockprotocol/type-system"; -import { splitEntityId } from "@blockprotocol/type-system"; -import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; import type { EntityQueryCursor, Filter } from "@local/hash-graph-client"; import type { CreateEmbeddingsParams, CreateEmbeddingsReturn, } from "@local/hash-graph-sdk/embeddings"; -import { deserializeQueryEntitiesResponse } from "@local/hash-graph-sdk/entity"; -import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; -import { - ActivityCancellationType, - continueAsNew, - executeChild, - proxyActivities, - workflowInfo, -} from "@temporalio/workflow"; import type { OpenAI } from "openai"; -import type { - createAiActivities, - createGraphActivities, -} from "./activities.js"; -import { runFlowWorkflow } from "./workflows/run-flow-workflow.js"; - const aiActivities = proxyActivities>({ cancellationType: ActivityCancellationType.WAIT_CANCELLATION_COMPLETED, startToCloseTimeout: "3600 second", // 1 hour diff --git a/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow.ts b/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow.ts index d77e3fe316d..59de60509c5 100644 --- a/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow.ts +++ b/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow.ts @@ -1,6 +1,16 @@ -import type { ProxyFlowActivity } from "@local/hash-backend-utils/flows"; +import { + ActivityCancellationType, + proxyActivities, +} from "@temporalio/workflow"; + import { processFlowWorkflow } from "@local/hash-backend-utils/flows/process-flow-workflow"; import { type AiFlowActionDefinitionId } from "@local/hash-isomorphic-utils/flows/action-definitions"; + +import { heartbeatTimeoutSeconds } from "../shared/heartbeats.js"; +import { setQueryAndSignalHandlers } from "./run-flow-workflow/set-query-and-signal-handlers.js"; + +import type { createFlowActivities } from "../activities/flow-activities.js"; +import type { ProxyFlowActivity } from "@local/hash-backend-utils/flows"; import type { RunAiFlowWorkflowParams, RunFlowWorkflowResponse, @@ -9,14 +19,6 @@ import type { FlowDefinition, FlowTrigger, } from "@local/hash-isomorphic-utils/flows/types"; -import { - ActivityCancellationType, - proxyActivities, -} from "@temporalio/workflow"; - -import type { createFlowActivities } from "../activities/flow-activities.js"; -import { heartbeatTimeoutSeconds } from "../shared/heartbeats.js"; -import { setQueryAndSignalHandlers } from "./run-flow-workflow/set-query-and-signal-handlers.js"; type FlowActivityId = keyof ReturnType; diff --git a/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow/set-query-and-signal-handlers.ts b/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow/set-query-and-signal-handlers.ts index 84a8f260983..f6c959ed57f 100644 --- a/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow/set-query-and-signal-handlers.ts +++ b/apps/hash-ai-worker-ts/src/workflows/run-flow-workflow/set-query-and-signal-handlers.ts @@ -1,13 +1,15 @@ -import type { SentrySinks } from "@local/hash-backend-utils/temporal/sinks/sentry"; +import { proxySinks, setHandler } from "@temporalio/workflow"; + import { externalInputResponseSignal } from "@local/hash-isomorphic-utils/flows/signals"; + +import { getExternalInputResponseQuery } from "../../shared/queries.js"; +import { externalInputRequestSignal } from "../../shared/signals.js"; + +import type { SentrySinks } from "@local/hash-backend-utils/temporal/sinks/sentry"; import type { ExternalInputRequestSignal, ExternalInputResponseSignal, } from "@local/hash-isomorphic-utils/flows/types"; -import { proxySinks, setHandler } from "@temporalio/workflow"; - -import { getExternalInputResponseQuery } from "../../shared/queries.js"; -import { externalInputRequestSignal } from "../../shared/signals.js"; const sinks = proxySinks(); diff --git a/apps/hash-ai-worker-ts/vitest.config.ts b/apps/hash-ai-worker-ts/vitest.config.ts index e99aee0dbe2..130ca964948 100644 --- a/apps/hash-ai-worker-ts/vitest.config.ts +++ b/apps/hash-ai-worker-ts/vitest.config.ts @@ -1,9 +1,10 @@ -/// -import { monorepoRootDir } from "@local/hash-backend-utils/environment"; // eslint-disable-next-line import/no-extraneous-dependencies import { loadEnv } from "vite"; import { defineConfig } from "vitest/config"; +/// +import { monorepoRootDir } from "@local/hash-backend-utils/environment"; + export default defineConfig(({ mode }) => { return { test: { diff --git a/apps/hash-api/codegen.config.ts b/apps/hash-api/codegen.config.ts index 6f65449917b..c7f68426d95 100644 --- a/apps/hash-api/codegen.config.ts +++ b/apps/hash-api/codegen.config.ts @@ -1,6 +1,7 @@ -import type { CodegenConfig } from "@graphql-codegen/cli"; import { baseGraphQlCodegenConfig } from "@local/hash-isomorphic-utils/graphql/base-codegen-config"; +import type { CodegenConfig } from "@graphql-codegen/cli"; + const config: CodegenConfig = { overwrite: true, schema: @@ -18,7 +19,7 @@ const config: CodegenConfig = { "../../libs/@local/hash-isomorphic-utils/src/graphql/queries/**/*.ts", ], hooks: { - afterOneFileWrite: ["biome format --write --vcs-use-ignore-file=false"], + afterOneFileWrite: ["oxfmt --write"], }, config: { noSchemaStitching: true, diff --git a/apps/hash-api/package.json b/apps/hash-api/package.json index 58972e49f89..5753e770c19 100644 --- a/apps/hash-api/package.json +++ b/apps/hash-api/package.json @@ -11,7 +11,7 @@ "dev": "NODE_ENV=development NODE_OPTIONS=--max-old-space-size=2048 tsx watch --clear-screen=false --import ./src/instrument.mjs ./src/index.ts", "fix:eslint": "eslint --fix .", "generate-hash-gpt-schema": "tsx ./src/ai/gpt/generate-hashgpt-schema.ts", - "generate-ontology-type-ids": "tsx ./src/generate-ontology-type-ids.ts; biome format --write ../../libs/@local/hash-isomorphic-utils/src/ontology-type-ids.ts", + "generate-ontology-type-ids": "tsx ./src/generate-ontology-type-ids.ts; oxfmt --write ../../libs/@local/hash-isomorphic-utils/src/ontology-type-ids.ts", "lint:eslint": "eslint --report-unused-disable-directives .", "lint:tsc": "tsc --noEmit", "start": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=2048 tsx --import ./src/instrument.mjs ./src/index.ts", diff --git a/apps/hash-api/src/ai/gpt/generate-hashgpt-schema.ts b/apps/hash-api/src/ai/gpt/generate-hashgpt-schema.ts index 622c0a0576b..65be5968f79 100644 --- a/apps/hash-api/src/ai/gpt/generate-hashgpt-schema.ts +++ b/apps/hash-api/src/ai/gpt/generate-hashgpt-schema.ts @@ -2,9 +2,10 @@ import { writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import { apiOrigin } from "@local/hash-isomorphic-utils/environment"; import * as generator from "ts-json-schema-generator"; +import { apiOrigin } from "@local/hash-isomorphic-utils/environment"; + const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/apps/hash-api/src/ai/gpt/gpt-get-user-webs.ts b/apps/hash-api/src/ai/gpt/gpt-get-user-webs.ts index 98c82b6518e..257b5b8e2a1 100644 --- a/apps/hash-api/src/ai/gpt/gpt-get-user-webs.ts +++ b/apps/hash-api/src/ai/gpt/gpt-get-user-webs.ts @@ -1,7 +1,7 @@ -import type { RequestHandler } from "express"; +import { getUserSimpleWebs } from "./shared/webs"; import type { SimpleWeb } from "./shared/webs"; -import { getUserSimpleWebs } from "./shared/webs"; +import type { RequestHandler } from "express"; export type GptGetUserWebsResponseBody = | { error: string } diff --git a/apps/hash-api/src/ai/gpt/gpt-query-entities.ts b/apps/hash-api/src/ai/gpt/gpt-query-entities.ts index 955e3e40670..372dee62147 100644 --- a/apps/hash-api/src/ai/gpt/gpt-query-entities.ts +++ b/apps/hash-api/src/ai/gpt/gpt-query-entities.ts @@ -1,18 +1,9 @@ -import type { EntityId, EntityUuid } from "@blockprotocol/type-system"; import { entityIdFromComponents, extractEntityUuidFromEntityId, extractWebIdFromEntityId, } from "@blockprotocol/type-system"; -import type { - SimpleEntityWithoutHref, - SimpleLinkWithoutHref, -} from "@local/hash-backend-utils/simplified-graph"; import { getSimpleGraph } from "@local/hash-backend-utils/simplified-graph"; -import type { - CreateEmbeddingsParams, - CreateEmbeddingsReturn, -} from "@local/hash-graph-sdk/embeddings"; import { queryEntitySubgraph } from "@local/hash-graph-sdk/entity"; import { frontendUrl } from "@local/hash-isomorphic-utils/environment"; import { generateEntityPath } from "@local/hash-isomorphic-utils/frontend-paths"; @@ -21,17 +12,27 @@ import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; + +import { getLatestEntityById } from "../../graph/knowledge/primitive/entity"; +import { stringifyResults } from "./shared/stringify-results"; +import { getUserSimpleWebs } from "./shared/webs"; + +import type { SimpleWeb } from "./shared/webs"; +import type { EntityId, EntityUuid } from "@blockprotocol/type-system"; +import type { + SimpleEntityWithoutHref, + SimpleLinkWithoutHref, +} from "@local/hash-backend-utils/simplified-graph"; +import type { + CreateEmbeddingsParams, + CreateEmbeddingsReturn, +} from "@local/hash-graph-sdk/embeddings"; import type { OrganizationProperties, UserProperties, } from "@local/hash-isomorphic-utils/system-types/shared"; import type { RequestHandler } from "express"; -import { getLatestEntityById } from "../../graph/knowledge/primitive/entity"; -import { stringifyResults } from "./shared/stringify-results"; -import type { SimpleWeb } from "./shared/webs"; -import { getUserSimpleWebs } from "./shared/webs"; - export type GptQueryEntitiesRequestBody = { /** * The titles of specific types of entities to retrieve. Types are typically capitalized, e.g. User, Organization. diff --git a/apps/hash-api/src/ai/gpt/gpt-query-types.ts b/apps/hash-api/src/ai/gpt/gpt-query-types.ts index 103cac0890d..ef9b8e5e6c7 100644 --- a/apps/hash-api/src/ai/gpt/gpt-query-types.ts +++ b/apps/hash-api/src/ai/gpt/gpt-query-types.ts @@ -1,20 +1,21 @@ import { typedValues } from "@local/advanced-types/typed-entries"; -import type { SimpleEntityType } from "@local/hash-backend-utils/simplified-graph"; import { getSimpleEntityType } from "@local/hash-backend-utils/simplified-graph"; -import type { - CreateEmbeddingsParams, - CreateEmbeddingsReturn, -} from "@local/hash-graph-sdk/embeddings"; import { queryEntityTypeSubgraph } from "@local/hash-graph-sdk/entity-type"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; -import type { RequestHandler } from "express"; import { stringifyResults } from "./shared/stringify-results"; +import type { SimpleEntityType } from "@local/hash-backend-utils/simplified-graph"; +import type { + CreateEmbeddingsParams, + CreateEmbeddingsReturn, +} from "@local/hash-graph-sdk/embeddings"; +import type { RequestHandler } from "express"; + export type GptQueryTypesRequestBody = { /** * Limit the response to types within the specified webs, identified by the web's uuid. diff --git a/apps/hash-api/src/ai/gpt/shared/webs.ts b/apps/hash-api/src/ai/gpt/shared/webs.ts index a26475d60e3..c521358f45f 100644 --- a/apps/hash-api/src/ai/gpt/shared/webs.ts +++ b/apps/hash-api/src/ai/gpt/shared/webs.ts @@ -1,9 +1,9 @@ -import type { ActorEntityUuid } from "@blockprotocol/type-system"; +import { getOrgMembershipOrg } from "../../../graph/knowledge/system-types/org-membership"; +import { getUserOrgMemberships } from "../../../graph/knowledge/system-types/user"; import type { ImpureGraphContext } from "../../../graph/context-types"; -import { getOrgMembershipOrg } from "../../../graph/knowledge/system-types/org-membership"; import type { User } from "../../../graph/knowledge/system-types/user"; -import { getUserOrgMemberships } from "../../../graph/knowledge/system-types/user"; +import type { ActorEntityUuid } from "@blockprotocol/type-system"; export type SimpleWeb = { uuid: string; diff --git a/apps/hash-api/src/ai/gpt/upsert-gpt-oauth-client.ts b/apps/hash-api/src/ai/gpt/upsert-gpt-oauth-client.ts index b61b2dd0279..b3ebc3adf86 100644 --- a/apps/hash-api/src/ai/gpt/upsert-gpt-oauth-client.ts +++ b/apps/hash-api/src/ai/gpt/upsert-gpt-oauth-client.ts @@ -1,8 +1,9 @@ import { isUserHashInstanceAdmin } from "@local/hash-graph-sdk/principal/hash-instance-admins"; -import type { RequestHandler } from "express"; import { hydraAdmin } from "../../auth/ory-hydra"; +import type { RequestHandler } from "express"; + type UpsertOAuthClientRequestBody = { redirectUri: string; }; diff --git a/apps/hash-api/src/ai/infer-entities-websocket.ts b/apps/hash-api/src/ai/infer-entities-websocket.ts index 678f0abdb5b..688469ad700 100644 --- a/apps/hash-api/src/ai/infer-entities-websocket.ts +++ b/apps/hash-api/src/ai/infer-entities-websocket.ts @@ -1,28 +1,29 @@ -import type http from "node:http"; +import { WebSocketServer } from "ws"; -import type { EntityUuid } from "@blockprotocol/type-system"; -import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; import { getFlowRunEntityById, getFlowRuns, } from "@local/hash-backend-utils/flows"; +import { externalInputResponseSignal } from "@local/hash-isomorphic-utils/flows/signals"; + +import { getUserAndSession } from "../auth/create-auth-handlers"; +import { FlowRunStatus } from "../graphql/api-types.gen"; +import { handleCancelInferEntitiesRequest } from "./infer-entities-websocket/handle-cancel-infer-entities-request"; +import { handleInferEntitiesRequest } from "./infer-entities-websocket/handle-infer-entities-request"; + +import type { GraphApi, ImpureGraphContext } from "../graph/context-types"; +import type { User } from "../graph/knowledge/system-types/user"; +import type { EntityUuid } from "@blockprotocol/type-system"; +import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; import type { Logger } from "@local/hash-backend-utils/logger"; import type { ExternalInputWebsocketRequestMessage, InferenceWebsocketClientMessage, } from "@local/hash-isomorphic-utils/ai-inference-types"; -import { externalInputResponseSignal } from "@local/hash-isomorphic-utils/flows/signals"; import type { ExternalInputResponseSignal } from "@local/hash-isomorphic-utils/flows/types"; import type { Client } from "@temporalio/client"; +import type http from "node:http"; import type { WebSocket } from "ws"; -import { WebSocketServer } from "ws"; - -import { getUserAndSession } from "../auth/create-auth-handlers"; -import type { GraphApi, ImpureGraphContext } from "../graph/context-types"; -import type { User } from "../graph/knowledge/system-types/user"; -import { FlowRunStatus } from "../graphql/api-types.gen"; -import { handleCancelInferEntitiesRequest } from "./infer-entities-websocket/handle-cancel-infer-entities-request"; -import { handleInferEntitiesRequest } from "./infer-entities-websocket/handle-infer-entities-request"; const inferEntitiesMessageHandler = async ({ socket, diff --git a/apps/hash-api/src/ai/infer-entities-websocket/handle-cancel-infer-entities-request.ts b/apps/hash-api/src/ai/infer-entities-websocket/handle-cancel-infer-entities-request.ts index e722f0c36c1..45737e15632 100644 --- a/apps/hash-api/src/ai/infer-entities-websocket/handle-cancel-infer-entities-request.ts +++ b/apps/hash-api/src/ai/infer-entities-websocket/handle-cancel-infer-entities-request.ts @@ -1,10 +1,10 @@ -import type { EntityUuid } from "@blockprotocol/type-system"; import { getFlowRunEntityById } from "@local/hash-backend-utils/flows"; -import type { CancelInferEntitiesWebsocketRequestMessage } from "@local/hash-isomorphic-utils/ai-inference-types"; -import type { Client } from "@temporalio/client"; import type { GraphApi } from "../../graph/context-types"; import type { User } from "../../graph/knowledge/system-types/user"; +import type { EntityUuid } from "@blockprotocol/type-system"; +import type { CancelInferEntitiesWebsocketRequestMessage } from "@local/hash-isomorphic-utils/ai-inference-types"; +import type { Client } from "@temporalio/client"; export const handleCancelInferEntitiesRequest = async ({ graphApiClient, diff --git a/apps/hash-api/src/ai/infer-entities-websocket/handle-infer-entities-request.ts b/apps/hash-api/src/ai/infer-entities-websocket/handle-infer-entities-request.ts index a6859170a4f..94fbd8d28f8 100644 --- a/apps/hash-api/src/ai/infer-entities-websocket/handle-infer-entities-request.ts +++ b/apps/hash-api/src/ai/infer-entities-websocket/handle-infer-entities-request.ts @@ -1,16 +1,20 @@ -import type { DistributiveOmit } from "@local/advanced-types/distribute"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; import { getFlowRuns } from "@local/hash-backend-utils/flows"; +import { + automaticBrowserInferenceFlowDefinition, + manualBrowserInferenceFlowDefinition, +} from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-definitions"; + +import { FlowRunStatus } from "../../graphql/api-types.gen"; + +import type { User } from "../../graph/knowledge/system-types/user"; +import type { DistributiveOmit } from "@local/advanced-types/distribute"; +import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; import type { GraphApi } from "@local/hash-graph-client"; import type { AutomaticInferenceWebsocketRequestMessage, ManualInferenceWebsocketRequestMessage, } from "@local/hash-isomorphic-utils/ai-inference-types"; -import { - automaticBrowserInferenceFlowDefinition, - manualBrowserInferenceFlowDefinition, -} from "@local/hash-isomorphic-utils/flows/browser-plugin-flow-definitions"; import type { AutomaticInferenceTriggerInputName, AutomaticInferenceTriggerInputs, @@ -25,9 +29,6 @@ import type { } from "@local/hash-isomorphic-utils/flows/types"; import type { Client } from "@temporalio/client"; -import type { User } from "../../graph/knowledge/system-types/user"; -import { FlowRunStatus } from "../../graphql/api-types.gen"; - export const handleInferEntitiesRequest = async ({ graphApiClient, storageProvider, diff --git a/apps/hash-api/src/auth/create-auth-handlers.ts b/apps/hash-api/src/auth/create-auth-handlers.ts index 6cac7ed6877..ae8b2990606 100644 --- a/apps/hash-api/src/auth/create-auth-handlers.ts +++ b/apps/hash-api/src/auth/create-auth-handlers.ts @@ -1,21 +1,23 @@ +import * as Sentry from "@sentry/node"; + import { timingSafeCompare } from "@local/hash-backend-utils/crypto"; import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { getHashInstance } from "@local/hash-backend-utils/hash-instance"; -import type { Logger } from "@local/hash-backend-utils/logger"; import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; -import type { Session } from "@ory/kratos-client"; -import * as Sentry from "@sentry/node"; -import type { AxiosError } from "axios"; -import type { Express, Request, RequestHandler } from "express"; -import type { ImpureGraphContext } from "../graph/context-types"; -import type { User } from "../graph/knowledge/system-types/user"; import { createUser, getUser } from "../graph/knowledge/system-types/user"; import { systemAccountId } from "../graph/system-account"; import { hydraAdmin } from "./ory-hydra"; -import type { KratosUserIdentity } from "./ory-kratos"; import { isUserEmailVerified, kratosFrontendApi } from "./ory-kratos"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { User } from "../graph/knowledge/system-types/user"; +import type { KratosUserIdentity } from "./ory-kratos"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { Session } from "@ory/kratos-client"; +import type { AxiosError } from "axios"; +import type { Express, Request, RequestHandler } from "express"; + const KRATOS_API_KEY = getRequiredEnv("KRATOS_API_KEY"); const requestHeaderContainsValidKratosApiKey = (req: Request): boolean => diff --git a/apps/hash-api/src/auth/create-unverified-email-cleanup-job.ts b/apps/hash-api/src/auth/create-unverified-email-cleanup-job.ts index 5d3d0fbaee4..9795b714773 100644 --- a/apps/hash-api/src/auth/create-unverified-email-cleanup-job.ts +++ b/apps/hash-api/src/auth/create-unverified-email-cleanup-job.ts @@ -1,18 +1,19 @@ -import type { Logger } from "@local/hash-backend-utils/logger"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes, generateVersionedUrlMatchingFilter, } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { User as UserEntity } from "@local/hash-isomorphic-utils/system-types/user"; -import type { Identity } from "@ory/kratos-client"; -import type { ImpureGraphContext } from "../graph/context-types"; import { getUserFromEntity } from "../graph/knowledge/system-types/user"; import { systemAccountId } from "../graph/system-account"; import { deleteKratosIdentity, kratosIdentityApi } from "./ory-kratos"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { User as UserEntity } from "@local/hash-isomorphic-utils/system-types/user"; +import type { Identity } from "@ory/kratos-client"; + /** * Identities created before this date are excluded from cleanup, preventing * retroactive deletion of accounts that existed before email verification diff --git a/apps/hash-api/src/auth/get-actor-id.ts b/apps/hash-api/src/auth/get-actor-id.ts index e3e6f5a3725..681b7dafc83 100644 --- a/apps/hash-api/src/auth/get-actor-id.ts +++ b/apps/hash-api/src/auth/get-actor-id.ts @@ -1,4 +1,5 @@ import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; + import type { Request } from "express"; export const getActorIdFromRequest = (request: Request) => diff --git a/apps/hash-api/src/auth/oauth-consent-handlers.ts b/apps/hash-api/src/auth/oauth-consent-handlers.ts index 7855dc037d1..115ac2f767a 100644 --- a/apps/hash-api/src/auth/oauth-consent-handlers.ts +++ b/apps/hash-api/src/auth/oauth-consent-handlers.ts @@ -1,11 +1,12 @@ import { randomBytes } from "node:crypto"; import { timingSafeCompare } from "@local/hash-backend-utils/crypto"; -import type { RequestHandler } from "express"; import { isDevEnv } from "../lib/env-config"; import { hydraAdmin } from "./ory-hydra"; +import type { RequestHandler } from "express"; + const CSRF_COOKIE_NAME = "_csrf_consent"; /** diff --git a/apps/hash-api/src/auth/ory-kratos.ts b/apps/hash-api/src/auth/ory-kratos.ts index 127298df450..b226d84a663 100644 --- a/apps/hash-api/src/auth/ory-kratos.ts +++ b/apps/hash-api/src/auth/ory-kratos.ts @@ -1,8 +1,10 @@ -import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { Configuration } from "@ory/client"; -import type { CreateIdentityBody, Identity } from "@ory/kratos-client"; import { FrontendApi, IdentityApi } from "@ory/kratos-client"; +import { getRequiredEnv } from "@local/hash-backend-utils/environment"; + +import type { CreateIdentityBody, Identity } from "@ory/kratos-client"; + export const kratosPublicUrl = getRequiredEnv("HASH_KRATOS_PUBLIC_URL"); export const kratosFrontendApi = new FrontendApi( diff --git a/apps/hash-api/src/block-protocol-external-service-method-proxy.ts b/apps/hash-api/src/block-protocol-external-service-method-proxy.ts index c278cb63906..00918922328 100644 --- a/apps/hash-api/src/block-protocol-external-service-method-proxy.ts +++ b/apps/hash-api/src/block-protocol-external-service-method-proxy.ts @@ -1,6 +1,8 @@ +import { createProxyMiddleware } from "http-proxy-middleware"; + import { blockProtocolHubOrigin } from "@local/hash-isomorphic-utils/blocks-constants"; + import type { Express, Request, Response } from "express"; -import { createProxyMiddleware } from "http-proxy-middleware"; /** * Set up a proxy to the blockprotocol.org proxy for the internal API, diff --git a/apps/hash-api/src/email/create-email-transporter.ts b/apps/hash-api/src/email/create-email-transporter.ts index 8f0ad8a8ece..18fde6d81ae 100644 --- a/apps/hash-api/src/email/create-email-transporter.ts +++ b/apps/hash-api/src/email/create-email-transporter.ts @@ -10,6 +10,7 @@ import { isDevEnv, isProdEnv, isTestEnv } from "../lib/env-config"; import { logger } from "../logger"; import { AwsSesEmailTransporter, DummyEmailTransporter } from "./transporters"; import { SmtpEmailTransporter } from "./transporters/smtp-email-transporter"; + import type { EmailTransporter } from "./transporters/types"; const transporterType = process.env.HASH_EMAIL_TRANSPORTER; diff --git a/apps/hash-api/src/email/transporters/aws-ses-email-transporter.ts b/apps/hash-api/src/email/transporters/aws-ses-email-transporter.ts index 05d7b0f816a..3fbd2b7fe31 100644 --- a/apps/hash-api/src/email/transporters/aws-ses-email-transporter.ts +++ b/apps/hash-api/src/email/transporters/aws-ses-email-transporter.ts @@ -2,13 +2,14 @@ import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2"; import { defaultProvider } from "@aws-sdk/credential-provider-node"; import { convert } from "html-to-text"; import nodemailer from "nodemailer"; -import type SESTransport from "nodemailer/lib/ses-transport"; import { logger } from "../../logger"; + import type { EmailTransporter, EmailTransporterSendMailOptions, } from "./types"; +import type SESTransport from "nodemailer/lib/ses-transport"; export interface AwsSesEmailTransporterConfig { from: string; diff --git a/apps/hash-api/src/email/transporters/dummy-email-transporter.ts b/apps/hash-api/src/email/transporters/dummy-email-transporter.ts index c6eb2ec70f6..137c9308bfa 100644 --- a/apps/hash-api/src/email/transporters/dummy-email-transporter.ts +++ b/apps/hash-api/src/email/transporters/dummy-email-transporter.ts @@ -6,6 +6,7 @@ import { convert } from "html-to-text"; import { dump } from "js-yaml"; import { logger } from "../../logger"; + import type { EmailTransporter, EmailTransporterSendMailOptions, diff --git a/apps/hash-api/src/email/transporters/smtp-email-transporter.ts b/apps/hash-api/src/email/transporters/smtp-email-transporter.ts index 864ce431bea..2dbe081fe39 100644 --- a/apps/hash-api/src/email/transporters/smtp-email-transporter.ts +++ b/apps/hash-api/src/email/transporters/smtp-email-transporter.ts @@ -1,13 +1,15 @@ -import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { convert } from "html-to-text"; import nodemailer from "nodemailer"; -import type SMTPTransport from "nodemailer/lib/smtp-transport"; + +import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { logger } from "../../logger"; + import type { EmailTransporter, EmailTransporterSendMailOptions, } from "./types"; +import type SMTPTransport from "nodemailer/lib/smtp-transport"; export interface SmtpEmailTransporterConfig { from: string; diff --git a/apps/hash-api/src/ensure-system-graph-is-initialized.ts b/apps/hash-api/src/ensure-system-graph-is-initialized.ts index 67ee8978b79..eaa8b9ce504 100644 --- a/apps/hash-api/src/ensure-system-graph-is-initialized.ts +++ b/apps/hash-api/src/ensure-system-graph-is-initialized.ts @@ -2,10 +2,11 @@ import { createGraphClient } from "@local/hash-backend-utils/create-graph-client import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { createTemporalClient } from "@local/hash-backend-utils/temporal"; -import type { ImpureGraphContext } from "./graph/context-types"; import { ensureSystemGraphIsInitialized } from "./graph/ensure-system-graph-is-initialized"; import { logger } from "./logger"; +import type { ImpureGraphContext } from "./graph/context-types"; + const context: ImpureGraphContext = { provenance: { actorType: "machine", diff --git a/apps/hash-api/src/express.d.ts b/apps/hash-api/src/express.d.ts index 96bee9b7d84..2acdc757866 100644 --- a/apps/hash-api/src/express.d.ts +++ b/apps/hash-api/src/express.d.ts @@ -1,8 +1,7 @@ -import type { VaultClient } from "@local/hash-backend-utils/vault"; -import type { Session } from "@ory/kratos-client"; - import type { ImpureGraphContext } from "./graph/context-types"; import type { User } from "./graph/knowledge/system-types/user"; +import type { VaultClient } from "@local/hash-backend-utils/vault"; +import type { Session } from "@ory/kratos-client"; declare global { namespace Express { diff --git a/apps/hash-api/src/generate-ontology-type-ids.ts b/apps/hash-api/src/generate-ontology-type-ids.ts index 4791a5972da..5e39533beeb 100644 --- a/apps/hash-api/src/generate-ontology-type-ids.ts +++ b/apps/hash-api/src/generate-ontology-type-ids.ts @@ -2,14 +2,6 @@ import { writeFile } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { - DataType, - DataTypeWithMetadata, - EntityType, - EntityTypeWithMetadata, - PropertyType, - PropertyTypeWithMetadata, -} from "@blockprotocol/type-system"; import { extractBaseUrl } from "@blockprotocol/type-system"; import { createGraphClient } from "@local/hash-backend-utils/create-graph-client"; import { getRequiredEnv } from "@local/hash-backend-utils/environment"; @@ -20,13 +12,22 @@ import { queryEntityTypes } from "@local/hash-graph-sdk/entity-type"; import { queryPropertyTypes } from "@local/hash-graph-sdk/property-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; +import { getOrgByShortname } from "./graph/knowledge/system-types/org"; +import { isEntityTypeLinkEntityType } from "./graph/ontology/primitive/entity-type"; + import type { ImpureGraphContext, ImpureGraphFunction, } from "./graph/context-types"; import type { Org } from "./graph/knowledge/system-types/org"; -import { getOrgByShortname } from "./graph/knowledge/system-types/org"; -import { isEntityTypeLinkEntityType } from "./graph/ontology/primitive/entity-type"; +import type { + DataType, + DataTypeWithMetadata, + EntityType, + EntityTypeWithMetadata, + PropertyType, + PropertyTypeWithMetadata, +} from "@blockprotocol/type-system"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized.ts index 0e9809d9517..ec547735b86 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized.ts @@ -1,10 +1,10 @@ -import type { Logger } from "@local/hash-backend-utils/logger"; - -import type { ImpureGraphContext } from "./context-types"; import { migrateOntologyTypes } from "./ensure-system-graph-is-initialized/migrate-ontology-types"; import { ensureSystemEntitiesExist } from "./ensure-system-graph-is-initialized/system-webs-and-entities"; import { ensureHashSystemAccountExists } from "./system-account"; +import type { ImpureGraphContext } from "./context-types"; +import type { Logger } from "@local/hash-backend-utils/logger"; + export const ensureSystemGraphIsInitialized = async (params: { logger: Logger; context: ImpureGraphContext; diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types.ts index 4fe93d14abb..424f9c671ae 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types.ts @@ -4,19 +4,20 @@ import { fileURLToPath } from "node:url"; import { extractVersion } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; -import type { HashInstance } from "@local/hash-backend-utils/hash-instance"; import { getHashInstance } from "@local/hash-backend-utils/hash-instance"; -import type { Logger } from "@local/hash-backend-utils/logger"; import { systemPropertyTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationsCompletedPropertyValueWithMetadata } from "@local/hash-isomorphic-utils/system-types/hashinstance"; import { isProdEnv } from "../../lib/env-config"; -import type { ImpureGraphContext } from "../context-types"; import { systemAccountId } from "../system-account"; + +import type { ImpureGraphContext } from "../context-types"; import type { MigrationFunction, MigrationState, } from "./migrate-ontology-types/types"; +import type { HashInstance } from "@local/hash-backend-utils/hash-instance"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { MigrationsCompletedPropertyValueWithMetadata } from "@local/hash-isomorphic-utils/system-types/hashinstance"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/000-create-first-custom-data-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/000-create-first-custom-data-types.migration.ts index 9841e2ebac8..885234020d0 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/000-create-first-custom-data-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/000-create-first-custom-data-types.migration.ts @@ -1,8 +1,9 @@ import { blockProtocolDataTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/001-create-hash-system-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/001-create-hash-system-types.migration.ts index f19559a383a..9637764be7b 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/001-create-hash-system-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/001-create-hash-system-types.migration.ts @@ -7,13 +7,14 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, getCurrentHashDataTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + /** * @todo H-4065 / H-4066: Support array and tuple data types (add /list/ here, which they should inherit from) */ diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/003-create-linear-system-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/003-create-linear-system-types.migration.ts index 1fb064011cc..635cd9be642 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/003-create-linear-system-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/003-create-linear-system-types.migration.ts @@ -1,7 +1,6 @@ import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { enabledIntegrations } from "../../../../integrations/enabled-integrations"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, @@ -9,6 +8,8 @@ import { getCurrentHashPropertyTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/004-create-machines-update-users.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/004-create-machines-update-users.migration.ts index 1b566ce63ac..3cc357d80c7 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/004-create-machines-update-users.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/004-create-machines-update-users.migration.ts @@ -1,11 +1,9 @@ -import type { EntityType } from "@blockprotocol/type-system"; import { atLeastOne } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { blockProtocolPropertyTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, @@ -15,6 +13,9 @@ import { upgradeDependenciesInHashEntityType, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/005-create-hash-system-entities-and-web-bots.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/005-create-hash-system-entities-and-web-bots.migration.ts index abaa4b84a0f..567ac5d516b 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/005-create-hash-system-entities-and-web-bots.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/005-create-hash-system-entities-and-web-bots.migration.ts @@ -14,12 +14,13 @@ import { ensureSystemWebEntitiesExist, owningWebs, } from "../../system-webs-and-entities"; -import type { MigrationFunction } from "../types"; import { getCurrentHashSystemEntityTypeId, getExistingUsersAndOrgs, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ authentication, context, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/007-create-api-usage-tracking.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/007-create-api-usage-tracking.migration.ts index 75a9e38072f..6389b0bd3f6 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/007-create-api-usage-tracking.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/007-create-api-usage-tracking.migration.ts @@ -1,12 +1,9 @@ -import type { Entity } from "@blockprotocol/type-system"; import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { ServiceFeature } from "@local/hash-isomorphic-utils/system-types/shared"; import { logger } from "../../../../logger"; import { createEntity } from "../../../knowledge/primitive/entity"; import { getOrgByShortname } from "../../../knowledge/system-types/org"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, @@ -14,6 +11,10 @@ import { getEntitiesByType, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { Entity } from "@blockprotocol/type-system"; +import type { ServiceFeature } from "@local/hash-isomorphic-utils/system-types/shared"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/008-create-plugin-settings-update-users.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/008-create-plugin-settings-update-users.migration.ts index ab300621369..8b8175c43ef 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/008-create-plugin-settings-update-users.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/008-create-plugin-settings-update-users.migration.ts @@ -1,4 +1,3 @@ -import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; @@ -7,7 +6,6 @@ import { systemEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, @@ -17,6 +15,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/009-add-upload-completed-at-property-type.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/009-add-upload-completed-at-property-type.migration.ts index ca057dd5bf7..2ad8199266f 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/009-add-upload-completed-at-property-type.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/009-add-upload-completed-at-property-type.migration.ts @@ -1,11 +1,9 @@ -import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; import { extractBaseUrl } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemPropertyTypeIfNotExists, getCurrentHashDataTypeId, @@ -15,6 +13,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/010-create-office-file-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/010-create-office-file-types.migration.ts index 8df0a3b88f1..29092698268 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/010-create-office-file-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/010-create-office-file-types.migration.ts @@ -1,9 +1,10 @@ -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, getCurrentHashSystemEntityTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/011-deprecate-preferred-name.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/011-deprecate-preferred-name.migration.ts index b1bfc156ae0..7e42170674c 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/011-deprecate-preferred-name.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/011-deprecate-preferred-name.migration.ts @@ -1,4 +1,3 @@ -import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; @@ -8,7 +7,6 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { getCurrentHashSystemEntityTypeId, updateSystemEntityType, @@ -17,6 +15,9 @@ import { } from "../util"; import { upgradeEntityTypeDependencies } from "../util/upgrade-entity-type-dependencies"; +import type { MigrationFunction } from "../types"; +import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/012-create-google-sheets-system-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/012-create-google-sheets-system-types.migration.ts index 33c3f125441..9e2eecd4026 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/012-create-google-sheets-system-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/012-create-google-sheets-system-types.migration.ts @@ -5,7 +5,6 @@ import { } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { enabledIntegrations } from "../../../../integrations/enabled-integrations"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists, createSystemEntityTypeIfNotExists, @@ -15,6 +14,8 @@ import { getCurrentHashSystemEntityTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/013-add-enabled-feature-flags-property.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/013-add-enabled-feature-flags-property.migration.ts index 25d0748fec9..eac96fbfb7d 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/013-add-enabled-feature-flags-property.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/013-add-enabled-feature-flags-property.migration.ts @@ -1,11 +1,9 @@ -import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; import { extractBaseUrl } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemPropertyTypeIfNotExists, getCurrentHashSystemEntityTypeId, @@ -14,6 +12,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/017-add-use-case-form-and-example-org.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/017-add-use-case-form-and-example-org.migration.ts index 17856d154bb..f83ac3421f0 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/017-add-use-case-form-and-example-org.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/017-add-use-case-form-and-example-org.migration.ts @@ -9,13 +9,14 @@ import { createOrg, getOrgByShortname, } from "../../../knowledge/system-types/org"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, getCurrentHashPropertyTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/018-add-application-preferences-property.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/018-add-application-preferences-property.migration.ts index b614711c784..974a44f6d97 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/018-add-application-preferences-property.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/018-add-application-preferences-property.migration.ts @@ -1,11 +1,9 @@ -import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; import { extractBaseUrl } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemPropertyTypeIfNotExists, getCurrentHashSystemEntityTypeId, @@ -14,6 +12,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/019-add-doc-company-and-person-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/019-add-doc-company-and-person-types.migration.ts index f6ca97d4734..cf2dd480bae 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/019-add-doc-company-and-person-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/019-add-doc-company-and-person-types.migration.ts @@ -5,7 +5,6 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists, createSystemEntityTypeIfNotExists, @@ -15,6 +14,8 @@ import { getCurrentHashPropertyTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/020-add-integration-parent-type.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/020-add-integration-parent-type.migration.ts index d6c8957e1bf..c7a196b7097 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/020-add-integration-parent-type.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/020-add-integration-parent-type.migration.ts @@ -1,11 +1,9 @@ -import type { EntityType } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { enabledIntegrations } from "../../../../integrations/enabled-integrations"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, getCurrentHashSystemEntityTypeId, @@ -13,6 +11,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/021-add-org-invites.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/021-add-org-invites.migration.ts index 90c6c4c41f7..0183d8231d0 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/021-add-org-invites.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/021-add-org-invites.migration.ts @@ -1,4 +1,3 @@ -import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; @@ -7,7 +6,6 @@ import { systemEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, getCurrentHashPropertyTypeId, @@ -17,6 +15,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { BaseUrl, EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/022-add-migrations-completed-to-hash-instance.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/022-add-migrations-completed-to-hash-instance.migration.ts index 4fb253930ad..2416a9f160f 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/022-add-migrations-completed-to-hash-instance.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/022-add-migrations-completed-to-hash-instance.migration.ts @@ -6,7 +6,6 @@ import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/gra import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { getOrCreateOwningWebId } from "../../system-webs-and-entities"; -import type { MigrationFunction } from "../types"; import { createSystemPropertyTypeIfNotExists, getCurrentHashSystemEntityTypeId, @@ -14,6 +13,8 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; + /** * This migration adds tracking properties to the HASH Instance entity type: * - `migrationsCompleted`: Array of migration numbers that have been run diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/023-create-more-custom-data-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/023-create-more-custom-data-types.migration.ts index fb34261a6e2..d80819fab02 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/023-create-more-custom-data-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/023-create-more-custom-data-types.migration.ts @@ -1,8 +1,9 @@ import { blockProtocolDataTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/024-add-flow-types.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/024-add-flow-types.migration.ts index 29504c66c68..53ad176ba9d 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/024-add-flow-types.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/024-add-flow-types.migration.ts @@ -1,4 +1,3 @@ -import type { EntityType } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; @@ -9,7 +8,6 @@ import { systemEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists, createSystemEntityTypeIfNotExists, @@ -20,6 +18,9 @@ import { upgradeEntitiesToNewTypeVersion, } from "../util"; +import type { MigrationFunction } from "../types"; +import type { EntityType } from "@blockprotocol/type-system"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/086-add-study-record-type.dev.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/086-add-study-record-type.dev.migration.ts index 88d4cabc728..954d4963d55 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/086-add-study-record-type.dev.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/086-add-study-record-type.dev.migration.ts @@ -5,7 +5,6 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists, createSystemEntityTypeIfNotExists, @@ -15,6 +14,8 @@ import { getCurrentHashSystemEntityTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/087-add-initial-currency-data-types.dev.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/087-add-initial-currency-data-types.dev.migration.ts index 4b95fc86179..435a913b2a2 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/087-add-initial-currency-data-types.dev.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/087-add-initial-currency-data-types.dev.migration.ts @@ -1,8 +1,9 @@ import { blockProtocolDataTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/090-add-aviation-types.dev.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/090-add-aviation-types.dev.migration.ts index 4cb73021291..c7f729ae636 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/090-add-aviation-types.dev.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/090-add-aviation-types.dev.migration.ts @@ -4,7 +4,6 @@ import { blockProtocolPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemDataTypeIfNotExists, createSystemEntityTypeIfNotExists, @@ -12,6 +11,8 @@ import { getCurrentHashDataTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/091-add-petri-nets.dev.migration.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/091-add-petri-nets.dev.migration.ts index 5edb1cb6438..fdafe4fbf47 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/091-add-petri-nets.dev.migration.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/migrations/091-add-petri-nets.dev.migration.ts @@ -1,12 +1,13 @@ import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { MigrationFunction } from "../types"; import { createSystemEntityTypeIfNotExists, createSystemPropertyTypeIfNotExists, getCurrentHashPropertyTypeId, } from "../util"; +import type { MigrationFunction } from "../types"; + const migrate: MigrationFunction = async ({ context, authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/types.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/types.ts index 75ac2983245..a1f5f6da1dc 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/types.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/types.ts @@ -1,8 +1,7 @@ +import type { ImpureGraphContext } from "../../context-types"; import type { BaseUrl, OntologyTypeVersion } from "@blockprotocol/type-system"; import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; -import type { ImpureGraphContext } from "../../context-types"; - export type MigrationState = { propertyTypeVersions: Record; entityTypeVersions: Record; diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util.ts index 4d2c3cd3dd3..de122819d64 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util.ts @@ -2,30 +2,6 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; -import type { - BaseUrl, - Conversions, - DataType, - DataTypeMetadata, - DataTypeReference, - DataTypeWithMetadata, - Entity, - EntityType, - EntityTypeMetadata, - EntityTypeWithMetadata, - OneOfSchema, - OntologyTypeRecordId, - PropertyObjectWithMetadata, - PropertyType, - PropertyTypeMetadata, - PropertyTypeReference, - PropertyTypeWithMetadata, - PropertyValueArray, - PropertyValueObject, - PropertyValues, - ValueOrArray, - VersionedUrl, -} from "@blockprotocol/type-system"; import { atLeastOne, componentsFromVersionedUrl, @@ -39,11 +15,9 @@ import { versionedUrlFromComponents, } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; -import type { UpdatePropertyType } from "@local/hash-graph-client"; import { getDataTypeById } from "@local/hash-graph-sdk/data-type"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { getEntityTypeById } from "@local/hash-graph-sdk/entity-type"; -import type { ConstructDataTypeParams } from "@local/hash-graph-sdk/ontology"; import { getPropertyTypeById } from "@local/hash-graph-sdk/property-type"; import { currentTimeInstantTemporalAxes, @@ -57,25 +31,52 @@ import { systemLinkEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - SchemaKind, - SystemTypeWebShortname, -} from "@local/hash-isomorphic-utils/ontology-types"; import { generateLinkMapWithConsistentSelfReferences, generateTypeBaseUrl, } from "@local/hash-isomorphic-utils/ontology-types"; -import type { ImpureGraphFunction } from "../../context-types"; import { createDataType } from "../../ontology/primitive/data-type"; import { createEntityType } from "../../ontology/primitive/entity-type"; import { createPropertyType } from "../../ontology/primitive/property-type"; -import type { PrimitiveDataTypeKey } from "../system-webs-and-entities"; import { getOrCreateOwningWebId } from "../system-webs-and-entities"; -import type { MigrationState } from "./types"; import { upgradeWebEntities } from "./util/upgrade-entities"; import { upgradeEntityTypeDependencies } from "./util/upgrade-entity-type-dependencies"; +import type { ImpureGraphFunction } from "../../context-types"; +import type { PrimitiveDataTypeKey } from "../system-webs-and-entities"; +import type { MigrationState } from "./types"; +import type { + BaseUrl, + Conversions, + DataType, + DataTypeMetadata, + DataTypeReference, + DataTypeWithMetadata, + Entity, + EntityType, + EntityTypeMetadata, + EntityTypeWithMetadata, + OneOfSchema, + OntologyTypeRecordId, + PropertyObjectWithMetadata, + PropertyType, + PropertyTypeMetadata, + PropertyTypeReference, + PropertyTypeWithMetadata, + PropertyValueArray, + PropertyValueObject, + PropertyValues, + ValueOrArray, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { UpdatePropertyType } from "@local/hash-graph-client"; +import type { ConstructDataTypeParams } from "@local/hash-graph-sdk/ontology"; +import type { + SchemaKind, + SystemTypeWebShortname, +} from "@local/hash-isomorphic-utils/ontology-types"; + const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entities.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entities.ts index a3623824338..c3d26b843f4 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entities.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entities.ts @@ -2,12 +2,6 @@ import { getBreadthFirstEntityTypesAndParents, getRoots, } from "@blockprotocol/graph/stdlib"; -import type { - ActorEntityUuid, - BaseUrl, - PropertyObjectWithMetadata, - WebId, -} from "@blockprotocol/type-system"; import { compareOntologyTypeVersions, componentsFromVersionedUrl, @@ -29,9 +23,16 @@ import { systemLinkEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ImpureGraphContext } from "../../../context-types"; import { updateEntity } from "../../../knowledge/primitive/entity"; + +import type { ImpureGraphContext } from "../../../context-types"; import type { MigrationState } from "../types"; +import type { + ActorEntityUuid, + BaseUrl, + PropertyObjectWithMetadata, + WebId, +} from "@blockprotocol/type-system"; export const upgradeWebEntities = async ({ authentication, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entity-type-dependencies.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entity-type-dependencies.ts index dc0daf77010..0d63f76fb0d 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entity-type-dependencies.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/migrate-ontology-types/util/upgrade-entity-type-dependencies.ts @@ -1,10 +1,11 @@ +import { atLeastOne, extractBaseUrl } from "@blockprotocol/type-system"; +import { typedEntries } from "@local/advanced-types/typed-entries"; + import type { EntityType, EntityTypeReference, VersionedUrl, } from "@blockprotocol/type-system"; -import { atLeastOne, extractBaseUrl } from "@blockprotocol/type-system"; -import { typedEntries } from "@local/advanced-types/typed-entries"; export const replaceEntityTypeReference = ({ reference, diff --git a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/system-webs-and-entities.ts b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/system-webs-and-entities.ts index c567d480c7c..9266814d936 100644 --- a/apps/hash-api/src/graph/ensure-system-graph-is-initialized/system-webs-and-entities.ts +++ b/apps/hash-api/src/graph/ensure-system-graph-is-initialized/system-webs-and-entities.ts @@ -1,8 +1,3 @@ -import type { - MachineId, - VersionedUrl, - WebId, -} from "@blockprotocol/type-system"; import { componentsFromVersionedUrl } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; import { NotFoundError } from "@local/hash-backend-utils/error"; @@ -16,16 +11,22 @@ import { createAiActor, } from "@local/hash-graph-sdk/principal/actor-group"; import { getWebByShortname } from "@local/hash-graph-sdk/principal/web"; -import type { blockProtocolDataTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { SystemTypeWebShortname } from "@local/hash-isomorphic-utils/ontology-types"; import { enabledIntegrations } from "../../integrations/enabled-integrations"; import { logger } from "../../logger"; -import type { ImpureGraphContext } from "../context-types"; import { createOrg, getOrgByShortname } from "../knowledge/system-types/org"; import { systemAccountId } from "../system-account"; +import type { ImpureGraphContext } from "../context-types"; +import type { + MachineId, + VersionedUrl, + WebId, +} from "@blockprotocol/type-system"; +import type { blockProtocolDataTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; +import type { SystemTypeWebShortname } from "@local/hash-isomorphic-utils/ontology-types"; + export const owningWebs: Record< SystemTypeWebShortname, { diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity.ts b/apps/hash-api/src/graph/knowledge/primitive/entity.ts index 3cb2f4f94f7..aaeb2ed650d 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity.ts @@ -4,39 +4,14 @@ import { type QueryTemporalAxesUnresolved, type Subgraph, } from "@blockprotocol/graph"; -import type { - BaseUrl, - Entity, - EntityEditionId, - EntityId, - LinkData, - PropertyObject, - PropertyPatchOperation, - TeamId, - TypeIdsAndPropertiesForEntity, - VersionedUrl, - WebId, -} from "@blockprotocol/type-system"; import { extractDraftIdFromEntityId, extractEntityUuidFromEntityId, extractWebIdFromEntityId, splitEntityId, } from "@blockprotocol/type-system"; -import type { Subtype } from "@local/advanced-types/subtype"; import { typedKeys } from "@local/advanced-types/typed-entries"; import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; -import type { - AllFilter, - CountEntitiesParams, - DiffEntityResult, - Filter, - HasPermissionForEntitiesParams, -} from "@local/hash-graph-client"; -import type { - UserPermissions, - UserPermissionsOnEntities, -} from "@local/hash-graph-sdk/authorization"; import { type CreateEntityParameters, type DiffEntityInput, @@ -53,23 +28,49 @@ import { import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; -import type { ActionName } from "@rust/hash-graph-authorization/types"; -import type { TraversalPath } from "@rust/hash-graph-store/types"; -import type { - EntityDefinition, - LinkedEntityDefinition, -} from "../../../graphql/api-types.gen"; import * as GraphQlError from "../../../graphql/error"; import { linkedTreeFlatten } from "../../../util"; -import type { ImpureGraphFunction } from "../../context-types"; import { afterCreateEntityHooks } from "./entity/after-create-entity-hooks"; import { afterUpdateEntityHooks } from "./entity/after-update-entity-hooks"; import { beforeCreateEntityHooks } from "./entity/before-create-entity-hooks"; import { beforeUpdateEntityHooks } from "./entity/before-update-entity-hooks"; import { createLinkEntity, isEntityLinkEntity } from "./link-entity"; +import type { + EntityDefinition, + LinkedEntityDefinition, +} from "../../../graphql/api-types.gen"; +import type { ImpureGraphFunction } from "../../context-types"; +import type { + BaseUrl, + Entity, + EntityEditionId, + EntityId, + LinkData, + PropertyObject, + PropertyPatchOperation, + TeamId, + TypeIdsAndPropertiesForEntity, + VersionedUrl, + WebId, +} from "@blockprotocol/type-system"; +import type { Subtype } from "@local/advanced-types/subtype"; +import type { + AllFilter, + CountEntitiesParams, + DiffEntityResult, + Filter, + HasPermissionForEntitiesParams, +} from "@local/hash-graph-client"; +import type { + UserPermissions, + UserPermissionsOnEntities, +} from "@local/hash-graph-sdk/authorization"; +import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; +import type { ActionName } from "@rust/hash-graph-authorization/types"; +import type { TraversalPath } from "@rust/hash-graph-store/types"; + /** @todo: potentially directly export this from the subgraph package */ export type PropertyValue = PropertyObject[BaseUrl]; @@ -166,8 +167,8 @@ export const countEntities: ImpureGraphFunction< graphApi.countEntities(actorId, params).then(({ data }) => data); type GetLatestEntityByIdFunction< - Properties extends - TypeIdsAndPropertiesForEntity = TypeIdsAndPropertiesForEntity, + Properties extends TypeIdsAndPropertiesForEntity = + TypeIdsAndPropertiesForEntity, > = ImpureGraphFunction< { entityId: EntityId; @@ -195,8 +196,8 @@ type GetLatestEntityByIdFunction< * fault */ export const getLatestEntityById = async < - Properties extends - TypeIdsAndPropertiesForEntity = TypeIdsAndPropertiesForEntity, + Properties extends TypeIdsAndPropertiesForEntity = + TypeIdsAndPropertiesForEntity, >( ...args: Parameters> ): ReturnType> => { diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/after-create-entity-hooks.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/after-create-entity-hooks.ts index ae001aab7c7..e12e8bd6403 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/after-create-entity-hooks.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/after-create-entity-hooks.ts @@ -1,4 +1,3 @@ -import type { EntityUuid, WebId } from "@blockprotocol/type-system"; import { entityIdFromComponents } from "@blockprotocol/type-system"; import { systemEntityTypes, @@ -6,7 +5,6 @@ import { } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { includesPageEntityTypeId } from "@local/hash-isomorphic-utils/page-entity-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; import { isProdEnv } from "../../../../lib/env-config"; import { createOrUpdateMailchimpUser } from "../../../../mailchimp"; @@ -32,11 +30,14 @@ import { } from "../../system-types/text"; import { getUser } from "../../system-types/user"; import { checkPermissionsOnEntity } from "../entity"; +import { getTextUpdateOccurredIn } from "./shared/mention-notification"; + import type { AfterCreateEntityHook, AfterCreateEntityHookCallback, } from "./create-entity-hooks"; -import { getTextUpdateOccurredIn } from "./shared/mention-notification"; +import type { EntityUuid, WebId } from "@blockprotocol/type-system"; +import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; /** * This after create `Comment` entity hook is responsible for creating diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks.ts index 7703bb4e1dc..26684c238aa 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks.ts @@ -6,6 +6,7 @@ import { } from "./after-update-entity-hooks/file-document-after-update-entity-hook-callback"; import { textAfterUpdateEntityHookCallback } from "./after-update-entity-hooks/text-after-update-entity-hook-callback"; import { userAfterUpdateEntityHookCallback } from "./after-update-entity-hooks/user-after-update-entity-hook"; + import type { AfterUpdateEntityHook } from "./update-entity-hooks"; export const afterUpdateEntityHooks: AfterUpdateEntityHook[] = [ diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/file-document-after-update-entity-hook-callback.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/file-document-after-update-entity-hook-callback.ts index 6ed73d1650e..0a7c099b21b 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/file-document-after-update-entity-hook-callback.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/file-document-after-update-entity-hook-callback.ts @@ -1,4 +1,3 @@ -import type { VersionedUrl } from "@blockprotocol/type-system"; import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { isStorageType, @@ -10,15 +9,16 @@ import { type HashEntity, } from "@local/hash-graph-sdk/entity"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; + +import type { AfterUpdateEntityHookCallback } from "../update-entity-hooks"; +import type { VersionedUrl } from "@blockprotocol/type-system"; +import type { ParseTextFromFileParams } from "@local/hash-isomorphic-utils/parse-text-from-file-types"; import type { DOCXDocument } from "@local/hash-isomorphic-utils/system-types/docxdocument"; import type { File } from "@local/hash-isomorphic-utils/system-types/file"; import type { PDFDocument } from "@local/hash-isomorphic-utils/system-types/pdfdocument"; import type { PPTXPresentation } from "@local/hash-isomorphic-utils/system-types/pptxpresentation"; -import type { AfterUpdateEntityHookCallback } from "../update-entity-hooks"; - export const entityTypesToParseTextFrom: VersionedUrl[] = [ systemEntityTypes.docxDocument.entityTypeId, systemEntityTypes.pdfDocument.entityTypeId, diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/text-after-update-entity-hook-callback.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/text-after-update-entity-hook-callback.ts index 7a4ce121276..420547003d9 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/text-after-update-entity-hook-callback.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/text-after-update-entity-hook-callback.ts @@ -1,8 +1,5 @@ -import type { EntityUuid, WebId } from "@blockprotocol/type-system"; import { entityIdFromComponents } from "@blockprotocol/type-system"; import { getDefinedPropertyFromPatchesGetter } from "@local/hash-graph-sdk/entity"; -import type { TextProperties } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { TextToken } from "@local/hash-isomorphic-utils/types"; import { archiveNotification, @@ -16,7 +13,11 @@ import { import { getUser } from "../../../system-types/user"; import { checkPermissionsOnEntity } from "../../entity"; import { getTextUpdateOccurredIn } from "../shared/mention-notification"; + import type { AfterUpdateEntityHookCallback } from "../update-entity-hooks"; +import type { EntityUuid, WebId } from "@blockprotocol/type-system"; +import type { TextProperties } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; /** * This after update `Text` entity hook is responsible for creating diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/user-after-update-entity-hook.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/user-after-update-entity-hook.ts index 2a36f6b1677..ed31a534fb9 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/user-after-update-entity-hook.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/after-update-entity-hooks/user-after-update-entity-hook.ts @@ -1,6 +1,5 @@ import { getDefinedPropertyFromPatchesGetter } from "@local/hash-graph-sdk/entity"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; import { isProdEnv } from "../../../../../lib/env-config"; import { createOrUpdateMailchimpUser } from "../../../../../mailchimp"; @@ -8,7 +7,9 @@ import { getUserFromEntity, updateUserKratosIdentityTraits, } from "../../../system-types/user"; + import type { AfterUpdateEntityHookCallback } from "../update-entity-hooks"; +import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; export const userAfterUpdateEntityHookCallback: AfterUpdateEntityHookCallback = async ({ context, propertyPatches, updatedEntity }) => { diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks.ts index 71c7213c32d..0d729cff065 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks.ts @@ -1,6 +1,7 @@ import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { userBeforeEntityUpdateHookCallback } from "./before-update-entity-hooks/user-before-update-entity-hook-callback"; + import type { BeforeUpdateEntityHook } from "./update-entity-hooks"; export const beforeUpdateEntityHooks: BeforeUpdateEntityHook[] = [ diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks/user-before-update-entity-hook-callback.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks/user-before-update-entity-hook-callback.ts index 052466fc221..d44434c6de8 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks/user-before-update-entity-hook-callback.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/before-update-entity-hooks/user-before-update-entity-hook-callback.ts @@ -1,8 +1,5 @@ -import type { - ActorEntityUuid, - BaseUrl, - WebId, -} from "@blockprotocol/type-system"; +import { GraphQLError } from "graphql"; + import { getDefinedPropertyFromPatchesGetter, isValueRemovedByPatches, @@ -17,13 +14,10 @@ import { shortnamePropertyBaseUrl, userSelfUpdatablePropertyBaseUrls, } from "@local/hash-graph-sdk/user-entity-restrictions"; -import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; -import { GraphQLError } from "graphql"; import { isUserEmailVerified } from "../../../../../auth/ory-kratos"; import * as Error from "../../../../../graphql/error"; import { userHasAccessToHash } from "../../../../../shared/user-has-access-to-hash"; -import type { ImpureGraphContext } from "../../../../context-types"; import { systemAccountId } from "../../../../system-account"; import { shortnameContainsInvalidCharacter, @@ -33,7 +27,15 @@ import { shortnameMinimumLength, } from "../../../system-types/account.fields"; import { getUserFromEntity } from "../../../system-types/user"; + +import type { ImpureGraphContext } from "../../../../context-types"; import type { BeforeUpdateEntityHookCallback } from "../update-entity-hooks"; +import type { + ActorEntityUuid, + BaseUrl, + WebId, +} from "@blockprotocol/type-system"; +import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; /** * Properties that have special handling in this hook beyond the general whitelist. diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/create-entity-hooks.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/create-entity-hooks.ts index 1a5b35f7e4d..c76fe11acb1 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/create-entity-hooks.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/create-entity-hooks.ts @@ -1,3 +1,4 @@ +import type { ImpureGraphContext } from "../../../context-types"; import type { PropertyObjectWithMetadata, VersionedUrl, @@ -5,8 +6,6 @@ import type { import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { ImpureGraphContext } from "../../../context-types"; - export type BeforeCreateEntityHookCallback = (params: { context: ImpureGraphContext; authentication: AuthenticationContext; diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/shared/mention-notification.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/shared/mention-notification.ts index 95cb6e5da16..382c248669d 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/shared/mention-notification.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/shared/mention-notification.ts @@ -1,18 +1,19 @@ import { includesPageEntityTypeId } from "@local/hash-isomorphic-utils/page-entity-type-ids"; -import type { ImpureGraphFunction } from "../../../../context-types"; -import type { Block } from "../../../system-types/block"; import { getBlockCollectionByBlock } from "../../../system-types/block"; -import type { Comment } from "../../../system-types/comment"; import { getCommentAncestorBlock } from "../../../system-types/comment"; -import type { Page } from "../../../system-types/page"; import { getPageFromEntity } from "../../../system-types/page"; -import type { Text } from "../../../system-types/text"; import { getCommentByText, getPageAndBlockByText, } from "../../../system-types/text"; +import type { ImpureGraphFunction } from "../../../../context-types"; +import type { Block } from "../../../system-types/block"; +import type { Comment } from "../../../system-types/comment"; +import type { Page } from "../../../system-types/page"; +import type { Text } from "../../../system-types/text"; + export const getTextUpdateOccurredIn: ImpureGraphFunction< { text: Text; includeDrafts?: boolean }, Promise<{ diff --git a/apps/hash-api/src/graph/knowledge/primitive/entity/update-entity-hooks.ts b/apps/hash-api/src/graph/knowledge/primitive/entity/update-entity-hooks.ts index ea4a029a5c2..be19b312c07 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/entity/update-entity-hooks.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/entity/update-entity-hooks.ts @@ -1,3 +1,4 @@ +import type { ImpureGraphContext } from "../../../context-types"; import type { PropertyPatchOperation, VersionedUrl, @@ -5,8 +6,6 @@ import type { import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { ImpureGraphContext } from "../../../context-types"; - type UpdateEntityHookCallbackBaseParams = { context: ImpureGraphContext; authentication: AuthenticationContext; diff --git a/apps/hash-api/src/graph/knowledge/primitive/link-entity.ts b/apps/hash-api/src/graph/knowledge/primitive/link-entity.ts index cf22fd17c0e..9e40fa0f259 100644 --- a/apps/hash-api/src/graph/knowledge/primitive/link-entity.ts +++ b/apps/hash-api/src/graph/knowledge/primitive/link-entity.ts @@ -1,3 +1,9 @@ +import { HashLinkEntity } from "@local/hash-graph-sdk/entity"; + +import { getLatestEntityById } from "./entity"; +import { afterCreateEntityHooks } from "./entity/after-create-entity-hooks"; + +import type { ImpureGraphFunction } from "../../context-types"; import type { LinkData, PropertyPatchOperation, @@ -7,11 +13,6 @@ import type { CreateEntityParameters, HashEntity, } from "@local/hash-graph-sdk/entity"; -import { HashLinkEntity } from "@local/hash-graph-sdk/entity"; - -import type { ImpureGraphFunction } from "../../context-types"; -import { getLatestEntityById } from "./entity"; -import { afterCreateEntityHooks } from "./entity/after-create-entity-hooks"; export const isEntityLinkEntity = ( entity: HashEntity, diff --git a/apps/hash-api/src/graph/knowledge/system-types/account.fields.ts b/apps/hash-api/src/graph/knowledge/system-types/account.fields.ts index 987fcff6943..6276a76430e 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/account.fields.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/account.fields.ts @@ -1,9 +1,10 @@ +import { getOrgByShortname } from "./org"; +import { getUser } from "./user"; + import type { ImpureGraphFunction, PureGraphFunction, } from "../../context-types"; -import { getOrgByShortname } from "./org"; -import { getUser } from "./user"; /** @todo: enable admins to expand upon restricted shortnames block list */ export const RESTRICTED_SHORTNAMES = [ diff --git a/apps/hash-api/src/graph/knowledge/system-types/block-collection.ts b/apps/hash-api/src/graph/knowledge/system-types/block-collection.ts index 909a6092d77..2c587bff1f8 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/block-collection.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/block-collection.ts @@ -1,8 +1,3 @@ -import type { - Entity, - EntityId, - VersionedUrl, -} from "@blockprotocol/type-system"; import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { HashLinkEntity, @@ -13,11 +8,7 @@ import { systemEntityTypes, systemLinkEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { HasSpatiallyPositionedContent } from "@local/hash-isomorphic-utils/system-types/canvas"; -import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { PositionInput } from "../../../graphql/api-types.gen"; -import type { ImpureGraphFunction } from "../../context-types"; import { getEntityOutgoingLinks, getLatestEntityById, @@ -27,9 +18,19 @@ import { getLinkEntityRightEntity, updateLinkEntity, } from "../primitive/link-entity"; -import type { Block } from "./block"; import { getBlockFromEntity } from "./block"; +import type { PositionInput } from "../../../graphql/api-types.gen"; +import type { ImpureGraphFunction } from "../../context-types"; +import type { Block } from "./block"; +import type { + Entity, + EntityId, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { HasSpatiallyPositionedContent } from "@local/hash-isomorphic-utils/system-types/canvas"; +import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; + /** * Get the blocks in this blockCollection. * diff --git a/apps/hash-api/src/graph/knowledge/system-types/block.ts b/apps/hash-api/src/graph/knowledge/system-types/block.ts index f8880ce5813..84f7c59521e 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/block.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/block.ts @@ -1,4 +1,3 @@ -import type { Entity, EntityId } from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, @@ -19,15 +18,7 @@ import { } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { contentLinkTypeFilter } from "@local/hash-isomorphic-utils/page-entity-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { - Block as BlockEntity, - HasData, -} from "@local/hash-isomorphic-utils/system-types/shared"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; import { createEntity, getEntityIncomingLinks, @@ -40,9 +31,19 @@ import { getLinkEntityRightEntity, isEntityLinkEntity, } from "../primitive/link-entity"; -import type { Comment } from "./comment"; import { getCommentFromEntity } from "./comment"; +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { Comment } from "./comment"; +import type { Entity, EntityId } from "@blockprotocol/type-system"; +import type { + Block as BlockEntity, + HasData, +} from "@local/hash-isomorphic-utils/system-types/shared"; + export type Block = { componentId: string; entity: HashEntity; diff --git a/apps/hash-api/src/graph/knowledge/system-types/comment.ts b/apps/hash-api/src/graph/knowledge/system-types/comment.ts index 338b7ec63f3..c1cfcc97464 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/comment.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/comment.ts @@ -1,9 +1,4 @@ -import type { EntityId, EntityUuid } from "@blockprotocol/type-system"; import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; -import type { - CreateEntityParameters, - HashEntity, -} from "@local/hash-graph-sdk/entity"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { blockProtocolPropertyTypes, @@ -11,18 +6,7 @@ import { systemLinkEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - Comment as CommentEntity, - CommentPropertiesWithMetadata, - Text as TextEntity, - TextPropertiesWithMetadata, -} from "@local/hash-isomorphic-utils/system-types/shared"; -import type { TextToken } from "@local/hash-isomorphic-utils/types"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; import { createEntity, getEntityIncomingLinks, @@ -34,13 +18,30 @@ import { getLinkEntityLeftEntity, getLinkEntityRightEntity, } from "../primitive/link-entity"; -import type { Block } from "./block"; import { getBlockFromEntity } from "./block"; -import type { Text } from "./text"; import { getTextFromEntity } from "./text"; -import type { User } from "./user"; import { getUserFromEntity } from "./user"; +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { Block } from "./block"; +import type { Text } from "./text"; +import type { User } from "./user"; +import type { EntityId, EntityUuid } from "@blockprotocol/type-system"; +import type { + CreateEntityParameters, + HashEntity, +} from "@local/hash-graph-sdk/entity"; +import type { + Comment as CommentEntity, + CommentPropertiesWithMetadata, + Text as TextEntity, + TextPropertiesWithMetadata, +} from "@local/hash-isomorphic-utils/system-types/shared"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; + export type Comment = { /** * @todo - these should probably be changed to encapsulate multi-axis versioning information, or should be explicitly diff --git a/apps/hash-api/src/graph/knowledge/system-types/file.ts b/apps/hash-api/src/graph/knowledge/system-types/file.ts index e5fdf71dd8f..944d95b7c26 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/file.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/file.ts @@ -1,24 +1,21 @@ -import type { - BaseUrl, - Entity, - VersionedUrl, - WebId, -} from "@blockprotocol/type-system"; +import mime from "mime-types"; + import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { PresignedPutUpload } from "@local/hash-backend-utils/file-storage"; import { formatFileUrl, getEntityTypeIdForMimeType, } from "@local/hash-backend-utils/file-storage"; import { validateExternalUrl } from "@local/hash-backend-utils/url-validation"; -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { normalizeWhitespace } from "@local/hash-isomorphic-utils/normalize"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; -import mime from "mime-types"; + +import { + createEntity, + getLatestEntityById, + updateEntity, +} from "../primitive/entity"; import type { MutationCreateFileFromUrlArgs, @@ -28,11 +25,16 @@ import type { ImpureGraphContext, ImpureGraphFunction, } from "../../context-types"; -import { - createEntity, - getLatestEntityById, - updateEntity, -} from "../primitive/entity"; +import type { + BaseUrl, + Entity, + VersionedUrl, + WebId, +} from "@blockprotocol/type-system"; +import type { PresignedPutUpload } from "@local/hash-backend-utils/file-storage"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; // 1800 seconds const UPLOAD_URL_EXPIRATION_SECONDS = 60 * 30; diff --git a/apps/hash-api/src/graph/knowledge/system-types/flow-schedule.ts b/apps/hash-api/src/graph/knowledge/system-types/flow-schedule.ts index fd2872d37c7..678d15af3b4 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/flow-schedule.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/flow-schedule.ts @@ -1,10 +1,4 @@ -import type { EntityId } from "@blockprotocol/type-system"; import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { - CreateFlowScheduleInput, - UpdateFlowScheduleInput, -} from "@local/hash-isomorphic-utils/flows/schedule-types"; import { defaultScheduleCatchupWindowMs, defaultScheduleOverlapPolicy, @@ -15,20 +9,27 @@ import { systemEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - FlowSchedule, - FlowSchedulePropertiesWithMetadata, - SchedulePauseStatePropertyValueWithMetadata, - ScheduleStatusPropertyValueWithMetadata, -} from "@local/hash-isomorphic-utils/system-types/shared"; -import type { ImpureGraphFunction } from "../../context-types"; import { createEntity, getLatestEntityById, updateEntity, } from "../primitive/entity"; +import type { ImpureGraphFunction } from "../../context-types"; +import type { EntityId } from "@blockprotocol/type-system"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { + CreateFlowScheduleInput, + UpdateFlowScheduleInput, +} from "@local/hash-isomorphic-utils/flows/schedule-types"; +import type { + FlowSchedule, + FlowSchedulePropertiesWithMetadata, + SchedulePauseStatePropertyValueWithMetadata, + ScheduleStatusPropertyValueWithMetadata, +} from "@local/hash-isomorphic-utils/system-types/shared"; + const isEntityFlowScheduleEntity = ( entity: HashEntity, ): entity is HashEntity => diff --git a/apps/hash-api/src/graph/knowledge/system-types/hash-instance.ts b/apps/hash-api/src/graph/knowledge/system-types/hash-instance.ts index 5b04d4c27e8..12e0208558b 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/hash-instance.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/hash-instance.ts @@ -1,18 +1,19 @@ -import type { ActorId, VersionedUrl } from "@blockprotocol/type-system"; import { NotFoundError } from "@local/hash-backend-utils/error"; -import type { HashInstance } from "@local/hash-backend-utils/hash-instance"; import { getHashInstance, getHashInstanceFromEntity, } from "@local/hash-backend-utils/hash-instance"; import { createPolicy, deletePolicyById } from "@local/hash-graph-sdk/policy"; import { getInstanceAdminsTeam } from "@local/hash-graph-sdk/principal/hash-instance-admins"; -import type { HASHInstance as HashInstanceEntity } from "@local/hash-isomorphic-utils/system-types/hashinstance"; import { logger } from "../../../logger"; -import type { ImpureGraphFunction } from "../../context-types"; import { createEntity } from "../primitive/entity"; +import type { ImpureGraphFunction } from "../../context-types"; +import type { ActorId, VersionedUrl } from "@blockprotocol/type-system"; +import type { HashInstance } from "@local/hash-backend-utils/hash-instance"; +import type { HASHInstance as HashInstanceEntity } from "@local/hash-isomorphic-utils/system-types/hashinstance"; + /** * Create the hash instance entity. * diff --git a/apps/hash-api/src/graph/knowledge/system-types/linear-integration-entity.ts b/apps/hash-api/src/graph/knowledge/system-types/linear-integration-entity.ts index 3499616ee40..70818ab2ddb 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/linear-integration-entity.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/linear-integration-entity.ts @@ -2,13 +2,6 @@ import { getRightEntityForLinkEntity, getRoots, } from "@blockprotocol/graph/stdlib"; -import type { - ActorEntityUuid, - BaseUrl, - Entity, - EntityId, - EntityUuid, -} from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, @@ -30,18 +23,26 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { - LinearIntegration as LinearIntegrationEntity, - SyncLinearDataWith, - SyncLinearDataWithProperties, -} from "@local/hash-isomorphic-utils/system-types/linearintegration"; + +import { getLatestEntityById, updateEntity } from "../primitive/entity"; +import { createLinkEntity } from "../primitive/link-entity"; import type { ImpureGraphFunction, PureGraphFunction, } from "../../context-types"; -import { getLatestEntityById, updateEntity } from "../primitive/entity"; -import { createLinkEntity } from "../primitive/link-entity"; +import type { + ActorEntityUuid, + BaseUrl, + Entity, + EntityId, + EntityUuid, +} from "@blockprotocol/type-system"; +import type { + LinearIntegration as LinearIntegrationEntity, + SyncLinearDataWith, + SyncLinearDataWithProperties, +} from "@local/hash-isomorphic-utils/system-types/linearintegration"; export type LinearIntegration = { linearOrgId: string; diff --git a/apps/hash-api/src/graph/knowledge/system-types/linear-user-secret.ts b/apps/hash-api/src/graph/knowledge/system-types/linear-user-secret.ts index 241719a29b8..3217556a34f 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/linear-user-secret.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/linear-user-secret.ts @@ -1,9 +1,5 @@ -import type { - ActorEntityUuid, - Entity, - EntityId, - WebId, -} from "@blockprotocol/type-system"; +import * as Sentry from "@sentry/node"; + import { extractWebIdFromEntityId, splitEntityId, @@ -12,7 +8,6 @@ import { EntityTypeMismatchError, NotFoundError, } from "@local/hash-backend-utils/error"; -import type { VaultClient } from "@local/hash-backend-utils/vault"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes, @@ -24,14 +19,20 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { LinearIntegration } from "@local/hash-isomorphic-utils/system-types/linearintegration"; -import type { UserSecret } from "@local/hash-isomorphic-utils/system-types/shared"; -import * as Sentry from "@sentry/node"; import type { ImpureGraphFunction, PureGraphFunction, } from "../../context-types"; +import type { + ActorEntityUuid, + Entity, + EntityId, + WebId, +} from "@blockprotocol/type-system"; +import type { VaultClient } from "@local/hash-backend-utils/vault"; +import type { LinearIntegration } from "@local/hash-isomorphic-utils/system-types/linearintegration"; +import type { UserSecret } from "@local/hash-isomorphic-utils/system-types/shared"; export type LinearUserSecret = { connectionSourceName: string; diff --git a/apps/hash-api/src/graph/knowledge/system-types/notification.ts b/apps/hash-api/src/graph/knowledge/system-types/notification.ts index 1846176fc33..ffb396c9a10 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/notification.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/notification.ts @@ -2,13 +2,8 @@ import { getOutgoingLinksForEntity, getRoots, } from "@blockprotocol/graph/stdlib"; -import type { EntityId, VersionedUrl } from "@blockprotocol/type-system"; import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; import { getWebMachineId } from "@local/hash-backend-utils/machine-actors"; -import type { - CreateEntityParameters, - HashEntity, -} from "@local/hash-graph-sdk/entity"; import { HashLinkEntity, queryEntitySubgraph, @@ -24,6 +19,24 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; + +import { createEntity, updateEntity } from "../primitive/entity"; +import { createLinkEntity } from "../primitive/link-entity"; + +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { Block } from "./block"; +import type { Comment } from "./comment"; +import type { Page } from "./page"; +import type { Text } from "./text"; +import type { User } from "./user"; +import type { EntityId, VersionedUrl } from "@blockprotocol/type-system"; +import type { + CreateEntityParameters, + HashEntity, +} from "@local/hash-graph-sdk/entity"; import type { ArchivedPropertyValueWithMetadata, CommentNotification as CommentNotificationEntity, @@ -38,18 +51,6 @@ import type { } from "@local/hash-isomorphic-utils/system-types/mentionnotification"; import type { Notification as NotificationEntity } from "@local/hash-isomorphic-utils/system-types/notification"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; -import { createEntity, updateEntity } from "../primitive/entity"; -import { createLinkEntity } from "../primitive/link-entity"; -import type { Block } from "./block"; -import type { Comment } from "./comment"; -import type { Page } from "./page"; -import type { Text } from "./text"; -import type { User } from "./user"; - type Notification = { archived?: boolean; entity: HashEntity; diff --git a/apps/hash-api/src/graph/knowledge/system-types/org-membership.ts b/apps/hash-api/src/graph/knowledge/system-types/org-membership.ts index 9dbb54cc669..e65c76553a5 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/org-membership.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/org-membership.ts @@ -1,34 +1,35 @@ -import type { - ActorEntityUuid, - EntityId, - EntityUuid, - UserId, -} from "@blockprotocol/type-system"; import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; -import type { HashLinkEntity } from "@local/hash-graph-sdk/entity"; import { addActorGroupMember, removeActorGroupMember, } from "@local/hash-graph-sdk/principal/actor-group"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { systemLinkEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { IsMemberOf } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; import { createLinkEntity, getLinkEntityLeftEntity, getLinkEntityRightEntity, } from "../primitive/link-entity"; -import type { Org } from "./org"; import { getOrgFromEntity } from "./org"; -import type { User } from "./user"; import { getUserFromEntity } from "./user"; +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { Org } from "./org"; +import type { User } from "./user"; +import type { + ActorEntityUuid, + EntityId, + EntityUuid, + UserId, +} from "@blockprotocol/type-system"; +import type { HashLinkEntity } from "@local/hash-graph-sdk/entity"; +import type { IsMemberOf } from "@local/hash-isomorphic-utils/system-types/shared"; + export type OrgMembership = { linkEntity: HashLinkEntity; }; diff --git a/apps/hash-api/src/graph/knowledge/system-types/org.ts b/apps/hash-api/src/graph/knowledge/system-types/org.ts index ccc7952ebc3..188e836f298 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/org.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/org.ts @@ -1,10 +1,3 @@ -import type { - ActorId, - EntityId, - MachineId, - OntologyTypeVersion, - WebId, -} from "@blockprotocol/type-system"; import { extractBaseUrl, extractWebIdFromEntityId, @@ -28,18 +21,8 @@ import { } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { validateOrgName } from "@local/hash-isomorphic-utils/organization"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { - Organization, - OrganizationNamePropertyValueWithMetadata, - OrganizationPropertiesWithMetadata, -} from "@local/hash-isomorphic-utils/system-types/shared"; -import type { PolicyId } from "@rust/hash-graph-authorization/types"; import { logger } from "../../../logger"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; import { systemAccountId } from "../../system-account"; import { createEntity, @@ -52,6 +35,24 @@ import { shortnameIsTaken, } from "./account.fields"; +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { + ActorId, + EntityId, + MachineId, + OntologyTypeVersion, + WebId, +} from "@blockprotocol/type-system"; +import type { + Organization, + OrganizationNamePropertyValueWithMetadata, + OrganizationPropertiesWithMetadata, +} from "@local/hash-isomorphic-utils/system-types/shared"; +import type { PolicyId } from "@rust/hash-graph-authorization/types"; + export type Org = { webId: WebId; orgName: string; diff --git a/apps/hash-api/src/graph/knowledge/system-types/page.ts b/apps/hash-api/src/graph/knowledge/system-types/page.ts index 9b65faf9823..5c7cb1e040b 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/page.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/page.ts @@ -1,4 +1,5 @@ -import type { EntityId, WebId } from "@blockprotocol/type-system"; +import { generateKeyBetween } from "fractional-indexing"; + import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; import { type CreateEntityParameters, @@ -19,21 +20,8 @@ import { pageEntityTypeIds, } from "@local/hash-isomorphic-utils/page-entity-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { - Canvas, - FractionalIndexPropertyValueWithMetadata, - HasParent, - HasSpatiallyPositionedContent, -} from "@local/hash-isomorphic-utils/system-types/canvas"; -import type { Document } from "@local/hash-isomorphic-utils/system-types/document"; -import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; -import { generateKeyBetween } from "fractional-indexing"; import * as GraphQlError from "../../../graphql/error"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; import { createEntity, getEntityOutgoingLinks, @@ -44,10 +32,24 @@ import { createLinkEntity, getLinkEntityRightEntity, } from "../primitive/link-entity"; -import type { Block } from "./block"; import { getBlockComments, getBlockFromEntity } from "./block"; import { addBlockToBlockCollection } from "./block-collection"; + +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { Block } from "./block"; import type { Comment } from "./comment"; +import type { EntityId, WebId } from "@blockprotocol/type-system"; +import type { + Canvas, + FractionalIndexPropertyValueWithMetadata, + HasParent, + HasSpatiallyPositionedContent, +} from "@local/hash-isomorphic-utils/system-types/canvas"; +import type { Document } from "@local/hash-isomorphic-utils/system-types/document"; +import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; export type Page = { title: string; diff --git a/apps/hash-api/src/graph/knowledge/system-types/text.ts b/apps/hash-api/src/graph/knowledge/system-types/text.ts index 6ef78af22d7..8dcf562383e 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/text.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/text.ts @@ -1,4 +1,3 @@ -import type { EntityId } from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; import { type HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; @@ -15,23 +14,25 @@ import { pageEntityTypeFilter, } from "@local/hash-isomorphic-utils/page-entity-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { Text as TextEntity } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { TextToken } from "@local/hash-isomorphic-utils/types"; + +import { getLatestEntityById } from "../primitive/entity"; +import { isEntityLinkEntity } from "../primitive/link-entity"; +import { getBlockById } from "./block"; +import { getCommentById } from "./comment"; +import { getPageFromEntity } from "./page"; +import { getUser } from "./user"; import type { ImpureGraphFunction, PureGraphFunction, } from "../../context-types"; -import { getLatestEntityById } from "../primitive/entity"; -import { isEntityLinkEntity } from "../primitive/link-entity"; import type { Block } from "./block"; -import { getBlockById } from "./block"; import type { Comment } from "./comment"; -import { getCommentById } from "./comment"; import type { Page } from "./page"; -import { getPageFromEntity } from "./page"; import type { User } from "./user"; -import { getUser } from "./user"; +import type { EntityId } from "@blockprotocol/type-system"; +import type { Text as TextEntity } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; export type Text = { textualContent: TextToken[]; diff --git a/apps/hash-api/src/graph/knowledge/system-types/user-secret.ts b/apps/hash-api/src/graph/knowledge/system-types/user-secret.ts index 313fa18584f..2b8928b9b3e 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/user-secret.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/user-secret.ts @@ -1,3 +1,14 @@ +import { getSecretEntitiesForIntegration } from "@local/hash-backend-utils/user-secret"; +import { createUserSecretPath } from "@local/hash-backend-utils/vault"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; +import { + systemEntityTypes, + systemLinkEntityTypes, +} from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { createEntity } from "../primitive/entity"; +import { createLinkEntity } from "../primitive/link-entity"; + import type { EntityId, EntityUuid, @@ -6,25 +17,15 @@ import type { UserId, WebId, } from "@blockprotocol/type-system"; -import { getSecretEntitiesForIntegration } from "@local/hash-backend-utils/user-secret"; import type { UserSecretService, VaultClient, } from "@local/hash-backend-utils/vault"; -import { createUserSecretPath } from "@local/hash-backend-utils/vault"; import type { GraphApi } from "@local/hash-graph-client"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import { - systemEntityTypes, - systemLinkEntityTypes, -} from "@local/hash-isomorphic-utils/ontology-type-ids"; import type { UsesUserSecret } from "@local/hash-isomorphic-utils/system-types/google/shared"; import type { UserSecret } from "@local/hash-isomorphic-utils/system-types/shared"; import type { Auth } from "googleapis"; -import { createEntity } from "../primitive/entity"; -import { createLinkEntity } from "../primitive/link-entity"; - type CreateUserSecretParams = { /** * Whether to archive all existing secrets linked from the sourceIntegrationEntityId. diff --git a/apps/hash-api/src/graph/knowledge/system-types/user.ts b/apps/hash-api/src/graph/knowledge/system-types/user.ts index 022193eb4dd..4e2eea5c1d9 100644 --- a/apps/hash-api/src/graph/knowledge/system-types/user.ts +++ b/apps/hash-api/src/graph/knowledge/system-types/user.ts @@ -1,4 +1,3 @@ -import type { EntityId, EntityUuid, UserId } from "@blockprotocol/type-system"; import { atLeastOne, extractBaseUrl, @@ -7,7 +6,6 @@ import { } from "@blockprotocol/type-system"; import { EntityTypeMismatchError } from "@local/hash-backend-utils/error"; import { createWebMachineActorEntity } from "@local/hash-backend-utils/machine-actors"; -import type { Filter } from "@local/hash-graph-client"; import { type HashEntity, queryEntities, @@ -26,29 +24,16 @@ import { currentTimeInstantTemporalAxes, generateVersionedUrlMatchingFilter, } from "@local/hash-isomorphic-utils/graph-queries"; -import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; import { systemEntityTypes, systemLinkEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { - EnabledFeatureFlagsPropertyValue, - User as UserEntity, -} from "@local/hash-isomorphic-utils/system-types/user"; -import type { - KratosUserIdentity, - KratosUserIdentityTraits, -} from "../../../auth/ory-kratos"; import { kratosIdentityApi } from "../../../auth/ory-kratos"; import { getPendingOrgInvitationsFromSubgraph } from "../../../graphql/resolvers/knowledge/org/shared"; import { logger } from "../../../logger"; -import type { - ImpureGraphFunction, - PureGraphFunction, -} from "../../context-types"; import { systemAccountId } from "../../system-account"; import { createEntity, @@ -60,13 +45,29 @@ import { shortnameIsRestricted, shortnameIsTaken, } from "./account.fields"; -import type { OrgMembership } from "./org-membership"; import { createOrgMembership, getOrgMembershipFromLinkEntity, getOrgMembershipOrg, } from "./org-membership"; +import type { + KratosUserIdentity, + KratosUserIdentityTraits, +} from "../../../auth/ory-kratos"; +import type { + ImpureGraphFunction, + PureGraphFunction, +} from "../../context-types"; +import type { OrgMembership } from "./org-membership"; +import type { EntityId, EntityUuid, UserId } from "@blockprotocol/type-system"; +import type { Filter } from "@local/hash-graph-client"; +import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; +import type { + EnabledFeatureFlagsPropertyValue, + User as UserEntity, +} from "@local/hash-isomorphic-utils/system-types/user"; + export type User = { accountId: UserId; displayName?: string; diff --git a/apps/hash-api/src/graph/ontology/primitive/data-type.ts b/apps/hash-api/src/graph/ontology/primitive/data-type.ts index b45db4428bf..7480ebf2343 100644 --- a/apps/hash-api/src/graph/ontology/primitive/data-type.ts +++ b/apps/hash-api/src/graph/ontology/primitive/data-type.ts @@ -1,3 +1,14 @@ +import { + DATA_TYPE_META_SCHEMA, + ontologyTypeRecordIdToVersionedUrl, +} from "@blockprotocol/type-system"; +import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; +import { hasPermissionForDataTypes } from "@local/hash-graph-sdk/data-type"; +import { generateTypeId } from "@local/hash-isomorphic-utils/ontology-types"; + +import { getWebShortname } from "./util"; + +import type { ImpureGraphFunction } from "../../context-types"; import type { BaseUrl, Conversions, @@ -9,25 +20,15 @@ import type { VersionedUrl, WebId, } from "@blockprotocol/type-system"; -import { - DATA_TYPE_META_SCHEMA, - ontologyTypeRecordIdToVersionedUrl, -} from "@blockprotocol/type-system"; -import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; import type { ArchiveDataTypeParams, UnarchiveDataTypeParams, } from "@local/hash-graph-client"; import type { UserPermissionsOnDataType } from "@local/hash-graph-sdk/authorization"; -import { hasPermissionForDataTypes } from "@local/hash-graph-sdk/data-type"; import type { ConstructDataTypeParams, DataTypeDirectConversionsMap, } from "@local/hash-graph-sdk/ontology"; -import { generateTypeId } from "@local/hash-isomorphic-utils/ontology-types"; - -import type { ImpureGraphFunction } from "../../context-types"; -import { getWebShortname } from "./util"; /** * Create a data type. diff --git a/apps/hash-api/src/graph/ontology/primitive/entity-type.ts b/apps/hash-api/src/graph/ontology/primitive/entity-type.ts index 4270d41d1f9..f06d4001854 100644 --- a/apps/hash-api/src/graph/ontology/primitive/entity-type.ts +++ b/apps/hash-api/src/graph/ontology/primitive/entity-type.ts @@ -1,3 +1,20 @@ +import { + ENTITY_TYPE_META_SCHEMA, + ontologyTypeRecordIdToVersionedUrl, +} from "@blockprotocol/type-system"; +import { NotFoundError } from "@local/hash-backend-utils/error"; +import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; +import { + getEntityTypeById, + hasPermissionForEntityTypes, +} from "@local/hash-graph-sdk/entity-type"; +import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; +import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; +import { generateTypeId } from "@local/hash-isomorphic-utils/ontology-types"; + +import { getWebShortname } from "./util"; + +import type { ImpureGraphFunction } from "../../context-types"; import type { EntityType, EntityTypeMetadata, @@ -8,29 +25,13 @@ import type { VersionedUrl, WebId, } from "@blockprotocol/type-system"; -import { - ENTITY_TYPE_META_SCHEMA, - ontologyTypeRecordIdToVersionedUrl, -} from "@blockprotocol/type-system"; -import { NotFoundError } from "@local/hash-backend-utils/error"; -import { publicUserAccountId } from "@local/hash-backend-utils/public-user-account-id"; import type { ArchiveEntityTypeParams, UnarchiveEntityTypeParams, UpdateEntityTypeRequest, } from "@local/hash-graph-client"; import type { UserPermissionsOnEntityType } from "@local/hash-graph-sdk/authorization"; -import { - getEntityTypeById, - hasPermissionForEntityTypes, -} from "@local/hash-graph-sdk/entity-type"; import type { ConstructEntityTypeParams } from "@local/hash-graph-sdk/ontology"; -import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; -import { blockProtocolEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import { generateTypeId } from "@local/hash-isomorphic-utils/ontology-types"; - -import type { ImpureGraphFunction } from "../../context-types"; -import { getWebShortname } from "./util"; export const checkPermissionsOnEntityType: ImpureGraphFunction< { entityTypeId: VersionedUrl }, diff --git a/apps/hash-api/src/graph/ontology/primitive/property-type.ts b/apps/hash-api/src/graph/ontology/primitive/property-type.ts index 498bd5b4caa..7a33c815b3b 100644 --- a/apps/hash-api/src/graph/ontology/primitive/property-type.ts +++ b/apps/hash-api/src/graph/ontology/primitive/property-type.ts @@ -1,3 +1,12 @@ +import { + ontologyTypeRecordIdToVersionedUrl, + PROPERTY_TYPE_META_SCHEMA, +} from "@blockprotocol/type-system"; +import { generateTypeId } from "@local/hash-isomorphic-utils/ontology-types"; + +import { getWebShortname } from "./util"; + +import type { ImpureGraphFunction } from "../../context-types"; import type { OntologyTemporalMetadata, OntologyTypeRecordId, @@ -7,20 +16,12 @@ import type { VersionedUrl, WebId, } from "@blockprotocol/type-system"; -import { - ontologyTypeRecordIdToVersionedUrl, - PROPERTY_TYPE_META_SCHEMA, -} from "@blockprotocol/type-system"; import type { ArchivePropertyTypeParams, UnarchivePropertyTypeParams, UpdatePropertyTypeRequest, } from "@local/hash-graph-client"; import type { ConstructPropertyTypeParams } from "@local/hash-graph-sdk/ontology"; -import { generateTypeId } from "@local/hash-isomorphic-utils/ontology-types"; - -import type { ImpureGraphFunction } from "../../context-types"; -import { getWebShortname } from "./util"; /** * Create a property type. diff --git a/apps/hash-api/src/graph/ontology/primitive/util.ts b/apps/hash-api/src/graph/ontology/primitive/util.ts index 04682e4e52d..913ebe2d7a8 100644 --- a/apps/hash-api/src/graph/ontology/primitive/util.ts +++ b/apps/hash-api/src/graph/ontology/primitive/util.ts @@ -1,9 +1,9 @@ -import type { VersionedUrl, WebId } from "@blockprotocol/type-system"; import { getWebById } from "@local/hash-graph-sdk/principal/web"; import { frontendUrl } from "@local/hash-isomorphic-utils/environment"; import { isSelfHostedInstance } from "@local/hash-isomorphic-utils/instance"; import type { ImpureGraphFunction } from "../../context-types"; +import type { VersionedUrl, WebId } from "@blockprotocol/type-system"; export const isExternalTypeId = (typeId: VersionedUrl) => !typeId.startsWith(frontendUrl) && diff --git a/apps/hash-api/src/graph/system-account.ts b/apps/hash-api/src/graph/system-account.ts index 3ded8563642..d517ff25e1d 100644 --- a/apps/hash-api/src/graph/system-account.ts +++ b/apps/hash-api/src/graph/system-account.ts @@ -1,8 +1,7 @@ +import type { ImpureGraphContext } from "./context-types"; import type { MachineId } from "@blockprotocol/type-system"; import type { Logger } from "@local/hash-backend-utils/logger"; -import type { ImpureGraphContext } from "./context-types"; - // eslint-disable-next-line import/no-mutable-exports export let systemAccountId: MachineId; diff --git a/apps/hash-api/src/graphql/context.ts b/apps/hash-api/src/graphql/context.ts index 253f450fca6..e8448430b4b 100644 --- a/apps/hash-api/src/graphql/context.ts +++ b/apps/hash-api/src/graphql/context.ts @@ -1,3 +1,6 @@ +import type { EmailTransporter } from "../email/transporters"; +import type { GraphApi } from "../graph/context-types"; +import type { User } from "../graph/knowledge/system-types/user"; import type { ProvidedEntityEditionProvenance } from "@blockprotocol/type-system"; import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; import type { Logger } from "@local/hash-backend-utils/logger"; @@ -5,10 +8,6 @@ import type { TemporalClient } from "@local/hash-backend-utils/temporal"; import type { VaultClient } from "@local/hash-backend-utils/vault"; import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; -import type { EmailTransporter } from "../email/transporters"; -import type { GraphApi } from "../graph/context-types"; -import type { User } from "../graph/knowledge/system-types/user"; - /** * Apollo context object with dataSources. For details see: * https://www.apollographql.com/docs/apollo-server/data/data-sources/ diff --git a/apps/hash-api/src/graphql/create-apollo-server.ts b/apps/hash-api/src/graphql/create-apollo-server.ts index 372247b9b4f..dbef03b36ac 100644 --- a/apps/hash-api/src/graphql/create-apollo-server.ts +++ b/apps/hash-api/src/graphql/create-apollo-server.ts @@ -1,4 +1,3 @@ -import type { Server } from "node:http"; import { performance } from "node:perf_hooks"; import { ApolloServer, type ApolloServerPlugin } from "@apollo/server"; @@ -10,25 +9,28 @@ import { import { KeyvAdapter } from "@apollo/utils.keyvadapter"; import { expressMiddleware } from "@as-integrations/express5"; import { makeExecutableSchema } from "@graphql-tools/schema"; -import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; -import type { Logger } from "@local/hash-backend-utils/logger"; -import type { TemporalClient } from "@local/hash-backend-utils/temporal"; -import type { VaultClient } from "@local/hash-backend-utils/vault"; +import * as Sentry from "@sentry/node"; + import { schema } from "@local/hash-isomorphic-utils/graphql/type-defs/schema"; import { getHashClientTypeFromRequest, hashClientHeaderKey, } from "@local/hash-isomorphic-utils/http-requests"; -import * as Sentry from "@sentry/node"; -import type { StatsD } from "hot-shots"; -import type Keyv from "keyv"; import { getActorIdFromRequest } from "../auth/get-actor-id"; +import { isProdEnv } from "../lib/env-config"; +import { resolvers } from "./resolvers"; + import type { EmailTransporter } from "../email/transporters"; import type { GraphApi } from "../graph/context-types"; -import { isProdEnv } from "../lib/env-config"; import type { GraphQLContext } from "./context"; -import { resolvers } from "./resolvers"; +import type { FileStorageProvider } from "@local/hash-backend-utils/file-storage"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { TemporalClient } from "@local/hash-backend-utils/temporal"; +import type { VaultClient } from "@local/hash-backend-utils/vault"; +import type { StatsD } from "hot-shots"; +import type Keyv from "keyv"; +import type { Server } from "node:http"; const statsPlugin = ({ statsd, diff --git a/apps/hash-api/src/graphql/resolvers/blockprotocol/get-block.ts b/apps/hash-api/src/graphql/resolvers/blockprotocol/get-block.ts index 8fe2f17e121..384234d6eff 100644 --- a/apps/hash-api/src/graphql/resolvers/blockprotocol/get-block.ts +++ b/apps/hash-api/src/graphql/resolvers/blockprotocol/get-block.ts @@ -1,8 +1,9 @@ import { blockProtocolHubOrigin } from "@local/hash-isomorphic-utils/blocks-constants"; +import * as Error from "../../error"; + import type { BlockProtocolBlock, ResolverFn } from "../../api-types.gen"; import type { GraphQLContext } from "../../context"; -import * as Error from "../../error"; export const getBlockProtocolBlocksResolver: ResolverFn< BlockProtocolBlock[], diff --git a/apps/hash-api/src/graphql/resolvers/embed/index.ts b/apps/hash-api/src/graphql/resolvers/embed/index.ts index ad90d5ec555..25a7508d107 100644 --- a/apps/hash-api/src/graphql/resolvers/embed/index.ts +++ b/apps/hash-api/src/graphql/resolvers/embed/index.ts @@ -1,6 +1,8 @@ import oEmbedData from "oembed-providers/providers.json"; import sanitizeHtml from "sanitize-html"; +import * as Error from "../../error"; + import type { Embed, Maybe, @@ -8,7 +10,6 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext } from "../../context"; -import * as Error from "../../error"; /** * Sanitize oEmbed HTML to prevent XSS from third-party providers. diff --git a/apps/hash-api/src/graphql/resolvers/flows/cancel-flow.ts b/apps/hash-api/src/graphql/resolvers/flows/cancel-flow.ts index 24db3d40580..c1792600628 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/cancel-flow.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/cancel-flow.ts @@ -1,12 +1,13 @@ -import type { EntityUuid } from "@blockprotocol/type-system"; import { getFlowRunEntityById } from "@local/hash-backend-utils/flows"; import { temporalNamespace } from "@local/hash-backend-utils/temporal"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { checkEntityPermission } from "../../../graph/knowledge/primitive/entity"; +import * as Error from "../../error"; + import type { MutationResetFlowArgs, ResolverFn } from "../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../context"; -import * as Error from "../../error"; +import type { EntityUuid } from "@blockprotocol/type-system"; export const cancelFlow: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/flows/flow-schedule.ts b/apps/hash-api/src/graphql/resolvers/flows/flow-schedule.ts index 737de5c23c2..614791aa478 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/flow-schedule.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/flow-schedule.ts @@ -1,11 +1,11 @@ +import { ScheduleNotFoundError } from "@temporalio/client"; + import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; import { defaultScheduleCatchupWindowMs, scheduleSpecToTemporalSpec, } from "@local/hash-isomorphic-utils/flows/schedule-types"; -import type { RunFlowWorkflowParams } from "@local/hash-isomorphic-utils/flows/temporal-types"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import { ScheduleNotFoundError } from "@temporalio/client"; import { createFlowSchedule as createFlowScheduleEntity, @@ -16,6 +16,9 @@ import { revertFlowScheduleResume, updateFlowSchedule as updateFlowScheduleEntity, } from "../../../graph/knowledge/system-types/flow-schedule"; +import * as GraphQLError from "../../error"; +import { graphQLContextToImpureGraphContext } from "../util"; + import type { Mutation, MutationArchiveFlowScheduleArgs, @@ -26,8 +29,7 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../context"; -import * as GraphQLError from "../../error"; -import { graphQLContextToImpureGraphContext } from "../util"; +import type { RunFlowWorkflowParams } from "@local/hash-isomorphic-utils/flows/temporal-types"; export const createFlowScheduleResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/flows/get-flow-run-by-id.ts b/apps/hash-api/src/graphql/resolvers/flows/get-flow-run-by-id.ts index ec1a00992ae..0e647e13cbd 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/get-flow-run-by-id.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/get-flow-run-by-id.ts @@ -1,6 +1,7 @@ -import type { EntityUuid } from "@blockprotocol/type-system"; import { getFlowRunById } from "@local/hash-backend-utils/flows"; -import type { SparseFlowRun } from "@local/hash-isomorphic-utils/flows/types"; + +import * as Error from "../../error"; +import { wereDetailedFieldsRequested } from "./shared/were-detailed-fields-requested"; import type { FlowRun, @@ -8,8 +9,8 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext } from "../../context"; -import * as Error from "../../error"; -import { wereDetailedFieldsRequested } from "./shared/were-detailed-fields-requested"; +import type { EntityUuid } from "@blockprotocol/type-system"; +import type { SparseFlowRun } from "@local/hash-isomorphic-utils/flows/types"; export const getFlowRunByIdResolver: ResolverFn< FlowRun | SparseFlowRun, diff --git a/apps/hash-api/src/graphql/resolvers/flows/get-flow-runs.ts b/apps/hash-api/src/graphql/resolvers/flows/get-flow-runs.ts index 8f9a8a0b898..8d27ac2f0e2 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/get-flow-runs.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/get-flow-runs.ts @@ -1,5 +1,6 @@ import { getFlowRuns } from "@local/hash-backend-utils/flows"; -import type { SparseFlowRun } from "@local/hash-isomorphic-utils/flows/types"; + +import { wereDetailedFieldsRequested } from "./shared/were-detailed-fields-requested"; import type { FlowRun, @@ -7,7 +8,7 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext } from "../../context"; -import { wereDetailedFieldsRequested } from "./shared/were-detailed-fields-requested"; +import type { SparseFlowRun } from "@local/hash-isomorphic-utils/flows/types"; export const getFlowRunsResolver: ResolverFn< { diff --git a/apps/hash-api/src/graphql/resolvers/flows/reset-flow.ts b/apps/hash-api/src/graphql/resolvers/flows/reset-flow.ts index de63a8ab860..f5811ba8003 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/reset-flow.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/reset-flow.ts @@ -1,14 +1,16 @@ -import type { EntityUuid } from "@blockprotocol/type-system"; +import proto from "@temporalio/proto"; +import Long from "long"; + import { getFlowRunEntityById } from "@local/hash-backend-utils/flows"; import { temporalNamespace } from "@local/hash-backend-utils/temporal"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import proto from "@temporalio/proto"; -import Long from "long"; import { checkEntityPermission } from "../../../graph/knowledge/primitive/entity"; +import * as Error from "../../error"; + import type { MutationResetFlowArgs, ResolverFn } from "../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../context"; -import * as Error from "../../error"; +import type { EntityUuid } from "@blockprotocol/type-system"; export const resetFlow: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/flows/shared/were-detailed-fields-requested.ts b/apps/hash-api/src/graphql/resolvers/flows/shared/were-detailed-fields-requested.ts index 233bd87f3c6..7876e1d4a40 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/shared/were-detailed-fields-requested.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/shared/were-detailed-fields-requested.ts @@ -1,8 +1,10 @@ -import type { DetailedFlowField } from "@local/hash-isomorphic-utils/flows/types"; +import { parseResolveInfo } from "graphql-parse-resolve-info"; + import { detailedFlowFields } from "@local/hash-isomorphic-utils/flows/types"; + +import type { DetailedFlowField } from "@local/hash-isomorphic-utils/flows/types"; import type { GraphQLResolveInfo } from "graphql"; import type { ResolveTree } from "graphql-parse-resolve-info"; -import { parseResolveInfo } from "graphql-parse-resolve-info"; /** * Works for both `getFlowRuns` (returns `PaginatedFlowRuns` wrapping `FlowRun`) diff --git a/apps/hash-api/src/graphql/resolvers/flows/start-flow.ts b/apps/hash-api/src/graphql/resolvers/flows/start-flow.ts index e939ce21f96..492619419c8 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/start-flow.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/start-flow.ts @@ -1,8 +1,3 @@ -import type { EntityUuid } from "@blockprotocol/type-system"; -import type { - RunFlowWorkflowParams, - RunFlowWorkflowResponse, -} from "@local/hash-isomorphic-utils/flows/temporal-types"; import { validateFlowDefinition } from "@local/hash-isomorphic-utils/flows/util"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; @@ -10,9 +5,15 @@ import { type MutationStartFlowArgs, type ResolverFn, } from "../../api-types.gen"; -import type { LoggedInGraphQLContext } from "../../context"; import * as Error from "../../error"; +import type { LoggedInGraphQLContext } from "../../context"; +import type { EntityUuid } from "@blockprotocol/type-system"; +import type { + RunFlowWorkflowParams, + RunFlowWorkflowResponse, +} from "@local/hash-isomorphic-utils/flows/temporal-types"; + export const startFlow: ResolverFn< Promise, Record, diff --git a/apps/hash-api/src/graphql/resolvers/flows/submit-external-input-response.ts b/apps/hash-api/src/graphql/resolvers/flows/submit-external-input-response.ts index 8cb9ccfd94f..91ddb0ed5f6 100644 --- a/apps/hash-api/src/graphql/resolvers/flows/submit-external-input-response.ts +++ b/apps/hash-api/src/graphql/resolvers/flows/submit-external-input-response.ts @@ -1,13 +1,14 @@ -import type { EntityUuid } from "@blockprotocol/type-system"; import { getFlowRunEntityById } from "@local/hash-backend-utils/flows"; import { externalInputResponseSignal } from "@local/hash-isomorphic-utils/flows/signals"; +import * as Error from "../../error"; + import type { MutationSubmitExternalInputResponseArgs, ResolverFn, } from "../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../context"; -import * as Error from "../../error"; +import type { EntityUuid } from "@blockprotocol/type-system"; export const submitExternalInputResponse: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/generation/generate-inverse.ts b/apps/hash-api/src/graphql/resolvers/generation/generate-inverse.ts index 496a7a0d53f..a149809841a 100644 --- a/apps/hash-api/src/graphql/resolvers/generation/generate-inverse.ts +++ b/apps/hash-api/src/graphql/resolvers/generation/generate-inverse.ts @@ -1,10 +1,11 @@ import { backOff } from "exponential-backoff"; -import type { QueryGenerateInverseArgs, ResolverFn } from "../../api-types.gen"; -import type { GraphQLContext } from "../../context"; import * as Error from "../../error"; import { getOpenAiClient } from "./shared/openai-client"; +import type { QueryGenerateInverseArgs, ResolverFn } from "../../api-types.gen"; +import type { GraphQLContext } from "../../context"; + const generatePrompt = (relationship: string): string => ` You are building the ontology for a knowledge graph. You have a directed relationship between two nodes called "${relationship}". diff --git a/apps/hash-api/src/graphql/resolvers/generation/generate-plural.ts b/apps/hash-api/src/graphql/resolvers/generation/generate-plural.ts index 8d329517bc9..d0388331207 100644 --- a/apps/hash-api/src/graphql/resolvers/generation/generate-plural.ts +++ b/apps/hash-api/src/graphql/resolvers/generation/generate-plural.ts @@ -1,10 +1,11 @@ import { backOff } from "exponential-backoff"; -import type { QueryGeneratePluralArgs, ResolverFn } from "../../api-types.gen"; -import type { GraphQLContext } from "../../context"; import * as Error from "../../error"; import { getOpenAiClient } from "./shared/openai-client"; +import type { QueryGeneratePluralArgs, ResolverFn } from "../../api-types.gen"; +import type { GraphQLContext } from "../../context"; + const generatePrompt = (type: string): string => ` You are building the ontology for a knowledge graph. diff --git a/apps/hash-api/src/graphql/resolvers/generation/is-generation-available.ts b/apps/hash-api/src/graphql/resolvers/generation/is-generation-available.ts index 0adddb4eb59..2b6f441d59a 100644 --- a/apps/hash-api/src/graphql/resolvers/generation/is-generation-available.ts +++ b/apps/hash-api/src/graphql/resolvers/generation/is-generation-available.ts @@ -1,11 +1,11 @@ -import type OpenAI from "openai"; +import { getOpenAiClient } from "./shared/openai-client"; import type { IsGenerationAvailableResponse, ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext } from "../../context"; -import { getOpenAiClient } from "./shared/openai-client"; +import type OpenAI from "openai"; export const isGenerationAvailableResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/index.ts b/apps/hash-api/src/graphql/resolvers/index.ts index 101b28388a2..1dbfa76322a 100644 --- a/apps/hash-api/src/graphql/resolvers/index.ts +++ b/apps/hash-api/src/graphql/resolvers/index.ts @@ -1,12 +1,5 @@ import { JSONObjectResolver } from "graphql-scalars"; -import type { - EntityAuthorizationSubject, - MutationResolvers, - PendingOrgInvitation, - QueryResolvers, - Resolvers, -} from "../api-types.gen"; import { getBlockProtocolBlocksResolver } from "./blockprotocol/get-block"; import { embedCode } from "./embed"; import { cancelFlow } from "./flows/cancel-flow"; @@ -27,10 +20,10 @@ import { generatePluralResolver } from "./generation/generate-plural"; import { isGenerationAvailableResolver } from "./generation/is-generation-available"; import { getLinearOrganizationResolver } from "./integrations/linear/linear-organization"; import { syncLinearIntegrationWithWebsMutation } from "./integrations/linear/sync-linear-integration-with-webs"; -import { blocksResolver } from "./knowledge/block/block"; -import { blockChildEntityResolver } from "./knowledge/block/data-entity"; import { blockCollectionContents } from "./knowledge/block-collection/block-collection-contents"; import { updateBlockCollectionContents } from "./knowledge/block-collection/update-block-collection-contents"; +import { blocksResolver } from "./knowledge/block/block"; +import { blockChildEntityResolver } from "./knowledge/block/data-entity"; import { commentAuthorResolver } from "./knowledge/comment/author"; import { createCommentResolver } from "./knowledge/comment/comment"; import { deleteCommentResolver } from "./knowledge/comment/delete"; @@ -114,6 +107,14 @@ import { updatePropertyTypeResolver, } from "./ontology/property-type"; +import type { + EntityAuthorizationSubject, + MutationResolvers, + PendingOrgInvitation, + QueryResolvers, + Resolvers, +} from "../api-types.gen"; + export const resolvers: Omit & { Query: Required; Mutation: Required; diff --git a/apps/hash-api/src/graphql/resolvers/integrations/linear/linear-organization.ts b/apps/hash-api/src/graphql/resolvers/integrations/linear/linear-organization.ts index fd9cbd855d7..2d6f0d6bd63 100644 --- a/apps/hash-api/src/graphql/resolvers/integrations/linear/linear-organization.ts +++ b/apps/hash-api/src/graphql/resolvers/integrations/linear/linear-organization.ts @@ -1,12 +1,13 @@ import { getLinearUserSecretByLinearOrgId } from "../../../../graph/knowledge/system-types/linear-user-secret"; import { getOrganization, listTeams } from "../../../../integrations/linear"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { LinearOrganization, QueryGetLinearOrganizationArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; export const getLinearOrganizationResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/integrations/linear/sync-linear-integration-with-webs.ts b/apps/hash-api/src/graphql/resolvers/integrations/linear/sync-linear-integration-with-webs.ts index ba7a2382224..e80fa40c843 100644 --- a/apps/hash-api/src/graphql/resolvers/integrations/linear/sync-linear-integration-with-webs.ts +++ b/apps/hash-api/src/graphql/resolvers/integrations/linear/sync-linear-integration-with-webs.ts @@ -1,8 +1,3 @@ -import type { - ActorEntityUuid, - Entity, - WebId, -} from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, @@ -20,12 +15,18 @@ import { } from "../../../../graph/knowledge/system-types/linear-integration-entity"; import { getLinearUserSecretByLinearOrgId } from "../../../../graph/knowledge/system-types/linear-user-secret"; import { Linear } from "../../../../integrations/linear"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { MutationSyncLinearIntegrationWithWebsArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { + ActorEntityUuid, + Entity, + WebId, +} from "@blockprotocol/type-system"; export const syncLinearIntegrationWithWebsMutation: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/block-collection-contents.ts b/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/block-collection-contents.ts index afb9a3b0e80..7550d253a64 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/block-collection-contents.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/block-collection-contents.ts @@ -1,14 +1,14 @@ -import type { Entity } from "@blockprotocol/type-system"; -import type { HashLinkEntity } from "@local/hash-graph-sdk/entity"; -import type { HasSpatiallyPositionedContent } from "@local/hash-isomorphic-utils/system-types/canvas"; -import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; - import { getBlockCollectionBlocks } from "../../../../graph/knowledge/system-types/block-collection"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapBlockToGQL } from "../graphql-mapping"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedBlockGQL } from "../graphql-mapping"; -import { mapBlockToGQL } from "../graphql-mapping"; +import type { Entity } from "@blockprotocol/type-system"; +import type { HashLinkEntity } from "@local/hash-graph-sdk/entity"; +import type { HasSpatiallyPositionedContent } from "@local/hash-isomorphic-utils/system-types/canvas"; +import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; export const blockCollectionContents: ResolverFn< { diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-actions.ts b/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-actions.ts index 50a8ff1f9a8..c248436d8db 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-actions.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-actions.ts @@ -1,30 +1,25 @@ import { ApolloServerErrorCode } from "@apollo/server/errors"; -import type { - Entity, - EntityId, - PropertyPatchOperation, - VersionedUrl, - WebId, -} from "@blockprotocol/type-system"; -import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; -import { mergePropertiesAndMetadata } from "@local/hash-graph-sdk/entity"; import { GraphQLError } from "graphql"; import { produce } from "immer"; -import type { ImpureGraphContext } from "../../../../graph/context-types"; -import type { PropertyValue } from "../../../../graph/knowledge/primitive/entity"; +import { typedEntries } from "@local/advanced-types/typed-entries"; +import { mergePropertiesAndMetadata } from "@local/hash-graph-sdk/entity"; + import { createEntityWithLinks, getLatestEntityById, updateEntity, } from "../../../../graph/knowledge/primitive/entity"; -import type { Block } from "../../../../graph/knowledge/system-types/block"; import { createBlock, getBlockById, updateBlockDataEntity, } from "../../../../graph/knowledge/system-types/block"; +import * as Error from "../../../error"; + +import type { ImpureGraphContext } from "../../../../graph/context-types"; +import type { PropertyValue } from "../../../../graph/knowledge/primitive/entity"; +import type { Block } from "../../../../graph/knowledge/system-types/block"; import type { User } from "../../../../graph/knowledge/system-types/user"; import type { CreateEntityAction, @@ -34,7 +29,14 @@ import type { UpdateBlockCollectionAction, UpdateEntityAction, } from "../../../api-types.gen"; -import * as Error from "../../../error"; +import type { + Entity, + EntityId, + PropertyPatchOperation, + VersionedUrl, + WebId, +} from "@blockprotocol/type-system"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; export const createEntityWithPlaceholdersFn = ( diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-contents.ts b/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-contents.ts index 74ecc11cd34..9f850d63040 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-contents.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/block-collection/update-block-collection-contents.ts @@ -1,5 +1,3 @@ -import type { Entity } from "@blockprotocol/type-system"; - import { getLatestEntityById } from "../../../../graph/knowledge/primitive/entity"; import { addBlockToBlockCollection, @@ -7,12 +5,6 @@ import { removeBlockFromBlockCollection, } from "../../../../graph/knowledge/system-types/block-collection"; import { exactlyOne } from "../../../../util"; -import type { - MutationUpdateBlockCollectionContentsArgs, - ResolverFn, - UpdateBlockCollectionContentsResult, -} from "../../../api-types.gen"; -import type { LoggedInGraphQLContext } from "../../../context"; import * as Error from "../../../error"; import { graphQLContextToImpureGraphContext } from "../../util"; import { @@ -25,6 +17,14 @@ import { PlaceholderResultsMap, } from "./update-block-collection-actions"; +import type { + MutationUpdateBlockCollectionContentsArgs, + ResolverFn, + UpdateBlockCollectionContentsResult, +} from "../../../api-types.gen"; +import type { LoggedInGraphQLContext } from "../../../context"; +import type { Entity } from "@blockprotocol/type-system"; + /** * @todo This operation should ideally be atomic in nature, either we do all * updates or none. currently there is no guarantee that a failure rolls back diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/block/block.ts b/apps/hash-api/src/graphql/resolvers/knowledge/block/block.ts index 67538bca43f..1781a2f2b35 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/block/block.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/block/block.ts @@ -1,7 +1,8 @@ import { getBlockById } from "../../../../graph/knowledge/system-types/block"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { QueryBlocksArgs, ResolverFn } from "../../../api-types.gen"; import type { GraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedBlockGQL } from "../graphql-mapping"; export const blocksResolver: ResolverFn< diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/block/data-entity.ts b/apps/hash-api/src/graphql/resolvers/knowledge/block/data-entity.ts index 49243c277de..ad62bc6f12a 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/block/data-entity.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/block/data-entity.ts @@ -1,13 +1,13 @@ -import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; - import { getBlockById, getBlockData, } from "../../../../graph/knowledge/system-types/block"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { ResolverFn } from "../../../api-types.gen"; import type { GraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedBlockGQL } from "../graphql-mapping"; +import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; export const blockChildEntityResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/author.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/author.ts index eec16745ade..e94d5b43a28 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/author.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/author.ts @@ -1,10 +1,10 @@ -import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; - import { getCommentAuthor } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; +import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; export const commentAuthorResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/comment.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/comment.ts index e6996d6105e..dac2af85ec1 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/comment.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/comment.ts @@ -1,14 +1,15 @@ import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { createComment } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapCommentToGQL } from "../graphql-mapping"; + import type { MutationCreateCommentArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; -import { mapCommentToGQL } from "../graphql-mapping"; export const createCommentResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/delete.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/delete.ts index af3c769c648..d0413502960 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/delete.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/delete.ts @@ -2,14 +2,15 @@ import { deleteComment, getCommentById, } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapCommentToGQL } from "../graphql-mapping"; + import type { MutationDeleteCommentArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; -import { mapCommentToGQL } from "../graphql-mapping"; export const deleteCommentResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/has-text.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/has-text.ts index 61b18eff06d..724046750b6 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/has-text.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/has-text.ts @@ -1,10 +1,10 @@ -import type { TextToken } from "@local/hash-isomorphic-utils/types"; - import { getCommentText } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; export const commentHasTextResolver: ResolverFn< TextToken[], diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/parent.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/parent.ts index 3404ac698c5..3771dbacc1a 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/parent.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/parent.ts @@ -1,10 +1,10 @@ -import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; - import { getCommentParent } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; +import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; export const commentParentResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/replies.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/replies.ts index e4cee3cb2e8..a3e563bae7d 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/replies.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/replies.ts @@ -1,9 +1,10 @@ import { getCommentReplies } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapCommentToGQL } from "../graphql-mapping"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; -import { mapCommentToGQL } from "../graphql-mapping"; export const commentRepliesResolver: ResolverFn< UnresolvedCommentGQL[], diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/resolve.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/resolve.ts index d60a8a5e231..f14b4876f80 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/resolve.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/resolve.ts @@ -2,14 +2,15 @@ import { getCommentById, resolveComment, } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapCommentToGQL } from "../graphql-mapping"; + import type { MutationResolveCommentArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; -import { mapCommentToGQL } from "../graphql-mapping"; export const resolveCommentResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/text-updated-at.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/text-updated-at.ts index d523f3642fa..8d6bca8811e 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/text-updated-at.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/text-updated-at.ts @@ -1,7 +1,8 @@ import { getCommentText } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { CommentResolvers } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; export const commentTextUpdatedAtResolver: CommentResolvers["textUpdatedAt"] = async ({ metadata }, _, graphQLContext) => { diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/comment/update-text.ts b/apps/hash-api/src/graphql/resolvers/knowledge/comment/update-text.ts index 92bf7194aae..89961872a54 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/comment/update-text.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/comment/update-text.ts @@ -2,14 +2,15 @@ import { getCommentById, updateCommentText, } from "../../../../graph/knowledge/system-types/comment"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapCommentToGQL } from "../graphql-mapping"; + import type { MutationUpdateCommentTextArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL } from "../graphql-mapping"; -import { mapCommentToGQL } from "../graphql-mapping"; export const updateCommentTextResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/entity/entity.ts b/apps/hash-api/src/graphql/resolvers/knowledge/entity/entity.ts index 08c54ec7909..a9c43736b1b 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/entity/entity.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/entity/entity.ts @@ -1,4 +1,3 @@ -import type { Entity, EntityId, WebId } from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId, mustHaveAtLeastOne, @@ -16,7 +15,6 @@ import { deletePolicyById, queryPolicies, } from "@local/hash-graph-sdk/policy"; -import type { EntityValidationReport } from "@local/hash-graph-sdk/validation"; import { canUserReadEntity, @@ -31,6 +29,10 @@ import { isEntityLinkEntity, updateLinkEntity, } from "../../../../graph/knowledge/primitive/link-entity"; +import { AuthorizationSubjectKind } from "../../../api-types.gen"; +import * as Error from "../../../error"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { MutationAddEntityViewerArgs, MutationArchiveEntitiesArgs, @@ -47,10 +49,9 @@ import type { QueryValidateEntityArgs, ResolverFn, } from "../../../api-types.gen"; -import { AuthorizationSubjectKind } from "../../../api-types.gen"; import type { GraphQLContext, LoggedInGraphQLContext } from "../../../context"; -import * as Error from "../../../error"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { Entity, EntityId, WebId } from "@blockprotocol/type-system"; +import type { EntityValidationReport } from "@local/hash-graph-sdk/validation"; export const createEntityResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/entity/get-entity-diffs.ts b/apps/hash-api/src/graphql/resolvers/knowledge/entity/get-entity-diffs.ts index 107aeca0577..832747c5e29 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/entity/get-entity-diffs.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/entity/get-entity-diffs.ts @@ -1,4 +1,5 @@ import { calculateEntityDiff } from "../../../../graph/knowledge/primitive/entity"; + import type { EntityDiff, Query, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/file/create-file-from-url.ts b/apps/hash-api/src/graphql/resolvers/knowledge/file/create-file-from-url.ts index 36e43a97bcd..2bfd2cd6caf 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/file/create-file-from-url.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/file/create-file-from-url.ts @@ -1,15 +1,16 @@ -import type { Entity } from "@blockprotocol/type-system"; import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; -import type { File as FileEntity } from "@local/hash-isomorphic-utils/system-types/shared"; import { createFileFromExternalUrl } from "../../../../graph/knowledge/system-types/file"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { triggerPdfAnalysisWorkflow } from "./shared"; + import type { MutationCreateFileFromUrlArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; -import { triggerPdfAnalysisWorkflow } from "./shared"; +import type { Entity } from "@blockprotocol/type-system"; +import type { File as FileEntity } from "@local/hash-isomorphic-utils/system-types/shared"; export const createFileFromUrl: ResolverFn< Promise>, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/file/request-file-upload.ts b/apps/hash-api/src/graphql/resolvers/knowledge/file/request-file-upload.ts index b96e4cead43..2b22e5c48c5 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/file/request-file-upload.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/file/request-file-upload.ts @@ -1,15 +1,16 @@ import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { createFileFromUploadRequest } from "../../../../graph/knowledge/system-types/file"; +import * as Error from "../../../error"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { triggerPdfAnalysisWorkflow } from "./shared"; + import type { MutationRequestFileUploadArgs, RequestFileUploadResponse, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import * as Error from "../../../error"; -import { graphQLContextToImpureGraphContext } from "../../util"; -import { triggerPdfAnalysisWorkflow } from "./shared"; /** * We want to limit the size of files that can be uploaded to account diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/file/shared.ts b/apps/hash-api/src/graphql/resolvers/knowledge/file/shared.ts index 23b9d00923e..f708489e997 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/file/shared.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/file/shared.ts @@ -1,11 +1,12 @@ +import { inferMetadataFromDocumentFlowDefinition } from "@local/hash-isomorphic-utils/flows/file-flow-definitions"; +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; + import type { Entity, UserId, WebId } from "@blockprotocol/type-system"; import type { TemporalClient } from "@local/hash-backend-utils/temporal"; -import { inferMetadataFromDocumentFlowDefinition } from "@local/hash-isomorphic-utils/flows/file-flow-definitions"; import type { RunFlowWorkflowParams, RunFlowWorkflowResponse, } from "@local/hash-isomorphic-utils/flows/temporal-types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; export const triggerPdfAnalysisWorkflow = async ({ diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/hash-instance/hash-instance.ts b/apps/hash-api/src/graphql/resolvers/knowledge/hash-instance/hash-instance.ts index 601a262be41..49fbcd34bb9 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/hash-instance/hash-instance.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/hash-instance/hash-instance.ts @@ -2,9 +2,10 @@ import { getHashInstance } from "@local/hash-backend-utils/hash-instance"; import { isUserHashInstanceAdmin } from "@local/hash-graph-sdk/principal/hash-instance-admins"; import { enabledIntegrations } from "../../../../integrations/enabled-integrations"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { HashInstanceSettings, ResolverFn } from "../../../api-types.gen"; import type { GraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; export const hashInstanceSettingsResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/accept-org-invitation.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/accept-org-invitation.ts index ab553b197b7..17587128d13 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/accept-org-invitation.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/accept-org-invitation.ts @@ -1,7 +1,5 @@ import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { getActorGroupRole } from "@local/hash-graph-sdk/principal/actor-group"; -import type { MutationAcceptOrgInvitationArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; import { systemLinkEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { isInvitationByEmail, @@ -21,13 +19,16 @@ import { joinOrg, } from "../../../../graph/knowledge/system-types/user"; import { systemAccountId } from "../../../../graph/system-account"; +import * as Error from "../../../error"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { AcceptInvitationResult, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import * as Error from "../../../error"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { MutationAcceptOrgInvitationArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; export const acceptOrgInvitationResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/create-org.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/create-org.ts index ccbd33cb262..bf2c150262c 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/create-org.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/create-org.ts @@ -1,10 +1,10 @@ -import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; - import { createOrg } from "../../../../graph/knowledge/system-types/org"; import { createOrgMembershipLinkEntity } from "../../../../graph/knowledge/system-types/org-membership"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { MutationCreateOrgArgs, ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { SerializedEntity } from "@local/hash-graph-sdk/entity"; export const createOrgResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/decline-org-invitation.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/decline-org-invitation.ts index 2eea5f7369e..47a0244e63b 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/decline-org-invitation.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/decline-org-invitation.ts @@ -1,13 +1,13 @@ -import type { MutationDeclineOrgInvitationArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; - import { getLatestEntityRootedSubgraph } from "../../../../graph/knowledge/primitive/entity"; import { systemAccountId } from "../../../../graph/system-account"; -import type { ResolverFn } from "../../../api-types.gen"; -import type { LoggedInGraphQLContext } from "../../../context"; import * as Error from "../../../error"; import { graphQLContextToImpureGraphContext } from "../../util"; import { getPendingOrgInvitationsFromSubgraph } from "./shared"; +import type { ResolverFn } from "../../../api-types.gen"; +import type { LoggedInGraphQLContext } from "../../../context"; +import type { MutationDeclineOrgInvitationArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; + /** * This resolver is used specifically to get an invitation to an organization issued to a user not yet signed up for HASH. * They will be emailed a link to sign up, which includes the entityId, and we need to retrieve it to show the invitation details on the signup page. diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/get-my-pending-invitations.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/get-my-pending-invitations.ts index 4ae87b7ca81..924df43e90c 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/get-my-pending-invitations.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/get-my-pending-invitations.ts @@ -1,9 +1,9 @@ -import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; - import { getUserPendingInvitations } from "../../../../graph/knowledge/system-types/user"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; export const getMyPendingInvitationsResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/get-pending-invitation-by-entity-id.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/get-pending-invitation-by-entity-id.ts index efa0fd338b1..f2e3dfe743d 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/get-pending-invitation-by-entity-id.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/get-pending-invitation-by-entity-id.ts @@ -1,14 +1,14 @@ -import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; - import { getLatestEntityRootedSubgraph } from "../../../../graph/knowledge/primitive/entity"; import { systemAccountId } from "../../../../graph/system-account"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { getPendingOrgInvitationsFromSubgraph } from "./shared"; + import type { QueryGetPendingInvitationByEntityIdArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; -import { getPendingOrgInvitationsFromSubgraph } from "./shared"; +import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; /** * This resolver is used specifically to get an invitation to an organization issued to a user not yet signed up for HASH. diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/invite-user-to-org.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/invite-user-to-org.ts index 1d6713a936d..14ded700bc1 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/invite-user-to-org.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/invite-user-to-org.ts @@ -1,3 +1,6 @@ +import dedent from "dedent"; +import sanitizeHtml from "sanitize-html"; + import { type EntityId, entityIdFromComponents, @@ -13,7 +16,6 @@ import { currentTimeInstantTemporalAxes, generateVersionedUrlMatchingFilter, } from "@local/hash-isomorphic-utils/graph-queries"; -import type { MutationInviteUserToOrgArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; import { blockProtocolDataTypes, systemDataTypes, @@ -21,15 +23,7 @@ import { systemLinkEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - HasIssuedInvitation, - InvitationViaEmail, - InvitationViaShortname, -} from "@local/hash-isomorphic-utils/system-types/shared"; -import dedent from "dedent"; -import sanitizeHtml from "sanitize-html"; -import type { EmailTransporter } from "../../../../email/transporters"; import { createEntity } from "../../../../graph/knowledge/primitive/entity"; import { createLinkEntity } from "../../../../graph/knowledge/primitive/link-entity"; import { @@ -41,12 +35,20 @@ import { isUserMemberOfOrg, type User, } from "../../../../graph/knowledge/system-types/user"; -import type { ResolverFn } from "../../../api-types.gen"; -import type { LoggedInGraphQLContext } from "../../../context"; import * as Error from "../../../error"; import { graphQLContextToImpureGraphContext } from "../../util"; import { getPendingOrgInvitationsFromSubgraph } from "./shared"; +import type { EmailTransporter } from "../../../../email/transporters"; +import type { ResolverFn } from "../../../api-types.gen"; +import type { LoggedInGraphQLContext } from "../../../context"; +import type { MutationInviteUserToOrgArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; +import type { + HasIssuedInvitation, + InvitationViaEmail, + InvitationViaShortname, +} from "@local/hash-isomorphic-utils/system-types/shared"; + const invitationDurationInDays = 30; const sendOrgEmailInvitationToEmailAddress = async (params: { diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/remove-user-from-org.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/remove-user-from-org.ts index 16ee4544b7a..b0b188289f1 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/remove-user-from-org.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/remove-user-from-org.ts @@ -6,16 +6,17 @@ import { import { queryEntities } from "@local/hash-graph-sdk/entity"; import { removeActorGroupMember } from "@local/hash-graph-sdk/principal/actor-group"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; -import type { MutationRemoveUserFromOrgArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; import { systemLinkEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { getOrgById } from "../../../../graph/knowledge/system-types/org"; import { getUser } from "../../../../graph/knowledge/system-types/user"; -import type { ResolverFn } from "../../../api-types.gen"; -import type { LoggedInGraphQLContext } from "../../../context"; import * as Error from "../../../error"; import { graphQLContextToImpureGraphContext } from "../../util"; +import type { ResolverFn } from "../../../api-types.gen"; +import type { LoggedInGraphQLContext } from "../../../context"; +import type { MutationRemoveUserFromOrgArgs } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; + export const removeUserFromOrgResolver: ResolverFn< Promise, Record, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/org/shared.ts b/apps/hash-api/src/graphql/resolvers/knowledge/org/shared.ts index e985ea38709..e56150675e7 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/org/shared.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/org/shared.ts @@ -1,8 +1,3 @@ -import type { - EntityRootType, - LinkEntityAndLeftEntity, - Subgraph, -} from "@blockprotocol/graph"; import { getIncomingLinkAndSourceEntities, getRoots, @@ -13,9 +8,6 @@ import { extractWebIdFromEntityId, type WebId, } from "@blockprotocol/type-system"; -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; -import type { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; -import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; import { systemEntityTypes, systemLinkEntityTypes, @@ -24,14 +16,23 @@ import { isInvitationByEmail, isInvitationByShortname, } from "@local/hash-isomorphic-utils/organization"; -import type { Organization } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { ImpureGraphContext } from "../../../../graph/context-types"; import { getUser, type User, } from "../../../../graph/knowledge/system-types/user"; +import type { ImpureGraphContext } from "../../../../graph/context-types"; +import type { + EntityRootType, + LinkEntityAndLeftEntity, + Subgraph, +} from "@blockprotocol/graph"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; +import type { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; +import type { PendingOrgInvitation } from "@local/hash-isomorphic-utils/graphql/api-types.gen"; +import type { Organization } from "@local/hash-isomorphic-utils/system-types/shared"; + const isOrgEntity = (entity: HashEntity): entity is HashEntity => entity.metadata.entityTypeIds.includes( systemEntityTypes.organization.entityTypeId, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/page/page-contents.ts b/apps/hash-api/src/graphql/resolvers/knowledge/page/page-contents.ts index 75c0b69f06e..90aa5ced459 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/page/page-contents.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/page/page-contents.ts @@ -1,14 +1,15 @@ -import type { Entity } from "@blockprotocol/type-system"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { HasSpatiallyPositionedContent } from "@local/hash-isomorphic-utils/system-types/canvas"; -import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; import { getPageBlocks } from "../../../../graph/knowledge/system-types/page"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapBlockToGQL } from "../graphql-mapping"; + import type { ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedBlockGQL, UnresolvedPageGQL } from "../graphql-mapping"; -import { mapBlockToGQL } from "../graphql-mapping"; +import type { Entity } from "@blockprotocol/type-system"; +import type { HasSpatiallyPositionedContent } from "@local/hash-isomorphic-utils/system-types/canvas"; +import type { HasIndexedContent } from "@local/hash-isomorphic-utils/system-types/shared"; export const pageContents: ResolverFn< { diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/page/page.ts b/apps/hash-api/src/graphql/resolvers/knowledge/page/page.ts index fb0fd9f7ef5..72edf663c78 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/page/page.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/page/page.ts @@ -2,18 +2,19 @@ import { createPage, getPageComments, } from "../../../../graph/knowledge/system-types/page"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapCommentToGQL, mapPageToGQL } from "../graphql-mapping"; + import type { MutationCreatePageArgs, QueryPageCommentsArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedCommentGQL, UnresolvedPageGQL, } from "../graphql-mapping"; -import { mapCommentToGQL, mapPageToGQL } from "../graphql-mapping"; export const createPageResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/page/set-parent-page.ts b/apps/hash-api/src/graphql/resolvers/knowledge/page/set-parent-page.ts index 329db44d3e2..44fcc10bdf5 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/page/set-parent-page.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/page/set-parent-page.ts @@ -2,15 +2,16 @@ import { getPageById, setPageParentPage, } from "../../../../graph/knowledge/system-types/page"; +import * as Error from "../../../error"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapPageToGQL } from "../graphql-mapping"; + import type { MutationSetParentPageArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import * as Error from "../../../error"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedPageGQL } from "../graphql-mapping"; -import { mapPageToGQL } from "../graphql-mapping"; export const setParentPageResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/page/update-page.ts b/apps/hash-api/src/graphql/resolvers/knowledge/page/update-page.ts index f8907902282..7a3118f12fe 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/page/update-page.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/page/update-page.ts @@ -6,14 +6,15 @@ import { getPageById, getPageFromEntity, } from "../../../../graph/knowledge/system-types/page"; +import { graphQLContextToImpureGraphContext } from "../../util"; +import { mapPageToGQL } from "../graphql-mapping"; + import type { MutationUpdatePageArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; import type { UnresolvedPageGQL } from "../graphql-mapping"; -import { mapPageToGQL } from "../graphql-mapping"; export const updatePageResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/shared/check-permissions.ts b/apps/hash-api/src/graphql/resolvers/knowledge/shared/check-permissions.ts index fa418b2aae6..3b30feab37b 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/shared/check-permissions.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/shared/check-permissions.ts @@ -1,13 +1,13 @@ -import type { Entity } from "@blockprotocol/type-system"; -import type { UserPermissions } from "@local/hash-graph-sdk/authorization"; - import { checkEntityPermission, checkPermissionsOnEntity, } from "../../../../graph/knowledge/primitive/entity"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { ResolverFn } from "../../../api-types.gen"; import type { GraphQLContext, LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { Entity } from "@blockprotocol/type-system"; +import type { UserPermissions } from "@local/hash-graph-sdk/authorization"; export const checkUserPermissionsOnEntity: ResolverFn< UserPermissions, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/shared/get-user-permissions-on-subgraph.ts b/apps/hash-api/src/graphql/resolvers/knowledge/shared/get-user-permissions-on-subgraph.ts index 4e593f832b0..883f9093300 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/shared/get-user-permissions-on-subgraph.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/shared/get-user-permissions-on-subgraph.ts @@ -1,13 +1,14 @@ -import type { Subgraph } from "@blockprotocol/graph"; -import type { UserPermissionsOnEntities } from "@local/hash-graph-sdk/authorization"; -import type { GraphQLResolveInfo } from "graphql"; -import type { ResolveTree } from "graphql-parse-resolve-info"; import { parseResolveInfo } from "graphql-parse-resolve-info"; import { checkPermissionsOnEntitiesInSubgraph } from "../../../../graph/knowledge/primitive/entity"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { SubgraphAndPermissions } from "../../../api-types.gen"; import type { GraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { Subgraph } from "@blockprotocol/graph"; +import type { UserPermissionsOnEntities } from "@local/hash-graph-sdk/authorization"; +import type { GraphQLResolveInfo } from "graphql"; +import type { ResolveTree } from "graphql-parse-resolve-info"; const werePermissionsRequested = (info: GraphQLResolveInfo) => { const parsedResolveInfoFragment = parseResolveInfo(info); diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/user/get-usage-records.ts b/apps/hash-api/src/graphql/resolvers/knowledge/user/get-usage-records.ts index 2285f4bcff7..3756d93b3d1 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/user/get-usage-records.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/user/get-usage-records.ts @@ -11,7 +11,9 @@ import { } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; + +import * as Error from "../../../error"; +import { graphQLContextToImpureGraphContext } from "../../util"; import type { Query, @@ -19,8 +21,7 @@ import type { UserUsageRecords, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import * as Error from "../../../error"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { UserProperties } from "@local/hash-isomorphic-utils/system-types/user"; export const getUsageRecordsResolver: ResolverFn< Query["getUsageRecords"], diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/user/get-waitlist-position.ts b/apps/hash-api/src/graphql/resolvers/knowledge/user/get-waitlist-position.ts index e90d31c13e8..391c42e9833 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/user/get-waitlist-position.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/user/get-waitlist-position.ts @@ -1,9 +1,9 @@ import { internalApiClient } from "@local/hash-backend-utils/internal-api-client"; import { isSelfHostedInstance } from "@local/hash-isomorphic-utils/instance"; -import type { GetWaitlistPosition200Response } from "@local/internal-api-client"; import type { Query, ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; +import type { GetWaitlistPosition200Response } from "@local/internal-api-client"; export const getWaitlistPositionResolver: ResolverFn< Query["getWaitlistPosition"], diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/user/has-access-to-hash.ts b/apps/hash-api/src/graphql/resolvers/knowledge/user/has-access-to-hash.ts index d985b39e453..b9f388b6d40 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/user/has-access-to-hash.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/user/has-access-to-hash.ts @@ -1,7 +1,8 @@ import { userHasAccessToHash } from "../../../../shared/user-has-access-to-hash"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { Query, ResolverFn } from "../../../api-types.gen"; import type { GraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; export const hasAccessToHashResolver: ResolverFn< Query["hasAccessToHash"], diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/user/is-shortname-taken.ts b/apps/hash-api/src/graphql/resolvers/knowledge/user/is-shortname-taken.ts index dc6d9a90863..7cf531cc8ec 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/user/is-shortname-taken.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/user/is-shortname-taken.ts @@ -2,12 +2,13 @@ import { shortnameIsRestricted, shortnameIsTaken, } from "../../../../graph/knowledge/system-types/account.fields"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { QueryIsShortnameTakenArgs, ResolverFn, } from "../../../api-types.gen"; import type { GraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; export const isShortnameTakenResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/user/me.ts b/apps/hash-api/src/graphql/resolvers/knowledge/user/me.ts index 7e4bf2d6271..13d4bbedf04 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/user/me.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/user/me.ts @@ -5,9 +5,10 @@ import { } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { Query, ResolverFn } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; export const meResolver: ResolverFn< Query["me"], diff --git a/apps/hash-api/src/graphql/resolvers/knowledge/user/submit-early-access-form.ts b/apps/hash-api/src/graphql/resolvers/knowledge/user/submit-early-access-form.ts index 6c5ad1145c5..872bf36c243 100644 --- a/apps/hash-api/src/graphql/resolvers/knowledge/user/submit-early-access-form.ts +++ b/apps/hash-api/src/graphql/resolvers/knowledge/user/submit-early-access-form.ts @@ -1,16 +1,17 @@ -import type { WebId } from "@blockprotocol/type-system"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { ProspectiveUser } from "@local/hash-isomorphic-utils/system-types/prospectiveuser"; import { createEntity } from "../../../../graph/knowledge/primitive/entity"; import { systemAccountId } from "../../../../graph/system-account"; +import { graphQLContextToImpureGraphContext } from "../../util"; + import type { MutationSubmitEarlyAccessFormArgs, ResolverFn, } from "../../../api-types.gen"; import type { LoggedInGraphQLContext } from "../../../context"; -import { graphQLContextToImpureGraphContext } from "../../util"; +import type { WebId } from "@blockprotocol/type-system"; +import type { ProspectiveUser } from "@local/hash-isomorphic-utils/system-types/prospectiveuser"; export const submitEarlyAccessFormResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/middlewares/logged-in-and-signed-up.ts b/apps/hash-api/src/graphql/resolvers/middlewares/logged-in-and-signed-up.ts index 88609a464bf..693466fc4d4 100644 --- a/apps/hash-api/src/graphql/resolvers/middlewares/logged-in-and-signed-up.ts +++ b/apps/hash-api/src/graphql/resolvers/middlewares/logged-in-and-signed-up.ts @@ -1,8 +1,9 @@ -import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; import { loggedInMiddleware } from "./logged-in"; -import type { ResolverMiddleware } from "./middleware-types"; import { signedUpMiddleware } from "./signed-up"; +import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; +import type { ResolverMiddleware } from "./middleware-types"; + export const loggedInAndSignedUpMiddleware: ResolverMiddleware< GraphQLContext, Record, diff --git a/apps/hash-api/src/graphql/resolvers/middlewares/logged-in.ts b/apps/hash-api/src/graphql/resolvers/middlewares/logged-in.ts index 87e4d6ea61b..36c4eb840dc 100644 --- a/apps/hash-api/src/graphql/resolvers/middlewares/logged-in.ts +++ b/apps/hash-api/src/graphql/resolvers/middlewares/logged-in.ts @@ -1,5 +1,6 @@ -import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; import * as Error from "../../error"; + +import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; import type { ResolverMiddleware } from "./middleware-types"; export const loggedInMiddleware: ResolverMiddleware< diff --git a/apps/hash-api/src/graphql/resolvers/middlewares/signed-up.ts b/apps/hash-api/src/graphql/resolvers/middlewares/signed-up.ts index f352c496e07..84e634d1ebb 100644 --- a/apps/hash-api/src/graphql/resolvers/middlewares/signed-up.ts +++ b/apps/hash-api/src/graphql/resolvers/middlewares/signed-up.ts @@ -1,5 +1,6 @@ -import type { LoggedInGraphQLContext } from "../../context"; import * as Error from "../../error"; + +import type { LoggedInGraphQLContext } from "../../context"; import type { ResolverMiddleware } from "./middleware-types"; export const signedUpMiddleware: ResolverMiddleware< diff --git a/apps/hash-api/src/graphql/resolvers/ontology/data-type.ts b/apps/hash-api/src/graphql/resolvers/ontology/data-type.ts index 853d650df34..edd876c553a 100644 --- a/apps/hash-api/src/graphql/resolvers/ontology/data-type.ts +++ b/apps/hash-api/src/graphql/resolvers/ontology/data-type.ts @@ -1,19 +1,9 @@ -import type { - DataTypeWithMetadata, - OntologyTemporalMetadata, -} from "@blockprotocol/type-system"; -import type { UserPermissionsOnDataType } from "@local/hash-graph-sdk/authorization"; -import type { - QueryDataTypesResponse, - SerializedQueryDataTypeSubgraphResponse, -} from "@local/hash-graph-sdk/data-type"; import { findDataTypeConversionTargets, queryDataTypes, queryDataTypeSubgraph, serializeQueryDataTypeSubgraphResponse, } from "@local/hash-graph-sdk/data-type"; -import type { DataTypeFullConversionTargetsMap } from "@local/hash-graph-sdk/ontology"; import { archiveDataType, @@ -22,6 +12,8 @@ import { unarchiveDataType, updateDataType, } from "../../../graph/ontology/primitive/data-type"; +import { graphQLContextToImpureGraphContext } from "../util"; + import type { MutationArchiveDataTypeArgs, MutationCreateDataTypeArgs, @@ -34,7 +26,16 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; -import { graphQLContextToImpureGraphContext } from "../util"; +import type { + DataTypeWithMetadata, + OntologyTemporalMetadata, +} from "@blockprotocol/type-system"; +import type { UserPermissionsOnDataType } from "@local/hash-graph-sdk/authorization"; +import type { + QueryDataTypesResponse, + SerializedQueryDataTypeSubgraphResponse, +} from "@local/hash-graph-sdk/data-type"; +import type { DataTypeFullConversionTargetsMap } from "@local/hash-graph-sdk/ontology"; export const queryDataTypesResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/ontology/entity-type.ts b/apps/hash-api/src/graphql/resolvers/ontology/entity-type.ts index b0e345818ad..4c3baf987fa 100644 --- a/apps/hash-api/src/graphql/resolvers/ontology/entity-type.ts +++ b/apps/hash-api/src/graphql/resolvers/ontology/entity-type.ts @@ -1,14 +1,3 @@ -import type { - EntityTypeWithMetadata, - OntologyTemporalMetadata, - WebId, -} from "@blockprotocol/type-system"; -import type { UserPermissionsOnEntityType } from "@local/hash-graph-sdk/authorization"; -import type { - GetClosedMultiEntityTypesResponse, - QueryEntityTypesResponse, - SerializedQueryEntityTypeSubgraphResponse, -} from "@local/hash-graph-sdk/entity-type"; import { getClosedMultiEntityTypes, queryEntityTypes, @@ -24,6 +13,8 @@ import { updateEntityType, updateEntityTypes, } from "../../../graph/ontology/primitive/entity-type"; +import { graphQLContextToImpureGraphContext } from "../util"; + import type { MutationArchiveEntityTypeArgs, MutationCreateEntityTypeArgs, @@ -37,7 +28,17 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; -import { graphQLContextToImpureGraphContext } from "../util"; +import type { + EntityTypeWithMetadata, + OntologyTemporalMetadata, + WebId, +} from "@blockprotocol/type-system"; +import type { UserPermissionsOnEntityType } from "@local/hash-graph-sdk/authorization"; +import type { + GetClosedMultiEntityTypesResponse, + QueryEntityTypesResponse, + SerializedQueryEntityTypeSubgraphResponse, +} from "@local/hash-graph-sdk/entity-type"; export const createEntityTypeResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/graphql/resolvers/ontology/property-type.ts b/apps/hash-api/src/graphql/resolvers/ontology/property-type.ts index 76d2fd48187..0f52e150014 100644 --- a/apps/hash-api/src/graphql/resolvers/ontology/property-type.ts +++ b/apps/hash-api/src/graphql/resolvers/ontology/property-type.ts @@ -1,8 +1,3 @@ -import type { - OntologyTemporalMetadata, - PropertyTypeWithMetadata, - WebId, -} from "@blockprotocol/type-system"; import { queryPropertyTypes, type QueryPropertyTypesResponse, @@ -17,6 +12,8 @@ import { unarchivePropertyType, updatePropertyType, } from "../../../graph/ontology/primitive/property-type"; +import { graphQLContextToImpureGraphContext } from "../util"; + import type { MutationArchivePropertyTypeArgs, MutationCreatePropertyTypeArgs, @@ -27,7 +24,11 @@ import type { ResolverFn, } from "../../api-types.gen"; import type { GraphQLContext, LoggedInGraphQLContext } from "../../context"; -import { graphQLContextToImpureGraphContext } from "../util"; +import type { + OntologyTemporalMetadata, + PropertyTypeWithMetadata, + WebId, +} from "@blockprotocol/type-system"; export const createPropertyTypeResolver: ResolverFn< Promise, diff --git a/apps/hash-api/src/index.ts b/apps/hash-api/src/index.ts index 0f9f29e84b2..573cb5bbbb5 100644 --- a/apps/hash-api/src/index.ts +++ b/apps/hash-api/src/index.ts @@ -1,8 +1,26 @@ import http from "node:http"; import { promisify } from "node:util"; -import type { ProvidedEntityEditionProvenance } from "@blockprotocol/type-system"; import KeyvRedis from "@keyv/redis"; +import * as Sentry from "@sentry/node"; +import bodyParser from "body-parser"; +import cors from "cors"; +import { Effect, Exit, Layer, Logger, LogLevel, ManagedRuntime } from "effect"; +import { RuntimeException } from "effect/Cause"; +import express, { raw } from "express"; +import { create as handlebarsCreate } from "express-handlebars"; +import { ipKeyGenerator, rateLimit } from "express-rate-limit"; +import helmet from "helmet"; +import { StatsD } from "hot-shots"; +import { + createProxyMiddleware, + fixRequestBody, + responseInterceptor, +} from "http-proxy-middleware"; +import httpTerminator from "http-terminator"; +import Keyv from "keyv"; +import { customAlphabet } from "nanoid"; + import { JsonDecoder, JsonEncoder } from "@local/harpc-client/codec"; import { Client as RpcClient, Transport } from "@local/harpc-client/net"; import { RequestIdProducer } from "@local/harpc-client/wire-protocol"; @@ -23,26 +41,6 @@ import { hashClientHeaderKey, } from "@local/hash-isomorphic-utils/http-requests"; import { isSelfHostedInstance } from "@local/hash-isomorphic-utils/instance"; -import * as Sentry from "@sentry/node"; -import bodyParser from "body-parser"; -import cors from "cors"; -import { Effect, Exit, Layer, Logger, LogLevel, ManagedRuntime } from "effect"; -import { RuntimeException } from "effect/Cause"; -import type { ErrorRequestHandler, Request, Response } from "express"; -import express, { raw } from "express"; -import { create as handlebarsCreate } from "express-handlebars"; -import type { Options as RateLimitOptions } from "express-rate-limit"; -import { ipKeyGenerator, rateLimit } from "express-rate-limit"; -import helmet from "helmet"; -import { StatsD } from "hot-shots"; -import { - createProxyMiddleware, - fixRequestBody, - responseInterceptor, -} from "http-proxy-middleware"; -import httpTerminator from "http-terminator"; -import Keyv from "keyv"; -import { customAlphabet } from "nanoid"; import { gptGetUserWebs } from "./ai/gpt/gpt-get-user-webs"; import { gptQueryEntities } from "./ai/gpt/gpt-query-entities"; @@ -95,6 +93,10 @@ import { } from "./storage"; import { setupTelemetry } from "./telemetry/snowplow-setup"; +import type { ProvidedEntityEditionProvenance } from "@blockprotocol/type-system"; +import type { ErrorRequestHandler, Request, Response } from "express"; +import type { Options as RateLimitOptions } from "express-rate-limit"; + const app = express(); const httpServer = http.createServer(app); diff --git a/apps/hash-api/src/instrument.mjs b/apps/hash-api/src/instrument.mjs index 9aff48c593b..9f48bdef97d 100644 --- a/apps/hash-api/src/instrument.mjs +++ b/apps/hash-api/src/instrument.mjs @@ -1,11 +1,5 @@ /** Required to load environment variables */ import "@local/hash-backend-utils/environment"; - -import { - createHttpInstrumentation, - createUndiciInstrumentation, - registerOpenTelemetry, -} from "@local/hash-backend-utils/opentelemetry"; import { ExpressInstrumentation, ExpressLayerType, @@ -13,6 +7,12 @@ import { import { GraphQLInstrumentation } from "@opentelemetry/instrumentation-graphql"; import * as Sentry from "@sentry/node"; +import { + createHttpInstrumentation, + createUndiciInstrumentation, + registerOpenTelemetry, +} from "@local/hash-backend-utils/opentelemetry"; + import { isProdEnv } from "./lib/env-config"; /** diff --git a/apps/hash-api/src/integrations/google/check-access-token.ts b/apps/hash-api/src/integrations/google/check-access-token.ts index 6ab26f66b6d..46c6e8c443e 100644 --- a/apps/hash-api/src/integrations/google/check-access-token.ts +++ b/apps/hash-api/src/integrations/google/check-access-token.ts @@ -1,11 +1,11 @@ +import { getGoogleAccessTokenForExpressRequest } from "./shared/get-or-check-access-token"; + import type { CheckGoogleTokenRequest, CheckGoogleTokenResponse, } from "@local/hash-isomorphic-utils/google-integration"; import type { RequestHandler } from "express"; -import { getGoogleAccessTokenForExpressRequest } from "./shared/get-or-check-access-token"; - /** * Check if a valid access token is present for the requested Google Account. * If the access token itself is required, use the route controlled by getGoogleAccessToken instead. diff --git a/apps/hash-api/src/integrations/google/get-access-token.ts b/apps/hash-api/src/integrations/google/get-access-token.ts index d74a306991e..14c903ebe5b 100644 --- a/apps/hash-api/src/integrations/google/get-access-token.ts +++ b/apps/hash-api/src/integrations/google/get-access-token.ts @@ -1,10 +1,10 @@ +import { getGoogleAccessTokenForExpressRequest } from "./shared/get-or-check-access-token"; + import type { GetGoogleTokenRequest, GetGoogleTokenResponse, } from "@local/hash-isomorphic-utils/google-integration"; import type { RequestHandler } from "express"; - -import { getGoogleAccessTokenForExpressRequest } from "./shared/get-or-check-access-token"; /** * Get an access token for use in the client where unavoidable, e.g. to use the Google File Picker. * Access tokens last for 1 hour. diff --git a/apps/hash-api/src/integrations/google/oauth-callback.ts b/apps/hash-api/src/integrations/google/oauth-callback.ts index e6f59a0f0a7..9310243169d 100644 --- a/apps/hash-api/src/integrations/google/oauth-callback.ts +++ b/apps/hash-api/src/integrations/google/oauth-callback.ts @@ -1,22 +1,24 @@ -import type { WebId } from "@blockprotocol/type-system"; +import { google } from "googleapis"; + import { NotFoundError } from "@local/hash-backend-utils/error"; import { createGoogleOAuth2Client, getGoogleAccountById, } from "@local/hash-backend-utils/google"; import { getMachineIdByIdentifier } from "@local/hash-backend-utils/machine-actors"; +import { googleEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; + +import { createEntity } from "../../graph/knowledge/primitive/entity"; +import { createUserSecret } from "../../graph/knowledge/system-types/user-secret"; +import { enabledIntegrations } from "../enabled-integrations"; + +import type { WebId } from "@blockprotocol/type-system"; import type { GoogleOAuth2CallbackRequest, GoogleOAuth2CallbackResponse, } from "@local/hash-isomorphic-utils/google-integration"; -import { googleEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import type { Account as GoogleAccount } from "@local/hash-isomorphic-utils/system-types/google/account"; import type { RequestHandler } from "express"; -import { google } from "googleapis"; - -import { createEntity } from "../../graph/knowledge/primitive/entity"; -import { createUserSecret } from "../../graph/knowledge/system-types/user-secret"; -import { enabledIntegrations } from "../enabled-integrations"; export const googleOAuthCallback: RequestHandler< Record, diff --git a/apps/hash-api/src/integrations/google/shared/get-or-check-access-token.ts b/apps/hash-api/src/integrations/google/shared/get-or-check-access-token.ts index cf7d70045a9..2cdf804eb00 100644 --- a/apps/hash-api/src/integrations/google/shared/get-or-check-access-token.ts +++ b/apps/hash-api/src/integrations/google/shared/get-or-check-access-token.ts @@ -3,10 +3,11 @@ import { getGoogleAccountById, getTokensForGoogleAccount, } from "@local/hash-backend-utils/google"; -import type { Request, Response } from "express"; import { enabledIntegrations } from "../../enabled-integrations"; +import type { Request, Response } from "express"; + /** * Shared function to retrieve a Google access token for an Express request, * providing standard error handling and response handling. diff --git a/apps/hash-api/src/integrations/linear.ts b/apps/hash-api/src/integrations/linear.ts index 974c6a9e234..0d503a0bbab 100644 --- a/apps/hash-api/src/integrations/linear.ts +++ b/apps/hash-api/src/integrations/linear.ts @@ -1,9 +1,11 @@ +import { LinearClient } from "@linear/sdk"; + +import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; + import type { MachineId, WebId } from "@blockprotocol/type-system"; import type { Organization, Team } from "@linear/sdk"; -import { LinearClient } from "@linear/sdk"; import type { TemporalClient } from "@local/hash-backend-utils/temporal"; import type { SyncWebWorkflow } from "@local/hash-backend-utils/temporal-integration-workflow-types"; -import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; export const listTeams = async (params: { apiKey: string; diff --git a/apps/hash-api/src/integrations/linear/oauth.ts b/apps/hash-api/src/integrations/linear/oauth.ts index 451702917ce..084fbe86f57 100644 --- a/apps/hash-api/src/integrations/linear/oauth.ts +++ b/apps/hash-api/src/integrations/linear/oauth.ts @@ -1,14 +1,8 @@ import crypto from "node:crypto"; -import type { - Entity, - EntityId, - EntityUuid, - UserId, - WebId, -} from "@blockprotocol/type-system"; -import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; import { LinearClient } from "@linear/sdk"; + +import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; import { getMachineIdByIdentifier } from "@local/hash-backend-utils/machine-actors"; import { apiOrigin, @@ -16,11 +10,8 @@ import { } from "@local/hash-isomorphic-utils/environment"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { LinearIntegrationPropertiesWithMetadata } from "@local/hash-isomorphic-utils/system-types/linearintegration"; -import type { RequestHandler } from "express"; import { createEntity } from "../../graph/knowledge/primitive/entity"; -import type { LinearIntegration } from "../../graph/knowledge/system-types/linear-integration-entity"; import { getLinearIntegrationByLinearOrgId, getLinearIntegrationFromEntity, @@ -28,6 +19,17 @@ import { import { isUserMemberOfOrg } from "../../graph/knowledge/system-types/user"; import { createUserSecret } from "../../graph/knowledge/system-types/user-secret"; +import type { LinearIntegration } from "../../graph/knowledge/system-types/linear-integration-entity"; +import type { + Entity, + EntityId, + EntityUuid, + UserId, + WebId, +} from "@blockprotocol/type-system"; +import type { LinearIntegrationPropertiesWithMetadata } from "@local/hash-isomorphic-utils/system-types/linearintegration"; +import type { RequestHandler } from "express"; + const linearClientId = process.env.LINEAR_CLIENT_ID; const linearClientSecret = process.env.LINEAR_CLIENT_SECRET; diff --git a/apps/hash-api/src/integrations/linear/sync-back.ts b/apps/hash-api/src/integrations/linear/sync-back.ts index 742726f6fd9..083d36b0f8f 100644 --- a/apps/hash-api/src/integrations/linear/sync-back.ts +++ b/apps/hash-api/src/integrations/linear/sync-back.ts @@ -1,4 +1,3 @@ -import type { EntityUuid, VersionedUrl } from "@blockprotocol/type-system"; import { entityIdFromComponents, extractWebIdFromEntityId, @@ -6,18 +5,20 @@ import { import { linearTypeMappings } from "@local/hash-backend-utils/linear-type-mappings"; import { getMachineIdByIdentifier } from "@local/hash-backend-utils/machine-actors"; import { createTemporalClient } from "@local/hash-backend-utils/temporal"; -import type { UpdateLinearDataWorkflow } from "@local/hash-backend-utils/temporal-integration-workflow-types"; import { type VaultClient } from "@local/hash-backend-utils/vault"; -import type { GraphApi } from "@local/hash-graph-client"; import { type HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; import { linearPropertyTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ImpureGraphContext } from "../../graph/context-types"; import { getLatestEntityById } from "../../graph/knowledge/primitive/entity"; import { getLinearSecretValueByHashWebEntityId } from "../../graph/knowledge/system-types/linear-user-secret"; import { systemAccountId } from "../../graph/system-account"; +import type { ImpureGraphContext } from "../../graph/context-types"; +import type { EntityUuid, VersionedUrl } from "@blockprotocol/type-system"; +import type { UpdateLinearDataWorkflow } from "@local/hash-backend-utils/temporal-integration-workflow-types"; +import type { GraphApi } from "@local/hash-graph-client"; + const supportedLinearEntityTypeIds = linearTypeMappings.map( ({ hashEntityTypeId }) => hashEntityTypeId as VersionedUrl, ); diff --git a/apps/hash-api/src/integrations/linear/webhook.ts b/apps/hash-api/src/integrations/linear/webhook.ts index c5b39974f73..c4482cc0ecb 100644 --- a/apps/hash-api/src/integrations/linear/webhook.ts +++ b/apps/hash-api/src/integrations/linear/webhook.ts @@ -1,17 +1,13 @@ import crypto from "node:crypto"; -import type { WebId } from "@blockprotocol/type-system"; import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; import { tupleIncludes } from "@local/advanced-types/includes"; import { timingSafeCompare } from "@local/hash-backend-utils/crypto"; import { getMachineIdByIdentifier } from "@local/hash-backend-utils/machine-actors"; import { createTemporalClient } from "@local/hash-backend-utils/temporal"; -import type { WorkflowTypeMap } from "@local/hash-backend-utils/temporal-integration-workflow-types"; import { supportedLinearTypes } from "@local/hash-backend-utils/temporal-integration-workflow-types"; import { generateUuid } from "@local/hash-isomorphic-utils/generate-uuid"; -import type { RequestHandler } from "express"; -import type { ImpureGraphContext } from "../../graph/context-types"; import { getAllLinearIntegrationsWithLinearOrgId, getSyncedWebsForLinearIntegration, @@ -20,6 +16,11 @@ import { getLinearSecretValueByHashWebEntityId } from "../../graph/knowledge/sys import { systemAccountId } from "../../graph/system-account"; import { logger } from "../../logger"; +import type { ImpureGraphContext } from "../../graph/context-types"; +import type { WebId } from "@blockprotocol/type-system"; +import type { WorkflowTypeMap } from "@local/hash-backend-utils/temporal-integration-workflow-types"; +import type { RequestHandler } from "express"; + type LinearWebhookPayload = { action: "create" | "update" | "delete"; createdAt: string; // ISO timestamp when the action took place. diff --git a/apps/hash-api/src/integrations/sync-back-watcher.ts b/apps/hash-api/src/integrations/sync-back-watcher.ts index 25580bacd75..3e15e8fa813 100644 --- a/apps/hash-api/src/integrations/sync-back-watcher.ts +++ b/apps/hash-api/src/integrations/sync-back-watcher.ts @@ -1,10 +1,6 @@ import { getRequiredEnv } from "@local/hash-backend-utils/environment"; -import type { Logger } from "@local/hash-backend-utils/logger"; import { getMachineIdByIdentifier } from "@local/hash-backend-utils/machine-actors"; import { RedisQueueExclusiveConsumer } from "@local/hash-backend-utils/queue/redis"; -import type { RedisClient } from "@local/hash-backend-utils/redis"; -import type { VaultClient } from "@local/hash-backend-utils/vault"; -import type { GraphApi } from "@local/hash-graph-client"; import { type HashEntity, queryEntities } from "@local/hash-graph-sdk/entity"; import { fullDecisionTimeAxis } from "@local/hash-isomorphic-utils/graph-queries"; @@ -14,6 +10,11 @@ import { supportedLinearTypeIds, } from "./linear/sync-back"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { RedisClient } from "@local/hash-backend-utils/redis"; +import type { VaultClient } from "@local/hash-backend-utils/vault"; +import type { GraphApi } from "@local/hash-graph-client"; + const sendEntityToRelevantProcessor = ({ entity, graphApi, diff --git a/apps/hash-api/src/lib/config.ts b/apps/hash-api/src/lib/config.ts index 3c0a7bc99a2..38b62a55b53 100644 --- a/apps/hash-api/src/lib/config.ts +++ b/apps/hash-api/src/lib/config.ts @@ -1,6 +1,7 @@ -import type { StorageType } from "@local/hash-backend-utils/file-storage"; import { storageTypes } from "@local/hash-backend-utils/file-storage"; import { frontendUrl } from "@local/hash-isomorphic-utils/environment"; + +import type { StorageType } from "@local/hash-backend-utils/file-storage"; import type corsMiddleware from "cors"; export function getEnvStorageType(): StorageType { diff --git a/apps/hash-api/src/seed-data/index.ts b/apps/hash-api/src/seed-data/index.ts index 5b267ec208d..9db3c9fc39f 100644 --- a/apps/hash-api/src/seed-data/index.ts +++ b/apps/hash-api/src/seed-data/index.ts @@ -1,19 +1,20 @@ import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; -import type { Logger } from "@local/hash-backend-utils/logger"; -import type { ImpureGraphContext } from "../graph/context-types"; -import type { Org } from "../graph/knowledge/system-types/org"; import { createOrg, getOrgByShortname, } from "../graph/knowledge/system-types/org"; import { createOrgMembershipLinkEntity } from "../graph/knowledge/system-types/org-membership"; -import type { User } from "../graph/knowledge/system-types/user"; import { joinOrg } from "../graph/knowledge/system-types/user"; -import type { PageDefinition } from "./seed-pages"; import { seedPages } from "./seed-pages"; import { ensureUsersAreSeeded } from "./seed-users"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { Org } from "../graph/knowledge/system-types/org"; +import type { User } from "../graph/knowledge/system-types/user"; +import type { PageDefinition } from "./seed-pages"; +import type { Logger } from "@local/hash-backend-utils/logger"; + // Seed Org with some pages. const seedOrg = async (params: { logger: Logger; diff --git a/apps/hash-api/src/seed-data/seed-flow-test-types.ts b/apps/hash-api/src/seed-data/seed-flow-test-types.ts index c946e536440..9a99b34d22e 100644 --- a/apps/hash-api/src/seed-data/seed-flow-test-types.ts +++ b/apps/hash-api/src/seed-data/seed-flow-test-types.ts @@ -20,11 +20,6 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ImpureGraphFunction } from "../graph/context-types"; -import type { - EntityTypeDefinition, - PropertyTypeDefinition, -} from "../graph/ensure-system-graph-is-initialized/migrate-ontology-types/util"; import { generateSystemEntityTypeSchema, generateSystemPropertyTypeSchema, @@ -38,6 +33,12 @@ import { createEntityType } from "../graph/ontology/primitive/entity-type"; import { createPropertyType } from "../graph/ontology/primitive/property-type"; import { logger } from "../logger"; +import type { ImpureGraphFunction } from "../graph/context-types"; +import type { + EntityTypeDefinition, + PropertyTypeDefinition, +} from "../graph/ensure-system-graph-is-initialized/migrate-ontology-types/util"; + const provenance: ProvidedEntityEditionProvenance = { actorType: "machine", origin: { diff --git a/apps/hash-api/src/seed-data/seed-pages.ts b/apps/hash-api/src/seed-data/seed-pages.ts index 21269f6ff6b..ba75b4d3353 100644 --- a/apps/hash-api/src/seed-data/seed-pages.ts +++ b/apps/hash-api/src/seed-data/seed-pages.ts @@ -1,14 +1,14 @@ -import type { WebId } from "@blockprotocol/type-system"; -import type { Logger } from "@local/hash-backend-utils/logger"; -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; - -import type { ImpureGraphContext } from "../graph/context-types"; -import type { Page } from "../graph/knowledge/system-types/page"; import { createPage, setPageParentPage, } from "../graph/knowledge/system-types/page"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { Page } from "../graph/knowledge/system-types/page"; +import type { WebId } from "@blockprotocol/type-system"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; + export type PageDefinition = { title: string; nestedPages?: PageDefinition[]; diff --git a/apps/hash-api/src/seed-data/seed-users.ts b/apps/hash-api/src/seed-data/seed-users.ts index 96a784734e8..d2f993a5aad 100644 --- a/apps/hash-api/src/seed-data/seed-users.ts +++ b/apps/hash-api/src/seed-data/seed-users.ts @@ -1,15 +1,16 @@ -import type { Logger } from "@local/hash-backend-utils/logger"; -import type { FeatureFlag } from "@local/hash-isomorphic-utils/feature-flags"; import { featureFlags } from "@local/hash-isomorphic-utils/feature-flags"; -import type { AxiosError } from "axios"; import { createKratosIdentity } from "../auth/ory-kratos"; -import type { ImpureGraphContext } from "../graph/context-types"; -import type { User } from "../graph/knowledge/system-types/user"; import { createUser } from "../graph/knowledge/system-types/user"; import { systemAccountId } from "../graph/system-account"; import { isDevEnv, isTestEnv } from "../lib/env-config"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { User } from "../graph/knowledge/system-types/user"; +import type { Logger } from "@local/hash-backend-utils/logger"; +import type { FeatureFlag } from "@local/hash-isomorphic-utils/feature-flags"; +import type { AxiosError } from "axios"; + type SeededUser = { email: string; shortname: string; diff --git a/apps/hash-api/src/shared/user-has-access-to-hash.ts b/apps/hash-api/src/shared/user-has-access-to-hash.ts index 627c812895f..f6dc08544a5 100644 --- a/apps/hash-api/src/shared/user-has-access-to-hash.ts +++ b/apps/hash-api/src/shared/user-has-access-to-hash.ts @@ -1,11 +1,11 @@ -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; - -import type { ImpureGraphContext } from "../graph/context-types"; import { getUserPendingInvitations, type User, } from "../graph/knowledge/system-types/user"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; + const isArrayOfStrings = (value: unknown): value is string[] => { return ( Array.isArray(value) && value.every((item) => typeof item === "string") diff --git a/apps/hash-api/src/storage/index.ts b/apps/hash-api/src/storage/index.ts index 6547613b443..785552b5305 100644 --- a/apps/hash-api/src/storage/index.ts +++ b/apps/hash-api/src/storage/index.ts @@ -1,16 +1,10 @@ -import type { Entity, EntityId } from "@blockprotocol/type-system"; import { isEntityId, splitEntityId } from "@blockprotocol/type-system"; import { getAwsS3Config } from "@local/hash-backend-utils/aws-config"; -import type { - FileStorageProvider, - StorageType, -} from "@local/hash-backend-utils/file-storage"; import { isStorageType, storageProviderLookup, } from "@local/hash-backend-utils/file-storage"; import { AwsS3StorageProvider } from "@local/hash-backend-utils/file-storage/aws-s3-storage-provider"; -import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; import { queryEntities } from "@local/hash-graph-sdk/entity"; import { apiOrigin } from "@local/hash-isomorphic-utils/environment"; import { fullDecisionTimeAxis } from "@local/hash-isomorphic-utils/graph-queries"; @@ -19,16 +13,23 @@ import { systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { File as FileEntity } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { Express } from "express"; -import type Keyv from "keyv"; import { getActorIdFromRequest } from "../auth/get-actor-id"; -import type { ImpureGraphContext } from "../graph/context-types"; import { LOCAL_FILE_UPLOAD_PATH } from "../lib/config"; import { logger } from "../logger"; import { LocalFileSystemStorageProvider } from "./local-file-storage"; +import type { ImpureGraphContext } from "../graph/context-types"; +import type { Entity, EntityId } from "@blockprotocol/type-system"; +import type { + FileStorageProvider, + StorageType, +} from "@local/hash-backend-utils/file-storage"; +import type { AuthenticationContext } from "@local/hash-graph-sdk/authentication-context"; +import type { File as FileEntity } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { Express } from "express"; +import type Keyv from "keyv"; + // S3-like APIs have a upper bound. // 7 days. const DOWNLOAD_URL_EXPIRATION_SECONDS = 60 * 60 * 24 * 7; diff --git a/apps/hash-api/src/storage/local-file-storage.ts b/apps/hash-api/src/storage/local-file-storage.ts index a0751c19fe1..bd21447cdf1 100644 --- a/apps/hash-api/src/storage/local-file-storage.ts +++ b/apps/hash-api/src/storage/local-file-storage.ts @@ -2,6 +2,12 @@ import fs from "node:fs"; import path from "node:path"; import { URL } from "node:url"; +import appRoot from "app-root-path"; +import express from "express"; +import mime from "mime-types"; + +import { getSafeContentType } from "@local/hash-backend-utils/file-storage"; + import type { Url } from "@blockprotocol/type-system"; import type { FileStorageProvider, @@ -12,12 +18,8 @@ import type { PresignedStorageRequest, StorageType, } from "@local/hash-backend-utils/file-storage"; -import { getSafeContentType } from "@local/hash-backend-utils/file-storage"; import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; -import appRoot from "app-root-path"; import type { Express } from "express"; -import express from "express"; -import mime from "mime-types"; export const UPLOAD_BASE_URL = "/local-file-storage-upload"; const DOWNLOAD_BASE_URL = "/uploads"; diff --git a/apps/hash-api/src/telemetry/rudderstack.ts b/apps/hash-api/src/telemetry/rudderstack.ts index 3dd88d42d21..363c788fa8f 100644 --- a/apps/hash-api/src/telemetry/rudderstack.ts +++ b/apps/hash-api/src/telemetry/rudderstack.ts @@ -1,6 +1,7 @@ -import { frontendDomain } from "@local/hash-isomorphic-utils/environment"; import RudderAnalytics from "@rudderstack/rudder-sdk-node"; +import { frontendDomain } from "@local/hash-isomorphic-utils/environment"; + const RUDDERSTACK_KEY = process.env.HASH_API_RUDDERSTACK_KEY || "2SKw8Q5jz5g08LNKpk0Ag82N7HL"; diff --git a/apps/hash-api/src/telemetry/snowplow-setup.ts b/apps/hash-api/src/telemetry/snowplow-setup.ts index f162d182e58..f1777ae1474 100644 --- a/apps/hash-api/src/telemetry/snowplow-setup.ts +++ b/apps/hash-api/src/telemetry/snowplow-setup.ts @@ -1,10 +1,11 @@ -import { getRequiredEnv } from "@local/hash-backend-utils/environment"; import { buildStructEvent, newTracker, type Tracker, } from "@snowplow/node-tracker"; +import { getRequiredEnv } from "@local/hash-backend-utils/environment"; + /** * Sets up snowplow telemetry for HASH usage. Disabled by default. * This tracking function simply sends an event when the platform starts to record usage metrics. diff --git a/apps/hash-api/views/consent.hbs b/apps/hash-api/views/consent.hbs index 03ed3581450..390fcc19f10 100644 --- a/apps/hash-api/views/consent.hbs +++ b/apps/hash-api/views/consent.hbs @@ -1,28 +1,47 @@
-
-

Grant access to HASH

-
- -

{{client.client_name}} wants access to your HASH graph.

+
+

Grant access to HASH

+ + +

{{client.client_name}} + wants access to your HASH graph.

- - + + - - {{#each requested_scope as |scope|}} - - {{/each}} - + + {{#each requested_scope as |scope|}} + + {{/each}} + - - - -
- -
+ + + +
+ + \ No newline at end of file diff --git a/apps/hash-api/views/layouts/main.hbs b/apps/hash-api/views/layouts/main.hbs index c232a9eb719..f94b6cc3947 100644 --- a/apps/hash-api/views/layouts/main.hbs +++ b/apps/hash-api/views/layouts/main.hbs @@ -1,14 +1,16 @@ - - - - + + + HASH - - - + + + -{{{body}}} + {{{body}}} - - + + \ No newline at end of file diff --git a/apps/hash-external-services/docker-compose.prod.yml b/apps/hash-external-services/docker-compose.prod.yml index 718bf008226..21cc89b6d24 100644 --- a/apps/hash-external-services/docker-compose.prod.yml +++ b/apps/hash-external-services/docker-compose.prod.yml @@ -63,7 +63,7 @@ services: HASH_GRAPH_LOG_LEVEL: "${HASH_GRAPH_LOG_LEVEL}" RUST_BACKTRACE: 1 healthcheck: - test: [ "CMD", "/hash-graph", "type-fetcher", "--healthcheck" ] + test: ["CMD", "/hash-graph", "type-fetcher", "--healthcheck"] interval: 2s timeout: 2s retries: 10 @@ -132,7 +132,15 @@ services: HASH_TEMPORAL_SERVER_PORT: "${HASH_TEMPORAL_SERVER_PORT}" RUST_BACKTRACE: 0 healthcheck: - test: [ "CMD", "/hash-graph", "server", "--healthcheck", "--api-port", "${HASH_GRAPH_HTTP_PORT}" ] + test: + [ + "CMD", + "/hash-graph", + "server", + "--healthcheck", + "--api-port", + "${HASH_GRAPH_HTTP_PORT}", + ] interval: 2s timeout: 2s retries: 10 diff --git a/apps/hash-external-services/docker-compose.test.yml b/apps/hash-external-services/docker-compose.test.yml index 9cf4f90595f..55fa2d637e4 100644 --- a/apps/hash-external-services/docker-compose.test.yml +++ b/apps/hash-external-services/docker-compose.test.yml @@ -48,7 +48,11 @@ services: condition: on-failure healthcheck: # Port 14269 is the Jaeger admin endpoint - test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:14269 || exit 1" ] + test: + [ + "CMD-SHELL", + "wget --no-verbose --tries=1 --spider http://localhost:14269 || exit 1", + ] interval: 2s timeout: 2s retries: 10 diff --git a/apps/hash-external-services/grafana/provisioning/datasources/tempo.yml b/apps/hash-external-services/grafana/provisioning/datasources/tempo.yml index a50d80495f1..52973af0a0a 100644 --- a/apps/hash-external-services/grafana/provisioning/datasources/tempo.yml +++ b/apps/hash-external-services/grafana/provisioning/datasources/tempo.yml @@ -9,27 +9,23 @@ datasources: jsonData: httpMethod: GET tracesToLogs: - datasourceUid: 'loki' - tags: ['service.name'] - mappedTags: [ - { key: 'service.name', value: 'service_name' } - ] + datasourceUid: "loki" + tags: ["service.name"] + mappedTags: [{ key: "service.name", value: "service_name" }] mapTagNamesEnabled: true filterByTraceID: true tracesToMetrics: - datasourceUid: 'mimir' - tags: [ - { key: 'service.name', value: 'service' } - ] + datasourceUid: "mimir" + tags: [{ key: "service.name", value: "service" }] queries: - - name: 'Request rate' - query: 'rate(traces_spanmetrics_latency_bucket{$$__tags}[5m])' - - name: 'Request duration' - query: 'histogram_quantile(0.95, rate(traces_spanmetrics_latency_bucket{$$__tags}[5m]))' + - name: "Request rate" + query: "rate(traces_spanmetrics_latency_bucket{$$__tags}[5m])" + - name: "Request duration" + query: "histogram_quantile(0.95, rate(traces_spanmetrics_latency_bucket{$$__tags}[5m]))" lokiSearch: - datasourceUid: 'loki' + datasourceUid: "loki" serviceMap: - datasourceUid: 'mimir' + datasourceUid: "mimir" search: hide: false nodeGraph: diff --git a/apps/hash-external-services/mimir/mimir.yml b/apps/hash-external-services/mimir/mimir.yml index 76f6d20ac89..4de8d03f708 100644 --- a/apps/hash-external-services/mimir/mimir.yml +++ b/apps/hash-external-services/mimir/mimir.yml @@ -40,4 +40,4 @@ ingester: # Basic limits for development limits: - ingestion_rate: 100000 \ No newline at end of file + ingestion_rate: 100000 diff --git a/apps/hash-frontend/codegen.config.ts b/apps/hash-frontend/codegen.config.ts index d845f05db7e..fa4dec83221 100644 --- a/apps/hash-frontend/codegen.config.ts +++ b/apps/hash-frontend/codegen.config.ts @@ -1,6 +1,7 @@ -import type { CodegenConfig } from "@graphql-codegen/cli"; import { baseGraphQlCodegenConfig } from "@local/hash-isomorphic-utils/graphql/base-codegen-config"; +import type { CodegenConfig } from "@graphql-codegen/cli"; + const config: CodegenConfig = { overwrite: true, schema: diff --git a/apps/hash-frontend/src/blocks/on-block-loaded.tsx b/apps/hash-frontend/src/blocks/on-block-loaded.tsx index 149e77080ed..6edf7f5770d 100644 --- a/apps/hash-frontend/src/blocks/on-block-loaded.tsx +++ b/apps/hash-frontend/src/blocks/on-block-loaded.tsx @@ -1,4 +1,3 @@ -import type { FunctionComponent, ReactNode } from "react"; import { createContext, useCallback, @@ -10,6 +9,8 @@ import { import { getBlockDomId } from "../shared/get-block-dom-id"; +import type { FunctionComponent, ReactNode } from "react"; + type OnBlockLoadedFunction = (blockEntityId: string) => void; /** @private enforces use of custom provider */ diff --git a/apps/hash-frontend/src/blocks/use-fetch-block-subgraph.ts b/apps/hash-frontend/src/blocks/use-fetch-block-subgraph.ts index 6b74f9e1223..c8df6f7ef41 100644 --- a/apps/hash-frontend/src/blocks/use-fetch-block-subgraph.ts +++ b/apps/hash-frontend/src/blocks/use-fetch-block-subgraph.ts @@ -1,16 +1,6 @@ import { useLazyQuery } from "@apollo/client"; -import type { - EntityRootType, - KnowledgeGraphVertices, - Subgraph, -} from "@blockprotocol/graph"; -import type { - ActorEntityUuid, - EntityEditionId, - EntityId, - PropertyObject, - VersionedUrl, -} from "@blockprotocol/type-system"; +import { useCallback } from "react"; + import { currentTimestamp, splitEntityId } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse, @@ -21,13 +11,24 @@ import { currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; import { queryEntitySubgraphQuery } from "@local/hash-isomorphic-utils/graphql/queries/entity.queries"; -import { useCallback } from "react"; import type { QueryEntitySubgraphQuery, QueryEntitySubgraphQueryVariables, SubgraphAndPermissions as SubgraphAndPermissionsGQL, } from "../graphql/api-types.gen"; +import type { + EntityRootType, + KnowledgeGraphVertices, + Subgraph, +} from "@blockprotocol/graph"; +import type { + ActorEntityUuid, + EntityEditionId, + EntityId, + PropertyObject, + VersionedUrl, +} from "@blockprotocol/type-system"; type SubgraphAndPermissions = Omit & { subgraph: Subgraph; diff --git a/apps/hash-frontend/src/blocks/user-blocks.tsx b/apps/hash-frontend/src/blocks/user-blocks.tsx index 7f2e4a7d2c3..e00cd9a9b3b 100644 --- a/apps/hash-frontend/src/blocks/user-blocks.tsx +++ b/apps/hash-frontend/src/blocks/user-blocks.tsx @@ -1,12 +1,3 @@ -import type { EntityType } from "@blockprotocol/type-system"; -import type { ComponentIdHashBlockMap } from "@local/hash-isomorphic-utils/blocks"; -import { fetchBlock } from "@local/hash-isomorphic-utils/blocks"; -import type { - Dispatch, - FunctionComponent, - ReactNode, - SetStateAction, -} from "react"; import { createContext, useCallback, @@ -15,9 +6,20 @@ import { useMemo, } from "react"; +import { fetchBlock } from "@local/hash-isomorphic-utils/blocks"; + import { useCachedDefaultState } from "../components/hooks/use-default-state"; import { useGetBlockProtocolBlocks } from "../components/hooks/use-get-block-protocol-blocks"; +import type { EntityType } from "@blockprotocol/type-system"; +import type { ComponentIdHashBlockMap } from "@local/hash-isomorphic-utils/blocks"; +import type { + Dispatch, + FunctionComponent, + ReactNode, + SetStateAction, +} from "react"; + interface UserBlocksContextState { value: ComponentIdHashBlockMap; setValue: Dispatch>; diff --git a/apps/hash-frontend/src/components/block-loader/block-loader.tsx b/apps/hash-frontend/src/components/block-loader/block-loader.tsx index 31450ded447..a785b763946 100644 --- a/apps/hash-frontend/src/components/block-loader/block-loader.tsx +++ b/apps/hash-frontend/src/components/block-loader/block-loader.tsx @@ -1,63 +1,65 @@ -import type { - BlockGraphProperties, - EntityRevisionId, - EntityRootType, - EntityVertex, - GraphEmbedderMessageCallbacks, - Subgraph, -} from "@blockprotocol/graph"; -import type { KnowledgeGraphEditionMap } from "@blockprotocol/graph/types"; -import type { - EntityId, - EntityRecordId, - PropertyObject, - VersionedUrl, -} from "@blockprotocol/type-system"; +import { + useCallback, + useContext, + useEffect, + useLayoutEffect, + useMemo, + useRef, + useState, +} from "react"; + import { extractWebIdFromEntityId, isEntityId, } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { EntityPermissionsMap } from "@local/hash-graph-sdk/entity"; import { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { HashBlockMeta } from "@local/hash-isomorphic-utils/blocks"; -import type { EntityStore } from "@local/hash-isomorphic-utils/entity-store"; import { getDraftEntityByEntityId, textualContentPropertyTypeBaseUrl, } from "@local/hash-isomorphic-utils/entity-store"; -import type { TextualContentPropertyValue } from "@local/hash-isomorphic-utils/system-types/shared"; -import type { FunctionComponent } from "react"; -import { - useCallback, - useContext, - useEffect, - useLayoutEffect, - useMemo, - useRef, - useState, -} from "react"; import { useBlockLoadedContext } from "../../blocks/on-block-loaded"; import { useFetchBlockSubgraph } from "../../blocks/use-fetch-block-subgraph"; import { useBlockContext } from "../../pages/shared/block-collection/block-context"; import { WorkspaceContext } from "../../pages/shared/workspace-context"; -import type { - ArchiveEntityMessageCallback, - CreateEntityMessageCallback, - UpdateEntityMessageCallback, - UploadFileRequestCallback, -} from "../hooks/block-protocol-functions/knowledge/knowledge-shim"; import { useBlockProtocolArchiveEntity } from "../hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity"; import { useBlockProtocolCreateEntity } from "../hooks/block-protocol-functions/knowledge/use-block-protocol-create-entity"; import { useBlockProtocolFileUpload } from "../hooks/block-protocol-functions/knowledge/use-block-protocol-file-upload"; import { useBlockProtocolGetEntity } from "../hooks/block-protocol-functions/knowledge/use-block-protocol-get-entity"; import { useBlockProtocolQueryEntities } from "../hooks/block-protocol-functions/knowledge/use-block-protocol-query-entities"; import { useBlockProtocolUpdateEntity } from "../hooks/block-protocol-functions/knowledge/use-block-protocol-update-entity"; -import type { RemoteBlockProps } from "../remote-block/remote-block"; import { RemoteBlock } from "../remote-block/remote-block"; import { fetchEmbedCode } from "./fetch-embed-code"; +import type { + ArchiveEntityMessageCallback, + CreateEntityMessageCallback, + UpdateEntityMessageCallback, + UploadFileRequestCallback, +} from "../hooks/block-protocol-functions/knowledge/knowledge-shim"; +import type { RemoteBlockProps } from "../remote-block/remote-block"; +import type { + BlockGraphProperties, + EntityRevisionId, + EntityRootType, + EntityVertex, + GraphEmbedderMessageCallbacks, + Subgraph, +} from "@blockprotocol/graph"; +import type { KnowledgeGraphEditionMap } from "@blockprotocol/graph/types"; +import type { + EntityId, + EntityRecordId, + PropertyObject, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { EntityPermissionsMap } from "@local/hash-graph-sdk/entity"; +import type { HashBlockMeta } from "@local/hash-isomorphic-utils/blocks"; +import type { EntityStore } from "@local/hash-isomorphic-utils/entity-store"; +import type { TextualContentPropertyValue } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { FunctionComponent } from "react"; + export type BlockLoaderProps = { blockCollectionSubgraph?: Subgraph>; blockEntityId?: EntityId; // @todo make this always defined diff --git a/apps/hash-frontend/src/components/block-loader/fetch-embed-code.ts b/apps/hash-frontend/src/components/block-loader/fetch-embed-code.ts index 02ed128460a..d776ff9fa83 100644 --- a/apps/hash-frontend/src/components/block-loader/fetch-embed-code.ts +++ b/apps/hash-frontend/src/components/block-loader/fetch-embed-code.ts @@ -1,6 +1,7 @@ -import type { JsonObject } from "@blockprotocol/core"; import { apiGraphQLEndpoint } from "@local/hash-isomorphic-utils/environment"; +import type { JsonObject } from "@blockprotocol/core"; + export type FetchEmbedCodeFn = ( url: string, type?: string, diff --git a/apps/hash-frontend/src/components/confirmation-alert.tsx b/apps/hash-frontend/src/components/confirmation-alert.tsx index 6f437e8354a..a563650c18e 100644 --- a/apps/hash-frontend/src/components/confirmation-alert.tsx +++ b/apps/hash-frontend/src/components/confirmation-alert.tsx @@ -5,10 +5,11 @@ import { DialogContentText, DialogTitle, } from "@mui/material"; -import type { FunctionComponent, ReactNode } from "react"; import { Button } from "../shared/ui"; +import type { FunctionComponent, ReactNode } from "react"; + type ConfirmationAlertProps = { children: ReactNode; open: boolean; diff --git a/apps/hash-frontend/src/components/dropdowns/version-dropdown.tsx b/apps/hash-frontend/src/components/dropdowns/version-dropdown.tsx index a70a70e5e76..38fc68159ae 100644 --- a/apps/hash-frontend/src/components/dropdowns/version-dropdown.tsx +++ b/apps/hash-frontend/src/components/dropdowns/version-dropdown.tsx @@ -1,5 +1,6 @@ import { Box } from "@mui/material"; import { formatDistance } from "date-fns"; + import type { ChangeEvent, FunctionComponent } from "react"; type VersionDropdownProps = { diff --git a/apps/hash-frontend/src/components/error-block/error-block.tsx b/apps/hash-frontend/src/components/error-block/error-block.tsx index 67fd2bbef18..4b8c7c4cc7c 100644 --- a/apps/hash-frontend/src/components/error-block/error-block.tsx +++ b/apps/hash-frontend/src/components/error-block/error-block.tsx @@ -1,8 +1,8 @@ +import { Button } from "../../shared/ui"; + import type { FallbackRender } from "@sentry/react"; import type { FunctionComponent } from "react"; -import { Button } from "../../shared/ui"; - type FallbackRenderProps = Parameters[0]; export interface ErrorBlockProps extends FallbackRenderProps { diff --git a/apps/hash-frontend/src/components/forms/select-input.tsx b/apps/hash-frontend/src/components/forms/select-input.tsx index 6298ae47c30..d5f75045e2c 100644 --- a/apps/hash-frontend/src/components/forms/select-input.tsx +++ b/apps/hash-frontend/src/components/forms/select-input.tsx @@ -1,8 +1,9 @@ import { Box } from "@mui/material"; import { uniqueId } from "lodash"; -import type { ChangeEvent, HTMLProps } from "react"; import { forwardRef, useCallback, useState } from "react"; +import type { ChangeEvent, HTMLProps } from "react"; + type SelectInputProps = { label?: string; labelClass?: string; diff --git a/apps/hash-frontend/src/components/forms/tags-input.tsx b/apps/hash-frontend/src/components/forms/tags-input.tsx index fa9f2af3bf5..32f5e70d044 100644 --- a/apps/hash-frontend/src/components/forms/tags-input.tsx +++ b/apps/hash-frontend/src/components/forms/tags-input.tsx @@ -1,7 +1,8 @@ import { Box } from "@mui/material"; -import type { FunctionComponent, KeyboardEvent } from "react"; import { useRef } from "react"; +import type { FunctionComponent, KeyboardEvent } from "react"; + type TagsInputProps = { minHeight?: number; tags: string[]; diff --git a/apps/hash-frontend/src/components/forms/text-input.tsx b/apps/hash-frontend/src/components/forms/text-input.tsx index ca04aa14f52..4f002487fd2 100644 --- a/apps/hash-frontend/src/components/forms/text-input.tsx +++ b/apps/hash-frontend/src/components/forms/text-input.tsx @@ -1,8 +1,9 @@ -import type { ChangeEvent, CSSProperties, HTMLProps } from "react"; import { forwardRef } from "react"; import { InputLabelWrapper } from "./input-label-wrapper"; +import type { ChangeEvent, CSSProperties, HTMLProps } from "react"; + type TextInputProps = { disallowRegExp?: RegExp; label?: string; diff --git a/apps/hash-frontend/src/components/grid/grid.tsx b/apps/hash-frontend/src/components/grid/grid.tsx index 0c6ac77543a..07026c1e53c 100644 --- a/apps/hash-frontend/src/components/grid/grid.tsx +++ b/apps/hash-frontend/src/components/grid/grid.tsx @@ -1,34 +1,15 @@ import "@glideapps/glide-data-grid/dist/index.css"; - -import type { BaseUrl, VersionedUrl } from "@blockprotocol/type-system"; -import type { - DataEditorProps, - DataEditorRef, - GridCell, - GridColumn as LibraryGridColumn, - GridSelection, - HeaderClickedEventArgs, - Item, - SizedGridColumn, - TextCell, - Theme, -} from "@glideapps/glide-data-grid"; import { CompactSelection, DataEditor, GridCellKind, } from "@glideapps/glide-data-grid"; -import { gridRowHeight } from "@local/hash-isomorphic-utils/data-grid"; -import type { PopperProps } from "@mui/material"; import { Box, useTheme } from "@mui/material"; -import type { - Instance as PopperInstance, - VirtualElement, -} from "@popperjs/core"; import { uniqueId } from "lodash"; -import type { MutableRefObject, Ref } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { gridRowHeight } from "@local/hash-isomorphic-utils/data-grid"; + import { getCellHorizontalPadding } from "./utils"; import { ColumnFilterMenu } from "./utils/column-filter-menu"; import { @@ -36,15 +17,35 @@ import { type ConversionTargetsByColumnKey, } from "./utils/conversion-menu"; import { customGridIcons } from "./utils/custom-grid-icons"; -import type { ColumnFilter } from "./utils/filtering"; import { InteractableManager } from "./utils/interactable-manager"; -import type { ColumnHeaderPath } from "./utils/interactable-manager/types"; import { overrideCustomRenderers } from "./utils/override-custom-renderers"; -import type { ColumnSort } from "./utils/sorting"; import { defaultSortRows } from "./utils/sorting"; import { generateInteractableId, useDrawHeader } from "./utils/use-draw-header"; import { useRenderGridPortal } from "./utils/use-render-grid-portal"; +import type { ColumnFilter } from "./utils/filtering"; +import type { ColumnHeaderPath } from "./utils/interactable-manager/types"; +import type { ColumnSort } from "./utils/sorting"; +import type { BaseUrl, VersionedUrl } from "@blockprotocol/type-system"; +import type { + DataEditorProps, + DataEditorRef, + GridCell, + GridColumn as LibraryGridColumn, + GridSelection, + HeaderClickedEventArgs, + Item, + SizedGridColumn, + TextCell, + Theme, +} from "@glideapps/glide-data-grid"; +import type { PopperProps } from "@mui/material"; +import type { + Instance as PopperInstance, + VirtualElement, +} from "@popperjs/core"; +import type { MutableRefObject, Ref } from "react"; + export type { ConversionTargetsByColumnKey }; export type ColumnKey = C["id"]; diff --git a/apps/hash-frontend/src/components/grid/utils.ts b/apps/hash-frontend/src/components/grid/utils.ts index 62c241b77e5..c7ee639b82f 100644 --- a/apps/hash-frontend/src/components/grid/utils.ts +++ b/apps/hash-frontend/src/components/grid/utils.ts @@ -1,6 +1,7 @@ -import type { CustomCell, DrawArgs, Theme } from "@glideapps/glide-data-grid"; import { getMiddleCenterBias, GridCellKind } from "@glideapps/glide-data-grid"; +import type { CustomCell, DrawArgs, Theme } from "@glideapps/glide-data-grid"; + /** * @returns vertical center of a grid cell, relative to the visible grid area */ diff --git a/apps/hash-frontend/src/components/grid/utils/column-filter-menu.tsx b/apps/hash-frontend/src/components/grid/utils/column-filter-menu.tsx index 45f42f056d1..e724877f5c6 100644 --- a/apps/hash-frontend/src/components/grid/utils/column-filter-menu.tsx +++ b/apps/hash-frontend/src/components/grid/utils/column-filter-menu.tsx @@ -1,5 +1,3 @@ -import { TextField } from "@hashintel/design-system"; -import { formatNumber } from "@local/hash-isomorphic-utils/format-number"; import { Box, Checkbox, @@ -16,13 +14,17 @@ import { type Theme, Typography, } from "@mui/material"; -import type { CSSProperties } from "react"; import { memo, useMemo, useState } from "react"; import { FixedSizeList } from "react-window"; +import { TextField } from "@hashintel/design-system"; +import { formatNumber } from "@local/hash-isomorphic-utils/format-number"; + import { MenuItem } from "../../../shared/ui"; + import type { GridRow } from "../grid"; import type { ColumnFilter } from "./filtering"; +import type { CSSProperties } from "react"; const blueFilterButtonSx: SxProps = ({ palette, transitions }) => ({ background: "transparent", diff --git a/apps/hash-frontend/src/components/grid/utils/conversion-menu.tsx b/apps/hash-frontend/src/components/grid/utils/conversion-menu.tsx index 8ca8978af67..fc1a79eec51 100644 --- a/apps/hash-frontend/src/components/grid/utils/conversion-menu.tsx +++ b/apps/hash-frontend/src/components/grid/utils/conversion-menu.tsx @@ -1,5 +1,3 @@ -import type { VersionedUrl } from "@blockprotocol/type-system"; -import { Select } from "@hashintel/design-system"; import { Box, ClickAwayListener, @@ -12,8 +10,12 @@ import { } from "@mui/material"; import { useEffect, useRef, useState } from "react"; +import { Select } from "@hashintel/design-system"; + import { MenuItem } from "../../../shared/ui"; +import type { VersionedUrl } from "@blockprotocol/type-system"; + export type ConversionTargetsByColumnKey = Record< string, { diff --git a/apps/hash-frontend/src/components/grid/utils/custom-grid-icons.ts b/apps/hash-frontend/src/components/grid/utils/custom-grid-icons.ts index ffa904a147d..e1c4e707005 100644 --- a/apps/hash-frontend/src/components/grid/utils/custom-grid-icons.ts +++ b/apps/hash-frontend/src/components/grid/utils/custom-grid-icons.ts @@ -1,6 +1,7 @@ -import type { SpriteProps } from "@glideapps/glide-data-grid"; import { customColors } from "@hashintel/design-system/theme"; +import type { SpriteProps } from "@glideapps/glide-data-grid"; + export const customGridIcons = { bpAsteriskCircle: ({ fgColor }) => ``, diff --git a/apps/hash-frontend/src/components/grid/utils/draw-chip-with-icon.ts b/apps/hash-frontend/src/components/grid/utils/draw-chip-with-icon.ts index b160c6113bb..da3f988641b 100644 --- a/apps/hash-frontend/src/components/grid/utils/draw-chip-with-icon.ts +++ b/apps/hash-frontend/src/components/grid/utils/draw-chip-with-icon.ts @@ -1,14 +1,15 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; import { customColors } from "@hashintel/design-system/theme"; +import { getChipColors } from "../../../pages/shared/chip-cell"; +import { getYCenter } from "../utils"; +import { drawChip } from "./draw-chip"; + import type { ChipCellColor, ChipCellVariant, } from "../../../pages/shared/chip-cell"; -import { getChipColors } from "../../../pages/shared/chip-cell"; -import { getYCenter } from "../utils"; import type { CustomIcon } from "./custom-grid-icons"; -import { drawChip } from "./draw-chip"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; const filledIconCanvasCache: { [originalUrl: string]: { diff --git a/apps/hash-frontend/src/components/grid/utils/draw-chip-with-text.ts b/apps/hash-frontend/src/components/grid/utils/draw-chip-with-text.ts index cbaeae93e58..97eb155b4f2 100644 --- a/apps/hash-frontend/src/components/grid/utils/draw-chip-with-text.ts +++ b/apps/hash-frontend/src/components/grid/utils/draw-chip-with-text.ts @@ -1,8 +1,8 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; - import { getYCenter } from "../utils"; import { drawChip } from "./draw-chip"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; + /** * @param args draw args of cell * @param text text content of chip diff --git a/apps/hash-frontend/src/components/grid/utils/draw-chip.ts b/apps/hash-frontend/src/components/grid/utils/draw-chip.ts index 3f1f2b92146..da20365e12e 100644 --- a/apps/hash-frontend/src/components/grid/utils/draw-chip.ts +++ b/apps/hash-frontend/src/components/grid/utils/draw-chip.ts @@ -1,8 +1,8 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; - import { getYCenter } from "../utils"; import { drawRoundRect } from "./draw-round-rect"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; + export const drawChip = ( args: DrawArgs, left: number, diff --git a/apps/hash-frontend/src/components/grid/utils/draw-text-with-icon.ts b/apps/hash-frontend/src/components/grid/utils/draw-text-with-icon.ts index 32a6b700557..64c0f53e334 100644 --- a/apps/hash-frontend/src/components/grid/utils/draw-text-with-icon.ts +++ b/apps/hash-frontend/src/components/grid/utils/draw-text-with-icon.ts @@ -1,7 +1,7 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; - import { getYCenter } from "../utils"; + import type { CustomIcon } from "./custom-grid-icons"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; interface DrawTextWithIconParams { args: DrawArgs; diff --git a/apps/hash-frontend/src/components/grid/utils/draw-url-as-link.ts b/apps/hash-frontend/src/components/grid/utils/draw-url-as-link.ts index 027c25d37fa..07cd785a229 100644 --- a/apps/hash-frontend/src/components/grid/utils/draw-url-as-link.ts +++ b/apps/hash-frontend/src/components/grid/utils/draw-url-as-link.ts @@ -1,8 +1,9 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; import { customColors } from "@hashintel/design-system/theme"; import { getYCenter } from "../utils"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; + interface DrawUrlParams { args: DrawArgs; url: string; diff --git a/apps/hash-frontend/src/components/grid/utils/draw-vertical-indentation-line.ts b/apps/hash-frontend/src/components/grid/utils/draw-vertical-indentation-line.ts index 1ebb7ec2852..65c1cc51c89 100644 --- a/apps/hash-frontend/src/components/grid/utils/draw-vertical-indentation-line.ts +++ b/apps/hash-frontend/src/components/grid/utils/draw-vertical-indentation-line.ts @@ -1,7 +1,7 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; - import { getYCenter } from "../utils"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; + export type VerticalIndentationLineDir = "up" | "down" | "full"; /** diff --git a/apps/hash-frontend/src/components/grid/utils/interactable-manager.ts b/apps/hash-frontend/src/components/grid/utils/interactable-manager.ts index 3040330d32e..fe5719aa68a 100644 --- a/apps/hash-frontend/src/components/grid/utils/interactable-manager.ts +++ b/apps/hash-frontend/src/components/grid/utils/interactable-manager.ts @@ -1,13 +1,5 @@ -import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; import { typedKeys } from "@local/advanced-types/typed-entries"; -import type { - CellPath, - ColumnHeaderDrawArgs, - ColumnHeaderPath, - CursorPos, - Interactable, -} from "./interactable-manager/types"; import { drawArgsToCellPath, drawArgsToColumnHeaderPath, @@ -16,6 +8,15 @@ import { splitPath, } from "./interactable-manager/utils"; +import type { + CellPath, + ColumnHeaderDrawArgs, + ColumnHeaderPath, + CursorPos, + Interactable, +} from "./interactable-manager/types"; +import type { CustomCell, DrawArgs } from "@glideapps/glide-data-grid"; + class InteractableManagerClass { static instance: InteractableManagerClass | null = null; diff --git a/apps/hash-frontend/src/components/grid/utils/interactable-manager/utils.ts b/apps/hash-frontend/src/components/grid/utils/interactable-manager/utils.ts index 74e6b1d4473..23bdb95c7f5 100644 --- a/apps/hash-frontend/src/components/grid/utils/interactable-manager/utils.ts +++ b/apps/hash-frontend/src/components/grid/utils/interactable-manager/utils.ts @@ -1,9 +1,3 @@ -import type { - CustomCell, - DrawArgs, - Rectangle, -} from "@glideapps/glide-data-grid"; - import type { CellPath, ColumnHeaderDrawArgs, @@ -11,6 +5,11 @@ import type { CursorPos, InteractablePosition, } from "./types"; +import type { + CustomCell, + DrawArgs, + Rectangle, +} from "@glideapps/glide-data-grid"; export const isPathCellPath = ( path: CellPath | ColumnHeaderPath, diff --git a/apps/hash-frontend/src/components/grid/utils/override-custom-renderers.tsx b/apps/hash-frontend/src/components/grid/utils/override-custom-renderers.tsx index 319687e10e9..2589c9265ee 100644 --- a/apps/hash-frontend/src/components/grid/utils/override-custom-renderers.tsx +++ b/apps/hash-frontend/src/components/grid/utils/override-custom-renderers.tsx @@ -1,4 +1,3 @@ -import type { DataEditorProps } from "@glideapps/glide-data-grid"; import { isObjectEditorCallbackResult } from "@glideapps/glide-data-grid"; import { type ReactNode, type RefObject } from "react"; @@ -6,6 +5,8 @@ import { useSlideStack } from "../../../pages/shared/slide-stack"; import { useScrollLock } from "../../../shared/use-scroll-lock"; import { InteractableManager } from "./interactable-manager"; +import type { DataEditorProps } from "@glideapps/glide-data-grid"; + /** * Lock scrolling outside when a Grid editor overlay is open. * @@ -22,7 +23,9 @@ import { InteractableManager } from "./interactable-manager"; */ const ScrollLockWrapper = ({ children, -}: { children: ReactNode | Promise }) => { +}: { + children: ReactNode | Promise; +}) => { const { currentSlideRef } = useSlideStack(); useScrollLock(true, currentSlideRef?.current ?? document.body); diff --git a/apps/hash-frontend/src/components/grid/utils/sorting.ts b/apps/hash-frontend/src/components/grid/utils/sorting.ts index 356b4e29eae..56b9e95e375 100644 --- a/apps/hash-frontend/src/components/grid/utils/sorting.ts +++ b/apps/hash-frontend/src/components/grid/utils/sorting.ts @@ -1,6 +1,5 @@ -import type { SizedGridColumn } from "@glideapps/glide-data-grid"; - import type { GridRow } from "../grid"; +import type { SizedGridColumn } from "@glideapps/glide-data-grid"; export type ColumnSortDirection = "asc" | "desc"; diff --git a/apps/hash-frontend/src/components/grid/utils/use-draw-header.ts b/apps/hash-frontend/src/components/grid/utils/use-draw-header.ts index 0503988b67c..0b88c67a37e 100644 --- a/apps/hash-frontend/src/components/grid/utils/use-draw-header.ts +++ b/apps/hash-frontend/src/components/grid/utils/use-draw-header.ts @@ -1,20 +1,21 @@ -import type { BaseUrl, VersionedUrl } from "@blockprotocol/type-system"; -import type { - DrawHeaderCallback, - SizedGridColumn, -} from "@glideapps/glide-data-grid"; import { useTheme } from "@mui/material"; import { useCallback } from "react"; -import type { ColumnKey, ConversionTargetsByColumnKey } from "../grid"; import { getCellHorizontalPadding, getYCenter } from "../utils"; -import type { ColumnFilter } from "./filtering"; import { InteractableManager } from "./interactable-manager"; + +import type { ColumnKey, ConversionTargetsByColumnKey } from "../grid"; +import type { ColumnFilter } from "./filtering"; import type { Interactable, InteractablePosition, } from "./interactable-manager/types"; import type { ColumnSort } from "./sorting"; +import type { BaseUrl, VersionedUrl } from "@blockprotocol/type-system"; +import type { + DrawHeaderCallback, + SizedGridColumn, +} from "@glideapps/glide-data-grid"; export const generateInteractableId = ( type: "filter" | "sort" | "convert", diff --git a/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip.tsx b/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip.tsx index fd73c7f5ec8..9439a364d63 100644 --- a/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip.tsx +++ b/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip.tsx @@ -1,11 +1,7 @@ -import type { DataEditorRef } from "@glideapps/glide-data-grid"; import { useWindowEvent } from "@mantine/hooks"; -import type { PopoverPosition } from "@mui/material"; import { Box, Popper, Typography } from "@mui/material"; -import type { VirtualElement } from "@popperjs/core"; import { isEqual } from "lodash"; import { usePopupState } from "material-ui-popup-state/hooks"; -import type { RefObject } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import type { @@ -13,6 +9,10 @@ import type { TooltipCellProps, UseGridTooltipResponse, } from "./use-grid-tooltip/types"; +import type { DataEditorRef } from "@glideapps/glide-data-grid"; +import type { PopoverPosition } from "@mui/material"; +import type { VirtualElement } from "@popperjs/core"; +import type { RefObject } from "react"; export const useGridTooltip = ( gridRef: RefObject, diff --git a/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/draw-interactable-tooltip-icons.ts b/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/draw-interactable-tooltip-icons.ts index 4b152e8ae8e..e2c395f5422 100644 --- a/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/draw-interactable-tooltip-icons.ts +++ b/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/draw-interactable-tooltip-icons.ts @@ -1,10 +1,10 @@ -import type { DrawArgs } from "@glideapps/glide-data-grid"; - import { getCellHorizontalPadding, getYCenter } from "../../utils"; import { drawCellFadeOutGradient } from "../draw-cell-fade-out-gradient"; import { InteractableManager } from "../interactable-manager"; + import type { Interactable } from "../interactable-manager/types"; import type { TooltipCell } from "./types"; +import type { DrawArgs } from "@glideapps/glide-data-grid"; const iconSize = 16; const iconGap = 10; diff --git a/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/types.ts b/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/types.ts index c550cfb4a57..46d8c9f3a4c 100644 --- a/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/types.ts +++ b/apps/hash-frontend/src/components/grid/utils/use-grid-tooltip/types.ts @@ -1,8 +1,7 @@ +import type { CustomIcon } from "../custom-grid-icons"; import type { CustomCell } from "@glideapps/glide-data-grid"; import type { ReactElement } from "react"; -import type { CustomIcon } from "../custom-grid-icons"; - export type GridTooltip = { colIndex: number; rowIndex: number; diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/knowledge-shim.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/knowledge-shim.ts index 1e0d7dc3f51..401b74ac450 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/knowledge-shim.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/knowledge-shim.ts @@ -6,6 +6,10 @@ * package and be removed from here. */ +import type { + FileEntityCreationInput, + FileEntityUpdateInput, +} from "../../../../graphql/api-types.gen"; import type { MessageCallback, MessageReturn } from "@blockprotocol/core"; import type { CreateResourceError, @@ -29,11 +33,6 @@ import type { TraversalPath, } from "@rust/hash-graph-store/types"; -import type { - FileEntityCreationInput, - FileEntityUpdateInput, -} from "../../../../graphql/api-types.gen"; - /* Entity CRU */ export type GetEntityData = { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity.ts index bf6404734dc..0939a28acd3 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity.ts @@ -1,11 +1,12 @@ import { useMutation } from "@apollo/client"; import { useCallback } from "react"; +import { archiveEntityMutation } from "../../../../graphql/queries/knowledge/entity.queries"; + import type { ArchiveEntityMutation, ArchiveEntityMutationVariables, } from "../../../../graphql/api-types.gen"; -import { archiveEntityMutation } from "../../../../graphql/queries/knowledge/entity.queries"; import type { ArchiveEntityMessageCallback } from "./knowledge-shim"; export const useBlockProtocolArchiveEntity = ( diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-create-entity.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-create-entity.ts index 124c2078851..cdf1bd0a2fe 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-create-entity.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-create-entity.ts @@ -1,22 +1,24 @@ import { useMutation } from "@apollo/client"; -import type { WebId } from "@blockprotocol/type-system"; +import { useCallback } from "react"; + import { HashEntity, mergePropertyObjectAndMetadata, } from "@local/hash-graph-sdk/entity"; -import { useCallback } from "react"; -import type { - CreateEntityMutation, - CreateEntityMutationVariables, -} from "../../../../graphql/api-types.gen"; import { createEntityMutation, queryEntitySubgraphQuery, } from "../../../../graphql/queries/knowledge/entity.queries"; import { useActiveWorkspace } from "../../../../pages/shared/workspace-context"; import { generateSidebarEntityTypeEntitiesQueryVariables } from "../../../../shared/use-entity-type-entities"; + +import type { + CreateEntityMutation, + CreateEntityMutationVariables, +} from "../../../../graphql/api-types.gen"; import type { CreateEntityMessageCallback } from "./knowledge-shim"; +import type { WebId } from "@blockprotocol/type-system"; export const useBlockProtocolCreateEntity = ( webId: WebId | null, diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-file-upload.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-file-upload.ts index c41c84a358e..4b5d654707e 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-file-upload.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-file-upload.ts @@ -1,21 +1,23 @@ import { useMutation } from "@apollo/client"; -import type { WebId } from "@blockprotocol/type-system"; -import { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; import { useCallback } from "react"; +import { HashEntity } from "@local/hash-graph-sdk/entity"; + +import { + createFileFromUrl, + requestFileUpload, +} from "../../../../graphql/queries/knowledge/file.queries"; +import { uploadFileToStorageProvider } from "../../../../shared/upload-to-storage-provider"; + import type { CreateFileFromUrlMutation, CreateFileFromUrlMutationVariables, RequestFileUploadMutation, RequestFileUploadMutationVariables, } from "../../../../graphql/api-types.gen"; -import { - createFileFromUrl, - requestFileUpload, -} from "../../../../graphql/queries/knowledge/file.queries"; -import { uploadFileToStorageProvider } from "../../../../shared/upload-to-storage-provider"; import type { UploadFileRequestCallback } from "./knowledge-shim"; +import type { WebId } from "@blockprotocol/type-system"; +import type { File } from "@local/hash-isomorphic-utils/system-types/shared"; export const useBlockProtocolFileUpload = ( webId?: WebId, diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-get-entity.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-get-entity.ts index a8601606a37..d1bd7cf6fd1 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-get-entity.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-get-entity.ts @@ -1,9 +1,10 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { splitEntityId } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { queryEntitySubgraphQuery } from "@local/hash-isomorphic-utils/graphql/queries/entity.queries"; -import { useCallback } from "react"; import type { QueryEntitySubgraphQuery, diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-query-entities.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-query-entities.ts index 267e0fb3943..690e6357b78 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-query-entities.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-query-entities.ts @@ -1,14 +1,16 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryEntitySubgraphResponse } from "@local/hash-graph-sdk/entity"; import { convertBpFilterToGraphFilter } from "@local/hash-graph-sdk/filter"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryEntitySubgraphQuery } from "../../../../graphql/queries/knowledge/entity.queries"; import type { QueryEntitySubgraphQuery, QueryEntitySubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryEntitySubgraphQuery } from "../../../../graphql/queries/knowledge/entity.queries"; import type { QueryEntitiesMessageCallback } from "./knowledge-shim"; export const useBlockProtocolQueryEntities = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-update-entity.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-update-entity.ts index fdaf4f021b8..c7855cb92a6 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-update-entity.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/knowledge/use-block-protocol-update-entity.ts @@ -1,16 +1,18 @@ import { useMutation } from "@apollo/client"; +import { useCallback } from "react"; + import { HashEntity, mergePropertyObjectAndMetadata, propertyObjectToPatches, } from "@local/hash-graph-sdk/entity"; -import { useCallback } from "react"; + +import { updateEntityMutation } from "../../../../graphql/queries/knowledge/entity.queries"; import type { UpdateEntityMutation, UpdateEntityMutationVariables, } from "../../../../graphql/api-types.gen"; -import { updateEntityMutation } from "../../../../graphql/queries/knowledge/entity.queries"; import type { UpdateEntityMessageCallback } from "./knowledge-shim"; export const useBlockProtocolUpdateEntity = ( diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-entity-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-entity-type.ts index 2b8826d7cc4..a9f647e8ece 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-entity-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-entity-type.ts @@ -1,13 +1,14 @@ import { useMutation } from "@apollo/client"; -import type { WebId } from "@blockprotocol/type-system"; import { useCallback } from "react"; +import { createEntityTypeMutation } from "../../../../graphql/queries/ontology/entity-type.queries"; + import type { CreateEntityTypeMutation, CreateEntityTypeMutationVariables, } from "../../../../graphql/api-types.gen"; -import { createEntityTypeMutation } from "../../../../graphql/queries/ontology/entity-type.queries"; import type { CreateEntityTypeMessageCallback } from "./ontology-types-shim"; +import type { WebId } from "@blockprotocol/type-system"; export const useBlockProtocolCreateEntityType = ( webId: WebId | null, diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-property-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-property-type.ts index 90f3bd142ee..801377d82d7 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-property-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-create-property-type.ts @@ -1,13 +1,14 @@ import { useMutation } from "@apollo/client"; -import type { WebId } from "@blockprotocol/type-system"; import { useCallback } from "react"; +import { createPropertyTypeMutation } from "../../../../graphql/queries/ontology/property-type.queries"; + import type { CreatePropertyTypeMutation, CreatePropertyTypeMutationVariables, } from "../../../../graphql/api-types.gen"; -import { createPropertyTypeMutation } from "../../../../graphql/queries/ontology/property-type.queries"; import type { CreatePropertyTypeMessageCallback } from "./ontology-types-shim"; +import type { WebId } from "@blockprotocol/type-system"; export const useBlockProtocolCreatePropertyType = ( webId: WebId | null, diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-data-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-data-type.ts index 0c4f0fe302d..5de62f20c12 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-data-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-data-type.ts @@ -1,16 +1,18 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryDataTypeSubgraphResponse } from "@local/hash-graph-sdk/data-type"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryDataTypeSubgraphQuery } from "../../../../graphql/queries/ontology/data-type.queries"; import type { QueryDataTypeSubgraphQuery, QueryDataTypeSubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryDataTypeSubgraphQuery } from "../../../../graphql/queries/ontology/data-type.queries"; import type { GetDataTypeMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolGetDataType = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-entity-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-entity-type.ts index fa2dde7ef39..37d37a0d049 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-entity-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-entity-type.ts @@ -1,16 +1,18 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryEntityTypeSubgraphResponse } from "@local/hash-graph-sdk/entity-type"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryEntityTypeSubgraphQuery } from "../../../../graphql/queries/ontology/entity-type.queries"; import type { QueryEntityTypeSubgraphQuery, QueryEntityTypeSubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryEntityTypeSubgraphQuery } from "../../../../graphql/queries/ontology/entity-type.queries"; import type { GetEntityTypeMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolGetEntityType = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-property-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-property-type.ts index fa0711d3391..6d699ec278f 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-property-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-get-property-type.ts @@ -1,16 +1,18 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryPropertyTypeSubgraphResponse } from "@local/hash-graph-sdk/property-type"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryPropertyTypeSubgraphQuery } from "../../../../graphql/queries/ontology/property-type.queries"; import type { QueryPropertyTypeSubgraphQuery, QueryPropertyTypeSubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryPropertyTypeSubgraphQuery } from "../../../../graphql/queries/ontology/property-type.queries"; import type { GetPropertyTypeMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolGetPropertyType = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-data-types.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-data-types.ts index 8fa06730c5b..7471ae7a576 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-data-types.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-data-types.ts @@ -1,16 +1,18 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryDataTypeSubgraphResponse } from "@local/hash-graph-sdk/data-type"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryDataTypeSubgraphQuery } from "../../../../graphql/queries/ontology/data-type.queries"; import type { QueryDataTypeSubgraphQuery, QueryDataTypeSubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryDataTypeSubgraphQuery } from "../../../../graphql/queries/ontology/data-type.queries"; import type { QueryDataTypesMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolQueryDataTypes = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-entity-types.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-entity-types.ts index 30b87b6468e..76415034fde 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-entity-types.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-entity-types.ts @@ -1,17 +1,19 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryEntityTypeSubgraphResponse } from "@local/hash-graph-sdk/entity-type"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, fullTransactionTimeAxis, } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryEntityTypeSubgraphQuery } from "../../../../graphql/queries/ontology/entity-type.queries"; import type { QueryEntityTypeSubgraphQuery, QueryEntityTypeSubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryEntityTypeSubgraphQuery } from "../../../../graphql/queries/ontology/entity-type.queries"; import type { QueryEntityTypesMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolQueryEntityTypes = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-property-types.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-property-types.ts index cb319b11974..b64fb2d3cdd 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-property-types.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-query-property-types.ts @@ -1,17 +1,19 @@ import { useLazyQuery } from "@apollo/client"; +import { useCallback } from "react"; + import { deserializeQueryPropertyTypeSubgraphResponse } from "@local/hash-graph-sdk/property-type"; import { almostFullOntologyResolveDepths, currentTimeInstantTemporalAxes, fullTransactionTimeAxis, } from "@local/hash-isomorphic-utils/graph-queries"; -import { useCallback } from "react"; + +import { queryPropertyTypeSubgraphQuery } from "../../../../graphql/queries/ontology/property-type.queries"; import type { QueryPropertyTypeSubgraphQuery, QueryPropertyTypeSubgraphQueryVariables, } from "../../../../graphql/api-types.gen"; -import { queryPropertyTypeSubgraphQuery } from "../../../../graphql/queries/ontology/property-type.queries"; import type { QueryPropertyTypesMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolQueryPropertyTypes = (): { diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-entity-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-entity-type.ts index 754019f6eaa..2e384a5c4cf 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-entity-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-entity-type.ts @@ -1,11 +1,12 @@ import { useMutation } from "@apollo/client"; import { useCallback } from "react"; +import { updateEntityTypeMutation } from "../../../../graphql/queries/ontology/entity-type.queries"; + import type { UpdateEntityTypeMutation, UpdateEntityTypeMutationVariables, } from "../../../../graphql/api-types.gen"; -import { updateEntityTypeMutation } from "../../../../graphql/queries/ontology/entity-type.queries"; import type { UpdateEntityTypeMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolUpdateEntityType = ( diff --git a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-property-type.ts b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-property-type.ts index 48aaa2f24da..0cb2af91177 100644 --- a/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-property-type.ts +++ b/apps/hash-frontend/src/components/hooks/block-protocol-functions/ontology/use-block-protocol-update-property-type.ts @@ -1,11 +1,12 @@ import { useMutation } from "@apollo/client"; import { useCallback } from "react"; +import { updatePropertyTypeMutation } from "../../../../graphql/queries/ontology/property-type.queries"; + import type { UpdatePropertyTypeMutation, UpdatePropertyTypeMutationVariables, } from "../../../../graphql/api-types.gen"; -import { updatePropertyTypeMutation } from "../../../../graphql/queries/ontology/property-type.queries"; import type { UpdatePropertyTypeMessageCallback } from "./ontology-types-shim"; export const useBlockProtocolUpdatePropertyType = ( diff --git a/apps/hash-frontend/src/components/hooks/shared/get-page-refetch-queries.ts b/apps/hash-frontend/src/components/hooks/shared/get-page-refetch-queries.ts index 8c42a553e29..e784e42d431 100644 --- a/apps/hash-frontend/src/components/hooks/shared/get-page-refetch-queries.ts +++ b/apps/hash-frontend/src/components/hooks/shared/get-page-refetch-queries.ts @@ -1,14 +1,16 @@ -import type { EntityId } from "@blockprotocol/type-system"; +import { useCallback } from "react"; + import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, } from "@blockprotocol/type-system"; -import { useCallback } from "react"; import { queryEntitySubgraphQuery } from "../../../graphql/queries/knowledge/entity.queries"; import { getBlockCollectionContentsStructuralQueryVariables } from "../../../pages/shared/block-collection-contents"; import { getAccountPagesVariables } from "../../../shared/account-pages-variables"; +import type { EntityId } from "@blockprotocol/type-system"; + /** * Some aspects of a page, e.g. the icon and title, are shown in multiple places: * 1. The header on the page's own page diff --git a/apps/hash-frontend/src/components/hooks/use-account-pages.ts b/apps/hash-frontend/src/components/hooks/use-account-pages.ts index 4579fa1e281..e261cc67334 100644 --- a/apps/hash-frontend/src/components/hooks/use-account-pages.ts +++ b/apps/hash-frontend/src/components/hooks/use-account-pages.ts @@ -1,27 +1,29 @@ -import type { ApolloQueryResult } from "@apollo/client"; import { useQuery } from "@apollo/client"; +import { useMemo } from "react"; + import { getOutgoingLinkAndTargetEntities, getRoots, } from "@blockprotocol/graph/stdlib"; -import type { EntityMetadata, WebId } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse } from "@local/hash-graph-sdk/entity"; import { systemEntityTypes, systemLinkEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { SimpleProperties } from "@local/hash-isomorphic-utils/simplify-properties"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { PageProperties } from "@local/hash-isomorphic-utils/system-types/shared"; -import { useMemo } from "react"; + +import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; +import { getAccountPagesVariables } from "../../shared/account-pages-variables"; +import { useHashInstance } from "./use-hash-instance"; import type { QueryEntitySubgraphQuery, QueryEntitySubgraphQueryVariables, } from "../../graphql/api-types.gen"; -import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; -import { getAccountPagesVariables } from "../../shared/account-pages-variables"; -import { useHashInstance } from "./use-hash-instance"; +import type { ApolloQueryResult } from "@apollo/client"; +import type { EntityMetadata, WebId } from "@blockprotocol/type-system"; +import type { SimpleProperties } from "@local/hash-isomorphic-utils/simplify-properties"; +import type { PageProperties } from "@local/hash-isomorphic-utils/system-types/shared"; export type SimplePage = SimpleProperties & { metadata: EntityMetadata; diff --git a/apps/hash-frontend/src/components/hooks/use-archive-page.ts b/apps/hash-frontend/src/components/hooks/use-archive-page.ts index 8139f11b4ad..64e263010f4 100644 --- a/apps/hash-frontend/src/components/hooks/use-archive-page.ts +++ b/apps/hash-frontend/src/components/hooks/use-archive-page.ts @@ -1,20 +1,22 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; +import { useCallback } from "react"; + import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, } from "@blockprotocol/type-system"; -import { useCallback } from "react"; -import type { - UpdatePageMutation, - UpdatePageMutationVariables, -} from "../../graphql/api-types.gen"; import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; import { updatePage } from "../../graphql/queries/page.queries"; import { getBlockCollectionContentsStructuralQueryVariables } from "../../pages/shared/block-collection-contents"; import { getAccountPagesVariables } from "../../shared/account-pages-variables"; +import type { + UpdatePageMutation, + UpdatePageMutationVariables, +} from "../../graphql/api-types.gen"; +import type { EntityId } from "@blockprotocol/type-system"; + export const useArchivePage = () => { const [updatePageFn, { loading }] = useMutation< UpdatePageMutation, diff --git a/apps/hash-frontend/src/components/hooks/use-create-comment.ts b/apps/hash-frontend/src/components/hooks/use-create-comment.ts index 39095e87a49..fa916c7c66d 100644 --- a/apps/hash-frontend/src/components/hooks/use-create-comment.ts +++ b/apps/hash-frontend/src/components/hooks/use-create-comment.ts @@ -1,14 +1,15 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; -import type { TextToken } from "@local/hash-isomorphic-utils/types"; import { useCallback } from "react"; +import { createComment } from "../../graphql/queries/comment.queries"; +import { getPageComments } from "../../graphql/queries/page.queries"; + import type { CreateCommentMutation, CreateCommentMutationVariables, } from "../../graphql/api-types.gen"; -import { createComment } from "../../graphql/queries/comment.queries"; -import { getPageComments } from "../../graphql/queries/page.queries"; +import type { EntityId } from "@blockprotocol/type-system"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; export const useCreateComment = (pageId: EntityId) => { const [createCommentFn, { loading }] = useMutation< diff --git a/apps/hash-frontend/src/components/hooks/use-create-page.ts b/apps/hash-frontend/src/components/hooks/use-create-page.ts index 8020a62c860..ac1f214a34b 100644 --- a/apps/hash-frontend/src/components/hooks/use-create-page.ts +++ b/apps/hash-frontend/src/components/hooks/use-create-page.ts @@ -1,22 +1,24 @@ import { useMutation } from "@apollo/client"; -import type { WebId } from "@blockprotocol/type-system"; +import { useRouter } from "next/router"; +import { useCallback } from "react"; + import { extractEntityUuidFromEntityId, extractWebIdFromEntityId, } from "@blockprotocol/type-system"; -import { useRouter } from "next/router"; -import { useCallback } from "react"; -import type { - CreatePageMutation, - CreatePageMutationVariables, -} from "../../graphql/api-types.gen"; import { PageType } from "../../graphql/api-types.gen"; import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; import { createPage } from "../../graphql/queries/page.queries"; import { constructPageRelativeUrl } from "../../lib/routes"; import { getAccountPagesVariables } from "../../shared/account-pages-variables"; +import type { + CreatePageMutation, + CreatePageMutationVariables, +} from "../../graphql/api-types.gen"; +import type { WebId } from "@blockprotocol/type-system"; + export const useCreatePage = ({ shortname, webId, diff --git a/apps/hash-frontend/src/components/hooks/use-create-sub-page.ts b/apps/hash-frontend/src/components/hooks/use-create-sub-page.ts index 2663e09cc2d..a7dd7a4f7ee 100644 --- a/apps/hash-frontend/src/components/hooks/use-create-sub-page.ts +++ b/apps/hash-frontend/src/components/hooks/use-create-sub-page.ts @@ -1,20 +1,22 @@ import { useMutation } from "@apollo/client"; -import type { EntityId, WebId } from "@blockprotocol/type-system"; -import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; import { useRouter } from "next/router"; import { useCallback } from "react"; +import { extractEntityUuidFromEntityId } from "@blockprotocol/type-system"; + +import { PageType } from "../../graphql/api-types.gen"; +import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; +import { createPage, setParentPage } from "../../graphql/queries/page.queries"; +import { constructPageRelativeUrl } from "../../lib/routes"; +import { getAccountPagesVariables } from "../../shared/account-pages-variables"; + import type { CreatePageMutation, CreatePageMutationVariables, SetParentPageMutation, SetParentPageMutationVariables, } from "../../graphql/api-types.gen"; -import { PageType } from "../../graphql/api-types.gen"; -import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; -import { createPage, setParentPage } from "../../graphql/queries/page.queries"; -import { constructPageRelativeUrl } from "../../lib/routes"; -import { getAccountPagesVariables } from "../../shared/account-pages-variables"; +import type { EntityId, WebId } from "@blockprotocol/type-system"; export const useCreateSubPage = ({ shortname, diff --git a/apps/hash-frontend/src/components/hooks/use-default-state.tsx b/apps/hash-frontend/src/components/hooks/use-default-state.tsx index 5e0f3d578b3..6f2385bee93 100644 --- a/apps/hash-frontend/src/components/hooks/use-default-state.tsx +++ b/apps/hash-frontend/src/components/hooks/use-default-state.tsx @@ -1,7 +1,8 @@ import { useLocalStorage } from "@mantine/hooks"; -import type { Dispatch, SetStateAction } from "react"; import { useCallback, useState } from "react"; +import type { Dispatch, SetStateAction } from "react"; + export const useDefaultState = < T extends object | number | string | boolean | null | undefined, >( diff --git a/apps/hash-frontend/src/components/hooks/use-delete-comment.ts b/apps/hash-frontend/src/components/hooks/use-delete-comment.ts index cf8adbb5959..ce0d2507985 100644 --- a/apps/hash-frontend/src/components/hooks/use-delete-comment.ts +++ b/apps/hash-frontend/src/components/hooks/use-delete-comment.ts @@ -1,13 +1,14 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; import { useCallback } from "react"; +import { deleteComment } from "../../graphql/queries/comment.queries"; +import { getPageComments } from "../../graphql/queries/page.queries"; + import type { DeleteCommentMutation, DeleteCommentMutationVariables, } from "../../graphql/api-types.gen"; -import { deleteComment } from "../../graphql/queries/comment.queries"; -import { getPageComments } from "../../graphql/queries/page.queries"; +import type { EntityId } from "@blockprotocol/type-system"; export const useDeleteComment = (pageId: EntityId) => { const [deleteCommentFn, { loading }] = useMutation< diff --git a/apps/hash-frontend/src/components/hooks/use-entity-by-id.ts b/apps/hash-frontend/src/components/hooks/use-entity-by-id.ts index 81e2dfd1609..d1205293023 100644 --- a/apps/hash-frontend/src/components/hooks/use-entity-by-id.ts +++ b/apps/hash-frontend/src/components/hooks/use-entity-by-id.ts @@ -1,5 +1,6 @@ import { useQuery } from "@apollo/client"; -import type { EntityRootType, Subgraph } from "@blockprotocol/graph"; +import { useMemo } from "react"; + import { type EntityId, splitEntityId } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse, @@ -7,16 +8,16 @@ import { } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { queryEntitySubgraphQuery } from "@local/hash-isomorphic-utils/graphql/queries/entity.queries"; -import type { - EntityTraversalPath, - GraphResolveDepths, -} from "@rust/hash-graph-store/types"; -import { useMemo } from "react"; import type { QueryEntitySubgraphQuery, QueryEntitySubgraphQueryVariables, } from "../../graphql/api-types.gen"; +import type { EntityRootType, Subgraph } from "@blockprotocol/graph"; +import type { + EntityTraversalPath, + GraphResolveDepths, +} from "@rust/hash-graph-store/types"; export const useEntityById = ({ entityId, diff --git a/apps/hash-frontend/src/components/hooks/use-font-loaded-callback.ts b/apps/hash-frontend/src/components/hooks/use-font-loaded-callback.ts index 119000c9776..bd7a2bb47b8 100644 --- a/apps/hash-frontend/src/components/hooks/use-font-loaded-callback.ts +++ b/apps/hash-frontend/src/components/hooks/use-font-loaded-callback.ts @@ -1,7 +1,8 @@ import { useLayoutEffect } from "react"; -import type { FontFace } from "use-font-face-observer"; import useFontFaceObserver from "use-font-face-observer"; +import type { FontFace } from "use-font-face-observer"; + export const useFontLoadedCallback = ( fontList: FontFace[], callback?: () => void, diff --git a/apps/hash-frontend/src/components/hooks/use-get-account-id-for-shortname.ts b/apps/hash-frontend/src/components/hooks/use-get-account-id-for-shortname.ts index 65932652b55..8db52515b97 100644 --- a/apps/hash-frontend/src/components/hooks/use-get-account-id-for-shortname.ts +++ b/apps/hash-frontend/src/components/hooks/use-get-account-id-for-shortname.ts @@ -1,10 +1,12 @@ -import type { WebId } from "@blockprotocol/type-system"; -import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { useMemo } from "react"; +import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; + import { useOrgs } from "./use-orgs"; import { useUsers } from "./use-users"; +import type { WebId } from "@blockprotocol/type-system"; + export const useGetWebIdForShortname = ( shortname: string | undefined, ): { loading: boolean; webId: WebId | undefined } => { diff --git a/apps/hash-frontend/src/components/hooks/use-get-block-protocol-blocks.ts b/apps/hash-frontend/src/components/hooks/use-get-block-protocol-blocks.ts index 8b5f92430eb..289cfb485cd 100644 --- a/apps/hash-frontend/src/components/hooks/use-get-block-protocol-blocks.ts +++ b/apps/hash-frontend/src/components/hooks/use-get-block-protocol-blocks.ts @@ -1,8 +1,9 @@ import { useQuery } from "@apollo/client"; -import type { GetBlockProtocolBlocksQuery } from "../../graphql/api-types.gen"; import { getBlockProtocolBlocksQuery } from "../../graphql/queries/block.queries"; +import type { GetBlockProtocolBlocksQuery } from "../../graphql/api-types.gen"; + export const useGetBlockProtocolBlocks = () => { const { data, error } = useQuery( getBlockProtocolBlocksQuery, diff --git a/apps/hash-frontend/src/components/hooks/use-get-owner-for-entity.ts b/apps/hash-frontend/src/components/hooks/use-get-owner-for-entity.ts index a43dbeab9bb..aec86da3c59 100644 --- a/apps/hash-frontend/src/components/hooks/use-get-owner-for-entity.ts +++ b/apps/hash-frontend/src/components/hooks/use-get-owner-for-entity.ts @@ -1,11 +1,13 @@ -import type { EntityId, WebId } from "@blockprotocol/type-system"; -import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import * as Sentry from "@sentry/nextjs"; import { useCallback } from "react"; +import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; + import { useOrgs } from "./use-orgs"; import { useUsers } from "./use-users"; +import type { EntityId, WebId } from "@blockprotocol/type-system"; + export const useGetOwnerForEntity = () => { /* * This is a simple way of getting all users and orgs to find an entity's owner's name diff --git a/apps/hash-frontend/src/components/hooks/use-hash-instance.ts b/apps/hash-frontend/src/components/hooks/use-hash-instance.ts index 9103abfcb0f..490389729f2 100644 --- a/apps/hash-frontend/src/components/hooks/use-hash-instance.ts +++ b/apps/hash-frontend/src/components/hooks/use-hash-instance.ts @@ -1,16 +1,18 @@ import { useQuery } from "@apollo/client"; +import { useMemo } from "react"; + import { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { Simplified } from "@local/hash-isomorphic-utils/simplify-properties"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; -import type { HASHInstance } from "@local/hash-isomorphic-utils/system-types/hashinstance"; -import { useMemo } from "react"; + +import { getHashInstanceSettings } from "../../graphql/queries/knowledge/hash-instance.queries"; import type { EnabledIntegrations, GetHashInstanceSettingsQueryQuery, GetHashInstanceSettingsQueryQueryVariables, } from "../../graphql/api-types.gen"; -import { getHashInstanceSettings } from "../../graphql/queries/knowledge/hash-instance.queries"; +import type { Simplified } from "@local/hash-isomorphic-utils/simplify-properties"; +import type { HASHInstance } from "@local/hash-isomorphic-utils/system-types/hashinstance"; export const useHashInstance = (): { loading: boolean; diff --git a/apps/hash-frontend/src/components/hooks/use-orgs-with-links.ts b/apps/hash-frontend/src/components/hooks/use-orgs-with-links.ts index 58f0a7e35e3..e0b0fc8a92a 100644 --- a/apps/hash-frontend/src/components/hooks/use-orgs-with-links.ts +++ b/apps/hash-frontend/src/components/hooks/use-orgs-with-links.ts @@ -1,22 +1,24 @@ -import type { ApolloQueryResult } from "@apollo/client"; import { useQuery } from "@apollo/client"; +import { useMemo } from "react"; + import { getRoots } from "@blockprotocol/graph/stdlib"; -import type { ActorGroupEntityUuid } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes, generateVersionedUrlMatchingFilter, } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import { useMemo } from "react"; + +import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; +import { constructOrg, isEntityOrgEntity } from "../../lib/user-and-org"; import type { QueryEntitySubgraphQuery, QueryEntitySubgraphQueryVariables, } from "../../graphql/api-types.gen"; -import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; import type { Org } from "../../lib/user-and-org"; -import { constructOrg, isEntityOrgEntity } from "../../lib/user-and-org"; +import type { ApolloQueryResult } from "@apollo/client"; +import type { ActorGroupEntityUuid } from "@blockprotocol/type-system"; const emptyOrgsArray: Org[] = []; diff --git a/apps/hash-frontend/src/components/hooks/use-orgs.ts b/apps/hash-frontend/src/components/hooks/use-orgs.ts index c8fdf3ae22f..b13dd7c970e 100644 --- a/apps/hash-frontend/src/components/hooks/use-orgs.ts +++ b/apps/hash-frontend/src/components/hooks/use-orgs.ts @@ -1,19 +1,21 @@ -import type { ApolloQueryResult } from "@apollo/client"; import { useQuery } from "@apollo/client"; + import { deserializeQueryEntitiesResponse } from "@local/hash-graph-sdk/entity"; import { convertBpFilterToGraphFilter } from "@local/hash-graph-sdk/filter"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; +import { queryEntitiesQuery } from "../../graphql/queries/knowledge/entity.queries"; +import { constructMinimalOrg, isEntityOrgEntity } from "../../lib/user-and-org"; +import { entityHasEntityTypeByVersionedUrlFilter } from "../../shared/filters"; +import { useMemoCompare } from "../../shared/use-memo-compare"; + import type { QueryEntitiesQuery, QueryEntitiesQueryVariables, } from "../../graphql/api-types.gen"; -import { queryEntitiesQuery } from "../../graphql/queries/knowledge/entity.queries"; import type { MinimalOrg } from "../../lib/user-and-org"; -import { constructMinimalOrg, isEntityOrgEntity } from "../../lib/user-and-org"; -import { entityHasEntityTypeByVersionedUrlFilter } from "../../shared/filters"; -import { useMemoCompare } from "../../shared/use-memo-compare"; +import type { ApolloQueryResult } from "@apollo/client"; /** * Retrieves a list of organizations diff --git a/apps/hash-frontend/src/components/hooks/use-page-comments.ts b/apps/hash-frontend/src/components/hooks/use-page-comments.ts index 8bfb287fdca..e329af1a249 100644 --- a/apps/hash-frontend/src/components/hooks/use-page-comments.ts +++ b/apps/hash-frontend/src/components/hooks/use-page-comments.ts @@ -1,17 +1,19 @@ import { useQuery } from "@apollo/client"; -import type { - EntityId, - EntityMetadata, - EntityTemporalMetadata, -} from "@blockprotocol/type-system"; + import { HashEntity } from "@local/hash-graph-sdk/entity"; -import type { TextToken } from "@local/hash-isomorphic-utils/types"; + +import { getPageComments } from "../../graphql/queries/page.queries"; import type { GetPageCommentsQuery, GetPageCommentsQueryVariables, } from "../../graphql/api-types.gen"; -import { getPageComments } from "../../graphql/queries/page.queries"; +import type { + EntityId, + EntityMetadata, + EntityTemporalMetadata, +} from "@blockprotocol/type-system"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; export type PageThread = PageComment & { replies: PageComment[]; diff --git a/apps/hash-frontend/src/components/hooks/use-reorder-page.ts b/apps/hash-frontend/src/components/hooks/use-reorder-page.ts index 8ec7d9c4322..528d6f5fb52 100644 --- a/apps/hash-frontend/src/components/hooks/use-reorder-page.ts +++ b/apps/hash-frontend/src/components/hooks/use-reorder-page.ts @@ -1,15 +1,17 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; -import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; import { useCallback } from "react"; +import { extractWebIdFromEntityId } from "@blockprotocol/type-system"; + +import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; +import { setParentPage } from "../../graphql/queries/page.queries"; +import { getAccountPagesVariables } from "../../shared/account-pages-variables"; + import type { SetParentPageMutation, SetParentPageMutationVariables, } from "../../graphql/api-types.gen"; -import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; -import { setParentPage } from "../../graphql/queries/page.queries"; -import { getAccountPagesVariables } from "../../shared/account-pages-variables"; +import type { EntityId } from "@blockprotocol/type-system"; export const useReorderPage = () => { const [setParentPageFn, { loading }] = useMutation< diff --git a/apps/hash-frontend/src/components/hooks/use-resolve-comment.ts b/apps/hash-frontend/src/components/hooks/use-resolve-comment.ts index 4f7313bc198..84999a5e1f3 100644 --- a/apps/hash-frontend/src/components/hooks/use-resolve-comment.ts +++ b/apps/hash-frontend/src/components/hooks/use-resolve-comment.ts @@ -1,13 +1,14 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; import { useCallback } from "react"; +import { resolveComment } from "../../graphql/queries/comment.queries"; +import { getPageComments } from "../../graphql/queries/page.queries"; + import type { ResolveCommentMutation, ResolveCommentMutationVariables, } from "../../graphql/api-types.gen"; -import { resolveComment } from "../../graphql/queries/comment.queries"; -import { getPageComments } from "../../graphql/queries/page.queries"; +import type { EntityId } from "@blockprotocol/type-system"; export const useResolveComment = (pageId: EntityId) => { const [resolveCommentFn, { loading }] = useMutation< diff --git a/apps/hash-frontend/src/components/hooks/use-shortname-input.ts b/apps/hash-frontend/src/components/hooks/use-shortname-input.ts index 5a3f9e753d7..f16ff9d49e9 100644 --- a/apps/hash-frontend/src/components/hooks/use-shortname-input.ts +++ b/apps/hash-frontend/src/components/hooks/use-shortname-input.ts @@ -1,11 +1,12 @@ import { useApolloClient } from "@apollo/client"; import { useCallback, useState } from "react"; +import { isShortnameTaken as isShortnameTakenQuery } from "../../graphql/queries/user.queries"; + import type { IsShortnameTakenQuery, QueryIsShortnameTakenArgs, } from "../../graphql/api-types.gen"; -import { isShortnameTaken as isShortnameTakenQuery } from "../../graphql/queries/user.queries"; type ShortnameErrorCode = | "IS_EMPTY" diff --git a/apps/hash-frontend/src/components/hooks/use-snackbar.ts b/apps/hash-frontend/src/components/hooks/use-snackbar.ts index 3bdffff91bd..30475abda9a 100644 --- a/apps/hash-frontend/src/components/hooks/use-snackbar.ts +++ b/apps/hash-frontend/src/components/hooks/use-snackbar.ts @@ -1,3 +1,9 @@ +import { + // eslint-disable-next-line no-restricted-imports + useSnackbar as useLibSnackbar, +} from "notistack"; +import { useMemo } from "react"; + import type { OptionsObject, ProviderContext, @@ -5,11 +11,6 @@ import type { SnackbarMessage, VariantType, } from "notistack"; -import { - // eslint-disable-next-line no-restricted-imports - useSnackbar as useLibSnackbar, -} from "notistack"; -import { useMemo } from "react"; type EnqueueWithoutVariant = ( message: SnackbarMessage, diff --git a/apps/hash-frontend/src/components/hooks/use-update-authenticated-user.ts b/apps/hash-frontend/src/components/hooks/use-update-authenticated-user.ts index 282fff47212..6e1397596fe 100644 --- a/apps/hash-frontend/src/components/hooks/use-update-authenticated-user.ts +++ b/apps/hash-frontend/src/components/hooks/use-update-authenticated-user.ts @@ -1,27 +1,29 @@ import { useLazyQuery, useMutation } from "@apollo/client"; -import type { EntityRootType } from "@blockprotocol/graph"; +import { useCallback, useState } from "react"; + import { getRoots } from "@blockprotocol/graph/stdlib"; -import type { PropertyPatchOperation } from "@blockprotocol/type-system"; import { typedEntries } from "@local/advanced-types/typed-entries"; -import type { HashEntity } from "@local/hash-graph-sdk/entity"; import { mapGqlSubgraphFieldsFragmentToSubgraph } from "@local/hash-isomorphic-utils/graph-queries"; import { blockProtocolPropertyTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { GraphQLError } from "graphql"; -import { useCallback, useState } from "react"; + +import { updateEntityMutation } from "../../graphql/queries/knowledge/entity.queries"; +import { meQuery } from "../../graphql/queries/user.queries"; +import { useAuthInfo } from "../../pages/shared/auth-info-context"; import type { MeQuery, UpdateEntityMutation, UpdateEntityMutationVariables, } from "../../graphql/api-types.gen"; -import { updateEntityMutation } from "../../graphql/queries/knowledge/entity.queries"; -import { meQuery } from "../../graphql/queries/user.queries"; import type { User } from "../../lib/user-and-org"; -import { useAuthInfo } from "../../pages/shared/auth-info-context"; import type { UserPreferences } from "../../shared/use-user-preferences"; +import type { EntityRootType } from "@blockprotocol/graph"; +import type { PropertyPatchOperation } from "@blockprotocol/type-system"; +import type { HashEntity } from "@local/hash-graph-sdk/entity"; +import type { GraphQLError } from "graphql"; type UpdateAuthenticatedUserParams = { shortname?: string; diff --git a/apps/hash-frontend/src/components/hooks/use-update-comment-text.ts b/apps/hash-frontend/src/components/hooks/use-update-comment-text.ts index 7fdf504ec3e..40391a6ab1c 100644 --- a/apps/hash-frontend/src/components/hooks/use-update-comment-text.ts +++ b/apps/hash-frontend/src/components/hooks/use-update-comment-text.ts @@ -1,14 +1,15 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; -import type { TextToken } from "@local/hash-isomorphic-utils/types"; import { useCallback } from "react"; +import { updateCommentText } from "../../graphql/queries/comment.queries"; +import { getPageComments } from "../../graphql/queries/page.queries"; + import type { UpdateCommentTextMutation, UpdateCommentTextMutationVariables, } from "../../graphql/api-types.gen"; -import { updateCommentText } from "../../graphql/queries/comment.queries"; -import { getPageComments } from "../../graphql/queries/page.queries"; +import type { EntityId } from "@blockprotocol/type-system"; +import type { TextToken } from "@local/hash-isomorphic-utils/types"; export const useUpdateCommentText = (pageId: EntityId) => { const [updatePageCommentTextFn, { loading }] = useMutation< diff --git a/apps/hash-frontend/src/components/hooks/use-update-page-title.ts b/apps/hash-frontend/src/components/hooks/use-update-page-title.ts index 403ea707c38..b33899dcc6c 100644 --- a/apps/hash-frontend/src/components/hooks/use-update-page-title.ts +++ b/apps/hash-frontend/src/components/hooks/use-update-page-title.ts @@ -1,13 +1,14 @@ import { useMutation } from "@apollo/client"; -import type { EntityId } from "@blockprotocol/type-system"; import { useCallback } from "react"; +import { updatePage } from "../../graphql/queries/page.queries"; +import { useGetPageRefetchQueries } from "./shared/get-page-refetch-queries"; + import type { UpdatePageMutation, UpdatePageMutationVariables, } from "../../graphql/api-types.gen"; -import { updatePage } from "../../graphql/queries/page.queries"; -import { useGetPageRefetchQueries } from "./shared/get-page-refetch-queries"; +import type { EntityId } from "@blockprotocol/type-system"; export const useUpdatePageTitle = () => { const [updatePageFn, { loading: updatePageTitleLoading }] = useMutation< diff --git a/apps/hash-frontend/src/components/hooks/use-user-or-org-shortname-by-owned-by-id.ts b/apps/hash-frontend/src/components/hooks/use-user-or-org-shortname-by-owned-by-id.ts index 8b56778000e..36aa21f3824 100644 --- a/apps/hash-frontend/src/components/hooks/use-user-or-org-shortname-by-owned-by-id.ts +++ b/apps/hash-frontend/src/components/hooks/use-user-or-org-shortname-by-owned-by-id.ts @@ -1,9 +1,11 @@ -import type { WebId } from "@blockprotocol/type-system"; -import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; import { useMemo } from "react"; +import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; + import { useUserOrOrg } from "../../shared/use-user-or-org"; +import type { WebId } from "@blockprotocol/type-system"; + export const useUserOrOrgShortnameByWebId = (params: { webId: WebId | null; }) => { diff --git a/apps/hash-frontend/src/components/hooks/use-users-with-links.ts b/apps/hash-frontend/src/components/hooks/use-users-with-links.ts index 92ec17aca45..b24c71c2be4 100644 --- a/apps/hash-frontend/src/components/hooks/use-users-with-links.ts +++ b/apps/hash-frontend/src/components/hooks/use-users-with-links.ts @@ -1,22 +1,24 @@ -import type { ApolloQueryResult } from "@apollo/client"; import { useQuery } from "@apollo/client"; +import { useMemo } from "react"; + import { getRoots } from "@blockprotocol/graph/stdlib"; -import type { ActorEntityUuid } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse } from "@local/hash-graph-sdk/entity"; import { currentTimeInstantTemporalAxes, generateVersionedUrlMatchingFilter, } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import { useMemo } from "react"; + +import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; +import { constructUser, isEntityUserEntity } from "../../lib/user-and-org"; import type { QueryEntitySubgraphQuery, QueryEntitySubgraphQueryVariables, } from "../../graphql/api-types.gen"; -import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; import type { User } from "../../lib/user-and-org"; -import { constructUser, isEntityUserEntity } from "../../lib/user-and-org"; +import type { ApolloQueryResult } from "@apollo/client"; +import type { ActorEntityUuid } from "@blockprotocol/type-system"; /** * Retrieves a specific set of users, with their avatars populated diff --git a/apps/hash-frontend/src/components/hooks/use-users.ts b/apps/hash-frontend/src/components/hooks/use-users.ts index 3f49d60cb00..788a104b3c4 100644 --- a/apps/hash-frontend/src/components/hooks/use-users.ts +++ b/apps/hash-frontend/src/components/hooks/use-users.ts @@ -1,15 +1,11 @@ import { useQuery } from "@apollo/client"; + import { deserializeQueryEntitiesResponse } from "@local/hash-graph-sdk/entity"; import { convertBpFilterToGraphFilter } from "@local/hash-graph-sdk/filter"; import { currentTimeInstantTemporalAxes } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { - QueryEntitiesQuery, - QueryEntitiesQueryVariables, -} from "../../graphql/api-types.gen"; import { queryEntitiesQuery } from "../../graphql/queries/knowledge/entity.queries"; -import type { MinimalUser } from "../../lib/user-and-org"; import { constructMinimalUser, isEntityUserEntity, @@ -17,6 +13,12 @@ import { import { entityHasEntityTypeByVersionedUrlFilter } from "../../shared/filters"; import { useMemoCompare } from "../../shared/use-memo-compare"; +import type { + QueryEntitiesQuery, + QueryEntitiesQueryVariables, +} from "../../graphql/api-types.gen"; +import type { MinimalUser } from "../../lib/user-and-org"; + export const useUsers = (): { loading: boolean; refetch: () => void; diff --git a/apps/hash-frontend/src/components/page-icon.tsx b/apps/hash-frontend/src/components/page-icon.tsx index 119b37e62f1..56d3e6eb7a0 100644 --- a/apps/hash-frontend/src/components/page-icon.tsx +++ b/apps/hash-frontend/src/components/page-icon.tsx @@ -1,12 +1,14 @@ import { faFile } from "@fortawesome/free-regular-svg-icons"; -import { FontAwesomeIcon } from "@hashintel/design-system"; -import type { BoxProps } from "@mui/material"; import { Box } from "@mui/material"; -import type { SizeVariant } from "../shared/edit-emoji-icon-button"; +import { FontAwesomeIcon } from "@hashintel/design-system"; + import { iconVariantSizes } from "../shared/edit-emoji-icon-button"; import { CanvasIcon } from "../shared/icons/canvas-icon"; +import type { SizeVariant } from "../shared/edit-emoji-icon-button"; +import type { BoxProps } from "@mui/material"; + interface PageIconProps { isCanvas?: boolean; icon?: string | null; diff --git a/apps/hash-frontend/src/components/remote-block/add-linked-query-prompt.tsx b/apps/hash-frontend/src/components/remote-block/add-linked-query-prompt.tsx index 29943f8fb56..6092e9e3a28 100644 --- a/apps/hash-frontend/src/components/remote-block/add-linked-query-prompt.tsx +++ b/apps/hash-frontend/src/components/remote-block/add-linked-query-prompt.tsx @@ -1,9 +1,10 @@ import { Box, Typography } from "@mui/material"; -import type { FunctionComponent } from "react"; import { useBlockContext } from "../../pages/shared/block-collection/block-context"; import { Button } from "../../shared/ui"; +import type { FunctionComponent } from "react"; + export const AddLinkedQueryPrompt: FunctionComponent<{ blockIconSrc?: string; blockName: string; diff --git a/apps/hash-frontend/src/components/remote-block/block-renderer.tsx b/apps/hash-frontend/src/components/remote-block/block-renderer.tsx index fd4263c43f3..5fc10433e23 100644 --- a/apps/hash-frontend/src/components/remote-block/block-renderer.tsx +++ b/apps/hash-frontend/src/components/remote-block/block-renderer.tsx @@ -1,9 +1,9 @@ -import type { BlockMetadata, UnknownRecord } from "@blockprotocol/core"; -import type { FunctionComponent, ReactElement } from "react"; - import { CustomElementLoader } from "./block-renderer/custom-element"; import { HtmlLoader } from "./block-renderer/html"; + import type { UnknownBlock } from "./load-remote-block"; +import type { BlockMetadata, UnknownRecord } from "@blockprotocol/core"; +import type { FunctionComponent, ReactElement } from "react"; type BlockRendererProps = { blockSource: UnknownBlock; diff --git a/apps/hash-frontend/src/components/remote-block/block-renderer/custom-element.tsx b/apps/hash-frontend/src/components/remote-block/block-renderer/custom-element.tsx index edad6c2fefe..465cd1c2a79 100644 --- a/apps/hash-frontend/src/components/remote-block/block-renderer/custom-element.tsx +++ b/apps/hash-frontend/src/components/remote-block/block-renderer/custom-element.tsx @@ -1,9 +1,9 @@ import { createComponent } from "@lit-labs/react"; -import type { FunctionComponent } from "react"; // eslint-disable-next-line unicorn/import-style import React, { useLayoutEffect, useRef, useState } from "react"; import type { CustomElementDefinition } from "../util"; +import type { FunctionComponent } from "react"; type CustomElementLoaderProps = { properties: Record; diff --git a/apps/hash-frontend/src/components/remote-block/block-renderer/html.tsx b/apps/hash-frontend/src/components/remote-block/block-renderer/html.tsx index beaff4bea54..a5817feb0c7 100644 --- a/apps/hash-frontend/src/components/remote-block/block-renderer/html.tsx +++ b/apps/hash-frontend/src/components/remote-block/block-renderer/html.tsx @@ -1,7 +1,9 @@ -import type { HtmlBlockDefinition } from "@blockprotocol/core/html"; +import { useEffect, useRef, useState } from "react"; + import { renderHtmlBlock } from "@blockprotocol/core/html"; + +import type { HtmlBlockDefinition } from "@blockprotocol/core/html"; import type { FunctionComponent } from "react"; -import { useEffect, useRef, useState } from "react"; type HtmlElementLoaderProps = { html: HtmlBlockDefinition; diff --git a/apps/hash-frontend/src/components/remote-block/construct-service-module-callbacks.ts b/apps/hash-frontend/src/components/remote-block/construct-service-module-callbacks.ts index 4dfa52d94b7..9fbbde35e05 100644 --- a/apps/hash-frontend/src/components/remote-block/construct-service-module-callbacks.ts +++ b/apps/hash-frontend/src/components/remote-block/construct-service-module-callbacks.ts @@ -1,6 +1,7 @@ -import type { ServiceEmbedderMessageCallbacks } from "@blockprotocol/service"; import { apiOrigin } from "@local/hash-isomorphic-utils/environment"; +import type { ServiceEmbedderMessageCallbacks } from "@blockprotocol/service"; + type ServiceFunction = ServiceEmbedderMessageCallbacks[keyof ServiceEmbedderMessageCallbacks]; diff --git a/apps/hash-frontend/src/components/remote-block/load-remote-block.ts b/apps/hash-frontend/src/components/remote-block/load-remote-block.ts index eb5b8bd4b00..983b567b711 100644 --- a/apps/hash-frontend/src/components/remote-block/load-remote-block.ts +++ b/apps/hash-frontend/src/components/remote-block/load-remote-block.ts @@ -1,9 +1,9 @@ -import type { ReactElement } from "react"; - import { blockDependencies } from "../../../block.dependencies"; import { memoizeFetchFunction } from "../../lib/memoize"; import { crossFrameFetchFn } from "../sandbox/framed-block/util"; +import type { ReactElement } from "react"; + export type UnknownBlock = | string | typeof HTMLElement diff --git a/apps/hash-frontend/src/components/remote-block/remote-block.tsx b/apps/hash-frontend/src/components/remote-block/remote-block.tsx index 5ca64746677..da288c150d5 100644 --- a/apps/hash-frontend/src/components/remote-block/remote-block.tsx +++ b/apps/hash-frontend/src/components/remote-block/remote-block.tsx @@ -1,9 +1,7 @@ -import type { BlockMetadata } from "@blockprotocol/core"; -import type { - BlockGraphProperties, - EntityRootType, - GraphEmbedderMessageCallbacks, -} from "@blockprotocol/graph"; +import { Skeleton } from "@mui/material"; +import { useEffect, useMemo, useRef } from "react"; +import { v4 as uuid } from "uuid"; + import { useGraphEmbedderModule } from "@blockprotocol/graph/react"; import { getOutgoingLinksForEntity, @@ -13,11 +11,6 @@ import { useHookEmbedderModule } from "@blockprotocol/hook/react"; import { useServiceEmbedderModule } from "@blockprotocol/service/react"; import { textualContentPropertyTypeBaseUrl } from "@local/hash-isomorphic-utils/entity-store"; import { blockProtocolLinkEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { SkeletonProps } from "@mui/material"; -import { Skeleton } from "@mui/material"; -import type { FunctionComponent } from "react"; -import { useEffect, useMemo, useRef } from "react"; -import { v4 as uuid } from "uuid"; import { useUserBlocks } from "../../blocks/user-blocks"; import { AddLinkedQueryPrompt } from "./add-linked-query-prompt"; @@ -25,6 +18,15 @@ import { BlockRenderer } from "./block-renderer"; import { serviceModuleCallbacks } from "./construct-service-module-callbacks"; import { useRemoteBlock } from "./use-remote-block"; +import type { BlockMetadata } from "@blockprotocol/core"; +import type { + BlockGraphProperties, + EntityRootType, + GraphEmbedderMessageCallbacks, +} from "@blockprotocol/graph"; +import type { SkeletonProps } from "@mui/material"; +import type { FunctionComponent } from "react"; + export type RemoteBlockProps = { graphCallbacks: Omit< /** @todo-0.3 - Add these back */ diff --git a/apps/hash-frontend/src/components/remote-block/use-remote-block.ts b/apps/hash-frontend/src/components/remote-block/use-remote-block.ts index 2e4255dc048..88373802e55 100644 --- a/apps/hash-frontend/src/components/remote-block/use-remote-block.ts +++ b/apps/hash-frontend/src/components/remote-block/use-remote-block.ts @@ -1,12 +1,13 @@ import { useEffect, useRef, useState } from "react"; -import type { UnknownBlock } from "./load-remote-block"; import { loadCrossFrameRemoteBlock, loadRemoteBlock, } from "./load-remote-block"; import { isTopWindow } from "./util"; +import type { UnknownBlock } from "./load-remote-block"; + type UseRemoteBlockHook = { ( url: string, diff --git a/apps/hash-frontend/src/components/sandbox/block-framer/block-framer.tsx b/apps/hash-frontend/src/components/sandbox/block-framer/block-framer.tsx index 3778f89b495..bbb38c2f355 100644 --- a/apps/hash-frontend/src/components/sandbox/block-framer/block-framer.tsx +++ b/apps/hash-frontend/src/components/sandbox/block-framer/block-framer.tsx @@ -1,13 +1,14 @@ -import type { GraphEmbedderMessageCallbacks } from "@blockprotocol/graph"; -import type { PropertyObject } from "@blockprotocol/type-system"; -import type { FunctionComponent } from "react"; import { useCallback, useEffect, useMemo, useRef } from "react"; import { v4 as uuid } from "uuid"; import { memoizeFetchFunction } from "../../../lib/memoize"; -import type { FetchEmbedCodeFn } from "../../block-loader/fetch-embed-code"; import { ResizingIFrame } from "../resizing-iframe/resizing-iframe"; + +import type { FetchEmbedCodeFn } from "../../block-loader/fetch-embed-code"; import type { MessageFromBlockFramer, MessageFromFramedBlock } from "../types"; +import type { GraphEmbedderMessageCallbacks } from "@blockprotocol/graph"; +import type { PropertyObject } from "@blockprotocol/type-system"; +import type { FunctionComponent } from "react"; export type CrossFrameProxyProps = GraphEmbedderMessageCallbacks & { blockProperties: PropertyObject; diff --git a/apps/hash-frontend/src/components/sandbox/framed-block/framed-block.tsx b/apps/hash-frontend/src/components/sandbox/framed-block/framed-block.tsx index 0bc367d339b..e7bfb851d83 100644 --- a/apps/hash-frontend/src/components/sandbox/framed-block/framed-block.tsx +++ b/apps/hash-frontend/src/components/sandbox/framed-block/framed-block.tsx @@ -1,20 +1,20 @@ import "iframe-resizer/js/iframeResizer.contentWindow"; - -import type { GraphEmbedderMessageCallbacks } from "@blockprotocol/graph"; -import type { Entity } from "@blockprotocol/type-system"; -import type * as Sentry from "@sentry/react"; -import type { FunctionComponent } from "react"; import { useCallback, useEffect, useState } from "react"; -import type { FetchEmbedCodeFn } from "../../block-loader/fetch-embed-code"; // import { ErrorBlock } from "../../error-block/error-block"; import { BlockLoadingIndicator, // RemoteBlock, } from "../../remote-block/remote-block"; -import type { MessageFromBlockFramer } from "../types"; import { sendMessage, settlePromiseFromResponse } from "./util"; +import type { FetchEmbedCodeFn } from "../../block-loader/fetch-embed-code"; +import type { MessageFromBlockFramer } from "../types"; +import type { GraphEmbedderMessageCallbacks } from "@blockprotocol/graph"; +import type { Entity } from "@blockprotocol/type-system"; +import type * as Sentry from "@sentry/react"; +import type { FunctionComponent } from "react"; + const params = new URL(window.location.href).searchParams; export const FramedBlock: FunctionComponent = () => { diff --git a/apps/hash-frontend/src/components/sandbox/framed-block/index.html b/apps/hash-frontend/src/components/sandbox/framed-block/index.html index e468f962155..791e2cc3af1 100644 --- a/apps/hash-frontend/src/components/sandbox/framed-block/index.html +++ b/apps/hash-frontend/src/components/sandbox/framed-block/index.html @@ -1,4 +1,4 @@ - + diff --git a/apps/hash-frontend/src/components/sandbox/resizing-iframe/resizing-iframe.tsx b/apps/hash-frontend/src/components/sandbox/resizing-iframe/resizing-iframe.tsx index 9fdbeae8704..c9bff4cd4ac 100644 --- a/apps/hash-frontend/src/components/sandbox/resizing-iframe/resizing-iframe.tsx +++ b/apps/hash-frontend/src/components/sandbox/resizing-iframe/resizing-iframe.tsx @@ -1,7 +1,8 @@ import { iframeResizer as iFrameResizer } from "iframe-resizer"; -import type { DetailedHTMLProps, IframeHTMLAttributes } from "react"; import { forwardRef, useEffect } from "react"; +import type { DetailedHTMLProps, IframeHTMLAttributes } from "react"; + /** * @todo expose the unused functions to component consumers, or use them here, * or remove the properties from the type. diff --git a/apps/hash-frontend/src/components/sandbox/types.ts b/apps/hash-frontend/src/components/sandbox/types.ts index 559e9e2ff0c..ef53a9c2168 100644 --- a/apps/hash-frontend/src/components/sandbox/types.ts +++ b/apps/hash-frontend/src/components/sandbox/types.ts @@ -1,6 +1,5 @@ -import type { GraphEmbedderMessageCallbacks } from "@blockprotocol/graph"; - import type { FetchEmbedCodeFn } from "../block-loader/fetch-embed-code"; +import type { GraphEmbedderMessageCallbacks } from "@blockprotocol/graph"; export type MessageFromFramedBlock = { requestId: string; diff --git a/apps/hash-frontend/src/contexts/collab-position-context.tsx b/apps/hash-frontend/src/contexts/collab-position-context.tsx index ed962103c58..8565273f48c 100644 --- a/apps/hash-frontend/src/contexts/collab-position-context.tsx +++ b/apps/hash-frontend/src/contexts/collab-position-context.tsx @@ -1,6 +1,7 @@ -import type { CollabPosition } from "@local/hash-isomorphic-utils/collab"; import { createContext, useContext } from "react"; +import type { CollabPosition } from "@local/hash-isomorphic-utils/collab"; + const CollabPositionContext = createContext([]); const { Provider, Consumer } = CollabPositionContext; diff --git a/apps/hash-frontend/src/graphql/queries/knowledge/org.queries.ts b/apps/hash-frontend/src/graphql/queries/knowledge/org.queries.ts index 5897a5d52f8..f72309a5930 100644 --- a/apps/hash-frontend/src/graphql/queries/knowledge/org.queries.ts +++ b/apps/hash-frontend/src/graphql/queries/knowledge/org.queries.ts @@ -18,8 +18,16 @@ export const acceptOrgInvitationMutation = gql` `; export const inviteUserToOrgMutation = gql` - mutation inviteUserToOrg($orgWebId: WebId!, $userEmail: String, $userShortname: String) { - inviteUserToOrg(orgWebId: $orgWebId, userEmail: $userEmail, userShortname: $userShortname) + mutation inviteUserToOrg( + $orgWebId: WebId! + $userEmail: String + $userShortname: String + ) { + inviteUserToOrg( + orgWebId: $orgWebId + userEmail: $userEmail + userShortname: $userShortname + ) } `; diff --git a/apps/hash-frontend/src/graphql/queries/ontology/data-type.queries.ts b/apps/hash-frontend/src/graphql/queries/ontology/data-type.queries.ts index 62a682206e2..72e726fb5f4 100644 --- a/apps/hash-frontend/src/graphql/queries/ontology/data-type.queries.ts +++ b/apps/hash-frontend/src/graphql/queries/ontology/data-type.queries.ts @@ -30,7 +30,11 @@ export const createDataTypeMutation = gql` $dataType: ConstructDataTypeParams! $conversions: DataTypeDirectConversionsMap ) { - createDataType(webId: $webId, dataType: $dataType, conversions: $conversions) + createDataType( + webId: $webId + dataType: $dataType + conversions: $conversions + ) } `; @@ -40,6 +44,10 @@ export const updateDataTypeMutation = gql` $dataType: ConstructDataTypeParams! $conversions: DataTypeDirectConversionsMap ) { - updateDataType(dataTypeId: $dataTypeId, dataType: $dataType, conversions: $conversions) + updateDataType( + dataTypeId: $dataTypeId + dataType: $dataType + conversions: $conversions + ) } `; diff --git a/apps/hash-frontend/src/graphql/queries/user.queries.ts b/apps/hash-frontend/src/graphql/queries/user.queries.ts index cb47ed5f0b6..d266ad9ba84 100644 --- a/apps/hash-frontend/src/graphql/queries/user.queries.ts +++ b/apps/hash-frontend/src/graphql/queries/user.queries.ts @@ -1,4 +1,5 @@ import { gql } from "@apollo/client"; + import { subgraphFieldsFragment } from "@local/hash-isomorphic-utils/graphql/queries/subgraph"; export const isShortnameTaken = gql` diff --git a/apps/hash-frontend/src/lib/routes.ts b/apps/hash-frontend/src/lib/routes.ts index c0a34aed0d5..3831dce96ac 100644 --- a/apps/hash-frontend/src/lib/routes.ts +++ b/apps/hash-frontend/src/lib/routes.ts @@ -1,7 +1,7 @@ -import type { EntityId } from "@blockprotocol/type-system"; - import { getBlockDomId } from "../shared/get-block-dom-id"; +import type { EntityId } from "@blockprotocol/type-system"; + export const constructPageRelativeUrl = (params: { workspaceShortname: string; pageEntityUuid: string; diff --git a/apps/hash-frontend/src/lib/user-and-org.ts b/apps/hash-frontend/src/lib/user-and-org.ts index b5c48e061be..46ae09b8cfb 100644 --- a/apps/hash-frontend/src/lib/user-and-org.ts +++ b/apps/hash-frontend/src/lib/user-and-org.ts @@ -1,8 +1,3 @@ -import type { - EntityRootType, - LinkEntityAndRightEntity, - Subgraph, -} from "@blockprotocol/graph"; import { getIncomingLinkAndSourceEntities, getOutgoingLinkAndTargetEntities, @@ -11,21 +6,12 @@ import { intervalCompareWithInterval, intervalForTimestamp, } from "@blockprotocol/graph/stdlib"; -import type { - BaseUrl, - Entity, - LinkEntity, - UserId, - WebId, -} from "@blockprotocol/type-system"; import { currentTimestamp, extractBaseUrl, extractWebIdFromEntityId, } from "@blockprotocol/type-system"; -import type { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; import { getFirstEntityRevision } from "@local/hash-isomorphic-utils/entity"; -import type { FeatureFlag } from "@local/hash-isomorphic-utils/feature-flags"; import { systemEntityTypes, systemLinkEntityTypes, @@ -35,6 +21,22 @@ import { isInvitationByShortname, } from "@local/hash-isomorphic-utils/organization"; import { simplifyProperties } from "@local/hash-isomorphic-utils/simplify-properties"; + +import type { UserPreferences } from "../shared/use-user-preferences"; +import type { + EntityRootType, + LinkEntityAndRightEntity, + Subgraph, +} from "@blockprotocol/graph"; +import type { + BaseUrl, + Entity, + LinkEntity, + UserId, + WebId, +} from "@blockprotocol/type-system"; +import type { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; +import type { FeatureFlag } from "@local/hash-isomorphic-utils/feature-flags"; import type { ImageFile } from "@local/hash-isomorphic-utils/system-types/imagefile"; import type { HasBio, @@ -48,8 +50,6 @@ import type { import type { User as UserEntity } from "@local/hash-isomorphic-utils/system-types/user"; import type { VerifiableIdentityAddress } from "@ory/client"; -import type { UserPreferences } from "../shared/use-user-preferences"; - export const constructMinimalOrg = (params: { orgEntity: Entity; }): MinimalOrg => { diff --git a/apps/hash-frontend/src/middleware/return-types-as-json.ts b/apps/hash-frontend/src/middleware/return-types-as-json.ts index d68803afb87..bc39da0a2cf 100644 --- a/apps/hash-frontend/src/middleware/return-types-as-json.ts +++ b/apps/hash-frontend/src/middleware/return-types-as-json.ts @@ -1,9 +1,6 @@ -import type { - DataType, - EntityType, - PropertyType, - VersionedUrl, -} from "@blockprotocol/type-system"; +import { NextResponse } from "next/server"; +import stringify from "safe-stable-stringify"; + import { apiGraphQLEndpoint, frontendUrl, @@ -12,10 +9,8 @@ import { type SystemTypeWebShortname, systemTypeWebShortnames, } from "@local/hash-isomorphic-utils/ontology-types"; -import type { GraphQLError } from "graphql"; -import type { NextRequest } from "next/server"; -import { NextResponse } from "next/server"; -import stringify from "safe-stable-stringify"; + +import { generateQueryArgs } from "./return-types-as-json/generate-query-args"; import type { QueryDataTypesQuery, @@ -25,7 +20,14 @@ import type { QueryPropertyTypesQuery, QueryPropertyTypesQueryVariables, } from "../graphql/api-types.gen"; -import { generateQueryArgs } from "./return-types-as-json/generate-query-args"; +import type { + DataType, + EntityType, + PropertyType, + VersionedUrl, +} from "@blockprotocol/type-system"; +import type { GraphQLError } from "graphql"; +import type { NextRequest } from "next/server"; const generateErrorResponse = ( status: 400 | 401 | 404 | 500, diff --git a/apps/hash-frontend/src/middleware/return-types-as-json/generate-query-args.ts b/apps/hash-frontend/src/middleware/return-types-as-json/generate-query-args.ts index 2a6a0d23af0..a22aa0cc39a 100644 --- a/apps/hash-frontend/src/middleware/return-types-as-json/generate-query-args.ts +++ b/apps/hash-frontend/src/middleware/return-types-as-json/generate-query-args.ts @@ -1,15 +1,16 @@ -import type { VersionedUrl } from "@blockprotocol/type-system"; import { fullTransactionTimeAxis } from "@local/hash-isomorphic-utils/graph-queries"; -import type { DocumentNode } from "graphql"; + +import { queryDataTypesQuery } from "../../graphql/queries/ontology/data-type.queries"; +import { queryEntityTypesQuery } from "../../graphql/queries/ontology/entity-type.queries"; +import { queryPropertyTypesQuery } from "../../graphql/queries/ontology/property-type.queries"; import type { QueryDataTypesQueryVariables, QueryEntityTypesQueryVariables, QueryPropertyTypesQueryVariables, } from "../../graphql/api-types.gen"; -import { queryDataTypesQuery } from "../../graphql/queries/ontology/data-type.queries"; -import { queryEntityTypesQuery } from "../../graphql/queries/ontology/entity-type.queries"; -import { queryPropertyTypesQuery } from "../../graphql/queries/ontology/property-type.queries"; +import type { VersionedUrl } from "@blockprotocol/type-system"; +import type { DocumentNode } from "graphql"; /** * Return the internal query string from a gql-tagged query, i.e. gql`string` -> string diff --git a/apps/hash-frontend/src/pages/404.page.tsx b/apps/hash-frontend/src/pages/404.page.tsx index 54808a8de51..ed4c67b74a8 100644 --- a/apps/hash-frontend/src/pages/404.page.tsx +++ b/apps/hash-frontend/src/pages/404.page.tsx @@ -1,10 +1,11 @@ -import type { ErrorProps } from "next/error"; import { NextSeo } from "next-seo"; -import type { NextPageWithLayout } from "../shared/layout"; import { getLayoutWithHeader } from "../shared/layout"; import { NotFound } from "./shared/not-found"; +import type { NextPageWithLayout } from "../shared/layout"; +import type { ErrorProps } from "next/error"; + const NotFoundPage: NextPageWithLayout = () => { return ( <> diff --git a/apps/hash-frontend/src/pages/@/[shortname].page.tsx b/apps/hash-frontend/src/pages/@/[shortname].page.tsx index 88460b8d0c2..e02c9d418ac 100644 --- a/apps/hash-frontend/src/pages/@/[shortname].page.tsx +++ b/apps/hash-frontend/src/pages/@/[shortname].page.tsx @@ -1,14 +1,11 @@ import { useQuery } from "@apollo/client"; +import { useRouter } from "next/router"; +import { useCallback, useMemo, useState } from "react"; + import { getEntityTypeAndDescendantsById, getRoots, } from "@blockprotocol/graph/stdlib"; -import type { - BaseUrl, - DataTypeWithMetadata, - EntityTypeWithMetadata, - PropertyTypeWithMetadata, -} from "@blockprotocol/type-system"; import { extractBaseUrl } from "@blockprotocol/type-system"; import { deserializeQueryEntitySubgraphResponse } from "@local/hash-graph-sdk/entity"; import { @@ -18,19 +15,7 @@ import { } from "@local/hash-isomorphic-utils/graph-queries"; import { systemEntityTypes } from "@local/hash-isomorphic-utils/ontology-type-ids"; import { pluralize } from "@local/hash-isomorphic-utils/pluralize"; -import { useRouter } from "next/router"; -import { useCallback, useMemo, useState } from "react"; -import type { - QueryDataTypesQuery, - QueryDataTypesQueryVariables, - QueryEntitySubgraphQuery, - QueryEntitySubgraphQueryVariables, - QueryEntityTypesQuery, - QueryEntityTypesQueryVariables, - QueryPropertyTypesQuery, - QueryPropertyTypesQueryVariables, -} from "../../graphql/api-types.gen"; import { queryEntitySubgraphQuery } from "../../graphql/queries/knowledge/entity.queries"; import { queryDataTypesQuery } from "../../graphql/queries/ontology/data-type.queries"; import { queryEntityTypesQuery } from "../../graphql/queries/ontology/entity-type.queries"; @@ -41,7 +26,6 @@ import { isEntityUserEntity, } from "../../lib/user-and-org"; import { useLatestEntityTypesOptional } from "../../shared/entity-types-context/hooks"; -import type { NextPageWithLayout } from "../../shared/layout"; import { getLayoutWithSidebar } from "../../shared/layout"; import { useUserOrOrg } from "../../shared/use-user-or-org"; import { NotFound } from "../shared/not-found"; @@ -49,9 +33,27 @@ import { useEnabledFeatureFlags } from "../shared/use-enabled-feature-flags"; import { EditUserProfileInfoModal } from "./[shortname].page/edit-user-profile-info-modal"; import { ProfilePageContent } from "./[shortname].page/profile-page-content"; import { ProfilePageHeader } from "./[shortname].page/profile-page-header"; -import type { ProfilePageTab } from "./[shortname].page/util"; import { parseProfilePageUrlQueryParams } from "./[shortname].page/util"; +import type { + QueryDataTypesQuery, + QueryDataTypesQueryVariables, + QueryEntitySubgraphQuery, + QueryEntitySubgraphQueryVariables, + QueryEntityTypesQuery, + QueryEntityTypesQueryVariables, + QueryPropertyTypesQuery, + QueryPropertyTypesQueryVariables, +} from "../../graphql/api-types.gen"; +import type { NextPageWithLayout } from "../../shared/layout"; +import type { ProfilePageTab } from "./[shortname].page/util"; +import type { + BaseUrl, + DataTypeWithMetadata, + EntityTypeWithMetadata, + PropertyTypeWithMetadata, +} from "@blockprotocol/type-system"; + const ProfilePage: NextPageWithLayout = () => { const router = useRouter(); const { latestEntityTypes } = useLatestEntityTypesOptional(); diff --git a/apps/hash-frontend/src/pages/@/[shortname].page/edit-pinned-entity-types-modal.tsx b/apps/hash-frontend/src/pages/@/[shortname].page/edit-pinned-entity-types-modal.tsx index c1c1bfbc887..31adb98b495 100644 --- a/apps/hash-frontend/src/pages/@/[shortname].page/edit-pinned-entity-types-modal.tsx +++ b/apps/hash-frontend/src/pages/@/[shortname].page/edit-pinned-entity-types-modal.tsx @@ -1,5 +1,10 @@ import { useMutation } from "@apollo/client"; -import type { EntityTypeWithMetadata, WebId } from "@blockprotocol/type-system"; +import { Box, Typography, typographyClasses } from "@mui/material"; +import { useCallback, useEffect, useRef, useState } from "react"; +import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd"; +import { createPortal } from "react-dom"; +import { useFieldArray, useForm } from "react-hook-form"; + import { AsteriskRegularIcon, IconButton, @@ -10,27 +15,9 @@ import { systemEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ModalProps } from "@mui/material"; -import { Box, Typography, typographyClasses } from "@mui/material"; -import type { FunctionComponent, ReactElement } from "react"; -import { useCallback, useEffect, useRef, useState } from "react"; -import type { - DraggableProvided, - DraggingStyle, - NotDraggingStyle, - OnDragEndResponder, -} from "react-beautiful-dnd"; -import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd"; -import { createPortal } from "react-dom"; -import { useFieldArray, useForm } from "react-hook-form"; import { useBlockProtocolCreateEntityType } from "../../../components/hooks/block-protocol-functions/ontology/use-block-protocol-create-entity-type"; -import type { - UpdateEntityMutation, - UpdateEntityMutationVariables, -} from "../../../graphql/api-types.gen"; import { updateEntityMutation } from "../../../graphql/queries/knowledge/entity.queries"; -import type { Org, User } from "../../../lib/user-and-org"; import { useLatestEntityTypesOptional } from "../../../shared/entity-types-context/hooks"; import { generateLinkParameters } from "../../../shared/generate-link-parameters"; import { ArrowUpRightRegularIcon } from "../../../shared/icons/arrow-up-right-regular-icon"; @@ -44,6 +31,21 @@ import { EntityTypeSelector } from "../../shared/entity-type-selector"; import { useActiveWorkspace } from "../../shared/workspace-context"; import { ProfileSectionHeading } from "../[shortname]/shared/profile-section-heading"; +import type { + UpdateEntityMutation, + UpdateEntityMutationVariables, +} from "../../../graphql/api-types.gen"; +import type { Org, User } from "../../../lib/user-and-org"; +import type { EntityTypeWithMetadata, WebId } from "@blockprotocol/type-system"; +import type { ModalProps } from "@mui/material"; +import type { FunctionComponent, ReactElement } from "react"; +import type { + DraggableProvided, + DraggingStyle, + NotDraggingStyle, + OnDragEndResponder, +} from "react-beautiful-dnd"; + /** @see https://github.com/atlassian/react-beautiful-dnd/issues/128#issuecomment-1010053365 */ const useDraggableInPortal = () => { const element = useRef(document.createElement("div")).current; diff --git a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal.tsx b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal.tsx index 7c5907c68f2..661476eece0 100644 --- a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal.tsx +++ b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal.tsx @@ -1,12 +1,14 @@ -import { Modal } from "@hashintel/design-system"; -import type { ModalProps } from "@mui/material"; import { Box } from "@mui/material"; -import type { FunctionComponent } from "react"; -import type { User } from "../../../lib/user-and-org"; +import { Modal } from "@hashintel/design-system"; + import { UserProfileInfoForm } from "./edit-user-profile-info-modal/user-profile-info-form"; import { UserProfileInfoModalHeader } from "./edit-user-profile-info-modal/user-profile-info-modal-header"; +import type { User } from "../../../lib/user-and-org"; +import type { ModalProps } from "@mui/material"; +import type { FunctionComponent } from "react"; + export const EditUserProfileInfoModal: FunctionComponent< Omit & { onClose: () => void; diff --git a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/service-accounts-input.tsx b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/service-accounts-input.tsx index 032f33a8332..1ad81a111ae 100644 --- a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/service-accounts-input.tsx +++ b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/service-accounts-input.tsx @@ -1,24 +1,26 @@ -import { - IconButton, - Select, - TextField, - XMarkRegularIcon, -} from "@hashintel/design-system"; import { Box, outlinedInputClasses, selectClasses, Typography, } from "@mui/material"; -import type { FunctionComponent } from "react"; import { Controller, useFieldArray, useFormContext } from "react-hook-form"; -import type { ServiceAccountKind } from "../../../../lib/user-and-org"; +import { + IconButton, + Select, + TextField, + XMarkRegularIcon, +} from "@hashintel/design-system"; + import { PlusRegularIcon } from "../../../../shared/icons/plus-regular"; import { Button, MenuItem } from "../../../../shared/ui"; -import type { UserProfileFormData } from "./user-profile-info-form"; import { urlRegex } from "./util"; +import type { ServiceAccountKind } from "../../../../lib/user-and-org"; +import type { UserProfileFormData } from "./user-profile-info-form"; +import type { FunctionComponent } from "react"; + const serviceAccountKindOptions: Record = { linkedinAccount: "LinkedIn", twitterAccount: "Twitter", diff --git a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-form.tsx b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-form.tsx index 81378904fb2..90567b7afcf 100644 --- a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-form.tsx +++ b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-form.tsx @@ -1,35 +1,37 @@ import { useMutation } from "@apollo/client"; -import type { WebId } from "@blockprotocol/type-system"; +import { Box, Typography } from "@mui/material"; +import { useCallback, useState } from "react"; +import { Controller, FormProvider, useForm } from "react-hook-form"; + import { Select, TextField } from "@hashintel/design-system"; -import type { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; import { validateDisplayName } from "@local/hash-graph-sdk/user-entity-restrictions"; import { systemEntityTypes, systemLinkEntityTypes, systemPropertyTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import type { ProfileURLPropertyValueWithMetadata } from "@local/hash-isomorphic-utils/system-types/shared"; -import { Box, Typography } from "@mui/material"; -import type { FunctionComponent } from "react"; -import { useCallback, useState } from "react"; -import { Controller, FormProvider, useForm } from "react-hook-form"; import { useBlockProtocolArchiveEntity } from "../../../../components/hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity"; import { useBlockProtocolCreateEntity } from "../../../../components/hooks/block-protocol-functions/knowledge/use-block-protocol-create-entity"; import { useUpdateAuthenticatedUser } from "../../../../components/hooks/use-update-authenticated-user"; +import { updateEntityMutation } from "../../../../graphql/queries/knowledge/entity.queries"; +import { Button, MenuItem } from "../../../../shared/ui"; +import { UrlInput } from "../../../shared/url-input"; +import { ServiceAccountsInput } from "./service-accounts-input"; + import type { UpdateEntityMutation, UpdateEntityMutationVariables, } from "../../../../graphql/api-types.gen"; -import { updateEntityMutation } from "../../../../graphql/queries/knowledge/entity.queries"; import type { ServiceAccountKind, User, UserServiceAccount, } from "../../../../lib/user-and-org"; -import { Button, MenuItem } from "../../../../shared/ui"; -import { UrlInput } from "../../../shared/url-input"; -import { ServiceAccountsInput } from "./service-accounts-input"; +import type { WebId } from "@blockprotocol/type-system"; +import type { HashEntity, HashLinkEntity } from "@local/hash-graph-sdk/entity"; +import type { ProfileURLPropertyValueWithMetadata } from "@local/hash-isomorphic-utils/system-types/shared"; +import type { FunctionComponent } from "react"; export type UserProfileFormServiceAccount = { existingLinkEntity?: HashLinkEntity; diff --git a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-modal-header.tsx b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-modal-header.tsx index 6aa932739b5..7fe90185e33 100644 --- a/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-modal-header.tsx +++ b/apps/hash-frontend/src/pages/@/[shortname].page/edit-user-profile-info-modal/user-profile-info-modal-header.tsx @@ -1,5 +1,8 @@ -import type { WebId } from "@blockprotocol/type-system"; import { faImage } from "@fortawesome/free-regular-svg-icons"; +import { Box, buttonClasses, styled } from "@mui/material"; +import Image from "next/image"; +import { useCallback, useRef, useState } from "react"; + import { Avatar, FontAwesomeIcon, @@ -11,22 +14,21 @@ import { systemEntityTypes, systemLinkEntityTypes, } from "@local/hash-isomorphic-utils/ontology-type-ids"; -import { Box, buttonClasses, styled } from "@mui/material"; -import Image from "next/image"; -import type { ChangeEventHandler, FunctionComponent } from "react"; -import { useCallback, useRef, useState } from "react"; import { useBlockProtocolArchiveEntity } from "../../../../components/hooks/block-protocol-functions/knowledge/use-block-protocol-archive-entity"; -import type { User } from "../../../../lib/user-and-org"; import { useFileUploads } from "../../../../shared/file-upload-context"; import { TrashRegularIcon } from "../../../../shared/icons/trash-regular-icon"; -import type { ButtonProps } from "../../../../shared/ui"; import { Button } from "../../../../shared/ui"; import { useAuthInfo } from "../../../shared/auth-info-context"; import { getImageUrlFromEntityProperties } from "../../../shared/get-file-properties"; import { useUpdateProfileAvatar } from "../../[shortname]/shared/use-update-profile-avatar"; import { leftColumnWidth } from "../util"; +import type { User } from "../../../../lib/user-and-org"; +import type { ButtonProps } from "../../../../shared/ui"; +import type { WebId } from "@blockprotocol/type-system"; +import type { ChangeEventHandler, FunctionComponent } from "react"; + const AvatarButton = styled((props: ButtonProps) => (