@cratis/arc 22.0.0 → 22.0.2

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 (24) hide show
  1. package/dist/cjs/queries/ObservableQueryFor.js +3 -3
  2. package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
  3. package/dist/esm/queries/ObservableQueryFor.d.ts +6 -6
  4. package/dist/esm/queries/ObservableQueryFor.d.ts.map +1 -1
  5. package/dist/esm/queries/ObservableQueryFor.js +3 -3
  6. package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
  7. package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.d.ts +17 -0
  8. package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.d.ts.map +1 -1
  9. package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.js +34 -0
  10. package/dist/esm/queries/for_ObservableQueryFor/given/TestQueries.js.map +1 -1
  11. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.d.ts +2 -1
  12. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.d.ts.map +1 -1
  13. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.js +3 -1
  14. package/dist/esm/queries/for_ObservableQueryFor/given/an_observable_query_for.js.map +1 -1
  15. package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.d.ts +2 -0
  16. package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.d.ts.map +1 -0
  17. package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.js +52 -0
  18. package/dist/esm/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.js.map +1 -0
  19. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/queries/ObservableQueryFor.ts +10 -10
  22. package/queries/for_ObservableQueryFor/given/TestQueries.ts +30 -1
  23. package/queries/for_ObservableQueryFor/given/an_observable_query_for.ts +3 -0
  24. package/queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.ts +76 -0
@@ -76,9 +76,7 @@ var QueryHttpRequest = require('./QueryHttpRequest.js');
76
76
  // Serve the failure through the connection rather than throwing, so a subscriber sees an invalid result
77
77
  // on its normal callback path instead of the empty result an unestablished connection would emit.
78
78
  this._connection = new NullObservableQueryConnection.NullObservableQueryConnection(this.defaultValue, QueryResult.QueryResult.validationFailed(clientValidationErrors, this));
79
- } else if (!this.validateArguments(args)) {
80
- this._connection = new NullObservableQueryConnection.NullObservableQueryConnection(this.defaultValue);
81
- } else {
79
+ } else if (this.validateArguments(args)) {
82
80
  this._connection = ObservableQueryConnectionFactory.createObservableQueryConnection({
83
81
  route: this.route,
84
82
  queryName: this.queryName ?? this.constructor.name,
@@ -87,6 +85,8 @@ var QueryHttpRequest = require('./QueryHttpRequest.js');
87
85
  microservice: this._microservice,
88
86
  args: args
89
87
  });
88
+ } else {
89
+ this._connection = new NullObservableQueryConnection.NullObservableQueryConnection(this.defaultValue);
90
90
  }
91
91
  // Descriptor-backed instance properties provide defaults; fresh args passed to subscribe()
