@daiso-tech/core 0.36.0 → 0.37.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.
- package/dist/async/middlewares/_shared.d.ts +6 -1
- package/dist/async/middlewares/_shared.js +11 -1
- package/dist/async/middlewares/_shared.js.map +1 -1
- package/dist/async/middlewares/fallback/fallback.middleware.d.ts +1 -1
- package/dist/async/middlewares/fallback/fallback.middleware.js +2 -1
- package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -1
- package/dist/async/middlewares/retry/retry.middleware.js +2 -2
- package/dist/async/middlewares/retry/retry.middleware.js.map +1 -1
- package/dist/cache/contracts/cache-factory.contract.d.ts +2 -2
- package/dist/cache/implementations/adapters/_module-exports.d.ts +1 -2
- package/dist/cache/implementations/adapters/_module-exports.js +1 -2
- package/dist/cache/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +41 -16
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +102 -57
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +15 -3
- package/dist/cache/implementations/derivables/cache/cache.js +15 -2
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +11 -8
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +9 -0
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/collection/contracts/async-collection.contract.d.ts +6 -0
- package/dist/collection/contracts/collection.contract.d.ts +6 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.d.ts +1 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.js +1 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.d.ts +7 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js +17 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js.map +1 -0
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +2 -0
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +4 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/_shared/_module.d.ts +1 -0
- package/dist/collection/implementations/iterable-collection/_shared/_module.js +1 -0
- package/dist/collection/implementations/iterable-collection/_shared/_module.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.d.ts +7 -0
- package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js +21 -0
- package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js.map +1 -0
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +2 -0
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +4 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +2 -0
- package/dist/collection/implementations/list-collection/list-collection.js +14 -1
- package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +2 -2
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +34 -4
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +46 -6
- 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 +9 -7
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +11 -0
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/lock/implementations/adapters/_module-exports.d.ts +1 -2
- package/dist/lock/implementations/adapters/_module-exports.js +1 -2
- package/dist/lock/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +37 -12
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +73 -32
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/utilities/functions/_module-exports.d.ts +1 -0
- package/dist/utilities/functions/_module-exports.js +1 -0
- package/dist/utilities/functions/_module-exports.js.map +1 -1
- package/dist/utilities/functions/lazy.d.ts +4 -0
- package/dist/utilities/functions/lazy.js +9 -3
- package/dist/utilities/functions/lazy.js.map +1 -1
- package/dist/utilities/functions/validate.d.ts +8 -0
- package/dist/utilities/functions/validate.js +17 -0
- package/dist/utilities/functions/validate.js.map +1 -0
- package/package.json +14 -11
- package/dist/cache/implementations/adapters/libsql-cache-adapter/_module.d.ts +0 -1
- package/dist/cache/implementations/adapters/libsql-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +0 -75
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +0 -95
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +0 -1
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/_module.d.ts +0 -1
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +0 -70
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +0 -94
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +0 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/_module.d.ts +0 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/_module.js +0 -2
- package/dist/lock/implementations/adapters/libsql-lock-adapter/_module.js.map +0 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +0 -60
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +0 -84
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +0 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/_module.d.ts +0 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/_module.js +0 -2
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/_module.js.map +0 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +0 -59
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +0 -83
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +0 -1
package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libsql-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kEAAkE,CAAC;AACt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AyB;QAClC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QAClB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAyB;QACzC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,IAAyB;QAC3C,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAA0B;QAC/C,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,IAAc;QACpC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAc;QAClC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,SAAS;QACX,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,iBAAiB,CAAC,MAAc;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../../cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/sqlite-cache-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,+EAA+E,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Cache
|
|
3
|
-
*/
|
|
4
|
-
import { type ICacheData, type ICacheInsert, type ICacheUpdate, type IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
5
|
-
import { type TimeSpan, type IInitizable, type IDeinitizable, type IPrunable, type ISqliteDatabase } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
import type { ISerde } from "../../../../serde/contracts/_module-exports.js";
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
|
|
10
|
-
* @group Adapters
|
|
11
|
-
*/
|
|
12
|
-
export type SqliteCacheAdapterSettings = {
|
|
13
|
-
database: ISqliteDatabase;
|
|
14
|
-
tableName?: string;
|
|
15
|
-
serde: ISerde<string>;
|
|
16
|
-
/**
|
|
17
|
-
* @default
|
|
18
|
-
* ```ts
|
|
19
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
20
|
-
*
|
|
21
|
-
* TimeSpan.fromMinutes(1);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
expiredKeysRemovalInterval?: TimeSpan;
|
|
25
|
-
/**
|
|
26
|
-
* @default {true}
|
|
27
|
-
*/
|
|
28
|
-
shouldRemoveExpiredKeys?: boolean;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* To utilize the `SqliteCacheAdapter`, you must install the `"better-sqlite3"` package and supply a {@link ISerde | `ISerde<string>`}, with adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
|
|
32
|
-
*
|
|
33
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
|
|
34
|
-
* @group Adapters
|
|
35
|
-
*/
|
|
36
|
-
export declare class SqliteCacheAdapter<TType = unknown> implements IDatabaseCacheAdapter<TType>, IInitizable, IDeinitizable, IPrunable {
|
|
37
|
-
private readonly adapter;
|
|
38
|
-
/**
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
42
|
-
* import { Serde } from "@daiso-tech/core/serde";
|
|
43
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
44
|
-
* import Sqlite from "better-sqlite3";
|
|
45
|
-
*
|
|
46
|
-
* const database = new Sqlite("local.db");
|
|
47
|
-
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
48
|
-
* const cacheAdapter = new SqliteCacheAdapter({
|
|
49
|
-
* database,
|
|
50
|
-
* serde,
|
|
51
|
-
* });
|
|
52
|
-
* // You need initialize the adapter once before using it.
|
|
53
|
-
* await cacheAdapter.init();
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
constructor(settings: SqliteCacheAdapterSettings);
|
|
57
|
-
removeAllExpired(): Promise<void>;
|
|
58
|
-
deInit(): Promise<void>;
|
|
59
|
-
init(): Promise<void>;
|
|
60
|
-
insert(data: ICacheInsert<TType>): Promise<void>;
|
|
61
|
-
upsert(data: ICacheInsert<TType>): Promise<ICacheData<TType> | null>;
|
|
62
|
-
find(key: string): Promise<ICacheData<TType> | null>;
|
|
63
|
-
updateExpired(data: ICacheInsert<TType>): Promise<number>;
|
|
64
|
-
updateUnexpired(data: ICacheUpdate<TType>): Promise<number>;
|
|
65
|
-
incrementUnexpired(data: ICacheUpdate<number>): Promise<number>;
|
|
66
|
-
removeUnexpiredMany(keys: string[]): Promise<number>;
|
|
67
|
-
removeExpiredMany(keys: string[]): Promise<number>;
|
|
68
|
-
removeAll(): Promise<void>;
|
|
69
|
-
removeByKeyPrefix(prefix: string): Promise<void>;
|
|
70
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Cache
|
|
3
|
-
*/
|
|
4
|
-
import {} from "../../../../cache/contracts/_module-exports.js";
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
-
import { SuperJsonSerdeAdapter } from "../../../../serde/implementations/adapters/_module-exports.js";
|
|
7
|
-
import { KyselyTableNameTransformerPlugin, } from "../../../../utilities/_module-exports.js";
|
|
8
|
-
import { Kysely, SqliteDialect } from "kysely";
|
|
9
|
-
import { KyselyCacheAdapter } from "../../../../cache/implementations/adapters/kysely-cache-adapter/_module.js";
|
|
10
|
-
/**
|
|
11
|
-
* To utilize the `SqliteCacheAdapter`, you must install the `"better-sqlite3"` package and supply a {@link ISerde | `ISerde<string>`}, with adapter like {@link SuperJsonSerdeAdapter | `SuperJsonSerdeAdapter `}.
|
|
12
|
-
*
|
|
13
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/adapters"`
|
|
14
|
-
* @group Adapters
|
|
15
|
-
*/
|
|
16
|
-
export class SqliteCacheAdapter {
|
|
17
|
-
adapter;
|
|
18
|
-
/**
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { SqliteCacheAdapter } from "@daiso-tech/core/cache/adapters";
|
|
22
|
-
* import { Serde } from "@daiso-tech/core/serde";
|
|
23
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
24
|
-
* import Sqlite from "better-sqlite3";
|
|
25
|
-
*
|
|
26
|
-
* const database = new Sqlite("local.db");
|
|
27
|
-
* const serde = new Serde(new SuperJsonSerdeAdapter());
|
|
28
|
-
* const cacheAdapter = new SqliteCacheAdapter({
|
|
29
|
-
* database,
|
|
30
|
-
* serde,
|
|
31
|
-
* });
|
|
32
|
-
* // You need initialize the adapter once before using it.
|
|
33
|
-
* await cacheAdapter.init();
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
constructor(settings) {
|
|
37
|
-
const { database, tableName = "cache", serde, expiredKeysRemovalInterval, shouldRemoveExpiredKeys, } = settings;
|
|
38
|
-
this.adapter = new KyselyCacheAdapter({
|
|
39
|
-
database: new Kysely({
|
|
40
|
-
dialect: new SqliteDialect({
|
|
41
|
-
database: database,
|
|
42
|
-
}),
|
|
43
|
-
plugins: [
|
|
44
|
-
new KyselyTableNameTransformerPlugin({
|
|
45
|
-
cache: tableName,
|
|
46
|
-
}),
|
|
47
|
-
],
|
|
48
|
-
}),
|
|
49
|
-
serde,
|
|
50
|
-
expiredKeysRemovalInterval,
|
|
51
|
-
shouldRemoveExpiredKeys,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async removeAllExpired() {
|
|
55
|
-
await this.adapter.removeAllExpired();
|
|
56
|
-
}
|
|
57
|
-
async deInit() {
|
|
58
|
-
await this.adapter.deInit();
|
|
59
|
-
}
|
|
60
|
-
async init() {
|
|
61
|
-
await this.adapter.init();
|
|
62
|
-
}
|
|
63
|
-
async insert(data) {
|
|
64
|
-
await this.adapter.insert(data);
|
|
65
|
-
}
|
|
66
|
-
async upsert(data) {
|
|
67
|
-
return await this.adapter.upsert(data);
|
|
68
|
-
}
|
|
69
|
-
async find(key) {
|
|
70
|
-
return await this.adapter.find(key);
|
|
71
|
-
}
|
|
72
|
-
async updateExpired(data) {
|
|
73
|
-
return await this.adapter.updateExpired(data);
|
|
74
|
-
}
|
|
75
|
-
async updateUnexpired(data) {
|
|
76
|
-
return await this.adapter.updateUnexpired(data);
|
|
77
|
-
}
|
|
78
|
-
async incrementUnexpired(data) {
|
|
79
|
-
return await this.adapter.incrementUnexpired(data);
|
|
80
|
-
}
|
|
81
|
-
async removeUnexpiredMany(keys) {
|
|
82
|
-
return await this.adapter.removeUnexpiredMany(keys);
|
|
83
|
-
}
|
|
84
|
-
async removeExpiredMany(keys) {
|
|
85
|
-
return await this.adapter.removeExpiredMany(keys);
|
|
86
|
-
}
|
|
87
|
-
async removeAll() {
|
|
88
|
-
await this.adapter.removeAll();
|
|
89
|
-
}
|
|
90
|
-
async removeByKeyPrefix(prefix) {
|
|
91
|
-
await this.adapter.removeByKeyPrefix(prefix);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=sqlite-cache-adapter.js.map
|
package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-cache-adapter.js","sourceRoot":"","sources":["../../../../../src/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAKN,MAAM,sCAAsC,CAAC;AAC9C,6DAA6D;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,EAIH,gCAAgC,GAGnC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kEAAkE,CAAC;AA4BtG;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAOV,OAAO,CAA4B;IAEpD;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,QAAoC;QAC5C,MAAM,EACF,QAAQ,EACR,SAAS,GAAG,OAAO,EACnB,KAAK,EACL,0BAA0B,EAC1B,uBAAuB,GAC1B,GAAG,QAAQ,CAAC;QAEb,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAkB,CAAC;YAClC,QAAQ,EAAE,IAAI,MAAM,CAAC;gBACjB,OAAO,EAAE,IAAI,aAAa,CAAC;oBACvB,QAAQ,EAAE,QAAQ;iBACrB,CAAC;gBACF,OAAO,EAAE;oBACL,IAAI,gCAAgC,CAAC;wBACjC,KAAK,EAAE,SAAS;qBACnB,CAAC;iBACL;aACJ,CAAC;YACF,KAAK;YACL,0BAA0B;YAC1B,uBAAuB;SAC1B,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,gBAAgB;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAC1C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ACnC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAc;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../../lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/libsql-lock-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,4EAA4E,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Lock
|
|
3
|
-
*/
|
|
4
|
-
import type { IDatabaseLockAdapter, ILockData } from "../../../../lock/contracts/_module-exports.js";
|
|
5
|
-
import { type IDeinitizable, type IInitizable, type IPrunable, TimeSpan } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
import type { Client } from "@libsql/client";
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
|
|
10
|
-
* @group Adapters
|
|
11
|
-
*/
|
|
12
|
-
export type LibsqlLockAdapterSettings = {
|
|
13
|
-
database: Client;
|
|
14
|
-
tableName?: string;
|
|
15
|
-
expiredKeysRemovalInterval?: TimeSpan;
|
|
16
|
-
shouldRemoveExpiredKeys?: boolean;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* To utilize the `LibsqlLockAdapter`, you must install the `"@libsql/client"` package.
|
|
20
|
-
*
|
|
21
|
-
* Note in order to use `LibsqlLockAdapter` correctly, ensure you use a single, consistent database across all server instances.
|
|
22
|
-
* This means you can't use libsql embedded replicas.
|
|
23
|
-
*
|
|
24
|
-
* IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
|
|
25
|
-
* @group Adapters
|
|
26
|
-
*/
|
|
27
|
-
export declare class LibsqlLockAdapter implements IDatabaseLockAdapter, IDeinitizable, IInitizable, IPrunable {
|
|
28
|
-
private databaseLockAdapter;
|
|
29
|
-
/***
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { LibsqlLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
33
|
-
* import { createClient } from "@libsql/client";
|
|
34
|
-
*
|
|
35
|
-
* const database = createClient({ url: "file:local.db" });
|
|
36
|
-
* const lockAdapter = new LibsqlLockAdapter({
|
|
37
|
-
* database,
|
|
38
|
-
* });
|
|
39
|
-
* // You need initialize the adapter once before using it.
|
|
40
|
-
* await lockAdapter.init();
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
constructor(settings: LibsqlLockAdapterSettings);
|
|
44
|
-
removeAllExpired(): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Removes the table where the lock keys are stored and removes the table indexes.
|
|
47
|
-
* Note all lock data will be removed.
|
|
48
|
-
*/
|
|
49
|
-
deInit(): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Creates the table where the lock keys are stored and it's related indexes.
|
|
52
|
-
* Note the `init` method needs to be called before using the adapter.
|
|
53
|
-
*/
|
|
54
|
-
init(): Promise<void>;
|
|
55
|
-
insert(key: string, owner: string, expiration: Date | null): Promise<void>;
|
|
56
|
-
update(key: string, owner: string, expiration: Date | null): Promise<number>;
|
|
57
|
-
remove(key: string, owner: string | null): Promise<void>;
|
|
58
|
-
refresh(key: string, owner: string, expiration: Date): Promise<number>;
|
|
59
|
-
find(key: string): Promise<ILockData | null>;
|
|
60
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Lock
|
|
3
|
-
*/
|
|
4
|
-
import { TimeSpan, } from "../../../../utilities/_module-exports.js";
|
|
5
|
-
import { Kysely } from "kysely";
|
|
6
|
-
import { KyselyTableNameTransformerPlugin } from "../../../../utilities/_module-exports.js";
|
|
7
|
-
import { LibsqlDialect } from "@libsql/kysely-libsql";
|
|
8
|
-
import { KyselyLockAdapter } from "../../../../lock/implementations/adapters/kysely-lock-adapter/_module.js";
|
|
9
|
-
/**
|
|
10
|
-
* To utilize the `LibsqlLockAdapter`, you must install the `"@libsql/client"` package.
|
|
11
|
-
*
|
|
12
|
-
* Note in order to use `LibsqlLockAdapter` correctly, ensure you use a single, consistent database across all server instances.
|
|
13
|
-
* This means you can't use libsql embedded replicas.
|
|
14
|
-
*
|
|
15
|
-
* IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
|
|
16
|
-
* @group Adapters
|
|
17
|
-
*/
|
|
18
|
-
export class LibsqlLockAdapter {
|
|
19
|
-
databaseLockAdapter;
|
|
20
|
-
/***
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { LibsqlLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
24
|
-
* import { createClient } from "@libsql/client";
|
|
25
|
-
*
|
|
26
|
-
* const database = createClient({ url: "file:local.db" });
|
|
27
|
-
* const lockAdapter = new LibsqlLockAdapter({
|
|
28
|
-
* database,
|
|
29
|
-
* });
|
|
30
|
-
* // You need initialize the adapter once before using it.
|
|
31
|
-
* await lockAdapter.init();
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
constructor(settings) {
|
|
35
|
-
const { database, tableName = "lock", expiredKeysRemovalInterval = TimeSpan.fromMinutes(1), shouldRemoveExpiredKeys = true, } = settings;
|
|
36
|
-
this.databaseLockAdapter = new KyselyLockAdapter({
|
|
37
|
-
database: new Kysely({
|
|
38
|
-
dialect: new LibsqlDialect({
|
|
39
|
-
client: database,
|
|
40
|
-
}),
|
|
41
|
-
plugins: [
|
|
42
|
-
new KyselyTableNameTransformerPlugin({
|
|
43
|
-
lock: tableName,
|
|
44
|
-
}),
|
|
45
|
-
],
|
|
46
|
-
}),
|
|
47
|
-
expiredKeysRemovalInterval,
|
|
48
|
-
shouldRemoveExpiredKeys,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async removeAllExpired() {
|
|
52
|
-
await this.databaseLockAdapter.removeAllExpired();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Removes the table where the lock keys are stored and removes the table indexes.
|
|
56
|
-
* Note all lock data will be removed.
|
|
57
|
-
*/
|
|
58
|
-
async deInit() {
|
|
59
|
-
await this.databaseLockAdapter.deInit();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Creates the table where the lock keys are stored and it's related indexes.
|
|
63
|
-
* Note the `init` method needs to be called before using the adapter.
|
|
64
|
-
*/
|
|
65
|
-
async init() {
|
|
66
|
-
await this.databaseLockAdapter.init();
|
|
67
|
-
}
|
|
68
|
-
async insert(key, owner, expiration) {
|
|
69
|
-
await this.databaseLockAdapter.insert(key, owner, expiration);
|
|
70
|
-
}
|
|
71
|
-
async update(key, owner, expiration) {
|
|
72
|
-
return await this.databaseLockAdapter.update(key, owner, expiration);
|
|
73
|
-
}
|
|
74
|
-
async remove(key, owner) {
|
|
75
|
-
await this.databaseLockAdapter.remove(key, owner);
|
|
76
|
-
}
|
|
77
|
-
async refresh(key, owner, expiration) {
|
|
78
|
-
return await this.databaseLockAdapter.refresh(key, owner, expiration);
|
|
79
|
-
}
|
|
80
|
-
async find(key) {
|
|
81
|
-
return await this.databaseLockAdapter.find(key);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=libsql-lock-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libsql-lock-adapter.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAIH,QAAQ,GACX,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,u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AAC,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,KAAoB;QAC1C,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,OAAO,CACT,GAAW,EACX,KAAa,EACb,UAAgB;QAEhB,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QAClB,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../../../lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/sqlite-lock-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,4EAA4E,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Lock
|
|
3
|
-
*/
|
|
4
|
-
import type { IDatabaseLockAdapter, ILockData } from "../../../../lock/contracts/_module-exports.js";
|
|
5
|
-
import { type IDeinitizable, type IInitizable, type IPrunable, type ISqliteDatabase, TimeSpan } from "../../../../utilities/_module-exports.js";
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
|
|
9
|
-
* @group Adapters
|
|
10
|
-
*/
|
|
11
|
-
export type SqliteLockAdapterSettings = {
|
|
12
|
-
database: ISqliteDatabase;
|
|
13
|
-
tableName?: string;
|
|
14
|
-
expiredKeysRemovalInterval?: TimeSpan;
|
|
15
|
-
shouldRemoveExpiredKeys?: boolean;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* To utilize the `SqliteLockAdapter`, you must install the `"better-sqlite3"` and `"@types/better-sqlite3"` packages.
|
|
19
|
-
*
|
|
20
|
-
* Note the `SqliteLockAdapter` is limited to single server usage and cannot be shared across multiple servers but it can be shared between different processes.
|
|
21
|
-
* To use it correctly, ensure all process instances access the same persisted database.
|
|
22
|
-
*
|
|
23
|
-
* IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
|
|
24
|
-
* @group Adapters
|
|
25
|
-
*/
|
|
26
|
-
export declare class SqliteLockAdapter implements IDatabaseLockAdapter, IDeinitizable, IInitizable, IPrunable {
|
|
27
|
-
private databaseLockAdapter;
|
|
28
|
-
/**
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
32
|
-
* import Sqlite from "better-sqlite3";
|
|
33
|
-
*
|
|
34
|
-
* const database = new Sqlite("local.db");
|
|
35
|
-
* const lockAdapter = new SqliteLockAdapter({
|
|
36
|
-
* database,
|
|
37
|
-
* });
|
|
38
|
-
* // You need initialize the adapter once before using it.
|
|
39
|
-
* await lockAdapter.init();
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
constructor(settings: SqliteLockAdapterSettings);
|
|
43
|
-
removeAllExpired(): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Removes the table where the lock keys are stored and removes the table indexes.
|
|
46
|
-
* Note all lock data will be removed.
|
|
47
|
-
*/
|
|
48
|
-
deInit(): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Creates the table where the lock keys are stored and it's related indexes.
|
|
51
|
-
* Note the `init` method needs to be called before using the adapter.
|
|
52
|
-
*/
|
|
53
|
-
init(): Promise<void>;
|
|
54
|
-
insert(key: string, owner: string, expiration: Date | null): Promise<void>;
|
|
55
|
-
update(key: string, owner: string, expiration: Date | null): Promise<number>;
|
|
56
|
-
remove(key: string, owner: string | null): Promise<void>;
|
|
57
|
-
refresh(key: string, owner: string, expiration: Date): Promise<number>;
|
|
58
|
-
find(key: string): Promise<ILockData | null>;
|
|
59
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module Lock
|
|
3
|
-
*/
|
|
4
|
-
import { TimeSpan, } from "../../../../utilities/_module-exports.js";
|
|
5
|
-
import { KyselyLockAdapter } from "../../../../lock/implementations/adapters/kysely-lock-adapter/_module.js";
|
|
6
|
-
import { Kysely, SqliteDialect } from "kysely";
|
|
7
|
-
import { KyselyTableNameTransformerPlugin } from "../../../../utilities/_module-exports.js";
|
|
8
|
-
/**
|
|
9
|
-
* To utilize the `SqliteLockAdapter`, you must install the `"better-sqlite3"` and `"@types/better-sqlite3"` packages.
|
|
10
|
-
*
|
|
11
|
-
* Note the `SqliteLockAdapter` is limited to single server usage and cannot be shared across multiple servers but it can be shared between different processes.
|
|
12
|
-
* To use it correctly, ensure all process instances access the same persisted database.
|
|
13
|
-
*
|
|
14
|
-
* IMPORT_PATH: `"@daiso-tech/core/lock/adapters"`
|
|
15
|
-
* @group Adapters
|
|
16
|
-
*/
|
|
17
|
-
export class SqliteLockAdapter {
|
|
18
|
-
databaseLockAdapter;
|
|
19
|
-
/**
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { SqliteLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
23
|
-
* import Sqlite from "better-sqlite3";
|
|
24
|
-
*
|
|
25
|
-
* const database = new Sqlite("local.db");
|
|
26
|
-
* const lockAdapter = new SqliteLockAdapter({
|
|
27
|
-
* database,
|
|
28
|
-
* });
|
|
29
|
-
* // You need initialize the adapter once before using it.
|
|
30
|
-
* await lockAdapter.init();
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
constructor(settings) {
|
|
34
|
-
const { database, tableName = "lock", shouldRemoveExpiredKeys = true, expiredKeysRemovalInterval = TimeSpan.fromMinutes(1), } = settings;
|
|
35
|
-
this.databaseLockAdapter = new KyselyLockAdapter({
|
|
36
|
-
database: new Kysely({
|
|
37
|
-
dialect: new SqliteDialect({
|
|
38
|
-
database: database,
|
|
39
|
-
}),
|
|
40
|
-
plugins: [
|
|
41
|
-
new KyselyTableNameTransformerPlugin({
|
|
42
|
-
lock: tableName,
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
}),
|
|
46
|
-
expiredKeysRemovalInterval,
|
|
47
|
-
shouldRemoveExpiredKeys,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async removeAllExpired() {
|
|
51
|
-
await this.databaseLockAdapter.removeAllExpired();
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Removes the table where the lock keys are stored and removes the table indexes.
|
|
55
|
-
* Note all lock data will be removed.
|
|
56
|
-
*/
|
|
57
|
-
async deInit() {
|
|
58
|
-
await this.databaseLockAdapter.deInit();
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Creates the table where the lock keys are stored and it's related indexes.
|
|
62
|
-
* Note the `init` method needs to be called before using the adapter.
|
|
63
|
-
*/
|
|
64
|
-
async init() {
|
|
65
|
-
await this.databaseLockAdapter.init();
|
|
66
|
-
}
|
|
67
|
-
async insert(key, owner, expiration) {
|
|
68
|
-
await this.databaseLockAdapter.insert(key, owner, expiration);
|
|
69
|
-
}
|
|
70
|
-
async update(key, owner, expiration) {
|
|
71
|
-
return await this.databaseLockAdapter.update(key, owner, expiration);
|
|
72
|
-
}
|
|
73
|
-
async remove(key, owner) {
|
|
74
|
-
await this.databaseLockAdapter.remove(key, owner);
|
|
75
|
-
}
|
|
76
|
-
async refresh(key, owner, expiration) {
|
|
77
|
-
return await this.databaseLockAdapter.refresh(key, owner, expiration);
|
|
78
|
-
}
|
|
79
|
-
async find(key) {
|
|
80
|
-
return await this.databaseLockAdapter.find(key);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=sqlite-lock-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-lock-adapter.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAKH,QAAQ,GACX,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gEAAgE,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAclF;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IAGlB,mBAAmB,CAAoB;IAE/C;;;;;;;;;;;;;OAaG;IACH,YAAY,QAAmC;QAC3C,MAAM,EACF,QAAQ,EACR,SAAS,GAAG,MAAM,EAClB,uBAAuB,GAAG,IAAI,EAC9B,0BAA0B,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,GACvD,GAAG,QAAQ,CAAC;QAEb,IAAI,CAAC,mBAAmB,GAAG,IAAI,iBAAiB,CAAC;YAC7C,QAAQ,EAAE,IAAI,MAAM,CAAC;gBACjB,OAAO,EAAE,IAAI,aAAa,CAAC;oBACvB,QAAQ,EAAE,QAAQ;iBACrB,CAAC;gBACF,OAAO,EAAE;oBACL,IAAI,gCAAgC,CAAC;wBACjC,IAAI,EAAE,SAAS;qBAClB,CAAC;iBACL;aACJ,CAAC;YACF,0BAA0B;YAC1B,uBAAuB;SAC1B,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,gBAAgB;QAClB,MAAM,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;IACtD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM;QACR,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;IAC5C,CAAC;IAED;;;OAG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