@cratis/arc 20.4.1 → 20.5.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 (75) hide show
  1. package/dist/cjs/queries/QueryResult.js +1 -1
  2. package/dist/cjs/queries/QueryResult.js.map +1 -1
  3. package/dist/cjs/queries/QueryResultWithState.js +3 -3
  4. package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
  5. package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts +2 -0
  6. package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts.map +1 -0
  7. package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts +2 -0
  8. package/dist/cjs/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts.map +1 -0
  9. package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts +2 -0
  10. package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts.map +1 -0
  11. package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts +2 -0
  12. package/dist/cjs/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts.map +1 -0
  13. package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts +2 -0
  14. package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts.map +1 -0
  15. package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts +2 -0
  16. package/dist/cjs/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts.map +1 -0
  17. package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts +2 -0
  18. package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts.map +1 -0
  19. package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts +2 -0
  20. package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts.map +1 -0
  21. package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts +2 -0
  22. package/dist/cjs/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts.map +1 -0
  23. package/dist/esm/queries/QueryResult.js +1 -1
  24. package/dist/esm/queries/QueryResult.js.map +1 -1
  25. package/dist/esm/queries/QueryResultWithState.js +3 -3
  26. package/dist/esm/queries/QueryResultWithState.js.map +1 -1
  27. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts +2 -0
  28. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.d.ts.map +1 -0
  29. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.js +23 -0
  30. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.js.map +1 -0
  31. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts +2 -0
  32. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.d.ts.map +1 -0
  33. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.js +23 -0
  34. package/dist/esm/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.js.map +1 -0
  35. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts +2 -0
  36. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.d.ts.map +1 -0
  37. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.js +9 -0
  38. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.js.map +1 -0
  39. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts +2 -0
  40. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.d.ts.map +1 -0
  41. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.js +9 -0
  42. package/dist/esm/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.js.map +1 -0
  43. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts +2 -0
  44. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.d.ts.map +1 -0
  45. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.js +25 -0
  46. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.js.map +1 -0
  47. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts +2 -0
  48. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.d.ts.map +1 -0
  49. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.js +25 -0
  50. package/dist/esm/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.js.map +1 -0
  51. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts +2 -0
  52. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.d.ts.map +1 -0
  53. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.js +9 -0
  54. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.js.map +1 -0
  55. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts +2 -0
  56. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.d.ts.map +1 -0
  57. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.js +9 -0
  58. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.js.map +1 -0
  59. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts +2 -0
  60. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.d.ts.map +1 -0
  61. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.js +9 -0
  62. package/dist/esm/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.js.map +1 -0
  63. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +1 -1
  65. package/queries/QueryResult.ts +1 -1
  66. package/queries/QueryResultWithState.ts +3 -3
  67. package/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.ts +29 -0
  68. package/queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.ts +29 -0
  69. package/queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.ts +13 -0
  70. package/queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.ts +13 -0
  71. package/queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.ts +30 -0
  72. package/queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.ts +30 -0
  73. package/queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.ts +13 -0
  74. package/queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.ts +13 -0
  75. package/queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.ts +13 -0
@@ -86,7 +86,7 @@ class QueryResult {
86
86
  this.data = data;
87
87
  }
88
88
  else {
89
- this.data = null;
89
+ this.data = (enumerable ? [] : {});
90
90
  }
91
91
  }
92
92
  data;
