platform icon indicating copy to clipboard operation
platform copied to clipboard

feat: optional object datastore

Open ankita-p17 opened this issue 9 months ago • 1 comments

This is linked to the issue 1162 to support addition object storage in CREDEBL.

  1. Created new storage service library which supports two providers
  2. Implemented for minio and refactored for aws S3.

Other improvements -

  1. Fixed lint issues in existing code - duplicate & unused common constants, unused imports.

ankita-p17 avatar May 14 '25 04:05 ankita-p17

@coderabbitai review

GHkrishna avatar Jun 06 '25 07:06 GHkrishna

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Jun 06 '25 07:06 coderabbitai[bot]

Walkthrough

Introduces a new storage abstraction (@credebl/storage) supporting MinIO and S3, replaces AwsService across apps, updates environment variables for storage and branding, removes libs/aws, adjusts several modules and services to use StorageService, changes connection invitation retrieval (first vs many), tweaks agent health endpoint, and refactors provisioning scripts.

Changes

Cohort / File(s) Summary
Environment config
.env.demo
Add MinIO and FILE_STORAGE_PROVIDER vars; rename buckets; remove SHORTENED_URL_DOMAIN; update POWERED_BY, POWERED_BY_URL, PUBLIC_PLATFORM_SUPPORT_EMAIL; enable VERIFIER_KEYCLOAK_MANAGEMENT_CLIENT_SECRET.
New Storage library
libs/storage/package.json, libs/storage/src/index.ts, libs/storage/src/storage.module.ts, libs/storage/src/storage.service.ts, libs/storage/src/storage.service.spec.ts, libs/storage/src/storage.interface.ts, libs/storage/src/providers/minio.provider.ts, libs/storage/src/providers/s3.provider.ts, libs/storage/tsconfig*.json
Add pluggable storage module/service with S3 and MinIO providers, interfaces, tests, and build config; expose via index.
Remove AWS library
libs/aws/src/aws.service.ts, libs/aws/src/aws.module.ts, libs/aws/src/index.ts
Remove AwsService, AwsModule, and re-exports.
Root config mapping
package.json, tsconfig.json
Map @credebl/storage path/alias for TS and Jest.
API Gateway: switch to StorageService
apps/api-gateway/src/issuance/issuance.controller.ts, .../issuance/issuance.module.ts, .../organization/organization.module.ts, .../user/user.controller.ts, .../user/user.module.ts, .../webhook/webhook.module.ts
Replace AwsService DI with StorageService and update upload calls; minor logging addition.
Issuance app
apps/issuance/src/issuance.module.ts, apps/issuance/src/issuance.service.ts, apps/issuance/src/issuance.repository.ts
Swap AwsService→StorageService; update file get/upload logic; minor log formatting; repo message formatting only.
Organization app
apps/organization/src/organization.module.ts, apps/organization/src/organization.service.ts
Replace AwsService with StorageService; rename upload method; use ORG_LOGO_BUCKET and CommonConstants.ENCODING; add logo constants; update call sites.
User app wiring cleanup
apps/user/src/fido/fido.module.ts, apps/user/src/user.module.ts, apps/user/src/user.service.ts
Replace/remove AwsService providers and related DI; remove userDevicesRepository from constructor.
Utility app
apps/utility/src/utilities.module.ts, apps/utility/src/utilities.service.ts
Import StorageModule; switch store/get/delete to StorageService; storeObject now returns URL string from storage provider.
Agent service
apps/agent-service/src/agent-service.service.ts, apps/agent-service/src/repositories/agent-service.repository.ts
Update health endpoint constant; add type annotation for whereClause; add eslint-disable for transaction.
Connection service behavior
apps/connection/src/connection.repository.ts, apps/connection/src/connection.service.ts
Change getInvitationDidByOrgId to return first (ordered) record instead of array; adjust service to use single legacyInvitationDid; minor formatting.
Agent provisioning
apps/agent-provisioning/AFJ/scripts/fargate.sh, apps/agent-provisioning/src/agent-provisioning.service.ts
Major script overhaul: ALB/TG/security groups, dynamic ports, endpoints via ALB, task/service config changes, token extraction; service file string formatting only.
Cloud wallet
apps/cloud-wallet/src/cloud-wallet.service.ts
Build URL with threadId as query param in template; formatting adjustments.
Ledger schema
apps/ledger/src/schema/enum/schema.enum.ts, apps/ledger/src/schema/interfaces/schema-payload.interface.ts, apps/ledger/src/schema/repositories/schema.repository.ts
Formatting in enums/interfaces; remove unused import in repository.
Common constants
libs/common/src/common.constant.ts
Remove PERMISSION_ROLE_MGMT; add ENCODING='base64'.
Validations (style)
libs/validations/*
Whitespace/formatting fixes; add missing class brace in keyword.ts; no logic changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Module as Feature Module
  participant Service as StorageService
  participant Provider as Provider (S3/MinIO)
  note over Service,Provider: Provider selected via FILE_STORAGE_PROVIDER

  Client->>Module: Upload request (file/body)
  Module->>Service: uploadCsvFile / uploadFileToBucket
  Service->>Provider: uploadFile/storeObject
  Provider-->>Service: URL or ack
  Service-->>Module: URL/void
  Module-->>Client: Response
sequenceDiagram
  autonumber
  participant ConnSvc as ConnectionService
  participant Repo as ConnectionRepository
  Note over ConnSvc,Repo: Reuse connection flow

  ConnSvc->>Repo: getInvitationDidByOrgId(orgId)
  Repo-->>ConnSvc: first agent_invitations (ordered by createDateTime)
  alt IsReuseConnection
    ConnSvc->>ConnSvc: legacyInvitationDid = data.invitationDid
    ConnSvc-->>ConnSvc: Use legacyInvitationDid
  else New invitation
    ConnSvc->>ConnSvc: Proceed to create new invitation
  end
sequenceDiagram
  autonumber
  participant APIGW as API Gateway
  participant Agent as Agent Service
  Note over APIGW,Agent: Health check endpoint change

  APIGW->>Agent: GET /agent/get-endpoint (URL_AGENT_GET_ENDPOINT)
  Agent-->>APIGW: Health data

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Suggested labels

feature

Suggested reviewers

  • RinkalBhojani
  • GHkrishna

Poem

In burrows of bytes I stash and store,
MinIO moonlight, S3 at the door.
Buckets renamed, the streams now sing,
A carrot of keys on timestamped string. 🥕
Agents report, connections renew—
Thump-thump! New storage, sleek and true.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately captures the primary enhancement introduced by this PR, namely support for an optional object datastore feature. It is clear, concise, and directly related to the overall addition of a new storage service library with MinIO and AWS S3 providers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch feat/optional-object-datastore

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jun 06 '25 07:06 coderabbitai[bot]

[!CAUTION] No docstrings were generated.

coderabbitai[bot] avatar Jun 06 '25 07:06 coderabbitai[bot]

@ankita-p17 you think the CodeRabbit reviews are useful?

ajile-in avatar Jun 09 '25 19:06 ajile-in

@ankita-p17 Do we have any further updates on this?

RinkalBhojani avatar Jul 16 '25 07:07 RinkalBhojani

@ankita-p17 - Any update or issue for this feature?

RinkalBhojani avatar Aug 20 '25 07:08 RinkalBhojani

Closing this PR as it has some unsigned commits from upstream which are resolved later. Created new PR for this implementation - https://github.com/credebl/platform/pull/1484

ankita-p17 avatar Oct 15 '25 06:10 ankita-p17