@xnestjs/redisess 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InjectSessionManager = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
- const redisess_utils_js_1 = require("./redisess.utils.js");
6
- const InjectSessionManager = (name) => (0, common_1.Inject)((0, redisess_utils_js_1.getSessionManagerToken)(name));
5
+ const get_session_manager_token_util_js_1 = require("../utils/get-session-manager-token.util.js");
6
+ const InjectSessionManager = (name) => (0, common_1.Inject)((0, get_session_manager_token_util_js_1.getSessionManagerToken)(name));
7
7
  exports.InjectSessionManager = InjectSessionManager;
package/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./redisess.decorators.js"), exports);
5
- tslib_1.__exportStar(require("./redisess.interface.js"), exports);
4
+ tslib_1.__exportStar(require("./decorators/inject-session-manager.decorators.js"), exports);
5
+ tslib_1.__exportStar(require("./interfaces/module-options.interface.js"), exports);
6
6
  tslib_1.__exportStar(require("./redisess.module.js"), exports);
7
- tslib_1.__exportStar(require("./redisess.utils.js"), exports);
7
+ tslib_1.__exportStar(require("./utils/get-session-manager-token.util.js"), exports);
@@ -3,12 +3,12 @@ var RedisessCoreModule_1;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.RedisessCoreModule = void 0;
5
5
  const tslib_1 = require("tslib");
6
- const crypto = tslib_1.__importStar(require("crypto"));
7
- const redisess_1 = require("redisess");
8
6
  const common_1 = require("@nestjs/common");
9
7
  const core_1 = require("@nestjs/core");
10
- const redisess_constants_js_1 = require("./redisess.constants.js");
11
- const redisess_utils_js_1 = require("./redisess.utils.js");
8
+ const crypto = tslib_1.__importStar(require("crypto"));
9
+ const redisess_1 = require("redisess");
10
+ const constants_1 = require("./constants");
11
+ const get_session_manager_token_util_js_1 = require("./utils/get-session-manager-token.util.js");
12
12
  let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
13
13
  constructor(options, moduleRef) {
14
14
  this.options = options;
@@ -16,30 +16,30 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
16
16
  }
17
17
  static forRoot(options) {
18
18
  const optionsProvider = {
19
- provide: redisess_constants_js_1.REDISESS_MODULE_OPTIONS,
20
- useValue: options
19
+ provide: constants_1.REDISESS_MODULE_OPTIONS,
20
+ useValue: options,
21
21
  };
22
22
  const connectionProvider = {
23
- provide: (0, redisess_utils_js_1.getSessionManagerToken)(options.name),
24
- useFactory: () => this.createSessionManager(options)
23
+ provide: (0, get_session_manager_token_util_js_1.getSessionManagerToken)(options.name),
24
+ useFactory: () => this.createSessionManager(options),
25
25
  };
26
26
  return {
27
27
  module: RedisessCoreModule_1,
28
28
  providers: [connectionProvider, optionsProvider],
29
- exports: [connectionProvider]
29
+ exports: [connectionProvider],
30
30
  };
31
31
  }
32
32
  static forRootAsync(asyncOptions) {
33
33
  const connectionProvider = {
34
- provide: (0, redisess_utils_js_1.getSessionManagerToken)(asyncOptions.name),
35
- inject: [redisess_constants_js_1.REDISESS_MODULE_OPTIONS],
34
+ provide: (0, get_session_manager_token_util_js_1.getSessionManagerToken)(asyncOptions.name),
35
+ inject: [constants_1.REDISESS_MODULE_OPTIONS],
36
36
  useFactory: async (oOptions) => {
37
37
  const name = asyncOptions.name || oOptions.name;
38
38
  return this.createSessionManager({
39
39
  ...oOptions,
40
- name
40
+ name,
41
41
  });
42
- }
42
+ },
43
43
  };
44
44
  const asyncProviders = this.createAsyncProviders(asyncOptions);
