@cosmicdrift/kumiko-types 0.326.1 → 0.328.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/action-icon.d.ts +3 -0
- package/dist/action-icon.js +51 -0
- package/{src/agent-exposure.ts → dist/agent-exposure.d.ts} +8 -15
- package/dist/agent-exposure.js +16 -0
- package/dist/concurrency-mode.d.ts +1 -0
- package/dist/config-scope.d.ts +1 -0
- package/dist/config-scope.js +1 -0
- package/dist/config.d.ts +234 -0
- package/dist/config.js +1 -0
- package/dist/cursor-types.d.ts +16 -0
- package/dist/cursor-types.js +1 -0
- package/dist/db-connection.d.ts +14 -0
- package/dist/db-connection.js +1 -0
- package/dist/define-handler.d.ts +58 -0
- package/dist/define-handler.js +1 -0
- package/dist/derivatives-types.d.ts +53 -0
- package/dist/derivatives-types.js +3 -0
- package/dist/entity-cache.d.ts +16 -0
- package/dist/entity-cache.js +1 -0
- package/dist/entity-handlers.d.ts +54 -0
- package/dist/entity-handlers.js +1 -0
- package/dist/entity-table-meta-types.d.ts +44 -0
- package/dist/entity-table-meta-types.js +6 -0
- package/dist/envelope-cipher-types.d.ts +5 -0
- package/dist/envelope-cipher-types.js +1 -0
- package/dist/event-store-executor-types.d.ts +86 -0
- package/dist/event-store-executor-types.js +1 -0
- package/dist/event-store-types.d.ts +37 -0
- package/dist/event-store-types.js +7 -0
- package/dist/event-type-map.d.ts +8 -0
- package/{src/event-type-map.ts → dist/event-type-map.js} +1 -16
- package/dist/executor-brand.d.ts +8 -0
- package/dist/executor-brand.js +1 -0
- package/dist/extension-options-map.d.ts +9 -0
- package/dist/extension-options-map.js +4 -0
- package/dist/feature.d.ts +518 -0
- package/dist/feature.js +1 -0
- package/dist/field-icon.d.ts +1 -0
- package/dist/field-icon.js +1 -0
- package/dist/fields.d.ts +729 -0
- package/dist/fields.js +50 -0
- package/dist/file-handle-types.d.ts +12 -0
- package/dist/file-handle-types.js +1 -0
- package/dist/file-provider-resolver-types.d.ts +3 -0
- package/dist/file-provider-resolver-types.js +1 -0
- package/dist/file-storage-provider-types.d.ts +17 -0
- package/dist/file-storage-provider-types.js +1 -0
- package/dist/geo-tz.d.ts +17 -0
- package/{src/geo-tz.ts → dist/geo-tz.js} +1 -20
- package/dist/handlers.d.ts +493 -0
- package/dist/handlers.js +49 -0
- package/dist/hook-phase.d.ts +1 -0
- package/dist/hook-phase.js +1 -0
- package/dist/hooks.d.ts +75 -0
- package/dist/hooks.js +1 -0
- package/dist/http-route.d.ts +52 -0
- package/dist/http-route.js +13 -0
- package/dist/identifiers.d.ts +8 -0
- package/{src/identifiers.ts → dist/identifiers.js} +7 -24
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/kms-adapter-types.d.ts +68 -0
- package/dist/kms-adapter-types.js +49 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +1 -0
- package/dist/multi-stream-apply-context-types.d.ts +18 -0
- package/dist/multi-stream-apply-context-types.js +1 -0
- package/dist/nav-icon.d.ts +3 -0
- package/dist/nav-icon.js +100 -0
- package/dist/nav.d.ts +39 -0
- package/dist/nav.js +1 -0
- package/dist/observability/index.d.ts +3 -0
- package/dist/observability/index.js +2 -0
- package/dist/observability/metric.d.ts +34 -0
- package/dist/observability/metric.js +3 -0
- package/dist/observability/provider.d.ts +24 -0
- package/dist/observability/provider.js +4 -0
- package/dist/observability/span.d.ts +32 -0
- package/dist/observability/span.js +4 -0
- package/dist/ownership.d.ts +33 -0
- package/dist/ownership.js +5 -0
- package/dist/projection.d.ts +38 -0
- package/dist/projection.js +1 -0
- package/dist/rate-limit-types.d.ts +19 -0
- package/dist/rate-limit-types.js +1 -0
- package/dist/relations.d.ts +25 -0
- package/dist/relations.js +1 -0
- package/dist/schema-table-types.d.ts +15 -0
- package/{src/schema-table-types.ts → dist/schema-table-types.js} +0 -20
- package/dist/screen.d.ts +1265 -0
- package/dist/screen.js +3 -0
- package/dist/search-adapter.d.ts +32 -0
- package/dist/search-adapter.js +1 -0
- package/dist/secrets-types.d.ts +52 -0
- package/dist/secrets-types.js +30 -0
- package/dist/snapshot-types.d.ts +13 -0
- package/dist/snapshot-types.js +1 -0
- package/dist/step.d.ts +304 -0
- package/dist/step.js +11 -0
- package/dist/target-ref.d.ts +5 -0
- package/{src/target-ref.ts → dist/target-ref.js} +1 -6
- package/dist/tenancy-brand.d.ts +6 -0
- package/dist/tenancy-brand.js +1 -0
- package/dist/tenant-db-types.d.ts +67 -0
- package/dist/tenant-db-types.js +5 -0
- package/dist/tree-node.d.ts +26 -0
- package/dist/tree-node.js +22 -0
- package/dist/tz-context.d.ts +48 -0
- package/dist/tz-context.js +6 -0
- package/dist/websocket-route.d.ts +46 -0
- package/dist/websocket-route.js +10 -0
- package/dist/where-clause-types.d.ts +20 -0
- package/dist/where-clause-types.js +1 -0
- package/dist/workspace.d.ts +10 -0
- package/dist/workspace.js +1 -0
- package/dist/write-error-info-types.d.ts +12 -0
- package/dist/write-error-info-types.js +1 -0
- package/package.json +362 -119
- package/src/changes.json +12 -0
- package/src/__tests__/handlers.test.ts +0 -40
- package/src/__tests__/plural-forms.test.ts +0 -18
- package/src/action-icon.ts +0 -57
- package/src/concurrency-mode.ts +0 -5
- package/src/config-scope.ts +0 -5
- package/src/config.ts +0 -563
- package/src/cursor-types.ts +0 -18
- package/src/db-connection.ts +0 -25
- package/src/define-handler.ts +0 -138
- package/src/derivatives-types.ts +0 -106
- package/src/entity-cache.ts +0 -35
- package/src/entity-handlers.ts +0 -68
- package/src/entity-table-meta-types.ts +0 -101
- package/src/envelope-cipher-types.ts +0 -6
- package/src/event-store-executor-types.ts +0 -163
- package/src/event-store-types.ts +0 -85
- package/src/executor-brand.ts +0 -19
- package/src/extension-options-map.ts +0 -21
- package/src/feature.ts +0 -1132
- package/src/field-icon.ts +0 -23
- package/src/fields.ts +0 -1114
- package/src/file-handle-types.ts +0 -20
- package/src/file-provider-resolver-types.ts +0 -7
- package/src/file-storage-provider-types.ts +0 -54
- package/src/handlers.ts +0 -1246
- package/src/hook-phase.ts +0 -2
- package/src/hooks.ts +0 -170
- package/src/http-route.ts +0 -78
- package/src/kms-adapter-types.ts +0 -128
- package/src/logger.ts +0 -7
- package/src/multi-stream-apply-context-types.ts +0 -52
- package/src/nav-icon.ts +0 -105
- package/src/nav.ts +0 -139
- package/src/observability/index.ts +0 -28
- package/src/observability/metric.ts +0 -56
- package/src/observability/provider.ts +0 -32
- package/src/observability/span.ts +0 -58
- package/src/ownership.ts +0 -83
- package/src/projection.ts +0 -170
- package/src/rate-limit-types.ts +0 -32
- package/src/relations.ts +0 -52
- package/src/screen.ts +0 -1593
- package/src/search-adapter.ts +0 -45
- package/src/secrets-types.ts +0 -182
- package/src/snapshot-types.ts +0 -36
- package/src/step.ts +0 -390
- package/src/tenancy-brand.ts +0 -9
- package/src/tenant-db-types.ts +0 -116
- package/src/tree-node.ts +0 -134
- package/src/tz-context.ts +0 -63
- package/src/where-clause-types.ts +0 -31
- package/src/workspace.ts +0 -42
- package/src/write-error-info-types.ts +0 -20
- /package/{src/index.ts → dist/concurrency-mode.js} +0 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import type * as z from "zod";
|
|
2
|
+
import type { ZodType } from "zod";
|
|
3
|
+
import type { ConfigKeyDefinition, ConfigKeyHandle, ConfigKeyType, ConfigSeedDef, ExtensionSelectorDef, JobDefinition, JobHandlerFn, NotificationDataFn, NotificationDefinition, NotificationRecipientFn, NotificationTemplateFn, ReferenceDataDef, RegistrarExtensionDef, RegistrarExtensionRegistration, TranslationKeys, TranslationsDef } from "./config.js";
|
|
4
|
+
import type { QueryHandlerDefinition, StreamHandlerDefinition, WriteHandlerDefinition } from "./define-handler.js";
|
|
5
|
+
import type { RegisterEntityCrudOptions } from "./entity-handlers.js";
|
|
6
|
+
import type { EntityTableMeta } from "./entity-table-meta-types.js";
|
|
7
|
+
import type { ExtensionOptionsArgs, ExtensionOptionsFor } from "./extension-options-map.js";
|
|
8
|
+
import type { EntityDefinition } from "./fields.js";
|
|
9
|
+
import type { AccessRule, AgentHandlerHints, AuthClaimsFn, AuthClaimsHookDef, ClaimKeyDefinition, ClaimKeyHandle, ClaimKeyType, DeclarativeEventMigration, EntityRef, EscapeHatchDeclaration, EventDef, EventMigrationDef, EventPiiStance, EventUpcastFn, HandlerRef, NameOrRef, QualifiedEventName, QueryHandlerDef, QueryHandlerFn, RateLimitDeclaration, StreamHandlerDef, StreamHandlerFn, WriteHandlerDef, WriteHandlerFn } from "./handlers.js";
|
|
10
|
+
import type { EntityHookMap, HookMap, HookPhase, OwnedFn, PostDeleteHookFn, PostQueryHookFn, PostSaveHookFn, PreDeleteHookFn, PreQueryHookFn, PreSaveHookFn, SearchPayloadContributorFn, ValidationHookFn } from "./hooks.js";
|
|
11
|
+
import type { HttpRouteDefinition } from "./http-route.js";
|
|
12
|
+
import type { ContentCollectionDefinition, NavDefinition } from "./nav.js";
|
|
13
|
+
import type { EntityProjectionExtension, MultiStreamProjectionDefinition, ProjectionDefinition } from "./projection.js";
|
|
14
|
+
import type { EntityRelations, RelationDefinition } from "./relations.js";
|
|
15
|
+
import type { ScreenDefinition } from "./screen.js";
|
|
16
|
+
import type { TreeActionDef, TreeActionsHandle } from "./tree-node.js";
|
|
17
|
+
import type { WebSocketRouteDefinition } from "./websocket-route.js";
|
|
18
|
+
import type { WorkspaceDefinition } from "./workspace.js";
|
|
19
|
+
export type FeatureMetricType = "counter" | "histogram" | "gauge";
|
|
20
|
+
export type FeatureMetricDef = {
|
|
21
|
+
readonly shortName: string;
|
|
22
|
+
readonly type: FeatureMetricType;
|
|
23
|
+
readonly description?: string;
|
|
24
|
+
readonly labels?: readonly string[];
|
|
25
|
+
readonly buckets?: readonly number[];
|
|
26
|
+
readonly unit?: string;
|
|
27
|
+
readonly tenantLabel?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type MetricOptions = Omit<FeatureMetricDef, "shortName">;
|
|
30
|
+
export type SecretKeyDefinition = {
|
|
31
|
+
readonly shortName: string;
|
|
32
|
+
readonly qualifiedName: string;
|
|
33
|
+
readonly label: {
|
|
34
|
+
readonly [locale: string]: string;
|
|
35
|
+
};
|
|
36
|
+
readonly redact?: (plaintext: string) => string;
|
|
37
|
+
readonly hint?: {
|
|
38
|
+
readonly [locale: string]: string;
|
|
39
|
+
};
|
|
40
|
+
readonly scope: "tenant";
|
|
41
|
+
readonly required?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type SecretOptions = Omit<SecretKeyDefinition, "shortName" | "qualifiedName">;
|
|
44
|
+
export type SecretKeyHandle = {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
};
|
|
47
|
+
/** Options accepted by `r.storeTable()`. The `reason` is required so the
|
|
48
|
+
* bypass leaves an audit trail at the registration site — reviewers can
|
|
49
|
+
* judge legitimacy without spelunking into history, and a future cleanup
|
|
50
|
+
* pass can find candidates for migration to `r.entity()`. */
|
|
51
|
+
export type StoreTableOptions = {
|
|
52
|
+
/** Why this table needs to bypass the event-sourcing system. Examples:
|
|
53
|
+
* "imported from pre-ES system, read-only", "external Stripe webhook
|
|
54
|
+
* payload cache, write-only by webhook handler", "denormalised
|
|
55
|
+
* projection of a non-Kumiko data source". */
|
|
56
|
+
readonly reason: string;
|
|
57
|
+
/** Direct-write stores skip the executor, so the executor's PII
|
|
58
|
+
* encryption never runs for them — a feature whose meta carries
|
|
59
|
+
* piiSubjectFields must encrypt those fields itself before every
|
|
60
|
+
* insert/update and declare that here, or boot fails (#820). */
|
|
61
|
+
readonly piiEncryptedOnWrite?: true;
|
|
62
|
+
};
|
|
63
|
+
/** Per-feature store-table registration. `meta` is the `EntityTableMeta`
|
|
64
|
+
* (framework-native shape used by `migrate-runner`). Carries the
|
|
65
|
+
* bypass-justification reason but knows nothing about the owning
|
|
66
|
+
* feature — that's added when the registry aggregates entries
|
|
67
|
+
* cross-feature into `StoreTableDef`. */
|
|
68
|
+
export type StoreTableEntry = {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly meta: EntityTableMeta;
|
|
71
|
+
readonly reason: string;
|
|
72
|
+
readonly piiEncryptedOnWrite?: true;
|
|
73
|
+
};
|
|
74
|
+
/** Registry-aggregated store-table — the per-feature `StoreTableEntry` plus
|
|
75
|
+
* the owning feature name. This is what `Registry.getAllStoreTables()`
|
|
76
|
+
* exposes to readers (dev-server, ops UIs). */
|
|
77
|
+
export type StoreTableDef = StoreTableEntry & {
|
|
78
|
+
readonly featureName: string;
|
|
79
|
+
};
|
|
80
|
+
export type UiHintOption = {
|
|
81
|
+
readonly key: string;
|
|
82
|
+
readonly label: string;
|
|
83
|
+
readonly type: "boolean";
|
|
84
|
+
readonly default: boolean;
|
|
85
|
+
};
|
|
86
|
+
export type UiHints = {
|
|
87
|
+
readonly displayLabel?: string;
|
|
88
|
+
readonly category?: string;
|
|
89
|
+
readonly recommended?: boolean;
|
|
90
|
+
readonly configurableOptions?: readonly UiHintOption[];
|
|
91
|
+
};
|
|
92
|
+
export type BootCheckContext = {
|
|
93
|
+
readonly features: readonly FeatureDefinition[];
|
|
94
|
+
};
|
|
95
|
+
export type BootCheckFn = (ctx: BootCheckContext) => void;
|
|
96
|
+
export type FeatureDefinition = {
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly description?: string;
|
|
99
|
+
readonly systemScope: boolean;
|
|
100
|
+
readonly exports?: unknown;
|
|
101
|
+
readonly requires: readonly string[];
|
|
102
|
+
readonly optionalRequires: readonly string[];
|
|
103
|
+
readonly requiredProjections: ReadonlySet<string>;
|
|
104
|
+
readonly requiredSteps: ReadonlySet<string>;
|
|
105
|
+
readonly toggleableDefault?: boolean;
|
|
106
|
+
readonly uiHints?: UiHints;
|
|
107
|
+
readonly entities?: Readonly<Record<string, EntityDefinition>>;
|
|
108
|
+
readonly entityTables?: Readonly<Record<string, unknown>>;
|
|
109
|
+
readonly relations: Readonly<Record<string, EntityRelations>>;
|
|
110
|
+
readonly writeHandlers: Readonly<Record<string, WriteHandlerDef>>;
|
|
111
|
+
readonly queryHandlers: Readonly<Record<string, QueryHandlerDef>>;
|
|
112
|
+
readonly streamHandlers: Readonly<Record<string, StreamHandlerDef>>;
|
|
113
|
+
readonly translations: TranslationKeys;
|
|
114
|
+
readonly hooks?: HookMap;
|
|
115
|
+
readonly entityHooks?: EntityHookMap;
|
|
116
|
+
readonly searchPayloadExtensions?: Readonly<Record<string, readonly OwnedFn<SearchPayloadContributorFn>[]>>;
|
|
117
|
+
readonly configKeys: Readonly<Record<string, ConfigKeyDefinition>>;
|
|
118
|
+
readonly configSeeds: readonly ConfigSeedDef[];
|
|
119
|
+
readonly jobs: Readonly<Record<string, JobDefinition>>;
|
|
120
|
+
readonly registrarExtensions: Readonly<Record<string, RegistrarExtensionDef>>;
|
|
121
|
+
readonly extensionUsages: readonly RegistrarExtensionRegistration[];
|
|
122
|
+
readonly extensionSelectors: readonly ExtensionSelectorDef[];
|
|
123
|
+
/**
|
|
124
|
+
* Cross-feature API names this feature exposes via `r.exposesApi(name)`.
|
|
125
|
+
* Pure Marker-Deklaration — die echte Implementation wird als
|
|
126
|
+
* Query-/Write-Handler unter dem QN-Pattern registriert (z.B.
|
|
127
|
+
* `compliance-profiles:query:effective-profile`). Boot-Validator prüft
|
|
128
|
+
* dass jedes `r.usesApi(name)` einen passenden Exposer hier findet —
|
|
129
|
+
* Tippfehler oder Drop-Refactorings werden zu Boot-Fail statt Runtime-Crash.
|
|
130
|
+
*/
|
|
131
|
+
readonly exposedApis: ReadonlySet<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Cross-feature API names this feature calls. Pflicht-Boot-Check:
|
|
134
|
+
* jeder Eintrag muss in `exposedApis` irgendeines Features auftauchen
|
|
135
|
+
* UND das Provider-Feature muss in requires/optionalRequires sein.
|
|
136
|
+
*/
|
|
137
|
+
readonly usedApis: ReadonlySet<string>;
|
|
138
|
+
/**
|
|
139
|
+
* Boot-time mount-invariant checks declared via `r.bootCheck(fn)`. Run
|
|
140
|
+
* once per feature after all other boot-validators, each with a ctx
|
|
141
|
+
* exposing the full mounted-feature set — throw to fail the boot with a
|
|
142
|
+
* feature-authored message (framework wraps it with `[Feature <name>]`).
|
|
143
|
+
*/
|
|
144
|
+
readonly bootChecks: readonly BootCheckFn[];
|
|
145
|
+
readonly referenceData: readonly ReferenceDataDef[];
|
|
146
|
+
readonly notifications: Readonly<Record<string, NotificationDefinition>>;
|
|
147
|
+
readonly events: Readonly<Record<string, EventDef>>;
|
|
148
|
+
readonly eventMigrations: Readonly<Record<string, readonly EventMigrationDef[]>>;
|
|
149
|
+
readonly configReads: readonly string[];
|
|
150
|
+
readonly handlerEntityMappings: Readonly<Record<string, string>>;
|
|
151
|
+
readonly metrics: Readonly<Record<string, FeatureMetricDef>>;
|
|
152
|
+
readonly secretKeys: Readonly<Record<string, SecretKeyDefinition>>;
|
|
153
|
+
readonly projections: Readonly<Record<string, ProjectionDefinition>>;
|
|
154
|
+
readonly entityProjectionExtensions?: Readonly<Record<string, readonly EntityProjectionExtension[]>>;
|
|
155
|
+
readonly multiStreamProjections: Readonly<Record<string, MultiStreamProjectionDefinition>>;
|
|
156
|
+
readonly authClaimsHooks: readonly AuthClaimsFn[];
|
|
157
|
+
readonly claimKeys: Readonly<Record<string, ClaimKeyDefinition>>;
|
|
158
|
+
readonly screens: Readonly<Record<string, ScreenDefinition>>;
|
|
159
|
+
readonly navs: Readonly<Record<string, NavDefinition>>;
|
|
160
|
+
readonly workspaces: Readonly<Record<string, WorkspaceDefinition>>;
|
|
161
|
+
readonly treeActions?: Readonly<Record<string, TreeActionDef>>;
|
|
162
|
+
readonly contentCollections?: Readonly<Record<string, ContentCollectionDefinition>>;
|
|
163
|
+
readonly httpRoutes: Readonly<Record<string, HttpRouteDefinition>>;
|
|
164
|
+
readonly webSocketRoutes: Readonly<Record<string, WebSocketRouteDefinition>>;
|
|
165
|
+
readonly storeTables: Readonly<Record<string, StoreTableEntry>>;
|
|
166
|
+
readonly envSchema?: z.ZodObject<z.ZodRawShape>;
|
|
167
|
+
readonly dedupeOptions?: Readonly<Record<string, unknown>>;
|
|
168
|
+
};
|
|
169
|
+
type RefOrRefs = NameOrRef | readonly NameOrRef[];
|
|
170
|
+
type HookTarget = RefOrRefs | {
|
|
171
|
+
readonly allOf: NameOrRef;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* `TFeature` is the literal feature-name from `defineFeature("foo", ...)` —
|
|
175
|
+
* default-`string` keeps every existing usage zero-config. Strict-typed
|
|
176
|
+
* features (apps that opt into the literal-name flavour) get propagated
|
|
177
|
+
* through to `defineEvent` so the returned `EventDef.name` is a literal
|
|
178
|
+
* `${CamelToKebab<TFeature>}:event:${CamelToKebab<TInner>}`. That literal
|
|
179
|
+
* threads through `ctx.appendEvent({ type: eventDef.name, ... })`,
|
|
180
|
+
* keeping strict-mode alive even when handlers route via `eventDef.name`
|
|
181
|
+
* instead of hand-typed string literals.
|
|
182
|
+
*/
|
|
183
|
+
/**
|
|
184
|
+
* `r.requires` is a callable+namespace: existing call form takes feature
|
|
185
|
+
* names (`r.requires("auth", "tenant")`), the `.projection` extension
|
|
186
|
+
* declares read-side projection tables that this feature's pipeline
|
|
187
|
+
* steps are allowed to write via `r.step.unsafeProjectionUpsert`.
|
|
188
|
+
* Hard-required for any unsafeProjection-* step usage (see Q10).
|
|
189
|
+
*/
|
|
190
|
+
export type RequiresApi = ((...featureNames: string[]) => void) & ((options: {
|
|
191
|
+
readonly features: readonly string[];
|
|
192
|
+
}) => void) & {
|
|
193
|
+
readonly projection: (tableName: string) => void;
|
|
194
|
+
readonly step: (stepKind: string) => void;
|
|
195
|
+
};
|
|
196
|
+
export type FeatureRegistrar<TFeature extends string = string> = {
|
|
197
|
+
systemScope(): void;
|
|
198
|
+
describe(text: string): void;
|
|
199
|
+
requires: RequiresApi;
|
|
200
|
+
optionalRequires(...featureNames: string[]): void;
|
|
201
|
+
optionalRequires(options: {
|
|
202
|
+
readonly features: readonly string[];
|
|
203
|
+
}): void;
|
|
204
|
+
toggleable(options: {
|
|
205
|
+
default: boolean;
|
|
206
|
+
}): void;
|
|
207
|
+
uiHints(hints: UiHints): void;
|
|
208
|
+
entity(name: string, definition: EntityDefinition, options?: {
|
|
209
|
+
readonly table?: unknown;
|
|
210
|
+
}): EntityRef;
|
|
211
|
+
entity(definition: {
|
|
212
|
+
readonly name: string;
|
|
213
|
+
} & EntityDefinition): EntityRef;
|
|
214
|
+
crud(entityName: string, entity: EntityDefinition, options?: RegisterEntityCrudOptions): void;
|
|
215
|
+
writeHandler<TName extends string, TSchema extends ZodType>(def: WriteHandlerDefinition<TName, TSchema>): HandlerRef;
|
|
216
|
+
writeHandler<TSchema extends ZodType>(name: string, schema: TSchema, handler: WriteHandlerFn<z.infer<TSchema>>, options: {
|
|
217
|
+
access: AccessRule;
|
|
218
|
+
rateLimit?: RateLimitDeclaration;
|
|
219
|
+
description?: string;
|
|
220
|
+
agent?: AgentHandlerHints;
|
|
221
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
222
|
+
}): HandlerRef;
|
|
223
|
+
queryHandler<TName extends string, TSchema extends ZodType>(def: QueryHandlerDefinition<TName, TSchema>): HandlerRef;
|
|
224
|
+
queryHandler<TSchema extends ZodType>(name: string, schema: TSchema, handler: QueryHandlerFn<z.infer<TSchema>>, options: {
|
|
225
|
+
access: AccessRule;
|
|
226
|
+
rateLimit?: RateLimitDeclaration;
|
|
227
|
+
outputSchema?: ZodType;
|
|
228
|
+
description?: string;
|
|
229
|
+
agent?: AgentHandlerHints;
|
|
230
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
231
|
+
}): HandlerRef;
|
|
232
|
+
streamHandler<TName extends string, TSchema extends ZodType>(def: StreamHandlerDefinition<TName, TSchema>): HandlerRef;
|
|
233
|
+
streamHandler<TSchema extends ZodType>(name: string, schema: TSchema, handler: StreamHandlerFn<z.infer<TSchema>>, options: {
|
|
234
|
+
access: AccessRule;
|
|
235
|
+
rateLimit?: RateLimitDeclaration;
|
|
236
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
237
|
+
}): HandlerRef;
|
|
238
|
+
relation(entity: NameOrRef, relationName: string, definition: RelationDefinition): void;
|
|
239
|
+
relation<TDef extends RelationDefinition>(definition: {
|
|
240
|
+
readonly entity: NameOrRef;
|
|
241
|
+
readonly name: string;
|
|
242
|
+
} & TDef): void;
|
|
243
|
+
hook(type: "validation", target: RefOrRefs, fn: ValidationHookFn): void;
|
|
244
|
+
hook(type: "preSave", target: RefOrRefs, fn: PreSaveHookFn, options?: {
|
|
245
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
246
|
+
}): void;
|
|
247
|
+
hook(type: "postSave", target: HookTarget, fn: PostSaveHookFn, options?: {
|
|
248
|
+
phase?: HookPhase;
|
|
249
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
250
|
+
}): void;
|
|
251
|
+
hook(type: "preDelete", target: HookTarget, fn: PreDeleteHookFn, options?: {
|
|
252
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
253
|
+
}): void;
|
|
254
|
+
hook(type: "postDelete", target: HookTarget, fn: PostDeleteHookFn, options?: {
|
|
255
|
+
phase?: HookPhase;
|
|
256
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
257
|
+
}): void;
|
|
258
|
+
hook(type: "preQuery", target: RefOrRefs, fn: PreQueryHookFn, options?: {
|
|
259
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
260
|
+
}): void;
|
|
261
|
+
hook(type: "postQuery", target: HookTarget, fn: PostQueryHookFn, options?: {
|
|
262
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
263
|
+
}): void;
|
|
264
|
+
searchPayloadExtension(entity: NameOrRef, fn: SearchPayloadContributorFn): void;
|
|
265
|
+
config<T extends ConfigKeyType>(keyName: string, def: ConfigKeyDefinition<T>): ConfigKeyHandle<T>;
|
|
266
|
+
config<TKeys extends Readonly<Record<string, ConfigKeyDefinition<ConfigKeyType>>>>(definition: {
|
|
267
|
+
readonly keys: TKeys;
|
|
268
|
+
readonly seeds?: Readonly<Record<string, ConfigSeedDef>>;
|
|
269
|
+
}): {
|
|
270
|
+
readonly [K in keyof TKeys]: ConfigKeyHandle<TKeys[K]["type"]>;
|
|
271
|
+
};
|
|
272
|
+
job(name: string, options: Omit<JobDefinition, "name" | "handler">, handler: JobHandlerFn): void;
|
|
273
|
+
job(definition: JobDefinition): void;
|
|
274
|
+
notification(name: string, definition: {
|
|
275
|
+
readonly trigger: {
|
|
276
|
+
readonly on: NameOrRef;
|
|
277
|
+
};
|
|
278
|
+
readonly recipient: NotificationRecipientFn;
|
|
279
|
+
readonly data: NotificationDataFn;
|
|
280
|
+
readonly templates?: Readonly<Record<string, NotificationTemplateFn>>;
|
|
281
|
+
}): void;
|
|
282
|
+
notification(definition: {
|
|
283
|
+
readonly name: string;
|
|
284
|
+
readonly trigger: {
|
|
285
|
+
readonly on: NameOrRef;
|
|
286
|
+
};
|
|
287
|
+
readonly recipient: NotificationRecipientFn;
|
|
288
|
+
readonly data: NotificationDataFn;
|
|
289
|
+
readonly templates?: Readonly<Record<string, NotificationTemplateFn>>;
|
|
290
|
+
}): void;
|
|
291
|
+
translations(def: TranslationsDef): void;
|
|
292
|
+
defineEvent<const TInner extends string, TPayload>(name: TInner, schema: ZodType<TPayload>, options: {
|
|
293
|
+
readonly version?: number;
|
|
294
|
+
readonly piiFields: EventPiiStance;
|
|
295
|
+
readonly migrations?: readonly {
|
|
296
|
+
readonly fromVersion: number;
|
|
297
|
+
readonly toVersion: number;
|
|
298
|
+
readonly transform: EventUpcastFn | DeclarativeEventMigration;
|
|
299
|
+
}[];
|
|
300
|
+
}): EventDef<TPayload, QualifiedEventName<TFeature, TInner>>;
|
|
301
|
+
readsConfig(...qualifiedKeys: string[]): void;
|
|
302
|
+
readsConfig(options: {
|
|
303
|
+
readonly keys: readonly string[];
|
|
304
|
+
}): void;
|
|
305
|
+
referenceData(entity: NameOrRef, data: readonly Record<string, unknown>[], options?: {
|
|
306
|
+
upsertKey?: string;
|
|
307
|
+
}): void;
|
|
308
|
+
referenceData(definition: {
|
|
309
|
+
readonly entity: NameOrRef;
|
|
310
|
+
readonly data: readonly Record<string, unknown>[];
|
|
311
|
+
readonly upsertKey?: string;
|
|
312
|
+
}): void;
|
|
313
|
+
extendsRegistrar(name: string, def: RegistrarExtensionDef): void;
|
|
314
|
+
useExtension<N extends string>(extensionName: N, entity: NameOrRef, ...options: ExtensionOptionsArgs<N>): void;
|
|
315
|
+
useExtension<N extends string>(definition: {
|
|
316
|
+
readonly name: N;
|
|
317
|
+
readonly entity: NameOrRef;
|
|
318
|
+
} & ExtensionOptionsFor<N>): void;
|
|
319
|
+
/**
|
|
320
|
+
* Declares which config key selects the active provider under an
|
|
321
|
+
* extension point — called by the point-owning foundation (e.g.
|
|
322
|
+
* `r.extensionSelector("mailTransport", configKeys.provider)`).
|
|
323
|
+
* Readiness gating counts a provider-feature's `required` keys and
|
|
324
|
+
* secrets only while that provider is the selected one. Registry-build
|
|
325
|
+
* fails on duplicate declarations per extension and on selector keys
|
|
326
|
+
* that no mounted feature declares. A masked tenant selector key makes the
|
|
327
|
+
* Settings-Hub render one tenant dashboard for the owner: the selector as a
|
|
328
|
+
* select of the mounted plugin ids, the selected plugin's config and secrets
|
|
329
|
+
* as panels, and plugin features lose their own tenant nav. `config:write:set`
|
|
330
|
+
* rejects unknown plugin ids (`""` clears).
|
|
331
|
+
*/
|
|
332
|
+
extensionSelector(extensionName: string, key: {
|
|
333
|
+
readonly name: string;
|
|
334
|
+
} | string): void;
|
|
335
|
+
/**
|
|
336
|
+
* Marker-Deklaration: dieses Feature stellt eine Cross-Feature-API
|
|
337
|
+
* unter dem genannten Namen bereit. Die eigentliche Implementation
|
|
338
|
+
* wird separat als Query- oder Write-Handler unter dem QN-Pattern
|
|
339
|
+
* registriert; `r.exposesApi` ist reine Boot-Check-Surface.
|
|
340
|
+
*
|
|
341
|
+
* Boot-Validator prüft, dass jedes `r.usesApi(name)` einen passenden
|
|
342
|
+
* Exposer findet, dass das Exposer-Feature in requires/optionalRequires
|
|
343
|
+
* gelisted ist und dass kein API-Name doppelt exposed wird.
|
|
344
|
+
*
|
|
345
|
+
* ```ts
|
|
346
|
+
* defineFeature("compliance-profiles", (r) => {
|
|
347
|
+
* r.exposesApi("compliance.forTenant");
|
|
348
|
+
* r.queryHandler({
|
|
349
|
+
* name: "compliance:query:for-tenant",
|
|
350
|
+
* // ... echte Implementation
|
|
351
|
+
* });
|
|
352
|
+
* });
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
exposesApi(apiName: string): void;
|
|
356
|
+
/**
|
|
357
|
+
* Declares that this feature calls a cross-feature API. Boot-Validator
|
|
358
|
+
* checkt dass irgendein anderes Feature `r.exposesApi(apiName)` macht
|
|
359
|
+
* und dass dieses Feature `r.requires/optionalRequires` darauf hat.
|
|
360
|
+
*
|
|
361
|
+
* ```ts
|
|
362
|
+
* defineFeature("user-data-rights", (r) => {
|
|
363
|
+
* r.requires("compliance-profiles");
|
|
364
|
+
* r.usesApi("compliance.forTenant");
|
|
365
|
+
* });
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
usesApi(apiName: string): void;
|
|
369
|
+
/**
|
|
370
|
+
* Declares a boot-time mount-invariant for this feature. `fn` runs once
|
|
371
|
+
* at boot with a ctx exposing every mounted feature — throw to fail the
|
|
372
|
+
* boot with a clear message. Multiple calls per feature are allowed.
|
|
373
|
+
*
|
|
374
|
+
* Use for cross-feature invariants that `r.requires` can't express
|
|
375
|
+
* because they're conditional (only fail when the feature has a
|
|
376
|
+
* specific shape), e.g. "if this feature has PII entities, some
|
|
377
|
+
* user-data-hook feature must be mounted" (the prompt-store trap,
|
|
378
|
+
* kumiko-enterprise#229 — a UserData feature was written but never
|
|
379
|
+
* mounted, and nothing caught it at boot):
|
|
380
|
+
*
|
|
381
|
+
* ```ts
|
|
382
|
+
* defineFeature("prompt-store", (r) => {
|
|
383
|
+
* const promptFields = { text: createTextField({ personal: "self", find: "none" }) };
|
|
384
|
+
* r.entity("prompt", { fields: promptFields });
|
|
385
|
+
* r.bootCheck(({ features }) => {
|
|
386
|
+
* // Conditional on this feature's own shape (has a pii field) —
|
|
387
|
+
* // r.requires("user-data-hook") can't express that, it would fail
|
|
388
|
+
* // even for a prompt-store variant with no PII fields at all.
|
|
389
|
+
* const hasPiiField = Object.values(promptFields).some((f) => f.pii);
|
|
390
|
+
* const hasUserDataHook = features.some((f) => f.name === "user-data-hook");
|
|
391
|
+
* if (hasPiiField && !hasUserDataHook) {
|
|
392
|
+
* throw new Error("prompt-store has PII fields but no user-data-hook feature is mounted");
|
|
393
|
+
* }
|
|
394
|
+
* });
|
|
395
|
+
* });
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
bootCheck(fn: BootCheckFn): void;
|
|
399
|
+
metric(shortName: string, options: MetricOptions): void;
|
|
400
|
+
metric(definition: {
|
|
401
|
+
readonly name: string;
|
|
402
|
+
} & MetricOptions): void;
|
|
403
|
+
secret(shortName: string, options: SecretOptions): SecretKeyHandle;
|
|
404
|
+
secret(definition: {
|
|
405
|
+
readonly name: string;
|
|
406
|
+
} & SecretOptions): SecretKeyHandle;
|
|
407
|
+
projection(definition: ProjectionDefinition): void;
|
|
408
|
+
multiStreamProjection(definition: MultiStreamProjectionDefinition): void;
|
|
409
|
+
extendEntityProjection(entityName: string, extension: EntityProjectionExtension): void;
|
|
410
|
+
authClaims(fn: AuthClaimsFn): void;
|
|
411
|
+
claimKey<T extends ClaimKeyType>(shortName: string, options: {
|
|
412
|
+
readonly type: T;
|
|
413
|
+
}): ClaimKeyHandle<T>;
|
|
414
|
+
claimKey<T extends ClaimKeyType>(definition: {
|
|
415
|
+
readonly name: string;
|
|
416
|
+
readonly type: T;
|
|
417
|
+
}): ClaimKeyHandle<T>;
|
|
418
|
+
screen(definition: ScreenDefinition): void;
|
|
419
|
+
nav(definition: NavDefinition): void;
|
|
420
|
+
contentCollection(definition: ContentCollectionDefinition): string;
|
|
421
|
+
workspace(definition: WorkspaceDefinition): void;
|
|
422
|
+
httpRoute(definition: HttpRouteDefinition): void;
|
|
423
|
+
webSocketRoute(definition: WebSocketRouteDefinition): void;
|
|
424
|
+
storeTable(meta: EntityTableMeta, options: StoreTableOptions): void;
|
|
425
|
+
treeActions<const TActions extends Record<string, TreeActionDef>>(actions: TActions): TreeActionsHandle<TFeature, TActions>;
|
|
426
|
+
envSchema(schema: z.ZodObject<z.ZodRawShape>): void;
|
|
427
|
+
};
|
|
428
|
+
export type Registry = {
|
|
429
|
+
readonly features: ReadonlyMap<string, FeatureDefinition>;
|
|
430
|
+
getFeature(name: string): FeatureDefinition | undefined;
|
|
431
|
+
getEntity(name: string): EntityDefinition | undefined;
|
|
432
|
+
getAllEntities(): ReadonlyMap<string, EntityDefinition>;
|
|
433
|
+
getWriteHandler(name: string): WriteHandlerDef | undefined;
|
|
434
|
+
getQueryHandler(name: string): QueryHandlerDef | undefined;
|
|
435
|
+
getAllQueryHandlers(): ReadonlyMap<string, QueryHandlerDef>;
|
|
436
|
+
getAllWriteHandlers(): ReadonlyMap<string, WriteHandlerDef>;
|
|
437
|
+
getStreamHandler(name: string): StreamHandlerDef | undefined;
|
|
438
|
+
getAllStreamHandlers(): ReadonlyMap<string, StreamHandlerDef>;
|
|
439
|
+
getSearchableFields(entityName: string): readonly string[];
|
|
440
|
+
getSortableFields(entityName: string): readonly string[];
|
|
441
|
+
getRelations(entityName: string): EntityRelations;
|
|
442
|
+
getSearchableReferences(entityName: string): ReadonlyArray<{
|
|
443
|
+
fieldName: string;
|
|
444
|
+
targetEntityName: string;
|
|
445
|
+
labelField: string;
|
|
446
|
+
}>;
|
|
447
|
+
getSortableReferences(entityName: string): ReadonlyArray<{
|
|
448
|
+
fieldName: string;
|
|
449
|
+
targetEntityName: string;
|
|
450
|
+
labelField: string;
|
|
451
|
+
}>;
|
|
452
|
+
getIncomingRelations(entityName: string): ReadonlyArray<{
|
|
453
|
+
sourceEntity: string;
|
|
454
|
+
relationName: string;
|
|
455
|
+
relation: RelationDefinition;
|
|
456
|
+
}>;
|
|
457
|
+
getPreSaveHooks(name: string, effectiveFeatures?: ReadonlySet<string>): readonly PreSaveHookFn[];
|
|
458
|
+
getPostSaveHooks(name: string, phase?: HookPhase, effectiveFeatures?: ReadonlySet<string>): readonly PostSaveHookFn[];
|
|
459
|
+
getPreDeleteHooks(name: string, phase?: HookPhase, effectiveFeatures?: ReadonlySet<string>): readonly PreDeleteHookFn[];
|
|
460
|
+
getPostDeleteHooks(name: string, phase?: HookPhase, effectiveFeatures?: ReadonlySet<string>): readonly PostDeleteHookFn[];
|
|
461
|
+
getPreQueryHooks(name: string, effectiveFeatures?: ReadonlySet<string>): readonly PreQueryHookFn[];
|
|
462
|
+
getPostQueryHooks(name: string, effectiveFeatures?: ReadonlySet<string>): readonly PostQueryHookFn[];
|
|
463
|
+
getEntityPostSaveHooks(entityName: string, phase?: HookPhase, effectiveFeatures?: ReadonlySet<string>): readonly PostSaveHookFn[];
|
|
464
|
+
getEntityPreDeleteHooks(entityName: string, phase?: HookPhase, effectiveFeatures?: ReadonlySet<string>): readonly PreDeleteHookFn[];
|
|
465
|
+
getEntityPostDeleteHooks(entityName: string, phase?: HookPhase, effectiveFeatures?: ReadonlySet<string>): readonly PostDeleteHookFn[];
|
|
466
|
+
getEntityPostQueryHooks(entityName: string, effectiveFeatures?: ReadonlySet<string>): readonly PostQueryHookFn[];
|
|
467
|
+
getSearchPayloadExtensions(entityName: string, effectiveFeatures?: ReadonlySet<string>): readonly SearchPayloadContributorFn[];
|
|
468
|
+
getHandlerEntity(qualifiedHandler: string): string | undefined;
|
|
469
|
+
isHandlerSystemScoped(qualifiedHandler: string): boolean;
|
|
470
|
+
isJobSystemScoped(qualifiedJobName: string): boolean;
|
|
471
|
+
getHandlerFeature(qualifiedHandler: string): string | undefined;
|
|
472
|
+
hasRateLimitedHandler(): boolean;
|
|
473
|
+
getAllMetrics(): ReadonlyMap<string, FeatureMetricDef & {
|
|
474
|
+
readonly featureName: string;
|
|
475
|
+
}>;
|
|
476
|
+
getAllTranslations(): TranslationKeys;
|
|
477
|
+
getConfigKey(qualifiedKey: string): ConfigKeyDefinition | undefined;
|
|
478
|
+
getAllConfigKeys(): ReadonlyMap<string, ConfigKeyDefinition>;
|
|
479
|
+
getAllConfigSeeds(): readonly ConfigSeedDef[];
|
|
480
|
+
getAllSecretKeys(): ReadonlyMap<string, SecretKeyDefinition>;
|
|
481
|
+
getSecretKey(qualifiedName: string): SecretKeyDefinition | undefined;
|
|
482
|
+
getJob(qualifiedName: string): JobDefinition | undefined;
|
|
483
|
+
getAllJobs(): ReadonlyMap<string, JobDefinition>;
|
|
484
|
+
getEvent(qualifiedName: string): EventDef | undefined;
|
|
485
|
+
getEventUpcasters(): ReadonlyMap<string, {
|
|
486
|
+
readonly currentVersion: number;
|
|
487
|
+
readonly chain: ReadonlyMap<number, EventUpcastFn>;
|
|
488
|
+
}>;
|
|
489
|
+
getExtension(name: string): RegistrarExtensionDef | undefined;
|
|
490
|
+
getExtensionUsages(extensionName: string): readonly RegistrarExtensionRegistration[];
|
|
491
|
+
getAllExtensionSelectors(): ReadonlyMap<string, string>;
|
|
492
|
+
getAllNotifications(): ReadonlyMap<string, NotificationDefinition>;
|
|
493
|
+
getAllReferenceData(): readonly ReferenceDataDef[];
|
|
494
|
+
getProjectionsForSource(entityName: string): readonly ProjectionDefinition[];
|
|
495
|
+
getAllProjections(): ReadonlyMap<string, ProjectionDefinition>;
|
|
496
|
+
getAllStoreTables(): ReadonlyMap<string, StoreTableDef>;
|
|
497
|
+
getAllMultiStreamProjections(): ReadonlyMap<string, MultiStreamProjectionDefinition>;
|
|
498
|
+
getMultiStreamProjectionFeature(qualifiedName: string): string | undefined;
|
|
499
|
+
getAuthClaimsHooks(): readonly AuthClaimsHookDef[];
|
|
500
|
+
getAllClaimKeys(): ReadonlyMap<string, ClaimKeyDefinition>;
|
|
501
|
+
getClaimKey(qualifiedName: string): ClaimKeyDefinition | undefined;
|
|
502
|
+
getAllScreens(): ReadonlyMap<string, ScreenDefinition>;
|
|
503
|
+
getScreen(qualifiedName: string): ScreenDefinition | undefined;
|
|
504
|
+
getScreenFeature(qualifiedName: string): string | undefined;
|
|
505
|
+
getScreensByEntity(entityName: string): readonly ScreenDefinition[];
|
|
506
|
+
getAllNavs(): ReadonlyMap<string, NavDefinition>;
|
|
507
|
+
getNav(qualifiedName: string): NavDefinition | undefined;
|
|
508
|
+
getNavFeature(qualifiedName: string): string | undefined;
|
|
509
|
+
getNavsByParent(parentQualifiedName: string): readonly NavDefinition[];
|
|
510
|
+
getTopLevelNavs(): readonly NavDefinition[];
|
|
511
|
+
getAllWorkspaces(): ReadonlyMap<string, WorkspaceDefinition>;
|
|
512
|
+
getWorkspace(qualifiedName: string): WorkspaceDefinition | undefined;
|
|
513
|
+
getWorkspaceFeature(qualifiedName: string): string | undefined;
|
|
514
|
+
getWorkspaceNavs(workspaceQualifiedName: string): readonly string[];
|
|
515
|
+
getDefaultWorkspace(): WorkspaceDefinition | undefined;
|
|
516
|
+
getTreeActions(featureName: string): Readonly<Record<string, TreeActionDef>> | undefined;
|
|
517
|
+
};
|
|
518
|
+
export {};
|
package/dist/feature.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FieldIconKey = "mail" | "lock" | "hash" | "search" | "user" | "phone" | "calendar" | "link" | "tag" | "building" | "globe" | "key" | "map-pin";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|