@cosmicdrift/kumiko-types 0.385.0 → 0.386.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/db-connection.d.ts +2 -2
- package/dist/handlers.d.ts +3 -1
- package/dist/handlers.js +13 -1
- package/package.json +1 -1
- package/src/changes.json +6 -0
package/dist/db-connection.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type postgres from "postgres";
|
|
2
2
|
export type RawDbClient = {
|
|
3
|
-
unsafe: (
|
|
4
|
-
begin: (
|
|
3
|
+
unsafe: (sql: string, params?: readonly unknown[]) => PromiseLike<readonly unknown[]>;
|
|
4
|
+
begin: <T>(fn: (tx: DbTx) => Promise<T>) => Promise<T>;
|
|
5
5
|
end?: (options?: {
|
|
6
6
|
timeout?: number;
|
|
7
7
|
}) => Promise<void>;
|
package/dist/handlers.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type RoleAccessRule = {
|
|
|
30
30
|
readonly personalData?: RoleAccessPersonalData;
|
|
31
31
|
};
|
|
32
32
|
export type AccessRule = RoleAccessRule | OpenToAllAccessRule;
|
|
33
|
-
export declare const ESCAPE_HATCH_GRANTS: readonly ["systemIdentity", "globalWrites", "unsafeRaw"];
|
|
33
|
+
export declare const ESCAPE_HATCH_GRANTS: readonly ["systemIdentity", "globalWrites", "unsafeRaw", "crossTenantReads"];
|
|
34
34
|
export type EscapeHatchGrant = (typeof ESCAPE_HATCH_GRANTS)[number];
|
|
35
35
|
export type EscapeHatchDeclaration = {
|
|
36
36
|
readonly reason: string;
|
|
@@ -39,6 +39,7 @@ export type EscapeHatchDeclaration = {
|
|
|
39
39
|
export declare function isEscapeHatchGrant(value: unknown): value is EscapeHatchGrant;
|
|
40
40
|
export declare function escapeHatchAllows(declaration: EscapeHatchDeclaration | undefined, grant: EscapeHatchGrant): boolean;
|
|
41
41
|
export declare function escapeHatchFor(declaration: EscapeHatchDeclaration | undefined, grant: EscapeHatchGrant): EscapeHatchDeclaration | undefined;
|
|
42
|
+
export declare function crossTenantReadsGrantFor(declaration: EscapeHatchDeclaration | undefined): EscapeHatchDeclaration | undefined;
|
|
42
43
|
export declare function escapeHatchGrantsProblem(declaration: {
|
|
43
44
|
readonly grants?: unknown;
|
|
44
45
|
}): string | undefined;
|
|
@@ -304,6 +305,7 @@ export type HandlerContext<TMap extends object = KumikoEventTypeMap> = SharedCon
|
|
|
304
305
|
*/
|
|
305
306
|
readonly dbOutsideTransaction: TenantDb | undefined;
|
|
306
307
|
readonly systemDb?: UncheckedSystemDb;
|
|
308
|
+
readonly crossTenantReads?: CrossTenantReads;
|
|
307
309
|
readonly registry: Registry;
|
|
308
310
|
/** Aktiver SessionUser des Handler-Aufrufs — Convenience-Alias zu
|
|
309
311
|
* `event.user`. Existiert weil Handler intuitiv `ctx.user.tenantId`
|
package/dist/handlers.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { isOneOf, propertyOf } from "./type-guards.js";
|
|
2
|
-
export const ESCAPE_HATCH_GRANTS = [
|
|
2
|
+
export const ESCAPE_HATCH_GRANTS = [
|
|
3
|
+
"systemIdentity",
|
|
4
|
+
"globalWrites",
|
|
5
|
+
"unsafeRaw",
|
|
6
|
+
"crossTenantReads",
|
|
7
|
+
];
|
|
3
8
|
export function isEscapeHatchGrant(value) {
|
|
4
9
|
return ESCAPE_HATCH_GRANTS.some((grant) => grant === value);
|
|
5
10
|
}
|
|
@@ -13,6 +18,13 @@ export function escapeHatchAllows(declaration, grant) {
|
|
|
13
18
|
export function escapeHatchFor(declaration, grant) {
|
|
14
19
|
return escapeHatchAllows(declaration, grant) ? declaration : undefined;
|
|
15
20
|
}
|
|
21
|
+
// unsafeRaw hands out a raw runner that reads everything anyway, so it implies the read-only grant.
|
|
22
|
+
export function crossTenantReadsGrantFor(declaration) {
|
|
23
|
+
return escapeHatchAllows(declaration, "crossTenantReads") ||
|
|
24
|
+
escapeHatchAllows(declaration, "unsafeRaw")
|
|
25
|
+
? declaration
|
|
26
|
+
: undefined;
|
|
27
|
+
}
|
|
16
28
|
// Boot-time check of `grants` (untyped sources can carry anything): must be a non-empty list of known grants.
|
|
17
29
|
export function escapeHatchGrantsProblem(declaration) {
|
|
18
30
|
const { grants } = declaration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.386.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>",
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.386.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "RawDbClient is typed instead of any",
|
|
6
|
+
"detail": "`RawDbClient.unsafe` and `begin` have real signatures, so `db.unsafe(...)` on a `DbConnection` no longer collapses to `any`. A hand-built fake runner needs `unsafe(sql, params?)` returning rows and a `begin` that takes a callback."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.385.0",
|
|
4
10
|
"type": "improvement",
|