45
45
  return {
@@ -49,45 +49,46 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
49
49
  ...asyncProviders,
50
50
  connectionProvider,
51
51
  {
52
- provide: redisess_constants_js_1.REDISESS_MODULE_TOKEN,
53
- useValue: crypto.randomUUID()
54
- }
52
+ provide: constants_1.REDISESS_MODULE_TOKEN,
53
+ useValue: crypto.randomUUID(),
54
+ },
55
55
  ],
56
- exports: [connectionProvider]
56
+ exports: [connectionProvider],
57
57
  };
58
58
  }
59
59
  async onApplicationShutdown() {
60
- const sessionManager = this.moduleRef.get((0, redisess_utils_js_1.getSessionManagerToken)(this.options.name));
60
+ const sessionManager = this.moduleRef.get((0, get_session_manager_token_util_js_1.getSessionManagerToken)(this.options.name));
61
61
  if (sessionManager)
62
62
  sessionManager.quit();
63
63
  }
64
64
  static createAsyncProviders(asyncOptions) {
65
65
  if (asyncOptions.useExisting || asyncOptions.useFactory)
66
66
  return [this.createAsyncOptionsProvider(asyncOptions)];
67
- if (asyncOptions.useClass)
67
+ if (asyncOptions.useClass) {
68
68
  return [
69
69
  this.createAsyncOptionsProvider(asyncOptions),
70
70
  {
71
71
  provide: asyncOptions.useClass,
72
- useClass: asyncOptions.useClass
73
- }
72
+ useClass: asyncOptions.useClass,
73
+ },
74
74
  ];
75
+ }
75
76
  throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
76
77
  }
