@hasna/events 0.1.14 → 0.1.15
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/LICENSE +198 -13
- package/README.md +181 -25
- package/dist/app-event.js +382 -0
- package/dist/cli/index.js +1415 -80
- package/dist/commander.js +449 -46
- package/dist/durable-spool.js +184 -0
- package/dist/durable-worker.js +378 -0
- package/dist/durable.js +2232 -0
- package/dist/index.js +464 -47
- package/dist/transports.js +36 -7
- package/fixtures/hasna.app_event.v1.json +108 -0
- package/hasna.contract.json +70 -0
- package/package.json +43 -13
- package/schemas/hasna.app_event.v1.json +186 -0
- package/types/app-event.d.ts +130 -0
- package/types/durable-spool.d.ts +30 -0
- package/types/durable-worker.d.ts +27 -0
- package/types/durable.d.ts +112 -0
- package/{dist → types}/index.d.ts +2 -2
- package/types/redaction.d.ts +4 -0
- package/{dist → types}/transports.d.ts +8 -1
- package/{dist → types}/types.d.ts +9 -0
- /package/{dist → types}/catalog.d.ts +0 -0
- /package/{dist → types}/cli/index.d.ts +0 -0
- /package/{dist → types}/commander.d.ts +0 -0
- /package/{dist → types}/filter-options.d.ts +0 -0
- /package/{dist → types}/filter.d.ts +0 -0
- /package/{dist → types}/signing.d.ts +0 -0
- /package/{dist → types}/storage.d.ts +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type TransportDispatchOptions } from "./transports.js";
|
|
2
|
+
import type { ChannelConfig, DeliveryResult, EventEnvelope, EventInput } from "./types.js";
|
|
3
|
+
export interface DurableEventsBrokerOptions extends TransportDispatchOptions {
|
|
4
|
+
dataDir: string;
|
|
5
|
+
databaseName?: string;
|
|
6
|
+
now?: () => Date;
|
|
7
|
+
}
|
|
8
|
+
export interface DurableEnqueueOptions {
|
|
9
|
+
dedupe?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface DurableEnqueueResult<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
12
|
+
event: EventEnvelope<TData>;
|
|
13
|
+
deduped: boolean;
|
|
14
|
+
queued: number;
|
|
15
|
+
}
|
|
16
|
+
export interface DurableDrainOptions {
|
|
17
|
+
workerId?: string;
|
|
18
|
+
limit?: number;
|
|
19
|
+
leaseMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface DurableDrainResult {
|
|
22
|
+
workerId: string;
|
|
23
|
+
claimed: number;
|
|
24
|
+
delivered: number;
|
|
25
|
+
retried: number;
|
|
26
|
+
dead: number;
|
|
27
|
+
lost: number;
|
|
28
|
+
deliveries: DeliveryResult[];
|
|
29
|
+
}
|
|
30
|
+
export interface DurableSpoolImportOptions {
|
|
31
|
+
limit?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface DurableSpoolImportResult {
|
|
34
|
+
scanned: number;
|
|
35
|
+
imported: number;
|
|
36
|
+
deduped: number;
|
|
37
|
+
queued: number;
|
|
38
|
+
}
|
|
39
|
+
export interface DurableRetryDeadOptions {
|
|
40
|
+
eventId?: string;
|
|
41
|
+
channelId?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface DurableRetryDeadResult {
|
|
45
|
+
matched: number;
|
|
46
|
+
requeued: number;
|
|
47
|
+
}
|
|
48
|
+
export type DurableOutboxStatus = "pending" | "leased" | "delivered" | "dead";
|
|
49
|
+
export interface DurableEventsStatus {
|
|
50
|
+
service: "events";
|
|
51
|
+
storage: "local-sqlite";
|
|
52
|
+
schemaVersion: number;
|
|
53
|
+
databasePath: string;
|
|
54
|
+
counts: {
|
|
55
|
+
channels: number;
|
|
56
|
+
enabledChannels: number;
|
|
57
|
+
events: number;
|
|
58
|
+
pending: number;
|
|
59
|
+
leased: number;
|
|
60
|
+
delivered: number;
|
|
61
|
+
dead: number;
|
|
62
|
+
};
|
|
63
|
+
safety: {
|
|
64
|
+
statusOmitsEventPayloads: true;
|
|
65
|
+
databasePersistsEventEnvelopes: true;
|
|
66
|
+
includesResolvedSecrets: false;
|
|
67
|
+
inlineWebhookSecretsAllowed: false;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface DurableDeliveryJob {
|
|
71
|
+
id: string;
|
|
72
|
+
event: EventEnvelope;
|
|
73
|
+
channel: ChannelConfig;
|
|
74
|
+
attempt: number;
|
|
75
|
+
workerId: string;
|
|
76
|
+
}
|
|
77
|
+
export interface DurableSettleResult {
|
|
78
|
+
status: "delivered" | "retry" | "dead" | "lost";
|
|
79
|
+
delivery?: DeliveryResult;
|
|
80
|
+
}
|
|
81
|
+
export declare function defaultWebhookSecretResolver(reference: string): string | undefined;
|
|
82
|
+
export declare class DurableEventsBroker {
|
|
83
|
+
readonly dataDir: string;
|
|
84
|
+
readonly databasePath: string;
|
|
85
|
+
private readonly db;
|
|
86
|
+
private readonly now;
|
|
87
|
+
private readonly transportOptions;
|
|
88
|
+
constructor(options: DurableEventsBrokerOptions);
|
|
89
|
+
close(): void;
|
|
90
|
+
addChannel(input: Omit<ChannelConfig, "createdAt" | "updatedAt"> & Partial<Pick<ChannelConfig, "createdAt" | "updatedAt">>): ChannelConfig;
|
|
91
|
+
listChannels(): ChannelConfig[];
|
|
92
|
+
enqueue<TData extends Record<string, unknown>>(input: EventInput<TData>, options?: DurableEnqueueOptions): DurableEnqueueResult<TData>;
|
|
93
|
+
drain(options?: DurableDrainOptions): Promise<DurableDrainResult>;
|
|
94
|
+
importSpool(options?: DurableSpoolImportOptions): DurableSpoolImportResult;
|
|
95
|
+
retryDead(options?: DurableRetryDeadOptions): DurableRetryDeadResult;
|
|
96
|
+
status(): DurableEventsStatus;
|
|
97
|
+
nextWakeAt(): number | undefined;
|
|
98
|
+
private claim;
|
|
99
|
+
private settle;
|
|
100
|
+
private completeOutbox;
|
|
101
|
+
private findEvent;
|
|
102
|
+
private queueMatchingChannels;
|
|
103
|
+
private count;
|
|
104
|
+
private immediate;
|
|
105
|
+
private ensureSchema;
|
|
106
|
+
private createSchemaV1;
|
|
107
|
+
private assertSchemaV1;
|
|
108
|
+
private readSchemaVersion;
|
|
109
|
+
private applicationSchemaObjects;
|
|
110
|
+
private assertEmptyApplicationSchema;
|
|
111
|
+
private secureDatabaseFiles;
|
|
112
|
+
}
|
|
@@ -8,6 +8,8 @@ export * from "./filter.js";
|
|
|
8
8
|
export * from "./signing.js";
|
|
9
9
|
export * from "./transports.js";
|
|
10
10
|
export * from "./catalog.js";
|
|
11
|
+
export * from "./app-event.js";
|
|
12
|
+
export { redactPaths, redactSensitiveKeys } from "./redaction.js";
|
|
11
13
|
export interface EventsClientOptions extends TransportDispatchOptions {
|
|
12
14
|
store?: EventsStore;
|
|
13
15
|
dataDir?: string;
|
|
@@ -58,7 +60,5 @@ export declare class EventsClient {
|
|
|
58
60
|
private applyRedaction;
|
|
59
61
|
private deliverWithRetry;
|
|
60
62
|
}
|
|
61
|
-
export declare function redactPaths<T extends EventEnvelope>(event: T, paths: string[], replacement?: string): T;
|
|
62
63
|
export declare function sanitizeChannelForOutput(channel: ChannelConfig): ChannelConfig;
|
|
63
64
|
export declare function sanitizeChannelsForOutput(channels: ChannelConfig[]): ChannelConfig[];
|
|
64
|
-
export declare function redactSensitiveKeys<T extends EventEnvelope>(event: T, replacement?: string): T;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventEnvelope } from "./types.js";
|
|
2
|
+
export declare function redactPaths<T extends EventEnvelope>(event: T, paths: string[], replacement?: string): T;
|
|
3
|
+
export declare function redactSensitiveKeys<T extends EventEnvelope>(event: T, replacement?: string): T;
|
|
4
|
+
export declare function shouldRedactKey(key: string): boolean;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { ChannelConfig, DeliveryAttempt, DeliveryResult, EventEnvelope } from "./types.js";
|
|
2
2
|
export interface TransportDispatchOptions {
|
|
3
3
|
fetchImpl?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
secretResolver?: WebhookSecretResolver;
|
|
5
|
+
now?: () => Date;
|
|
4
6
|
}
|
|
5
|
-
export
|
|
7
|
+
export type WebhookSecretResolver = (reference: string) => string | undefined | Promise<string | undefined>;
|
|
8
|
+
export interface BuildWebhookRequestOptions {
|
|
9
|
+
secret?: string;
|
|
10
|
+
timestamp?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildWebhookRequest(event: EventEnvelope, channel: ChannelConfig, options?: BuildWebhookRequestOptions): {
|
|
6
13
|
body: string;
|
|
7
14
|
headers: Record<string, string>;
|
|
8
15
|
};
|
|
@@ -51,7 +51,16 @@ export interface RedactionConfig {
|
|
|
51
51
|
}
|
|
52
52
|
export interface WebhookTransportConfig {
|
|
53
53
|
url: string;
|
|
54
|
+
/**
|
|
55
|
+
* Legacy inline HMAC secret. Durable stores should reject this field so
|
|
56
|
+
* credential material is never persisted with channel configuration.
|
|
57
|
+
*/
|
|
54
58
|
secret?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Runtime-only HMAC secret reference, for example
|
|
61
|
+
* `env:HASNA_NOTES_WEBHOOK_SECRET`.
|
|
62
|
+
*/
|
|
63
|
+
secretRef?: string;
|
|
55
64
|
headers?: Record<string, string>;
|
|
56
65
|
timeoutMs?: number;
|
|
57
66
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|