chz-telegram-bot 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAE9D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,cAAc;IAC1D,SAAS,YAAoB;IAC7B,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAE9D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,cAAc;IAC1D,SAAS,YAAoB;IAC7B,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;YAevC,IAAI;YAUJ,YAAY;YAmBZ,IAAI;IAalB,OAAO,CAAC,eAAe;IAOjB,IAAI,CAAC,GAAG,EAAE,MAAM;IAMhB,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM;IAUzD,cAAc,CAAC,YAAY,SAAS,YAAY,EAClD,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM;IASZ,yBAAyB,CAC3B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB;IAYlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -10,6 +10,11 @@ class JsonFileStorage {
|
|
|
10
10
|
this.cache = new Map();
|
|
11
11
|
this.botName = botName;
|
|
12
12
|
this.storagePath = path ?? 'storage';
|
|
13
|
+
const targetPath = this.buidPathFromKey(`${this.storagePath}/${this.botName}`);
|
|
14
|
+
const folderName = (0, path_1.dirname)(targetPath);
|
|
15
|
+
if (!(0, fs_1.existsSync)(folderName)) {
|
|
16
|
+
(0, fs_1.mkdirSync)(folderName, { recursive: true });
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
async lock(action) {
|
|
15
20
|
await this.semaphore.acquire();
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
1
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
2
2
|
import { dirname } from 'path';
|
|
3
3
|
import TransactionResult from '../entities/transactionResult';
|
|
4
4
|
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
@@ -18,6 +18,15 @@ export default class JsonFileStorage implements IStorageClient {
|
|
|
18
18
|
this.cache = new Map<string, Record<number, ActionStateBase>>();
|
|
19
19
|
this.botName = botName;
|
|
20
20
|
this.storagePath = path ?? 'storage';
|
|
21
|
+
|
|
22
|
+
const targetPath = this.buidPathFromKey(
|
|
23
|
+
`${this.storagePath}/${this.botName}`
|
|
24
|
+
);
|
|
25
|
+
const folderName = dirname(targetPath);
|
|
26
|
+
|
|
27
|
+
if (!existsSync(folderName)) {
|
|
28
|
+
mkdirSync(folderName, { recursive: true });
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
private async lock<TType>(action: () => Promise<TType>) {
|