@cosmicdrift/kumiko-types 0.165.0 → 0.165.2
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/LICENSE +1 -1
- package/README.md +15 -0
- package/package.json +10 -4
- package/src/concurrency-mode.ts +4 -1
- package/src/config-scope.ts +4 -1
- package/src/db-connection.ts +18 -4
- package/src/entity-table-meta-types.ts +3 -3
- package/src/feature.ts +1 -1
- package/src/fields.ts +2 -0
- package/src/file-storage-provider-types.ts +6 -0
- package/src/handlers.ts +6 -0
- package/src/rate-limit-types.ts +2 -0
- package/src/relations.ts +4 -2
- package/src/schema-table-types.ts +6 -0
- package/src/where-clause-types.ts +9 -3
- package/src/write-error-info-types.ts +2 -4
package/LICENSE
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @cosmicdrift/kumiko-types
|
|
2
|
+
|
|
3
|
+
[](../../LICENSE)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
|
|
6
|
+
Framework type definitions for Kumiko — `FeatureDefinition`, boot-check types,
|
|
7
|
+
and the pure engine types. Lets downstream consumers build against the type
|
|
8
|
+
contracts without importing the whole framework package.
|
|
9
|
+
|
|
10
|
+
Also contains the identity-sensitive error classes (`event-store-errors.ts`,
|
|
11
|
+
`kms-adapter-types.ts`) as runtime code — `kumiko-framework`/
|
|
12
|
+
`kumiko-bundled-features` declare this package as a `peerDependency`
|
|
13
|
+
(single-copy constraint), not a plain dependency.
|
|
14
|
+
|
|
15
|
+
See the [monorepo root README](../../README.md) for the broader pitch.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.165.
|
|
4
|
-
"description": "Framework-Type-Definitions für Kumiko — FeatureDefinition, BootCheck-Types und die reinen Engine-Types
|
|
3
|
+
"version": "0.165.2",
|
|
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 auch die identitaets-sensitiven Error-Klassen (event-store-errors.ts, kms-adapter-types.ts) als Runtime-Code — kumiko-framework/kumiko-bundled-features deklarieren dieses Package deshalb als peerDependency (Single-Copy-Zwang), nicht als plain dependency.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
7
7
|
"repository": {
|
|
@@ -227,9 +227,15 @@
|
|
|
227
227
|
"default": "./src/snapshot-types.ts"
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
|
-
"
|
|
230
|
+
"devDependencies": {
|
|
231
231
|
"hono": "^4.12.18",
|
|
232
|
-
"postgres": "^3.4.9"
|
|
232
|
+
"postgres": "^3.4.9",
|
|
233
|
+
"temporal-polyfill": "^0.3.2"
|
|
234
|
+
},
|
|
235
|
+
"peerDependencies": {
|
|
236
|
+
"hono": "^4.12.18",
|
|
237
|
+
"postgres": "^3.4.9",
|
|
238
|
+
"temporal-polyfill": "^0.3.2"
|
|
233
239
|
},
|
|
234
240
|
"publishConfig": {
|
|
235
241
|
"registry": "https://registry.npmjs.org",
|
package/src/concurrency-mode.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Canonical source — packages/framework/src/engine/constants.ts's
|
|
2
|
+
// ConcurrencyModes value object is `satisfies Record<string, ConcurrencyMode>`
|
|
3
|
+
// against this type, so adding a mode only here (or only there) is a compile
|
|
4
|
+
// error instead of silent drift (#1423/#1439).
|
|
2
5
|
export type ConcurrencyMode = "parallel" | "skip" | "replace" | "sequential" | "debounce";
|
package/src/config-scope.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Canonical source — packages/framework/src/engine/constants.ts's
|
|
2
|
+
// ConfigScopes value object is `satisfies Record<string, ConfigScope>`
|
|
3
|
+
// against this type, so adding a scope only here (or only there) is a
|
|
4
|
+
// compile error instead of silent drift (#1423/#1439).
|
|
2
5
|
export type ConfigScope = "system" | "tenant" | "user";
|
package/src/db-connection.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import type postgres from "postgres";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
export type
|
|
3
|
+
// Minimal structural surface both postgres-js and Bun.SQL satisfy for
|
|
4
|
+
// asRawClient() / query helpers. Avoid `| any` — TS unions with `any`
|
|
5
|
+
// collapse to `any` and erase the postgres side entirely.
|
|
6
|
+
export type RawDbClient = {
|
|
7
|
+
// Signatures are intentionally loose: postgres-js uses (string, values?),
|
|
8
|
+
// Bun.SQL uses tagged templates / unsafe(string). Call sites go through
|
|
9
|
+
// asRawClient() which normalizes at runtime.
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: cross-provider unsafe arity
|
|
11
|
+
unsafe: (...args: any[]) => any;
|
|
12
|
+
// biome-ignore lint/suspicious/noExplicitAny: cross-provider begin arity
|
|
13
|
+
begin: (...args: any[]) => any;
|
|
14
|
+
end?: (options?: { timeout?: number }) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Raw SQL client (postgres-js instance or Bun.SQL). Distinct from the
|
|
18
|
+
// framework's structural pool handle (`DbPoolHandle` in db/api.ts).
|
|
19
|
+
export type DbConnection = ReturnType<typeof postgres> | RawDbClient;
|
|
20
|
+
export type DbTx = postgres.TransactionSql<Record<string, unknown>> | RawDbClient;
|
|
7
21
|
export type DbRunner = DbConnection | DbTx;
|
|
8
22
|
export type DbRow = Record<string, unknown>;
|
|
9
23
|
export type PgClient = ReturnType<typeof postgres>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Plain-data types for EntityTableMeta — split from the runtime
|
|
2
|
-
// (
|
|
2
|
+
// (deriveEntityTableMeta, resolveTableName, defineUnmanagedTable) in
|
|
3
3
|
// entity-table-meta.ts. Prep step for the types-only package extraction
|
|
4
4
|
// (#1283) — this file must have ONLY `import type`, no value imports
|
|
5
5
|
// (crypto/DB deps).
|
|
@@ -73,7 +73,7 @@ export type EntityTableMeta = {
|
|
|
73
73
|
// discriminator to render warnings ("X tables are unmanaged").
|
|
74
74
|
readonly source: "managed" | "unmanaged";
|
|
75
75
|
// PII-subject-annotated field names (pii/userOwned/tenantOwned). Set by
|
|
76
|
-
//
|
|
76
|
+
// deriveEntityTableMeta so the registry can reject r.storeTable stores
|
|
77
77
|
// whose direct writes would skip the executor's encryption (#820).
|
|
78
78
|
readonly piiSubjectFields?: readonly string[];
|
|
79
79
|
};
|
|
@@ -81,7 +81,7 @@ export type EntityTableMeta = {
|
|
|
81
81
|
export type BuildEntityTableMetaOptions = {
|
|
82
82
|
readonly featureName?: string;
|
|
83
83
|
readonly relations?: EntityRelations;
|
|
84
|
-
readonly source?: "
|
|
84
|
+
readonly source?: EntityTableMeta["source"];
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
export type UnmanagedTableInput = {
|
package/src/feature.ts
CHANGED
|
@@ -791,7 +791,7 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
791
791
|
//
|
|
792
792
|
// EntityTableMeta carries the same column-shape that r.entity() builds,
|
|
793
793
|
// minus the audit-trail + base-columns scaffolding. The `meta` argument
|
|
794
|
-
// is the result of `defineUnmanagedTable(...)` / `
|
|
794
|
+
// is the result of `defineUnmanagedTable(...)` / `deriveEntityTableMeta(...)`
|
|
795
795
|
// from `@cosmicdrift/kumiko-framework/db`.
|
|
796
796
|
//
|
|
797
797
|
// The required `reason` string is the marker that justifies the bypass —
|
package/src/fields.ts
CHANGED
|
@@ -220,6 +220,8 @@ export type NumberFieldDef = {
|
|
|
220
220
|
readonly default?: number;
|
|
221
221
|
readonly access?: FieldAccess;
|
|
222
222
|
readonly min?: number;
|
|
223
|
+
/** Upper bound at the write boundary (Zod `.max`). */
|
|
224
|
+
readonly max?: number;
|
|
223
225
|
/** `true` → `integer` column + `.int()` Zod validation. Omitted/`false` →
|
|
224
226
|
* `double precision` column, fractional values allowed. */
|
|
225
227
|
readonly integer?: boolean;
|
|
@@ -20,6 +20,12 @@ export type WriteStreamOptions = {
|
|
|
20
20
|
// shuttle bytes. `mimeType` on write() is a hint for providers that need a
|
|
21
21
|
// Content-Type header (S3/R2/…); local filesystems can ignore it.
|
|
22
22
|
//
|
|
23
|
+
// writeStream/readStream are required, not optional: user-data-export jobs
|
|
24
|
+
// need streams for large files, and providers can satisfy the contract with
|
|
25
|
+
// a single-chunk yield if they don't have a native stream API — an optional
|
|
26
|
+
// type here would let a provider skip them and fail silently in production
|
|
27
|
+
// the first time an export job hits it.
|
|
28
|
+
//
|
|
23
29
|
// getSignedUrl is optional — providers without native presigned-URL support
|
|
24
30
|
// (filesystem) leave it undefined; the route then returns 501 and the
|
|
25
31
|
// client falls back to streaming via GET /files/:id. Callers must
|
package/src/handlers.ts
CHANGED
|
@@ -272,6 +272,12 @@ type SharedContextFields = {
|
|
|
272
272
|
// the same process. Returns the Set of feature names effectively
|
|
273
273
|
// enabled for that tenant. Absent = all features on (back-compat).
|
|
274
274
|
readonly effectiveFeatures?: (tenantId: TenantId) => ReadonlySet<string>;
|
|
275
|
+
// Queue a side-effect to run after the outermost write transaction commits
|
|
276
|
+
// (same sink as ctx.write / dispatch-write lifecycle afterCommit). Seed
|
|
277
|
+
// helpers and other mid-tx callers use this instead of firing afterCommit
|
|
278
|
+
// hooks synchronously (kumiko-framework#1566). Absent outside a write
|
|
279
|
+
// pipeline — callers fall back to immediate fire (fixture / no-tx paths).
|
|
280
|
+
readonly scheduleAfterCommit?: (hook: () => Promise<void>) => void;
|
|
275
281
|
};
|
|
276
282
|
|
|
277
283
|
// All optional — used at pipeline/system boundaries.
|
package/src/rate-limit-types.ts
CHANGED
package/src/relations.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
type
|
|
1
|
+
// Canonical definition — packages/framework/src/engine/constants.ts imports
|
|
2
|
+
// this type and binds its OnDeleteStrategies runtime object to it via
|
|
3
|
+
// `satisfies`, so a drift between the two fails to compile.
|
|
4
|
+
export type OnDeleteStrategy = "cascade" | "restrict" | "setNull" | "nothing";
|
|
3
5
|
|
|
4
6
|
// --- Relations ---
|
|
5
7
|
|
|
@@ -5,6 +5,11 @@ import type { EntityTableMeta, PgType } from "./entity-table-meta-types";
|
|
|
5
5
|
// exactly the same unique-symbol type as the one used to construct the table.
|
|
6
6
|
export const KUMIKO_NAME_SYMBOL = Symbol.for("kumiko:schema:Name");
|
|
7
7
|
export const KUMIKO_COLUMNS_SYMBOL = Symbol.for("kumiko:schema:Columns");
|
|
8
|
+
// Shadow-proof handle on the canonical EntityTableMeta — SchemaTable also
|
|
9
|
+
// spreads these fields as enumerable string-keyed props, which an entity
|
|
10
|
+
// field named `source`/`columns`/`tableName`/… could shadow; readers that
|
|
11
|
+
// need the canonical meta regardless of shadowing use this symbol instead.
|
|
12
|
+
export const KUMIKO_META_SYMBOL = Symbol.for("kumiko:schema:Meta");
|
|
8
13
|
|
|
9
14
|
// Column handle exposed on the SchemaTable. The `name` is the SQL column
|
|
10
15
|
// name (snake_case); legacy code accesses `table.fieldName.name` to
|
|
@@ -20,5 +25,6 @@ export type ColumnHandle = {
|
|
|
20
25
|
export type SchemaTable = EntityTableMeta & {
|
|
21
26
|
readonly [KUMIKO_NAME_SYMBOL]: string;
|
|
22
27
|
readonly [KUMIKO_COLUMNS_SYMBOL]: Record<string, ColumnHandle>;
|
|
28
|
+
readonly [KUMIKO_META_SYMBOL]: EntityTableMeta;
|
|
23
29
|
readonly [field: string]: unknown;
|
|
24
30
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// WhereValue: primitive for eq, array for IN, null for IS NULL, or an
|
|
2
|
-
// operator-object for range/comparisons.
|
|
2
|
+
// operator-object for range/comparisons. Deliberately NOT `unknown |
|
|
3
|
+
// WhereOperator` — that union collapses to `unknown` and erases the
|
|
4
|
+
// operator form at every call site (a typo like `{ gtee: x }` would
|
|
5
|
+
// type-check, then bind as eq at runtime).
|
|
3
6
|
export type WhereOperator = {
|
|
4
7
|
readonly gt?: unknown;
|
|
5
8
|
readonly gte?: unknown;
|
|
@@ -9,8 +12,11 @@ export type WhereOperator = {
|
|
|
9
12
|
readonly in?: readonly unknown[];
|
|
10
13
|
readonly like?: string;
|
|
11
14
|
};
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
15
|
+
export type WherePrimitive = string | number | boolean | bigint | Date | null | undefined;
|
|
16
|
+
export type WhereValue = WherePrimitive | readonly WherePrimitive[] | WhereOperator;
|
|
17
|
+
// Wider index so dynamic Record<string, unknown> builders still typecheck;
|
|
18
|
+
// annotate literals as WhereValue / satisfies WhereValue to catch typos.
|
|
19
|
+
export type WhereObject = Record<string, WhereValue | unknown>;
|
|
14
20
|
|
|
15
21
|
export type OrderByClause = {
|
|
16
22
|
readonly col: string;
|
|
@@ -12,10 +12,8 @@ export type WriteErrorInfo = {
|
|
|
12
12
|
readonly details?: unknown;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
// The failure half of WriteResult — `{ isSuccess: false } + error`.
|
|
16
|
-
//
|
|
17
|
-
// share one shape instead of restating it. Not generic: the error carries
|
|
18
|
-
// zero data, so there's nothing for the caller to narrow.
|
|
15
|
+
// The failure half of WriteResult — `{ isSuccess: false } + error`. Not
|
|
16
|
+
// generic: the error carries zero data, so there's nothing to narrow.
|
|
19
17
|
export type WriteFailure = {
|
|
20
18
|
readonly isSuccess: false;
|
|
21
19
|
readonly error: WriteErrorInfo;
|