@cratis/arc 22.139.0 → 22.140.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/UrlHelpers.ts +20 -1
- package/commands/Command.ts +7 -1
- package/commands/for_Command/when_validating/with_null_required_property.ts +4 -1
- package/commands/for_Command/when_validating/with_required_property_missing.ts +7 -1
- package/dist/cjs/UrlHelpers.d.ts +1 -0
- package/dist/cjs/UrlHelpers.d.ts.map +1 -1
- package/dist/cjs/UrlHelpers.js +17 -1
- package/dist/cjs/UrlHelpers.js.map +1 -1
- package/dist/cjs/commands/Command.d.ts.map +1 -1
- package/dist/cjs/commands/Command.js +5 -1
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryMultiplexer.d.ts.map +1 -1
- package/dist/cjs/queries/ObservableQueryMultiplexer.js +2 -1
- package/dist/cjs/queries/ObservableQueryMultiplexer.js.map +1 -1
- package/dist/cjs/validation/ValidationResult.d.ts.map +1 -1
- package/dist/cjs/validation/ValidationResult.js +4 -1
- package/dist/cjs/validation/ValidationResult.js.map +1 -1
- package/dist/cjs/validation/ValidationResultReasonDetail.d.ts +4 -0
- package/dist/cjs/validation/ValidationResultReasonDetail.d.ts.map +1 -0
- package/dist/cjs/validation/ValidationResultReasonDetail.js +15 -0
- package/dist/cjs/validation/ValidationResultReasonDetail.js.map +1 -0
- package/dist/cjs/validation/index.d.ts +1 -0
- package/dist/cjs/validation/index.d.ts.map +1 -1
- package/dist/cjs/validation/index.js +2 -0
- package/dist/cjs/validation/index.js.map +1 -1
- package/dist/esm/UrlHelpers.d.ts +1 -0
- package/dist/esm/UrlHelpers.d.ts.map +1 -1
- package/dist/esm/UrlHelpers.js +17 -2
- package/dist/esm/UrlHelpers.js.map +1 -1
- package/dist/esm/commands/Command.d.ts.map +1 -1
- package/dist/esm/commands/Command.js +5 -1
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/for_Command/when_validating/with_null_required_property.js +4 -1
- package/dist/esm/commands/for_Command/when_validating/with_null_required_property.js.map +1 -1
- package/dist/esm/commands/for_Command/when_validating/with_required_property_missing.js +7 -1
- package/dist/esm/commands/for_Command/when_validating/with_required_property_missing.js.map +1 -1
- package/dist/esm/for_UrlHelpers/when_building_query_params/with_object_values.d.ts +2 -0
- package/dist/esm/for_UrlHelpers/when_building_query_params/with_object_values.d.ts.map +1 -0
- package/dist/esm/for_UrlHelpers/when_building_query_params/with_object_values.js +23 -0
- package/dist/esm/for_UrlHelpers/when_building_query_params/with_object_values.js.map +1 -0
- package/dist/esm/queries/ObservableQueryMultiplexer.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryMultiplexer.js +2 -1
- package/dist/esm/queries/ObservableQueryMultiplexer.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryMultiplexer/when_building_a_subscription_request/with_dictionary_values.d.ts +2 -0
- package/dist/esm/queries/for_ObservableQueryMultiplexer/when_building_a_subscription_request/with_dictionary_values.d.ts.map +1 -0
- package/dist/esm/queries/for_ObservableQueryMultiplexer/when_building_a_subscription_request/with_dictionary_values.js +22 -0
- package/dist/esm/queries/for_ObservableQueryMultiplexer/when_building_a_subscription_request/with_dictionary_values.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/validation/ValidationResult.d.ts.map +1 -1
- package/dist/esm/validation/ValidationResult.js +4 -1
- package/dist/esm/validation/ValidationResult.js.map +1 -1
- package/dist/esm/validation/ValidationResultReasonDetail.d.ts +4 -0
- package/dist/esm/validation/ValidationResultReasonDetail.d.ts.map +1 -0
- package/dist/esm/validation/ValidationResultReasonDetail.js +13 -0
- package/dist/esm/validation/ValidationResultReasonDetail.js.map +1 -0
- package/dist/esm/validation/index.d.ts +1 -0
- package/dist/esm/validation/index.d.ts.map +1 -1
- package/dist/esm/validation/index.js +1 -0
- package/dist/esm/validation/index.js.map +1 -1
- package/for_UrlHelpers/when_building_query_params/with_object_values.ts +30 -0
- package/package.json +1 -1
- package/queries/ObservableQueryMultiplexer.ts +2 -1
- package/queries/for_ObservableQueryMultiplexer/when_building_a_subscription_request/with_dictionary_values.ts +27 -0
- package/validation/ValidationResult.ts +4 -1
- package/validation/ValidationResultReasonDetail.ts +13 -0
- package/validation/index.ts +1 -0
package/UrlHelpers.ts
CHANGED
|
@@ -13,6 +13,25 @@ function formatQueryValue(value: unknown): string {
|
|
|
13
13
|
return String(value);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function formatHttpQueryValue(value: unknown): string {
|
|
17
|
+
return value instanceof Date ? formatQueryValue(value) : formatObjectQueryValue(value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isPlainObject(value: unknown): boolean {
|
|
21
|
+
if (value === null || typeof value !== 'object') return false;
|
|
22
|
+
const prototype = Object.getPrototypeOf(value);
|
|
23
|
+
return prototype === Object.prototype || prototype === null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Serialize plain query argument objects as JSON while retaining JS coercion for other values.
|
|
28
|
+
* @param {unknown} value The argument value.
|
|
29
|
+
* @returns {string} The serialized value.
|
|
30
|
+
*/
|
|
31
|
+
export function formatObjectQueryValue(value: unknown): string {
|
|
32
|
+
return isPlainObject(value) ? JSON.stringify(value) : String(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
16
35
|
export class UrlHelpers {
|
|
17
36
|
/**
|
|
18
37
|
* Creates a URL from the given origin, API base path, and route.
|
|
@@ -81,7 +100,7 @@ export class UrlHelpers {
|
|
|
81
100
|
queryParams.append(key, formatQueryValue(item));
|
|
82
101
|
}
|
|
83
102
|
} else {
|
|
84
|
-
queryParams.set(key,
|
|
103
|
+
queryParams.set(key, formatHttpQueryValue(value));
|
|
85
104
|
}
|
|
86
105
|
}
|
|
87
106
|
}
|
package/commands/Command.ts
CHANGED
|
@@ -12,6 +12,8 @@ import { GetHttpHeaders } from '../GetHttpHeaders.js';
|
|
|
12
12
|
import { PropertyDescriptor } from '../reflection/PropertyDescriptor.js';
|
|
13
13
|
import { ValidationResult } from '../validation/ValidationResult.js';
|
|
14
14
|
import { ValidationResultSeverity } from '../validation/ValidationResultSeverity.js';
|
|
15
|
+
import { ValidationResultReason } from '../validation/ValidationResultReason.js';
|
|
16
|
+
import { ValidationResultReasonDetail } from '../validation/ValidationResultReasonDetail.js';
|
|
15
17
|
|
|
16
18
|
type Callback = {
|
|
17
19
|
callback: WeakRef<PropertyChanged>;
|
|
@@ -20,6 +22,8 @@ type Callback = {
|
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Represents an implementation of {@link ICommand} that works with HTTP fetch.
|
|
25
|
+
* Missing required properties produce a {@link ValidationResultReason.Rule} result with
|
|
26
|
+
* {@link ValidationResultReasonDetail.Required}, without contacting the server.
|
|
23
27
|
*/
|
|
24
28
|
export abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {
|
|
25
29
|
private _microservice: string;
|
|
@@ -175,7 +179,9 @@ export abstract class Command<TCommandContent = object, TCommandResponse = objec
|
|
|
175
179
|
ValidationResultSeverity.Error,
|
|
176
180
|
`${propertyDescriptor.name} is required`,
|
|
177
181
|
[propertyDescriptor.name],
|
|
178
|
-
null
|
|
182
|
+
null,
|
|
183
|
+
ValidationResultReason.Rule,
|
|
184
|
+
ValidationResultReasonDetail.Required
|
|
179
185
|
));
|
|
180
186
|
}
|
|
181
187
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
4
|
import { given } from '../../../given.js';
|
|
5
|
+
import { ValidationResultReason, ValidationResultReasonDetail } from '../../../validation/index.js';
|
|
5
6
|
import { CommandResult } from '../../CommandResult.js';
|
|
6
7
|
import { a_command } from '../given/a_command.js';
|
|
7
8
|
|
|
@@ -25,5 +26,7 @@ describe("when validating with null required property", given(class extends a_co
|
|
|
25
26
|
it("should return invalid result", () => result.isValid.should.be.false);
|
|
26
27
|
it("should have validation error", () => result.validationResults.length.should.equal(1));
|
|
27
28
|
it("should have validation message for property", () => result.validationResults[0].message.should.equal('someProperty is required'));
|
|
28
|
-
it("should have validation member for property", () => result.validationResults[0].members
|
|
29
|
+
it("should have validation member for property", () => result.validationResults[0].members.should.deep.equal(['someProperty']));
|
|
30
|
+
it("should identify a rule rejection", () => result.validationResults[0].reason.should.equal(ValidationResultReason.Rule));
|
|
31
|
+
it("should identify a required property rejection", () => result.validationResults[0].reasonDetail!.should.equal(ValidationResultReasonDetail.Required));
|
|
29
32
|
}));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
4
|
import { given } from '../../../given.js';
|
|
5
|
+
import { ValidationResultReason, ValidationResultReasonDetail, ValidationResultSeverity } from '../../../validation/index.js';
|
|
5
6
|
import { CommandResult } from '../../CommandResult.js';
|
|
6
7
|
import { a_command } from '../given/a_command.js';
|
|
7
8
|
|
|
@@ -24,5 +25,10 @@ describe("when validating with required property missing", given(class extends a
|
|
|
24
25
|
it("should not call server", () => context.fetchStub.called.should.be.false);
|
|
25
26
|
it("should return invalid result", () => result.isValid.should.be.false);
|
|
26
27
|
it("should have validation error", () => result.validationResults.length.should.equal(1));
|
|
27
|
-
it("should have error for missing property", () => result.validationResults[0].members
|
|
28
|
+
it("should have error for missing property", () => result.validationResults[0].members.should.deep.equal(['someProperty']));
|
|
29
|
+
it("should identify a rule rejection", () => result.validationResults[0].reason.should.equal(ValidationResultReason.Rule));
|
|
30
|
+
it("should identify a required property rejection", () => result.validationResults[0].reasonDetail!.should.equal(ValidationResultReasonDetail.Required));
|
|
31
|
+
it("should preserve the message", () => result.validationResults[0].message.should.equal('someProperty is required'));
|
|
32
|
+
it("should preserve the severity", () => result.validationResults[0].severity.should.equal(ValidationResultSeverity.Error));
|
|
33
|
+
it("should preserve the state", () => (result.validationResults[0].state === null).should.be.true);
|
|
28
34
|
}));
|
package/dist/cjs/UrlHelpers.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlHelpers.d.ts","sourceRoot":"","sources":["../../UrlHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UrlHelpers.d.ts","sourceRoot":"","sources":["../../UrlHelpers.ts"],"names":[],"mappings":"AA8BA,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7D;AAED,qBAAa,UAAU;IAQnB,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAM5E;IASD,MAAM,CAAC,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;KAAE,CA0B9H;IASD,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,eAAe,CAsBrH;CACJ"}
|
package/dist/cjs/UrlHelpers.js
CHANGED
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
}
|
|
13
13
|
return String(value);
|
|
14
14
|
}
|
|
15
|
+
function formatHttpQueryValue(value) {
|
|
16
|
+
return value instanceof Date ? formatQueryValue(value) : formatObjectQueryValue(value);
|
|
17
|
+
}
|
|
18
|
+
function isPlainObject(value) {
|
|
19
|
+
if (value === null || typeof value !== 'object') return false;
|
|
20
|
+
const prototype = Object.getPrototypeOf(value);
|
|
21
|
+
return prototype === Object.prototype || prototype === null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Serialize plain query argument objects as JSON while retaining JS coercion for other values.
|
|
25
|
+
* @param {unknown} value The argument value.
|
|
26
|
+
* @returns {string} The serialized value.
|
|
27
|
+
*/ function formatObjectQueryValue(value) {
|
|
28
|
+
return isPlainObject(value) ? JSON.stringify(value) : String(value);
|
|
29
|
+
}
|
|
15
30
|
class UrlHelpers {
|
|
16
31
|
/**
|
|
17
32
|
* Creates a URL from the given origin, API base path, and route.
|
|
@@ -76,7 +91,7 @@ class UrlHelpers {
|
|
|
76
91
|
queryParams.append(key, formatQueryValue(item));
|
|
77
92
|
}
|
|
78
93
|
} else {
|
|
79
|
-
queryParams.set(key,
|
|
94
|
+
queryParams.set(key, formatHttpQueryValue(value));
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
97
|
}
|
|
@@ -90,4 +105,5 @@ class UrlHelpers {
|
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
exports.UrlHelpers = UrlHelpers;
|
|
108
|
+
exports.formatObjectQueryValue = formatObjectQueryValue;
|
|
93
109
|
//# sourceMappingURL=UrlHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlHelpers.js","sources":["../../UrlHelpers.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\n/**\n * Format a single query / route parameter value into a string the .NET TypeConverter\n * infrastructure can round-trip. Date values are emitted as ISO 8601 so DateTimeOffset\n * binding succeeds; everything else falls back to the JS String coercion.\n */\nfunction formatQueryValue(value: unknown): string {\n if (value instanceof Date) {\n return value.toISOString();\n }\n return String(value);\n}\n\nexport class UrlHelpers {\n /**\n * Creates a URL from the given origin, API base path, and route.\n * @param origin The origin of the request. If not provided, it defaults to the current document's origin.\n * @param apiBasePath The base path for the API.\n * @param route The specific route for the request.\n * @returns The constructed URL.\n */\n static createUrlFrom(origin: string, apiBasePath: string, route: string): URL {\n if ((!origin || origin.length === 0) && typeof document !== 'undefined') {\n origin = document.location?.origin ?? '';\n }\n\n return new URL(route, `${origin}${apiBasePath}`);\n }\n\n /**\n * Replaces route parameters in the route template with values from the parameters object.\n * Returns both the updated route and the parameters that were not used in the route.\n * @param route The route template with placeholders like {paramName}.\n * @param parameters The parameters to replace in the route.\n * @returns An object containing the updated route and unused parameters.\n */\n static replaceRouteParameters<T extends object>(route: string, parameters?: T): { route: string; unusedParameters: Partial<T> } {\n if (!parameters) {\n return { route, unusedParameters: {} };\n }\n\n let result = route;\n const unusedParameters: Partial<T> = { ...parameters };\n\n for (const [key, value] of Object.entries(parameters)) {\n // Array values cannot be encoded as a single route segment — leave them as unused so\n // they are serialized as repeated query string parameters (e.g. ?ids=1&ids=2&ids=3).\n if (Array.isArray(value)) {\n continue;\n }\n\n const escapedKey = key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pattern = new RegExp(`\\\\{${escapedKey}\\\\}`, 'gi');\n const newRoute = result.replace(pattern, encodeURIComponent(formatQueryValue(value)));\n\n if (newRoute !== result) {\n delete unusedParameters[key as keyof T];\n result = newRoute;\n }\n }\n\n return { route: result, unusedParameters };\n }\n\n /**\n * Builds URLSearchParams from the given parameters and additional query parameters.\n * Array values are serialized as repeated key=value pairs (e.g. ?ids=1&ids=2&ids=3).\n * @param unusedParameters Parameters that were not used in route replacement.\n * @param additionalParams Additional query parameters to include.\n * @returns URLSearchParams containing all parameters.\n */\n static buildQueryParams(unusedParameters: object, additionalParams?: Record<string, string | number>): URLSearchParams {\n const queryParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(unusedParameters)) {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n for (const item of value) {\n queryParams.append(key, formatQueryValue(item));\n }\n } else {\n queryParams.set(key,
|
|
1
|
+
{"version":3,"file":"UrlHelpers.js","sources":["../../UrlHelpers.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\n/**\n * Format a single query / route parameter value into a string the .NET TypeConverter\n * infrastructure can round-trip. Date values are emitted as ISO 8601 so DateTimeOffset\n * binding succeeds; everything else falls back to the JS String coercion.\n */\nfunction formatQueryValue(value: unknown): string {\n if (value instanceof Date) {\n return value.toISOString();\n }\n return String(value);\n}\n\nfunction formatHttpQueryValue(value: unknown): string {\n return value instanceof Date ? formatQueryValue(value) : formatObjectQueryValue(value);\n}\n\nfunction isPlainObject(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Serialize plain query argument objects as JSON while retaining JS coercion for other values.\n * @param {unknown} value The argument value.\n * @returns {string} The serialized value.\n */\nexport function formatObjectQueryValue(value: unknown): string {\n return isPlainObject(value) ? JSON.stringify(value) : String(value);\n}\n\nexport class UrlHelpers {\n /**\n * Creates a URL from the given origin, API base path, and route.\n * @param origin The origin of the request. If not provided, it defaults to the current document's origin.\n * @param apiBasePath The base path for the API.\n * @param route The specific route for the request.\n * @returns The constructed URL.\n */\n static createUrlFrom(origin: string, apiBasePath: string, route: string): URL {\n if ((!origin || origin.length === 0) && typeof document !== 'undefined') {\n origin = document.location?.origin ?? '';\n }\n\n return new URL(route, `${origin}${apiBasePath}`);\n }\n\n /**\n * Replaces route parameters in the route template with values from the parameters object.\n * Returns both the updated route and the parameters that were not used in the route.\n * @param route The route template with placeholders like {paramName}.\n * @param parameters The parameters to replace in the route.\n * @returns An object containing the updated route and unused parameters.\n */\n static replaceRouteParameters<T extends object>(route: string, parameters?: T): { route: string; unusedParameters: Partial<T> } {\n if (!parameters) {\n return { route, unusedParameters: {} };\n }\n\n let result = route;\n const unusedParameters: Partial<T> = { ...parameters };\n\n for (const [key, value] of Object.entries(parameters)) {\n // Array values cannot be encoded as a single route segment — leave them as unused so\n // they are serialized as repeated query string parameters (e.g. ?ids=1&ids=2&ids=3).\n if (Array.isArray(value)) {\n continue;\n }\n\n const escapedKey = key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pattern = new RegExp(`\\\\{${escapedKey}\\\\}`, 'gi');\n const newRoute = result.replace(pattern, encodeURIComponent(formatQueryValue(value)));\n\n if (newRoute !== result) {\n delete unusedParameters[key as keyof T];\n result = newRoute;\n }\n }\n\n return { route: result, unusedParameters };\n }\n\n /**\n * Builds URLSearchParams from the given parameters and additional query parameters.\n * Array values are serialized as repeated key=value pairs (e.g. ?ids=1&ids=2&ids=3).\n * @param unusedParameters Parameters that were not used in route replacement.\n * @param additionalParams Additional query parameters to include.\n * @returns URLSearchParams containing all parameters.\n */\n static buildQueryParams(unusedParameters: object, additionalParams?: Record<string, string | number>): URLSearchParams {\n const queryParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(unusedParameters)) {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n for (const item of value) {\n queryParams.append(key, formatQueryValue(item));\n }\n } else {\n queryParams.set(key, formatHttpQueryValue(value));\n }\n }\n }\n\n if (additionalParams) {\n for (const [key, value] of Object.entries(additionalParams)) {\n queryParams.set(key, formatQueryValue(value));\n }\n }\n\n return queryParams;\n }\n}\n"],"names":["formatQueryValue","value","Date","toISOString","String","formatHttpQueryValue","formatObjectQueryValue","isPlainObject","prototype","Object","getPrototypeOf","JSON","stringify","UrlHelpers","createUrlFrom","origin","apiBasePath","route","length","document","location","URL","replaceRouteParameters","parameters","unusedParameters","result","key","entries","Array","isArray","escapedKey","replace","pattern","RegExp","newRoute","encodeURIComponent","buildQueryParams","additionalParams","queryParams","URLSearchParams","undefined","item","append","set"],"mappings":";;AAAA;AACA;AAEA;;;;IAKA,SAASA,iBAAiBC,KAAc,EAAA;AACpC,IAAA,IAAIA,iBAAiBC,IAAAA,EAAM;AACvB,QAAA,OAAOD,MAAME,WAAW,EAAA;AAC5B,IAAA;AACA,IAAA,OAAOC,MAAAA,CAAOH,KAAAA,CAAAA;AAClB;AAEA,SAASI,qBAAqBJ,KAAc,EAAA;AACxC,IAAA,OAAOA,KAAAA,YAAiBC,IAAAA,GAAOF,gBAAAA,CAAiBC,KAAAA,CAAAA,GAASK,sBAAAA,CAAuBL,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O;oBACHH,WAAAA,CAAYK,GAAG,CAACjB,GAAAA,EAAKrB,oBAAAA,CAAqBJ,KAAAA,CAAAA,CAAAA;AAC9C,gBAAA;AACJ,YAAA;AACJ,QAAA;AAEA,QAAA,IAAIoC,gBAAAA,EAAkB;YAClB,KAAK,MAAM,CAACX,GAAAA,EAAKzB,KAAAA,CAAM,IAAIQ,MAAAA,CAAOkB,OAAO,CAACU,gBAAAA,CAAAA,CAAmB;gBACzDC,WAAAA,CAAYK,GAAG,CAACjB,GAAAA,EAAK1B,gBAAAA,CAAiBC,KAAAA,CAAAA,CAAAA;AAC1C,YAAA;AACJ,QAAA;QAEA,OAAOqC,WAAAA;AACX,IAAA;AACJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../commands/Command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAInE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../commands/Command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAInE,OAAO,EAAE,cA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EAAE,wBAAwB,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAwB5H;IAGK,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CA2BzD;IAGD,kBAAkB,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAwBpD;IAED,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,0BAA0B;IAoBlC,OAAO,CAAC,iCAAiC;IAczC,OAAO,CAAC,YAAY;YAuBN,cAAc;IA+B5B,KAAK,IAAI,IAAI,CAOZ;IAGD,gBAAgB,CAAC,MAAM,EAAE,eAAe,QASvC;IAGD,iCAAiC,SAQhC;IAGD,aAAa,IAAI,IAAI,CAKpB;IAGD,IAAI,UAAU,YAEb;IAGD,eAAe,CAAC,QAAQ,EAAE,MAAM,QAY/B;IAGD,iBAAiB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAK3D;IAED,OAAO,CAAC,gBAAgB;CAM3B"}
|
|
@@ -7,11 +7,15 @@ var joinPaths = require('../joinPaths.js');
|
|
|
7
7
|
var UrlHelpers = require('../UrlHelpers.js');
|
|
8
8
|
var ValidationResult = require('../validation/ValidationResult.js');
|
|
9
9
|
var ValidationResultSeverity = require('../validation/ValidationResultSeverity.js');
|
|
10
|
+
var ValidationResultReason = require('../validation/ValidationResultReason.js');
|
|
11
|
+
var ValidationResultReasonDetail = require('../validation/ValidationResultReasonDetail.js');
|
|
10
12
|
|
|
11
13
|
// Copyright (c) Cratis. All rights reserved.
|
|
12
14
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
13
15
|
/**
|
|
14
16
|
* Represents an implementation of {@link ICommand} that works with HTTP fetch.
|
|
17
|
+
* Missing required properties produce a {@link ValidationResultReason.Rule} result with
|
|
18
|
+
* {@link ValidationResultReasonDetail.Required}, without contacting the server.
|
|
15
19
|
*/ class Command {
|
|
16
20
|
_responseType;
|
|
17
21
|
_isResponseTypeEnumerable;
|
|
@@ -140,7 +144,7 @@ var ValidationResultSeverity = require('../validation/ValidationResultSeverity.j
|
|
|
140
144
|
if (value === undefined || value === null) {
|
|
141
145
|
validationErrors.push(new ValidationResult.ValidationResult(ValidationResultSeverity.ValidationResultSeverity.Error, `${propertyDescriptor.name} is required`, [
|
|
142
146
|
propertyDescriptor.name
|
|
143
|
-
], null));
|
|
147
|
+
], null, ValidationResultReason.ValidationResultReason.Rule, ValidationResultReasonDetail.ValidationResultReasonDetail.Required));
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","sources":["../../../commands/Command.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ICommand, PropertyChanged } from './ICommand.js';\nimport { CommandResult } from \"./CommandResult.js\";\nimport { CommandValidator } from './CommandValidator.js';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { Globals } from '../Globals.js';\nimport { joinPaths } from '../joinPaths.js';\nimport { UrlHelpers } from '../UrlHelpers.js';\nimport { GetHttpHeaders } from '../GetHttpHeaders.js';\nimport { PropertyDescriptor } from '../reflection/PropertyDescriptor.js';\nimport { ValidationResult } from '../validation/ValidationResult.js';\nimport { ValidationResultSeverity } from '../validation/ValidationResultSeverity.js';\n\ntype Callback = {\n callback: WeakRef<PropertyChanged>;\n thisArg: WeakRef<object>;\n}\n\n/**\n * Represents an implementation of {@link ICommand} that works with HTTP fetch.\n */\nexport abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _httpHeadersCallback: GetHttpHeaders;\n abstract readonly route: string;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n readonly validation?: CommandValidator<any>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n readonly roles: string[] = [];\n /** Inclusive minimum blocking severity declared by a model-bound command proxy. */\n readonly blockOnValidationSeverity?: ValidationResultSeverity;\n abstract readonly propertyDescriptors: PropertyDescriptor[];\n abstract get requestParameters(): string[];\n\n private _initialValues: object = {};\n private _hasChanges = false;\n private _callbacks: Callback[] = [];\n\n /**\n * Initializes a new instance of the {@link Command<,>} class.\n * @param _responseType Type of response.\n * @param _isResponseTypeEnumerable Whether or not the response type is enumerable.\n */\n constructor(readonly _responseType: Constructor = Object, readonly _isResponseTypeEnumerable: boolean) {\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n async execute(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors, allowedSeverity, ignoreWarnings);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors, allowedSeverity, ignoreWarnings);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n const result = await this.performRequest(actualRoute, 'Command not found at route', 'Error during server call', allowedSeverity, ignoreWarnings);\n this.setInitialValuesFromCurrentValues();\n return result;\n }\n\n /** @inheritdoc */\n async validate(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n actualRoute = `${actualRoute}/validate`;\n const result = await this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');\n if (result.isSuccess && clientValidationErrors.length > 0) {\n return Object.assign(result, { validationResults: [...result.validationResults, ...clientValidationErrors] });\n }\n return result;\n }\n\n /** @inheritdoc */\n validateClientSide(): CommandResult<TCommandResponse> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n const advisoryResults = [...clientValidationErrors, ...validationErrors];\n if (advisoryResults.length === 0) {\n return CommandResult.empty as CommandResult<TCommandResponse>;\n }\n\n return new CommandResult({\n ...CommandResult.empty,\n correlationId: CommandResult.empty.correlationId.toString(),\n validationResults: advisoryResults,\n response: null\n }, Object, false) as CommandResult<TCommandResponse>;\n }\n\n private buildPayload(): object {\n const payload = {};\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n payload[property] = this[property];\n });\n return payload;\n }\n\n private validateRequiredProperties(): ValidationResult[] {\n const validationErrors: ValidationResult[] = [];\n this.propertyDescriptors.forEach(propertyDescriptor => {\n if (!propertyDescriptor.isOptional && !this.requestParameters.includes(propertyDescriptor.name)) {\n const value = this[propertyDescriptor.name];\n if (value === undefined || value === null) {\n validationErrors.push(new ValidationResult(\n ValidationResultSeverity.Error,\n `${propertyDescriptor.name} is required`,\n [propertyDescriptor.name],\n null\n ));\n }\n }\n });\n return validationErrors;\n }\n\n private filterValidationResultsBySeverity(validationResults: ValidationResult[], allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): ValidationResult[] {\n if (this.blockOnValidationSeverity !== undefined) {\n const effectiveAllowed = Math.min(allowedSeverity ?? ValidationResultSeverity.Error, this.blockOnValidationSeverity - 1);\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Unknown || result.severity > effectiveAllowed);\n }\n if (ignoreWarnings === true) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n if (allowedSeverity === undefined) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n return validationResults.filter(result => result.severity > allowedSeverity);\n }\n\n private buildHeaders(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): HeadersInit {\n const customHeaders = this._httpHeadersCallback?.() ?? {};\n const headers = {\n ...customHeaders,\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n if (allowedSeverity !== undefined) {\n headers['X-Allowed-Severity'] = allowedSeverity.toString();\n }\n\n if (ignoreWarnings === true) {\n headers['X-Ignore-Warnings'] = 'true';\n }\n\n return headers;\n }\n\n private async performRequest(\n route: string,\n notFoundMessage: string,\n errorMessage: string,\n allowedSeverity?: ValidationResultSeverity,\n ignoreWarnings?: boolean\n ): Promise<CommandResult<TCommandResponse>> {\n const payload = this.buildPayload();\n const headers = this.buildHeaders(allowedSeverity, ignoreWarnings);\n const actualRoute = joinPaths(this._apiBasePath, route);\n const url = UrlHelpers.createUrlFrom(this._origin, this._apiBasePath, actualRoute);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JsonSerializer.serialize(payload)\n });\n\n if (response.status === 404) {\n return CommandResult.failed([`${notFoundMessage} '${actualRoute}'`]) as CommandResult<TCommandResponse>;\n }\n\n const result = await response.json();\n return new CommandResult(result, this._responseType, this._isResponseTypeEnumerable);\n } catch (ex) {\n return CommandResult.failed([`${errorMessage}: ${ex}`]) as CommandResult<TCommandResponse>;\n }\n }\n\n /** @inheritdoc */\n clear(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = undefined;\n });\n this._initialValues = {};\n this._hasChanges = false;\n }\n\n /** @inheritdoc */\n setInitialValues(values: TCommandContent) {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (Object.prototype.hasOwnProperty.call(values, property)) {\n this._initialValues[property] = values[property];\n this[property] = values[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n setInitialValuesFromCurrentValues() {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (this[property]) {\n this._initialValues[property] = this[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n revertChanges(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = this._initialValues[property];\n });\n }\n\n /** @inheritdoc */\n get hasChanges() {\n return this._hasChanges;\n }\n\n /** @inheritdoc */\n propertyChanged(property: string) {\n this.updateHasChanges();\n\n this._callbacks.forEach(callbackContainer => {\n const callback = callbackContainer.callback.deref();\n const thisArg = callbackContainer.thisArg.deref();\n if (callback && thisArg) {\n callback.call(thisArg, property);\n } else {\n this._callbacks = this._callbacks.filter(_ => _.callback !== callbackContainer.callback);\n }\n });\n }\n\n /** @inheritdoc */\n onPropertyChanged(callback: PropertyChanged, thisArg: object) {\n this._callbacks.push({\n callback: new WeakRef(callback),\n thisArg: new WeakRef(thisArg)\n });\n }\n\n private updateHasChanges() {\n this._hasChanges = this.propertyDescriptors.some(propertyDescriptor => {\n const property = propertyDescriptor.name;\n return this[property] !== this._initialValues[property];\n });\n }\n}\n"],"names":["Command","_microservice","_apiBasePath","_origin","_httpHeadersCallback","validation","roles","blockOnValidationSeverity","_initialValues","_hasChanges","_callbacks","_responseType","Object","_isResponseTypeEnumerable","Globals","microservice","apiBasePath","origin","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","execute","allowedSeverity","ignoreWarnings","clientValidationErrors","validate","filteredClientErrors","filterValidationResultsBySeverity","length","CommandResult","validationFailed","validationErrors","validateRequiredProperties","filteredRequiredErrors","actualRoute","route","requestParameters","payload","buildPayload","UrlHelpers","replaceRouteParameters","result","performRequest","setInitialValuesFromCurrentValues","isSuccess","assign","validationResults","validateClientSide","advisoryResults","empty","correlationId","toString","response","propertyDescriptors","forEach","propertyDescriptor","property","name","isOptional","includes","value","undefined","push","ValidationResult","ValidationResultSeverity","Error","effectiveAllowed","Math","min","filter","severity","Unknown","buildHeaders","customHeaders","headers","microserviceHttpHeader","notFoundMessage","errorMessage","joinPaths","url","createUrlFrom","fetch","method","body","JsonSerializer","serialize","status","failed","json","ex","clear","setInitialValues","values","prototype","hasOwnProperty","call","updateHasChanges","revertChanges","hasChanges","propertyChanged","callbackContainer","deref","thisArg","_","onPropertyChanged","WeakRef","some"],"mappings":";;;;;;;;;;AAAA;AACA;AAmBA;;AAEC,IACM,MAAeA,OAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,oBAAAA;4DAGR,UAASC;AAC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"version":3,"file":"Command.js","sources":["../../../commands/Command.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ICommand, PropertyChanged } from './ICommand.js';\nimport { CommandResult } from \"./CommandResult.js\";\nimport { CommandValidator } from './CommandValidator.js';\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\nimport { Globals } from '../Globals.js';\nimport { joinPaths } from '../joinPaths.js';\nimport { UrlHelpers } from '../UrlHelpers.js';\nimport { GetHttpHeaders } from '../GetHttpHeaders.js';\nimport { PropertyDescriptor } from '../reflection/PropertyDescriptor.js';\nimport { ValidationResult } from '../validation/ValidationResult.js';\nimport { ValidationResultSeverity } from '../validation/ValidationResultSeverity.js';\nimport { ValidationResultReason } from '../validation/ValidationResultReason.js';\nimport { ValidationResultReasonDetail } from '../validation/ValidationResultReasonDetail.js';\n\ntype Callback = {\n callback: WeakRef<PropertyChanged>;\n thisArg: WeakRef<object>;\n}\n\n/**\n * Represents an implementation of {@link ICommand} that works with HTTP fetch.\n * Missing required properties produce a {@link ValidationResultReason.Rule} result with\n * {@link ValidationResultReasonDetail.Required}, without contacting the server.\n */\nexport abstract class Command<TCommandContent = object, TCommandResponse = object> implements ICommand<TCommandContent, TCommandResponse> {\n private _microservice: string;\n private _apiBasePath: string;\n private _origin: string;\n private _httpHeadersCallback: GetHttpHeaders;\n abstract readonly route: string;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n readonly validation?: CommandValidator<any>;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n readonly roles: string[] = [];\n /** Inclusive minimum blocking severity declared by a model-bound command proxy. */\n readonly blockOnValidationSeverity?: ValidationResultSeverity;\n abstract readonly propertyDescriptors: PropertyDescriptor[];\n abstract get requestParameters(): string[];\n\n private _initialValues: object = {};\n private _hasChanges = false;\n private _callbacks: Callback[] = [];\n\n /**\n * Initializes a new instance of the {@link Command<,>} class.\n * @param _responseType Type of response.\n * @param _isResponseTypeEnumerable Whether or not the response type is enumerable.\n */\n constructor(readonly _responseType: Constructor = Object, readonly _isResponseTypeEnumerable: boolean) {\n this._microservice = Globals.microservice ?? '';\n this._apiBasePath = Globals.apiBasePath ?? '';\n this._origin = Globals.origin ?? '';\n this._httpHeadersCallback = () => ({});\n }\n\n /** @inheritdoc */\n setMicroservice(microservice: string) {\n this._microservice = microservice;\n }\n\n /** @inheritdoc */\n setApiBasePath(apiBasePath: string): void {\n this._apiBasePath = apiBasePath;\n }\n\n /** @inheritdoc */\n setOrigin(origin: string): void {\n this._origin = origin;\n }\n\n /** @inheritdoc */\n setHttpHeadersCallback(callback: GetHttpHeaders): void {\n this._httpHeadersCallback = callback;\n }\n\n /** @inheritdoc */\n async execute(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors, allowedSeverity, ignoreWarnings);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors, allowedSeverity, ignoreWarnings);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n const result = await this.performRequest(actualRoute, 'Command not found at route', 'Error during server call', allowedSeverity, ignoreWarnings);\n this.setInitialValuesFromCurrentValues();\n return result;\n }\n\n /** @inheritdoc */\n async validate(): Promise<CommandResult<TCommandResponse>> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n let actualRoute = this.route;\n\n if (this.requestParameters && this.requestParameters.length > 0) {\n const payload = this.buildPayload();\n const { route } = UrlHelpers.replaceRouteParameters(this.route, payload);\n actualRoute = route;\n }\n\n actualRoute = `${actualRoute}/validate`;\n const result = await this.performRequest(actualRoute, 'Command validation endpoint not found at route', 'Error during validation call');\n if (result.isSuccess && clientValidationErrors.length > 0) {\n return Object.assign(result, { validationResults: [...result.validationResults, ...clientValidationErrors] });\n }\n return result;\n }\n\n /** @inheritdoc */\n validateClientSide(): CommandResult<TCommandResponse> {\n const clientValidationErrors = this.validation?.validate(this) || [];\n const filteredClientErrors = this.filterValidationResultsBySeverity(clientValidationErrors);\n if (filteredClientErrors.length > 0) {\n return CommandResult.validationFailed(filteredClientErrors) as CommandResult<TCommandResponse>;\n }\n\n const validationErrors = this.validateRequiredProperties();\n const filteredRequiredErrors = this.filterValidationResultsBySeverity(validationErrors);\n if (filteredRequiredErrors.length > 0) {\n return CommandResult.validationFailed(filteredRequiredErrors) as CommandResult<TCommandResponse>;\n }\n\n const advisoryResults = [...clientValidationErrors, ...validationErrors];\n if (advisoryResults.length === 0) {\n return CommandResult.empty as CommandResult<TCommandResponse>;\n }\n\n return new CommandResult({\n ...CommandResult.empty,\n correlationId: CommandResult.empty.correlationId.toString(),\n validationResults: advisoryResults,\n response: null\n }, Object, false) as CommandResult<TCommandResponse>;\n }\n\n private buildPayload(): object {\n const payload = {};\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n payload[property] = this[property];\n });\n return payload;\n }\n\n private validateRequiredProperties(): ValidationResult[] {\n const validationErrors: ValidationResult[] = [];\n this.propertyDescriptors.forEach(propertyDescriptor => {\n if (!propertyDescriptor.isOptional && !this.requestParameters.includes(propertyDescriptor.name)) {\n const value = this[propertyDescriptor.name];\n if (value === undefined || value === null) {\n validationErrors.push(new ValidationResult(\n ValidationResultSeverity.Error,\n `${propertyDescriptor.name} is required`,\n [propertyDescriptor.name],\n null,\n ValidationResultReason.Rule,\n ValidationResultReasonDetail.Required\n ));\n }\n }\n });\n return validationErrors;\n }\n\n private filterValidationResultsBySeverity(validationResults: ValidationResult[], allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): ValidationResult[] {\n if (this.blockOnValidationSeverity !== undefined) {\n const effectiveAllowed = Math.min(allowedSeverity ?? ValidationResultSeverity.Error, this.blockOnValidationSeverity - 1);\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Unknown || result.severity > effectiveAllowed);\n }\n if (ignoreWarnings === true) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n if (allowedSeverity === undefined) {\n return validationResults.filter(result => result.severity === ValidationResultSeverity.Error);\n }\n return validationResults.filter(result => result.severity > allowedSeverity);\n }\n\n private buildHeaders(allowedSeverity?: ValidationResultSeverity, ignoreWarnings?: boolean): HeadersInit {\n const customHeaders = this._httpHeadersCallback?.() ?? {};\n const headers = {\n ...customHeaders,\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n if (this._microservice?.length > 0) {\n headers[Globals.microserviceHttpHeader] = this._microservice;\n }\n\n if (allowedSeverity !== undefined) {\n headers['X-Allowed-Severity'] = allowedSeverity.toString();\n }\n\n if (ignoreWarnings === true) {\n headers['X-Ignore-Warnings'] = 'true';\n }\n\n return headers;\n }\n\n private async performRequest(\n route: string,\n notFoundMessage: string,\n errorMessage: string,\n allowedSeverity?: ValidationResultSeverity,\n ignoreWarnings?: boolean\n ): Promise<CommandResult<TCommandResponse>> {\n const payload = this.buildPayload();\n const headers = this.buildHeaders(allowedSeverity, ignoreWarnings);\n const actualRoute = joinPaths(this._apiBasePath, route);\n const url = UrlHelpers.createUrlFrom(this._origin, this._apiBasePath, actualRoute);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JsonSerializer.serialize(payload)\n });\n\n if (response.status === 404) {\n return CommandResult.failed([`${notFoundMessage} '${actualRoute}'`]) as CommandResult<TCommandResponse>;\n }\n\n const result = await response.json();\n return new CommandResult(result, this._responseType, this._isResponseTypeEnumerable);\n } catch (ex) {\n return CommandResult.failed([`${errorMessage}: ${ex}`]) as CommandResult<TCommandResponse>;\n }\n }\n\n /** @inheritdoc */\n clear(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = undefined;\n });\n this._initialValues = {};\n this._hasChanges = false;\n }\n\n /** @inheritdoc */\n setInitialValues(values: TCommandContent) {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (Object.prototype.hasOwnProperty.call(values, property)) {\n this._initialValues[property] = values[property];\n this[property] = values[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n setInitialValuesFromCurrentValues() {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n if (this[property]) {\n this._initialValues[property] = this[property];\n }\n });\n this.updateHasChanges();\n }\n\n /** @inheritdoc */\n revertChanges(): void {\n this.propertyDescriptors.forEach(propertyDescriptor => {\n const property = propertyDescriptor.name;\n this[property] = this._initialValues[property];\n });\n }\n\n /** @inheritdoc */\n get hasChanges() {\n return this._hasChanges;\n }\n\n /** @inheritdoc */\n propertyChanged(property: string) {\n this.updateHasChanges();\n\n this._callbacks.forEach(callbackContainer => {\n const callback = callbackContainer.callback.deref();\n const thisArg = callbackContainer.thisArg.deref();\n if (callback && thisArg) {\n callback.call(thisArg, property);\n } else {\n this._callbacks = this._callbacks.filter(_ => _.callback !== callbackContainer.callback);\n }\n });\n }\n\n /** @inheritdoc */\n onPropertyChanged(callback: PropertyChanged, thisArg: object) {\n this._callbacks.push({\n callback: new WeakRef(callback),\n thisArg: new WeakRef(thisArg)\n });\n }\n\n private updateHasChanges() {\n this._hasChanges = this.propertyDescriptors.some(propertyDescriptor => {\n const property = propertyDescriptor.name;\n return this[property] !== this._initialValues[property];\n });\n }\n}\n"],"names":["Command","_microservice","_apiBasePath","_origin","_httpHeadersCallback","validation","roles","blockOnValidationSeverity","_initialValues","_hasChanges","_callbacks","_responseType","Object","_isResponseTypeEnumerable","Globals","microservice","apiBasePath","origin","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","callback","execute","allowedSeverity","ignoreWarnings","clientValidationErrors","validate","filteredClientErrors","filterValidationResultsBySeverity","length","CommandResult","validationFailed","validationErrors","validateRequiredProperties","filteredRequiredErrors","actualRoute","route","requestParameters","payload","buildPayload","UrlHelpers","replaceRouteParameters","result","performRequest","setInitialValuesFromCurrentValues","isSuccess","assign","validationResults","validateClientSide","advisoryResults","empty","correlationId","toString","response","propertyDescriptors","forEach","propertyDescriptor","property","name","isOptional","includes","value","undefined","push","ValidationResult","ValidationResultSeverity","Error","ValidationResultReason","Rule","ValidationResultReasonDetail","Required","effectiveAllowed","Math","min","filter","severity","Unknown","buildHeaders","customHeaders","headers","microserviceHttpHeader","notFoundMessage","errorMessage","joinPaths","url","createUrlFrom","fetch","method","body","JsonSerializer","serialize","status","failed","json","ex","clear","setInitialValues","values","prototype","hasOwnProperty","call","updateHasChanges","revertChanges","hasChanges","propertyChanged","callbackContainer","deref","thisArg","_","onPropertyChanged","WeakRef","some"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAqBA;;;;AAIC,IACM,MAAeA,OAAAA,CAAAA;;;IACVC,aAAAA;IACAC,YAAAA;IACAC,OAAAA;IACAC,oBAAAA;4DAGR,UAASC;AACT,2DACSC,KAAAA,GAAkB,EAAE;wFAE7B,yBAASC;AAIDC,IAAAA,cAAAA,GAAyB,EAAC;AAC1BC,IAAAA,WAAAA,GAAc,KAAA;AACdC,IAAAA,UAAAA,GAAyB,EAAE;AAEnC;;;;AAIC,QACD,YA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G,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAT/B,OAAO,CAAC,QAAQ,CAAC,CAAa;IAO9B,YACqB,KAAK,EAAE,0BAA0B,EACjC,UAAU,EAAE,MAAM,EAEtC;IAGD,IAAI,eAAe,IAAI,MAAM,CAE5B;IAGD,IAAI,cAAc,IAAI,MAAM,CAE3B;IAGD,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAM5E;IAGD,UAAU,IAAI,IAAI,CAGjB;CACJ;AAeD,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,6BAA6B,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,MAAqC,GAAG,0BAA0B,CASxL;AAMD,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAKD,wBAAgB,oBAAoB,IAAI,0BAA0B,GAAG,SAAS,CAE7E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Globals = require('../Globals.js');
|
|
4
|
+
var UrlHelpers = require('../UrlHelpers.js');
|
|
4
5
|
|
|
5
6
|
// Copyright (c) Cratis. All rights reserved.
|
|
6
7
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -101,7 +102,7 @@ var Globals = require('../Globals.js');
|
|
|
101
102
|
for (const [key, value] of Object.entries(a)){
|
|
102
103
|
if (pagingAndSortingKeys.has(key)) continue;
|
|
103
104
|
if (value === undefined || value === null) continue;
|
|
104
|
-
remaining[key] =
|
|
105
|
+
remaining[key] = UrlHelpers.formatObjectQueryValue(value);
|
|
105
106
|
hasRemaining = true;
|
|
106
107
|
}
|
|
107
108
|
if (hasRemaining) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryMultiplexer.js","sources":["../../../queries/ObservableQueryMultiplexer.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 { IObservableQueryConnection } from './IObservableQueryConnection.js';\nimport { IObservableQueryHubConnection } from './IObservableQueryHubConnection.js';\nimport { DataReceived } from './ObservableQueryConnection.js';\nimport { SubscriptionRequest } from './WebSocketHubConnection.js';\nimport { Globals } from '../Globals.js';\nimport { MultiplexerConnectionState } from './ObservableQueryDiagnosticsSnapshot.js';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * The WebSocket demultiplexer route used when connecting through the multiplexed observable query endpoint.\n */\nexport const WS_HUB_ROUTE = '/.cratis/queries/ws';\n\n/**\n * Multiplexes multiple observable query subscriptions across a bounded pool of physical\n * connections (WebSocket or SSE) to the backend demultiplexer.\n *\n * Each pool slot is a single multiplexed connection. When a new subscription is requested,\n * the slot with the fewest active queries is chosen. This balances load across N physical\n * connections while keeping the total connection count bounded.\n */\nexport class ObservableQueryMultiplexer {\n private readonly _connections: IObservableQueryHubConnection[];\n private readonly _size: number;\n\n /**\n * Initializes a new {@link ObservableQueryMultiplexer}.\n * @param {number} size Number of physical connections (pool slots).\n * @param {() => IObservableQueryHubConnection} connectionFactory Factory function to create each connection.\n */\n constructor(size: number, connectionFactory: () => IObservableQueryHubConnection) {\n this._size = Math.max(1, size);\n this._connections = Array.from({ length: this._size }, () => connectionFactory());\n }\n\n /**\n * Gets the pool size.\n */\n get size(): number {\n return this._size;\n }\n\n /**\n * Gets the best available ping latency across all connections.\n */\n get lastPingLatency(): number {\n return this._connections.reduce((min, c) =>\n c.lastPingLatency > 0 && c.lastPingLatency < min ? c.lastPingLatency : min,\n Number.MAX_SAFE_INTEGER\n );\n }\n\n /**\n * Gets the average latency across all connections.\n */\n get averageLatency(): number {\n const active = this._connections.filter(c => c.averageLatency > 0);\n if (active.length === 0) return 0;\n return active.reduce((sum, c) => sum + c.averageLatency, 0) / active.length;\n }\n\n /**\n * Subscribe to a query through the multiplexer. Picks the least-loaded connection\n * and sends a Subscribe message on it.\n * @param {string} queryName Fully qualified backend query name.\n * @param {object} queryArguments Flat query arguments (incl. page, pageSize, sortBy, sortDirection).\n * @param {DataReceived<any>} callback Callback invoked for each result.\n * @returns A cleanup function that unsubscribes from the query.\n */\n subscribe(queryName: string, queryArguments: object | undefined, callback: DataReceived<any>): () => void {\n const request = this.buildSubscriptionRequest(queryName, queryArguments);\n const conn = this.leastLoaded();\n const queryId = this.generateQueryId();\n\n conn.subscribe(queryId, request, callback);\n\n return () => {\n conn.unsubscribe(queryId);\n };\n }\n\n /**\n * Dispose all connections in the multiplexer.\n */\n dispose(): void {\n for (const conn of this._connections) {\n conn.dispose();\n }\n }\n\n private leastLoaded(): IObservableQueryHubConnection {\n return this._connections.reduce((min, c) =>\n c.queryCount < min.queryCount ? c : min, this._connections[0]);\n }\n\n private generateQueryId(): string {\n // Use crypto.randomUUID when available, fall back to timestamp + random\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;\n }\n\n private buildSubscriptionRequest(queryName: string, args?: object): SubscriptionRequest {\n const request: SubscriptionRequest = { queryName };\n\n // Always include the transfer mode so the server knows which emission strategy to use.\n request.transferMode = Globals.observableQueryTransferMode;\n\n if (!args) return request;\n\n const a = args as Record<string, any>;\n const pagingAndSortingKeys = new Set(['page', 'pageSize', 'sortBy', 'sortDirection']);\n\n if (a.page !== undefined && a.page !== null) request.page = Number(a.page);\n if (a.pageSize !== undefined && a.pageSize !== null) request.pageSize = Number(a.pageSize);\n if (a.sortBy !== undefined && a.sortBy !== null) request.sortBy = String(a.sortBy);\n if (a.sortDirection !== undefined && a.sortDirection !== null) request.sortDirection = String(a.sortDirection);\n\n // Everything else goes into arguments as string key-value pairs\n const remaining: Record<string, string | null> = {};\n let hasRemaining = false;\n\n for (const [key, value] of Object.entries(a)) {\n if (pagingAndSortingKeys.has(key)) continue;\n if (value === undefined || value === null) continue;\n remaining[key] = String(value);\n hasRemaining = true;\n }\n\n if (hasRemaining) {\n request.arguments = remaining;\n }\n\n return request;\n }\n\n /**\n * Returns a snapshot of the per-connection state for diagnostics.\n * @returns An array describing each slot in the connection pool.\n */\n getConnectionsSnapshot(): MultiplexerConnectionState[] {\n return this._connections.map((conn, index) => ({\n index,\n isConnected: conn.isConnected,\n queryCount: conn.queryCount,\n }));\n }\n}\n\n/**\n * Wraps an {@link ObservableQueryMultiplexer} subscription as an {@link IObservableQueryConnection},\n * allowing the multiplexed transport to plug into the existing query subscription pipeline\n * without changes to callers.\n */\nexport class MultiplexedObservableQueryConnection<TDataType> implements IObservableQueryConnection<TDataType> {\n private _cleanup?: () => void;\n\n /**\n * Initializes a new {@link MultiplexedObservableQueryConnection}.\n * @param {ObservableQueryMultiplexer} multiplexer The shared multiplexer.\n * @param {string} queryName The fully qualified backend query name.\n */\n constructor(\n private readonly _pool: ObservableQueryMultiplexer,\n private readonly _queryName: string,\n ) {\n }\n\n /** @inheritdoc */\n get lastPingLatency(): number {\n return this._pool.lastPingLatency;\n }\n\n /** @inheritdoc */\n get averageLatency(): number {\n return this._pool.averageLatency;\n }\n\n /** @inheritdoc */\n connect(dataReceived: DataReceived<TDataType>, queryArguments?: object): void {\n this._cleanup = this._pool.subscribe(\n this._queryName,\n queryArguments,\n dataReceived as DataReceived<any>,\n );\n }\n\n /** @inheritdoc */\n disconnect(): void {\n this._cleanup?.();\n this._cleanup = undefined;\n }\n}\n\n// ----- Shared pool singleton management -----\n\nlet _sharedMultiplexer: ObservableQueryMultiplexer | undefined;\nlet _sharedMultiplexerKey = '';\n\n/**\n * Returns the shared {@link ObservableQueryMultiplexer}, creating or re-creating it when the\n * configuration (connection count, origin, base path, microservice, transport) changes.\n * @param {() => IObservableQueryHubConnection} connectionFactory Factory to create individual connections.\n * @param {string} cacheKey A string that identifies the current configuration for invalidation.\n * @param {number} size Number of physical connections to create. Defaults to {@link Globals.queryConnectionCount}.\n * @returns The shared multiplexer instance.\n */\nexport function getOrCreateMultiplexer(connectionFactory: () => IObservableQueryHubConnection, cacheKey: string, size: number = Globals.queryConnectionCount): ObservableQueryMultiplexer {\n if (_sharedMultiplexer && _sharedMultiplexerKey === cacheKey) {\n return _sharedMultiplexer;\n }\n\n _sharedMultiplexer?.dispose();\n _sharedMultiplexer = new ObservableQueryMultiplexer(size, connectionFactory);\n _sharedMultiplexerKey = cacheKey;\n return _sharedMultiplexer;\n}\n\n/**\n * Disposes and clears the shared multiplexer singleton.\n * Intended for use in test teardown to prevent state leakage across tests.\n */\nexport function resetSharedMultiplexer(): void {\n _sharedMultiplexer?.dispose();\n _sharedMultiplexer = undefined;\n _sharedMultiplexerKey = '';\n}\n\n/**\n * Returns the current shared multiplexer instance, or {@code undefined} if none has been created yet.\n */\nexport function getSharedMultiplexer(): ObservableQueryMultiplexer | undefined {\n return _sharedMultiplexer;\n}\n"],"names":["WS_HUB_ROUTE","ObservableQueryMultiplexer","_connections","_size","size","connectionFactory","Math","max","Array","from","length","lastPingLatency","reduce","min","c","Number","MAX_SAFE_INTEGER","averageLatency","active","filter","sum","subscribe","queryName","queryArguments","callback","request","buildSubscriptionRequest","conn","leastLoaded","queryId","generateQueryId","unsubscribe","dispose","queryCount","crypto","randomUUID","Date","now","random","toString","substring","args","transferMode","Globals","observableQueryTransferMode","a","pagingAndSortingKeys","Set","page","undefined","pageSize","sortBy","String","sortDirection","remaining","hasRemaining","key","value","Object","entries","has","arguments","getConnectionsSnapshot","map","index","isConnected","MultiplexedObservableQueryConnection","_cleanup","_queryName","_pool","connect","dataReceived","disconnect","_sharedMultiplexer","_sharedMultiplexerKey","getOrCreateMultiplexer","cacheKey","queryConnectionCount","resetSharedMultiplexer","getSharedMultiplexer"],"mappings":";;;;AAAA;AACA;AASA;;IAKO,MAAMA,YAAAA,GAAe;AAE5B;;;;;;;AAOC,IACM,MAAMC,0BAAAA,CAAAA;IACQC,YAAAA;IACAC,KAAAA;AAEjB;;;;AAIC,QACD,WAAA,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EAAA;AAE5B;;;;;;;IAQO,SAASC,sBAAAA,CAAuBtE,iBAAsD,EAAEuE,QAAgB,EAAExE,IAAAA,GAAeuC,eAAAA,CAAQkC,oBAAoB,EAAA;IACxJ,IAAIJ,kBAAAA,IAAsBC,0BAA0BE,QAAAA,EAAU;QAC1D,OAAOH,kBAAAA;AACX,IAAA;IAEAA,kBAAAA,EAAoBzC,OAAAA,EAAAA;IACpByC,kBAAAA,GAAqB,IAAIxE,2BAA2BG,IAAAA,EAAMC,iBAAAA,CAAAA;IAC1DqE,qBAAAA,GAAwBE,QAAAA;IACxB,OAAOH,kBAAAA;AACX;AAEA;;;AAGC,IACM,SAASK,sBAAAA,GAAAA;IACZL,kBAAAA,EAAoBzC,OAAAA,EAAAA;IACpByC,kBAAAA,GAAqBxB,SAAAA;IACrByB,qBAAAA,GAAwB,EAAA;AAC5B;AAEA;;AAEC,IACM,SAASK,oBAAAA,GAAAA;IACZ,OAAON,kBAAAA;AACX;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ObservableQueryMultiplexer.js","sources":["../../../queries/ObservableQueryMultiplexer.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 { IObservableQueryConnection } from './IObservableQueryConnection.js';\nimport { IObservableQueryHubConnection } from './IObservableQueryHubConnection.js';\nimport { DataReceived } from './ObservableQueryConnection.js';\nimport { SubscriptionRequest } from './WebSocketHubConnection.js';\nimport { Globals } from '../Globals.js';\nimport { MultiplexerConnectionState } from './ObservableQueryDiagnosticsSnapshot.js';\nimport { formatObjectQueryValue } from '../UrlHelpers.js';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * The WebSocket demultiplexer route used when connecting through the multiplexed observable query endpoint.\n */\nexport const WS_HUB_ROUTE = '/.cratis/queries/ws';\n\n/**\n * Multiplexes multiple observable query subscriptions across a bounded pool of physical\n * connections (WebSocket or SSE) to the backend demultiplexer.\n *\n * Each pool slot is a single multiplexed connection. When a new subscription is requested,\n * the slot with the fewest active queries is chosen. This balances load across N physical\n * connections while keeping the total connection count bounded.\n */\nexport class ObservableQueryMultiplexer {\n private readonly _connections: IObservableQueryHubConnection[];\n private readonly _size: number;\n\n /**\n * Initializes a new {@link ObservableQueryMultiplexer}.\n * @param {number} size Number of physical connections (pool slots).\n * @param {() => IObservableQueryHubConnection} connectionFactory Factory function to create each connection.\n */\n constructor(size: number, connectionFactory: () => IObservableQueryHubConnection) {\n this._size = Math.max(1, size);\n this._connections = Array.from({ length: this._size }, () => connectionFactory());\n }\n\n /**\n * Gets the pool size.\n */\n get size(): number {\n return this._size;\n }\n\n /**\n * Gets the best available ping latency across all connections.\n */\n get lastPingLatency(): number {\n return this._connections.reduce((min, c) =>\n c.lastPingLatency > 0 && c.lastPingLatency < min ? c.lastPingLatency : min,\n Number.MAX_SAFE_INTEGER\n );\n }\n\n /**\n * Gets the average latency across all connections.\n */\n get averageLatency(): number {\n const active = this._connections.filter(c => c.averageLatency > 0);\n if (active.length === 0) return 0;\n return active.reduce((sum, c) => sum + c.averageLatency, 0) / active.length;\n }\n\n /**\n * Subscribe to a query through the multiplexer. Picks the least-loaded connection\n * and sends a Subscribe message on it.\n * @param {string} queryName Fully qualified backend query name.\n * @param {object} queryArguments Flat query arguments (incl. page, pageSize, sortBy, sortDirection).\n * @param {DataReceived<any>} callback Callback invoked for each result.\n * @returns A cleanup function that unsubscribes from the query.\n */\n subscribe(queryName: string, queryArguments: object | undefined, callback: DataReceived<any>): () => void {\n const request = this.buildSubscriptionRequest(queryName, queryArguments);\n const conn = this.leastLoaded();\n const queryId = this.generateQueryId();\n\n conn.subscribe(queryId, request, callback);\n\n return () => {\n conn.unsubscribe(queryId);\n };\n }\n\n /**\n * Dispose all connections in the multiplexer.\n */\n dispose(): void {\n for (const conn of this._connections) {\n conn.dispose();\n }\n }\n\n private leastLoaded(): IObservableQueryHubConnection {\n return this._connections.reduce((min, c) =>\n c.queryCount < min.queryCount ? c : min, this._connections[0]);\n }\n\n private generateQueryId(): string {\n // Use crypto.randomUUID when available, fall back to timestamp + random\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;\n }\n\n private buildSubscriptionRequest(queryName: string, args?: object): SubscriptionRequest {\n const request: SubscriptionRequest = { queryName };\n\n // Always include the transfer mode so the server knows which emission strategy to use.\n request.transferMode = Globals.observableQueryTransferMode;\n\n if (!args) return request;\n\n const a = args as Record<string, any>;\n const pagingAndSortingKeys = new Set(['page', 'pageSize', 'sortBy', 'sortDirection']);\n\n if (a.page !== undefined && a.page !== null) request.page = Number(a.page);\n if (a.pageSize !== undefined && a.pageSize !== null) request.pageSize = Number(a.pageSize);\n if (a.sortBy !== undefined && a.sortBy !== null) request.sortBy = String(a.sortBy);\n if (a.sortDirection !== undefined && a.sortDirection !== null) request.sortDirection = String(a.sortDirection);\n\n // Everything else goes into arguments as string key-value pairs\n const remaining: Record<string, string | null> = {};\n let hasRemaining = false;\n\n for (const [key, value] of Object.entries(a)) {\n if (pagingAndSortingKeys.has(key)) continue;\n if (value === undefined || value === null) continue;\n remaining[key] = formatObjectQueryValue(value);\n hasRemaining = true;\n }\n\n if (hasRemaining) {\n request.arguments = remaining;\n }\n\n return request;\n }\n\n /**\n * Returns a snapshot of the per-connection state for diagnostics.\n * @returns An array describing each slot in the connection pool.\n */\n getConnectionsSnapshot(): MultiplexerConnectionState[] {\n return this._connections.map((conn, index) => ({\n index,\n isConnected: conn.isConnected,\n queryCount: conn.queryCount,\n }));\n }\n}\n\n/**\n * Wraps an {@link ObservableQueryMultiplexer} subscription as an {@link IObservableQueryConnection},\n * allowing the multiplexed transport to plug into the existing query subscription pipeline\n * without changes to callers.\n */\nexport class MultiplexedObservableQueryConnection<TDataType> implements IObservableQueryConnection<TDataType> {\n private _cleanup?: () => void;\n\n /**\n * Initializes a new {@link MultiplexedObservableQueryConnection}.\n * @param {ObservableQueryMultiplexer} multiplexer The shared multiplexer.\n * @param {string} queryName The fully qualified backend query name.\n */\n constructor(\n private readonly _pool: ObservableQueryMultiplexer,\n private readonly _queryName: string,\n ) {\n }\n\n /** @inheritdoc */\n get lastPingLatency(): number {\n return this._pool.lastPingLatency;\n }\n\n /** @inheritdoc */\n get averageLatency(): number {\n return this._pool.averageLatency;\n }\n\n /** @inheritdoc */\n connect(dataReceived: DataReceived<TDataType>, queryArguments?: object): void {\n this._cleanup = this._pool.subscribe(\n this._queryName,\n queryArguments,\n dataReceived as DataReceived<any>,\n );\n }\n\n /** @inheritdoc */\n disconnect(): void {\n this._cleanup?.();\n this._cleanup = undefined;\n }\n}\n\n// ----- Shared pool singleton management -----\n\nlet _sharedMultiplexer: ObservableQueryMultiplexer | undefined;\nlet _sharedMultiplexerKey = '';\n\n/**\n * Returns the shared {@link ObservableQueryMultiplexer}, creating or re-creating it when the\n * configuration (connection count, origin, base path, microservice, transport) changes.\n * @param {() => IObservableQueryHubConnection} connectionFactory Factory to create individual connections.\n * @param {string} cacheKey A string that identifies the current configuration for invalidation.\n * @param {number} size Number of physical connections to create. Defaults to {@link Globals.queryConnectionCount}.\n * @returns The shared multiplexer instance.\n */\nexport function getOrCreateMultiplexer(connectionFactory: () => IObservableQueryHubConnection, cacheKey: string, size: number = Globals.queryConnectionCount): ObservableQueryMultiplexer {\n if (_sharedMultiplexer && _sharedMultiplexerKey === cacheKey) {\n return _sharedMultiplexer;\n }\n\n _sharedMultiplexer?.dispose();\n _sharedMultiplexer = new ObservableQueryMultiplexer(size, connectionFactory);\n _sharedMultiplexerKey = cacheKey;\n return _sharedMultiplexer;\n}\n\n/**\n * Disposes and clears the shared multiplexer singleton.\n * Intended for use in test teardown to prevent state leakage across tests.\n */\nexport function resetSharedMultiplexer(): void {\n _sharedMultiplexer?.dispose();\n _sharedMultiplexer = undefined;\n _sharedMultiplexerKey = '';\n}\n\n/**\n * Returns the current shared multiplexer instance, or {@code undefined} if none has been created yet.\n */\nexport function getSharedMultiplexer(): ObservableQueryMultiplexer | undefined {\n return _sharedMultiplexer;\n}\n"],"names":["WS_HUB_ROUTE","ObservableQueryMultiplexer","_connections","_size","size","connectionFactory","Math","max","Array","from","length","lastPingLatency","reduce","min","c","Number","MAX_SAFE_INTEGER","averageLatency","active","filter","sum","subscribe","queryName","queryArguments","callback","request","buildSubscriptionRequest","conn","leastLoaded","queryId","generateQueryId","unsubscribe","dispose","queryCount","crypto","randomUUID","Date","now","random","toString","substring","args","transferMode","Globals","observableQueryTransferMode","a","pagingAndSortingKeys","Set","page","undefined","pageSize","sortBy","String","sortDirection","remaining","hasRemaining","key","value","Object","entries","has","formatObjectQueryValue","arguments","getConnectionsSnapshot","map","index","isConnected","MultiplexedObservableQueryConnection","_cleanup","_queryName","_pool","connect","dataReceived","disconnect","_sharedMultiplexer","_sharedMultiplexerKey","getOrCreateMultiplexer","cacheKey","queryConnectionCount","resetSharedMultiplexer","getSharedMultiplexer"],"mappings":";;;;;AAAA;AACA;AAUA;;IAKO,MAAMA,YAAAA,GAAe;AAE5B;;;;;;;AAOC,IACM,MAAMC,0BAAAA,CAAAA;IACQC,YAAAA;IACAC,KAAAA;AAEjB;;;;AAIC,QACD,WAAA,CAAYC,IAAY,EAAEC,iBAAsD,CAAE;AAC9E,QAAA,IAAI,CAACF,KAAK,GAAGG,IAAAA,CAAKC,GAAG,CAAC,CAAA,EAAGH,IAAAA,CAAAA;AACzB,QAAA,IAAI,CAACF,YAAY,GAAGM,KAAAA,CAAMC,IAAI,CAAC;YAAEC,MAAAA,EAAQ,IAAI,CAACP;AAAM,SAAA,EAAG,IAAME,iBAAAA,EAAAA,CAAAA;AACjE,IAAA;AAEA;;AAEC,QACD,IAAID,IAAAA,GAAe;QACf,OAAO,IAAI,CAACD,KAAK;AACrB,IAAA;AAEA;;AAEC,QACD,IAAIQ,eAAAA,GAA0B;QAC1B,OAAO,IAAI,CAACT,YAAY,CAACU,MAAM,CAAC,CAACC,GAAAA,EAAKC,CA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0C,kBAAAA,GAAqBzB,SAAAA;IACrB0B,qBAAAA,GAAwB,EAAA;AAC5B;AAEA;;AAEC,IACM,SAASK,oBAAAA,GAAAA;IACZ,OAAON,kBAAAA;AACX;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResult.d.ts","sourceRoot":"","sources":["../../../validation/ValidationResult.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"ValidationResult.d.ts","sourceRoot":"","sources":["../../../validation/ValidationResult.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AASzE,qBAAa,gBAAgB;IAcrB,QAAQ,CAAC,QAAQ,EAAE,wBAAwB;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE;IAC1B,QAAQ,CAAC,KAAK,EAAE,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,sBAAsB;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM;IANlC,YACa,QAAQ,EAAE,wBAAwB,EAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,EAAE,GAAG,EACV,MAAM,GAAE,sBAAoD,EAC5D,YAAY,CAAC,EAAE,MAAM,YAAA,EACjC;CACJ"}
|
|
@@ -6,6 +6,8 @@ var ValidationResultReason = require('./ValidationResultReason.js');
|
|
|
6
6
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */ /**
|
|
8
8
|
* Represents a validation error with a message for one or more members.
|
|
9
|
+
* Client-generated missing required properties use `rule` with `ValidationResultReasonDetail.Required`.
|
|
10
|
+
* Their messages are framework diagnostics, not application-authored user-facing copy.
|
|
9
11
|
*/ class ValidationResult {
|
|
10
12
|
severity;
|
|
11
13
|
message;
|
|
@@ -16,7 +18,8 @@ var ValidationResultReason = require('./ValidationResultReason.js');
|
|
|
16
18
|
/**
|
|
17
19
|
* Initializes a new instance of the {@link ValidationResult} class.
|
|
18
20
|
* @param severity The severity of the result.
|
|
19
|
-
* @param message The message. A developer diagnostic when {@link reason} is anything but `rule
|
|
21
|
+
* @param message The message. A developer diagnostic when {@link reason} is anything but `rule`,
|
|
22
|
+
* or when the client supplies the `Required` reasonDetail.
|
|
20
23
|
* @param members The members the result is attributed to.
|
|
21
24
|
* @param state State associated with the result - the rule author's, carried straight through.
|
|
22
25
|
* @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResultReason } from './ValidationResultReason.js';\nimport { ValidationResultSeverity } from './ValidationResultSeverity.js';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule
|
|
1
|
+
{"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResultReason } from './ValidationResultReason.js';\nimport { ValidationResultSeverity } from './ValidationResultSeverity.js';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n * Client-generated missing required properties use `rule` with `ValidationResultReasonDetail.Required`.\n * Their messages are framework diagnostics, not application-authored user-facing copy.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`,\n * or when the client supplies the `Required` reasonDetail.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated\n * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.\n * Branch on this rather than matching {@link message}, which is prose and free to change.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule,\n readonly reasonDetail?: string) {\n }\n}\n"],"names":["ValidationResult","reason","ValidationResultReason","Rule","reasonDetail","severity","message","members","state"],"mappings":";;;;AAAA;AACA;AAKA;;;;AAMC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;;AACT;;;;;;;;;;;QAYA,WAAA,CACI,QAA2C,EAC3C,OAAwB,EACxB,OAA0B,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,6CAAAA,CAAuBC,IAAI,EAC5DC,YAAqB,CAAE;aALvBC,QAAAA,GAAAA,QAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,KAAAA,GAAAA,KAAAA;aACAP,MAAAA,GAAAA,MAAAA;aACAG,YAAAA,GAAAA,YAAAA;AACb,IAAA;AACJ;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationResultReasonDetail.d.ts","sourceRoot":"","sources":["../../../validation/ValidationResultReasonDetail.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B;aAKrC,QAAQ,EAAE,UAAU;CACd,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Holds well-known finer identities within a validation result's reason.
|
|
7
|
+
*/ const ValidationResultReasonDetail = {
|
|
8
|
+
/**
|
|
9
|
+
* The client found a missing required command property. Used with `rule`.
|
|
10
|
+
* The message is framework-authored; map it to your own user-facing copy.
|
|
11
|
+
*/ Required: 'Required'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.ValidationResultReasonDetail = ValidationResultReasonDetail;
|
|
15
|
+
//# sourceMappingURL=ValidationResultReasonDetail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationResultReasonDetail.js","sources":["../../../validation/ValidationResultReasonDetail.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\n/**\n * Holds well-known finer identities within a validation result's reason.\n */\nexport const ValidationResultReasonDetail = {\n /**\n * The client found a missing required command property. Used with `rule`.\n * The message is framework-authored; map it to your own user-facing copy.\n */\n Required: 'Required'\n} as const;\n"],"names":["ValidationResultReasonDetail","Required"],"mappings":";;AAAA;AACA;AAEA;;UAGaA,4BAAAA,GAA+B;AACxC;;;AAGC,QACDC,QAAAA,EAAU;AACd;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './Validator.js';
|
|
2
2
|
export * from './ValidationResult.js';
|
|
3
3
|
export * from './ValidationResultReason.js';
|
|
4
|
+
export * from './ValidationResultReasonDetail.js';
|
|
4
5
|
export * from './ValidationResultSeverity.js';
|
|
5
6
|
export * from './IValidationRule.js';
|
|
6
7
|
export * from './PropertyValidator.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../validation/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../validation/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var Validator = require('./Validator.js');
|
|
4
4
|
var ValidationResult = require('./ValidationResult.js');
|
|
5
5
|
var ValidationResultReason = require('./ValidationResultReason.js');
|
|
6
|
+
var ValidationResultReasonDetail = require('./ValidationResultReasonDetail.js');
|
|
6
7
|
var ValidationResultSeverity = require('./ValidationResultSeverity.js');
|
|
7
8
|
var PropertyValidator = require('./PropertyValidator.js');
|
|
8
9
|
var PropertyRule = require('./PropertyRule.js');
|
|
@@ -20,6 +21,7 @@ var ComparisonRules = require('./rules/ComparisonRules.js');
|
|
|
20
21
|
exports.Validator = Validator.Validator;
|
|
21
22
|
exports.ValidationResult = ValidationResult.ValidationResult;
|
|
22
23
|
exports.ValidationResultReason = ValidationResultReason.ValidationResultReason;
|
|
24
|
+
exports.ValidationResultReasonDetail = ValidationResultReasonDetail.ValidationResultReasonDetail;
|
|
23
25
|
exports.ValidationResultSeverity = ValidationResultSeverity.ValidationResultSeverity;
|
|
24
26
|
exports.PropertyValidator = PropertyValidator.PropertyValidator;
|
|
25
27
|
exports.PropertyRule = PropertyRule.PropertyRule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../validation/index.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\nexport * from './Validator.js';\nexport * from './ValidationResult.js';\nexport * from './ValidationResultReason.js';\nexport * from './ValidationResultSeverity.js';\nexport * from './IValidationRule.js';\nexport * from './PropertyValidator.js';\nexport * from './PropertyRule.js';\nexport * from './RuleBuilder.js';\nexport * from './RuleBuilderExtensions.js';\nexport * from './rules/NotEmptyRule.js';\nexport * from './rules/LengthRules.js';\nexport * from './rules/EmailRule.js';\nexport * from './rules/RegexRule.js';\nexport * from './rules/ComparisonRules.js';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../validation/index.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\nexport * from './Validator.js';\nexport * from './ValidationResult.js';\nexport * from './ValidationResultReason.js';\nexport * from './ValidationResultReasonDetail.js';\nexport * from './ValidationResultSeverity.js';\nexport * from './IValidationRule.js';\nexport * from './PropertyValidator.js';\nexport * from './PropertyRule.js';\nexport * from './RuleBuilder.js';\nexport * from './RuleBuilderExtensions.js';\nexport * from './rules/NotEmptyRule.js';\nexport * from './rules/LengthRules.js';\nexport * from './rules/EmailRule.js';\nexport * from './rules/RegexRule.js';\nexport * from './rules/ComparisonRules.js';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/esm/UrlHelpers.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlHelpers.d.ts","sourceRoot":"","sources":["../../UrlHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UrlHelpers.d.ts","sourceRoot":"","sources":["../../UrlHelpers.ts"],"names":[],"mappings":"AA8BA,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7D;AAED,qBAAa,UAAU;IAQnB,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAM5E;IASD,MAAM,CAAC,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;KAAE,CA0B9H;IASD,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,eAAe,CAsBrH;CACJ"}
|