@cosmicdrift/kumiko-types 0.159.0 → 0.159.1
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/package.json +9 -1
- package/src/entity-cache.ts +35 -0
- package/src/file-handle-types.ts +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.159.
|
|
3
|
+
"version": "0.159.1",
|
|
4
4
|
"description": "Framework-Type-Definitions für Kumiko — FeatureDefinition, BootCheck-Types und die reinen Engine-Types, ohne Runtime-Code. Erlaubt Downstream-Konsumenten, gegen die Type-Contracts zu bauen, ohne das ganze Framework-Package zu importieren.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -77,6 +77,14 @@
|
|
|
77
77
|
"./db-connection": {
|
|
78
78
|
"types": "./src/db-connection.ts",
|
|
79
79
|
"default": "./src/db-connection.ts"
|
|
80
|
+
},
|
|
81
|
+
"./entity-cache": {
|
|
82
|
+
"types": "./src/entity-cache.ts",
|
|
83
|
+
"default": "./src/entity-cache.ts"
|
|
84
|
+
},
|
|
85
|
+
"./file-handle-types": {
|
|
86
|
+
"types": "./src/file-handle-types.ts",
|
|
87
|
+
"default": "./src/file-handle-types.ts"
|
|
80
88
|
}
|
|
81
89
|
},
|
|
82
90
|
"dependencies": {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EntityId, TenantId } from "./identifiers";
|
|
2
|
+
|
|
3
|
+
export type EntityCache = {
|
|
4
|
+
/** Get a single cached entity. Returns null on miss. */
|
|
5
|
+
get(
|
|
6
|
+
tenantId: TenantId,
|
|
7
|
+
entityName: string,
|
|
8
|
+
id: EntityId,
|
|
9
|
+
): Promise<Record<string, unknown> | null>;
|
|
10
|
+
|
|
11
|
+
/** Get multiple cached entities. Returns a Map of id → data (misses are absent). */
|
|
12
|
+
mget(
|
|
13
|
+
tenantId: TenantId,
|
|
14
|
+
entityName: string,
|
|
15
|
+
ids: readonly EntityId[],
|
|
16
|
+
): Promise<Map<EntityId, Record<string, unknown>>>;
|
|
17
|
+
|
|
18
|
+
/** Cache a single entity. */
|
|
19
|
+
set(
|
|
20
|
+
tenantId: TenantId,
|
|
21
|
+
entityName: string,
|
|
22
|
+
id: EntityId,
|
|
23
|
+
data: Record<string, unknown>,
|
|
24
|
+
): Promise<void>;
|
|
25
|
+
|
|
26
|
+
/** Cache multiple entities at once. */
|
|
27
|
+
mset(
|
|
28
|
+
tenantId: TenantId,
|
|
29
|
+
entityName: string,
|
|
30
|
+
entries: ReadonlyArray<{ id: EntityId; data: Record<string, unknown> }>,
|
|
31
|
+
): Promise<void>;
|
|
32
|
+
|
|
33
|
+
/** Invalidate a single cached entity. */
|
|
34
|
+
del(tenantId: TenantId, entityName: string, id: EntityId): Promise<void>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type FileHandle = {
|
|
2
|
+
readonly key: string;
|
|
3
|
+
read(): Promise<Uint8Array>;
|
|
4
|
+
write(data: Uint8Array, mimeType?: string): Promise<void>;
|
|
5
|
+
delete(): Promise<void>;
|
|
6
|
+
exists(): Promise<boolean>;
|
|
7
|
+
// Produce a handle for a derived key (e.g. a thumbnail). Does not touch
|
|
8
|
+
// storage; only computes the key. Writing to the derived handle is the
|
|
9
|
+
// caller's job.
|
|
10
|
+
derive(suffix: string): FileHandle;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// The `ctx.files` service — a factory that materialises a FileHandle for a
|
|
14
|
+
// storage key. One per request/event, bound to a single tenant: the provider
|
|
15
|
+
// is resolved per-tenant through file-foundation, so uploads, ctx.files and the
|
|
16
|
+
// GDPR jobs all hit the same store by construction.
|
|
17
|
+
export type FileContext = {
|
|
18
|
+
ref(key: string): FileHandle;
|
|
19
|
+
};
|