@@ -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, JsonSerializer } from '@cratis/fundamentals';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\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}\n\ntype ServerValidationResult = {\n severity: number;\n message: string;\n members: string[];\n state: object;\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 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));\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 let data: object = result.data;\n if (enumerable) {\n if (Array.isArray(result.data)) {\n data = JsonSerializer.deserializeArrayFromInstance(instanceType, data);\n } else {\n data = [];\n }\n } else {\n data = JsonSerializer.deserializeFromInstance(instanceType, data);\n }\n\n this.data = data as TDataType;\n } else {\n this.data = null as TDataType;\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 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":["ValidationResult","PagingInfo","JsonSerializer"],"mappings":";;;;;;MAwCa,WAAW,CAAA;IAEpB,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI,WAAW,CAAC;AACnB,YAAA,IAAI,EAAE,YAAsB;AAC5B,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,aAAa,EAAE,KAAK;AACpB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA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H,IAAI,GAAG,EAAE;gBACb;YACJ;iBAAO;gBACH,IAAI,GAAGA,2BAAc,CAAC,uBAAuB,CAAC,YAAY,EAAE,IAAI,CAAC;YACrE;AAEA,YAAA,IAAI,CAAC,IAAI,GAAG,IAAiB;QACjC;aAAO;AACH,YAAA,IAAI,CAAC,IAAI,GAAG,IAAiB;QACjC;IACJ;AAGS,IAAA,IAAI;AAGJ,IAAA,MAAM;AAGN,IAAA,SAAS;AAGT,IAAA,YAAY;AAGZ,IAAA,OAAO;AAGP,IAAA,aAAa;AAGb,IAAA,iBAAiB;AAGjB,IAAA,iBAAiB;AAGjB,IAAA,mBAAmB;AAK5B,IAAA,IAAI,OAAO,GAAA;AACP,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC1B,gBAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAC/B;AACA,YAAA,OAAO,IAAI;QACf;AACA,QAAA,OAAO,KAAK;IAChB;;;;;"}
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, JsonSerializer } from '@cratis/fundamentals';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\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}\n\ntype ServerValidationResult = {\n severity: number;\n message: string;\n members: string[];\n state: object;\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 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));\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 let data: object = result.data;\n if (enumerable) {\n if (Array.isArray(result.data)) {\n data = JsonSerializer.deserializeArrayFromInstance(instanceType, data);\n } else {\n data = [];\n }\n } else {\n data = JsonSerializer.deserializeFromInstance(instanceType, data);\n }\n\n this.data = data as TDataType;\n } else {\n this.data = (enumerable ? [] : {}) as TDataType;\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 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":["ValidationResult","PagingInfo","JsonSerializer"],"mappings":";;;;;;MAwCa,WAAW,CAAA;IAEpB,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI,WAAW,CAAC;AACnB,YAAA,IAAI,EAAE,YAAsB;AAC5B,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,aAAa,EAAE,KAAK;AACpB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA,mBAAmB,EAAE,EAAE;AACvB,YAAA,MAAM,EAAE;AACJ,gBAAA,UAAU,EAAE,CAAC;AACb,gBAAA,UAAU,EAAE,CAAC;AACb,gBAAA,IAAI,EAAE,CAAC;AACP,gBAAA,IAAI,EAAE;AACT;AAEJ,SAAA,EAAE,MAAM,EAAE,KAAK,CAAC;IACrB;AAEA,I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AAGS,IAAA,IAAI;AAGJ,IAAA,MAAM;AAGN,IAAA,SAAS;AAGT,IAAA,YAAY;AAGZ,IAAA,OAAO;AAGP,IAAA,aAAa;AAGb,IAAA,iBAAiB;AAGjB,IAAA,iBAAiB;AAGjB,IAAA,mBAAmB;AAK5B,IAAA,IAAI,OAAO,GAAA;AACP,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC1B,gBAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAC/B;AACA,YAAA,OAAO,IAAI;QACf;AACA,QAAA,OAAO,KAAK;IAChB;;;;;"}
@@ -14,10 +14,10 @@ class QueryResultWithState {
14
14
  exceptionStackTrace;
15
15
  isPerforming;
16
16
  static empty(defaultValue) {
17
- return new QueryResultWithState(defaultValue, PagingInfo.PagingInfo.noPaging, true, true, true, [], false, [], '', false);
17
+ return new QueryResultWithState(defaultValue ?? [], PagingInfo.PagingInfo.noPaging, true, true, true, [], false, [], '', false);
18
18
  }
19
19
  static initial(defaultValue) {
20
- return new QueryResultWithState(defaultValue, PagingInfo.PagingInfo.noPaging, true, true, true, [], false, [], '', true);
20
+ return new QueryResultWithState(defaultValue ?? [], PagingInfo.PagingInfo.noPaging, true, true, true, [], false, [], '', true);
21
21
  }
22
22
  constructor(data, paging, isSuccess, isAuthorized, isValid, validationResults, hasExceptions, exceptionMessages, exceptionStackTrace, isPerforming) {
23
23
  this.data = data;
@@ -38,7 +38,7 @@ class QueryResultWithState {
38
38
  return !!this.data;
39
39
  }
40
40
  static fromQueryResult(queryResult, isPerforming) {
41
- return new QueryResultWithState(queryResult.data, queryResult.paging, queryResult.isSuccess, queryResult.isAuthorized, queryResult.isValid, queryResult.validationResults, queryResult.hasExceptions, queryResult.exceptionMessages, queryResult.exceptionStackTrace, isPerforming);
41
+ return new QueryResultWithState(queryResult.data ?? [], queryResult.paging, queryResult.isSuccess, queryResult.isAuthorized, queryResult.isValid, queryResult.validationResults, queryResult.hasExceptions, queryResult.exceptionMessages, queryResult.exceptionStackTrace, isPerforming);
42
42
  }
43
43
  }
44
44
 
@@ -1 +1 @@
1
- {"version":3,"file":"QueryResultWithState.js","sources":["../../../queries/QueryResultWithState.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 { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\nimport { QueryResult } from './QueryResult';\n\n/**\n * Represents a specialized {@link QueryResult<TDataType>} that holds state for its execution\n */\nexport class QueryResultWithState<TDataType> implements IQueryResult<TDataType> {\n\n static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n false);\n }\n\n static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n true);\n }\n\n /**\n * Initializes an instance of {@link QueryResultWithState<TDataType>}.\n * @param {TDataType} data The items returned, if any - can be empty.\n * @param {PagingInfo} paging The paging info.\n * @param {boolean} isSuccess Whether or not the query was successful.\n * @param {boolean} isAuthorized Whether or not the query was authorized.\n * @param {boolean} isValid Whether or not it is valid.\n * @param {ValidationResult[]} validationResults Any validation errors.\n * @param {boolean} hasExceptions Whether or not it has exceptions.\n * @param {string[]} exceptionMessages Any exception messages.\n * @param {string} exceptionStackTrace Exception stack trace, if any.\n * @param {boolean} isPerforming Whether or not the query is being performed. True if its performing, false if it is done.\n */\n constructor(\n readonly data: TDataType,\n readonly paging: PagingInfo,\n readonly isSuccess: boolean,\n readonly isAuthorized: boolean,\n readonly isValid: boolean,\n readonly validationResults: ValidationResult[],\n readonly hasExceptions: boolean,\n readonly exceptionMessages: string[],\n readonly exceptionStackTrace: string,\n readonly isPerforming: boolean) {\n }\n\n /** @inheritdoc */\n get hasData(): boolean {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return !!this.data;\n }\n\n /**\n * Create a new {@link QueryResultWithState<TDataType>} from {@link QueryResult<TDataType>}.\n * @param queryResult The original query result.\n * @param isPerforming Whether or not the query is performing.\n * @returns A new {@link QueryResultWithState<TDataType>}\n */\n static fromQueryResult<TDataType>(queryResult: QueryResult<TDataType>, isPerforming: boolean) {\n return new QueryResultWithState<TDataType>(\n queryResult.data,\n queryResult.paging,\n queryResult.isSuccess,\n queryResult.isAuthorized,\n queryResult.isValid,\n queryResult.validationResults,\n queryResult.hasExceptions,\n queryResult.exceptionMessages,\n queryResult.exceptionStackTrace,\n isPerforming);\n }\n}\n"],"names":["PagingInfo"],"mappings":";;;;MAWa,oBAAoB,CAAA;AA4ChB,IAAA,IAAA;AACA,IAAA,MAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,iBAAA;AACA,IAAA,aAAA;AACA,IAAA,iBAAA;AACA,IAAA,mBAAA;AACA,IAAA,YAAA;IAnDb,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI,oBAAoB,CAC3B,YAAY,EACZA,qBAAU,CAAC,QAAQ,EACnB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,EAAE,EACF,EAAE,EACF,KAAK,CAAC;IACd;IAEA,OAAO,OAAO,CAAY,YAAuB,EAAA;QAC7C,OAAO,IAAI,oBAAoB,CAC3B,YAAY,EACZA,qBAAU,CAAC,QAAQ,EACnB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,EAAE,EACF,EAAE,EACF,IAAI,CAAC;IACb;AAeA,IAAA,WAAA,CACa,IAAe,EACf,MAAkB,EAClB,SAAkB,EAClB,YAAqB,EACrB,OAAgB,EAChB,iBAAqC,EACrC,aAAsB,EACtB,iBAA2B,EAC3B,mBAA2B,EAC3B,YAAqB,EAAA;QATrB,IAAA,CAAA,IAAI,GAAJ,IAAI;QACJ,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,SAAS,GAAT,SAAS;QACT,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,iBAAiB,GAAjB,iBAAiB;QACjB,IAAA,CAAA,aAAa,GAAb,aAAa;QACb,IAAA,CAAA,iBAAiB,GAAjB,iBAAiB;QACjB,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QACnB,IAAA,CAAA,YAAY,GAAZ,YAAY;IACzB;AAGA,IAAA,IAAI,OAAO,GAAA;QACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC1B,YAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QAC/B;AACA,QAAA,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI;IACtB;AAQA,IAAA,OAAO,eAAe,CAAY,WAAmC,EAAE,YAAqB,EAAA;AACxF,QAAA,OAAO,IAAI,oBAAoB,CAC3B,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,SAAS,EACrB,WAAW,CAAC,YAAY,EACxB,WAAW,CAAC,OAAO,EACnB,WAAW,CAAC,iBAAiB,EAC7B,WAAW,CAAC,aAAa,EACzB,WAAW,CAAC,iBAAiB,EAC7B,WAAW,CAAC,mBAAmB,EAC/B,YAAY,CAAC;IACrB;AACH;;;;"}
1
+ {"version":3,"file":"QueryResultWithState.js","sources":["../../../queries/QueryResultWithState.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 { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\nimport { QueryResult } from './QueryResult';\n\n/**\n * Represents a specialized {@link QueryResult<TDataType>} that holds state for its execution\n */\nexport class QueryResultWithState<TDataType> implements IQueryResult<TDataType> {\n\n static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue ?? ([] as unknown as TDataType),\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n false);\n }\n\n static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue ?? ([] as unknown as TDataType),\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n true);\n }\n\n /**\n * Initializes an instance of {@link QueryResultWithState<TDataType>}.\n * @param {TDataType} data The items returned, if any - can be empty.\n * @param {PagingInfo} paging The paging info.\n * @param {boolean} isSuccess Whether or not the query was successful.\n * @param {boolean} isAuthorized Whether or not the query was authorized.\n * @param {boolean} isValid Whether or not it is valid.\n * @param {ValidationResult[]} validationResults Any validation errors.\n * @param {boolean} hasExceptions Whether or not it has exceptions.\n * @param {string[]} exceptionMessages Any exception messages.\n * @param {string} exceptionStackTrace Exception stack trace, if any.\n * @param {boolean} isPerforming Whether or not the query is being performed. True if its performing, false if it is done.\n */\n constructor(\n readonly data: TDataType,\n readonly paging: PagingInfo,\n readonly isSuccess: boolean,\n readonly isAuthorized: boolean,\n readonly isValid: boolean,\n readonly validationResults: ValidationResult[],\n readonly hasExceptions: boolean,\n readonly exceptionMessages: string[],\n readonly exceptionStackTrace: string,\n readonly isPerforming: boolean) {\n }\n\n /** @inheritdoc */\n get hasData(): boolean {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return !!this.data;\n }\n\n /**\n * Create a new {@link QueryResultWithState<TDataType>} from {@link QueryResult<TDataType>}.\n * @param queryResult The original query result.\n * @param isPerforming Whether or not the query is performing.\n * @returns A new {@link QueryResultWithState<TDataType>}\n */\n static fromQueryResult<TDataType>(queryResult: QueryResult<TDataType>, isPerforming: boolean) {\n return new QueryResultWithState<TDataType>(\n queryResult.data ?? ([] as unknown as TDataType),\n queryResult.paging,\n queryResult.isSuccess,\n queryResult.isAuthorized,\n queryResult.isValid,\n queryResult.validationResults,\n queryResult.hasExceptions,\n queryResult.exceptionMessages,\n queryResult.exceptionStackTrace,\n isPerforming);\n }\n}\n"],"names":["PagingInfo"],"mappings":";;;;MAWa,oBAAoB,CAAA;AA4ChB,IAAA,IAAA;AACA,IAAA,MAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,iBAAA;AACA,IAAA,aAAA;AACA,IAAA,iBAAA;AACA,IAAA,mBAAA;AACA,IAAA,YAAA;IAnDb,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI,oBAAoB,CAC3B,YAAY,IAAK,EAA2B,EAC5CA,qBAAU,CAAC,QAAQ,EACnB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,EAAE,EACF,EAAE,EACF,KAAK,CAAC;IACd;IAEA,OAAO,OAAO,CAAY,YAAuB,EAAA;QAC7C,OAAO,IAAI,oBAAoB,CAC3B,YAAY,IAAK,EAA2B,EAC5CA,qBAAU,CAAC,QAAQ,EACnB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,EAAE,EACF,EAAE,EACF,IAAI,CAAC;IACb;AAeA,IAAA,WAAA,CACa,IAAe,EACf,MAAkB,EAClB,SAAkB,EAClB,YAAqB,EACrB,OAAgB,EAChB,iBAAqC,EACrC,aAAsB,EACtB,iBAA2B,EAC3B,mBAA2B,EAC3B,YAAqB,EAAA;QATrB,IAAA,CAAA,IAAI,GAAJ,IAAI;QACJ,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,SAAS,GAAT,SAAS;QACT,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,iBAAiB,GAAjB,iBAAiB;QACjB,IAAA,CAAA,aAAa,GAAb,aAAa;QACb,IAAA,CAAA,iBAAiB,GAAjB,iBAAiB;QACjB,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QACnB,IAAA,CAAA,YAAY,GAAZ,YAAY;IACzB;AAGA,IAAA,IAAI,OAAO,GAAA;QACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC1B,YAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QAC/B;AACA,QAAA,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI;IACtB;AAQA,IAAA,OAAO,eAAe,CAAY,WAAmC,EAAE,YAAqB,EAAA;AACxF,QAAA,OAAO,IAAI,oBAAoB,CAC3B,WAAW,CAAC,IAAI,IAAK,EAA2B,EAChD,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,SAAS,EACrB,WAAW,CAAC,YAAY,EACxB,WAAW,CAAC,OAAO,EACnB,WAAW,CAAC,iBAAiB,EAC7B,WAAW,CAAC,aAAa,EACzB,WAAW,CAAC,iBAAiB,EAC7B,WAAW,CAAC,mBAAmB,EAC/B,YAAY,CAAC;IACrB;AACH;;;;"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=and_it_is_null_for_enumerable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_it_is_null_for_enumerable.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=and_it_is_null_for_non_enumerable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_it_is_null_for_non_enumerable.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_null_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_undefined_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_null_data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_data.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_undefined_data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_data.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_null_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_undefined_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_valid_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_valid_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.ts"],"names":[],"mappings":""}
@@ -84,7 +84,7 @@ class QueryResult {
84
84
  this.data = data;
85
85
  }
86
86
  else {
87
- this.data = null;
87
+ this.data = (enumerable ? [] : {});
88
88
  }
89
89
  }
90
90
  data;
@@ -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, JsonSerializer } from '@cratis/fundamentals';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\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}\n\ntype ServerValidationResult = {\n severity: number;\n message: string;\n members: string[];\n state: object;\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 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));\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 let data: object = result.data;\n if (enumerable) {\n if (Array.isArray(result.data)) {\n data = JsonSerializer.deserializeArrayFromInstance(instanceType, data);\n } else {\n data = [];\n }\n } else {\n data = JsonSerializer.deserializeFromInstance(instanceType, data);\n }\n\n this.data = data as TDataType;\n } else {\n this.data = null as TDataType;\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 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":[],"mappings":";;;;MAwCa,WAAW,CAAA;IAEpB,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI,WAAW,CAAC;AACnB,YAAA,IAAI,EAAE,YAAsB;AAC5B,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,aAAa,EAAE,KAAK;AACpB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA,mBAAmB,EAAE,EAAE;AACvB,YAAA,MAAM,EAAE;AACJ,gBAAA,UAAU,EAAE,CAAC;AACb,gBAAA,UAAU,EAAE,CAAC;AACb,gBAAA,IAAI,EAAE,CAAC;AACP,gBAAA,IAAI,EAAE;AACT;AAEJ,SAAA,EAAE,MAAM,EAAE,KAAK,CAAC;IACrB;AAEA,IAAA,OAAO,YAAY,GAAA;QACf,OAAO,IAAI,WAAW,CAAC;AACnB,YAAA,IAAI,EAAE,IAAyB;AAC/B,YAAA,SAAS,EAAE,KAAK;AAChB,YAAA,YAAY,EAAE,KAAK;AACnB,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,aAAa,EAAE,KAAK;AACpB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA,iBAAiB,EAAE,EAAE;AACrB,YAAA,mBAAmB,EAAE,EAAE;AACvB,YAAA,MAAM,EAAE;AACJ,gBAAA,UAAU,EAAE,CAAC;AACb,gBAAA,UAAU,EAAE,CAAC;AACb,gBAAA,IAAI,EAAE,CAAC;AACP,gBAAA,IAAI,EAAE;AACT;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ries/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, JsonSerializer } from '@cratis/fundamentals';\nimport { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\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}\n\ntype ServerValidationResult = {\n severity: number;\n message: string;\n members: string[];\n state: object;\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 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));\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 let data: object = result.data;\n if (enumerable) {\n if (Array.isArray(result.data)) {\n data = JsonSerializer.deserializeArrayFromInstance(instanceType, data);\n } else {\n data = [];\n }\n } else {\n data = JsonSerializer.deserializeFromInstance(instanceType, data);\n }\n\n this.data = data as TDataType;\n } else {\n this.data = (enumerable ? [] : {}) as TDataType;\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 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":[],"mappings":";;;;MAwCa,WAAW,CAAA;IAEpB,OAAO,KAAK,CAAY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AE;AACb,YAAA,IAAI,IAAI,GAAW,MAAM,CAAC,IAAI;YAC9B,IAAI,UAAU,EAAE;gBACZ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC5B,IAAI,GAAG,cAAc,CAAC,4BAA4B,CAAC,YAAY,EAAE,IAAI,CAAC;gBAC1E;qBAAO;oBACH,IAAI,GAAG,EAAE;gBACb;YACJ;iBAAO;gBACH,IAAI,GAAG,cAAc,CAAC,uBAAuB,CAAC,YAAY,EAAE,IAAI,CAAC;YACrE;AAEA,YAAA,IAAI,CAAC,IAAI,GAAG,IAAiB;QACjC;aAAO;AACH,YAAA,IAAI,CAAC,IAAI,IAAI,UAAU,GAAG,EAAE,GAAG,EAAE,CAAc;QACnD;IACJ;AAGS,IAAA,IAAI;AAGJ,IAAA,MAAM;AAGN,IAAA,SAAS;AAGT,IAAA,YAAY;AAGZ,IAAA,OAAO;AAGP,IAAA,aAAa;AAGb,IAAA,iBAAiB;AAGjB,IAAA,iBAAiB;AAGjB,IAAA,mBAAmB;AAK5B,IAAA,IAAI,OAAO,GAAA;AACP,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC1B,gBAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAC/B;AACA,YAAA,OAAO,IAAI;QACf;AACA,QAAA,OAAO,KAAK;IAChB;;;;;"}
@@ -12,10 +12,10 @@ class QueryResultWithState {
12
12
  exceptionStackTrace;
13
13
  isPerforming;
14
14
  static empty(defaultValue) {
15
- return new QueryResultWithState(defaultValue, PagingInfo.noPaging, true, true, true, [], false, [], '', false);
15
+ return new QueryResultWithState(defaultValue ?? [], PagingInfo.noPaging, true, true, true, [], false, [], '', false);
16
16
  }
17
17
  static initial(defaultValue) {
18
- return new QueryResultWithState(defaultValue, PagingInfo.noPaging, true, true, true, [], false, [], '', true);
18
+ return new QueryResultWithState(defaultValue ?? [], PagingInfo.noPaging, true, true, true, [], false, [], '', true);
19
19
  }
20
20
  constructor(data, paging, isSuccess, isAuthorized, isValid, validationResults, hasExceptions, exceptionMessages, exceptionStackTrace, isPerforming) {
21
21
  this.data = data;
@@ -36,7 +36,7 @@ class QueryResultWithState {
36
36
  return !!this.data;
37
37
  }
38
38
  static fromQueryResult(queryResult, isPerforming) {
39
- return new QueryResultWithState(queryResult.data, queryResult.paging, queryResult.isSuccess, queryResult.isAuthorized, queryResult.isValid, queryResult.validationResults, queryResult.hasExceptions, queryResult.exceptionMessages, queryResult.exceptionStackTrace, isPerforming);
39
+ return new QueryResultWithState(queryResult.data ?? [], queryResult.paging, queryResult.isSuccess, queryResult.isAuthorized, queryResult.isValid, queryResult.validationResults, queryResult.hasExceptions, queryResult.exceptionMessages, queryResult.exceptionStackTrace, isPerforming);
40
40
  }
41
41
  }
42
42
 
@@ -1 +1 @@
1
- {"version":3,"file":"QueryResultWithState.js","sources":["../../../queries/QueryResultWithState.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 { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\nimport { QueryResult } from './QueryResult';\n\n/**\n * Represents a specialized {@link QueryResult<TDataType>} that holds state for its execution\n */\nexport class QueryResultWithState<TDataType> implements IQueryResult<TDataType> {\n\n static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n false);\n }\n\n static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue,\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n true);\n }\n\n /**\n * Initializes an instance of {@link QueryResultWithState<TDataType>}.\n * @param {TDataType} data The items returned, if any - can be empty.\n * @param {PagingInfo} paging The paging info.\n * @param {boolean} isSuccess Whether or not the query was successful.\n * @param {boolean} isAuthorized Whether or not the query was authorized.\n * @param {boolean} isValid Whether or not it is valid.\n * @param {ValidationResult[]} validationResults Any validation errors.\n * @param {boolean} hasExceptions Whether or not it has exceptions.\n * @param {string[]} exceptionMessages Any exception messages.\n * @param {string} exceptionStackTrace Exception stack trace, if any.\n * @param {boolean} isPerforming Whether or not the query is being performed. True if its performing, false if it is done.\n */\n constructor(\n readonly data: TDataType,\n readonly paging: PagingInfo,\n readonly isSuccess: boolean,\n readonly isAuthorized: boolean,\n readonly isValid: boolean,\n readonly validationResults: ValidationResult[],\n readonly hasExceptions: boolean,\n readonly exceptionMessages: string[],\n readonly exceptionStackTrace: string,\n readonly isPerforming: boolean) {\n }\n\n /** @inheritdoc */\n get hasData(): boolean {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return !!this.data;\n }\n\n /**\n * Create a new {@link QueryResultWithState<TDataType>} from {@link QueryResult<TDataType>}.\n * @param queryResult The original query result.\n * @param isPerforming Whether or not the query is performing.\n * @returns A new {@link QueryResultWithState<TDataType>}\n */\n static fromQueryResult<TDataType>(queryResult: QueryResult<TDataType>, isPerforming: boolean) {\n return new QueryResultWithState<TDataType>(\n queryResult.data,\n queryResult.paging,\n queryResult.isSuccess,\n queryResult.isAuthorized,\n queryResult.isValid,\n queryResult.validationResults,\n queryResult.hasExceptions,\n queryResult.exceptionMessages,\n queryResult.exceptionStackTrace,\n isPerforming);\n }\n}\n"],"names":[],"mappings":";;MAWa,oBAAoB,CAAA;AA4ChB,IAAA,IAAA;AACA,IAAA,MAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,iBAAA;AACA,IAAA,aAAA;AACA,IAAA,iBAAA;AACA,IAAA,mBAAA;AACA,IAAA,YAAA;IAnDb,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI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ChB,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,SAAS,EACrB,WAAW,CAAC,YAAY,EACxB,WAAW,CAAC,OAAO,EACnB,WAAW,CAAC,iBAAiB,EAC7B,WAAW,CAAC,aAAa,EACzB,WAAW,CAAC,iBAAiB,EAC7B,WAAW,CAAC,mBAAmB,EAC/B,YAAY,CAAC;IACrB;AACH;;;;"}
1
+ {"version":3,"file":"QueryResultWithState.js","sources":["../../../queries/QueryResultWithState.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 { ValidationResult } from '../validation/ValidationResult';\nimport { IQueryResult } from './IQueryResult';\nimport { PagingInfo } from './PagingInfo';\nimport { QueryResult } from './QueryResult';\n\n/**\n * Represents a specialized {@link QueryResult<TDataType>} that holds state for its execution\n */\nexport class QueryResultWithState<TDataType> implements IQueryResult<TDataType> {\n\n static empty<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue ?? ([] as unknown as TDataType),\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n false);\n }\n\n static initial<TDataType>(defaultValue: TDataType): QueryResultWithState<TDataType> {\n return new QueryResultWithState(\n defaultValue ?? ([] as unknown as TDataType),\n PagingInfo.noPaging,\n true,\n true,\n true,\n [],\n false,\n [],\n '',\n true);\n }\n\n /**\n * Initializes an instance of {@link QueryResultWithState<TDataType>}.\n * @param {TDataType} data The items returned, if any - can be empty.\n * @param {PagingInfo} paging The paging info.\n * @param {boolean} isSuccess Whether or not the query was successful.\n * @param {boolean} isAuthorized Whether or not the query was authorized.\n * @param {boolean} isValid Whether or not it is valid.\n * @param {ValidationResult[]} validationResults Any validation errors.\n * @param {boolean} hasExceptions Whether or not it has exceptions.\n * @param {string[]} exceptionMessages Any exception messages.\n * @param {string} exceptionStackTrace Exception stack trace, if any.\n * @param {boolean} isPerforming Whether or not the query is being performed. True if its performing, false if it is done.\n */\n constructor(\n readonly data: TDataType,\n readonly paging: PagingInfo,\n readonly isSuccess: boolean,\n readonly isAuthorized: boolean,\n readonly isValid: boolean,\n readonly validationResults: ValidationResult[],\n readonly hasExceptions: boolean,\n readonly exceptionMessages: string[],\n readonly exceptionStackTrace: string,\n readonly isPerforming: boolean) {\n }\n\n /** @inheritdoc */\n get hasData(): boolean {\n if (Array.isArray(this.data)) {\n return this.data.length > 0;\n }\n return !!this.data;\n }\n\n /**\n * Create a new {@link QueryResultWithState<TDataType>} from {@link QueryResult<TDataType>}.\n * @param queryResult The original query result.\n * @param isPerforming Whether or not the query is performing.\n * @returns A new {@link QueryResultWithState<TDataType>}\n */\n static fromQueryResult<TDataType>(queryResult: QueryResult<TDataType>, isPerforming: boolean) {\n return new QueryResultWithState<TDataType>(\n queryResult.data ?? ([] as unknown as TDataType),\n queryResult.paging,\n queryResult.isSuccess,\n queryResult.isAuthorized,\n queryResult.isValid,\n queryResult.validationResults,\n queryResult.hasExceptions,\n queryResult.exceptionMessages,\n queryResult.exceptionStackTrace,\n isPerforming);\n }\n}\n"],"names":[],"mappings":";;MAWa,oBAAoB,CAAA;AA4ChB,IAAA,IAAA;AACA,IAAA,MAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,iBAAA;AACA,IAAA,aAAA;AACA,IAAA,iBAAA;AACA,IAAA,mBAAA;AACA,IAAA,YAAA;IAnDb,OAAO,KAAK,CAAY,YAAuB,EAAA;QAC3C,OAAO,IAAI,oBAAoB,CAC3B,YAAY,IAAK,EAA2B,EAC5C,UAAU,CAAC,QAAQ,EACnB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,EAAE,EACF,EAAE,EACF,KAAK,CAAC;IACd;IAEA,OAAO,OAAO,CAAY,YAAuB,EAAA;QAC7C,OAAO,IAAI,oBAAoB,CAC3B,YAAY,IAAK,EAA2B,EAC5C,UAAU,CAAC,QAAQ,EACnB,IAAI,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@@
1
+ export {};
2
+ //# sourceMappingURL=and_it_is_null_for_enumerable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_it_is_null_for_enumerable.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import { QueryResult } from '../../QueryResult';
2
+ describe('when asking has data and it is null for enumerable query', () => {
3
+ const queryResult = new QueryResult({
4
+ isSuccess: true,
5
+ isAuthorized: true,
6
+ isValid: true,
7
+ hasExceptions: false,
8
+ exceptionMessages: [],
9
+ exceptionStackTrace: '',
10
+ paging: {
11
+ totalItems: 0,
12
+ totalPages: 0,
13
+ page: 0,
14
+ size: 0
15
+ },
16
+ validationResults: [],
17
+ data: null
18
+ }, Object, true);
19
+ it('should consider it to not have data', () => queryResult.hasData.should.be.false);
20
+ it('should have data that is not null', () => (queryResult.data !== null).should.be.true);
21
+ it('should have data that is an empty array', () => queryResult.data.should.deep.equal([]));
22
+ });
23
+ //# sourceMappingURL=and_it_is_null_for_enumerable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_it_is_null_for_enumerable.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_enumerable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,QAAQ,CAAC,0DAA0D,EAAE,GAAG,EAAE;IACtE,MAAM,WAAW,GAAG,IAAI,WAAW,CAAM;QACrC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,MAAM,EAAE;YACJ,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;SACV;QACD,iBAAiB,EAAE,EAAE;QACrB,IAAI,EAAE,IAAI;KACb,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEjB,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACrF,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1F,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAChG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=and_it_is_null_for_non_enumerable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_it_is_null_for_non_enumerable.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import { QueryResult } from '../../QueryResult';
2
+ describe('when asking has data and it is null for non-enumerable query', () => {
3
+ const queryResult = new QueryResult({
4
+ isSuccess: true,
5
+ isAuthorized: true,
6
+ isValid: true,
7
+ hasExceptions: false,
8
+ exceptionMessages: [],
9
+ exceptionStackTrace: '',
10
+ paging: {
11
+ totalItems: 0,
12
+ totalPages: 0,
13
+ page: 0,
14
+ size: 0
15
+ },
16
+ validationResults: [],
17
+ data: null
18
+ }, Object, false);
19
+ it('should consider to have data since empty object is truthy', () => queryResult.hasData.should.be.true);
20
+ it('should have data that is not null', () => (queryResult.data !== null).should.be.true);
21
+ it('should have data that is an empty object', () => queryResult.data.should.deep.equal({}));
22
+ });
23
+ //# sourceMappingURL=and_it_is_null_for_non_enumerable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_it_is_null_for_non_enumerable.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResult/when_asking_has_data/and_it_is_null_for_non_enumerable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,QAAQ,CAAC,8DAA8D,EAAE,GAAG,EAAE;IAC1E,MAAM,WAAW,GAAG,IAAI,WAAW,CAAM;QACrC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,MAAM,EAAE;YACJ,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;SACV;QACD,iBAAiB,EAAE,EAAE;QACrB,IAAI,EAAE,IAAI;KACb,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAElB,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1G,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1F,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_null_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { QueryResultWithState } from '../../QueryResultWithState';
2
+ describe('when creating empty with null default value', () => {
3
+ const result = QueryResultWithState.empty(null);
4
+ it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
5
+ it('should have data that is not null', () => (result.data !== null).should.be.true);
6
+ it('should not have data', () => result.hasData.should.be.false);
7
+ it('should not be performing', () => result.isPerforming.should.be.false);
8
+ });
9
+ //# sourceMappingURL=with_null_default_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_default_value.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_empty/with_null_default_value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;IACzD,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAW,IAA2B,CAAC,CAAC;IAEjF,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/F,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACrF,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACjE,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_undefined_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { QueryResultWithState } from '../../QueryResultWithState';
2
+ describe('when creating empty with undefined default value', () => {
3
+ const result = QueryResultWithState.empty(undefined);
4
+ it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
5
+ it('should have data that is not null', () => (result.data !== null).should.be.true);
6
+ it('should not have data', () => result.hasData.should.be.false);
7
+ it('should not be performing', () => result.isPerforming.should.be.false);
8
+ });
9
+ //# sourceMappingURL=with_undefined_default_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_default_value.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_empty/with_undefined_default_value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC9D,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAW,SAAgC,CAAC,CAAC;IAEtF,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/F,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACrF,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACjE,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_null_data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_data.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { QueryResult } from '../../QueryResult';
2
+ import { QueryResultWithState } from '../../QueryResultWithState';
3
+ describe('when creating from query result with null data', () => {
4
+ const queryResult = new QueryResult({
5
+ data: null,
6
+ isSuccess: true,
7
+ isAuthorized: true,
8
+ isValid: true,
9
+ hasExceptions: false,
10
+ validationResults: [],
11
+ exceptionMessages: [],
12
+ exceptionStackTrace: '',
13
+ paging: {
14
+ totalItems: 0,
15
+ totalPages: 0,
16
+ page: 0,
17
+ size: 0
18
+ }
19
+ }, Object, true);
20
+ const result = QueryResultWithState.fromQueryResult(queryResult, false);
21
+ it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
22
+ it('should have data that is not null', () => (result.data !== null).should.be.true);
23
+ it('should not have data', () => result.hasData.should.be.false);
24
+ });
25
+ //# sourceMappingURL=with_null_data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_data.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_from_query_result/with_null_data.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC5D,MAAM,WAAW,GAAG,IAAI,WAAW,CAAS;QACxC,IAAI,EAAE,IAAyB;QAC/B,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,MAAM,EAAE;YACJ,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;SACV;KACJ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEjB,MAAM,MAAM,GAAG,oBAAoB,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAExE,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/F,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACrF,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_undefined_data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_data.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { QueryResult } from '../../QueryResult';
2
+ import { QueryResultWithState } from '../../QueryResultWithState';
3
+ describe('when creating from query result with undefined data', () => {
4
+ const queryResult = new QueryResult({
5
+ data: undefined,
6
+ isSuccess: true,
7
+ isAuthorized: true,
8
+ isValid: true,
9
+ hasExceptions: false,
10
+ validationResults: [],
11
+ exceptionMessages: [],
12
+ exceptionStackTrace: '',
13
+ paging: {
14
+ totalItems: 0,
15
+ totalPages: 0,
16
+ page: 0,
17
+ size: 0
18
+ }
19
+ }, Object, true);
20
+ const result = QueryResultWithState.fromQueryResult(queryResult, false);
21
+ it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
22
+ it('should have data that is not null', () => (result.data !== null).should.be.true);
23
+ it('should not have data', () => result.hasData.should.be.false);
24
+ });
25
+ //# sourceMappingURL=with_undefined_data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_data.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_from_query_result/with_undefined_data.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,qDAAqD,EAAE,GAAG,EAAE;IACjE,MAAM,WAAW,GAAG,IAAI,WAAW,CAAS;QACxC,IAAI,EAAE,SAA8B;QACpC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,MAAM,EAAE;YACJ,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;SACV;KACJ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEjB,MAAM,MAAM,GAAG,oBAAoB,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAExE,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/F,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACrF,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_null_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { QueryResultWithState } from '../../QueryResultWithState';
2
+ describe('when creating initial with null default value', () => {
3
+ const result = QueryResultWithState.initial(null);
4
+ it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
5
+ it('should have data that is not null', () => (result.data !== null).should.be.true);
6
+ it('should not have data', () => result.hasData.should.be.false);
7
+ it('should be performing', () => result.isPerforming.should.be.true);
8
+ });
9
+ //# sourceMappingURL=with_null_default_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_null_default_value.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_null_default_value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,+CAA+C,EAAE,GAAG,EAAE;IAC3D,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAW,IAA2B,CAAC,CAAC;IAEnF,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/F,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACrF,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACjE,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_undefined_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { QueryResultWithState } from '../../QueryResultWithState';
2
+ describe('when creating initial with undefined default value', () => {
3
+ const result = QueryResultWithState.initial(undefined);
4
+ it('should have data that is not undefined', () => (result.data !== undefined).should.be.true);
5
+ it('should have data that is not null', () => (result.data !== null).should.be.true);
6
+ it('should not have data', () => result.hasData.should.be.false);
7
+ it('should be performing', () => result.isPerforming.should.be.true);
8
+ });
9
+ //# sourceMappingURL=with_undefined_default_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_undefined_default_value.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_undefined_default_value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAChE,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAW,SAAgC,CAAC,CAAC;IAExF,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/F,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACrF,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACjE,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=with_valid_default_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_valid_default_value.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { QueryResultWithState } from '../../QueryResultWithState';
2
+ describe('when creating initial with valid default value', () => {
3
+ const defaultValue = [{ id: '1', name: 'test' }];
4
+ const result = QueryResultWithState.initial(defaultValue);
5
+ it('should use the provided default value', () => result.data.should.equal(defaultValue));
6
+ it('should have data', () => result.hasData.should.be.true);
7
+ it('should be performing', () => result.isPerforming.should.be.true);
8
+ });
9
+ //# sourceMappingURL=with_valid_default_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_valid_default_value.js","sourceRoot":"","sources":["../../../../../queries/for_QueryResultWithState/when_creating_initial/with_valid_default_value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC5D,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE1D,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC1F,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5D,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"}