Skip to content

Update add evaluation to have create and update paramsΒ #132

@Kzoeps

Description

@Kzoeps

πŸ› οΈ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's see the actual code at lines 1803-1809
echo "=== Code at lines 1803-1809 ==="
sed -n '1800,1815p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

# Find the HypercertEvaluation type definition
echo -e "\n=== HypercertEvaluation type definition ==="
rg -n "type HypercertEvaluation|interface HypercertEvaluation" packages/sdk-core/src/

# Check evaluators field definition
echo -e "\n=== Evaluators field in types ==="
rg -n "evaluators" packages/sdk-core/src/services/hypercerts/types.ts -A 2 -B 2

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1047


🏁 Script executed:

#!/bin/bash
# Check the lexicon definition for the Evaluation record
echo "=== Searching lexicon for Evaluation ==="
find . -name "*.ts" -o -name "*.json" | xargs grep -l "Evaluation" | grep -i lexicon | head -5

# Look for OrgHypercertsEvaluation in lexicon
echo -e "\n=== OrgHypercerts Evaluation type ==="
rg -n "OrgHypercertsEvaluation" packages/sdk-core/src/ -A 5 -B 1

Repository: hypercerts-org/hypercerts-sdk

Length of output: 431


🏁 Script executed:

#!/bin/bash
# Check how evaluators is used elsewhere in the file
echo "=== All evaluators references in HypercertOperationsImpl ==="
rg -n "evaluators" packages/sdk-core/src/repository/HypercertOperationsImpl.ts -B 2 -A 2

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1190


🏁 Script executed:

#!/bin/bash
# Find OrgHypercertsClaimEvaluation definition
echo "=== Looking for OrgHypercertsClaimEvaluation definition ==="
rg -n "OrgHypercertsClaimEvaluation" packages/sdk-core/src/ -A 10 | head -50

# Check the main lexicon definitions
echo -e "\n=== Checking for lexicon files ==="
find packages/sdk-core/src -name "*lexicon*" -type f

Repository: hypercerts-org/hypercerts-sdk

Length of output: 3924


🏁 Script executed:

#!/bin/bash
# Look for where OrgHypercertsClaimEvaluation comes from
echo "=== Imports of OrgHypercertsClaimEvaluation ==="
rg "import.*OrgHypercertsClaimEvaluation" packages/sdk-core/src/

# Check the schema files
echo -e "\n=== Schema and definition files ==="
find packages/sdk-core/src -name "*.ts" | xargs grep -l "evaluators.*did" | head -10

Repository: hypercerts-org/hypercerts-sdk

Length of output: 217


🏁 Script executed:

#!/bin/bash
# Look at the types file more carefully
echo "=== Full types.ts file (first 200 lines) ==="
head -200 packages/sdk-core/src/services/hypercerts/types.ts

Repository: hypercerts-org/hypercerts-sdk

Length of output: 7180


🏁 Script executed:

#!/bin/bash
# Check what `@hypercerts-org/lexicon` exports for OrgHypercertsClaimEvaluation
echo "=== Checking lexicon package ==="
# Since it's from `@hypercerts-org/lexicon`, let's see if there's a local copy or we need web search
find packages -name "lexicon*" -type d

# Check the lexicons.ts file
echo -e "\n=== Content of lexicons.ts ==="
cat packages/sdk-core/src/lexicons.ts

Repository: hypercerts-org/hypercerts-sdk

Length of output: 5715


🌐 Web query:

@hypercerts-org/lexicon OrgHypercertsClaimEvaluation evaluators field type definition

πŸ’‘ Result:

I couldn’t confirm the evaluators field’s type for OrgHypercertsClaimEvaluation from publicly accessible schema text.

What I was able to verify is that @hypercerts-org/lexicon is generated from the hypercerts-lexicon repository’s ATProto lexicon JSON schemas, but the repo pages that would show the actual JSON for the org.hypercerts.claim.evaluation record (where evaluators would be defined) weren’t retrievable in a way that exposed the file contents. [1]

The quickest way to get the exact type definition is to open the lexicon JSON for the claim evaluation record (e.g., org.hypercerts.claim.evaluation) and look at record.properties.evaluators (and any referenced defs). If the schema is published to ATProto, Lexicon Garden also suggests resolving it directly by NSID via https://lexicon.garden/nsid/<nsid>. [2]

Sources: [1], [2]


🏁 Script executed:

#!/bin/bash
# Find where EVALUATION_LEXICON_JSON comes from - it's from `@hypercerts-org/lexicon`
# Let's check if there's a local definition or if we need to check node_modules structure

echo "=== Searching for evaluation lexicon JSON files ==="
find packages -name "*evaluation*" -type f | grep -E "\.(json|ts)$"

