derive-dashboards 0.11.2 → 0.12.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # derive-dashboards
2
2
 
3
+ ## 0.12.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fb1fe09: A drill's path names a value shown as another by its name: drilling into a sheet's row reads "Outdoor brands", never its id.
8
+
9
+ ## 0.12.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 29a5e6b: A viewer can switch to their own time zone, for themselves, where the host allows it (`time.viewerZone: true`): their requests carry the zone in `x-dashboards-zone` (`ZONE_HEADER`). The standard view stays one zone for everyone who opens a dashboard: its own, then `time.timezone`, then UTC.
14
+
3
15
  ## 0.11.2
4
16
 
5
17
  ### Patch Changes
@@ -5,4 +5,4 @@
5
5
  * older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
6
6
  * against the files and prints the new value when they change.
7
7
  */
8
- export declare const ENGINE_VERSION = "0184cbc78d9b6863";
8
+ export declare const ENGINE_VERSION = "7a3995eb2ba47d55";
@@ -6,5 +6,5 @@
6
6
  * older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
7
7
  * against the files and prints the new value when they change.
8
8
  */
9
- const ENGINE_VERSION = "0184cbc78d9b6863";
9
+ const ENGINE_VERSION = "7a3995eb2ba47d55";
10
10
  export { ENGINE_VERSION };
@@ -71,8 +71,8 @@ import { Awaitable, Column, ConnectionId, DimensionName, IanaZone, IsoInstant, I
71
71
  import { Catalog, Explanation, PageRequest, QueryCtx, RawLevels, RawResult, RecordPage, RunOptions, SemanticProvider } from "./types/provider.mjs";
72
72
  import { ColumnType, DbSchema, IntrospectingConnection, Param, QueryConnection, ReadSession, Sql } from "./types/source.mjs";
73
73
  import { Author, DashAdapter, DashboardHead, DashboardReader, DashboardStore, DashboardSummary, Draft, DraftTarget, OverlapPart, Preview, Published, Refusal, Row, SchemaDriver, StoredVersion, Tenant, Token, UnpublishedDraft, VersionEntry, Where } from "./types/store.mjs";
74
- import { CanFn, Channel, Principal, Resource, TenantKeysOf, Verb, Viewer, ViewerFor, principalTenant } from "./types/viewer.mjs";
74
+ import { CanFn, Channel, Principal, Resource, TenantKeysOf, Verb, Viewer, ViewerFor, ZONE_HEADER, principalTenant } from "./types/viewer.mjs";
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, shownAsMember, 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, ZONE_HEADER, 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 };
@@ -52,7 +52,7 @@ import { requestInstant } from "./time/range.mjs";
52
52
  import { LIBRARY_WIDGET_KINDS, defineDashboard } from "./types/dashboard.mjs";
53
53
  import { MIN_SECRET_BYTES, StartError, dashboardKeyIssues, layoutWidgetIssues, refuseStart, widgetKindIssues } from "./types/options-check.mjs";
54
54
  import { createDashEndpoint } from "./types/plugin.mjs";
55
- import { principalTenant } from "./types/viewer.mjs";
55
+ import { ZONE_HEADER, 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, shownAsMember, 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, ZONE_HEADER, 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 };
@@ -47,6 +47,7 @@ export declare const dashOptionsSchema: z.ZodObject<{
47
47
  }, z.core.$strict>>;
48
48
  time: z.ZodExactOptional<z.ZodObject<{
49
49
  timezone: z.ZodExactOptional<z.ZodString>;
50
+ viewerZone: z.ZodExactOptional<z.ZodBoolean>;
50
51
  weekStart: z.ZodExactOptional<z.ZodLiteral<0 | 1 | 6>>;
51
52
  fiscalYearStartMonth: z.ZodExactOptional<z.ZodNumber>;
52
53
  }, z.core.$strict>>;
@@ -28,6 +28,7 @@ const cache = strict({
28
28
  });
