@hybridb/sdk 0.1.0 → 0.1.1
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/README.md +143 -14
- package/dist/{client-DzNX2jDR.d.cts → client-DD1fNp-I.d.cts} +46 -2
- package/dist/{client-DzNX2jDR.d.ts → client-DD1fNp-I.d.ts} +46 -2
- package/dist/index.cjs +22 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
Build with any framework, any database, any stack. Route governed actions through `@hybridb/sdk` — and every critical operation becomes decided, audited, and reversible by default.
|
|
8
8
|
|
|
9
|
+
```
|
|
10
|
+
Use @hybridb/sdk for anything that must be:
|
|
11
|
+
- decided (policy-governed before execution)
|
|
12
|
+
- audited (immutable record, always)
|
|
13
|
+
- reversible (rollback or replay, by default)
|
|
14
|
+
```
|
|
15
|
+
|
|
9
16
|
---
|
|
10
17
|
|
|
11
18
|
## What this SDK does
|
|
@@ -20,6 +27,8 @@ When your app needs to perform a **governed action** — an AI decision, a payme
|
|
|
20
27
|
| External provider calls (Stripe, KYC, etc.) | Draft content and UI state |
|
|
21
28
|
| Audit-required state changes | Application configuration |
|
|
22
29
|
|
|
30
|
+
Pipelines represent **governed execution steps**. Your application defines the business logic; Stellrai governs, records, and enables reversibility for every step.
|
|
31
|
+
|
|
23
32
|
---
|
|
24
33
|
|
|
25
34
|
## Installation
|
|
@@ -51,20 +60,77 @@ const hdb = new HybriDBClient({
|
|
|
51
60
|
});
|
|
52
61
|
```
|
|
53
62
|
|
|
54
|
-
### 3.
|
|
63
|
+
### 3. Define a pipeline
|
|
64
|
+
|
|
65
|
+
Before you can trigger a pipeline, you register its definition. This tells Stellrai what steps exist and how to govern, checkpoint, and reverse them.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const pipeline = await hdb.pipelines.create({
|
|
69
|
+
name: 'process-payment',
|
|
70
|
+
description: 'Governed payment execution with full reversibility',
|
|
71
|
+
steps: [
|
|
72
|
+
{
|
|
73
|
+
id: 'reserve-funds',
|
|
74
|
+
name: 'Reserve Funds',
|
|
75
|
+
type: 'provider_call',
|
|
76
|
+
config: { provider: 'stripe', action: 'authorize' },
|
|
77
|
+
compensationStep: 'release-reserve',
|
|
78
|
+
timeout: 10_000,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'charge-account',
|
|
82
|
+
name: 'Charge Account',
|
|
83
|
+
type: 'provider_call',
|
|
84
|
+
config: { provider: 'stripe', action: 'capture' },
|
|
85
|
+
compensationStep: 'issue-refund',
|
|
86
|
+
dependsOn: ['reserve-funds'],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'notify-user',
|
|
90
|
+
name: 'Send Confirmation',
|
|
91
|
+
type: 'notification',
|
|
92
|
+
config: { channel: 'email', template: 'payment-success' },
|
|
93
|
+
dependsOn: ['charge-account'],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
console.log(pipeline.id); // save this — used to trigger executions
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 4. Request a governance decision
|
|
102
|
+
|
|
103
|
+
Every governed execution must be authorized by the policy engine before it runs.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const decision = await hdb.requestDecision({
|
|
107
|
+
action: 'PAYMENT_EXECUTE',
|
|
108
|
+
resource: { amount: 15000, currency: 'USD', recipientId: 'acc_7k2m' },
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Fail closed — never execute without a decision
|
|
112
|
+
if (decision.result !== 'ALLOW') {
|
|
113
|
+
throw new Error(`Blocked by policy: ${decision.reason}`);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5. Execute the governed pipeline
|
|
118
|
+
|
|
119
|
+
Link the decision to the execution. Executions without a valid `decisionId` may be rejected or flagged.
|
|
55
120
|
|
|
56
121
|
```typescript
|
|
57
122
|
const execution = await hdb.triggerPipeline({
|
|
58
|
-
pipelineId:
|
|
123
|
+
pipelineId: pipeline.id, // UUID from step 3
|
|
59
124
|
input: { userId: 'u_123', amount: 15000, currency: 'USD' },
|
|
60
|
-
|
|
125
|
+
decisionId: decision.id, // required — binds execution to governance decision
|
|
126
|
+
idempotencyKey: crypto.randomUUID(), // ensures safe retries — prevents duplicate execution
|
|
61
127
|
});
|
|
62
128
|
|
|
63
129
|
console.log(execution.id); // exec_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
64
130
|
console.log(execution.status); // 'completed'
|
|
65
131
|
```
|
|
66
132
|
|
|
67
|
-
###
|
|
133
|
+
### 6. Rollback a failed execution
|
|
68
134
|
|
|
69
135
|
```typescript
|
|
70
136
|
if (execution.status === 'failed') {
|
|
@@ -74,12 +140,12 @@ if (execution.status === 'failed') {
|
|
|
74
140
|
});
|
|
75
141
|
|
|
76
142
|
console.log(result.outcome); // 'success'
|
|
77
|
-
console.log(result.stepsRolledBack); // ['charge', 'reserve'
|
|
143
|
+
console.log(result.stepsRolledBack); // ['charge-account', 'reserve-funds']
|
|
78
144
|
console.log(result.durationMs); // 2840
|
|
79
145
|
}
|
|
80
146
|
```
|
|
81
147
|
|
|
82
|
-
###
|
|
148
|
+
### 7. Replay from a checkpoint
|
|
83
149
|
|
|
84
150
|
```typescript
|
|
85
151
|
const checkpoints = await hdb.reversibility.getCheckpoints(execution.id);
|
|
@@ -95,6 +161,65 @@ console.log(replay.parentExecutionId); // original execution
|
|
|
95
161
|
|
|
96
162
|
---
|
|
97
163
|
|
|
164
|
+
## Core concepts
|
|
165
|
+
|
|
166
|
+
### Decision binding
|
|
167
|
+
|
|
168
|
+
Every governed execution must be linked to a prior policy decision via `decisionId`. This ensures no pipeline runs without a policy clearance and audit record.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// ✅ Correct — execution is governance-bound
|
|
172
|
+
await hdb.triggerPipeline({ pipelineId, input, decisionId: decision.id, idempotencyKey });
|
|
173
|
+
|
|
174
|
+
// ⚠️ Without decisionId — execution may proceed but will be flagged as ungoverned
|
|
175
|
+
await hdb.triggerPipeline({ pipelineId, input, idempotencyKey });
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Fail-closed pattern
|
|
179
|
+
|
|
180
|
+
Never execute a governed action when the decision is missing or unavailable.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
let decision;
|
|
184
|
+
try {
|
|
185
|
+
decision = await hdb.requestDecision({ action: 'PAYMENT_EXECUTE', resource });
|
|
186
|
+
} catch (err) {
|
|
187
|
+
// Decision service unavailable — fail closed, do not proceed
|
|
188
|
+
throw new Error('Governance unavailable — execution blocked');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (decision.result !== 'ALLOW') {
|
|
192
|
+
throw new Error(`Policy blocked: ${decision.reason}`);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Idempotency
|
|
197
|
+
|
|
198
|
+
Always pass `idempotencyKey` when triggering pipelines. It ensures safe retries after network errors and prevents duplicate execution of the same operation.
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// Use a stable key derived from your business operation
|
|
202
|
+
const idempotencyKey = `payment-${orderId}-${Date.now()}`;
|
|
203
|
+
|
|
204
|
+
await hdb.triggerPipeline({ pipelineId, input, decisionId, idempotencyKey });
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Identity (optional)
|
|
208
|
+
|
|
209
|
+
The `hdb.authenticate()` and actor management methods are only required if you use **Governed Identity** — where Stellrai manages your user identities and sessions.
|
|
210
|
+
|
|
211
|
+
If you use your own auth system (Clerk, Auth0, Supabase Auth, custom JWT), pass identity context via API keys and token headers. You do not need to call `hdb.authenticate()`.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// If using your own auth — just use your API key
|
|
215
|
+
const hdb = new HybriDBClient({ baseUrl, apiKey: process.env.HYBRIDB_API_KEY! });
|
|
216
|
+
|
|
217
|
+
// If using Governed Identity — authenticate via Stellrai
|
|
218
|
+
const tokens = await hdb.authenticate({ email, password });
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
98
223
|
## API reference
|
|
99
224
|
|
|
100
225
|
### `HybriDBClient`
|
|
@@ -112,10 +237,19 @@ const hdb = new HybriDBClient({
|
|
|
112
237
|
### Pipelines
|
|
113
238
|
|
|
114
239
|
```typescript
|
|
115
|
-
hdb.
|
|
240
|
+
hdb.pipelines.create(input) // register a pipeline definition → returns { id, name, ... }
|
|
241
|
+
hdb.triggerPipeline(input) // trigger execution by pipeline UUID
|
|
242
|
+
hdb.triggerPipelineByName(name, input) // trigger execution by pipeline name
|
|
116
243
|
hdb.getPipelineExecution(executionId) // get execution status
|
|
117
244
|
```
|
|
118
245
|
|
|
246
|
+
### Decisions
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
hdb.requestDecision(request) // policy-governed decision → { id, result: 'ALLOW'|'DENY'|'ESCALATE' }
|
|
250
|
+
hdb.getDecision(decisionId) // retrieve a past decision
|
|
251
|
+
```
|
|
252
|
+
|
|
119
253
|
### Reversibility
|
|
120
254
|
|
|
121
255
|
```typescript
|
|
@@ -128,15 +262,10 @@ hdb.reversibility.getCircuitBreaker(pipelineId) // get circuit breaker s
|
|
|
128
262
|
hdb.reversibility.setCircuitBreaker(pipelineId, input) // open / close circuit breaker
|
|
129
263
|
```
|
|
130
264
|
|
|
131
|
-
### Decisions
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
hdb.requestDecision(request) // policy-governed decision
|
|
135
|
-
hdb.getDecision(decisionId) // retrieve a past decision
|
|
136
|
-
```
|
|
137
|
-
|
|
138
265
|
### Identity & Auth
|
|
139
266
|
|
|
267
|
+
Only required when using Governed Identity mode. Not required if you manage your own user auth.
|
|
268
|
+
|
|
140
269
|
```typescript
|
|
141
270
|
hdb.authenticate(input) // email + password → token pair
|
|
142
271
|
hdb.refreshToken(refreshToken) // refresh an access token
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TokenPair, ActorContext, UUID, IdentityMapping, OrgMembership, InitiateRollbackInput, RollbackResult, InitiateReplayInput, ReplayResult, CheckpointSummary, Checkpoint, RollbackLog, CircuitBreakerStatus, SetCircuitBreakerInput, DecisionInput, DecisionResponse, TriggerPipelineInput, PipelineExecution, PublishEventInput, HybriDBEvent, PaginatedResponse, AuditEntry } from './common/index.js';
|
|
1
|
+
import { StepType, TokenPair, ActorContext, UUID, IdentityMapping, OrgMembership, InitiateRollbackInput, RollbackResult, InitiateReplayInput, ReplayResult, CheckpointSummary, Checkpoint, RollbackLog, CircuitBreakerStatus, SetCircuitBreakerInput, DecisionInput, DecisionResponse, PipelineDefinition, TriggerPipelineInput, PipelineExecution, PublishEventInput, HybriDBEvent, PaginatedResponse, AuditEntry } from './common/index.js';
|
|
2
2
|
|
|
3
3
|
interface HybriDBClientConfig {
|
|
4
4
|
baseUrl: string;
|
|
@@ -27,6 +27,35 @@ interface ApiKeyInput {
|
|
|
27
27
|
scopes: string[];
|
|
28
28
|
expiresAt?: string;
|
|
29
29
|
}
|
|
30
|
+
interface CreatePipelineStepInput {
|
|
31
|
+
/** Unique step identifier within this pipeline (used in dependsOn / compensationStep). */
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
type: StepType;
|
|
35
|
+
config?: Record<string, unknown>;
|
|
36
|
+
dependsOn?: string[];
|
|
37
|
+
/** Name of the step to run if this step needs to be compensated (reversed). */
|
|
38
|
+
compensationStep?: string;
|
|
39
|
+
/** Timeout in ms. Default: 30 000. */
|
|
40
|
+
timeout?: number;
|
|
41
|
+
retryPolicy?: {
|
|
42
|
+
maxAttempts: number;
|
|
43
|
+
backoffMs: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface CreatePipelineInput {
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
steps: CreatePipelineStepInput[];
|
|
50
|
+
inputSchema?: Record<string, unknown>;
|
|
51
|
+
outputSchema?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
interface TriggerByNameInput {
|
|
54
|
+
input?: Record<string, unknown>;
|
|
55
|
+
decisionId?: UUID;
|
|
56
|
+
triggerEvent?: string;
|
|
57
|
+
idempotencyKey?: string;
|
|
58
|
+
}
|
|
30
59
|
interface AuditQueryParams {
|
|
31
60
|
actorId?: string;
|
|
32
61
|
action?: string;
|
|
@@ -128,7 +157,22 @@ declare class HybriDBClient {
|
|
|
128
157
|
};
|
|
129
158
|
requestDecision(request: DecisionInput): Promise<DecisionResponse>;
|
|
130
159
|
getDecision(decisionId: UUID): Promise<DecisionResponse>;
|
|
160
|
+
/** Namespace for pipeline definition management. */
|
|
161
|
+
readonly pipelines: {
|
|
162
|
+
/**
|
|
163
|
+
* Register a pipeline definition. Returns the definition record including its UUID,
|
|
164
|
+
* which you pass to triggerPipeline() as pipelineId.
|
|
165
|
+
* Requires pipeline:write scope.
|
|
166
|
+
*/
|
|
167
|
+
readonly create: (input: CreatePipelineInput) => Promise<PipelineDefinition>;
|
|
168
|
+
};
|
|
131
169
|
triggerPipeline(input: TriggerPipelineInput): Promise<PipelineExecution>;
|
|
170
|
+
/**
|
|
171
|
+
* Trigger a pipeline execution by its name instead of UUID.
|
|
172
|
+
* Equivalent to triggerPipeline() but resolves the pipeline ID server-side.
|
|
173
|
+
* Requires pipeline:execute scope.
|
|
174
|
+
*/
|
|
175
|
+
triggerPipelineByName(name: string, input: TriggerByNameInput): Promise<PipelineExecution>;
|
|
132
176
|
getPipelineExecution(executionId: UUID): Promise<PipelineExecution>;
|
|
133
177
|
/** Publish a business event. Note: use actorId (v1.2), not identityId. */
|
|
134
178
|
publishEvent(input: PublishEventInput): Promise<HybriDBEvent>;
|
|
@@ -154,4 +198,4 @@ declare class HybriDBError extends Error {
|
|
|
154
198
|
constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
|
|
155
199
|
}
|
|
156
200
|
|
|
157
|
-
export { type ApiKeyInput as A, type CreateMappingInput as C, HybriDBClient as H, type OrgMemberInput as O, type AuditQueryParams as a, type AuthenticateInput as b, type
|
|
201
|
+
export { type ApiKeyInput as A, type CreateMappingInput as C, HybriDBClient as H, type OrgMemberInput as O, type TriggerByNameInput as T, type AuditQueryParams as a, type AuthenticateInput as b, type CreatePipelineInput as c, type CreatePipelineStepInput as d, type HybriDBClientConfig as e, HybriDBError as f };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TokenPair, ActorContext, UUID, IdentityMapping, OrgMembership, InitiateRollbackInput, RollbackResult, InitiateReplayInput, ReplayResult, CheckpointSummary, Checkpoint, RollbackLog, CircuitBreakerStatus, SetCircuitBreakerInput, DecisionInput, DecisionResponse, TriggerPipelineInput, PipelineExecution, PublishEventInput, HybriDBEvent, PaginatedResponse, AuditEntry } from './common/index.js';
|
|
1
|
+
import { StepType, TokenPair, ActorContext, UUID, IdentityMapping, OrgMembership, InitiateRollbackInput, RollbackResult, InitiateReplayInput, ReplayResult, CheckpointSummary, Checkpoint, RollbackLog, CircuitBreakerStatus, SetCircuitBreakerInput, DecisionInput, DecisionResponse, PipelineDefinition, TriggerPipelineInput, PipelineExecution, PublishEventInput, HybriDBEvent, PaginatedResponse, AuditEntry } from './common/index.js';
|
|
2
2
|
|
|
3
3
|
interface HybriDBClientConfig {
|
|
4
4
|
baseUrl: string;
|
|
@@ -27,6 +27,35 @@ interface ApiKeyInput {
|
|
|
27
27
|
scopes: string[];
|
|
28
28
|
expiresAt?: string;
|
|
29
29
|
}
|
|
30
|
+
interface CreatePipelineStepInput {
|
|
31
|
+
/** Unique step identifier within this pipeline (used in dependsOn / compensationStep). */
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
type: StepType;
|
|
35
|
+
config?: Record<string, unknown>;
|
|
36
|
+
dependsOn?: string[];
|
|
37
|
+
/** Name of the step to run if this step needs to be compensated (reversed). */
|
|
38
|
+
compensationStep?: string;
|
|
39
|
+
/** Timeout in ms. Default: 30 000. */
|
|
40
|
+
timeout?: number;
|
|
41
|
+
retryPolicy?: {
|
|
42
|
+
maxAttempts: number;
|
|
43
|
+
backoffMs: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
interface CreatePipelineInput {
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
steps: CreatePipelineStepInput[];
|
|
50
|
+
inputSchema?: Record<string, unknown>;
|
|
51
|
+
outputSchema?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
interface TriggerByNameInput {
|
|
54
|
+
input?: Record<string, unknown>;
|
|
55
|
+
decisionId?: UUID;
|
|
56
|
+
triggerEvent?: string;
|
|
57
|
+
idempotencyKey?: string;
|
|
58
|
+
}
|
|
30
59
|
interface AuditQueryParams {
|
|
31
60
|
actorId?: string;
|
|
32
61
|
action?: string;
|
|
@@ -128,7 +157,22 @@ declare class HybriDBClient {
|
|
|
128
157
|
};
|
|
129
158
|
requestDecision(request: DecisionInput): Promise<DecisionResponse>;
|
|
130
159
|
getDecision(decisionId: UUID): Promise<DecisionResponse>;
|
|
160
|
+
/** Namespace for pipeline definition management. */
|
|
161
|
+
readonly pipelines: {
|
|
162
|
+
/**
|
|
163
|
+
* Register a pipeline definition. Returns the definition record including its UUID,
|
|
164
|
+
* which you pass to triggerPipeline() as pipelineId.
|
|
165
|
+
* Requires pipeline:write scope.
|
|
166
|
+
*/
|
|
167
|
+
readonly create: (input: CreatePipelineInput) => Promise<PipelineDefinition>;
|
|
168
|
+
};
|
|
131
169
|
triggerPipeline(input: TriggerPipelineInput): Promise<PipelineExecution>;
|
|
170
|
+
/**
|
|
171
|
+
* Trigger a pipeline execution by its name instead of UUID.
|
|
172
|
+
* Equivalent to triggerPipeline() but resolves the pipeline ID server-side.
|
|
173
|
+
* Requires pipeline:execute scope.
|
|
174
|
+
*/
|
|
175
|
+
triggerPipelineByName(name: string, input: TriggerByNameInput): Promise<PipelineExecution>;
|
|
132
176
|
getPipelineExecution(executionId: UUID): Promise<PipelineExecution>;
|
|
133
177
|
/** Publish a business event. Note: use actorId (v1.2), not identityId. */
|
|
134
178
|
publishEvent(input: PublishEventInput): Promise<HybriDBEvent>;
|
|
@@ -154,4 +198,4 @@ declare class HybriDBError extends Error {
|
|
|
154
198
|
constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
|
|
155
199
|
}
|
|
156
200
|
|
|
157
|
-
export { type ApiKeyInput as A, type CreateMappingInput as C, HybriDBClient as H, type OrgMemberInput as O, type AuditQueryParams as a, type AuthenticateInput as b, type
|
|
201
|
+
export { type ApiKeyInput as A, type CreateMappingInput as C, HybriDBClient as H, type OrgMemberInput as O, type TriggerByNameInput as T, type AuditQueryParams as a, type AuthenticateInput as b, type CreatePipelineInput as c, type CreatePipelineStepInput as d, type HybriDBClientConfig as e, HybriDBError as f };
|
package/dist/index.cjs
CHANGED
|
@@ -196,10 +196,31 @@ var HybriDBClient = class {
|
|
|
196
196
|
return this.unwrap(res);
|
|
197
197
|
}
|
|
198
198
|
// ─── Pipelines ─────────────────────────────────────────────────────────────
|
|
199
|
+
/** Namespace for pipeline definition management. */
|
|
200
|
+
pipelines = {
|
|
201
|
+
/**
|
|
202
|
+
* Register a pipeline definition. Returns the definition record including its UUID,
|
|
203
|
+
* which you pass to triggerPipeline() as pipelineId.
|
|
204
|
+
* Requires pipeline:write scope.
|
|
205
|
+
*/
|
|
206
|
+
create: async (input) => {
|
|
207
|
+
const res = await this.post("/api/v1/pipelines", input);
|
|
208
|
+
return this.unwrap(res);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
199
211
|
async triggerPipeline(input) {
|
|
200
212
|
const res = await this.post("/api/v1/pipelines/trigger", input);
|
|
201
213
|
return this.unwrap(res);
|
|
202
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Trigger a pipeline execution by its name instead of UUID.
|
|
217
|
+
* Equivalent to triggerPipeline() but resolves the pipeline ID server-side.
|
|
218
|
+
* Requires pipeline:execute scope.
|
|
219
|
+
*/
|
|
220
|
+
async triggerPipelineByName(name, input) {
|
|
221
|
+
const res = await this.post(`/api/v1/pipelines/${encodeURIComponent(name)}/execute`, input);
|
|
222
|
+
return this.unwrap(res);
|
|
223
|
+
}
|
|
203
224
|
async getPipelineExecution(executionId) {
|
|
204
225
|
const res = await this.get(`/api/v1/pipelines/executions/${executionId}`);
|
|
205
226
|
return this.unwrap(res);
|
|
@@ -249,7 +270,7 @@ var HybriDBClient = class {
|
|
|
249
270
|
try {
|
|
250
271
|
const headers = {
|
|
251
272
|
"Content-Type": "application/json",
|
|
252
|
-
"X-SDK-Version": "1.
|
|
273
|
+
"X-SDK-Version": "1.4.0"
|
|
253
274
|
};
|
|
254
275
|
if (authenticated) {
|
|
255
276
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;;;AAgGA,IAAI,SAAA,GAAwD,IAAA;AAC5D,IAAI,YAAA,GAAe,CAAA;AACnB,IAAM,aAAA,GAAgB,IAAA;AAIf,IAAM,gBAAN,MAAoB;AAAA,EACR,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EAEjB,YAAY,MAAA,EAA6B;AACvC,IAAA,IAAI,CAAC,MAAA,CAAO,OAAA,QAAe,IAAI,YAAA,CAAa,gBAAgB,kCAAkC,CAAA;AAC9F,IAAA,IAAI,CAAC,MAAA,CAAO,MAAA,QAAe,IAAI,YAAA,CAAa,gBAAgB,iCAAiC,CAAA;AAE7F,IAAA,IAAA,CAAK,OAAA,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AAyB,uBAAA;AAAA;AAAA,EAEzB,aAAA,EAAyB,eAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA;AAAA,EAEzB,sBAAA,EAAyB,wBAAA;AAAA,EACzB,mBAAA,EAAyB,qBAAA;AAAA;AAAA,EAEzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,mBAAA,EAAyB;AAC3B","file":"index.cjs","sourcesContent":["// hybriDB SDK Client — v1.3\n//\n// v1.3 changes (v2.4 Reversible Autonomy):\n// - reversibility namespace: rollback(), replay(), getCheckpoints(), getCheckpoint(),\n// getRollbackLog(), getCircuitBreaker(), setCircuitBreaker()\n// - SDK-Version header bumped to 1.3.0\n//\n// v1.2 changes:\n// - db.actors.* namespace (replaces db.identities.*)\n// - createMapping() — create identity mapping for an actor\n// - assignRole() — assign a role to an actor\n// - orgs.addMember(), orgs.revokeMember(), orgs.listMembers(), orgs.updateMemberRole()\n// - verifyToken() — JWKS-based local token verification\n// - 7 new HybriDBErrorCode values (see @stellrai/types)\n// - actorId field in PublishEventInput (replaces identityId)\n// - SDK-Version header bumped to 1.2.0\n\nimport type {\n UUID,\n ApiResponse,\n DecisionInput,\n DecisionRequest,\n DecisionResponse,\n TriggerPipelineInput,\n PipelineExecution,\n PublishEventInput,\n HybriDBEvent,\n AuditEntry,\n PaginatedResponse,\n Actor,\n ActorContext,\n TokenPair,\n OrgMembership,\n IdentityMapping,\n // v2.4 Reversible Autonomy\n InitiateRollbackInput,\n RollbackResult,\n InitiateReplayInput,\n ReplayResult,\n Checkpoint,\n CheckpointSummary,\n RollbackLog,\n CircuitBreakerStatus,\n SetCircuitBreakerInput,\n} from '@stellrai/types';\n\n// ─── Client config ────────────────────────────────────────────────────────────\n\nexport interface HybriDBClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout?: number; // ms, default 10000\n retries?: number; // default 3\n retryDelay?: number; // ms, default 500\n}\n\n// ─── Auth inputs ─────────────────────────────────────────────────────────────\n\nexport interface AuthenticateInput {\n email: string;\n password: string;\n orgId?: string;\n}\n\nexport interface CreateMappingInput {\n providerId: string;\n externalId: string;\n userId: string;\n actorId: string;\n}\n\nexport interface OrgMemberInput {\n actorId: string;\n role: string;\n}\n\nexport interface ApiKeyInput {\n name?: string;\n scopes: string[];\n expiresAt?: string;\n}\n\nexport interface AuditQueryParams {\n actorId?: string;\n action?: string;\n outcome?: string;\n decisionId?: string;\n sessionId?: string;\n from?: string;\n to?: string;\n page?: number;\n limit?: number;\n}\n\n// ─── JWKS cache (module-level — shared across instances) ─────────────────────\n\nlet jwksCache: { keys: Record<string, unknown>[] } | null = null;\nlet jwksCachedAt = 0;\nconst JWKS_CACHE_MS = 3_600_000; // 1 hour\n\n// ─── HybriDBClient ────────────────────────────────────────────────────────────\n\nexport class HybriDBClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly retries: number;\n private readonly retryDelay: number;\n\n constructor(config: HybriDBClientConfig) {\n if (!config.baseUrl) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: baseUrl is required');\n if (!config.apiKey) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: apiKey is required');\n\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n this.timeout = config.timeout ?? 10_000;\n this.retries = config.retries ?? 3;\n this.retryDelay = config.retryDelay ?? 500;\n }\n\n // ─── auth — token issuance ──────────────────────────────────────────────────\n\n /** Exchange email + password for an access + refresh token pair. */\n async authenticate(input: AuthenticateInput): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/token', input);\n return this.unwrap(res);\n }\n\n /** Refresh an access token using a refresh token. */\n async refreshToken(refreshToken: string): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/refresh', { refreshToken });\n return this.unwrap(res);\n }\n\n /** Revoke the current session (requires authenticated API key/JWT). */\n async revokeSession(): Promise<void> {\n await this.delete('/api/v1/auth/token');\n }\n\n /**\n * Verify a JWT token locally using JWKS from the hybriDB server.\n * Returns the decoded actor context without making a decision API call.\n * JWKS is cached for 1 hour (spec: Cache-Control: max-age=3600).\n */\n async verifyToken(token: string): Promise<ActorContext> {\n const jwks = await this.getJwks();\n\n // Dynamic import — jose is optional peer dependency for token verification\n const { createRemoteJWKSet, jwtVerify } = await import('jose').catch(() => {\n throw new HybriDBError('DEPENDENCY_MISSING', 'jose is required for verifyToken() — install it: npm i jose');\n });\n\n // Build an in-memory JWKS from our cached keys\n const { createLocalJWKSet } = await import('jose');\n const keySet = createLocalJWKSet({ keys: jwks.keys as unknown as Parameters<typeof createLocalJWKSet>[0]['keys'] });\n\n const { payload } = await jwtVerify(token, keySet, { issuer: 'hybridb' });\n\n const p = payload as Record<string, unknown>;\n return {\n actorId: p['actor_id'] as string,\n actorType: p['actor_type'] as ActorContext['actorType'],\n orgId: p['org_id'] as string | null,\n scopes: (p['scopes'] as string[]) ?? [],\n policyVersion: p['policy_version'] as number,\n };\n }\n\n /** Fetch JWKS from the hybriDB server (cached for 1 hour). */\n async getJwks(): Promise<{ keys: Record<string, unknown>[] }> {\n if (jwksCache && Date.now() - jwksCachedAt < JWKS_CACHE_MS) {\n return jwksCache;\n }\n\n const res = await this.getPublic<{ keys: Record<string, unknown>[] }>('/.well-known/jwks.json');\n const data = this.unwrap(res);\n jwksCache = data;\n jwksCachedAt = Date.now();\n return data;\n }\n\n // ─── db.actors — actor management ──────────────────────────────────────────\n\n /** Namespace for actor management operations. */\n readonly actors = {\n /** Issue an API key for an actor. Requires actor:admin scope. */\n createApiKey: async (actorId: UUID, input: ApiKeyInput): Promise<{ id: string; key: string }> => {\n const res = await this.post<{ id: string; key: string }>(\n `/api/v1/actors/${actorId}/api-keys`, input,\n );\n return this.unwrap(res);\n },\n\n /** Revoke an API key. Requires actor:admin scope. */\n revokeApiKey: async (actorId: UUID, keyId: UUID): Promise<void> => {\n await this.delete(`/api/v1/actors/${actorId}/api-keys/${keyId}`);\n },\n\n /** Create an identity mapping (external provider → actor). Requires actor:write scope. */\n createMapping: async (actorId: UUID, input: CreateMappingInput): Promise<IdentityMapping> => {\n const res = await this.post<IdentityMapping>(\n `/api/v1/actors/${actorId}/identity-mappings`, input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── orgs — organisation membership ────────────────────────────────────────\n\n /** Namespace for organisation membership operations. */\n readonly orgs = {\n /** Add a member to an organisation. Requires org:admin scope. */\n addMember: async (orgId: UUID, input: OrgMemberInput): Promise<OrgMembership> => {\n const res = await this.post<OrgMembership>(`/api/v1/orgs/${orgId}/memberships`, input);\n return this.unwrap(res);\n },\n\n /** Update a member's role. Requires org:admin scope. */\n updateMemberRole: async (orgId: UUID, actorId: UUID, role: string): Promise<OrgMembership> => {\n const res = await this.patch<OrgMembership>(\n `/api/v1/orgs/${orgId}/memberships/${actorId}`, { role },\n );\n return this.unwrap(res);\n },\n\n /** Revoke an actor's membership. Requires org:admin scope. */\n revokeMember: async (orgId: UUID, actorId: UUID): Promise<void> => {\n await this.delete(`/api/v1/orgs/${orgId}/memberships/${actorId}`);\n },\n\n /** List organisation members. Requires org:read scope. */\n listMembers: async (orgId: UUID): Promise<OrgMembership[]> => {\n const res = await this.get<OrgMembership[]>(`/api/v1/orgs/${orgId}/memberships`);\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Reversibility (v2.4) ──────────────────────────────────────────────────\n\n /** Namespace for Reversible Autonomy operations (v2.4). */\n readonly reversibility = {\n /**\n * Initiate a rollback for an execution.\n * Types: 'full' (all steps), 'selective' (targetSteps list), 'to_checkpoint'.\n * Requires pipeline:rollback scope.\n */\n rollback: async (executionId: UUID, input: Omit<InitiateRollbackInput, 'executionId'>): Promise<RollbackResult> => {\n const res = await this.post<RollbackResult>(`/api/v1/executions/${executionId}/rollback`, input);\n return this.unwrap(res);\n },\n\n /**\n * Initiate a replay from a checkpoint.\n * Creates a new child execution starting from the checkpoint's step.\n * Requires pipeline:replay scope.\n */\n replay: async (executionId: UUID, input: Omit<InitiateReplayInput, 'executionId'>): Promise<ReplayResult> => {\n const res = await this.post<ReplayResult>(`/api/v1/executions/${executionId}/replay`, input);\n return this.unwrap(res);\n },\n\n /**\n * List all checkpoints for an execution (ordered by step_index asc).\n * Requires pipeline:read scope.\n */\n getCheckpoints: async (executionId: UUID): Promise<CheckpointSummary[]> => {\n const res = await this.get<CheckpointSummary[]>(`/api/v1/executions/${executionId}/checkpoints`);\n return this.unwrap(res);\n },\n\n /**\n * Get a specific checkpoint (with checksum verification).\n * Throws REPLAY_CONTEXT_INVALID if checksum mismatches.\n * Requires pipeline:read scope.\n */\n getCheckpoint: async (executionId: UUID, checkpointId: UUID): Promise<Checkpoint> => {\n const res = await this.get<Checkpoint>(`/api/v1/executions/${executionId}/checkpoints/${checkpointId}`);\n return this.unwrap(res);\n },\n\n /**\n * List all rollback log entries for an execution.\n * Requires pipeline:read scope.\n */\n getRollbackLog: async (executionId: UUID): Promise<RollbackLog[]> => {\n const res = await this.get<RollbackLog[]>(`/api/v1/executions/${executionId}/rollback-log`);\n return this.unwrap(res);\n },\n\n /**\n * Get circuit breaker status for a pipeline.\n * Requires pipeline:read scope.\n */\n getCircuitBreaker: async (pipelineId: UUID): Promise<CircuitBreakerStatus> => {\n const res = await this.get<CircuitBreakerStatus>(`/api/v1/pipelines/${pipelineId}/circuit-breaker`);\n return this.unwrap(res);\n },\n\n /**\n * Open or close the circuit breaker for a pipeline.\n * Opening halts all future executions immediately.\n * Requires pipeline:circuit_breaker scope.\n */\n setCircuitBreaker: async (pipelineId: UUID, input: Omit<SetCircuitBreakerInput, 'pipelineId'>): Promise<CircuitBreakerStatus> => {\n const res = await this.post<CircuitBreakerStatus>(\n `/api/v1/pipelines/${pipelineId}/circuit-breaker`,\n input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Decisions ─────────────────────────────────────────────────────────────\n\n async requestDecision(request: DecisionInput): Promise<DecisionResponse> {\n const res = await this.post<DecisionResponse>('/api/v1/decisions', request);\n return this.unwrap(res);\n }\n\n async getDecision(decisionId: UUID): Promise<DecisionResponse> {\n const res = await this.get<DecisionResponse>(`/api/v1/decisions/${decisionId}`);\n return this.unwrap(res);\n }\n\n // ─── Pipelines ─────────────────────────────────────────────────────────────\n\n async triggerPipeline(input: TriggerPipelineInput): Promise<PipelineExecution> {\n const res = await this.post<PipelineExecution>('/api/v1/pipelines/trigger', input);\n return this.unwrap(res);\n }\n\n async getPipelineExecution(executionId: UUID): Promise<PipelineExecution> {\n const res = await this.get<PipelineExecution>(`/api/v1/pipelines/executions/${executionId}`);\n return this.unwrap(res);\n }\n\n // ─── Events ────────────────────────────────────────────────────────────────\n\n /** Publish a business event. Note: use actorId (v1.2), not identityId. */\n async publishEvent(input: PublishEventInput): Promise<HybriDBEvent> {\n const res = await this.post<HybriDBEvent>('/api/v1/events', input);\n return this.unwrap(res);\n }\n\n // ─── Audit ─────────────────────────────────────────────────────────────────\n\n async queryAuditLog(params: AuditQueryParams): Promise<PaginatedResponse<AuditEntry>> {\n const query = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) query.set(k, String(v));\n }\n const res = await this.get<PaginatedResponse<AuditEntry>>(`/api/v1/audit?${query.toString()}`);\n return this.unwrap(res);\n }\n\n // ─── Health ────────────────────────────────────────────────────────────────\n\n async health(): Promise<{ status: string; version: string }> {\n const res = await this.getPublic<{ status: string; version: string }>('/health');\n return this.unwrap(res);\n }\n\n // ─── HTTP primitives ───────────────────────────────────────────────────────\n\n private async get<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, true);\n }\n\n private async getPublic<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, false);\n }\n\n private async post<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, true);\n }\n\n private async postPublic<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, false);\n }\n\n private async patch<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('PATCH', path, body, true);\n }\n\n private async delete(path: string): Promise<void> {\n await this.request<void>('DELETE', path, undefined, true);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body: unknown,\n authenticated: boolean,\n attempt = 1,\n ): Promise<ApiResponse<T>> {\n const controller = new AbortController();\n const timerId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-SDK-Version': '1.3.0',\n };\n if (authenticated) {\n headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n\n const response = await fetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n ...(body !== undefined ? { body: JSON.stringify(body) } : {}),\n signal: controller.signal,\n });\n\n // 204 No Content — return success with no data\n if (response.status === 204) {\n return { success: true, data: undefined as T };\n }\n\n const json = await response.json() as ApiResponse<T>;\n\n if (!response.ok && attempt < this.retries && this.isRetryable(response.status)) {\n await this.sleep(this.retryDelay * attempt);\n return this.request<T>(method, path, body, authenticated, attempt + 1);\n }\n\n return json;\n } finally {\n clearTimeout(timerId);\n }\n }\n\n private unwrap<T>(response: ApiResponse<T>): T {\n if (!response.success || response.data === undefined) {\n throw new HybriDBError(\n response.error?.code ?? 'UNKNOWN_ERROR',\n response.error?.message ?? 'hybriDB request failed',\n response.error?.details,\n );\n }\n return response.data;\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n}\n\n// ─── HybriDBError ─────────────────────────────────────────────────────────────\n\nexport class HybriDBError extends Error {\n constructor(\n public readonly code: string,\n message: string,\n public readonly details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'HybriDBError';\n }\n}\n","// hybriDB SDK — v1.2\nexport { HybriDBClient, HybriDBError } from './client.js';\nexport type {\n HybriDBClientConfig,\n AuthenticateInput,\n CreateMappingInput,\n OrgMemberInput,\n ApiKeyInput,\n AuditQueryParams,\n} from './client.js';\n\n// React context — exported from '@hybridb/sdk/react' (separate entry point, browser only)\n\n// Re-export commonly used types for SDK consumers\nexport type {\n // Actor-centric (v1.2)\n Actor,\n ActorContext,\n ActorType,\n ActorStatus,\n User,\n OrgMembership,\n IdentityMapping,\n Session,\n TokenPair,\n // Decisions\n DecisionRequest,\n DecisionResponse,\n DecisionResult,\n // Pipelines\n TriggerPipelineInput,\n PipelineExecution,\n // Events — actorId (v1.2), not identityId\n PublishEventInput,\n HybriDBEvent,\n // Audit\n AuditEntry,\n AuditOutcome,\n // Policy\n Policy,\n PolicyEvaluationResult,\n // Shared\n ApiResponse,\n ApiError,\n PaginatedResponse,\n UUID,\n ISO8601,\n // Errors\n HybriDBErrorCode,\n} from '@stellrai/types';\n\n// ─── Event type constants (v1.2) ──────────────────────────────────────────────\n\nexport const HYBRIDB_EVENT_TYPES = {\n // Decisions\n DECISION_REQUESTED: 'decision.requested',\n DECISION_ALLOWED: 'decision.allowed',\n DECISION_BLOCKED: 'decision.blocked',\n DECISION_ESCALATED: 'decision.escalated',\n // Pipelines\n PIPELINE_STARTED: 'pipeline.started',\n PIPELINE_COMPLETED: 'pipeline.completed',\n PIPELINE_FAILED: 'pipeline.failed',\n PIPELINE_COMPENSATED: 'pipeline.compensated',\n // Payments\n PAYMENT_INITIATED: 'payment.initiated',\n PAYMENT_COMPLETED: 'payment.completed',\n PAYMENT_FAILED: 'payment.failed',\n PAYMENT_REVERSED: 'payment.reversed',\n // Identity (v1.2 — actor-centric)\n ACTOR_CREATED: 'actor.created',\n ACTOR_SUSPENDED: 'actor.suspended',\n ACTOR_REVOKED: 'actor.revoked',\n IDENTITY_RESOLVED: 'identity.resolved',\n IDENTITY_RESOLUTION_FAILED: 'identity.resolution_failed',\n // Policy\n POLICY_ACTIVATED: 'policy.activated',\n POLICY_DEACTIVATED: 'policy.deactivated',\n POLICY_VERSION_BUMPED: 'policy.version_bumped',\n // KYC\n KYC_SUBMITTED: 'kyc.submitted',\n KYC_APPROVED: 'kyc.approved',\n KYC_REJECTED: 'kyc.rejected',\n // AI\n AI_INFERENCE_COMPLETED: 'ai.inference_completed',\n AI_INFERENCE_FAILED: 'ai.inference_failed',\n // Fraud\n FRAUD_SIGNAL_DETECTED: 'fraud.signal_detected',\n // sync-back\n SYNC_BACK_EXHAUSTED: 'sync_back.exhausted',\n} as const;\n\nexport type HybriDBEventType = typeof HYBRIDB_EVENT_TYPES[keyof typeof HYBRIDB_EVENT_TYPES];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;;;AAwIA,IAAI,SAAA,GAAwD,IAAA;AAC5D,IAAI,YAAA,GAAe,CAAA;AACnB,IAAM,aAAA,GAAgB,IAAA;AAIf,IAAM,gBAAN,MAAoB;AAAA,EACR,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EAEjB,YAAY,MAAA,EAA6B;AACvC,IAAA,IAAI,CAAC,MAAA,CAAO,OAAA,QAAe,IAAI,YAAA,CAAa,gBAAgB,kCAAkC,CAAA;AAC9F,IAAA,IAAI,CAAC,MAAA,CAAO,MAAA,QAAe,IAAI,YAAA,CAAa,gBAAgB,iCAAiC,CAAA;AAE7F,IAAA,IAAA,CAAK,OAAA,GAAa,MAAA,CAAO,OAAA,CAAQ,OAAA,CAAQ,OAAO,EAAE,CAAA;AAClD,IAAA,IAAA,CAAK,SAAa,MAAA,CAAO,MAAA;AACzB,IAAA,IAAA,CAAK,OAAA,GAAa,OAAO,OAAA,IAAa,GAAA;AACtC,IAAA,IAAA,CAAK,OAAA,GAAa,OAAO,OAAA,IAAa,CAAA;AACtC,IAAA,IAAA,CAAK,UAAA,GAAa,OAAO,UAAA,IAAc,GAAA;AAAA,EACzC;AAAA;AAAA;AAAA,EAKA,MAAM,aAAa,KAAA,EAA8C;AAC/D,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,UAAA,CAAsB,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A,EACzB,0BAAA,EAA4B,4BAAA;AAAA;AAAA,EAE5B,gBAAA,EAAyB,kBAAA;AAAA,EACzB,kBAAA,EAAyB,oBAAA;AAAA,EACzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,aAAA,EAAyB,eAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA;AAAA,EAEzB,sBAAA,EAAyB,wBAAA;AAAA,EACzB,mBAAA,EAAyB,qBAAA;AAAA;AAAA,EAEzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,mBAAA,EAAyB;AAC3B","file":"index.cjs","sourcesContent":["// hybriDB SDK Client — v1.4\n//\n// v1.4 changes:\n// - pipelines namespace: create() — register a pipeline definition\n// - triggerPipelineByName() — trigger execution by pipeline name (URL-based)\n// - CreatePipelineInput, CreatePipelineStepInput, TriggerByNameInput types\n// - SDK-Version header bumped to 1.4.0\n//\n// v1.3 changes (v2.4 Reversible Autonomy):\n// - reversibility namespace: rollback(), replay(), getCheckpoints(), getCheckpoint(),\n// getRollbackLog(), getCircuitBreaker(), setCircuitBreaker()\n// - SDK-Version header bumped to 1.3.0\n//\n// v1.2 changes:\n// - db.actors.* namespace (replaces db.identities.*)\n// - createMapping() — create identity mapping for an actor\n// - assignRole() — assign a role to an actor\n// - orgs.addMember(), orgs.revokeMember(), orgs.listMembers(), orgs.updateMemberRole()\n// - verifyToken() — JWKS-based local token verification\n// - 7 new HybriDBErrorCode values (see @stellrai/types)\n// - actorId field in PublishEventInput (replaces identityId)\n// - SDK-Version header bumped to 1.2.0\n\nimport type {\n UUID,\n ApiResponse,\n DecisionInput,\n DecisionRequest,\n DecisionResponse,\n TriggerPipelineInput,\n PipelineDefinition,\n PipelineExecution,\n StepType,\n PublishEventInput,\n HybriDBEvent,\n AuditEntry,\n PaginatedResponse,\n Actor,\n ActorContext,\n TokenPair,\n OrgMembership,\n IdentityMapping,\n // v2.4 Reversible Autonomy\n InitiateRollbackInput,\n RollbackResult,\n InitiateReplayInput,\n ReplayResult,\n Checkpoint,\n CheckpointSummary,\n RollbackLog,\n CircuitBreakerStatus,\n SetCircuitBreakerInput,\n} from '@stellrai/types';\n\n// ─── Client config ────────────────────────────────────────────────────────────\n\nexport interface HybriDBClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout?: number; // ms, default 10000\n retries?: number; // default 3\n retryDelay?: number; // ms, default 500\n}\n\n// ─── Auth inputs ─────────────────────────────────────────────────────────────\n\nexport interface AuthenticateInput {\n email: string;\n password: string;\n orgId?: string;\n}\n\nexport interface CreateMappingInput {\n providerId: string;\n externalId: string;\n userId: string;\n actorId: string;\n}\n\nexport interface OrgMemberInput {\n actorId: string;\n role: string;\n}\n\nexport interface ApiKeyInput {\n name?: string;\n scopes: string[];\n expiresAt?: string;\n}\n\nexport interface CreatePipelineStepInput {\n /** Unique step identifier within this pipeline (used in dependsOn / compensationStep). */\n id: string;\n name: string;\n type: StepType;\n config?: Record<string, unknown>;\n dependsOn?: string[];\n /** Name of the step to run if this step needs to be compensated (reversed). */\n compensationStep?: string;\n /** Timeout in ms. Default: 30 000. */\n timeout?: number;\n retryPolicy?: {\n maxAttempts: number;\n backoffMs: number;\n };\n}\n\nexport interface CreatePipelineInput {\n name: string;\n description?: string;\n steps: CreatePipelineStepInput[];\n inputSchema?: Record<string, unknown>;\n outputSchema?: Record<string, unknown>;\n}\n\nexport interface TriggerByNameInput {\n input?: Record<string, unknown>;\n decisionId?: UUID;\n triggerEvent?: string;\n idempotencyKey?: string;\n}\n\nexport interface AuditQueryParams {\n actorId?: string;\n action?: string;\n outcome?: string;\n decisionId?: string;\n sessionId?: string;\n from?: string;\n to?: string;\n page?: number;\n limit?: number;\n}\n\n// ─── JWKS cache (module-level — shared across instances) ─────────────────────\n\nlet jwksCache: { keys: Record<string, unknown>[] } | null = null;\nlet jwksCachedAt = 0;\nconst JWKS_CACHE_MS = 3_600_000; // 1 hour\n\n// ─── HybriDBClient ────────────────────────────────────────────────────────────\n\nexport class HybriDBClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly retries: number;\n private readonly retryDelay: number;\n\n constructor(config: HybriDBClientConfig) {\n if (!config.baseUrl) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: baseUrl is required');\n if (!config.apiKey) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: apiKey is required');\n\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n this.timeout = config.timeout ?? 10_000;\n this.retries = config.retries ?? 3;\n this.retryDelay = config.retryDelay ?? 500;\n }\n\n // ─── auth — token issuance ──────────────────────────────────────────────────\n\n /** Exchange email + password for an access + refresh token pair. */\n async authenticate(input: AuthenticateInput): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/token', input);\n return this.unwrap(res);\n }\n\n /** Refresh an access token using a refresh token. */\n async refreshToken(refreshToken: string): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/refresh', { refreshToken });\n return this.unwrap(res);\n }\n\n /** Revoke the current session (requires authenticated API key/JWT). */\n async revokeSession(): Promise<void> {\n await this.delete('/api/v1/auth/token');\n }\n\n /**\n * Verify a JWT token locally using JWKS from the hybriDB server.\n * Returns the decoded actor context without making a decision API call.\n * JWKS is cached for 1 hour (spec: Cache-Control: max-age=3600).\n */\n async verifyToken(token: string): Promise<ActorContext> {\n const jwks = await this.getJwks();\n\n // Dynamic import — jose is optional peer dependency for token verification\n const { createRemoteJWKSet, jwtVerify } = await import('jose').catch(() => {\n throw new HybriDBError('DEPENDENCY_MISSING', 'jose is required for verifyToken() — install it: npm i jose');\n });\n\n // Build an in-memory JWKS from our cached keys\n const { createLocalJWKSet } = await import('jose');\n const keySet = createLocalJWKSet({ keys: jwks.keys as unknown as Parameters<typeof createLocalJWKSet>[0]['keys'] });\n\n const { payload } = await jwtVerify(token, keySet, { issuer: 'hybridb' });\n\n const p = payload as Record<string, unknown>;\n return {\n actorId: p['actor_id'] as string,\n actorType: p['actor_type'] as ActorContext['actorType'],\n orgId: p['org_id'] as string | null,\n scopes: (p['scopes'] as string[]) ?? [],\n policyVersion: p['policy_version'] as number,\n };\n }\n\n /** Fetch JWKS from the hybriDB server (cached for 1 hour). */\n async getJwks(): Promise<{ keys: Record<string, unknown>[] }> {\n if (jwksCache && Date.now() - jwksCachedAt < JWKS_CACHE_MS) {\n return jwksCache;\n }\n\n const res = await this.getPublic<{ keys: Record<string, unknown>[] }>('/.well-known/jwks.json');\n const data = this.unwrap(res);\n jwksCache = data;\n jwksCachedAt = Date.now();\n return data;\n }\n\n // ─── db.actors — actor management ──────────────────────────────────────────\n\n /** Namespace for actor management operations. */\n readonly actors = {\n /** Issue an API key for an actor. Requires actor:admin scope. */\n createApiKey: async (actorId: UUID, input: ApiKeyInput): Promise<{ id: string; key: string }> => {\n const res = await this.post<{ id: string; key: string }>(\n `/api/v1/actors/${actorId}/api-keys`, input,\n );\n return this.unwrap(res);\n },\n\n /** Revoke an API key. Requires actor:admin scope. */\n revokeApiKey: async (actorId: UUID, keyId: UUID): Promise<void> => {\n await this.delete(`/api/v1/actors/${actorId}/api-keys/${keyId}`);\n },\n\n /** Create an identity mapping (external provider → actor). Requires actor:write scope. */\n createMapping: async (actorId: UUID, input: CreateMappingInput): Promise<IdentityMapping> => {\n const res = await this.post<IdentityMapping>(\n `/api/v1/actors/${actorId}/identity-mappings`, input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── orgs — organisation membership ────────────────────────────────────────\n\n /** Namespace for organisation membership operations. */\n readonly orgs = {\n /** Add a member to an organisation. Requires org:admin scope. */\n addMember: async (orgId: UUID, input: OrgMemberInput): Promise<OrgMembership> => {\n const res = await this.post<OrgMembership>(`/api/v1/orgs/${orgId}/memberships`, input);\n return this.unwrap(res);\n },\n\n /** Update a member's role. Requires org:admin scope. */\n updateMemberRole: async (orgId: UUID, actorId: UUID, role: string): Promise<OrgMembership> => {\n const res = await this.patch<OrgMembership>(\n `/api/v1/orgs/${orgId}/memberships/${actorId}`, { role },\n );\n return this.unwrap(res);\n },\n\n /** Revoke an actor's membership. Requires org:admin scope. */\n revokeMember: async (orgId: UUID, actorId: UUID): Promise<void> => {\n await this.delete(`/api/v1/orgs/${orgId}/memberships/${actorId}`);\n },\n\n /** List organisation members. Requires org:read scope. */\n listMembers: async (orgId: UUID): Promise<OrgMembership[]> => {\n const res = await this.get<OrgMembership[]>(`/api/v1/orgs/${orgId}/memberships`);\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Reversibility (v2.4) ──────────────────────────────────────────────────\n\n /** Namespace for Reversible Autonomy operations (v2.4). */\n readonly reversibility = {\n /**\n * Initiate a rollback for an execution.\n * Types: 'full' (all steps), 'selective' (targetSteps list), 'to_checkpoint'.\n * Requires pipeline:rollback scope.\n */\n rollback: async (executionId: UUID, input: Omit<InitiateRollbackInput, 'executionId'>): Promise<RollbackResult> => {\n const res = await this.post<RollbackResult>(`/api/v1/executions/${executionId}/rollback`, input);\n return this.unwrap(res);\n },\n\n /**\n * Initiate a replay from a checkpoint.\n * Creates a new child execution starting from the checkpoint's step.\n * Requires pipeline:replay scope.\n */\n replay: async (executionId: UUID, input: Omit<InitiateReplayInput, 'executionId'>): Promise<ReplayResult> => {\n const res = await this.post<ReplayResult>(`/api/v1/executions/${executionId}/replay`, input);\n return this.unwrap(res);\n },\n\n /**\n * List all checkpoints for an execution (ordered by step_index asc).\n * Requires pipeline:read scope.\n */\n getCheckpoints: async (executionId: UUID): Promise<CheckpointSummary[]> => {\n const res = await this.get<CheckpointSummary[]>(`/api/v1/executions/${executionId}/checkpoints`);\n return this.unwrap(res);\n },\n\n /**\n * Get a specific checkpoint (with checksum verification).\n * Throws REPLAY_CONTEXT_INVALID if checksum mismatches.\n * Requires pipeline:read scope.\n */\n getCheckpoint: async (executionId: UUID, checkpointId: UUID): Promise<Checkpoint> => {\n const res = await this.get<Checkpoint>(`/api/v1/executions/${executionId}/checkpoints/${checkpointId}`);\n return this.unwrap(res);\n },\n\n /**\n * List all rollback log entries for an execution.\n * Requires pipeline:read scope.\n */\n getRollbackLog: async (executionId: UUID): Promise<RollbackLog[]> => {\n const res = await this.get<RollbackLog[]>(`/api/v1/executions/${executionId}/rollback-log`);\n return this.unwrap(res);\n },\n\n /**\n * Get circuit breaker status for a pipeline.\n * Requires pipeline:read scope.\n */\n getCircuitBreaker: async (pipelineId: UUID): Promise<CircuitBreakerStatus> => {\n const res = await this.get<CircuitBreakerStatus>(`/api/v1/pipelines/${pipelineId}/circuit-breaker`);\n return this.unwrap(res);\n },\n\n /**\n * Open or close the circuit breaker for a pipeline.\n * Opening halts all future executions immediately.\n * Requires pipeline:circuit_breaker scope.\n */\n setCircuitBreaker: async (pipelineId: UUID, input: Omit<SetCircuitBreakerInput, 'pipelineId'>): Promise<CircuitBreakerStatus> => {\n const res = await this.post<CircuitBreakerStatus>(\n `/api/v1/pipelines/${pipelineId}/circuit-breaker`,\n input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Decisions ─────────────────────────────────────────────────────────────\n\n async requestDecision(request: DecisionInput): Promise<DecisionResponse> {\n const res = await this.post<DecisionResponse>('/api/v1/decisions', request);\n return this.unwrap(res);\n }\n\n async getDecision(decisionId: UUID): Promise<DecisionResponse> {\n const res = await this.get<DecisionResponse>(`/api/v1/decisions/${decisionId}`);\n return this.unwrap(res);\n }\n\n // ─── Pipelines ─────────────────────────────────────────────────────────────\n\n /** Namespace for pipeline definition management. */\n readonly pipelines = {\n /**\n * Register a pipeline definition. Returns the definition record including its UUID,\n * which you pass to triggerPipeline() as pipelineId.\n * Requires pipeline:write scope.\n */\n create: async (input: CreatePipelineInput): Promise<PipelineDefinition> => {\n const res = await this.post<PipelineDefinition>('/api/v1/pipelines', input);\n return this.unwrap(res);\n },\n } as const;\n\n async triggerPipeline(input: TriggerPipelineInput): Promise<PipelineExecution> {\n const res = await this.post<PipelineExecution>('/api/v1/pipelines/trigger', input);\n return this.unwrap(res);\n }\n\n /**\n * Trigger a pipeline execution by its name instead of UUID.\n * Equivalent to triggerPipeline() but resolves the pipeline ID server-side.\n * Requires pipeline:execute scope.\n */\n async triggerPipelineByName(name: string, input: TriggerByNameInput): Promise<PipelineExecution> {\n const res = await this.post<PipelineExecution>(`/api/v1/pipelines/${encodeURIComponent(name)}/execute`, input);\n return this.unwrap(res);\n }\n\n async getPipelineExecution(executionId: UUID): Promise<PipelineExecution> {\n const res = await this.get<PipelineExecution>(`/api/v1/pipelines/executions/${executionId}`);\n return this.unwrap(res);\n }\n\n // ─── Events ────────────────────────────────────────────────────────────────\n\n /** Publish a business event. Note: use actorId (v1.2), not identityId. */\n async publishEvent(input: PublishEventInput): Promise<HybriDBEvent> {\n const res = await this.post<HybriDBEvent>('/api/v1/events', input);\n return this.unwrap(res);\n }\n\n // ─── Audit ─────────────────────────────────────────────────────────────────\n\n async queryAuditLog(params: AuditQueryParams): Promise<PaginatedResponse<AuditEntry>> {\n const query = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) query.set(k, String(v));\n }\n const res = await this.get<PaginatedResponse<AuditEntry>>(`/api/v1/audit?${query.toString()}`);\n return this.unwrap(res);\n }\n\n // ─── Health ────────────────────────────────────────────────────────────────\n\n async health(): Promise<{ status: string; version: string }> {\n const res = await this.getPublic<{ status: string; version: string }>('/health');\n return this.unwrap(res);\n }\n\n // ─── HTTP primitives ───────────────────────────────────────────────────────\n\n private async get<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, true);\n }\n\n private async getPublic<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, false);\n }\n\n private async post<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, true);\n }\n\n private async postPublic<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, false);\n }\n\n private async patch<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('PATCH', path, body, true);\n }\n\n private async delete(path: string): Promise<void> {\n await this.request<void>('DELETE', path, undefined, true);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body: unknown,\n authenticated: boolean,\n attempt = 1,\n ): Promise<ApiResponse<T>> {\n const controller = new AbortController();\n const timerId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-SDK-Version': '1.4.0',\n };\n if (authenticated) {\n headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n\n const response = await fetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n ...(body !== undefined ? { body: JSON.stringify(body) } : {}),\n signal: controller.signal,\n });\n\n // 204 No Content — return success with no data\n if (response.status === 204) {\n return { success: true, data: undefined as T };\n }\n\n const json = await response.json() as ApiResponse<T>;\n\n if (!response.ok && attempt < this.retries && this.isRetryable(response.status)) {\n await this.sleep(this.retryDelay * attempt);\n return this.request<T>(method, path, body, authenticated, attempt + 1);\n }\n\n return json;\n } finally {\n clearTimeout(timerId);\n }\n }\n\n private unwrap<T>(response: ApiResponse<T>): T {\n if (!response.success || response.data === undefined) {\n throw new HybriDBError(\n response.error?.code ?? 'UNKNOWN_ERROR',\n response.error?.message ?? 'hybriDB request failed',\n response.error?.details,\n );\n }\n return response.data;\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n}\n\n// ─── HybriDBError ─────────────────────────────────────────────────────────────\n\nexport class HybriDBError extends Error {\n constructor(\n public readonly code: string,\n message: string,\n public readonly details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'HybriDBError';\n }\n}\n","// hybriDB SDK — v1.4\nexport { HybriDBClient, HybriDBError } from './client.js';\nexport type {\n HybriDBClientConfig,\n AuthenticateInput,\n CreateMappingInput,\n OrgMemberInput,\n ApiKeyInput,\n AuditQueryParams,\n // v1.4 — pipeline self-service\n CreatePipelineInput,\n CreatePipelineStepInput,\n TriggerByNameInput,\n} from './client.js';\n\n// React context — exported from '@hybridb/sdk/react' (separate entry point, browser only)\n\n// Re-export commonly used types for SDK consumers\nexport type {\n // Actor-centric (v1.2)\n Actor,\n ActorContext,\n ActorType,\n ActorStatus,\n User,\n OrgMembership,\n IdentityMapping,\n Session,\n TokenPair,\n // Decisions\n DecisionRequest,\n DecisionResponse,\n DecisionResult,\n // Pipelines\n PipelineDefinition,\n PipelineStepDefinition,\n StepType,\n TriggerPipelineInput,\n PipelineExecution,\n // Events — actorId (v1.2), not identityId\n PublishEventInput,\n HybriDBEvent,\n // Audit\n AuditEntry,\n AuditOutcome,\n // Policy\n Policy,\n PolicyEvaluationResult,\n // Shared\n ApiResponse,\n ApiError,\n PaginatedResponse,\n UUID,\n ISO8601,\n // Errors\n HybriDBErrorCode,\n} from '@stellrai/types';\n\n// ─── Event type constants (v1.2) ──────────────────────────────────────────────\n\nexport const HYBRIDB_EVENT_TYPES = {\n // Decisions\n DECISION_REQUESTED: 'decision.requested',\n DECISION_ALLOWED: 'decision.allowed',\n DECISION_BLOCKED: 'decision.blocked',\n DECISION_ESCALATED: 'decision.escalated',\n // Pipelines\n PIPELINE_STARTED: 'pipeline.started',\n PIPELINE_COMPLETED: 'pipeline.completed',\n PIPELINE_FAILED: 'pipeline.failed',\n PIPELINE_COMPENSATED: 'pipeline.compensated',\n // Payments\n PAYMENT_INITIATED: 'payment.initiated',\n PAYMENT_COMPLETED: 'payment.completed',\n PAYMENT_FAILED: 'payment.failed',\n PAYMENT_REVERSED: 'payment.reversed',\n // Identity (v1.2 — actor-centric)\n ACTOR_CREATED: 'actor.created',\n ACTOR_SUSPENDED: 'actor.suspended',\n ACTOR_REVOKED: 'actor.revoked',\n IDENTITY_RESOLVED: 'identity.resolved',\n IDENTITY_RESOLUTION_FAILED: 'identity.resolution_failed',\n // Policy\n POLICY_ACTIVATED: 'policy.activated',\n POLICY_DEACTIVATED: 'policy.deactivated',\n POLICY_VERSION_BUMPED: 'policy.version_bumped',\n // KYC\n KYC_SUBMITTED: 'kyc.submitted',\n KYC_APPROVED: 'kyc.approved',\n KYC_REJECTED: 'kyc.rejected',\n // AI\n AI_INFERENCE_COMPLETED: 'ai.inference_completed',\n AI_INFERENCE_FAILED: 'ai.inference_failed',\n // Fraud\n FRAUD_SIGNAL_DETECTED: 'fraud.signal_detected',\n // sync-back\n SYNC_BACK_EXHAUSTED: 'sync_back.exhausted',\n} as const;\n\nexport type HybriDBEventType = typeof HYBRIDB_EVENT_TYPES[keyof typeof HYBRIDB_EVENT_TYPES];\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as ApiKeyInput, a as AuditQueryParams, b as AuthenticateInput, C as CreateMappingInput, H as HybriDBClient,
|
|
2
|
-
export { Actor, ActorContext, ActorStatus, ActorType, ApiError, ApiResponse, AuditEntry, AuditOutcome, DecisionRequest, DecisionResponse, DecisionResult, HybriDBErrorCode, HybriDBEvent, ISO8601, IdentityMapping, OrgMembership, PaginatedResponse, PipelineExecution, Policy, PolicyEvaluationResult, PublishEventInput, Session, TokenPair, TriggerPipelineInput, UUID, User } from './common/index.js';
|
|
1
|
+
export { A as ApiKeyInput, a as AuditQueryParams, b as AuthenticateInput, C as CreateMappingInput, c as CreatePipelineInput, d as CreatePipelineStepInput, H as HybriDBClient, e as HybriDBClientConfig, f as HybriDBError, O as OrgMemberInput, T as TriggerByNameInput } from './client-DD1fNp-I.cjs';
|
|
2
|
+
export { Actor, ActorContext, ActorStatus, ActorType, ApiError, ApiResponse, AuditEntry, AuditOutcome, DecisionRequest, DecisionResponse, DecisionResult, HybriDBErrorCode, HybriDBEvent, ISO8601, IdentityMapping, OrgMembership, PaginatedResponse, PipelineDefinition, PipelineExecution, PipelineStepDefinition, Policy, PolicyEvaluationResult, PublishEventInput, Session, StepType, TokenPair, TriggerPipelineInput, UUID, User } from './common/index.js';
|
|
3
3
|
|
|
4
4
|
declare const HYBRIDB_EVENT_TYPES: {
|
|
5
5
|
readonly DECISION_REQUESTED: "decision.requested";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as ApiKeyInput, a as AuditQueryParams, b as AuthenticateInput, C as CreateMappingInput, H as HybriDBClient,
|
|
2
|
-
export { Actor, ActorContext, ActorStatus, ActorType, ApiError, ApiResponse, AuditEntry, AuditOutcome, DecisionRequest, DecisionResponse, DecisionResult, HybriDBErrorCode, HybriDBEvent, ISO8601, IdentityMapping, OrgMembership, PaginatedResponse, PipelineExecution, Policy, PolicyEvaluationResult, PublishEventInput, Session, TokenPair, TriggerPipelineInput, UUID, User } from './common/index.js';
|
|
1
|
+
export { A as ApiKeyInput, a as AuditQueryParams, b as AuthenticateInput, C as CreateMappingInput, c as CreatePipelineInput, d as CreatePipelineStepInput, H as HybriDBClient, e as HybriDBClientConfig, f as HybriDBError, O as OrgMemberInput, T as TriggerByNameInput } from './client-DD1fNp-I.js';
|
|
2
|
+
export { Actor, ActorContext, ActorStatus, ActorType, ApiError, ApiResponse, AuditEntry, AuditOutcome, DecisionRequest, DecisionResponse, DecisionResult, HybriDBErrorCode, HybriDBEvent, ISO8601, IdentityMapping, OrgMembership, PaginatedResponse, PipelineDefinition, PipelineExecution, PipelineStepDefinition, Policy, PolicyEvaluationResult, PublishEventInput, Session, StepType, TokenPair, TriggerPipelineInput, UUID, User } from './common/index.js';
|
|
3
3
|
|
|
4
4
|
declare const HYBRIDB_EVENT_TYPES: {
|
|
5
5
|
readonly DECISION_REQUESTED: "decision.requested";
|
package/dist/index.js
CHANGED
|
@@ -194,10 +194,31 @@ var HybriDBClient = class {
|
|
|
194
194
|
return this.unwrap(res);
|
|
195
195
|
}
|
|
196
196
|
// ─── Pipelines ─────────────────────────────────────────────────────────────
|
|
197
|
+
/** Namespace for pipeline definition management. */
|
|
198
|
+
pipelines = {
|
|
199
|
+
/**
|
|
200
|
+
* Register a pipeline definition. Returns the definition record including its UUID,
|
|
201
|
+
* which you pass to triggerPipeline() as pipelineId.
|
|
202
|
+
* Requires pipeline:write scope.
|
|
203
|
+
*/
|
|
204
|
+
create: async (input) => {
|
|
205
|
+
const res = await this.post("/api/v1/pipelines", input);
|
|
206
|
+
return this.unwrap(res);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
197
209
|
async triggerPipeline(input) {
|
|
198
210
|
const res = await this.post("/api/v1/pipelines/trigger", input);
|
|
199
211
|
return this.unwrap(res);
|
|
200
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Trigger a pipeline execution by its name instead of UUID.
|
|
215
|
+
* Equivalent to triggerPipeline() but resolves the pipeline ID server-side.
|
|
216
|
+
* Requires pipeline:execute scope.
|
|
217
|
+
*/
|
|
218
|
+
async triggerPipelineByName(name, input) {
|
|
219
|
+
const res = await this.post(`/api/v1/pipelines/${encodeURIComponent(name)}/execute`, input);
|
|
220
|
+
return this.unwrap(res);
|
|
221
|
+
}
|
|
201
222
|
async getPipelineExecution(executionId) {
|
|
202
223
|
const res = await this.get(`/api/v1/pipelines/executions/${executionId}`);
|
|
203
224
|
return this.unwrap(res);
|
|
@@ -247,7 +268,7 @@ var HybriDBClient = class {
|
|
|
247
268
|
try {
|
|
248
269
|
const headers = {
|
|
249
270
|
"Content-Type": "application/json",
|
|
250
|
-
"X-SDK-Version": "1.
|
|
271
|
+
"X-SDK-Version": "1.4.0"
|
|
251
272
|
};
|
|
252
273
|
if (authenticated) {
|
|
253
274
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;AAgGA,IAAI,SAAA,GAAwD,IAAA;AAC5D,IAAI,YAAA,GAAe,CAAA;AACnB,IAAM,aAAA,GAAgB,IAAA;AAIf,IAAM,gBAAN,MAAoB;AAAA,EACR,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAA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AA;AAAA,EAEzB,aAAA,EAAyB,eAAA;AAAA,EACzB,eAAA,EAAyB,iBAAA;AAAA,EACzB,aAAA,EAAyB,eAAA;AAAA,EACzB,iBAAA,EAAyB,mBAAA;AAAA,EACzB,0BAAA,EAA4B,4BAAA;AAAA;AAAA,EAE5B,gBAAA,EAAyB,kBAAA;AAAA,EACzB,kBAAA,EAAyB,oBAAA;AAAA,EACzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,aAAA,EAAyB,eAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA;AAAA,EAEzB,sBAAA,EAAyB,wBAAA;AAAA,EACzB,mBAAA,EAAyB,qBAAA;AAAA;AAAA,EAEzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,mBAAA,EAAyB;AAC3B","file":"index.js","sourcesContent":["// hybriDB SDK Client — v1.3\n//\n// v1.3 changes (v2.4 Reversible Autonomy):\n// - reversibility namespace: rollback(), replay(), getCheckpoints(), getCheckpoint(),\n// getRollbackLog(), getCircuitBreaker(), setCircuitBreaker()\n// - SDK-Version header bumped to 1.3.0\n//\n// v1.2 changes:\n// - db.actors.* namespace (replaces db.identities.*)\n// - createMapping() — create identity mapping for an actor\n// - assignRole() — assign a role to an actor\n// - orgs.addMember(), orgs.revokeMember(), orgs.listMembers(), orgs.updateMemberRole()\n// - verifyToken() — JWKS-based local token verification\n// - 7 new HybriDBErrorCode values (see @stellrai/types)\n// - actorId field in PublishEventInput (replaces identityId)\n// - SDK-Version header bumped to 1.2.0\n\nimport type {\n UUID,\n ApiResponse,\n DecisionInput,\n DecisionRequest,\n DecisionResponse,\n TriggerPipelineInput,\n PipelineExecution,\n PublishEventInput,\n HybriDBEvent,\n AuditEntry,\n PaginatedResponse,\n Actor,\n ActorContext,\n TokenPair,\n OrgMembership,\n IdentityMapping,\n // v2.4 Reversible Autonomy\n InitiateRollbackInput,\n RollbackResult,\n InitiateReplayInput,\n ReplayResult,\n Checkpoint,\n CheckpointSummary,\n RollbackLog,\n CircuitBreakerStatus,\n SetCircuitBreakerInput,\n} from '@stellrai/types';\n\n// ─── Client config ────────────────────────────────────────────────────────────\n\nexport interface HybriDBClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout?: number; // ms, default 10000\n retries?: number; // default 3\n retryDelay?: number; // ms, default 500\n}\n\n// ─── Auth inputs ─────────────────────────────────────────────────────────────\n\nexport interface AuthenticateInput {\n email: string;\n password: string;\n orgId?: string;\n}\n\nexport interface CreateMappingInput {\n providerId: string;\n externalId: string;\n userId: string;\n actorId: string;\n}\n\nexport interface OrgMemberInput {\n actorId: string;\n role: string;\n}\n\nexport interface ApiKeyInput {\n name?: string;\n scopes: string[];\n expiresAt?: string;\n}\n\nexport interface AuditQueryParams {\n actorId?: string;\n action?: string;\n outcome?: string;\n decisionId?: string;\n sessionId?: string;\n from?: string;\n to?: string;\n page?: number;\n limit?: number;\n}\n\n// ─── JWKS cache (module-level — shared across instances) ─────────────────────\n\nlet jwksCache: { keys: Record<string, unknown>[] } | null = null;\nlet jwksCachedAt = 0;\nconst JWKS_CACHE_MS = 3_600_000; // 1 hour\n\n// ─── HybriDBClient ────────────────────────────────────────────────────────────\n\nexport class HybriDBClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly retries: number;\n private readonly retryDelay: number;\n\n constructor(config: HybriDBClientConfig) {\n if (!config.baseUrl) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: baseUrl is required');\n if (!config.apiKey) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: apiKey is required');\n\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n this.timeout = config.timeout ?? 10_000;\n this.retries = config.retries ?? 3;\n this.retryDelay = config.retryDelay ?? 500;\n }\n\n // ─── auth — token issuance ──────────────────────────────────────────────────\n\n /** Exchange email + password for an access + refresh token pair. */\n async authenticate(input: AuthenticateInput): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/token', input);\n return this.unwrap(res);\n }\n\n /** Refresh an access token using a refresh token. */\n async refreshToken(refreshToken: string): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/refresh', { refreshToken });\n return this.unwrap(res);\n }\n\n /** Revoke the current session (requires authenticated API key/JWT). */\n async revokeSession(): Promise<void> {\n await this.delete('/api/v1/auth/token');\n }\n\n /**\n * Verify a JWT token locally using JWKS from the hybriDB server.\n * Returns the decoded actor context without making a decision API call.\n * JWKS is cached for 1 hour (spec: Cache-Control: max-age=3600).\n */\n async verifyToken(token: string): Promise<ActorContext> {\n const jwks = await this.getJwks();\n\n // Dynamic import — jose is optional peer dependency for token verification\n const { createRemoteJWKSet, jwtVerify } = await import('jose').catch(() => {\n throw new HybriDBError('DEPENDENCY_MISSING', 'jose is required for verifyToken() — install it: npm i jose');\n });\n\n // Build an in-memory JWKS from our cached keys\n const { createLocalJWKSet } = await import('jose');\n const keySet = createLocalJWKSet({ keys: jwks.keys as unknown as Parameters<typeof createLocalJWKSet>[0]['keys'] });\n\n const { payload } = await jwtVerify(token, keySet, { issuer: 'hybridb' });\n\n const p = payload as Record<string, unknown>;\n return {\n actorId: p['actor_id'] as string,\n actorType: p['actor_type'] as ActorContext['actorType'],\n orgId: p['org_id'] as string | null,\n scopes: (p['scopes'] as string[]) ?? [],\n policyVersion: p['policy_version'] as number,\n };\n }\n\n /** Fetch JWKS from the hybriDB server (cached for 1 hour). */\n async getJwks(): Promise<{ keys: Record<string, unknown>[] }> {\n if (jwksCache && Date.now() - jwksCachedAt < JWKS_CACHE_MS) {\n return jwksCache;\n }\n\n const res = await this.getPublic<{ keys: Record<string, unknown>[] }>('/.well-known/jwks.json');\n const data = this.unwrap(res);\n jwksCache = data;\n jwksCachedAt = Date.now();\n return data;\n }\n\n // ─── db.actors — actor management ──────────────────────────────────────────\n\n /** Namespace for actor management operations. */\n readonly actors = {\n /** Issue an API key for an actor. Requires actor:admin scope. */\n createApiKey: async (actorId: UUID, input: ApiKeyInput): Promise<{ id: string; key: string }> => {\n const res = await this.post<{ id: string; key: string }>(\n `/api/v1/actors/${actorId}/api-keys`, input,\n );\n return this.unwrap(res);\n },\n\n /** Revoke an API key. Requires actor:admin scope. */\n revokeApiKey: async (actorId: UUID, keyId: UUID): Promise<void> => {\n await this.delete(`/api/v1/actors/${actorId}/api-keys/${keyId}`);\n },\n\n /** Create an identity mapping (external provider → actor). Requires actor:write scope. */\n createMapping: async (actorId: UUID, input: CreateMappingInput): Promise<IdentityMapping> => {\n const res = await this.post<IdentityMapping>(\n `/api/v1/actors/${actorId}/identity-mappings`, input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── orgs — organisation membership ────────────────────────────────────────\n\n /** Namespace for organisation membership operations. */\n readonly orgs = {\n /** Add a member to an organisation. Requires org:admin scope. */\n addMember: async (orgId: UUID, input: OrgMemberInput): Promise<OrgMembership> => {\n const res = await this.post<OrgMembership>(`/api/v1/orgs/${orgId}/memberships`, input);\n return this.unwrap(res);\n },\n\n /** Update a member's role. Requires org:admin scope. */\n updateMemberRole: async (orgId: UUID, actorId: UUID, role: string): Promise<OrgMembership> => {\n const res = await this.patch<OrgMembership>(\n `/api/v1/orgs/${orgId}/memberships/${actorId}`, { role },\n );\n return this.unwrap(res);\n },\n\n /** Revoke an actor's membership. Requires org:admin scope. */\n revokeMember: async (orgId: UUID, actorId: UUID): Promise<void> => {\n await this.delete(`/api/v1/orgs/${orgId}/memberships/${actorId}`);\n },\n\n /** List organisation members. Requires org:read scope. */\n listMembers: async (orgId: UUID): Promise<OrgMembership[]> => {\n const res = await this.get<OrgMembership[]>(`/api/v1/orgs/${orgId}/memberships`);\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Reversibility (v2.4) ──────────────────────────────────────────────────\n\n /** Namespace for Reversible Autonomy operations (v2.4). */\n readonly reversibility = {\n /**\n * Initiate a rollback for an execution.\n * Types: 'full' (all steps), 'selective' (targetSteps list), 'to_checkpoint'.\n * Requires pipeline:rollback scope.\n */\n rollback: async (executionId: UUID, input: Omit<InitiateRollbackInput, 'executionId'>): Promise<RollbackResult> => {\n const res = await this.post<RollbackResult>(`/api/v1/executions/${executionId}/rollback`, input);\n return this.unwrap(res);\n },\n\n /**\n * Initiate a replay from a checkpoint.\n * Creates a new child execution starting from the checkpoint's step.\n * Requires pipeline:replay scope.\n */\n replay: async (executionId: UUID, input: Omit<InitiateReplayInput, 'executionId'>): Promise<ReplayResult> => {\n const res = await this.post<ReplayResult>(`/api/v1/executions/${executionId}/replay`, input);\n return this.unwrap(res);\n },\n\n /**\n * List all checkpoints for an execution (ordered by step_index asc).\n * Requires pipeline:read scope.\n */\n getCheckpoints: async (executionId: UUID): Promise<CheckpointSummary[]> => {\n const res = await this.get<CheckpointSummary[]>(`/api/v1/executions/${executionId}/checkpoints`);\n return this.unwrap(res);\n },\n\n /**\n * Get a specific checkpoint (with checksum verification).\n * Throws REPLAY_CONTEXT_INVALID if checksum mismatches.\n * Requires pipeline:read scope.\n */\n getCheckpoint: async (executionId: UUID, checkpointId: UUID): Promise<Checkpoint> => {\n const res = await this.get<Checkpoint>(`/api/v1/executions/${executionId}/checkpoints/${checkpointId}`);\n return this.unwrap(res);\n },\n\n /**\n * List all rollback log entries for an execution.\n * Requires pipeline:read scope.\n */\n getRollbackLog: async (executionId: UUID): Promise<RollbackLog[]> => {\n const res = await this.get<RollbackLog[]>(`/api/v1/executions/${executionId}/rollback-log`);\n return this.unwrap(res);\n },\n\n /**\n * Get circuit breaker status for a pipeline.\n * Requires pipeline:read scope.\n */\n getCircuitBreaker: async (pipelineId: UUID): Promise<CircuitBreakerStatus> => {\n const res = await this.get<CircuitBreakerStatus>(`/api/v1/pipelines/${pipelineId}/circuit-breaker`);\n return this.unwrap(res);\n },\n\n /**\n * Open or close the circuit breaker for a pipeline.\n * Opening halts all future executions immediately.\n * Requires pipeline:circuit_breaker scope.\n */\n setCircuitBreaker: async (pipelineId: UUID, input: Omit<SetCircuitBreakerInput, 'pipelineId'>): Promise<CircuitBreakerStatus> => {\n const res = await this.post<CircuitBreakerStatus>(\n `/api/v1/pipelines/${pipelineId}/circuit-breaker`,\n input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Decisions ─────────────────────────────────────────────────────────────\n\n async requestDecision(request: DecisionInput): Promise<DecisionResponse> {\n const res = await this.post<DecisionResponse>('/api/v1/decisions', request);\n return this.unwrap(res);\n }\n\n async getDecision(decisionId: UUID): Promise<DecisionResponse> {\n const res = await this.get<DecisionResponse>(`/api/v1/decisions/${decisionId}`);\n return this.unwrap(res);\n }\n\n // ─── Pipelines ─────────────────────────────────────────────────────────────\n\n async triggerPipeline(input: TriggerPipelineInput): Promise<PipelineExecution> {\n const res = await this.post<PipelineExecution>('/api/v1/pipelines/trigger', input);\n return this.unwrap(res);\n }\n\n async getPipelineExecution(executionId: UUID): Promise<PipelineExecution> {\n const res = await this.get<PipelineExecution>(`/api/v1/pipelines/executions/${executionId}`);\n return this.unwrap(res);\n }\n\n // ─── Events ────────────────────────────────────────────────────────────────\n\n /** Publish a business event. Note: use actorId (v1.2), not identityId. */\n async publishEvent(input: PublishEventInput): Promise<HybriDBEvent> {\n const res = await this.post<HybriDBEvent>('/api/v1/events', input);\n return this.unwrap(res);\n }\n\n // ─── Audit ─────────────────────────────────────────────────────────────────\n\n async queryAuditLog(params: AuditQueryParams): Promise<PaginatedResponse<AuditEntry>> {\n const query = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) query.set(k, String(v));\n }\n const res = await this.get<PaginatedResponse<AuditEntry>>(`/api/v1/audit?${query.toString()}`);\n return this.unwrap(res);\n }\n\n // ─── Health ────────────────────────────────────────────────────────────────\n\n async health(): Promise<{ status: string; version: string }> {\n const res = await this.getPublic<{ status: string; version: string }>('/health');\n return this.unwrap(res);\n }\n\n // ─── HTTP primitives ───────────────────────────────────────────────────────\n\n private async get<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, true);\n }\n\n private async getPublic<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, false);\n }\n\n private async post<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, true);\n }\n\n private async postPublic<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, false);\n }\n\n private async patch<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('PATCH', path, body, true);\n }\n\n private async delete(path: string): Promise<void> {\n await this.request<void>('DELETE', path, undefined, true);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body: unknown,\n authenticated: boolean,\n attempt = 1,\n ): Promise<ApiResponse<T>> {\n const controller = new AbortController();\n const timerId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-SDK-Version': '1.3.0',\n };\n if (authenticated) {\n headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n\n const response = await fetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n ...(body !== undefined ? { body: JSON.stringify(body) } : {}),\n signal: controller.signal,\n });\n\n // 204 No Content — return success with no data\n if (response.status === 204) {\n return { success: true, data: undefined as T };\n }\n\n const json = await response.json() as ApiResponse<T>;\n\n if (!response.ok && attempt < this.retries && this.isRetryable(response.status)) {\n await this.sleep(this.retryDelay * attempt);\n return this.request<T>(method, path, body, authenticated, attempt + 1);\n }\n\n return json;\n } finally {\n clearTimeout(timerId);\n }\n }\n\n private unwrap<T>(response: ApiResponse<T>): T {\n if (!response.success || response.data === undefined) {\n throw new HybriDBError(\n response.error?.code ?? 'UNKNOWN_ERROR',\n response.error?.message ?? 'hybriDB request failed',\n response.error?.details,\n );\n }\n return response.data;\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n}\n\n// ─── HybriDBError ─────────────────────────────────────────────────────────────\n\nexport class HybriDBError extends Error {\n constructor(\n public readonly code: string,\n message: string,\n public readonly details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'HybriDBError';\n }\n}\n","// hybriDB SDK — v1.2\nexport { HybriDBClient, HybriDBError } from './client.js';\nexport type {\n HybriDBClientConfig,\n AuthenticateInput,\n CreateMappingInput,\n OrgMemberInput,\n ApiKeyInput,\n AuditQueryParams,\n} from './client.js';\n\n// React context — exported from '@hybridb/sdk/react' (separate entry point, browser only)\n\n// Re-export commonly used types for SDK consumers\nexport type {\n // Actor-centric (v1.2)\n Actor,\n ActorContext,\n ActorType,\n ActorStatus,\n User,\n OrgMembership,\n IdentityMapping,\n Session,\n TokenPair,\n // Decisions\n DecisionRequest,\n DecisionResponse,\n DecisionResult,\n // Pipelines\n TriggerPipelineInput,\n PipelineExecution,\n // Events — actorId (v1.2), not identityId\n PublishEventInput,\n HybriDBEvent,\n // Audit\n AuditEntry,\n AuditOutcome,\n // Policy\n Policy,\n PolicyEvaluationResult,\n // Shared\n ApiResponse,\n ApiError,\n PaginatedResponse,\n UUID,\n ISO8601,\n // Errors\n HybriDBErrorCode,\n} from '@stellrai/types';\n\n// ─── Event type constants (v1.2) ──────────────────────────────────────────────\n\nexport const HYBRIDB_EVENT_TYPES = {\n // Decisions\n DECISION_REQUESTED: 'decision.requested',\n DECISION_ALLOWED: 'decision.allowed',\n DECISION_BLOCKED: 'decision.blocked',\n DECISION_ESCALATED: 'decision.escalated',\n // Pipelines\n PIPELINE_STARTED: 'pipeline.started',\n PIPELINE_COMPLETED: 'pipeline.completed',\n PIPELINE_FAILED: 'pipeline.failed',\n PIPELINE_COMPENSATED: 'pipeline.compensated',\n // Payments\n PAYMENT_INITIATED: 'payment.initiated',\n PAYMENT_COMPLETED: 'payment.completed',\n PAYMENT_FAILED: 'payment.failed',\n PAYMENT_REVERSED: 'payment.reversed',\n // Identity (v1.2 — actor-centric)\n ACTOR_CREATED: 'actor.created',\n ACTOR_SUSPENDED: 'actor.suspended',\n ACTOR_REVOKED: 'actor.revoked',\n IDENTITY_RESOLVED: 'identity.resolved',\n IDENTITY_RESOLUTION_FAILED: 'identity.resolution_failed',\n // Policy\n POLICY_ACTIVATED: 'policy.activated',\n POLICY_DEACTIVATED: 'policy.deactivated',\n POLICY_VERSION_BUMPED: 'policy.version_bumped',\n // KYC\n KYC_SUBMITTED: 'kyc.submitted',\n KYC_APPROVED: 'kyc.approved',\n KYC_REJECTED: 'kyc.rejected',\n // AI\n AI_INFERENCE_COMPLETED: 'ai.inference_completed',\n AI_INFERENCE_FAILED: 'ai.inference_failed',\n // Fraud\n FRAUD_SIGNAL_DETECTED: 'fraud.signal_detected',\n // sync-back\n SYNC_BACK_EXHAUSTED: 'sync_back.exhausted',\n} as const;\n\nexport type HybriDBEventType = typeof HYBRIDB_EVENT_TYPES[keyof typeof HYBRIDB_EVENT_TYPES];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;AAwIA,IAAI,SAAA,GAAwD,IAAA;AAC5D,IAAI,YAAA,GAAe,CAAA;AACnB,IAAM,aAAA,GAAgB,IAAA;AAIf,IAAM,gBAAN,MAAoB;AAAA,EACR,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EAEjB,YAAY,MAAA,EAA6B;AACvC,IAAA,IAAI,CAAC,MAAA,CAAO,OAAA,QAAe,IAAI,YAAA,CAAa,gBAAgB,kCAAkC,CAAA;AAC9F,IAAA,IAAI,CAAC,MAAA,CAAO,MAAA,QAAe,IAAI,YAAA,CAAa,gBAAgB,iCAAiC,CAAA;AAE7F,IAAA,IAAA,CAAK,OAAA,GAAa,MAAA,CAAO,OAAA,CAAQ,OAAA,CAAQ,OAAO,EAAE,CAAA;AAClD,IAAA,IAAA,CAAK,SAAa,MAAA,CAAO,MAAA;AACzB,IAAA,IAAA,CAAK,OAAA,GAAa,OAAO,OAAA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AA,EAAyB,mBAAA;AAAA,EACzB,iBAAA,EAAyB,mBAAA;AAAA,EACzB,cAAA,EAAyB,gBAAA;AAAA,EACzB,gBAAA,EAAyB,kBAAA;AAAA;AAAA,EAEzB,aAAA,EAAyB,eAAA;AAAA,EACzB,eAAA,EAAyB,iBAAA;AAAA,EACzB,aAAA,EAAyB,eAAA;AAAA,EACzB,iBAAA,EAAyB,mBAAA;AAAA,EACzB,0BAAA,EAA4B,4BAAA;AAAA;AAAA,EAE5B,gBAAA,EAAyB,kBAAA;AAAA,EACzB,kBAAA,EAAyB,oBAAA;AAAA,EACzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,aAAA,EAAyB,eAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA,EACzB,YAAA,EAAyB,cAAA;AAAA;AAAA,EAEzB,sBAAA,EAAyB,wBAAA;AAAA,EACzB,mBAAA,EAAyB,qBAAA;AAAA;AAAA,EAEzB,qBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,mBAAA,EAAyB;AAC3B","file":"index.js","sourcesContent":["// hybriDB SDK Client — v1.4\n//\n// v1.4 changes:\n// - pipelines namespace: create() — register a pipeline definition\n// - triggerPipelineByName() — trigger execution by pipeline name (URL-based)\n// - CreatePipelineInput, CreatePipelineStepInput, TriggerByNameInput types\n// - SDK-Version header bumped to 1.4.0\n//\n// v1.3 changes (v2.4 Reversible Autonomy):\n// - reversibility namespace: rollback(), replay(), getCheckpoints(), getCheckpoint(),\n// getRollbackLog(), getCircuitBreaker(), setCircuitBreaker()\n// - SDK-Version header bumped to 1.3.0\n//\n// v1.2 changes:\n// - db.actors.* namespace (replaces db.identities.*)\n// - createMapping() — create identity mapping for an actor\n// - assignRole() — assign a role to an actor\n// - orgs.addMember(), orgs.revokeMember(), orgs.listMembers(), orgs.updateMemberRole()\n// - verifyToken() — JWKS-based local token verification\n// - 7 new HybriDBErrorCode values (see @stellrai/types)\n// - actorId field in PublishEventInput (replaces identityId)\n// - SDK-Version header bumped to 1.2.0\n\nimport type {\n UUID,\n ApiResponse,\n DecisionInput,\n DecisionRequest,\n DecisionResponse,\n TriggerPipelineInput,\n PipelineDefinition,\n PipelineExecution,\n StepType,\n PublishEventInput,\n HybriDBEvent,\n AuditEntry,\n PaginatedResponse,\n Actor,\n ActorContext,\n TokenPair,\n OrgMembership,\n IdentityMapping,\n // v2.4 Reversible Autonomy\n InitiateRollbackInput,\n RollbackResult,\n InitiateReplayInput,\n ReplayResult,\n Checkpoint,\n CheckpointSummary,\n RollbackLog,\n CircuitBreakerStatus,\n SetCircuitBreakerInput,\n} from '@stellrai/types';\n\n// ─── Client config ────────────────────────────────────────────────────────────\n\nexport interface HybriDBClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout?: number; // ms, default 10000\n retries?: number; // default 3\n retryDelay?: number; // ms, default 500\n}\n\n// ─── Auth inputs ─────────────────────────────────────────────────────────────\n\nexport interface AuthenticateInput {\n email: string;\n password: string;\n orgId?: string;\n}\n\nexport interface CreateMappingInput {\n providerId: string;\n externalId: string;\n userId: string;\n actorId: string;\n}\n\nexport interface OrgMemberInput {\n actorId: string;\n role: string;\n}\n\nexport interface ApiKeyInput {\n name?: string;\n scopes: string[];\n expiresAt?: string;\n}\n\nexport interface CreatePipelineStepInput {\n /** Unique step identifier within this pipeline (used in dependsOn / compensationStep). */\n id: string;\n name: string;\n type: StepType;\n config?: Record<string, unknown>;\n dependsOn?: string[];\n /** Name of the step to run if this step needs to be compensated (reversed). */\n compensationStep?: string;\n /** Timeout in ms. Default: 30 000. */\n timeout?: number;\n retryPolicy?: {\n maxAttempts: number;\n backoffMs: number;\n };\n}\n\nexport interface CreatePipelineInput {\n name: string;\n description?: string;\n steps: CreatePipelineStepInput[];\n inputSchema?: Record<string, unknown>;\n outputSchema?: Record<string, unknown>;\n}\n\nexport interface TriggerByNameInput {\n input?: Record<string, unknown>;\n decisionId?: UUID;\n triggerEvent?: string;\n idempotencyKey?: string;\n}\n\nexport interface AuditQueryParams {\n actorId?: string;\n action?: string;\n outcome?: string;\n decisionId?: string;\n sessionId?: string;\n from?: string;\n to?: string;\n page?: number;\n limit?: number;\n}\n\n// ─── JWKS cache (module-level — shared across instances) ─────────────────────\n\nlet jwksCache: { keys: Record<string, unknown>[] } | null = null;\nlet jwksCachedAt = 0;\nconst JWKS_CACHE_MS = 3_600_000; // 1 hour\n\n// ─── HybriDBClient ────────────────────────────────────────────────────────────\n\nexport class HybriDBClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly retries: number;\n private readonly retryDelay: number;\n\n constructor(config: HybriDBClientConfig) {\n if (!config.baseUrl) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: baseUrl is required');\n if (!config.apiKey) throw new HybriDBError('CONFIG_ERROR', 'hybriDB SDK: apiKey is required');\n\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n this.timeout = config.timeout ?? 10_000;\n this.retries = config.retries ?? 3;\n this.retryDelay = config.retryDelay ?? 500;\n }\n\n // ─── auth — token issuance ──────────────────────────────────────────────────\n\n /** Exchange email + password for an access + refresh token pair. */\n async authenticate(input: AuthenticateInput): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/token', input);\n return this.unwrap(res);\n }\n\n /** Refresh an access token using a refresh token. */\n async refreshToken(refreshToken: string): Promise<TokenPair> {\n const res = await this.postPublic<TokenPair>('/api/v1/auth/refresh', { refreshToken });\n return this.unwrap(res);\n }\n\n /** Revoke the current session (requires authenticated API key/JWT). */\n async revokeSession(): Promise<void> {\n await this.delete('/api/v1/auth/token');\n }\n\n /**\n * Verify a JWT token locally using JWKS from the hybriDB server.\n * Returns the decoded actor context without making a decision API call.\n * JWKS is cached for 1 hour (spec: Cache-Control: max-age=3600).\n */\n async verifyToken(token: string): Promise<ActorContext> {\n const jwks = await this.getJwks();\n\n // Dynamic import — jose is optional peer dependency for token verification\n const { createRemoteJWKSet, jwtVerify } = await import('jose').catch(() => {\n throw new HybriDBError('DEPENDENCY_MISSING', 'jose is required for verifyToken() — install it: npm i jose');\n });\n\n // Build an in-memory JWKS from our cached keys\n const { createLocalJWKSet } = await import('jose');\n const keySet = createLocalJWKSet({ keys: jwks.keys as unknown as Parameters<typeof createLocalJWKSet>[0]['keys'] });\n\n const { payload } = await jwtVerify(token, keySet, { issuer: 'hybridb' });\n\n const p = payload as Record<string, unknown>;\n return {\n actorId: p['actor_id'] as string,\n actorType: p['actor_type'] as ActorContext['actorType'],\n orgId: p['org_id'] as string | null,\n scopes: (p['scopes'] as string[]) ?? [],\n policyVersion: p['policy_version'] as number,\n };\n }\n\n /** Fetch JWKS from the hybriDB server (cached for 1 hour). */\n async getJwks(): Promise<{ keys: Record<string, unknown>[] }> {\n if (jwksCache && Date.now() - jwksCachedAt < JWKS_CACHE_MS) {\n return jwksCache;\n }\n\n const res = await this.getPublic<{ keys: Record<string, unknown>[] }>('/.well-known/jwks.json');\n const data = this.unwrap(res);\n jwksCache = data;\n jwksCachedAt = Date.now();\n return data;\n }\n\n // ─── db.actors — actor management ──────────────────────────────────────────\n\n /** Namespace for actor management operations. */\n readonly actors = {\n /** Issue an API key for an actor. Requires actor:admin scope. */\n createApiKey: async (actorId: UUID, input: ApiKeyInput): Promise<{ id: string; key: string }> => {\n const res = await this.post<{ id: string; key: string }>(\n `/api/v1/actors/${actorId}/api-keys`, input,\n );\n return this.unwrap(res);\n },\n\n /** Revoke an API key. Requires actor:admin scope. */\n revokeApiKey: async (actorId: UUID, keyId: UUID): Promise<void> => {\n await this.delete(`/api/v1/actors/${actorId}/api-keys/${keyId}`);\n },\n\n /** Create an identity mapping (external provider → actor). Requires actor:write scope. */\n createMapping: async (actorId: UUID, input: CreateMappingInput): Promise<IdentityMapping> => {\n const res = await this.post<IdentityMapping>(\n `/api/v1/actors/${actorId}/identity-mappings`, input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── orgs — organisation membership ────────────────────────────────────────\n\n /** Namespace for organisation membership operations. */\n readonly orgs = {\n /** Add a member to an organisation. Requires org:admin scope. */\n addMember: async (orgId: UUID, input: OrgMemberInput): Promise<OrgMembership> => {\n const res = await this.post<OrgMembership>(`/api/v1/orgs/${orgId}/memberships`, input);\n return this.unwrap(res);\n },\n\n /** Update a member's role. Requires org:admin scope. */\n updateMemberRole: async (orgId: UUID, actorId: UUID, role: string): Promise<OrgMembership> => {\n const res = await this.patch<OrgMembership>(\n `/api/v1/orgs/${orgId}/memberships/${actorId}`, { role },\n );\n return this.unwrap(res);\n },\n\n /** Revoke an actor's membership. Requires org:admin scope. */\n revokeMember: async (orgId: UUID, actorId: UUID): Promise<void> => {\n await this.delete(`/api/v1/orgs/${orgId}/memberships/${actorId}`);\n },\n\n /** List organisation members. Requires org:read scope. */\n listMembers: async (orgId: UUID): Promise<OrgMembership[]> => {\n const res = await this.get<OrgMembership[]>(`/api/v1/orgs/${orgId}/memberships`);\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Reversibility (v2.4) ──────────────────────────────────────────────────\n\n /** Namespace for Reversible Autonomy operations (v2.4). */\n readonly reversibility = {\n /**\n * Initiate a rollback for an execution.\n * Types: 'full' (all steps), 'selective' (targetSteps list), 'to_checkpoint'.\n * Requires pipeline:rollback scope.\n */\n rollback: async (executionId: UUID, input: Omit<InitiateRollbackInput, 'executionId'>): Promise<RollbackResult> => {\n const res = await this.post<RollbackResult>(`/api/v1/executions/${executionId}/rollback`, input);\n return this.unwrap(res);\n },\n\n /**\n * Initiate a replay from a checkpoint.\n * Creates a new child execution starting from the checkpoint's step.\n * Requires pipeline:replay scope.\n */\n replay: async (executionId: UUID, input: Omit<InitiateReplayInput, 'executionId'>): Promise<ReplayResult> => {\n const res = await this.post<ReplayResult>(`/api/v1/executions/${executionId}/replay`, input);\n return this.unwrap(res);\n },\n\n /**\n * List all checkpoints for an execution (ordered by step_index asc).\n * Requires pipeline:read scope.\n */\n getCheckpoints: async (executionId: UUID): Promise<CheckpointSummary[]> => {\n const res = await this.get<CheckpointSummary[]>(`/api/v1/executions/${executionId}/checkpoints`);\n return this.unwrap(res);\n },\n\n /**\n * Get a specific checkpoint (with checksum verification).\n * Throws REPLAY_CONTEXT_INVALID if checksum mismatches.\n * Requires pipeline:read scope.\n */\n getCheckpoint: async (executionId: UUID, checkpointId: UUID): Promise<Checkpoint> => {\n const res = await this.get<Checkpoint>(`/api/v1/executions/${executionId}/checkpoints/${checkpointId}`);\n return this.unwrap(res);\n },\n\n /**\n * List all rollback log entries for an execution.\n * Requires pipeline:read scope.\n */\n getRollbackLog: async (executionId: UUID): Promise<RollbackLog[]> => {\n const res = await this.get<RollbackLog[]>(`/api/v1/executions/${executionId}/rollback-log`);\n return this.unwrap(res);\n },\n\n /**\n * Get circuit breaker status for a pipeline.\n * Requires pipeline:read scope.\n */\n getCircuitBreaker: async (pipelineId: UUID): Promise<CircuitBreakerStatus> => {\n const res = await this.get<CircuitBreakerStatus>(`/api/v1/pipelines/${pipelineId}/circuit-breaker`);\n return this.unwrap(res);\n },\n\n /**\n * Open or close the circuit breaker for a pipeline.\n * Opening halts all future executions immediately.\n * Requires pipeline:circuit_breaker scope.\n */\n setCircuitBreaker: async (pipelineId: UUID, input: Omit<SetCircuitBreakerInput, 'pipelineId'>): Promise<CircuitBreakerStatus> => {\n const res = await this.post<CircuitBreakerStatus>(\n `/api/v1/pipelines/${pipelineId}/circuit-breaker`,\n input,\n );\n return this.unwrap(res);\n },\n } as const;\n\n // ─── Decisions ─────────────────────────────────────────────────────────────\n\n async requestDecision(request: DecisionInput): Promise<DecisionResponse> {\n const res = await this.post<DecisionResponse>('/api/v1/decisions', request);\n return this.unwrap(res);\n }\n\n async getDecision(decisionId: UUID): Promise<DecisionResponse> {\n const res = await this.get<DecisionResponse>(`/api/v1/decisions/${decisionId}`);\n return this.unwrap(res);\n }\n\n // ─── Pipelines ─────────────────────────────────────────────────────────────\n\n /** Namespace for pipeline definition management. */\n readonly pipelines = {\n /**\n * Register a pipeline definition. Returns the definition record including its UUID,\n * which you pass to triggerPipeline() as pipelineId.\n * Requires pipeline:write scope.\n */\n create: async (input: CreatePipelineInput): Promise<PipelineDefinition> => {\n const res = await this.post<PipelineDefinition>('/api/v1/pipelines', input);\n return this.unwrap(res);\n },\n } as const;\n\n async triggerPipeline(input: TriggerPipelineInput): Promise<PipelineExecution> {\n const res = await this.post<PipelineExecution>('/api/v1/pipelines/trigger', input);\n return this.unwrap(res);\n }\n\n /**\n * Trigger a pipeline execution by its name instead of UUID.\n * Equivalent to triggerPipeline() but resolves the pipeline ID server-side.\n * Requires pipeline:execute scope.\n */\n async triggerPipelineByName(name: string, input: TriggerByNameInput): Promise<PipelineExecution> {\n const res = await this.post<PipelineExecution>(`/api/v1/pipelines/${encodeURIComponent(name)}/execute`, input);\n return this.unwrap(res);\n }\n\n async getPipelineExecution(executionId: UUID): Promise<PipelineExecution> {\n const res = await this.get<PipelineExecution>(`/api/v1/pipelines/executions/${executionId}`);\n return this.unwrap(res);\n }\n\n // ─── Events ────────────────────────────────────────────────────────────────\n\n /** Publish a business event. Note: use actorId (v1.2), not identityId. */\n async publishEvent(input: PublishEventInput): Promise<HybriDBEvent> {\n const res = await this.post<HybriDBEvent>('/api/v1/events', input);\n return this.unwrap(res);\n }\n\n // ─── Audit ─────────────────────────────────────────────────────────────────\n\n async queryAuditLog(params: AuditQueryParams): Promise<PaginatedResponse<AuditEntry>> {\n const query = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) query.set(k, String(v));\n }\n const res = await this.get<PaginatedResponse<AuditEntry>>(`/api/v1/audit?${query.toString()}`);\n return this.unwrap(res);\n }\n\n // ─── Health ────────────────────────────────────────────────────────────────\n\n async health(): Promise<{ status: string; version: string }> {\n const res = await this.getPublic<{ status: string; version: string }>('/health');\n return this.unwrap(res);\n }\n\n // ─── HTTP primitives ───────────────────────────────────────────────────────\n\n private async get<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, true);\n }\n\n private async getPublic<T>(path: string): Promise<ApiResponse<T>> {\n return this.request<T>('GET', path, undefined, false);\n }\n\n private async post<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, true);\n }\n\n private async postPublic<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('POST', path, body, false);\n }\n\n private async patch<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return this.request<T>('PATCH', path, body, true);\n }\n\n private async delete(path: string): Promise<void> {\n await this.request<void>('DELETE', path, undefined, true);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body: unknown,\n authenticated: boolean,\n attempt = 1,\n ): Promise<ApiResponse<T>> {\n const controller = new AbortController();\n const timerId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-SDK-Version': '1.4.0',\n };\n if (authenticated) {\n headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n\n const response = await fetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n ...(body !== undefined ? { body: JSON.stringify(body) } : {}),\n signal: controller.signal,\n });\n\n // 204 No Content — return success with no data\n if (response.status === 204) {\n return { success: true, data: undefined as T };\n }\n\n const json = await response.json() as ApiResponse<T>;\n\n if (!response.ok && attempt < this.retries && this.isRetryable(response.status)) {\n await this.sleep(this.retryDelay * attempt);\n return this.request<T>(method, path, body, authenticated, attempt + 1);\n }\n\n return json;\n } finally {\n clearTimeout(timerId);\n }\n }\n\n private unwrap<T>(response: ApiResponse<T>): T {\n if (!response.success || response.data === undefined) {\n throw new HybriDBError(\n response.error?.code ?? 'UNKNOWN_ERROR',\n response.error?.message ?? 'hybriDB request failed',\n response.error?.details,\n );\n }\n return response.data;\n }\n\n private isRetryable(status: number): boolean {\n return status === 429 || status >= 500;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n}\n\n// ─── HybriDBError ─────────────────────────────────────────────────────────────\n\nexport class HybriDBError extends Error {\n constructor(\n public readonly code: string,\n message: string,\n public readonly details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'HybriDBError';\n }\n}\n","// hybriDB SDK — v1.4\nexport { HybriDBClient, HybriDBError } from './client.js';\nexport type {\n HybriDBClientConfig,\n AuthenticateInput,\n CreateMappingInput,\n OrgMemberInput,\n ApiKeyInput,\n AuditQueryParams,\n // v1.4 — pipeline self-service\n CreatePipelineInput,\n CreatePipelineStepInput,\n TriggerByNameInput,\n} from './client.js';\n\n// React context — exported from '@hybridb/sdk/react' (separate entry point, browser only)\n\n// Re-export commonly used types for SDK consumers\nexport type {\n // Actor-centric (v1.2)\n Actor,\n ActorContext,\n ActorType,\n ActorStatus,\n User,\n OrgMembership,\n IdentityMapping,\n Session,\n TokenPair,\n // Decisions\n DecisionRequest,\n DecisionResponse,\n DecisionResult,\n // Pipelines\n PipelineDefinition,\n PipelineStepDefinition,\n StepType,\n TriggerPipelineInput,\n PipelineExecution,\n // Events — actorId (v1.2), not identityId\n PublishEventInput,\n HybriDBEvent,\n // Audit\n AuditEntry,\n AuditOutcome,\n // Policy\n Policy,\n PolicyEvaluationResult,\n // Shared\n ApiResponse,\n ApiError,\n PaginatedResponse,\n UUID,\n ISO8601,\n // Errors\n HybriDBErrorCode,\n} from '@stellrai/types';\n\n// ─── Event type constants (v1.2) ──────────────────────────────────────────────\n\nexport const HYBRIDB_EVENT_TYPES = {\n // Decisions\n DECISION_REQUESTED: 'decision.requested',\n DECISION_ALLOWED: 'decision.allowed',\n DECISION_BLOCKED: 'decision.blocked',\n DECISION_ESCALATED: 'decision.escalated',\n // Pipelines\n PIPELINE_STARTED: 'pipeline.started',\n PIPELINE_COMPLETED: 'pipeline.completed',\n PIPELINE_FAILED: 'pipeline.failed',\n PIPELINE_COMPENSATED: 'pipeline.compensated',\n // Payments\n PAYMENT_INITIATED: 'payment.initiated',\n PAYMENT_COMPLETED: 'payment.completed',\n PAYMENT_FAILED: 'payment.failed',\n PAYMENT_REVERSED: 'payment.reversed',\n // Identity (v1.2 — actor-centric)\n ACTOR_CREATED: 'actor.created',\n ACTOR_SUSPENDED: 'actor.suspended',\n ACTOR_REVOKED: 'actor.revoked',\n IDENTITY_RESOLVED: 'identity.resolved',\n IDENTITY_RESOLUTION_FAILED: 'identity.resolution_failed',\n // Policy\n POLICY_ACTIVATED: 'policy.activated',\n POLICY_DEACTIVATED: 'policy.deactivated',\n POLICY_VERSION_BUMPED: 'policy.version_bumped',\n // KYC\n KYC_SUBMITTED: 'kyc.submitted',\n KYC_APPROVED: 'kyc.approved',\n KYC_REJECTED: 'kyc.rejected',\n // AI\n AI_INFERENCE_COMPLETED: 'ai.inference_completed',\n AI_INFERENCE_FAILED: 'ai.inference_failed',\n // Fraud\n FRAUD_SIGNAL_DETECTED: 'fraud.signal_detected',\n // sync-back\n SYNC_BACK_EXHAUSTED: 'sync_back.exhausted',\n} as const;\n\nexport type HybriDBEventType = typeof HYBRIDB_EVENT_TYPES[keyof typeof HYBRIDB_EVENT_TYPES];\n"]}
|
package/dist/react.d.cts
CHANGED
package/dist/react.d.ts
CHANGED