Skip to content

Improve setup documentation, sample artifacts, and Redis/TLS configuration#596

Open
Shamly-Shanawaz wants to merge 5 commits intowso2:mainfrom
Shamly-Shanawaz:main
Open

Improve setup documentation, sample artifacts, and Redis/TLS configuration#596
Shamly-Shanawaz wants to merge 5 commits intowso2:mainfrom
Shamly-Shanawaz:main

Conversation

@Shamly-Shanawaz
Copy link
Contributor

@Shamly-Shanawaz Shamly-Shanawaz commented Dec 16, 2025

Purpose

This PR introduces the following changes:

  • Reworked README.md to provide clearer prerequisites, config file setup, DB creation steps, and notes on handling TLS / self-signed certificate errors.
  • Added new sample API content for CountriesAPI and LeisureActivitiesAPI, plus updated/added artifact scripts to seed org, API, and theme data.
  • Updated Redis connection helper/service and sample_config.json to better reflect current Redis/TLS configuration options.
  • Removed the legacy docs/InstallationGuide.md now that the main README covers installation and local setup.

Summary by CodeRabbit

  • New Features

    • Redis connectivity is now optional and can be disabled via configuration
    • Added new sample APIs including GraphQL and SOAP endpoint examples
  • Documentation

    • README restructured with comprehensive step-by-step setup instructions
    • Removed outdated installation guide documentation
  • Configuration

    • Updated sample configuration with new defaults

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Walkthrough

The pull request consolidates setup documentation, enhances database seeding workflows for APIs and organizations with metadata and labeling, introduces a new theme asset ingestion script, updates database schema cleanup operations, refactors Redis service to support optional enable/disable states, and adjusts configuration defaults to disable Redis and enable HTTP advanced features.

Changes

Cohort / File(s) Summary
Documentation
README.md, docs/InstallationGuide.md
Comprehensive rewrite of README Prerequisites and Setup sections with detailed step-by-step instructions, JSON examples, and structured workflows. Removal of dedicated InstallationGuide.md.
API Content Definitions
artifacts/default/apiContent/CountriesAPI/content/apiDefinition.json, artifacts/default/apiContent/LeisureActivitiesAPI/content/apiDefinition.json
New OpenAPI 3.0.3 specifications for GraphQL (Countries) and SOAP (LeisureActivities) endpoints with request/response schemas.
Database Schema
artifacts/script.sql
Updated table drop sequence: removed DP\_SDK\_JOBS, added DP\_APP\_KEY\_MAPPING and DP\_SDK\_JOB.
Seeding Scripts
artifacts/api_data.sh, artifacts/org_data.sh
Enhanced data insertion with new metadata fields (STATUS, API\_HANDLE, CONTENT\_TYPE), default view and label creation with linking, and ON CONFLICT clauses for idempotency.
New Theme Asset Script
artifacts/theme_data.sh
New end-to-end script for ingesting theme assets from base content, organization overlays, and ZIP archives; supports asset type classification, PostgreSQL large object imports, and conditional reset.
Configuration
sample_config.json
Changed Redis enabled from true to false, HTTP advanced from false to true, and set default identity provider clientId placeholder.
Redis Service
src/services/redisService.js, src/services/redisConnectionHelper.js
Added enabled flag to conditionally activate Redis; guards early returns across init, publish, store, and retrieve methods; added TLS support with optional conditional configuration.

Sequence Diagram(s)

sequenceDiagram
    participant Admin as Admin/User
    participant Script as theme_data.sh
    participant FS as File System
    participant DB as PostgreSQL
    
    Admin->>Script: Execute with config.json
    Script->>Script: Parse DB connection & fetch VIEW_ID
    
    rect rgb(240, 248, 255)
    Note over Script,DB: Process Base Theme Directory
    Script->>FS: Read base content files
    Script->>Script: Classify by type (style, layout, etc.)
    Script->>DB: Create LO objects & upsert DP_ORGANIZATION_ASSETS
    end
    
    rect rgb(240, 248, 255)
    Note over Script,FS: Process Optional Org Overlay (if exists)
    Script->>FS: Read org-specific overrides
    Script->>DB: Upsert overlaid assets
    end
    
    rect rgb(240, 248, 255)
    Note over Script,FS: Process Optional Theme ZIP (if exists)
    Script->>Script: Extract ZIP via Python
    Script->>FS: Write to temp directory
    Script->>FS: Read temp theme files
    Script->>DB: Create LO objects & upsert assets
    end
    
    Script->>Admin: Return completion status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

