Browse Source

fix: adapter importing in cjs mode

e22m4u 1 year ago
parent
commit
91ab3bd038
4 changed files with 12 additions and 6 deletions
  1. 3 3
      dist/cjs/index.cjs
  2. 1 1
      src/adapter/adapter-loader.js
  3. 2 2
      src/adapter/adapter.js
  4. 6 0
      src/adapter/adapter.spec.js

+ 3 - 3
dist/cjs/index.cjs

@@ -5611,11 +5611,11 @@ var init_adapter = __esm({
     init_decorator();
     init_decorator();
     Adapter = class _Adapter extends Service {
     Adapter = class _Adapter extends Service {
       /**
       /**
-       * Class name.
+       * Kind.
        *
        *
        * @type {string}
        * @type {string}
        */
        */
-      get className() {
+      get kind() {
         return _Adapter.name;
         return _Adapter.name;
       }
       }
       /**
       /**
@@ -6202,7 +6202,7 @@ function findAdapterCtorInModule(module2) {
   if (!module2 || typeof module2 !== "object" || Array.isArray(module2)) return;
   if (!module2 || typeof module2 !== "object" || Array.isArray(module2)) return;
   for (const ctor of Object.values(module2)) {
   for (const ctor of Object.values(module2)) {
     console.log(ctor);
     console.log(ctor);
-    if (typeof ctor === "function" && ctor.prototype && typeof ctor.prototype === "object" && ctor.prototype.className === Adapter.name) {
+    if (typeof ctor === "function" && ctor.prototype && typeof ctor.prototype === "object" && ctor.prototype.kind === Adapter.name) {
       adapterCtor = ctor;
       adapterCtor = ctor;
       break;
       break;
     }
     }

+ 1 - 1
src/adapter/adapter-loader.js

@@ -59,7 +59,7 @@ function findAdapterCtorInModule(module) {
       typeof ctor === 'function' &&
       typeof ctor === 'function' &&
       ctor.prototype &&
       ctor.prototype &&
       typeof ctor.prototype === 'object' &&
       typeof ctor.prototype === 'object' &&
-      ctor.prototype.className === Adapter.name
+      ctor.prototype.kind === Adapter.name
     ) {
     ) {
       adapterCtor = ctor;
       adapterCtor = ctor;
       break;
       break;

+ 2 - 2
src/adapter/adapter.js

@@ -15,11 +15,11 @@ import {PropertyUniquenessDecorator} from './decorator/index.js';
  */
  */
 export class Adapter extends Service {
 export class Adapter extends Service {
   /**
   /**
-   * Class name.
+   * Kind.
    *
    *
    * @type {string}
    * @type {string}
    */
    */
-  get className() {
+  get kind() {
     return Adapter.name;
     return Adapter.name;
   }
   }
 
 

+ 6 - 0
src/adapter/adapter.spec.js

@@ -15,6 +15,12 @@ import {PropertyUniquenessDecorator} from './decorator/index.js';
 const sandbox = chai.spy.sandbox();
 const sandbox = chai.spy.sandbox();
 
 
 describe('Adapter', function () {
 describe('Adapter', function () {
+  it('exposes kind getter', function () {
+    const adapter = new Adapter();
+    expect(adapter.kind).to.be.eq('Adapter');
+    expect(Adapter.prototype.kind).to.be.eq('Adapter');
+  });
+
   describe('constructor', function () {
   describe('constructor', function () {
     afterEach(function () {
     afterEach(function () {
       sandbox.restore();
       sandbox.restore();