@cratis/arc 21.9.2 → 21.11.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.
Files changed (43) hide show
  1. package/commands/CommandResult.ts +5 -2
  2. package/commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.ts +48 -0
  3. package/commands/for_CommandResult/when_creating_a_validation_failed_result.ts +25 -0
  4. package/dist/cjs/commands/CommandResult.js +4 -2
  5. package/dist/cjs/commands/CommandResult.js.map +1 -1
  6. package/dist/cjs/queries/QueryResult.js +4 -2
  7. package/dist/cjs/queries/QueryResult.js.map +1 -1
  8. package/dist/cjs/validation/ValidationResult.js +6 -1
  9. package/dist/cjs/validation/ValidationResult.js.map +1 -1
  10. package/dist/esm/commands/CommandResult.d.ts +1 -0
  11. package/dist/esm/commands/CommandResult.d.ts.map +1 -1
  12. package/dist/esm/commands/CommandResult.js +4 -2
  13. package/dist/esm/commands/CommandResult.js.map +1 -1
  14. package/dist/esm/commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.d.ts +2 -0
  15. package/dist/esm/commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.d.ts.map +1 -0
  16. package/dist/esm/commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.js +38 -0
  17. package/dist/esm/commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.js.map +1 -0
  18. package/dist/esm/commands/for_CommandResult/when_creating_a_validation_failed_result.d.ts +2 -0
  19. package/dist/esm/commands/for_CommandResult/when_creating_a_validation_failed_result.d.ts.map +1 -0
  20. package/dist/esm/commands/for_CommandResult/when_creating_a_validation_failed_result.js +12 -0
  21. package/dist/esm/commands/for_CommandResult/when_creating_a_validation_failed_result.js.map +1 -0
  22. package/dist/esm/queries/QueryResult.d.ts +1 -0
  23. package/dist/esm/queries/QueryResult.d.ts.map +1 -1
  24. package/dist/esm/queries/QueryResult.js +4 -2
  25. package/dist/esm/queries/QueryResult.js.map +1 -1
  26. package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result_with_a_constraint_violation.d.ts +2 -0
  27. package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result_with_a_constraint_violation.d.ts.map +1 -0
  28. package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result_with_a_constraint_violation.js +28 -0
  29. package/dist/esm/queries/for_QueryResult/when_constructing_from_a_server_result_with_a_constraint_violation.js.map +1 -0
  30. package/dist/esm/queries/for_QueryResult/when_creating_a_validation_failed_result.d.ts +2 -0
  31. package/dist/esm/queries/for_QueryResult/when_creating_a_validation_failed_result.d.ts.map +1 -0
  32. package/dist/esm/queries/for_QueryResult/when_creating_a_validation_failed_result.js +12 -0
  33. package/dist/esm/queries/for_QueryResult/when_creating_a_validation_failed_result.js.map +1 -0
  34. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  35. package/dist/esm/validation/ValidationResult.d.ts +2 -1
  36. package/dist/esm/validation/ValidationResult.d.ts.map +1 -1
  37. package/dist/esm/validation/ValidationResult.js +6 -1
  38. package/dist/esm/validation/ValidationResult.js.map +1 -1
  39. package/package.json +1 -1
  40. package/queries/QueryResult.ts +5 -2
  41. package/queries/for_QueryResult/when_constructing_from_a_server_result_with_a_constraint_violation.ts +35 -0
  42. package/queries/for_QueryResult/when_creating_a_validation_failed_result.ts +27 -0
  43. package/validation/ValidationResult.ts +5 -1
@@ -43,6 +43,7 @@ type ServerCommandResult = {
43
43
  members: string[];
44
44
  state: object;
45
45
  reason?: string;
46
+ reasonDetail?: string;
46
47
  }[];
47
48
  exceptionMessages: string[];
48
49
  exceptionStackTrace: string;
@@ -97,7 +98,9 @@ export class CommandResult<TResponse = object> implements ICommandResult<TRespon
97
98
  severity: _.severity,
98
99
  message: _.message,
99
100
  members: _.members,
100
- state: _.state
101
+ state: _.state,
102
+ reason: _.reason,
103
+ reasonDetail: _.reasonDetail
101
104
  })),
102
105
  exceptionMessages: [],
103
106
  exceptionStackTrace: '',
@@ -148,7 +151,7 @@ export class CommandResult<TResponse = object> implements ICommandResult<TRespon
148
151
  this.isAuthorized = result.isAuthorized;
149
152
  this.isValid = result.isValid;
150
153
  this.hasExceptions = result.hasExceptions;
151
- this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason));
154
+ this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));
152
155
  this.exceptionMessages = result.exceptionMessages;
153
156
  this.exceptionStackTrace = result.exceptionStackTrace;
154
157
  this.authorizationFailureReason = result.authorizationFailureReason;
@@ -0,0 +1,48 @@
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 { ValidationResultReason } from '../../validation/ValidationResultReason';
5
+ import { ValidationResultSeverity } from '../../validation/ValidationResultSeverity';
6
+ import { CommandResult } from '../CommandResult';
7
+
8
+ describe('when constructing from a server result with a constraint violation', () => {
9
+ const result = new CommandResult({
10
+ correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
11
+ isSuccess: false,
12
+ isAuthorized: true,
13
+ isValid: false,
14
+ hasExceptions: false,
15
+ validationResults: [
16
+ {
17
+ severity: ValidationResultSeverity.Error,
18
+ message: 'The organization number is already in use',
19
+ members: ['organizationNumber'],
20
+ state: {},
21
+ reason: ValidationResultReason.ConstraintViolation,
22
+ reasonDetail: 'UniqueOrganizationNumber'
23
+ },
24
+ {
25
+ severity: ValidationResultSeverity.Error,
26
+ message: 'Name is required',
27
+ members: ['name'],
28
+ state: {}
29
+ }
30
+ ],
31
+ exceptionMessages: [],
32
+ exceptionStackTrace: '',
33
+ authorizationFailureReason: '',
34
+ response: null
35
+ }, String, false);
36
+
37
+ it('should carry the name of the violated constraint across the wire', () =>
38
+ result.validationResults[0].reasonDetail!.should.equal('UniqueOrganizationNumber'));
39
+
40
+ // A reason with no finer identity - and a server that predates this - both send nothing.
41
+ it('should leave the detail undefined when the server sends none', () =>
42
+ (result.validationResults[1].reasonDetail === undefined).should.be.true);
43
+
44
+ it('should let a client tell one constraint from another without reading the message', () =>
45
+ result.validationResults
46
+ .filter(_ => _.reason === ValidationResultReason.ConstraintViolation && _.reasonDetail === 'UniqueOrganizationNumber')
47
+ .length.should.equal(1));
48
+ });
@@ -0,0 +1,25 @@
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 { ValidationResult } from '../../validation/ValidationResult';
5
+ import { ValidationResultReason } from '../../validation/ValidationResultReason';
6
+ import { ValidationResultSeverity } from '../../validation/ValidationResultSeverity';
7
+ import { CommandResult } from '../CommandResult';
8
+
9
+ describe('when creating a validation failed result', () => {
10
+ const result = CommandResult.validationFailed([
11
+ new ValidationResult(
12
+ ValidationResultSeverity.Error,
13
+ 'The organization number is already in use',
14
+ ['organizationNumber'],
15
+ {},
16
+ ValidationResultReason.ConstraintViolation,
17
+ 'UniqueOrganizationNumber')
18
+ ]);
19
+
20
+ it('should keep the reason the caller gave it', () =>
21
+ result.validationResults[0].reason.should.equal(ValidationResultReason.ConstraintViolation));
22
+
23
+ it('should keep the name of the violated constraint', () =>
24
+ result.validationResults[0].reasonDetail!.should.equal('UniqueOrganizationNumber'));
25
+ });
@@ -45,7 +45,9 @@ var ValidationResult = require('../validation/ValidationResult.js');
45
45
  severity: _.severity,
46
46
  message: _.message,
47
47
  members: _.members,
48
- state: _.state
48
+ state: _.state,
49
+ reason: _.reason,
50
+ reasonDetail: _.reasonDetail
49
51
  })),
50
52
  exceptionMessages: [],
51
53
  exceptionStackTrace: '',
@@ -74,7 +76,7 @@ var ValidationResult = require('../validation/ValidationResult.js');
74
76
  this.isAuthorized = result.isAuthorized;
75
77
  this.isValid = result.isValid;
76
78
  this.hasExceptions = result.hasExceptions;
77
- this.validationResults = result.validationResults.map((_)=>new ValidationResult.ValidationResult(_.severity, _.message, _.members, _.state, _.reason));
79
+ this.validationResults = result.validationResults.map((_)=>new ValidationResult.ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));
78
80
  this.exceptionMessages = result.exceptionMessages;
79
81
  this.exceptionStackTrace = result.exceptionStackTrace;
