Skip to content

Commit

Permalink
fix: export MemoryStore through library root, update MemoryStore.get …
Browse files Browse the repository at this point in the history
…type signature (#364)

OKTA-550323 fix: export MemoryStore through library root, update MemoryStore.get type signature

Co-authored-by: Denys Oblohin <[email protected]>
  • Loading branch information
1 parent eb8932d commit 79fbab9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Okta Node SDK Changelog

# 6.6.0

### Bug Fixes

- [#329](https://github.com/okta/okta-sdk-nodejs/pull/360) Fixes path and type signature issues for MemoryStore.


# 6.5.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ To prevent this behavior, and instead remove expired values from memory proactiv

```javascript
const okta = require('@okta/okta-sdk-nodejs');
const MemoryStore = require('@okta/okta-sdk-nodejs/src/memory-store');
const MemoryStore = okta.MemoryStore;

const client = new okta.Client({
orgUrl: 'https://dev-1234.oktapreview.com/',
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = Object.assign(
RequestExecutor: require('./request-executor'),
DefaultRequestExecutor: require('./default-request-executor'),
Collection: require('./collection'),
MemoryStore: require('./memory-store'),
},
require('./models')
);
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './client';
export * from './request-executor';
export * from './default-request-executor';
export * from './collection';
export * from './memory-store';
export * from './parameterized-operations-client';
export * from './request-options/AutoLoginApplicationOptions';
export * from './request-options/BasicAuthApplicationOptions';
Expand Down
4 changes: 2 additions & 2 deletions src/types/memory-store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/** Interface methods required for cache storage implementations. */
export interface CacheStorage {
get(key: string): Promise<string>;
get(key: string): Promise<string | undefined>;
set(key: string, value: string, options?: Record<string, string | number>): Promise<string>;
delete(key: string): Promise<void>;
}
Expand All @@ -26,7 +26,7 @@ export declare class MemoryStore implements CacheStorage {
_keyLimit: number;
_store: Map<string, unknown>;
_interval: NodeJS.Timeout;
get(key: string): Promise<string>;
get(key: string): Promise<string | undefined>;
set(key: string, string: string, options?: {ttl: number }): Promise<string>;
delete(key: string): Promise<void>;
}
5 changes: 3 additions & 2 deletions test/it/application-user-schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import utils = require('../utils');
import { Client, BookmarkApplication, UserSchema, DefaultRequestExecutor } from '@okta/okta-sdk-nodejs';
import { Client, BookmarkApplication, UserSchema, DefaultRequestExecutor, MemoryStore } from '@okta/okta-sdk-nodejs';
import getMockSchemaProperty = require('./mocks/user-schema-property');


Expand All @@ -15,7 +15,8 @@ const client = new Client({
scopes: ['okta.schemas.read', 'okta.schemas.manage'],
orgUrl: orgUrl,
token: process.env.OKTA_CLIENT_TOKEN,
requestExecutor: new DefaultRequestExecutor()
requestExecutor: new DefaultRequestExecutor(),
cacheStore: new MemoryStore(),
});

describe('App User Schema', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/type/memory-store.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { MemoryStore } from '../../src/types/memory-store';

const memoryStore = new MemoryStore({});
expectType<Promise<void>>(memoryStore.delete('key'));
expectType<Promise<string>>(memoryStore.get('key'));
expectType<Promise<string|undefined>>(memoryStore.get('key'));
expectType<Promise<string>>(memoryStore.set('key', 'value'));

0 comments on commit 79fbab9

Please sign in to comment.