@pristine-ts/file 0.0.348 → 0.0.350
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/lib/cjs/file.module.js +3 -0
- package/dist/lib/cjs/file.module.js.map +1 -1
- package/dist/lib/cjs/resolvers/file.resolver.js +73 -0
- package/dist/lib/cjs/resolvers/file.resolver.js.map +1 -0
- package/dist/lib/cjs/resolvers/resolvers.js +18 -0
- package/dist/lib/cjs/resolvers/resolvers.js.map +1 -0
- package/dist/lib/esm/file.module.js +3 -0
- package/dist/lib/esm/file.module.js.map +1 -1
- package/dist/lib/esm/resolvers/file.resolver.js +69 -0
- package/dist/lib/esm/resolvers/file.resolver.js.map +1 -0
- package/dist/lib/esm/resolvers/resolvers.js +2 -0
- package/dist/lib/esm/resolvers/resolvers.js.map +1 -0
- package/dist/types/file.module.d.ts +1 -0
- package/dist/types/resolvers/file.resolver.d.ts +19 -0
- package/dist/types/resolvers/resolvers.d.ts +1 -0
- package/package.json +7 -3
|
@@ -17,15 +17,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.FileModule = void 0;
|
|
18
18
|
const common_1 = require("@pristine-ts/common");
|
|
19
19
|
const file_module_keyname_1 = require("./file.module.keyname");
|
|
20
|
+
const data_mapping_1 = require("@pristine-ts/data-mapping");
|
|
20
21
|
__exportStar(require("./enums/enums"), exports);
|
|
21
22
|
__exportStar(require("./interfaces/interfaces"), exports);
|
|
22
23
|
__exportStar(require("./managers/managers"), exports);
|
|
23
24
|
__exportStar(require("./options/options"), exports);
|
|
25
|
+
__exportStar(require("./resolvers/resolvers"), exports);
|
|
24
26
|
exports.FileModule = {
|
|
25
27
|
keyname: file_module_keyname_1.FileModuleKeyname,
|
|
26
28
|
configurationDefinitions: [],
|
|
27
29
|
importModules: [
|
|
28
30
|
common_1.CommonModule,
|
|
31
|
+
data_mapping_1.DataMappingModule,
|
|
29
32
|
],
|
|
30
33
|
};
|
|
31
34
|
//# sourceMappingURL=file.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/file.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAkE;AAClE,+DAAwD;
|
|
1
|
+
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/file.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAkE;AAClE,+DAAwD;AACxD,4DAA4D;AAE5D,gDAA8B;AAC9B,0DAAwC;AACxC,sDAAoC;AACpC,oDAAkC;AAClC,wDAAsC;AAEzB,QAAA,UAAU,GAAoB;IACvC,OAAO,EAAE,uCAAiB;IAC1B,wBAAwB,EAAE,EACzB;IACD,aAAa,EAAE;QACX,qBAAY;QACZ,gCAAiB;KACpB;CACJ,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FileResolver = void 0;
|
|
13
|
+
const promises_1 = require("fs/promises");
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const configuration_1 = require("@pristine-ts/configuration");
|
|
16
|
+
/**
|
|
17
|
+
* This class is a resolver that is used to resolve the configuration coming from a file.
|
|
18
|
+
|
|
19
|
+
*/
|
|
20
|
+
class FileResolver {
|
|
21
|
+
constructor(options, dataMapper, validator) {
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.dataMapper = dataMapper;
|
|
24
|
+
this.validator = validator;
|
|
25
|
+
}
|
|
26
|
+
resolveFilename(value) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === "object" && typeof value.resolve === "function") {
|
|
32
|
+
return this.resolveFilename(yield value.resolve());
|
|
33
|
+
}
|
|
34
|
+
throw new configuration_1.ConfigurationResolverError("Cannot resolve the value passed. It isn't of type string or ResolverInterface.", value);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
resolve() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const filename = yield this.resolveFilename(this.options.filename);
|
|
40
|
+
if ((0, node_fs_1.existsSync)(filename) === false) {
|
|
41
|
+
throw new configuration_1.ConfigurationResolverError("The file doesn't exist.", filename);
|
|
42
|
+
}
|
|
43
|
+
const content = yield (0, promises_1.readFile)(filename, { encoding: "utf-8" });
|
|
44
|
+
let options;
|
|
45
|
+
try {
|
|
46
|
+
options = JSON.parse(content);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new configuration_1.ConfigurationResolverError("Cannot JSON parse the content of this file", content);
|
|
50
|
+
}
|
|
51
|
+
if (this.dataMapper === undefined) {
|
|
52
|
+
return options;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
options = yield this.dataMapper.autoMap(JSON.parse(content), this.options.classType);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw new configuration_1.ConfigurationResolverError("The content of the file is not valid.", content);
|
|
59
|
+
}
|
|
60
|
+
if (this.validator === undefined) {
|
|
61
|
+
return options;
|
|
62
|
+
}
|
|
63
|
+
// Validate the options
|
|
64
|
+
const errors = yield this.validator.validate(options);
|
|
65
|
+
if (errors.length > 0) {
|
|
66
|
+
throw new configuration_1.ConfigurationResolverError("There are errors in the configuration.", content);
|
|
67
|
+
}
|
|
68
|
+
return options;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.FileResolver = FileResolver;
|
|
73
|
+
//# sourceMappingURL=file.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/file.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,0CAAqC;AACrC,qCAAmC;AAEnC,8DAAsE;AAEtE;;;GAGG;AACH,MAAa,YAAY;IACrB,YACqB,OAGpB,EACoB,UAAuB,EACvB,SAAqB;QALrB,YAAO,GAAP,OAAO,CAG3B;QACoB,eAAU,GAAV,UAAU,CAAa;QACvB,cAAS,GAAT,SAAS,CAAY;IAC1C,CAAC;IAEa,eAAe,CAAC,KAA0C;;YACpE,IAAG,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC3B,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,IAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClE,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,IAAI,0CAA0B,CAAC,gFAAgF,EAAE,KAAK,CAAC,CAAC;QAClI,CAAC;KAAA;IAEK,OAAO;;YACT,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEnE,IAAG,IAAA,oBAAU,EAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;gBAChC,MAAM,IAAI,0CAA0B,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;YAC9E,CAAC;YAED,MA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|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file.resolver"), exports);
|
|
18
|
+
//# sourceMappingURL=resolvers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../../src/resolvers/resolvers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { CommonModule } from "@pristine-ts/common";
|
|
2
2
|
import { FileModuleKeyname } from "./file.module.keyname";
|
|
3
|
+
import { DataMappingModule } from "@pristine-ts/data-mapping";
|
|
3
4
|
export * from "./enums/enums";
|
|
4
5
|
export * from "./interfaces/interfaces";
|
|
5
6
|
export * from "./managers/managers";
|
|
6
7
|
export * from "./options/options";
|
|
8
|
+
export * from "./resolvers/resolvers";
|
|
7
9
|
export const FileModule = {
|
|
8
10
|
keyname: FileModuleKeyname,
|
|
9
11
|
configurationDefinitions: [],
|
|
10
12
|
importModules: [
|
|
11
13
|
CommonModule,
|
|
14
|
+
DataMappingModule,
|
|
12
15
|
],
|
|
13
16
|
};
|
|
14
17
|
//# sourceMappingURL=file.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/file.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/file.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAE5D,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,MAAM,CAAC,MAAM,UAAU,GAAoB;IACvC,OAAO,EAAE,iBAAiB;IAC1B,wBAAwB,EAAE,EACzB;IACD,aAAa,EAAE;QACX,YAAY;QACZ,iBAAiB;KACpB;CACJ,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { readFile } from "fs/promises";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
import { ConfigurationResolverError } from "@pristine-ts/configuration";
|
|
13
|
+
/**
|
|
14
|
+
* This class is a resolver that is used to resolve the configuration coming from a file.
|
|
15
|
+
|
|
16
|
+
*/
|
|
17
|
+
export class FileResolver {
|
|
18
|
+
constructor(options, dataMapper, validator) {
|
|
19
|
+
this.options = options;
|
|
20
|
+
this.dataMapper = dataMapper;
|
|
21
|
+
this.validator = validator;
|
|
22
|
+
}
|
|
23
|
+
resolveFilename(value) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (typeof value === "string") {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === "object" && typeof value.resolve === "function") {
|
|
29
|
+
return this.resolveFilename(yield value.resolve());
|
|
30
|
+
}
|
|
31
|
+
throw new ConfigurationResolverError("Cannot resolve the value passed. It isn't of type string or ResolverInterface.", value);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
resolve() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const filename = yield this.resolveFilename(this.options.filename);
|
|
37
|
+
if (existsSync(filename) === false) {
|
|
38
|
+
throw new ConfigurationResolverError("The file doesn't exist.", filename);
|
|
39
|
+
}
|
|
40
|
+
const content = yield readFile(filename, { encoding: "utf-8" });
|
|
41
|
+
let options;
|
|
42
|
+
try {
|
|
43
|
+
options = JSON.parse(content);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new ConfigurationResolverError("Cannot JSON parse the content of this file", content);
|
|
47
|
+
}
|
|
48
|
+
if (this.dataMapper === undefined) {
|
|
49
|
+
return options;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
options = yield this.dataMapper.autoMap(JSON.parse(content), this.options.classType);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new ConfigurationResolverError("The content of the file is not valid.", content);
|
|
56
|
+
}
|
|
57
|
+
if (this.validator === undefined) {
|
|
58
|
+
return options;
|
|
59
|
+
}
|
|
60
|
+
// Validate the options
|
|
61
|
+
const errors = yield this.validator.validate(options);
|
|
62
|
+
if (errors.length > 0) {
|
|
63
|
+
throw new ConfigurationResolverError("There are errors in the configuration.", content);
|
|
64
|
+
}
|
|
65
|
+
return options;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=file.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.resolver.js","sourceRoot":"","sources":["../../../../src/resolvers/file.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AAEtE;;;GAGG;AACH,MAAM,OAAO,YAAY;IACrB,YACqB,OAGpB,EACoB,UAAuB,EACvB,SAAqB;QALrB,YAAO,GAAP,OAAO,CAG3B;QACoB,eAAU,GAAV,UAAU,CAAa;QACvB,cAAS,GAAT,SAAS,CAAY;IAC1C,CAAC;IAEa,eAAe,CAAC,KAA0C;;YACpE,IAAG,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC3B,OAAO,KAAK,CAAC;YACjB,CAAC;YAED,IAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClE,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,IAAI,0BAA0B,CAAC,gFAAgF,EAAE,KAAK,CAAC,CAAC;QAClI,CAAC;KAAA;IAEK,OAAO;;YACT,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEnE,IAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;gBAChC,MAAM,IAAI,0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],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ResolverInterface } from "@pristine-ts/common";
|
|
2
|
+
import { ClassConstructor } from "class-transformer";
|
|
3
|
+
import { DataMapper } from "@pristine-ts/data-mapping-common";
|
|
4
|
+
import { Validator } from "@pristine-ts/class-validator";
|
|
5
|
+
/**
|
|
6
|
+
* This class is a resolver that is used to resolve the configuration coming from a file.
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
export declare class FileResolver<Options> implements ResolverInterface<Options> {
|
|
10
|
+
private readonly options;
|
|
11
|
+
private readonly dataMapper?;
|
|
12
|
+
private readonly validator?;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
filename: string | ResolverInterface<string>;
|
|
15
|
+
classType: ClassConstructor<Options>;
|
|
16
|
+
}, dataMapper?: DataMapper | undefined, validator?: Validator | undefined);
|
|
17
|
+
private resolveFilename;
|
|
18
|
+
resolve(): Promise<Options>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./file.resolver";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/file",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.350",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/file.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/file.module.js",
|
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@pristine-ts/
|
|
23
|
+
"@pristine-ts/class-validator": "^1.0.25",
|
|
24
|
+
"@pristine-ts/common": "^0.0.350",
|
|
25
|
+
"@pristine-ts/configuration": "^0.0.350",
|
|
26
|
+
"@pristine-ts/data-mapping": "^0.0.350",
|
|
27
|
+
"@pristine-ts/data-mapping-common": "^0.0.350"
|
|
24
28
|
},
|
|
25
29
|
"jest": {
|
|
26
30
|
"transform": {
|
|
@@ -56,5 +60,5 @@
|
|
|
56
60
|
"src/*.{js,ts}"
|
|
57
61
|
]
|
|
58
62
|
},
|
|
59
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b6d399b8ad2862f654c86f911443ad90fe1205ca"
|
|
60
64
|
}
|