🐰 From config files to schemas bright,
Theme seeds planted, views just right,
APIs dance with labels new,
Redis optional, light and true,
The setup warren feels complete—
Configuration's taste is sweet! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description addresses Purpose and Issues but is missing most required sections from the template (Goals, Approach, User stories, Release note, Documentation, etc.). Complete the PR description by adding Goals, Approach, Release note, Documentation impact statement, and other relevant sections from the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: improved setup documentation, new sample artifacts, and Redis/TLS configuration updates.
✨ Finishing touches
  • 📝 Generate docstrings

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

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

@Shamly-Shanawaz Shamly-Shanawaz marked this pull request as ready for review January 6, 2026 07:52
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/services/redisConnectionHelper.js (1)

23-23: Fix config loading pattern inconsistency to use .json extension.

The config is loaded using require(process.cwd() + '/config') without the .json extension, while most other files in the codebase use require(process.cwd() + '/config.json'). This inconsistency affects not only this file but also src/services/redisService.js, src/services/sdkJobService.js, src/controllers/devportalController.js, and src/controllers/applicationsContentController.js. In Node.js, these patterns resolve differently—require('./config') may load config.js before config.json—potentially causing unexpected behavior if both files exist. Standardize all config loading to use the .json extension for consistency.

src/services/redisService.js (1)

23-23: Standardize config loading pattern to use /config.json extension.

This file uses require(process.cwd() + '/config') without the .json extension, but the majority of the codebase uses require(process.cwd() + '/config.json'). Files affected by this inconsistency:

  • src/services/redisService.js
  • src/services/redisConnectionHelper.js
  • src/services/sdkJobService.js
  • src/controllers/devportalController.js
  • src/controllers/applicationsContentController.js

Align these files with the standard .json extension pattern used across the rest of the codebase.

