vona-module-a-redlock 5.0.21 → 5.0.23

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.
@@ -1,19 +1,8 @@
1
1
  import { Meta } from 'vona-module-a-meta';
2
2
  import { BeanRedlockBase } from 'vona-module-a-redlock';
3
3
 
4
- export interface Meta<%=argv.beanNameCapitalize%> {
5
- // lock<RESULT>(resource: 'name', fn: FunctionAsync<RESULT>, options?: IRedlockLockOptions): Promise<RESULT>;
6
- // lockIsolate<RESULT>(
7
- // resource: 'name',
8
- // fn: FunctionAsync<RESULT>,
9
- // options?: IRedlockLockIsolateOptions,
10
- // ): Promise<RESULT>;
11
- // lockIsolate<RESULT, KEY extends string>(
12
- // resource: `prefix.${KEY}`,
13
- // fn: FunctionAsync<RESULT>,
14
- // options?: IRedlockLockIsolateOptions,
15
- // ): Promise<RESULT>;
16
- }
4
+ export type Type<%=argv.beanNameCapitalize%>LockResource = never;
5
+ export type Type<%=argv.beanNameCapitalize%>LockIsolateResource = never;
17
6
 
18
7
  @Meta()
19
- export class Meta<%=argv.beanNameCapitalize%> extends BeanRedlockBase {}
8
+ export class Meta<%=argv.beanNameCapitalize%> extends BeanRedlockBase<Type<%=argv.beanNameCapitalize%>LockResource,Type<%=argv.beanNameCapitalize%>LockIsolateResource> {}
package/dist/index.js CHANGED
@@ -94,16 +94,11 @@ let ScopeModuleARedlock = (_dec = Scope(), _dec2 = BeanInfo({
94
94
  /** scope: end */
95
95
 
96
96
  class BeanRedlockBase extends BeanBase {
97
- __get__(prop) {
98
- if (prop === 'lock') {
99
- return (resource, fn, options) => {
100
- return this.$scope.redlock.service.redlock.lock(this._prepareResource(resource), fn, options);
101
- };
102
- } else if (prop === 'lockIsolate') {
103
- return (resource, fn, options) => {
104
- return this.$scope.redlock.service.redlock.lockIsolate(this._prepareResource(resource), fn, options);
105
- };
106
- }
97
+ async lock(resource, fn, options) {
98
+ return this.$scope.redlock.service.redlock.lock(this._prepareResource(resource), fn, options);
99
+ }
100
+ async lockIsolate(resource, fn, options) {
101
+ return this.$scope.redlock.service.redlock.lockIsolate(this._prepareResource(resource), fn, options);
107
102
  }
108
103
  _prepareResource(resource) {
109
104
  return `${this[SymbolModuleBelong]}.${resource}`;
@@ -1,7 +1,8 @@
1
1
  import type { FunctionAsync } from 'vona';
2
- import type { IRedlockLockIsolateOptions } from '../types/redlock.ts';
2
+ import type { IRedlockLockIsolateOptions, IRedlockLockOptions } from '../types/redlock.ts';
3
3
  import { BeanBase } from 'vona';
4
- export declare class BeanRedlockBase extends BeanBase {
5
- protected __get__(prop: string): ((resource: string, fn: FunctionAsync<any>, options?: IRedlockLockIsolateOptions) => Promise<any>) | undefined;
4
+ export declare class BeanRedlockBase<TypeRedlockLockResource, TypeRedlockLockIsolateResource> extends BeanBase {
5
+ lock<RESULT>(resource: TypeRedlockLockResource, fn: FunctionAsync<RESULT>, options?: IRedlockLockOptions): Promise<RESULT>;
6
+ lockIsolate<RESULT>(resource: TypeRedlockLockIsolateResource, fn: FunctionAsync<RESULT>, options?: IRedlockLockIsolateOptions): Promise<RESULT>;
6
7
  private _prepareResource;
7
8
  }
@@ -8,3 +8,8 @@ export interface IRedlockLockOptions {
8
8
  }
9
9
  export interface IRedlockLockIsolateOptions extends IRedlockLockOptions, Partial<IDbInfo> {
10
10
  }
11
+ declare module 'vona-module-a-meta' {
12
+ interface IMetaNameRecord {
13
+ redlock: never;
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-redlock",
3
3
  "type": "module",
4
- "version": "5.0.21",
4
+ "version": "5.0.23",
5
5
  "title": "a-redlock",
6
6
  "vonaModule": {
7
7
  "dependencies": {},