okta/okta-sdk-nodejs

MemoryStore src and types do not align with importing

SamMurphyDev opened this issue · 3 comments

Describe the bug?

When using the SDK with TypeScript, importing the MemoryStore is on the path @okta/okta-sdk-nodejs/src/memory-store. This causes TypeScript to throw errors as the MemoryStore import is of the "any" type. The package json is set to allow the types to work when using the "@okta/okta-sdk-nodejs" import.
image

To make TypeScript happy it requires you to import @okta/okta-sdk-nodejs/src/types/memory-store, which module loading will fail as the source is not located at that library path.
image

Error: Cannot find module '@okta/okta-sdk-nodejs/src/types/memory-store'
...Stacktrace {
  code: 'MODULE_NOT_FOUND'
}

What is expected to happen?

The module to be imported with the correct types from the library

What is the actual behavior?

TypeScript is unable to find the types for the module

Reproduction Steps?

  1. Create a new TypeScript project
  2. Import Okta SDK
  3. Create a new Client
import { Client } from '@okta/okta-sdk-nodejs';
import { MemoryStore } from '@okta/okta-sdk-nodejs/src/memory-store';

new Client({
      orgUrl: '',
      cacheStore: new MemoryStore({
        keyLimit: 1000,
      })
});
  1. See that TypeScript is unable to resolve the types for MemoryStore

SDK Versions

"@okta/okta-sdk-nodejs": "^6.5.0",

Execution Environment

This particular error show up using ts-node.

NodeJS 14.19.0
npx 8.12.1
ts-node v10.9.1

Additional Information?

No response

Thanks for report @SamMurphyDev - we will update module exports to align with type definitions paths.
Internal ref: OKTA-550323

Hi, is it possible to also add http module to the exports list?