77
78
  static createAsyncOptionsProvider(asyncOptions) {
78
79
  if (asyncOptions.useFactory) {
79
80
  return {
80
- provide: redisess_constants_js_1.REDISESS_MODULE_OPTIONS,
81
+ provide: constants_1.REDISESS_MODULE_OPTIONS,
81
82
  useFactory: asyncOptions.useFactory,
82
- inject: asyncOptions.inject || []
83
+ inject: asyncOptions.inject || [],
83
84
  };
84
85
  }
85
86
  const useClass = asyncOptions.useClass || asyncOptions.useExisting;
86
87
  if (useClass) {
87
88
  return {
88
- provide: redisess_constants_js_1.REDISESS_MODULE_OPTIONS,
89
+ provide: constants_1.REDISESS_MODULE_OPTIONS,
89
90
  useFactory: (optionsFactory) => optionsFactory.createOptions(asyncOptions.name),
90
- inject: [useClass]
91
+ inject: [useClass],
91
92
  };
92
93
  }
93
94
  throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
@@ -103,6 +104,6 @@ exports.RedisessCoreModule = RedisessCoreModule;
103
104
  exports.RedisessCoreModule = RedisessCoreModule = RedisessCoreModule_1 = tslib_1.__decorate([
104
105
  (0, common_1.Global)(),
105
106
  (0, common_1.Module)({}),
106
- tslib_1.__param(0, (0, common_1.Inject)(redisess_constants_js_1.REDISESS_MODULE_OPTIONS)),
107
+ tslib_1.__param(0, (0, common_1.Inject)(constants_1.REDISESS_MODULE_OPTIONS)),
107
108
  tslib_1.__metadata("design:paramtypes", [Object, core_1.ModuleRef])
108
109
  ], RedisessCoreModule);
@@ -9,13 +9,13 @@ let RedisessModule = RedisessModule_1 = class RedisessModule {
9
9
  static forRoot(options) {
10
10
  return {
11
11
  module: RedisessModule_1,
12
- imports: [redisess_core_module_js_1.RedisessCoreModule.forRoot(options)]
12
+ imports: [redisess_core_module_js_1.RedisessCoreModule.forRoot(options)],
13
13
  };
14
14
  }
15
15
  static forRootAsync(options) {
16
16
  return {
17
17
  module: RedisessModule_1,
18
- imports: [redisess_core_module_js_1.RedisessCoreModule.forRootAsync(options)]
18
+ imports: [redisess_core_module_js_1.RedisessCoreModule.forRootAsync(options)],
19
19
  };
20
20
  }
21
21
  };
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSessionManagerToken = void 0;
3
+ exports.getSessionManagerToken = getSessionManagerToken;
4
4
  const redisess_1 = require("redisess");
5
5
  function getSessionManagerToken(name) {
6
6
  if (!name)
7
7
  return redisess_1.SessionManager;
8
+ // noinspection SuspiciousTypeOfGuard
8
9
  if (typeof name === 'symbol' || typeof name === 'function')
9
10
  return name;
10
11
  return `${name}_SessionManager`;
11
12
  }
12
- exports.getSessionManagerToken = getSessionManagerToken;
@@ -1,3 +1,3 @@
1
1
  import { Inject } from '@nestjs/common';
2
- import { getSessionManagerToken } from './redisess.utils.js';
2
+ import { getSessionManagerToken } from '../utils/get-session-manager-token.util.js';
3
3
  export const InjectSessionManager = (name) => Inject(getSessionManagerToken(name));
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './redisess.decorators.js';
2
- export * from './redisess.interface.js';
1
+ export * from './decorators/inject-session-manager.decorators.js';
2
+ export * from './interfaces/module-options.interface.js';
3
3
  export * from './redisess.module.js';
4
- export * from './redisess.utils.js';
4
+ export * from './utils/get-session-manager-token.util.js';
@@ -1,11 +1,11 @@
1
1
  var RedisessCoreModule_1;
2
2
  import { __decorate, __metadata, __param } from "tslib";
3
- import * as crypto from 'crypto';
4
- import { SessionManager } from 'redisess';
5
3
  import { Global, Inject, Module } from '@nestjs/common';
6
4
  import { ModuleRef } from '@nestjs/core';
7
- import { REDISESS_MODULE_OPTIONS, REDISESS_MODULE_TOKEN } from './redisess.constants.js';
8
- import { getSessionManagerToken } from './redisess.utils.js';
5
+ import * as crypto from 'crypto';
6
+ import { SessionManager } from 'redisess';
7
+ import { REDISESS_MODULE_OPTIONS, REDISESS_MODULE_TOKEN } from './constants';
8
+ import { getSessionManagerToken } from './utils/get-session-manager-token.util.js';
9
9
  let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
10
10
  constructor(options, moduleRef) {
11
11
  this.options = options;
@@ -14,16 +14,16 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
14
14
  static forRoot(options) {
15
15
  const optionsProvider = {
16
16
  provide: REDISESS_MODULE_OPTIONS,
17
- useValue: options
17
+ useValue: options,
18
18
  };
19
19
  const connectionProvider = {
20
20
  provide: getSessionManagerToken(options.name),
21
- useFactory: () => this.createSessionManager(options)
21
+ useFactory: () => this.createSessionManager(options),
22
22
  };
23
23
  return {
24
24
  module: RedisessCoreModule_1,
25
25
  providers: [connectionProvider, optionsProvider],
26
- exports: [connectionProvider]
26
+ exports: [connectionProvider],
27
27
  };
28
28
  }
29
29
  static forRootAsync(asyncOptions) {
@@ -34,9 +34,9 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
34
34
  const name = asyncOptions.name || oOptions.name;
35
35
  return this.createSessionManager({
36
36
  ...oOptions,
37
- name
37
+ name,
38
38
  });
39
- }
39
+ },
40
40
  };
41
41
  const asyncProviders = this.createAsyncProviders(asyncOptions);
42
42
  return {
@@ -47,10 +47,10 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
47
47
  connectionProvider,
48
48
  {
49
49
  provide: REDISESS_MODULE_TOKEN,
50
- useValue: crypto.randomUUID()
51
- }
50
+ useValue: crypto.randomUUID(),
51
+ },
52
52
  ],