80
82
  this.authorizationFailureReason = result.authorizationFailureReason;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandResult.js","sources":["../../../commands/CommandResult.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 { Guid } from '@cratis/fundamentals';\nimport { ICommandResult } from './ICommandResult';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\n\n/**\n * Delegate type for the onSuccess callback.\n */\ntype OnSuccess = (<TResponse>(response: TResponse) => void) | (() => void);\n\n/**\n * Delegate type for the onFailed callback.\n */\ntype OnFailed<TResponse> = ((commandResult: CommandResult<TResponse>) => void) | (() => void);\n\n/**\n * Delegate type for the onException callback.\n */\ntype OnException = (messages: string[], stackTrace: string) => void;\n\n/**\n * Delegate type for the onUnauthorized callback.\n */\ntype OnUnauthorized = () => void;\n\n/**\n * Delegate type for the onValidationFailure callback.\n */\ntype OnValidationFailure = (validationResults: ValidationResult[]) => void;\n\ntype ServerCommandResult = {\n correlationId: string;\n isSuccess: boolean;\n isAuthorized: boolean;\n isValid: boolean;\n hasExceptions: boolean;\n validationResults: {\n severity: number;\n message: string;\n members: string[];\n state: object;\n reason?: string;\n }[];\n exceptionMessages: string[];\n exceptionStackTrace: string;\n authorizationFailureReason: string;\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n response: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n/**\n * Represents the result from executing a {@link ICommand}.\n */\nexport class CommandResult<TResponse = object> implements ICommandResult<TResponse> {\n\n static empty: CommandResult = new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: true,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n\n static failed = (exceptionMessages: string[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: true,\n hasExceptions: true,\n validationResults: [],\n exceptionMessages: exceptionMessages,\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n static validationFailed = (validationResults: ValidationResult[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: false,\n hasExceptions: false,\n validationResults: validationResults.map(_ => ({\n severity: _.severity,\n message: _.message,\n members: _.members,\n state: _.state\n })),\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n /** @inheritdoc */\n readonly correlationId: Guid;\n\n /** @inheritdoc */\n readonly isSuccess: boolean;\n\n /** @inheritdoc */\n readonly isAuthorized: boolean;\n\n /** @inheritdoc */\n readonly isValid: boolean;\n\n /** @inheritdoc */\n readonly hasExceptions: boolean;\n\n /** @inheritdoc */\n readonly validationResults: ValidationResult[];\n\n /** @inheritdoc */\n readonly exceptionMessages: string[];\n\n /** @inheritdoc */\n readonly exceptionStackTrace: string;\n\n /** @inheritdoc */\n readonly authorizationFailureReason: string;\n\n /** @inheritdoc */\n readonly response?: TResponse;\n\n /**\n * Creates an instance of command result.\n * @param {*} result The JSON/any representation of the command result;\n * @param {Constructor} responseInstanceType The {@see Constructor} that represents the type of response, if any. Defaults to {@see Object}.\n * @param {boolean} isResponseTypeEnumerable Whether or not the response type is an enumerable or not.\n */\n constructor(result: ServerCommandResult, responseInstanceType: Constructor = Object, isResponseTypeEnumerable: boolean) {\n this.correlationId = Guid.parse(result.correlationId);\n this.isSuccess = result.isSuccess;\n this.isAuthorized = result.isAuthorized;\n this.isValid = result.isValid;\n this.hasExceptions = result.hasExceptions;\n this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason));\n this.exceptionMessages = result.exceptionMessages;\n this.exceptionStackTrace = result.exceptionStackTrace;\n this.authorizationFailureReason = result.authorizationFailureReason;\n\n if (result.response !== undefined && result.response !== null) {\n const isPrimitive = responseInstanceType === String || responseInstanceType === Number || responseInstanceType === Boolean;\n if (isResponseTypeEnumerable) {\n this.response = (Array.isArray(result.response)\n ? (isPrimitive\n ? Array.from(result.response)\n : JsonSerializer.deserializeArrayFromInstance(responseInstanceType, result.response))\n : []) as TResponse;\n } else {\n this.response = (isPrimitive\n ? result.response\n : JsonSerializer.deserializeFromInstance(responseInstanceType, result.response)) as TResponse;\n }\n }\n }\n\n /**\n * Set up a callback for when the command was successful.\n * @param {OnSuccess} callback The callback to call when the command was successful.\n * @returns {CommandResult} The instance of the command result.\n */\n onSuccess(callback: OnSuccess): CommandResult<TResponse> {\n if (this.isSuccess) {\n callback(this.response as TResponse);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed.\n * @param {OnFailed} callback The callback to call when the command failed.\n * @returns {CommandResult} The instance of the command result.\n */\n onFailed(callback: OnFailed<TResponse>): CommandResult<TResponse> {\n if (!this.isSuccess) {\n callback(this);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed with an exception.\n * @param {OnException} callback The callback to call when the command had an exception.\n * @returns {CommandResult} The instance of the command result.\n */\n onException(callback: OnException): CommandResult<TResponse> {\n if (this.hasExceptions) {\n callback(this.exceptionMessages, this.exceptionStackTrace);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command was unauthorized.\n * @param {OnUnauthorized} callback The callback to call when the command was unauthorized.\n * @returns {CommandResult} The instance of the command result.\n */\n onUnauthorized(callback: OnUnauthorized): CommandResult<TResponse> {\n if (!this.isAuthorized) {\n callback();\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command had validation errors.\n * @param {OnSuccess} callback The callback to call when the command was invalid.\n * @returns {CommandResult} The instance of the command result.\n */\n onValidationFailure(callback: OnValidationFailure): CommandResult<TResponse> {\n if (!this.isValid) {\n callback(this.validationResults);\n }\n return this;\n }\n}\n"],"names":["CommandResult","empty","correlationId","Guid","toString","isSuccess","isAuthorized","isValid","hasExceptions","validationResults","exceptionMessages","exceptionStackTrace","authorizationFailureReason","response","Object","failed","validationFailed","map","_","severity","message","members","state","result","responseInstanceType","isResponseTypeEnumerable","parse","ValidationResult","reason","undefined","isPrimitive","String","Number","Boolean","Array","isArray","from","JsonSerializer","deserializeArrayFromInstance","deserializeFromInstance","onSuccess","callback","onFailed","onException","onUnauthorized","onValidationFailure"],"mappings":";;;;;AAAA;AACA;AAsDA;;AAEC,IACM,MAAMA,aAAAA,CAAAA;IAET,OAAOC,KAAAA,GAAuB,IAAID,aAAAA,CAAc;QAC5CE,aAAAA,EAAeC,iBAAAA,CAAKF,KAAK,CAACG,QAAQ,EAAA;QAClCC,SAAAA,EAAW,IAAA;QACXC,YAAAA,EAAc,IAAA;QACdC,OAAAA,EAAS,IAAA;QACTC,aAAAA,EAAe,KAAA;AACfC,QAAAA,iBAAAA,EAAmB,EAAE;AACrBC,QAAAA,iBAAAA,EAAmB,EAAE;QACrBC,mBAAAA,EAAqB,EAAA;QACrBC,0BAAAA,EAA4B,EAAA;QAC5BC,QAAAA,EAAU;AACd,KAAA,EAAGC,QAAQ,KAAA,CAAA;AAEX,IAAA,OAAOC,SAAS,CAACL,iBAAAA,GAAAA;AACb,QAAA,OAAO,IAAIV,aAAAA,CAAc;YACrBE,aAAAA,EAAeC,iBAAAA,CAAKF,KAAK,CAACG,QAAQ,EAAA;YAClCC,SAAAA,EAAW,KAAA;YACXC,YAAAA,EAAc,IAAA;YACdC,OAAAA,EAAS,IAAA;YACTC,aAAAA,EAAe,IAAA;AACfC,YAAAA,iBAAAA,EAAmB,EAAE;YACrBC,iBAAAA,EAAmBA,iBAAAA;YACnBC,mBAAAA,EAAqB,EAAA;YACrBC,0BAAAA,EAA4B,EAAA;YAC5BC,QAAAA,EAAU;AACd,SAAA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AAmB,EAA4B;QACrD,IAAI,IAAI,CAACpC,SAAS,EAAE;YAChBoC,QAAAA,CAAS,IAAI,CAAC5B,QAAQ,CAAA;AAC1B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKA6B,QAAAA,CAASD,QAA6B,EAA4B;AAC9D,QAAA,IAAI,CAAC,IAAI,CAACpC,SAAS,EAAE;AACjBoC,YAAAA,QAAAA,CAAS,IAAI,CAAA;AACjB,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAE,WAAAA,CAAYF,QAAqB,EAA4B;QACzD,IAAI,IAAI,CAACjC,aAAa,EAAE;AACpBiC,YAAAA,QAAAA,CAAS,IAAI,CAAC/B,iBAAiB,EAAE,IAAI,CAACC,mBAAmB,CAAA;AAC7D,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAiC,cAAAA,CAAeH,QAAwB,EAA4B;AAC/D,QAAA,IAAI,CAAC,IAAI,CAACnC,YAAY,EAAE;AACpBmC,YAAAA,QAAAA,EAAAA;AACJ,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAI,mBAAAA,CAAoBJ,QAA6B,EAA4B;AACzE,QAAA,IAAI,CAAC,IAAI,CAAClC,OAAO,EAAE;YACfkC,QAAAA,CAAS,IAAI,CAAChC,iBAAiB,CAAA;AACnC,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;;;"}
1
+ {"version":3,"file":"CommandResult.js","sources":["../../../commands/CommandResult.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 { Guid } from '@cratis/fundamentals';\nimport { ICommandResult } from './ICommandResult';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\n\n/**\n * Delegate type for the onSuccess callback.\n */\ntype OnSuccess = (<TResponse>(response: TResponse) => void) | (() => void);\n\n/**\n * Delegate type for the onFailed callback.\n */\ntype OnFailed<TResponse> = ((commandResult: CommandResult<TResponse>) => void) | (() => void);\n\n/**\n * Delegate type for the onException callback.\n */\ntype OnException = (messages: string[], stackTrace: string) => void;\n\n/**\n * Delegate type for the onUnauthorized callback.\n */\ntype OnUnauthorized = () => void;\n\n/**\n * Delegate type for the onValidationFailure callback.\n */\ntype OnValidationFailure = (validationResults: ValidationResult[]) => void;\n\ntype ServerCommandResult = {\n correlationId: string;\n isSuccess: boolean;\n isAuthorized: boolean;\n isValid: boolean;\n hasExceptions: boolean;\n validationResults: {\n severity: number;\n message: string;\n members: string[];\n state: object;\n reason?: string;\n reasonDetail?: string;\n }[];\n exceptionMessages: string[];\n exceptionStackTrace: string;\n authorizationFailureReason: string;\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n response: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n/**\n * Represents the result from executing a {@link ICommand}.\n */\nexport class CommandResult<TResponse = object> implements ICommandResult<TResponse> {\n\n static empty: CommandResult = new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: true,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n\n static failed = (exceptionMessages: string[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: true,\n hasExceptions: true,\n validationResults: [],\n exceptionMessages: exceptionMessages,\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n static validationFailed = (validationResults: ValidationResult[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: false,\n hasExceptions: false,\n validationResults: validationResults.map(_ => ({\n severity: _.severity,\n message: _.message,\n members: _.members,\n state: _.state,\n reason: _.reason,\n reasonDetail: _.reasonDetail\n })),\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n /** @inheritdoc */\n readonly correlationId: Guid;\n\n /** @inheritdoc */\n readonly isSuccess: boolean;\n\n /** @inheritdoc */\n readonly isAuthorized: boolean;\n\n /** @inheritdoc */\n readonly isValid: boolean;\n\n /** @inheritdoc */\n readonly hasExceptions: boolean;\n\n /** @inheritdoc */\n readonly validationResults: ValidationResult[];\n\n /** @inheritdoc */\n readonly exceptionMessages: string[];\n\n /** @inheritdoc */\n readonly exceptionStackTrace: string;\n\n /** @inheritdoc */\n readonly authorizationFailureReason: string;\n\n /** @inheritdoc */\n readonly response?: TResponse;\n\n /**\n * Creates an instance of command result.\n * @param {*} result The JSON/any representation of the command result;\n * @param {Constructor} responseInstanceType The {@see Constructor} that represents the type of response, if any. Defaults to {@see Object}.\n * @param {boolean} isResponseTypeEnumerable Whether or not the response type is an enumerable or not.\n */\n constructor(result: ServerCommandResult, responseInstanceType: Constructor = Object, isResponseTypeEnumerable: boolean) {\n this.correlationId = Guid.parse(result.correlationId);\n this.isSuccess = result.isSuccess;\n this.isAuthorized = result.isAuthorized;\n this.isValid = result.isValid;\n this.hasExceptions = result.hasExceptions;\n this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));\n this.exceptionMessages = result.exceptionMessages;\n this.exceptionStackTrace = result.exceptionStackTrace;\n this.authorizationFailureReason = result.authorizationFailureReason;\n\n if (result.response !== undefined && result.response !== null) {\n const isPrimitive = responseInstanceType === String || responseInstanceType === Number || responseInstanceType === Boolean;\n if (isResponseTypeEnumerable) {\n this.response = (Array.isArray(result.response)\n ? (isPrimitive\n ? Array.from(result.response)\n : JsonSerializer.deserializeArrayFromInstance(responseInstanceType, result.response))\n : []) as TResponse;\n } else {\n this.response = (isPrimitive\n ? result.response\n : JsonSerializer.deserializeFromInstance(responseInstanceType, result.response)) as TResponse;\n }\n }\n }\n\n /**\n * Set up a callback for when the command was successful.\n * @param {OnSuccess} callback The callback to call when the command was successful.\n * @returns {CommandResult} The instance of the command result.\n */\n onSuccess(callback: OnSuccess): CommandResult<TResponse> {\n if (this.isSuccess) {\n callback(this.response as TResponse);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed.\n * @param {OnFailed} callback The callback to call when the command failed.\n * @returns {CommandResult} The instance of the command result.\n */\n onFailed(callback: OnFailed<TResponse>): CommandResult<TResponse> {\n if (!this.isSuccess) {\n callback(this);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed with an exception.\n * @param {OnException} callback The callback to call when the command had an exception.\n * @returns {CommandResult} The instance of the command result.\n */\n onException(callback: OnException): CommandResult<TResponse> {\n if (this.hasExceptions) {\n callback(this.exceptionMessages, this.exceptionStackTrace);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command was unauthorized.\n * @param {OnUnauthorized} callback The callback to call when the command was unauthorized.\n * @returns {CommandResult} The instance of the command result.\n */\n onUnauthorized(callback: OnUnauthorized): CommandResult<TResponse> {\n if (!this.isAuthorized) {\n callback();\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command had validation errors.\n * @param {OnSuccess} callback The callback to call when the command was invalid.\n * @returns {CommandResult} The instance of the command result.\n */\n onValidationFailure(callback: OnValidationFailure): CommandResult<TResponse> {\n if (!this.isValid) {\n callback(this.validationResults);\n }\n return this;\n }\n}\n"],"names":["CommandResult","empty","correlationId","Guid","toString","isSuccess","isAuthorized","isValid","hasExceptions","validationResults","exceptionMessages","exceptionStackTrace","authorizationFailureReason","response","Object","failed","validationFailed","map","_","severity","message","members","state","reason","reasonDetail","result","responseInstanceType","isResponseTypeEnumerable","parse","ValidationResult","undefined","isPrimitive","String","Number","Boolean","Array","isArray","from","JsonSerializer","deserializeArrayFromInstance","deserializeFromInstance","onSuccess","callback","onFailed","onException","onUnauthorized","onValidationFailure"],"mappings":";;;;;AAAA;AACA;AAuDA;;AAEC,IACM,MAAMA,aAAAA,CAAAA;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,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAE,WAAAA,CAAYF,QAAqB,EAA4B;QACzD,IAAI,IAAI,CAAClC,aAAa,EAAE;AACpBkC,YAAAA,QAAAA,CAAS,IAAI,CAAChC,iBAAiB,EAAE,IAAI,CAACC,mBAAmB,CAAA;AAC7D,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAkC,cAAAA,CAAeH,QAAwB,EAA4B;AAC/D,QAAA,IAAI,CAAC,IAAI,CAACpC,YAAY,EAAE;AACpBoC,YAAAA,QAAAA,EAAAA;AACJ,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAI,mBAAAA,CAAoBJ,QAA6B,EAA4B;AACzE,QAAA,IAAI,CAAC,IAAI,CAACnC,OAAO,EAAE;YACfmC,QAAAA,CAAS,IAAI,CAACjC,iBAAiB,CAAA;AACnC,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;;;"}
@@ -46,7 +46,9 @@ var deserializeQueryModel = require('./deserializeQueryModel.js');
46
46
  severity: _.severity,
47
47
  message: _.message,
48
48
  members: _.members,
49
- state: _.state
49
+ state: _.state,
50
+ reason: _.reason,
51
+ reasonDetail: _.reasonDetail
50
52
  })),
51
53
  exceptionMessages: [],
52
54
  exceptionStackTrace: '',
@@ -102,7 +104,7 @@ var deserializeQueryModel = require('./deserializeQueryModel.js');
102
104
  this.isAuthorized = result.isAuthorized;
103
105
  this.isValid = result.isValid;
104
106
  this.hasExceptions = result.hasExceptions;
105
- this.validationResults = result.validationResults.map((_)=>new ValidationResult.ValidationResult(_.severity, _.message, _.members, _.state, _.reason));
107
+ this.validationResults = result.validationResults.map((_)=>new ValidationResult.ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));
106
108
  this.exceptionMessages = result.exceptionMessages;
107
109
  this.exceptionStackTrace = result.exceptionStackTrace;
108
110
  this.paging = new PagingInfo.PagingInfo();
@@ -1 +1 @@
1
- {"version":3,"file":"QueryResult.js","sources":["../../../queries/QueryResult.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 { Constructor } from '@cratis/fundamentals';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\nimport { ChangeSet } from './ChangeSet';\nimport { deserializeQueryModel, deserializeQueryModels } from './deserializeQueryModel';\n\ntype ServerQueryResult = {\n /* eslint-disable @typescript-eslint/no-explicit-any */\n data: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n isSuccess: boolean;\n isAuthorized: boolean;\n isValid: boolean;\n hasExceptions: boolean;\n validationResults: ServerValidationResult[];\n exceptionMessages: string[];\n exceptionStackTrace: string;\n paging: ServerPagingInfo;\n changeSet?: ServerChangeSet;\n}\n\ntype ServerChangeSet = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n added: any[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replaced: any[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n removed: any[];\n}\n\ntype ServerValidationResult = {\n severity: number;\n message: string;\n members: string[];\n state: object;\n reason?: string;\n}\n\ntype ServerPagingInfo = {\n page: number;\n size: number; \n totalItems: number;\n totalPages: number;\n}\n\n/**\n * Represents the result from executing a {@link IQueryFor}.\n * @template TDataType The data type.\n */\nexport class QueryResult<TDataType = object> implements IQueryResult<TDataType> {\n\n static empty<TDataType>(defaultValue: TDataType): QueryResult<TDataType> {\n return new QueryResult({\n data: defaultValue as object,\n isSuccess: true,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n\n }, Object, false);\n }\n\n /**\n * Creates a {@link QueryResult} representing a query rejected by client-side validation, mirroring\n * {@link CommandResult.validationFailed} so a caller reads a failed query the same way it reads a failed command.\n * @param {ValidationResult[]} validationResults The validation results that caused the failure.\n * @param {object} query The query being rejected, which describes how to shape its own result.\n * @returns {QueryResult<TDataType>} A result that is neither successful nor valid.\n */\n static validationFailed<TDataType>(\n validationResults: ValidationResult[],\n query: { readonly defaultValue: TDataType; readonly modelType: Constructor; readonly enumerable: boolean }): QueryResult<TDataType> {\n const { defaultValue, modelType, enumerable } = query;\n return new QueryResult({\n data: defaultValue as object,\n isSuccess: false,\n isAuthorized: true,\n isValid: false,\n hasExceptions: false,\n validationResults: validationResults.map(_ => ({\n severity: _.severity,\n message: _.message,\n members: _.members,\n state: _.state\n })),\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n }, modelType, enumerable) as QueryResult<TDataType>;\n }\n\n static unauthorized<TDataType>(): QueryResult<TDataType> {\n return new QueryResult({\n data: null as unknown as object,\n isSuccess: false,\n isAuthorized: false,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n }, Object, false);\n }\n\n static noSuccess: QueryResult = new QueryResult({\n data: {},\n isSuccess: false,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n }, Object, false);\n\n /**\n * Creates an instance of query result.\n * @param {*} result The raw result from the backend.\n * @param {Constructor} instanceType The type of instance to deserialize.\n * @param {boolean} enumerable Whether or not the result is supposed be an enumerable or not.\n */\n constructor(result: ServerQueryResult, instanceType: Constructor, enumerable: boolean) {\n this.isSuccess = result.isSuccess;\n this.isAuthorized = result.isAuthorized;\n this.isValid = result.isValid;\n this.hasExceptions = result.hasExceptions;\n this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason));\n this.exceptionMessages = result.exceptionMessages;\n this.exceptionStackTrace = result.exceptionStackTrace;\n this.paging = new PagingInfo();\n this.paging.page = result.paging.page;\n this.paging.size = result.paging.size;\n this.paging.totalItems = result.paging.totalItems;\n this.paging.totalPages = result.paging.totalPages;\n\n if (result.data) {\n this.data = (enumerable\n ? deserializeQueryModels(instanceType, result.data)\n : deserializeQueryModel(instanceType, result.data)) as TDataType;\n } else {\n this.data = (enumerable ? [] : null) as TDataType;\n }\n\n if (enumerable && result.changeSet) {\n this.changeSet = {\n added: deserializeQueryModels(instanceType, result.changeSet.added ?? []),\n replaced: deserializeQueryModels(instanceType, result.changeSet.replaced ?? []),\n removed: deserializeQueryModels(instanceType, result.changeSet.removed ?? []),\n } as ChangeSet<unknown>;\n }\n }\n\n /** @inheritdoc */\n readonly data: TDataType;\n\n /** @inheritdoc */\n readonly paging: PagingInfo;\n\n /** @inheritdoc */\n readonly isSuccess: boolean;\n\n /** @inheritdoc */\n readonly isAuthorized: boolean;\n\n /** @inheritdoc */\n readonly isValid: boolean;\n\n /** @inheritdoc */\n readonly hasExceptions: boolean;\n\n /** @inheritdoc */\n readonly validationResults: ValidationResult[];\n\n /** @inheritdoc */\n readonly exceptionMessages: string[];\n\n /** @inheritdoc */\n readonly exceptionStackTrace: string;\n\n /**\n * Gets the optional change set describing what changed since the previous update.\n * Set by the server when the delta transfer mode is active.\n * When present, clients can apply the delta to their local state rather than replacing\n * the full dataset.\n */\n readonly changeSet?: ChangeSet<unknown>;\n\n /**\n * Gets whether or not the query has data.\n */\n get hasData(): boolean {\n if (this.data) {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return true;\n }\n return false;\n }\n}\n"],"names":["QueryResult","empty","defaultValue","data","isSuccess","isAuthorized","isValid","hasExceptions","validationResults","exceptionMessages","exceptionStackTrace","paging","totalItems","totalPages","page","size","Object","validationFailed","query","modelType","enumerable","map","_","severity","message","members","state","unauthorized","noSuccess","result","instanceType","ValidationResult","reason","PagingInfo","deserializeQueryModels","deserializeQueryModel","changeSet","added","replaced","removed","hasData","Array","isArray","length"],"mappings":";;;;;;AAAA;AACA;AAgDA;;;AAGC,IACM,MAAMA,WAAAA,CAAAA;IAET,OAAOC,KAAAA,CAAiBC,YAAuB,EAA0B;AACrE,QAAA,OAAO,IAAIF,WAAAA,CAAY;YACnBG,IAAAA,EAAMD,YAAAA;YACNE,SAAAA,EAAW,IAAA;YACXC,YAAAA,EAAc,IAAA;YACdC,OAAAA,EAAS,IAAA;YACTC,aAAAA,EAAe,KAAA;AACfC,YAAAA,iBAAAA,EAAmB,EAAE;AACrBC,YAAAA,iBAAAA,EAAmB,EAAE;YACrBC,mBAAAA,EAAqB,EAAA;YACrBC,MAAAA,EAAQ;gBACJC,UAAAA,EAAY,CAAA;gBACZC,UAAAA,EAAY,CAAA;gBACZC,IAAAA,EAAM,CAAA;gBACNC,IAAAA,EAAM;AACV;AAEJ,SAAA,EAAGC,MAAAA,EAAQ,KAAA,CAAA;AACf,IAAA;AAEA;;;;;;AAMC,QACD,OAAOC,gBAAAA,CACHT,iBAAqC,EACrCU,KAA0G,EAA0B;AACpI,QAAA,MAAM,EAAEhB,YAAY,EAAEiB,SAAS,EAAEC,UAAU,EAAE,GAAGF,KAAAA;AAChD,QAAA,OAAO,IAAIlB,WAAAA,CAAY;YACnBG,IAAAA,EAAMD,YAAAA;YACNE,SAAAA,EAAW,KAAA;YACXC,YAAAA,EAAc,IAAA;YACdC,OAAAA,EAAS,KAAA;YACTC,aAAAA,EAAe,KAAA;AACfC,YAAAA,iBAAAA,EAAmBA,iBAAAA,CAAkBa,GAAG,CAACC,CAAAA,KAAM;AAC3CC,oBAAAA,QAAAA,EAAUD,EAAEC,QAAQ;AACpBC,oBAAAA,OAAAA,EAASF,EAAEE,OAAO;AAClBC,oBAAAA,OAAAA,EAASH,EAAEG,OAAO;AAClBC,oBAAAA,KAAAA,EAAOJ,EAAEI;iBACb,CAAA,CAAA;AACAjB,YAAAA,iBAA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,MAAO;AACH,YAAA,IAAI,CAACA,IAAI,GAAIiB,UAAAA,GAAa,EAAE,GAAG,IAAA;AACnC,QAAA;QAEA,IAAIA,UAAAA,IAAcS,MAAAA,CAAOO,SAAS,EAAE;YAChC,IAAI,CAACA,SAAS,GAAG;AACbC,gBAAAA,KAAAA,EAAOH,6CAAuBJ,YAAAA,EAAcD,MAAAA,CAAOO,SAAS,CAACC,KAAK,IAAI,EAAE,CAAA;AACxEC,gBAAAA,QAAAA,EAAUJ,6CAAuBJ,YAAAA,EAAcD,MAAAA,CAAOO,SAAS,CAACE,QAAQ,IAAI,EAAE,CAAA;AAC9EC,gBAAAA,OAAAA,EAASL,6CAAuBJ,YAAAA,EAAcD,MAAAA,CAAOO,SAAS,CAACG,OAAO,IAAI,EAAE;AAChF,aAAA;AACJ,QAAA;AACJ,IAAA;uBAGA,IAASpC;uBAGT,MAASQ;uBAGT,SAASP;uBAGT,YAASC;uBAGT,OAASC;uBAGT,aAASC;uBAGT,iBAASC;uBAGT,iBAASC;uBAGT,mBAASC;AAET;;;;;AAKC,QACD,SAAS0B;AAET;;AAEC,QACD,IAAII,OAAAA,GAAmB;QACnB,IAAI,IAAI,CAACrC,IAAI,EAAE;AACX,YAAA,IAAIsC,MAAMC,OAAO,CAAC,IAAI,CAACvC,IAAI,CAAA,EAAG;AAC1B,gBAAA,OAAO,IAAI,CAACA,IAAI,CAACwC,MAAM,GAAG,CAAA;AAC9B,YAAA;YACA,OAAO,IAAA;AACX,QAAA;QACA,OAAO,KAAA;AACX,IAAA;AACJ;;;;"}
1
+ {"version":3,"file":"QueryResult.js","sources":["../../../queries/QueryResult.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 { Constructor } from '@cratis/fundamentals';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\nimport { ChangeSet } from './ChangeSet';\nimport { deserializeQueryModel, deserializeQueryModels } from './deserializeQueryModel';\n\ntype ServerQueryResult = {\n /* eslint-disable @typescript-eslint/no-explicit-any */\n data: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n isSuccess: boolean;\n isAuthorized: boolean;\n isValid: boolean;\n hasExceptions: boolean;\n validationResults: ServerValidationResult[];\n exceptionMessages: string[];\n exceptionStackTrace: string;\n paging: ServerPagingInfo;\n changeSet?: ServerChangeSet;\n}\n\ntype ServerChangeSet = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n added: any[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replaced: any[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n removed: any[];\n}\n\ntype ServerValidationResult = {\n severity: number;\n message: string;\n members: string[];\n state: object;\n reason?: string;\n reasonDetail?: string;\n}\n\ntype ServerPagingInfo = {\n page: number;\n size: number; \n totalItems: number;\n totalPages: number;\n}\n\n/**\n * Represents the result from executing a {@link IQueryFor}.\n * @template TDataType The data type.\n */\nexport class QueryResult<TDataType = object> implements IQueryResult<TDataType> {\n\n static empty<TDataType>(defaultValue: TDataType): QueryResult<TDataType> {\n return new QueryResult({\n data: defaultValue as object,\n isSuccess: true,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n\n }, Object, false);\n }\n\n /**\n * Creates a {@link QueryResult} representing a query rejected by client-side validation, mirroring\n * {@link CommandResult.validationFailed} so a caller reads a failed query the same way it reads a failed command.\n * @param {ValidationResult[]} validationResults The validation results that caused the failure.\n * @param {object} query The query being rejected, which describes how to shape its own result.\n * @returns {QueryResult<TDataType>} A result that is neither successful nor valid.\n */\n static validationFailed<TDataType>(\n validationResults: ValidationResult[],\n query: { readonly defaultValue: TDataType; readonly modelType: Constructor; readonly enumerable: boolean }): QueryResult<TDataType> {\n const { defaultValue, modelType, enumerable } = query;\n return new QueryResult({\n data: defaultValue as object,\n isSuccess: false,\n isAuthorized: true,\n isValid: false,\n hasExceptions: false,\n validationResults: validationResults.map(_ => ({\n severity: _.severity,\n message: _.message,\n members: _.members,\n state: _.state,\n reason: _.reason,\n reasonDetail: _.reasonDetail\n })),\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n }, modelType, enumerable) as QueryResult<TDataType>;\n }\n\n static unauthorized<TDataType>(): QueryResult<TDataType> {\n return new QueryResult({\n data: null as unknown as object,\n isSuccess: false,\n isAuthorized: false,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n }, Object, false);\n }\n\n static noSuccess: QueryResult = new QueryResult({\n data: {},\n isSuccess: false,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n paging: {\n totalItems: 0,\n totalPages: 0,\n page: 0,\n size: 0\n }\n }, Object, false);\n\n /**\n * Creates an instance of query result.\n * @param {*} result The raw result from the backend.\n * @param {Constructor} instanceType The type of instance to deserialize.\n * @param {boolean} enumerable Whether or not the result is supposed be an enumerable or not.\n */\n constructor(result: ServerQueryResult, instanceType: Constructor, enumerable: boolean) {\n this.isSuccess = result.isSuccess;\n this.isAuthorized = result.isAuthorized;\n this.isValid = result.isValid;\n this.hasExceptions = result.hasExceptions;\n this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));\n this.exceptionMessages = result.exceptionMessages;\n this.exceptionStackTrace = result.exceptionStackTrace;\n this.paging = new PagingInfo();\n this.paging.page = result.paging.page;\n this.paging.size = result.paging.size;\n this.paging.totalItems = result.paging.totalItems;\n this.paging.totalPages = result.paging.totalPages;\n\n if (result.data) {\n this.data = (enumerable\n ? deserializeQueryModels(instanceType, result.data)\n : deserializeQueryModel(instanceType, result.data)) as TDataType;\n } else {\n this.data = (enumerable ? [] : null) as TDataType;\n }\n\n if (enumerable && result.changeSet) {\n this.changeSet = {\n added: deserializeQueryModels(instanceType, result.changeSet.added ?? []),\n replaced: deserializeQueryModels(instanceType, result.changeSet.replaced ?? []),\n removed: deserializeQueryModels(instanceType, result.changeSet.removed ?? []),\n } as ChangeSet<unknown>;\n }\n }\n\n /** @inheritdoc */\n readonly data: TDataType;\n\n /** @inheritdoc */\n readonly paging: PagingInfo;\n\n /** @inheritdoc */\n readonly isSuccess: boolean;\n\n /** @inheritdoc */\n readonly isAuthorized: boolean;\n\n /** @inheritdoc */\n readonly isValid: boolean;\n\n /** @inheritdoc */\n readonly hasExceptions: boolean;\n\n /** @inheritdoc */\n readonly validationResults: ValidationResult[];\n\n /** @inheritdoc */\n readonly exceptionMessages: string[];\n\n /** @inheritdoc */\n readonly exceptionStackTrace: string;\n\n /**\n * Gets the optional change set describing what changed since the previous update.\n * Set by the server when the delta transfer mode is active.\n * When present, clients can apply the delta to their local state rather than replacing\n * the full dataset.\n */\n readonly changeSet?: ChangeSet<unknown>;\n\n /**\n * Gets whether or not the query has data.\n */\n get hasData(): boolean {\n if (this.data) {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return true;\n }\n return false;\n }\n}\n"],"names":["QueryResult","empty","defaultValue","data","isSuccess","isAuthorized","isValid","hasExceptions","validationResults","exceptionMessages","exceptionStackTrace","paging","totalItems","totalPages","page","size","Object","validationFailed","query","modelType","enumerable","map","_","severity","message","members","state","reason","reasonDetail","unauthorized","noSuccess","result","instanceType","ValidationResult","PagingInfo","deserializeQueryModels","deserializeQueryModel","changeSet","added","replaced","removed","hasData","Array","isArray","length"],"mappings":";;;;;;AAAA;AACA;AAiDA;;;AAGC,IACM,MAAMA,WAAAA,CAAAA;IAET,OAAOC,KAAAA,CAAiBC,YAAuB,EAA0B;AACrE,QAAA,OAAO,IAAIF,WAAAA,CAAY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QAAA;QAEA,IAAIA,UAAAA,IAAcW,MAAAA,CAAOM,SAAS,EAAE;YAChC,IAAI,CAACA,SAAS,GAAG;AACbC,gBAAAA,KAAAA,EAAOH,6CAAuBH,YAAAA,EAAcD,MAAAA,CAAOM,SAAS,CAACC,KAAK,IAAI,EAAE,CAAA;AACxEC,gBAAAA,QAAAA,EAAUJ,6CAAuBH,YAAAA,EAAcD,MAAAA,CAAOM,SAAS,CAACE,QAAQ,IAAI,EAAE,CAAA;AAC9EC,gBAAAA,OAAAA,EAASL,6CAAuBH,YAAAA,EAAcD,MAAAA,CAAOM,SAAS,CAACG,OAAO,IAAI,EAAE;AAChF,aAAA;AACJ,QAAA;AACJ,IAAA;uBAGA,IAASrC;uBAGT,MAASQ;uBAGT,SAASP;uBAGT,YAASC;uBAGT,OAASC;uBAGT,aAASC;uBAGT,iBAASC;uBAGT,iBAASC;uBAGT,mBAASC;AAET;;;;;AAKC,QACD,SAAS2B;AAET;;AAEC,QACD,IAAII,OAAAA,GAAmB;QACnB,IAAI,IAAI,CAACtC,IAAI,EAAE;AACX,YAAA,IAAIuC,MAAMC,OAAO,CAAC,IAAI,CAACxC,IAAI,CAAA,EAAG;AAC1B,gBAAA,OAAO,IAAI,CAACA,IAAI,CAACyC,MAAM,GAAG,CAAA;AAC9B,YAAA;YACA,OAAO,IAAA;AACX,QAAA;QACA,OAAO,KAAA;AACX,IAAA;AACJ;;;;"}
@@ -12,6 +12,7 @@ var ValidationResultReason = require('./ValidationResultReason.js');
12
12
  members;
13
13
  state;
14
14
  reason;
15
+ reasonDetail;
15
16
  /**
16
17
  * Initializes a new instance of the {@link ValidationResult} class.
17
18
  * @param severity The severity of the result.
@@ -19,12 +20,16 @@ var ValidationResultReason = require('./ValidationResultReason.js');
19
20
  * @param members The members the result is attributed to.
20
21
  * @param state State associated with the result - the rule author's, carried straight through.
21
22
  * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.
22
- */ constructor(severity, message, members, state, reason = ValidationResultReason.ValidationResultReason.Rule){
23
+ * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated
24
+ * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.
25
+ * Branch on this rather than matching {@link message}, which is prose and free to change.
26
+ */ constructor(severity, message, members, state, reason = ValidationResultReason.ValidationResultReason.Rule, reasonDetail){
23
27
  this.severity = severity;
24
28
  this.message = message;
25
29
  this.members = members;
26
30
  this.state = state;
27
31
  this.reason = reason;
32
+ this.reasonDetail = reasonDetail;
28
33
  }
29
34
  }
30
35
 
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.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 { ValidationResultReason } from './ValidationResultReason';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule) {\n }\n}\n"],"names":["ValidationResult","message","members","reason","ValidationResultReason","Rule","severity","state"],"mappings":";;;;AAAA;AACA;AAKA;;AAIC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;AACT;;;;;;;AAOC,QACD,YACI,QAA2C,EAClCC,OAAe,EACfC,OAAiB,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,6CAAAA,CAAuBC,IAAI,CAAE;aAJ9DC,QAAAA,GAAAA,QAAAA;aACAL,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAK,KAAAA,GAAAA,KAAAA;aACAJ,MAAAA,GAAAA,MAAAA;AACb,IAAA;AACJ;;;;"}
1
+ {"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.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 { ValidationResultReason } from './ValidationResultReason';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated\n * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.\n * Branch on this rather than matching {@link message}, which is prose and free to change.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule,\n readonly reasonDetail?: string) {\n }\n}\n"],"names":["ValidationResult","reason","ValidationResultReason","Rule","reasonDetail","severity","message","members","state"],"mappings":";;;;AAAA;AACA;AAKA;;AAIC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;;AACT;;;;;;;;;;QAWA,WAAA,CACI,QAA2C,EAC3C,OAAwB,EACxB,OAA0B,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,6CAAAA,CAAuBC,IAAI,EAC5DC,YAAqB,CAAE;aALvBC,QAAAA,GAAAA,QAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,KAAAA,GAAAA,KAAAA;aACAP,MAAAA,GAAAA,MAAAA;aACAG,YAAAA,GAAAA,YAAAA;AACb,IAAA;AACJ;;;;"}
@@ -19,6 +19,7 @@ type ServerCommandResult = {
19
19
  members: string[];
20
20
  state: object;
21
21
  reason?: string;
22
+ reasonDetail?: string;
22
23
  }[];
23
24
  exceptionMessages: string[];
24
25
  exceptionStackTrace: string;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandResult.d.ts","sourceRoot":"","sources":["../../../commands/CommandResult.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAKnE,KAAK,SAAS,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,KAAK,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAK3E,KAAK,QAAQ,CAAC,SAAS,IAAI,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAK9F,KAAK,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;AAKpE,KAAK,cAAc,GAAG,MAAM,IAAI,CAAC;AAKjC,KAAK,mBAAmB,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;AAE3E,KAAK,mBAAmB,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QA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,QAAQ,EAAE,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,CAKvD;IAOD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,CAKhE;IAOD,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,CAK3D;IAOD,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,aAAa,CAAC,SAAS,CAAC,CAKjE;IAOD,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,aAAa,CAAC,SAAS,CAAC,CAK3E;CACJ"}
@@ -43,7 +43,9 @@ import { ValidationResult } from '../validation/ValidationResult.js';
43
43
  severity: _.severity,
44
44
  message: _.message,
45
45
  members: _.members,
46
- state: _.state
46
+ state: _.state,
47
+ reason: _.reason,
48
+ reasonDetail: _.reasonDetail
47
49
  })),
48
50
  exceptionMessages: [],
49
51
  exceptionStackTrace: '',
@@ -72,7 +74,7 @@ import { ValidationResult } from '../validation/ValidationResult.js';
72
74
  this.isAuthorized = result.isAuthorized;
73
75
  this.isValid = result.isValid;
74
76
  this.hasExceptions = result.hasExceptions;
75
- this.validationResults = result.validationResults.map((_)=>new ValidationResult(_.severity, _.message, _.members, _.state, _.reason));
77
+ this.validationResults = result.validationResults.map((_)=>new ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));
76
78
  this.exceptionMessages = result.exceptionMessages;
