@spinajs/validation 2.0.180 → 2.0.182

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.
Files changed (45) hide show
  1. package/lib/cjs/bootstrap.d.ts +4 -4
  2. package/lib/cjs/bootstrap.js +23 -23
  3. package/lib/cjs/bootstrap.js.map +1 -1
  4. package/lib/cjs/config/validation.d.ts +9 -9
  5. package/lib/cjs/config/validation.js +15 -15
  6. package/lib/cjs/decorators.d.ts +8 -8
  7. package/lib/cjs/decorators.js +16 -16
  8. package/lib/cjs/exceptions/index.d.ts +11 -11
  9. package/lib/cjs/exceptions/index.js +14 -14
  10. package/lib/cjs/index.d.ts +13 -13
  11. package/lib/cjs/index.js +34 -34
  12. package/lib/cjs/schemas/validation.d.ts +21 -21
  13. package/lib/cjs/schemas/validation.js +15 -15
  14. package/lib/cjs/sources.d.ts +13 -13
  15. package/lib/cjs/sources.js +92 -93
  16. package/lib/cjs/sources.js.map +1 -1
  17. package/lib/cjs/types.d.ts +17 -17
  18. package/lib/cjs/types.js +6 -6
  19. package/lib/cjs/validator.d.ts +61 -61
  20. package/lib/cjs/validator.js +164 -164
  21. package/lib/cjs/validator.js.map +1 -1
  22. package/lib/mjs/bootstrap.d.ts +4 -4
  23. package/lib/mjs/bootstrap.js +17 -17
  24. package/lib/mjs/bootstrap.js.map +1 -1
  25. package/lib/mjs/config/validation.d.ts +9 -9
  26. package/lib/mjs/config/validation.js +13 -13
  27. package/lib/mjs/decorators.d.ts +8 -8
  28. package/lib/mjs/decorators.js +12 -12
  29. package/lib/mjs/exceptions/index.d.ts +11 -11
  30. package/lib/mjs/exceptions/index.js +10 -10
  31. package/lib/mjs/index.d.ts +13 -13
  32. package/lib/mjs/index.js +13 -13
  33. package/lib/mjs/schemas/validation.d.ts +21 -21
  34. package/lib/mjs/schemas/validation.js +13 -13
  35. package/lib/mjs/sources.d.ts +13 -13
  36. package/lib/mjs/sources.js +63 -63
  37. package/lib/mjs/sources.js.map +1 -1
  38. package/lib/mjs/types.d.ts +17 -17
  39. package/lib/mjs/types.js +2 -2
  40. package/lib/mjs/validator.d.ts +61 -61
  41. package/lib/mjs/validator.js +158 -158
  42. package/lib/mjs/validator.js.map +1 -1
  43. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  44. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  45. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
- import { Bootstrapper } from '@spinajs/di';
2
- export declare class ValidatorBootstraper extends Bootstrapper {
3
- bootstrap(): void;
4
- }
1
+ import { Bootstrapper } from '@spinajs/di';
2
+ export declare class ValidatorBootstraper extends Bootstrapper {
3
+ bootstrap(): void;
4
+ }
5
5
  //# sourceMappingURL=bootstrap.d.ts.map
