derive-dashboards 0.11.2 → 0.12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # derive-dashboards
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
3
9
  ## 0.11.2
4
10
 
5
11
  ### 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 };
@@ -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/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.0",
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",