@cosmicdrift/kumiko-types 0.159.1 → 0.161.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,30 @@
1
+ export type RateLimitDecision = {
2
+ readonly allowed: boolean;
3
+ readonly limit: number;
4
+ readonly remaining: number;
5
+ readonly retryAfterSeconds: number;
6
+ readonly windowSeconds: number;
7
+ readonly resetAt: Temporal.Instant;
8
+ };
9
+
10
+ export type RateLimitConfig = {
11
+ readonly limit: number;
12
+ readonly windowSeconds: number;
13
+ readonly cost?: number;
14
+ };
15
+
16
+ export type RateLimitResolver = {
17
+ // Atomic check + deduct. Returns the decision and current bucket state
18
+ // — caller decides whether to throw RateLimitError or proceed.
19
+ check(bucket: string, config: RateLimitConfig): Promise<RateLimitDecision>;
20
+
21
+ // Convenience: throws RateLimitError when blocked. Useful inside the
22
+ // dispatcher / middleware code-paths where the failure shape is fixed.
23
+ enforce(bucket: string, config: RateLimitConfig): Promise<RateLimitDecision>;
24
+
25
+ // Read-only inspection: returns the same shape as check() but never
26
+ // mutates the bucket — no token deduction, no refill-timestamp update.
27
+ // Use for ops/status queries (e.g. "kumiko rl status user:42") that
28
+ // must observe the bucket without disturbing it.
29
+ peek(bucket: string, config: Omit<RateLimitConfig, "cost">): Promise<RateLimitDecision>;
30
+ };
@@ -0,0 +1,24 @@
1
+ import type { EntityTableMeta, PgType } from "./entity-table-meta-types";
2
+
3
+ // Global-registry symbols the native dialect stamps onto every SchemaTable —
4
+ // shared identity so downstream introspection (Symbol.for lookups) matches
5
+ // exactly the same unique-symbol type as the one used to construct the table.
6
+ export const KUMIKO_NAME_SYMBOL = Symbol.for("kumiko:schema:Name");
7
+ export const KUMIKO_COLUMNS_SYMBOL = Symbol.for("kumiko:schema:Columns");
8
+
9
+ // Column handle exposed on the SchemaTable. The `name` is the SQL column
10
+ // name (snake_case); legacy code accesses `table.fieldName.name` to
11
+ // produce raw SQL.
12
+ export type ColumnHandle = {
13
+ readonly name: string;
14
+ readonly pgType: PgType;
15
+ readonly getSQLType: () => string;
16
+ };
17
+
18
+ // SchemaTable — opaque shape with both EntityTableMeta + Symbol-based
19
+ // introspection. Returned by `table(...)`.
20
+ export type SchemaTable = EntityTableMeta & {
21
+ readonly [KUMIKO_NAME_SYMBOL]: string;
22
+ readonly [KUMIKO_COLUMNS_SYMBOL]: Record<string, ColumnHandle>;
23
+ readonly [field: string]: unknown;
24
+ };