@cosmicdrift/kumiko-types 0.350.0 → 0.352.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/dist/fields.d.ts CHANGED
@@ -213,6 +213,14 @@ export type SelectFieldDef<TOptions extends readonly string[] = readonly string[
213
213
  /** Payload sent with every `optionsQuery` call. `{ field }` entries re-load the
214
214
  * options when that sibling field changes. */
215
215
  readonly optionsQueryPayload?: OptionsQueryPayload;
216
+ /** Marks static options as unavailable per tenant (e.g. by tier). Contract:
217
+ * `{ rows: { value: string; disabled?: boolean; hint?: string }[] }`. The renderer
218
+ * loads it (with `optionsQueryPayload` resolved like for `optionsQuery`, `{}` when
219
+ * absent) and merges it onto `options`: `disabled` disables the option, `hint` becomes
220
+ * its description. The currently stored value always stays enabled; unknown values
221
+ * are ignored. Static `options` stay authoritative, and the write path must enforce
222
+ * the same rule (see `withTierOptionGate`), the renderer only mirrors it. */
223
+ readonly optionsAvailabilityQuery?: string;
216
224
  } & ResolvedPiiFlags;
217
225
  export type MultiSelectFieldDef<TOptions extends readonly string[] = readonly string[]> = {
218
226
  readonly type: "multiSelect";
@@ -2,7 +2,7 @@ import type { Redis } from "ioredis";
2
2
  import type { ZodType } from "zod";
3
3
  import type { CacheSyncBus } from "./cache-sync-types.js";
4
4
  import type { ConfigAccessor, ConfigAccessorFactory, ConfigResolver } from "./config.js";
5
- import type { DbConnection } from "./db-connection.js";
5
+ import type { DbConnection, DbTx } from "./db-connection.js";
6
6
  import type { DerivativesContext } from "./derivatives-types.js";
7
7
  import type { EntityCache } from "./entity-cache.js";
8
8
  import type { EventMetadata, WriteOrigin } from "./event-store-types.js";
@@ -505,12 +505,24 @@ export type AgentExposure = {
505
505
  };
506
506
  /** Undoes a reservation made before the handler transaction. */
507
507
  export type ReservationRelease = () => Promise<void>;
508
- /** Runs in the dispatcher after access and schema checks but before the
509
- * handler transaction opens, so it must commit its own short write instead
510
- * of holding a second connection while the transaction is open. The returned
511
- * release runs when the transaction does not commit (failure result, throw,
512
- * rollback, failed commit). Throwing a KumikoError rejects the write. */
513
- export type PreTransactionReservation = (event: WriteEvent, ctx: HandlerContext) => Promise<ReservationRelease | undefined>;
508
+ /** The dispatcher's own open handler transaction: a reservation must settle on it, not on
509
+ * HandlerContext, whose db is fail-closed for r.systemScope() handlers. */
510
+ export type ReservationConfirmContext = {
511
+ readonly tx: DbTx;
512
+ readonly tenantId: TenantId;
513
+ };
514
+ /** A reservation that also settles inside the handler transaction. `confirmInTransaction` runs
515
+ * after the handler succeeded and before COMMIT; a throw fails the write and rolls it back. */
516
+ export type ReservationHandle = {
517
+ readonly release: ReservationRelease;
518
+ readonly confirmInTransaction: (confirm: ReservationConfirmContext) => Promise<void>;
519
+ };
520
+ /** Runs in the dispatcher after every pre-handler gate (feature, rate limit, access, schema,
521
+ * validation, field roles) passed but before the handler transaction opens, so it must commit
522
+ * its own short write instead of holding a second connection while the transaction is open.
523
+ * The returned release (or handle.release) runs when the transaction does not commit (failure
524
+ * result, throw, rollback, failed commit). Throwing a KumikoError rejects the write. */
525
+ export type PreTransactionReservation = (event: WriteEvent, ctx: HandlerContext) => Promise<ReservationRelease | ReservationHandle | undefined>;
514
526
  export type WriteHandlerDef = {
515
527
  readonly name: string;
516
528
  readonly schema: ZodType;
@@ -1,4 +1,4 @@
1
- import type { Temporal } from "temporal-polyfill";
1
+ import type { Temporal } from "./temporal.js";
2
2
  export type RateLimitDecision = {
3
3
  readonly allowed: boolean;
4
4
  readonly limit: number;
package/dist/screen.d.ts CHANGED
@@ -691,6 +691,9 @@ export type DashboardPanelQueryOptions = {
691
691
  * `timeRange` still is. */
692
692
  readonly ignoreScreenFilter?: boolean;
693
693
  };
694
+ export type DashboardPanelGate = {
695
+ readonly visibleWhen?: DashboardPanelVisibility;
696
+ };
694
697
  export type DashboardPanelSpan = "half" | "full";
695
698
  export type DashboardPanelEmptyState = {
696
699
  readonly span?: DashboardPanelSpan;
@@ -698,11 +701,11 @@ export type DashboardPanelEmptyState = {
698
701
  /** Second line under `emptyLabel`. */
699
702
  readonly emptyHint?: string;
700
703
  };
701
- export type DashboardStatPanel = DashboardPanelQueryOptions & {
704
+ export type DashboardStatPanel = DashboardPanelQueryOptions & DashboardPanelGate & {
702
705
  readonly kind: "stat";
703
706
  /** Stable id: kebab-case, unique within the panel set. */
704
707
  readonly id: string;
705
- /** Anzeige-Text (i18n-Key). */
708
+ /** Display text (i18n key). */
706
709
  readonly label: string;
707
710
  readonly query: string;
708
711
  readonly valueField: string;
@@ -715,29 +718,49 @@ export type DashboardStatPanel = DashboardPanelQueryOptions & {
715
718
  /** Record field holding `{ atMs, value | null }[]` (MetricResult.points),
716
719
  * drawn as a sparkline next to the value. */
717
720
  readonly sparklineField?: string;
718
- /** Optionaler Delta-Chip (z.B. "↓23 %") neben dem Label. Nur wenn BEIDE
719
- * Felder gesetzt sind UND der Query-Handler sie liefert, rendert der Chip
720
- * — sonst bleibt die Kachel wie ohne Delta. `deltaToneField` fällt auf
721
- * `toneField`/"default" zurück, wenn ungesetzt. */
721
+ /** Delta chip (e.g. "↓23 %") next to the label. It renders only when BOTH
722
+ * fields are set AND the query handler returns them; otherwise the tile
723
+ * looks as it does without a delta. `deltaToneField` falls back to
724
+ * `toneField`/"default" when unset. */
722
725
  readonly deltaField?: string;
723
726
  readonly deltaDirectionField?: string;
724
727
  readonly deltaToneField?: string;
725
- /** Statisches Icon neben dem Label — anders als value/sub/delta variiert
726
- * das Icon nicht pro Query-Result, sondern ist eine Author-Entscheidung
727
- * wie das Panel selbst. Aufgelöst über dieselbe extensionSectionComponents-
728
- * Registry wie custom-Panels; die registrierte Komponente ignoriert
729
- * typischerweise entityName/entityId/filterParams (kein Entity-Kontext
730
- * für ein reines Icon). */
728
+ /** Static icon next to the label. Unlike value/sub/delta it does not vary
729
+ * per query result; it is an author decision like the panel itself.
730
+ * Resolved through the same extensionSectionComponents registry as custom
731
+ * panels; the registered component usually ignores
732
+ * entityName/entityId/filterParams (a plain icon has no entity context). */
731
733
  readonly icon?: PlatformComponent;
732
- /** Statischer CSS-Farbwert (z.B. "var(--color-debt)") für den Icon-Chip —
733
- * Passthrough an die Kachel, keine Registry, kein Lookup. Wirkt NUR wenn
734
- * `icon` gesetzt ist (StatCard rendert den Chip nur zusammen mit einem
735
- * Icon) — ohne icon wird der Wert still verworfen. */
734
+ /** Static CSS color value (e.g. "var(--color-debt)") for the icon chip,
735
+ * passed straight to the tile without a registry lookup. Applies ONLY when
736
+ * `icon` is set (StatCard renders the chip only together with an icon);
737
+ * without an icon the value is silently dropped. Without `accentColor` the
738
+ * chip follows the tone, including a `toneField` value delivered per result.
739
+ * An accent that should change with the result (e.g. by sign) goes through
740
+ * `toneField`; leave `accentColor` unset then. */
736
741
  readonly accentColor?: string;
737
742
  };
738
743
  export type DashboardChartKind = "timeseries" | "stacked-bars" | "segment-bars" | "stacked-area";
739
744
  export type DashboardChartTone = "positive" | "negative" | "active" | "neutral";
740
- export type DashboardChartPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & {
745
+ /** Look of the markers whose `kind` matches: a dashed guide line through the
746
+ * plot plus a colored pin. `color` (raw CSS color) wins over `tone`. */
747
+ export type DashboardChartMarkerKind = {
748
+ readonly tone?: DashboardChartTone;
749
+ readonly color?: string;
750
+ };
751
+ /** One option of a stacked-area range switch. Without `months` the option
752
+ * shows every bucket; with it, a window of that many months anchored at
753
+ * `todayMs` (or the last bucket). `label` is an i18n key. */
754
+ export type DashboardChartRangeOption = {
755
+ readonly value: string;
756
+ readonly label: string;
757
+ readonly months?: number;
758
+ };
759
+ export type DashboardChartRanges = {
760
+ readonly options: readonly DashboardChartRangeOption[];
761
+ readonly default: string;
762
+ };
763
+ export type DashboardChartPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & DashboardPanelGate & {
741
764
  readonly kind: "chart";
742
765
  readonly id: string;
743
766
  readonly label: string;
@@ -745,34 +768,47 @@ export type DashboardChartPanel = DashboardPanelQueryOptions & DashboardPanelEmp
745
768
  readonly query: string;
746
769
  /** i18n key under the title, e.g. "7 days, by creation day". */
747
770
  readonly subtitle?: string;
748
- /** Series/segment key -> tone; unmapped keys fall back to a palette. */
771
+ /** Series/segment/line key -> tone; unmapped keys fall back to a palette. */
749
772
  readonly seriesTones?: Readonly<Record<string, DashboardChartTone>>;
773
+ /** Series/segment/line key -> raw CSS color (e.g. "var(--color-debt)"); wins over `seriesTones`. */
774
+ readonly seriesColors?: Readonly<Record<string, string>>;
750
775
  /** Formats values as currency (minor units): y ticks, legend totals and tooltips on
751
776
  * stacked-bars/segment-bars/stacked-area, only the y ticks on timeseries. */
752
777
  readonly valueFormat?: DashboardValueFormat;
753
778
  /** Only for chart "stacked-area": fixed width per bucket, plot scrolls horizontally. */
754
779
  readonly scrollable?: boolean;
780
+ /** Only for chart "stacked-area": marker `kind` -> look. Markers without a
781
+ * declared kind keep the neutral numbered pin. */
782
+ readonly markerKinds?: Readonly<Record<string, DashboardChartMarkerKind>>;
783
+ /** Only for chart "stacked-area": false hides the per-series sums in the
784
+ * legend (they mean nothing for balances). Default true. */
785
+ readonly legendTotals?: boolean;
786
+ /** Only for chart "stacked-area": range switch in the panel header. */
787
+ readonly ranges?: DashboardChartRanges;
755
788
  };
756
- export type DashboardListPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & {
789
+ export type DashboardListPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & DashboardPanelGate & {
757
790
  readonly kind: "list";
758
791
  readonly id: string;
759
792
  readonly label: string;
760
793
  readonly query: string;
761
794
  readonly columns: readonly ListColumnSpec[];
762
795
  };
763
- export type DashboardStatGroupPanel = {
796
+ export type DashboardStatGroupPanel = DashboardPanelGate & {
764
797
  readonly kind: "stat-group";
765
798
  readonly id: string;
766
799
  readonly label?: string;
800
+ /** i18n key, a line under `label`; the boot validator requires `label`. */
801
+ readonly subtitle?: string;
802
+ readonly span?: DashboardPanelSpan;
767
803
  readonly stats: readonly DashboardStatPanel[];
768
804
  };
769
- export type DashboardFeedPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & {
805
+ export type DashboardFeedPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & DashboardPanelGate & {
770
806
  readonly kind: "feed";
771
807
  readonly id: string;
772
808
  readonly label: string;
773
809
  readonly query: string;
774
810
  };
775
- export type DashboardProgressListPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & {
811
+ export type DashboardProgressListPanel = DashboardPanelQueryOptions & DashboardPanelEmptyState & DashboardPanelGate & {
776
812
  readonly kind: "progress-list";
777
813
  readonly id: string;
778
814
  readonly label: string;
@@ -8,8 +8,9 @@ export declare function createSecret<T>(value: T): Secret<T>;
8
8
  export declare function isSecret(v: unknown): v is Secret<unknown>;
9
9
  type Primitive = string | number | boolean | bigint | symbol | null | undefined;
10
10
  type SafeLeaf = Date | RegExp | Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.PlainTime | Temporal.PlainYearMonth | Temporal.PlainMonthDay | Temporal.Duration | Map<unknown, unknown> | Set<unknown>;
11
- export type ContainsSecret<T> = [T] extends [never] ? false : unknown extends T ? false : T extends Secret<unknown> ? true : T extends Primitive ? false : T extends SafeLeaf ? false : T extends readonly (infer U)[] ? ContainsSecret<U> : T extends object ? true extends {
12
- [K in keyof T]-?: ContainsSecret<T[K]>;
11
+ type MaxSecretDepth = 8;
12
+ export type ContainsSecret<T, Depth extends readonly unknown[] = []> = [T] extends [never] ? false : unknown extends T ? false : Depth["length"] extends MaxSecretDepth ? false : T extends Secret<unknown> ? true : T extends Primitive ? false : T extends SafeLeaf ? false : T extends readonly (infer U)[] ? ContainsSecret<U, [...Depth, unknown]> : T extends object ? true extends {
13
+ [K in keyof T]-?: ContainsSecret<T[K], [...Depth, unknown]>;
13
14
  }[keyof T] ? true : false : false;
14
15
  export type SecretAuditContext = {
15
16
  readonly userId: string;
@@ -0,0 +1,49 @@
1
+ /// <reference types="temporal-polyfill/global" preserve="true" />
2
+ export type TemporalApi = typeof globalThis.Temporal;
3
+ export declare const Temporal: TemporalApi;
4
+ export declare namespace Temporal {
5
+ type ComparisonResult = globalThis.Temporal.ComparisonResult;
6
+ type RoundingMode = globalThis.Temporal.RoundingMode;
7
+ type AssignmentOptions = globalThis.Temporal.AssignmentOptions;
8
+ type DurationOptions = globalThis.Temporal.DurationOptions;
9
+ type ToInstantOptions = globalThis.Temporal.ToInstantOptions;
10
+ type OffsetDisambiguationOptions = globalThis.Temporal.OffsetDisambiguationOptions;
11
+ type ZonedDateTimeAssignmentOptions = globalThis.Temporal.ZonedDateTimeAssignmentOptions;
12
+ type ArithmeticOptions = globalThis.Temporal.ArithmeticOptions;
13
+ type DateUnit = globalThis.Temporal.DateUnit;
14
+ type TimeUnit = globalThis.Temporal.TimeUnit;
15
+ type DateTimeUnit = globalThis.Temporal.DateTimeUnit;
16
+ type ToStringPrecisionOptions = globalThis.Temporal.ToStringPrecisionOptions;
17
+ type ShowCalendarOption = globalThis.Temporal.ShowCalendarOption;
18
+ type CalendarTypeToStringOptions = globalThis.Temporal.CalendarTypeToStringOptions;
19
+ type ZonedDateTimeToStringOptions = globalThis.Temporal.ZonedDateTimeToStringOptions;
20
+ type InstantToStringOptions = globalThis.Temporal.InstantToStringOptions;
21
+ type TransitionDirection = globalThis.Temporal.TransitionDirection;
22
+ type DurationLike = globalThis.Temporal.DurationLike;
23
+ type DurationFormatOptions = globalThis.Temporal.DurationFormatOptions;
24
+ type Duration = globalThis.Temporal.Duration;
25
+ type Instant = globalThis.Temporal.Instant;
26
+ type CalendarLike = globalThis.Temporal.CalendarLike;
27
+ type PlainDateLike = globalThis.Temporal.PlainDateLike;
28
+ type PlainDate = globalThis.Temporal.PlainDate;
29
+ type PlainDateTimeLike = globalThis.Temporal.PlainDateTimeLike;
30
+ type PlainDateTime = globalThis.Temporal.PlainDateTime;
31
+ type PlainMonthDayLike = globalThis.Temporal.PlainMonthDayLike;
32
+ type PlainMonthDay = globalThis.Temporal.PlainMonthDay;
33
+ type PlainTimeLike = globalThis.Temporal.PlainTimeLike;
34
+ type PlainTime = globalThis.Temporal.PlainTime;
35
+ type TimeZoneLike = globalThis.Temporal.TimeZoneLike;
36
+ type PlainYearMonthLike = globalThis.Temporal.PlainYearMonthLike;
37
+ type PlainYearMonth = globalThis.Temporal.PlainYearMonth;
38
+ type ZonedDateTimeLike = globalThis.Temporal.ZonedDateTimeLike;
39
+ type ZonedDateTime = globalThis.Temporal.ZonedDateTime;
40
+ type DurationArithmeticOptions = globalThis.Temporal.DurationArithmeticOptions;
41
+ type DurationRoundTo = globalThis.Temporal.DurationRoundTo;
42
+ type DurationTotalOf = globalThis.Temporal.DurationTotalOf;
43
+ type PluralUnit<T extends globalThis.Temporal.DateTimeUnit> = globalThis.Temporal.PluralUnit<T>;
44
+ type LargestUnit<T extends globalThis.Temporal.DateTimeUnit> = globalThis.Temporal.LargestUnit<T>;
45
+ type SmallestUnit<T extends globalThis.Temporal.DateTimeUnit> = globalThis.Temporal.SmallestUnit<T>;
46
+ type TotalUnit<T extends globalThis.Temporal.DateTimeUnit> = globalThis.Temporal.TotalUnit<T>;
47
+ type DifferenceOptions<T extends globalThis.Temporal.DateTimeUnit> = globalThis.Temporal.DifferenceOptions<T>;
48
+ type RoundTo<T extends globalThis.Temporal.DateTimeUnit> = globalThis.Temporal.RoundTo<T>;
49
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="temporal-polyfill/global" preserve="true" />
2
+ import { Temporal as TemporalPolyfill } from "temporal-polyfill";
3
+ function resolveTemporal() {
4
+ // System boundary: same TC39 API, only the typings differ.
5
+ const native = globalThis.Temporal;
6
+ if (native !== undefined)
7
+ return native;
8
+ const polyfill = TemporalPolyfill;
9
+ Object.assign(globalThis, { Temporal: polyfill });
10
+ return polyfill;
11
+ }
12
+ export const Temporal = resolveTemporal();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-types",
3
- "version": "0.350.0",
3
+ "version": "0.352.0",
4
4
  "description": "Framework-Type-Definitions für Kumiko — FeatureDefinition, BootCheck-Types und die reinen Engine-Types. Erlaubt Downstream-Konsumenten, gegen die Type-Contracts zu bauen, ohne das ganze Framework-Package zu importieren. Enthaelt keine identitaets-sensitiven Runtime-Werte mehr (Error-Klassen leben seit #1629 in kumiko-framework, Brand-Symbole nutzen Symbol.for) und ist deshalb eine plain dependency, keine peerDependency.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -261,6 +261,10 @@
261
261
  "./agent-exposure": {
262
262
  "types": "./dist/agent-exposure.d.ts",
263
263
  "default": "./dist/agent-exposure.js"
264
+ },
265
+ "./temporal": {
266
+ "types": "./dist/temporal.d.ts",
267
+ "default": "./dist/temporal.js"
264
268
  }
265
269
  },
266
270
  "devDependencies": {
@@ -524,6 +528,10 @@
524
528
  "./agent-exposure": {
525
529
  "types": "./dist/agent-exposure.d.ts",
526
530
  "default": "./dist/agent-exposure.js"
531
+ },
532
+ "./temporal": {
533
+ "types": "./dist/temporal.d.ts",
534
+ "default": "./dist/temporal.js"
527
535
  }
528
536
  }
529
537
  },
package/src/changes.json CHANGED
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "version": "0.352.0",
4
+ "type": "improvement",
5
+ "title": "SelectFieldDef.optionsAvailabilityQuery marks static select options as unavailable per tenant",
6
+ "detail": "The query returns { rows: { value, disabled?, hint? }[] }; the renderer merges it onto options and keeps the stored value enabled."
7
+ },
8
+ {
9
+ "version": "0.352.0",
10
+ "type": "breaking",
11
+ "title": "Apps must import Temporal from @cosmicdrift/kumiko-types/temporal instead of temporal-polyfill (affects every app since 0.351.0)",
12
+ "detail": "Since 0.351.0 the native globalThis.Temporal wins over the polyfill. A Temporal imported from \"temporal-polyfill\" is a second implementation, so instanceof and z.instanceof(Temporal.Instant) reject values the framework creates. This applies whether you upgrade from before 0.351.0 or are already on it.",
13
+ "migration": "Replace every value import from \"temporal-polyfill\" in app code and tests, e.g. `import { Temporal } from \"temporal-polyfill\"`, with `import { Temporal } from \"@cosmicdrift/kumiko-types/temporal\"`, and drop side-effect imports of \"temporal-polyfill/global\" (importing @cosmicdrift/kumiko-types/temporal already installs the global when the runtime has none). `import type` and `/// <reference types=\"temporal-polyfill/global\" />` may stay. Then run `kumiko check`; the No-Temporal-Polyfill-Import guard lists anything left. Close the step with `kumiko-upgrade --resolve <id> --reason \"<what you changed>\"`, or add `--not-applicable` when the repo never imported temporal-polyfill."
14
+ },
15
+ {
16
+ "version": "0.351.0",
17
+ "type": "fix",
18
+ "title": "ContainsSecret no longer fails with TS2615 on recursive types such as DashboardI18nText",
19
+ "detail": "ContainsSecret works on recursive types\n`ContainsSecret<T>` stops after eight levels of nesting. Query handlers whose output contains `DashboardI18nText` (which refers to itself through `i18nParams`) no longer fail to compile with TS2615. A secret nested deeper than that is still caught by the runtime leak guard."
20
+ },
21
+ {
22
+ "version": "0.351.0",
23
+ "type": "improvement",
24
+ "title": "New @cosmicdrift/kumiko-types/temporal export resolves one Temporal (native first, polyfill as fallback) for framework and app code",
25
+ "detail": "One Temporal implementation: `@cosmicdrift/kumiko-types/temporal`\nThe new export returns the native `globalThis.Temporal` when the runtime has it (Bun 1.4, current browsers) and falls back to `temporal-polyfill` otherwise, installing it on `globalThis`. Framework, bundled features and renderers import from there, so values made by the framework pass `instanceof` and `z.instanceof(Temporal.Instant)` checks in app code. `ensureTemporalPolyfill()` puts the same instance on the global. Apps should import `Temporal` from `@cosmicdrift/kumiko-types/temporal` instead of `temporal-polyfill`.",
26
+ "migration": "Replace imports from \"temporal-polyfill\" with \"@cosmicdrift/kumiko-types/temporal\" so app code and framework share one set of Temporal classes."
27
+ },
2
28
  {
3
29
  "version": "0.340.0",
4
30
  "type": "improvement",