Skip to content

URI resolver for external data fetching#50

Merged
vimmotions merged 15 commits intomainfrom
vim/hyp-178-feature-uri-resolver-for-type-safe-external-data-fetching
Feb 24, 2026
Merged

URI resolver for external data fetching#50
vimmotions merged 15 commits intomainfrom
vim/hyp-178-feature-uri-resolver-for-type-safe-external-data-fetching

Conversation

@vimmotions
Copy link
Contributor

Extended Resolve Macro - URL Resolution Support

Overview

This PR extends the #[resolve] macro to support URL-based data fetching in addition to the existing Token metadata resolution via DAS API.

New Capability

The #[resolve] macro now supports fetching and extracting data from HTTP URLs:

// Token resolver (existing functionality)
#[resolve(address = "oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp")]
pub ore_metadata: Option<TokenMetadata>,

// URL resolver (new)
#[resolve(url = info.uri, extract = "image")]
pub resolved_image: Option<String>,

// URL resolver with HTTP method
#[resolve(url = api.endpoint, method = POST, extract = "data.result")]
pub result: Option<String>,

Resolver Type Detection

The macro automatically determines the resolver type based on parameters:

Parameters Resolver Type
url = ... URL Resolver (HTTP fetch + JSON extraction)
address = ... or from = ... Token Resolver (DAS API)

Parameters are mutually exclusive - specifying both url and address/from is a compile error.

URL Resolver Parameters

Parameter Required Description
url Yes Field path containing the URL to fetch (e.g., info.uri)
extract Yes JSON path to extract from response (e.g., "image", "data.nested.field")
method No HTTP method: GET (default) or POST

Example Usage

pub struct TokenInfo {
    #[from_instruction([Create::uri], strategy = SetOnce)]
    pub uri: Option<String>,

    // Fetch metadata JSON from uri and extract the "image" field
    #[resolve(url = info.uri, extract = "image")]
    pub resolved_image: Option<String>,
}

Changes

Files Modified

  • hyperstack-macros/src/parse/attributes.rs

    • Added url and method fields to ResolveAttributeArgs
    • Updated parser to handle dot-path syntax for URL field references
    • Added validation for mutually exclusive parameters
  • hyperstack-macros/src/stream_spec/entity.rs

    • Updated resolve branch to create ResolverType::Url when url parameter is present
  • hyperstack-macros/src/stream_spec/sections.rs

    • Same updates as entity.rs with section-name prefixing for unqualified paths
  • stacks/pumpfun/src/stack.rs

    • Added example usage of URL resolution

…raction paths

- Introduced `UrlResolverConfig` struct to define URL resolution parameters.
- Added `HttpMethod` enum for specifying GET and POST methods.
- Enhanced `ResolverType` to include URL resolvers.
- Implemented URL resolution logic in the code generation and runtime, allowing for batch processing and JSON path extraction from responses.
- Updated parsing logic to support new `url_resolve` attribute in macros.
- Updated the `hyperstack` macro documentation to reflect the new `#[resolve(...)]` attribute.
- Refactored parsing logic to support new parameters for URL resolution, including `url` and `method`.
- Removed the deprecated `url_resolve` attribute and integrated its functionality into the `resolve` attribute.
- Enhanced error handling for mutually exclusive parameters in the `resolve` attribute.
- Updated entity processing to accommodate the new resolver logic for URL and token sources.
@vercel
Copy link

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperstack-docs Ready Ready Preview, Comment Feb 24, 2026 0:43am

Request Review

@vimmotions vimmotions requested a review from adiman9 February 16, 2026 17:58
Copy link
Contributor

@adiman9 adiman9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is great. Follows the overall patterns and handles things well.

Few things i've noticed:

Highest prio is there are a few spots where we silently fail and don't retry. This happens in extract_json_path as well as failed http requests. The token resolver has some retry patterns you can reference.

I've also created HYP-180 as a future plan to consolidate some of the resolver stuff

…ri-resolver-for-type-safe-external-data-fetching
adiman9
adiman9 previously approved these changes Feb 24, 2026
}

/// Batch resolve multiple URLs (each URL resolved independently)
/// Batch resolve multiple URLs in parallel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually using resolve_batch anywhere?

@vimmotions vimmotions merged commit 7e6d669 into main Feb 24, 2026
9 checks passed
@vimmotions vimmotions deleted the vim/hyp-178-feature-uri-resolver-for-type-safe-external-data-fetching branch February 24, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants