@travetto/model-file 5.0.16 → 5.1.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/package.json +8 -8
- package/src/service.ts +7 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-file",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "File system backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datastore",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
],
|
|
22
22
|
"main": "__index__.ts",
|
|
23
23
|
"repository": {
|
|
24
|
-
"url": "https://github.com/travetto/travetto.git",
|
|
24
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
25
25
|
"directory": "module/model-file"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@travetto/config": "^5.0
|
|
29
|
-
"@travetto/di": "^5.0
|
|
30
|
-
"@travetto/model": "^5.0
|
|
31
|
-
"@travetto/schema": "^5.0
|
|
28
|
+
"@travetto/config": "^5.1.0",
|
|
29
|
+
"@travetto/di": "^5.1.0",
|
|
30
|
+
"@travetto/model": "^5.1.0",
|
|
31
|
+
"@travetto/schema": "^5.1.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/cli": "^5.0
|
|
35
|
-
"@travetto/test": "^5.0
|
|
34
|
+
"@travetto/cli": "^5.1.0",
|
|
35
|
+
"@travetto/test": "^5.1.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@travetto/cli": {
|
package/src/service.ts
CHANGED
|
@@ -43,7 +43,8 @@ const exists = (f: string): Promise<boolean> => fs.stat(f).then(() => true, () =
|
|
|
43
43
|
@Injectable()
|
|
44
44
|
export class FileModelService implements ModelCrudSupport, ModelBlobSupport, ModelExpirySupport, ModelStorageSupport {
|
|
45
45
|
|
|
46
|
-
private
|
|
46
|
+
/** @private */
|
|
47
|
+
static async * scanFolder(folder: string, suffix: string): AsyncGenerator<[id: string, field: string]> {
|
|
47
48
|
for (const sub of await fs.readdir(folder)) {
|
|
48
49
|
for (const file of await fs.readdir(path.resolve(folder, sub))) {
|
|
49
50
|
if (file.endsWith(suffix)) {
|
|
@@ -54,15 +55,16 @@ export class FileModelService implements ModelCrudSupport, ModelBlobSupport, Mod
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
idSource = ModelCrudUtil.uuidSource();
|
|
58
|
+
config: FileModelConfig;
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
return this.config.folder;
|
|
60
|
-
}
|
|
60
|
+
constructor(config: FileModelConfig) { this.config = config; }
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* The root location for all activity
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
get client(): string {
|
|
66
|
+
return this.config.folder;
|
|
67
|
+
}
|
|
66
68
|
|
|
67
69
|
async #resolveName<T extends ModelType>(cls: Class<T> | string, suffix?: Suffix, id?: string): Promise<string> {
|
|
68
70
|
const name = typeof cls === 'string' ? cls : ModelRegistry.getStore(cls);
|