@@ -1,24 +1,24 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ValidatorBootstraper = void 0;
13
- const di_1 = require("@spinajs/di");
14
- const validation_js_1 = __importDefault(require("./schemas/validation.js"));
15
- let ValidatorBootstraper = class ValidatorBootstraper extends di_1.Bootstrapper {
16
- bootstrap() {
17
- di_1.DI.register(validation_js_1.default).asValue('__configurationSchema__');
18
- }
19
- };
20
- ValidatorBootstraper = __decorate([
21
- (0, di_1.Injectable)(di_1.Bootstrapper)
22
- ], ValidatorBootstraper);
23
- exports.ValidatorBootstraper = ValidatorBootstraper;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ValidatorBootstraper = void 0;
13
+ const di_1 = require("@spinajs/di");
14
+ const validation_js_1 = __importDefault(require("./schemas/validation.js"));
15
+ let ValidatorBootstraper = class ValidatorBootstraper extends di_1.Bootstrapper {
16
+ bootstrap() {
17
+ di_1.DI.register(validation_js_1.default).asValue('__configurationSchema__');
18
+ }
19
+ };
20
+ exports.ValidatorBootstraper = ValidatorBootstraper;
21
+ exports.ValidatorBootstraper = ValidatorBootstraper = __decorate([
22
+ (0, di_1.Injectable)(di_1.Bootstrapper)
23
+ ], ValidatorBootstraper);
24
24
  //# sourceMappingURL=bootstrap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAA2D;AAC3D,4EAA2D;AAGpD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,iBAAY;IAC7C,SAAS;QACd,OAAE,CAAC,QAAQ,CAAC,uBAAoB,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvE,CAAC;CACF,CAAA;AAJY,oBAAoB;IADhC,IAAA,eAAU,EAAC,iBAAY,CAAC;GACZ,oBAAoB,CAIhC;AAJY,oDAAoB"}
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAA2D;AAC3D,4EAA2D;AAGpD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,iBAAY;IAC7C,SAAS;QACd,OAAE,CAAC,QAAQ,CAAC,uBAAoB,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvE,CAAC;CACF,CAAA;AAJY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,eAAU,EAAC,iBAAY,CAAC;GACZ,oBAAoB,CAIhC"}
@@ -1,10 +1,10 @@
1
- declare const config: {
2
- validation: {
3
- allErrors: boolean;
4
- removeAdditional: boolean;
5
- useDefaults: boolean;
6
- coerceTypes: boolean;
7
- };
8
- };
9
- export default config;
1
+ declare const config: {
2
+ validation: {
3
+ allErrors: boolean;
4
+ removeAdditional: boolean;
5
+ useDefaults: boolean;
6
+ coerceTypes: boolean;
7
+ };
8
+ };
9
+ export default config;
10
10
  //# sourceMappingURL=validation.d.ts.map
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config = {
4
- validation: {
5
- // enable all errors on validation, not only first one that occurred
6
- allErrors: true,
7
- // remove properties that are not defined in schema
8
- removeAdditional: true,
9
- // set default values if possible
10
- useDefaults: true,
11
- // The option coerceTypes allows you to have your data types coerced to the types specified in your schema type keywords
12
- coerceTypes: true,
13
- },
14
- };
15
- exports.default = config;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config = {
4
+ validation: {
5
+ // enable all errors on validation, not only first one that occurred
6
+ allErrors: true,
7
+ // remove properties that are not defined in schema
8
+ removeAdditional: true,
9
+ // set default values if possible
10
+ useDefaults: true,
11
+ // The option coerceTypes allows you to have your data types coerced to the types specified in your schema type keywords
12
+ coerceTypes: true,
13
+ },
14
+ };
15
+ exports.default = config;
16
16
  //# sourceMappingURL=validation.js.map
@@ -1,9 +1,9 @@
1
- export declare const SCHEMA_SYMBOL: unique symbol;
2
- /**
3
- *
4
- * Add schema for object eg. model or dto.
5
- *
6
- * @param schema - schema for object or schema name
7
- */
8
- export declare function Schema(schema: object | string): (target: any) => void;
1
+ export declare const SCHEMA_SYMBOL: unique symbol;
2
+ /**
3
+ *
4
+ * Add schema for object eg. model or dto.
5
+ *
6
+ * @param schema - schema for object or schema name
7
+ */
8
+ export declare function Schema(schema: object | string): (target: any) => void;
9
9
  //# sourceMappingURL=decorators.d.ts.map
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Schema = exports.SCHEMA_SYMBOL = void 0;
4
- exports.SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
5
- /**
6
- *
7
- * Add schema for object eg. model or dto.
8
- *
9
- * @param schema - schema for object or schema name
10
- */
11
- function Schema(schema) {
12
- return (target) => {
13
- Reflect.defineMetadata(exports.SCHEMA_SYMBOL, schema, target.prototype ?? target);
14
- };
15
- }
16
- exports.Schema = Schema;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Schema = exports.SCHEMA_SYMBOL = void 0;
4
+ exports.SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
5
+ /**
6
+ *
7
+ * Add schema for object eg. model or dto.
8
+ *
9
+ * @param schema - schema for object or schema name
10
+ */
11
+ function Schema(schema) {
12
+ return (target) => {
13
+ Reflect.defineMetadata(exports.SCHEMA_SYMBOL, schema, target.prototype ?? target);
14
+ };
15
+ }
16
+ exports.Schema = Schema;
17
17
  //# sourceMappingURL=decorators.js.map
