@daiso-tech/core 0.30.0 → 0.31.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/dist/async/utilities/lazy-promise/lazy-promise.d.ts +16 -12
- package/dist/async/utilities/lazy-promise/lazy-promise.js +16 -12
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +2 -2
- package/dist/cache/implementations/derivables/cache/cache.d.ts +7 -151
- package/dist/cache/implementations/derivables/cache/cache.js +7 -151
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +8 -10
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +8 -10
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +5 -5
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +5 -5
- package/dist/collection/implementations/_shared.d.ts +2 -0
- package/dist/collection/implementations/_shared.js +2 -0
- package/dist/collection/implementations/_shared.js.map +1 -1
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +5 -5
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +5 -5
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +5 -5
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +5 -5
- 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 +6 -6
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +6 -6
- package/dist/lock/contracts/lock.contract.d.ts +4 -4
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +1 -2
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +1 -2
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +33 -16
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +33 -16
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +0 -204
- package/dist/lock/implementations/derivables/lock-provider/lock.js +0 -204
- 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 +8 -12
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +8 -12
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +1 -2
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +1 -2
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +0 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +0 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +1 -1
- package/dist/serde/contracts/flexible-serde.contract.d.ts +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +7 -7
- package/dist/serde/implementations/derivables/serde.js +7 -7
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +0 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +0 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js.map +1 -1
- package/package.json +2 -2
|
@@ -120,6 +120,9 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
120
120
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
121
121
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
122
122
|
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
123
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
124
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
125
|
+
* import Sqlite from "better-sqlite3";
|
|
123
126
|
*
|
|
124
127
|
* const database = new Sqlite("local.db");
|
|
125
128
|
* const lockAdapter = new SqliteLockAdapter({
|
|
@@ -128,8 +131,10 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
128
131
|
* // You need initialize the adapter once before using it.
|
|
129
132
|
* await lockAdapter.init();
|
|
130
133
|
*
|
|
134
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter())
|
|
131
135
|
* const lockProvider = new LockProvider({
|
|
132
136
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
137
|
+
* serde,
|
|
133
138
|
* adapter: lockAdapter,
|
|
134
139
|
* });
|
|
135
140
|
* ```
|
|
@@ -138,11 +143,14 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
138
143
|
* @example
|
|
139
144
|
* ```ts
|
|
140
145
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
141
|
-
* import type {
|
|
146
|
+
* import type { IDatabaseLockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
142
147
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
143
|
-
* import { KeyPrefixer, type ISqliteDatabase, type
|
|
148
|
+
* import { KeyPrefixer, type ISqliteDatabase, type AsyncFactoryFn } from "@daiso-tech/core/utilities";
|
|
149
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
150
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
151
|
+
* import Sqlite from "better-sqlite3";
|
|
144
152
|
*
|
|
145
|
-
*
|
|
153
|
+
* function lockAdapterFactory(database: ISqliteDatabase): AsyncFactoryFn<string, IDatabaseLockAdapter> {
|
|
146
154
|
* return async (prefix) => {
|
|
147
155
|
* const lockAdapter = new SqliteLockAdapter({
|
|
148
156
|
* database,
|
|
@@ -155,8 +163,10 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
155
163
|
* }
|
|
156
164
|
*
|
|
157
165
|
* const database = new Sqlite("local.db");
|
|
166
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
158
167
|
* const lockProvider = new LockProvider({
|
|
159
168
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
169
|
+
* serde,
|
|
160
170
|
* adapter: lockAdapterFactory(database),
|
|
161
171
|
* });
|
|
162
172
|
* ```
|
|
@@ -165,14 +175,17 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
165
175
|
* @example
|
|
166
176
|
* ```ts
|
|
167
177
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
168
|
-
* import type {
|
|
178
|
+
* import type { IDatabaseLockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
169
179
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
170
|
-
* import { KeyPrefixer, type ISqliteDatabase, type
|
|
180
|
+
* import { KeyPrefixer, type ISqliteDatabase, type IAsyncFactoryObject, type Promisable } from "@daiso-tech/core/utilities";
|
|
181
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
182
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
183
|
+
* import Sqlite from "better-sqlite3";
|
|
171
184
|
*
|
|
172
|
-
* class LockAdapterFactory implements
|
|
185
|
+
* class LockAdapterFactory implements IAsyncFactoryObject<string, IDatabaseLockAdapter> {
|
|
173
186
|
* constructor(private readonly database: ISqliteDatabase) {}
|
|
174
187
|
*
|
|
175
|
-
* async use(prefix: string):
|
|
188
|
+
* async use(prefix: string): Promise<IDatabaseLockAdapter> {
|
|
176
189
|
* const lockAdapter = new SqliteLockAdapter({
|
|
177
190
|
* database,
|
|
178
191
|
* tableName: `lock_${prefix}`,
|
|
@@ -184,8 +197,10 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
184
197
|
* }
|
|
185
198
|
*
|
|
186
199
|
* const database = new Sqlite("local.db");
|
|
200
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter())
|
|
187
201
|
* const lockProvider = new LockProvider({
|
|
188
202
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
203
|
+
* serde,
|
|
189
204
|
* adapter: new LockAdapterFactory(database),
|
|
190
205
|
* });
|
|
191
206
|
* ```
|
|
@@ -242,9 +257,9 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
242
257
|
* ```ts
|
|
243
258
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
244
259
|
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
245
|
-
* import { KeyPrefixer
|
|
246
|
-
* import { Serde } from "@daiso-tech/core/
|
|
247
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/
|
|
260
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
261
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
262
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
248
263
|
*
|
|
249
264
|
* const lockProvider = new LockProvider({
|
|
250
265
|
* adapter: new MemoryLockAdapter(),
|
|
@@ -262,13 +277,14 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
262
277
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
263
278
|
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
264
279
|
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
265
|
-
* import { Serde } from "@daiso-tech/core/
|
|
266
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/
|
|
280
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
281
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
267
282
|
*
|
|
283
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
268
284
|
* const lockProvider = new LockProvider({
|
|
269
285
|
* adapter: new MemoryLockAdapter(),
|
|
270
286
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
271
|
-
* serde
|
|
287
|
+
* serde,
|
|
272
288
|
* });
|
|
273
289
|
*
|
|
274
290
|
* // Will log null because the lockProvider is not in a group
|
|
@@ -287,13 +303,14 @@ export declare class LockProvider implements IGroupableLockProvider {
|
|
|
287
303
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
288
304
|
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
289
305
|
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
290
|
-
* import { Serde } from "@daiso-tech/core/
|
|
291
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/
|
|
306
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
307
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
292
308
|
*
|
|
309
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
293
310
|
* const lockProvider = new LockProvider({
|
|
294
311
|
* adapter: new MemoryLockAdapter(),
|
|
295
312
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
296
|
-
* serde
|
|
313
|
+
* serde,
|
|
297
314
|
* });
|
|
298
315
|
*
|
|
299
316
|
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
@@ -73,6 +73,9 @@ export class LockProvider {
|
|
|
73
73
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
74
74
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
75
75
|
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
76
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
77
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
78
|
+
* import Sqlite from "better-sqlite3";
|
|
76
79
|
*
|
|
77
80
|
* const database = new Sqlite("local.db");
|
|
78
81
|
* const lockAdapter = new SqliteLockAdapter({
|
|
@@ -81,8 +84,10 @@ export class LockProvider {
|
|
|
81
84
|
* // You need initialize the adapter once before using it.
|
|
82
85
|
* await lockAdapter.init();
|
|
83
86
|
*
|
|
87
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter())
|
|
84
88
|
* const lockProvider = new LockProvider({
|
|
85
89
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
90
|
+
* serde,
|
|
86
91
|
* adapter: lockAdapter,
|
|
87
92
|
* });
|
|
88
93
|
* ```
|
|
@@ -91,11 +96,14 @@ export class LockProvider {
|
|
|
91
96
|
* @example
|
|
92
97
|
* ```ts
|
|
93
98
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
94
|
-
* import type {
|
|
99
|
+
* import type { IDatabaseLockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
95
100
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
96
|
-
* import { KeyPrefixer, type ISqliteDatabase, type
|
|
101
|
+
* import { KeyPrefixer, type ISqliteDatabase, type AsyncFactoryFn } from "@daiso-tech/core/utilities";
|
|
102
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
103
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
104
|
+
* import Sqlite from "better-sqlite3";
|
|
97
105
|
*
|
|
98
|
-
*
|
|
106
|
+
* function lockAdapterFactory(database: ISqliteDatabase): AsyncFactoryFn<string, IDatabaseLockAdapter> {
|
|
99
107
|
* return async (prefix) => {
|
|
100
108
|
* const lockAdapter = new SqliteLockAdapter({
|
|
101
109
|
* database,
|
|
@@ -108,8 +116,10 @@ export class LockProvider {
|
|
|
108
116
|
* }
|
|
109
117
|
*
|
|
110
118
|
* const database = new Sqlite("local.db");
|
|
119
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
111
120
|
* const lockProvider = new LockProvider({
|
|
112
121
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
122
|
+
* serde,
|
|
113
123
|
* adapter: lockAdapterFactory(database),
|
|
114
124
|
* });
|
|
115
125
|
* ```
|
|
@@ -118,14 +128,17 @@ export class LockProvider {
|
|
|
118
128
|
* @example
|
|
119
129
|
* ```ts
|
|
120
130
|
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
121
|
-
* import type {
|
|
131
|
+
* import type { IDatabaseLockAdapter } from "@daiso-tech/core/lock/contracts";
|
|
122
132
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
123
|
-
* import { KeyPrefixer, type ISqliteDatabase, type
|
|
133
|
+
* import { KeyPrefixer, type ISqliteDatabase, type IAsyncFactoryObject, type Promisable } from "@daiso-tech/core/utilities";
|
|
134
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
135
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
136
|
+
* import Sqlite from "better-sqlite3";
|
|
124
137
|
*
|
|
125
|
-
* class LockAdapterFactory implements
|
|
138
|
+
* class LockAdapterFactory implements IAsyncFactoryObject<string, IDatabaseLockAdapter> {
|
|
126
139
|
* constructor(private readonly database: ISqliteDatabase) {}
|
|
127
140
|
*
|
|
128
|
-
* async use(prefix: string):
|
|
141
|
+
* async use(prefix: string): Promise<IDatabaseLockAdapter> {
|
|
129
142
|
* const lockAdapter = new SqliteLockAdapter({
|
|
130
143
|
* database,
|
|
131
144
|
* tableName: `lock_${prefix}`,
|
|
@@ -137,8 +150,10 @@ export class LockProvider {
|
|
|
137
150
|
* }
|
|
138
151
|
*
|
|
139
152
|
* const database = new Sqlite("local.db");
|
|
153
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter())
|
|
140
154
|
* const lockProvider = new LockProvider({
|
|
141
155
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
156
|
+
* serde,
|
|
142
157
|
* adapter: new LockAdapterFactory(database),
|
|
143
158
|
* });
|
|
144
159
|
* ```
|
|
@@ -258,9 +273,9 @@ export class LockProvider {
|
|
|
258
273
|
* ```ts
|
|
259
274
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
260
275
|
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
261
|
-
* import { KeyPrefixer
|
|
262
|
-
* import { Serde } from "@daiso-tech/core/
|
|
263
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/
|
|
276
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
277
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
278
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
264
279
|
*
|
|
265
280
|
* const lockProvider = new LockProvider({
|
|
266
281
|
* adapter: new MemoryLockAdapter(),
|
|
@@ -307,13 +322,14 @@ export class LockProvider {
|
|
|
307
322
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
308
323
|
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
309
324
|
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
310
|
-
* import { Serde } from "@daiso-tech/core/
|
|
311
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/
|
|
325
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
326
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
312
327
|
*
|
|
328
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
313
329
|
* const lockProvider = new LockProvider({
|
|
314
330
|
* adapter: new MemoryLockAdapter(),
|
|
315
331
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
316
|
-
* serde
|
|
332
|
+
* serde,
|
|
317
333
|
* });
|
|
318
334
|
*
|
|
319
335
|
* // Will log null because the lockProvider is not in a group
|
|
@@ -334,13 +350,14 @@ export class LockProvider {
|
|
|
334
350
|
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
335
351
|
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
336
352
|
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
337
|
-
* import { Serde } from "@daiso-tech/core/
|
|
338
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/
|
|
353
|
+
* import { Serde } from "@daiso-tech/core/serde";
|
|
354
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters";
|
|
339
355
|
*
|
|
356
|
+
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
340
357
|
* const lockProvider = new LockProvider({
|
|
341
358
|
* adapter: new MemoryLockAdapter(),
|
|
342
359
|
* keyPrefixer: new KeyPrefixer("lock"),
|
|
343
|
-
* serde
|
|
360
|
+
* serde,
|
|
344
361
|
* });
|
|
345
362
|
*
|
|
346
363
|
* const groupedLockProvider = lockProvider.withGroup("group-a");
|
|
@@ -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,EAMR,IAAI,EACJ,uBAAuB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAkB,MAAM,gCAAgC,CAAC;AAK7E,OAAO,EAMN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,WAAW,GAId,MAAM,4BAA4B,CAAC;AAapC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6EAA6E,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0EAA0E,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,2DAA2D,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EACH,SAAS,GAEZ,MAAM,+DAA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AkB;IAC9B,YAAY,CAAkB;IAC9B,WAAW,CAAe;IAC1B,aAAa,CAAe;IAC5B,UAAU,CAAkB;IAC5B,uBAAuB,CAAW;IAClC,mBAAmB,CAAW;IAC9B,kBAAkB,CAAW;IAC7B,KAAK,CAA4B;IAElD
|
|
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,EACJ,uBAAuB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAkB,MAAM,gCAAgC,CAAC;AAK7E,OAAO,EAMN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,WAAW,GAId,MAAM,4BAA4B,CAAC;AAapC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6EAA6E,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0EAA0E,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,2DAA2D,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,yDAAyD,CAAC;AAC/E,OAAO,EACH,SAAS,GAEZ,MAAM,+DAA+D,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2EAA2E,CAAC;AA4FjH;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAY;IACb,MAAM,CAAC,kBAAkB,CAC7B,OAA4C;QAE5C,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAC9C,WAAmC,E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,YAAY,CAAC;YACpB,OAAO,EAAE,IAAI,CAAC,kBAAkB;YAChC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC;YAC9C,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,iBAAiB;YAChC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;SAClC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -106,213 +106,9 @@ export declare class Lock implements ILock {
|
|
|
106
106
|
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
107
107
|
*/
|
|
108
108
|
subscribeMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
109
|
-
/**
|
|
110
|
-
* You can pass in a sync function or async function.
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
114
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
115
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
116
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
117
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
118
|
-
*
|
|
119
|
-
* const lockProvider = new LockProvider({
|
|
120
|
-
* adapter: new MemoryLockAdapter(),
|
|
121
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
122
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
123
|
-
* });
|
|
124
|
-
*
|
|
125
|
-
* const lock = lockProvider.create("a");
|
|
126
|
-
*
|
|
127
|
-
* await lock.run(async () => {
|
|
128
|
-
* console.log("START");
|
|
129
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
130
|
-
* console.log("END");
|
|
131
|
-
* });
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
135
|
-
* @example
|
|
136
|
-
* ```ts
|
|
137
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
138
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
139
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
140
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
141
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
142
|
-
*
|
|
143
|
-
* const lockProvider = new LockProvider({
|
|
144
|
-
* adapter: new MemoryLockAdapter(),
|
|
145
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
146
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
147
|
-
* });
|
|
148
|
-
*
|
|
149
|
-
* const lock = lockProvider.create("a");
|
|
150
|
-
*
|
|
151
|
-
* await lock.run(
|
|
152
|
-
* new LazyPromise(async () => {
|
|
153
|
-
* console.log("START");
|
|
154
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
155
|
-
* console.log("END");
|
|
156
|
-
* })
|
|
157
|
-
* );
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
109
|
run<TValue = void>(asyncFn: AsyncLazy<TValue>): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
161
|
-
/**
|
|
162
|
-
* You can pass in a sync function or async function.
|
|
163
|
-
* @example
|
|
164
|
-
* ```ts
|
|
165
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
166
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
167
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
168
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
169
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
170
|
-
*
|
|
171
|
-
* const lockProvider = new LockProvider({
|
|
172
|
-
* adapter: new MemoryLockAdapter(),
|
|
173
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
174
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* const lock = lockProvider.create("a");
|
|
178
|
-
*
|
|
179
|
-
* await lock.runOrFail(async () => {
|
|
180
|
-
* console.log("START");
|
|
181
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
182
|
-
* console.log("END");
|
|
183
|
-
* });
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
187
|
-
* @example
|
|
188
|
-
* ```ts
|
|
189
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
190
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
191
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
192
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
193
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
194
|
-
*
|
|
195
|
-
* const lockProvider = new LockProvider({
|
|
196
|
-
* adapter: new MemoryLockAdapter(),
|
|
197
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
198
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
199
|
-
* });
|
|
200
|
-
*
|
|
201
|
-
* const lock = lockProvider.create("a");
|
|
202
|
-
*
|
|
203
|
-
* await lock.runOrFail(
|
|
204
|
-
* new LazyPromise(async () => {
|
|
205
|
-
* console.log("START");
|
|
206
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
207
|
-
* console.log("END");
|
|
208
|
-
* })
|
|
209
|
-
* );
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
110
|
runOrFail<TValue = void>(asyncFn: AsyncLazy<TValue>): LazyPromise<TValue>;
|
|
213
|
-
/**
|
|
214
|
-
* You can pass in a sync function or async function.
|
|
215
|
-
* @example
|
|
216
|
-
* ```ts
|
|
217
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
218
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
219
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
220
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
221
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
222
|
-
*
|
|
223
|
-
* const lockProvider = new LockProvider({
|
|
224
|
-
* adapter: new MemoryLockAdapter(),
|
|
225
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
226
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
227
|
-
* });
|
|
228
|
-
*
|
|
229
|
-
* const lock = lockProvider.create("a");
|
|
230
|
-
*
|
|
231
|
-
* await lock.runBlocking(async () => {
|
|
232
|
-
* console.log("START");
|
|
233
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
234
|
-
* console.log("END");
|
|
235
|
-
* });
|
|
236
|
-
* ```
|
|
237
|
-
*
|
|
238
|
-
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
239
|
-
* @example
|
|
240
|
-
* ```ts
|
|
241
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
242
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
243
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
244
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
245
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
246
|
-
*
|
|
247
|
-
* const lockProvider = new LockProvider({
|
|
248
|
-
* adapter: new MemoryLockAdapter(),
|
|
249
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
250
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
251
|
-
* });
|
|
252
|
-
*
|
|
253
|
-
* const lock = lockProvider.create("a");
|
|
254
|
-
*
|
|
255
|
-
* await lock.runBlocking(
|
|
256
|
-
* new LazyPromise(async () => {
|
|
257
|
-
* console.log("START");
|
|
258
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
259
|
-
* console.log("END");
|
|
260
|
-
* })
|
|
261
|
-
* );
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
111
|
runBlocking<TValue = void>(asyncFn: AsyncLazy<TValue>, settings?: AquireBlockingSettings): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
265
|
-
/**
|
|
266
|
-
* You can pass in a sync function or async function.
|
|
267
|
-
* @example
|
|
268
|
-
* ```ts
|
|
269
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
270
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
271
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
272
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
273
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
274
|
-
*
|
|
275
|
-
* const lockProvider = new LockProvider({
|
|
276
|
-
* adapter: new MemoryLockAdapter(),
|
|
277
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
278
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
279
|
-
* });
|
|
280
|
-
*
|
|
281
|
-
* const lock = lockProvider.create("a");
|
|
282
|
-
*
|
|
283
|
-
* await lock.runBlockingOrFail(async () => {
|
|
284
|
-
* console.log("START");
|
|
285
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
286
|
-
* console.log("END");
|
|
287
|
-
* });
|
|
288
|
-
* ```
|
|
289
|
-
*
|
|
290
|
-
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
291
|
-
* @example
|
|
292
|
-
* ```ts
|
|
293
|
-
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
294
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
295
|
-
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
296
|
-
* import { Serde } from "@daiso-tech/core/adapter";
|
|
297
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
298
|
-
*
|
|
299
|
-
* const lockProvider = new LockProvider({
|
|
300
|
-
* adapter: new MemoryLockAdapter(),
|
|
301
|
-
* keyPrefixer: new KeyPrefixer("lock"),
|
|
302
|
-
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
303
|
-
* });
|
|
304
|
-
*
|
|
305
|
-
* const lock = lockProvider.create("a");
|
|
306
|
-
*
|
|
307
|
-
* await lock.runBlockingOrFail(
|
|
308
|
-
* new LazyPromise(async () => {
|
|
309
|
-
* console.log("START");
|
|
310
|
-
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
311
|
-
* console.log("END");
|
|
312
|
-
* })
|
|
313
|
-
* );
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
112
|
runBlockingOrFail<TValue = void>(asyncFn: AsyncLazy<TValue>, settings?: AquireBlockingSettings): LazyPromise<TValue>;
|
|
317
113
|
acquire(): LazyPromise<boolean>;
|
|
318
114
|
acquireOrFail(): LazyPromise<void>;
|