77
79
  this.exceptionStackTrace = result.exceptionStackTrace;
78
80
  this.authorizationFailureReason = result.authorizationFailureReason;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandResult.js","sources":["../../../commands/CommandResult.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 { Guid } from '@cratis/fundamentals';\nimport { ICommandResult } from './ICommandResult';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\n\n/**\n * Delegate type for the onSuccess callback.\n */\ntype OnSuccess = (<TResponse>(response: TResponse) => void) | (() => void);\n\n/**\n * Delegate type for the onFailed callback.\n */\ntype OnFailed<TResponse> = ((commandResult: CommandResult<TResponse>) => void) | (() => void);\n\n/**\n * Delegate type for the onException callback.\n */\ntype OnException = (messages: string[], stackTrace: string) => void;\n\n/**\n * Delegate type for the onUnauthorized callback.\n */\ntype OnUnauthorized = () => void;\n\n/**\n * Delegate type for the onValidationFailure callback.\n */\ntype OnValidationFailure = (validationResults: ValidationResult[]) => void;\n\ntype ServerCommandResult = {\n correlationId: string;\n isSuccess: boolean;\n isAuthorized: boolean;\n isValid: boolean;\n hasExceptions: boolean;\n validationResults: {\n severity: number;\n message: string;\n members: string[];\n state: object;\n reason?: string;\n }[];\n exceptionMessages: string[];\n exceptionStackTrace: string;\n authorizationFailureReason: string;\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n response: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n/**\n * Represents the result from executing a {@link ICommand}.\n */\nexport class CommandResult<TResponse = object> implements ICommandResult<TResponse> {\n\n static empty: CommandResult = new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: true,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n\n static failed = (exceptionMessages: string[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: true,\n hasExceptions: true,\n validationResults: [],\n exceptionMessages: exceptionMessages,\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n static validationFailed = (validationResults: ValidationResult[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: false,\n hasExceptions: false,\n validationResults: validationResults.map(_ => ({\n severity: _.severity,\n message: _.message,\n members: _.members,\n state: _.state\n })),\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n /** @inheritdoc */\n readonly correlationId: Guid;\n\n /** @inheritdoc */\n readonly isSuccess: boolean;\n\n /** @inheritdoc */\n readonly isAuthorized: boolean;\n\n /** @inheritdoc */\n readonly isValid: boolean;\n\n /** @inheritdoc */\n readonly hasExceptions: boolean;\n\n /** @inheritdoc */\n readonly validationResults: ValidationResult[];\n\n /** @inheritdoc */\n readonly exceptionMessages: string[];\n\n /** @inheritdoc */\n readonly exceptionStackTrace: string;\n\n /** @inheritdoc */\n readonly authorizationFailureReason: string;\n\n /** @inheritdoc */\n readonly response?: TResponse;\n\n /**\n * Creates an instance of command result.\n * @param {*} result The JSON/any representation of the command result;\n * @param {Constructor} responseInstanceType The {@see Constructor} that represents the type of response, if any. Defaults to {@see Object}.\n * @param {boolean} isResponseTypeEnumerable Whether or not the response type is an enumerable or not.\n */\n constructor(result: ServerCommandResult, responseInstanceType: Constructor = Object, isResponseTypeEnumerable: boolean) {\n this.correlationId = Guid.parse(result.correlationId);\n this.isSuccess = result.isSuccess;\n this.isAuthorized = result.isAuthorized;\n this.isValid = result.isValid;\n this.hasExceptions = result.hasExceptions;\n this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason));\n this.exceptionMessages = result.exceptionMessages;\n this.exceptionStackTrace = result.exceptionStackTrace;\n this.authorizationFailureReason = result.authorizationFailureReason;\n\n if (result.response !== undefined && result.response !== null) {\n const isPrimitive = responseInstanceType === String || responseInstanceType === Number || responseInstanceType === Boolean;\n if (isResponseTypeEnumerable) {\n this.response = (Array.isArray(result.response)\n ? (isPrimitive\n ? Array.from(result.response)\n : JsonSerializer.deserializeArrayFromInstance(responseInstanceType, result.response))\n : []) as TResponse;\n } else {\n this.response = (isPrimitive\n ? result.response\n : JsonSerializer.deserializeFromInstance(responseInstanceType, result.response)) as TResponse;\n }\n }\n }\n\n /**\n * Set up a callback for when the command was successful.\n * @param {OnSuccess} callback The callback to call when the command was successful.\n * @returns {CommandResult} The instance of the command result.\n */\n onSuccess(callback: OnSuccess): CommandResult<TResponse> {\n if (this.isSuccess) {\n callback(this.response as TResponse);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed.\n * @param {OnFailed} callback The callback to call when the command failed.\n * @returns {CommandResult} The instance of the command result.\n */\n onFailed(callback: OnFailed<TResponse>): CommandResult<TResponse> {\n if (!this.isSuccess) {\n callback(this);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed with an exception.\n * @param {OnException} callback The callback to call when the command had an exception.\n * @returns {CommandResult} The instance of the command result.\n */\n onException(callback: OnException): CommandResult<TResponse> {\n if (this.hasExceptions) {\n callback(this.exceptionMessages, this.exceptionStackTrace);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command was unauthorized.\n * @param {OnUnauthorized} callback The callback to call when the command was unauthorized.\n * @returns {CommandResult} The instance of the command result.\n */\n onUnauthorized(callback: OnUnauthorized): CommandResult<TResponse> {\n if (!this.isAuthorized) {\n callback();\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command had validation errors.\n * @param {OnSuccess} callback The callback to call when the command was invalid.\n * @returns {CommandResult} The instance of the command result.\n */\n onValidationFailure(callback: OnValidationFailure): CommandResult<TResponse> {\n if (!this.isValid) {\n callback(this.validationResults);\n }\n return this;\n }\n}\n"],"names":["CommandResult","empty","correlationId","Guid","toString","isSuccess","isAuthorized","isValid","hasExceptions","validationResults","exceptionMessages","exceptionStackTrace","authorizationFailureReason","response","Object","failed","validationFailed","map","_","severity","message","members","state","result","responseInstanceType","isResponseTypeEnumerable","parse","ValidationResult","reason","undefined","isPrimitive","String","Number","Boolean","Array","isArray","from","JsonSerializer","deserializeArrayFromInstance","deserializeFromInstance","onSuccess","callback","onFailed","onException","onUnauthorized","onValidationFailure"],"mappings":";;;AAAA;AACA;AAsDA;;AAEC,IACM,MAAMA,aAAAA,CAAAA;IAET,O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,IAAI,CAAC/B,iBAAiB,EAAE,IAAI,CAACC,mBAAmB,CAAA;AAC7D,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAiC,cAAAA,CAAeH,QAAwB,EAA4B;AAC/D,QAAA,IAAI,CAAC,IAAI,CAACnC,YAAY,EAAE;AACpBmC,YAAAA,QAAAA,EAAAA;AACJ,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAI,mBAAAA,CAAoBJ,QAA6B,EAA4B;AACzE,QAAA,IAAI,CAAC,IAAI,CAAClC,OAAO,EAAE;YACfkC,QAAAA,CAAS,IAAI,CAAChC,iBAAiB,CAAA;AACnC,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;;;"}
1
+ {"version":3,"file":"CommandResult.js","sources":["../../../commands/CommandResult.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 { Guid } from '@cratis/fundamentals';\nimport { ICommandResult } from './ICommandResult';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\n\n/**\n * Delegate type for the onSuccess callback.\n */\ntype OnSuccess = (<TResponse>(response: TResponse) => void) | (() => void);\n\n/**\n * Delegate type for the onFailed callback.\n */\ntype OnFailed<TResponse> = ((commandResult: CommandResult<TResponse>) => void) | (() => void);\n\n/**\n * Delegate type for the onException callback.\n */\ntype OnException = (messages: string[], stackTrace: string) => void;\n\n/**\n * Delegate type for the onUnauthorized callback.\n */\ntype OnUnauthorized = () => void;\n\n/**\n * Delegate type for the onValidationFailure callback.\n */\ntype OnValidationFailure = (validationResults: ValidationResult[]) => void;\n\ntype ServerCommandResult = {\n correlationId: string;\n isSuccess: boolean;\n isAuthorized: boolean;\n isValid: boolean;\n hasExceptions: boolean;\n validationResults: {\n severity: number;\n message: string;\n members: string[];\n state: object;\n reason?: string;\n reasonDetail?: string;\n }[];\n exceptionMessages: string[];\n exceptionStackTrace: string;\n authorizationFailureReason: string;\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n response: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n/**\n * Represents the result from executing a {@link ICommand}.\n */\nexport class CommandResult<TResponse = object> implements ICommandResult<TResponse> {\n\n static empty: CommandResult = new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: true,\n isAuthorized: true,\n isValid: true,\n hasExceptions: false,\n validationResults: [],\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n\n static failed = (exceptionMessages: string[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: true,\n hasExceptions: true,\n validationResults: [],\n exceptionMessages: exceptionMessages,\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n static validationFailed = (validationResults: ValidationResult[]): CommandResult => {\n return new CommandResult({\n correlationId: Guid.empty.toString(),\n isSuccess: false,\n isAuthorized: true,\n isValid: false,\n hasExceptions: false,\n validationResults: validationResults.map(_ => ({\n severity: _.severity,\n message: _.message,\n members: _.members,\n state: _.state,\n reason: _.reason,\n reasonDetail: _.reasonDetail\n })),\n exceptionMessages: [],\n exceptionStackTrace: '',\n authorizationFailureReason: '',\n response: null\n }, Object, false);\n };\n\n /** @inheritdoc */\n readonly correlationId: Guid;\n\n /** @inheritdoc */\n readonly isSuccess: boolean;\n\n /** @inheritdoc */\n readonly isAuthorized: boolean;\n\n /** @inheritdoc */\n readonly isValid: boolean;\n\n /** @inheritdoc */\n readonly hasExceptions: boolean;\n\n /** @inheritdoc */\n readonly validationResults: ValidationResult[];\n\n /** @inheritdoc */\n readonly exceptionMessages: string[];\n\n /** @inheritdoc */\n readonly exceptionStackTrace: string;\n\n /** @inheritdoc */\n readonly authorizationFailureReason: string;\n\n /** @inheritdoc */\n readonly response?: TResponse;\n\n /**\n * Creates an instance of command result.\n * @param {*} result The JSON/any representation of the command result;\n * @param {Constructor} responseInstanceType The {@see Constructor} that represents the type of response, if any. Defaults to {@see Object}.\n * @param {boolean} isResponseTypeEnumerable Whether or not the response type is an enumerable or not.\n */\n constructor(result: ServerCommandResult, responseInstanceType: Constructor = Object, isResponseTypeEnumerable: boolean) {\n this.correlationId = Guid.parse(result.correlationId);\n this.isSuccess = result.isSuccess;\n this.isAuthorized = result.isAuthorized;\n this.isValid = result.isValid;\n this.hasExceptions = result.hasExceptions;\n this.validationResults = result.validationResults.map(_ => new ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));\n this.exceptionMessages = result.exceptionMessages;\n this.exceptionStackTrace = result.exceptionStackTrace;\n this.authorizationFailureReason = result.authorizationFailureReason;\n\n if (result.response !== undefined && result.response !== null) {\n const isPrimitive = responseInstanceType === String || responseInstanceType === Number || responseInstanceType === Boolean;\n if (isResponseTypeEnumerable) {\n this.response = (Array.isArray(result.response)\n ? (isPrimitive\n ? Array.from(result.response)\n : JsonSerializer.deserializeArrayFromInstance(responseInstanceType, result.response))\n : []) as TResponse;\n } else {\n this.response = (isPrimitive\n ? result.response\n : JsonSerializer.deserializeFromInstance(responseInstanceType, result.response)) as TResponse;\n }\n }\n }\n\n /**\n * Set up a callback for when the command was successful.\n * @param {OnSuccess} callback The callback to call when the command was successful.\n * @returns {CommandResult} The instance of the command result.\n */\n onSuccess(callback: OnSuccess): CommandResult<TResponse> {\n if (this.isSuccess) {\n callback(this.response as TResponse);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed.\n * @param {OnFailed} callback The callback to call when the command failed.\n * @returns {CommandResult} The instance of the command result.\n */\n onFailed(callback: OnFailed<TResponse>): CommandResult<TResponse> {\n if (!this.isSuccess) {\n callback(this);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command failed with an exception.\n * @param {OnException} callback The callback to call when the command had an exception.\n * @returns {CommandResult} The instance of the command result.\n */\n onException(callback: OnException): CommandResult<TResponse> {\n if (this.hasExceptions) {\n callback(this.exceptionMessages, this.exceptionStackTrace);\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command was unauthorized.\n * @param {OnUnauthorized} callback The callback to call when the command was unauthorized.\n * @returns {CommandResult} The instance of the command result.\n */\n onUnauthorized(callback: OnUnauthorized): CommandResult<TResponse> {\n if (!this.isAuthorized) {\n callback();\n }\n return this;\n }\n\n /**\n * Set up a callback for when the command had validation errors.\n * @param {OnSuccess} callback The callback to call when the command was invalid.\n * @returns {CommandResult} The instance of the command result.\n */\n onValidationFailure(callback: OnValidationFailure): CommandResult<TResponse> {\n if (!this.isValid) {\n callback(this.validationResults);\n }\n return this;\n }\n}\n"],"names":["CommandResult","empty","correlationId","Guid","toString","isSuccess","isAuthorized","isValid","hasExceptions","validationResults","exceptionMessages","exceptionStackTrace","authorizationFailureReason","response","Object","failed","validationFailed","map","_","severity","message","members","state","reason","reasonDetail","result","responseInstanceType","isResponseTypeEnumerable","parse","ValidationResult","undefined","isPrimitive","String","Number","Boolean","Array","isArray","from","JsonSerializer","deserializeArrayFromInstance","deserializeFromInstance","onSuccess","callback","onFailed","onException","onUnauthorized","onValidationFailure"],"mappings":";;;AAAA;AACA;AAuDA;;AAEC,IACM,MAAMA,aAAAA,CAAAA;IAET,OAAOC,KAAAA,GAAuB,IAAID,aAAAA,CAAc;QAC5CE,aAAAA,EAAeC,IAAAA,CAAKF,KAAK,CAACG,QAAQ,EAAA;QAClCC,SAAAA,EAAW,IAAA;QACXC,YAAAA,EAAc,IAAA;QACdC,OAAAA,EAAS,IAAA;QACTC,aAAAA,EAAe,KAAA;AACfC,QAAAA,iBAAAA,EAAmB,EAAE;AACrBC,QAAAA,iBAAAA,EAAmB,EAAE;QACrBC,mBAAAA,EAAqB,EAAA;QACrBC,0BAAAA,EAA4B,EAAA;QAC5BC,QAAAA,EAAU;AACd,KAAA,EAAGC,QAAQ,KAAA,CAAA;AAEX,IAAA,OAAOC,SAAS,CAACL,iBAAAA,GAAA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A,CAAoBJ,QAA6B,EAA4B;AACzE,QAAA,IAAI,CAAC,IAAI,CAACnC,OAAO,EAAE;YACfmC,QAAAA,CAAS,IAAI,CAACjC,iBAAiB,CAAA;AACnC,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;;;"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=when_constructing_from_a_server_result_with_a_constraint_violation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_constructing_from_a_server_result_with_a_constraint_violation.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { ValidationResultReason } from '../../validation/ValidationResultReason';
2
+ import { ValidationResultSeverity } from '../../validation/ValidationResultSeverity';
3
+ import { CommandResult } from '../CommandResult';
4
+ describe('when constructing from a server result with a constraint violation', () => {
5
+ const result = new CommandResult({
6
+ correlationId: '0c0ee8c8-b5a6-4999-b030-6e6a0c931b91',
7
+ isSuccess: false,
8
+ isAuthorized: true,
9
+ isValid: false,
10
+ hasExceptions: false,
11
+ validationResults: [
12
+ {
13
+ severity: ValidationResultSeverity.Error,
14
+ message: 'The organization number is already in use',
15
+ members: ['organizationNumber'],
16
+ state: {},
17
+ reason: ValidationResultReason.ConstraintViolation,
18
+ reasonDetail: 'UniqueOrganizationNumber'
19
+ },
20
+ {
21
+ severity: ValidationResultSeverity.Error,
22
+ message: 'Name is required',
23
+ members: ['name'],
24
+ state: {}
25
+ }
26
+ ],
27
+ exceptionMessages: [],
28
+ exceptionStackTrace: '',
29
+ authorizationFailureReason: '',
30
+ response: null
31
+ }, String, false);
32
+ it('should carry the name of the violated constraint across the wire', () => result.validationResults[0].reasonDetail.should.equal('UniqueOrganizationNumber'));
33
+ it('should leave the detail undefined when the server sends none', () => (result.validationResults[1].reasonDetail === undefined).should.be.true);
34
+ it('should let a client tell one constraint from another without reading the message', () => result.validationResults
35
+ .filter(_ => _.reason === ValidationResultReason.ConstraintViolation && _.reasonDetail === 'UniqueOrganizationNumber')
36
+ .length.should.equal(1));
37
+ });
38
+ //# sourceMappingURL=when_constructing_from_a_server_result_with_a_constraint_violation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_constructing_from_a_server_result_with_a_constraint_violation.js","sourceRoot":"","sources":["../../../../commands/for_CommandResult/when_constructing_from_a_server_result_with_a_constraint_violation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,QAAQ,CAAC,oEAAoE,EAAE,GAAG,EAAE;IAChF,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC;QAC7B,aAAa,EAAE,sCAAsC;QACrD,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE;YACf;gBACI,QAAQ,EAAE,wBAAwB,CAAC,KAAK;gBACxC,OAAO,EAAE,2CAA2C;gBACpD,OAAO,EAAE,CAAC,oBAAoB,CAAC;gBAC/B,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,sBAAsB,CAAC,mBAAmB;gBAClD,YAAY,EAAE,0BAA0B;aAC3C;YACD;gBACI,QAAQ,EAAE,wBAAwB,CAAC,KAAK;gBACxC,OAAO,EAAE,kBAAkB;gBAC3B,OAAO,EAAE,CAAC,MAAM,CAAC;gBACjB,KAAK,EAAE,EAAE;aACZ;SACJ;QACD,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,0BAA0B,EAAE,EAAE;QAC9B,QAAQ,EAAE,IAAI;KACjB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAElB,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE,CACxE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,YAAa,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAGxF,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE,CACpE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAE7E,EAAE,CAAC,kFAAkF,EAAE,GAAG,EAAE,CACxF,MAAM,CAAC,iBAAiB;SACnB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,sBAAsB,CAAC,mBAAmB,IAAI,CAAC,CAAC,YAAY,KAAK,0BAA0B,CAAC;SACrH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=when_creating_a_validation_failed_result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_creating_a_validation_failed_result.d.ts","sourceRoot":"","sources":["../../../../commands/for_CommandResult/when_creating_a_validation_failed_result.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { ValidationResult } from '../../validation/ValidationResult';
2
+ import { ValidationResultReason } from '../../validation/ValidationResultReason';
3
+ import { ValidationResultSeverity } from '../../validation/ValidationResultSeverity';
4
+ import { CommandResult } from '../CommandResult';
5
+ describe('when creating a validation failed result', () => {
6
+ const result = CommandResult.validationFailed([
7
+ new ValidationResult(ValidationResultSeverity.Error, 'The organization number is already in use', ['organizationNumber'], {}, ValidationResultReason.ConstraintViolation, 'UniqueOrganizationNumber')
8
+ ]);
9
+ it('should keep the reason the caller gave it', () => result.validationResults[0].reason.should.equal(ValidationResultReason.ConstraintViolation));
10
+ it('should keep the name of the violated constraint', () => result.validationResults[0].reasonDetail.should.equal('UniqueOrganizationNumber'));
11
+ });
12
+ //# sourceMappingURL=when_creating_a_validation_failed_result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when_creating_a_validation_failed_result.js","sourceRoot":"","sources":["../../../../commands/for_CommandResult/when_creating_a_validation_failed_result.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;IACtD,MAAM,MAAM,GAAG,aAAa,CAAC,gBAAgB,CAAC;QAC1C,IAAI,gBAAgB,CAChB,wBAAwB,CAAC,KAAK,EAC9B,2CAA2C,EAC3C,CAAC,oBAAoB,CAAC,EACtB,EAAE,EACF,sBAAsB,CAAC,mBAAmB,EAC1C,0BAA0B,CAAC;KAClC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE,CACjD,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAEjG,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE,CACvD,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,YAAa,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;AAC5F,CAAC,CAAC,CAAC"}
@@ -26,6 +26,7 @@ type ServerValidationResult = {
26
26
  members: string[];
27
27
  state: object;
28
28
  reason?: string;
29
+ reasonDetail?: string;
29
30
  };
30
31
  type ServerPagingInfo = {
31
32
  page: number;
@@ -1 +1 @@
1
- {"version":3,"file":"QueryResult.d.ts","sourceRoot":"","sources":["../../../queries/Q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,SAAS,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAkBvE;IASD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAC7B,iBAAiB,EAAE,gBAAgB,EAAE,EACrC,KAAK,EAAE;QAAE,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,WAAW,CAAC,SAAS,CAAC,CAyBtI;IAED,MAAM,CAAC,YAAY,CAAC,SAAS,KAAK,WAAW,CAAC,SAAS,CAAC,CAiBvD;IAED,MAAM,CAAC,SAAS,EAAE,WAAW,CAeX;IAQlB,YAAY,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EA6BpF;IAGD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAGzB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAG5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAG5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAG/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAG1B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAGhC,QAAQ,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAG/C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAGrC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IAQrC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAKxC,IAAI,OAAO,IAAI,OAAO,CAQrB;CACJ"}
@@ -44,7 +44,9 @@ import { deserializeQueryModels, deserializeQueryModel } from './deserializeQuer
44
44
  severity: _.severity,
45
45
  message: _.message,
46
46
  members: _.members,
47
- state: _.state
47
+ state: _.state,
48
+ reason: _.reason,
49
+ reasonDetail: _.reasonDetail
48
50
  })),
49
51
  exceptionMessages: [],
50
52
  exceptionStackTrace: '',
@@ -100,7 +102,7 @@ import { deserializeQueryModels, deserializeQueryModel } from './deserializeQuer
100
102
  this.isAuthorized = result.isAuthorized;
101
103
  this.isValid = result.isValid;
102
104
  this.hasExceptions = result.hasExceptions;
103
- this.validationResults = result.validationResults.map((_)=>new ValidationResult(_.severity, _.message, _.members, _.state, _.reason));
105
+ this.validationResults = result.validationResults.map((_)=>new ValidationResult(_.severity, _.message, _.members, _.state, _.reason, _.reasonDetail));
104
106
  this.exceptionMessages = result.exceptionMessages;
105
107
  this.exceptionStackTrace = result.exceptionStackTrace;
106
108
  this.paging = new PagingInfo();