@furystack/filesystem-store 3.1.0 → 3.1.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.
|
@@ -4,13 +4,20 @@ const fs_1 = require("fs");
|
|
|
4
4
|
const filesystem_store_1 = require("./filesystem-store");
|
|
5
5
|
const core_1 = require("@furystack/core");
|
|
6
6
|
const utils_1 = require("@furystack/utils");
|
|
7
|
+
const store_manager_helpers_1 = require("./store-manager-helpers");
|
|
7
8
|
let storeCount = 0;
|
|
8
9
|
describe('FileSystemStore', () => {
|
|
9
10
|
const storeNames = [];
|
|
10
|
-
const createStore = () => {
|
|
11
|
+
const createStore = (i) => {
|
|
11
12
|
const fileName = `filestore-test-${storeCount++}.json`;
|
|
12
13
|
storeNames.push(fileName);
|
|
13
|
-
|
|
14
|
+
(0, store_manager_helpers_1.useFileSystemStore)({
|
|
15
|
+
injector: i,
|
|
16
|
+
model: core_1.TestClass,
|
|
17
|
+
fileName,
|
|
18
|
+
primaryKey: 'id',
|
|
19
|
+
});
|
|
20
|
+
return i.getInstance(core_1.StoreManager).getStoreFor(core_1.TestClass, 'id');
|
|
14
21
|
};
|
|
15
22
|
(0, core_1.createStoreTest)({
|
|
16
23
|
createStore,
|
|
@@ -55,11 +62,14 @@ describe('FileSystemStore', () => {
|
|
|
55
62
|
await store.dispose();
|
|
56
63
|
});
|
|
57
64
|
afterAll(async () => {
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
for (const fileName of storeNames) {
|
|
66
|
+
try {
|
|
60
67
|
await fs_1.promises.unlink(fileName);
|
|
61
68
|
}
|
|
62
|
-
|
|
69
|
+
catch (error) {
|
|
70
|
+
// Ignore, maybe already deleted
|
|
71
|
+
}
|
|
72
|
+
}
|
|
63
73
|
});
|
|
64
74
|
});
|
|
65
75
|
//# sourceMappingURL=filesystem-store.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-store.spec.js","sourceRoot":"","sources":["../src/filesystem-store.spec.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"filesystem-store.spec.js","sourceRoot":"","sources":["../src/filesystem-store.spec.ts"],"names":[],"mappings":";;AAAA,2BAA6B;AAC7B,yDAAoD;AACpD,0CAA0E;AAC1E,4CAA6C;AAE7C,mEAA4D;AAE5D,IAAI,UAAU,GAAG,CAAC,CAAA;AAElB,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,MAAM,WAAW,GAAG,CAAC,CAAW,EAAE,EAAE;QAClC,MAAM,QAAQ,GAAG,kBAAkB,UAAU,EAAE,OAAO,CAAA;QACtD,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEzB,IAAA,0CAAkB,EAAC;YACjB,QAAQ,EAAE,CAAC;YACX,KAAK,EAAE,gBAAS;YAChB,QAAQ;YACR,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;QAEF,OAAO,CAAC,CAAC,WAAW,CAAC,mBAAY,CAAC,CAAC,WAAW,CAAC,gBAAS,EAAE,IAAI,CAAC,CAAA;IACjE,CAAC,CAAA;IAED,IAAA,sBAAe,EAAC;QACd,WAAW;QACX,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAA;IAEF,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,QAAQ,GAAG,kBAAkB,UAAU,EAAE,OAAO,CAAA;QACtD,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACzB,MAAM,KAAK,GAAG,IAAI,kCAAe,CAAC,EAAE,KAAK,EAAE,gBAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAChG,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QAE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CAAC,OAAO,EAAE,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,IAAI;gBACF,MAAM,aAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;aAChC;YAAC,OAAO,KAAK,EAAE;gBACd,gCAAgC;aACjC;SACF;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/filesystem-store",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Simple File System store implementation for FuryStack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/furystack/furystack",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@furystack/core": "^11.1.
|
|
33
|
-
"@furystack/inject": "^7.1.
|
|
34
|
-
"@furystack/utils": "^3.1.
|
|
32
|
+
"@furystack/core": "^11.1.1",
|
|
33
|
+
"@furystack/inject": "^7.1.1",
|
|
34
|
+
"@furystack/utils": "^3.1.1",
|
|
35
35
|
"semaphore-async-await": "^1.5.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/jest": "^29.
|
|
39
|
-
"@types/node": "^18.
|
|
38
|
+
"@types/jest": "^29.2.1",
|
|
39
|
+
"@types/node": "^18.11.9"
|
|
40
40
|
},
|
|
41
41
|
"typings": "./types/index.d.ts",
|
|
42
42
|
"gitHead": "1045d854bfd8c475b7035471d130d401417a2321"
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { promises
|
|
1
|
+
import { promises } from 'fs'
|
|
2
2
|
import { FileSystemStore } from './filesystem-store'
|
|
3
|
-
import { TestClass, createStoreTest } from '@furystack/core'
|
|
3
|
+
import { TestClass, createStoreTest, StoreManager } from '@furystack/core'
|
|
4
4
|
import { sleepAsync } from '@furystack/utils'
|
|
5
|
+
import type { Injector } from '@furystack/inject'
|
|
6
|
+
import { useFileSystemStore } from './store-manager-helpers'
|
|
5
7
|
|
|
6
8
|
let storeCount = 0
|
|
7
9
|
|
|
8
10
|
describe('FileSystemStore', () => {
|
|
9
11
|
const storeNames: string[] = []
|
|
10
|
-
const createStore = () => {
|
|
12
|
+
const createStore = (i: Injector) => {
|
|
11
13
|
const fileName = `filestore-test-${storeCount++}.json`
|
|
12
14
|
storeNames.push(fileName)
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
useFileSystemStore({
|
|
17
|
+
injector: i,
|
|
18
|
+
model: TestClass,
|
|
19
|
+
fileName,
|
|
20
|
+
primaryKey: 'id',
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return i.getInstance(StoreManager).getStoreFor(TestClass, 'id')
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
createStoreTest({
|
|
@@ -61,12 +71,12 @@ describe('FileSystemStore', () => {
|
|
|
61
71
|
})
|
|
62
72
|
|
|
63
73
|
afterAll(async () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
74
|
+
for (const fileName of storeNames) {
|
|
75
|
+
try {
|
|
76
|
+
await promises.unlink(fileName)
|
|
77
|
+
} catch (error) {
|
|
78
|
+
// Ignore, maybe already deleted
|
|
79
|
+
}
|
|
80
|
+
}
|
|
71
81
|
})
|
|
72
82
|
})
|