53
- exports: [connectionProvider]
53
+ exports: [connectionProvider],
54
54
  };
55
55
  }
56
56
  async onApplicationShutdown() {
@@ -61,14 +61,15 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
61
61
  static createAsyncProviders(asyncOptions) {
62
62
  if (asyncOptions.useExisting || asyncOptions.useFactory)
63
63
  return [this.createAsyncOptionsProvider(asyncOptions)];
64
- if (asyncOptions.useClass)
64
+ if (asyncOptions.useClass) {
65
65
  return [
66
66
  this.createAsyncOptionsProvider(asyncOptions),
67
67
  {
68
68
  provide: asyncOptions.useClass,
69
- useClass: asyncOptions.useClass
70
- }
69
+ useClass: asyncOptions.useClass,
70
+ },
71
71
  ];
72
+ }
72
73
  throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
73
74
  }
74
75
  static createAsyncOptionsProvider(asyncOptions) {
@@ -76,7 +77,7 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
76
77
  return {
77
78
  provide: REDISESS_MODULE_OPTIONS,
78
79
  useFactory: asyncOptions.useFactory,
79
- inject: asyncOptions.inject || []
80
+ inject: asyncOptions.inject || [],
80
81
  };
81
82
  }
82
83
  const useClass = asyncOptions.useClass || asyncOptions.useExisting;
@@ -84,7 +85,7 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
84
85
  return {
85
86
  provide: REDISESS_MODULE_OPTIONS,
86
87
  useFactory: (optionsFactory) => optionsFactory.createOptions(asyncOptions.name),
87
- inject: [useClass]
88
+ inject: [useClass],
88
89
  };
89
90
  }
90
91
  throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
@@ -6,13 +6,13 @@ let RedisessModule = RedisessModule_1 = class RedisessModule {
6
6
  static forRoot(options) {
7
7
  return {
8
8
  module: RedisessModule_1,
9
- imports: [RedisessCoreModule.forRoot(options)]
9
+ imports: [RedisessCoreModule.forRoot(options)],
10
10
  };
11
11
  }
12
12
  static forRootAsync(options) {
13
13
  return {
14
14
  module: RedisessModule_1,
15
- imports: [RedisessCoreModule.forRootAsync(options)]
15
+ imports: [RedisessCoreModule.forRootAsync(options)],
16
16
  };
17
17
  }
18
18
  };
@@ -2,6 +2,7 @@ import { SessionManager } from 'redisess';
2
2
  export function getSessionManagerToken(name) {
3
3
  if (!name)
4
4
  return SessionManager;
5
+ // noinspection SuspiciousTypeOfGuard
5
6
  if (typeof name === 'symbol' || typeof name === 'function')
6
7
  return name;
7
8
  return `${name}_SessionManager`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnestjs/redisess",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "NestJS extension library for redisess",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -20,6 +20,8 @@
20
20
  "build:esm": "tsc -b tsconfig-build-esm.json",
21
21
  "postbuild": "cp package.json README.md ../../LICENSE ../../build/redisess && cp ../../package.cjs.json ../../build/redisess/cjs/package.json",
22
22
  "lint": "eslint . --max-warnings=0",
23
+ "lint:fix": "eslint . --max-warnings=0 --fix",
24
+ "format": "prettier . --write --log-level=warn",
23
25
  "check": "madge --circular src/**",
24
26
  "test": "jest",
25
27
  "cover": "jest --collect-coverage",
@@ -29,12 +31,13 @@
29
31
  "clean:cover": "rimraf ../../coverage/redisess"
30
32
  },
31
33
  "peerDependencies": {
32
- "@nestjs/common": "^10.2.10",
33
- "@xnestjs/ioredis": "^0.7.0",
34
- "redisess": "^2.2.0"
34
+ "@nestjs/common": "^10.3.10",
35
+ "@xnestjs/ioredis": "^0.7.1",
36
+ "redisess": "^2.4.0",
37
+ "ioredis": "^5.4.1"
35
38
  },
