derive-dashboards 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/body.mjs +5 -1
  3. package/dist/charts/data/words.d.mts +5 -0
  4. package/dist/charts/data/words.mjs +1 -0
  5. package/dist/charts/kinds/columns-data.mjs +4 -1
  6. package/dist/charts/kinds/grid-layout.mjs +84 -8
  7. package/dist/charts/kinds/grid-legend.mjs +27 -4
  8. package/dist/charts/kinds/grid-marks.mjs +56 -4
  9. package/dist/charts/kinds/grid.mjs +2 -1
  10. package/dist/charts/scale/value.mjs +15 -8
  11. package/dist/charts/scene/types.d.mts +1 -1
  12. package/dist/core/document/display-entries.mjs +9 -2
  13. package/dist/core/document/display.d.mts +7 -3
  14. package/dist/core/document/display.mjs +15 -2
  15. package/dist/core/engine/version.d.mts +1 -1
  16. package/dist/core/engine/version.mjs +1 -1
  17. package/dist/core/error/codes.d.mts +2 -0
  18. package/dist/core/error/codes.mjs +2 -0
  19. package/dist/core/index.d.mts +2 -2
  20. package/dist/core/index.mjs +3 -3
  21. package/dist/core/model/member.d.mts +6 -0
  22. package/dist/core/model/member.mjs +11 -1
  23. package/dist/core/model/types.d.mts +6 -0
  24. package/dist/core/model/validate/known-members.mjs +1 -0
  25. package/dist/core/model/validate/members.mjs +12 -1
  26. package/dist/core/query/closure.mjs +2 -0
  27. package/dist/core/query/drill/links.mjs +16 -4
  28. package/dist/core/result/columns.mjs +15 -2
  29. package/dist/core/result/types.d.mts +2 -0
  30. package/dist/core/schema/answer-parts.mjs +1 -0
  31. package/dist/core/schema/answers.d.mts +14 -0
  32. package/dist/core/schema/answers.mjs +4 -2
  33. package/dist/core/schema/tools.mjs +4 -0
  34. package/dist/core/types/api.d.mts +7 -1
  35. package/dist/core/types/api.mjs +1 -1
  36. package/dist/endpoints/index.d.mts +5 -4
  37. package/dist/endpoints/meta.mjs +30 -12
  38. package/dist/endpoints/query.mjs +11 -5
  39. package/dist/endpoints/values.mjs +38 -24
  40. package/dist/execute.mjs +22 -1
  41. package/dist/labels.mjs +68 -0
  42. package/dist/listing.mjs +13 -0
  43. package/dist/react/Canvas.mjs +28 -2
  44. package/dist/react/Cell.mjs +1 -1
  45. package/dist/react/Dashboard.d.mts +2 -3
  46. package/dist/react/Tile.d.mts +1 -1
  47. package/dist/react/arrange-steps.mjs +99 -11
  48. package/dist/react/arrange.mjs +10 -3
  49. package/dist/react/builder/base.mjs +11 -6
  50. package/dist/react/builder/display.mjs +16 -2
  51. package/dist/react/builder/state.mjs +3 -3
  52. package/dist/react/builder/words.mjs +8 -0
  53. package/dist/react/dates-shown.mjs +27 -9
  54. package/dist/react/filters/bar.d.mts +1 -1
  55. package/dist/react/filters/bar.mjs +17 -7
  56. package/dist/react/filters/chip.mjs +5 -3
  57. package/dist/react/filters/context.mjs +2 -2
  58. package/dist/react/filters/dates-said.mjs +29 -11
  59. package/dist/react/filters/hooks.d.mts +8 -0
  60. package/dist/react/filters/hooks.mjs +39 -2
  61. package/dist/react/filters/menu.mjs +8 -18
  62. package/dist/react/filters/phone.mjs +3 -3
  63. package/dist/react/filters/values.mjs +47 -28
  64. package/dist/react/filters/words.mjs +2 -2
  65. package/dist/react/format.d.mts +1 -1
  66. package/dist/react/format.mjs +8 -2
  67. package/dist/react/renderers/moved.mjs +160 -0
  68. package/dist/react/renderers/number-before.mjs +2 -157
  69. package/dist/react/renderers/props.d.mts +3 -3
  70. package/dist/react/renderers/table-cells.mjs +97 -11
  71. package/dist/react/renderers/table-head.mjs +7 -1
  72. package/dist/react/renderers/table-measure.mjs +147 -25
  73. package/dist/react/renderers/table-over.mjs +72 -0
  74. package/dist/react/renderers/table-scale.mjs +54 -1
  75. package/dist/react/renderers/table-trend.mjs +55 -0
  76. package/dist/react/renderers/table.d.mts +5 -1
  77. package/dist/react/renderers/table.mjs +29 -6
  78. package/dist/react/theme-unlayered.css +1 -1
  79. package/dist/react/theme.css +1 -1
  80. package/package.json +1 -1
@@ -6,7 +6,7 @@ import { describeQueries } from "./model/catalog/queries.mjs";
6
6
  import { missingTenantKey, policyBinding, tenantValues } from "./model/defaults.mjs";
7
7
  import { DimensionId, JoinedDimensionId, MeasureId, MemberId, ModelError, OwnDimensionId, SourceNameOf, defineModel } from "./model/define.mjs";
8
8
  import { DimensionHints, Noun, NumberFormat, RecordsHint, Tone } from "./model/hints.mjs";
9
- import { MemberRef, ResolvedDimension, parseMemberId, recordDimensions, resolveDimension, sourceOf } from "./model/member.mjs";
9
+ import { MemberRef, ResolvedDimension, parseMemberId, recordDimensions, resolveDimension, shownAsMember, sourceOf } from "./model/member.mjs";
10
10
  import { ColumnRole, Mark, Receipt, RecordColumn, Result, ResultCell, ResultColumn, ResultRows, TimeAxis, TimeBucket } from "./result/types.mjs";
11
11
  import { cellDigits, decimalPlaces, formatExact, movePoint, parseExact } from "./exact/text.mjs";
12
12
  import { Exact } from "./exact/decimal.mjs";
