@daiso-tech/core 0.27.0 → 0.28.1
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.
- package/README.md +10 -10
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +57 -19
- package/dist/async/utilities/lazy-promise/lazy-promise.js +93 -52
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +2 -0
- package/dist/async/utilities/retry/retry-or-fail.js.map +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +98 -14
- package/dist/cache/implementations/adapters/_module-exports.d.ts +1 -0
- package/dist/cache/implementations/adapters/_module-exports.js +1 -0
- package/dist/cache/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.d.ts +1 -0
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js +2 -0
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js.map +1 -0
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +23 -0
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +41 -0
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +2 -3
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +250 -45
- package/dist/cache/implementations/derivables/cache/cache.js +256 -28
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +57 -18
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +70 -20
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +4 -20
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +7 -4
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +1 -1
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +21 -36
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +24 -17
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +57 -14
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +61 -13
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/lock/contracts/lock-provider.contract.d.ts +19 -5
- package/dist/lock/contracts/lock.contract.d.ts +37 -8
- package/dist/lock/implementations/adapters/_module-exports.d.ts +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.d.ts +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js +2 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js.map +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +17 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +24 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -0
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +2 -3
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +134 -62
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +139 -47
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +2 -0
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +8 -2
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +238 -0
- package/dist/lock/implementations/derivables/lock-provider/lock.js +258 -0
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +75 -9
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +86 -7
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +162 -8
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +1 -0
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +1 -0
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js.map +1 -1
- package/dist/utilities/_module-exports.d.ts +1 -1
- package/dist/utilities/_module-exports.js +1 -1
- package/dist/utilities/_module-exports.js.map +1 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +1 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
- package/dist/utilities/{_constants.d.ts → constants.d.ts} +0 -3
- package/dist/utilities/constants.js +5 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +2 -1
- package/dist/utilities/contracts/_module.js +2 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/sqlite-database.contract.d.ts +26 -0
- package/dist/utilities/contracts/sqlite-database.contract.js +5 -0
- package/dist/utilities/contracts/sqlite-database.contract.js.map +1 -0
- package/dist/utilities/functions.d.ts +4 -0
- package/dist/utilities/functions.js +10 -4
- package/dist/utilities/functions.js.map +1 -1
- package/dist/utilities/types.d.ts +4 -4
- package/package.json +1 -1
- package/dist/utilities/_constants.js +0 -8
- package/dist/utilities/_constants.js.map +0 -1
|
@@ -5,7 +5,7 @@ import { TimeSpan, type Factoryable, type IKeyPrefixer, type Items } from "../..
|
|
|
5
5
|
import { type Invokable, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
6
6
|
import type { IDatabaseLockAdapter, LockEvents } from "../../../../lock/contracts/_module-exports.js";
|
|
7
7
|
import { type ILock, type IGroupableLockProvider, type LockProviderCreateSettings, type ILockProvider, type ILockAdapter } from "../../../../lock/contracts/_module-exports.js";
|
|
8
|
-
import { LazyPromise, type
|
|
8
|
+
import { LazyPromise, type LazyPromiseSettingsBase } from "../../../../async/_module-exports.js";
|
|
9
9
|
import type { EventClass, EventInstance, IGroupableEventBus, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
10
10
|
import type { IFlexibleSerde } from "../../../../serde/contracts/_module-exports.js";
|
|
11
11
|
/**
|
|
@@ -13,9 +13,13 @@ import type { IFlexibleSerde } from "../../../../serde/contracts/_module-exports
|
|
|
13
13
|
* IMPORT_PATH: ```"@daiso-tech/core/lock"```
|
|
14
14
|
* @group Derivables
|
|
15
15
|
*/
|
|
16
|
-
export type LockProviderSettingsBase = {
|
|
16
|
+
export type LockProviderSettingsBase = LazyPromiseSettingsBase & {
|
|
17
17
|
keyPrefixer: IKeyPrefixer;
|
|
18
18
|
serde: OneOrMore<IFlexibleSerde>;
|
|
19
|
+
/**
|
|
20
|
+
* @default {""}
|
|
21
|
+
*/
|
|
22
|
+
serdeTransformerName?: string;
|
|
19
23
|
/**
|
|
20
24
|
* You can pass your owner id generator function.
|
|
21
25
|
*/
|
|
@@ -65,26 +69,6 @@ export type LockProviderSettingsBase = {
|
|
|
65
69
|
* ```
|
|
66
70
|
*/
|
|
67
71
|
defaultRefreshTime?: TimeSpan;
|
|
68
|
-
/**
|
|
69
|
-
* The default retry attempt to use in the returned <i>LazyPromise</i>.
|
|
70
|
-
* @default {null}
|
|
71
|
-
*/
|
|
72
|
-
retryAttempts?: number | null;
|
|
73
|
-
/**
|
|
74
|
-
* The default backof policy to use in the returned <i>LazyPromise</i>.
|
|
75
|
-
* @default {null}
|
|
76
|
-
*/
|
|
77
|
-
backoffPolicy?: BackoffPolicy | null;
|
|
78
|
-
/**
|
|
79
|
-
* The default retry policy to use in the returned <i>LazyPromise</i>.
|
|
80
|
-
* @default {null}
|
|
81
|
-
*/
|
|
82
|
-
retryPolicy?: RetryPolicy | null;
|
|
83
|
-
/**
|
|
84
|
-
* The default timeout to use in the returned <i>LazyPromise</i>.
|
|
85
|
-
* @default {null}
|
|
86
|
-
*/
|
|
87
|
-
timeout?: TimeSpan | null;
|
|
88
72
|
};
|
|
89
73
|
/**
|
|
90
74
|
*
|
|
@@ -121,7 +105,8 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
121
105
|
private readonly retryAttempts;
|
|
122
106
|
private readonly backoffPolicy;
|
|
123
107
|
private readonly retryPolicy;
|
|
124
|
-
private readonly
|
|
108
|
+
private readonly retryTimeout;
|
|
109
|
+
private readonly totalTimeout;
|
|
125
110
|
private readonly keyPrefixer;
|
|
126
111
|
private readonly createOwnerId;
|
|
127
112
|
private readonly defaultTtl;
|
|
@@ -153,19 +138,26 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
153
138
|
* @example
|
|
154
139
|
* ```ts
|
|
155
140
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
141
|
+
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
156
142
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
157
|
-
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
143
|
+
* import { KeyPrefixer, type ISqliteDatabase, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
158
144
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
145
|
+
* async function lockAdapterFactory(database: ISqliteDatabase): FactoryFn<string, ILockAdapter> {
|
|
146
|
+
* return async (prefix) => {
|
|
147
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
148
|
+
* database,
|
|
149
|
+
* tableName: `lock_${prefix}`,
|
|
150
|
+
* });
|
|
151
|
+
* // You need initialize the adapter once before using it.
|
|
152
|
+
* await lockAdapter.init();
|
|
153
|
+
* return lockAdapter;
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
165
156
|
*
|
|
157
|
+
* const database = new Sqlite("local.db");
|
|
166
158
|
* const lockProvider = new LockProvider({
|
|
167
159
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
168
|
-
* adapter:
|
|
160
|
+
* adapter: lockAdapterFactory(database),
|
|
169
161
|
* });
|
|
170
162
|
* ```
|
|
171
163
|
*
|
|
@@ -175,39 +167,12 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
175
167
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
176
168
|
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
177
169
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
178
|
-
* import { KeyPrefixer, type Promiseable } from "@daiso-tech/core/utilities";
|
|
179
|
-
*
|
|
180
|
-
* async function lockAdapterFactory(prefix: string): Promiseable<ILockAdapter> {
|
|
181
|
-
* const database = new Sqlite("local.db");
|
|
182
|
-
* const database = new Sqlite("local.db");
|
|
183
|
-
* const lockAdapter = new SqliteLockAdapter({
|
|
184
|
-
* database,
|
|
185
|
-
* tableName: `lock_${prefix}`,
|
|
186
|
-
* });
|
|
187
|
-
* // You need initialize the adapter once before using it.
|
|
188
|
-
* await lockAdapter.init();
|
|
189
|
-
* return lockAdapter;
|
|
190
|
-
* }
|
|
191
|
-
*
|
|
170
|
+
* import { KeyPrefixer, type ISqliteDatabase, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
192
171
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* adapter: lockAdapterFactory,
|
|
196
|
-
* });
|
|
197
|
-
* ```
|
|
198
|
-
*
|
|
199
|
-
* You can pass factory function that will create an adapter for every group.
|
|
200
|
-
* @example
|
|
201
|
-
* ```ts
|
|
202
|
-
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
203
|
-
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
204
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
205
|
-
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
172
|
+
* class LockAdapterFactory implements IFactoryObject<string, ILockAdapter> {
|
|
173
|
+
* constructor(private readonly database: ISqliteDatabase) {}
|
|
206
174
|
*
|
|
207
|
-
* class LockAdapterFactory implementations IFactoryObject<string, ILockAdapter> {
|
|
208
175
|
* async use(prefix: string): Promiseable<ILockAdapter> {
|
|
209
|
-
* const database = new Sqlite("local.db");
|
|
210
|
-
* const database = new Sqlite("local.db");
|
|
211
176
|
* const lockAdapter = new SqliteLockAdapter({
|
|
212
177
|
* database,
|
|
213
178
|
* tableName: `lock_${prefix}`,
|
|
@@ -218,23 +183,130 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
218
183
|
* }
|
|
219
184
|
* }
|
|
220
185
|
*
|
|
186
|
+
* const database = new Sqlite("local.db");
|
|
221
187
|
* const lockProvider = new LockProvider({
|
|
222
188
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
223
|
-
* adapter: new LockAdapterFactory(),
|
|
189
|
+
* adapter: new LockAdapterFactory(database),
|
|
224
190
|
* });
|
|
225
191
|
* ```
|
|
226
192
|
*/
|
|
227
193
|
constructor(settings: LockProviderSettings);
|
|
194
|
+
/**
|
|
195
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
196
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
197
|
+
*/
|
|
228
198
|
addListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
201
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
202
|
+
*/
|
|
229
203
|
addListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
206
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
207
|
+
*/
|
|
230
208
|
removeListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
211
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
212
|
+
*/
|
|
231
213
|
removeListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
216
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
217
|
+
*/
|
|
232
218
|
listenOnce<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
221
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
222
|
+
*/
|
|
233
223
|
asPromise<TEventClass extends EventClass<LockEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
224
|
+
/**
|
|
225
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
226
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
227
|
+
*/
|
|
234
228
|
subscribe<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
229
|
+
/**
|
|
230
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
231
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
232
|
+
*/
|
|
235
233
|
subscribeMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
236
234
|
private createLazyPromise;
|
|
235
|
+
/**
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
239
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
240
|
+
* import { KeyPrefixer, TimeSpan } from "@daiso-tech/core/utilities";
|
|
241
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
242
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
243
|
+
*
|
|
244
|
+
* const lockProvider = new LockProvider({
|
|
245
|
+
* adapter: new MemoryLockAdapter(),
|
|
246
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
247
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
248
|
+
* });
|
|
249
|
+
*
|
|
250
|
+
* const lock = lockProvider.create("a");
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
237
253
|
create(key: OneOrMore<string>, settings?: LockProviderCreateSettings): ILock;
|
|
254
|
+
/**
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
258
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
259
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
260
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
261
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
262
|
+
*
|
|
263
|
+
* const lockProvider = new LockProvider({
|
|
264
|
+
* adapter: new MemoryLockAdapter(),
|
|
265
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
266
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* // Will log null because the lockProvider is not in a group
|
|
270
|
+
* console.log(lockProvider.getGroup());
|
|
271
|
+
*
|
|
272
|
+
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
273
|
+
*
|
|
274
|
+
* // Will log "group-a" because the groupedLockProvider is in a group
|
|
275
|
+
* console.log(groupedLockProvider.getGroup());
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
238
278
|
getGroup(): string | null;
|
|
279
|
+
/**
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
283
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
284
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
285
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
286
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
287
|
+
*
|
|
288
|
+
* const lockProvider = new LockProvider({
|
|
289
|
+
* adapter: new MemoryLockAdapter(),
|
|
290
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
291
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
292
|
+
* });
|
|
293
|
+
*
|
|
294
|
+
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
295
|
+
*
|
|
296
|
+
* // Will log true because they are in different groups.
|
|
297
|
+
* console.log(
|
|
298
|
+
* await lockProvider
|
|
299
|
+
* .create("a")
|
|
300
|
+
* .acquire()
|
|
301
|
+
* );
|
|
302
|
+
*
|
|
303
|
+
* // Will log true because the lockProviders are in different groups.
|
|
304
|
+
* console.log(
|
|
305
|
+
* await groupedLockProvider
|
|
306
|
+
* .create("a")
|
|
307
|
+
* .acquire()
|
|
308
|
+
* );
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
239
311
|
withGroup(group: OneOrMore<string>): ILockProvider;
|
|
240
312
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Lock
|
|
3
3
|
*/
|
|
4
|
-
import { resolveOneOrMore, TimeSpan, } from "../../../../utilities/_module-exports.js";
|
|
4
|
+
import { resolveOneOrMore, TimeSpan, CORE, } from "../../../../utilities/_module-exports.js";
|
|
5
5
|
import { KeyPrefixer, resolveFactoryable, } from "../../../../utilities/_module-exports.js";
|
|
6
6
|
import {} from "../../../../lock/contracts/_module-exports.js";
|
|
7
7
|
import { LazyPromise, } from "../../../../async/_module-exports.js";
|
|
@@ -31,7 +31,7 @@ export class LockProvider {
|
|
|
31
31
|
return adapter;
|
|
32
32
|
}
|
|
33
33
|
static async resolveLockAdapterFactoryable(factoryable, settings) {
|
|
34
|
-
const { serde, lockStore, keyPrefixer, createLazyPromise, defaultBlockingInterval, defaultBlockingTime, defaultRefreshTime, groupableEventBus, } = settings;
|
|
34
|
+
const { serdeTransformerName, serde, lockStore, keyPrefixer, createLazyPromise, defaultBlockingInterval, defaultBlockingTime, defaultRefreshTime, groupableEventBus, } = settings;
|
|
35
35
|
const adapter = await resolveFactoryable(factoryable, keyPrefixer.keyPrefix);
|
|
36
36
|
const resolvedAdapter = LockProvider.resolveLockAdapter(adapter);
|
|
37
37
|
const transformer = new LockSerdeTransformer({
|
|
@@ -43,9 +43,10 @@ export class LockProvider {
|
|
|
43
43
|
defaultBlockingTime,
|
|
44
44
|
defaultRefreshTime,
|
|
45
45
|
groupableEventBus,
|
|
46
|
+
serdeTransformerName,
|
|
46
47
|
});
|
|
47
48
|
for (const serde_ of resolveOneOrMore(serde)) {
|
|
48
|
-
serde_.registerCustom(transformer);
|
|
49
|
+
serde_.registerCustom(transformer, CORE);
|
|
49
50
|
}
|
|
50
51
|
return resolvedAdapter;
|
|
51
52
|
}
|
|
@@ -57,7 +58,8 @@ export class LockProvider {
|
|
|
57
58
|
retryAttempts;
|
|
58
59
|
backoffPolicy;
|
|
59
60
|
retryPolicy;
|
|
60
|
-
|
|
61
|
+
retryTimeout;
|
|
62
|
+
totalTimeout;
|
|
61
63
|
keyPrefixer;
|
|
62
64
|
createOwnerId;
|
|
63
65
|
defaultTtl;
|
|
@@ -89,61 +91,41 @@ export class LockProvider {
|
|
|
89
91
|
* @example
|
|
90
92
|
* ```ts
|
|
91
93
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
92
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
93
|
-
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
94
|
-
*
|
|
95
|
-
* const database = new Sqlite("local.db");
|
|
96
|
-
* const lockAdapter = new SqliteLockAdapter({
|
|
97
|
-
* database,
|
|
98
|
-
* });
|
|
99
|
-
* // You need initialize the adapter once before using it.
|
|
100
|
-
* await lockAdapter.init();
|
|
101
|
-
*
|
|
102
|
-
* const lockProvider = new LockProvider({
|
|
103
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
104
|
-
* adapter: lockAdapter,
|
|
105
|
-
* });
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
112
94
|
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
113
95
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
114
|
-
* import { KeyPrefixer, type
|
|
96
|
+
* import { KeyPrefixer, type ISqliteDatabase, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
115
97
|
*
|
|
116
|
-
* async function lockAdapterFactory(
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
98
|
+
* async function lockAdapterFactory(database: ISqliteDatabase): FactoryFn<string, ILockAdapter> {
|
|
99
|
+
* return async (prefix) => {
|
|
100
|
+
* const lockAdapter = new SqliteLockAdapter({
|
|
101
|
+
* database,
|
|
102
|
+
* tableName: `lock_${prefix}`,
|
|
103
|
+
* });
|
|
104
|
+
* // You need initialize the adapter once before using it.
|
|
105
|
+
* await lockAdapter.init();
|
|
106
|
+
* return lockAdapter;
|
|
107
|
+
* }
|
|
126
108
|
* }
|
|
127
109
|
*
|
|
128
|
-
*
|
|
110
|
+
* const database = new Sqlite("local.db");
|
|
129
111
|
* const lockProvider = new LockProvider({
|
|
130
112
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
131
|
-
* adapter: lockAdapterFactory,
|
|
113
|
+
* adapter: lockAdapterFactory(database),
|
|
132
114
|
* });
|
|
133
115
|
* ```
|
|
134
116
|
*
|
|
135
|
-
* You can pass factory
|
|
117
|
+
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
136
118
|
* @example
|
|
137
119
|
* ```ts
|
|
138
120
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
139
121
|
* import type { ILockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
140
122
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
141
|
-
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
123
|
+
* import { KeyPrefixer, type ISqliteDatabase, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
124
|
+
*
|
|
125
|
+
* class LockAdapterFactory implements IFactoryObject<string, ILockAdapter> {
|
|
126
|
+
* constructor(private readonly database: ISqliteDatabase) {}
|
|
142
127
|
*
|
|
143
|
-
* class LockAdapterFactory implementations IFactoryObject<string, ILockAdapter> {
|
|
144
128
|
* async use(prefix: string): Promiseable<ILockAdapter> {
|
|
145
|
-
* const database = new Sqlite("local.db");
|
|
146
|
-
* const database = new Sqlite("local.db");
|
|
147
129
|
* const lockAdapter = new SqliteLockAdapter({
|
|
148
130
|
* database,
|
|
149
131
|
* tableName: `lock_${prefix}`,
|
|
@@ -154,9 +136,10 @@ export class LockProvider {
|
|
|
154
136
|
* }
|
|
155
137
|
* }
|
|
156
138
|
*
|
|
139
|
+
* const database = new Sqlite("local.db");
|
|
157
140
|
* const lockProvider = new LockProvider({
|
|
158
141
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
159
|
-
* adapter: new LockAdapterFactory(),
|
|
142
|
+
* adapter: new LockAdapterFactory(database),
|
|
160
143
|
* });
|
|
161
144
|
* ```
|
|
162
145
|
*/
|
|
@@ -164,7 +147,7 @@ export class LockProvider {
|
|
|
164
147
|
const { defaultTtl = TimeSpan.fromMinutes(5), defaultBlockingInterval = TimeSpan.fromSeconds(1), defaultBlockingTime = TimeSpan.fromMinutes(1), defaultRefreshTime = TimeSpan.fromMinutes(5), createOwnerId = () => v4(), serde, keyPrefixer, adapter, eventBus: groupableEventBus = new EventBus({
|
|
165
148
|
keyPrefixer: new KeyPrefixer("events"),
|
|
166
149
|
adapter: new MemoryEventBusAdapter(),
|
|
167
|
-
}), retryAttempts = null, backoffPolicy = null, retryPolicy = null,
|
|
150
|
+
}), retryAttempts = null, backoffPolicy = null, retryPolicy = null, retryTimeout = null, totalTimeout = null, serdeTransformerName = "", } = settings;
|
|
168
151
|
this.serde = serde;
|
|
169
152
|
this.defaultBlockingInterval = defaultBlockingInterval;
|
|
170
153
|
this.defaultBlockingTime = defaultBlockingTime;
|
|
@@ -177,7 +160,8 @@ export class LockProvider {
|
|
|
177
160
|
this.retryAttempts = retryAttempts;
|
|
178
161
|
this.backoffPolicy = backoffPolicy;
|
|
179
162
|
this.retryPolicy = retryPolicy;
|
|
180
|
-
this.
|
|
163
|
+
this.retryTimeout = retryTimeout;
|
|
164
|
+
this.totalTimeout = totalTimeout;
|
|
181
165
|
this.eventBus = this.eventBus = this.groupableEventBus.withGroup(this.keyPrefixer.resolvedRootPrefix);
|
|
182
166
|
if (this.keyPrefixer.resolvedGroup) {
|
|
183
167
|
this.eventBus = this.groupableEventBus.withGroup([
|
|
@@ -194,29 +178,62 @@ export class LockProvider {
|
|
|
194
178
|
defaultBlockingTime,
|
|
195
179
|
defaultRefreshTime,
|
|
196
180
|
groupableEventBus,
|
|
181
|
+
serdeTransformerName,
|
|
197
182
|
}));
|
|
198
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
186
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
187
|
+
*/
|
|
199
188
|
addListener(event, listener) {
|
|
200
189
|
return this.eventBus.addListener(event, listener);
|
|
201
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
193
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
194
|
+
*/
|
|
202
195
|
addListenerMany(events, listener) {
|
|
203
196
|
return this.eventBus.addListenerMany(events, listener);
|
|
204
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
200
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
201
|
+
*/
|
|
205
202
|
removeListener(event, listener) {
|
|
206
203
|
return this.eventBus.removeListener(event, listener);
|
|
207
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
207
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
208
|
+
*/
|
|
208
209
|
removeListenerMany(events, listener) {
|
|
209
210
|
return this.eventBus.removeListenerMany(events, listener);
|
|
210
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
214
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
215
|
+
*/
|
|
211
216
|
listenOnce(event, listener) {
|
|
212
217
|
return this.eventBus.listenOnce(event, listener);
|
|
213
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
221
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
222
|
+
*/
|
|
214
223
|
asPromise(event) {
|
|
215
224
|
return this.eventBus.asPromise(event);
|
|
216
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
228
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
229
|
+
*/
|
|
217
230
|
subscribe(event, listener) {
|
|
218
231
|
return this.eventBus.subscribe(event, listener);
|
|
219
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* You can listen to the following <i>{@link LockEvents}</i> of all <i>{@link ILock}</i> instances created by the <i>{@link ILockProvider}</i>.
|
|
235
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
236
|
+
*/
|
|
220
237
|
subscribeMany(events, listener) {
|
|
221
238
|
return this.eventBus.subscribeMany(events, listener);
|
|
222
239
|
}
|
|
@@ -225,9 +242,28 @@ export class LockProvider {
|
|
|
225
242
|
retryAttempts: this.retryAttempts,
|
|
226
243
|
backoffPolicy: this.backoffPolicy,
|
|
227
244
|
retryPolicy: this.retryPolicy,
|
|
228
|
-
|
|
245
|
+
retryTimeout: this.retryTimeout,
|
|
246
|
+
totalTimeout: this.totalTimeout,
|
|
229
247
|
});
|
|
230
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
253
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
254
|
+
* import { KeyPrefixer, TimeSpan } from "@daiso-tech/core/utilities";
|
|
255
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
256
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
257
|
+
*
|
|
258
|
+
* const lockProvider = new LockProvider({
|
|
259
|
+
* adapter: new MemoryLockAdapter(),
|
|
260
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
261
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* const lock = lockProvider.create("a");
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
231
267
|
create(key, settings = {}) {
|
|
232
268
|
const { ttl = this.defaultTtl, owner = this.createOwnerId() } = settings;
|
|
233
269
|
const keyObj = this.keyPrefixer.create(key);
|
|
@@ -258,9 +294,65 @@ export class LockProvider {
|
|
|
258
294
|
defaultRefreshTime: this.defaultRefreshTime,
|
|
259
295
|
});
|
|
260
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
301
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
302
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
303
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
304
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
305
|
+
*
|
|
306
|
+
* const lockProvider = new LockProvider({
|
|
307
|
+
* adapter: new MemoryLockAdapter(),
|
|
308
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
309
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
310
|
+
* });
|
|
311
|
+
*
|
|
312
|
+
* // Will log null because the lockProvider is not in a group
|
|
313
|
+
* console.log(lockProvider.getGroup());
|
|
314
|
+
*
|
|
315
|
+
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
316
|
+
*
|
|
317
|
+
* // Will log "group-a" because the groupedLockProvider is in a group
|
|
318
|
+
* console.log(groupedLockProvider.getGroup());
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
261
321
|
getGroup() {
|
|
262
322
|
return this.keyPrefixer.resolvedGroup;
|
|
263
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
328
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
329
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
330
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
331
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
332
|
+
*
|
|
333
|
+
* const lockProvider = new LockProvider({
|
|
334
|
+
* adapter: new MemoryLockAdapter(),
|
|
335
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
336
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
337
|
+
* });
|
|
338
|
+
*
|
|
339
|
+
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
340
|
+
*
|
|
341
|
+
* // Will log true because they are in different groups.
|
|
342
|
+
* console.log(
|
|
343
|
+
* await lockProvider
|
|
344
|
+
* .create("a")
|
|
345
|
+
* .acquire()
|
|
346
|
+
* );
|
|
347
|
+
*
|
|
348
|
+
* // Will log true because the lockProviders are in different groups.
|
|
349
|
+
* console.log(
|
|
350
|
+
* await groupedLockProvider
|
|
351
|
+
* .create("a")
|
|
352
|
+
* .acquire()
|
|
353
|
+
* );
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
264
356
|
withGroup(group) {
|
|
265
357
|
return new LockProvider({
|
|
266
358
|
adapter: this.adapterFactoryable,
|
|
@@ -275,7 +367,7 @@ export class LockProvider {
|
|
|
275
367
|
retryAttempts: this.retryAttempts,
|
|
276
368
|
backoffPolicy: this.backoffPolicy,
|
|
277
369
|
retryPolicy: this.retryPolicy,
|
|
278
|
-
|
|
370
|
+
retryTimeout: this.retryTimeout,
|
|
279
371
|
});
|
|
280
372
|
}
|
|
281
373
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-provider.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/derivables/lock-provider/lock-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,gBAAgB,EAChB,QAAQ,
|
|
1
|
+
{"version":3,"file":"lock-provider.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/derivables/lock-provider/lock-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,gBAAgB,EAChB,QAAQ,EAMR,IAAI,GACP,MAAM,gCAAgC,CAAC;AACxC,O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ClC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -21,6 +21,7 @@ export type LockSerdeTransformerSettings = {
|
|
|
21
21
|
defaultBlockingTime: TimeSpan;
|
|
22
22
|
defaultRefreshTime: TimeSpan;
|
|
23
23
|
groupableEventBus: IGroupableEventBus<LockEvents>;
|
|
24
|
+
serdeTransformerName: string;
|
|
24
25
|
};
|
|
25
26
|
/**
|
|
26
27
|
* @internal
|
|
@@ -34,6 +35,7 @@ export declare class LockSerdeTransformer implements ISerdeTransformer<Lock, ISe
|
|
|
34
35
|
private readonly defaultBlockingTime;
|
|
35
36
|
private readonly defaultRefreshTime;
|
|
36
37
|
private readonly groupableEventBus;
|
|
38
|
+
private readonly serdeTransformerName;
|
|
37
39
|
constructor(settings: LockSerdeTransformerSettings);
|
|
38
40
|
get name(): OneOrMore<string>;
|
|
39
41
|
isApplicable(value: unknown): value is Lock;
|
|
@@ -16,8 +16,10 @@ export class LockSerdeTransformer {
|
|
|
16
16
|
defaultBlockingTime;
|
|
17
17
|
defaultRefreshTime;
|
|
18
18
|
groupableEventBus;
|
|
19
|
+
serdeTransformerName;
|
|
19
20
|
constructor(settings) {
|
|
20
|
-
const { adapter, lockStore, keyPrefixer, createLazyPromise, defaultBlockingInterval, defaultBlockingTime, defaultRefreshTime, groupableEventBus, } = settings;
|
|
21
|
+
const { adapter, lockStore, keyPrefixer, createLazyPromise, defaultBlockingInterval, defaultBlockingTime, defaultRefreshTime, groupableEventBus, serdeTransformerName, } = settings;
|
|
22
|
+
this.serdeTransformerName = serdeTransformerName;
|
|
21
23
|
this.adapter = adapter;
|
|
22
24
|
this.lockStore = lockStore;
|
|
23
25
|
this.keyPrefixer = keyPrefixer;
|
|
@@ -28,7 +30,11 @@ export class LockSerdeTransformer {
|
|
|
28
30
|
this.groupableEventBus = groupableEventBus;
|
|
29
31
|
}
|
|
30
32
|
get name() {
|
|
31
|
-
return [
|
|
33
|
+
return [
|
|
34
|
+
"lock",
|
|
35
|
+
this.serdeTransformerName,
|
|
36
|
+
getConstructorName(this.adapter),
|
|
37
|
+
];
|
|
32
38
|
}
|
|
33
39
|
isApplicable(value) {
|
|
34
40
|
return value instanceof Lock && getConstructorName(value) === Lock.name;
|