@cosmicdrift/kumiko-types 0.411.0 → 0.412.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/api-example.d.ts +32 -0
- package/dist/api-example.js +24 -0
- package/dist/event-store-executor-types.d.ts +4 -0
- package/dist/feature-registrar.d.ts +9 -1
- package/dist/feature.d.ts +31 -0
- package/dist/fields.d.ts +2 -0
- package/package.json +9 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const apiExampleEndpoints: readonly ["/api/query", "/api/write", "/api/batch"];
|
|
3
|
+
export type ApiExampleEndpoint = (typeof apiExampleEndpoints)[number];
|
|
4
|
+
export declare const ApiExampleFileSchema: z.ZodObject<{
|
|
5
|
+
request: z.ZodObject<{
|
|
6
|
+
endpoint: z.ZodEnum<{
|
|
7
|
+
"/api/batch": "/api/batch";
|
|
8
|
+
"/api/query": "/api/query";
|
|
9
|
+
"/api/write": "/api/write";
|
|
10
|
+
}>;
|
|
11
|
+
body: z.ZodObject<{
|
|
12
|
+
type: z.ZodOptional<z.ZodString>;
|
|
13
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
14
|
+
commands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
+
type: z.ZodString;
|
|
16
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
17
|
+
}, z.core.$strip>>>;
|
|
18
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
response: z.ZodObject<{
|
|
22
|
+
status: z.ZodNumber;
|
|
23
|
+
body: z.ZodUnknown;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type ApiExampleFile = z.infer<typeof ApiExampleFileSchema>;
|
|
27
|
+
export declare const WebhookExampleFileSchema: z.ZodObject<{
|
|
28
|
+
event: z.ZodString;
|
|
29
|
+
version: z.ZodNumber;
|
|
30
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type WebhookExampleFile = z.infer<typeof WebhookExampleFileSchema>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
// One recorded HTTP exchange, shared by the recorder (testing) and the API docs generator (bundled-features).
|
|
3
|
+
export const apiExampleEndpoints = ["/api/query", "/api/write", "/api/batch"];
|
|
4
|
+
export const ApiExampleFileSchema = z.object({
|
|
5
|
+
request: z.object({
|
|
6
|
+
endpoint: z.enum(apiExampleEndpoints),
|
|
7
|
+
body: z.object({
|
|
8
|
+
type: z.string().optional(),
|
|
9
|
+
payload: z.unknown().optional(),
|
|
10
|
+
commands: z.array(z.object({ type: z.string(), payload: z.unknown().optional() })).optional(),
|
|
11
|
+
requestId: z.string().optional(),
|
|
12
|
+
}),
|
|
13
|
+
}),
|
|
14
|
+
response: z.object({
|
|
15
|
+
status: z.number().int(),
|
|
16
|
+
body: z.unknown(),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
// One recorded webhook delivery payload; `event` is the QN of its contract.
|
|
20
|
+
export const WebhookExampleFileSchema = z.object({
|
|
21
|
+
event: z.string(),
|
|
22
|
+
version: z.number().int().positive(),
|
|
23
|
+
payload: z.record(z.string(), z.unknown()),
|
|
24
|
+
});
|
|
@@ -9,6 +9,10 @@ import type { SearchAdapter } from "./search-adapter.ts";
|
|
|
9
9
|
import type { TenantDb } from "./tenant-db-types.ts";
|
|
10
10
|
export type ParentVisibilityOption = {
|
|
11
11
|
readonly entities: ReadonlyMap<string, EntityDefinition>;
|
|
12
|
+
readonly readModelEntities?: ReadonlyMap<string, {
|
|
13
|
+
readonly entity: EntityDefinition;
|
|
14
|
+
readonly table: SchemaTable;
|
|
15
|
+
}>;
|
|
12
16
|
readonly canReadEntity?: (entityName: string) => boolean;
|
|
13
17
|
readonly resolveTable?: (entityName: string) => SchemaTable;
|
|
14
18
|
};
|
|
@@ -6,7 +6,7 @@ import type { RegisterEntityCrudOptions } from "./entity-handlers.ts";
|
|
|
6
6
|
import type { EntityTableMeta } from "./entity-table-meta-types.ts";
|
|
7
7
|
import type { KumikoEventTypeMap } from "./event-type-map.ts";
|
|
8
8
|
import type { ExtensionOptionsArgs, ExtensionOptionsFor } from "./extension-options-map.ts";
|
|
9
|
-
import type { BootCheckFn, MetricOptions, SecretKeyHandle, SecretNamespaceHandle, SecretNamespaceOptions, SecretOptions, StoreTableOptions, UiHints } from "./feature.ts";
|
|
9
|
+
import type { BootCheckFn, MetricOptions, SecretKeyHandle, SecretNamespaceHandle, SecretNamespaceOptions, SecretOptions, StoreTableOptions, UiHints, WebhookEventHandle } from "./feature.ts";
|
|
10
10
|
import type { EntityDefinition } from "./fields.ts";
|
|
11
11
|
import type { AccessRule, AuthClaimsFn, BeforeTransactionWhenNested, ClaimKeyHandle, ClaimKeyType, DeclarativeEventMigration, EntityRef, EscapeHatchDeclaration, EventDef, EventPiiStance, EventUpcastFn, HandlerRef, NameOrRef, QualifiedEventName, RateLimitDeclaration, StreamHandlerFn } from "./handlers.ts";
|
|
12
12
|
import type { HookPhase, PostDeleteHookFn, PostQueryHookFn, PostSaveHookFn, PreDeleteHookFn, PreSaveHookFn, SearchPayloadContributorFn, ValidationHookFn } from "./hooks.ts";
|
|
@@ -184,6 +184,14 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
184
184
|
readonly transform: EventUpcastFn | DeclarativeEventMigration;
|
|
185
185
|
}[];
|
|
186
186
|
}): EventDef<TPayload, QualifiedEventName<TFeature, TInner>>;
|
|
187
|
+
defineWebhookEvent(definition: {
|
|
188
|
+
readonly name: string;
|
|
189
|
+
readonly description: string;
|
|
190
|
+
readonly payload: z.ZodObject;
|
|
191
|
+
readonly version: number;
|
|
192
|
+
/** Name in the delivered webhook and in the generated docs. Defaults to `name`. */
|
|
193
|
+
readonly wireName?: string;
|
|
194
|
+
}): WebhookEventHandle;
|
|
187
195
|
readsConfig(...qualifiedKeys: string[]): void;
|
|
188
196
|
readsConfig(options: {
|
|
189
197
|
readonly keys: readonly string[];
|
package/dist/feature.d.ts
CHANGED
|
@@ -108,6 +108,33 @@ export type UiHints = {
|
|
|
108
108
|
readonly recommended?: boolean;
|
|
109
109
|
readonly configurableOptions?: readonly UiHintOption[];
|
|
110
110
|
};
|
|
111
|
+
/** Lifecycle verbs of an entity that can be released as webhook events. */
|
|
112
|
+
export type WebhookEntityVerb = "created" | "updated" | "deleted";
|
|
113
|
+
/** What `r.defineWebhookEvent` stores; `qn` is `<feature>:<name>`. */
|
|
114
|
+
export type WebhookEventDef = {
|
|
115
|
+
readonly qn: string;
|
|
116
|
+
readonly wireName: string;
|
|
117
|
+
readonly description: string;
|
|
118
|
+
readonly payload: z.ZodObject;
|
|
119
|
+
readonly version: number;
|
|
120
|
+
};
|
|
121
|
+
export type WebhookEventHandle = {
|
|
122
|
+
readonly name: string;
|
|
123
|
+
readonly payload: z.ZodObject;
|
|
124
|
+
readonly version: number;
|
|
125
|
+
};
|
|
126
|
+
/** Public payload contract of a webhook event: declared by a feature or derived from an entity. */
|
|
127
|
+
export type WebhookEventContract = {
|
|
128
|
+
readonly qn: string;
|
|
129
|
+
/** The event name receivers see in the delivered webhook: `wireName` of a declared event, `entity.verb` of a derived one. */
|
|
130
|
+
readonly wireName: string;
|
|
131
|
+
readonly description: string;
|
|
132
|
+
readonly payload: z.ZodObject;
|
|
133
|
+
readonly version: number;
|
|
134
|
+
readonly origin: "declared" | "entity";
|
|
135
|
+
readonly entity?: string;
|
|
136
|
+
readonly verb?: WebhookEntityVerb;
|
|
137
|
+
};
|
|
111
138
|
export type BootCheckContext = {
|
|
112
139
|
readonly features: readonly FeatureDefinition[];
|
|
113
140
|
};
|
|
@@ -174,6 +201,8 @@ export type FeatureDefinition = {
|
|
|
174
201
|
readonly referenceData: readonly ReferenceDataDef[];
|
|
175
202
|
readonly notifications: Readonly<Record<string, NotificationDefinition>>;
|
|
176
203
|
readonly events: Readonly<Record<string, EventDef>>;
|
|
204
|
+
/** Public webhook contracts from r.defineWebhookEvent, keyed by QN. Absent when the feature declares none. */
|
|
205
|
+
readonly webhookEvents?: Readonly<Record<string, WebhookEventDef>>;
|
|
177
206
|
readonly eventMigrations: Readonly<Record<string, readonly EventMigrationDef[]>>;
|
|
178
207
|
readonly configReads: readonly string[];
|
|
179
208
|
readonly handlerEntityMappings: Readonly<Record<string, string>>;
|
|
@@ -257,6 +286,8 @@ export type Registry = {
|
|
|
257
286
|
getJob(qualifiedName: string): JobDefinition | undefined;
|
|
258
287
|
getAllJobs(): ReadonlyMap<string, JobDefinition>;
|
|
259
288
|
getEvent(qualifiedName: string): EventDef | undefined;
|
|
289
|
+
getWebhookEventContract(qualifiedName: string): WebhookEventContract | undefined;
|
|
290
|
+
getWebhookEventContracts(): readonly WebhookEventContract[];
|
|
260
291
|
getEventUpcasters(): ReadonlyMap<string, {
|
|
261
292
|
readonly currentVersion: number;
|
|
262
293
|
readonly chain: ReadonlyMap<number, EventUpcastFn>;
|
package/dist/fields.d.ts
CHANGED
|
@@ -728,6 +728,8 @@ export type EntityDefinition<F extends FieldsMap = FieldsMap, T extends EntityTe
|
|
|
728
728
|
* only for genuinely tenant-independent aggregates like `user`. The first
|
|
729
729
|
* event (create) is what's routed; updates resolve the stream tenant upstream. */
|
|
730
730
|
readonly systemStream?: boolean;
|
|
731
|
+
/** Lets token scopes release `<entity>.created/.updated/.deleted` as webhook events. Off by default: bundle entities can hold secrets. */
|
|
732
|
+
readonly webhookEvents?: boolean;
|
|
731
733
|
/** Schema version stamped on every lifecycle event (default 1, integer 1..999). Bump it together with a step in `eventMigrations`. */
|
|
732
734
|
readonly eventVersion?: number;
|
|
733
735
|
/** One step per version, fromVersion → fromVersion+1. Transforms run on row-shaped field records; the record may be partial, touch only keys that are present.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.412.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": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./api-example": {
|
|
26
|
+
"types": "./dist/api-example.d.ts",
|
|
27
|
+
"default": "./dist/api-example.js"
|
|
28
|
+
},
|
|
25
29
|
"./kebab-case": {
|
|
26
30
|
"types": "./dist/kebab-case.d.ts",
|
|
27
31
|
"default": "./dist/kebab-case.js"
|
|
@@ -329,6 +333,10 @@
|
|
|
329
333
|
"types": "./dist/index.d.ts",
|
|
330
334
|
"default": "./dist/index.js"
|
|
331
335
|
},
|
|
336
|
+
"./api-example": {
|
|
337
|
+
"types": "./dist/api-example.d.ts",
|
|
338
|
+
"default": "./dist/api-example.js"
|
|
339
|
+
},
|
|
332
340
|
"./kebab-case": {
|
|
333
341
|
"types": "./dist/kebab-case.d.ts",
|
|
334
342
|
"default": "./dist/kebab-case.js"
|