@cratis/arc 22.28.1 → 22.30.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/commands/Command.ts +20 -14
- package/commands/for_Command/when_executing/with_rule_severities_and_declared_policy.ts +62 -0
- package/commands/for_Command/when_validating/with_rule_severities.ts +120 -0
- package/dist/cjs/commands/Command.d.ts.map +1 -1
- package/dist/cjs/commands/Command.js +27 -6
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/validation/PropertyRule.d.ts +3 -0
- package/dist/cjs/validation/PropertyRule.d.ts.map +1 -1
- package/dist/cjs/validation/PropertyRule.js +13 -1
- package/dist/cjs/validation/PropertyRule.js.map +1 -1
- package/dist/cjs/validation/RuleBuilder.d.ts +2 -0
- package/dist/cjs/validation/RuleBuilder.d.ts.map +1 -1
- package/dist/cjs/validation/RuleBuilder.js +10 -0
- package/dist/cjs/validation/RuleBuilder.js.map +1 -1
- package/dist/esm/commands/Command.d.ts.map +1 -1
- package/dist/esm/commands/Command.js +27 -6
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/for_Command/when_executing/with_rule_severities_and_declared_policy.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_executing/with_rule_severities_and_declared_policy.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_rule_severities_and_declared_policy.js +51 -0
- package/dist/esm/commands/for_Command/when_executing/with_rule_severities_and_declared_policy.js.map +1 -0
- package/dist/esm/commands/for_Command/when_validating/with_rule_severities.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_validating/with_rule_severities.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_validating/with_rule_severities.js +104 -0
- package/dist/esm/commands/for_Command/when_validating/with_rule_severities.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/validation/PropertyRule.d.ts +3 -0
- package/dist/esm/validation/PropertyRule.d.ts.map +1 -1
- package/dist/esm/validation/PropertyRule.js +13 -1
- package/dist/esm/validation/PropertyRule.js.map +1 -1
- package/dist/esm/validation/RuleBuilder.d.ts +2 -0
- package/dist/esm/validation/RuleBuilder.d.ts.map +1 -1
- package/dist/esm/validation/RuleBuilder.js +10 -0
- package/dist/esm/validation/RuleBuilder.js.map +1 -1
- package/package.json +1 -1
- package/validation/PropertyRule.ts +16 -1
- package/validation/RuleBuilder.ts +13 -0
package/commands/Command.ts
CHANGED
|
@@ -102,17 +102,13 @@ export abstract class Command<TCommandContent = object, TCommandResponse = objec
|
|
|
102
102
|
/** @inheritdoc */
|
|
103
103
|
async validate(): Promise<CommandResult<TCommandResponse>> {
|
|
104
104
|
const clientValidationErrors = this.validation?.validate(this) || [];
|
|
105
|
-
const filteredClientErrors = this.
|
|
106
|
-
? clientValidationErrors
|
|
107
|
-
: this.filterValidationResultsBySeverity(clientValidationErrors);
|
|
105
|
+
const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);
|
|
108
106
|
if (filteredClientErrors.length > 0) {
|
|
109
107
|
return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
const validationErrors = this.validateRequiredProperties();
|
|
113
|
-
const filteredRequiredErrors = this.
|
|
114
|
-
? validationErrors
|
|
115
|
-
: this.filterValidationResultsBySeverity(validationErrors);
|
|
111
|
+
const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);
|
|
116
112
|
if (filteredRequiredErrors.length > 0) {
|
|
117
113
|
return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;
|
|
118
114
|
}
|
|
@@ -126,28 +122,38 @@ export abstract class Command<TCommandContent = object, TCommandResponse = objec
|
|
|
126
122
|
}
|
|
127
123
|
|
|
128
124
|
actualRoute = `${actualRoute}/validate`;
|
|
129
|
-
|
|
125
|
+
const result = await this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');
|
|
126
|
+
if (result.isSuccess && clientValidationErrors.length > 0) {
|
|
127
|
+
return Object.assign(result, { validationResults: [...result.validationResults, ...clientValidationErrors] });
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/** @inheritdoc */
|
|
133
133
|
validateClientSide(): CommandResult<TCommandResponse> {
|
|
134
134
|
const clientValidationErrors = this.validation?.validate(this) || [];
|
|
135
|
-
const filteredClientErrors = this.
|
|
136
|
-
? clientValidationErrors
|
|
137
|
-
: this.filterValidationResultsBySeverity(clientValidationErrors);
|
|
135
|
+
const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);
|
|
138
136
|
if (filteredClientErrors.length > 0) {
|
|
139
137
|
return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
const validationErrors = this.validateRequiredProperties();
|
|
143
|
-
const filteredRequiredErrors = this.
|
|
144
|
-
? validationErrors
|
|
145
|
-
: this.filterValidationResultsBySeverity(validationErrors);
|
|
141
|
+
const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);
|
|
146
142
|
if (filteredRequiredErrors.length > 0) {
|
|
147
143
|
return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;
|
|
148
144
|
}
|
|
149
145
|
|
|
150
|
-
|
|
146
|
+
const advisoryResults = [...clientValidationErrors, ...validationErrors];
|
|
147
|
+
if (advisoryResults.length === 0) {
|
|
148
|
+
return CommandResult.empty as CommandResult<TCommandResponse>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return new CommandResult({
|
|
152
|
+
...CommandResult.empty,
|
|
153
|
+
correlationId: CommandResult.empty.correlationId.toString(),
|
|
154
|
+
validationResults: advisoryResults,
|
|
155
|
+
response: null
|
|
156
|
+
}, Object, false) as CommandResult<TCommandResponse>;
|
|
151
157
|
}
|
|
152
158
|
|
|
153
159
|
private buildPayload(): object {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Command } from '../../Command.js';
|
|
5
|
+
import { CommandResult } from '../../CommandResult.js';
|
|
6
|
+
import { CommandValidator } from '../../CommandValidator.js';
|
|
7
|
+
import { PropertyDescriptor } from '../../../reflection/PropertyDescriptor.js';
|
|
8
|
+
import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity.js';
|
|
9
|
+
import '../../../validation/RuleBuilderExtensions.js';
|
|
10
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper.js';
|
|
11
|
+
import sinon from 'sinon';
|
|
12
|
+
|
|
13
|
+
class PolicyValidator extends CommandValidator<{ information: string; error: string; dynamic: string }> {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.ruleFor(c => c.information).notEmpty().withSeverity(ValidationResultSeverity.Information);
|
|
17
|
+
this.ruleFor(c => c.error).notEmpty().withSeverity(ValidationResultSeverity.Error);
|
|
18
|
+
this.ruleFor(c => c.dynamic).notEmpty().withSeverity(null);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class PolicyCommand extends Command<{ information: string; error: string; dynamic: string }, void> {
|
|
23
|
+
readonly route = '/test';
|
|
24
|
+
readonly validation = new PolicyValidator();
|
|
25
|
+
readonly blockOnValidationSeverity = ValidationResultSeverity.Warning;
|
|
26
|
+
readonly propertyDescriptors: PropertyDescriptor[] = [];
|
|
27
|
+
information = '';
|
|
28
|
+
error = 'valid';
|
|
29
|
+
dynamic = '';
|
|
30
|
+
get requestParameters(): string[] { return []; }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('when executing with rule severities and a declared warning policy', () => {
|
|
34
|
+
let command: PolicyCommand;
|
|
35
|
+
let fetchStub: sinon.SinonStub;
|
|
36
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
command = new PolicyCommand(Object, false);
|
|
40
|
+
command.setOrigin('http://localhost');
|
|
41
|
+
fetchHelper = createFetchHelper();
|
|
42
|
+
fetchStub = fetchHelper.stubFetch();
|
|
43
|
+
fetchStub.resolves({ json: async () => ({ ...CommandResult.empty, correlationId: CommandResult.empty.correlationId.toString() }) } as Response);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(() => fetchHelper.restore());
|
|
47
|
+
|
|
48
|
+
it('lets information and runtime-dependent severity reach the server', async () => {
|
|
49
|
+
const result = await command.execute();
|
|
50
|
+
result.isSuccess.should.be.true;
|
|
51
|
+
fetchStub.should.have.been.calledOnce;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('blocks errors locally even with a permissive caller threshold', async () => {
|
|
55
|
+
command.error = '';
|
|
56
|
+
const result = await command.execute(ValidationResultSeverity.Error);
|
|
57
|
+
result.isSuccess.should.be.false;
|
|
58
|
+
result.validationResults.should.have.length(1);
|
|
59
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Error);
|
|
60
|
+
fetchStub.should.not.have.been.called;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Command } from '../../Command.js';
|
|
5
|
+
import { CommandResult } from '../../CommandResult.js';
|
|
6
|
+
import { CommandValidator } from '../../CommandValidator.js';
|
|
7
|
+
import { PropertyDescriptor } from '../../../reflection/PropertyDescriptor.js';
|
|
8
|
+
import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity.js';
|
|
9
|
+
import '../../../validation/RuleBuilderExtensions.js';
|
|
10
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper.js';
|
|
11
|
+
import sinon from 'sinon';
|
|
12
|
+
|
|
13
|
+
class SeverityValidator extends CommandValidator<{ warning: string; error: string; information: string }> {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.ruleFor(c => c.warning).notEmpty().withSeverity(ValidationResultSeverity.Warning);
|
|
17
|
+
this.ruleFor(c => c.error).notEmpty();
|
|
18
|
+
this.ruleFor(c => c.information).notEmpty().withSeverity(ValidationResultSeverity.Information);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class SeverityCommand extends Command<{ warning: string; error: string; information: string }> {
|
|
23
|
+
readonly route = '/test';
|
|
24
|
+
readonly validation = new SeverityValidator();
|
|
25
|
+
readonly propertyDescriptors: PropertyDescriptor[] = [];
|
|
26
|
+
warning = '';
|
|
27
|
+
error = 'valid';
|
|
28
|
+
information = 'valid';
|
|
29
|
+
get requestParameters(): string[] { return []; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class PolicyCommand extends SeverityCommand {
|
|
33
|
+
readonly blockOnValidationSeverity = ValidationResultSeverity.Warning;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe('when validating command rule severities', () => {
|
|
37
|
+
let command: SeverityCommand;
|
|
38
|
+
let fetchStub: sinon.SinonStub;
|
|
39
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
command = new SeverityCommand(Object, false);
|
|
43
|
+
command.setOrigin('http://localhost');
|
|
44
|
+
fetchHelper = createFetchHelper();
|
|
45
|
+
fetchStub = fetchHelper.stubFetch();
|
|
46
|
+
fetchStub.resolves({ json: async () => ({ ...CommandResult.empty, correlationId: CommandResult.empty.correlationId.toString() }) } as Response);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => fetchHelper.restore());
|
|
50
|
+
|
|
51
|
+
it('returns warning-only local results as valid advisories without a policy', () => {
|
|
52
|
+
const result = command.validateClientSide();
|
|
53
|
+
result.isSuccess.should.be.true;
|
|
54
|
+
result.isValid.should.be.true;
|
|
55
|
+
result.validationResults.should.have.length(1);
|
|
56
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Warning);
|
|
57
|
+
fetchStub.should.not.have.been.called;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('calls server validation with a warning-only local result and returns its advisory', async () => {
|
|
61
|
+
const result = await command.validate();
|
|
62
|
+
result.isSuccess.should.be.true;
|
|
63
|
+
result.isValid.should.be.true;
|
|
64
|
+
result.validationResults.should.have.length(1);
|
|
65
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Warning);
|
|
66
|
+
fetchStub.should.have.been.calledOnce;
|
|
67
|
+
fetchStub.firstCall.args[0].toString().should.contain('/test/validate');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('rejects an error locally in both methods without a policy', async () => {
|
|
71
|
+
command.error = '';
|
|
72
|
+
const localResult = command.validateClientSide();
|
|
73
|
+
const preflightResult = await command.validate();
|
|
74
|
+
for (const result of [localResult, preflightResult]) {
|
|
75
|
+
result.isValid.should.be.false;
|
|
76
|
+
result.validationResults.should.have.length(1);
|
|
77
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Error);
|
|
78
|
+
}
|
|
79
|
+
fetchStub.should.not.have.been.called;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('rejects a warning locally in both methods when a warning policy is declared', async () => {
|
|
83
|
+
command = new PolicyCommand(Object, false);
|
|
84
|
+
const localResult = command.validateClientSide();
|
|
85
|
+
const preflightResult = await command.validate();
|
|
86
|
+
for (const result of [localResult, preflightResult]) {
|
|
87
|
+
result.isValid.should.be.false;
|
|
88
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Warning);
|
|
89
|
+
}
|
|
90
|
+
fetchStub.should.not.have.been.called;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('returns information advisories under a declared warning policy and still calls the server', async () => {
|
|
94
|
+
command = new PolicyCommand(Object, false);
|
|
95
|
+
command.setOrigin('http://localhost');
|
|
96
|
+
command.warning = 'valid';
|
|
97
|
+
command.information = '';
|
|
98
|
+
const localResult = command.validateClientSide();
|
|
99
|
+
const preflightResult = await command.validate();
|
|
100
|
+
for (const result of [localResult, preflightResult]) {
|
|
101
|
+
result.isValid.should.be.true;
|
|
102
|
+
result.validationResults.should.have.length(1);
|
|
103
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Information);
|
|
104
|
+
}
|
|
105
|
+
fetchStub.should.have.been.calledOnce;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('rejects an error locally in both methods when a warning policy is declared', async () => {
|
|
109
|
+
command = new PolicyCommand(Object, false);
|
|
110
|
+
command.warning = 'valid';
|
|
111
|
+
command.error = '';
|
|
112
|
+
const localResult = command.validateClientSide();
|
|
113
|
+
const preflightResult = await command.validate();
|
|
114
|
+
for (const result of [localResult, preflightResult]) {
|
|
115
|
+
result.isValid.should.be.false;
|
|
116
|
+
result.validationResults[0].severity.should.equal(ValidationResultSeverity.Error);
|
|
117
|
+
}
|
|
118
|
+
fetchStub.should.not.have.been.called;
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../commands/Command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAInE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAUrF,8BAAsB,OAAO,CAAC,eAAe,GAAG,MAAM,EAAE,gB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AS;IAC5B,OAAO,CAAC,UAAU,CAAkB;IAOpC,YAAqB,aAAa,EAAE,WAAW,YAAS,EAAW,yBAAyB,EAAE,OAAO,EAKpG;IAGD,eAAe,CAAC,YAAY,EAAE,MAAM,QAEnC;IAGD,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAExC;IAGD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9B;IAGD,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAErD;IAGK,OAAO,CAAC,eAAe,CAAC,EAAE,wBAAwB,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAwB5H;IAGK,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CA2BzD;IAGD,kBAAkB,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAwBpD;IAED,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,0BAA0B;IAkBlC,OAAO,CAAC,iCAAiC;IAczC,OAAO,CAAC,YAAY;YAuBN,cAAc;IA+B5B,KAAK,IAAI,IAAI,CAOZ;IAGD,gBAAgB,CAAC,MAAM,EAAE,eAAe,QASvC;IAGD,iCAAiC,SAQhC;IAGD,aAAa,IAAI,IAAI,CAKpB;IAGD,IAAI,UAAU,YAEb;IAGD,eAAe,CAAC,QAAQ,EAAE,MAAM,QAY/B;IAGD,iBAAiB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAK3D;IAED,OAAO,CAAC,gBAAgB;CAM3B"}
|
|
@@ -72,12 +72,12 @@ var ValidationResultSeverity = require('../validation/ValidationResultSeverity.j
|
|
|
72
72
|
}
|
|
73
73
|
/** @inheritdoc */ async validate() {
|
|
74
74
|
const clientValidationErrors = this.validation?.validate(this) || [];
|
|
75
|
-
const filteredClientErrors = this.
|
|
75
|
+
const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);
|
|
76
76
|
if (filteredClientErrors.length > 0) {
|
|
77
77
|
return CommandResult.CommandResult.validationFailed(filteredClientErrors);
|
|
78
78
|
}
|
|
79
79
|
const validationErrors = this.validateRequiredProperties();
|
|
80
|
-
const filteredRequiredErrors = this.
|
|
80
|
+
const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);
|
|
81
81
|
if (filteredRequiredErrors.length > 0) {
|
|
82
82
|
return CommandResult.CommandResult.validationFailed(filteredRequiredErrors);
|
|
83
83
|
}
|
|
@@ -88,20 +88,41 @@ var ValidationResultSeverity = require('../validation/ValidationResultSeverity.j
|
|
|
88
88
|
actualRoute = route;
|
|
89
89
|
}
|
|
90
90
|
actualRoute = `${actualRoute}/validate`;
|
|
91
|
-
|
|
91
|
+
const result = await this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');
|
|
92
|
+
if (result.isSuccess && clientValidationErrors.length > 0) {
|
|
93
|
+
return Object.assign(result, {
|
|
94
|
+
validationResults: [
|
|
95
|
+
...result.validationResults,
|
|
96
|
+
...clientValidationErrors
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
92
101
|
}
|
|
93
102
|
/** @inheritdoc */ validateClientSide() {
|
|
94
103
|
const clientValidationErrors = this.validation?.validate(this) || [];
|
|
95
|
-
const filteredClientErrors = this.
|
|
104
|
+
const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);
|
|
96
105
|
if (filteredClientErrors.length > 0) {
|
|
97
106
|
return CommandResult.CommandResult.validationFailed(filteredClientErrors);
|
|
98
107
|
}
|
|
99
108
|
const validationErrors = this.validateRequiredProperties();
|
|
100
|
-
const filteredRequiredErrors = this.
|
|
109
|
+
const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);
|
|
101
110
|
if (filteredRequiredErrors.length > 0) {
|
|
102
111
|
return CommandResult.CommandResult.validationFailed(filteredRequiredErrors);
|
|
103
112
|
}
|
|
104
|
-
|
|
113
|
+
const advisoryResults = [
|
|
114
|
+
...clientValidationErrors,
|
|
115
|
+
...validationErrors
|
|
116
|
+
];
|
|
117
|
+
if (advisoryResults.length === 0) {
|
|
118
|
+
return CommandResult.CommandResult.empty;
|
|
119
|
+
}
|
|
120
|
+
return new CommandResult.CommandResult({
|
|
121
|
+
...CommandResult.CommandResult.empty,
|
|
122
|
+
correlationId: CommandResult.CommandResult.empty.correlationId.toString(),
|
|
123
|
+
validationResults: advisoryResults,
|
|
124
|
+
response: null
|
|
125
|
+
}, Object, false);
|
|
105
126
|
}
|
|
106
127
|
buildPayload() {
|
|
107
128
|
const payload = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","sources":["../../../commands/Command.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ICommand, PropertyChanged } from './ICommand.js';\nimport { CommandResult } from \"./CommandResult.js\";\nimport { CommandValidator } from './CommandValidator.js';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { Globals } from '../Globals.js';\nimport { joinPaths } from '../joinPaths.js';\nimport { UrlHelpers } from '../UrlHelpers.js';\nimport { GetHttpHeaders } from '../GetHttpHeaders.js';\nimport { PropertyDescriptor } from '../reflection/PropertyDescriptor.js';\nimport { ValidationResult } from '../validation/ValidationResult.js';\nimport { ValidationResultSeverity } from '../validation/ValidationResultSeverity.js';\n\ntype Callback = {\n callback: WeakRef<PropertyChanged>;\n thisArg: WeakRef<object>;\n}\n\n/**\n * Represents an implementation of {@link ICommand} that works with HTTP fetch.\n */\nexport abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _httpHeadersCallback: GetHttpHeaders;\n abstract readonly route: string;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n readonly validation?: CommandValidator<any>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n readonly roles: string[] = [];\n /** Inclusive minimum blocking severity declared by a model-bound command proxy. */\n readonly blockOnValidationSeverity?: ValidationResultSeverity;\n abstract readonly propertyDescriptors: PropertyDescriptor[];\n abstract get requestParameters(): string[];\n\n private _initialValues: object = {};\n private _hasChanges = false;\n private _callbacks: Callback[] = [];\n\n /**\n * Initializes a new instance of the {@link Command<,>} class.\n * @param _responseType Type of response.\n * @param _isResponseTypeEnumerable Whether or not the response type is enumerable.\n */\n constructor(readonly _responseType: Constructor = Object, readonly _isResponseTypeEnumerable: boolean) {\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n async execute(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors, allowedSeverity, ignoreWarnings);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors, allowedSeverity, ignoreWarnings);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n const result = await this.performRequest(actualRoute, 'Command not found at route', 'Error during server call', allowedSeverity, ignoreWarnings);\n this.setInitialValuesFromCurrentValues();\n return result;\n }\n\n /** @inheritdoc */\n async validate(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.blockOnValidationSeverity === undefined\n ? clientValidationErrors\n : this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.blockOnValidationSeverity === undefined\n ? validationErrors\n : this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n actualRoute = `${actualRoute}/validate`;\n return this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');\n }\n\n /** @inheritdoc */\n validateClientSide(): CommandResult<TCommandResponse> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.blockOnValidationSeverity === undefined\n ? clientValidationErrors\n : this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.blockOnValidationSeverity === undefined\n ? validationErrors\n : this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n return CommandResult.empty as unknown as CommandResult<TCommandResponse>;\n }\n\n private buildPayload(): object {\n const payload = {};\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n payload[property] = this[property];\n });\n return payload;\n }\n\n private validateRequiredProperties(): ValidationResult[] {\n const validationErrors: ValidationResult[] = [];\n this.propertyDescriptors.forEach(propertyDescriptor => {\n if (!propertyDescriptor.isOptional && !this.requestParameters.includes(propertyDescriptor.name)) {\n const value = this[propertyDescriptor.name];\n if (value === undefined || value === null) {\n validationErrors.push(new ValidationResult(\n ValidationResultSeverity.Error,\n `${propertyDescriptor.name} is required`,\n [propertyDescriptor.name],\n null\n ));\n }\n }\n });\n return validationErrors;\n }\n\n private filterValidationResultsBySeverity(validationResults: ValidationResult[], allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): ValidationResult[] {\n if (this.blockOnValidationSeverity !== undefined) {\n const effectiveAllowed = Math.min(allowedSeverity ?? ValidationResultSeverity.Error, this.blockOnValidationSeverity - 1);\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Unknown || result.severity > effectiveAllowed);\n }\n if (ignoreWarnings === true) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n if (allowedSeverity === undefined) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n return validationResults.filter(result => result.severity > allowedSeverity);\n }\n\n private buildHeaders(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): HeadersInit {\n const customHeaders = this._httpHeadersCallback?.() ?? {};\n const headers = {\n ...customHeaders,\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n if (allowedSeverity !== undefined) {\n headers['X-Allowed-Severity'] = allowedSeverity.toString();\n }\n\n if (ignoreWarnings === true) {\n headers['X-Ignore-Warnings'] = 'true';\n }\n\n return headers;\n }\n\n private async performRequest(\n route: string,\n notFoundMessage: string,\n errorMessage: string,\n allowedSeverity?: ValidationResultSeverity,\n ignoreWarnings?: boolean\n ): Promise<CommandResult<TCommandResponse>> {\n const payload = this.buildPayload();\n const headers = this.buildHeaders(allowedSeverity, ignoreWarnings);\n const actualRoute = joinPaths(this._apiBasePath, route);\n const url = UrlHelpers.createUrlFrom(this._origin, this._apiBasePath, actualRoute);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JsonSerializer.serialize(payload)\n });\n\n if (response.status === 404) {\n return CommandResult.failed([`${notFoundMessage} '${actualRoute}'`]) as CommandResult<TCommandResponse>;\n }\n\n const result = await response.json();\n return new CommandResult(result, this._responseType, this._isResponseTypeEnumerable);\n } catch (ex) {\n return CommandResult.failed([`${errorMessage}: ${ex}`]) as CommandResult<TCommandResponse>;\n }\n }\n\n /** @inheritdoc */\n clear(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = undefined;\n });\n this._initialValues = {};\n this._hasChanges = false;\n }\n\n /** @inheritdoc */\n setInitialValues(values: TCommandContent) {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (Object.prototype.hasOwnProperty.call(values, property)) {\n this._initialValues[property] = values[property];\n this[property] = values[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n setInitialValuesFromCurrentValues() {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (this[property]) {\n this._initialValues[property] = this[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n revertChanges(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = this._initialValues[property];\n });\n }\n\n /** @inheritdoc */\n get hasChanges() {\n return this._hasChanges;\n }\n\n /** @inheritdoc */\n propertyChanged(property: string) {\n this.updateHasChanges();\n\n this._callbacks.forEach(callbackContainer => {\n const callback = callbackContainer.callback.deref();\n const thisArg = callbackContainer.thisArg.deref();\n if (callback && thisArg) {\n callback.call(thisArg, property);\n } else {\n this._callbacks = this._callbacks.filter(_ => _.callback !== callbackContainer.callback);\n }\n });\n }\n\n /** @inheritdoc */\n onPropertyChanged(callback: PropertyChanged, thisArg: object) {\n this._callbacks.push({\n callback: new WeakRef(callback),\n thisArg: new WeakRef(thisArg)\n });\n }\n\n private updateHasChanges() {\n this._hasChanges = this.propertyDescriptors.some(propertyDescriptor => {\n const property = propertyDescriptor.name;\n return this[property] !== this._initialValues[property];\n });\n }\n}\n"],"names":["Command","_microservice","_apiBasePath","_origin","_httpHeadersCallback","validation","roles","blockOnValidationSeverity","_initialValues","_hasChanges","_callbacks","_responseType","Object","_isResponseTypeEnumerable","Globals","microservice","apiBasePath","origin","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","execute","allowedSeverity","ignoreWarnings","clientValidationErrors","validate","filteredClientErrors","filterValidationResultsBySeverity","length","CommandResult","validationFailed","validationErrors","validateRequiredProperties","filteredRequiredErrors","actualRoute","route","requestParameters","payload","buildPayload","UrlHelpers","replaceRouteParameters","result","performRequest","setInitialValuesFromCurrentValues","undefined","validateClientSide","empty","propertyDescriptors","forEach","propertyDescriptor","property","name","isOptional","includes","value","push","ValidationResult","ValidationResultSeverity","Error","validationResults","effectiveAllowed","Math","min","filter","severity","Unknown","buildHeaders","customHeaders","headers","microserviceHttpHeader","toString","notFoundMessage","errorMessage","joinPaths","url","createUrlFrom","response","fetch","method","body","JsonSerializer","serialize","status","failed","json","ex","clear","setInitialValues","values","prototype","hasOwnProperty","call","updateHasChanges","revertChanges","hasChanges","propertyChanged","callbackContainer","deref","thisArg","_","onPropertyChanged","WeakRef","some"],"mappings":";;;;;;;;;;AAAA;AACA;AAmBA;;AAEC,IACM,MAAeA,OAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,oBAAAA;4DAGR,UAASC;AACT,2DACSC,KAAAA,GAAkB,EAAE;wFAE7B,yBAASC;AAIDC,IAAAA,cAAAA,GAAyB,EAAC;AAC1BC,IAAAA,WAAAA,GAAc,KAAA;A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uBACAgF,iBAAAA,CAAkBhF,QAAyB,EAAE8E,OAAe,EAAE;AAC1D,QAAA,IAAI,CAAC1F,UAAU,CAAC+C,IAAI,CAAC;AACjBnC,YAAAA,QAAAA,EAAU,IAAIiF,OAAAA,CAAQjF,QAAAA,CAAAA;AACtB8E,YAAAA,OAAAA,EAAS,IAAIG,OAAAA,CAAQH,OAAAA;AACzB,SAAA,CAAA;AACJ,IAAA;IAEQN,gBAAAA,GAAmB;QACvB,IAAI,CAACrF,WAAW,GAAG,IAAI,CAACwC,mBAAmB,CAACuD,IAAI,CAACrD,CAAAA,kBAAAA,GAAAA;YAC7C,MAAMC,QAAAA,GAAWD,mBAAmBE,IAAI;YACxC,OAAO,IAAI,CAACD,QAAAA,CAAS,KAAK,IAAI,CAAC5C,cAAc,CAAC4C,QAAAA,CAAS;AAC3D,QAAA,CAAA,CAAA;AACJ,IAAA;AACJ;;"}
|
|
1
|
+
{"version":3,"file":"Command.js","sources":["../../../commands/Command.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ICommand, PropertyChanged } from './ICommand.js';\nimport { CommandResult } from \"./CommandResult.js\";\nimport { CommandValidator } from './CommandValidator.js';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { Globals } from '../Globals.js';\nimport { joinPaths } from '../joinPaths.js';\nimport { UrlHelpers } from '../UrlHelpers.js';\nimport { GetHttpHeaders } from '../GetHttpHeaders.js';\nimport { PropertyDescriptor } from '../reflection/PropertyDescriptor.js';\nimport { ValidationResult } from '../validation/ValidationResult.js';\nimport { ValidationResultSeverity } from '../validation/ValidationResultSeverity.js';\n\ntype Callback = {\n callback: WeakRef<PropertyChanged>;\n thisArg: WeakRef<object>;\n}\n\n/**\n * Represents an implementation of {@link ICommand} that works with HTTP fetch.\n */\nexport abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _httpHeadersCallback: GetHttpHeaders;\n abstract readonly route: string;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n readonly validation?: CommandValidator<any>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n readonly roles: string[] = [];\n /** Inclusive minimum blocking severity declared by a model-bound command proxy. */\n readonly blockOnValidationSeverity?: ValidationResultSeverity;\n abstract readonly propertyDescriptors: PropertyDescriptor[];\n abstract get requestParameters(): string[];\n\n private _initialValues: object = {};\n private _hasChanges = false;\n private _callbacks: Callback[] = [];\n\n /**\n * Initializes a new instance of the {@link Command<,>} class.\n * @param _responseType Type of response.\n * @param _isResponseTypeEnumerable Whether or not the response type is enumerable.\n */\n constructor(readonly _responseType: Constructor = Object, readonly _isResponseTypeEnumerable: boolean) {\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n async execute(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors, allowedSeverity, ignoreWarnings);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors, allowedSeverity, ignoreWarnings);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n const result = await this.performRequest(actualRoute, 'Command not found at route', 'Error during server call', allowedSeverity, ignoreWarnings);\n this.setInitialValuesFromCurrentValues();\n return result;\n }\n\n /** @inheritdoc */\n async validate(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n actualRoute = `${actualRoute}/validate`;\n const result = await this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');\n if (result.isSuccess && clientValidationErrors.length > 0) {\n return Object.assign(result, { validationResults: [...result.validationResults, ...clientValidationErrors] });\n }\n return result;\n }\n\n /** @inheritdoc */\n validateClientSide(): CommandResult<TCommandResponse> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n const advisoryResults = [...clientValidationErrors, ...validationErrors];\n if (advisoryResults.length === 0) {\n return CommandResult.empty as CommandResult<TCommandResponse>;\n }\n\n return new CommandResult({\n ...CommandResult.empty,\n correlationId: CommandResult.empty.correlationId.toString(),\n validationResults: advisoryResults,\n response: null\n }, Object, false) as CommandResult<TCommandResponse>;\n }\n\n private buildPayload(): object {\n const payload = {};\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n payload[property] = this[property];\n });\n return payload;\n }\n\n private validateRequiredProperties(): ValidationResult[] {\n const validationErrors: ValidationResult[] = [];\n this.propertyDescriptors.forEach(propertyDescriptor => {\n if (!propertyDescriptor.isOptional && !this.requestParameters.includes(propertyDescriptor.name)) {\n const value = this[propertyDescriptor.name];\n if (value === undefined || value === null) {\n validationErrors.push(new ValidationResult(\n ValidationResultSeverity.Error,\n `${propertyDescriptor.name} is required`,\n [propertyDescriptor.name],\n null\n ));\n }\n }\n });\n return validationErrors;\n }\n\n private filterValidationResultsBySeverity(validationResults: ValidationResult[], allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): ValidationResult[] {\n if (this.blockOnValidationSeverity !== undefined) {\n const effectiveAllowed = Math.min(allowedSeverity ?? ValidationResultSeverity.Error, this.blockOnValidationSeverity - 1);\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Unknown || result.severity > effectiveAllowed);\n }\n if (ignoreWarnings === true) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n if (allowedSeverity === undefined) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n return validationResults.filter(result => result.severity > allowedSeverity);\n }\n\n private buildHeaders(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): HeadersInit {\n const customHeaders = this._httpHeadersCallback?.() ?? {};\n const headers = {\n ...customHeaders,\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n if (allowedSeverity !== undefined) {\n headers['X-Allowed-Severity'] = allowedSeverity.toString();\n }\n\n if (ignoreWarnings === true) {\n headers['X-Ignore-Warnings'] = 'true';\n }\n\n return headers;\n }\n\n private async performRequest(\n route: string,\n notFoundMessage: string,\n errorMessage: string,\n allowedSeverity?: ValidationResultSeverity,\n ignoreWarnings?: boolean\n ): Promise<CommandResult<TCommandResponse>> {\n const payload = this.buildPayload();\n const headers = this.buildHeaders(allowedSeverity, ignoreWarnings);\n const actualRoute = joinPaths(this._apiBasePath, route);\n const url = UrlHelpers.createUrlFrom(this._origin, this._apiBasePath, actualRoute);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JsonSerializer.serialize(payload)\n });\n\n if (response.status === 404) {\n return CommandResult.failed([`${notFoundMessage} '${actualRoute}'`]) as CommandResult<TCommandResponse>;\n }\n\n const result = await response.json();\n return new CommandResult(result, this._responseType, this._isResponseTypeEnumerable);\n } catch (ex) {\n return CommandResult.failed([`${errorMessage}: ${ex}`]) as CommandResult<TCommandResponse>;\n }\n }\n\n /** @inheritdoc */\n clear(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = undefined;\n });\n this._initialValues = {};\n this._hasChanges = false;\n }\n\n /** @inheritdoc */\n setInitialValues(values: TCommandContent) {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (Object.prototype.hasOwnProperty.call(values, property)) {\n this._initialValues[property] = values[property];\n this[property] = values[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n setInitialValuesFromCurrentValues() {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (this[property]) {\n this._initialValues[property] = this[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n revertChanges(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = this._initialValues[property];\n });\n }\n\n /** @inheritdoc */\n get hasChanges() {\n return this._hasChanges;\n }\n\n /** @inheritdoc */\n propertyChanged(property: string) {\n this.updateHasChanges();\n\n this._callbacks.forEach(callbackContainer => {\n const callback = callbackContainer.callback.deref();\n const thisArg = callbackContainer.thisArg.deref();\n if (callback && thisArg) {\n callback.call(thisArg, property);\n } else {\n this._callbacks = this._callbacks.filter(_ => _.callback !== callbackContainer.callback);\n }\n });\n }\n\n /** @inheritdoc */\n onPropertyChanged(callback: PropertyChanged, thisArg: object) {\n this._callbacks.push({\n callback: new WeakRef(callback),\n thisArg: new WeakRef(thisArg)\n });\n }\n\n private updateHasChanges() {\n this._hasChanges = this.propertyDescriptors.some(propertyDescriptor => {\n const property = propertyDescriptor.name;\n return this[property] !== this._initialValues[property];\n });\n }\n}\n"],"names":["Command","_microservice","_apiBasePath","_origin","_httpHeadersCallback","validation","roles","blockOnValidationSeverity","_initialValues","_hasChanges","_callbacks","_responseType","Object","_isResponseTypeEnumerable","Globals","microservice","apiBasePath","origin","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","execute","allowedSeverity","ignoreWarnings","clientValidationErrors","validate","filteredClientErrors","filterValidationResultsBySeverity","length","CommandResult","validationFailed","validationErrors","validateRequiredProperties","filteredRequiredErrors","actualRoute","route","requestParameters","payload","buildPayload","UrlHelpers","replaceRouteParameters","result","performRequest","setInitialValuesFromCurrentValues","isSuccess","assign","validationResults","validateClientSide","advisoryResults","empty","correlationId","toString","response","propertyDescriptors","forEach","propertyDescriptor","property","name","isOptional","includes","value","undefined","push","ValidationResult","ValidationResultSeverity","Error","effectiveAllowed","Math","min","filter","severity","Unknown","buildHeaders","customHeaders","headers","microserviceHttpHeader","notFoundMessage","errorMessage","joinPaths","url","createUrlFrom","fetch","method","body","JsonSerializer","serialize","status","failed","json","ex","clear","setInitialValues","values","prototype","hasOwnProperty","call","updateHasChanges","revertChanges","hasChanges","propertyChanged","callbackContainer","deref","thisArg","_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AWD,mBAAmBE,IAAI;YACxC,OAAO,IAAI,CAACD,QAAAA,CAAS,KAAK,IAAI,CAAClD,cAAc,CAACkD,QAAAA,CAAS;AAC3D,QAAA,CAAA,CAAA;AACJ,IAAA;AACJ;;"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { IValidationRule } from './IValidationRule.js';
|
|
2
2
|
import { ValidationResult } from './ValidationResult.js';
|
|
3
|
+
import { ValidationResultSeverity } from './ValidationResultSeverity.js';
|
|
3
4
|
export declare abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {
|
|
4
5
|
protected readonly propertyAccessor: (instance: T) => TProperty;
|
|
5
6
|
protected errorMessage: string;
|
|
7
|
+
private severity;
|
|
6
8
|
constructor(propertyAccessor: (instance: T) => TProperty, defaultErrorMessage: string);
|
|
7
9
|
withMessage(message: string): this;
|
|
10
|
+
withSeverity(severity: ValidationResultSeverity | null): this;
|
|
8
11
|
validate(instance: T, propertyName: string): ValidationResult[];
|
|
9
12
|
protected abstract isValid(value: TProperty, instance: T): boolean;
|
|
10
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRule.d.ts","sourceRoot":"","sources":["../../../validation/PropertyRule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyRule.d.ts","sourceRoot":"","sources":["../../../validation/PropertyRule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAOzE,8BAAsB,YAAY,CAAC,CAAC,EAAE,SAAS,CAAE,YAAW,eAAe,CAAC,CAAC,CAAC;IAUtE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,SAAS;IATnE,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAmE;IAOnF,YACuB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,SAAS,EAC/D,mBAAmB,EAAE,MAAM,EAG9B;IAOD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGjC;IAOD,YAAY,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,GAAG,IAAI,CAG5D;IAGD,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAe9D;IAQD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC;CACtE"}
|
|
@@ -12,6 +12,7 @@ var ValidationResultSeverity = require('./ValidationResultSeverity.js');
|
|
|
12
12
|
*/ class PropertyRule {
|
|
13
13
|
propertyAccessor;
|
|
14
14
|
errorMessage;
|
|
15
|
+
severity = ValidationResultSeverity.ValidationResultSeverity.Error;
|
|
15
16
|
/**
|
|
16
17
|
* Initializes a new instance of the {@link PropertyRule} class.
|
|
17
18
|
* @param propertyAccessor Function to access the property value from the instance.
|
|
@@ -28,11 +29,22 @@ var ValidationResultSeverity = require('./ValidationResultSeverity.js');
|
|
|
28
29
|
this.errorMessage = message;
|
|
29
30
|
return this;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Set the severity of this rule. Null leaves an unrepresentable server-side rule to server validation.
|
|
34
|
+
* @param severity The severity, or null if it cannot be determined statically.
|
|
35
|
+
* @returns This rule instance for chaining.
|
|
36
|
+
*/ withSeverity(severity) {
|
|
37
|
+
this.severity = severity;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
31
40
|
/** @inheritdoc */ validate(instance, propertyName) {
|
|
41
|
+
if (this.severity === null) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
32
44
|
const value = this.propertyAccessor(instance);
|
|
33
45
|
if (!this.isValid(value, instance)) {
|
|
34
46
|
return [
|
|
35
|
-
new ValidationResult.ValidationResult(
|
|
47
|
+
new ValidationResult.ValidationResult(this.severity, this.errorMessage.replace('{PropertyName}', propertyName), [
|
|
36
48
|
propertyName
|
|
37
49
|
], null)
|
|
38
50
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRule.js","sources":["../../../validation/PropertyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule.js';\nimport { ValidationResult } from './ValidationResult.js';\nimport { ValidationResultSeverity } from './ValidationResultSeverity.js';\n\n/**\n * Base class for property-based validation rules.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {\n protected errorMessage: string;\n\n /**\n * Initializes a new instance of the {@link PropertyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param defaultErrorMessage The default error message if validation fails.\n */\n constructor(\n protected readonly propertyAccessor: (instance: T) => TProperty,\n defaultErrorMessage: string\n ) {\n this.errorMessage = defaultErrorMessage;\n }\n\n /**\n * Set a custom error message for this rule.\n * @param message The custom error message.\n * @returns This rule instance for chaining.\n */\n withMessage(message: string): this {\n this.errorMessage = message;\n return this;\n }\n\n /** @inheritdoc */\n validate(instance: T, propertyName: string): ValidationResult[] {\n const value = this.propertyAccessor(instance);\n if (!this.isValid(value, instance)) {\n return [new ValidationResult(\n
|
|
1
|
+
{"version":3,"file":"PropertyRule.js","sources":["../../../validation/PropertyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule.js';\nimport { ValidationResult } from './ValidationResult.js';\nimport { ValidationResultSeverity } from './ValidationResultSeverity.js';\n\n/**\n * Base class for property-based validation rules.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {\n protected errorMessage: string;\n private severity: ValidationResultSeverity | null = ValidationResultSeverity.Error;\n\n /**\n * Initializes a new instance of the {@link PropertyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param defaultErrorMessage The default error message if validation fails.\n */\n constructor(\n protected readonly propertyAccessor: (instance: T) => TProperty,\n defaultErrorMessage: string\n ) {\n this.errorMessage = defaultErrorMessage;\n }\n\n /**\n * Set a custom error message for this rule.\n * @param message The custom error message.\n * @returns This rule instance for chaining.\n */\n withMessage(message: string): this {\n this.errorMessage = message;\n return this;\n }\n\n /**\n * Set the severity of this rule. Null leaves an unrepresentable server-side rule to server validation.\n * @param severity The severity, or null if it cannot be determined statically.\n * @returns This rule instance for chaining.\n */\n withSeverity(severity: ValidationResultSeverity | null): this {\n this.severity = severity;\n return this;\n }\n\n /** @inheritdoc */\n validate(instance: T, propertyName: string): ValidationResult[] {\n if (this.severity === null) {\n return [];\n }\n\n const value = this.propertyAccessor(instance);\n if (!this.isValid(value, instance)) {\n return [new ValidationResult(\n this.severity,\n this.errorMessage.replace('{PropertyName}', propertyName),\n [propertyName],\n null\n )];\n }\n return [];\n }\n\n /**\n * Determine if the property value is valid.\n * @param value The property value.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n protected abstract isValid(value: TProperty, instance: T): boolean;\n}\n"],"names":["PropertyRule","errorMessage","severity","ValidationResultSeverity","Error","propertyAccessor","defaultErrorMessage","withMessage","message","withSeverity","validate","instance","propertyName","value","isValid","ValidationResult","replace"],"mappings":";;;;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;;IACRC,YAAAA;IACFC,QAAAA,GAA4CC,iDAAAA,CAAyBC,KAAK;AAElF;;;;AAIC,QACD,WAAA,CACuBC,gBAA4C,EAC/DC,mBAA2B,CAC7B;aAFqBD,gBAAAA,GAAAA,gBAAAA;QAGnB,IAAI,CAACJ,YAAY,GAAGK,mBAAAA;AACxB,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAAQ;QAC/B,IAAI,CAACP,YAAY,GAAGO,OAAAA;AACpB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAC,YAAAA,CAAaP,QAAyC,EAAQ;QAC1D,IAAI,CAACA,QAAQ,GAAGA,QAAAA;AAChB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA,uBACAQ,QAAAA,CAASC,QAAW,EAAEC,YAAoB,EAAsB;AAC5D,QAAA,IAAI,IAAI,CAACV,QAAQ,KAAK,IAAA,EAAM;AACxB,YAAA,OAAO,EAAE;AACb,QAAA;AAEA,QAAA,MAAMW,KAAAA,GAAQ,IAAI,CAACR,gBAAgB,CAACM,QAAAA,CAAAA;AACpC,QAAA,IAAI,CAAC,IAAI,CAACG,OAAO,CAACD,OAAOF,QAAAA,CAAAA,EAAW;YAChC,OAAO;AAAC,gBAAA,IAAII,iCAAAA,CACR,IAAI,CAACb,QAAQ,EACb,IAAI,CAACD,YAAY,CAACe,OAAO,CAAC,gBAAA,EAAkBJ,YAAAA,CAAAA,EAC5C;AAACA,oBAAAA;iBAAa,EACd,IAAA;AACF,aAAA;AACN,QAAA;AACA,QAAA,OAAO,EAAE;AACb,IAAA;AASJ;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropertyValidator } from './PropertyValidator.js';
|
|
2
2
|
import { IValidationRule } from './IValidationRule.js';
|
|
3
|
+
import { ValidationResultSeverity } from './ValidationResultSeverity.js';
|
|
3
4
|
export declare class RuleBuilder<T, TProperty> {
|
|
4
5
|
private readonly propertyValidator;
|
|
5
6
|
private readonly _propertyAccessor;
|
|
@@ -7,5 +8,6 @@ export declare class RuleBuilder<T, TProperty> {
|
|
|
7
8
|
constructor(propertyValidator: PropertyValidator<T>, _propertyAccessor: (instance: T) => TProperty);
|
|
8
9
|
addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty>;
|
|
9
10
|
withMessage(message: string): RuleBuilder<T, TProperty>;
|
|
11
|
+
withSeverity(severity: ValidationResultSeverity | null): RuleBuilder<T, TProperty>;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=RuleBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBuilder.d.ts","sourceRoot":"","sources":["../../../validation/RuleBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"RuleBuilder.d.ts","sourceRoot":"","sources":["../../../validation/RuleBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAOzE,qBAAa,WAAW,CAAC,CAAC,EAAE,SAAS;IAS7B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IATtC,OAAO,CAAC,QAAQ,CAAC,CAAqB;IAOtC,YACqB,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACvC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,SAAS,EAEjE;IAOD,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,SAAS,CAAC,CAI3D;IAOD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,SAAS,CAAC,CAKtD;IAOD,YAAY,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,EAAE,SAAS,CAAC,CAKjF;CACJ"}
|
|
@@ -39,6 +39,16 @@ var PropertyRule = require('./PropertyRule.js');
|
|
|
39
39
|
}
|
|
40
40
|
return this;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Set the severity of the last property rule.
|
|
44
|
+
* @param severity The rule's severity, or null when it is determined only on the server.
|
|
45
|
+
* @returns The rule builder for chaining.
|
|
46
|
+
*/ withSeverity(severity) {
|
|
47
|
+
if (this.lastRule && this.lastRule instanceof PropertyRule.PropertyRule) {
|
|
48
|
+
this.lastRule.withSeverity(severity);
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
exports.RuleBuilder = RuleBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBuilder.js","sources":["../../../validation/RuleBuilder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyValidator } from './PropertyValidator.js';\nimport { IValidationRule } from './IValidationRule.js';\nimport { PropertyRule } from './PropertyRule.js';\n\n/**\n * Represents a builder for creating validation rules for a property.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport class RuleBuilder<T, TProperty> {\n private lastRule?: IValidationRule<T>;\n\n /**\n * Initializes a new instance of the {@link RuleBuilder} class.\n * @param propertyValidator The property validator to add rules to.\n * @param _propertyAccessor Function to access the property value.\n */\n constructor(\n private readonly propertyValidator: PropertyValidator<T>,\n private readonly _propertyAccessor: (instance: T) => TProperty\n ) {\n }\n\n /**\n * Add a custom validation rule.\n * @param rule The validation rule to add.\n * @returns The rule builder for chaining.\n */\n addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty> {\n this.propertyValidator.addRule(rule);\n this.lastRule = rule;\n return this;\n }\n\n /**\n * Set a custom error message for the last added rule.\n * @param message The custom error message.\n * @returns The rule builder for chaining.\n */\n withMessage(message: string): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withMessage(message);\n }\n return this;\n }\n}\n"],"names":["RuleBuilder","lastRule","_propertyAccessor","propertyValidator","addRule","rule","withMessage","message","PropertyRule"],"mappings":";;;;AAAA;AACA;
|
|
1
|
+
{"version":3,"file":"RuleBuilder.js","sources":["../../../validation/RuleBuilder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyValidator } from './PropertyValidator.js';\nimport { IValidationRule } from './IValidationRule.js';\nimport { PropertyRule } from './PropertyRule.js';\nimport { ValidationResultSeverity } from './ValidationResultSeverity.js';\n\n/**\n * Represents a builder for creating validation rules for a property.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport class RuleBuilder<T, TProperty> {\n private lastRule?: IValidationRule<T>;\n\n /**\n * Initializes a new instance of the {@link RuleBuilder} class.\n * @param propertyValidator The property validator to add rules to.\n * @param _propertyAccessor Function to access the property value.\n */\n constructor(\n private readonly propertyValidator: PropertyValidator<T>,\n private readonly _propertyAccessor: (instance: T) => TProperty\n ) {\n }\n\n /**\n * Add a custom validation rule.\n * @param rule The validation rule to add.\n * @returns The rule builder for chaining.\n */\n addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty> {\n this.propertyValidator.addRule(rule);\n this.lastRule = rule;\n return this;\n }\n\n /**\n * Set a custom error message for the last added rule.\n * @param message The custom error message.\n * @returns The rule builder for chaining.\n */\n withMessage(message: string): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withMessage(message);\n }\n return this;\n }\n\n /**\n * Set the severity of the last property rule.\n * @param severity The rule's severity, or null when it is determined only on the server.\n * @returns The rule builder for chaining.\n */\n withSeverity(severity: ValidationResultSeverity | null): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withSeverity(severity);\n }\n return this;\n }\n}\n"],"names":["RuleBuilder","lastRule","_propertyAccessor","propertyValidator","addRule","rule","withMessage","message","PropertyRule","withSeverity","severity"],"mappings":";;;;AAAA;AACA;AAOA;;;;AAIC,IACM,MAAMA,WAAAA,CAAAA;;;IACDC,QAAAA;AAER;;;;AAIC,QACD,YACI,iBAAwD,EACvCC,iBAA6C,CAChE;aAFmBC,iBAAAA,GAAAA,iBAAAA;aACAD,iBAAAA,GAAAA,iBAAAA;AAErB,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQC,IAAwB,EAA6B;AACzD,QAAA,IAAI,CAACF,iBAAiB,CAACC,OAAO,CAACC,IAAAA,CAAAA;QAC/B,IAAI,CAACJ,QAAQ,GAAGI,IAAAA;AAChB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAA6B;QACpD,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,CAACA,QAAQ,YAAYO,yBAAAA,EAAc;AACxD,YAAA,IAAI,CAACP,QAAQ,CAACK,WAAW,CAACC,OAAAA,CAAAA;AAC9B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAE,YAAAA,CAAaC,QAAyC,EAA6B;QAC/E,IAAI,IAAI,CAACT,QAAQ,IAAI,IAAI,CAACA,QAAQ,YAAYO,yBAAAA,EAAc;AACxD,YAAA,IAAI,CAACP,QAAQ,CAACQ,YAAY,CAACC,QAAAA,CAAAA;AAC/B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../commands/Command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,E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