Skip to content

Conversation

@harshithad0703
Copy link
Contributor

No description provided.

nadeem-cs and others added 13 commits August 19, 2025 15:12
test: add tests for html escaping in jsontohtml function
…ing logic

- Bump version from 1.5.0 to 1.6.0 in package.json
- Change types path in package.json to point to src/index.d.ts
- Refactor getContentstackEndpoint function to use local regions data
- Add error handling for invalid regions and services
- Implement helper functions for default endpoint retrieval and region lookup
…er-functions

feat: add helper functions for endpoints
@harshithad0703 harshithad0703 requested a review from a team as a code owner October 29, 2025 07:59
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Coverage report

Caution

You've enabled annotations option, but checks permission is missing. To fix this, add this to your action.yaml file:

jobs:
    permissions:
        contents: write
        pull-requests: write
+       checks: write
    coverage:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v3
            - uses: ArtiomTr/jest-coverage-report-action@v2
St.
Category Percentage Covered / Total
🟢 Statements
92.34% (-6.79% 🔻)
591/640
🟢 Branches
83.33% (-4.5% 🔻)
525/630
🟢 Functions
95.74% (-4.26% 🔻)
135/141
🟢 Lines
92.54% (-6.89% 🔻)
546/590
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴 endpoints.ts 31.25% 13.16% 40% 29.31%

Test suite run failed

Failed tests: 48/321. Failed suites: 1/20.
  ● getContentstackEndpoint › Basic functionality › should return default endpoints for valid region without service

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:27:45)

  ● getContentstackEndpoint › Basic functionality › should return specific service endpoint for valid region and service

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:36:45)

  ● getContentstackEndpoint › Basic functionality › should return EU endpoints for EU region

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:42:45)

  ● getContentstackEndpoint › Basic functionality › should return undefined for invalid service

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:48:45)

  ● getContentstackEndpoint › Region alias matching › should match region by alias "na"

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:56:45)

  ● getContentstackEndpoint › Region alias matching › should match region by alias "aws-na"

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:62:45)

  ● getContentstackEndpoint › Region alias matching › should match region by alias "aws_na"

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:68:45)

  ● getContentstackEndpoint › Region alias matching › should be case insensitive for region matching

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:74:45)

  ● getContentstackEndpoint › Region alias matching › should trim whitespace from region input

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:80:45)

  ● getContentstackEndpoint › omitHttps parameter › should strip https from string endpoint when omitHttps is true

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:88:45)

  ● getContentstackEndpoint › omitHttps parameter › should strip https from all endpoints when omitHttps is true and no service specified

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:94:45)

  ● getContentstackEndpoint › omitHttps parameter › should preserve https when omitHttps is false

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:102:45)

  ● getContentstackEndpoint › Error handling and edge cases › should return default endpoint for invalid region

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:116:45)

  ● getContentstackEndpoint › Error handling and edge cases › should return default endpoint for region with underscores/dashes

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:122:45)

  ● getContentstackEndpoint › Error handling and edge cases › should handle malformed regions data gracefully

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:131:45)

  ● getContentstackEndpoint › Error handling and edge cases › should fallback to default when region is not found

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:137:45)

  ● getContentstackEndpoint › Default parameters › should use default region "us" when no region provided

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:145:45)

  ● getContentstackEndpoint › Default parameters › should use default service "" when no service provided

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:153:45)

  ● getContentstackEndpoint › Default parameters › should use default omitHttps false when not provided

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:160:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct application endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:168:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct auth endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:174:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct graphqlDelivery endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:180:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct preview endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:186:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct images endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:192:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct assets endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:198:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct automate endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:204:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct launch endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:210:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct developerHub endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:216:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct brandKit endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:222:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct genAI endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:228:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct personalize endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:234:45)

  ● getContentstackEndpoint › Service-specific endpoints › should return correct personalizeEdge endpoint

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:240:45)

  ● getContentstackEndpoint › Different regions › should return correct EU endpoints

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:248:45)

  ● getContentstackEndpoint › Different regions › should return correct Azure NA endpoints

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:254:45)

  ● getContentstackEndpoint › Different regions › should return correct GCP NA endpoints

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:260:45)

  ● getContentstackEndpoint › Additional regions and aliases › should return correct Australia endpoints

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:268:45)

  ● getContentstackEndpoint › Additional regions and aliases › should match Australia region by alias "aws-au"

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:274:45)

  ● getContentstackEndpoint › Additional regions and aliases › should return correct Azure EU endpoints

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:280:45)

  ● getContentstackEndpoint › Additional regions and aliases › should return correct GCP EU endpoints

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:286:45)

  ● getContentstackEndpoint › Additional regions and aliases › should match Azure region by underscore alias

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:292:45)

  ● getContentstackEndpoint › Additional regions and aliases › should match GCP region by underscore alias

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:298:45)

  ● getContentstackEndpoint › Edge cases and error scenarios › should handle null region gracefully

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:306:45)

  ● getContentstackEndpoint › Edge cases and error scenarios › should handle undefined region gracefully

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:312:45)

  ● getContentstackEndpoint › Edge cases and error scenarios › should handle region with only whitespace

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:318:45)

  ● getContentstackEndpoint › Edge cases and error scenarios › should handle region with special characters

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:324:45)

  ● getContentstackEndpoint › Edge cases and error scenarios › should handle very long region name

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:331:45)

  ● getContentstackEndpoint › Console warnings › should warn for invalid region

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:343:30)

  ● getContentstackEndpoint › Console warnings › should warn for failed endpoint fetch

    regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.

      40 |   
      41 |   // If not found, throw clear error
    > 42 |   throw new Error('regions.json file not found at dist/lib/regions.json. Please ensure the package is properly installed and postinstall script has run.');
         |         ^
      43 | }
      44 |
      45 | // Cache the loaded regions data

      at loadRegions (src/endpoints.ts:42:9)
      at loadRegions (src/endpoints.ts:50:21)
      at getRegions (src/endpoints.ts:114:19)
      at getDefaultEndpoint (src/endpoints.ts:109:12)
      at Object.<anonymous> (__test__/endpoints.test.ts:349:30)

Report generated by 🧪jest coverage report action from 8cacebc

Merge pull request #195 from contentstack/staging
@github-actions
Copy link

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
99.04% (-0.09% 🔻)
622/628
🟢 Branches
87.7% (-0.14% 🔻)
549/626
🟢 Functions 100% 139/139
🟢 Lines
99.31% (-0.13% 🔻)
574/578
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢 endpoints.ts 98.08% 85.29% 100% 97.83%

Test suite run success

321 tests passing in 20 suites.

Report generated by 🧪jest coverage report action from 9725c8a

nadeem-cs and others added 7 commits October 31, 2025 16:33
- Added runtime loading of regions.json with fallback options in endpoints.ts
- Updated rollup.config.js to exclude regions.json from bundling
- Modified package.json scripts to save regions.json in the dist/lib directory
- Updated ESLint configuration to define globals
- Updated TypeScript configuration for better compatibility
…er-functions

Enhance region loading and error handling
Stag PR | Endpoints story | enhance region loading and update configurations
…er-functions

feat: update CI workflow to include node setup and npm install steps
@harshithad0703 harshithad0703 merged commit bb0f83b into master Nov 3, 2025
10 of 12 checks passed
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.

5 participants