92
92
  // must take precedence over any stale instance property values. Spread parameterValues
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableQueryFor.js","sources":["../../../queries/ObservableQueryFor.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 { IObservableQueryFor, OnNextResult } from './IObservableQueryFor';\nimport { ObservableQuerySubscription } from './ObservableQuerySubscription';\nimport { ValidateRequestArguments } from './ValidateRequestArguments';\nimport { QueryValidator } from './QueryValidator';\nimport { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { NullObservableQueryConnection } from './NullObservableQueryConnection';\nimport { createObservableQueryConnection } from './ObservableQueryConnectionFactory';\nimport { Constructor } from '@cratis/fundamentals';\nimport { deserializeQueryModel, deserializeQueryModels } from './deserializeQueryModel';\nimport { QueryResult } from './QueryResult';\nimport { Sorting } from './Sorting';\nimport { Paging } from './Paging';\nimport { SortDirection } from './SortDirection';\nimport { Globals } from '../Globals';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { GetHttpHeaders } from '../GetHttpHeaders';\nimport { ParameterDescriptor } from '../reflection/ParameterDescriptor';\nimport { ParametersHelper } from '../reflection/ParametersHelper';\nimport { QueryHttpMethod } from './QueryHttpMethod';\nimport { executeQueryHttpRequest } from './QueryHttpRequest';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents an implementation of {@link IQueryFor}.\n * @template TDataType Type of data returned by the query.\n */\nexport abstract class ObservableQueryFor<TDataType, TParameters = object> implements IObservableQueryFor<TDataType, TParameters> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _connection?: IObservableQueryConnection<TDataType>;\n private _httpHeadersCallback: GetHttpHeaders;\n private _httpMethod?: QueryHttpMethod;\n\n abstract readonly route: string;\n abstract readonly defaultValue: TDataType;\n readonly roles: string[] = [];\n readonly validation?: QueryValidator<any>;\n /** Backend fully-qualified query name used when subscribing via the SSE hub. Overridden in generated proxies. */\n readonly queryName?: string;\n abstract readonly parameterDescriptors: ParameterDescriptor[];\n abstract get requiredRequestParameters(): string[];\n sorting: Sorting;\n paging: Paging;\n\n /**\n * Initializes a new instance of the {@link ObservableQueryFor<,>}} class.\n * @param modelType Type of model, if an enumerable, this is the instance type.\n * @param enumerable Whether or not it is an enumerable.\n */\n constructor(readonly modelType: Constructor, readonly enumerable: boolean) {\n this.sorting = Sorting.none;\n this.paging = Paging.noPaging;\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /**\n * Disposes the query.\n */\n dispose() {\n this._connection?.disconnect();\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n setHttpMethod(method: QueryHttpMethod): void {\n this._httpMethod = method;\n }\n\n /** @inheritdoc */\n subscribe(callback: OnNextResult<QueryResult<TDataType>>, args?: TParameters): ObservableQuerySubscription<TDataType> {\n if (this._connection) {\n this._connection.disconnect();\n }\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n // Serve the failure through the connection rather than throwing, so a subscriber sees an invalid result\n // on its normal callback path instead of the empty result an unestablished connection would emit.\n this._connection = new NullObservableQueryConnection(\n this.defaultValue,\n QueryResult.validationFailed(clientValidationErrors, this));\n } else if (!this.validateArguments(args)) {\n this._connection = new NullObservableQueryConnection(this.defaultValue);\n } else {\n this._connection = createObservableQueryConnection({\n route: this.route,\n queryName: this.queryName ?? this.constructor.name,\n origin: this._origin,\n apiBasePath: this._apiBasePath,\n microservice: this._microservice,\n args: args as object,\n });\n }\n\n // Descriptor-backed instance properties provide defaults; fresh args passed to subscribe()\n // must take precedence over any stale instance property values. Spread parameterValues\n // first so that the caller-supplied args can override them.\n //\n // In direct mode the route arguments are already embedded in the URL path, so only\n // the unused (non-route) parameters are appended as additional query arguments.\n // In multiplexed mode ALL arguments — including route-derived ones — must be included\n // in the subscribe payload so the server can execute the query correctly.\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const { unusedParameters } = UrlHelpers.replaceRouteParameters(this.route, args as object);\n const connectionQueryArguments: any = {\n ...parameterValues,\n ...(Globals.queryDirectMode ? unusedParameters : (args as object) || {}),\n ...this.buildQueryArguments()\n };\n\n const subscriber = new ObservableQuerySubscription(this._connection);\n this._connection.connect(data => {\n const result: any = data;\n try {\n this.deserializeResult(result);\n callback(result);\n } catch (ex) {\n console.log(ex);\n }\n }, connectionQueryArguments);\n return subscriber;\n }\n\n /** @inheritdoc */\n async perform(args?: TParameters): Promise<QueryResult<TDataType>> {\n const noSuccess = { ...QueryResult.noSuccess, ...{ data: this.defaultValue } } as QueryResult<TDataType>;\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n return QueryResult.validationFailed(clientValidationErrors, this);\n }\n\n if (!this.validateArguments(args)) {\n return new Promise<QueryResult<TDataType>>((resolve) => {\n resolve(noSuccess);\n });\n }\n\n // Collect parameter values from parameterDescriptors that are set\n const parameterValues = ParametersHelper.collectParameterValues(this);\n\n const headers = {\n ...(this._httpHeadersCallback?.() || {}),\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n const response = await executeQueryHttpRequest(this._httpMethod, {\n route: this.route,\n apiBasePath: this._apiBasePath,\n origin: this._origin,\n args: (args as object) ?? {},\n parameterValues,\n paging: this.paging,\n sorting: this.sorting,\n headers\n });\n\n try {\n const result = await response.json();\n return new QueryResult(result, this.modelType, this.enumerable);\n } catch {\n return noSuccess;\n }\n }\n\n private validateArguments(args?: TParameters): boolean {\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const combinedArgs = { ...(args as object || {}), ...parameterValues };\n return ValidateRequestArguments(this.constructor.name, this.requiredRequestParameters, combinedArgs as object);\n }\n\n private buildQueryArguments(): any {\n const queryArguments: any = {};\n\n if (this.paging && this.paging.pageSize > 0) {\n queryArguments.pageSize = this.paging.pageSize;\n queryArguments.page = this.paging.page;\n }\n\n if (this.sorting.hasSorting) {\n queryArguments.sortBy = this.sorting.field;\n queryArguments.sortDirection = (this.sorting.direction === SortDirection.descending) ? 'desc' : 'asc';\n }\n\n return queryArguments;\n }\n\n private deserializeResult(result: any): void {\n if (this.enumerable) {\n result.data = deserializeQueryModels(this.modelType, result.data);\n } else if (result.data) {\n result.data = deserializeQueryModel(this.modelType, result.data);\n }\n }\n}\n"],"names":["ObservableQueryFor","_microservice","_apiBasePath","_origin","_connection","_httpHeadersCallback","_httpMethod","roles","validation","queryName","sorting","paging","enumerable","modelType","Sorting","none","Paging","noPaging","Globals","microservice","apiBasePath","origin","dispose","disconnect","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","setHttpMethod","method","subscribe","args","clientValidationErrors","validate","length","NullObservableQueryConnection","defaultValue","QueryResult","validationFailed","validateArguments","createObservableQueryConnection","route","name","parameterValues","ParametersHelper","collectParameterValues","unusedParameters","UrlHelpers","replaceRouteParameters","connectionQueryArguments","queryDirectMode","buildQueryArguments","subscriber","ObservableQuerySubscription","connect","data","result","deserializeResult","ex","console","log","perform","noSuccess","Promise","resolve","headers","microserviceHttpHeader","response","executeQueryHttpRequest","json","combinedArgs","ValidateRequestArguments","requiredRequestParameters","queryArguments","pageSize","page","hasSorting","sortBy","field","sortDirection","direction","SortDirection","descending","deserializeQueryModels","deserializeQueryModel"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAuBA;;;AAKC,IACM,MAAeA,kBAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,WAAAA;IACAC,oBAAAA;IACAC,WAAAA;AAICC,IAAAA,KAAAA,GAAkB,EAAE;IACpBC,UAAAA;sHAET,SAASC;IAGTC,OAAAA;IACAC,MAAAA;AAEA;;;;AAIC,QACD,YAAY,SAA+B,EAAWC,UAAmB,CAAE;aAAtDC,SAAAA,GAAAA,SAAAA;aAAiCD,UAAAA,GAAAA,UAAAA;AAClD,QAAA,IAAI,CAACF,OAAO,GAAGI,eAAAA,CAAQC,IAAI;AAC3B,QAAA,IAAI,CAACJ,MAAM,GAAGK,aAAAA,CAAOC,QAAQ;AAC7B,QAAA,IAAI,CAAChB,aAAa,GAAGiB,eAAAA,CAAQC,YAAY,IAAI,EAAA;AAC7C,QAAA,IAAI,CAACjB,YAAY,GAAGgB,eAAAA,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,cAAAA,CAAeI,MAAM,GAAG,IAAI,CAACpE,OAAO,CAACqE,KAAK;AAC1CL,YAAAA,cAAAA,CAAeM,aAAa,GAAG,IAAK,CAACtE,OAAO,CAACuE,SAAS,KAAKC,2BAAAA,CAAcC,UAAU,GAAI,MAAA,GAAS,KAAA;AACpG,QAAA;QAEA,OAAOT,cAAAA;AACX,IAAA;AAEQhB,IAAAA,iBAAAA,CAAkBD,MAAW,EAAQ;QACzC,IAAI,IAAI,CAAC7C,UAAU,EAAE;YACjB6C,MAAAA,CAAOD,IAAI,GAAG4B,4CAAAA,CAAuB,IAAI,CAACvE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;QACpE,CAAA,MAAO,IAAIC,MAAAA,CAAOD,IAAI,EAAE;YACpBC,MAAAA,CAAOD,IAAI,GAAG6B,2CAAAA,CAAsB,IAAI,CAACxE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;AACnE,QAAA;AACJ,IAAA;AACJ;;;;"}
1
+ {"version":3,"file":"ObservableQueryFor.js","sources":["../../../queries/ObservableQueryFor.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 type { IObservableQueryFor, OnNextResult } from './IObservableQueryFor';\nimport { ObservableQuerySubscription } from './ObservableQuerySubscription';\nimport { ValidateRequestArguments } from './ValidateRequestArguments';\nimport type { QueryValidator } from './QueryValidator';\nimport type { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { NullObservableQueryConnection } from './NullObservableQueryConnection';\nimport { createObservableQueryConnection } from './ObservableQueryConnectionFactory';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { deserializeQueryModel, deserializeQueryModels } from './deserializeQueryModel';\nimport { QueryResult } from './QueryResult';\nimport { Sorting } from './Sorting';\nimport { Paging } from './Paging';\nimport { SortDirection } from './SortDirection';\nimport { Globals } from '../Globals';\nimport { UrlHelpers } from '../UrlHelpers';\nimport type { GetHttpHeaders } from '../GetHttpHeaders';\nimport type { ParameterDescriptor } from '../reflection/ParameterDescriptor';\nimport { ParametersHelper } from '../reflection/ParametersHelper';\nimport type { QueryHttpMethod } from './QueryHttpMethod';\nimport { executeQueryHttpRequest } from './QueryHttpRequest';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents an implementation of {@link IQueryFor}.\n * @template TDataType Type of data returned by the query.\n */\nexport abstract class ObservableQueryFor<TDataType, TParameters = object> implements IObservableQueryFor<TDataType, TParameters> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _connection?: IObservableQueryConnection<TDataType>;\n private _httpHeadersCallback: GetHttpHeaders;\n private _httpMethod?: QueryHttpMethod;\n\n abstract readonly route: string;\n abstract readonly defaultValue: TDataType;\n readonly roles: string[] = [];\n readonly validation?: QueryValidator<any>;\n /** Backend fully-qualified query name used when subscribing via the SSE hub. Overridden in generated proxies. */\n readonly queryName?: string;\n abstract readonly parameterDescriptors: ParameterDescriptor[];\n abstract get requiredRequestParameters(): string[];\n sorting: Sorting;\n paging: Paging;\n\n /**\n * Initializes a new instance of the {@link ObservableQueryFor<,>}} class.\n * @param modelType Type of model, if an enumerable, this is the instance type.\n * @param enumerable Whether or not it is an enumerable.\n */\n constructor(readonly modelType: Constructor, readonly enumerable: boolean) {\n this.sorting = Sorting.none;\n this.paging = Paging.noPaging;\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /**\n * Disposes the query.\n */\n dispose() {\n this._connection?.disconnect();\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n setHttpMethod(method: QueryHttpMethod): void {\n this._httpMethod = method;\n }\n\n /** @inheritdoc */\n subscribe(callback: OnNextResult<QueryResult<TDataType>>, args?: TParameters): ObservableQuerySubscription<TDataType> {\n if (this._connection) {\n this._connection.disconnect();\n }\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n // Serve the failure through the connection rather than throwing, so a subscriber sees an invalid result\n // on its normal callback path instead of the empty result an unestablished connection would emit.\n this._connection = new NullObservableQueryConnection(\n this.defaultValue,\n QueryResult.validationFailed(clientValidationErrors, this));\n } else if (this.validateArguments(args)) {\n this._connection = createObservableQueryConnection({\n route: this.route,\n queryName: this.queryName ?? this.constructor.name,\n origin: this._origin,\n apiBasePath: this._apiBasePath,\n microservice: this._microservice,\n args: args as object,\n });\n } else {\n this._connection = new NullObservableQueryConnection(this.defaultValue);\n }\n\n // Descriptor-backed instance properties provide defaults; fresh args passed to subscribe()\n // must take precedence over any stale instance property values. Spread parameterValues\n // first so that the caller-supplied args can override them.\n //\n // In direct mode the route arguments are already embedded in the URL path, so only\n // the unused (non-route) parameters are appended as additional query arguments.\n // In multiplexed mode ALL arguments — including route-derived ones — must be included\n // in the subscribe payload so the server can execute the query correctly.\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const { unusedParameters } = UrlHelpers.replaceRouteParameters(this.route, args as object);\n const connectionQueryArguments: any = {\n ...parameterValues,\n ...(Globals.queryDirectMode ? unusedParameters : (args as object) || {}),\n ...this.buildQueryArguments()\n };\n\n const subscriber = new ObservableQuerySubscription(this._connection);\n this._connection.connect(data => {\n const result: any = data;\n try {\n this.deserializeResult(result);\n callback(result);\n } catch (ex) {\n console.log(ex);\n }\n }, connectionQueryArguments);\n return subscriber;\n }\n\n /** @inheritdoc */\n async perform(args?: TParameters): Promise<QueryResult<TDataType>> {\n const noSuccess = { ...QueryResult.noSuccess, ...{ data: this.defaultValue } } as QueryResult<TDataType>;\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n return QueryResult.validationFailed(clientValidationErrors, this);\n }\n\n if (!this.validateArguments(args)) {\n return new Promise<QueryResult<TDataType>>((resolve) => {\n resolve(noSuccess);\n });\n }\n\n // Collect parameter values from parameterDescriptors that are set\n const parameterValues = ParametersHelper.collectParameterValues(this);\n\n const headers = {\n ...(this._httpHeadersCallback?.() || {}),\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n const response = await executeQueryHttpRequest(this._httpMethod, {\n route: this.route,\n apiBasePath: this._apiBasePath,\n origin: this._origin,\n args: (args as object) ?? {},\n parameterValues,\n paging: this.paging,\n sorting: this.sorting,\n headers\n });\n\n try {\n const result = await response.json();\n return new QueryResult(result, this.modelType, this.enumerable);\n } catch {\n return noSuccess;\n }\n }\n\n private validateArguments(args?: TParameters): boolean {\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const combinedArgs = { ...(args as object || {}), ...parameterValues };\n return ValidateRequestArguments(this.constructor.name, this.requiredRequestParameters, combinedArgs as object);\n }\n\n private buildQueryArguments(): any {\n const queryArguments: any = {};\n\n if (this.paging && this.paging.pageSize > 0) {\n queryArguments.pageSize = this.paging.pageSize;\n queryArguments.page = this.paging.page;\n }\n\n if (this.sorting.hasSorting) {\n queryArguments.sortBy = this.sorting.field;\n queryArguments.sortDirection = (this.sorting.direction === SortDirection.descending) ? 'desc' : 'asc';\n }\n\n return queryArguments;\n }\n\n private deserializeResult(result: any): void {\n if (this.enumerable) {\n result.data = deserializeQueryModels(this.modelType, result.data);\n } else if (result.data) {\n result.data = deserializeQueryModel(this.modelType, result.data);\n }\n }\n}\n"],"names":["ObservableQueryFor","_microservice","_apiBasePath","_origin","_connection","_httpHeadersCallback","_httpMethod","roles","validation","queryName","sorting","paging","enumerable","modelType","Sorting","none","Paging","noPaging","Globals","microservice","apiBasePath","origin","dispose","disconnect","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","setHttpMethod","method","subscribe","args","clientValidationErrors","validate","length","NullObservableQueryConnection","defaultValue","QueryResult","validationFailed","validateArguments","createObservableQueryConnection","route","name","parameterValues","ParametersHelper","collectParameterValues","unusedParameters","UrlHelpers","replaceRouteParameters","connectionQueryArguments","queryDirectMode","buildQueryArguments","subscriber","ObservableQuerySubscription","connect","data","result","deserializeResult","ex","console","log","perform","noSuccess","Promise","resolve","headers","microserviceHttpHeader","response","executeQueryHttpRequest","json","combinedArgs","ValidateRequestArguments","requiredRequestParameters","queryArguments","pageSize","page","hasSorting","sortBy","field","sortDirection","direction","SortDirection","descending","deserializeQueryModels","deserializeQueryModel"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAuBA;;;AAKC,IACM,MAAeA,kBAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,WAAAA;IACAC,oBAAAA;IACAC,WAAAA;AAICC,IAAAA,KAAAA,GAAkB,EAAE;IACpBC,UAAAA;sHAET,SAASC;IAGTC,OAAAA;IACAC,MAAAA;AAEA;;;;AAIC,QACD,YAAY,SAA+B,EAAWC,UAAmB,CAAE;aAAtDC,SAAAA,GAAAA,SAAAA;aAAiCD,UAAAA,GAAAA,UAAAA;AAClD,QAAA,IAAI,CAACF,OAAO,GAAGI,eAAAA,CAAQC,IAAI;AAC3B,QAAA,IAAI,CAACJ,MAAM,GAAGK,aAAAA,CAAOC,QAAQ;AAC7B,QAAA,IAAI,CAAChB,aAAa,GAAGiB,eAAAA,CAAQC,YAAY,IAAI,EAAA;AAC7C,QAAA,IAAI,CAACjB,YAAY,GAAGgB,eAAAA,CAAQE,WAAW,IAAI,EAAA;AAC3C,QAAA,IAAI,CAACjB,OAAO,GAAGe,eAAAA,CAAQG,MAAM,IAAI,EAAA;AACjC,QAAA,IAAI,CAAChB,oBAAoB,GAAG,KAAO,EAAC,CAAA;AACxC,IAAA;AAEA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AAS,KAAA;AACpG,QAAA;QAEA,OAAOT,cAAAA;AACX,IAAA;AAEQhB,IAAAA,iBAAAA,CAAkBD,MAAW,EAAQ;QACzC,IAAI,IAAI,CAAC7C,UAAU,EAAE;YACjB6C,MAAAA,CAAOD,IAAI,GAAG4B,4CAAAA,CAAuB,IAAI,CAACvE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;QACpE,CAAA,MAAO,IAAIC,MAAAA,CAAOD,IAAI,EAAE;YACpBC,MAAAA,CAAOD,IAAI,GAAG6B,2CAAAA,CAAsB,IAAI,CAACxE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;AACnE,QAAA;AACJ,IAAA;AACJ;;;;"}
@@ -1,13 +1,13 @@
1
- import { IObservableQueryFor, OnNextResult } from './IObservableQueryFor';
1
+ import type { IObservableQueryFor, OnNextResult } from './IObservableQueryFor';
2
2
  import { ObservableQuerySubscription } from './ObservableQuerySubscription';
3
- import { QueryValidator } from './QueryValidator';
4
- import { Constructor } from '@cratis/fundamentals';
3
+ import type { QueryValidator } from './QueryValidator';
4
+ import type { Constructor } from '@cratis/fundamentals';
5
5
  import { QueryResult } from './QueryResult';
6
6
  import { Sorting } from './Sorting';
7
7
  import { Paging } from './Paging';
8
- import { GetHttpHeaders } from '../GetHttpHeaders';
9
- import { ParameterDescriptor } from '../reflection/ParameterDescriptor';
10
- import { QueryHttpMethod } from './QueryHttpMethod';
8
+ import type { GetHttpHeaders } from '../GetHttpHeaders';
9
+ import type { ParameterDescriptor } from '../reflection/ParameterDescriptor';
10
+ import type { QueryHttpMethod } from './QueryHttpMethod';
11
11
  export declare abstract class ObservableQueryFor<TDataType, TParameters = object> implements IObservableQueryFor<TDataType, TParameters> {
12
12
  readonly modelType: Constructor;
13
13
  readonly enumerable: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableQueryFor.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryFor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,Y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GAAG,IAAI,CAExC;IAGD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9B;IAGD,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAErD;IAGD,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAE3C;IAGD,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAoDpH;IAGK,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CA4CjE;IAED,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,iBAAiB;CAO5B"}
@@ -74,9 +74,7 @@ import { executeQueryHttpRequest } from './QueryHttpRequest.js';
74
74
  // Serve the failure through the connection rather than throwing, so a subscriber sees an invalid result
75
75
  // on its normal callback path instead of the empty result an unestablished connection would emit.
76
76
  this._connection = new NullObservableQueryConnection(this.defaultValue, QueryResult.validationFailed(clientValidationErrors, this));
77
- } else if (!this.validateArguments(args)) {
78
- this._connection = new NullObservableQueryConnection(this.defaultValue);
79
- } else {
77
+ } else if (this.validateArguments(args)) {
80
78
  this._connection = createObservableQueryConnection({
81
79
  route: this.route,
82
80
  queryName: this.queryName ?? this.constructor.name,
@@ -85,6 +83,8 @@ import { executeQueryHttpRequest } from './QueryHttpRequest.js';
85
83
  microservice: this._microservice,
86
84
  args: args
87
85
  });
86
+ } else {
87
+ this._connection = new NullObservableQueryConnection(this.defaultValue);
88
88
  }
89
89
  // Descriptor-backed instance properties provide defaults; fresh args passed to subscribe()
90
90
  // must take precedence over any stale instance property values. Spread parameterValues
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableQueryFor.js","sources":["../../../queries/ObservableQueryFor.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 { IObservableQueryFor, OnNextResult } from './IObservableQueryFor';\nimport { ObservableQuerySubscription } from './ObservableQuerySubscription';\nimport { ValidateRequestArguments } from './ValidateRequestArguments';\nimport { QueryValidator } from './QueryValidator';\nimport { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { NullObservableQueryConnection } from './NullObservableQueryConnection';\nimport { createObservableQueryConnection } from './ObservableQueryConnectionFactory';\nimport { Constructor } from '@cratis/fundamentals';\nimport { deserializeQueryModel, deserializeQueryModels } from './deserializeQueryModel';\nimport { QueryResult } from './QueryResult';\nimport { Sorting } from './Sorting';\nimport { Paging } from './Paging';\nimport { SortDirection } from './SortDirection';\nimport { Globals } from '../Globals';\nimport { UrlHelpers } from '../UrlHelpers';\nimport { GetHttpHeaders } from '../GetHttpHeaders';\nimport { ParameterDescriptor } from '../reflection/ParameterDescriptor';\nimport { ParametersHelper } from '../reflection/ParametersHelper';\nimport { QueryHttpMethod } from './QueryHttpMethod';\nimport { executeQueryHttpRequest } from './QueryHttpRequest';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents an implementation of {@link IQueryFor}.\n * @template TDataType Type of data returned by the query.\n */\nexport abstract class ObservableQueryFor<TDataType, TParameters = object> implements IObservableQueryFor<TDataType, TParameters> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _connection?: IObservableQueryConnection<TDataType>;\n private _httpHeadersCallback: GetHttpHeaders;\n private _httpMethod?: QueryHttpMethod;\n\n abstract readonly route: string;\n abstract readonly defaultValue: TDataType;\n readonly roles: string[] = [];\n readonly validation?: QueryValidator<any>;\n /** Backend fully-qualified query name used when subscribing via the SSE hub. Overridden in generated proxies. */\n readonly queryName?: string;\n abstract readonly parameterDescriptors: ParameterDescriptor[];\n abstract get requiredRequestParameters(): string[];\n sorting: Sorting;\n paging: Paging;\n\n /**\n * Initializes a new instance of the {@link ObservableQueryFor<,>}} class.\n * @param modelType Type of model, if an enumerable, this is the instance type.\n * @param enumerable Whether or not it is an enumerable.\n */\n constructor(readonly modelType: Constructor, readonly enumerable: boolean) {\n this.sorting = Sorting.none;\n this.paging = Paging.noPaging;\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /**\n * Disposes the query.\n */\n dispose() {\n this._connection?.disconnect();\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n setHttpMethod(method: QueryHttpMethod): void {\n this._httpMethod = method;\n }\n\n /** @inheritdoc */\n subscribe(callback: OnNextResult<QueryResult<TDataType>>, args?: TParameters): ObservableQuerySubscription<TDataType> {\n if (this._connection) {\n this._connection.disconnect();\n }\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n // Serve the failure through the connection rather than throwing, so a subscriber sees an invalid result\n // on its normal callback path instead of the empty result an unestablished connection would emit.\n this._connection = new NullObservableQueryConnection(\n this.defaultValue,\n QueryResult.validationFailed(clientValidationErrors, this));\n } else if (!this.validateArguments(args)) {\n this._connection = new NullObservableQueryConnection(this.defaultValue);\n } else {\n this._connection = createObservableQueryConnection({\n route: this.route,\n queryName: this.queryName ?? this.constructor.name,\n origin: this._origin,\n apiBasePath: this._apiBasePath,\n microservice: this._microservice,\n args: args as object,\n });\n }\n\n // Descriptor-backed instance properties provide defaults; fresh args passed to subscribe()\n // must take precedence over any stale instance property values. Spread parameterValues\n // first so that the caller-supplied args can override them.\n //\n // In direct mode the route arguments are already embedded in the URL path, so only\n // the unused (non-route) parameters are appended as additional query arguments.\n // In multiplexed mode ALL arguments — including route-derived ones — must be included\n // in the subscribe payload so the server can execute the query correctly.\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const { unusedParameters } = UrlHelpers.replaceRouteParameters(this.route, args as object);\n const connectionQueryArguments: any = {\n ...parameterValues,\n ...(Globals.queryDirectMode ? unusedParameters : (args as object) || {}),\n ...this.buildQueryArguments()\n };\n\n const subscriber = new ObservableQuerySubscription(this._connection);\n this._connection.connect(data => {\n const result: any = data;\n try {\n this.deserializeResult(result);\n callback(result);\n } catch (ex) {\n console.log(ex);\n }\n }, connectionQueryArguments);\n return subscriber;\n }\n\n /** @inheritdoc */\n async perform(args?: TParameters): Promise<QueryResult<TDataType>> {\n const noSuccess = { ...QueryResult.noSuccess, ...{ data: this.defaultValue } } as QueryResult<TDataType>;\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n return QueryResult.validationFailed(clientValidationErrors, this);\n }\n\n if (!this.validateArguments(args)) {\n return new Promise<QueryResult<TDataType>>((resolve) => {\n resolve(noSuccess);\n });\n }\n\n // Collect parameter values from parameterDescriptors that are set\n const parameterValues = ParametersHelper.collectParameterValues(this);\n\n const headers = {\n ...(this._httpHeadersCallback?.() || {}),\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n const response = await executeQueryHttpRequest(this._httpMethod, {\n route: this.route,\n apiBasePath: this._apiBasePath,\n origin: this._origin,\n args: (args as object) ?? {},\n parameterValues,\n paging: this.paging,\n sorting: this.sorting,\n headers\n });\n\n try {\n const result = await response.json();\n return new QueryResult(result, this.modelType, this.enumerable);\n } catch {\n return noSuccess;\n }\n }\n\n private validateArguments(args?: TParameters): boolean {\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const combinedArgs = { ...(args as object || {}), ...parameterValues };\n return ValidateRequestArguments(this.constructor.name, this.requiredRequestParameters, combinedArgs as object);\n }\n\n private buildQueryArguments(): any {\n const queryArguments: any = {};\n\n if (this.paging && this.paging.pageSize > 0) {\n queryArguments.pageSize = this.paging.pageSize;\n queryArguments.page = this.paging.page;\n }\n\n if (this.sorting.hasSorting) {\n queryArguments.sortBy = this.sorting.field;\n queryArguments.sortDirection = (this.sorting.direction === SortDirection.descending) ? 'desc' : 'asc';\n }\n\n return queryArguments;\n }\n\n private deserializeResult(result: any): void {\n if (this.enumerable) {\n result.data = deserializeQueryModels(this.modelType, result.data);\n } else if (result.data) {\n result.data = deserializeQueryModel(this.modelType, result.data);\n }\n }\n}\n"],"names":["ObservableQueryFor","_microservice","_apiBasePath","_origin","_connection","_httpHeadersCallback","_httpMethod","roles","validation","queryName","sorting","paging","enumerable","modelType","Sorting","none","Paging","noPaging","Globals","microservice","apiBasePath","origin","dispose","disconnect","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","setHttpMethod","method","subscribe","args","clientValidationErrors","validate","length","NullObservableQueryConnection","defaultValue","QueryResult","validationFailed","validateArguments","createObservableQueryConnection","route","name","parameterValues","ParametersHelper","collectParameterValues","unusedParameters","UrlHelpers","replaceRouteParameters","connectionQueryArguments","queryDirectMode","buildQueryArguments","subscriber","ObservableQuerySubscription","connect","data","result","deserializeResult","ex","console","log","perform","noSuccess","Promise","resolve","headers","microserviceHttpHeader","response","executeQueryHttpRequest","json","combinedArgs","ValidateRequestArguments","requiredRequestParameters","queryArguments","pageSize","page","hasSorting","sortBy","field","sortDirection","direction","SortDirection","descending","deserializeQueryModels","deserializeQueryModel"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAuBA;;;AAKC,IACM,MAAeA,kBAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,WAAAA;IACAC,oBAAAA;IACAC,WAAAA;AAICC,IAAAA,KAAAA,GAAkB,EAAE;IACpBC,UAAAA;sHAET,SAASC;IAGTC,OAAAA;IACAC,MAAAA;AAEA;;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B,iBAAsB,EAAC;QAE7B,IAAI,IAAI,CAAC/D,MAAM,IAAI,IAAI,CAACA,MAAM,CAACgE,QAAQ,GAAG,CAAA,EAAG;AACzCD,YAAAA,cAAAA,CAAeC,QAAQ,GAAG,IAAI,CAAChE,MAAM,CAACgE,QAAQ;AAC9CD,YAAAA,cAAAA,CAAeE,IAAI,GAAG,IAAI,CAACjE,MAAM,CAACiE,IAAI;AAC1C,QAAA;AAEA,QAAA,IAAI,IAAI,CAAClE,OAAO,CAACmE,UAAU,EAAE;AACzBH,YAAAA,cAAAA,CAAeI,MAAM,GAAG,IAAI,CAACpE,OAAO,CAACqE,KAAK;AAC1CL,YAAAA,cAAAA,CAAeM,aAAa,GAAG,IAAK,CAACtE,OAAO,CAACuE,SAAS,KAAKC,aAAAA,CAAcC,UAAU,GAAI,MAAA,GAAS,KAAA;AACpG,QAAA;QAEA,OAAOT,cAAAA;AACX,IAAA;AAEQhB,IAAAA,iBAAAA,CAAkBD,MAAW,EAAQ;QACzC,IAAI,IAAI,CAAC7C,UAAU,EAAE;YACjB6C,MAAAA,CAAOD,IAAI,GAAG4B,sBAAAA,CAAuB,IAAI,CAACvE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;QACpE,CAAA,MAAO,IAAIC,MAAAA,CAAOD,IAAI,EAAE;YACpBC,MAAAA,CAAOD,IAAI,GAAG6B,qBAAAA,CAAsB,IAAI,CAACxE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;AACnE,QAAA;AACJ,IAAA;AACJ;;;;"}
1
+ {"version":3,"file":"ObservableQueryFor.js","sources":["../../../queries/ObservableQueryFor.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 type { IObservableQueryFor, OnNextResult } from './IObservableQueryFor';\nimport { ObservableQuerySubscription } from './ObservableQuerySubscription';\nimport { ValidateRequestArguments } from './ValidateRequestArguments';\nimport type { QueryValidator } from './QueryValidator';\nimport type { IObservableQueryConnection } from './IObservableQueryConnection';\nimport { NullObservableQueryConnection } from './NullObservableQueryConnection';\nimport { createObservableQueryConnection } from './ObservableQueryConnectionFactory';\nimport type { Constructor } from '@cratis/fundamentals';\nimport { deserializeQueryModel, deserializeQueryModels } from './deserializeQueryModel';\nimport { QueryResult } from './QueryResult';\nimport { Sorting } from './Sorting';\nimport { Paging } from './Paging';\nimport { SortDirection } from './SortDirection';\nimport { Globals } from '../Globals';\nimport { UrlHelpers } from '../UrlHelpers';\nimport type { GetHttpHeaders } from '../GetHttpHeaders';\nimport type { ParameterDescriptor } from '../reflection/ParameterDescriptor';\nimport { ParametersHelper } from '../reflection/ParametersHelper';\nimport type { QueryHttpMethod } from './QueryHttpMethod';\nimport { executeQueryHttpRequest } from './QueryHttpRequest';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents an implementation of {@link IQueryFor}.\n * @template TDataType Type of data returned by the query.\n */\nexport abstract class ObservableQueryFor<TDataType, TParameters = object> implements IObservableQueryFor<TDataType, TParameters> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _connection?: IObservableQueryConnection<TDataType>;\n private _httpHeadersCallback: GetHttpHeaders;\n private _httpMethod?: QueryHttpMethod;\n\n abstract readonly route: string;\n abstract readonly defaultValue: TDataType;\n readonly roles: string[] = [];\n readonly validation?: QueryValidator<any>;\n /** Backend fully-qualified query name used when subscribing via the SSE hub. Overridden in generated proxies. */\n readonly queryName?: string;\n abstract readonly parameterDescriptors: ParameterDescriptor[];\n abstract get requiredRequestParameters(): string[];\n sorting: Sorting;\n paging: Paging;\n\n /**\n * Initializes a new instance of the {@link ObservableQueryFor<,>}} class.\n * @param modelType Type of model, if an enumerable, this is the instance type.\n * @param enumerable Whether or not it is an enumerable.\n */\n constructor(readonly modelType: Constructor, readonly enumerable: boolean) {\n this.sorting = Sorting.none;\n this.paging = Paging.noPaging;\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /**\n * Disposes the query.\n */\n dispose() {\n this._connection?.disconnect();\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n setHttpMethod(method: QueryHttpMethod): void {\n this._httpMethod = method;\n }\n\n /** @inheritdoc */\n subscribe(callback: OnNextResult<QueryResult<TDataType>>, args?: TParameters): ObservableQuerySubscription<TDataType> {\n if (this._connection) {\n this._connection.disconnect();\n }\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n // Serve the failure through the connection rather than throwing, so a subscriber sees an invalid result\n // on its normal callback path instead of the empty result an unestablished connection would emit.\n this._connection = new NullObservableQueryConnection(\n this.defaultValue,\n QueryResult.validationFailed(clientValidationErrors, this));\n } else if (this.validateArguments(args)) {\n this._connection = createObservableQueryConnection({\n route: this.route,\n queryName: this.queryName ?? this.constructor.name,\n origin: this._origin,\n apiBasePath: this._apiBasePath,\n microservice: this._microservice,\n args: args as object,\n });\n } else {\n this._connection = new NullObservableQueryConnection(this.defaultValue);\n }\n\n // Descriptor-backed instance properties provide defaults; fresh args passed to subscribe()\n // must take precedence over any stale instance property values. Spread parameterValues\n // first so that the caller-supplied args can override them.\n //\n // In direct mode the route arguments are already embedded in the URL path, so only\n // the unused (non-route) parameters are appended as additional query arguments.\n // In multiplexed mode ALL arguments — including route-derived ones — must be included\n // in the subscribe payload so the server can execute the query correctly.\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const { unusedParameters } = UrlHelpers.replaceRouteParameters(this.route, args as object);\n const connectionQueryArguments: any = {\n ...parameterValues,\n ...(Globals.queryDirectMode ? unusedParameters : (args as object) || {}),\n ...this.buildQueryArguments()\n };\n\n const subscriber = new ObservableQuerySubscription(this._connection);\n this._connection.connect(data => {\n const result: any = data;\n try {\n this.deserializeResult(result);\n callback(result);\n } catch (ex) {\n console.log(ex);\n }\n }, connectionQueryArguments);\n return subscriber;\n }\n\n /** @inheritdoc */\n async perform(args?: TParameters): Promise<QueryResult<TDataType>> {\n const noSuccess = { ...QueryResult.noSuccess, ...{ data: this.defaultValue } } as QueryResult<TDataType>;\n\n const clientValidationErrors = this.validation?.validate(args as object || {}) || [];\n if (clientValidationErrors.length > 0) {\n return QueryResult.validationFailed(clientValidationErrors, this);\n }\n\n if (!this.validateArguments(args)) {\n return new Promise<QueryResult<TDataType>>((resolve) => {\n resolve(noSuccess);\n });\n }\n\n // Collect parameter values from parameterDescriptors that are set\n const parameterValues = ParametersHelper.collectParameterValues(this);\n\n const headers = {\n ...(this._httpHeadersCallback?.() || {}),\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n const response = await executeQueryHttpRequest(this._httpMethod, {\n route: this.route,\n apiBasePath: this._apiBasePath,\n origin: this._origin,\n args: (args as object) ?? {},\n parameterValues,\n paging: this.paging,\n sorting: this.sorting,\n headers\n });\n\n try {\n const result = await response.json();\n return new QueryResult(result, this.modelType, this.enumerable);\n } catch {\n return noSuccess;\n }\n }\n\n private validateArguments(args?: TParameters): boolean {\n const parameterValues = ParametersHelper.collectParameterValues(this);\n const combinedArgs = { ...(args as object || {}), ...parameterValues };\n return ValidateRequestArguments(this.constructor.name, this.requiredRequestParameters, combinedArgs as object);\n }\n\n private buildQueryArguments(): any {\n const queryArguments: any = {};\n\n if (this.paging && this.paging.pageSize > 0) {\n queryArguments.pageSize = this.paging.pageSize;\n queryArguments.page = this.paging.page;\n }\n\n if (this.sorting.hasSorting) {\n queryArguments.sortBy = this.sorting.field;\n queryArguments.sortDirection = (this.sorting.direction === SortDirection.descending) ? 'desc' : 'asc';\n }\n\n return queryArguments;\n }\n\n private deserializeResult(result: any): void {\n if (this.enumerable) {\n result.data = deserializeQueryModels(this.modelType, result.data);\n } else if (result.data) {\n result.data = deserializeQueryModel(this.modelType, result.data);\n }\n }\n}\n"],"names":["ObservableQueryFor","_microservice","_apiBasePath","_origin","_connection","_httpHeadersCallback","_httpMethod","roles","validation","queryName","sorting","paging","enumerable","modelType","Sorting","none","Paging","noPaging","Globals","microservice","apiBasePath","origin","dispose","disconnect","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","setHttpMethod","method","subscribe","args","clientValidationErrors","validate","length","NullObservableQueryConnection","defaultValue","QueryResult","validationFailed","validateArguments","createObservableQueryConnection","route","name","parameterValues","ParametersHelper","collectParameterValues","unusedParameters","UrlHelpers","replaceRouteParameters","connectionQueryArguments","queryDirectMode","buildQueryArguments","subscriber","ObservableQuerySubscription","connect","data","result","deserializeResult","ex","console","log","perform","noSuccess","Promise","resolve","headers","microserviceHttpHeader","response","executeQueryHttpRequest","json","combinedArgs","ValidateRequestArguments","requiredRequestParameters","queryArguments","pageSize","page","hasSorting","sortBy","field","sortDirection","direction","SortDirection","descending","deserializeQueryModels","deserializeQueryModel"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAuBA;;;AAKC,IACM,MAAeA,kBAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,WAAAA;IACAC,oBAAAA;IACAC,WAAAA;AAICC,IAAAA,KAAAA,GAAkB,EAAE;IACpBC,UAAAA;sHAET,SAASC;IAGTC,OAAAA;IACAC,MAAAA;AAEA;;;;AAIC,QACD,YAAY,SAA+B,EAAWC,UAAmB,CAAE;aAAtDC,SAAAA,GAAAA,SAAAA;aAAiCD,UAAAA,GAAAA,UAAAA;AAClD,QAAA,IAAI,CAACF,OAAO,GAAGI,OAAAA,CAAQC,IAAI;AAC3B,QAAA,IAAI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CD,YAAAA,cAAAA,CAAeE,IAAI,GAAG,IAAI,CAACjE,MAAM,CAACiE,IAAI;AAC1C,QAAA;AAEA,QAAA,IAAI,IAAI,CAAClE,OAAO,CAACmE,UAAU,EAAE;AACzBH,YAAAA,cAAAA,CAAeI,MAAM,GAAG,IAAI,CAACpE,OAAO,CAACqE,KAAK;AAC1CL,YAAAA,cAAAA,CAAeM,aAAa,GAAG,IAAK,CAACtE,OAAO,CAACuE,SAAS,KAAKC,aAAAA,CAAcC,UAAU,GAAI,MAAA,GAAS,KAAA;AACpG,QAAA;QAEA,OAAOT,cAAAA;AACX,IAAA;AAEQhB,IAAAA,iBAAAA,CAAkBD,MAAW,EAAQ;QACzC,IAAI,IAAI,CAAC7C,UAAU,EAAE;YACjB6C,MAAAA,CAAOD,IAAI,GAAG4B,sBAAAA,CAAuB,IAAI,CAACvE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;QACpE,CAAA,MAAO,IAAIC,MAAAA,CAAOD,IAAI,EAAE;YACpBC,MAAAA,CAAOD,IAAI,GAAG6B,qBAAAA,CAAsB,IAAI,CAACxE,SAAS,EAAE4C,OAAOD,IAAI,CAAA;AACnE,QAAA;AACJ,IAAA;AACJ;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { ObservableQueryFor } from '../../ObservableQueryFor';
2
+ import { DateOnly, TimeOnly } from '@cratis/fundamentals';
2
3
  import { ParameterDescriptor } from '../../../reflection/ParameterDescriptor';
3
4
  export declare class TestObservableQuery extends ObservableQueryFor<string, {
4
5
  id: string;
@@ -18,6 +19,22 @@ export declare class TestEnumerableQuery extends ObservableQueryFor<string[], {
18
19
  get requiredRequestParameters(): string[];
19
20
  constructor();
20
21
  }
22
+ export declare class TestCalendarChild {
23
+ date: DateOnly;
24
+ time: TimeOnly;
25
+ }
26
+ export declare class TestCalendarItem {
27
+ children: TestCalendarChild[];
28
+ }
29
+ export declare class TestCalendarEnumerableQuery extends ObservableQueryFor<TestCalendarItem[], {
30
+ category: string;
31
+ }> {
32
+ readonly route = "/api/calendar-items/{category}";
33
+ readonly defaultValue: TestCalendarItem[];
34
+ readonly parameterDescriptors: ParameterDescriptor[];
35
+ get requiredRequestParameters(): string[];
36
+ constructor();
37
+ }
21
38
  export declare class TestObservableQueryWithParameterDescriptorValues extends ObservableQueryFor<string, object> {
22
39
  readonly route = "/api/search";
23
40
  readonly defaultValue = "";
@@ -1 +1 @@
1
- {"version":3,"file":"TestQueries.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/TestQueries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,qBAAa,mBAAoB,SAAQ,kBAAkB,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;IAC/E,QAAQ,CAAC,KAAK,oBAAoB;IAClC,QAAQ,CAAC,YAAY,MAAM;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAElD;IAEF,IAAI,yBAAyB,IAAI,MAAM,EAAE,CAExC;IAED,cAEC;CACJ;AAED,qBAAa,mBAAoB,SAAQ,kBAAkB,CAAC,MAAM,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;IACvF,QAAQ,CAAC,KAAK,2BAA2B;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAM;IACrC,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAElD;IAEF,IAAI,yBAAyB,IAAI,MAAM,EAAE,CAExC;IAED,cAEC;CACJ;AAED,qBAAa,gDAAiD,SAAQ,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC;IACpG,QAAQ,CAAC,KAAK,iBAAiB;IAC/B,QAAQ,CAAC,YAAY,MAAM;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAGlD;IAEF,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E,CAExC;IAED,cAEC;CACJ;AAED,MAAM,WAAW,wCAAwC;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,wCAAyC,SAAQ,kBAAkB,CAAC,MAAM,EAAE,wCAAwC,CAAC;IAC9H,QAAQ,CAAC,KAAK,qBAAqB;IACnC,QAAQ,CAAC,YAAY,MAAM;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAIlD;IAEF,IAAI,yBAAyB,IAAI,MAAM,EAAE,CAExC;IAED,cAEC;CACJ;AAED,MAAM,WAAW,0DAA0D;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,iDAAkD,SAAQ,kBAAkB,CAAC,MAAM,EAAE,0DAA0D,CAAC;IACzJ,QAAQ,CAAC,KAAK,qCAAqC;IACnD,QAAQ,CAAC,YAAY,MAAM;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAGlD;IAEF,IAAI,yBAAyB,IAAI,MAAM,EAAE,CAExC;IAED,cAEC;CACJ"}
@@ -1,4 +1,6 @@
1
+ import { __decorate, __metadata } from "tslib";
1
2
  import { ObservableQueryFor } from '../../ObservableQueryFor';
3
+ import { DateOnly, field, TimeOnly } from '@cratis/fundamentals';
2
4
  import { ParameterDescriptor } from '../../../reflection/ParameterDescriptor';
3
5
  export class TestObservableQuery extends ObservableQueryFor {
4
6
  route = '/api/test/{id}';
@@ -26,6 +28,38 @@ export class TestEnumerableQuery extends ObservableQueryFor {
26
28
  super(String, true);
27
29
  }
28
30
  }
31
+ export class TestCalendarChild {
32
+ date;
33
+ time;
34
+ }
35
+ __decorate([
36
+ field(DateOnly),
37
+ __metadata("design:type", DateOnly)
38
+ ], TestCalendarChild.prototype, "date", void 0);
39
+ __decorate([
40
+ field(TimeOnly),
41
+ __metadata("design:type", TimeOnly)
42
+ ], TestCalendarChild.prototype, "time", void 0);
43
+ export class TestCalendarItem {
44
+ children;
45
+ }
46
+ __decorate([
47
+ field(TestCalendarChild, true),
48
+ __metadata("design:type", Array)
49
+ ], TestCalendarItem.prototype, "children", void 0);
50
+ export class TestCalendarEnumerableQuery extends ObservableQueryFor {
51
+ route = '/api/calendar-items/{category}';
52
+ defaultValue = [];
53
+ parameterDescriptors = [
54
+ new ParameterDescriptor('category', String)
55
+ ];
56
+ get requiredRequestParameters() {
57
+ return ['category'];
58
+ }
59
+ constructor() {
60
+ super(TestCalendarItem, true);
61
+ }
62
+ }
29
63
  export class TestObservableQueryWithParameterDescriptorValues extends ObservableQueryFor {
30
64
  route = '/api/search';
31
65
  defaultValue = '';
@@ -1 +1 @@
1
- {"version":3,"file":"TestQueries.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/TestQueries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,MAAM,OAAO,mBAAoB,SAAQ,kBAA0C;IACtE,KAAK,GAAG,gBAAgB,CAAC;IACzB,YAAY,GAAG,EAAE,CAAC;IAClB,oBAAoB,GAA0B;QACnD,IAAI,mBAAmB,CAAC,IAAI,EAAE,MAAqB,CAAC;KACvD,CAAC;IAEF,IAAI,yBAAyB;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED;QACI,KAAK,CAAC,MAAqB,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ;AAED,MAAM,OAAO,mBAAoB,SAAQ,kBAAkD;IAC9E,KAAK,GAAG,uBAAuB,CAAC;IAChC,YAAY,GAAa,EAAE,CAAC;IAC5B,oBAAoB,GAA0B;QACnD,IAAI,mBAAmB,CAAC,UAAU,EAAE,MAAqB,CAAC;KAC7D,CAAC;IAEF,IAAI,yBAAyB;QACzB,OAAO,CAAC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Q,EAAE,UAAU,CAAC,CAAC;IAClC,CAAC;IAED;QACI,KAAK,CAAC,MAAqB,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ"}
1
+ {"version":3,"file":"TestQueries.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/TestQueries.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAe,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,MAAM,OAAO,mBAAoB,SAAQ,kBAA0C;IACtE,KAAK,GAAG,gBAAgB,CAAC;IACzB,YAAY,GAAG,EAAE,CAAC;IAClB,oBAAoB,GAA0B;QACnD,IAAI,mBAAmB,CAAC,IAAI,EAAE,MAAqB,CAAC;KACvD,CAAC;IAEF,IAAI,yBAAyB;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED;QACI,KAAK,CAAC,MAAqB,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ;AAED,MAAM,OAAO,mBAAoB,SAAQ,kBAAkD;IAC9E,KAAK,GAAG,uBAAuB,CAAC;IAChC,YAAY,GAAa,EAAE,CAAC;IAC5B,oBAAoB,GAA0B;QACnD,IAAI,mBAAmB,CAAC,UAAU,EAAE,MAAqB,CAAC;KAC7D,CAAC;IAEF,IAAI,yBAAyB;QACzB,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;IAED;QACI,KAAK,CAAC,MAAqB,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,MAAM,OAAO,iBAAiB;IAE1B,IAAI,CAAY;IAGhB,IAAI,CAAY;CACnB;AAJG;IADC,KAAK,CAAC,QAAQ,CAAC;8BACT,QAAQ;+CAAC;AAGhB;IADC,KAAK,CAAC,QAAQ,CAAC;8BACT,QAAQ;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KAAK,CAAC,MAAqB,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ;AAOD,MAAM,OAAO,iDAAkD,SAAQ,kBAAsF;IAChJ,KAAK,GAAG,iCAAiC,CAAC;IAC1C,YAAY,GAAG,EAAE,CAAC;IAClB,oBAAoB,GAA0B;QACnD,IAAI,mBAAmB,CAAC,QAAQ,EAAE,MAAqB,CAAC;QACxD,IAAI,mBAAmB,CAAC,UAAU,EAAE,MAAqB,CAAC;KAC7D,CAAC;IAEF,IAAI,yBAAyB;QACzB,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAClC,CAAC;IAED;QACI,KAAK,CAAC,MAAqB,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ"}
@@ -1,7 +1,8 @@
1
- import { TestObservableQuery, TestEnumerableQuery, TestObservableQueryWithParameterDescriptorValues, TestObservableQueryWithRouteAndQueryArgs, TestObservableQueryWithMultipleRequiredParameters } from './TestQueries';
1
+ import { TestObservableQuery, TestEnumerableQuery, TestCalendarEnumerableQuery, TestObservableQueryWithParameterDescriptorValues, TestObservableQueryWithRouteAndQueryArgs, TestObservableQueryWithMultipleRequiredParameters } from './TestQueries';
2
2
  export declare class an_observable_query_for {
3
3
  query: TestObservableQuery;
4
4
  enumerableQuery: TestEnumerableQuery;
5
+ calendarEnumerableQuery: TestCalendarEnumerableQuery;
5
6
  queryWithParameterDescriptorValues: TestObservableQueryWithParameterDescriptorValues;
6
7
  queryWithRouteAndQueryArgs: TestObservableQueryWithRouteAndQueryArgs;
7
8
  queryWithMultipleRequiredParameters: TestObservableQueryWithMultipleRequiredParameters;
@@ -1 +1 @@
1
- {"version":3,"file":"an_observable_query_for.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/an_observable_query_for.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,gDAAgD,EAChD,wCAAwC,EACxC,iDAAiD,EACpD,MAAM,eAAe,CAAC;AAEvB,qBAAa,uBAAuB;IAChC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,eAAe,EAAE,mBAAmB,CAAC;IACrC,kCAAkC,EAAE,gDAAgD,CAAC;IACrF,0BAA0B,EAAE,wCAAwC,CAAC;IACrE,mCAAmC,EAAE,iDAAiD,CAAC;IAEvF,cAMC;CACJ"}
1
+ {"version":3,"file":"an_observable_query_for.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/an_observable_query_for.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,gDAAgD,EAChD,wCAAwC,EACxC,iDAAiD,EACpD,MAAM,eAAe,CAAC;AAEvB,qBAAa,uBAAuB;IAChC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,eAAe,EAAE,mBAAmB,CAAC;IACrC,uBAAuB,EAAE,2BAA2B,CAAC;IACrD,kCAAkC,EAAE,gDAAgD,CAAC;IACrF,0BAA0B,EAAE,wCAAwC,CAAC;IACrE,mCAAmC,EAAE,iDAAiD,CAAC;IAEvF,cAOC;CACJ"}
@@ -1,13 +1,15 @@
1
- import { TestObservableQuery, TestEnumerableQuery, TestObservableQueryWithParameterDescriptorValues, TestObservableQueryWithRouteAndQueryArgs, TestObservableQueryWithMultipleRequiredParameters } from './TestQueries';
1
+ import { TestObservableQuery, TestEnumerableQuery, TestCalendarEnumerableQuery, TestObservableQueryWithParameterDescriptorValues, TestObservableQueryWithRouteAndQueryArgs, TestObservableQueryWithMultipleRequiredParameters } from './TestQueries';
2
2
  export class an_observable_query_for {
3
3
  query;
4
4
  enumerableQuery;
5
+ calendarEnumerableQuery;
5
6
  queryWithParameterDescriptorValues;
6
7
  queryWithRouteAndQueryArgs;
7
8
  queryWithMultipleRequiredParameters;
8
9
  constructor() {
9
10
  this.query = new TestObservableQuery();
10
11
  this.enumerableQuery = new TestEnumerableQuery();
12
+ this.calendarEnumerableQuery = new TestCalendarEnumerableQuery();
11
13
  this.queryWithParameterDescriptorValues = new TestObservableQueryWithParameterDescriptorValues();
12
14
  this.queryWithRouteAndQueryArgs = new TestObservableQueryWithRouteAndQueryArgs();
13
15
  this.queryWithMultipleRequiredParameters = new TestObservableQueryWithMultipleRequiredParameters();
@@ -1 +1 @@
1
- {"version":3,"file":"an_observable_query_for.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/an_observable_query_for.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,gDAAgD,EAChD,wCAAwC,EACxC,iDAAiD,EACpD,MAAM,eAAe,CAAC;AAEvB,MAAM,OAAO,uBAAuB;IAChC,KAAK,CAAsB;IAC3B,eAAe,CAAsB;IACrC,kCAAkC,CAAmD;IACrF,0BAA0B,CAA2C;IACrE,mCAAmC,CAAoD;IAEvF;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACjD,IAAI,CAAC,kCAAkC,GAAG,IAAI,gDAAgD,EAAE,CAAC;QACjG,IAAI,CAAC,0BAA0B,GAAG,IAAI,wCAAwC,EAAE,CAAC;QACjF,IAAI,CAAC,mCAAmC,GAAG,IAAI,iDAAiD,EAAE,CAAC;IACvG,CAAC;CACJ"}
1
+ {"version":3,"file":"an_observable_query_for.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/given/an_observable_query_for.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,gDAAgD,EAChD,wCAAwC,EACxC,iDAAiD,EACpD,MAAM,eAAe,CAAC;AAEvB,MAAM,OAAO,uBAAuB;IAChC,KAAK,CAAsB;IAC3B,eAAe,CAAsB;IACrC,uBAAuB,CAA8B;IACrD,kCAAkC,CAAmD;IACrF,0BAA0B,CAA2C;IACrE,mCAAmC,CAAoD;IAEvF;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACjD,IAAI,CAAC,uBAAuB,GAAG,IAAI,2BAA2B,EAAE,CAAC;QACjE,IAAI,CAAC,kCAAkC,GAAG,IAAI,gDAAgD,EAAE,CAAC;QACjG,IAAI,CAAC,0BAA0B,GAAG,IAAI,wCAAwC,EAAE,CAAC;QACjF,IAAI,CAAC,mCAAmC,GAAG,IAAI,iDAAiD,EAAE,CAAC;IACvG,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=and_the_model_has_a_calendar_collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_the_model_has_a_calendar_collection.d.ts","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import * as sinon from 'sinon';
2
+ import { DateOnly, TimeOnly } from '@cratis/fundamentals';
3
+ import { an_observable_query_for } from '../given/an_observable_query_for';
4
+ import { given } from '../../../given';
5
+ import { Globals } from '../../../Globals';
6
+ import { QueryTransportMethod } from '../../QueryTransportMethod';
7
+ describe('and the model has a calendar collection', given(an_observable_query_for, context => {
8
+ let subscription;
9
+ let fakeEventSource;
10
+ let received;
11
+ let originalQueryDirectMode;
12
+ let originalTransportMethod;
13
+ let originalFactory;
14
+ beforeEach(() => {
15
+ originalQueryDirectMode = Globals.queryDirectMode;
16
+ originalTransportMethod = Globals.queryTransportMethod;
17
+ originalFactory = Globals.eventSourceFactory;
18
+ Globals.queryDirectMode = true;
19
+ Globals.queryTransportMethod = QueryTransportMethod.ServerSentEvents;
20
+ fakeEventSource = { onmessage: null, onerror: null, close: sinon.stub() };
21
+ Globals.eventSourceFactory = (() => fakeEventSource);
22
+ context.calendarEnumerableQuery.setOrigin('https://example.com');
23
+ received = [];
24
+ subscription = context.calendarEnumerableQuery.subscribe(result => received.push(result), { category: 'test-category' });
25
+ fakeEventSource.onmessage({
26
+ data: JSON.stringify({
27
+ data: [{ children: [{ date: '2026-02-03', time: '14:15:16' }] }],
28
+ isSuccess: true,
29
+ isAuthorized: true,
30
+ isValid: true,
31
+ hasExceptions: false,
32
+ validationResults: [],
33
+ exceptionMessages: [],
34
+ exceptionStackTrace: '',
35
+ paging: { page: 0, size: 0, totalItems: 1, totalPages: 1 }
36
+ })
37
+ });
38
+ });
39
+ afterEach(() => {
40
+ subscription?.unsubscribe();
41
+ Globals.queryDirectMode = originalQueryDirectMode;
42
+ Globals.queryTransportMethod = originalTransportMethod;
43
+ Globals.eventSourceFactory = originalFactory;
44
+ sinon.restore();
45
+ });
46
+ it('should deliver the result to the subscriber', () => received.length.should.equal(1));
47
+ it('should deserialize the child date', () => received[0].data[0].children[0].date.should.be.instanceOf(DateOnly));
48
+ it('should preserve the child date', () => received[0].data[0].children[0].date.equals(DateOnly.from(2026, 2, 3)).should.be.true);
49
+ it('should deserialize the child time', () => received[0].data[0].children[0].time.should.be.instanceOf(TimeOnly));
50
+ it('should preserve the child time', () => received[0].data[0].children[0].time.equals(TimeOnly.from(14, 15, 16)).should.be.true);
51
+ }));
52
+ //# sourceMappingURL=and_the_model_has_a_calendar_collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and_the_model_has_a_calendar_collection.js","sourceRoot":"","sources":["../../../../../queries/for_ObservableQueryFor/when_receiving_a_result/and_the_model_has_a_calendar_collection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,OAA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