# Look for lexicon JSON in a common location
echo -e "\n=== Checking node_modules structure ==="
find node_modules/@hypercerts-org/lexicon -name "*evaluation*" 2>/dev/null | head -20

Repository: hypercerts-org/hypercerts-sdk

Length of output: 165


🏁 Script executed:

#!/bin/bash
# Let's check the generated types from the lexicon package
# Look for the type definition in `@hypercerts-org/lexicon`
echo "=== Looking for OrgHypercertsClaimEvaluation in node_modules ==="
find node_modules/@hypercerts-org/lexicon -name "*.d.ts" 2>/dev/null | xargs grep -l "OrgHypercertsClaimEvaluation" 2>/dev/null | head -5

# And check for the actual evaluation schema
echo -e "\n=== Looking for evaluation schema ==="
find node_modules/@hypercerts-org/lexicon -name "*.json" 2>/dev/null | xargs grep -l "evaluation" 2>/dev/null | head -5

Repository: hypercerts-org/hypercerts-sdk

Length of output: 176


🏁 Script executed:

#!/bin/bash
# Check if nullish coalescing is used for $type and createdAt in the current code
echo "=== Checking for nullish coalescing pattern at lines 1803-1809 ==="
sed -n '1800,1815p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

# Look for similar patterns in other record creation methods
echo -e "\n=== Looking for other record creation methods with nullish coalescing ==="
rg -n "buildAttachmentRecord|createLocationRecord" packages/sdk-core/src/repository/ -A 10 | head -50

Repository: hypercerts-org/hypercerts-sdk

Length of output: 5608


🏁 Script executed:

#!/bin/bash
# Get the full buildAttachmentRecord method to see nullish coalescing pattern
echo "=== Full buildAttachmentRecord method ==="
sed -n '1131,1155p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

# Now let's check the buildLocationRecord or createLocationRecord
echo -e "\n=== Looking for createLocationRecord ==="
rg -n "createLocationRecord|buildLocationRecord" packages/sdk-core/src/repository/HypercertOperationsImpl.ts -A 15 | head -60

Repository: hypercerts-org/hypercerts-sdk

Length of output: 3233


🏁 Script executed:

#!/bin/bash
# Search for all nullish coalescing usage for $type and createdAt in the file
echo "=== Nullish coalescing for \$type and createdAt patterns ==="
rg -n "\$\?|createdAt.*\?\?" packages/sdk-core/src/repository/HypercertOperationsImpl.ts | head -20

Repository: hypercerts-org/hypercerts-sdk

Length of output: 244


🏁 Script executed:

#!/bin/bash
# Let's try running TypeScript compiler to see if there's actually a TS error
echo "=== Checking if there's a TS compiler available ==="
which tsc

# Try to run tsc on just the specific file
echo -e "\n=== Running TypeScript check ==="
cd packages/sdk-core && npx tsc --noEmit src/repository/HypercertOperationsImpl.ts 2>&1 | grep -A 5 -B 5 "1806\|evaluators" | head -30

Repository: hypercerts-org/hypercerts-sdk

Length of output: 219


🏁 Script executed:

#!/bin/bash
# Check if CreateEvaluationParams or similar type is defined
echo "=== Looking for CreateEvaluationParams type ==="
rg -n "CreateEvaluationParams|CreateHypercertEvaluationParams" packages/sdk-core/src/

# Check what types are defined in types.ts for other entities
echo -e "\n=== Checking what Create*Params types exist ==="
rg -n "^export type Create" packages/sdk-core/src/services/hypercerts/types.ts | head -20

Repository: hypercerts-org/hypercerts-sdk

Length of output: 646


🏁 Script executed:

#!/bin/bash
# Check the full method signature and see if there's a params type
echo "=== Full addEvaluation method signature and start ==="
sed -n '1798,1815p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

# Look for other similar add* methods to see the pattern
echo -e "\n=== Other add* methods ==="
rg -n "async add\w+\(" packages/sdk-core/src/repository/HypercertOperationsImpl.ts | head -10

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1315


🏁 Script executed:

#!/bin/bash
# Check how measurement was created (similar pattern)
echo "=== Looking for addMeasurement method ==="
rg -n "async addMeasurement" packages/sdk-core/src/repository/HypercertOperationsImpl.ts -A 20 | head -40

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1031


🏁 Script executed:

#!/bin/bash
# Check the complete types.ts to see all Create*Params patterns
echo "=== All Create*Params and Update*Params types ==="
rg -n "export type (Create|Update)" packages/sdk-core/src/services/hypercerts/types.ts

# Look for EvaluationParams specifically
echo -e "\n=== Any Evaluation*Params types ==="
rg -n "Evaluation" packages/sdk-core/src/services/hypercerts/types.ts

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1194