🤖 Fix all issues with AI Agents
In @artifacts/api_data.sh:
- Around line 133-149: The INSERT_QUERY construction interpolates FILE_NAME
directly into the SQL, risking injection; before building INSERT_QUERY sanitize
FILE_NAME by escaping single quotes (replace ' with ''), assign that to a new
variable (e.g., ESCAPED_FILE_NAME) and use that variable in the VALUES clause
instead of FILE_NAME; ensure any other interpolated values used in SQL (e.g.,
TARGET_TYPE, API_ID) are similarly validated/escaped or passed as
parameters/psql variables to protect DP_API_CONTENT inserts referencing
lo_get($OID).

In @artifacts/org_data.sh:
- Line 141: The INSERT_QUERY builds SQL by interpolating unescaped FILE_NAME
(and potentially FILE_TYPE/FILE_PATH) which allows SQL injection; add a
sanitizer like the existing sql_escape function (or implement one that doubles
single quotes) and use it when constructing INSERT_QUERY (e.g.,
escaped_FILE_NAME = sql_escape "$FILE_NAME") and replace direct variables with
their escaped counterparts in the INSERT_QUERY string, ensuring any other
file-derived variables (FILE_TYPE, FILE_PATH) are similarly escaped or
parameterized.

In @artifacts/script.sql:
- Around line 12-13: The DROP order is incorrect: DP_APP_KEY_MAPPING and
DP_SDK_JOB are dropped after DP_ORGANIZATION is dropped with CASCADE, making
those explicit DROP statements redundant and confusing; move the DROP TABLE IF
EXISTS "DP_APP_KEY_MAPPING" and DROP TABLE IF EXISTS "DP_SDK_JOB" so they
execute before the DROP TABLE ... "DP_ORGANIZATION" ... CASCADE statement to
enforce an explicit child-before-parent drop ordering and avoid relying on
CASCADE to remove child tables.

In @README.md:
- Around line 157-180: The section "Add a third-party API (Admin APIs)" uses
level-4 headings (####) for its subsections which breaks the document hierarchy;
change the headings "1) Configure a provider (control plane)", "2) Create an API
(metadata + API definition upload)" and the "Upload API landing page content
(templates/assets)" heading from #### to ### so the subsections are proper h3
headings and apply the same change to the other instances noted in the comment.
🧹 Nitpick comments (3)
artifacts/script.sql (1)

219-231: Consider adding indexes for the new tables.

The new DP_APP_KEY_MAPPING and DP_SDK_JOB tables may benefit from indexes on frequently queried columns, particularly foreign key columns and status fields that are likely used in WHERE clauses.

🔎 Suggested indexes for query performance

Add these indexes after line 265:

-- Indexes for DP_APP_KEY_MAPPING
CREATE INDEX idx_app_key_mapping_app_id ON "DP_APP_KEY_MAPPING"("APP_ID");
CREATE INDEX idx_app_key_mapping_org_id ON "DP_APP_KEY_MAPPING"("ORG_ID");

-- Indexes for DP_SDK_JOB
CREATE INDEX idx_sdk_job_app_id ON "DP_SDK_JOB"("APP_ID");
CREATE INDEX idx_sdk_job_org_id ON "DP_SDK_JOB"("ORG_ID");
CREATE INDEX idx_sdk_job_status ON "DP_SDK_JOB"("JOB_STATUS");
CREATE INDEX idx_sdk_job_created_at ON "DP_SDK_JOB"("CREATED_AT");

The JOB_STATUS and CREATED_AT indexes are particularly useful for querying pending/in-progress jobs and job history queries.

Also applies to: 234-247

sample_config.json (1)

9-9: Document HTTP setting implications.

Changing advanced.http to true enables HTTP mode. Since this is a sample configuration file, ensure that documentation clearly warns users that this setting should be false in production environments to enforce HTTPS.

artifacts/theme_data.sh (1)

174-181: Minor: folder naming inconsistency between styles/* and file extension check.

The case statement filters for styles/* but file_type_for checks for *.css extension. This works correctly, but note that non-CSS files in styles/ would be classified as "image" by the fallback. If that's intentional, consider adding a comment.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d8e1cbf and 2489f83.

📒 Files selected for processing (11)
  • README.md
  • artifacts/api_data.sh
  • artifacts/default/apiContent/CountriesAPI/content/apiDefinition.json
  • artifacts/default/apiContent/LeisureActivitiesAPI/content/apiDefinition.json
  • artifacts/org_data.sh
  • artifacts/script.sql
  • artifacts/theme_data.sh
  • docs/InstallationGuide.md
  • sample_config.json
  • src/services/redisConnectionHelper.js
  • src/services/redisService.js
💤 Files with no reviewable changes (1)
  • docs/InstallationGuide.md
🧰 Additional context used
🧬 Code graph analysis (2)
src/services/redisService.js (2)
src/services/redisConnectionHelper.js (1)
  • config (23-23)
src/services/sdkJobService.js (1)
  • config (28-28)
src/services/redisConnectionHelper.js (2)
src/controllers/apiContentController.js (1)
  • config (20-20)
src/services/sdkJobService.js (1)
  • config (28-28)
🪛 Checkov (3.2.334)
artifacts/default/apiContent/LeisureActivitiesAPI/content/apiDefinition.json

[high] 1-40: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)


[high] 1-40: Ensure that security operations is not empty.

(CKV_OPENAPI_5)

artifacts/default/apiContent/CountriesAPI/content/apiDefinition.json

[high] 1-45: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)


[high] 1-45: Ensure that security operations is not empty.

(CKV_OPENAPI_5)

🪛 LanguageTool
README.md

[style] ~186-~186: To form a complete sentence, be sure to include a subject.
Context: ...+ definition file) Notes: - apiType can be REST, AsyncAPI, GraphQL, or `S...

(MISSING_IT_THERE)

🪛 markdownlint-cli2 (0.18.1)
README.md

170-170: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🔇 Additional comments (21)
src/services/redisConnectionHelper.js (4)

30-33: LGTM! Early exit for disabled Redis.

The early guard correctly prevents connection attempts when Redis is disabled, entering offline mode immediately. This aligns with the feature toggle design.


49-52: LGTM! TLS configuration correctly applied.

The TLS options are conditionally constructed and spread into the Redis config only when tlsEnabled is true. The rejectUnauthorized defaults to true (secure by default) unless explicitly set to false in config, which is good security practice.

Also applies to: 67-67


302-304: LGTM! Consistent disabled check.

The early guard in performFileOnlyConnection matches the pattern in performConnection, returning false when Redis is disabled.


314-317: LGTM! TLS configuration duplicated correctly.

The TLS configuration logic is identical to the main connection path (lines 49-52, 67), ensuring consistent behavior for file-only reconnections.

Also applies to: 332-332

sample_config.json (2)

73-73: LGTM! Appropriate placeholder for sample config.

Using <CLIENT_ID> as a placeholder clearly indicates that users need to replace this value with their actual client ID.


133-133: LGTM! Redis disabled by default.

Setting redis.enabled to false in the sample config is appropriate, as it allows the application to run without Redis dependencies during initial setup and development.

src/services/redisService.js (5)

42-45: LGTM! Robust enabled flag initialization.

The enabled flag correctly prioritizes the environment variable (REDIS_ENABLED) over the config file, with sensible parsing of truthy values ('true' or '1'). The default when neither is set treats Redis as enabled unless explicitly disabled in config.


52-59: LGTM! Conditional Redis initialization.

The conditional initialization prevents unnecessary connection attempts when Redis is disabled, improving startup performance and reducing error logs.


62-67: LGTM! Consistent early exit pattern.

The init() method correctly returns a resolved promise when disabled, maintaining the async interface without attempting connection.


147-149: LGTM! Consistent disabled guards across methods.

All methods consistently return false or null when Redis is disabled, providing predictable behavior without throwing errors. This allows the application to gracefully degrade functionality when Redis is unavailable.

Also applies to: 218-220, 357-359, 401-403, 439-441, 471-473, 495-497


258-260: This inconsistency is not problematic in practice.

While storeFile() throws an error when disabled and storeFileWithRetry() returns false, the only direct call to storeFile() (line 225) is internal to storeFileWithRetry(), which guards against the disabled state with its own check at lines 218-219. The exception is properly caught and handled in the try-catch block. No external direct callers of storeFile() exist in the codebase, so the different error-handling approaches do not create inconsistency for callers.

artifacts/default/apiContent/CountriesAPI/content/apiDefinition.json (1)

1-45: Sample OpenAPI spec looks good; security field is optional for seed data.

The static analysis flags the missing global security field (CKV_OPENAPI_4/5). Since this is sample seed data for local development demonstration, this is acceptable. If these specs are ever used in production or as templates for real APIs, consider adding a security scheme.

Example security addition (optional)
   "paths": {
     "/graphql": {
       ...
     }
-  }
+  },
+  "components": {
+    "securitySchemes": {
+      "bearerAuth": {
+        "type": "http",
+        "scheme": "bearer"
+      }
+    }
+  },
+  "security": [
+    { "bearerAuth": [] }
+  ]
 }
artifacts/default/apiContent/LeisureActivitiesAPI/content/apiDefinition.json (1)

1-40: LGTM - consistent with CountriesAPI sample spec.

Same security field consideration applies as noted for CountriesAPI. Acceptable for sample seed data.

artifacts/org_data.sh (1)

69-99: View and label creation logic is sound.

The idempotent approach (check-then-insert) and the ON CONFLICT DO NOTHING for the view-label link are appropriate patterns for seed scripts.

README.md (1)

1-156: Documentation improvements are clear and comprehensive.

The restructured README provides actionable setup instructions covering prerequisites, database configuration, seeding, and identity provider setup. The Docker example and PGPASSWORD hints are helpful additions.

artifacts/theme_data.sh (3)

1-35: Good use of set -euo pipefail and proper error handling.

The script correctly validates prerequisites (base directory, view existence) and provides actionable error messages. The dependency on org_data.sh running first is clearly documented.


67-71: SQL escaping is correctly implemented.

The sql_escape function properly escapes single quotes for SQL string literals. This is the pattern that should be applied to other scripts in this PR.


145-160: Good practice: cleaning up large objects after use.

The lo_unlink call after reading the LO content prevents PostgreSQL large object bloat. The || true is appropriate for cleanup operations.

artifacts/api_data.sh (3)

46-55: API-label linking implementation is correct.

The subquery approach to fetch the label ID and the ON CONFLICT DO NOTHING clause ensure idempotent execution. This correctly integrates with the view-based listing system.


68-109: Idempotent inserts with ON CONFLICT are a good improvement.

The added ON CONFLICT DO NOTHING clauses across image data, subscription policies, and API subscription policies enable safe re-runs of the seed script.


179-179: WS is a supported API type — no action needed.

The NavigationAPI's use of API_TYPE="WS" is valid. The system explicitly supports WS (WebSocket) as one of five documented API types: REST, WS, GRAPHQL, SOAP, and WEBSUB. This is confirmed in the ENUM definition and implemented throughout the codebase with dedicated WebSocket handling in controllers and viewers.

Comment on lines +133 to +149
TARGET_TYPE="$CONTENT_TYPE"
if [[ "$FILE_NAME" == "apiDefinition.json" ]]; then
TARGET_TYPE="API_DEFINITION"
elif [[ "$FILE_NAME" == "apiDefinition.xml" ]]; then
TARGET_TYPE="API_DEFINITION"
elif [[ "$FILE_NAME" == "apiDefinition.graphql" ]]; then
TARGET_TYPE="API_DEFINITION"
elif [[ "$FILE_NAME" == "schemaDefinition.json" ]]; then
TARGET_TYPE="SCHEMA_DEFINITION"
fi

INSERT_QUERY=$(cat <<EOF
INSERT INTO "DP_API_CONTENT" ("API_FILE", "FILE_NAME", "TYPE", "API_ID")
VALUES (lo_get($OID), '$FILE_NAME', '$TARGET_TYPE', '$API_ID')
ON CONFLICT ("API_ID", "FILE_NAME", "TYPE") DO NOTHING;
EOF
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

SQL injection risk: FILE_NAME is interpolated without escaping.

Similar to org_data.sh, file names are interpolated directly into SQL. A maliciously named file could break or exploit the query.

Suggested fix

Add escaping for FILE_NAME:

+sql_escape() {
+  echo "$1" | sed "s/'/''/g"
+}
+
 process_files() {
     ...
             FILE_NAME=$(basename "$file")
+            FILE_NAME_SQL=$(sql_escape "$FILE_NAME")
             ...
             INSERT_QUERY=$(cat <<EOF
 INSERT INTO "DP_API_CONTENT" ("API_FILE", "FILE_NAME", "TYPE", "API_ID")
-VALUES (lo_get($OID), '$FILE_NAME', '$TARGET_TYPE', '$API_ID')
+VALUES (lo_get($OID), '$FILE_NAME_SQL', '$TARGET_TYPE', '$API_ID')
 ON CONFLICT ("API_ID", "FILE_NAME", "TYPE") DO NOTHING;
 EOF
 )

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @artifacts/api_data.sh around lines 133 - 149, The INSERT_QUERY construction
interpolates FILE_NAME directly into the SQL, risking injection; before building
INSERT_QUERY sanitize FILE_NAME by escaping single quotes (replace ' with ''),
assign that to a new variable (e.g., ESCAPED_FILE_NAME) and use that variable in
the VALUES clause instead of FILE_NAME; ensure any other interpolated values
used in SQL (e.g., TARGET_TYPE, API_ID) are similarly validated/escaped or
passed as parameters/psql variables to protect DP_API_CONTENT inserts
referencing lo_get($OID).

echo "OID: $OID"

INSERT_QUERY="INSERT INTO \"DP_ORGANIZATION_ASSETS\" (\"ASSET_ID\", \"FILE_CONTENT\", \"FILE_NAME\", \"FILE_TYPE\", \"FILE_PATH\", \"ORG_ID\") VALUES ( gen_random_uuid(), lo_get($OID), '$FILE_NAME', '$FILE_TYPE', '$FILE_PATH', '$ORG_ID');"
INSERT_QUERY="INSERT INTO \"DP_ORGANIZATION_ASSETS\" (\"ASSET_ID\", \"FILE_CONTENT\", \"FILE_NAME\", \"FILE_TYPE\", \"FILE_PATH\", \"ORG_ID\", \"VIEW_ID\") VALUES ( gen_random_uuid(), lo_get($OID), '$FILE_NAME', '$FILE_TYPE', '$FILE_PATH', '$ORG_ID', '$VIEW_ID');"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

SQL injection risk: FILE_NAME is interpolated without escaping.

FILE_NAME is derived from user-controlled file names. A file named foo'; DROP TABLE "DP_ORGANIZATION_ASSETS"; -- would break the query. Consider adding SQL escaping similar to the sql_escape function in theme_data.sh.

Suggested fix

Add an escape function and use it:

+sql_escape() {
+  echo "$1" | sed "s/'/''/g"
+}
+
 process_directory() {
     ...
+            FILE_NAME_SQL=$(sql_escape "$FILE_NAME")
+            FILE_PATH_SQL=$(sql_escape "$FILE_PATH")
-            INSERT_QUERY="INSERT INTO \"DP_ORGANIZATION_ASSETS\" (\"ASSET_ID\", \"FILE_CONTENT\", \"FILE_NAME\", \"FILE_TYPE\", \"FILE_PATH\", \"ORG_ID\", \"VIEW_ID\") VALUES ( gen_random_uuid(), lo_get($OID), '$FILE_NAME', '$FILE_TYPE', '$FILE_PATH', '$ORG_ID', '$VIEW_ID');"
+            INSERT_QUERY="INSERT INTO \"DP_ORGANIZATION_ASSETS\" (\"ASSET_ID\", \"FILE_CONTENT\", \"FILE_NAME\", \"FILE_TYPE\", \"FILE_PATH\", \"ORG_ID\", \"VIEW_ID\") VALUES ( gen_random_uuid(), lo_get($OID), '$FILE_NAME_SQL', '$FILE_TYPE', '$FILE_PATH_SQL', '$ORG_ID', '$VIEW_ID');"

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @artifacts/org_data.sh at line 141, The INSERT_QUERY builds SQL by
interpolating unescaped FILE_NAME (and potentially FILE_TYPE/FILE_PATH) which
allows SQL injection; add a sanitizer like the existing sql_escape function (or
implement one that doubles single quotes) and use it when constructing
INSERT_QUERY (e.g., escaped_FILE_NAME = sql_escape "$FILE_NAME") and replace
direct variables with their escaped counterparts in the INSERT_QUERY string,
ensuring any other file-derived variables (FILE_TYPE, FILE_PATH) are similarly
escaped or parameterized.

Comment on lines +12 to +13
DROP TABLE IF EXISTS "DP_APP_KEY_MAPPING";
DROP TABLE IF EXISTS "DP_SDK_JOB";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Incorrect DROP order: child tables dropped after parent CASCADE.

Lines 12-13 drop DP_APP_KEY_MAPPING and DP_SDK_JOB after DP_ORGANIZATION is dropped with CASCADE at line 10. Since both tables have foreign key constraints to DP_ORGANIZATION (lines 229 and 245), the CASCADE at line 10 will automatically drop them first, making these explicit DROP statements redundant and potentially confusing.

Recommended approach: Move lines 12-13 to execute before line 10 to establish explicit, predictable drop ordering.

🔎 Proposed fix to reorder DROP statements

Move the new DROP statements before the parent table drops:

 DROP TABLE IF EXISTS "DP_API_METADATA" CASCADE;
+DROP TABLE IF EXISTS "DP_APP_KEY_MAPPING";
+DROP TABLE IF EXISTS "DP_SDK_JOB";
 DROP TABLE IF EXISTS "DP_ORGANIZATION" CASCADE;
 DROP TABLE IF EXISTS "DP_PROVIDER";
-DROP TABLE IF EXISTS "DP_APP_KEY_MAPPING";
-DROP TABLE IF EXISTS "DP_SDK_JOB";
 DROP TABLE IF EXISTS "DP_VIEWS" CASCADE;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DROP TABLE IF EXISTS "DP_APP_KEY_MAPPING";
DROP TABLE IF EXISTS "DP_SDK_JOB";
DROP TABLE IF EXISTS "DP_API_METADATA" CASCADE;
DROP TABLE IF EXISTS "DP_APP_KEY_MAPPING";
DROP TABLE IF EXISTS "DP_SDK_JOB";
DROP TABLE IF EXISTS "DP_ORGANIZATION" CASCADE;
DROP TABLE IF EXISTS "DP_PROVIDER";
DROP TABLE IF EXISTS "DP_VIEWS" CASCADE;
🤖 Prompt for AI Agents
In @artifacts/script.sql around lines 12 - 13, The DROP order is incorrect:
DP_APP_KEY_MAPPING and DP_SDK_JOB are dropped after DP_ORGANIZATION is dropped
with CASCADE, making those explicit DROP statements redundant and confusing;
move the DROP TABLE IF EXISTS "DP_APP_KEY_MAPPING" and DROP TABLE IF EXISTS
"DP_SDK_JOB" so they execute before the DROP TABLE ... "DP_ORGANIZATION" ...
CASCADE statement to enforce an explicit child-before-parent drop ordering and
avoid relying on CASCADE to remove child tables.

Comment on lines +157 to +180
## Add a third-party API (Admin APIs)

If you want to add real APIs (instead of the sample seed scripts), you can use the Devportal Admin APIs to:

- Configure a **provider** (control plane)
- Create an **API** (metadata + API definition upload)
- Upload **API landing page content** (templates/assets)

These requests typically require:

- `orgId` / `organizationID` / `apiID` (depending on the endpoint)
- `Authorization: Bearer <access_token>`

#### 1) Configure a provider (control plane)

```bash
curl --location 'http://localhost:3000/devportal/organizations/{orgId}/provider' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <access_token>' \
--data '{
"name": "MuleSoft",
"providerURL": "https://anypoint.mulesoft.com/login/signin?apintent=generic"
}'
```


- Create an API in the developer portal:

The apiType values include REST, AsyncAPI, GraphQL or SOAP

The provider value should be the name of the control plane configured in the developer portal.

visibility - PUBLIC/PRIVATE

This is a multi part request containing a json with metadata related to the API and a file attachement of the api schema definition file.
``` bash
 curl --location 'http://localhost:devportal/organizations/{organizationID}/apis'

   --form 'api-metadata="{
                  "apiInfo": { 
                     "referenceID": "<UUID for the API created in WSO2 publisher>",
                     "apiName": "NavigationAPI",
                     "provider": "MuleSoft",
                     "orgName": "ACME",
                     "apiCategory": "Travel",
                     "apiDescription": "API for retrieving information about hotels and managing reservations",
                     "visibility" : "PUBLIC",
                     "visibleGroups": \["HR"\],
                     "owners" : {
                      "technicalOwner": "john",
                      "technicalOwnerEmail": "john@gmail.com",
                      "businessOwner" : "sam",
                      "businessOwnerEmail":"sam@gmail.com"
                     },
                     "apiVersion" : "3.0.2",
                     "apiType" : "REST"
                  },
                  "subscriptionPolicies": [
                     {
                        "policyName": "gold"
                     },
                     {
                        "policyName": "platinum"
                     }
                  ],
                  "endPoints": {
                     "sandboxURL": "http://taxi-navigation.mnm.abc.com",
                     "productionURL": "https://taxi-navigation.mnm.abc.com"
                  }
            }"; type=application/json'
   --form 'apiDefinition=@"{apiDefinition.json}"'
```
- Upload the api landing page content.

To upload the content to be displayed on the api-landing page, create a zip file with the folder structure as follows:
``` bash
{API NAME}
└───content
   │   api-content.hbs
   │   apiContent.md
└───images
   │   icon.svg
   │   product.png
```
This is a multi part request, containing the metadata about the images in the api landing page.
This should be sent as a json key value map, with the key referring to the name in the hbs where the image is referenced and the name of the image file as the value.
For example, the key should be sent as api-icon to display the relevant image in the following img tag.
``` bash
<img src={{apiInfo.apiImageMetadata.api-icon}} class="api-card-img" alt="..." />

```
Run the following command to upload the content.
``` bash
curl --location --request POST 'http://localhost:3000/devportal/organizations/{organizationID}/apis/{apiID}/template'
     --form 'apiContent=@"{path-to-zip-file}"' \\
     --form 'imageMetadata="{
               \\"api-icon\\" : \\"navigation.jpeg\\",
               \\"api-hero\\": \\"api.svg\\"
            }"
```

Use this (https://devportal-4432.postman.co/workspace/Devportal-Workspace~9221a728-2c4b-46ec-acc3-095b9debacbc/collection/5029047-61d763dc-d7b9-4436-9a2e-94585c806943?action=share&creator=5029047) POSTMAN collection to test the API requests.
}'
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Heading levels skip from h2 to h4.

The #### headings under "Add a third-party API" should be ### to maintain proper heading hierarchy (MD001). This affects accessibility and document outline navigation.

Suggested fix
-#### 1) Configure a provider (control plane)
+### 1) Configure a provider (control plane)

Apply the same change to headings at lines 182, 207, and 233.

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

170-170: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🤖 Prompt for AI Agents
In @README.md around lines 157 - 180, The section "Add a third-party API (Admin
APIs)" uses level-4 headings (####) for its subsections which breaks the
document hierarchy; change the headings "1) Configure a provider (control
plane)", "2) Create an API (metadata + API definition upload)" and the "Upload
API landing page content (templates/assets)" heading from #### to ### so the
subsections are proper h3 headings and apply the same change to the other
instances noted in the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments