@cosmicdrift/kumiko-framework 0.397.0 → 0.399.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.
@@ -0,0 +1,119 @@
1
+ <!-- Generated by `bun run gen:agent-docs` from packages/framework/src/errors/index.ts. Do not edit. -->
2
+
3
+ # @cosmicdrift/kumiko-framework/errors
4
+
5
+ Import from `@cosmicdrift/kumiko-framework/errors`. Types used here but not exported by any entry point are in `api/types.md`.
6
+
7
+ ## Functions
8
+
9
+ ```ts
10
+ function failNotFound(entity: string, id?: number | string): WriteFailure;
11
+ function failTransition(from: string, to: string, allowed: string[]): WriteFailure; // Convenience for state-transition rejects: produces a WriteFailure with reason="invalid_transition", a structured `from`/`to`/`allowed` detail block, and a readable message.
12
+ function failUnprocessable(reason: string, details?: Readonly<Record<string, unknown>> & { reason?: never; }): WriteFailure;
13
+ function isKumikoError(e: unknown): e is KumikoError;
14
+ function reraiseAsKumikoError(info: WriteErrorInfo): KumikoError;
15
+ function subjectErasedConflict(cause?: unknown): ConflictError;
16
+ function validationErrorFromZod(error: ZodError): ValidationError;
17
+ function writeFailure(err: KumikoError): WriteFailure;
18
+ ```
19
+
20
+ ## Constants
21
+
22
+ ```ts
23
+ const FrameworkReasons: { staleState; invalidTransition; fieldAccessDenied; deleteRestricted; featureDisabled; systemIdentitySwitchDenied; identitySwitchDenied; tenantOverrideRequiresSystemAdmin; notifyForeignTenantBroadcast; unsafeAllTenantsDenied; memberResolutionDenied; memberResolutionReadOnly; publicIntakeRequired; irreversibleOperationRequiresHighRisk; instructionFieldWriteRequiresHighRisk; subjectErased; fileRejected; fileViolatesBindTarget };
24
+ ```
25
+
26
+ ## Classes
27
+
28
+ ```ts
29
+ class AccessDeniedError extends KumikoError {
30
+ constructor(opts?: Pick<ErrorOpts, "message" | "i18nKey" | "i18nParams" | "details" | "cause">);
31
+ code: unknown;
32
+ httpStatus: unknown;
33
+ }
34
+ class ConflictError extends KumikoError {
35
+ constructor(opts?: Pick<ErrorOpts, "message" | "i18nKey" | "i18nParams" | "details" | "cause">);
36
+ code: string;
37
+ httpStatus: unknown;
38
+ }
39
+ class FeatureDisabledError extends KumikoError {
40
+ constructor(feature: string, handler: string, opts?: Pick<ErrorOpts, "cause">);
41
+ code: unknown;
42
+ httpStatus: unknown;
43
+ }
44
+ class InternalError extends KumikoError {
45
+ constructor(opts?: Pick<ErrorOpts, "message" | "i18nKey" | "i18nParams" | "details" | "cause">);
46
+ code: unknown;
47
+ httpStatus: unknown;
48
+ }
49
+ class KumikoError extends Error {
50
+ constructor(input: ErrorCtorInput);
51
+ code: string;
52
+ httpStatus: number;
53
+ i18nKey: string;
54
+ i18nParams: Readonly<Record<string, unknown>> | undefined;
55
+ details: unknown;
56
+ retryAfterSeconds: number | undefined;
57
+ }
58
+ class NotFoundError extends KumikoError {
59
+ constructor(entity: string, id?: string | number, opts?: Pick<ErrorOpts, "i18nKey" | "i18nParams" | "cause">);
60
+ code: unknown;
61
+ httpStatus: unknown;
62
+ }
63
+ class RateLimitError extends KumikoError {
64
+ constructor(details: RateLimitDetails, opts?: Pick<ErrorOpts, "i18nKey" | "cause">);
65
+ code: unknown;
66
+ httpStatus: unknown;
67
+ details: RateLimitDetails;
68
+ }
69
+ class UnconfiguredError extends UnprocessableError {
70
+ constructor(details: UnconfiguredDetails, opts?: Pick<ErrorOpts, "i18nKey" | "cause">);
71
+ code: string;
72
+ }
73
+ class UniqueViolationError extends ConflictError {
74
+ constructor(details: UniqueViolationDetails, opts?: Pick<ErrorOpts, "i18nKey" | "cause">);
75
+ code: string;
76
+ }
77
+ class UnprocessableError extends KumikoError {
78
+ constructor(reason: string, opts?: UnprocessableOpts);
79
+ code: string;
80
+ httpStatus: unknown;
81
+ }
82
+ class ValidationError extends KumikoError {
83
+ constructor(details: ValidationDetails, opts?: Pick<ErrorOpts, "i18nKey" | "cause">);
84
+ code: unknown;
85
+ httpStatus: unknown;
86
+ }
87
+ class VersionConflictError extends ConflictError {
88
+ constructor(details: VersionConflictDetails, opts?: Pick<ErrorOpts, "i18nKey" | "cause">);
89
+ code: string;
90
+ }
91
+ ```
92
+
93
+ ## Types
94
+
95
+ ```ts
96
+ type ErrorDocsConfig = { // Links an app's own error reasons to its own docs; uncovered reasons fall back to the framework page of the error code.
97
+ baseUrl: string;
98
+ reasons?: string[] | "all";
99
+ };
100
+ type FieldIssue = {
101
+ path: string;
102
+ code: string;
103
+ i18nKey: string;
104
+ params?: Readonly<Record<string, unknown>>;
105
+ };
106
+ type WriteErrorInfo = {
107
+ code: string;
108
+ httpStatus: number;
109
+ i18nKey: string;
110
+ i18nParams?: Readonly<Record<string, unknown>>;
111
+ message: string;
112
+ details?: unknown;
113
+ retryAfterSeconds?: number;
114
+ };
115
+ type WriteFailure = {
116
+ isSuccess: false;
117
+ error: WriteErrorInfo;
118
+ };
119
+ ```
@@ -0,0 +1,99 @@
1
+ <!-- Generated by `bun run gen:agent-docs` from packages/framework/src/event-store/index.ts. Do not edit. -->
2
+
3
+ # @cosmicdrift/kumiko-framework/event-store
4
+
5
+ Import from `@cosmicdrift/kumiko-framework/event-store`. Types used here but not exported by any entry point are in `api/types.md`.
6
+
7
+ ## Functions
8
+
9
+ ```ts
10
+ function append(db: DbRunner, event: EventToAppend): Promise<StoredEvent>;
11
+ function appendEventInTenantDb(tenantDb: TenantDb, event: Omit<EventToAppend, "tenantId">, options?: AppendEventInTenantDbOptions): Promise<StoredEvent>;
12
+ function appendProvenanceEvent(db: TenantDb, event: ProvenanceEventInput): Promise<void>;
13
+ function archiveStream(db: DbRunner, args: ArchiveStreamArgs): Promise<void>;
14
+ function assertSeedModeNotInProduction(env?: Readonly<Record<string, string | undefined>>): void;
15
+ function backfillEventPiiEncryption(db: DbRunner, registry: Registry, options?: PiiBackfillOptions): Promise<PiiBackfillResult>;
16
+ function backfillEventPiiEncryptionBatch(db: DbRunner, registry: Registry, options?: PiiBackfillBatchOptions): Promise<PiiBackfillBatchResult>;
17
+ function createArchivedStreamsTable(db: DbConnection): Promise<void>;
18
+ function createEventsTable(db: DbConnection): Promise<void>;
19
+ function deleteRowsWithoutReplayableStream(db: AnyDb, args: DeleteRowsWithoutReplayableStreamArgs): Promise<string[]>;
20
+ function getEventsHighWaterMark(db: DbRunner): Promise<bigint>;
21
+ function getStreamVersion(db: DbRunner, aggregateId: string, tenantId: TenantId): Promise<number>;
22
+ function getStreamVersionInTenantDb(tenantDb: TenantDb, aggregateId: string): Promise<number>;
23
+ function getStreamVersions(db: DbRunner, aggregateIds: string[], tenantId: TenantId): Promise<Map<string, number>>;
24
+ function getUnscopedAggregateStreamMaxVersion(db: DbRunner, aggregateId: string): Promise<number>; // MAX(version) for one aggregate — no tenant filter.
25
+ function getUnscopedStreamMaxVersionForSeed(...args: Parameters<typeof getUnscopedAggregateStreamMaxVersion>): ReturnType<typeof getUnscopedAggregateStreamMaxVersion>; // Seed/orphan helper — prefer this over importing the restricted existence-oracle by name.
26
+ function isSeedModeEnabled(env?: Readonly<Record<string, string | undefined>>): boolean;
27
+ function isStreamArchived(db: DbRunner, tenantId: TenantId, aggregateId: string): Promise<boolean>;
28
+ function loadAggregate(db: DbRunner, aggregateId: string, tenantId: TenantId, options?: { includeArchived?: boolean; aggregateType?: string; atVersion?: number; }): Promise<StoredEvent[]>;
29
+ function makeUpcastCtx(db: DbRunner, tenantId: TenantId): EventUpcastCtx;
30
+ function runSeedWritesAt<T>(createdAt: Temporal.Instant, fn: () => Promise<T>): Promise<T>; // Runs `fn` so that every event appended inside it (through the normal write path: handlers, validation, projections) is stored with `createdAt` instead of the database `now()`.
31
+ function streamAllEventsByType(db: DbRunner, aggregateType: string, batchSize?, signal?: AbortSignal): AsyncIterable<StoredEvent>;
32
+ function transferAggregateStreams(db: DbRunner, args: TransferAggregateStreamsArgs): Promise<number>;
33
+ function upcastStoredEvent(event: StoredEvent, upcasters: EventUpcasters, ctx: EventUpcastCtx): Promise<StoredEvent>;
34
+ ```
35
+
36
+ ## Constants
37
+
38
+ ```ts
39
+ const AGGREGATE_TRANSFERRED_EVENT_TYPE: "kumiko:system:aggregate.transferred";
40
+ const AGGREGATE_TRANSFER_STREAM_TYPE: "aggregate-transfer";
41
+ const APP_INSTANCE_STREAM_TYPE: "app-instance";
42
+ const APP_STARTED_EVENT_TYPE: "kumiko:system:app.started";
43
+ const SEED_MODE_ENV: "KUMIKO_TEST_SEED";
44
+ const archivedStreamsTable: WritableSchemaTable;
45
+ const eventsTable: WritableSchemaTable;
46
+ const snapshotsTable: WritableSchemaTable;
47
+ const upcasterDeadLetterTable: WritableSchemaTable;
48
+ ```
49
+
50
+ ## Classes
51
+
52
+ ```ts
53
+ class SeedModeDisabledError extends Error {
54
+ constructor(message: string);
55
+ }
56
+ class SeedTimeOrderError extends Error {
57
+ constructor(aggregateType: string, aggregateId: string, version: number, seedCreatedAt: Temporal.Instant, predecessorCreatedAt: Temporal.Instant);
58
+ aggregateType: string;
59
+ aggregateId: string;
60
+ version: number;
61
+ seedCreatedAt: Temporal.Instant;
62
+ predecessorCreatedAt: Temporal.Instant;
63
+ }
64
+ class VersionConflictError extends Error {
65
+ constructor(aggregateId: string, expectedVersion: number, currentVersion?: number);
66
+ aggregateId: string;
67
+ expectedVersion: number;
68
+ currentVersion: number | undefined;
69
+ }
70
+ ```
71
+
72
+ ## Types
73
+
74
+ ```ts
75
+ type EventMetadata = {
76
+ userId: string;
77
+ requestId?: string;
78
+ correlationId?: string;
79
+ causationId?: string;
80
+ idempotencyKey?: string;
81
+ headers?: Readonly<Record<string, string | number | boolean>>;
82
+ feature?: string;
83
+ handler?: string;
84
+ writeOrigin?: WriteOrigin;
85
+ };
86
+ type StoredEvent<TPayload = Record<string, unknown>> = {
87
+ id: string;
88
+ aggregateId: string;
89
+ aggregateType: string;
90
+ tenantId: TenantId;
91
+ version: number;
92
+ type: string;
93
+ eventVersion: number;
94
+ payload: TPayload;
95
+ metadata: EventMetadata;
96
+ createdAt: Temporal.Instant;
97
+ createdBy: string;
98
+ };
99
+ ```
@@ -0,0 +1,26 @@
1
+ <!-- Generated by `bun run gen:agent-docs` from packages/framework/src/seeding/index.ts. Do not edit. -->
2
+
3
+ # @cosmicdrift/kumiko-framework/seeding
4
+
5
+ Import from `@cosmicdrift/kumiko-framework/seeding`. Types used here but not exported by any entry point are in `api/types.md`.
6
+
7
+ ## Functions
8
+
9
+ ```ts
10
+ function createTestUser(overrides?: Partial<Omit<SessionUser, "id">> & { id?: string | number; }): SessionUser;
11
+ function runEventStoreSeed<TId extends string | number = string, TExisting extends EventStoreSeedExisting<TId> = EventStoreSeedExisting<TId>>(opts: RunEventStoreSeedOptions<TId, TExisting>): Promise<{ id: TId; }>; // Shared create-or-skip/update path for event-store boot-seed helpers.
12
+ function testTenantId(n: number): TenantId;
13
+ function testUserId(n: number): string;
14
+ ```
15
+
16
+ ## Constants
17
+
18
+ ```ts
19
+ const TestUsers: { admin; systemAdmin; user; driver; otherTenant };
20
+ ```
21
+
22
+ ## Types
23
+
24
+ ```ts
25
+ type SeedIfExists = "skip" | "update"; // Boot-seed semantics for event-sourced entity helpers.
26
+ ```