@aguardic/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -0
- package/dist/index.d.mts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +241 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +207 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @aguardic/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the [Aguardic](https://aguardic.com) governance API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @aguardic/sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @aguardic/sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @aguardic/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Requirements:** Node.js 18+
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import Aguardic from "@aguardic/sdk";
|
|
21
|
+
|
|
22
|
+
const aguardic = new Aguardic("ag_live_xxxxx");
|
|
23
|
+
|
|
24
|
+
const result = await aguardic.evaluate({
|
|
25
|
+
input: { content: "Transfer $50,000 to account 12345" },
|
|
26
|
+
targetKey: "bank-transfer",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (result.enforcementAction === "BLOCK") {
|
|
30
|
+
console.log("Blocked:", result.violations);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Simple — API key only
|
|
38
|
+
const aguardic = new Aguardic("ag_live_xxxxx");
|
|
39
|
+
|
|
40
|
+
// Advanced — full options
|
|
41
|
+
const aguardic = new Aguardic({
|
|
42
|
+
apiKey: "ag_live_xxxxx",
|
|
43
|
+
baseUrl: "https://api.aguardic.com/v1", // default
|
|
44
|
+
timeout: 30000, // default, in milliseconds
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API Reference
|
|
49
|
+
|
|
50
|
+
### `aguardic.evaluate(params)`
|
|
51
|
+
|
|
52
|
+
Evaluate content against your bound policies.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const result = await aguardic.evaluate({
|
|
56
|
+
input: { content: "User message to check" },
|
|
57
|
+
targetKey: "chat-message", // optional — route to specific policies
|
|
58
|
+
correlationId: "req-123", // optional — for tracking
|
|
59
|
+
sessionId: "sess-abc", // optional — for session-based evaluation
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// result.outcome: 'ALLOW' | 'DENY' | 'FLAG'
|
|
63
|
+
// result.enforcementAction: 'ALLOW' | 'WARN' | 'BLOCK' | 'APPROVAL_REQUIRED'
|
|
64
|
+
// result.violations: Violation[]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `aguardic.sessions.create(params?)`
|
|
68
|
+
|
|
69
|
+
Create an evaluation session for multi-step interactions.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const session = await aguardic.sessions.create({
|
|
73
|
+
metadata: { agentId: "support-bot" },
|
|
74
|
+
});
|
|
75
|
+
// session.id, session.status
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `aguardic.sessions.get(sessionId)`
|
|
79
|
+
|
|
80
|
+
Get session details including all actions.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const detail = await aguardic.sessions.get(session.id);
|
|
84
|
+
// detail.actions, detail.actionCount, detail.toolsUsed
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### `aguardic.sessions.end(sessionId, params?)`
|
|
88
|
+
|
|
89
|
+
End an active session.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const summary = await aguardic.sessions.end(session.id, {
|
|
93
|
+
status: "COMPLETED", // or 'TERMINATED'
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `aguardic.reviews.get(reviewId)`
|
|
98
|
+
|
|
99
|
+
Get a review request by ID (for approval flows).
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const review = await aguardic.reviews.get(result.reviewRequestId);
|
|
103
|
+
// review.status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'EXPIRED' | 'CANCELLED'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `aguardic.reviews.getByCorrelation(correlationId)`
|
|
107
|
+
|
|
108
|
+
Get a review request by correlation ID.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const review = await aguardic.reviews.getByCorrelation("req-123");
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Error Handling
|
|
115
|
+
|
|
116
|
+
The SDK throws typed errors for different HTTP status codes:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { AguardicError, AuthenticationError, ValidationError } from "@aguardic/sdk";
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
await aguardic.evaluate({ input: { content: "test" } });
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (error instanceof AuthenticationError) {
|
|
125
|
+
// 401 — invalid API key
|
|
126
|
+
} else if (error instanceof ValidationError) {
|
|
127
|
+
// 400 — invalid request body
|
|
128
|
+
} else if (error instanceof AguardicError) {
|
|
129
|
+
// Any API error
|
|
130
|
+
console.log(error.statusCode, error.errors);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Error classes:**
|
|
136
|
+
|
|
137
|
+
| Class | Status Code |
|
|
138
|
+
|-------|-------------|
|
|
139
|
+
| `ValidationError` | 400 |
|
|
140
|
+
| `AuthenticationError` | 401 |
|
|
141
|
+
| `ForbiddenError` | 403 |
|
|
142
|
+
| `NotFoundError` | 404 |
|
|
143
|
+
| `RateLimitError` | 429 |
|
|
144
|
+
| `ServerError` | 500+ |
|
|
145
|
+
|
|
146
|
+
## Full Example — AI Agent Guardrails
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import Aguardic from "@aguardic/sdk";
|
|
150
|
+
|
|
151
|
+
const aguardic = new Aguardic(process.env.AGUARDIC_API_KEY!);
|
|
152
|
+
|
|
153
|
+
async function runAgent() {
|
|
154
|
+
// Start a session
|
|
155
|
+
const session = await aguardic.sessions.create({
|
|
156
|
+
metadata: { agentId: "support-bot", userId: "user-456" },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Check each action before executing
|
|
160
|
+
const result = await aguardic.evaluate({
|
|
161
|
+
input: {
|
|
162
|
+
tool: "send_email",
|
|
163
|
+
to: "customer@example.com",
|
|
164
|
+
subject: "Account update",
|
|
165
|
+
body: "Your password has been reset.",
|
|
166
|
+
},
|
|
167
|
+
sessionId: session.id,
|
|
168
|
+
targetKey: "send_email",
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (result.enforcementAction === "BLOCK") {
|
|
172
|
+
console.log("Action blocked:", result.violations);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (result.enforcementAction === "APPROVAL_REQUIRED") {
|
|
177
|
+
// Poll for approval
|
|
178
|
+
const review = await aguardic.reviews.get(result.reviewRequestId!);
|
|
179
|
+
console.log("Waiting for approval:", review.status);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Action allowed — proceed
|
|
184
|
+
await sendEmail(/* ... */);
|
|
185
|
+
|
|
186
|
+
// End session when done
|
|
187
|
+
await aguardic.sessions.end(session.id);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
interface HttpClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
timeout: number;
|
|
5
|
+
}
|
|
6
|
+
declare class HttpClient {
|
|
7
|
+
private readonly apiKey;
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly timeout;
|
|
10
|
+
constructor(options: HttpClientOptions);
|
|
11
|
+
get<T>(path: string): Promise<T>;
|
|
12
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
13
|
+
private request;
|
|
14
|
+
private throwError;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface AguardicOptions {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
interface EvaluateParams {
|
|
23
|
+
input: Record<string, any>;
|
|
24
|
+
targetKey?: string;
|
|
25
|
+
targetMetadata?: Record<string, any>;
|
|
26
|
+
correlationId?: string;
|
|
27
|
+
callbackUrl?: string;
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
}
|
|
30
|
+
interface EvaluateResponse {
|
|
31
|
+
outcome: "ALLOW" | "DENY" | "FLAG";
|
|
32
|
+
enforcementAction: "ALLOW" | "WARN" | "BLOCK" | "APPROVAL_REQUIRED";
|
|
33
|
+
evaluationRunId: string | null;
|
|
34
|
+
reviewRequestId: string | null;
|
|
35
|
+
pollUrl: string | null;
|
|
36
|
+
sessionId: string | null;
|
|
37
|
+
violations: Violation[];
|
|
38
|
+
}
|
|
39
|
+
interface Violation {
|
|
40
|
+
id: string;
|
|
41
|
+
ruleId: string;
|
|
42
|
+
ruleName: string;
|
|
43
|
+
severity: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL" | null;
|
|
44
|
+
resolvedAction: "BLOCK" | "APPROVAL_REQUIRED" | "WARN" | "LOG" | null;
|
|
45
|
+
explanation: string | null;
|
|
46
|
+
field: string | null;
|
|
47
|
+
snippet: string | null;
|
|
48
|
+
}
|
|
49
|
+
interface CreateSessionParams {
|
|
50
|
+
entityId?: string;
|
|
51
|
+
externalSessionId?: string;
|
|
52
|
+
expiresAt?: string;
|
|
53
|
+
metadata?: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
interface Session {
|
|
56
|
+
id: string;
|
|
57
|
+
status: "ACTIVE" | "COMPLETED" | "EXPIRED" | "TERMINATED";
|
|
58
|
+
entityId: string | null;
|
|
59
|
+
externalSessionId: string | null;
|
|
60
|
+
startedAt: string;
|
|
61
|
+
expiresAt: string | null;
|
|
62
|
+
metadata: Record<string, any> | null;
|
|
63
|
+
}
|
|
64
|
+
interface EndSessionParams {
|
|
65
|
+
status?: "COMPLETED" | "TERMINATED";
|
|
66
|
+
}
|
|
67
|
+
interface EndSessionResponse {
|
|
68
|
+
id: string;
|
|
69
|
+
status: string;
|
|
70
|
+
endedAt: string;
|
|
71
|
+
actionCount: number;
|
|
72
|
+
dataTags: string[];
|
|
73
|
+
toolsUsed: string[];
|
|
74
|
+
}
|
|
75
|
+
interface ReviewRequest {
|
|
76
|
+
id: string;
|
|
77
|
+
status: "PENDING" | "APPROVED" | "REJECTED" | "EXPIRED" | "CANCELLED";
|
|
78
|
+
decidedAt: string | null;
|
|
79
|
+
decidedByUserId: string | null;
|
|
80
|
+
decisionComment: string | null;
|
|
81
|
+
expiresAt: string | null;
|
|
82
|
+
correlationId: string | null;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare class ReviewsResource {
|
|
87
|
+
private readonly http;
|
|
88
|
+
constructor(http: HttpClient);
|
|
89
|
+
get(reviewId: string): Promise<ReviewRequest>;
|
|
90
|
+
getByCorrelation(correlationId: string): Promise<ReviewRequest>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class SessionsResource {
|
|
94
|
+
private readonly http;
|
|
95
|
+
constructor(http: HttpClient);
|
|
96
|
+
create(params?: CreateSessionParams): Promise<Session>;
|
|
97
|
+
end(sessionId: string, params?: EndSessionParams): Promise<EndSessionResponse>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class Aguardic {
|
|
101
|
+
readonly sessions: SessionsResource;
|
|
102
|
+
readonly reviews: ReviewsResource;
|
|
103
|
+
private readonly evaluateResource;
|
|
104
|
+
constructor(apiKeyOrOptions: string | AguardicOptions);
|
|
105
|
+
evaluate(params: EvaluateParams): Promise<EvaluateResponse>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class AguardicError extends Error {
|
|
109
|
+
readonly statusCode: number;
|
|
110
|
+
readonly errors: Array<{
|
|
111
|
+
message: string;
|
|
112
|
+
}>;
|
|
113
|
+
constructor(statusCode: number, errors: Array<{
|
|
114
|
+
message: string;
|
|
115
|
+
}>, message?: string);
|
|
116
|
+
}
|
|
117
|
+
declare class ValidationError extends AguardicError {
|
|
118
|
+
constructor(errors: Array<{
|
|
119
|
+
message: string;
|
|
120
|
+
}>);
|
|
121
|
+
}
|
|
122
|
+
declare class AuthenticationError extends AguardicError {
|
|
123
|
+
constructor(errors?: Array<{
|
|
124
|
+
message: string;
|
|
125
|
+
}>);
|
|
126
|
+
}
|
|
127
|
+
declare class ForbiddenError extends AguardicError {
|
|
128
|
+
constructor(errors?: Array<{
|
|
129
|
+
message: string;
|
|
130
|
+
}>);
|
|
131
|
+
}
|
|
132
|
+
declare class NotFoundError extends AguardicError {
|
|
133
|
+
constructor(errors?: Array<{
|
|
134
|
+
message: string;
|
|
135
|
+
}>);
|
|
136
|
+
}
|
|
137
|
+
declare class RateLimitError extends AguardicError {
|
|
138
|
+
constructor(errors?: Array<{
|
|
139
|
+
message: string;
|
|
140
|
+
}>);
|
|
141
|
+
}
|
|
142
|
+
declare class ServerError extends AguardicError {
|
|
143
|
+
constructor(statusCode?: number, errors?: Array<{
|
|
144
|
+
message: string;
|
|
145
|
+
}>);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { Aguardic, AguardicError, type AguardicOptions, AuthenticationError, type CreateSessionParams, type EndSessionParams, type EndSessionResponse, type EvaluateParams, type EvaluateResponse, ForbiddenError, NotFoundError, RateLimitError, type ReviewRequest, ServerError, type Session, ValidationError, type Violation, Aguardic as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
interface HttpClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
timeout: number;
|
|
5
|
+
}
|
|
6
|
+
declare class HttpClient {
|
|
7
|
+
private readonly apiKey;
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly timeout;
|
|
10
|
+
constructor(options: HttpClientOptions);
|
|
11
|
+
get<T>(path: string): Promise<T>;
|
|
12
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
13
|
+
private request;
|
|
14
|
+
private throwError;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface AguardicOptions {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
interface EvaluateParams {
|
|
23
|
+
input: Record<string, any>;
|
|
24
|
+
targetKey?: string;
|
|
25
|
+
targetMetadata?: Record<string, any>;
|
|
26
|
+
correlationId?: string;
|
|
27
|
+
callbackUrl?: string;
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
}
|
|
30
|
+
interface EvaluateResponse {
|
|
31
|
+
outcome: "ALLOW" | "DENY" | "FLAG";
|
|
32
|
+
enforcementAction: "ALLOW" | "WARN" | "BLOCK" | "APPROVAL_REQUIRED";
|
|
33
|
+
evaluationRunId: string | null;
|
|
34
|
+
reviewRequestId: string | null;
|
|
35
|
+
pollUrl: string | null;
|
|
36
|
+
sessionId: string | null;
|
|
37
|
+
violations: Violation[];
|
|
38
|
+
}
|
|
39
|
+
interface Violation {
|
|
40
|
+
id: string;
|
|
41
|
+
ruleId: string;
|
|
42
|
+
ruleName: string;
|
|
43
|
+
severity: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL" | null;
|
|
44
|
+
resolvedAction: "BLOCK" | "APPROVAL_REQUIRED" | "WARN" | "LOG" | null;
|
|
45
|
+
explanation: string | null;
|
|
46
|
+
field: string | null;
|
|
47
|
+
snippet: string | null;
|
|
48
|
+
}
|
|
49
|
+
interface CreateSessionParams {
|
|
50
|
+
entityId?: string;
|
|
51
|
+
externalSessionId?: string;
|
|
52
|
+
expiresAt?: string;
|
|
53
|
+
metadata?: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
interface Session {
|
|
56
|
+
id: string;
|
|
57
|
+
status: "ACTIVE" | "COMPLETED" | "EXPIRED" | "TERMINATED";
|
|
58
|
+
entityId: string | null;
|
|
59
|
+
externalSessionId: string | null;
|
|
60
|
+
startedAt: string;
|
|
61
|
+
expiresAt: string | null;
|
|
62
|
+
metadata: Record<string, any> | null;
|
|
63
|
+
}
|
|
64
|
+
interface EndSessionParams {
|
|
65
|
+
status?: "COMPLETED" | "TERMINATED";
|
|
66
|
+
}
|
|
67
|
+
interface EndSessionResponse {
|
|
68
|
+
id: string;
|
|
69
|
+
status: string;
|
|
70
|
+
endedAt: string;
|
|
71
|
+
actionCount: number;
|
|
72
|
+
dataTags: string[];
|
|
73
|
+
toolsUsed: string[];
|
|
74
|
+
}
|
|
75
|
+
interface ReviewRequest {
|
|
76
|
+
id: string;
|
|
77
|
+
status: "PENDING" | "APPROVED" | "REJECTED" | "EXPIRED" | "CANCELLED";
|
|
78
|
+
decidedAt: string | null;
|
|
79
|
+
decidedByUserId: string | null;
|
|
80
|
+
decisionComment: string | null;
|
|
81
|
+
expiresAt: string | null;
|
|
82
|
+
correlationId: string | null;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare class ReviewsResource {
|
|
87
|
+
private readonly http;
|
|
88
|
+
constructor(http: HttpClient);
|
|
89
|
+
get(reviewId: string): Promise<ReviewRequest>;
|
|
90
|
+
getByCorrelation(correlationId: string): Promise<ReviewRequest>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class SessionsResource {
|
|
94
|
+
private readonly http;
|
|
95
|
+
constructor(http: HttpClient);
|
|
96
|
+
create(params?: CreateSessionParams): Promise<Session>;
|
|
97
|
+
end(sessionId: string, params?: EndSessionParams): Promise<EndSessionResponse>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class Aguardic {
|
|
101
|
+
readonly sessions: SessionsResource;
|
|
102
|
+
readonly reviews: ReviewsResource;
|
|
103
|
+
private readonly evaluateResource;
|
|
104
|
+
constructor(apiKeyOrOptions: string | AguardicOptions);
|
|
105
|
+
evaluate(params: EvaluateParams): Promise<EvaluateResponse>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class AguardicError extends Error {
|
|
109
|
+
readonly statusCode: number;
|
|
110
|
+
readonly errors: Array<{
|
|
111
|
+
message: string;
|
|
112
|
+
}>;
|
|
113
|
+
constructor(statusCode: number, errors: Array<{
|
|
114
|
+
message: string;
|
|
115
|
+
}>, message?: string);
|
|
116
|
+
}
|
|
117
|
+
declare class ValidationError extends AguardicError {
|
|
118
|
+
constructor(errors: Array<{
|
|
119
|
+
message: string;
|
|
120
|
+
}>);
|
|
121
|
+
}
|
|
122
|
+
declare class AuthenticationError extends AguardicError {
|
|
123
|
+
constructor(errors?: Array<{
|
|
124
|
+
message: string;
|
|
125
|
+
}>);
|
|
126
|
+
}
|
|
127
|
+
declare class ForbiddenError extends AguardicError {
|
|
128
|
+
constructor(errors?: Array<{
|
|
129
|
+
message: string;
|
|
130
|
+
}>);
|
|
131
|
+
}
|
|
132
|
+
declare class NotFoundError extends AguardicError {
|
|
133
|
+
constructor(errors?: Array<{
|
|
134
|
+
message: string;
|
|
135
|
+
}>);
|
|
136
|
+
}
|
|
137
|
+
declare class RateLimitError extends AguardicError {
|
|
138
|
+
constructor(errors?: Array<{
|
|
139
|
+
message: string;
|
|
140
|
+
}>);
|
|
141
|
+
}
|
|
142
|
+
declare class ServerError extends AguardicError {
|
|
143
|
+
constructor(statusCode?: number, errors?: Array<{
|
|
144
|
+
message: string;
|
|
145
|
+
}>);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { Aguardic, AguardicError, type AguardicOptions, AuthenticationError, type CreateSessionParams, type EndSessionParams, type EndSessionResponse, type EvaluateParams, type EvaluateResponse, ForbiddenError, NotFoundError, RateLimitError, type ReviewRequest, ServerError, type Session, ValidationError, type Violation, Aguardic as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Aguardic: () => Aguardic,
|
|
24
|
+
AguardicError: () => AguardicError,
|
|
25
|
+
AuthenticationError: () => AuthenticationError,
|
|
26
|
+
ForbiddenError: () => ForbiddenError,
|
|
27
|
+
NotFoundError: () => NotFoundError,
|
|
28
|
+
RateLimitError: () => RateLimitError,
|
|
29
|
+
ServerError: () => ServerError,
|
|
30
|
+
ValidationError: () => ValidationError,
|
|
31
|
+
default: () => Aguardic
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/errors.ts
|
|
36
|
+
var AguardicError = class extends Error {
|
|
37
|
+
statusCode;
|
|
38
|
+
errors;
|
|
39
|
+
constructor(statusCode, errors, message) {
|
|
40
|
+
const msg = message || errors.map((e) => e.message).join(", ") || "Unknown error";
|
|
41
|
+
super(msg);
|
|
42
|
+
this.name = "AguardicError";
|
|
43
|
+
this.statusCode = statusCode;
|
|
44
|
+
this.errors = errors;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var ValidationError = class extends AguardicError {
|
|
48
|
+
constructor(errors) {
|
|
49
|
+
super(400, errors);
|
|
50
|
+
this.name = "ValidationError";
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var AuthenticationError = class extends AguardicError {
|
|
54
|
+
constructor(errors = [{ message: "Unauthorized" }]) {
|
|
55
|
+
super(401, errors);
|
|
56
|
+
this.name = "AuthenticationError";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var ForbiddenError = class extends AguardicError {
|
|
60
|
+
constructor(errors = [{ message: "Forbidden" }]) {
|
|
61
|
+
super(403, errors);
|
|
62
|
+
this.name = "ForbiddenError";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var NotFoundError = class extends AguardicError {
|
|
66
|
+
constructor(errors = [{ message: "Not found" }]) {
|
|
67
|
+
super(404, errors);
|
|
68
|
+
this.name = "NotFoundError";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var RateLimitError = class extends AguardicError {
|
|
72
|
+
constructor(errors = [{ message: "Rate limit exceeded" }]) {
|
|
73
|
+
super(429, errors);
|
|
74
|
+
this.name = "RateLimitError";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var ServerError = class extends AguardicError {
|
|
78
|
+
constructor(statusCode = 500, errors = [{ message: "Internal server error" }]) {
|
|
79
|
+
super(statusCode, errors);
|
|
80
|
+
this.name = "ServerError";
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/http.ts
|
|
85
|
+
var HttpClient = class {
|
|
86
|
+
apiKey;
|
|
87
|
+
baseUrl;
|
|
88
|
+
timeout;
|
|
89
|
+
constructor(options) {
|
|
90
|
+
this.apiKey = options.apiKey;
|
|
91
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
92
|
+
this.timeout = options.timeout;
|
|
93
|
+
}
|
|
94
|
+
async get(path) {
|
|
95
|
+
return this.request("GET", path);
|
|
96
|
+
}
|
|
97
|
+
async post(path, body) {
|
|
98
|
+
return this.request("POST", path, body);
|
|
99
|
+
}
|
|
100
|
+
async request(method, path, body) {
|
|
101
|
+
const url = `${this.baseUrl}${path}`;
|
|
102
|
+
const controller = new AbortController();
|
|
103
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
104
|
+
try {
|
|
105
|
+
const headers = {
|
|
106
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
107
|
+
"Content-Type": "application/json"
|
|
108
|
+
};
|
|
109
|
+
const init = {
|
|
110
|
+
method,
|
|
111
|
+
headers,
|
|
112
|
+
signal: controller.signal
|
|
113
|
+
};
|
|
114
|
+
if (body !== void 0) {
|
|
115
|
+
init.body = JSON.stringify(body);
|
|
116
|
+
}
|
|
117
|
+
const response = await fetch(url, init);
|
|
118
|
+
const json = await response.json();
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
this.throwError(response.status, json);
|
|
121
|
+
}
|
|
122
|
+
return json.data;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (error instanceof AguardicError) throw error;
|
|
125
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
126
|
+
throw new AguardicError(0, [
|
|
127
|
+
{ message: `Request timed out after ${this.timeout}ms` }
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
throw new AguardicError(0, [
|
|
131
|
+
{
|
|
132
|
+
message: error instanceof Error ? error.message : "Unknown network error"
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
} finally {
|
|
136
|
+
clearTimeout(timeoutId);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
throwError(statusCode, body) {
|
|
140
|
+
const errors = body?.errors ?? body?.message ? [{ message: body.message }] : [{ message: `Request failed with status ${statusCode}` }];
|
|
141
|
+
switch (statusCode) {
|
|
142
|
+
case 400:
|
|
143
|
+
throw new ValidationError(errors);
|
|
144
|
+
case 401:
|
|
145
|
+
throw new AuthenticationError(errors);
|
|
146
|
+
case 403:
|
|
147
|
+
throw new ForbiddenError(errors);
|
|
148
|
+
case 404:
|
|
149
|
+
throw new NotFoundError(errors);
|
|
150
|
+
case 429:
|
|
151
|
+
throw new RateLimitError(errors);
|
|
152
|
+
default:
|
|
153
|
+
if (statusCode >= 500) {
|
|
154
|
+
throw new ServerError(statusCode, errors);
|
|
155
|
+
}
|
|
156
|
+
throw new AguardicError(statusCode, errors);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// src/resources/evaluate.ts
|
|
162
|
+
var EvaluateResource = class {
|
|
163
|
+
constructor(http) {
|
|
164
|
+
this.http = http;
|
|
165
|
+
}
|
|
166
|
+
// Evaluate content against bound policies
|
|
167
|
+
async evaluate(params) {
|
|
168
|
+
return this.http.post("/evaluate", params);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/resources/reviews.ts
|
|
173
|
+
var ReviewsResource = class {
|
|
174
|
+
constructor(http) {
|
|
175
|
+
this.http = http;
|
|
176
|
+
}
|
|
177
|
+
// Get a review request by ID
|
|
178
|
+
async get(reviewId) {
|
|
179
|
+
return this.http.get(`/reviews/${reviewId}`);
|
|
180
|
+
}
|
|
181
|
+
// Get a review request by correlation ID
|
|
182
|
+
async getByCorrelation(correlationId) {
|
|
183
|
+
return this.http.get(
|
|
184
|
+
`/reviews/by-correlation/${correlationId}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/resources/sessions.ts
|
|
190
|
+
var SessionsResource = class {
|
|
191
|
+
constructor(http) {
|
|
192
|
+
this.http = http;
|
|
193
|
+
}
|
|
194
|
+
// Create a new evaluation session
|
|
195
|
+
async create(params = {}) {
|
|
196
|
+
return this.http.post("/evaluation-sessions", params);
|
|
197
|
+
}
|
|
198
|
+
// End an active session
|
|
199
|
+
async end(sessionId, params = {}) {
|
|
200
|
+
return this.http.post(
|
|
201
|
+
`/evaluation-sessions/${sessionId}/end`,
|
|
202
|
+
params
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/client.ts
|
|
208
|
+
var DEFAULT_BASE_URL = "https://api.aguardic.com/v1";
|
|
209
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
210
|
+
var Aguardic = class {
|
|
211
|
+
sessions;
|
|
212
|
+
reviews;
|
|
213
|
+
evaluateResource;
|
|
214
|
+
constructor(apiKeyOrOptions) {
|
|
215
|
+
const options = typeof apiKeyOrOptions === "string" ? { apiKey: apiKeyOrOptions } : apiKeyOrOptions;
|
|
216
|
+
const http = new HttpClient({
|
|
217
|
+
apiKey: options.apiKey,
|
|
218
|
+
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
219
|
+
timeout: options.timeout ?? DEFAULT_TIMEOUT
|
|
220
|
+
});
|
|
221
|
+
this.evaluateResource = new EvaluateResource(http);
|
|
222
|
+
this.sessions = new SessionsResource(http);
|
|
223
|
+
this.reviews = new ReviewsResource(http);
|
|
224
|
+
}
|
|
225
|
+
// Evaluate content against bound policies
|
|
226
|
+
async evaluate(params) {
|
|
227
|
+
return this.evaluateResource.evaluate(params);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
Aguardic,
|
|
233
|
+
AguardicError,
|
|
234
|
+
AuthenticationError,
|
|
235
|
+
ForbiddenError,
|
|
236
|
+
NotFoundError,
|
|
237
|
+
RateLimitError,
|
|
238
|
+
ServerError,
|
|
239
|
+
ValidationError
|
|
240
|
+
});
|
|
241
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/evaluate.ts","../src/resources/reviews.ts","../src/resources/sessions.ts","../src/client.ts"],"sourcesContent":["export { Aguardic } from \"./client\";\nexport type {\n AguardicOptions,\n CreateSessionParams,\n EndSessionParams,\n EndSessionResponse,\n EvaluateParams,\n EvaluateResponse,\n ReviewRequest,\n Session,\n Violation,\n} from \"./types\";\nexport {\n AguardicError,\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from \"./errors\";\n\n// Default export for convenience: import Aguardic from '@aguardic/sdk'\nexport { Aguardic as default } from \"./client\";\n","export class AguardicError extends Error {\n readonly statusCode: number;\n readonly errors: Array<{ message: string }>;\n\n constructor(\n statusCode: number,\n errors: Array<{ message: string }>,\n message?: string,\n ) {\n const msg =\n message || errors.map((e) => e.message).join(\", \") || \"Unknown error\";\n super(msg);\n this.name = \"AguardicError\";\n this.statusCode = statusCode;\n this.errors = errors;\n }\n}\n\n// 400\nexport class ValidationError extends AguardicError {\n constructor(errors: Array<{ message: string }>) {\n super(400, errors);\n this.name = \"ValidationError\";\n }\n}\n\n// 401\nexport class AuthenticationError extends AguardicError {\n constructor(errors: Array<{ message: string }> = [{ message: \"Unauthorized\" }]) {\n super(401, errors);\n this.name = \"AuthenticationError\";\n }\n}\n\n// 403\nexport class ForbiddenError extends AguardicError {\n constructor(errors: Array<{ message: string }> = [{ message: \"Forbidden\" }]) {\n super(403, errors);\n this.name = \"ForbiddenError\";\n }\n}\n\n// 404\nexport class NotFoundError extends AguardicError {\n constructor(errors: Array<{ message: string }> = [{ message: \"Not found\" }]) {\n super(404, errors);\n this.name = \"NotFoundError\";\n }\n}\n\n// 429\nexport class RateLimitError extends AguardicError {\n constructor(\n errors: Array<{ message: string }> = [{ message: \"Rate limit exceeded\" }],\n ) {\n super(429, errors);\n this.name = \"RateLimitError\";\n }\n}\n\n// 500+\nexport class ServerError extends AguardicError {\n constructor(\n statusCode: number = 500,\n errors: Array<{ message: string }> = [{ message: \"Internal server error\" }],\n ) {\n super(statusCode, errors);\n this.name = \"ServerError\";\n }\n}\n","import {\n AguardicError,\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from \"./errors\";\n\nexport interface HttpClientOptions {\n apiKey: string;\n baseUrl: string;\n timeout: number;\n}\n\n// Internal HTTP client — unwraps { success, statusCode, data } response wrapper\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n\n constructor(options: HttpClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.timeout = options.timeout;\n }\n\n async get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(\"POST\", path, body);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n };\n\n const init: RequestInit = {\n method,\n headers,\n signal: controller.signal,\n };\n\n if (body !== undefined) {\n init.body = JSON.stringify(body);\n }\n\n const response = await fetch(url, init);\n const json = await response.json();\n\n if (!response.ok) {\n this.throwError(response.status, json);\n }\n\n // Unwrap { success, statusCode, data } wrapper\n return json.data as T;\n } catch (error: unknown) {\n if (error instanceof AguardicError) throw error;\n\n if (error instanceof DOMException && error.name === \"AbortError\") {\n throw new AguardicError(0, [\n { message: `Request timed out after ${this.timeout}ms` },\n ]);\n }\n\n throw new AguardicError(0, [\n {\n message:\n error instanceof Error ? error.message : \"Unknown network error\",\n },\n ]);\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n private throwError(statusCode: number, body: any): never {\n const errors: Array<{ message: string }> = body?.errors ??\n body?.message\n ? [{ message: body.message }]\n : [{ message: `Request failed with status ${statusCode}` }];\n\n switch (statusCode) {\n case 400:\n throw new ValidationError(errors);\n case 401:\n throw new AuthenticationError(errors);\n case 403:\n throw new ForbiddenError(errors);\n case 404:\n throw new NotFoundError(errors);\n case 429:\n throw new RateLimitError(errors);\n default:\n if (statusCode >= 500) {\n throw new ServerError(statusCode, errors);\n }\n throw new AguardicError(statusCode, errors);\n }\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { EvaluateParams, EvaluateResponse } from \"../types\";\n\nexport class EvaluateResource {\n constructor(private readonly http: HttpClient) {}\n\n // Evaluate content against bound policies\n async evaluate(params: EvaluateParams): Promise<EvaluateResponse> {\n return this.http.post<EvaluateResponse>(\"/evaluate\", params);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { ReviewRequest } from \"../types\";\n\nexport class ReviewsResource {\n constructor(private readonly http: HttpClient) {}\n\n // Get a review request by ID\n async get(reviewId: string): Promise<ReviewRequest> {\n return this.http.get<ReviewRequest>(`/reviews/${reviewId}`);\n }\n\n // Get a review request by correlation ID\n async getByCorrelation(correlationId: string): Promise<ReviewRequest> {\n return this.http.get<ReviewRequest>(\n `/reviews/by-correlation/${correlationId}`,\n );\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateSessionParams,\n EndSessionParams,\n EndSessionResponse,\n Session,\n} from \"../types\";\n\nexport class SessionsResource {\n constructor(private readonly http: HttpClient) {}\n\n // Create a new evaluation session\n async create(params: CreateSessionParams = {}): Promise<Session> {\n return this.http.post<Session>(\"/evaluation-sessions\", params);\n }\n\n // End an active session\n async end(\n sessionId: string,\n params: EndSessionParams = {},\n ): Promise<EndSessionResponse> {\n return this.http.post<EndSessionResponse>(\n `/evaluation-sessions/${sessionId}/end`,\n params,\n );\n }\n}\n","import { HttpClient } from \"./http\";\nimport { EvaluateResource } from \"./resources/evaluate\";\nimport { ReviewsResource } from \"./resources/reviews\";\nimport { SessionsResource } from \"./resources/sessions\";\nimport type { AguardicOptions, EvaluateParams, EvaluateResponse } from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://api.aguardic.com/v1\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class Aguardic {\n readonly sessions: SessionsResource;\n readonly reviews: ReviewsResource;\n\n private readonly evaluateResource: EvaluateResource;\n\n constructor(apiKeyOrOptions: string | AguardicOptions) {\n const options =\n typeof apiKeyOrOptions === \"string\"\n ? { apiKey: apiKeyOrOptions }\n : apiKeyOrOptions;\n\n const http = new HttpClient({\n apiKey: options.apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n timeout: options.timeout ?? DEFAULT_TIMEOUT,\n });\n\n this.evaluateResource = new EvaluateResource(http);\n this.sessions = new SessionsResource(http);\n this.reviews = new ReviewsResource(http);\n }\n\n // Evaluate content against bound policies\n async evaluate(params: EvaluateParams): Promise<EvaluateResponse> {\n return this.evaluateResource.evaluate(params);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YACE,YACA,QACA,SACA;AACA,UAAM,MACJ,WAAW,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;AACxD,UAAM,GAAG;AACT,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,SAAS;AAAA,EAChB;AACF;AAGO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EACjD,YAAY,QAAoC;AAC9C,UAAM,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Y,iBAA2C;AACrD,UAAM,UACJ,OAAO,oBAAoB,WACvB,EAAE,QAAQ,gBAAgB,IAC1B;AAEN,UAAM,OAAO,IAAI,WAAW;AAAA,MAC1B,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ,WAAW;AAAA,MAC5B,SAAS,QAAQ,WAAW;AAAA,IAC9B,CAAC;AAED,SAAK,mBAAmB,IAAI,iBAAiB,IAAI;AACjD,SAAK,WAAW,IAAI,iBAAiB,IAAI;AACzC,SAAK,UAAU,IAAI,gBAAgB,IAAI;AAAA,EACzC;AAAA;AAAA,EAGA,MAAM,SAAS,QAAmD;AAChE,WAAO,KAAK,iBAAiB,SAAS,MAAM;AAAA,EAC9C;AACF;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var AguardicError = class extends Error {
|
|
3
|
+
statusCode;
|
|
4
|
+
errors;
|
|
5
|
+
constructor(statusCode, errors, message) {
|
|
6
|
+
const msg = message || errors.map((e) => e.message).join(", ") || "Unknown error";
|
|
7
|
+
super(msg);
|
|
8
|
+
this.name = "AguardicError";
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.errors = errors;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var ValidationError = class extends AguardicError {
|
|
14
|
+
constructor(errors) {
|
|
15
|
+
super(400, errors);
|
|
16
|
+
this.name = "ValidationError";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var AuthenticationError = class extends AguardicError {
|
|
20
|
+
constructor(errors = [{ message: "Unauthorized" }]) {
|
|
21
|
+
super(401, errors);
|
|
22
|
+
this.name = "AuthenticationError";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var ForbiddenError = class extends AguardicError {
|
|
26
|
+
constructor(errors = [{ message: "Forbidden" }]) {
|
|
27
|
+
super(403, errors);
|
|
28
|
+
this.name = "ForbiddenError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var NotFoundError = class extends AguardicError {
|
|
32
|
+
constructor(errors = [{ message: "Not found" }]) {
|
|
33
|
+
super(404, errors);
|
|
34
|
+
this.name = "NotFoundError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var RateLimitError = class extends AguardicError {
|
|
38
|
+
constructor(errors = [{ message: "Rate limit exceeded" }]) {
|
|
39
|
+
super(429, errors);
|
|
40
|
+
this.name = "RateLimitError";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var ServerError = class extends AguardicError {
|
|
44
|
+
constructor(statusCode = 500, errors = [{ message: "Internal server error" }]) {
|
|
45
|
+
super(statusCode, errors);
|
|
46
|
+
this.name = "ServerError";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/http.ts
|
|
51
|
+
var HttpClient = class {
|
|
52
|
+
apiKey;
|
|
53
|
+
baseUrl;
|
|
54
|
+
timeout;
|
|
55
|
+
constructor(options) {
|
|
56
|
+
this.apiKey = options.apiKey;
|
|
57
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
58
|
+
this.timeout = options.timeout;
|
|
59
|
+
}
|
|
60
|
+
async get(path) {
|
|
61
|
+
return this.request("GET", path);
|
|
62
|
+
}
|
|
63
|
+
async post(path, body) {
|
|
64
|
+
return this.request("POST", path, body);
|
|
65
|
+
}
|
|
66
|
+
async request(method, path, body) {
|
|
67
|
+
const url = `${this.baseUrl}${path}`;
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
70
|
+
try {
|
|
71
|
+
const headers = {
|
|
72
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
73
|
+
"Content-Type": "application/json"
|
|
74
|
+
};
|
|
75
|
+
const init = {
|
|
76
|
+
method,
|
|
77
|
+
headers,
|
|
78
|
+
signal: controller.signal
|
|
79
|
+
};
|
|
80
|
+
if (body !== void 0) {
|
|
81
|
+
init.body = JSON.stringify(body);
|
|
82
|
+
}
|
|
83
|
+
const response = await fetch(url, init);
|
|
84
|
+
const json = await response.json();
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
this.throwError(response.status, json);
|
|
87
|
+
}
|
|
88
|
+
return json.data;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof AguardicError) throw error;
|
|
91
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
92
|
+
throw new AguardicError(0, [
|
|
93
|
+
{ message: `Request timed out after ${this.timeout}ms` }
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
throw new AguardicError(0, [
|
|
97
|
+
{
|
|
98
|
+
message: error instanceof Error ? error.message : "Unknown network error"
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
} finally {
|
|
102
|
+
clearTimeout(timeoutId);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throwError(statusCode, body) {
|
|
106
|
+
const errors = body?.errors ?? body?.message ? [{ message: body.message }] : [{ message: `Request failed with status ${statusCode}` }];
|
|
107
|
+
switch (statusCode) {
|
|
108
|
+
case 400:
|
|
109
|
+
throw new ValidationError(errors);
|
|
110
|
+
case 401:
|
|
111
|
+
throw new AuthenticationError(errors);
|
|
112
|
+
case 403:
|
|
113
|
+
throw new ForbiddenError(errors);
|
|
114
|
+
case 404:
|
|
115
|
+
throw new NotFoundError(errors);
|
|
116
|
+
case 429:
|
|
117
|
+
throw new RateLimitError(errors);
|
|
118
|
+
default:
|
|
119
|
+
if (statusCode >= 500) {
|
|
120
|
+
throw new ServerError(statusCode, errors);
|
|
121
|
+
}
|
|
122
|
+
throw new AguardicError(statusCode, errors);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/resources/evaluate.ts
|
|
128
|
+
var EvaluateResource = class {
|
|
129
|
+
constructor(http) {
|
|
130
|
+
this.http = http;
|
|
131
|
+
}
|
|
132
|
+
// Evaluate content against bound policies
|
|
133
|
+
async evaluate(params) {
|
|
134
|
+
return this.http.post("/evaluate", params);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/resources/reviews.ts
|
|
139
|
+
var ReviewsResource = class {
|
|
140
|
+
constructor(http) {
|
|
141
|
+
this.http = http;
|
|
142
|
+
}
|
|
143
|
+
// Get a review request by ID
|
|
144
|
+
async get(reviewId) {
|
|
145
|
+
return this.http.get(`/reviews/${reviewId}`);
|
|
146
|
+
}
|
|
147
|
+
// Get a review request by correlation ID
|
|
148
|
+
async getByCorrelation(correlationId) {
|
|
149
|
+
return this.http.get(
|
|
150
|
+
`/reviews/by-correlation/${correlationId}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/resources/sessions.ts
|
|
156
|
+
var SessionsResource = class {
|
|
157
|
+
constructor(http) {
|
|
158
|
+
this.http = http;
|
|
159
|
+
}
|
|
160
|
+
// Create a new evaluation session
|
|
161
|
+
async create(params = {}) {
|
|
162
|
+
return this.http.post("/evaluation-sessions", params);
|
|
163
|
+
}
|
|
164
|
+
// End an active session
|
|
165
|
+
async end(sessionId, params = {}) {
|
|
166
|
+
return this.http.post(
|
|
167
|
+
`/evaluation-sessions/${sessionId}/end`,
|
|
168
|
+
params
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// src/client.ts
|
|
174
|
+
var DEFAULT_BASE_URL = "https://api.aguardic.com/v1";
|
|
175
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
176
|
+
var Aguardic = class {
|
|
177
|
+
sessions;
|
|
178
|
+
reviews;
|
|
179
|
+
evaluateResource;
|
|
180
|
+
constructor(apiKeyOrOptions) {
|
|
181
|
+
const options = typeof apiKeyOrOptions === "string" ? { apiKey: apiKeyOrOptions } : apiKeyOrOptions;
|
|
182
|
+
const http = new HttpClient({
|
|
183
|
+
apiKey: options.apiKey,
|
|
184
|
+
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
185
|
+
timeout: options.timeout ?? DEFAULT_TIMEOUT
|
|
186
|
+
});
|
|
187
|
+
this.evaluateResource = new EvaluateResource(http);
|
|
188
|
+
this.sessions = new SessionsResource(http);
|
|
189
|
+
this.reviews = new ReviewsResource(http);
|
|
190
|
+
}
|
|
191
|
+
// Evaluate content against bound policies
|
|
192
|
+
async evaluate(params) {
|
|
193
|
+
return this.evaluateResource.evaluate(params);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
export {
|
|
197
|
+
Aguardic,
|
|
198
|
+
AguardicError,
|
|
199
|
+
AuthenticationError,
|
|
200
|
+
ForbiddenError,
|
|
201
|
+
NotFoundError,
|
|
202
|
+
RateLimitError,
|
|
203
|
+
ServerError,
|
|
204
|
+
ValidationError,
|
|
205
|
+
Aguardic as default
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/evaluate.ts","../src/resources/reviews.ts","../src/resources/sessions.ts","../src/client.ts"],"sourcesContent":["export class AguardicError extends Error {\n readonly statusCode: number;\n readonly errors: Array<{ message: string }>;\n\n constructor(\n statusCode: number,\n errors: Array<{ message: string }>,\n message?: string,\n ) {\n const msg =\n message || errors.map((e) => e.message).join(\", \") || \"Unknown error\";\n super(msg);\n this.name = \"AguardicError\";\n this.statusCode = statusCode;\n this.errors = errors;\n }\n}\n\n// 400\nexport class ValidationError extends AguardicError {\n constructor(errors: Array<{ message: string }>) {\n super(400, errors);\n this.name = \"ValidationError\";\n }\n}\n\n// 401\nexport class AuthenticationError extends AguardicError {\n constructor(errors: Array<{ message: string }> = [{ message: \"Unauthorized\" }]) {\n super(401, errors);\n this.name = \"AuthenticationError\";\n }\n}\n\n// 403\nexport class ForbiddenError extends AguardicError {\n constructor(errors: Array<{ message: string }> = [{ message: \"Forbidden\" }]) {\n super(403, errors);\n this.name = \"ForbiddenError\";\n }\n}\n\n// 404\nexport class NotFoundError extends AguardicError {\n constructor(errors: Array<{ message: string }> = [{ message: \"Not found\" }]) {\n super(404, errors);\n this.name = \"NotFoundError\";\n }\n}\n\n// 429\nexport class RateLimitError extends AguardicError {\n constructor(\n errors: Array<{ message: string }> = [{ message: \"Rate limit exceeded\" }],\n ) {\n super(429, errors);\n this.name = \"RateLimitError\";\n }\n}\n\n// 500+\nexport class ServerError extends AguardicError {\n constructor(\n statusCode: number = 500,\n errors: Array<{ message: string }> = [{ message: \"Internal server error\" }],\n ) {\n super(statusCode, errors);\n this.name = \"ServerError\";\n }\n}\n","import {\n AguardicError,\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n RateLimitError,\n ServerError,\n ValidationError,\n} from \"./errors\";\n\nexport interface HttpClientOptions {\n apiKey: string;\n baseUrl: string;\n timeout: number;\n}\n\n// Internal HTTP client — unwraps { success, statusCode, data } response wrapper\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n\n constructor(options: HttpClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.timeout = options.timeout;\n }\n\n async get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n\n async post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(\"POST\", path, body);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n };\n\n const init: RequestInit = {\n method,\n headers,\n signal: controller.signal,\n };\n\n if (body !== undefined) {\n init.body = JSON.stringify(body);\n }\n\n const response = await fetch(url, init);\n const json = await response.json();\n\n if (!response.ok) {\n this.throwError(response.status, json);\n }\n\n // Unwrap { success, statusCode, data } wrapper\n return json.data as T;\n } catch (error: unknown) {\n if (error instanceof AguardicError) throw error;\n\n if (error instanceof DOMException && error.name === \"AbortError\") {\n throw new AguardicError(0, [\n { message: `Request timed out after ${this.timeout}ms` },\n ]);\n }\n\n throw new AguardicError(0, [\n {\n message:\n error instanceof Error ? error.message : \"Unknown network error\",\n },\n ]);\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n private throwError(statusCode: number, body: any): never {\n const errors: Array<{ message: string }> = body?.errors ??\n body?.message\n ? [{ message: body.message }]\n : [{ message: `Request failed with status ${statusCode}` }];\n\n switch (statusCode) {\n case 400:\n throw new ValidationError(errors);\n case 401:\n throw new AuthenticationError(errors);\n case 403:\n throw new ForbiddenError(errors);\n case 404:\n throw new NotFoundError(errors);\n case 429:\n throw new RateLimitError(errors);\n default:\n if (statusCode >= 500) {\n throw new ServerError(statusCode, errors);\n }\n throw new AguardicError(statusCode, errors);\n }\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { EvaluateParams, EvaluateResponse } from \"../types\";\n\nexport class EvaluateResource {\n constructor(private readonly http: HttpClient) {}\n\n // Evaluate content against bound policies\n async evaluate(params: EvaluateParams): Promise<EvaluateResponse> {\n return this.http.post<EvaluateResponse>(\"/evaluate\", params);\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type { ReviewRequest } from \"../types\";\n\nexport class ReviewsResource {\n constructor(private readonly http: HttpClient) {}\n\n // Get a review request by ID\n async get(reviewId: string): Promise<ReviewRequest> {\n return this.http.get<ReviewRequest>(`/reviews/${reviewId}`);\n }\n\n // Get a review request by correlation ID\n async getByCorrelation(correlationId: string): Promise<ReviewRequest> {\n return this.http.get<ReviewRequest>(\n `/reviews/by-correlation/${correlationId}`,\n );\n }\n}\n","import type { HttpClient } from \"../http\";\nimport type {\n CreateSessionParams,\n EndSessionParams,\n EndSessionResponse,\n Session,\n} from \"../types\";\n\nexport class SessionsResource {\n constructor(private readonly http: HttpClient) {}\n\n // Create a new evaluation session\n async create(params: CreateSessionParams = {}): Promise<Session> {\n return this.http.post<Session>(\"/evaluation-sessions\", params);\n }\n\n // End an active session\n async end(\n sessionId: string,\n params: EndSessionParams = {},\n ): Promise<EndSessionResponse> {\n return this.http.post<EndSessionResponse>(\n `/evaluation-sessions/${sessionId}/end`,\n params,\n );\n }\n}\n","import { HttpClient } from \"./http\";\nimport { EvaluateResource } from \"./resources/evaluate\";\nimport { ReviewsResource } from \"./resources/reviews\";\nimport { SessionsResource } from \"./resources/sessions\";\nimport type { AguardicOptions, EvaluateParams, EvaluateResponse } from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://api.aguardic.com/v1\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class Aguardic {\n readonly sessions: SessionsResource;\n readonly reviews: ReviewsResource;\n\n private readonly evaluateResource: EvaluateResource;\n\n constructor(apiKeyOrOptions: string | AguardicOptions) {\n const options =\n typeof apiKeyOrOptions === \"string\"\n ? { apiKey: apiKeyOrOptions }\n : apiKeyOrOptions;\n\n const http = new HttpClient({\n apiKey: options.apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n timeout: options.timeout ?? DEFAULT_TIMEOUT,\n });\n\n this.evaluateResource = new EvaluateResource(http);\n this.sessions = new SessionsResource(http);\n this.reviews = new ReviewsResource(http);\n }\n\n // Evaluate content against bound policies\n async evaluate(params: EvaluateParams): Promise<EvaluateResponse> {\n return this.evaluateResource.evaluate(params);\n }\n}\n"],"mappings":";AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YACE,YACA,QACA,SACA;AACA,UAAM,MACJ,WAAW,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;AACxD,UAAM,GAAG;AACT,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,SAAS;AAAA,EAChB;AACF;AAGO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EACjD,YAAY,QAAoC;AAC9C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jB,YAAY,iBAA2C;AACrD,UAAM,UACJ,OAAO,oBAAoB,WACvB,EAAE,QAAQ,gBAAgB,IAC1B;AAEN,UAAM,OAAO,IAAI,WAAW;AAAA,MAC1B,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ,WAAW;AAAA,MAC5B,SAAS,QAAQ,WAAW;AAAA,IAC9B,CAAC;AAED,SAAK,mBAAmB,IAAI,iBAAiB,IAAI;AACjD,SAAK,WAAW,IAAI,iBAAiB,IAAI;AACzC,SAAK,UAAU,IAAI,gBAAgB,IAAI;AAAA,EACzC;AAAA;AAAA,EAGA,MAAM,SAAS,QAAmD;AAChE,WAAO,KAAK,iBAAiB,SAAS,MAAM;AAAA,EAC9C;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aguardic/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official TypeScript SDK for the Aguardic governance API",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"clean": "rm -rf dist"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"tsup": "^8.0.0",
|
|
32
|
+
"typescript": "^5.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|