-
-
Notifications
You must be signed in to change notification settings - Fork 202
feat: add sourcePolicy to History API values requests #2817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { | |
| PathSpec, | ||
| PathsRequest, | ||
| PathsResponse, | ||
| HistorySourcePolicy, | ||
| TimeRangeParams, | ||
| ValuesRequest, | ||
| ValuesResponse, | ||
|
|
@@ -281,6 +282,13 @@ const parseValuesQuery = (query: Record<string, unknown>): ValuesRequest => { | |
| errors.push('paths parameter is required and must be a string') | ||
| } | ||
|
|
||
| let sourcePolicy: HistorySourcePolicy | undefined | ||
| try { | ||
| sourcePolicy = parseSourcePolicy(query.sourcePolicy) | ||
| } catch (error) { | ||
| errors.push(error instanceof Error ? error.message : 'Invalid sourcePolicy') | ||
| } | ||
|
|
||
|
Comment on lines
+285
to
+291
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win Consider validating/documenting
Not blocking since provider behavior for this combination isn't defined in this PR's scope, but worth a validation error or explicit doc note to avoid confusing edge-case behavior downstream. Also applies to: 296-299, 312-316, 368-396 🤖 Prompt for AI Agents |
||
| if (errors.length > 0) { | ||
| throw new Error(`Validation errors: ${errors.join(', ')}`) | ||
| } | ||
|
|
@@ -294,12 +302,19 @@ const parseValuesQuery = (query: Record<string, unknown>): ValuesRequest => { | |
| ...timeRangeParams, | ||
| context, | ||
| resolution, | ||
| sourcePolicy, | ||
| pathSpecs | ||
| } | ||
| debug.enabled && debug(JSON.stringify(parsed, null, 2)) | ||
| return parsed | ||
| } | ||
|
|
||
| const parseSourcePolicy = (value: unknown): HistorySourcePolicy | undefined => { | ||
| if (value === undefined || value === null || value === '') return undefined | ||
| if (value === 'preferred' || value === 'all') return value | ||
| throw new Error("sourcePolicy parameter must be 'preferred' or 'all'") | ||
| } | ||
|
|
||
| // Maps the single-letter unit suffix in a resolution time expression to seconds. | ||
| const RESOLUTION_UNIT_SECONDS: Record<string, number> = { | ||
| s: 1, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. What would 'preferred' mean in practise? That provider would be able to figure out what source's value was preferred at the time, for arbitrarily varying lengths of time slices? To me that sounds like getting into the too complex domain.
Is this really needed? I'd like to leave it out.