@@ -1,12 +1,12 @@
1
- import { Exception } from '@spinajs/exceptions';
2
- import { ErrorObject } from 'ajv';
3
- /**
4
- * The exception that is thrown when JSON entity is checked against schema and is invalid
5
- */
6
- export declare class ValidationFailed extends Exception {
7
- parameter: any;
8
- constructor(message: string, validationErrors: IValidationError[]);
9
- }
10
- export interface IValidationError extends ErrorObject {
11
- }
1
+ import { Exception } from '@spinajs/exceptions';
2
+ import { ErrorObject } from 'ajv';
3
+ /**
4
+ * The exception that is thrown when JSON entity is checked against schema and is invalid
5
+ */
6
+ export declare class ValidationFailed extends Exception {
7
+ parameter: any;
8
+ constructor(message: string, validationErrors: IValidationError[]);
9
+ }
10
+ export interface IValidationError extends ErrorObject {
11
+ }
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationFailed = void 0;
4
- const exceptions_1 = require("@spinajs/exceptions");
5
- /**
6
- * The exception that is thrown when JSON entity is checked against schema and is invalid
7
- */
8
- class ValidationFailed extends exceptions_1.Exception {
9
- constructor(message, validationErrors) {
10
- super(message);
11
- this.parameter = validationErrors;
12
- }
13
- }
14
- exports.ValidationFailed = ValidationFailed;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationFailed = void 0;
4
+ const exceptions_1 = require("@spinajs/exceptions");
5
+ /**
6
+ * The exception that is thrown when JSON entity is checked against schema and is invalid
7
+ */
8
+ class ValidationFailed extends exceptions_1.Exception {
9
+ constructor(message, validationErrors) {
10
+ super(message);
11
+ this.parameter = validationErrors;
12
+ }
13
+ }
14
+ exports.ValidationFailed = ValidationFailed;
15
15
  //# sourceMappingURL=index.js.map
@@ -1,14 +1,14 @@
1
- /**
2
- * We export default configuration for webpack modules
3
- * Normally we load configuration from disk via filesystem
4
- * But webpack is bundlig all files into one.
5
- *
6
- * When we export, we can see configuration variable
7
- * in webpack module cache and webpack config loader can see it
8
- */
9
- export { default } from './config/validation.js';
10
- export * from './decorators.js';
11
- export * from './exceptions/index.js';
12
- export * from './sources.js';
13
- export * from './validator.js';
1
+ /**
2
+ * We export default configuration for webpack modules
3
+ * Normally we load configuration from disk via filesystem
4
+ * But webpack is bundlig all files into one.
5
+ *
6
+ * When we export, we can see configuration variable
7
+ * in webpack module cache and webpack config loader can see it
8
+ */
9
+ export { default } from './config/validation.js';
10
+ export * from './decorators.js';
11
+ export * from './exceptions/index.js';
12
+ export * from './sources.js';
13
+ export * from './validator.js';
14
14
  //# sourceMappingURL=index.d.ts.map
package/lib/cjs/index.js CHANGED
@@ -1,35 +1,35 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- 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
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.default = void 0;
21
- /**
22
- * We export default configuration for webpack modules
23
- * Normally we load configuration from disk via filesystem
24
- * But webpack is bundlig all files into one.
25
- *
26
- * When we export, we can see configuration variable
27
- * in webpack module cache and webpack config loader can see it
28
- */
29
- var validation_js_1 = require("./config/validation.js");
30
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(validation_js_1).default; } });
31
- __exportStar(require("./decorators.js"), exports);
32
- __exportStar(require("./exceptions/index.js"), exports);
33
- __exportStar(require("./sources.js"), exports);
34
- __exportStar(require("./validator.js"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ 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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.default = void 0;
21
+ /**
22
+ * We export default configuration for webpack modules
23
+ * Normally we load configuration from disk via filesystem
24
+ * But webpack is bundlig all files into one.
25
+ *
26
+ * When we export, we can see configuration variable
27
+ * in webpack module cache and webpack config loader can see it
28
+ */
29
+ var validation_js_1 = require("./config/validation.js");
30
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(validation_js_1).default; } });
31
+ __exportStar(require("./decorators.js"), exports);
32
+ __exportStar(require("./exceptions/index.js"), exports);
33
+ __exportStar(require("./sources.js"), exports);
34
+ __exportStar(require("./validator.js"), exports);
35
35
  //# sourceMappingURL=index.js.map