🏁 Script executed:

#!/bin/bash
# Check CreateMeasurementParams to see the pattern
echo "=== CreateMeasurementParams definition ==="
rg -n "CreateMeasurementParams" packages/sdk-core/src/services/hypercerts/types.ts -A 10

# Check CreateAttachmentParams pattern
echo -e "\n=== CreateAttachmentParams definition ==="
rg -n "CreateAttachmentParams" packages/sdk-core/src/services/hypercerts/types.ts -A 10

Repository: hypercerts-org/hypercerts-sdk

Length of output: 4769


🏁 Script executed:

#!/bin/bash
# Look at the addEvaluation method more carefully - check if $type uses nullish coalescing
echo "=== Complete addEvaluation method ==="
sed -n '1798,1825p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

# Compare with addMeasurement to see the pattern
echo -e "\n=== addMeasurement for comparison ==="
sed -n '1657,1690p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

Repository: hypercerts-org/hypercerts-sdk

Length of output: 2579


🏁 Script executed:

#!/bin/bash
# Let's verify if there's supposed to be a CreateEvaluationParams type
# by checking the learnings guideline more carefully
echo "=== Looking for any UpdateEvaluationParams pattern ==="
rg -n "UpdateMeasurementParams|UpdateAttachmentParams" packages/sdk-core/src/services/hypercerts/types.ts

# Check if evaluation should have both Create and Update params
echo -e "\n=== Pattern: every entity should have Create/Update params ==="
rg -n "^export type (Create|Update)" packages/sdk-core/src/services/hypercerts/types.ts | grep -E "(Measurement|Attachment|Evaluation)"

# Look at the complete addMeasurement to see if it uses nullish coalescing
echo -e "\n=== Full measurementRecord creation with nullish coalescing check ==="
sed -n '1664,1677p' packages/sdk-core/src/repository/HypercertOperationsImpl.ts

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1359


🏁 Script executed:

#!/bin/bash
# Check if there's a pattern for params.$type and params.createdAt
echo "=== Looking for params.$type or params.createdAt patterns ==="
rg -n "params\.\$type|params\.createdAt" packages/sdk-core/src/repository/HypercertOperationsImpl.ts | head -20

Repository: hypercerts-org/hypercerts-sdk

Length of output: 129


🏁 Script executed:

#!/bin/bash
# Let's check the entire types.ts structure around evaluation
echo "=== Context around HypercertEvaluation in types.ts ==="
sed -n '150,170p' packages/sdk-core/src/services/hypercerts/types.ts

Repository: hypercerts-org/hypercerts-sdk

Length of output: 1121


Define CreateEvaluationParams type and refactor addEvaluation to follow SDK patterns.

The addEvaluation method violates the SDK's type definition guidelines:

  1. Missing type definitions: Unlike CreateMeasurementParams and CreateAttachmentParams, there is no CreateEvaluationParams type. According to guidelines, each lexicon entity should define five types: Main, HypercertXxx alias, CreateXxxParams, UpdateXxxParams, and XxxParams union type. Add these missing types to packages/sdk-core/src/services/hypercerts/types.ts.

  2. Incorrect method signature: The method uses an inline params object instead of CreateEvaluationParams. Update the signature to:

    async addEvaluation(params: CreateEvaluationParams): Promise<CreateResult>
  3. Missing nullish coalescing: Per guidelines, use nullish coalescing to preserve caller-supplied $type and createdAt fields when provided:

    $type: params.$type ?? HYPERCERT_COLLECTIONS.EVALUATION,
    createdAt: params.createdAt ?? new Date().toISOString(),
🧰 Tools
πŸͺ› GitHub Actions: Test

[error] 1806-1806: TS2322: Type '{ did: string; }[]' is not assignable to type 'string[]'.

πŸ€– Prompt for AI Agents
In `@packages/sdk-core/src/repository/HypercertOperationsImpl.ts` around lines
1803 - 1809, Add a new CreateEvaluationParams type (and the required
Main/alias/Update/union types for evaluation) to
packages/sdk-core/src/services/hypercerts/types.ts, then update the
HypercertOperationsImpl.addEvaluation method signature to async
addEvaluation(params: CreateEvaluationParams): Promise<CreateResult>; inside
addEvaluation build the HypercertEvaluation using params and preserve
caller-provided $type and createdAt via nullish coalescing (e.g. $type:
params.$type ?? HYPERCERT_COLLECTIONS.EVALUATION and createdAt: params.createdAt
?? new Date().toISOString()), and keep mapping evaluators from params.evaluators
to { did } objects before returning the CreateResult.

Originally posted by @coderabbitai[bot] in #125 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions