@cratis/arc 22.13.0 → 22.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/cjs/Globals.js.map +1 -1
- package/dist/cjs/UrlHelpers.js.map +1 -1
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/commands/CommandResult.js.map +1 -1
- package/dist/cjs/commands/CommandResults.js.map +1 -1
- package/dist/cjs/commands/CommandValidator.js.map +1 -1
- package/dist/cjs/commands/index.js.map +1 -1
- package/dist/cjs/deepEqual.js.map +1 -1
- package/dist/cjs/identity/IIdentityProvider.js.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/identity/index.js.map +1 -1
- package/dist/cjs/joinPaths.js.map +1 -1
- package/dist/cjs/messaging/IMessenger.js.map +1 -1
- package/dist/cjs/messaging/Message.js.map +1 -1
- package/dist/cjs/messaging/Messenger.js.map +1 -1
- package/dist/cjs/messaging/index.js.map +1 -1
- package/dist/cjs/queries/HubConnectionKeepAlive.js.map +1 -1
- package/dist/cjs/queries/IQueryProvider.js.map +1 -1
- package/dist/cjs/queries/NullObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnectionFactory.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnectionPool.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryDiagnostics.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryMultiplexer.js.map +1 -1
- package/dist/cjs/queries/ObservableQuerySubscription.js.map +1 -1
- package/dist/cjs/queries/Paging.js.map +1 -1
- package/dist/cjs/queries/PagingInfo.js.map +1 -1
- package/dist/cjs/queries/QueryFor.js.map +1 -1
- package/dist/cjs/queries/QueryHttpMethod.js.map +1 -1
- package/dist/cjs/queries/QueryHttpMethodResolver.js.map +1 -1
- package/dist/cjs/queries/QueryHttpRequest.js.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
- package/dist/cjs/queries/QueryProvider.js.map +1 -1
- package/dist/cjs/queries/QueryResult.js.map +1 -1
- package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
- package/dist/cjs/queries/QueryTransportMethod.js.map +1 -1
- package/dist/cjs/queries/QueryValidator.js.map +1 -1
- package/dist/cjs/queries/ReconnectPolicy.js.map +1 -1
- package/dist/cjs/queries/ServerSentEventHubConnection.js.map +1 -1
- package/dist/cjs/queries/ServerSentEventQueryConnection.js.map +1 -1
- package/dist/cjs/queries/SortDirection.js.map +1 -1
- package/dist/cjs/queries/Sorting.js.map +1 -1
- package/dist/cjs/queries/SortingActions.js.map +1 -1
- package/dist/cjs/queries/SortingActionsForObservableQuery.js.map +1 -1
- package/dist/cjs/queries/SortingActionsForQuery.js.map +1 -1
- package/dist/cjs/queries/ValidateRequestArguments.js.map +1 -1
- package/dist/cjs/queries/WebSocketHubConnection.js.map +1 -1
- package/dist/cjs/queries/WebSocketMessage.js.map +1 -1
- package/dist/cjs/queries/deserializeQueryModel.js.map +1 -1
- package/dist/cjs/queries/index.js.map +1 -1
- package/dist/cjs/queries/isAbortError.js.map +1 -1
- package/dist/cjs/queries/reconcileQueryData.js.map +1 -1
- package/dist/cjs/reflection/ParameterDescriptor.js.map +1 -1
- package/dist/cjs/reflection/ParametersHelper.js.map +1 -1
- package/dist/cjs/reflection/PropertyDescriptor.js.map +1 -1
- package/dist/cjs/reflection/index.js.map +1 -1
- package/dist/cjs/validation/PropertyRule.js.map +1 -1
- package/dist/cjs/validation/PropertyValidator.js.map +1 -1
- package/dist/cjs/validation/RuleBuilder.js.map +1 -1
- package/dist/cjs/validation/RuleBuilderExtensions.js.map +1 -1
- package/dist/cjs/validation/ValidationResult.js.map +1 -1
- package/dist/cjs/validation/ValidationResultReason.js.map +1 -1
- package/dist/cjs/validation/ValidationResultSeverity.js.map +1 -1
- package/dist/cjs/validation/Validator.js.map +1 -1
- package/dist/cjs/validation/index.js.map +1 -1
- package/dist/cjs/validation/rules/ComparisonRules.js.map +1 -1
- package/dist/cjs/validation/rules/EmailRule.js.map +1 -1
- package/dist/cjs/validation/rules/LengthRules.js.map +1 -1
- package/dist/cjs/validation/rules/NotEmptyRule.js.map +1 -1
- package/dist/cjs/validation/rules/PhoneRule.js.map +1 -1
- package/dist/cjs/validation/rules/RegexRule.js.map +1 -1
- package/dist/cjs/validation/rules/UrlRule.js.map +1 -1
- package/dist/esm/Globals.js.map +1 -1
- package/dist/esm/UrlHelpers.js.map +1 -1
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/CommandResult.js.map +1 -1
- package/dist/esm/commands/CommandResults.js.map +1 -1
- package/dist/esm/commands/CommandValidator.js.map +1 -1
- package/dist/esm/deepEqual.js.map +1 -1
- package/dist/esm/identity/IIdentityProvider.js.map +1 -1
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/joinPaths.js.map +1 -1
- package/dist/esm/messaging/IMessenger.js.map +1 -1
- package/dist/esm/messaging/Message.js.map +1 -1
- package/dist/esm/messaging/Messenger.js.map +1 -1
- package/dist/esm/queries/HubConnectionKeepAlive.js.map +1 -1
- package/dist/esm/queries/IQueryProvider.js.map +1 -1
- package/dist/esm/queries/NullObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnectionFactory.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnectionPool.js.map +1 -1
- package/dist/esm/queries/ObservableQueryDiagnostics.js.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
- package/dist/esm/queries/ObservableQueryMultiplexer.js.map +1 -1
- package/dist/esm/queries/ObservableQuerySubscription.js.map +1 -1
- package/dist/esm/queries/Paging.js.map +1 -1
- package/dist/esm/queries/PagingInfo.js.map +1 -1
- package/dist/esm/queries/QueryFor.js.map +1 -1
- package/dist/esm/queries/QueryHttpMethod.js.map +1 -1
- package/dist/esm/queries/QueryHttpMethodResolver.js.map +1 -1
- package/dist/esm/queries/QueryHttpRequest.js.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
- package/dist/esm/queries/QueryProvider.js.map +1 -1
- package/dist/esm/queries/QueryResult.js.map +1 -1
- package/dist/esm/queries/QueryResultWithState.js.map +1 -1
- package/dist/esm/queries/QueryTransportMethod.js.map +1 -1
- package/dist/esm/queries/QueryValidator.js.map +1 -1
- package/dist/esm/queries/ReconnectPolicy.js.map +1 -1
- package/dist/esm/queries/ServerSentEventHubConnection.js.map +1 -1
- package/dist/esm/queries/ServerSentEventQueryConnection.js.map +1 -1
- package/dist/esm/queries/SortDirection.js.map +1 -1
- package/dist/esm/queries/Sorting.js.map +1 -1
- package/dist/esm/queries/SortingActions.js.map +1 -1
- package/dist/esm/queries/SortingActionsForObservableQuery.js.map +1 -1
- package/dist/esm/queries/SortingActionsForQuery.js.map +1 -1
- package/dist/esm/queries/ValidateRequestArguments.js.map +1 -1
- package/dist/esm/queries/WebSocketHubConnection.js.map +1 -1
- package/dist/esm/queries/WebSocketMessage.js.map +1 -1
- package/dist/esm/queries/deserializeQueryModel.js.map +1 -1
- package/dist/esm/queries/isAbortError.js.map +1 -1
- package/dist/esm/queries/reconcileQueryData.js.map +1 -1
- package/dist/esm/reflection/ParameterDescriptor.js.map +1 -1
- package/dist/esm/reflection/ParametersHelper.js.map +1 -1
- package/dist/esm/reflection/PropertyDescriptor.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/validation/PropertyRule.js.map +1 -1
- package/dist/esm/validation/PropertyValidator.js.map +1 -1
- package/dist/esm/validation/RuleBuilder.js.map +1 -1
- package/dist/esm/validation/RuleBuilderExtensions.js.map +1 -1
- package/dist/esm/validation/ValidationResult.js.map +1 -1
- package/dist/esm/validation/ValidationResultReason.js.map +1 -1
- package/dist/esm/validation/ValidationResultSeverity.js.map +1 -1
- package/dist/esm/validation/Validator.js.map +1 -1
- package/dist/esm/validation/rules/ComparisonRules.js.map +1 -1
- package/dist/esm/validation/rules/EmailRule.js.map +1 -1
- package/dist/esm/validation/rules/LengthRules.js.map +1 -1
- package/dist/esm/validation/rules/NotEmptyRule.js.map +1 -1
- package/dist/esm/validation/rules/PhoneRule.js.map +1 -1
- package/dist/esm/validation/rules/RegexRule.js.map +1 -1
- package/dist/esm/validation/rules/UrlRule.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortingActionsForQuery.js","sources":["../../../queries/SortingActionsForQuery.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 { IQueryFor } from './IQueryFor';\nimport { SortDirection } from './SortDirection';\nimport { Sorting } from './Sorting';\n\n/**\n * Represents sorting for a query.\n */\nexport class SortingActionsForQuery<TDataType, TArguments = object> {\n\n /**\n * Initializes a new instance of {@link SortingActionsForQuery}.\n * @param {string} field The field that the sorting represents.\n * @param {IQueryFor<TDataType, TArguments>} query The query that holds the field.\n */\n constructor(readonly field: string, readonly query: IQueryFor<TDataType, TArguments>) { \n }\n\n /**\n * Instructs query to sort ascending for the field.\n */\n ascending(): Sorting {\n this.query.sorting = new Sorting(this.field, SortDirection.ascending);\n return this.query.sorting;\n }\n\n /**\n * Instructs query to sort ascending for the field.\n */\n descending(): Sorting {\n this.query.sorting = new Sorting(this.field, SortDirection.descending);\n return this.query.sorting;\n }\n}\n"],"names":["SortingActionsForQuery","query","field","ascending","sorting","Sorting","SortDirection","descending"],"mappings":";;;;;AAAA;AACA;AAMA;;AAEC,IACM,MAAMA,sBAAAA,CAAAA;;;AAET;;;;AAIC,QACD,YAAY,KAAsB,EAAWC,KAAuC,CAAE;aAAjEC,KAAAA,GAAAA,KAAAA;aAAwBD,KAAAA,GAAAA,KAAAA;AAC7C,IAAA;AAEA;;AAEE,SACFE,SAAAA,GAAqB;AACjB,QAAA,IAAI,CAACF,KAAK,CAACG,OAAO,GAAG,IAAIC,eAAAA,CAAQ,IAAI,CAACH,KAAK,EAAEI,2BAAAA,CAAcH,SAAS,CAAA;AACpE,QAAA,OAAO,IAAI,CAACF,KAAK,CAACG,OAAO;AAC7B,IAAA;AAEA;;AAEE,SACFG,UAAAA,GAAsB;AAClB,QAAA,IAAI,CAACN,KAAK,CAACG,OAAO,GAAG,IAAIC,eAAAA,CAAQ,IAAI,CAACH,KAAK,EAAEI,2BAAAA,CAAcC,UAAU,CAAA;AACrE,QAAA,OAAO,IAAI,CAACN,KAAK,CAACG,OAAO;AAC7B,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"SortingActionsForQuery.js","sources":["../../../queries/SortingActionsForQuery.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 { IQueryFor } from './IQueryFor';\nimport { SortDirection } from './SortDirection';\nimport { Sorting } from './Sorting';\n\n/**\n * Represents sorting for a query.\n */\nexport class SortingActionsForQuery<TDataType, TArguments = object> {\n\n /**\n * Initializes a new instance of {@link SortingActionsForQuery}.\n * @param {string} field The field that the sorting represents.\n * @param {IQueryFor<TDataType, TArguments>} query The query that holds the field.\n */\n constructor(readonly field: string, readonly query: IQueryFor<TDataType, TArguments>) { \n }\n\n /**\n * Instructs query to sort ascending for the field.\n */\n ascending(): Sorting {\n this.query.sorting = new Sorting(this.field, SortDirection.ascending);\n return this.query.sorting;\n }\n\n /**\n * Instructs query to sort ascending for the field.\n */\n descending(): Sorting {\n this.query.sorting = new Sorting(this.field, SortDirection.descending);\n return this.query.sorting;\n }\n}\n"],"names":["SortingActionsForQuery","query","field","ascending","sorting","Sorting","SortDirection","descending"],"mappings":";;;;;AAAA;AACA;AAMA;;AAEC,IACM,MAAMA,sBAAAA,CAAAA;;;AAET;;;;AAIC,QACD,YAAY,KAAsB,EAAWC,KAAuC,CAAE;aAAjEC,KAAAA,GAAAA,KAAAA;aAAwBD,KAAAA,GAAAA,KAAAA;AAC7C,IAAA;AAEA;;AAEE,SACFE,SAAAA,GAAqB;AACjB,QAAA,IAAI,CAACF,KAAK,CAACG,OAAO,GAAG,IAAIC,eAAAA,CAAQ,IAAI,CAACH,KAAK,EAAEI,2BAAAA,CAAcH,SAAS,CAAA;AACpE,QAAA,OAAO,IAAI,CAACF,KAAK,CAACG,OAAO;AAC7B,IAAA;AAEA;;AAEE,SACFG,UAAAA,GAAsB;AAClB,QAAA,IAAI,CAACN,KAAK,CAACG,OAAO,GAAG,IAAIC,eAAAA,CAAQ,IAAI,CAACH,KAAK,EAAEI,2BAAAA,CAAcC,UAAU,CAAA;AACrE,QAAA,OAAO,IAAI,CAACN,KAAK,CAACG,OAAO;AAC7B,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidateRequestArguments.js","sources":["../../../queries/ValidateRequestArguments.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 * Validate request arguments.\n * @param {string} requestName Name of request.\n * @param {string[]} expectedRequestArguments Array of all expected arguments.\n * @param {*} actualArguments Object containing the arguments.\n * @returns True if valid, false if not.\n*/\nexport function ValidateRequestArguments(requestName: string, expectedRequestArguments: string[], actualArguments?: object): boolean {\n if (expectedRequestArguments.length > 0) {\n const missing: string[] = [];\n\n if (!actualArguments) {\n expectedRequestArguments.forEach(_ => missing.push(_));\n } else {\n for (const argument of expectedRequestArguments) {\n if (!actualArguments.hasOwnProperty(argument) ||\n actualArguments[argument] === undefined ||\n actualArguments[argument] === null ||\n actualArguments[argument] === '') {\n missing.push(argument);\n }\n }\n }\n\n if (missing.length > 0) {\n const missingArgumentsString = missing.join(', ');\n console.log(`Warning: Missing (${missingArgumentsString}) arguments for request (${requestName}). Will not perform.`);\n return false;\n }\n }\n\n return true;\n}\n"],"names":["ValidateRequestArguments","requestName","expectedRequestArguments","actualArguments","length","missing","forEach","_","push","argument","hasOwnProperty","undefined","missingArgumentsString","join","console","log"],"mappings":";;AAAA;AACA;AAEA;;;;;;AAMA,GACO,SAASA,wBAAAA,CAAyBC,WAAmB,EAAEC,wBAAkC,EAAEC,eAAwB,EAAA;IACtH,IAAID,wBAAAA,CAAyBE,MAAM,GAAG,CAAA,EAAG;AACrC,QAAA,MAAMC,UAAoB,EAAE;AAE5B,QAAA,IAAI,CAACF,eAAAA,EAAiB;AAClBD,YAAAA,wBAAAA,CAAyBI,OAAO,CAACC,CAAAA,CAAAA,GAAKF,OAAAA,CAAQG,IAAI,CAACD,CAAAA,CAAAA,CAAAA;QACvD,CAAA,MAAO;YACH,KAAK,MAAME,YAAYP,wBAAAA,CAA0B;AAC7C,gBAAA,IAAI,CAACC,eAAAA,CAAgBO,cAAc,CAACD,QAAAA,CAAAA,IAChCN,eAAe,CAACM,QAAAA,CAAS,KAAKE,aAC9BR,eAAe,CAACM,SAAS,KAAK,IAAA,IAC9BN,eAAe,CAACM,QAAAA,CAAS,KAAK,EAAA,EAAI;AAClCJ,oBAAAA,OAAAA,CAAQG,IAAI,CAACC,QAAAA,CAAAA;AACjB,gBAAA;AACJ,YAAA;AACJ,QAAA;QAEA,IAAIJ,OAAAA,CAAQD,MAAM,GAAG,CAAA,EAAG;YACpB,MAAMQ,sBAAAA,GAAyBP,OAAAA,CAAQQ,IAAI,CAAC,IAAA,CAAA;YAC5CC,OAAAA,CAAQC,GAAG,CAAC,CAAC,kBAAkB,EAAEH,uBAAuB,yBAAyB,EAAEX,WAAAA,CAAY,oBAAoB,CAAC,CAAA;YACpH,OAAO,KAAA;AACX,QAAA;AACJ,IAAA;IAEA,OAAO,IAAA;AACX
|
|
1
|
+
{"version":3,"file":"ValidateRequestArguments.js","sources":["../../../queries/ValidateRequestArguments.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 * Validate request arguments.\n * @param {string} requestName Name of request.\n * @param {string[]} expectedRequestArguments Array of all expected arguments.\n * @param {*} actualArguments Object containing the arguments.\n * @returns True if valid, false if not.\n*/\nexport function ValidateRequestArguments(requestName: string, expectedRequestArguments: string[], actualArguments?: object): boolean {\n if (expectedRequestArguments.length > 0) {\n const missing: string[] = [];\n\n if (!actualArguments) {\n expectedRequestArguments.forEach(_ => missing.push(_));\n } else {\n for (const argument of expectedRequestArguments) {\n if (!actualArguments.hasOwnProperty(argument) ||\n actualArguments[argument] === undefined ||\n actualArguments[argument] === null ||\n actualArguments[argument] === '') {\n missing.push(argument);\n }\n }\n }\n\n if (missing.length > 0) {\n const missingArgumentsString = missing.join(', ');\n console.log(`Warning: Missing (${missingArgumentsString}) arguments for request (${requestName}). Will not perform.`);\n return false;\n }\n }\n\n return true;\n}\n"],"names":["ValidateRequestArguments","requestName","expectedRequestArguments","actualArguments","length","missing","forEach","_","push","argument","hasOwnProperty","undefined","missingArgumentsString","join","console","log"],"mappings":";;AAAA;AACA;AAEA;;;;;;AAMA,GACO,SAASA,wBAAAA,CAAyBC,WAAmB,EAAEC,wBAAkC,EAAEC,eAAwB,EAAA;IACtH,IAAID,wBAAAA,CAAyBE,MAAM,GAAG,CAAA,EAAG;AACrC,QAAA,MAAMC,UAAoB,EAAE;AAE5B,QAAA,IAAI,CAACF,eAAAA,EAAiB;AAClBD,YAAAA,wBAAAA,CAAyBI,OAAO,CAACC,CAAAA,CAAAA,GAAKF,OAAAA,CAAQG,IAAI,CAACD,CAAAA,CAAAA,CAAAA;QACvD,CAAA,MAAO;YACH,KAAK,MAAME,YAAYP,wBAAAA,CAA0B;AAC7C,gBAAA,IAAI,CAACC,eAAAA,CAAgBO,cAAc,CAACD,QAAAA,CAAAA,IAChCN,eAAe,CAACM,QAAAA,CAAS,KAAKE,aAC9BR,eAAe,CAACM,SAAS,KAAK,IAAA,IAC9BN,eAAe,CAACM,QAAAA,CAAS,KAAK,EAAA,EAAI;AAClCJ,oBAAAA,OAAAA,CAAQG,IAAI,CAACC,QAAAA,CAAAA;AACjB,gBAAA;AACJ,YAAA;AACJ,QAAA;QAEA,IAAIJ,OAAAA,CAAQD,MAAM,GAAG,CAAA,EAAG;YACpB,MAAMQ,sBAAAA,GAAyBP,OAAAA,CAAQQ,IAAI,CAAC,IAAA,CAAA;YAC5CC,OAAAA,CAAQC,GAAG,CAAC,CAAC,kBAAkB,EAAEH,uBAAuB,yBAAyB,EAAEX,WAAAA,CAAY,oBAAoB,CAAC,CAAA;YACpH,OAAO,KAAA;AACX,QAAA;AACJ,IAAA;IAEA,OAAO,IAAA;AACX;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketHubConnection.js","sources":["../../../queries/WebSocketHubConnection.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 { Globals } from '../Globals';\nimport type { DataReceived } from './ObservableQueryConnection';\nimport { HubConnectionKeepAlive } from './HubConnectionKeepAlive';\nimport type { IReconnectPolicy } from './IReconnectPolicy';\nimport { ReconnectPolicy } from './ReconnectPolicy';\nimport { QueryResult } from './QueryResult';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Message types matching the backend {@link ObservableQueryHubMessageType} enum.\n * Serialized as strings by the JsonStringEnumConverter on the server.\n */\nexport enum HubMessageType {\n Subscribe = 'Subscribe',\n Unsubscribe = 'Unsubscribe',\n QueryResult = 'QueryResult',\n Unauthorized = 'Unauthorized',\n Error = 'Error',\n Ping = 'Ping',\n Pong = 'Pong',\n Connected = 'Connected',\n}\n\n/**\n * Wire format for messages exchanged over the observable query WebSocket and SSE hub transports.\n */\nexport interface HubMessage {\n type: HubMessageType;\n queryId?: string;\n\n /** Optional positive safe-integer revision used to reject stale replacement messages. */\n revision?: number;\n\n /**\n * Whether the server supports revision-aware subscription operations and result frames.\n * Only present on {@link HubMessageType.Connected} messages from capable servers.\n */\n supportsSubscriptionRevisions?: boolean;\n payload?: any;\n timestamp?: number;\n\n /**\n * The server's keep-alive interval in milliseconds, or 0 when keep-alive is disabled.\n * Only present on {@link HubMessageType.Connected} messages.\n */\n keepAliveIntervalMs?: number;\n}\n\n/**\n * Matches the backend {@link ObservableQuerySubscriptionRequest} record.\n */\nexport interface SubscriptionRequest {\n queryName: string;\n arguments?: Record<string, string | null>;\n page?: number;\n pageSize?: number;\n sortBy?: string;\n sortDirection?: string;\n transferMode?: string;\n}\n\ninterface ActiveSubscription {\n request: SubscriptionRequest;\n callback: DataReceived<any>;\n revision: number;\n}\n\n/**\n * Represents a single multiplexed WebSocket connection to the observable query hub\n * at {@code /.cratis/queries/ws}.\n *\n * Multiple query subscriptions are carried over the same physical WebSocket. Each subscription\n * is identified by a client-generated {@code queryId}; the server tags every result message with\n * the same id so responses can be routed to the correct callback. The client initially subscribes\n * without revisions for compatibility with older servers, then replaces active subscriptions with\n * revision-aware operations when the server advertises support in a Connected message.\n */\nexport class WebSocketHubConnection {\n private _socket?: WebSocket;\n private _disconnected = false;\n private _subscriptions: Map<string, ActiveSubscription> = new Map();\n private readonly _keepAlive: HubConnectionKeepAlive;\n private _lastPingSentTime?: number;\n private _lastPongLatency: number = 0;\n private _latencySamples: number[] = [];\n private _nextRevision = 0;\n private _supportsSubscriptionRevisions = false;\n private _reconnectPending = false;\n\n /**\n * Initializes a new instance of {@link WebSocketHubConnection}.\n * @param {string} _url The WebSocket URL of the hub endpoint (e.g. {@code ws://localhost:5000/.cratis/queries/ws}).\n * @param {string} _microservice The microservice name to pass as a query argument.\n * @param {number} pingIntervalMs How often to send keep-alive pings when the connection is idle (default: 10 000 ms).\n * @param {IReconnectPolicy} _policy The reconnect policy to use (default: {@link ReconnectPolicy}).\n */\n constructor(\n private readonly _url: string,\n private readonly _microservice: string,\n pingIntervalMs: number = 10000,\n private readonly _policy: IReconnectPolicy = new ReconnectPolicy(),\n ) {\n this._keepAlive = new HubConnectionKeepAlive(pingIntervalMs, () => {\n if (this._socket?.readyState === WebSocket.OPEN) {\n this._lastPingSentTime = Date.now();\n this.sendMessage({\n type: HubMessageType.Ping,\n timestamp: this._lastPingSentTime,\n });\n }\n });\n }\n\n /**\n * Gets the number of active query subscriptions on this connection.\n */\n get queryCount(): number {\n return this._subscriptions.size;\n }\n\n /**\n * Gets whether the WebSocket connection is currently open.\n */\n get isConnected(): boolean {\n return this._socket?.readyState === WebSocket.OPEN;\n }\n\n /**\n * Gets the latency of the last ping/pong sequence in milliseconds.\n */\n get lastPingLatency(): number {\n return this._lastPongLatency;\n }\n\n /**\n * Gets the rolling average latency in milliseconds.\n */\n get averageLatency(): number {\n if (this._latencySamples.length === 0) return 0;\n return (\n this._latencySamples.reduce((a, b) => a + b, 0) / this._latencySamples.length\n );\n }\n\n /**\n * Subscribe to a query on this hub connection.\n * If the WebSocket is not yet open, the subscribe message will be sent once the connection is established.\n * @param {string} queryId Client-generated unique identifier for this subscription.\n * @param {SubscriptionRequest} request The subscription request payload.\n * @param {DataReceived<any>} callback Callback invoked whenever the server pushes a result for this query.\n */\n subscribe(\n queryId: string,\n request: SubscriptionRequest,\n callback: DataReceived<any>,\n ): void {\n const subscription = { request, callback, revision: this.getNextRevision() };\n this._subscriptions.set(queryId, subscription);\n this.ensureConnected();\n\n if (this._socket?.readyState === WebSocket.OPEN) {\n this.sendSubscribeMessage(queryId, subscription);\n }\n // If not yet open, sendAllSubscriptions will fire in onopen.\n }\n\n /**\n * Unsubscribe from a query on this hub connection.\n * @param {string} queryId The identifier of the subscription to cancel.\n */\n unsubscribe(queryId: string): void {\n const subscription = this._subscriptions.get(queryId);\n this._subscriptions.delete(queryId);\n\n if (this._socket?.readyState === WebSocket.OPEN && subscription) {\n const message: HubMessage = {\n type: HubMessageType.Unsubscribe,\n queryId,\n };\n if (this._supportsSubscriptionRevisions) {\n message.revision = subscription.revision;\n }\n this.sendMessage(message);\n }\n\n // If no subscriptions remain, close the connection to free resources.\n if (this._subscriptions.size === 0) {\n this.close();\n }\n }\n\n /**\n * Permanently close this hub connection and clean up all subscriptions.\n */\n dispose(): void {\n this._subscriptions.clear();\n this.close();\n }\n\n private ensureConnected(): void {\n if (this._disconnected) {\n // Reset disconnected flag when a new subscription comes in\n this._disconnected = false;\n }\n\n if (\n this._socket &&\n (this._socket.readyState === WebSocket.OPEN ||\n this._socket.readyState === WebSocket.CONNECTING)\n ) {\n this.cancelPendingReconnect();\n return;\n }\n\n // A subscription can arrive while an earlier close is waiting in reconnect backoff. The immediate open owns\n // the connection now, so the delayed callback must not be allowed to create a competing socket later.\n this.cancelPendingReconnect();\n this.openSocket();\n }\n\n private close(): void {\n this._disconnected = true;\n this._keepAlive.stop();\n this._policy.cancel();\n this._reconnectPending = false;\n const socket = this._socket;\n this._socket = undefined;\n this._supportsSubscriptionRevisions = false;\n if (socket) {\n this.detachAndCloseSocket(socket);\n }\n }\n\n private openSocket(): void {\n const currentSocket = this._socket;\n if (\n currentSocket &&\n (currentSocket.readyState === WebSocket.OPEN ||\n currentSocket.readyState === WebSocket.CONNECTING)\n ) {\n return;\n }\n\n if (currentSocket) {\n this._socket = undefined;\n this.detachAndCloseSocket(currentSocket);\n }\n\n this._supportsSubscriptionRevisions = false;\n\n let url = this._url;\n if (this._microservice?.length > 0) {\n const param = `${Globals.microserviceWSQueryArgument}=${encodeURIComponent(this._microservice)}`;\n url += (url.includes('?') ? '&' : '?') + param;\n }\n\n const socket = new WebSocket(url);\n this._socket = socket;\n\n socket.onopen = () => {\n if (this._socket !== socket || this._disconnected) return;\n console.log('Hub connection established', url);\n this.cancelPendingReconnect();\n this._policy.reset();\n this._keepAlive.start();\n this.sendAllSubscriptions();\n };\n\n socket.onclose = () => {\n if (this._socket !== socket || this._disconnected) return;\n console.log('Hub connection closed', url);\n this._socket = undefined;\n this._supportsSubscriptionRevisions = false;\n this._keepAlive.stop();\n if (this._subscriptions.size === 0) return;\n this._reconnectPending = true;\n const scheduled = this._policy.schedule(() => {\n this._reconnectPending = false;\n if (!this._disconnected && this._subscriptions.size > 0) {\n this.ensureConnected();\n }\n }, this._url);\n if (!scheduled) {\n this._reconnectPending = false;\n }\n };\n\n socket.onerror = (error) => {\n if (this._socket !== socket || this._disconnected) return;\n console.error('Hub connection error', url, error);\n this._keepAlive.stop();\n // onclose will fire after onerror, triggering reconnect\n };\n\n socket.onmessage = (ev) => {\n if (this._socket !== socket || this._disconnected) return;\n this.handleMessage(ev.data as string);\n };\n }\n\n private cancelPendingReconnect(): void {\n if (!this._reconnectPending) return;\n\n this._policy.cancel();\n this._reconnectPending = false;\n }\n\n private detachAndCloseSocket(socket: WebSocket): void {\n socket.onopen = null;\n socket.onclose = null;\n socket.onerror = null;\n socket.onmessage = null;\n socket.close();\n }\n\n private sendAllSubscriptions(): void {\n for (const [queryId, sub] of this._subscriptions) {\n this.sendSubscribeMessage(queryId, sub);\n }\n }\n\n private sendSubscribeMessage(\n queryId: string,\n subscription: ActiveSubscription,\n ): void {\n const message: HubMessage = {\n type: HubMessageType.Subscribe,\n queryId,\n payload: subscription.request,\n };\n if (this._supportsSubscriptionRevisions) {\n message.revision = subscription.revision;\n }\n this.sendMessage(message);\n }\n\n private sendMessage(message: HubMessage): void {\n if (this._socket?.readyState === WebSocket.OPEN) {\n this._socket.send(JSON.stringify(message));\n }\n }\n\n private handleMessage(rawData: string): void {\n try {\n const message = JSON.parse(rawData) as HubMessage;\n\n // Every received message is activity — skip keep-alive ping if data is flowing.\n this._keepAlive.recordActivity();\n\n switch (message.type) {\n case HubMessageType.Connected:\n this.handleConnected(message);\n break;\n case HubMessageType.QueryResult:\n this.handleQueryResult(message);\n break;\n case HubMessageType.Pong:\n this.handlePong(message);\n break;\n case HubMessageType.Unauthorized:\n console.warn('Hub: query unauthorized', message.queryId);\n this.handleUnauthorized(message);\n break;\n case HubMessageType.Error:\n if (this.isMessageForCurrentSubscription(message)) {\n console.error(\n 'Hub: query error',\n message.queryId,\n message.payload,\n );\n }\n break;\n }\n } catch (error) {\n console.error('Hub: error parsing message', error);\n }\n }\n\n private handleConnected(message: HubMessage): void {\n if (\n message.supportsSubscriptionRevisions !== true ||\n this._supportsSubscriptionRevisions\n ) {\n return;\n }\n\n this._supportsSubscriptionRevisions = true;\n\n // The legacy subscriptions sent on socket open keep this client compatible with older servers.\n // Ordered WebSocket delivery means these revision-aware replacements are processed afterwards.\n this.sendAllSubscriptions();\n }\n\n private handleQueryResult(message: HubMessage): void {\n if (!message.queryId) return;\n\n const sub = this._subscriptions.get(message.queryId);\n if (!sub || !this.isMessageForCurrentSubscription(message)) return;\n\n const result = message.payload as QueryResult<any>;\n sub.callback(result);\n }\n\n private handleUnauthorized(message: HubMessage): void {\n if (!message.queryId) return;\n\n const sub = this._subscriptions.get(message.queryId);\n if (!sub || !this.isMessageForCurrentSubscription(message)) return;\n\n this._subscriptions.delete(message.queryId);\n sub.callback(QueryResult.unauthorized());\n }\n\n private isMessageForCurrentSubscription(message: HubMessage): boolean {\n if (!message.queryId) return false;\n\n if (!this._supportsSubscriptionRevisions) {\n return (\n message.revision === undefined &&\n this._subscriptions.has(message.queryId)\n );\n }\n\n return (\n this.isValidRevision(message.revision) &&\n this._subscriptions.get(message.queryId)?.revision === message.revision\n );\n }\n\n private isValidRevision(revision: number | undefined): revision is number {\n return revision !== undefined && Number.isSafeInteger(revision) && revision > 0;\n }\n\n private getNextRevision(): number {\n if (this._nextRevision >= Number.MAX_SAFE_INTEGER) {\n throw new RangeError(\n 'WebSocket hub subscription revision exhausted the safe integer range',\n );\n }\n\n return ++this._nextRevision;\n }\n\n private handlePong(message: HubMessage): void {\n if (message.timestamp && this._lastPingSentTime) {\n const latency = Date.now() - message.timestamp;\n this._lastPongLatency = latency;\n this._latencySamples.push(latency);\n\n if (this._latencySamples.length > 100) {\n this._latencySamples.shift();\n }\n }\n }\n}\n"],"names":["HubMessageType","WebSocketHubConnection","_socket","_disconnected","_subscriptions","Map","_keepAlive","_lastPingSentTime","_lastPongLatency","_latencySamples","_nextRevision","_supportsSubscriptionRevisions","_reconnectPending","_url","pingIntervalMs","_policy","ReconnectPolicy","_microservice","HubConnectionKeepAlive","readyState","WebSocket","OPEN","Date","now","sendMessage","type","timestamp","queryCount","size","isConnected","lastPingLatency","averageLatency","length","reduce","a","b","subscribe","queryId","request","callback","subscription","revision","getNextRevision","set","ensureConnected","sendSubscribeMessage","unsubscribe","get","delete","message","close","dispose","clear","CONNECTING","cancelPendingReconnect","openSocket","stop","cancel","socket","undefined","detachAndCloseSocket","currentSocket","url","param","Globals","microserviceWSQueryArgument","encodeURIComponent","includes","onopen","console","log","reset","start","sendAllSubscriptions","onclose","scheduled","schedule","onerror","error","onmessage","ev","handleMessage","data","sub","payload","send","JSON","stringify","rawData","parse","recordActivity","handleConnected","handleQueryResult","handlePong","warn","handleUnauthorized","isMessageForCurrentSubscription","supportsSubscriptionRevisions","result","QueryResult","unauthorized","has","isValidRevision","Number","isSafeInteger","MAX_SAFE_INTEGER","RangeError","latency","push","shift"],"mappings":";;;;;;;AAAA;AACA;AASA;;;IAMO,IAAKA,cAAAA,iBAAAA,SAAAA,cAAAA,EAAAA;;;;;;;;;AAAAA,IAAAA,OAAAA,cAAAA;AASX,CAAA,CAAA,EAAA;AA8CD;;;;;;;;;AASC,IACM,MAAMC,sBAAAA,CAAAA;;;;IACDC,OAAAA;AACAC,IAAAA,aAAAA,GAAgB,KAAA;AAChBC,IAAAA,cAAAA,GAAkD,IAAIC,GAAAA,EAAAA;IAC7CC,UAAAA;IACTC,iBAAAA;AACAC,IAAAA,gBAAAA,GAA2B,CAAA;AAC3BC,IAAAA,eAAAA,GAA4B,EAAE;AAC9BC,IAAAA,aAAAA,GAAgB,CAAA;AAChBC,IAAAA,8BAAAA,GAAiC,KAAA;AACjCC,IAAAA,iBAAAA,GAAoB,KAAA;AAE5B;;;;;;AAMC,QACD,WAAA,CACqBC,IAAY,EAC7B,aAAsC,EACtCC,cAAAA,GAAyB,KAAK,EACbC,OAAAA,GAA4B,IAAIC,iCAAiB,CACpE;aAJmBH,IAAAA,GAAAA,IAAAA;aACAI,aAAA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MAAAA,CAAOE,gBAAgB,EAAE;AAC/C,YAAA,MAAM,IAAIC,UAAAA,CACN,sEAAA,CAAA;AAER,QAAA;QAEA,OAAO,EAAE,IAAI,CAAChG,aAAa;AAC/B,IAAA;AAEQmF,IAAAA,UAAAA,CAAW5C,OAAmB,EAAQ;AAC1C,QAAA,IAAIA,QAAQvB,SAAS,IAAI,IAAI,CAACnB,iBAAiB,EAAE;AAC7C,YAAA,MAAMoG,OAAAA,GAAUrF,IAAAA,CAAKC,GAAG,EAAA,GAAK0B,QAAQvB,SAAS;YAC9C,IAAI,CAAClB,gBAAgB,GAAGmG,OAAAA;AACxB,YAAA,IAAI,CAAClG,eAAe,CAACmG,IAAI,CAACD,OAAAA,CAAAA;AAE1B,YAAA,IAAI,IAAI,CAAClG,eAAe,CAACuB,MAAM,GAAG,GAAA,EAAK;gBACnC,IAAI,CAACvB,eAAe,CAACoG,KAAK,EAAA;AAC9B,YAAA;AACJ,QAAA;AACJ,IAAA;AACJ;;;;;"}
|
|
1
|
+
{"version":3,"file":"WebSocketHubConnection.js","sources":["../../../queries/WebSocketHubConnection.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 { Globals } from '../Globals';\nimport type { DataReceived } from './ObservableQueryConnection';\nimport { HubConnectionKeepAlive } from './HubConnectionKeepAlive';\nimport type { IReconnectPolicy } from './IReconnectPolicy';\nimport { ReconnectPolicy } from './ReconnectPolicy';\nimport { QueryResult } from './QueryResult';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Message types matching the backend {@link ObservableQueryHubMessageType} enum.\n * Serialized as strings by the JsonStringEnumConverter on the server.\n */\nexport enum HubMessageType {\n Subscribe = 'Subscribe',\n Unsubscribe = 'Unsubscribe',\n QueryResult = 'QueryResult',\n Unauthorized = 'Unauthorized',\n Error = 'Error',\n Ping = 'Ping',\n Pong = 'Pong',\n Connected = 'Connected',\n}\n\n/**\n * Wire format for messages exchanged over the observable query WebSocket and SSE hub transports.\n */\nexport interface HubMessage {\n type: HubMessageType;\n queryId?: string;\n\n /** Optional positive safe-integer revision used to reject stale replacement messages. */\n revision?: number;\n\n /**\n * Whether the server supports revision-aware subscription operations and result frames.\n * Only present on {@link HubMessageType.Connected} messages from capable servers.\n */\n supportsSubscriptionRevisions?: boolean;\n payload?: any;\n timestamp?: number;\n\n /**\n * The server's keep-alive interval in milliseconds, or 0 when keep-alive is disabled.\n * Only present on {@link HubMessageType.Connected} messages.\n */\n keepAliveIntervalMs?: number;\n}\n\n/**\n * Matches the backend {@link ObservableQuerySubscriptionRequest} record.\n */\nexport interface SubscriptionRequest {\n queryName: string;\n arguments?: Record<string, string | null>;\n page?: number;\n pageSize?: number;\n sortBy?: string;\n sortDirection?: string;\n transferMode?: string;\n}\n\ninterface ActiveSubscription {\n request: SubscriptionRequest;\n callback: DataReceived<any>;\n revision: number;\n}\n\n/**\n * Represents a single multiplexed WebSocket connection to the observable query hub\n * at {@code /.cratis/queries/ws}.\n *\n * Multiple query subscriptions are carried over the same physical WebSocket. Each subscription\n * is identified by a client-generated {@code queryId}; the server tags every result message with\n * the same id so responses can be routed to the correct callback. The client initially subscribes\n * without revisions for compatibility with older servers, then replaces active subscriptions with\n * revision-aware operations when the server advertises support in a Connected message.\n */\nexport class WebSocketHubConnection {\n private _socket?: WebSocket;\n private _disconnected = false;\n private _subscriptions: Map<string, ActiveSubscription> = new Map();\n private readonly _keepAlive: HubConnectionKeepAlive;\n private _lastPingSentTime?: number;\n private _lastPongLatency: number = 0;\n private _latencySamples: number[] = [];\n private _nextRevision = 0;\n private _supportsSubscriptionRevisions = false;\n private _reconnectPending = false;\n\n /**\n * Initializes a new instance of {@link WebSocketHubConnection}.\n * @param {string} _url The WebSocket URL of the hub endpoint (e.g. {@code ws://localhost:5000/.cratis/queries/ws}).\n * @param {string} _microservice The microservice name to pass as a query argument.\n * @param {number} pingIntervalMs How often to send keep-alive pings when the connection is idle (default: 10 000 ms).\n * @param {IReconnectPolicy} _policy The reconnect policy to use (default: {@link ReconnectPolicy}).\n */\n constructor(\n private readonly _url: string,\n private readonly _microservice: string,\n pingIntervalMs: number = 10000,\n private readonly _policy: IReconnectPolicy = new ReconnectPolicy(),\n ) {\n this._keepAlive = new HubConnectionKeepAlive(pingIntervalMs, () => {\n if (this._socket?.readyState === WebSocket.OPEN) {\n this._lastPingSentTime = Date.now();\n this.sendMessage({\n type: HubMessageType.Ping,\n timestamp: this._lastPingSentTime,\n });\n }\n });\n }\n\n /**\n * Gets the number of active query subscriptions on this connection.\n */\n get queryCount(): number {\n return this._subscriptions.size;\n }\n\n /**\n * Gets whether the WebSocket connection is currently open.\n */\n get isConnected(): boolean {\n return this._socket?.readyState === WebSocket.OPEN;\n }\n\n /**\n * Gets the latency of the last ping/pong sequence in milliseconds.\n */\n get lastPingLatency(): number {\n return this._lastPongLatency;\n }\n\n /**\n * Gets the rolling average latency in milliseconds.\n */\n get averageLatency(): number {\n if (this._latencySamples.length === 0) return 0;\n return (\n this._latencySamples.reduce((a, b) => a + b, 0) / this._latencySamples.length\n );\n }\n\n /**\n * Subscribe to a query on this hub connection.\n * If the WebSocket is not yet open, the subscribe message will be sent once the connection is established.\n * @param {string} queryId Client-generated unique identifier for this subscription.\n * @param {SubscriptionRequest} request The subscription request payload.\n * @param {DataReceived<any>} callback Callback invoked whenever the server pushes a result for this query.\n */\n subscribe(\n queryId: string,\n request: SubscriptionRequest,\n callback: DataReceived<any>,\n ): void {\n const subscription = { request, callback, revision: this.getNextRevision() };\n this._subscriptions.set(queryId, subscription);\n this.ensureConnected();\n\n if (this._socket?.readyState === WebSocket.OPEN) {\n this.sendSubscribeMessage(queryId, subscription);\n }\n // If not yet open, sendAllSubscriptions will fire in onopen.\n }\n\n /**\n * Unsubscribe from a query on this hub connection.\n * @param {string} queryId The identifier of the subscription to cancel.\n */\n unsubscribe(queryId: string): void {\n const subscription = this._subscriptions.get(queryId);\n this._subscriptions.delete(queryId);\n\n if (this._socket?.readyState === WebSocket.OPEN && subscription) {\n const message: HubMessage = {\n type: HubMessageType.Unsubscribe,\n queryId,\n };\n if (this._supportsSubscriptionRevisions) {\n message.revision = subscription.revision;\n }\n this.sendMessage(message);\n }\n\n // If no subscriptions remain, close the connection to free resources.\n if (this._subscriptions.size === 0) {\n this.close();\n }\n }\n\n /**\n * Permanently close this hub connection and clean up all subscriptions.\n */\n dispose(): void {\n this._subscriptions.clear();\n this.close();\n }\n\n private ensureConnected(): void {\n if (this._disconnected) {\n // Reset disconnected flag when a new subscription comes in\n this._disconnected = false;\n }\n\n if (\n this._socket &&\n (this._socket.readyState === WebSocket.OPEN ||\n this._socket.readyState === WebSocket.CONNECTING)\n ) {\n this.cancelPendingReconnect();\n return;\n }\n\n // A subscription can arrive while an earlier close is waiting in reconnect backoff. The immediate open owns\n // the connection now, so the delayed callback must not be allowed to create a competing socket later.\n this.cancelPendingReconnect();\n this.openSocket();\n }\n\n private close(): void {\n this._disconnected = true;\n this._keepAlive.stop();\n this._policy.cancel();\n this._reconnectPending = false;\n const socket = this._socket;\n this._socket = undefined;\n this._supportsSubscriptionRevisions = false;\n if (socket) {\n this.detachAndCloseSocket(socket);\n }\n }\n\n private openSocket(): void {\n const currentSocket = this._socket;\n if (\n currentSocket &&\n (currentSocket.readyState === WebSocket.OPEN ||\n currentSocket.readyState === WebSocket.CONNECTING)\n ) {\n return;\n }\n\n if (currentSocket) {\n this._socket = undefined;\n this.detachAndCloseSocket(currentSocket);\n }\n\n this._supportsSubscriptionRevisions = false;\n\n let url = this._url;\n if (this._microservice?.length > 0) {\n const param = `${Globals.microserviceWSQueryArgument}=${encodeURIComponent(this._microservice)}`;\n url += (url.includes('?') ? '&' : '?') + param;\n }\n\n const socket = new WebSocket(url);\n this._socket = socket;\n\n socket.onopen = () => {\n if (this._socket !== socket || this._disconnected) return;\n console.log('Hub connection established', url);\n this.cancelPendingReconnect();\n this._policy.reset();\n this._keepAlive.start();\n this.sendAllSubscriptions();\n };\n\n socket.onclose = () => {\n if (this._socket !== socket || this._disconnected) return;\n console.log('Hub connection closed', url);\n this._socket = undefined;\n this._supportsSubscriptionRevisions = false;\n this._keepAlive.stop();\n if (this._subscriptions.size === 0) return;\n this._reconnectPending = true;\n const scheduled = this._policy.schedule(() => {\n this._reconnectPending = false;\n if (!this._disconnected && this._subscriptions.size > 0) {\n this.ensureConnected();\n }\n }, this._url);\n if (!scheduled) {\n this._reconnectPending = false;\n }\n };\n\n socket.onerror = (error) => {\n if (this._socket !== socket || this._disconnected) return;\n console.error('Hub connection error', url, error);\n this._keepAlive.stop();\n // onclose will fire after onerror, triggering reconnect\n };\n\n socket.onmessage = (ev) => {\n if (this._socket !== socket || this._disconnected) return;\n this.handleMessage(ev.data as string);\n };\n }\n\n private cancelPendingReconnect(): void {\n if (!this._reconnectPending) return;\n\n this._policy.cancel();\n this._reconnectPending = false;\n }\n\n private detachAndCloseSocket(socket: WebSocket): void {\n socket.onopen = null;\n socket.onclose = null;\n socket.onerror = null;\n socket.onmessage = null;\n socket.close();\n }\n\n private sendAllSubscriptions(): void {\n for (const [queryId, sub] of this._subscriptions) {\n this.sendSubscribeMessage(queryId, sub);\n }\n }\n\n private sendSubscribeMessage(\n queryId: string,\n subscription: ActiveSubscription,\n ): void {\n const message: HubMessage = {\n type: HubMessageType.Subscribe,\n queryId,\n payload: subscription.request,\n };\n if (this._supportsSubscriptionRevisions) {\n message.revision = subscription.revision;\n }\n this.sendMessage(message);\n }\n\n private sendMessage(message: HubMessage): void {\n if (this._socket?.readyState === WebSocket.OPEN) {\n this._socket.send(JSON.stringify(message));\n }\n }\n\n private handleMessage(rawData: string): void {\n try {\n const message = JSON.parse(rawData) as HubMessage;\n\n // Every received message is activity — skip keep-alive ping if data is flowing.\n this._keepAlive.recordActivity();\n\n switch (message.type) {\n case HubMessageType.Connected:\n this.handleConnected(message);\n break;\n case HubMessageType.QueryResult:\n this.handleQueryResult(message);\n break;\n case HubMessageType.Pong:\n this.handlePong(message);\n break;\n case HubMessageType.Unauthorized:\n console.warn('Hub: query unauthorized', message.queryId);\n this.handleUnauthorized(message);\n break;\n case HubMessageType.Error:\n if (this.isMessageForCurrentSubscription(message)) {\n console.error(\n 'Hub: query error',\n message.queryId,\n message.payload,\n );\n }\n break;\n }\n } catch (error) {\n console.error('Hub: error parsing message', error);\n }\n }\n\n private handleConnected(message: HubMessage): void {\n if (\n message.supportsSubscriptionRevisions !== true ||\n this._supportsSubscriptionRevisions\n ) {\n return;\n }\n\n this._supportsSubscriptionRevisions = true;\n\n // The legacy subscriptions sent on socket open keep this client compatible with older servers.\n // Ordered WebSocket delivery means these revision-aware replacements are processed afterwards.\n this.sendAllSubscriptions();\n }\n\n private handleQueryResult(message: HubMessage): void {\n if (!message.queryId) return;\n\n const sub = this._subscriptions.get(message.queryId);\n if (!sub || !this.isMessageForCurrentSubscription(message)) return;\n\n const result = message.payload as QueryResult<any>;\n sub.callback(result);\n }\n\n private handleUnauthorized(message: HubMessage): void {\n if (!message.queryId) return;\n\n const sub = this._subscriptions.get(message.queryId);\n if (!sub || !this.isMessageForCurrentSubscription(message)) return;\n\n this._subscriptions.delete(message.queryId);\n sub.callback(QueryResult.unauthorized());\n }\n\n private isMessageForCurrentSubscription(message: HubMessage): boolean {\n if (!message.queryId) return false;\n\n if (!this._supportsSubscriptionRevisions) {\n return (\n message.revision === undefined &&\n this._subscriptions.has(message.queryId)\n );\n }\n\n return (\n this.isValidRevision(message.revision) &&\n this._subscriptions.get(message.queryId)?.revision === message.revision\n );\n }\n\n private isValidRevision(revision: number | undefined): revision is number {\n return revision !== undefined && Number.isSafeInteger(revision) && revision > 0;\n }\n\n private getNextRevision(): number {\n if (this._nextRevision >= Number.MAX_SAFE_INTEGER) {\n throw new RangeError(\n 'WebSocket hub subscription revision exhausted the safe integer range',\n );\n }\n\n return ++this._nextRevision;\n }\n\n private handlePong(message: HubMessage): void {\n if (message.timestamp && this._lastPingSentTime) {\n const latency = Date.now() - message.timestamp;\n this._lastPongLatency = latency;\n this._latencySamples.push(latency);\n\n if (this._latencySamples.length > 100) {\n this._latencySamples.shift();\n }\n }\n }\n}\n"],"names":["HubMessageType","WebSocketHubConnection","_socket","_disconnected","_subscriptions","Map","_keepAlive","_lastPingSentTime","_lastPongLatency","_latencySamples","_nextRevision","_supportsSubscriptionRevisions","_reconnectPending","_url","pingIntervalMs","_policy","ReconnectPolicy","_microservice","HubConnectionKeepAlive","readyState","WebSocket","OPEN","Date","now","sendMessage","type","timestamp","queryCount","size","isConnected","lastPingLatency","averageLatency","length","reduce","a","b","subscribe","queryId","request","callback","subscription","revision","getNextRevision","set","ensureConnected","sendSubscribeMessage","unsubscribe","get","delete","message","close","dispose","clear","CONNECTING","cancelPendingReconnect","openSocket","stop","cancel","socket","undefined","detachAndCloseSocket","currentSocket","url","param","Globals","microserviceWSQueryArgument","encodeURIComponent","includes","onopen","console","log","reset","start","sendAllSubscriptions","onclose","scheduled","schedule","onerror","error","onmessage","ev","handleMessage","data","sub","payload","send","JSON","stringify","rawData","parse","recordActivity","handleConnected","handleQueryResult","handlePong","warn","handleUnauthorized","isMessageForCurrentSubscription","supportsSubscriptionRevisions","result","QueryResult","unauthorized","has","isValidRevision","Number","isSafeInteger","MAX_SAFE_INTEGER","RangeError","latency","push","shift"],"mappings":";;;;;;;AAAA;AACA;AASA;;;IAMO,IAAKA,cAAAA,iBAAAA,SAAAA,cAAAA,EAAAA;;;;;;;;;AAAAA,IAAAA,OAAAA,cAAAA;AASX,CAAA,CAAA,EAAA;AA8CD;;;;;;;;;AASC,IACM,MAAMC,sBAAAA,CAAAA;;;;IACDC,OAAAA;AACAC,IAAAA,aAAAA,GAAgB,KAAA;AAChBC,IAAAA,cAAAA,GAAkD,IAAIC,GAAAA,EAAAA;IAC7CC,UAAAA;IACTC,iBAAAA;AACAC,IAAAA,gBAAAA,GAA2B,CAAA;AAC3BC,IAAAA,eAAAA,GAA4B,EAAE;AAC9BC,IAAAA,aAAAA,GAAgB,CAAA;AAChBC,IAAAA,8BAA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6D,IAAAA,eAAAA,CAAgB7D,QAA4B,EAAsB;AACtE,QAAA,OAAOA,aAAakB,SAAAA,IAAa4C,MAAAA,CAAOC,aAAa,CAAC/D,aAAaA,QAAAA,GAAW,CAAA;AAClF,IAAA;IAEQC,eAAAA,GAA0B;AAC9B,QAAA,IAAI,IAAI,CAAChC,aAAa,IAAI6F,MAAAA,CAAOE,gBAAgB,EAAE;AAC/C,YAAA,MAAM,IAAIC,UAAAA,CACN,sEAAA,CAAA;AAER,QAAA;QAEA,OAAO,EAAE,IAAI,CAAChG,aAAa;AAC/B,IAAA;AAEQmF,IAAAA,UAAAA,CAAW5C,OAAmB,EAAQ;AAC1C,QAAA,IAAIA,QAAQvB,SAAS,IAAI,IAAI,CAACnB,iBAAiB,EAAE;AAC7C,YAAA,MAAMoG,OAAAA,GAAUrF,IAAAA,CAAKC,GAAG,EAAA,GAAK0B,QAAQvB,SAAS;YAC9C,IAAI,CAAClB,gBAAgB,GAAGmG,OAAAA;AACxB,YAAA,IAAI,CAAClG,eAAe,CAACmG,IAAI,CAACD,OAAAA,CAAAA;AAE1B,YAAA,IAAI,IAAI,CAAClG,eAAe,CAACuB,MAAM,GAAG,GAAA,EAAK;gBACnC,IAAI,CAACvB,eAAe,CAACoG,KAAK,EAAA;AAC9B,YAAA;AACJ,QAAA;AACJ,IAAA;AACJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketMessage.js","sources":["../../../queries/WebSocketMessage.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 * Represents the type of WebSocket message.\n */\nexport enum WebSocketMessageType {\n /**\n * A data message containing query results.\n */\n Data = 'Data',\n\n /**\n * A ping message sent from client to server.\n */\n Ping = 'Ping',\n\n /**\n * A pong message sent from server to client in response to a ping.\n */\n Pong = 'Pong'\n}\n\n/**\n * Represents a WebSocket message envelope.\n */\nexport type WebSocketMessage = {\n /**\n * The type of message.\n */\n type: WebSocketMessageType;\n\n /**\n * The timestamp when the message was sent (for ping/pong latency tracking).\n */\n timestamp?: number;\n\n /**\n * The payload data (for data messages).\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n data?: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n};\n"],"names":["WebSocketMessageType"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,oBAAAA,iBAAAA,SAAAA,oBAAAA,EAAAA;AACR;;AAEC,QAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAGD;;AAEC,QAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAGD;;AAEC,QAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAbOA,IAAAA,OAAAA,oBAAAA;AAeX,CAAA,CAAA,EAAA
|
|
1
|
+
{"version":3,"file":"WebSocketMessage.js","sources":["../../../queries/WebSocketMessage.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 * Represents the type of WebSocket message.\n */\nexport enum WebSocketMessageType {\n /**\n * A data message containing query results.\n */\n Data = 'Data',\n\n /**\n * A ping message sent from client to server.\n */\n Ping = 'Ping',\n\n /**\n * A pong message sent from server to client in response to a ping.\n */\n Pong = 'Pong'\n}\n\n/**\n * Represents a WebSocket message envelope.\n */\nexport type WebSocketMessage = {\n /**\n * The type of message.\n */\n type: WebSocketMessageType;\n\n /**\n * The timestamp when the message was sent (for ping/pong latency tracking).\n */\n timestamp?: number;\n\n /**\n * The payload data (for data messages).\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n data?: any;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n};\n"],"names":["WebSocketMessageType"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,oBAAAA,iBAAAA,SAAAA,oBAAAA,EAAAA;AACR;;AAEC,QAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAGD;;AAEC,QAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAGD;;AAEC,QAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAbOA,IAAAA,OAAAA,oBAAAA;AAeX,CAAA,CAAA,EAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializeQueryModel.js","sources":["../../../queries/deserializeQueryModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\n\n/*\n * ⚠️ deserializeQueryModel / deserializeQueryModels are for use WITHIN this package only.\n *\n * JsonSerializer's converter registry is module state, and a consumer package can easily resolve a\n * different physical copy of @cratis/fundamentals than this one. Calling these from another package\n * therefore looks up Guid/Date/concept converters in the wrong registry and silently degrades those\n * values to plain deserialization. Other packages should use isPrimitiveModelType - which compares\n * against the JavaScript globals and is safe across copies - and deserialize through their own\n * JsonSerializer.\n */\n\n/**\n * Determines whether a model type is a JavaScript primitive wrapper rather than a real model.\n *\n * A query whose backend returns a primitive collection - `IEnumerable<string>`, `IEnumerable<int>` -\n * generates a proxy with `String`, `Number` or `Boolean` as its model type.\n * @param {Constructor} modelType The model type the query describes itself with.\n * @returns {boolean} True when the type is a primitive wrapper.\n */\nexport function isPrimitiveModelType(modelType: Constructor | null | undefined): boolean {\n return modelType === String || modelType === Number || modelType === Boolean;\n}\n\n/**\n * Deserializes a single query payload into its model type, passing primitives through untouched.\n *\n * {@link JsonSerializer.deserializeFromInstance} is destructive for primitive wrapper types: it\n * constructs `new String()` and copies declared fields onto it, which for a primitive means the\n * value is discarded and an empty wrapper object is produced. Primitives therefore need to bypass\n * deserialization entirely - they already arrive in their final shape.\n * @param {Constructor} modelType The model type to deserialize into.\n * @param {unknown} data The payload to deserialize.\n * @returns {TDataType} The deserialized instance, or the payload unchanged for primitive types.\n */\nexport function deserializeQueryModel<TDataType>(modelType: Constructor | null | undefined, data: unknown): TDataType {\n if (!modelType || modelType === Object || isPrimitiveModelType(modelType)) {\n return data as TDataType;\n }\n\n return JsonSerializer.deserializeFromInstance(modelType, data) as TDataType;\n}\n\n/**\n * Deserializes a query payload collection into its model type, passing primitives through untouched.\n *\n * See {@link deserializeQueryModel} for why primitive model types must bypass deserialization.\n * @param {Constructor} modelType The instance type of the items to deserialize into.\n * @param {unknown} data The payload to deserialize. A non-array payload yields an empty collection.\n * @returns {TDataType[]} The deserialized items, or the items unchanged for primitive types.\n */\nexport function deserializeQueryModels<TDataType>(modelType: Constructor | null | undefined, data: unknown): TDataType[] {\n if (!Array.isArray(data)) {\n return [];\n }\n\n if (!modelType || modelType === Object || isPrimitiveModelType(modelType)) {\n return Array.from(data) as TDataType[];\n }\n\n return JsonSerializer.deserializeArrayFromInstance(modelType, data) as TDataType[];\n}\n"],"names":["isPrimitiveModelType","modelType","String","Number","Boolean","deserializeQueryModel","data","Object","JsonSerializer","deserializeFromInstance","deserializeQueryModels","Array","isArray","from","deserializeArrayFromInstance"],"mappings":";;;;AAAA;AACA;AAIA;;;;;;;;;;;;;;;;IAmBO,SAASA,oBAAAA,CAAqBC,SAAyC,EAAA;AAC1E,IAAA,OAAOA,SAAAA,KAAcC,MAAAA,IAAUD,SAAAA,KAAcE,MAAAA,IAAUF,SAAAA,KAAcG,OAAAA;AACzE;AAEA;;;;;;;;;;AAUC,IACM,SAASC,qBAAAA,CAAiCJ,SAAyC,EAAEK,IAAa,EAAA;AACrG,IAAA,IAAI,CAACL,SAAAA,IAAaA,SAAAA,KAAcM,MAAAA,IAAUP,qBAAqBC,SAAAA,CAAAA,EAAY;QACvE,OAAOK,IAAAA;AACX,IAAA;IAEA,OAAOE,2BAAAA,CAAeC,uBAAuB,CAACR,SAAAA,EAAWK,IAAAA,CAAAA;AAC7D;AAEA;;;;;;;AAOC,IACM,SAASI,sBAAAA,CAAkCT,SAAyC,EAAEK,IAAa,EAAA;AACtG,IAAA,IAAI,CAACK,KAAAA,CAAMC,OAAO,CAACN,IAAAA,CAAAA,EAAO;AACtB,QAAA,OAAO,EAAE;AACb,IAAA;AAEA,IAAA,IAAI,CAACL,SAAAA,IAAaA,SAAAA,KAAcM,MAAAA,IAAUP,qBAAqBC,SAAAA,CAAAA,EAAY;QACvE,OAAOU,KAAAA,CAAME,IAAI,CAACP,IAAAA,CAAAA;AACtB,IAAA;IAEA,OAAOE,2BAAAA,CAAeM,4BAA4B,CAACb,SAAAA,EAAWK,IAAAA,CAAAA;AAClE
|
|
1
|
+
{"version":3,"file":"deserializeQueryModel.js","sources":["../../../queries/deserializeQueryModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor, JsonSerializer } from '@cratis/fundamentals';\n\n/*\n * ⚠️ deserializeQueryModel / deserializeQueryModels are for use WITHIN this package only.\n *\n * JsonSerializer's converter registry is module state, and a consumer package can easily resolve a\n * different physical copy of @cratis/fundamentals than this one. Calling these from another package\n * therefore looks up Guid/Date/concept converters in the wrong registry and silently degrades those\n * values to plain deserialization. Other packages should use isPrimitiveModelType - which compares\n * against the JavaScript globals and is safe across copies - and deserialize through their own\n * JsonSerializer.\n */\n\n/**\n * Determines whether a model type is a JavaScript primitive wrapper rather than a real model.\n *\n * A query whose backend returns a primitive collection - `IEnumerable<string>`, `IEnumerable<int>` -\n * generates a proxy with `String`, `Number` or `Boolean` as its model type.\n * @param {Constructor} modelType The model type the query describes itself with.\n * @returns {boolean} True when the type is a primitive wrapper.\n */\nexport function isPrimitiveModelType(modelType: Constructor | null | undefined): boolean {\n return modelType === String || modelType === Number || modelType === Boolean;\n}\n\n/**\n * Deserializes a single query payload into its model type, passing primitives through untouched.\n *\n * {@link JsonSerializer.deserializeFromInstance} is destructive for primitive wrapper types: it\n * constructs `new String()` and copies declared fields onto it, which for a primitive means the\n * value is discarded and an empty wrapper object is produced. Primitives therefore need to bypass\n * deserialization entirely - they already arrive in their final shape.\n * @param {Constructor} modelType The model type to deserialize into.\n * @param {unknown} data The payload to deserialize.\n * @returns {TDataType} The deserialized instance, or the payload unchanged for primitive types.\n */\nexport function deserializeQueryModel<TDataType>(modelType: Constructor | null | undefined, data: unknown): TDataType {\n if (!modelType || modelType === Object || isPrimitiveModelType(modelType)) {\n return data as TDataType;\n }\n\n return JsonSerializer.deserializeFromInstance(modelType, data) as TDataType;\n}\n\n/**\n * Deserializes a query payload collection into its model type, passing primitives through untouched.\n *\n * See {@link deserializeQueryModel} for why primitive model types must bypass deserialization.\n * @param {Constructor} modelType The instance type of the items to deserialize into.\n * @param {unknown} data The payload to deserialize. A non-array payload yields an empty collection.\n * @returns {TDataType[]} The deserialized items, or the items unchanged for primitive types.\n */\nexport function deserializeQueryModels<TDataType>(modelType: Constructor | null | undefined, data: unknown): TDataType[] {\n if (!Array.isArray(data)) {\n return [];\n }\n\n if (!modelType || modelType === Object || isPrimitiveModelType(modelType)) {\n return Array.from(data) as TDataType[];\n }\n\n return JsonSerializer.deserializeArrayFromInstance(modelType, data) as TDataType[];\n}\n"],"names":["isPrimitiveModelType","modelType","String","Number","Boolean","deserializeQueryModel","data","Object","JsonSerializer","deserializeFromInstance","deserializeQueryModels","Array","isArray","from","deserializeArrayFromInstance"],"mappings":";;;;AAAA;AACA;AAIA;;;;;;;;;;;;;;;;IAmBO,SAASA,oBAAAA,CAAqBC,SAAyC,EAAA;AAC1E,IAAA,OAAOA,SAAAA,KAAcC,MAAAA,IAAUD,SAAAA,KAAcE,MAAAA,IAAUF,SAAAA,KAAcG,OAAAA;AACzE;AAEA;;;;;;;;;;AAUC,IACM,SAASC,qBAAAA,CAAiCJ,SAAyC,EAAEK,IAAa,EAAA;AACrG,IAAA,IAAI,CAACL,SAAAA,IAAaA,SAAAA,KAAcM,MAAAA,IAAUP,qBAAqBC,SAAAA,CAAAA,EAAY;QACvE,OAAOK,IAAAA;AACX,IAAA;IAEA,OAAOE,2BAAAA,CAAeC,uBAAuB,CAACR,SAAAA,EAAWK,IAAAA,CAAAA;AAC7D;AAEA;;;;;;;AAOC,IACM,SAASI,sBAAAA,CAAkCT,SAAyC,EAAEK,IAAa,EAAA;AACtG,IAAA,IAAI,CAACK,KAAAA,CAAMC,OAAO,CAACN,IAAAA,CAAAA,EAAO;AACtB,QAAA,OAAO,EAAE;AACb,IAAA;AAEA,IAAA,IAAI,CAACL,SAAAA,IAAaA,SAAAA,KAAcM,MAAAA,IAAUP,qBAAqBC,SAAAA,CAAAA,EAAY;QACvE,OAAOU,KAAAA,CAAME,IAAI,CAACP,IAAAA,CAAAA;AACtB,IAAA;IAEA,OAAOE,2BAAAA,CAAeM,4BAA4B,CAACb,SAAAA,EAAWK,IAAAA,CAAAA;AAClE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../queries/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 './ChangeSet';\nexport * from './IChangeStreamFor';\nexport * from './IQuery';\nexport * from './IQueryFor';\nexport * from './Paging';\nexport * from './Sorting';\nexport * from './SortDirection';\nexport * from './SortingActions';\nexport * from './SortingActionsForQuery';\nexport * from './SortingActionsForObservableQuery';\nexport * from './QueryFor';\nexport * from './QueryHttpMethod';\nexport * from './QueryHttpMethodResolver';\nexport * from './QueryHttpRequest';\nexport * from './QueryResult';\nexport * from './QueryResultWithState';\nexport * from './IObservableQueryFor';\nexport * from './ObservableQueryFor';\nexport * from './IObservableQueryConnection';\nexport * from './IObservableQueryHubConnection';\nexport * from './IReconnectPolicy';\nexport * from './ReconnectPolicy';\nexport * from './HubConnectionKeepAlive';\nexport * from './ObservableQueryConnection';\nexport * from './ObservableQueryConnectionFactory';\nexport * from './ObservableQueryConnectionPool';\nexport * from './ServerSentEventQueryConnection';\nexport * from './ServerSentEventHubConnection';\nexport * from './WebSocketHubConnection';\nexport * from './ObservableQueryMultiplexer';\nexport * from './ObservableQuerySubscription';\nexport * from './WebSocketMessage';\nexport * from './QueryTransportMethod';\nexport * from './QueryInstanceCache';\nexport * from './reconcileQueryData';\nexport * from './deserializeQueryModel';\nexport * from './IQueryProvider';\nexport * from './QueryProvider';\nexport * from './QueryValidator';\nexport * from './IObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnosticsSnapshot';\nimport '../validation';"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../queries/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 './ChangeSet';\nexport * from './IChangeStreamFor';\nexport * from './IQuery';\nexport * from './IQueryFor';\nexport * from './Paging';\nexport * from './Sorting';\nexport * from './SortDirection';\nexport * from './SortingActions';\nexport * from './SortingActionsForQuery';\nexport * from './SortingActionsForObservableQuery';\nexport * from './QueryFor';\nexport * from './QueryHttpMethod';\nexport * from './QueryHttpMethodResolver';\nexport * from './QueryHttpRequest';\nexport * from './QueryResult';\nexport * from './QueryResultWithState';\nexport * from './IObservableQueryFor';\nexport * from './ObservableQueryFor';\nexport * from './IObservableQueryConnection';\nexport * from './IObservableQueryHubConnection';\nexport * from './IReconnectPolicy';\nexport * from './ReconnectPolicy';\nexport * from './HubConnectionKeepAlive';\nexport * from './ObservableQueryConnection';\nexport * from './ObservableQueryConnectionFactory';\nexport * from './ObservableQueryConnectionPool';\nexport * from './ServerSentEventQueryConnection';\nexport * from './ServerSentEventHubConnection';\nexport * from './WebSocketHubConnection';\nexport * from './ObservableQueryMultiplexer';\nexport * from './ObservableQuerySubscription';\nexport * from './WebSocketMessage';\nexport * from './QueryTransportMethod';\nexport * from './QueryInstanceCache';\nexport * from './reconcileQueryData';\nexport * from './deserializeQueryModel';\nexport * from './IQueryProvider';\nexport * from './QueryProvider';\nexport * from './QueryValidator';\nexport * from './IObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnostics';\nexport * from './ObservableQueryDiagnosticsSnapshot';\nimport '../validation';"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAbortError.js","sources":["../../../queries/isAbortError.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 * Determines whether an error is the rejection produced by aborting a request through an\n * {@link AbortSignal} - as opposed to a genuine transport failure.\n *\n * Deliberately kept out of the `queries` barrel: it is an internal detail shared by the query\n * transport and {@link QueryFor}, not public surface for consumers to depend on.\n * @param error The error to inspect.\n * @returns True if the error represents an aborted request, false otherwise.\n */\nexport function isAbortError(error: unknown): boolean {\n return (error as { name?: string })?.name === 'AbortError';\n}\n"],"names":["isAbortError","error","name"],"mappings":";;AAAA;AACA;AAEA;;;;;;;;IASO,SAASA,YAAAA,CAAaC,KAAc,EAAA;IACvC,OAAQA,OAA6BC,IAAAA,KAAS,YAAA;AAClD
|
|
1
|
+
{"version":3,"file":"isAbortError.js","sources":["../../../queries/isAbortError.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 * Determines whether an error is the rejection produced by aborting a request through an\n * {@link AbortSignal} - as opposed to a genuine transport failure.\n *\n * Deliberately kept out of the `queries` barrel: it is an internal detail shared by the query\n * transport and {@link QueryFor}, not public surface for consumers to depend on.\n * @param error The error to inspect.\n * @returns True if the error represents an aborted request, false otherwise.\n */\nexport function isAbortError(error: unknown): boolean {\n return (error as { name?: string })?.name === 'AbortError';\n}\n"],"names":["isAbortError","error","name"],"mappings":";;AAAA;AACA;AAEA;;;;;;;;IASO,SAASA,YAAAA,CAAaC,KAAc,EAAA;IACvC,OAAQA,OAA6BC,IAAAA,KAAS,YAAA;AAClD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcileQueryData.js","sources":["../../../queries/reconcileQueryData.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 { deepEqual } from '../deepEqual';\n\n/**\n * Resolves the conventional identity of an item so it can be matched against its previous version.\n *\n * Uses the `id` property, the same strategy the server-side change-set computation applies, and\n * reduces concept-style identities (objects with a meaningful `toString()`) to a comparable value.\n * @param {unknown} item The item to resolve identity for.\n * @returns {unknown} The identity value, or `undefined` when the item carries no usable identity.\n */\nfunction getIdentity(item: unknown): unknown {\n const id = (item as Record<string, unknown>)?.id;\n\n if (id === null || id === undefined) {\n return undefined;\n }\n\n if (typeof id === 'object') {\n const stringValue = id.toString();\n return stringValue !== '[object Object]' ? stringValue : JSON.stringify(id);\n }\n\n return id;\n}\n\n/**\n * Reconciles a full payload against the previous one, carrying over the previous object references\n * for every item that did not actually change.\n *\n * Observable queries re-deliver a complete snapshot whenever a subscription is (re-)established.\n * Deserializing that snapshot produces entirely new object references, so consumers that compare by\n * reference — memoized components, effect dependencies — treat every item as changed even when the\n * payload is identical to what they already display. Reconciling restores referential stability:\n * unchanged items keep their previous reference, and when nothing changed at all the previous\n * payload itself is returned so callers can detect \"no change\" with a single `===`.\n *\n * Items are matched by their `id` when present, falling back to position for identity-less items.\n * @template T The payload type.\n * @param {T} previous The payload currently held.\n * @param {T} next The freshly received payload.\n * @returns {T} `previous` when nothing changed; otherwise the new payload with unchanged items carried over by reference.\n */\nexport function reconcileQueryData<T>(previous: T, next: T): T {\n if (previous === next) {\n return previous;\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return reconcileArray(previous, next) as T;\n }\n\n return deepEqual(previous, next) ? previous : next;\n}\n\n/**\n * Reconciles two arrays element by element, preserving previous references for unchanged items.\n * @param {unknown[]} previous The array currently held.\n * @param {unknown[]} next The freshly received array.\n * @returns {unknown[]} `previous` when the arrays are equivalent; otherwise a new array reusing unchanged items.\n */\nfunction reconcileArray(previous: unknown[], next: unknown[]): unknown[] {\n const previousByIdentity = new Map<unknown, unknown>();\n\n for (const item of previous) {\n const identity = getIdentity(item);\n\n // Keep the first occurrence — duplicate identities are not a shape we can reconcile\n // meaningfully, and preferring the first keeps the result deterministic.\n if (identity !== undefined && !previousByIdentity.has(identity)) {\n previousByIdentity.set(identity, item);\n }\n }\n\n let changed = previous.length !== next.length;\n\n const reconciled = next.map((item, index) => {\n const identity = getIdentity(item);\n const candidate = identity !== undefined ? previousByIdentity.get(identity) : previous[index];\n\n if (candidate !== undefined && deepEqual(candidate, item)) {\n // An unchanged item that moved still leaves the collection changed as a whole, but the\n // item itself keeps its reference so only the ordering re-renders, not its content.\n if (candidate !== previous[index]) {\n changed = true;\n }\n\n return candidate;\n }\n\n changed = true;\n return item;\n });\n\n return changed ? reconciled : previous;\n}\n"],"names":["getIdentity","item","id","undefined","stringValue","toString","JSON","stringify","reconcileQueryData","previous","next","Array","isArray","reconcileArray","deepEqual","previousByIdentity","Map","identity","has","set","changed","length","reconciled","map","index","candidate","get"],"mappings":";;;;AAAA;AACA;AAIA;;;;;;;IAQA,SAASA,YAAYC,IAAa,EAAA;AAC9B,IAAA,MAAMC,KAAMD,IAAAA,EAAkCC,EAAAA;IAE9C,IAAIA,EAAAA,KAAO,IAAA,IAAQA,EAAAA,KAAOC,SAAAA,EAAW;QACjC,OAAOA,SAAAA;AACX,IAAA;IAEA,IAAI,OAAOD,OAAO,QAAA,EAAU;QACxB,MAAME,WAAAA,GAAcF,GAAGG,QAAQ,EAAA;AAC/B,QAAA,OAAOD,WAAAA,KAAgB,iBAAA,GAAoBA,WAAAA,GAAcE,IAAAA,CAAKC,SAAS,CAACL,EAAAA,CAAAA;AAC5E,IAAA;IAEA,OAAOA,EAAAA;AACX;AAEA;;;;;;;;;;;;;;;;AAgBC,IACM,SAASM,kBAAA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GvD,YAAA,IAAIwB,SAAAA,KAAchB,QAAQ,CAACe,KAAAA,CAAM,EAAE;gBAC/BJ,OAAAA,GAAU,IAAA;AACd,YAAA;YAEA,OAAOK,SAAAA;AACX,QAAA;QAEAL,OAAAA,GAAU,IAAA;QACV,OAAOnB,IAAAA;AACX,IAAA,CAAA,CAAA;AAEA,IAAA,OAAOmB,UAAUE,UAAAA,GAAab,QAAAA;AAClC
|
|
1
|
+
{"version":3,"file":"reconcileQueryData.js","sources":["../../../queries/reconcileQueryData.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 { deepEqual } from '../deepEqual';\n\n/**\n * Resolves the conventional identity of an item so it can be matched against its previous version.\n *\n * Uses the `id` property, the same strategy the server-side change-set computation applies, and\n * reduces concept-style identities (objects with a meaningful `toString()`) to a comparable value.\n * @param {unknown} item The item to resolve identity for.\n * @returns {unknown} The identity value, or `undefined` when the item carries no usable identity.\n */\nfunction getIdentity(item: unknown): unknown {\n const id = (item as Record<string, unknown>)?.id;\n\n if (id === null || id === undefined) {\n return undefined;\n }\n\n if (typeof id === 'object') {\n const stringValue = id.toString();\n return stringValue !== '[object Object]' ? stringValue : JSON.stringify(id);\n }\n\n return id;\n}\n\n/**\n * Reconciles a full payload against the previous one, carrying over the previous object references\n * for every item that did not actually change.\n *\n * Observable queries re-deliver a complete snapshot whenever a subscription is (re-)established.\n * Deserializing that snapshot produces entirely new object references, so consumers that compare by\n * reference — memoized components, effect dependencies — treat every item as changed even when the\n * payload is identical to what they already display. Reconciling restores referential stability:\n * unchanged items keep their previous reference, and when nothing changed at all the previous\n * payload itself is returned so callers can detect \"no change\" with a single `===`.\n *\n * Items are matched by their `id` when present, falling back to position for identity-less items.\n * @template T The payload type.\n * @param {T} previous The payload currently held.\n * @param {T} next The freshly received payload.\n * @returns {T} `previous` when nothing changed; otherwise the new payload with unchanged items carried over by reference.\n */\nexport function reconcileQueryData<T>(previous: T, next: T): T {\n if (previous === next) {\n return previous;\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return reconcileArray(previous, next) as T;\n }\n\n return deepEqual(previous, next) ? previous : next;\n}\n\n/**\n * Reconciles two arrays element by element, preserving previous references for unchanged items.\n * @param {unknown[]} previous The array currently held.\n * @param {unknown[]} next The freshly received array.\n * @returns {unknown[]} `previous` when the arrays are equivalent; otherwise a new array reusing unchanged items.\n */\nfunction reconcileArray(previous: unknown[], next: unknown[]): unknown[] {\n const previousByIdentity = new Map<unknown, unknown>();\n\n for (const item of previous) {\n const identity = getIdentity(item);\n\n // Keep the first occurrence — duplicate identities are not a shape we can reconcile\n // meaningfully, and preferring the first keeps the result deterministic.\n if (identity !== undefined && !previousByIdentity.has(identity)) {\n previousByIdentity.set(identity, item);\n }\n }\n\n let changed = previous.length !== next.length;\n\n const reconciled = next.map((item, index) => {\n const identity = getIdentity(item);\n const candidate = identity !== undefined ? previousByIdentity.get(identity) : previous[index];\n\n if (candidate !== undefined && deepEqual(candidate, item)) {\n // An unchanged item that moved still leaves the collection changed as a whole, but the\n // item itself keeps its reference so only the ordering re-renders, not its content.\n if (candidate !== previous[index]) {\n changed = true;\n }\n\n return candidate;\n }\n\n changed = true;\n return item;\n });\n\n return changed ? reconciled : previous;\n}\n"],"names":["getIdentity","item","id","undefined","stringValue","toString","JSON","stringify","reconcileQueryData","previous","next","Array","isArray","reconcileArray","deepEqual","previousByIdentity","Map","identity","has","set","changed","length","reconciled","map","index","candidate","get"],"mappings":";;;;AAAA;AACA;AAIA;;;;;;;IAQA,SAASA,YAAYC,IAAa,EAAA;AAC9B,IAAA,MAAMC,KAAMD,IAAAA,EAAkCC,EAAAA;IAE9C,IAAIA,EAAAA,KAAO,IAAA,IAAQA,EAAAA,KAAOC,SAAAA,EAAW;QACjC,OAAOA,SAAAA;AACX,IAAA;IAEA,IAAI,OAAOD,OAAO,QAAA,EAAU;QACxB,MAAME,WAAAA,GAAcF,GAAGG,QAAQ,EAAA;AAC/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AAYY,kBAAAA,CAAmBW,GAAG,CAACT,QAAAA,CAAAA,GAAYR,QAAQ,CAACe,KAAAA,CAAM;AAE7F,QAAA,IAAIC,SAAAA,KAActB,SAAAA,IAAaW,mBAAAA,CAAUW,SAAAA,EAAWxB,IAAAA,CAAAA,EAAO;;;AAGvD,YAAA,IAAIwB,SAAAA,KAAchB,QAAQ,CAACe,KAAAA,CAAM,EAAE;gBAC/BJ,OAAAA,GAAU,IAAA;AACd,YAAA;YAEA,OAAOK,SAAAA;AACX,QAAA;QAEAL,OAAAA,GAAU,IAAA;QACV,OAAOnB,IAAAA;AACX,IAAA,CAAA,CAAA;AAEA,IAAA,OAAOmB,UAAUE,UAAAA,GAAab,QAAAA;AAClC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParameterDescriptor.js","sources":["../../../reflection/ParameterDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '@cratis/fundamentals';\n\n/**\n * Represents a parameter descriptor.\n */\nexport class ParameterDescriptor {\n /**\n * Initializes a new instance of the {@link ParameterDescriptor} class.\n * @param name Name of the parameter.\n * @param type Type of the parameter.\n * @param isEnumerable Whether the parameter is an enumerable (collection) type.\n */\n constructor(readonly name: string, readonly type: Constructor, readonly isEnumerable: boolean = false) {\n }\n}\n"],"names":["ParameterDescriptor","type","isEnumerable","name"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,MAAMA,mBAAAA,CAAAA;;;;AACT;;;;;QAMA,WAAA,CAAY,IAAqB,EAAWC,IAAiB,EAAWC,YAAAA,GAAwB,KAAK,CAAE;aAAlFC,IAAAA,GAAAA,IAAAA;aAAuBF,IAAAA,GAAAA,IAAAA;aAA4BC,YAAAA,GAAAA,YAAAA;AACxE,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"ParameterDescriptor.js","sources":["../../../reflection/ParameterDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '@cratis/fundamentals';\n\n/**\n * Represents a parameter descriptor.\n */\nexport class ParameterDescriptor {\n /**\n * Initializes a new instance of the {@link ParameterDescriptor} class.\n * @param name Name of the parameter.\n * @param type Type of the parameter.\n * @param isEnumerable Whether the parameter is an enumerable (collection) type.\n */\n constructor(readonly name: string, readonly type: Constructor, readonly isEnumerable: boolean = false) {\n }\n}\n"],"names":["ParameterDescriptor","type","isEnumerable","name"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,MAAMA,mBAAAA,CAAAA;;;;AACT;;;;;QAMA,WAAA,CAAY,IAAqB,EAAWC,IAAiB,EAAWC,YAAAA,GAAwB,KAAK,CAAE;aAAlFC,IAAAA,GAAAA,IAAAA;aAAuBF,IAAAA,GAAAA,IAAAA;aAA4BC,YAAAA,GAAAA,YAAAA;AACxE,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParametersHelper.js","sources":["../../../reflection/ParametersHelper.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 { IHaveParameters } from './IHaveParameters';\n\n/**\n * Helper for working with types that have parameters.\n */\nexport const ParametersHelper = {\n /**\n * Collects the parameter values from an instance based on its parameter descriptors.\n * @param instance The instance to collect parameter values from.\n * @returns A record of parameter names to their values.\n */\n collectParameterValues(instance: IHaveParameters): Record<string, unknown> {\n const values: Record<string, unknown> = {};\n for (const descriptor of instance.parameterDescriptors) {\n const value = (instance as unknown as Record<string, unknown>)[descriptor.name];\n if (value !== undefined && value !== null) {\n values[descriptor.name] = value;\n }\n }\n return values;\n }\n};\n"],"names":["ParametersHelper","collectParameterValues","instance","values","descriptor","parameterDescriptors","value","name","undefined"],"mappings":";;AAAA;AACA;AAIA;;UAGaA,gBAAAA,GAAmB;AAC5B;;;;AAIC,QACDC,wBAAuBC,QAAyB,EAAA;AAC5C,QAAA,MAAMC,SAAkC,EAAC;AACzC,QAAA,KAAK,MAAMC,UAAAA,IAAcF,QAAAA,CAASG,oBAAoB,CAAE;AACpD,YAAA,MAAMC,QAAQ,QAAgD,CAACF,UAAAA,CAAWG,IAAI,CAAC;YAC/E,IAAID,KAAAA,KAAUE,SAAAA,IAAaF,KAAAA,KAAU,IAAA,EAAM;AACvCH,gBAAAA,MAAM,CAACC,UAAAA,CAAWG,IAAI,CAAC,GAAGD,KAAAA;AAC9B,YAAA;AACJ,QAAA;QACA,OAAOH,MAAAA;AACX,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"ParametersHelper.js","sources":["../../../reflection/ParametersHelper.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 { IHaveParameters } from './IHaveParameters';\n\n/**\n * Helper for working with types that have parameters.\n */\nexport const ParametersHelper = {\n /**\n * Collects the parameter values from an instance based on its parameter descriptors.\n * @param instance The instance to collect parameter values from.\n * @returns A record of parameter names to their values.\n */\n collectParameterValues(instance: IHaveParameters): Record<string, unknown> {\n const values: Record<string, unknown> = {};\n for (const descriptor of instance.parameterDescriptors) {\n const value = (instance as unknown as Record<string, unknown>)[descriptor.name];\n if (value !== undefined && value !== null) {\n values[descriptor.name] = value;\n }\n }\n return values;\n }\n};\n"],"names":["ParametersHelper","collectParameterValues","instance","values","descriptor","parameterDescriptors","value","name","undefined"],"mappings":";;AAAA;AACA;AAIA;;UAGaA,gBAAAA,GAAmB;AAC5B;;;;AAIC,QACDC,wBAAuBC,QAAyB,EAAA;AAC5C,QAAA,MAAMC,SAAkC,EAAC;AACzC,QAAA,KAAK,MAAMC,UAAAA,IAAcF,QAAAA,CAASG,oBAAoB,CAAE;AACpD,YAAA,MAAMC,QAAQ,QAAgD,CAACF,UAAAA,CAAWG,IAAI,CAAC;YAC/E,IAAID,KAAAA,KAAUE,SAAAA,IAAaF,KAAAA,KAAU,IAAA,EAAM;AACvCH,gBAAAA,MAAM,CAACC,UAAAA,CAAWG,IAAI,CAAC,GAAGD,KAAAA;AAC9B,YAAA;AACJ,QAAA;QACA,OAAOH,MAAAA;AACX,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyDescriptor.js","sources":["../../../reflection/PropertyDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '@cratis/fundamentals';\n\n/**\n * Represents a property descriptor.\n */\nexport class PropertyDescriptor {\n /**\n * Initializes a new instance of the {@link PropertyDescriptor} class.\n * @param name Name of the property.\n * @param type Type of the property.\n * @param isOptional Whether the property is optional (nullable).\n */\n constructor(readonly name: string, readonly type: Constructor, readonly isOptional: boolean = false) {\n }\n}\n"],"names":["PropertyDescriptor","type","isOptional","name"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,MAAMA,kBAAAA,CAAAA;;;;AACT;;;;;QAMA,WAAA,CAAY,IAAqB,EAAWC,IAAiB,EAAWC,UAAAA,GAAsB,KAAK,CAAE;aAAhFC,IAAAA,GAAAA,IAAAA;aAAuBF,IAAAA,GAAAA,IAAAA;aAA4BC,UAAAA,GAAAA,UAAAA;AACxE,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"PropertyDescriptor.js","sources":["../../../reflection/PropertyDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '@cratis/fundamentals';\n\n/**\n * Represents a property descriptor.\n */\nexport class PropertyDescriptor {\n /**\n * Initializes a new instance of the {@link PropertyDescriptor} class.\n * @param name Name of the property.\n * @param type Type of the property.\n * @param isOptional Whether the property is optional (nullable).\n */\n constructor(readonly name: string, readonly type: Constructor, readonly isOptional: boolean = false) {\n }\n}\n"],"names":["PropertyDescriptor","type","isOptional","name"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,MAAMA,kBAAAA,CAAAA;;;;AACT;;;;;QAMA,WAAA,CAAY,IAAqB,EAAWC,IAAiB,EAAWC,UAAAA,GAAsB,KAAK,CAAE;aAAhFC,IAAAA,GAAAA,IAAAA;aAAuBF,IAAAA,GAAAA,IAAAA;aAA4BC,UAAAA,GAAAA,UAAAA;AACxE,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../reflection/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 './IHaveParameters';\nexport * from './ParameterDescriptor';\nexport * from './ParametersHelper';\nexport * from './PropertyDescriptor';\n"],"names":[],"mappings":";;;;;;AAAA;AACA
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../reflection/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 './IHaveParameters';\nexport * from './ParameterDescriptor';\nexport * from './ParametersHelper';\nexport * from './PropertyDescriptor';\n"],"names":[],"mappings":";;;;;;AAAA;AACA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRule.js","sources":["../../../validation/PropertyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/**\n * Base class for property-based validation rules.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {\n protected errorMessage: string;\n\n /**\n * Initializes a new instance of the {@link PropertyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param defaultErrorMessage The default error message if validation fails.\n */\n constructor(\n protected readonly propertyAccessor: (instance: T) => TProperty,\n defaultErrorMessage: string\n ) {\n this.errorMessage = defaultErrorMessage;\n }\n\n /**\n * Set a custom error message for this rule.\n * @param message The custom error message.\n * @returns This rule instance for chaining.\n */\n withMessage(message: string): this {\n this.errorMessage = message;\n return this;\n }\n\n /** @inheritdoc */\n validate(instance: T, propertyName: string): ValidationResult[] {\n const value = this.propertyAccessor(instance);\n if (!this.isValid(value, instance)) {\n return [new ValidationResult(\n ValidationResultSeverity.Error,\n this.errorMessage.replace('{PropertyName}', propertyName),\n [propertyName],\n null\n )];\n }\n return [];\n }\n\n /**\n * Determine if the property value is valid.\n * @param value The property value.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n protected abstract isValid(value: TProperty, instance: T): boolean;\n}\n"],"names":["PropertyRule","errorMessage","propertyAccessor","defaultErrorMessage","withMessage","message","validate","instance","propertyName","value","isValid","ValidationResult","ValidationResultSeverity","Error","replace"],"mappings":";;;;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;;IACRC,YAAAA;AAEV;;;;AAIC,QACD,WAAA,CACuBC,gBAA4C,EAC/DC,mBAA2B,CAC7B;aAFqBD,gBAAAA,GAAAA,gBAAAA;QAGnB,IAAI,CAACD,YAAY,GAAGE,mBAAAA;AACxB,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAAQ;QAC/B,IAAI,CAACJ,YAAY,GAAGI,OAAAA;AACpB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA,uBACAC,QAAAA,CAASC,QAAW,EAAEC,YAAoB,EAAsB;AAC5D,QAAA,MAAMC,KAAAA,GAAQ,IAAI,CAACP,gBAAgB,CAACK,QAAAA,CAAAA;AACpC,QAAA,IAAI,CAAC,IAAI,CAACG,OAAO,CAACD,OAAOF,QAAAA,CAAAA,EAAW;YAChC,OAAO;gBAAC,IAAII,iCAAAA,CACRC,iDAAAA,CAAyBC,KAAK,EAC9B,IAAI,CAACZ,YAAY,CAACa,OAAO,CAAC,gBAAA,EAAkBN,YAAAA,CAAAA,EAC5C;AAACA,oBAAAA;iBAAa,EACd,IAAA;AACF,aAAA;AACN,QAAA;AACA,QAAA,OAAO,EAAE;AACb,IAAA;AASJ
|
|
1
|
+
{"version":3,"file":"PropertyRule.js","sources":["../../../validation/PropertyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/**\n * Base class for property-based validation rules.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {\n protected errorMessage: string;\n\n /**\n * Initializes a new instance of the {@link PropertyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param defaultErrorMessage The default error message if validation fails.\n */\n constructor(\n protected readonly propertyAccessor: (instance: T) => TProperty,\n defaultErrorMessage: string\n ) {\n this.errorMessage = defaultErrorMessage;\n }\n\n /**\n * Set a custom error message for this rule.\n * @param message The custom error message.\n * @returns This rule instance for chaining.\n */\n withMessage(message: string): this {\n this.errorMessage = message;\n return this;\n }\n\n /** @inheritdoc */\n validate(instance: T, propertyName: string): ValidationResult[] {\n const value = this.propertyAccessor(instance);\n if (!this.isValid(value, instance)) {\n return [new ValidationResult(\n ValidationResultSeverity.Error,\n this.errorMessage.replace('{PropertyName}', propertyName),\n [propertyName],\n null\n )];\n }\n return [];\n }\n\n /**\n * Determine if the property value is valid.\n * @param value The property value.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n protected abstract isValid(value: TProperty, instance: T): boolean;\n}\n"],"names":["PropertyRule","errorMessage","propertyAccessor","defaultErrorMessage","withMessage","message","validate","instance","propertyName","value","isValid","ValidationResult","ValidationResultSeverity","Error","replace"],"mappings":";;;;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;;IACRC,YAAAA;AAEV;;;;AAIC,QACD,WAAA,CACuBC,gBAA4C,EAC/DC,mBAA2B,CAC7B;aAFqBD,gBAAAA,GAAAA,gBAAAA;QAGnB,IAAI,CAACD,YAAY,GAAGE,mBAAAA;AACxB,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAAQ;QAC/B,IAAI,CAACJ,YAAY,GAAGI,OAAAA;AACpB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA,uBACAC,QAAAA,CAASC,QAAW,EAAEC,YAAoB,EAAsB;AAC5D,QAAA,MAAMC,KAAAA,GAAQ,IAAI,CAACP,gBAAgB,CAACK,QAAAA,CAAAA;AACpC,QAAA,IAAI,CAAC,IAAI,CAACG,OAAO,CAACD,OAAOF,QAAAA,CAAAA,EAAW;YAChC,OAAO;gBAAC,IAAII,iCAAAA,CACRC,iDAAAA,CAAyBC,KAAK,EAC9B,IAAI,CAACZ,YAAY,CAACa,OAAO,CAAC,gBAAA,EAAkBN,YAAAA,CAAAA,EAC5C;AAACA,oBAAAA;iBAAa,EACd,IAAA;AACF,aAAA;AACN,QAAA;AACA,QAAA,OAAO,EAAE;AACb,IAAA;AASJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyValidator.js","sources":["../../../validation/PropertyValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\n\n/**\n * Represents a validator for a specific property.\n * @template T The type being validated.\n */\nexport class PropertyValidator<T> {\n private readonly _rules: IValidationRule<T>[] = [];\n\n /**\n * Initializes a new instance of the {@link PropertyValidator} class.\n * @param propertyName The name of the property being validated.\n */\n constructor(readonly propertyName: string) {\n }\n\n /**\n * Add a validation rule to this property validator.\n * @param rule The rule to add.\n */\n addRule(rule: IValidationRule<T>): void {\n this._rules.push(rule);\n }\n\n /**\n * Validate the property value.\n * @param instance The instance being validated.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const rule of this._rules) {\n const ruleResults = rule.validate(instance, this.propertyName);\n results.push(...ruleResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the property is valid.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n isValid(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n}\n"],"names":["PropertyValidator","_rules","propertyName","addRule","rule","push","validate","instance","results","ruleResults","isValid","length"],"mappings":";;AAAA;AACA;AAKA;;;AAGC,IACM,MAAMA,iBAAAA,CAAAA;;AACQC,IAAAA,MAAAA,GAA+B,EAAE;AAElD;;;QAIA,WAAA,CAAY,YAA6B,CAAE;aAAtBC,YAAAA,GAAAA,YAAAA;AACrB,IAAA;AAEA;;;QAIAC,OAAAA,CAAQC,IAAwB,EAAQ;AACpC,QAAA,IAAI,CAACH,MAAM,CAACI,IAAI,CAACD,IAAAA,CAAAA;AACrB,IAAA;AAEA;;;;QAKAE,QAAAA,CAASC,QAAW,EAAsB;AACtC,QAAA,MAAMC,UAA8B,EAAE;AACtC,QAAA,KAAK,MAAMJ,IAAAA,IAAQ,IAAI,CAACH,MAAM,CAAE;AAC5B,YAAA,MAAMQ,cAAcL,IAAAA,CAAKE,QAAQ,CAACC,QAAAA,EAAU,IAAI,CAACL,YAAY,CAAA;AAC7DM,YAAAA,OAAAA,CAAQH,IAAI,CAAA,GAAII,WAAAA,CAAAA;AACpB,QAAA;QACA,OAAOD,OAAAA;AACX,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQH,QAAW,EAAW;AAC1B,QAAA,OAAO,IAAI,CAACD,QAAQ,CAACC,QAAAA,CAAAA,CAAUI,MAAM,KAAK,CAAA;AAC9C,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"PropertyValidator.js","sources":["../../../validation/PropertyValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\n\n/**\n * Represents a validator for a specific property.\n * @template T The type being validated.\n */\nexport class PropertyValidator<T> {\n private readonly _rules: IValidationRule<T>[] = [];\n\n /**\n * Initializes a new instance of the {@link PropertyValidator} class.\n * @param propertyName The name of the property being validated.\n */\n constructor(readonly propertyName: string) {\n }\n\n /**\n * Add a validation rule to this property validator.\n * @param rule The rule to add.\n */\n addRule(rule: IValidationRule<T>): void {\n this._rules.push(rule);\n }\n\n /**\n * Validate the property value.\n * @param instance The instance being validated.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const rule of this._rules) {\n const ruleResults = rule.validate(instance, this.propertyName);\n results.push(...ruleResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the property is valid.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n isValid(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n}\n"],"names":["PropertyValidator","_rules","propertyName","addRule","rule","push","validate","instance","results","ruleResults","isValid","length"],"mappings":";;AAAA;AACA;AAKA;;;AAGC,IACM,MAAMA,iBAAAA,CAAAA;;AACQC,IAAAA,MAAAA,GAA+B,EAAE;AAElD;;;QAIA,WAAA,CAAY,YAA6B,CAAE;aAAtBC,YAAAA,GAAAA,YAAAA;AACrB,IAAA;AAEA;;;QAIAC,OAAAA,CAAQC,IAAwB,EAAQ;AACpC,QAAA,IAAI,CAACH,MAAM,CAACI,IAAI,CAACD,IAAAA,CAAAA;AACrB,IAAA;AAEA;;;;QAKAE,QAAAA,CAASC,QAAW,EAAsB;AACtC,QAAA,MAAMC,UAA8B,EAAE;AACtC,QAAA,KAAK,MAAMJ,IAAAA,IAAQ,IAAI,CAACH,MAAM,CAAE;AAC5B,YAAA,MAAMQ,cAAcL,IAAAA,CAAKE,QAAQ,CAACC,QAAAA,EAAU,IAAI,CAACL,YAAY,CAAA;AAC7DM,YAAAA,OAAAA,CAAQH,IAAI,CAAA,GAAII,WAAAA,CAAAA;AACpB,QAAA;QACA,OAAOD,OAAAA;AACX,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQH,QAAW,EAAW;AAC1B,QAAA,OAAO,IAAI,CAACD,QAAQ,CAACC,QAAAA,CAAAA,CAAUI,MAAM,KAAK,CAAA;AAC9C,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBuilder.js","sources":["../../../validation/RuleBuilder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyValidator } from './PropertyValidator';\nimport { IValidationRule } from './IValidationRule';\nimport { PropertyRule } from './PropertyRule';\n\n/**\n * Represents a builder for creating validation rules for a property.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport class RuleBuilder<T, TProperty> {\n private lastRule?: IValidationRule<T>;\n\n /**\n * Initializes a new instance of the {@link RuleBuilder} class.\n * @param propertyValidator The property validator to add rules to.\n * @param _propertyAccessor Function to access the property value.\n */\n constructor(\n private readonly propertyValidator: PropertyValidator<T>,\n private readonly _propertyAccessor: (instance: T) => TProperty\n ) {\n }\n\n /**\n * Add a custom validation rule.\n * @param rule The validation rule to add.\n * @returns The rule builder for chaining.\n */\n addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty> {\n this.propertyValidator.addRule(rule);\n this.lastRule = rule;\n return this;\n }\n\n /**\n * Set a custom error message for the last added rule.\n * @param message The custom error message.\n * @returns The rule builder for chaining.\n */\n withMessage(message: string): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withMessage(message);\n }\n return this;\n }\n}\n"],"names":["RuleBuilder","lastRule","_propertyAccessor","propertyValidator","addRule","rule","withMessage","message","PropertyRule"],"mappings":";;;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAMA,WAAAA,CAAAA;;;IACDC,QAAAA;AAER;;;;AAIC,QACD,YACI,iBAAwD,EACvCC,iBAA6C,CAChE;aAFmBC,iBAAAA,GAAAA,iBAAAA;aACAD,iBAAAA,GAAAA,iBAAAA;AAErB,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQC,IAAwB,EAA6B;AACzD,QAAA,IAAI,CAACF,iBAAiB,CAACC,OAAO,CAACC,IAAAA,CAAAA;QAC/B,IAAI,CAACJ,QAAQ,GAAGI,IAAAA;AAChB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAA6B;QACpD,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,CAACA,QAAQ,YAAYO,yBAAAA,EAAc;AACxD,YAAA,IAAI,CAACP,QAAQ,CAACK,WAAW,CAACC,OAAAA,CAAAA;AAC9B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"RuleBuilder.js","sources":["../../../validation/RuleBuilder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyValidator } from './PropertyValidator';\nimport { IValidationRule } from './IValidationRule';\nimport { PropertyRule } from './PropertyRule';\n\n/**\n * Represents a builder for creating validation rules for a property.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport class RuleBuilder<T, TProperty> {\n private lastRule?: IValidationRule<T>;\n\n /**\n * Initializes a new instance of the {@link RuleBuilder} class.\n * @param propertyValidator The property validator to add rules to.\n * @param _propertyAccessor Function to access the property value.\n */\n constructor(\n private readonly propertyValidator: PropertyValidator<T>,\n private readonly _propertyAccessor: (instance: T) => TProperty\n ) {\n }\n\n /**\n * Add a custom validation rule.\n * @param rule The validation rule to add.\n * @returns The rule builder for chaining.\n */\n addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty> {\n this.propertyValidator.addRule(rule);\n this.lastRule = rule;\n return this;\n }\n\n /**\n * Set a custom error message for the last added rule.\n * @param message The custom error message.\n * @returns The rule builder for chaining.\n */\n withMessage(message: string): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withMessage(message);\n }\n return this;\n }\n}\n"],"names":["RuleBuilder","lastRule","_propertyAccessor","propertyValidator","addRule","rule","withMessage","message","PropertyRule"],"mappings":";;;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAMA,WAAAA,CAAAA;;;IACDC,QAAAA;AAER;;;;AAIC,QACD,YACI,iBAAwD,EACvCC,iBAA6C,CAChE;aAFmBC,iBAAAA,GAAAA,iBAAAA;aACAD,iBAAAA,GAAAA,iBAAAA;AAErB,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQC,IAAwB,EAA6B;AACzD,QAAA,IAAI,CAACF,iBAAiB,CAACC,OAAO,CAACC,IAAAA,CAAAA;QAC/B,IAAI,CAACJ,QAAQ,GAAGI,IAAAA;AAChB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAA6B;QACpD,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,CAACA,QAAQ,YAAYO,yBAAAA,EAAc;AACxD,YAAA,IAAI,CAACP,QAAQ,CAACK,WAAW,CAACC,OAAAA,CAAAA;AAC9B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBuilderExtensions.js","sources":["../../../validation/RuleBuilderExtensions.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 { RuleBuilder } from './RuleBuilder';\nimport { NotEmptyRule, NotNullRule } from './rules/NotEmptyRule';\nimport { MinLengthRule, MaxLengthRule, LengthRule } from './rules/LengthRules';\nimport { EmailRule } from './rules/EmailRule';\nimport { PhoneRule } from './rules/PhoneRule';\nimport { UrlRule } from './rules/UrlRule';\nimport { RegexRule } from './rules/RegexRule';\nimport { GreaterThanRule, GreaterThanOrEqualRule, LessThanRule, LessThanOrEqualRule } from './rules/ComparisonRules';\n\n/**\n * Extension methods for {@link RuleBuilder} to add validation rules in a fluent manner.\n */\n\n/**\n * Add a rule that the property must not be empty (not null, undefined, empty string, or empty array).\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notEmpty<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotEmptyRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the property must not be null or undefined.\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notNull<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotNullRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must have at least the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The minimum length.\n * @returns The rule builder for chaining.\n */\nexport function minLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MinLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have at most the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function maxLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MaxLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have a length between min and max.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param min The minimum length.\n * @param max The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function length<T>(this: RuleBuilder<T, string>, min: number, max: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new LengthRule<T>(propertyAccessor, min, max));\n}\n\n/**\n * Add a rule that the string property must be a valid email address.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function emailAddress<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new EmailRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid phone number.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function phone<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new PhoneRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid URL.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function url<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new UrlRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must match the specified regular expression.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param pattern The regular expression pattern.\n * @param errorMessage Optional error message.\n * @returns The rule builder for chaining.\n */\nexport function matches<T>(this: RuleBuilder<T, string>, pattern: RegExp, errorMessage?: string): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new RegexRule<T>(propertyAccessor, pattern, errorMessage));\n}\n\n/**\n * Add a rule that the number property must be greater than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be greater than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n// Add the extension methods to the RuleBuilder prototype\nRuleBuilder.prototype.notEmpty = notEmpty;\nRuleBuilder.prototype.notNull = notNull;\n(RuleBuilder.prototype as unknown as { minLength: typeof minLength }).minLength = minLength;\n(RuleBuilder.prototype as unknown as { maxLength: typeof maxLength }).maxLength = maxLength;\n(RuleBuilder.prototype as unknown as { length: typeof length }).length = length;\n(RuleBuilder.prototype as unknown as { emailAddress: typeof emailAddress }).emailAddress = emailAddress;\n(RuleBuilder.prototype as unknown as { phone: typeof phone }).phone = phone;\n(RuleBuilder.prototype as unknown as { url: typeof url }).url = url;\n(RuleBuilder.prototype as unknown as { matches: typeof matches }).matches = matches;\n(RuleBuilder.prototype as unknown as { greaterThan: typeof greaterThan }).greaterThan = greaterThan;\n(RuleBuilder.prototype as unknown as { greaterThanOrEqual: typeof greaterThanOrEqual }).greaterThanOrEqual = greaterThanOrEqual;\n(RuleBuilder.prototype as unknown as { lessThan: typeof lessThan }).lessThan = lessThan;\n(RuleBuilder.prototype as unknown as { lessThanOrEqual: typeof lessThanOrEqual }).lessThanOrEqual = lessThanOrEqual;\n\n// Extend the RuleBuilder interface to include these methods\ndeclare module './RuleBuilder' {\n interface RuleBuilder<T, TProperty> {\n notEmpty(): RuleBuilder<T, TProperty>;\n notNull(): RuleBuilder<T, TProperty>;\n minLength(length: number): RuleBuilder<T, TProperty>;\n maxLength(length: number): RuleBuilder<T, TProperty>;\n length(min: number, max: number): RuleBuilder<T, TProperty>;\n emailAddress(): RuleBuilder<T, TProperty>;\n phone(): RuleBuilder<T, TProperty>;\n url(): RuleBuilder<T, TProperty>;\n matches(pattern: RegExp, errorMessage?: string): RuleBuilder<T, TProperty>;\n greaterThan(threshold: number): RuleBuilder<T, TProperty>;\n greaterThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n lessThan(threshold: number): RuleBuilder<T, TProperty>;\n lessThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n }\n}\n"],"names":["notEmpty","propertyAccessor","_propertyAccessor","addRule","NotEmptyRule","notNull","NotNullRule","minLength","length","MinLengthRule","maxLength","MaxLengthRule","min","max","LengthRule","emailAddress","EmailRule","phone","PhoneRule","url","UrlRule","matches","pattern","errorMessage","RegexRule","greaterThan","threshold","GreaterTh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AGA,eAAAA;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"RuleBuilderExtensions.js","sources":["../../../validation/RuleBuilderExtensions.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 { RuleBuilder } from './RuleBuilder';\nimport { NotEmptyRule, NotNullRule } from './rules/NotEmptyRule';\nimport { MinLengthRule, MaxLengthRule, LengthRule } from './rules/LengthRules';\nimport { EmailRule } from './rules/EmailRule';\nimport { PhoneRule } from './rules/PhoneRule';\nimport { UrlRule } from './rules/UrlRule';\nimport { RegexRule } from './rules/RegexRule';\nimport { GreaterThanRule, GreaterThanOrEqualRule, LessThanRule, LessThanOrEqualRule } from './rules/ComparisonRules';\n\n/**\n * Extension methods for {@link RuleBuilder} to add validation rules in a fluent manner.\n */\n\n/**\n * Add a rule that the property must not be empty (not null, undefined, empty string, or empty array).\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notEmpty<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotEmptyRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the property must not be null or undefined.\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notNull<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotNullRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must have at least the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The minimum length.\n * @returns The rule builder for chaining.\n */\nexport function minLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MinLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have at most the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function maxLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MaxLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have a length between min and max.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param min The minimum length.\n * @param max The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function length<T>(this: RuleBuilder<T, string>, min: number, max: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new LengthRule<T>(propertyAccessor, min, max));\n}\n\n/**\n * Add a rule that the string property must be a valid email address.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function emailAddress<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new EmailRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid phone number.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function phone<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new PhoneRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid URL.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function url<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new UrlRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must match the specified regular expression.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param pattern The regular expression pattern.\n * @param errorMessage Optional error message.\n * @returns The rule builder for chaining.\n */\nexport function matches<T>(this: RuleBuilder<T, string>, pattern: RegExp, errorMessage?: string): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new RegexRule<T>(propertyAccessor, pattern, errorMessage));\n}\n\n/**\n * Add a rule that the number property must be greater than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be greater than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n// Add the extension methods to the RuleBuilder prototype\nRuleBuilder.prototype.notEmpty = notEmpty;\nRuleBuilder.prototype.notNull = notNull;\n(RuleBuilder.prototype as unknown as { minLength: typeof minLength }).minLength = minLength;\n(RuleBuilder.prototype as unknown as { maxLength: typeof maxLength }).maxLength = maxLength;\n(RuleBuilder.prototype as unknown as { length: typeof length }).length = length;\n(RuleBuilder.prototype as unknown as { emailAddress: typeof emailAddress }).emailAddress = emailAddress;\n(RuleBuilder.prototype as unknown as { phone: typeof phone }).phone = phone;\n(RuleBuilder.prototype as unknown as { url: typeof url }).url = url;\n(RuleBuilder.prototype as unknown as { matches: typeof matches }).matches = matches;\n(RuleBuilder.prototype as unknown as { greaterThan: typeof greaterThan }).greaterThan = greaterThan;\n(RuleBuilder.prototype as unknown as { greaterThanOrEqual: typeof greaterThanOrEqual }).greaterThanOrEqual = greaterThanOrEqual;\n(RuleBuilder.prototype as unknown as { lessThan: typeof lessThan }).lessThan = lessThan;\n(RuleBuilder.prototype as unknown as { lessThanOrEqual: typeof lessThanOrEqual }).lessThanOrEqual = lessThanOrEqual;\n\n// Extend the RuleBuilder interface to include these methods\ndeclare module './RuleBuilder' {\n interface RuleBuilder<T, TProperty> {\n notEmpty(): RuleBuilder<T, TProperty>;\n notNull(): RuleBuilder<T, TProperty>;\n minLength(length: number): RuleBuilder<T, TProperty>;\n maxLength(length: number): RuleBuilder<T, TProperty>;\n length(min: number, max: number): RuleBuilder<T, TProperty>;\n emailAddress(): RuleBuilder<T, TProperty>;\n phone(): RuleBuilder<T, TProperty>;\n url(): RuleBuilder<T, TProperty>;\n matches(pattern: RegExp, errorMessage?: string): RuleBuilder<T, TProperty>;\n greaterThan(threshold: number): RuleBuilder<T, TProperty>;\n greaterThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n lessThan(threshold: number): RuleBuilder<T, TProperty>;\n lessThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n }\n}\n"],"names":["notEmpty","propertyAccessor","_propertyAccessor","addRule","NotEmptyRule","notNull","NotNullRule","minLength","length","MinLengthRule","maxLength","MaxLengthRule","min","max","LengthRule","emailAddress","EmailRule","phone","PhoneRule","url","UrlRule","matches","pattern","errorMessage","RegexRule","greaterThan","threshold","GreaterThanRule","greaterThanOrEqual","GreaterThanOrEqualRule","lessThan","LessThanRule","lessThanOrEqual","LessThanOrEqualRule","RuleBuilder","prototype"],"mappings":";;;;;;;;;;;AAAA;AACA;AAWA;;;;;;;;AAUC,IACM,SAASA,QAAAA,GAAAA;AACZ,IAAA,MAAMC,gBAAAA,GAAoB,IAAI,CAAkEC,iBAAiB;AACjH,IAAA,OAAO,IAAI,CAACC,OAAO,CAAC,IAAIC,yBAAAA,CAAgBH,gBAAAA,CAAAA,CAAAA;AAC5C;AAEA;;;;;;AAMC,IACM,SAASI,OAAAA,GAAAA;AACZ,IAAA,MAAMJ,gBAAAA,GAAoB,IAAI,CAAkEC,iBAAiB;AACjH,IAAA,OAAO,IAAI,CAACC,OAAO,CAAC,IAAIG,wBAAAA,CAAeL,gBAAAA,CAAAA,CAAAA;AAC3C;AAEA;;;;;;IAOO,SAASM,SAAAA,CAA2CC,MAAc,EAAA;AACrE,IAAA,MAAMP,gBAAAA,GAAoB,IAAI,CAA+DC,iBAAiB;AAC9G,IAAA,OAAO,IAAI,CAACC,OAAO,CAAC,IAAIM,0BAAiBR,gBAAAA,EAAkBO,MAAAA,CAAAA,CAAAA;AAC/D;AAEA;;;;;;IAOO,SAASE,SAAAA,CAA2CF,MAAc,EAAA;AACrE,IAAA,MAAMP,gBAAAA,GAAoB,IAAI,CAA+DC,iBAAiB;AAC9G,IAAA,OAAO,IAAI,CAACC,OAAO,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AAA;AACrEiB,uBAAAA,CAAYC,SAAS,CAAoChB,GAAG,GAAGA,GAAAA;AAC/De,uBAAAA,CAAYC,SAAS,CAA4Cd,OAAO,GAAGA,OAAAA;AAC3Ea,uBAAAA,CAAYC,SAAS,CAAoDV,WAAW,GAAGA,WAAAA;AACvFS,uBAAAA,CAAYC,SAAS,CAAkEP,kBAAkB,GAAGA,kBAAAA;AAC5GM,uBAAAA,CAAYC,SAAS,CAA8CL,QAAQ,GAAGA,QAAAA;AAC9EI,uBAAAA,CAAYC,SAAS,CAA4DH,eAAe,GAAGA,eAAAA;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResultReason } from './ValidationResultReason';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated\n * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.\n * Branch on this rather than matching {@link message}, which is prose and free to change.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule,\n readonly reasonDetail?: string) {\n }\n}\n"],"names":["ValidationResult","reason","ValidationResultReason","Rule","reasonDetail","severity","message","members","state"],"mappings":";;;;AAAA;AACA;AAKA;;AAIC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;;AACT;;;;;;;;;;QAWA,WAAA,CACI,QAA2C,EAC3C,OAAwB,EACxB,OAA0B,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,6CAAAA,CAAuBC,IAAI,EAC5DC,YAAqB,CAAE;aALvBC,QAAAA,GAAAA,QAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,KAAAA,GAAAA,KAAAA;aACAP,MAAAA,GAAAA,MAAAA;aACAG,YAAAA,GAAAA,YAAAA;AACb,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResultReason } from './ValidationResultReason';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated\n * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.\n * Branch on this rather than matching {@link message}, which is prose and free to change.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule,\n readonly reasonDetail?: string) {\n }\n}\n"],"names":["ValidationResult","reason","ValidationResultReason","Rule","reasonDetail","severity","message","members","state"],"mappings":";;;;AAAA;AACA;AAKA;;AAIC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;;AACT;;;;;;;;;;QAWA,WAAA,CACI,QAA2C,EAC3C,OAAwB,EACxB,OAA0B,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,6CAAAA,CAAuBC,IAAI,EAC5DC,YAAqB,CAAE;aALvBC,QAAAA,GAAAA,QAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,KAAAA,GAAAA,KAAAA;aACAP,MAAAA,GAAAA,MAAAA;aACAG,YAAAA,GAAAA,YAAAA;AACb,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResultReason.js","sources":["../../../validation/ValidationResultReason.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 the well-known values for what composed a validation result - the machine-readable counterpart to its\n * message.\n * @remarks\n * A rejection's message is a developer diagnostic, not copy to show a user. Branch on this instead of matching the\n * message, and render your own wording for anything the framework composed.\n *\n * This is deliberately not an enum. Rejections are composed in Arc, in Chronicle and in application code, so the set\n * is open: treat an unrecognized value the way you would treat {@link ValidationResultReason.Rule} rather than as an\n * error.\n */\nexport const ValidationResultReason = {\n\n /**\n * A rule authored by the application rejected the input. The message is the author's, and is meant to be shown.\n */\n Rule: 'rule',\n\n /**\n * The append was rejected because the event source moved on since it was read. Retryable - re-read and resubmit.\n */\n ConcurrencyViolation: 'concurrencyViolation',\n\n /**\n * A constraint on the event store rejected the append.\n */\n ConstraintViolation: 'constraintViolation',\n\n /**\n * A validator threw, and the framework substituted this result for the one the validator would have produced.\n * Nothing the author wrote survives, so the message is not theirs to show.\n */\n ValidatorFailed: 'validatorFailed',\n\n /**\n * Something the command needed in order to be evaluated was not available, most often the read model a\n * validator depends on. Raised before any rule ran, so nothing about the command's own rules was decided.\n */\n DependencyUnavailable: 'dependencyUnavailable',\n\n /**\n * The request itself could not be read - a malformed body, or a value that could not be bound. No rule was\n * reached.\n */\n MalformedRequest: 'malformedRequest'\n} as const;\n\n/**\n * The type of a validation result reason. Widened to string because the set is open.\n */\nexport type ValidationResultReason = string;\n"],"names":["ValidationResultReason","Rule","ConcurrencyViolation","ConstraintViolation","ValidatorFailed","DependencyUnavailable","MalformedRequest"],"mappings":";;AAAA;AACA;AAEA;;;;;;;;;;UAWaA,sBAAAA,GAAyB;AAElC;;AAEC,QACDC,IAAAA,EAAM,MAAA;AAEN;;AAEC,QACDC,oBAAAA,EAAsB,sBAAA;AAEtB;;AAEC,QACDC,mBAAAA,EAAqB,qBAAA;AAErB;;;AAGC,QACDC,eAAAA,EAAiB,iBAAA;AAEjB;;;AAGC,QACDC,qBAAAA,EAAuB,uBAAA;AAEvB;;;AAGC,QACDC,gBAAAA,EAAkB;AACtB
|
|
1
|
+
{"version":3,"file":"ValidationResultReason.js","sources":["../../../validation/ValidationResultReason.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 the well-known values for what composed a validation result - the machine-readable counterpart to its\n * message.\n * @remarks\n * A rejection's message is a developer diagnostic, not copy to show a user. Branch on this instead of matching the\n * message, and render your own wording for anything the framework composed.\n *\n * This is deliberately not an enum. Rejections are composed in Arc, in Chronicle and in application code, so the set\n * is open: treat an unrecognized value the way you would treat {@link ValidationResultReason.Rule} rather than as an\n * error.\n */\nexport const ValidationResultReason = {\n\n /**\n * A rule authored by the application rejected the input. The message is the author's, and is meant to be shown.\n */\n Rule: 'rule',\n\n /**\n * The append was rejected because the event source moved on since it was read. Retryable - re-read and resubmit.\n */\n ConcurrencyViolation: 'concurrencyViolation',\n\n /**\n * A constraint on the event store rejected the append.\n */\n ConstraintViolation: 'constraintViolation',\n\n /**\n * A validator threw, and the framework substituted this result for the one the validator would have produced.\n * Nothing the author wrote survives, so the message is not theirs to show.\n */\n ValidatorFailed: 'validatorFailed',\n\n /**\n * Something the command needed in order to be evaluated was not available, most often the read model a\n * validator depends on. Raised before any rule ran, so nothing about the command's own rules was decided.\n */\n DependencyUnavailable: 'dependencyUnavailable',\n\n /**\n * The request itself could not be read - a malformed body, or a value that could not be bound. No rule was\n * reached.\n */\n MalformedRequest: 'malformedRequest'\n} as const;\n\n/**\n * The type of a validation result reason. Widened to string because the set is open.\n */\nexport type ValidationResultReason = string;\n"],"names":["ValidationResultReason","Rule","ConcurrencyViolation","ConstraintViolation","ValidatorFailed","DependencyUnavailable","MalformedRequest"],"mappings":";;AAAA;AACA;AAEA;;;;;;;;;;UAWaA,sBAAAA,GAAyB;AAElC;;AAEC,QACDC,IAAAA,EAAM,MAAA;AAEN;;AAEC,QACDC,oBAAAA,EAAsB,sBAAA;AAEtB;;AAEC,QACDC,mBAAAA,EAAqB,qBAAA;AAErB;;;AAGC,QACDC,eAAAA,EAAiB,iBAAA;AAEjB;;;AAGC,QACDC,qBAAAA,EAAuB,uBAAA;AAEvB;;;AAGC,QACDC,gBAAAA,EAAkB;AACtB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResultSeverity.js","sources":["../../../validation/ValidationResultSeverity.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 the values for severity of a validation result.\n */\nexport enum ValidationResultSeverity {\n\n /**\n * The validation result is unknown.\n */\n Unknown = 0,\n\n /**\n * The validation result is a warning.\n */\n Information = 1,\n\n /**\n * The validation result is a warning.\n */\n Warning = 2,\n\n /**\n * The validation result is an error.\n */\n Error = 3\n}\n"],"names":["ValidationResultSeverity"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,wBAAAA,iBAAAA,SAAAA,wBAAAA,EAAAA;AAER;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,aAAA,CAAA,GACa,CAAA,CAAA,GAAA,aAAA;AAEd;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,OAAA,CAAA,GACO,CAAA,CAAA,GAAA,OAAA;AApBAA,IAAAA,OAAAA,wBAAAA;AAqBX,CAAA,CAAA,EAAA
|
|
1
|
+
{"version":3,"file":"ValidationResultSeverity.js","sources":["../../../validation/ValidationResultSeverity.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 the values for severity of a validation result.\n */\nexport enum ValidationResultSeverity {\n\n /**\n * The validation result is unknown.\n */\n Unknown = 0,\n\n /**\n * The validation result is a warning.\n */\n Information = 1,\n\n /**\n * The validation result is a warning.\n */\n Warning = 2,\n\n /**\n * The validation result is an error.\n */\n Error = 3\n}\n"],"names":["ValidationResultSeverity"],"mappings":";;AAAA;AACA;AAEA;;IAGO,IAAKA,wBAAAA,iBAAAA,SAAAA,wBAAAA,EAAAA;AAER;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,aAAA,CAAA,GACa,CAAA,CAAA,GAAA,aAAA;AAEd;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,OAAA,CAAA,GACO,CAAA,CAAA,GAAA,OAAA;AApBAA,IAAAA,OAAAA,wBAAAA;AAqBX,CAAA,CAAA,EAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.js","sources":["../../../validation/Validator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResult } from './ValidationResult';\nimport { PropertyValidator } from './PropertyValidator';\nimport { RuleBuilder } from './RuleBuilder';\n\n/**\n * Represents a validator for a type that builds validation rules programmatically.\n * @template T The type being validated.\n */\nexport class Validator<T = object> {\n private readonly _propertyValidators = new Map<string, PropertyValidator<T>>();\n\n /**\n * Define validation rules for a property.\n * @template TProperty The type of the property.\n * @param propertyAccessor Function to access the property from the instance.\n * @returns A rule builder for the property.\n */\n ruleFor<TProperty>(propertyAccessor: (instance: T) => TProperty): RuleBuilder<T, TProperty> {\n const propertyName = this.getPropertyName(propertyAccessor);\n let propertyValidator = this._propertyValidators.get(propertyName);\n \n if (!propertyValidator) {\n propertyValidator = new PropertyValidator<T>(propertyName);\n this._propertyValidators.set(propertyName, propertyValidator);\n }\n\n return new RuleBuilder<T, TProperty>(propertyValidator, propertyAccessor);\n }\n\n /**\n * Validate an instance.\n * @param instance The instance to validate.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const propertyValidator of this._propertyValidators.values()) {\n const propertyResults = propertyValidator.validate(instance);\n results.push(...propertyResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Gets whether or not a specific instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n isValidFor(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n\n private getPropertyName<TProperty>(propertyAccessor: (instance: T) => TProperty): string {\n // Create a proxy to capture property access\n const propertyNames: string[] = [];\n const proxy = new Proxy({} as Record<string, unknown>, {\n get(_target, prop) {\n if (typeof prop === 'string') {\n propertyNames.push(prop);\n }\n return undefined;\n }\n });\n\n try {\n propertyAccessor(proxy as T);\n } catch {\n // Ignore errors - we're just capturing the property name\n }\n\n return propertyNames[0] || 'unknown';\n }\n}\n"],"names":["Validator","_propertyValidators","Map","ruleFor","propertyAccessor","propertyName","getPropertyName","propertyValidator","get","PropertyValidator","set","RuleBuilder","validate","instance","results","values","propertyResults","push","isValid","isValidFor","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ErF,QAAA,MAAMiB,gBAA0B,EAAE;AAClC,QAAA,MAAMC,KAAAA,GAAQ,IAAIC,KAAAA,CAAM,EAAC,EAA8B;YACnDf,GAAAA,CAAAA,CAAIgB,OAAO,EAAEC,IAAI,EAAA;gBACb,IAAI,OAAOA,SAAS,QAAA,EAAU;AAC1BJ,oBAAAA,aAAAA,CAAcJ,IAAI,CAACQ,IAAAA,CAAAA;AACvB,gBAAA;gBACA,OAAOC,SAAAA;AACX,YAAA;AACJ,SAAA,CAAA;QAEA,IAAI;YACAtB,gBAAAA,CAAiBkB,KAAAA,CAAAA;AACrB,QAAA,CAAA,CAAE,OAAM;;AAER,QAAA;QAEA,OAAOD,aAAa,CAAC,CAAA,CAAE,IAAI,SAAA;AAC/B,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"Validator.js","sources":["../../../validation/Validator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResult } from './ValidationResult';\nimport { PropertyValidator } from './PropertyValidator';\nimport { RuleBuilder } from './RuleBuilder';\n\n/**\n * Represents a validator for a type that builds validation rules programmatically.\n * @template T The type being validated.\n */\nexport class Validator<T = object> {\n private readonly _propertyValidators = new Map<string, PropertyValidator<T>>();\n\n /**\n * Define validation rules for a property.\n * @template TProperty The type of the property.\n * @param propertyAccessor Function to access the property from the instance.\n * @returns A rule builder for the property.\n */\n ruleFor<TProperty>(propertyAccessor: (instance: T) => TProperty): RuleBuilder<T, TProperty> {\n const propertyName = this.getPropertyName(propertyAccessor);\n let propertyValidator = this._propertyValidators.get(propertyName);\n \n if (!propertyValidator) {\n propertyValidator = new PropertyValidator<T>(propertyName);\n this._propertyValidators.set(propertyName, propertyValidator);\n }\n\n return new RuleBuilder<T, TProperty>(propertyValidator, propertyAccessor);\n }\n\n /**\n * Validate an instance.\n * @param instance The instance to validate.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const propertyValidator of this._propertyValidators.values()) {\n const propertyResults = propertyValidator.validate(instance);\n results.push(...propertyResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Gets whether or not a specific instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n isValidFor(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n\n private getPropertyName<TProperty>(propertyAccessor: (instance: T) => TProperty): string {\n // Create a proxy to capture property access\n const propertyNames: string[] = [];\n const proxy = new Proxy({} as Record<string, unknown>, {\n get(_target, prop) {\n if (typeof prop === 'string') {\n propertyNames.push(prop);\n }\n return undefined;\n }\n });\n\n try {\n propertyAccessor(proxy as T);\n } catch {\n // Ignore errors - we're just capturing the property name\n }\n\n return propertyNames[0] || 'unknown';\n }\n}\n"],"names":["Validator","_propertyValidators","Map","ruleFor","propertyAccessor","propertyName","getPropertyName","propertyValidator","get","PropertyValidator","set","RuleBuilder","validate","instance","results","values","propertyResults","push","isValid","isValidFor","length","propertyNames","proxy","Proxy","_target","prop","undefined"],"mappings":";;;;;AAAA;AACA;AAMA;;;AAGC,IACM,MAAMA,SAAAA,CAAAA;AACQC,IAAAA,mBAAAA,GAAsB,IAAIC,GAAAA,EAAAA;AAE3C;;;;;QAMAC,OAAAA,CAAmBC,gBAA4C,EAA6B;AACxF,QAAA,MAAMC,YAAAA,GAAe,IAAI,CAACC,eAAe,CAACF,gBAAAA,CAAAA;AAC1C,QAAA,IAAIG,oBAAoB,IAAI,CAACN,mBAAmB,CAACO,GAAG,CAACH,YAAAA,CAAAA;AAErD,QAAA,IAAI,CAACE,iBAAAA,EAAmB;AACpBA,YAAAA,iBAAAA,GAAoB,IAAIE,mCAAAA,CAAqBJ,YAAAA,CAAAA;AAC7C,YAAA,IAAI,CAACJ,mBAAmB,CAACS,GAAG,CAACL,YAAAA,EAAcE,iB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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';\nexport * from './ValidationResult';\nexport * from './ValidationResultReason';\nexport * from './ValidationResultSeverity';\nexport * from './IValidationRule';\nexport * from './PropertyValidator';\nexport * from './PropertyRule';\nexport * from './RuleBuilder';\nexport * from './RuleBuilderExtensions';\nexport * from './rules/NotEmptyRule';\nexport * from './rules/LengthRules';\nexport * from './rules/EmailRule';\nexport * from './rules/RegexRule';\nexport * from './rules/ComparisonRules';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA
|
|
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';\nexport * from './ValidationResult';\nexport * from './ValidationResultReason';\nexport * from './ValidationResultSeverity';\nexport * from './IValidationRule';\nexport * from './PropertyValidator';\nexport * from './PropertyRule';\nexport * from './RuleBuilder';\nexport * from './RuleBuilderExtensions';\nexport * from './rules/NotEmptyRule';\nexport * from './rules/LengthRules';\nexport * from './rules/EmailRule';\nexport * from './rules/RegexRule';\nexport * from './rules/ComparisonRules';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComparisonRules.js","sources":["../../../../validation/rules/ComparisonRules.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 { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a number is greater than a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value > this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is greater than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value >= this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than a specified value.\n * @template T The type being validated.\n */\nexport class LessThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value < this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class LessThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value <= this.threshold;\n }\n}\n"],"names":["GreaterThanRule","PropertyRule","propertyAccessor","threshold","isValid","value","undefined","GreaterThanOrEqualRule","LessThanRule","LessThanOrEqualRule"],"mappings":";;;;AAAA;AACA;AAIA;;;IAIO,MAAMA,eAAAA,SAA2BC,yBAAAA,CAAAA;;AACpC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,sCAAsC,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADTA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,GAAQ,IAAI,CAACF,SAAS;AACjC,IAAA;AACJ;AAEA;;;IAIO,MAAMI,sBAAAA,SAAkCN,yBAAAA,CAAAA;;AAC3C;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,kDAAkD,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADrBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,IAAS,IAAI,CAACF,SAAS;AAClC,IAAA;AACJ;AAEA;;;IAIO,MAAMK,YAAAA,SAAwBP,yBAAAA,CAAAA;;AACjC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,mCAAmC,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADNA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,GAAQ,IAAI,CAACF,SAAS;AACjC,IAAA;AACJ;AAEA;;;IAIO,MAAMM,mBAAAA,SAA+BR,yBAAAA,CAAAA;;AACxC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,+CAA+C,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADlBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,IAAS,IAAI,CAACF,SAAS;AAClC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"ComparisonRules.js","sources":["../../../../validation/rules/ComparisonRules.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 { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a number is greater than a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value > this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is greater than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value >= this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than a specified value.\n * @template T The type being validated.\n */\nexport class LessThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value < this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class LessThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value <= this.threshold;\n }\n}\n"],"names":["GreaterThanRule","PropertyRule","propertyAccessor","threshold","isValid","value","undefined","GreaterThanOrEqualRule","LessThanRule","LessThanOrEqualRule"],"mappings":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A,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,GAAQ,IAAI,CAACF,SAAS;AACjC,IAAA;AACJ;AAEA;;;IAIO,MAAMM,mBAAAA,SAA+BR,yBAAAA,CAAAA;;AACxC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,+CAA+C,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADlBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,IAAS,IAAI,CAACF,SAAS;AAClC,IAAA;AACJ;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailRule.js","sources":["../../../../validation/rules/EmailRule.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 { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string matches an email pattern.\n * @template T The type being validated.\n */\nexport class EmailRule<T> extends PropertyRule<T, string> {\n private static readonly emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n /**\n * Initializes a new instance of the {@link EmailRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid email address.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return EmailRule.emailRegex.test(value);\n }\n}\n"],"names":["EmailRule","PropertyRule","emailRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;;;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,yBAAAA,CAAAA;AAC9B,IAAA,OAAwBC,aAAa,4BAAA;AAErC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,gDAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,SAAAA,CAAUE,UAAU,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACrC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"EmailRule.js","sources":["../../../../validation/rules/EmailRule.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 { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string matches an email pattern.\n * @template T The type being validated.\n */\nexport class EmailRule<T> extends PropertyRule<T, string> {\n private static readonly emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n /**\n * Initializes a new instance of the {@link EmailRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid email address.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return EmailRule.emailRegex.test(value);\n }\n}\n"],"names":["EmailRule","PropertyRule","emailRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;;;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,yBAAAA,CAAAA;AAC9B,IAAA,OAAwBC,aAAa,4BAAA;AAErC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,gDAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,SAAAA,CAAUE,UAAU,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACrC,IAAA;AACJ;;"}
|