@allma/core-sdk 1.0.1 → 1.0.3
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 +63 -0
- package/package.json +9 -4
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @allma/core-sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@allma/core-sdk)
|
|
4
|
+
[](https://github.com/ALLMA-dev/allma-core/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
This package provides a collection of shared utilities for building on the Allma platform. It is primarily designed to be used within AWS Lambda functions, such as custom step handlers (`CUSTOM_LAMBDA_INVOKE`) or Admin API handlers.
|
|
7
|
+
|
|
8
|
+
## What is Allma?
|
|
9
|
+
|
|
10
|
+
**Allma is a serverless, event-driven platform designed to build, execute, and manage complex, AI-powered automated workflows, known as `Flows`.** It acts as a "digital factory" for orchestrating sophisticated business processes, combining data integration, conditional logic, and advanced AI capabilities in a robust, scalable, and observable environment built on AWS.
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- **Structured JSON Logger:** A simple, level-based logger that outputs structured JSON for easy searching and analysis in Amazon CloudWatch Logs.
|
|
15
|
+
- **S3 Payload Offloading:** Utilities (`offloadIfLarge`, `hydrateInputFromS3Pointers`) to automatically handle large data payloads by storing them in S3, avoiding AWS service limits.
|
|
16
|
+
- **API Response Builders:** Helpers for creating standardized, consistent API Gateway responses.
|
|
17
|
+
- **Auth Middleware:** A higher-order function (`withAdminAuth`) to easily secure Admin API Lambda handlers with Cognito JWT authentication.
|
|
18
|
+
- **JSON Repair Utility:** A robust function (`extractAndParseJson`) to parse JSON from noisy LLM outputs.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @allma/core-sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Core Usage
|
|
27
|
+
|
|
28
|
+
**Example: Using the structured logger in a custom Lambda handler.**
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { log_info, log_error } from '@allma/core-sdk';
|
|
32
|
+
import { Handler } from 'aws-lambda';
|
|
33
|
+
|
|
34
|
+
export const handler: Handler = async (event, context) => {
|
|
35
|
+
const correlationId = context.awsRequestId; // Use a request ID for tracing
|
|
36
|
+
|
|
37
|
+
log_info('Handler invoked', { input: event }, correlationId);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
// ... Your business logic here ...
|
|
41
|
+
const result = { status: 'success' };
|
|
42
|
+
log_info('Processing completed successfully', { result }, correlationId);
|
|
43
|
+
return result;
|
|
44
|
+
} catch (error: any) {
|
|
45
|
+
log_error('An unexpected error occurred during processing', {
|
|
46
|
+
errorName: error.name,
|
|
47
|
+
errorMessage: error.message,
|
|
48
|
+
stack: error.stack
|
|
49
|
+
}, correlationId);
|
|
50
|
+
|
|
51
|
+
// Re-throw the error or handle it as needed
|
|
52
|
+
throw new Error('Processing failed');
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
58
|
+
|
|
59
|
+
This package is part of the `allma-core` monorepo. We welcome contributions! Please see our main [repository](https://github.com/ALLMA-dev/allma-core) and [contribution guide](https://docs.allma.dev/docs/community/contribution-guide) for more details.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
This project is licensed under the Apache-2.0 License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allma/core-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Core SDK with shared utilities (logging, auth, S3 utils) for building on the Allma serverless AI orchestration platform.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@allma/core-types": "^1.0.
|
|
37
|
+
"@allma/core-types": "^1.0.4",
|
|
38
38
|
"@aws-sdk/client-s3": "^3.500.0",
|
|
39
39
|
"@aws-sdk/client-secrets-manager": "^3.500.0",
|
|
40
40
|
"@aws-sdk/client-sns": "^3.500.0",
|
|
@@ -42,11 +42,16 @@
|
|
|
42
42
|
"@aws-sdk/client-ssm": "^3.500.0",
|
|
43
43
|
"@aws-sdk/client-sfn": "^3.500.0",
|
|
44
44
|
"@aws-sdk/lib-dynamodb": "^3.500.0",
|
|
45
|
-
"
|
|
45
|
+
"js-tiktoken": "^1.0.12",
|
|
46
|
+
"jsonpath-plus": "^9.0.0",
|
|
47
|
+
"jsonrepair": "^3.8.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"typescript": "^5.9.3",
|
|
49
51
|
"eslint": "^9.8.0",
|
|
50
52
|
"typescript-eslint": "^8.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"zod": "^3.22.4"
|
|
51
56
|
}
|
|
52
|
-
}
|
|
57
|
+
}
|