@allma/cdk-integration-utils 1.0.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 ADDED
@@ -0,0 +1,25 @@
1
+ # Allma CDK Integration Utilities
2
+
3
+ This package contains shared CDK constructs and utilities intended for consumers of the Allma platform. It provides the necessary building blocks to integrate your own AWS resources, such as custom Lambda functions, with your Allma flows.
4
+
5
+ ## Purpose
6
+
7
+ The primary purpose of this package is to facilitate the `CUSTOM_LAMBDA_INVOKE` step type within Allma. It exports the necessary interfaces and utility functions to grant the Allma orchestrator the required IAM permissions to invoke your custom Lambdas.
8
+
9
+ ## Usage
10
+
11
+ To allow Allma to invoke a custom Lambda function, you need to use the `grantInvoke` utility from this package within your CDK stack.
12
+
13
+ ```typescript
14
+ import { grantInvoke } from '@allma/cdk-integration-utils';
15
+ import { MyCustomStack } from './my-custom-stack';
16
+
17
+ // In your CDK app file
18
+ const app = new cdk.App();
19
+ const myStack = new MyCustomStack(app, 'MyCustomStack');
20
+
21
+ // Grant the Allma orchestrator permission to invoke your function
22
+ grantInvoke(myStack, 'MyCustomFunction', {
23
+ allmaStackName: 'MyAllmaStack',
24
+ function: myStack.myFunction,
25
+ });
@@ -0,0 +1,42 @@
1
+ import { Construct } from 'constructs';
2
+ import { StepType } from '@allma/core-types';
3
+ export interface ExternalStepRegistrationProps {
4
+ /**
5
+ The name of the central Allma configuration table.
6
+ */
7
+ configTableName: string;
8
+ /**
9
+ The unique identifier for the step (e.g., 'my-module/my-step').
10
+ */
11
+ moduleIdentifier: string;
12
+ /**
13
+ The user-friendly name for the step in the UI.
14
+ */
15
+ displayName: string;
16
+ /**
17
+ A short description of what the step does.
18
+ */
19
+ description: string;
20
+ /**
21
+ The step's functional type (e.g., DATA_LOAD).
22
+ */
23
+ stepType: StepType;
24
+ /**
25
+ The ARN of the Lambda function that executes the step's logic.
26
+ */
27
+ lambdaArn: string;
28
+ /**
29
+ A default configuration object for the step instance when dragged onto the canvas.
30
+ It will be automatically merged with the moduleIdentifier.
31
+ */
32
+ defaultConfig: Record<string, any>;
33
+ }
34
+ /**
35
+ A reusable CDK utility to register an external step in the Allma DynamoDB registry.
36
+ Creates an AwsCustomResource that handles putting the item on deploy/update and deleting it on destroy.
37
+ @param scope The CDK Construct scope.
38
+ @param id The unique ID for this construct.
39
+ @param props The properties for the step registration.
40
+ */
41
+ export declare function createExternalStepRegistration(scope: Construct, id: string, props: ExternalStepRegistrationProps): void;
42
+ //# sourceMappingURL=cdk-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdk-utils.d.ts","sourceRoot":"","sources":["../src/cdk-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,MAAM,WAAW,6BAA6B;IAC1C;;MAEE;IACF,eAAe,EAAE,MAAM,CAAC;IACxB;;MAEE;IACF,gBAAgB,EAAE,MAAM,CAAC;IACzB;;MAEE;IACF,WAAW,EAAE,MAAM,CAAC;IACpB;;MAEE;IACF,WAAW,EAAE,MAAM,CAAC;IACpB;;MAEE;IACF,QAAQ,EAAE,QAAQ,CAAC;IACnB;;MAEE;IACF,SAAS,EAAE,MAAM,CAAC;IAClB;;;MAGE;IACF,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC;AACD;;;;;;EAME;AACF,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,6BAA6B,QAiDhH"}
@@ -0,0 +1,62 @@
1
+ import * as cdk from 'aws-cdk-lib';
2
+ import * as iam from 'aws-cdk-lib/aws-iam';
3
+ import { AwsCustomResource, PhysicalResourceId } from 'aws-cdk-lib/custom-resources';
4
+ import { RetentionDays } from 'aws-cdk-lib/aws-logs';
5
+ /**
6
+ A reusable CDK utility to register an external step in the Allma DynamoDB registry.
7
+ Creates an AwsCustomResource that handles putting the item on deploy/update and deleting it on destroy.
8
+ @param scope The CDK Construct scope.
9
+ @param id The unique ID for this construct.
10
+ @param props The properties for the step registration.
11
+ */
12
+ export function createExternalStepRegistration(scope, id, props) {
13
+ const { configTableName, moduleIdentifier, displayName, description, stepType, lambdaArn, defaultConfig } = props;
14
+ const registrationId = `EXTERNAL_STEP#${moduleIdentifier}`;
15
+ const stack = cdk.Stack.of(scope);
16
+ const sdkCall = {
17
+ service: 'DynamoDB',
18
+ action: 'putItem',
19
+ parameters: {
20
+ TableName: configTableName,
21
+ Item: {
22
+ PK: { S: registrationId },
23
+ SK: { S: 'METADATA' },
24
+ itemType: { S: 'ALLMA_EXTERNAL_STEP_REGISTRY' },
25
+ moduleIdentifier: { S: moduleIdentifier },
26
+ lambdaArn: { S: lambdaArn },
27
+ displayName: { S: displayName },
28
+ description: { S: description },
29
+ stepType: { S: stepType },
30
+ defaultConfig: { S: JSON.stringify({ moduleIdentifier, ...defaultConfig }) },
31
+ },
32
+ },
33
+ physicalResourceId: PhysicalResourceId.of(registrationId),
34
+ };
35
+ const deleteCall = {
36
+ service: 'DynamoDB',
37
+ action: 'deleteItem',
38
+ parameters: {
39
+ TableName: configTableName,
40
+ Key: {
41
+ PK: { S: registrationId },
42
+ SK: { S: 'METADATA' },
43
+ },
44
+ },
45
+ };
46
+ new AwsCustomResource(scope, id, {
47
+ onCreate: sdkCall,
48
+ onUpdate: sdkCall,
49
+ onDelete: deleteCall,
50
+ logRetention: RetentionDays.ONE_WEEK,
51
+ installLatestAwsSdk: true, // Ensures SDK is up-to-date for DynamoDB calls
52
+ policy: {
53
+ statements: [
54
+ new iam.PolicyStatement({
55
+ actions: ['dynamodb:PutItem', 'dynamodb:DeleteItem'],
56
+ resources: [`arn:aws:dynamodb:${stack.region}:${stack.account}:table/${configTableName}`],
57
+ }),
58
+ ],
59
+ },
60
+ });
61
+ }
62
+ //# sourceMappingURL=cdk-utils.js.map
@@ -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,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC,EAAE;aAC/E;SACJ;QACD,kBAAkB,EAAE,kBAAkB,CAAC,EAAE,CAAC,cAAc,CAAC;KAC5D,CAAC;IACF,MAAM,UAAU,GAAe;QAC3B,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,YAAY;QACpB,UAAU,EAAE;YACR,SAAS,EAAE,eAAe;YAC1B,GAAG,EAAE;gBACD,EAAE,EAAE,EAAE,CAAC,EAAE,cAAc,EAAE;gBACzB,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE;aACxB;SACJ;KACJ,CAAC;IACF,IAAI,iBAAiB,CAAC,KAAK,EAAE,EAAE,EAAE;QAC7B,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,UAAU;QACpB,YAAY,EAAE,aAAa,CAAC,QAAQ;QACpC,mBAAmB,EAAE,IAAI,EAAE,+CAA+C;QAC1E,MAAM,EAAE;YACJ,UAAU,EAAE;gBACR,IAAI,GAAG,CAAC,eAAe,CAAC;oBACpB,OAAO,EAAE,CAAC,kBAAkB,EAAE,qBAAqB,CAAC;oBACpD,SAAS,EAAE,CAAC,oBAAoB,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,UAAU,eAAe,EAAE,CAAC;iBAC5F,CAAC;aACL;SACJ;KACJ,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './cdk-utils.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './cdk-utils.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@allma/cdk-integration-utils",
3
+ "version": "1.0.1",
4
+ "description": "Shared CDK constructs and utilities for integrating external modules with the Allma serverless AI orchestration platform.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
13
+ "build": "npm run clean && tsc",
14
+ "dev": "tsc --watch",
15
+ "lint": "eslint ."
16
+ },
17
+ "keywords": [
18
+ "allma",
19
+ "cdk",
20
+ "constructs",
21
+ "aws",
22
+ "serverless",
23
+ "integration",
24
+ "ai",
25
+ "orchestration"
26
+ ],
27
+ "author": "@webjema",
28
+ "license": "Apache-2.0",
29
+ "homepage": "https://docs.allma.dev",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/ALLMA-dev/allma-core.git",
33
+ "directory": "packages/cdk-integration-utils"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "dependencies": {
39
+ "@allma/core-types": "1.0.1",
40
+ "aws-cdk-lib": "^2.200.1",
41
+ "constructs": "^10.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^22.15.30",
45
+ "eslint": "^9.8.0",
46
+ "typescript-eslint": "^8.0.0",
47
+ "rimraf": "^6.0.1",
48
+ "typescript": "^5.9.3"
49
+ }
50
+ }