Skip to content

Function metadata API: getAvailableFunctions / getFunctionDetails (HF-249)#1692

Open
marcin-kordas-hoc wants to merge 17 commits into
developfrom
feature/hf-249-function-metadata-api
Open

Function metadata API: getAvailableFunctions / getFunctionDetails (HF-249)#1692
marcin-kordas-hoc wants to merge 17 commits into
developfrom
feature/hf-249-function-metadata-api

Conversation

@marcin-kordas-hoc

@marcin-kordas-hoc marcin-kordas-hoc commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a two-tier public API for retrieving built-in function metadata, intended for a Formula Builder / function picker:

  • HyperFormula.getAvailableFunctions(code) (static) / hfInstance.getAvailableFunctions() (instance) → FunctionListEntry[] — a short, sorted list: translated name, canonical name, category, short description.
  • HyperFormula.getFunctionDetails(canonicalName, code) (static) / hfInstance.getFunctionDetails(canonicalName) (instance) → FunctionDetails | undefined — full details including generated syntax and per-parameter optionality/repeatability.

Instance methods delegate to the static ones using the configured language. The catalogue covers built-in functions only — custom functions are not listed and getFunctionDetails returns undefined for them.

Catalogue

The 363-function catalogue is generated from docs/guide/built-in-functions.md by scripts/hf249-migrate-function-docs.ts (dev-only; not shipped — tsconfig include is ["src"]). Parameter names come from the Syntax column; their count and optionality follow the implementation arity in implementedFunctions. Repeating groups collapse onto the arity and duplicate names are disambiguated.

Tests

Paired tests PR: handsontable/hyperformula-tests#14 (branch feature/hf-249-function-metadata-api):

  • public API: static + instance, i18n, custom-function exclusion, present-but-empty MVP fields
  • coverage parity: FUNCTION_DOCS keys == canonical set (both directions)
  • parameter consistency: count == arity, unique non-empty names, repeatable count == repeatLastArgs
  • generated-syntax fixtures, ordering determinism, 18-language i18n sweep, normalized migration fidelity vs the docs

MVP scope

parameters[].description, documentationUrl, and examples are present but empty; authored in a later phase.

Notes

  • Sort order: category, then canonical name.
  • Empty language-pack translations fall back to the canonical id (e.g. SWITCH in several locales).

Note

Medium Risk
Large additive public API and generated catalogue; runtime behavior is read-only metadata, but list/detail consistency depends on doc vs implementation arity staying in sync.

Overview
Adds a two-tier public API for built-in function metadata (formula pickers / builders): getAvailableFunctions() returns a sorted short list (translated name, canonical id, category, description), and getFunctionDetails(canonicalName) returns full details including generated syntax and per-parameter optional/repeatable flags. Both exist as static methods (with language code) and instance helpers (instance language).

Introduces a FUNCTION_DOCS catalogue (~363 functions) under src/interpreter/functionMetadata/, composed from per-category files and regenerated from docs/guide/built-in-functions.md via dev-only scripts/hf249-migrate-function-docs.ts. Listing is gated so only documented, registered functions with catalogue arity matching implementedFunctions appear—custom functions are excluded (getFunctionDetailsundefined).

Exports new types (FunctionListEntry, FunctionDetails, etc.) from the package entry. MVP leaves parameters[].description, documentationUrl, and examples empty for a later phase.

Reviewed by Cursor Bugbot for commit c98e9b1. Bugbot is set up for automated code reviews on this repo. Configure here.

…c API (HF-249)

Add static and instance getAvailableFunctions and getFunctionDetails to
HyperFormula, backed by the function metadata catalogue. Instance methods
delegate to the static ones using the configured language. Re-export the
public catalogue types from the package entry point.
Replace the seeded catalogue with all 363 canonical built-ins, generated from
docs/guide/built-in-functions.md by scripts/hf249-migrate-function-docs.ts (dev-only,
not shipped). Parameter names come from the Syntax column but their count and
optionality follow the implementation arity; repeating groups collapse and duplicate
names are disambiguated. Also fall back to the canonical id when a language pack leaves
a function name empty (e.g. SWITCH in several locales).
…-249)