@@ -1,22 +1,22 @@
1
- declare const CONFIGURATION_SCHEMA: {
2
- $id: string;
3
- $configurationModule: string;
4
- description: string;
5
- type: string;
6
- properties: {
7
- allErrors: {
8
- type: string;
9
- };
10
- removeAdditional: {
11
- type: string;
12
- };
13
- useDefaults: {
14
- type: string;
15
- };
16
- coerceTypes: {
17
- type: string;
18
- };
19
- };
20
- };
21
- export default CONFIGURATION_SCHEMA;
1
+ declare const CONFIGURATION_SCHEMA: {
2
+ $id: string;
3
+ $configurationModule: string;
4
+ description: string;
5
+ type: string;
6
+ properties: {
7
+ allErrors: {
8
+ type: string;
9
+ };
10
+ removeAdditional: {
11
+ type: string;
12
+ };
13
+ useDefaults: {
14
+ type: string;
15
+ };
16
+ coerceTypes: {
17
+ type: string;
18
+ };
19
+ };
20
+ };
21
+ export default CONFIGURATION_SCHEMA;
22
22
  //# sourceMappingURL=validation.d.ts.map
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const CONFIGURATION_SCHEMA = {
4
- $id: 'spinajs/validation.configuration.schema.json',
5
- $configurationModule: 'validation',
6
- description: 'Validation module configuration schema',
7
- type: 'object',
8
- properties: {
9
- allErrors: { type: 'boolean' },
10
- removeAdditional: { type: 'boolean' },
11
- useDefaults: { type: 'boolean' },
12
- coerceTypes: { type: 'boolean' },
13
- },
14
- };
15
- exports.default = CONFIGURATION_SCHEMA;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const CONFIGURATION_SCHEMA = {
4
+ $id: 'spinajs/validation.configuration.schema.json',
5
+ $configurationModule: 'validation',
6
+ description: 'Validation module configuration schema',
7
+ type: 'object',
8
+ properties: {
9
+ allErrors: { type: 'boolean' },
10
+ removeAdditional: { type: 'boolean' },
11
+ useDefaults: { type: 'boolean' },
12
+ coerceTypes: { type: 'boolean' },
13
+ },
14
+ };
15
+ exports.default = CONFIGURATION_SCHEMA;
16
16
  //# sourceMappingURL=validation.js.map
@@ -1,14 +1,14 @@
1
- import { ISchema, ISchemaObject, SchemaSource } from './types.js';
2
- export declare class FileSystemSource extends SchemaSource {
3
- SchemaDirs: string[];
4
- LoadJSSchema(): Promise<{
5
- schema: ISchemaObject;
6
- file: string;
7
- }[]>;
8
- LoadJSONSchema(): {
9
- schema: ISchemaObject;
10
- file: string;
11
- }[];
12
- Load(): Promise<ISchema[]>;
13
- }
1
+ import { ISchema, ISchemaObject, SchemaSource } from './types.js';
2
+ export declare class FileSystemSource extends SchemaSource {
3
+ SchemaDirs: string[];
4
+ LoadJSSchema(): Promise<{
5
+ schema: ISchemaObject;
6
+ file: string;
7
+ }[]>;
8
+ LoadJSONSchema(): {
9
+ schema: ISchemaObject;
10
+ file: string;
11
+ }[];
12
+ Load(): Promise<ISchema[]>;
13
+ }
14
14
  //# sourceMappingURL=sources.d.ts.map
