@cosmicdrift/kumiko-types 0.379.0 → 0.381.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/executor-brand.d.ts +13 -6
- package/dist/projection.d.ts +3 -3
- package/dist/tenant-db-types.d.ts +10 -7
- package/package.json +1 -1
package/dist/executor-brand.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
6
|
-
|
|
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/projection.d.ts
CHANGED
|
@@ -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:
|
|
9
|
-
export type MultiStreamApplyFn<TPayload = Record<string, unknown>> = (event: StoredEvent<TPayload>, tx:
|
|
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;
|
|
@@ -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 {
|
|
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
|
|
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
|
|
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
|
/**
|
|
@@ -54,10 +58,9 @@ export type TenantDb = {
|
|
|
54
58
|
/** Postgres `now()`; inside a transaction this is the transaction start. */
|
|
55
59
|
databaseNow(): Promise<Date>;
|
|
56
60
|
aggregate(table: SchemaTable | EntityTableMeta, spec: AggregateSpec, where?: WhereObject): Promise<readonly AggregateRow[]>;
|
|
57
|
-
insertOne<T = Record<string, unknown>>(table: WritableTable, values: Record<string, unknown>): Promise<T | undefined>;
|
|
58
|
-
updateMany<T = Record<string, unknown>>(table: WritableTable, set: Record<string, unknown>, where: WhereObject): Promise<readonly T[]>;
|
|
59
|
-
deleteMany(table: WritableTable, where: WhereObject): Promise<number>;
|
|
60
61
|
};
|
|
62
|
+
export type TenantDb = TenantDbNonWrites & TenantDbWrites<WritableTable>;
|
|
63
|
+
export type ExecutorManagedTenantDb = TenantDbNonWrites & TenantDbWrites<EntityTableMeta> & ExecutorManagedWriteCapability;
|
|
61
64
|
export declare const SYSTEM_SCOPE_CHECK_BRAND: unique symbol;
|
|
62
65
|
export type UncheckedSystemDb = {
|
|
63
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.
|
|
3
|
+
"version": "0.381.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>",
|