-
Notifications
You must be signed in to change notification settings - Fork 79
feat(chore): kiro power added #2433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2148c9
Kiro Power added
4891266
Merge branch 'master' into feature/kiro-power
yeshamavani 0f32e00
docs(readme): update readme
vaibhavbhalla2505 0dec05b
Merge branch 'master' into feature/kiro-power
yeshamavani 84eab7c
Merge branch 'master' into feature/kiro-power
yeshamavani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # ARC by SourceLoop - Kiro Powers | ||
|
|
||
| This directory contains [Kiro Powers](https://kiro.dev/powers/) for the ARC microservice catalog. Each power provides specialized context and tools to Kiro agents for working with SourceLoop services. | ||
|
|
||
| ## Available Powers | ||
|
|
||
| | Power | Description | | ||
| |-------|-------------| | ||
| | [`sourceloop`](./sourceloop/) | Core ARC framework, CLI scaffolding, and LoopBack 4 patterns | | ||
| | [`sourceloop-authentication-service`](./sourceloop-authentication-service/) | Multi-tenant authentication with OAuth, MFA, SAML, JWT | | ||
| | [`sourceloop-oidc-service`](./sourceloop-oidc-service/) | OpenID Connect identity server | | ||
| | [`sourceloop-audit-service`](./sourceloop-audit-service/) | Audit logging with S3 archival | | ||
| | [`sourceloop-notification-service`](./sourceloop-notification-service/) | Multi-channel notifications (email, SMS, push, WebSocket) | | ||
| | [`sourceloop-chat-service`](./sourceloop-chat-service/) | Real-time chat messaging with groups | | ||
| | [`sourceloop-in-mail-service`](./sourceloop-in-mail-service/) | Incoming email management | | ||
| | [`sourceloop-video-conferencing-service`](./sourceloop-video-conferencing-service/) | Video conferencing with Vonage and Twilio | | ||
| | [`sourceloop-payment-service`](./sourceloop-payment-service/) | Payments via PayPal, Stripe, Razorpay | | ||
| | [`sourceloop-bpmn-service`](./sourceloop-bpmn-service/) | BPMN workflows with Camunda | | ||
| | [`sourceloop-task-service`](./sourceloop-task-service/) | Event-driven task management (Kafka/SQS/HTTP) | | ||
| | [`sourceloop-scheduler-service`](./sourceloop-scheduler-service/) | Job scheduling and cron tasks | | ||
| | [`sourceloop-search-service`](./sourceloop-search-service/) | Full-text search and filtering | | ||
| | [`sourceloop-survey-service`](./sourceloop-survey-service/) | Surveys, questionnaires, and feedback | | ||
| | [`sourceloop-feature-toggle-service`](./sourceloop-feature-toggle-service/) | Feature flags and toggles | | ||
| | [`sourceloop-user-tenant-service`](./sourceloop-user-tenant-service/) | User and tenant management with RBAC | | ||
| | [`sourceloop-reporting-service`](./sourceloop-reporting-service/) | Report generation with S3 export | | ||
|
|
||
| ## Installing a Power | ||
|
|
||
| In Kiro IDE: | ||
|
|
||
| 1. Open the Powers panel | ||
| 2. Click **Add power from Local Path** | ||
| 3. Select the power directory | ||
|
|
||
| ## Power Structure | ||
|
|
||
| Each power contains: | ||
|
|
||
| ``` | ||
| power-name/ | ||
| ├── POWER.md # Metadata, documentation, and agent guidance | ||
|
vaibhavbhalla2505 marked this conversation as resolved.
|
||
| └── mcp.json # MCP server configuration (points to @sourceloop/cli) | ||
| ``` | ||
|
|
||
| The core `sourceloop` power also includes steering files: | ||
|
|
||
|
vaibhavbhalla2505 marked this conversation as resolved.
|
||
| ``` | ||
| sourceloop/ | ||
| ├── POWER.md | ||
| ├── mcp.json | ||
| └── steering/ | ||
| ├── loopback4-patterns.md # LoopBack 4 conventions and patterns | ||
| └── cli-usage.md # ARC CLI command reference | ||
| ``` | ||
|
|
||
| ## MCP Server | ||
|
|
||
| All powers reference the `@sourceloop/cli` MCP server, which provides tools for: | ||
|
|
||
| - Scaffolding monorepos and microservices | ||
| - Adding AWS CDK deployment support | ||
| - Generating Angular and React frontends | ||
| - Updating project dependencies | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,246 @@ | ||
| --- | ||
| name: 'sourceloop-audit-service' | ||
| displayName: 'SourceLoop Audit Service' | ||
| description: 'Track and record user actions with audit logging - inserts, updates, deletes with S3 archival and CSV export capabilities' | ||
| keywords: | ||
| [ | ||
| 'audit', | ||
| 'logging', | ||
| 'audit-trail', | ||
| 'compliance', | ||
| 'tracking', | ||
| 'sourceloop', | ||
| 's3-archival', | ||
| ] | ||
| author: 'SourceFuse' | ||
| --- | ||
|
|
||
| # SourceLoop Audit Service | ||
|
|
||
| ## Overview | ||
|
|
||
| A LoopBack 4 microservice for audit logging that tracks and records user actions including inserts, updates, and deletes. Supports S3 archival for long-term storage and CSV export capabilities. | ||
|
|
||
| **Key capabilities:** | ||
|
|
||
| - **Action Tracking**: Record inserts, updates, and deletes across services | ||
| - **S3 Archival**: Archive audit logs to AWS S3 for compliance | ||
| - **CSV Export**: Export audit data as CSV via ExcelJS | ||
| - **Repository Mixin**: Drop-in audit logging for any repository | ||
| - **Multi-source Retrieval**: Query from both database and archive | ||
|
|
||
| ## Available MCP Servers | ||
|
|
||
| ### sourceloop-cli | ||
|
|
||
| **Package:** `@sourceloop/cli` | ||
| **Connection:** Local stdio via npx | ||
|
|
||
| Use the `microservice` tool with `--baseOnService --baseService=audit-service` to scaffold a new audit service instance. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```typescript | ||
| import {AuditServiceComponent} from '@sourceloop/audit-service'; | ||
| import {BootMixin} from '@loopback/boot'; | ||
| import {ApplicationConfig} from '@loopback/core'; | ||
| import {RestApplication} from '@loopback/rest'; | ||
|
|
||
| export class MyApplication extends BootMixin(RestApplication) { | ||
| constructor(options: ApplicationConfig = {}) { | ||
| super(options); | ||
|
|
||
| // Validate required environment variables | ||
| this.validateAuditEnv(); | ||
|
|
||
| try { | ||
| this.component(AuditServiceComponent); | ||
| console.log('✅ Audit service loaded successfully'); | ||
| } catch (error) { | ||
| console.error('❌ Failed to initialize audit service:', error.message); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| private validateAuditEnv() { | ||
| const required = ['DB_HOST', 'DB_PORT', 'DB_DATABASE']; | ||
| const missing = required.filter(env => !process.env[env]); | ||
| if (missing.length > 0) { | ||
| throw new Error( | ||
| `Missing required environment variables: ${missing.join(', ')}`, | ||
| ); | ||
| } | ||
|
|
||
| // Validate S3 config if archival is enabled | ||
| if (process.env.ENABLE_ARCHIVAL === 'true') { | ||
| const s3Required = [ | ||
| 'AWS_ACCESS_KEY_ID', | ||
| 'AWS_SECRET_ACCESS_KEY', | ||
| 'S3_BUCKET_NAME', | ||
| ]; | ||
| const s3Missing = s3Required.filter(env => !process.env[env]); | ||
| if (s3Missing.length > 0) { | ||
| throw new Error( | ||
| `S3 archival enabled but missing: ${s3Missing.join(', ')}`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Key Models | ||
|
|
||
| - **AuditLog** - Core audit log entry with action, actor, timestamp, before/after data | ||
| - **CustomFilter** - Custom query filters for audit retrieval | ||
| - **MappingLog** - Entity mapping audit records | ||
| - **Job** - Background archival job tracking | ||
|
|
||
| ## Key Controllers | ||
|
|
||
| - **AuditController** - CRUD operations for audit logs, export, archival | ||
|
|
||
| ## Common Workflows | ||
|
|
||
| ### Workflow 1: Setup Audit Service | ||
|
|
||
| ```bash | ||
| npx @sourceloop/cli microservice my-audit \ | ||
| --baseOnService \ | ||
| --baseService=audit-service \ | ||
| --datasourceName=auditdb \ | ||
| --datasourceType=postgresql \ | ||
|
vaibhavbhalla2505 marked this conversation as resolved.
|
||
| --includeMigrations | ||
|
|
||
| # After scaffolding, add these verification steps: | ||
| cd my-audit | ||
|
|
||
| # Test database connection | ||
| npm run db:ping | ||
|
|
||
| # Run migrations and verify | ||
| npm run db:migrate | ||
| npm run db:migrate:status | ||
|
|
||
| # Verify service starts | ||
| npm run build | ||
| npm start & | ||
| curl http://localhost:3000/ping | ||
| ``` | ||
|
|
||
| **Critical validation checklist:** | ||
|
|
||
| - ✅ Database connectivity verified | ||
| - ✅ All migrations applied successfully | ||
| - ✅ Service starts without errors | ||
| - ✅ Health endpoint responds | ||
|
|
||
| ### Workflow 2: Add Audit Logging to a Repository | ||
|
|
||
| Use the audit mixin from `@sourceloop/audit-log`: | ||
|
|
||
| ```typescript | ||
| import {AuditRepositoryMixin} from '@sourceloop/audit-log'; | ||
|
|
||
| export class MyEntityRepository extends AuditRepositoryMixin< | ||
| MyEntity, | ||
| typeof MyEntity.prototype.id, | ||
| MyEntityRelations | ||
| >(DefaultCrudRepository) { | ||
| constructor(@inject('datasources.db') dataSource: DataSource) { | ||
| super(MyEntity, dataSource); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| ### Do: | ||
|
|
||
| - Archive old audit logs to S3 for cost-effective long-term storage | ||
| - Use the repository mixin for automatic audit logging | ||
| - Index audit logs by actor, action type, and timestamp | ||
| - Configure retention policies for compliance requirements | ||
|
|
||
| ### Don't: | ||
|
|
||
| - Store sensitive data (passwords, tokens) in audit log details | ||
| - Skip audit logging for delete operations | ||
| - Query large audit datasets without filters - use pagination | ||
|
|
||
| ## Testing | ||
|
|
||
| ### Unit Tests | ||
|
|
||
| ```typescript | ||
| import {createStubInstance, expect} from '@loopback/testlab'; | ||
| import {AuditLogRepository} from '../repositories'; | ||
| import {MyEntityRepository} from '../repositories'; | ||
|
|
||
| describe('AuditRepositoryMixin', () => { | ||
| let repository: MyEntityRepository; | ||
| let auditRepo: sinon.SinonStubbedInstance<AuditLogRepository>; | ||
|
|
||
| beforeEach(() => { | ||
| auditRepo = createStubInstance(AuditLogRepository); | ||
| repository = new MyEntityRepository(dataSource, auditRepo); | ||
| }); | ||
|
|
||
| it('should create audit log on entity creation', async () => { | ||
| const entity = {name: 'Test Entity'}; | ||
| await repository.create(entity); | ||
|
|
||
| sinon.assert.calledOnce(auditRepo.create); | ||
| sinon.assert.calledWith(auditRepo.create, sinon.match({ | ||
| action: 'CREATE', | ||
| entityName: 'MyEntity', | ||
| })); | ||
| }); | ||
| }); | ||
| ``` | ||
|
|
||
| ### Integration Tests | ||
|
|
||
| ```typescript | ||
| import {Client, expect} from '@loopback/testlab'; | ||
| import {AuditApplication} from '../application'; | ||
|
|
||
| describe('Audit Logs API', () => { | ||
| let app: AuditApplication; | ||
| let client: Client; | ||
|
|
||
| before('setupApplication', async () => { | ||
| ({app, client} = await setupApplication()); | ||
| }); | ||
|
|
||
| it('GET /audit-logs returns paginated results', async () => { | ||
| const res = await client.get('/audit-logs').expect(200); | ||
|
|
||
| expect(res.body).to.be.Array(); | ||
| expect(res.headers).to.have.property('x-total-count'); | ||
| }); | ||
| }); | ||
| ``` | ||
|
|
||
| ### Testing Best Practices | ||
|
|
||
| - Test audit log creation for all CRUD operations | ||
| - Verify audit logs capture user identity (actedBy field) | ||
| - Test audit log queries with pagination and filters | ||
| - Ensure sensitive data is not logged in before/after fields | ||
| - Test audit log retention and archival processes | ||
|
|
||
| ## Database | ||
|
|
||
| Requires PostgreSQL. Run migrations: | ||
|
|
||
| ```bash | ||
| npx db-migrate up --config database.json --migrations-dir migrations | ||
| ``` | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - `@sourceloop/core` | ||
| - `@sourceloop/audit-log` | ||
| - `exceljs` (CSV export) | ||
| - `csvtojson` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
|
vaibhavbhalla2505 marked this conversation as resolved.
|
||
| "mcpServers": { | ||
| "sourceloop-cli": { | ||
| "command": "npx", | ||
| "args": ["-y", "@sourceloop/cli", "mcp"], | ||
| "env": {} | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.