@@ -1,94 +1,93 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- 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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __metadata = (this && this.__metadata) || function (k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.FileSystemSource = void 0;
39
- const configuration_1 = require("@spinajs/configuration");
40
- const di_1 = require("@spinajs/di");
41
- const fs = __importStar(require("fs"));
42
- const glob_1 = __importDefault(require("glob"));
43
- const path = __importStar(require("path"));
44
- const types_js_1 = require("./types.js");
45
- let FileSystemSource = class FileSystemSource extends types_js_1.SchemaSource {
46
- async LoadJSSchema() {
47
- if (!this.SchemaDirs)
48
- return [];
49
- const promises = this.SchemaDirs.filter((dir) => fs.existsSync(dir))
50
- .flatMap((d) => glob_1.default.sync(path.join(d, '/**/*.+(js|cjs)').replace(/\\/g, '/')))
51
- .map((f) => {
52
- var _a;
53
- return (_a = `file://${f}`, Promise.resolve().then(() => __importStar(require(_a)))).then((result) => {
54
- return {
55
- result: result,
56
- file: path.basename(f),
57
- };
58
- });
59
- });
60
- const result = await Promise.all(promises);
61
- return result.map((x) => {
62
- return {
63
- schema: x.result.default,
64
- file: x.file,
65
- };
66
- });
67
- }
68
- LoadJSONSchema() {
69
- if (!this.SchemaDirs)
70
- return [];
71
- return this.SchemaDirs.filter((dir) => fs.existsSync(dir))
72
- .flatMap((d) => glob_1.default.sync(path.join(d, '/**/*.+(json)').replace(/\\/g, '/')))
73
- .map((f) => {
74
- return {
75
- schema: JSON.parse(fs.readFileSync(f, 'utf-8')),
76
- file: path.basename(f),
77
- };
78
- });
79
- }
80
- async Load() {
81
- const sJS = await this.LoadJSSchema();
82
- const sJSON = this.LoadJSONSchema();
83
- return sJS.concat(sJSON);
84
- }
85
- };
86
- __decorate([
87
- (0, configuration_1.Config)('system.dirs.schemas'),
88
- __metadata("design:type", Array)
89
- ], FileSystemSource.prototype, "SchemaDirs", void 0);
90
- FileSystemSource = __decorate([
91
- (0, di_1.Injectable)(types_js_1.SchemaSource)
92
- ], FileSystemSource);
93
- exports.FileSystemSource = FileSystemSource;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ 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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.FileSystemSource = void 0;
39
+ const configuration_1 = require("@spinajs/configuration");
40
+ const di_1 = require("@spinajs/di");
41
+ const fs = __importStar(require("fs"));
42
+ const glob_1 = __importDefault(require("glob"));
43
+ const path = __importStar(require("path"));
44
+ const types_js_1 = require("./types.js");
45
+ let FileSystemSource = class FileSystemSource extends types_js_1.SchemaSource {
46
+ async LoadJSSchema() {
47
+ if (!this.SchemaDirs)
48
+ return [];
49
+ const promises = this.SchemaDirs.filter((dir) => fs.existsSync(dir))
50
+ .flatMap((d) => glob_1.default.sync(path.join(d, '/**/*.+(js|cjs)').replace(/\\/g, '/')))
51
+ .map((f) => {
52
+ return Promise.resolve(`${`file://${f}`}`).then(s => __importStar(require(s))).then((result) => {
53
+ return {
54
+ result: result,
55
+ file: path.basename(f),
56
+ };
57
+ });
58
+ });
59
+ const result = await Promise.all(promises);
60
+ return result.map((x) => {
61
+ return {
62
+ schema: x.result.default,
63
+ file: x.file,
64
+ };
65
+ });
66
+ }
67
+ LoadJSONSchema() {
68
+ if (!this.SchemaDirs)
69
+ return [];
70
+ return this.SchemaDirs.filter((dir) => fs.existsSync(dir))
71
+ .flatMap((d) => glob_1.default.sync(path.join(d, '/**/*.+(json)').replace(/\\/g, '/')))
72
+ .map((f) => {
73
+ return {
74
+ schema: JSON.parse(fs.readFileSync(f, 'utf-8')),
75
+ file: path.basename(f),
76
+ };
77
+ });
78
+ }
79
+ async Load() {
80
+ const sJS = await this.LoadJSSchema();
81
+ const sJSON = this.LoadJSONSchema();
82
+ return sJS.concat(sJSON);
83
+ }
84
+ };
85
+ exports.FileSystemSource = FileSystemSource;
86
+ __decorate([
87
+ (0, configuration_1.Config)('system.dirs.schemas'),
88
+ __metadata("design:type", Array)
89
+ ], FileSystemSource.prototype, "SchemaDirs", void 0);
90
+ exports.FileSystemSource = FileSystemSource = __decorate([
91
+ (0, di_1.Injectable)(types_js_1.SchemaSource)
92
+ ], FileSystemSource);
94
93
  //# sourceMappingURL=sources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sources.js","sourceRoot":"","sources":["../../src/sources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,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