Add a CHANGELOG entry for the new built-in function metadata API, and a
"Function metadata" section to the custom functions guide clarifying that the
catalogue covers built-ins only — custom functions are absent from
getAvailableFunctions() and getFunctionDetails() returns undefined for them.
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Performance comparison of head (c98e9b1) vs base (d4195b5)

                                     testName |   base |   head | change
------------------------------------------------------------------------
                                      Sheet A |  481.1 | 482.18 | +0.22%
                                      Sheet B | 152.91 | 153.06 | +0.10%
                                      Sheet T | 136.15 | 134.95 | -0.88%
                                Column ranges | 506.02 | 507.82 | +0.36%
Sheet A:  change value, add/remove row/column |  14.72 |  15.64 | +6.25%
 Sheet B: change value, add/remove row/column | 131.15 | 131.82 | +0.51%
                   Column ranges - add column | 150.47 |  156.2 | +3.81%
                Column ranges - without batch | 469.01 | 469.07 | +0.01%
                        Column ranges - batch | 119.76 | 119.29 | -0.39%

@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for hyperformula-dev-docs ready!

Name Link
🔨 Latest commit c98e9b1
🔍 Latest deploy log https://app.netlify.com/projects/hyperformula-dev-docs/deploys/6a294ec37b316200089716ac
😎 Deploy Preview https://deploy-preview-1692--hyperformula-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@marcin-kordas-hoc marcin-kordas-hoc force-pushed the feature/hf-249-function-metadata-api branch from 8983d26 to 3f8857b Compare June 10, 2026 03:21
marcinkordas

This comment was marked as resolved.

@marcin-kordas-hoc marcin-kordas-hoc marked this pull request as ready for review June 10, 2026 10:54
Comment thread src/HyperFormula.ts
…ith getFunctionDetails (HF-249)

getAvailableFunctions derived its id set from each plugin class's static implementedFunctions, so an unregistered built-in (or a registry mutation) could still appear in the list while getFunctionDetails returned undefined for it. Gate the list on FunctionRegistry.getFunctionPlugin(id) — the same resolution getFunctionDetails uses — so list and details never disagree. (Cursor Bugbot, #1692.)
Comment thread src/HyperFormula.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4078a56. Configure here.

Comment thread src/HyperFormula.ts
…tFunctionDetails agree (HF-249)

getAvailableFunctions filtered on documented+registered but not the catalogue-vs-implementation arity check that getFunctionDetails applies, so a drifted function could appear in the list yet return undefined from details. Extract resolveListableMetadata (documented + registered + arity-consistent) and use it in both. (Cursor, #1692.)
@marcin-kordas-hoc marcin-kordas-hoc requested a review from sequba June 10, 2026 13:52
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (d4195b5) to head (c98e9b1).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1692      +/-   ##
===========================================
+ Coverage    97.16%   97.17%   +0.01%     
===========================================
  Files          176      192      +16     
  Lines        15322    15412      +90     
  Branches      3356     3401      +45     
===========================================
+ Hits         14887    14977      +90     
- Misses         427      435       +8     
+ Partials         8        0       -8     
Files with missing lines Coverage Δ
src/HyperFormula.ts 99.74% <100.00%> (+0.01%) ⬆️
src/index.ts 100.00% <ø> (ø)
...nterpreter/functionMetadata/FunctionDescription.ts 100.00% <100.00%> (ø)
...eter/functionMetadata/buildFunctionDescriptions.ts 100.00% <100.00%> (ø)
.../functionMetadata/categories/array-manipulation.ts 100.00% <100.00%> (ø)
...nterpreter/functionMetadata/categories/database.ts 100.00% <100.00%> (ø)
...reter/functionMetadata/categories/date-and-time.ts 100.00% <100.00%> (ø)
...rpreter/functionMetadata/categories/engineering.ts 100.00% <100.00%> (ø)
...terpreter/functionMetadata/categories/financial.ts 100.00% <100.00%> (ø)
...rpreter/functionMetadata/categories/information.ts 100.00% <100.00%> (ø)
... and 8 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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