29
29
  const time = strict({
30
30
  timezone: z.string().refine(isZone, { error: "Not a known time zone." }).exactOptional(),
31
+ viewerZone: z.boolean().exactOptional(),
31
32
  weekStart: z.literal([
32
33
  0,
33
34
  1,
@@ -98,7 +98,14 @@ export type DashOptions = {
98
98
  };
99
99
  };
100
100
  time?: {
101
+ /** The zone days are counted in, for every viewer: one zone, so everyone sees the same days. */
101
102
  timezone?: IanaZone;
103
+ /**
104
+ * Let a viewer switch to their own zone, for themselves: their requests carry it in
105
+ * `ZONE_HEADER`. The standard view stays one zone for everyone (the dashboard's, then
106
+ * `timezone`, then UTC). Off by default.
107
+ */
108
+ viewerZone?: boolean;
102
109
  weekStart?: WeekStart;
103
110
  fiscalYearStartMonth?: number;
104
111
  };
@@ -1,4 +1,9 @@
1
1
  import { Awaitable, IanaZone } from "./primitives.mjs";
2
+ /**
3
+ * The request header a viewer's switch to their own zone travels in (an IANA name), where the
4
+ * host allows it (`time.viewerZone`). Only that viewer's answers change.
5
+ */
6
+ export declare const ZONE_HEADER = "x-dashboards-zone";
2
7
  /** The signed-in person a request runs as. The host builds it from its own session. */
3
8
  export type Viewer = {
4
9
  id: string;
@@ -1,6 +1,11 @@
1
1
  // src/types/viewer.ts
2
+ /**
3
+ * The request header a viewer's switch to their own zone travels in (an IANA name), where the
4
+ * host allows it (`time.viewerZone`). Only that viewer's answers change.
5
+ */
6
+ const ZONE_HEADER = "x-dashboards-zone";
2
7
  /** The tenant values a principal carries, whichever channel it is on. */
3
8
  function principalTenant(principal) {
4
9
  return (principal.channel === "user" ? principal.viewer.tenant : principal.tenant) ?? {};
5
10
  }
6
- export { principalTenant };
11
+ export { ZONE_HEADER, principalTenant };
@@ -59,7 +59,7 @@ async function compareGroups(opened, state, requested) {
59
59
  }, [view.member]);
60
60
  return forOpener({
61
61
  state: normalizedDrillState(state, o.path, view),
62
- path: crumbs(o),
62
+ path: await crumbs(o),
63
63
  view: {
64
64
  by: "comparison",
65
65
  answer: wire(answer),
@@ -1,3 +1,5 @@
1
+ import { execute } from "./execute.mjs";
2
+ import { namesOf } from "./labels.mjs";
1
3
  import { bucketWithin, resultColumns } from "derive-dashboards/core";
2
4
  // src/drill-crumbs.ts
3
5
  /** A field's label as a column of the tile would read it. */
@@ -36,7 +38,7 @@ function groupCrumb(fields) {
36
38
  * One step as a breadcrumb: its fields and its values; a time point with its grain and the part
37
39
  * of it the window reads (`range`), so the panel says "so far" of a week still running.
38
40
  */
39
- function crumbOf(o, step, range) {
41
+ function crumbOf(o, step, range, names) {
40
42
  if ("bucket" in step) {
41
43
  const { member, from, to, grain } = step.bucket;
42
44
  return {
@@ -62,7 +64,7 @@ function crumbOf(o, step, range) {
62
64
  };
63
65
  return groupCrumb(step.group.map((g) => ({
64
66
  label: fieldLabel(o, g.member),
65
- value: g.value
67
+ value: typeof g.value === "string" ? names.get(g.member)?.[g.value] ?? g.value : g.value
66
68
  })));
67
69
  }
68
70
  /**
@@ -96,16 +98,37 @@ function selectionOf(steps) {
96
98
  * One selection as a breadcrumb, marked when it is of the period before. A time step reads the
97
99
  * part of its bucket that selection's own window covers.
98
100
  */
99
- function selectionCrumb(o, selection) {
101
+ function selectionCrumb(o, selection, names) {
100
102
  const range = selection.previous === true ? o.pinned.compare : o.pinned.range;
101
- const crumb = selectionOf(selection.steps.map((step) => crumbOf(o, step, range)));
103
+ const crumb = selectionOf(selection.steps.map((step) => crumbOf(o, step, range, names)));
102
104
  return selection.previous === true ? {
103
105
  ...crumb,
104
106
  previous: true
105
107
  } : crumb;
106
108
  }
107
- /** The path as breadcrumbs, one per selection, in order. */
108
- const crumbs = (o) => o.selections.map((s) => selectionCrumb(o, s));
109
+ /** The names the path's grouped values read as, read under the drill's own viewer and lock. */
110
+ async function pathNames(o) {
111
+ const grouped = o.selections.flatMap((s) => s.steps.flatMap((step) => "group" in step ? step.group : []));
112
+ const values = Map.groupBy(grouped, (g) => g.member);
113
+ const { model } = o.x.rt.options;
114
+ const read = await Promise.all([...values].map(async ([member, steps]) => {
115
+ const at = {
116
+ source: o.x.query.source,
117
+ member,
118
+ keys: steps.map((g) => g.value)
119
+ };
120
+ return [member, await namesOf(model, at, (query) => execute({
121
+ ...o.x,
122
+ query
123
+ }))];
124
+ }));
125
+ return new Map(read.flatMap(([m, n]) => n === void 0 ? [] : [[m, n]]));
126
+ }
127
+ /** The path as breadcrumbs, one per selection, in order, each value as people read it. */
128
+ async function crumbs(o) {
129
+ const names = await pathNames(o);
130
+ return o.selections.map((s) => selectionCrumb(o, s, names));
131
+ }
109
132
  /**
110
133
  * What of a receipt a viewer who did not draw the link may read: a fixed list, so a field added
111
134
  * to receipts later is held back until it is listed here. The filter (it states the drill's
package/dist/drill.mjs CHANGED
@@ -119,7 +119,7 @@ async function runDrill(rt, principal, request, body) {
119
119
  const state = normalizedDrillState(body.state, r.o.path, plain);
120
120
  return forOpener({
121
121
  ...r.summed === void 0 ? {} : { summary: r.summed.summary },
122
- path: crumbs(r.o),
122
+ path: await crumbs(r.o),
123
123
  state,
124
124
  view: shown
125
125
  }, r.o.foreign);
@@ -17,7 +17,7 @@ async function freeExecution(rt, principal, request, query) {
17
17
  request,
18
18
  principal: user,
19
19
  now: nowOf(rt.options),
20
- calendar: calendarOf(rt.options),
20
+ calendar: calendarOf(rt.options, void 0, request),
21
21
  query,
22
22
  lock: [],
23
23
  coverage: {
@@ -54,7 +54,7 @@ async function memberValues(x, a) {
54
54
  const answer = await execute({
55
55
  ...x,
56
56
  query,
57
- calendar: calendarOf(x.rt.options)
57
+ calendar: calendarOf(x.rt.options, void 0, x.request)
58
58
  });
59
59
  const rows = answer.rows.flatMap((row) => {
60
60
  const cell = row[0] ?? null;
package/dist/labels.mjs CHANGED
@@ -18,6 +18,37 @@ function cellsAt(index, sets) {
18
18
  }));
19
19
  }
20
20
  /**
21
+ * The names of some values of a dimension shown as another, read by one query grouped by the
22
+ * value and its name under the same viewer and lock (the query's closure holds the names, so
23
+ * whoever may not read them was refused before). Undefined for a dimension shown as itself.
24
+ */
25
+ async function namesOf(model, at, run) {
26
+ const shown = shownAsMember(model, at.source, at.member);
27
+ if (shown === void 0) return void 0;
28
+ const keys = [...new Set(at.keys.filter((v) => typeof v === "string"))];
29
+ if (keys.length === 0) return {};
30
+ return namesIn((await run({
31
+ kind: "aggregate",
32
+ source: at.source,
33
+ measures: [{
34
+ id: "m1",
35
+ measure: listingMeasure(model, at.member)
36
+ }],
37
+ dimensions: [{
38
+ id: "d1",
39
+ member: at.member
40
+ }, {
41
+ id: "d2",
42
+ member: shown
43
+ }],
44
+ filters: {
45
+ member: at.member,
46
+ op: "in",
47
+ values: keys
48
+ }
49
+ })).rows, 0, 1);
50
+ }
51
+ /**
21
52
  * The labels of an answer's dimension columns that are `shownAs` another: from the answer's own
22
53
  * rows when it groups by the names too, else by one query grouped by the value and its name,
23
54
  * under the same viewer and lock (the query's closure holds the names, so whoever may not read
@@ -34,35 +65,16 @@ function labelColumns(model, answer, run) {
34
65
  ...column,
35
66
  labels: namesIn(sets.flatMap((r) => r ?? []), i, named)
36
67
  };
37
- const keys = [...new Set(cellsAt(i, sets).filter((v) => typeof v === "string"))];
38
- if (keys.length === 0) return {
39
- ...column,
40
- labels: {}
41
- };
42
- const read = await run({
43
- kind: "aggregate",
68
+ const keys = cellsAt(i, sets);
69
+ const at = {
44
70
  source: query.source,
45
- measures: [{
46
- id: "m1",
47
- measure: listingMeasure(model, column.member)
48
- }],
49
- dimensions: [{
50
- id: "d1",
51
- member: column.member
52
- }, {
53
- id: "d2",
54
- member: shown
55
- }],
56
- filters: {
57
- member: column.member,
58
- op: "in",
59
- values: keys
60
- }
61
- });
71
+ member: column.member,
72
+ keys
73
+ };
62
74
  return {
63
75
  ...column,
64
- labels: namesIn(read.rows, 0, 1)
76
+ labels: await namesOf(model, at, run) ?? {}
65
77
  };
66
78
  }));
67
79
  }
68
- export { labelColumns };
80
+ export { labelColumns, namesOf };
package/dist/request.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HttpError } from "./http.mjs";
2
+ import { ZONE_HEADER } from "derive-dashboards/core";
2
3
  // src/request.ts
3
4
  /** The signed-in viewer a request runs as; anything else is a 401. */
4
5
  function userOf(principal) {
@@ -9,12 +10,32 @@ function userOf(principal) {
9
10
  function nowOf(options) {
10
11
  return options.now?.() ?? /* @__PURE__ */ new Date();
11
12
  }
12
- /** The request's calendar: the dashboard's zone, then the host's, then UTC. */
13
- function calendarOf(options, doc) {
13
+ /** A zone the runtime knows; anything else is left out rather than thrown on. */
14
+ function knownZone(zone) {
15
+ if (zone === void 0) return void 0;
16
+ try {
17
+ new Intl.DateTimeFormat("en-US", { timeZone: zone }).format(0);
18
+ return zone;
19
+ } catch {
20
+ return;
21
+ }
22
+ }
23
+ /**
24
+ * The zone a viewer switched to for themselves (`ZONE_HEADER`), where the host lets viewers
25
+ * switch: a known zone, or none.
26
+ */
27
+ const switchedZone = (options, request) => options.time?.viewerZone === true ? knownZone(request?.headers.get(ZONE_HEADER) ?? void 0) : void 0;
28
+ /**
29
+ * The request's calendar. The standard view is one zone for everyone who opens a dashboard: its
30
+ * own, then the host's, then UTC. Where the host sets `time.viewerZone`, a viewer may switch to
31
+ * their own zone for themselves (`ZONE_HEADER` on their requests); nobody else's view changes.
32
+ */
33
+ function calendarOf(options, doc, request) {
34
+ const { time } = options;
14
35
  return {
15
- timezone: doc?.scope.timezone ?? options.time?.timezone ?? "UTC",
16
- weekStart: options.time?.weekStart ?? 1,
17
- fiscalYearStartMonth: options.time?.fiscalYearStartMonth ?? 1
36
+ timezone: switchedZone(options, request) ?? doc?.scope.timezone ?? time?.timezone ?? "UTC",
37
+ weekStart: time?.weekStart ?? 1,
38
+ fiscalYearStartMonth: time?.fiscalYearStartMonth ?? 1
18
39
  };
19
40
  }
20
41
  export { calendarOf, nowOf, userOf };
package/dist/tiles.mjs CHANGED
@@ -21,7 +21,7 @@ function tileExecution(ctx, tile) {
21
21
  request: ctx.request,
22
22
  principal: ctx.principal,
23
23
  now: ctx.now,
24
- calendar: calendarOf(options, ctx.doc),
24
+ calendar: calendarOf(options, ctx.doc, ctx.request),
25
25
  query: composed.query,
26
26
  lock: composed.lock,
27
27
  coverage: composed.coverage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "derive-dashboards",
3
- "version": "0.11.2",
3
+ "version": "0.12.1",
4
4
  "description": "Open-source embedded dashboards for your product: the server, the engine, React components, charts and the CLI, in one package.",
5
5
  "type": "module",
6
6
  "license": "MIT",