@cosmicdrift/kumiko-framework 0.299.0 → 0.304.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/package.json +4 -4
- package/src/api/__tests__/api.test.ts +3 -2
- package/src/api/__tests__/http-route-entry.integration.test.ts +114 -0
- package/src/api/auth-routes.ts +53 -24
- package/src/api/server.ts +71 -32
- package/src/changes.json +26 -0
- package/src/engine/__tests__/http-route-anonymous-required.test.ts +43 -0
- package/src/engine/__tests__/membership-roles.test.ts +13 -4
- package/src/engine/boot-validator/__tests__/access-declarations.test.ts +127 -0
- package/src/engine/boot-validator/__tests__/no-all-role-in-handler-access.test.ts +77 -0
- package/src/engine/boot-validator/access-declarations.ts +59 -7
- package/src/engine/boot-validator/entity-handler.ts +20 -0
- package/src/engine/feature-ast/__tests__/patch.test.ts +1 -0
- package/src/engine/feature-ast/__tests__/patcher.test.ts +1 -0
- package/src/engine/feature-ast/__tests__/read-optional-access-rule.test.ts +14 -0
- package/src/engine/feature-ast/extractors/hooks.ts +3 -1
- package/src/engine/feature-ast/extractors/jobs-routes.ts +5 -2
- package/src/engine/feature-ast/patcher.ts +2 -2
- package/src/engine/feature-ast/patterns.ts +1 -1
- package/src/engine/feature-ast/render.ts +1 -1
- package/src/engine/feature-ui-extensions.ts +6 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/membership-roles.ts +20 -4
- package/src/engine/pattern-library/__tests__/library.test.ts +1 -0
- package/src/engine/pattern-library/mixed-schemas.ts +1 -0
- package/src/engine/types/index.ts +2 -0
- package/src/observability/__tests__/metrics-wiring.test.ts +61 -0
- package/src/observability/index.ts +5 -0
- package/src/observability/metrics-wiring.ts +32 -0
- package/src/testing/handler-context.ts +3 -1
- package/src/ui-types/index.ts +2 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createNoopProvider } from "./noop-provider";
|
|
3
|
+
import { createPrometheusMeter, type PrometheusMeter } from "./prometheus-meter";
|
|
4
|
+
import type { ObservabilityProvider } from "./types";
|
|
5
|
+
|
|
6
|
+
export const prometheusMetricsEnvSchema = z.object({
|
|
7
|
+
PROMETHEUS_METRICS_TOKEN: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(32)
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Bearer token for /metrics; unset keeps the endpoint off.")
|
|
12
|
+
.meta({ kumiko: { pulumi: { secret: true, generator: "openssl rand -base64 32" } } }),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
type PrometheusObservabilityProvider = ObservabilityProvider & { readonly meter: PrometheusMeter };
|
|
16
|
+
|
|
17
|
+
export type ObservabilityWiring =
|
|
18
|
+
| {
|
|
19
|
+
readonly observability: PrometheusObservabilityProvider;
|
|
20
|
+
readonly metrics: { readonly path: string; readonly token: string };
|
|
21
|
+
}
|
|
22
|
+
| Record<string, never>;
|
|
23
|
+
|
|
24
|
+
// Fail-closed: public tenant hosts share the /metrics port, so no token means no endpoint.
|
|
25
|
+
export function resolveObservabilityWiring(metricsToken: string | undefined): ObservabilityWiring {
|
|
26
|
+
if (!metricsToken) return {};
|
|
27
|
+
return {
|
|
28
|
+
// Overrides the spread's name "noop", which would otherwise show up in diagnostics/logs.
|
|
29
|
+
observability: { ...createNoopProvider(), name: "prometheus", meter: createPrometheusMeter() },
|
|
30
|
+
metrics: { path: "/metrics", token: metricsToken },
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// production services (delivery-service uses it to run cross-feature notify
|
|
6
6
|
// calls without a real dispatcher). Hence the runtime classification despite
|
|
7
7
|
// living under `testing/` — no vitest imports, no test side-effects.
|
|
8
|
+
|
|
9
|
+
import { ANONYMOUS_ROLE } from "../engine/system-user";
|
|
8
10
|
import type {
|
|
9
11
|
AppendEventArgs,
|
|
10
12
|
FetchForWritingArgs,
|
|
@@ -76,7 +78,7 @@ export function bridgeStub(opts?: {
|
|
|
76
78
|
const stubUser: SessionUser = opts?.user ?? {
|
|
77
79
|
id: "00000000-0000-0000-0000-000000000000",
|
|
78
80
|
tenantId: "00000000-0000-0000-0000-000000000000" as SessionUser["tenantId"], // @cast-boundary engine-bridge
|
|
79
|
-
roles: [
|
|
81
|
+
roles: [ANONYMOUS_ROLE],
|
|
80
82
|
};
|
|
81
83
|
return {
|
|
82
84
|
user: stubUser,
|
package/src/ui-types/index.ts
CHANGED
|
@@ -61,6 +61,8 @@ export type {
|
|
|
61
61
|
OpenToAllAccessRule,
|
|
62
62
|
OpenToAllDeclaration,
|
|
63
63
|
OpenToAllPersonalData,
|
|
64
|
+
RoleAccessPersonalData,
|
|
65
|
+
RoleAccessRule,
|
|
64
66
|
} from "../engine/types/handlers";
|
|
65
67
|
export { isOpenToAllGranted } from "../engine/types/handlers";
|
|
66
68
|
export type { IconKey, NavDefinition, NavIconKey } from "../engine/types/nav";
|