@@ -75,4 +75,4 @@ import { CanFn, Channel, Principal, Resource, TenantKeysOf, Verb, Viewer, Viewer
75
75
  import { canonical } from "./value/canonical.mjs";
76
76
  import { fold } from "./value/casefold.mjs";
77
77
  import { Reading, StoredValue, Unread } from "./value/stored.mjs";
78
- export { type AccessParts, type Alias, type AnswerDrill, type ApiError, type AssertionContext, type Author, type Awaitable, BASE_ERROR_CODES, type Better, type BoundFilter, type BoundPolicy, type BoundPolicyFilter, type BoundRule, type ByQuery, CATALOG, CONTRACT_VERSION, type CalcAlias, type CalcEntry, type Calendar, type CanFn, type Catalog, type CatalogIssueCode, type Cell, type Change, type Channel, type ClosedRow, type Closure, type CodeDashboard, type Column, type ColumnRole, type ColumnType, type Command, type CommandBody, type CommandId, type ComparisonFields, type ComposeCtx, type ComposeDelta, type ComposedQuery, type ComposedTile, type CompositionPolicy, type ConnectionId, type Control, type ControlId, type CoreApi, type CoreContract, type CustomSource, type Cuts, DISPLAY_OPTIONS, DRILL_REASONS, type Dash, type DashAdapter, type DashEndpoint, type DashHook, type DashOptions, type DashPlugin, type DashboardHead, type DashboardListResponse, type DashboardReader, type DashboardResponse, type DashboardStore, type DashboardSummary, type DatePart, type DateRange, type DbSchema, type DimensionAlias, type DimensionCut, type DimensionDef, type DimensionHints, type DimensionId, type DimensionName, type Display, type DisplayKind, type DisplayOf, type DisplayOptionName, type Doc, type DocumentRefusalCode, type DocumentSlice, type Draft, type DraftResponse, type DraftTarget, type Drill, type DrillAbilities, type DrillAnswer, type DrillBody, type DrillCan, type DrillComparisonView, type DrillCrumb, type DrillExplanationView, type DrillField, type DrillGroupedView, type DrillItem, type DrillItemsView, type DrillOperand, type DrillOrigin, type DrillReason, type DrillSemantics, type DrillState, type DrillStep, type DrillSummary, type DrillView, type EncodeOptions, type EndpointAccess, type EndpointContext, type EndpointsByPath, type EntryId, type Exact, type ExactSum, type Explanation, type ExplicitRange, type Expr, type ExprCondition, type ExprFunction, type Field, type FieldType, type Format, type Formula, type FormulaNode, type FormulaRef, GRID_COLUMNS, type Gap, type Grain, type GroupedRead, type HeadersLike, type HookContext, type HostCell, type HostRows, type IanaZone, type IntrospectingConnection, type IsoInstant, type Issue, type IssueCode, type ItemColumn, type ItemLinks, type ItemLinksFor, type JoinDef, type JoinName, type JoinedDimensionId, LIBRARY_WIDGET_KINDS, type LayoutItem, type Leaf, type LibraryWidgetKind, type LinearTerm, type LockEntry, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MINUS, MIN_SECRET_BYTES, type Mark, type MeasureAlias, type MeasureDef, type MeasureId, type MeasureName, type MemberId, type MemberMeta, type MemberRef, type MetaJoin, type MetaMember, type MetaResponse, type Micros, type Model, ModelError, type ModelIssueCode, type Moment, type NaiveRule, type NegativeOp, type NodeId, type Noun, type NullOp, type NumberFormat, type NumberShape, type NumberWriter, type Numeric, type Offer, type Op, type Operands, type OptionType, type Outcome, type OverlapPart, type OwnDimensionId, type PageRequest, type Param, type Picks, type PinnedExecution, type Placement, type PluginEndpoints, type PluginErrorCodes, type PolicyBinding, type PolicyFilter, type PolicyName, type PolicyRule, type PositiveOp, type Preview, type Primitive, type Principal, type PublishResponse, type Published, type QueryAnswer, type QueryConnection, type QueryCtx, type QueryLine, QueryReferenceError, type QueryRefusalCode, type RawError, type RawLevels, type RawResult, type ReadContext, type ReadField, type ReadFilter, type ReadMeasure, type ReadSession, type Reading, type Receipt, type RecordColumn, type RecordPage, type Recorded, type RecordsHint, type RecordsRead, type RecordsResponse, type RefOf, type Refusal, type Relationship, type RelativeRange, type Replayed, type RequiredEntry, type ResolvedDimension, type ResolvedRange, type Resource, type Result, type ResultCell, type ResultColumn, type ResultRows, type ResultWarningCode, type Row, type RowPolicy, type RunOptions, type RuntimeErrorCode, SHARED_OPTIONS, START_REFUSALS, type SchemaDriver, type Scope, type ScopeCoverage, type SealedAnswer, type SecondaryStorage, type Selection, type SemanticProvider, type ServerCall, type ServerCallInput, type ServerCalls, type SharedDisplay, type SourceDef, type SourceName, type SourceNameOf, type Span, type Sql, StartError, type StartIssue, type StartRefusalCode, type StoreDialect, type StoredFilter, type StoredFormulaNode, type StoredLockEntry, type StoredQuery, type StoredValue, type StoredVersion, TABLES, TITLE_MOST, type Tab, type TabId, type TableCheck, type TableDef, type TableName, type Tenant, type TenantBinding, type TenantKey, type TenantKeysOf, type TileAnswer, type TileInput, type TileLine, type TileRef, type TileRequest, type TileResult, type TilesRequest, type TimeAxis, type TimeBucket, type TimeStorage, type Token, type Tone, type TypedFilter, type TypedQuery, type UniqueIds, type Unit, type UnpublishedDraft, type Unread, VIEW_PREFIX, type ValidateResponse, type ValueLeaf, type ValuesResponse, type VariableLeaf, type Verb, type VersionEntry, type ViewState, type Viewer, type ViewerFor, type ViewerLeaf, type ViewerMatch, type ViewerRef, type WeekStart, type Where, type Widget, type WidgetId, type WidgetPart, type WireFilter, type WireQuery, addsUp, answerStatus, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketWithin, canonical, cellDigits, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonsByQuery, composeTile, controlFieldIssues, controlFieldOffers, createDashEndpoint, createTable, currencyOf, dashboardKeyIssues, dateMillis, decimalPlaces, defineDashboard, defineErrorCodes, defineModel, describeQueries, didYouMean, diffDocs, displayOf, displayOptionsOf, documentDisplayIssues, documentLock, durationUnits, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entriesNamed, entryAliases, entryNamed, fold, formatExact, formatTextTime, formulaRefs, freeSpot, isBound, isDateOnly, isDateRange, isMark, isRunning, isStarting, isValuePick, itemLink, lastIncludedMillisecond, layoutGaps, layoutWidgetIssues, linkTemplateIssues, lockChanged, markShifted, markedRows, markedWhole, memberLabel, missingTenantKey, movePoint, namedPolicy, namesValues, numberWriters, parseExact, parseMemberId, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, refuseStart, refusedDisplayOptions, replay, requestInstant, resolveDimension, resultColumns, roleOf, rowValue, schemaChecks, shareOf, sharedDisplay, signOf, smallestFor, sourceOf, stepCommands, sumLinear, tenantValues, textMillis, tileInputs, toWire, unreadWarnings, validateModel, viaJoins, viewFor, viewLayout, wallClock, wholeAnswer, widgetDiff, widgetKindIssues, withTime, withView };
78
+ export { type AccessParts, type Alias, type AnswerDrill, type ApiError, type AssertionContext, type Author, type Awaitable, BASE_ERROR_CODES, type Better, type BoundFilter, type BoundPolicy, type BoundPolicyFilter, type BoundRule, type ByQuery, CATALOG, CONTRACT_VERSION, type CalcAlias, type CalcEntry, type Calendar, type CanFn, type Catalog, type CatalogIssueCode, type Cell, type Change, type Channel, type ClosedRow, type Closure, type CodeDashboard, type Column, type ColumnRole, type ColumnType, type Command, type CommandBody, type CommandId, type ComparisonFields, type ComposeCtx, type ComposeDelta, type ComposedQuery, type ComposedTile, type CompositionPolicy, type ConnectionId, type Control, type ControlId, type CoreApi, type CoreContract, type CustomSource, type Cuts, DISPLAY_OPTIONS, DRILL_REASONS, type Dash, type DashAdapter, type DashEndpoint, type DashHook, type DashOptions, type DashPlugin, type DashboardHead, type DashboardListResponse, type DashboardReader, type DashboardResponse, type DashboardStore, type DashboardSummary, type DatePart, type DateRange, type DbSchema, type DimensionAlias, type DimensionCut, type DimensionDef, type DimensionHints, type DimensionId, type DimensionName, type Display, type DisplayKind, type DisplayOf, type DisplayOptionName, type Doc, type DocumentRefusalCode, type DocumentSlice, type Draft, type DraftResponse, type DraftTarget, type Drill, type DrillAbilities, type DrillAnswer, type DrillBody, type DrillCan, type DrillComparisonView, type DrillCrumb, type DrillExplanationView, type DrillField, type DrillGroupedView, type DrillItem, type DrillItemsView, type DrillOperand, type DrillOrigin, type DrillReason, type DrillSemantics, type DrillState, type DrillStep, type DrillSummary, type DrillView, type EncodeOptions, type EndpointAccess, type EndpointContext, type EndpointsByPath, type EntryId, type Exact, type ExactSum, type Explanation, type ExplicitRange, type Expr, type ExprCondition, type ExprFunction, type Field, type FieldType, type Format, type Formula, type FormulaNode, type FormulaRef, GRID_COLUMNS, type Gap, type Grain, type GroupedRead, type HeadersLike, type HookContext, type HostCell, type HostRows, type IanaZone, type IntrospectingConnection, type IsoInstant, type Issue, type IssueCode, type ItemColumn, type ItemLinks, type ItemLinksFor, type JoinDef, type JoinName, type JoinedDimensionId, LIBRARY_WIDGET_KINDS, type LayoutItem, type Leaf, type LibraryWidgetKind, type LinearTerm, type LockEntry, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MINUS, MIN_SECRET_BYTES, type Mark, type MeasureAlias, type MeasureDef, type MeasureId, type MeasureName, type MemberId, type MemberMeta, type MemberRef, type MetaJoin, type MetaMember, type MetaResponse, type Micros, type Model, ModelError, type ModelIssueCode, type Moment, type NaiveRule, type NegativeOp, type NodeId, type Noun, type NullOp, type NumberFormat, type NumberShape, type NumberWriter, type Numeric, type Offer, type Op, type Operands, type OptionType, type Outcome, type OverlapPart, type OwnDimensionId, type PageRequest, type Param, type Picks, type PinnedExecution, type Placement, type PluginEndpoints, type PluginErrorCodes, type PolicyBinding, type PolicyFilter, type PolicyName, type PolicyRule, type PositiveOp, type Preview, type Primitive, type Principal, type PublishResponse, type Published, type QueryAnswer, type QueryConnection, type QueryCtx, type QueryLine, QueryReferenceError, type QueryRefusalCode, type RawError, type RawLevels, type RawResult, type ReadContext, type ReadField, type ReadFilter, type ReadMeasure, type ReadSession, type Reading, type Receipt, type RecordColumn, type RecordPage, type Recorded, type RecordsHint, type RecordsRead, type RecordsResponse, type RefOf, type Refusal, type Relationship, type RelativeRange, type Replayed, type RequiredEntry, type ResolvedDimension, type ResolvedRange, type Resource, type Result, type ResultCell, type ResultColumn, type ResultRows, type ResultWarningCode, type Row, type RowPolicy, type RunOptions, type RuntimeErrorCode, SHARED_OPTIONS, START_REFUSALS, type SchemaDriver, type Scope, type ScopeCoverage, type SealedAnswer, type SecondaryStorage, type Selection, type SemanticProvider, type ServerCall, type ServerCallInput, type ServerCalls, type SharedDisplay, type SourceDef, type SourceName, type SourceNameOf, type Span, type Sql, StartError, type StartIssue, type StartRefusalCode, type StoreDialect, type StoredFilter, type StoredFormulaNode, type StoredLockEntry, type StoredQuery, type StoredValue, type StoredVersion, TABLES, TITLE_MOST, type Tab, type TabId, type TableCheck, type TableDef, type TableName, type Tenant, type TenantBinding, type TenantKey, type TenantKeysOf, type TileAnswer, type TileInput, type TileLine, type TileRef, type TileRequest, type TileResult, type TilesRequest, type TimeAxis, type TimeBucket, type TimeStorage, type Token, type Tone, type TypedFilter, type TypedQuery, type UniqueIds, type Unit, type UnpublishedDraft, type Unread, VIEW_PREFIX, type ValidateResponse, type ValueLeaf, type ValuesResponse, type VariableLeaf, type Verb, type VersionEntry, type ViewState, type Viewer, type ViewerFor, type ViewerLeaf, type ViewerMatch, type ViewerRef, type WeekStart, type Where, type Widget, type WidgetId, type WidgetPart, type WireFilter, type WireQuery, addsUp, answerStatus, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketWithin, canonical, cellDigits, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonsByQuery, composeTile, controlFieldIssues, controlFieldOffers, createDashEndpoint, createTable, currencyOf, dashboardKeyIssues, dateMillis, decimalPlaces, defineDashboard, defineErrorCodes, defineModel, describeQueries, didYouMean, diffDocs, displayOf, displayOptionsOf, documentDisplayIssues, documentLock, durationUnits, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entriesNamed, entryAliases, entryNamed, fold, formatExact, formatTextTime, formulaRefs, freeSpot, isBound, isDateOnly, isDateRange, isMark, isRunning, isStarting, isValuePick, itemLink, lastIncludedMillisecond, layoutGaps, layoutWidgetIssues, linkTemplateIssues, lockChanged, markShifted, markedRows, markedWhole, memberLabel, missingTenantKey, movePoint, namedPolicy, namesValues, numberWriters, parseExact, parseMemberId, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, refuseStart, refusedDisplayOptions, replay, requestInstant, resolveDimension, resultColumns, roleOf, rowValue, schemaChecks, shareOf, sharedDisplay, shownAsMember, signOf, smallestFor, sourceOf, stepCommands, sumLinear, tenantValues, textMillis, tileInputs, toWire, unreadWarnings, validateModel, viaJoins, viewFor, viewLayout, wallClock, wholeAnswer, widgetDiff, widgetKindIssues, withTime, withView };
@@ -3,6 +3,7 @@ import { numberWriters } from "./format/index.mjs";
3
3
  import { controlFieldIssues, controlFieldOffers } from "./document/control-fields.mjs";
4
4
  import { checkCatalog } from "./model/catalog/check.mjs";
5
5
  import { changedWidget, diffDocs, markShifted, placementOf, widgetDiff } from "./document/diff.mjs";
6
+ import { itemLink, linkTemplateIssues } from "./query/drill/links.mjs";
6
7
  import { DISPLAY_OPTIONS, SHARED_OPTIONS, displayOf, displayOptionsOf, sharedDisplay } from "./document/display.mjs";
7
8
  import { comparisonsByQuery } from "./document/display-comparisons.mjs";
8
9
  import { describeQueries } from "./model/catalog/queries.mjs";
@@ -17,7 +18,7 @@ import { emptyDoc } from "./document/types.mjs";
17
18
  import { ModelError, defineModel } from "./model/define.mjs";
18
19
  import { VIEW_PREFIX, encodeView, viewFor, withView } from "./document/view.mjs";
19
20
  import { smallestFor, viewLayout } from "./document/view-layout.mjs";
20
- import { parseMemberId, recordDimensions, resolveDimension, sourceOf } from "./model/member.mjs";
21
+ import { parseMemberId, recordDimensions, resolveDimension, shownAsMember, sourceOf } from "./model/member.mjs";
21
22
  import { rowValue, sumLinear } from "./exact/sum.mjs";
22
23
  import { cellDigits, decimalPlaces, formatExact, movePoint, parseExact } from "./exact/text.mjs";
23
24
  import { MINUS, currencyOf } from "./format/write.mjs";
@@ -34,7 +35,6 @@ import { isBound } from "./query/filter.mjs";
34
35
  import { changeOf, formulaRefs, shareOf } from "./query/formulas.mjs";
35
36
  import { isDateRange, isValuePick, pickProblem } from "./query/picks.mjs";
36
37
  import { QueryReferenceError, entryAliases, entryNamed, toWire } from "./query/to-wire.mjs";
37
- import { itemLink, linkTemplateIssues } from "./query/drill/links.mjs";
38
38
  import { MAX_DRILL_ROWS, MAX_DRILL_STEPS } from "./query/drill/types.mjs";
39
39
  import { CONTRACT_VERSION } from "./types/api.mjs";
40
40
  import { addsUp } from "./result/additive.mjs";
@@ -55,4 +55,4 @@ import { createDashEndpoint } from "./types/plugin.mjs";
55
55
  import { principalTenant } from "./types/viewer.mjs";
56
56
  import { canonical } from "./value/canonical.mjs";
57
57
  import { fold } from "./value/casefold.mjs";
58
- export { BASE_ERROR_CODES, CATALOG, CONTRACT_VERSION, DISPLAY_OPTIONS, DRILL_REASONS, GRID_COLUMNS, LIBRARY_WIDGET_KINDS, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MINUS, MIN_SECRET_BYTES, ModelError, QueryReferenceError, SHARED_OPTIONS, START_REFUSALS, StartError, TABLES, TITLE_MOST, VIEW_PREFIX, addsUp, answerStatus, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketWithin, canonical, cellDigits, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonsByQuery, composeTile, controlFieldIssues, controlFieldOffers, createDashEndpoint, createTable, currencyOf, dashboardKeyIssues, dateMillis, decimalPlaces, defineDashboard, defineErrorCodes, defineModel, describeQueries, didYouMean, diffDocs, displayOf, displayOptionsOf, documentDisplayIssues, documentLock, durationUnits, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entriesNamed, entryAliases, entryNamed, fold, formatExact, formatTextTime, formulaRefs, freeSpot, isBound, isDateOnly, isDateRange, isMark, isRunning, isStarting, isValuePick, itemLink, lastIncludedMillisecond, layoutGaps, layoutWidgetIssues, linkTemplateIssues, lockChanged, markShifted, markedRows, markedWhole, memberLabel, missingTenantKey, movePoint, namedPolicy, namesValues, numberWriters, parseExact, parseMemberId, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, refuseStart, refusedDisplayOptions, replay, requestInstant, resolveDimension, resultColumns, roleOf, rowValue, schemaChecks, shareOf, sharedDisplay, signOf, smallestFor, sourceOf, stepCommands, sumLinear, tenantValues, textMillis, tileInputs, toWire, unreadWarnings, validateModel, viaJoins, viewFor, viewLayout, wallClock, wholeAnswer, widgetDiff, widgetKindIssues, withTime, withView };
58
+ export { BASE_ERROR_CODES, CATALOG, CONTRACT_VERSION, DISPLAY_OPTIONS, DRILL_REASONS, GRID_COLUMNS, LIBRARY_WIDGET_KINDS, MAX_DRILL_ROWS, MAX_DRILL_STEPS, MICROS_PER_DAY, MINUS, MIN_SECRET_BYTES, ModelError, QueryReferenceError, SHARED_OPTIONS, START_REFUSALS, StartError, TABLES, TITLE_MOST, VIEW_PREFIX, addsUp, answerStatus, bindPolicy, bindQueryViewer, bindViewer, bucketLabel, bucketWithin, canonical, cellDigits, changeOf, changedWidget, checkCatalog, closeGaps, closeGapsCommands, commandWidget, comparisonsByQuery, composeTile, controlFieldIssues, controlFieldOffers, createDashEndpoint, createTable, currencyOf, dashboardKeyIssues, dateMillis, decimalPlaces, defineDashboard, defineErrorCodes, defineModel, describeQueries, didYouMean, diffDocs, displayOf, displayOptionsOf, documentDisplayIssues, documentLock, durationUnits, editedDisplayIssues, effectiveFilter, emptyDoc, encodeView, entriesNamed, entryAliases, entryNamed, fold, formatExact, formatTextTime, formulaRefs, freeSpot, isBound, isDateOnly, isDateRange, isMark, isRunning, isStarting, isValuePick, itemLink, lastIncludedMillisecond, layoutGaps, layoutWidgetIssues, linkTemplateIssues, lockChanged, markShifted, markedRows, markedWhole, memberLabel, missingTenantKey, movePoint, namedPolicy, namesValues, numberWriters, parseExact, parseMemberId, parseTextTime, pickProblem, placeItem, placementOf, policyBinding, principalTenant, queryClosure, readingOrder, recordColumns, recordDimensions, reduce, reduceAll, refuseStart, refusedDisplayOptions, replay, requestInstant, resolveDimension, resultColumns, roleOf, rowValue, schemaChecks, shareOf, sharedDisplay, shownAsMember, signOf, smallestFor, sourceOf, stepCommands, sumLinear, tenantValues, textMillis, tileInputs, toWire, unreadWarnings, validateModel, viaJoins, viewFor, viewLayout, wallClock, wholeAnswer, widgetDiff, widgetKindIssues, withTime, withView };
@@ -21,6 +21,12 @@ export type DimensionValueType = "string" | "number" | "boolean" | "time";
21
21
  * that reaches at most one row. Undefined when it does not exist.
22
22
  */
23
23
  export declare function resolveDimension(model: Model, sourceName: string, id: string): ResolvedDimension | undefined;
24
+ /**
25
+ * The member that names a dimension's values, for a string dimension `shownAs` another: the
26
+ * same path, ending in the other's name ("task.projectId" shown as "task.project"). None for
27
+ * any other dimension.
28
+ */
29
+ export declare function shownAsMember(model: Model, source: string, member: string): string | undefined;
24
30
  /**
25
31
  * The dimensions a records view of a source shows, by name: its `records.columns`, or else up
26
32
  * to twelve that are neither hidden, sensitive nor `drill: false`: its text fields, then its
@@ -67,6 +67,16 @@ function resolveDimension(model, sourceName, id) {
67
67
  if (ref === void 0 || ref.source !== sourceName) return void 0;
68
68
  return ref.join === void 0 ? ownDimension(model, sourceName, ref.name) : joinedDimension(model, sourceName, ref.join, ref.name);
69
69
  }
70
+ /**
71
+ * The member that names a dimension's values, for a string dimension `shownAs` another: the
72
+ * same path, ending in the other's name ("task.projectId" shown as "task.project"). None for
73
+ * any other dimension.
74
+ */
75
+ function shownAsMember(model, source, member) {
76
+ const def = resolveDimension(model, source, member)?.dimension;
77
+ if (def?.kind !== "string" || def.shownAs === void 0) return void 0;
78
+ return `${member.slice(0, member.lastIndexOf("."))}.${def.shownAs}`;
79
+ }
70
80
  /** The measure a member id names. Measures are always the source's own. */
71
81
  function resolveMeasure(model, sourceName, id) {
72
82
  const ref = parseMemberId(id);
@@ -103,4 +113,4 @@ function recordDimensions(model, sourceName) {
103
113
  * check holds a merge to the measure's kind, so this is true only of a count or a sum.
104
114
  */
105
115
  const mergesBySum = (def) => def.merge === "sum";
106
- export { dimensionValueType, isOnSource, memberIdOf, mergesBySum, ownEntry, parseMemberId, recordDimensions, resolveDimension, resolveMeasure, sourceOf };
116
+ export { dimensionValueType, isOnSource, memberIdOf, mergesBySum, ownEntry, parseMemberId, recordDimensions, resolveDimension, resolveMeasure, shownAsMember, sourceOf };
@@ -222,6 +222,12 @@ export type DimensionDef = MemberMeta & DimensionHints & ({
222
222
  values?: readonly string[] | "lookup";
223
223
  search?: boolean;
224
224
  collation: "binary" | "ci";
225
+ /**
226
+ * Another string dimension of this source that names each value: rows group and filter
227
+ * by this one (an id), and answers and value lists show it as that one's value (a
228
+ * name), so two rows with one name never merge.
229
+ */
230
+ shownAs?: DimensionName;
225
231
  } | {
226
232
  kind: "number" | "boolean";
227
233
  column: Column;
@@ -92,6 +92,7 @@ const DIMENSION = byKind("a dimension", {
92
92
  "values",
93
93
  "search",
94
94
  "collation",
95
+ "shownAs",
95
96
  ...HINTS,
96
97
  ...META
97
98
  ]), hints),
@@ -21,6 +21,13 @@ function bucketIssues(dim, path) {
21
21
  function collationIssues(collation, path) {
22
22
  return when(!(collation === "binary" || collation === "ci"), "COLLATION_MISSING", path, "A string dimension must declare \"binary\" or \"ci\".");
23
23
  }
24
+ /** `shownAs` names another string dimension of the source, which is not shown as another itself. */
25
+ function shownAsIssues(source, shownAs, path) {
26
+ if (shownAs === void 0) return [];
27
+ const named = source.dimensions[shownAs];
28
+ const ok = named?.kind === "string" && named.shownAs === void 0;
29
+ return when(!ok, "SHOWN_AS_UNKNOWN", path, `"${shownAs}" is not a string dimension of this source that is shown as itself. Name one of its string dimensions that has no shownAs of its own.`);
30
+ }
24
31
  function timeIssues(dim, path) {
25
32
  const storage = dim.storage;
26
33
  if (typeof storage !== "object" || !("timestamp" in storage)) return [];
@@ -34,7 +41,11 @@ function timeIssues(dim, path) {
34
41
  }
35
42
  function dimensionIssues(source, dim, path) {
36
43
  switch (dim.kind) {
37
- case "string": return collationIssues(dim.collation, [...path, "collation"]);
44
+ case "string": return [
45
+ ...collationIssues(dim.collation, [...path, "collation"]),
46
+ ...shownAsIssues(source, dim.shownAs, [...path, "shownAs"]),
47
+ ...when(dim.shownAs !== void 0 && Array.isArray(dim.values), "SHOWN_AS_VALUES", [...path, "values"], "A dimension shown as another lists its values from the data: leave out its own values list.")
48
+ ];
38
49
  case "ref": return refIssues(source, dim, [...path, "join"]);
39
50
  case "bucket": return bucketIssues(dim, path);
40
51
  case "expr": return exprIssues(source, dim.expr, [...path, "expr"]);
@@ -29,6 +29,8 @@ function dimension(w, source, id, path) {
29
29
  const name = parseMemberId(id)?.name ?? id;
30
30
  w.sources.add(resolved.source);
31
31
  w.members.add(`${resolved.source}.${name}`);
32
+ const { dimension: def } = resolved;
33
+ if (def.kind === "string" && def.shownAs !== void 0) w.members.add(`${resolved.source}.${def.shownAs}`);
32
34
  return resolved;
33
35
  }
34
36
  function measure(w, source, id, path) {
@@ -8,6 +8,8 @@ const LINK_PART = /\{(id|key\.[^{}]+)\}/gu;
8
8
  * where its link goes, and no link runs script (`javascript:`) or carries inline data (`data:`).
9
9
  */
10
10
  const SAFE_START = /^(?:\/(?![/\\])|https?:\/\/[^/\\?#{}\s@]+(?:[/?#]|$))/iu;
11
+ /** A path on the host's own site: one "/", then not a second "/" or "\\". */
12
+ const SAME_SITE = /^\/(?![/\\])/u;
11
13
  /**
12
14
  * What the URL parser strips or reads as a break before it reads a link: whitespace and control
13
15
  * characters. Text checked with one inside is not the link a browser follows (`"/\t/evil.example"`
@@ -15,14 +17,24 @@ const SAFE_START = /^(?:\/(?![/\\])|https?:\/\/[^/\\?#{}\s@]+(?:[/?#]|$))/iu;
15
17
  */
16
18
  const UNWRITTEN = /[\s\p{Cc}]/u;
17
19
  /**
20
+ * What is wrong with where a link template goes, in words; none when it is right: a path on the
21
+ * host's site or, when `offSite` (a link the host's own code writes), an http(s) URL with its
22
+ * host written out; holding no space or control character. The one rule for every link the
23
+ * library writes: item links (`offSite`), and a list's `href`, which editors write (same site).
24
+ */
25
+ function linkWhereIssues(template, offSite = true) {
26
+ if (UNWRITTEN.test(template)) return [`${JSON.stringify(template)}: a link holds no space or control character, which a browser drops or reads as a break ("/\\t/evil.example" goes to evil.example); encode one as %20 or %09.`];
27
+ if (!offSite && !SAME_SITE.test(template)) return [`"${template}": a link an editor writes is a path on this site, starting with one "/" ("/tasks/{id}").`];
28
+ if (!SAFE_START.test(template)) return [`"${template}": a link is a path starting with one "/" ("/orders/{id}") or an http(s) URL with its host written out ("https://crm.example.com/o/{id}").`];
29
+ return [];
30
+ }
31
+ /**
18
32
  * What is wrong with a link template for a source with this key, in words; none when it is right.
19
33
  * A template is a path on the host's site ("/orders/{id}") or an http(s) URL with its host written
20
34
  * out ("https://crm.example.com/o/{id}"), and names only {id} and {key.<column>} of that key.
21
35
  */
22
36
  function linkTemplateIssues(template, key) {
23
- const issues = [];
24
- if (UNWRITTEN.test(template)) issues.push(`${JSON.stringify(template)}: a link holds no space or control character, which a browser drops or reads as a break ("/\\t/evil.example" goes to evil.example); encode one as %20 or %09.`);
25
- else if (!SAFE_START.test(template)) issues.push(`"${template}": a link is a path starting with one "/" ("/orders/{id}") or an http(s) URL with its host written out ("https://crm.example.com/o/{id}").`);
37
+ const issues = linkWhereIssues(template);
26
38
  for (const [, part = ""] of template.matchAll(/\{([^{}]*)\}/gu)) {
27
39
  const column = part.startsWith("key.") ? part.slice(4) : void 0;
28
40
  if (part !== "id" && column === void 0) issues.push(`names {${part}}: a template names {id} or {key.<column>} only.`);
@@ -42,4 +54,4 @@ function itemLink(links, item) {
42
54
  });
43
55
  return missing ? void 0 : link;
44
56
  }
45
- export { itemLink, linkTemplateIssues };
57
+ export { itemLink, linkTemplateIssues, linkWhereIssues };
@@ -1,4 +1,4 @@
1
- import { dimensionValueType, mergesBySum, parseMemberId, resolveDimension, resolveMeasure } from "../model/member.mjs";
1
+ import { dimensionValueType, mergesBySum, parseMemberId, resolveDimension, resolveMeasure, shownAsMember } from "../model/member.mjs";
2
2
  import { idRole } from "../query/alias.mjs";
3
3
  import { formulaRefs } from "../query/formulas.mjs";
4
4
  import { calcAddsUp } from "./additive.mjs";
@@ -73,7 +73,8 @@ function dimensionColumns(model, query) {
73
73
  const perJoin = /* @__PURE__ */ new Map();
74
74
  for (const { resolved } of resolvedDims) if (resolved?.join !== void 0) perJoin.set(resolved.join, (perJoin.get(resolved.join) ?? 0) + 1);
75
75
  return resolvedDims.map(({ d, resolved }) => {
76
- const own = memberLabel(d.member, resolved?.dimension.label);
76
+ const shown = shownMember(model, query.source, d.member, resolved);
77
+ const own = memberLabel(shown.member, shown.label);
77
78
  const join = resolved?.join;
78
79
  const label = join === void 0 ? own : (perJoin.get(join) ?? 0) > 1 ? `${words(join)} ${own.toLowerCase()}` : words(join);
79
80
  return {
@@ -86,6 +87,18 @@ function dimensionColumns(model, query) {
86
87
  };
87
88
  });
88
89
  }
90
+ /** The member a column is named by: its own, or for one `shownAs` another, what it shows (a name). */
91
+ function shownMember(model, source, member, resolved) {
92
+ const shown = shownAsMember(model, source, member);
93
+ if (shown === void 0) return {
94
+ member,
95
+ label: resolved?.dimension.label
96
+ };
97
+ return {
98
+ member: shown,
99
+ label: resolveDimension(model, source, shown)?.dimension.label
100
+ };
101
+ }
89
102
  /** The values a string dimension declares, for a chart to colour by; none for a lookup or a free field. */
90
103
  function declaredValues(def) {
91
104
  const values = def?.kind === "string" ? def.values : void 0;
@@ -22,6 +22,8 @@ export type ResultColumn = {
22
22
  * gives each a colour by its place here, so a value keeps its colour whatever else is drawn.
23
23
  */
24
24
  values?: readonly string[];
25
+ /** On a dimension the model labels: each value's label, for the values in the answer. */
26
+ labels?: Readonly<Record<string, string>>;
25
27
  /** On a calc's column, or a ratio the model reads as a percent: how its values read. */
26
28
  format?: Format;
27
29
  /** On a calc that reads the comparison period: a change, shown with its sign (+3.2%). */
@@ -37,6 +37,7 @@ const column = z.looseObject({
37
37
  member: z.string().exactOptional(),
38
38
  grain: grain.exactOptional(),
39
39
  values: z.array(z.string()).readonly().exactOptional(),
40
+ labels: z.record(z.string(), z.string()).readonly().exactOptional(),
40
41
  format: z.enum([
41
42
  "number",
42
43
  "percent",
@@ -50,6 +50,7 @@ export declare const tileLineSchema: z.ZodUnion<readonly [z.ZodObject<{
50
50
  year: "year";
51
51
  }>>;
52
52
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
53
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
53
54
  format: z.ZodExactOptional<z.ZodEnum<{
54
55
  number: "number";
55
56
  percent: "percent";
@@ -1980,6 +1981,7 @@ export declare const answerSchemas: {
1980
1981
  values: z.ZodExactOptional<z.ZodUnion<readonly [z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>, z.ZodLiteral<"lookup">]>>;
1981
1982
  aggregate: z.ZodExactOptional<z.ZodString>;
1982
1983
  unit: z.ZodExactOptional<z.ZodString>;
1984
+ labelled: z.ZodExactOptional<z.ZodLiteral<true>>;
1983
1985
  }, z.core.$loose>>;
1984
1986
  dimensions: z.ZodArray<z.ZodObject<{
1985
1987
  id: z.ZodString;
@@ -1995,6 +1997,7 @@ export declare const answerSchemas: {
1995
1997
  values: z.ZodExactOptional<z.ZodUnion<readonly [z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>, z.ZodLiteral<"lookup">]>>;
1996
1998
  aggregate: z.ZodExactOptional<z.ZodString>;
1997
1999
  unit: z.ZodExactOptional<z.ZodString>;
2000
+ labelled: z.ZodExactOptional<z.ZodLiteral<true>>;
1998
2001
  }, z.core.$loose>>;
1999
2002
  joins: z.ZodArray<z.ZodObject<{
2000
2003
  name: z.ZodString;
@@ -2013,6 +2016,7 @@ export declare const answerSchemas: {
2013
2016
  "/meta/values": z.ZodObject<{
2014
2017
  values: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
2015
2018
  more: z.ZodBoolean;
2019
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
2016
2020
  }, z.core.$loose>;
2017
2021
  "/dashboards/list": z.ZodObject<{
2018
2022
  dashboards: z.ZodArray<z.ZodObject<{
@@ -2178,6 +2182,7 @@ export declare const answerSchemas: {
2178
2182
  "/dashboards/control-values": z.ZodObject<{
2179
2183
  values: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
2180
2184
  more: z.ZodBoolean;
2185
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
2181
2186
  }, z.core.$loose>;
2182
2187
  "/dashboards/records": z.ZodObject<{
2183
2188
  columns: z.ZodArray<z.ZodObject<{
@@ -2423,6 +2428,7 @@ export declare const answerSchemas: {
2423
2428
  year: "year";
2424
2429
  }>>;
2425
2430
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
2431
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
2426
2432
  format: z.ZodExactOptional<z.ZodEnum<{
2427
2433
  number: "number";
2428
2434
  percent: "percent";
@@ -2751,6 +2757,7 @@ export declare const answerSchemas: {
2751
2757
  year: "year";
2752
2758
  }>>;
2753
2759
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
2760
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
2754
2761
  format: z.ZodExactOptional<z.ZodEnum<{
2755
2762
  number: "number";
2756
2763
  percent: "percent";
@@ -3335,6 +3342,7 @@ export declare const answerSchemas: {
3335
3342
  year: "year";
3336
3343
  }>>;
3337
3344
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
3345
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
3338
3346
  format: z.ZodExactOptional<z.ZodEnum<{
3339
3347
  number: "number";
3340
3348
  percent: "percent";
@@ -3561,6 +3569,7 @@ export declare const answerSchemas: {
3561
3569
  year: "year";
3562
3570
  }>>;
3563
3571
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
3572
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
3564
3573
  format: z.ZodExactOptional<z.ZodEnum<{
3565
3574
  number: "number";
3566
3575
  percent: "percent";
@@ -3756,6 +3765,7 @@ export declare const answerSchemas: {
3756
3765
  year: "year";
3757
3766
  }>>;
3758
3767
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
3768
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
3759
3769
  format: z.ZodExactOptional<z.ZodEnum<{
3760
3770
  number: "number";
3761
3771
  percent: "percent";
@@ -4248,6 +4258,7 @@ export declare const answerSchemas: {
4248
4258
  year: "year";
4249
4259
  }>>;
4250
4260
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
4261
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
4251
4262
  format: z.ZodExactOptional<z.ZodEnum<{
4252
4263
  number: "number";
4253
4264
  percent: "percent";
@@ -4576,6 +4587,7 @@ export declare const answerSchemas: {
4576
4587
  year: "year";
4577
4588
  }>>;
4578
4589
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
4590
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
4579
4591
  format: z.ZodExactOptional<z.ZodEnum<{
4580
4592
  number: "number";
4581
4593
  percent: "percent";
@@ -5160,6 +5172,7 @@ export declare const answerSchemas: {
5160
5172
  year: "year";
5161
5173
  }>>;
5162
5174
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
5175
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
5163
5176
  format: z.ZodExactOptional<z.ZodEnum<{
5164
5177
  number: "number";
5165
5178
  percent: "percent";
@@ -5386,6 +5399,7 @@ export declare const answerSchemas: {
5386
5399
  year: "year";
5387
5400
  }>>;
5388
5401
  values: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
5402
+ labels: z.ZodExactOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
5389
5403
  format: z.ZodExactOptional<z.ZodEnum<{
5390
5404
  number: "number";
5391
5405
  percent: "percent";
@@ -17,7 +17,8 @@ const queryAnswer = result.extend({
17
17
  });
18
18
  const values = z.looseObject({
19
19
  values: z.array(primitive),
20
- more: z.boolean()
20
+ more: z.boolean(),
21
+ labels: z.record(z.string(), z.string()).readonly().exactOptional()
21
22
  });
22
23
  const metaMember = z.looseObject({
23
24
  id: z.string(),
@@ -32,7 +33,8 @@ const metaMember = z.looseObject({
32
33
  ]),
33
34
  values: z.union([z.array(primitive).readonly(), z.literal("lookup")]).exactOptional(),
34
35
  aggregate: z.string().exactOptional(),
35
- unit: z.string().exactOptional()
36
+ unit: z.string().exactOptional(),
37
+ labelled: z.literal(true).exactOptional()
36
38
  });
37
39
  const meta = z.looseObject({ sources: z.array(z.looseObject({
38
40
  name: z.string(),
@@ -23,6 +23,10 @@ function toolSchemas() {
23
23
  const OPTION_TYPES = {
24
24
  boolean: { type: "boolean" },
25
25
  text: { type: "string" },
26
+ link: {
27
+ type: "string",
28
+ pattern: "^/(?![/\\\\])"
29
+ },
26
30
  texts: {
27
31
  type: "array",
28
32
  items: { type: "string" }
@@ -23,6 +23,8 @@ export type MetaMember = {
23
23
  tones?: Readonly<Record<string, "positive" | "negative" | "warning" | "neutral">>;
24
24
  /** On a number dimension: its bucket edges, ascending, from the model's hints. */
25
25
  buckets?: readonly number[];
26
+ /** On a dimension the model labels: values are ids, each shown by its label (`labels`). */
27
+ labelled?: true;
26
28
  };
27
29
  /** A join a query can group by: `<source>.<join>.<dimension>` names a dimension of `source`. */
28
30
  export type MetaJoin = {
@@ -77,6 +79,8 @@ export type PublishResponse = Published;
77
79
  export type ValuesResponse = {
78
80
  values: Primitive[];
79
81
  more: boolean;
82
+ /** For a member the model labels: each listed value's label. */
83
+ labels?: Readonly<Record<string, string>>;
80
84
  };
81
85
  /**
82
86
  * A page of the rows behind a tile or a query: its columns and rows, and when more follow,
@@ -201,6 +205,8 @@ export type CoreContract = {
201
205
  dashboardId: string;
202
206
  controlId: string;
203
207
  search?: string;
208
+ /** Only these values: a pick read back with its labels. */
209
+ keys?: readonly string[];
204
210
  limit?: number;
205
211
  };
206
212
  answer: ValuesResponse;
@@ -344,4 +350,4 @@ export type CoreContract = {
344
350
  * than reading a shape it does not know. A test recomputes it from the answer schemas, so a
345
351
  * change to an answer fails until this is updated.
346
352
  */
347
- export declare const CONTRACT_VERSION = "dce7624268464e69";
353
+ export declare const CONTRACT_VERSION = "abd7c4243079e13c";
@@ -5,5 +5,5 @@
5
5
  * than reading a shape it does not know. A test recomputes it from the answer schemas, so a
6
6
  * change to an answer fails until this is updated.
7
7
  */
8
- const CONTRACT_VERSION = "dce7624268464e69";
8
+ const CONTRACT_VERSION = "abd7c4243079e13c";
9
9
  export { CONTRACT_VERSION };
@@ -464,6 +464,7 @@ export declare function coreEndpoints(rt: Runtime): {
464
464
  total?: boolean;
465
465
  fill?: "zero" | "none";
466
466
  };
467
+ order?: readonly (readonly [string, "asc" | "desc"])[];
467
468
  after?: string;
468
469
  limit?: number;
469
470
  }, import("derive-dashboards/core").RecordsResponse, "POST">;
@@ -648,6 +649,7 @@ export declare function coreEndpoints(rt: Runtime): {
648
649
  dashboardId: string;
649
650
  controlId: string;
650
651
  search?: string;
652
+ keys?: readonly string[];
651
653
  limit?: number;
652
654
  draft?: true;
653
655
  }, import("derive-dashboards/core").ValuesResponse, "POST">;
@@ -702,6 +704,7 @@ export declare function coreEndpoints(rt: Runtime): {
702
704
  unit?: string;
703
705
  tones?: Readonly<Record<string, "positive" | "negative" | "warning" | "neutral">>;
704
706
  buckets?: readonly number[];
707
+ labelled?: true;
705
708
  }[];
706
709
  dimensions: {
707
710
  id: string;
@@ -712,6 +715,7 @@ export declare function coreEndpoints(rt: Runtime): {
712
715
  unit?: string;
713
716
  tones?: Readonly<Record<string, "positive" | "negative" | "warning" | "neutral">>;
714
717
  buckets?: readonly number[];
718
+ labelled?: true;
715
719
  }[];
716
720
  joins: {
717
721
  name: string;
@@ -731,8 +735,5 @@ export declare function coreEndpoints(rt: Runtime): {
731
735
  member: string;
732
736
  search?: string;
733
737
  limit?: number;
734
- }, {
735
- values: import("derive-dashboards/core").Primitive[];
736
- more: boolean;
737
- }, "POST">;
738
+ }, import("derive-dashboards/core").ValuesResponse, "POST">;
738
739
  };
@@ -1,9 +1,10 @@
1
+ import { authorizeFree } from "../authorize.mjs";
1
2
  import { bodies, bodySchemas, parseWith } from "../body.mjs";
2
3
  import { allows, allowsSensitive } from "../grant.mjs";
3
4
  import { nowOf, userOf } from "../request.mjs";
4
5
  import { viewMember } from "./access.mjs";
5
6
  import { memberValues } from "./values.mjs";
6
- import { createDashEndpoint, memberLabel } from "derive-dashboards/core";
7
+ import { createDashEndpoint, memberLabel, parseMemberId } from "derive-dashboards/core";
7
8
  import { toolSchemas } from "derive-dashboards/core/schema";
8
9
  // src/endpoints/meta.ts
9
10
  function dimensionType(def) {
@@ -57,6 +58,10 @@ function unitOf(def) {
57
58
  }
58
59
  /** A dimension's own list of values, when the model gives one. */
59
60
  function staticValues(def) {
61
+ if (def.kind === "string" && def.shownAs !== void 0) return {
62
+ values: "lookup",
63
+ labelled: true
64
+ };
60
65
  if (def.kind === "string" && def.values !== void 0) return { values: def.values === "lookup" ? "lookup" : def.values };
61
66
  return def.kind === "bucket" ? { values: def.labels } : {};
62
67
  }
@@ -116,17 +121,30 @@ function metaEndpoints(rt) {
116
121
  method: "POST",
117
122
  access: viewMember,
118
123
  parse: (input) => parseWith(bodies.memberValues, input),
119
- handler: ({ body, principal, request }) => memberValues({
120
- rt,
121
- request,
122
- principal: userOf(principal),
123
- now: nowOf(rt.options),
124
- lock: [],
125
- coverage: {
126
- applied: [],
127
- dropped: []
128
- }
129
- }, body)
124
+ handler: async ({ body, principal, request }) => {
125
+ const user = userOf(principal);
126
+ const source = parseMemberId(body.member)?.source ?? "";
127
+ await authorizeFree(rt.options, user.viewer, {
128
+ kind: "aggregate",
129
+ source,
130
+ measures: [],
131
+ dimensions: [{
132
+ id: "d1",
133
+ member: body.member
134
+ }]
135
+ });
136
+ return memberValues({
137
+ rt,
138
+ request,
139
+ principal: user,
140
+ now: nowOf(rt.options),
141
+ lock: [],
142
+ coverage: {
143
+ applied: [],
144
+ dropped: []
145
+ }
146
+ }, body);
147
+ }
130
148
  })
131
149
  };
132
150
  }
@@ -1,4 +1,4 @@
1
- import { authorizeFree, readableOffer } from "../authorize.mjs";
1
+ import { authorizeFree, checkSensitive, readableOffer } from "../authorize.mjs";
2
2
  import { bodies, parseWith } from "../body.mjs";
3
3
  import { issueDrill } from "../drill-seal.mjs";
4
4
  import { execute, wire } from "../execute.mjs";
@@ -67,19 +67,25 @@ function queryEndpoints(rt) {
67
67
  access: { kind: "signed_in" },
68
68
  parse: (input) => parseWith(bodies.queryRecords, input, "QUERY_INVALID"),
69
69
  handler: async ({ body, principal, request }) => {
70
- const columns = recordDimensions(rt.options.model, body.query.source).map((n, i) => ({
70
+ const names = [...recordDimensions(rt.options.model, body.query.source), ...(body.order ?? []).map(([name]) => name)];
71
+ const columns = [...new Set(names)].map((n, i) => ({
71
72
  id: `d${i + 1}`,
72
73
  member: `${body.query.source}.${n}`
73
74
  }));
74
- await authorizeFree(rt.options, userOf(principal).viewer, {
75
+ const read = {
75
76
  ...body.query,
76
77
  dimensions: columns
77
- });
78
+ };
79
+ const user = userOf(principal);
80
+ checkSensitive(rt.options, user, read);
81
+ await authorizeFree(rt.options, user.viewer, read);
78
82
  const x = await freeExecution(rt, principal, request, body.query);
79
83
  const after = body.after === void 0 ? {} : { after: body.after };
84
+ const shape = body.order === void 0 ? {} : { shape: { order: body.order } };
80
85
  return executeRecords(x, {
81
86
  limit: body.limit ?? RECORDS_LIMIT,
82
- ...after
87
+ ...after,
88
+ ...shape
83
89
  });
84
90
  }
85
91
  }),