36
39
  "devDependencies": {
37
- "@types/ioredis": "^5.0.0"
40
+ "@nestjs/core": "^10.3.10"
38
41
  },
39
42
  "engines": {
40
43
  "node": ">=16.0",
@@ -55,4 +58,4 @@
55
58
  "manager",
56
59
  "redis"
57
60
  ]
58
- }
61
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './redisess.decorators.js';
2
- export * from './redisess.interface.js';
1
+ export * from './decorators/inject-session-manager.decorators.js';
2
+ export * from './interfaces/module-options.interface.js';
3
3
  export * from './redisess.module.js';
4
- export * from './redisess.utils.js';
4
+ export * from './utils/get-session-manager-token.util.js';
@@ -1,7 +1,7 @@
1
- import Redis, { Cluster } from 'ioredis';
2
- import type { SessionManager } from 'redisess';
3
1
  import type { Type } from '@nestjs/common';
4
2
  import type { ModuleMetadata } from '@nestjs/common/interfaces';
3
+ import Redis, { Cluster } from 'ioredis';
4
+ import type { SessionManager } from 'redisess';
5
5
  export interface RedisessModuleOptions extends SessionManager.Options {
6
6
  /**
7
7
  * Connection name
@@ -12,7 +12,7 @@ export interface RedisessModuleOptions extends SessionManager.Options {
12
12
  export interface RedisessModuleOptionsFactory {
13
13
  createOptions(connectionName?: string): Promise<RedisessModuleOptions> | RedisessModuleOptions;
14
14
  }
15
- export interface RedisesModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
15
+ export interface RedisessModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
16
16
  name?: string;
17
17
  useExisting?: Type<RedisessModuleOptionsFactory>;
18
18
  useClass?: Type<RedisessModuleOptionsFactory>;
@@ -1,12 +1,12 @@
1
1
  import { DynamicModule, OnApplicationShutdown } from '@nestjs/common';
2
2
  import { ModuleRef } from '@nestjs/core';
3
- import { RedisesModuleAsyncOptions, RedisessModuleOptions } from './redisess.interface.js';
3
+ import { RedisessModuleAsyncOptions, RedisessModuleOptions } from './interfaces/module-options.interface.js';
4
4
  export declare class RedisessCoreModule implements OnApplicationShutdown {
5
5
  private readonly options;
6
6
  private readonly moduleRef;
7
7
  constructor(options: RedisessModuleOptions, moduleRef: ModuleRef);
8
8
  static forRoot(options: RedisessModuleOptions): DynamicModule;
9
- static forRootAsync(asyncOptions: RedisesModuleAsyncOptions): DynamicModule;
9
+ static forRootAsync(asyncOptions: RedisessModuleAsyncOptions): DynamicModule;
10
10
  onApplicationShutdown(): Promise<void>;
11
11
  private static createAsyncProviders;
12
12
  private static createAsyncOptionsProvider;
@@ -1,6 +1,6 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import type { RedisesModuleAsyncOptions, RedisessModuleOptions } from './redisess.interface.js';
2
+ import type { RedisessModuleAsyncOptions, RedisessModuleOptions } from './interfaces/module-options.interface.js';
3
3
  export declare class RedisessModule {
4
4
  static forRoot(options: RedisessModuleOptions): DynamicModule;
5
- static forRootAsync(options: RedisesModuleAsyncOptions): DynamicModule;
5
+ static forRootAsync(options: RedisessModuleAsyncOptions): DynamicModule;
6
6
  }
File without changes
File without changes
@@ -1,3 +1,3 @@
1
- import { SessionManager } from 'redisess';
2
1
  import { Type } from '@nestjs/common';
2
+ import { SessionManager } from 'redisess';
3
3
  export declare function getSessionManagerToken(name?: string | symbol | Type<SessionManager>): string | symbol | Type<SessionManager>;