@neurana/sdk 1.0.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/LICENSE +21 -0
- package/README.md +370 -0
- package/lib/client.d.ts +20 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +69 -0
- package/lib/client.js.map +1 -0
- package/lib/constants/api.d.ts +50 -0
- package/lib/constants/api.d.ts.map +1 -0
- package/lib/constants/api.js +50 -0
- package/lib/constants/api.js.map +1 -0
- package/lib/constants/errors.d.ts +18 -0
- package/lib/constants/errors.d.ts.map +1 -0
- package/lib/constants/errors.js +33 -0
- package/lib/constants/errors.js.map +1 -0
- package/lib/constants/http.d.ts +47 -0
- package/lib/constants/http.d.ts.map +1 -0
- package/lib/constants/http.js +47 -0
- package/lib/constants/http.js.map +1 -0
- package/lib/constants/index.d.ts +5 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/constants/index.js +5 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/limits.d.ts +28 -0
- package/lib/constants/limits.d.ts.map +1 -0
- package/lib/constants/limits.js +28 -0
- package/lib/constants/limits.js.map +1 -0
- package/lib/errors.d.ts +40 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +100 -0
- package/lib/errors.js.map +1 -0
- package/lib/http.d.ts +27 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +177 -0
- package/lib/http.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/logger.d.ts +29 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +109 -0
- package/lib/logger.js.map +1 -0
- package/lib/resources/api-keys.d.ts +16 -0
- package/lib/resources/api-keys.d.ts.map +1 -0
- package/lib/resources/api-keys.js +73 -0
- package/lib/resources/api-keys.js.map +1 -0
- package/lib/resources/code.d.ts +13 -0
- package/lib/resources/code.d.ts.map +1 -0
- package/lib/resources/code.js +56 -0
- package/lib/resources/code.js.map +1 -0
- package/lib/resources/execution.d.ts +12 -0
- package/lib/resources/execution.d.ts.map +1 -0
- package/lib/resources/execution.js +63 -0
- package/lib/resources/execution.js.map +1 -0
- package/lib/resources/index.d.ts +6 -0
- package/lib/resources/index.d.ts.map +1 -0
- package/lib/resources/index.js +6 -0
- package/lib/resources/index.js.map +1 -0
- package/lib/resources/secrets.d.ts +12 -0
- package/lib/resources/secrets.d.ts.map +1 -0
- package/lib/resources/secrets.js +63 -0
- package/lib/resources/secrets.js.map +1 -0
- package/lib/resources/workflows.d.ts +19 -0
- package/lib/resources/workflows.d.ts.map +1 -0
- package/lib/resources/workflows.js +145 -0
- package/lib/resources/workflows.js.map +1 -0
- package/lib/types/api-keys.d.ts +81 -0
- package/lib/types/api-keys.d.ts.map +1 -0
- package/lib/types/api-keys.js +2 -0
- package/lib/types/api-keys.js.map +1 -0
- package/lib/types/code.d.ts +41 -0
- package/lib/types/code.d.ts.map +1 -0
- package/lib/types/code.js +2 -0
- package/lib/types/code.js.map +1 -0
- package/lib/types/common.d.ts +31 -0
- package/lib/types/common.d.ts.map +1 -0
- package/lib/types/common.js +2 -0
- package/lib/types/common.js.map +1 -0
- package/lib/types/execution.d.ts +35 -0
- package/lib/types/execution.d.ts.map +1 -0
- package/lib/types/execution.js +2 -0
- package/lib/types/execution.js.map +1 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/secrets.d.ts +21 -0
- package/lib/types/secrets.d.ts.map +1 -0
- package/lib/types/secrets.js +2 -0
- package/lib/types/secrets.js.map +1 -0
- package/lib/types/workflows.d.ts +120 -0
- package/lib/types/workflows.d.ts.map +1 -0
- package/lib/types/workflows.js +2 -0
- package/lib/types/workflows.js.map +1 -0
- package/lib/utils/file-utils.d.ts +12 -0
- package/lib/utils/file-utils.d.ts.map +1 -0
- package/lib/utils/file-utils.js +138 -0
- package/lib/utils/file-utils.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Neurana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://neurana.io/logo.svg" alt="Neurana" width="200" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Neurana SDK</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Official TypeScript/JavaScript SDK for the Neurana AI Workflow Automation Platform</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@neurana/sdk"><img src="https://img.shields.io/npm/v/@neurana/sdk.svg" alt="npm version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@neurana/sdk"><img src="https://img.shields.io/npm/dm/@neurana/sdk.svg" alt="npm downloads" /></a>
|
|
14
|
+
<a href="https://github.com/neurana/sdk/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@neurana/sdk.svg" alt="license" /></a>
|
|
15
|
+
<a href="https://github.com/neurana/sdk"><img src="https://img.shields.io/badge/TypeScript-5.0+-blue.svg" alt="TypeScript" /></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="#installation">Installation</a> •
|
|
20
|
+
<a href="#quick-start">Quick Start</a> •
|
|
21
|
+
<a href="#api-reference">API Reference</a> •
|
|
22
|
+
<a href="#examples">Examples</a> •
|
|
23
|
+
<a href="#support">Support</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
Neurana is a powerful AI-driven workflow automation platform that enables you to build, deploy, and manage serverless workflows at scale.
|
|
31
|
+
|
|
32
|
+
- ⚡ **Execute Serverless Workflows** — Run complex automation pipelines with zero infrastructure
|
|
33
|
+
- 🔐 **Secure Secret Management** — Store and access sensitive credentials safely
|
|
34
|
+
- 📁 **Code Management** — Upload and version Python/Node.js code for workflow steps
|
|
35
|
+
- 📊 **Full Observability** — Monitor executions with real-time WebSocket updates
|
|
36
|
+
- 🔑 **API Key Management** — Create scoped keys with granular permissions
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @neurana/sdk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
yarn add @neurana/sdk
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm add @neurana/sdk
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { NeuranaClient } from '@neurana/sdk';
|
|
56
|
+
|
|
57
|
+
const neurana = new NeuranaClient({
|
|
58
|
+
apiKey: process.env.NEURANA_API_KEY,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// List workflows
|
|
62
|
+
const { data: workflows } = await neurana.workflows.list();
|
|
63
|
+
|
|
64
|
+
// Trigger a workflow
|
|
65
|
+
const { executionId } = await neurana.workflows.trigger('my-workflow', {
|
|
66
|
+
message: 'Hello from SDK!',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Check execution status
|
|
70
|
+
const status = await neurana.executions.getStatus(executionId);
|
|
71
|
+
console.log(`Status: ${status.status}`);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const neurana = new NeuranaClient({
|
|
78
|
+
apiKey: 'your-api-key',
|
|
79
|
+
|
|
80
|
+
// Optional: Custom endpoints
|
|
81
|
+
baseUrl: 'https://workflows.neurana.io',
|
|
82
|
+
mainApiUrl: 'https://api.neurana.io',
|
|
83
|
+
|
|
84
|
+
// Optional: Request timeout (default: 30000ms)
|
|
85
|
+
timeout: 30000,
|
|
86
|
+
|
|
87
|
+
// Optional: Allow HTTP for local development
|
|
88
|
+
allowInsecureHttp: false,
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## API Reference
|
|
93
|
+
|
|
94
|
+
### Workflows
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// List all workflows
|
|
98
|
+
const { data, pagination } = await neurana.workflows.list({ limit: 20 });
|
|
99
|
+
|
|
100
|
+
// Get workflow by key
|
|
101
|
+
const workflow = await neurana.workflows.get('workflow-key');
|
|
102
|
+
|
|
103
|
+
// Create a workflow with inline code
|
|
104
|
+
const workflow = await neurana.workflows.create({
|
|
105
|
+
name: 'Data Processor',
|
|
106
|
+
description: 'Process incoming data',
|
|
107
|
+
steps: [
|
|
108
|
+
{
|
|
109
|
+
id: 'process',
|
|
110
|
+
name: 'Process Data',
|
|
111
|
+
type: 'code',
|
|
112
|
+
config: {
|
|
113
|
+
runtime: 'python',
|
|
114
|
+
code: `
|
|
115
|
+
def handler(event, context):
|
|
116
|
+
return {"processed": True, "data": event}
|
|
117
|
+
`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Update workflow
|
|
124
|
+
await neurana.workflows.update('workflow-key', {
|
|
125
|
+
name: 'Updated Name',
|
|
126
|
+
enabled: true,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Delete workflow
|
|
130
|
+
await neurana.workflows.delete('workflow-key');
|
|
131
|
+
|
|
132
|
+
// Trigger workflow execution
|
|
133
|
+
const { executionId } = await neurana.workflows.trigger('workflow-key', {
|
|
134
|
+
orderId: 'ORD-12345',
|
|
135
|
+
items: [{ sku: 'PROD-001', qty: 2 }],
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Executions
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
// Get execution status
|
|
143
|
+
const status = await neurana.executions.getStatus('execution-id');
|
|
144
|
+
|
|
145
|
+
// List all runs
|
|
146
|
+
const { data: runs } = await neurana.executions.listRuns({ limit: 50 });
|
|
147
|
+
|
|
148
|
+
// List runs for specific workflow
|
|
149
|
+
const { data: workflowRuns } = await neurana.executions.listWorkflowRuns('workflow-key');
|
|
150
|
+
|
|
151
|
+
// Test a step in isolation
|
|
152
|
+
const result = await neurana.executions.testStep({
|
|
153
|
+
stepType: 'http',
|
|
154
|
+
stepConfig: {
|
|
155
|
+
url: 'https://api.example.com/data',
|
|
156
|
+
method: 'GET',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Code Management
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// Upload code file
|
|
165
|
+
const file = await neurana.code.upload({
|
|
166
|
+
fileName: 'processor.py',
|
|
167
|
+
content: 'def handler(event, context): return event',
|
|
168
|
+
language: 'python',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// List code files
|
|
172
|
+
const { data: files } = await neurana.code.list();
|
|
173
|
+
|
|
174
|
+
// Get code file with download URL
|
|
175
|
+
const code = await neurana.code.get('file-key');
|
|
176
|
+
|
|
177
|
+
// Get version history
|
|
178
|
+
const { data: history } = await neurana.code.getHistoryByKey('file-key');
|
|
179
|
+
|
|
180
|
+
// Delete code file
|
|
181
|
+
await neurana.code.delete('file-key');
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Secrets
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// Create a secret
|
|
188
|
+
await neurana.secrets.create({
|
|
189
|
+
name: 'OPENAI_API_KEY',
|
|
190
|
+
value: 'sk-...',
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// List secrets (values hidden)
|
|
194
|
+
const { data: secrets } = await neurana.secrets.list();
|
|
195
|
+
|
|
196
|
+
// Get secret with value
|
|
197
|
+
const secret = await neurana.secrets.get('OPENAI_API_KEY');
|
|
198
|
+
|
|
199
|
+
// Update secret
|
|
200
|
+
await neurana.secrets.update('OPENAI_API_KEY', { value: 'sk-new-value' });
|
|
201
|
+
|
|
202
|
+
// Delete secret
|
|
203
|
+
await neurana.secrets.delete('OPENAI_API_KEY');
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### API Keys
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// Create API key with permissions
|
|
210
|
+
const { apiKey } = await neurana.apiKeys.create({
|
|
211
|
+
name: 'Production Backend',
|
|
212
|
+
permissions: ['workflows:read', 'workflows:trigger', 'runs:read'],
|
|
213
|
+
expiresInDays: 90,
|
|
214
|
+
rateLimit: 10000,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// List API keys
|
|
218
|
+
const { data: keys } = await neurana.apiKeys.list();
|
|
219
|
+
|
|
220
|
+
// Rotate key (24h grace period)
|
|
221
|
+
const { apiKey: newKey } = await neurana.apiKeys.rotate('key-id');
|
|
222
|
+
|
|
223
|
+
// Revoke key immediately
|
|
224
|
+
await neurana.apiKeys.revoke('key-id');
|
|
225
|
+
|
|
226
|
+
// Get usage statistics
|
|
227
|
+
const usage = await neurana.apiKeys.getUsage('key-id');
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### Available Permissions
|
|
231
|
+
|
|
232
|
+
| Permission | Description |
|
|
233
|
+
|------------|-------------|
|
|
234
|
+
| `workflows:read` | View workflows |
|
|
235
|
+
| `workflows:write` | Create/update workflows |
|
|
236
|
+
| `workflows:trigger` | Execute workflows |
|
|
237
|
+
| `workflows:delete` | Delete workflows |
|
|
238
|
+
| `code:read` | View code files |
|
|
239
|
+
| `code:write` | Upload code |
|
|
240
|
+
| `secrets:read` | Access secrets |
|
|
241
|
+
| `runs:read` | View execution history |
|
|
242
|
+
|
|
243
|
+
## Error Handling
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import {
|
|
247
|
+
NeuranaClient,
|
|
248
|
+
AuthenticationError,
|
|
249
|
+
ValidationError,
|
|
250
|
+
NotFoundError,
|
|
251
|
+
RateLimitError,
|
|
252
|
+
NeuranaError,
|
|
253
|
+
} from '@neurana/sdk';
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
await neurana.workflows.trigger('my-workflow');
|
|
257
|
+
} catch (error) {
|
|
258
|
+
if (error instanceof AuthenticationError) {
|
|
259
|
+
console.error('Invalid or expired API key');
|
|
260
|
+
} else if (error instanceof ValidationError) {
|
|
261
|
+
console.error('Invalid request:', error.message);
|
|
262
|
+
} else if (error instanceof NotFoundError) {
|
|
263
|
+
console.error('Workflow not found');
|
|
264
|
+
} else if (error instanceof RateLimitError) {
|
|
265
|
+
console.error(`Rate limited. Retry after ${error.retryAfter}s`);
|
|
266
|
+
} else if (error instanceof NeuranaError) {
|
|
267
|
+
console.error(`Error [${error.code}]: ${error.message}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## TypeScript Support
|
|
273
|
+
|
|
274
|
+
Full TypeScript support with exported types:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import type {
|
|
278
|
+
Workflow,
|
|
279
|
+
WorkflowStep,
|
|
280
|
+
ExecutionStatus,
|
|
281
|
+
ApiKey,
|
|
282
|
+
Secret,
|
|
283
|
+
CodeFile,
|
|
284
|
+
Run,
|
|
285
|
+
PaginatedResponse,
|
|
286
|
+
} from '@neurana/sdk';
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Examples
|
|
290
|
+
|
|
291
|
+
### Webhook Handler (Next.js)
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { NeuranaClient } from '@neurana/sdk';
|
|
295
|
+
|
|
296
|
+
const neurana = new NeuranaClient({
|
|
297
|
+
apiKey: process.env.NEURANA_API_KEY,
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
export async function POST(req: Request) {
|
|
301
|
+
const payload = await req.json();
|
|
302
|
+
|
|
303
|
+
const { executionId } = await neurana.workflows.trigger(
|
|
304
|
+
'process-webhook',
|
|
305
|
+
payload
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
return Response.json({ executionId });
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Polling for Completion
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
async function waitForCompletion(executionId: string, timeoutMs = 60000) {
|
|
316
|
+
const start = Date.now();
|
|
317
|
+
|
|
318
|
+
while (Date.now() - start < timeoutMs) {
|
|
319
|
+
const status = await neurana.executions.getStatus(executionId);
|
|
320
|
+
|
|
321
|
+
if (status.status === 'SUCCEEDED') return status.output;
|
|
322
|
+
if (status.status === 'FAILED') throw new Error(status.error);
|
|
323
|
+
|
|
324
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
throw new Error('Execution timed out');
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Environment-Based Configuration
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
const neurana = new NeuranaClient({
|
|
335
|
+
apiKey: process.env.NODE_ENV === 'production'
|
|
336
|
+
? process.env.NEURANA_PROD_KEY
|
|
337
|
+
: process.env.NEURANA_DEV_KEY,
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Resources Summary
|
|
342
|
+
|
|
343
|
+
| Resource | Methods |
|
|
344
|
+
|----------|---------|
|
|
345
|
+
| `workflows` | `list`, `get`, `create`, `update`, `delete`, `trigger`, `updateVisibility` |
|
|
346
|
+
| `executions` | `getStatus`, `listRuns`, `listTestRuns`, `listWorkflowRuns`, `testStep` |
|
|
347
|
+
| `code` | `list`, `get`, `upload`, `delete`, `listHistory`, `getHistoryByKey` |
|
|
348
|
+
| `secrets` | `list`, `get`, `create`, `update`, `delete` |
|
|
349
|
+
| `apiKeys` | `list`, `get`, `create`, `update`, `delete`, `rotate`, `revoke`, `getUsage`, `validate` |
|
|
350
|
+
|
|
351
|
+
## Requirements
|
|
352
|
+
|
|
353
|
+
- Node.js 18+
|
|
354
|
+
- TypeScript 5.0+ (for TypeScript users)
|
|
355
|
+
|
|
356
|
+
## Security
|
|
357
|
+
|
|
358
|
+
- HTTPS enforced for all non-localhost connections
|
|
359
|
+
- API keys never logged
|
|
360
|
+
- Request tracing via `X-Request-ID` header
|
|
361
|
+
- Sensitive data redacted from logs
|
|
362
|
+
|
|
363
|
+
## Support
|
|
364
|
+
|
|
365
|
+
- 📚 [Documentation](https://neurana.io/docs)
|
|
366
|
+
- 🐛 [GitHub Issues](https://github.com/neurana/sdk/issues)
|
|
367
|
+
|
|
368
|
+
## License
|
|
369
|
+
|
|
370
|
+
MIT © [Neurana](https://neurana.io)
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WorkflowsResource, CodeResource, SecretsResource, ApiKeysResource, ExecutionResource } from "./resources/index.js";
|
|
2
|
+
export interface NeuranaConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
mainApiUrl?: string;
|
|
6
|
+
sdkBaseUrl?: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
allowInsecureHttp?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class NeuranaClient {
|
|
11
|
+
readonly workflows: WorkflowsResource;
|
|
12
|
+
readonly code: CodeResource;
|
|
13
|
+
readonly secrets: SecretsResource;
|
|
14
|
+
readonly apiKeys: ApiKeysResource;
|
|
15
|
+
readonly executions: ExecutionResource;
|
|
16
|
+
constructor(config: NeuranaConfig);
|
|
17
|
+
private validateConfig;
|
|
18
|
+
private validateEndpointSecurity;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,qBAAa,aAAa;IACxB,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;gBAE3B,MAAM,EAAE,aAAa;IA8BjC,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,wBAAwB;CAcjC"}
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { HttpClient } from "./http.js";
|
|
2
|
+
import { ConfigurationError } from "./errors.js";
|
|
3
|
+
import { BASE_URL, MAIN_API_URL, VALIDATION } from "./constants/index.js";
|
|
4
|
+
import { logger } from "./logger.js";
|
|
5
|
+
import { WorkflowsResource, CodeResource, SecretsResource, ApiKeysResource, ExecutionResource, } from "./resources/index.js";
|
|
6
|
+
export class NeuranaClient {
|
|
7
|
+
workflows;
|
|
8
|
+
code;
|
|
9
|
+
secrets;
|
|
10
|
+
apiKeys;
|
|
11
|
+
executions;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.validateConfig(config);
|
|
14
|
+
const workflowsHttp = new HttpClient({
|
|
15
|
+
baseUrl: config.baseUrl ?? BASE_URL,
|
|
16
|
+
apiKey: config.apiKey,
|
|
17
|
+
timeout: config.timeout,
|
|
18
|
+
});
|
|
19
|
+
const mainHttp = new HttpClient({
|
|
20
|
+
baseUrl: config.mainApiUrl ?? MAIN_API_URL,
|
|
21
|
+
apiKey: config.apiKey,
|
|
22
|
+
timeout: config.timeout,
|
|
23
|
+
});
|
|
24
|
+
this.code = new CodeResource(workflowsHttp);
|
|
25
|
+
this.secrets = new SecretsResource(mainHttp);
|
|
26
|
+
this.apiKeys = new ApiKeysResource(mainHttp);
|
|
27
|
+
this.executions = new ExecutionResource(workflowsHttp);
|
|
28
|
+
this.workflows = new WorkflowsResource(workflowsHttp, async (fileName, content, language) => {
|
|
29
|
+
const result = await this.code.upload({ fileName, content, language });
|
|
30
|
+
return { key: result.key };
|
|
31
|
+
}, config.sdkBaseUrl);
|
|
32
|
+
}
|
|
33
|
+
validateConfig(config) {
|
|
34
|
+
if (!config.apiKey) {
|
|
35
|
+
throw new ConfigurationError("API key is required");
|
|
36
|
+
}
|
|
37
|
+
if (typeof config.apiKey !== "string") {
|
|
38
|
+
throw new ConfigurationError("API key must be a string");
|
|
39
|
+
}
|
|
40
|
+
const key = config.apiKey.trim();
|
|
41
|
+
if (key.length < VALIDATION.MIN_API_KEY_LENGTH) {
|
|
42
|
+
throw new ConfigurationError("Invalid API key format");
|
|
43
|
+
}
|
|
44
|
+
if (key.length > VALIDATION.MAX_API_KEY_LENGTH) {
|
|
45
|
+
throw new ConfigurationError("API key exceeds maximum length");
|
|
46
|
+
}
|
|
47
|
+
if (key.startsWith("nrn_") && !VALIDATION.API_KEY_PATTERN.test(key)) {
|
|
48
|
+
throw new ConfigurationError("Invalid API key format");
|
|
49
|
+
}
|
|
50
|
+
this.validateEndpointSecurity(config.baseUrl, config.allowInsecureHttp);
|
|
51
|
+
this.validateEndpointSecurity(config.mainApiUrl, config.allowInsecureHttp);
|
|
52
|
+
this.validateEndpointSecurity(config.sdkBaseUrl, config.allowInsecureHttp);
|
|
53
|
+
}
|
|
54
|
+
validateEndpointSecurity(url, allowInsecure) {
|
|
55
|
+
if (!url)
|
|
56
|
+
return;
|
|
57
|
+
const isSecure = url.startsWith("https://");
|
|
58
|
+
const isLocalhost = url.includes("localhost") || url.includes("127.0.0.1");
|
|
59
|
+
if (!isSecure && !isLocalhost) {
|
|
60
|
+
if (allowInsecure) {
|
|
61
|
+
logger.warn("Using insecure HTTP connection", { url: url.split("?")[0] }, "security");
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new ConfigurationError("HTTPS is required for non-localhost endpoints");
|
|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C;QACzD,CAAC;QAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACxE,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC3E,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC7E,CAAC;IAEO,wBAAwB,CAAC,GAAuB,EAAE,aAAuB;QAC/E,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAE3E,IAAI,CAAC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;YAC9B,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;YACxF,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,kBAAkB,CAAC,+CAA+C,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const API_VERSION = "v1";
|
|
2
|
+
export declare const BASE_URL = "https://workflows.neurana.io";
|
|
3
|
+
export declare const MAIN_API_URL = "https://api.neurana.io";
|
|
4
|
+
export declare const ENDPOINTS: {
|
|
5
|
+
readonly WORKFLOWS: {
|
|
6
|
+
readonly LIST: "/workflows";
|
|
7
|
+
readonly CREATE: "/workflows";
|
|
8
|
+
readonly GET: (id: string) => string;
|
|
9
|
+
readonly UPDATE: (id: string) => string;
|
|
10
|
+
readonly DELETE: (id: string) => string;
|
|
11
|
+
readonly TRIGGER: "/trigger";
|
|
12
|
+
readonly VISIBILITY: (id: string) => string;
|
|
13
|
+
};
|
|
14
|
+
readonly CODE: {
|
|
15
|
+
readonly LIST: "/upload-code";
|
|
16
|
+
readonly UPLOAD: "/upload-code";
|
|
17
|
+
readonly GET: (fileId: string) => string;
|
|
18
|
+
readonly DELETE: (fileId: string) => string;
|
|
19
|
+
readonly HISTORY: "/code-history";
|
|
20
|
+
readonly HISTORY_BY_KEY: (key: string) => string;
|
|
21
|
+
};
|
|
22
|
+
readonly SECRETS: {
|
|
23
|
+
readonly LIST: "/secrets";
|
|
24
|
+
readonly CREATE: "/secrets";
|
|
25
|
+
readonly GET: (secretId: string) => string;
|
|
26
|
+
readonly UPDATE: (secretId: string) => string;
|
|
27
|
+
readonly DELETE: (secretId: string) => string;
|
|
28
|
+
};
|
|
29
|
+
readonly API_KEYS: {
|
|
30
|
+
readonly LIST: "/api-keys";
|
|
31
|
+
readonly CREATE: "/api-keys";
|
|
32
|
+
readonly GET: (keyId: string) => string;
|
|
33
|
+
readonly UPDATE: (keyId: string) => string;
|
|
34
|
+
readonly DELETE: (keyId: string) => string;
|
|
35
|
+
readonly ROTATE: (keyId: string) => string;
|
|
36
|
+
readonly REVOKE: (keyId: string) => string;
|
|
37
|
+
readonly USAGE: (keyId: string) => string;
|
|
38
|
+
readonly VALIDATE: "/api-keys/validate";
|
|
39
|
+
};
|
|
40
|
+
readonly EXECUTION: {
|
|
41
|
+
readonly TEST_STEP: "/test-step-async";
|
|
42
|
+
readonly STATUS: (executionId: string) => string;
|
|
43
|
+
};
|
|
44
|
+
readonly RUNS: {
|
|
45
|
+
readonly LIST_ALL: "/runs";
|
|
46
|
+
readonly LIST_TEST: "/runs/tests";
|
|
47
|
+
readonly LIST_WORKFLOW: (workflowKey: string) => string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/constants/api.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,eAAO,MAAM,QAAQ,iCAAiC,CAAC;AACvD,eAAO,MAAM,YAAY,2BAA2B,CAAC;AAErD,eAAO,MAAM,SAAS;;;;2BAIR,MAAM;8BACH,MAAM;8BACN,MAAM;;kCAEF,MAAM;;;;;+BAKT,MAAM;kCACH,MAAM;;uCAED,MAAM;;;;;iCAKZ,MAAM;oCACH,MAAM;oCACN,MAAM;;;;;8BAKZ,MAAM;iCACH,MAAM;iCACN,MAAM;iCACN,MAAM;iCACN,MAAM;gCACP,MAAM;;;;;uCAKC,MAAM;;;;;8CAKC,MAAM;;CAE7B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const API_VERSION = "v1";
|
|
2
|
+
export const BASE_URL = "https://workflows.neurana.io";
|
|
3
|
+
export const MAIN_API_URL = "https://api.neurana.io";
|
|
4
|
+
export const ENDPOINTS = {
|
|
5
|
+
WORKFLOWS: {
|
|
6
|
+
LIST: "/workflows",
|
|
7
|
+
CREATE: "/workflows",
|
|
8
|
+
GET: (id) => `/workflows/${id}`,
|
|
9
|
+
UPDATE: (id) => `/workflows/${id}`,
|
|
10
|
+
DELETE: (id) => `/workflows/${id}`,
|
|
11
|
+
TRIGGER: "/trigger",
|
|
12
|
+
VISIBILITY: (id) => `/workflows/${id}/visibility`,
|
|
13
|
+
},
|
|
14
|
+
CODE: {
|
|
15
|
+
LIST: "/upload-code",
|
|
16
|
+
UPLOAD: "/upload-code",
|
|
17
|
+
GET: (fileId) => `/upload-code/${encodeURIComponent(fileId)}`,
|
|
18
|
+
DELETE: (fileId) => `/upload-code/${encodeURIComponent(fileId)}`,
|
|
19
|
+
HISTORY: "/code-history",
|
|
20
|
+
HISTORY_BY_KEY: (key) => `/code-history/${encodeURIComponent(key)}`,
|
|
21
|
+
},
|
|
22
|
+
SECRETS: {
|
|
23
|
+
LIST: "/secrets",
|
|
24
|
+
CREATE: "/secrets",
|
|
25
|
+
GET: (secretId) => `/secrets/${encodeURIComponent(secretId)}`,
|
|
26
|
+
UPDATE: (secretId) => `/secrets/${encodeURIComponent(secretId)}`,
|
|
27
|
+
DELETE: (secretId) => `/secrets/${encodeURIComponent(secretId)}`,
|
|
28
|
+
},
|
|
29
|
+
API_KEYS: {
|
|
30
|
+
LIST: "/api-keys",
|
|
31
|
+
CREATE: "/api-keys",
|
|
32
|
+
GET: (keyId) => `/api-keys/${keyId}`,
|
|
33
|
+
UPDATE: (keyId) => `/api-keys/${keyId}`,
|
|
34
|
+
DELETE: (keyId) => `/api-keys/${keyId}`,
|
|
35
|
+
ROTATE: (keyId) => `/api-keys/${keyId}/rotate`,
|
|
36
|
+
REVOKE: (keyId) => `/api-keys/${keyId}/revoke`,
|
|
37
|
+
USAGE: (keyId) => `/api-keys/${keyId}/usage`,
|
|
38
|
+
VALIDATE: "/api-keys/validate",
|
|
39
|
+
},
|
|
40
|
+
EXECUTION: {
|
|
41
|
+
TEST_STEP: "/test-step-async",
|
|
42
|
+
STATUS: (executionId) => `/execution/${executionId}`,
|
|
43
|
+
},
|
|
44
|
+
RUNS: {
|
|
45
|
+
LIST_ALL: "/runs",
|
|
46
|
+
LIST_TEST: "/runs/tests",
|
|
47
|
+
LIST_WORKFLOW: (workflowKey) => `/runs/workflows/${workflowKey}`,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/constants/api.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEhC,MAAM,CAAC,MAAM,QAAQ,GAAG,8BAA8B,CAAC;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAErD,MAAM,CAAC,M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AAC,KAAa,EAAE,EAAE,CAAC,aAAa,KAAK,EAAE;QAC/C,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,aAAa,KAAK,EAAE;QAC/C,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,aAAa,KAAK,SAAS;QACtD,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,aAAa,KAAK,SAAS;QACtD,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,aAAa,KAAK,QAAQ;QACpD,QAAQ,EAAE,oBAAoB;KAC/B;IACD,SAAS,EAAE;QACT,SAAS,EAAE,kBAAkB;QAC7B,MAAM,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,cAAc,WAAW,EAAE;KAC7D;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,aAAa;QACxB,aAAa,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,mBAAmB,WAAW,EAAE;KACzE;CACO,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const ERROR_CODES: {
|
|
2
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
3
|
+
readonly AUTHENTICATION_FAILED: "AUTH_FAILED";
|
|
4
|
+
readonly AUTHORIZATION_FAILED: "FORBIDDEN";
|
|
5
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
6
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
7
|
+
readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT";
|
|
8
|
+
readonly SERVER_ERROR: "SERVER_ERROR";
|
|
9
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
10
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
11
|
+
readonly WEBSOCKET_ERROR: "WEBSOCKET_ERROR";
|
|
12
|
+
readonly PARSE_ERROR: "PARSE_ERROR";
|
|
13
|
+
readonly SECURITY_ERROR: "SECURITY_ERROR";
|
|
14
|
+
readonly ANALYZER_ERROR: "ANALYZER_ERROR";
|
|
15
|
+
readonly AI_GENERATION_ERROR: "AI_GENERATION_ERROR";
|
|
16
|
+
};
|
|
17
|
+
export declare const ERROR_MESSAGES: Record<string, string>;
|
|
18
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/constants/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;CAed,CAAC;AAEX,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAejD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const ERROR_CODES = {
|
|
2
|
+
INVALID_CONFIG: 'INVALID_CONFIG',
|
|
3
|
+
AUTHENTICATION_FAILED: 'AUTH_FAILED',
|
|
4
|
+
AUTHORIZATION_FAILED: 'FORBIDDEN',
|
|
5
|
+
NOT_FOUND: 'NOT_FOUND',
|
|
6
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
7
|
+
RATE_LIMIT_EXCEEDED: 'RATE_LIMIT',
|
|
8
|
+
SERVER_ERROR: 'SERVER_ERROR',
|
|
9
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
10
|
+
TIMEOUT: 'TIMEOUT',
|
|
11
|
+
WEBSOCKET_ERROR: 'WEBSOCKET_ERROR',
|
|
12
|
+
PARSE_ERROR: 'PARSE_ERROR',
|
|
13
|
+
SECURITY_ERROR: 'SECURITY_ERROR',
|
|
14
|
+
ANALYZER_ERROR: 'ANALYZER_ERROR',
|
|
15
|
+
AI_GENERATION_ERROR: 'AI_GENERATION_ERROR',
|
|
16
|
+
};
|
|
17
|
+
export const ERROR_MESSAGES = {
|
|
18
|
+
[ERROR_CODES.INVALID_CONFIG]: 'Invalid configuration provided',
|
|
19
|
+
[ERROR_CODES.AUTHENTICATION_FAILED]: 'Authentication failed. Check your API key',
|
|
20
|
+
[ERROR_CODES.AUTHORIZATION_FAILED]: 'Access denied. Insufficient permissions',
|
|
21
|
+
[ERROR_CODES.NOT_FOUND]: 'Resource not found',
|
|
22
|
+
[ERROR_CODES.VALIDATION_ERROR]: 'Request validation failed',
|
|
23
|
+
[ERROR_CODES.RATE_LIMIT_EXCEEDED]: 'Rate limit exceeded. Please retry later',
|
|
24
|
+
[ERROR_CODES.SERVER_ERROR]: 'Server error occurred',
|
|
25
|
+
[ERROR_CODES.NETWORK_ERROR]: 'Network connection failed',
|
|
26
|
+
[ERROR_CODES.TIMEOUT]: 'Request timed out',
|
|
27
|
+
[ERROR_CODES.WEBSOCKET_ERROR]: 'WebSocket connection error',
|
|
28
|
+
[ERROR_CODES.PARSE_ERROR]: 'Failed to parse response',
|
|
29
|
+
[ERROR_CODES.SECURITY_ERROR]: 'Security violation detected',
|
|
30
|
+
[ERROR_CODES.ANALYZER_ERROR]: 'Project analysis failed',
|
|
31
|
+
[ERROR_CODES.AI_GENERATION_ERROR]: 'AI workflow generation failed',
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/constants/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,cAAc,EAAE,gBAAgB;IAChC,qBAAqB,EAAE,aAAa;IACpC,oBAAoB,EAAE,WAAW;IACjC,SAAS,EAAE,WAAW;IACtB,gBAAgB,EAAE,kBAAkB;IACpC,mBAAmB,EAAE,YAAY;IACjC,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;IAClB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,mBAAmB,EAAE,qBAAqB;CAClC,CAAC;AAEX,MAAM,CAAC,MAAM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