@cosmicdrift/kumiko-types 0.378.0 → 0.380.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.
@@ -1,8 +1,15 @@
1
- declare const EXECUTOR_ONLY: unique symbol;
2
- export interface ExecutorOnly {
3
- readonly [EXECUTOR_ONLY]: true;
1
+ import type { DbRunner } from "./db-connection.ts";
2
+ import type { EntityTableMeta } from "./entity-table-meta-types.ts";
3
+ import type { SchemaTable } from "./schema-table-types.ts";
4
+ declare const WRITABLE: unique symbol;
5
+ export interface Writable {
6
+ readonly [WRITABLE]: true;
4
7
  }
5
- export type NotExecutorOnly = {
6
- readonly [EXECUTOR_ONLY]?: never;
7
- };
8
+ export type WritableTable = EntityTableMeta & Writable;
9
+ declare const EXECUTOR_MANAGED_WRITE: unique symbol;
10
+ export interface ExecutorManagedWriteCapability {
11
+ readonly [EXECUTOR_MANAGED_WRITE]: true;
12
+ }
13
+ export type ExecutorManagedRunner = DbRunner & ExecutorManagedWriteCapability;
14
+ export type WritableSchemaTable = SchemaTable & Writable;
8
15
  export {};
package/dist/fields.d.ts CHANGED
@@ -493,6 +493,10 @@ export type EmbeddedDerivedCellDef = {
493
493
  readonly op: "multiply" | "sum" | "subtract" | "percent";
494
494
  readonly from: readonly string[];
495
495
  };
496
+ export type EmbeddedTotalDef = string | {
497
+ readonly label: string;
498
+ readonly from: readonly string[];
499
+ };
496
500
  export type EmbeddedFieldDef = {
497
501
  readonly type: "embedded";
498
502
  readonly description?: string;
@@ -519,9 +523,12 @@ export type EmbeddedFieldDef = {
519
523
  * sub-fields of the same row, rounded to that sub-field's declared
520
524
  * precision. Only valid with `multiple: true`. */
521
525
  readonly derived?: Readonly<Record<string, EmbeddedDerivedCellDef>>;
522
- /** Renderer metadata: numeric sub-field names to sum in a totals row. Only
523
- * valid with `multiple: true`. */
524
- readonly totals?: readonly string[];
526
+ /** Renderer metadata: footer totals. A string is the sum of that numeric
527
+ * sub-field under the column label; an object shows the sum of all `from`
528
+ * sub-fields under its own i18n `label` (e.g. net, VAT, gross). Display
529
+ * only; the server derivation is unchanged. Only valid with
530
+ * `multiple: true`. */
531
+ readonly totals?: readonly EmbeddedTotalDef[];
525
532
  /** Maps an embedded-list subfield name to a sibling top-level money field
526
533
  * name — the sum of that subfield across all rows must equal the sibling
527
534
  * field's amount. Validated both client- and server-side (schema-builder
@@ -637,6 +644,10 @@ export type FilesFieldDef = {
637
644
  readonly maxSize?: string;
638
645
  readonly accept?: readonly string[];
639
646
  readonly maxCount?: number;
647
+ /** `"list"` (default) shows the picked files as a list with a file picker; `"dropzone"` shows a
648
+ * drag-and-drop zone with one status row per file, a remove action per file and the field's
649
+ * `maxCount`/`accept`/`maxSize` as hints. The stored value is the same array of FileRef ids. */
650
+ readonly display?: "list" | "dropzone";
640
651
  readonly access?: FieldAccess;
641
652
  } & ResolvedPiiFlags;
642
653
  export type ImagesFieldDef = {
@@ -645,6 +656,10 @@ export type ImagesFieldDef = {
645
656
  readonly maxSize?: string;
646
657
  readonly accept?: readonly string[];
647
658
  readonly maxCount?: number;
659
+ /** `"list"` (default) shows the picked files as a list with a file picker; `"dropzone"` shows a
660
+ * drag-and-drop zone with one status row per file, a remove action per file and the field's
661
+ * `maxCount`/`accept`/`maxSize` as hints. The stored value is the same array of FileRef ids. */
662
+ readonly display?: "list" | "dropzone";
648
663
  readonly variants?: Readonly<Record<string, VariantSpec>>;
649
664
  /** Forwarded to the file input's `capture` attribute so a phone opens the
650
665
  * camera instead of the file picker. */
@@ -232,7 +232,7 @@ type SharedContextFields = {
232
232
  readonly forTenant?: (tenantId: TenantId) => TenantWriteTarget;
233
233
  /** Mints the per-request `ctx.config`; set by the boot (`addConfigAccessorFactory`) from the effective `configResolver`, overriding an app-supplied value. */
234
234
  readonly configAccessorFactory?: ConfigAccessorFactory;
235
- /** @deprecated Use `configAccessorFactory`; the underscore name is removed in the next major. */
235
+ /** @deprecated Use `configAccessorFactory`; the underscore name is removed in 0.390.0. */
236
236
  readonly _configAccessorFactory?: ConfigAccessorFactory;
237
237
  readonly configEncryption?: import("./envelope-cipher-types.ts").EnvelopeCipher;
238
238
  readonly rateLimit?: import("./rate-limit-types.ts").RateLimitResolver;
@@ -297,15 +297,12 @@ export type HandlerContext<TMap extends object = KumikoEventTypeMap> = SharedCon
297
297
  * Same tenant scoping as `db`, but never bound to the handler's tx: writes through it survive
298
298
  * a rollback. `undefined` only in the denial phases (member-resolution, before-transaction)
299
299
  * and in platform-metering tenant mode; narrow with `hasOutsideTransactionDb(ctx)` or take it
300
- * via `requireOutsideTransactionDb(ctx)` (`@cosmicdrift/kumiko-framework/db`). For
300
+ * via `requireOutsideTransactionDb(ctx)` (`@cosmicdrift/kumiko-framework/db`). For atomic
301
+ * multi-statement writes outside the tx use `runInOwnTransaction(ctx.dbOutsideTransaction, fn)`; `fn`
302
+ * must not touch rows the handler's own tx has locked. For
301
303
  * r.systemScope() handlers it is a fail-closed Proxy; use `systemDb.outsideTransaction`.
302
304
  */
303
305
  readonly dbOutsideTransaction: TenantDb | undefined;
304
- /**
305
- * @deprecated Use `runInOwnTransaction(ctx.dbOutsideTransaction, fn)` from
306
- * `@cosmicdrift/kumiko-framework/db`; removed in the next major.
307
- */
308
- readonly outsideTransaction?: <T>(fn: (db: TenantDb) => Promise<T>) => Promise<T>;
309
306
  readonly systemDb?: UncheckedSystemDb;
310
307
  readonly registry: Registry;
311
308
  /** Aktiver SessionUser des Handler-Aufrufs — Convenience-Alias zu
@@ -460,7 +457,7 @@ export type EventPiiSubject = {
460
457
  } | {
461
458
  readonly personal: "self";
462
459
  } | {
463
- /** @deprecated use `{ personal: { of: "<ownerField>" } }` instead. */
460
+ /** @deprecated use `{ personal: { of: "<ownerField>" } }` instead. Removed in 0.390.0. */
464
461
  readonly subjectField: string;
465
462
  };
466
463
  export type EventPiiFields = Readonly<Record<string, EventPiiSubject>>;
@@ -1,12 +1,12 @@
1
1
  import type { RunIn } from "./config.ts";
2
- import type { DbRunner } from "./db-connection.ts";
3
2
  import type { StoredEvent } from "./event-store-types.ts";
3
+ import type { ExecutorManagedRunner } from "./executor-brand.ts";
4
4
  import type { EntityDefinition } from "./fields.ts";
5
5
  import type { MultiStreamApplyContext } from "./multi-stream-apply-context-types.ts";
6
6
  import type { SchemaTable } from "./schema-table-types.ts";
7
7
  export type ProjectionTable = SchemaTable;
8
- export type SingleStreamApplyFn<TPayload = Record<string, unknown>> = (event: StoredEvent<TPayload>, tx: DbRunner, table: ProjectionTable) => Promise<void>;
9
- export type MultiStreamApplyFn<TPayload = Record<string, unknown>> = (event: StoredEvent<TPayload>, tx: DbRunner, ctx: MultiStreamApplyContext) => Promise<void>;
8
+ export type SingleStreamApplyFn<TPayload = Record<string, unknown>> = (event: StoredEvent<TPayload>, tx: ExecutorManagedRunner, table: ProjectionTable) => Promise<void>;
9
+ export type MultiStreamApplyFn<TPayload = Record<string, unknown>> = (event: StoredEvent<TPayload>, tx: ExecutorManagedRunner, ctx: MultiStreamApplyContext) => Promise<void>;
10
10
  export type ProjectionRowIdOf = (source: Pick<StoredEvent, "tenantId" | "aggregateId">) => string;
11
11
  export type ProjectionDefinition = {
12
12
  readonly name: string;
package/dist/screen.d.ts CHANGED
@@ -925,6 +925,15 @@ export type DashboardTextBlock = {
925
925
  } | {
926
926
  readonly kind: "hint";
927
927
  readonly text: string;
928
+ } | {
929
+ readonly kind: "link";
930
+ /** Link label (i18n key). */
931
+ readonly text: string;
932
+ /** Same-feature short id or cross-feature QN `<feature>:screen:<id>`. */
933
+ readonly screen: string;
934
+ /** Show the link only to users holding one of these roles. Display
935
+ * gate only: the target screen's own `access` stays the enforcement. */
936
+ readonly roles?: readonly string[];
928
937
  };
929
938
  export type DashboardTextPanel = DashboardPanelGate & {
930
939
  readonly kind: "text";
@@ -1703,6 +1712,11 @@ export type ActionFormLoad = {
1703
1712
  readonly query: string;
1704
1713
  /** Payload key carrying the record id (default "id"). */
1705
1714
  readonly idParam?: string;
1715
+ /** The query picks the row from the caller's tenant/session context, so the
1716
+ * form loads without a record id and the query is called WITHOUT `idParam`
1717
+ * (same semantics as `ProjectionDetailScreenDefinition.singleton`). Boot
1718
+ * rejects declaring `idParam` alongside it. */
1719
+ readonly singleton?: boolean;
1706
1720
  };
1707
1721
  /** One key figure of the success box, read from the handler's success payload. */
1708
1722
  export type ActionFormSuccessFact = {
@@ -1,12 +1,11 @@
1
1
  import type { AggregateRow, AggregateSpec } from "./aggregate-types.ts";
2
2
  import type { DbRunner } from "./db-connection.ts";
3
3
  import type { EntityTableMeta } from "./entity-table-meta-types.ts";
4
- import type { ExecutorOnly, NotExecutorOnly } from "./executor-brand.ts";
4
+ import type { ExecutorManagedWriteCapability, Writable, WritableTable } from "./executor-brand.ts";
5
5
  import type { TenantId } from "./identifiers.ts";
6
6
  import type { SchemaTable } from "./schema-table-types.ts";
7
7
  import type { TenancyBrand } from "./tenancy-brand.ts";
8
8
  import type { SelectOptions, WhereObject } from "./where-clause-types.ts";
9
- type WritableTable = (SchemaTable | EntityTableMeta) & NotExecutorOnly;
10
9
  type GlobalReads = {
11
10
  selectMany<T = Record<string, unknown>>(where?: WhereObject, options?: SelectOptions): Promise<readonly T[]>;
12
11
  fetchOne<T = Record<string, unknown>>(where: WhereObject): Promise<T | undefined>;
@@ -16,7 +15,7 @@ type GlobalWrites = {
16
15
  updateMany<T = Record<string, unknown>>(set: Record<string, unknown>, where: WhereObject): Promise<readonly T[]>;
17
16
  deleteMany(where: WhereObject): Promise<void>;
18
17
  };
19
- export type GlobalTableDb<TTable> = GlobalReads & (TTable extends ExecutorOnly ? unknown : GlobalWrites);
18
+ export type GlobalTableDb<TTable> = GlobalReads & (TTable extends Writable ? GlobalWrites : unknown);
20
19
  /**
21
20
  * TenantDb scope modes:
22
21
  *
@@ -30,7 +29,12 @@ export type GlobalTableDb<TTable> = GlobalReads & (TTable extends ExecutorOnly ?
30
29
  */
31
30
  export type TenantDbMode = "tenant" | "system";
32
31
  export type CrossTenantReads = Pick<TenantDb, "selectMany" | "fetchOne" | "count">;
33
- export type TenantDb = {
32
+ export type TenantDbWrites<TTable> = {
33
+ insertOne<T = Record<string, unknown>>(table: TTable, values: Record<string, unknown>): Promise<T | undefined>;
34
+ updateMany<T = Record<string, unknown>>(table: TTable, set: Record<string, unknown>, where: WhereObject): Promise<readonly T[]>;
35
+ deleteMany(table: TTable, where: WhereObject): Promise<number>;
36
+ };
37
+ type TenantDbNonWrites = {
34
38
  readonly tenantId: TenantId;
35
39
  readonly mode: TenantDbMode;
36
40
  /**
@@ -51,11 +55,12 @@ export type TenantDb = {
51
55
  * commit or rollback. Keys of different tenants never contend. Only serialises inside a transaction.
52
56
  */
53
57
  advisoryXactLock(namespace: number, key: string): Promise<void>;
58
+ /** Postgres `now()`; inside a transaction this is the transaction start. */
59
+ databaseNow(): Promise<Date>;
54
60
  aggregate(table: SchemaTable | EntityTableMeta, spec: AggregateSpec, where?: WhereObject): Promise<readonly AggregateRow[]>;
55
- insertOne<T = Record<string, unknown>>(table: WritableTable, values: Record<string, unknown>): Promise<T | undefined>;
56
- updateMany<T = Record<string, unknown>>(table: WritableTable, set: Record<string, unknown>, where: WhereObject): Promise<readonly T[]>;
57
- deleteMany(table: WritableTable, where: WhereObject): Promise<number>;
58
61
  };
62
+ export type TenantDb = TenantDbNonWrites & TenantDbWrites<WritableTable>;
63
+ export type ExecutorManagedTenantDb = TenantDbNonWrites & TenantDbWrites<EntityTableMeta> & ExecutorManagedWriteCapability;
59
64
  export declare const SYSTEM_SCOPE_CHECK_BRAND: unique symbol;
60
65
  export type UncheckedSystemDb = {
61
66
  readonly [SYSTEM_SCOPE_CHECK_BRAND]: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-types",
3
- "version": "0.378.0",
3
+ "version": "0.380.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>",
package/src/changes.json CHANGED
@@ -1,4 +1,11 @@
1
1
  [
2
+ {
3
+ "version": "0.379.0",
4
+ "type": "breaking",
5
+ "title": "HandlerContext.outsideTransaction removed",
6
+ "detail": "The deprecated outsideTransaction field no longer exists on HandlerContext. ctx.dbOutsideTransaction together with runInOwnTransaction replaces it.",
7
+ "migration": "Replace ctx.outsideTransaction(fn) with runInOwnTransaction(requireOutsideTransactionDb(ctx), fn); both are exported from @cosmicdrift/kumiko-framework/db and fn keeps its (db) => Promise signature."
8
+ },
2
9
  {
3
10
  "version": "0.377.0",
4
11
  "type": "improvement",