@ahoo-wang/fetcher-wow 2.16.2 → 2.16.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/command/commandClient.ts","../src/command/commandHeaders.ts","../src/command/types.ts","../src/query/operator.ts","../src/query/condition.ts","../src/query/pagination.ts","../src/query/projection.ts","../src/query/queryable.ts","../src/query/sort.ts","../src/query/event/domainEventStream.ts","../src/query/event/eventStreamQueryApi.ts","../src/query/event/eventStreamQueryClient.ts","../src/query/snapshot/snapshot.ts","../src/query/snapshot/snapshotQueryApi.ts","../src/query/snapshot/snapshotQueryClient.ts","../src/query/state/loadStateAggregateClient.ts","../src/query/state/loadOwnerStateAggregateClient.ts","../src/query/cursorQuery.ts","../src/query/queryClients.ts","../src/types/endpoints.ts","../src/types/error.ts","../src/types/function.ts","../src/types/modeling.ts","../src/types/bi.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type CommandRequest } from './commandRequest';\nimport {\n type CommandResult,\n type CommandResultEventStream,\n} from './commandResult';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport { JsonEventStreamResultExtractor } from '@ahoo-wang/fetcher-eventstream';\n\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n endpoint,\n request,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * Command Client for sending commands to the server.\n *\n * The CommandClient is responsible for sending commands to the server and handling the responses.\n * It provides methods for both regular command execution and streaming command results.\n *\n * @example\n * ```typescript\n * // Create a client options configuration\n * const clientOptions: ClientOptions = {\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart'\n * };\n *\n * // Create a command client instance\n * const commandClient = new CommandClient(clientOptions);\n *\n * // Define command endpoint\n * const addCartItem = 'add_cart_item';\n *\n * // Create a command request\n * const addCartItemCommand: CommandRequest<AddCartItem> = {\n * method: HttpMethod.POST,\n * headers: {\n * [CommandHttpHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,\n * },\n * body: {\n * productId: 'productId',\n * quantity: 1,\n * }\n * };\n *\n * // Send command and get result\n * const commandResult = await commandClient.send(addCartItem, addCartItemCommand);\n *\n * // Send command and get result as stream\n * const commandResultStream = await commandClient.sendAndWaitStream(addCartItem, addCartItemCommand);\n * for await (const commandResultEvent of commandResultStream) {\n * console.log('Received:', commandResultEvent.data);\n * }\n * ```\n */\n@api()\nexport class CommandClient<C extends object = object>\n implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n }\n\n /**\n * Send a command to the server and wait for the result.\n *\n * @param commandRequest - The command request to send\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the command execution result\n *\n * @example\n * ```typescript\n * const commandResult = await commandClient.send('add_cart_item', {\n * method: HttpMethod.POST,\n * body: {\n * productId: 'product-1',\n * quantity: 2\n * }\n * });\n * ```\n */\n @endpoint()\n send(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<CommandResult> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n\n /**\n * Send a command to the server and wait for the result as a stream.\n * This is useful for long-running commands that produce multiple events.\n *\n * @param commandRequest - The command request to send\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a stream of command execution results\n *\n * @example\n * ```typescript\n * const commandResultStream = await commandClient.sendAndWaitStream('add_cart_item', {\n * method: HttpMethod.POST,\n * headers: {\n * Accept: ContentTypeValues.TEXT_EVENT_STREAM\n * },\n * body: {\n * productId: 'product-1',\n * quantity: 2\n * }\n * });\n *\n * for await (const commandResultEvent of commandResultStream) {\n * console.log('Received event:', commandResultEvent.data);\n * }\n * ```\n */\n @endpoint(undefined, undefined, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n sendAndWaitStream(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<CommandResultEventStream> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Command Header Constants\n *\n * Defines standard HTTP header constants used in command processing within the Wow framework.\n * These headers are used to pass metadata and control information between services.\n *\n * @example\n * ```typescript\n * // Using header constants in a request\n * const request = {\n * headers: {\n * [CommandHttpHeaders.TENANT_ID]: 'tenant-123',\n * [CommandHttpHeaders.AGGREGATE_ID]: 'aggregate-456',\n * [CommandHttpHeaders.REQUEST_ID]: 'request-789'\n * },\n * body: command\n * };\n * ```\n */\nexport class CommandHeaders {\n /**\n * Prefix for all command-related headers\n */\n static readonly COMMAND_HEADERS_PREFIX = 'Command-';\n\n /**\n * Tenant identifier header\n * Used to identify the tenant context for the command\n */\n static readonly TENANT_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Tenant-Id`;\n\n /**\n * Owner identifier header\n * Used to identify the owner context for the command\n */\n static readonly OWNER_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Owner-Id`;\n\n /**\n * Aggregate identifier header\n * Used to identify the aggregate root for the command\n */\n static readonly AGGREGATE_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Id`;\n\n /**\n * Aggregate version header\n * Used to specify the expected version of the aggregate root\n */\n static readonly AGGREGATE_VERSION = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Version`;\n\n /**\n * Wait prefix for wait-related headers\n */\n static readonly WAIT_PREFIX = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Wait-`;\n\n /**\n * Wait timeout header\n * Specifies the maximum time to wait for command processing\n */\n static readonly WAIT_TIME_OUT = `${CommandHeaders.WAIT_PREFIX}Timeout`;\n\n // region Wait Stage\n /**\n * Wait stage header\n * Specifies the processing stage to wait for\n */\n static readonly WAIT_STAGE = `${CommandHeaders.WAIT_PREFIX}Stage`;\n\n /**\n * Wait context header\n * Specifies the bounded context to wait for\n */\n static readonly WAIT_CONTEXT = `${CommandHeaders.WAIT_PREFIX}Context`;\n\n /**\n * Wait processor header\n * Specifies the processor to wait for\n */\n static readonly WAIT_PROCESSOR = `${CommandHeaders.WAIT_PREFIX}Processor`;\n\n /**\n * Wait function header\n * Specifies the function to wait for\n */\n static readonly WAIT_FUNCTION = `${CommandHeaders.WAIT_PREFIX}Function`;\n // endregion\n\n // region Wait Chain Tail\n /**\n * Wait tail prefix for wait chain tail-related headers\n */\n static readonly WAIT_TAIL_PREFIX = `${CommandHeaders.WAIT_PREFIX}Tail-`;\n\n /**\n * Wait tail stage header\n * Specifies the tail processing stage to wait for\n */\n static readonly WAIT_TAIL_STAGE = `${CommandHeaders.WAIT_TAIL_PREFIX}Stage`;\n\n /**\n * Wait tail context header\n * Specifies the tail bounded context to wait for\n */\n static readonly WAIT_TAIL_CONTEXT = `${CommandHeaders.WAIT_TAIL_PREFIX}Context`;\n\n /**\n * Wait tail processor header\n * Specifies the tail processor to wait for\n */\n static readonly WAIT_TAIL_PROCESSOR = `${CommandHeaders.WAIT_TAIL_PREFIX}Processor`;\n\n /**\n * Wait tail function header\n * Specifies the tail function to wait for\n */\n static readonly WAIT_TAIL_FUNCTION = `${CommandHeaders.WAIT_TAIL_PREFIX}Function`;\n // endregion\n\n /**\n * Request identifier header\n * Used to track the request ID for correlation\n */\n static readonly REQUEST_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Request-Id`;\n\n /**\n * Local first header\n * Indicates whether to prefer local processing\n */\n static readonly LOCAL_FIRST = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Local-First`;\n\n /**\n * Command aggregate context header\n * Specifies the bounded context of the aggregate\n */\n static readonly COMMAND_AGGREGATE_CONTEXT = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Context`;\n\n /**\n * Command aggregate name header\n * Specifies the name of the aggregate\n */\n static readonly COMMAND_AGGREGATE_NAME = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Name`;\n\n /**\n * Command type header\n * Specifies the type of the command\n */\n static readonly COMMAND_TYPE = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Type`;\n\n /**\n * Command header prefix for custom headers\n * Used to prefix custom command headers\n */\n static readonly COMMAND_HEADER_X_PREFIX = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Header-`;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorInfo, FunctionInfoCapable, Identifier } from '../types';\nimport { PartialBy } from '@ahoo-wang/fetcher';\n\n/**\n * Command identifier interface\n *\n * Represents the unique identifier for a command.\n */\nexport interface CommandId {\n commandId: string;\n}\n\n/**\n * Wait command identifier capable interface\n *\n * Represents the identifier of the command being waited for.\n */\nexport interface WaitCommandIdCapable {\n waitCommandId: string;\n}\n\n/**\n * Request identifier interface\n *\n * Represents the unique identifier for a request, used for idempotency control.\n */\nexport interface RequestId {\n requestId: string;\n}\n\n/**\n * Command execution stage enum\n *\n * Represents the different stages of command execution lifecycle.\n */\nexport enum CommandStage {\n /**\n * When the command is published to the command bus/queue, a completion signal is generated.\n */\n SENT = 'SENT',\n\n /**\n * When the command is processed by the aggregate root, a completion signal is generated.\n */\n PROCESSED = 'PROCESSED',\n\n /**\n * When the snapshot is generated, a completion signal is generated.\n */\n SNAPSHOT = 'SNAPSHOT',\n\n /**\n * When the events generated by the command are *projected*, a completion signal is generated.\n */\n PROJECTED = 'PROJECTED',\n\n /**\n * When the events generated by the command are processed by *event handlers*, a completion signal is generated.\n */\n EVENT_HANDLED = 'EVENT_HANDLED',\n\n /**\n * When the events generated by the command are processed by *Saga*, a completion signal is generated.\n */\n SAGA_HANDLED = 'SAGA_HANDLED',\n}\n\n/**\n * Command stage capable interface\n *\n * Represents an object that has a command execution stage.\n */\nexport interface CommandStageCapable {\n stage: CommandStage;\n}\n\n/**\n * Command result capable interface\n *\n * Represents an object that contains command execution results.\n */\nexport interface CommandResultCapable {\n result: Record<string, any>;\n}\n\n/**\n * Signal time capable interface\n *\n * Represents an object that has a signal time (timestamp).\n */\nexport interface SignalTimeCapable {\n signalTime: number;\n}\n\n/**\n * Nullable aggregate version capable interface\n *\n * Represents an object that may have an aggregate version for optimistic concurrency control.\n */\nexport interface NullableAggregateVersionCapable {\n /**\n * Aggregate root version number\n * - When command processing succeeds, this is the version number after the aggregate root has completed command processing\n * - When command validation fails at the command gateway, this is null\n * - When command execution fails in the command handler, this is the current version number of the aggregate root\n */\n aggregateVersion?: number;\n}\n\n/**\n * Represents a target for compensation operations.\n *\n * This interface extends Identifier (with optional id) and FunctionInfoCapable to define\n * the structure for objects that can be targeted for compensation operations. Compensation\n * targets typically represent entities that can have operations reversed or corrected.\n */\nexport interface CompensationTarget\n extends PartialBy<Identifier, 'id'>,\n FunctionInfoCapable {\n}\n\n/**\n * Represents a command to delete an aggregate.\n *\n * This interface defines the structure for commands that request the deletion of an aggregate.\n * It is typically used in conjunction with other command interfaces to provide a complete\n * command processing workflow.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DeleteAggregate {\n}\n\n/**\n * Represents a command to recover an aggregate.\n *\n * This interface defines the structure for commands that request the recovery of an aggregate,\n * typically used in scenarios where an aggregate needs to be restored to a previous state\n * or recovered from an error condition.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface RecoverAggregate {\n}\n\n/**\n * Represents the result of a batch operation, containing information about\n * the pagination and error status of the operation.\n *\n * Extends ErrorInfo to include error details if the batch operation failed.\n */\nexport interface BatchResult extends ErrorInfo {\n /**\n * The cursor or identifier for the next item after the current batch.\n * Used for pagination to continue fetching the next batch of items.\n */\n after: string;\n\n /**\n * The number of items in the current batch.\n */\n size: number;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum Operator {\n /**\n * Performs logical AND on the provided condition list\n */\n AND = 'AND',\n\n /**\n * Performs logical OR on the provided condition list\n */\n OR = 'OR',\n\n /**\n * Performs logical NOR on the provided condition list\n */\n NOR = 'NOR',\n\n /**\n * Matches all documents where the `id` field value equals the specified value\n */\n ID = 'ID',\n\n /**\n * Matches all documents where the `id` field value equals any value in the specified list\n */\n IDS = 'IDS',\n\n /**\n * Matches documents where the aggregate root ID equals the specified value\n */\n AGGREGATE_ID = 'AGGREGATE_ID',\n\n /**\n * Matches all documents where the aggregate root ID equals any value in the specified list\n */\n AGGREGATE_IDS = 'AGGREGATE_IDS',\n\n /**\n * Matches all documents where the `tenantId` field value equals the specified value\n */\n TENANT_ID = 'TENANT_ID',\n\n /**\n * Matches all documents where the `ownerId` field value equals the specified value\n */\n OWNER_ID = 'OWNER_ID',\n\n /**\n * Matches all documents where the `deleted` field value equals the specified value\n */\n DELETED = 'DELETED',\n\n /**\n * Matches all documents\n */\n ALL = 'ALL',\n\n /**\n * Matches all documents where the field name value equals the specified value\n */\n EQ = 'EQ',\n\n /**\n * Matches all documents where the field name value does not equal the specified value\n */\n NE = 'NE',\n\n /**\n * Matches all documents where the given field's value is greater than the specified value\n */\n GT = 'GT',\n\n /**\n * Matches all documents where the given field's value is less than the specified value\n */\n LT = 'LT',\n\n /**\n * Matches all documents where the given field's value is greater than or equal to the specified value\n */\n GTE = 'GTE',\n\n /**\n * Matches all documents where the given field's value is less than or equal to the specified value\n */\n LTE = 'LTE',\n\n /**\n * Matches all documents where the given field's value contains the specified value\n */\n CONTAINS = 'CONTAINS',\n\n /**\n * Matches all documents where the field value equals any value in the specified list\n */\n IN = 'IN',\n\n /**\n * Matches all documents where the field value does not equal any specified value or does not exist\n */\n NOT_IN = 'NOT_IN',\n\n /**\n * Matches all documents where the field value is within the specified range\n */\n BETWEEN = 'BETWEEN',\n\n /**\n * Matches all documents where the field value is an array containing all specified values\n */\n ALL_IN = 'ALL_IN',\n\n /**\n * Matches documents where the field value starts with the specified string\n */\n STARTS_WITH = 'STARTS_WITH',\n\n /**\n * Matches documents where the field value ends with the specified string\n */\n ENDS_WITH = 'ENDS_WITH',\n\n /**\n * Matches all documents where the condition includes an array field,\n * and at least one member of the array matches the given condition.\n */\n ELEM_MATCH = 'ELEM_MATCH',\n\n /**\n * Matches all documents where the field value is `null`\n */\n NULL = 'NULL',\n\n /**\n * Matches all documents where the field value is not `null`\n */\n NOT_NULL = 'NOT_NULL',\n\n /**\n * Matches all documents where the field value is `true`\n */\n TRUE = 'TRUE',\n\n /**\n * Matches all documents where the field value is `false`\n */\n FALSE = 'FALSE',\n\n /**\n * Matches documents based on whether the field exists\n */\n EXISTS = 'EXISTS',\n\n // #region Date filtering conditions, field requirement: `long` type timestamp in milliseconds\n /**\n * Matches all documents where the field is within today's range\n * > For example: if `today` is `2024-06-06`, matches documents in the range\n * `2024-06-06 00:00:00.000` ~ `2024-06-06 23:59:59.999`\n */\n TODAY = 'TODAY',\n\n /**\n * Matches all documents where the field is before today\n */\n BEFORE_TODAY = 'BEFORE_TODAY',\n\n /**\n * Matches all documents where the field is within yesterday's range\n * > For example: if `today` is `2024-06-06`, matches documents in the range\n * `2024-06-05 00:00:00.000` ~ `2024-06-05 23:59:59.999`\n */\n TOMORROW = 'TOMORROW',\n\n /**\n * Matches all documents where the field is within this week's range\n */\n THIS_WEEK = 'THIS_WEEK',\n\n /**\n * Matches all documents where the field is within next week's range\n */\n NEXT_WEEK = 'NEXT_WEEK',\n\n /**\n * Matches all documents where the field is within last week's range\n */\n LAST_WEEK = 'LAST_WEEK',\n\n /**\n * Matches all documents where the field is within this month's range\n * > For example:\n * - `today`: `2024-06-06`\n * - Matching range: `2024-06-01 00:00:00.000` ~ `2024-06-30 23:59:59.999`\n */\n THIS_MONTH = 'THIS_MONTH',\n\n /**\n * Matches all documents where the field is within last month's range\n * > For example:\n * - `today`: `2024-06-06`\n * - Matching range: `2024-05-01 00:00:00.000` ~ `2024-05-31 23:59:59.999`\n */\n LAST_MONTH = 'LAST_MONTH',\n\n /**\n * Matches all documents where the field is within the specified number of recent days\n * > For example: last 3 days\n * - `today`: `2024-06-06`\n * - Matching range: `2024-06-04 00:00:00.000` ~ `2024-06-06 23:59:59.999`\n * - That is: today, yesterday, the day before yesterday\n */\n RECENT_DAYS = 'RECENT_DAYS',\n\n /**\n * Matches all documents where the field is before the specified number of days\n *\n * > For example: before 3 days\n * - `today`: `2024-06-06`\n * - Matching range: all documents less than `2024-06-04 00:00:00.000`\n */\n EARLIER_DAYS = 'EARLIER_DAYS',\n // #endregion\n\n /**\n * Raw operator, uses the condition value directly as the raw database query condition\n */\n RAW = 'RAW',\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Operator } from './operator';\n\n/**\n * Helper function to detect condition is validate or not\n *\n * @param condition - Condition\n * @returns If condition is validate return true, otherwise return false\n */\nexport function isValidateCondition(\n condition: Condition | undefined | null,\n): condition is Condition {\n return !!condition;\n}\n\n/**\n * Condition option keys enumeration\n *\n * Defines standard option keys used in query conditions for special handling.\n */\nexport class ConditionOptionKey {\n /**\n * Ignore case option key for string comparisons\n */\n static readonly IGNORE_CASE_OPTION_KEY = 'ignoreCase';\n\n /**\n * Time zone ID option key for date operations\n */\n static readonly ZONE_ID_OPTION_KEY = 'zoneId';\n\n /**\n * Date pattern option key for date formatting\n */\n static readonly DATE_PATTERN_OPTION_KEY = 'datePattern';\n}\n\n/**\n * Condition options interface\n *\n * Represents additional options that can be applied to query conditions,\n * such as case sensitivity, date patterns, and time zones.\n */\nexport interface ConditionOptions {\n /**\n * Whether to ignore case in string comparisons\n */\n ignoreCase?: boolean;\n\n /**\n * Date pattern for date formatting\n */\n datePattern?: string;\n\n /**\n * Time zone ID for date operations\n */\n zoneId?: string;\n\n /**\n * Additional custom options\n */\n [key: string]: any;\n}\n\n/**\n * Helper function to create condition options with ignoreCase flag.\n *\n * @param ignoreCase - Whether to ignore case\n * @returns Condition options or undefined if ignoreCase is undefined\n */\nexport function ignoreCaseOptions(\n ignoreCase?: boolean,\n): ConditionOptions | undefined {\n if (typeof ignoreCase === 'undefined') {\n return undefined;\n }\n return { ignoreCase };\n}\n\n/**\n * Helper function to create condition options with date pattern and zone ID.\n *\n * @param datePattern - Date pattern\n * @param zoneId - Time zone ID\n * @returns Condition options or undefined if both parameters are undefined\n */\nexport function dateOptions(\n datePattern?: string,\n zoneId?: string,\n): ConditionOptions | undefined {\n if (typeof datePattern === 'undefined' && typeof zoneId === 'undefined') {\n return undefined;\n }\n const options: ConditionOptions = {};\n if (typeof datePattern !== 'undefined') {\n options.datePattern = datePattern;\n }\n if (typeof zoneId !== 'undefined') {\n options.zoneId = zoneId;\n }\n return options;\n}\n\n/**\n * Interface for query conditions.\n *\n * When `operator` is `AND` or `OR` or `NOR`, `children` cannot be empty.\n */\nexport interface Condition<FIELDS extends string = string> {\n /**\n * Field name for the condition\n */\n field?: FIELDS;\n\n /**\n * Operator for the condition\n */\n operator?: Operator;\n\n /**\n * Value for the condition\n */\n value?: any;\n\n /**\n * Child conditions for logical operators (AND, OR, NOR)\n */\n children?: Condition<FIELDS>[];\n\n /**\n * Additional options for the condition\n */\n options?: ConditionOptions;\n}\n\n/**\n * Interface for objects that have a condition.\n */\nexport interface ConditionCapable<FIELDS extends string = string> {\n condition: Condition<FIELDS>;\n}\n\n/**\n * Deletion state enumeration\n *\n * Represents the different states of deletion for entities.\n */\nexport enum DeletionState {\n /**\n * Active state - entity is not deleted\n */\n ACTIVE = 'ACTIVE',\n\n /**\n * Deleted state - entity is deleted\n */\n DELETED = 'DELETED',\n\n /**\n * All state - includes both active and deleted entities\n */\n ALL = 'ALL',\n}\n\n/**\n * Creates an AND condition with the specified conditions.\n *\n * This function combines multiple conditions using the logical AND operator.\n * It provides optimizations such as returning the condition directly when\n * only one is provided, and flattening nested AND conditions.\n *\n * @param conditions - Conditions to combine with AND. If empty, returns an ALL condition.\n * If exactly one, returns that condition directly.\n * If multiple, combines them into an AND condition with flattening optimization.\n * @returns A condition with AND operator or an optimized condition based on the input\n */\nexport function and<FIELDS extends string = string>(\n ...conditions: Array<Condition<FIELDS> | undefined | null>\n): Condition<FIELDS> {\n if (conditions.length === 0) {\n return all();\n }\n if (conditions.length === 1) {\n return isValidateCondition(conditions[0]) ? conditions[0] : all();\n }\n const andChildren: Condition<FIELDS>[] = [];\n conditions.forEach(condition => {\n if (\n condition?.operator === Operator.ALL ||\n !isValidateCondition(condition)\n ) {\n return;\n }\n if (condition.operator === Operator.AND && condition.children) {\n andChildren.push(...condition.children);\n } else {\n andChildren.push(condition);\n }\n });\n return { operator: Operator.AND, children: andChildren };\n}\n\n/**\n * Creates an OR condition with the specified conditions.\n *\n * @param conditions - Conditions to combine with OR\n * @returns A condition with OR operator\n */\nexport function or<FIELDS extends string = string>(\n ...conditions: Array<Condition<FIELDS> | undefined | null>\n): Condition<FIELDS> {\n const validateConditions = conditions?.filter(condition =>\n isValidateCondition(condition),\n );\n if (validateConditions.length === 0) {\n return all();\n }\n return { operator: Operator.OR, children: validateConditions };\n}\n\n/**\n * Creates a NOR condition with the specified conditions.\n *\n * @param conditions - Conditions to combine with NOR\n * @returns A condition with NOR operator\n */\nexport function nor<FIELDS extends string = string>(\n ...conditions: Condition<FIELDS>[]\n): Condition<FIELDS> {\n if (conditions.length === 0) {\n return all();\n }\n return { operator: Operator.NOR, children: conditions };\n}\n\n/**\n * Creates an ID condition with the specified value.\n *\n * @param value - The ID value to match\n * @returns A condition with ID operator\n */\nexport function id<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.ID, value: value };\n}\n\n/**\n * Creates an IDS condition with the specified values.\n *\n * @param value - The ID values to match\n * @returns A condition with IDS operator\n */\nexport function ids<FIELDS extends string = string>(\n value: string[],\n): Condition<FIELDS> {\n return { operator: Operator.IDS, value: value };\n}\n\n/**\n * Creates an AGGREGATE_ID condition with the specified value.\n *\n * @param value - The aggregate ID value to match\n * @returns A condition with AGGREGATE_ID operator\n */\nexport function aggregateId<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.AGGREGATE_ID, value: value };\n}\n\n/**\n * Creates an AGGREGATE_IDS condition with the specified values.\n *\n * @param value - The aggregate ID values to match\n * @returns A condition with AGGREGATE_IDS operator\n */\nexport function aggregateIds<FIELDS extends string = string>(\n value: string[],\n): Condition<FIELDS> {\n return { operator: Operator.AGGREGATE_IDS, value: value };\n}\n\n/**\n * Creates a TENANT_ID condition with the specified value.\n *\n * @param value - The tenant ID value to match\n * @returns A condition with TENANT_ID operator\n */\nexport function tenantId<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.TENANT_ID, value: value };\n}\n\n/**\n * Creates an OWNER_ID condition with the specified value.\n *\n * @param value - The owner ID value to match\n * @returns A condition with OWNER_ID operator\n */\nexport function ownerId<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.OWNER_ID, value: value };\n}\n\n/**\n * Creates a DELETED condition with the specified value.\n *\n * @param value - The deletion state value to match\n * @returns A condition with DELETED operator\n */\nexport function deleted<FIELDS extends string = string>(\n value: DeletionState,\n): Condition<FIELDS> {\n return { operator: Operator.DELETED, value: value };\n}\n\n/**\n * Creates an ACTIVE deletion state condition.\n *\n * @returns A condition with DELETED operator set to ACTIVE\n */\nexport function active<FIELDS extends string = string>(): Condition<FIELDS> {\n return deleted(DeletionState.ACTIVE);\n}\n\n/**\n * Creates an ALL condition.\n *\n * @returns A condition with ALL operator\n */\nexport function all<FIELDS extends string = string>(): Condition<FIELDS> {\n return {\n operator: Operator.ALL,\n };\n}\n\n/**\n * Creates an EQ (equals) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with EQ operator\n */\nexport function eq<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.EQ, value };\n}\n\n/**\n * Creates a NE (not equals) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with NE operator\n */\nexport function ne<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.NE, value };\n}\n\n/**\n * Creates a GT (greater than) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with GT operator\n */\nexport function gt<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.GT, value };\n}\n\n/**\n * Creates a LT (less than) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with LT operator\n */\nexport function lt<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.LT, value };\n}\n\n/**\n * Creates a GTE (greater than or equal) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with GTE operator\n */\nexport function gte<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.GTE, value };\n}\n\n/**\n * Creates a LTE (less than or equal) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with LTE operator\n */\nexport function lte<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.LTE, value };\n}\n\n/**\n * Creates a CONTAINS condition with the specified field and value.\n *\n * @param field - The field name to search in\n * @param value - The value to search for\n * @param ignoreCase - Whether to ignore case in the search\n * @returns A condition with CONTAINS operator\n */\nexport function contains<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n ignoreCase?: boolean,\n): Condition<FIELDS> {\n const options: Record<string, any> | undefined =\n ignoreCaseOptions(ignoreCase);\n return { field, operator: Operator.CONTAINS, value, options };\n}\n\n/**\n * Creates an IN condition with the specified field and values.\n *\n * @param field - The field name to compare\n * @param value - The values to compare against\n * @returns A condition with IN operator\n */\nexport function isIn<FIELDS extends string = string>(\n field: FIELDS,\n ...value: any[]\n): Condition<FIELDS> {\n return { field, operator: Operator.IN, value };\n}\n\n/**\n * Creates a NOT_IN condition with the specified field and values.\n *\n * @param field - The field name to compare\n * @param value - The values to compare against\n * @returns A condition with NOT_IN operator\n */\nexport function notIn<FIELDS extends string = string>(\n field: FIELDS,\n ...value: any[]\n): Condition<FIELDS> {\n return { field, operator: Operator.NOT_IN, value };\n}\n\n/**\n * Creates a BETWEEN condition with the specified field and range.\n *\n * @param field - The field name to compare\n * @param start - The start value of the range\n * @param end - The end value of the range\n * @returns A condition with BETWEEN operator\n */\nexport function between<FIELDS extends string = string>(\n field: FIELDS,\n start: any,\n end: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.BETWEEN, value: [start, end] };\n}\n\n/**\n * Creates an ALL_IN condition with the specified field and values.\n *\n * @param field - The field name to compare\n * @param value - The values to compare against\n * @returns A condition with ALL_IN operator\n */\nexport function allIn<FIELDS extends string = string>(\n field: FIELDS,\n ...value: any[]\n): Condition<FIELDS> {\n return { field, operator: Operator.ALL_IN, value };\n}\n\n/**\n * Creates a STARTS_WITH condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @param ignoreCase - Whether to ignore case in the comparison\n * @returns A condition with STARTS_WITH operator\n */\nexport function startsWith<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n ignoreCase?: boolean,\n): Condition<FIELDS> {\n const options: Record<string, any> | undefined =\n ignoreCaseOptions(ignoreCase);\n return { field, operator: Operator.STARTS_WITH, value, options };\n}\n\n/**\n * Creates an ENDS_WITH condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @param ignoreCase - Whether to ignore case in the comparison\n * @returns A condition with ENDS_WITH operator\n */\nexport function endsWith<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n ignoreCase?: boolean,\n): Condition<FIELDS> {\n const options: Record<string, any> | undefined =\n ignoreCaseOptions(ignoreCase);\n return { field, operator: Operator.ENDS_WITH, value, options };\n}\n\n/**\n * Creates an ELEM_MATCH condition with the specified field and child condition.\n *\n * @param field - The field name to match elements in\n * @param value - The condition to match elements against\n * @returns A condition with ELEM_MATCH operator\n */\nexport function elemMatch<FIELDS extends string = string>(\n field: FIELDS,\n value: Condition<FIELDS>,\n): Condition<FIELDS> {\n return { field, operator: Operator.ELEM_MATCH, children: [value] };\n}\n\n/**\n * Creates a NULL condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with NULL operator\n */\nexport function isNull<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.NULL };\n}\n\n/**\n * Creates a NOT_NULL condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with NOT_NULL operator\n */\nexport function notNull<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.NOT_NULL };\n}\n\n/**\n * Creates a TRUE condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with TRUE operator\n */\nexport function isTrue<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.TRUE };\n}\n\n/**\n * Creates a FALSE condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with FALSE operator\n */\nexport function isFalse<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.FALSE };\n}\n\n/**\n * Creates an EXISTS condition with the specified field and existence flag.\n *\n * @param field - The field name to check\n * @param exists - Whether the field should exist (default: true)\n * @returns A condition with EXISTS operator\n */\nexport function exists<FIELDS extends string = string>(\n field: FIELDS,\n exists: boolean = true,\n): Condition<FIELDS> {\n return { field, operator: Operator.EXISTS, value: exists };\n}\n\n/**\n * Creates a TODAY condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with TODAY operator\n */\nexport function today<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.TODAY, options };\n}\n\n/**\n * Creates a BEFORE_TODAY condition with the specified field and time.\n *\n * @param field - The field name to check\n * @param time - The time to compare against\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with BEFORE_TODAY operator\n */\nexport function beforeToday<FIELDS extends string = string>(\n field: FIELDS,\n time: any,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.BEFORE_TODAY, value: time, options };\n}\n\n/**\n * Creates a TOMORROW condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with TOMORROW operator\n */\nexport function tomorrow<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.TOMORROW, options };\n}\n\n/**\n * Creates a THIS_WEEK condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with THIS_WEEK operator\n */\nexport function thisWeek<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.THIS_WEEK, options };\n}\n\n/**\n * Creates a NEXT_WEEK condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with NEXT_WEEK operator\n */\nexport function nextWeek<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.NEXT_WEEK, options };\n}\n\n/**\n * Creates a LAST_WEEK condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with LAST_WEEK operator\n */\nexport function lastWeek<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.LAST_WEEK, options };\n}\n\n/**\n * Creates a THIS_MONTH condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with THIS_MONTH operator\n */\nexport function thisMonth<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.THIS_MONTH, options };\n}\n\n/**\n * Creates a LAST_MONTH condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with LAST_MONTH operator\n */\nexport function lastMonth<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.LAST_MONTH, options };\n}\n\n/**\n * Creates a RECENT_DAYS condition with the specified field and number of days.\n *\n * @param field - The field name to check\n * @param days - The number of recent days to include\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with RECENT_DAYS operator\n */\nexport function recentDays<FIELDS extends string = string>(\n field: FIELDS,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.RECENT_DAYS, value: days, options };\n}\n\n/**\n * Creates an EARLIER_DAYS condition with the specified field and number of days.\n *\n * @param field - The field name to check\n * @param days - The number of days to look back\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with EARLIER_DAYS operator\n */\nexport function earlierDays<FIELDS extends string = string>(\n field: FIELDS,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.EARLIER_DAYS, value: days, options };\n}\n\n/**\n * Creates a RAW condition with the specified raw value.\n *\n * @param raw - The raw condition value\n * @returns A condition with RAW operator\n */\nexport function raw<FIELDS extends string = string>(\n raw: any,\n): Condition<FIELDS> {\n return { operator: Operator.RAW, value: raw };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for pagination information.\n *\n * Page number, starting from 1\n * Page size\n */\nexport interface Pagination {\n index: number;\n size: number;\n}\n\n/**\n * Default pagination configuration.\n * Page index starts at 1, page size is 10.\n */\nexport const DEFAULT_PAGINATION: Pagination = {\n index: 1,\n size: 10,\n};\n\n/**\n * Creates a Pagination object with the provided parameters.\n *\n * This function is a factory for creating Pagination objects, which represent\n * pagination information including page index and page size. It provides default\n * values for optional properties while allowing customization of index and size.\n *\n * @param options - The pagination options. Optional.\n * @param options.index - The page index, starting from 1. Defaults to DEFAULT_PAGINATION.index.\n * @param options.size - The page size. Defaults to DEFAULT_PAGINATION.size.\n * @returns A Pagination object with the specified parameters\n */\nexport function pagination({\n index = DEFAULT_PAGINATION.index,\n size = DEFAULT_PAGINATION.size,\n }: Partial<Pagination> = DEFAULT_PAGINATION): Pagination {\n return {\n index,\n size,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for field projection.\n */\nexport interface Projection<FIELDS extends string = string> {\n include?: FIELDS[];\n exclude?: FIELDS[];\n}\n\n/**\n * Default projection configuration.\n * Empty projection object includes all fields.\n */\nexport const DEFAULT_PROJECTION: Projection = {};\n\nexport function defaultProjection<\n FIELDS extends string = string,\n>(): Projection<FIELDS> {\n return DEFAULT_PROJECTION as Projection<FIELDS>;\n}\n\n/**\n * Creates a Projection object with the provided parameters.\n *\n * This function is a factory for creating Projection objects, which represent\n * field projection specifications for queries. It allows specifying which fields\n * to include or exclude in query results.\n *\n * @param options - The projection options. Defaults to DEFAULT_PROJECTION.\n * @param options.include - Array of field names to include in the projection. Optional.\n * @param options.exclude - Array of field names to exclude from the projection. Optional.\n * @returns A Projection object with the specified parameters\n */\nexport function projection<FIELDS extends string = string>(\n { include, exclude }: Projection<FIELDS> = defaultProjection(),\n): Projection<FIELDS> {\n return {\n include,\n exclude,\n };\n}\n\n/**\n * Interface for objects that support field projection.\n */\nexport interface ProjectionCapable<FIELDS extends string = string> {\n projection?: Projection<FIELDS>;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { all, type ConditionCapable } from './condition';\nimport { type SortCapable } from './sort';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination';\nimport { type ProjectionCapable } from './projection';\n\n/**\n * Interface for queryable objects that support conditions, projection, and sorting.\n */\nexport interface Queryable<FIELDS extends string = string>\n extends ConditionCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {\n}\n\n/**\n * Interface for single query objects.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface SingleQuery<FIELDS extends string = string>\n extends Queryable<FIELDS> {\n}\n\n/**\n * Creates a SingleQuery object with the provided parameters.\n *\n * This function is a factory for creating SingleQuery objects, which represent\n * queries that return a single result. It provides default values for optional\n * properties while allowing customization of condition, projection, and sort criteria.\n *\n * @param condition - The query condition. Defaults to an 'all' condition that matches everything.\n * @param projection - The field projection specification. Optional.\n * @param sort - The sort criteria. Optional.\n * @returns A SingleQuery object with the specified parameters\n */\nexport function singleQuery<FIELDS extends string = string>({\n condition = all(),\n projection,\n sort,\n }: Partial<SingleQuery<FIELDS>> = {}): SingleQuery<FIELDS> {\n return {\n condition,\n projection,\n sort,\n };\n}\n\n/**\n * Interface for list query objects.\n *\n * Limit the number of results. Default: DEFAULT_PAGINATION.size\n */\nexport interface ListQuery<FIELDS extends string = string>\n extends Queryable<FIELDS> {\n limit?: number;\n}\n\n/**\n * Creates a ListQuery object with the provided parameters.\n *\n * This function is a factory for creating ListQuery objects, which represent\n * queries that return a list of results. It provides default values for optional\n * properties while allowing customization of condition, projection, sort criteria,\n * and result limit.\n *\n * @param condition - The query condition. Defaults to an 'all' condition that matches everything.\n * @param projection - The field projection specification. Optional.\n * @param sort - The sort criteria. Optional.\n * @param limit - The maximum number of results to return. Defaults to DEFAULT_PAGINATION.size.\n * @returns A ListQuery object with the specified parameters\n */\nexport function listQuery<FIELDS extends string = string>({\n condition = all(),\n projection,\n sort,\n limit = DEFAULT_PAGINATION.size,\n }: Partial<ListQuery<FIELDS>> = {}): ListQuery<FIELDS> {\n return {\n condition,\n projection,\n sort,\n limit,\n };\n}\n\n/**\n * Interface for paged query objects.\n */\nexport interface PagedQuery<FIELDS extends string = string>\n extends Queryable<FIELDS> {\n pagination?: Pagination;\n}\n\n/**\n * Creates a PagedQuery object with the provided parameters.\n *\n * This function is a factory for creating PagedQuery objects, which represent\n * queries that return a paged list of results. It provides default values for optional\n * properties while allowing customization of condition, projection, sort criteria,\n * and pagination.\n *\n * @param condition - The query condition. Defaults to an 'all' condition that matches everything.\n * @param projection - The field projection specification. Optional.\n * @param sort - The sort criteria. Optional.\n * @param pagination - The pagination specification. Optional.\n *\n * @returns A PagedQuery object with the specified parameters\n */\nexport function pagedQuery<FIELDS extends string = string>({\n condition = all(),\n projection,\n sort,\n pagination = DEFAULT_PAGINATION,\n }: Partial<PagedQuery<FIELDS>> = {}): PagedQuery<FIELDS> {\n return {\n condition,\n projection,\n sort,\n pagination,\n };\n}\n\n/**\n * Interface for paged list results.\n */\nexport interface PagedList<T> {\n total: number;\n list: T[];\n}\n\nexport const EMPTY_PAGED_LIST: PagedList<any> = {\n total: 0,\n list: [],\n};\n\n/**\n * Creates a PagedList object with the provided parameters.\n *\n * This function is a factory for creating PagedList objects, which represent\n * a page of results with total count information. It provides default values\n * for optional properties while allowing customization of total count and list data.\n *\n * @param total - The total number of items. Defaults to 0.\n * @param list - The array of items in the current page. Defaults to an empty array.\n * @returns A PagedList object with the specified parameters\n */\nexport function pagedList<T>({\n total,\n list = [],\n }: Partial<PagedList<T>> = EMPTY_PAGED_LIST): PagedList<T> {\n if (total === undefined) {\n total = list.length;\n }\n return {\n total,\n list,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Enumeration of sort directions.\n * ASC for ascending order, DESC for descending order.\n */\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\n/**\n * Interface for sort criteria.\n */\nexport interface FieldSort<FIELDS extends string = string> {\n field: FIELDS;\n direction: SortDirection;\n}\n\n/**\n * Creates a sort object with ascending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and ascending direction\n */\nexport function asc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field,\n direction: SortDirection.ASC,\n };\n}\n\n/**\n * Creates a sort object with descending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and descending direction\n */\nexport function desc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field,\n direction: SortDirection.DESC,\n };\n}\n\n/**\n * Interface for objects that support sorting.\n */\nexport interface SortCapable<FIELDS extends string = string> {\n sort?: FieldSort<FIELDS>[];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateId,\n CreateTimeCapable,\n DeletedCapable,\n FirstEventTimeCapable,\n FirstOperatorCapable,\n Identifier,\n Named,\n OwnerId,\n StateCapable,\n Version,\n} from '../../types';\nimport type { CommandId, CommandStage, RequestId } from '../../command';\nimport type { BodyCapable } from '../../types';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\n\n/**\n * Represents a domain event with a specific body type.\n * Extends Identifier, Named, and BodyCapable interfaces to provide identification,\n * naming, and body capabilities for the domain event.\n * @template BODY - The type of the event content for this domain event\n */\nexport interface DomainEvent<BODY>\n extends Identifier,\n Named,\n BodyCapable<BODY> {\n /**\n * The type of the event content.\n */\n bodyType: string;\n /**\n * The revision of the domain event.\n */\n revision: string;\n}\n\n/**\n * Represents the header information for a domain event stream.\n * Contains metadata about the event stream such as command information,\n * network details, and tracing information.\n */\nexport interface DomainEventStreamHeader {\n /**\n * The operator that executed the command.\n */\n command_operator?: string;\n /**\n * The endpoint to wait for command completion.\n */\n command_wait_endpoint?: string;\n /**\n * The stage to wait for in command execution.\n */\n command_wait_stage?: CommandStage;\n\n local_first?: string;\n /**\n * The IP address of the remote client.\n */\n remote_ip: string;\n /**\n * The user agent of the client.\n */\n user_agent?: string;\n /**\n * The trace identifier for distributed tracing.\n */\n trace_id?: string;\n\n /**\n * Index signature for additional custom header properties.\n * Allows for any additional string key-value pairs to be included as header properties.\n */\n [key: string]: string | undefined;\n}\n\n/**\n * Represents a stream of domain events.\n * Combines multiple interfaces to provide a complete domain event stream,\n * including identification, aggregation, ownership, command information,\n * versioning, and the actual event data.\n */\nexport interface DomainEventStream<DomainEventBody = any>\n extends Identifier,\n AggregateId,\n OwnerId,\n CommandId,\n CreateTimeCapable,\n RequestId,\n Version,\n BodyCapable<DomainEvent<DomainEventBody>[]> {\n /**\n * The header information for the domain event stream.\n */\n header: DomainEventStreamHeader;\n}\n\nexport interface StateEvent<DomainEventBody = any, S = any>\n extends DomainEventStream<DomainEventBody>,\n StateCapable<S>,\n FirstOperatorCapable,\n FirstEventTimeCapable,\n DeletedCapable {\n}\n\n/**\n * Provides field names for domain event stream metadata.\n *\n * This class contains static readonly properties that define the field names used in domain event stream metadata.\n * These field names are used to access and manipulate domain event stream data in a consistent manner.\n * The fields include headers, identifiers, command information, versioning, body content, and creation time.\n */\nexport class DomainEventStreamMetadataFields {\n static readonly HEADER = 'header';\n static readonly COMMAND_OPERATOR = `${DomainEventStreamMetadataFields.HEADER}.command_operator`;\n static readonly AGGREGATE_ID = 'aggregateId';\n static readonly TENANT_ID = 'tenantId';\n static readonly OWNER_ID = 'ownerId';\n static readonly COMMAND_ID = 'commandId';\n static readonly REQUEST_ID = 'requestId';\n static readonly VERSION = 'version';\n static readonly BODY = 'body';\n static readonly BODY_ID = `${DomainEventStreamMetadataFields.BODY}.id`;\n static readonly BODY_NAME = `${DomainEventStreamMetadataFields.BODY}.name`;\n static readonly BODY_TYPE = `${DomainEventStreamMetadataFields.BODY}.bodyType`;\n static readonly BODY_REVISION = `${DomainEventStreamMetadataFields.BODY}.revision`;\n static readonly BODY_BODY = `${DomainEventStreamMetadataFields.BODY}.body`;\n static readonly CREATE_TIME = 'createTime';\n}\n\n/**\n * Represents a readable stream of domain event streams.\n *\n * This type defines a ReadableStream that emits JsonServerSentEvent objects containing DomainEventStream data.\n * It is used for streaming domain events in a server-sent event format.\n */\nexport type ReadableDomainEventStream = ReadableStream<\n JsonServerSentEvent<DomainEventStream>\n>;\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DomainEventStream } from './domainEventStream';\nimport type { QueryApi } from '../queryApi';\n\n/**\n * Interface for event stream query API operations.\n * Extends the base QueryApi interface but omits the 'single' method,\n * as event stream queries typically work with collections of events rather than single events.\n * @template DomainEventStream - The type of domain event stream this API works with\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface EventStreamQueryApi<\n DomainEventBody = any,\n FIELDS extends string = string,\n> extends Omit<\n QueryApi<DomainEventStream<DomainEventBody>, FIELDS>,\n 'single'\n> {\n}\n\n/**\n * Provides endpoint paths for event stream query operations.\n *\n * This class contains static readonly properties that define the endpoint paths used for various event stream query operations.\n * These paths are used when making API calls to retrieve event stream data in different formats such as counts, lists, and paged results.\n * The paths are constructed based on a base resource name and extended with specific operation identifiers.\n */\nexport class EventStreamQueryEndpointPaths {\n static readonly EVENT_STREAM_RESOURCE_NAME = 'event';\n static readonly COUNT = `${EventStreamQueryEndpointPaths.EVENT_STREAM_RESOURCE_NAME}/count`;\n static readonly LIST = `${EventStreamQueryEndpointPaths.EVENT_STREAM_RESOURCE_NAME}/list`;\n static readonly PAGED = `${EventStreamQueryEndpointPaths.EVENT_STREAM_RESOURCE_NAME}/paged`;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type EventStreamQueryApi,\n EventStreamQueryEndpointPaths,\n} from './eventStreamQueryApi';\nimport type { Condition } from '../condition';\nimport type { ListQuery, PagedList, PagedQuery } from '../queryable';\nimport type { DomainEventStream } from './domainEventStream';\nimport {\n JsonEventStreamResultExtractor,\n JsonServerSentEvent,\n} from '@ahoo-wang/fetcher-eventstream';\n\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n body,\n post,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * Client for querying event streams through HTTP endpoints.\n * Extends QueryClient and implements EventStreamQueryApi to provide methods\n * for querying domain event streams with different query patterns.\n * This client supports counting, listing, streaming, and paging operations on event streams.\n *\n * @example\n * ```typescript\n * // Create client options configuration\n * const clientOptions: ClientOptions = {\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart'\n * };\n *\n * // Create an event stream query client instance\n * const eventStreamQueryClient = new EventStreamQueryClient(clientOptions);\n *\n * // Count event streams\n * const count = await eventStreamQueryClient.count(all());\n *\n * // List event streams\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await eventStreamQueryClient.list(listQuery);\n *\n * // List event streams as stream\n * const listStream = await eventStreamQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const domainEventStream = event.data;\n * console.log('Received:', domainEventStream);\n * }\n *\n * // Paged event streams\n * const pagedQuery: PagedQuery = {\n * condition: all()\n * };\n * const paged = await eventStreamQueryClient.paged(pagedQuery);\n * ```\n */\n@api()\nexport class EventStreamQueryClient<\n DomainEventBody = any,\n FIELDS extends string = string,\n>\n implements EventStreamQueryApi<DomainEventBody, FIELDS>, ApiMetadataCapable {\n /**\n * Creates a new EventStreamQueryClient instance.\n */\n constructor(public readonly apiMetadata?: ApiMetadata) {\n }\n\n /**\n * Counts the number of domain event streams that match the given condition.\n *\n * @param condition - The condition to filter event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the count of matching event streams\n *\n * @example\n * ```typescript\n * const count = await eventStreamQueryClient.count(all());\n * console.log('Total event streams:', count);\n * ```\n */\n @post(EventStreamQueryEndpointPaths.COUNT)\n count(\n @body() condition: Condition<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<number> {\n throw autoGeneratedError(condition, attributes);\n }\n\n /**\n * Retrieves a list of domain event streams based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial domain event streams\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await eventStreamQueryClient.list(listQuery);\n * for (const domainEventStream of list) {\n * console.log('Event stream:', domainEventStream);\n * }\n * ```\n */\n @post(EventStreamQueryEndpointPaths.LIST)\n list<\n T extends Partial<\n DomainEventStream<DomainEventBody>\n > = DomainEventStream<DomainEventBody>,\n >(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T[]> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a stream of domain event streams based on the provided query parameters.\n * Sets the Accept header to text/event-stream to indicate that the response should be streamed.\n *\n * @param listQuery - The query parameters for listing event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial domain event streams\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const listStream = await eventStreamQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const domainEventStream = event.data;\n * console.log('Received event stream:', domainEventStream);\n * }\n * ```\n */\n @post(EventStreamQueryEndpointPaths.LIST, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n listStream<\n T extends Partial<\n DomainEventStream<DomainEventBody>\n > = DomainEventStream<DomainEventBody>,\n >(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a paged list of domain event streams based on the provided query parameters.\n *\n * @param pagedQuery - The query parameters for paging event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial domain event streams\n *\n * @example\n * ```typescript\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const paged = await eventStreamQueryClient.paged(pagedQuery);\n * console.log('Total:', paged.total);\n * for (const domainEventStream of paged.list) {\n * console.log('Event stream:', domainEventStream);\n * }\n * ```\n */\n @post(EventStreamQueryEndpointPaths.PAGED)\n paged<\n T extends Partial<\n DomainEventStream<DomainEventBody>\n > = DomainEventStream<DomainEventBody>,\n >(\n @body() pagedQuery: PagedQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<PagedList<T>> {\n throw autoGeneratedError(pagedQuery, attributes);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateId,\n DeletedCapable,\n EventIdCapable,\n EventTimeCapable,\n FirstEventTimeCapable,\n FirstOperatorCapable,\n NamedAggregate,\n OperatorCapable,\n OwnerId,\n SnapshotTimeCapable,\n StateCapable,\n TenantId,\n Version,\n} from '../../types';\n\n/**\n * Interface for materialized snapshots with full capabilities.\n */\nexport interface MaterializedSnapshot<S>\n extends StateCapable<S>,\n AggregateId,\n TenantId,\n OwnerId,\n Version,\n EventIdCapable,\n FirstOperatorCapable,\n OperatorCapable,\n FirstEventTimeCapable,\n EventTimeCapable,\n SnapshotTimeCapable,\n DeletedCapable {\n}\n\n/**\n * Interface for materialized snapshots with medium capabilities.\n *\n * Represents a materialized snapshot for medium data, implementing multiple capabilities through inheritance.\n * This interface is designed to be generic, capable of holding state data of any type.\n * Each snapshot corresponds to a specific version of the state within a tenant and owner context,\n * and records information such as event IDs and operation times to support tracing and auditing.\n */\nexport interface MediumMaterializedSnapshot<S>\n extends StateCapable<S>,\n NamedAggregate,\n TenantId,\n OwnerId,\n Version,\n EventIdCapable,\n FirstOperatorCapable,\n OperatorCapable,\n FirstEventTimeCapable,\n EventTimeCapable {\n}\n\n/**\n * Interface for simplified materialized snapshots with generic state.\n *\n * This interface implements multiple interfaces to provide version, materialization, first event time, and state information.\n */\nexport interface SmallMaterializedSnapshot<S>\n extends StateCapable<S>,\n NamedAggregate,\n Version,\n FirstEventTimeCapable {\n}\n\n/**\n * Provides field names for snapshot metadata.\n *\n * This class contains static readonly properties that define the field names used in snapshot metadata.\n * These field names are used to access and manipulate snapshot data in a consistent manner.\n */\nexport class SnapshotMetadataFields {\n static readonly VERSION = 'version';\n static readonly TENANT_ID = 'tenantId';\n static readonly OWNER_ID = 'ownerId';\n static readonly EVENT_ID = 'eventId';\n static readonly FIRST_EVENT_TIME = 'firstEventTime';\n static readonly EVENT_TIME = 'eventTime';\n static readonly FIRST_OPERATOR = 'firstOperator';\n static readonly OPERATOR = 'operator';\n static readonly SNAPSHOT_TIME = 'snapshotTime';\n static readonly DELETED = 'deleted';\n static readonly STATE = 'state';\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QueryApi } from '../queryApi';\nimport type { MaterializedSnapshot } from './snapshot';\nimport type {\n ListQuery,\n PagedList,\n PagedQuery,\n SingleQuery,\n} from '../queryable';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\n\n/**\n * Interface for snapshot query API operations.\n * Extends the base QueryApi interface for MaterializedSnapshot and adds methods\n * for querying snapshot states directly without the full MaterializedSnapshot wrapper.\n * @template S - The type of the snapshot state\n */\nexport interface SnapshotQueryApi<S, FIELDS extends string = string>\n extends QueryApi<MaterializedSnapshot<S>, FIELDS> {\n /**\n * Retrieves a single snapshot state based on the provided query parameters.\n * @param singleQuery - The query parameters for retrieving a single snapshot state\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a partial snapshot state\n */\n singleState<T extends Partial<S> = S>(\n singleQuery: SingleQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<T>;\n\n /**\n * Retrieves a list of snapshot states based on the provided query parameters.\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial snapshot states\n */\n listState<T extends Partial<S> = S>(\n listQuery: ListQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<T[]>;\n\n /**\n * Retrieves a stream of snapshot states based on the provided query parameters.\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial snapshot states\n */\n listStateStream<T extends Partial<S> = S>(\n listQuery: ListQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>>;\n\n /**\n * Retrieves a paged list of snapshot states based on the provided query parameters.\n * @param pagedQuery - The query parameters for paging snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial snapshot states\n */\n pagedState<T extends Partial<S> = S>(\n pagedQuery: PagedQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<PagedList<T>>;\n}\n\n/**\n * Provides endpoint paths for snapshot query operations.\n *\n * This class contains static readonly properties that define the endpoint paths used for various snapshot query operations.\n * These paths are used when making API calls to retrieve snapshot data in different formats such as counts, lists, paged results, and single items.\n * The paths are constructed based on a base resource name and extended with specific operation identifiers.\n */\nexport class SnapshotQueryEndpointPaths {\n static readonly SNAPSHOT_RESOURCE_NAME = 'snapshot';\n static readonly COUNT = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/count`;\n static readonly LIST = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/list`;\n static readonly LIST_STATE = `${SnapshotQueryEndpointPaths.LIST}/state`;\n static readonly PAGED = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/paged`;\n static readonly PAGED_STATE = `${SnapshotQueryEndpointPaths.PAGED}/state`;\n static readonly SINGLE = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/single`;\n static readonly SINGLE_STATE = `${SnapshotQueryEndpointPaths.SINGLE}/state`;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type SnapshotQueryApi, SnapshotQueryEndpointPaths, } from './snapshotQueryApi';\nimport { aggregateId, aggregateIds, Condition } from '../condition';\nimport { listQuery, ListQuery, PagedList, PagedQuery, singleQuery, SingleQuery, } from '../queryable';\nimport type { MaterializedSnapshot } from './snapshot';\nimport { JsonEventStreamResultExtractor, JsonServerSentEvent, } from '@ahoo-wang/fetcher-eventstream';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport '@ahoo-wang/fetcher-eventstream';\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n body,\n post,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * A client for querying snapshot data through HTTP endpoints.\n * Provides methods for various query operations such as counting, listing, paging, and retrieving single snapshots.\n *\n * @example\n * ```typescript\n * // Define the state interface\n * interface CartItem {\n * productId: string;\n * quantity: number;\n * }\n *\n * interface CartState {\n * items: CartItem[];\n * }\n *\n * // Create client options configuration\n * const clientOptions: ClientOptions = {\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart'\n * };\n *\n * // Create a snapshot query client instance\n * const snapshotQueryClient = new SnapshotQueryClient<CartState>(clientOptions);\n *\n * // Count snapshots\n * const count = await snapshotQueryClient.count(all());\n *\n * // List snapshots\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await snapshotQueryClient.list(listQuery);\n *\n * // List snapshots as stream\n * const listStream = await snapshotQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const snapshot = event.data;\n * console.log('Received:', snapshot);\n * }\n *\n * // List snapshot states\n * const stateList = await snapshotQueryClient.listState(listQuery);\n *\n * // List snapshot states as stream\n * const stateListStream = await snapshotQueryClient.listStateStream(listQuery);\n * for await (const event of stateListStream) {\n * const state = event.data;\n * console.log('Received state:', state);\n * }\n *\n * // Paged snapshots\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const paged = await snapshotQueryClient.paged(pagedQuery);\n *\n * // Paged snapshot states\n * const pagedState = await snapshotQueryClient.pagedState(pagedQuery);\n *\n * // Single snapshot\n * const singleQuery: SingleQuery = {\n * condition: all()\n * };\n * const single = await snapshotQueryClient.single(singleQuery);\n *\n * // Single snapshot state\n * const singleState = await snapshotQueryClient.singleState(singleQuery);\n * ```\n *\n * @template S The type of the snapshot state\n */\n@api()\nexport class SnapshotQueryClient<S, FIELDS extends string = string>\n implements SnapshotQueryApi<S, FIELDS>, ApiMetadataCapable\n{\n /**\n * Creates a new SnapshotQueryClient instance.\n */\n constructor(public readonly apiMetadata?: ApiMetadata) {}\n\n /**\n * Counts the number of snapshots that match the given condition.\n *\n * @param condition - The condition to match snapshots against\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the count of matching snapshots\n *\n * @example\n * ```typescript\n * const count = await snapshotQueryClient.count(all());\n * console.log('Total snapshots:', count);\n * ```\n */\n @post(SnapshotQueryEndpointPaths.COUNT)\n count(\n @body() condition: Condition<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<number> {\n throw autoGeneratedError(condition, attributes);\n }\n\n /**\n * Retrieves a list of materialized snapshots based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshots\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial materialized snapshots\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await snapshotQueryClient.list(listQuery);\n * for (const snapshot of list) {\n * console.log('Snapshot:', snapshot);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST)\n list<T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>>(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T[]> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a stream of materialized snapshots based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshots\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial materialized snapshots\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const listStream = await snapshotQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const snapshot = event.data;\n * console.log('Received snapshot:', snapshot);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n listStream<\n T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>,\n >(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a list of snapshot states based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial snapshot states\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await snapshotQueryClient.listState(listQuery);\n * for (const state of list) {\n * console.log('State:', state);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST_STATE)\n listState<T extends Partial<S> = S>(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T[]> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a stream of snapshot states based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial snapshot states\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const listStream = await snapshotQueryClient.listStateStream(listQuery);\n * for await (const event of listStream) {\n * const state = event.data;\n * console.log('Received state:', state);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST_STATE, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n listStateStream<T extends Partial<S> = S>(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a paged list of materialized snapshots based on the provided query parameters.\n *\n * @param pagedQuery - The query parameters for paging snapshots\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial materialized snapshots\n *\n * @example\n * ```typescript\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const paged = await snapshotQueryClient.paged(pagedQuery);\n * console.log('Total:', paged.total);\n * for (const snapshot of paged.list) {\n * console.log('Snapshot:', snapshot);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.PAGED)\n paged<T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>>(\n @body() pagedQuery: PagedQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<PagedList<T>> {\n throw autoGeneratedError(pagedQuery, attributes);\n }\n\n /**\n * Retrieves a paged list of snapshot states based on the provided query parameters.\n *\n * @param pagedQuery - The query parameters for paging snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial snapshot states\n *\n * @example\n * ```typescript\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const pagedState = await snapshotQueryClient.pagedState(pagedQuery);\n * for (const state of pagedState.list) {\n * console.log('State:', state);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.PAGED_STATE)\n pagedState<T extends Partial<S> = S>(\n @body() pagedQuery: PagedQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<PagedList<T>> {\n throw autoGeneratedError(pagedQuery, attributes);\n }\n\n /**\n * Retrieves a single materialized snapshot based on the provided query parameters.\n *\n * @param singleQuery - The query parameters for retrieving a single snapshot\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a partial materialized snapshot\n *\n * @example\n * ```typescript\n * const singleQuery: SingleQuery = {\n * condition: all()\n * };\n * const single = await snapshotQueryClient.single(singleQuery);\n * console.log('Snapshot:', single);\n * ```\n */\n @post(SnapshotQueryEndpointPaths.SINGLE)\n single<T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>>(\n @body() singleQuery: SingleQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T> {\n throw autoGeneratedError(singleQuery, attributes);\n }\n\n /**\n * Retrieves a single snapshot state based on the provided query parameters.\n *\n * @param singleQuery - The query parameters for retrieving a single snapshot state\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a partial snapshot state\n *\n * @example\n * ```typescript\n * const singleQuery: SingleQuery = {\n * condition: all()\n * };\n * const singleState = await snapshotQueryClient.singleState(singleQuery);\n * console.log('State:', singleState);\n * ```\n */\n @post(SnapshotQueryEndpointPaths.SINGLE_STATE)\n singleState<T extends Partial<S> = S>(\n @body() singleQuery: SingleQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T> {\n throw autoGeneratedError(singleQuery, attributes);\n }\n\n /**\n * Retrieves a single materialized snapshot by its ID.\n *\n * @param id - The unique identifier of the snapshot to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the materialized snapshot with the specified ID\n *\n * @example\n * ```typescript\n * const snapshot = await snapshotQueryClient.getById('snapshot-123');\n * console.log('Snapshot:', snapshot);\n * ```\n */\n getById(\n id: string,\n @attribute() attributes?: Record<string, any>,\n ): Promise<MaterializedSnapshot<S>> {\n const query = singleQuery<FIELDS>({\n condition: aggregateId(id),\n });\n return this.single(query, attributes);\n }\n\n /**\n * Retrieves a single snapshot state by its ID.\n *\n * @param id - The unique identifier of the snapshot whose state to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the snapshot state with the specified ID\n *\n * @example\n * ```typescript\n * const state = await snapshotQueryClient.getStateById('snapshot-123');\n * console.log('State:', state);\n * ```\n */\n getStateById(\n id: string,\n @attribute() attributes?: Record<string, any>,\n ): Promise<S> {\n const query = singleQuery<FIELDS>({\n condition: aggregateId(id),\n });\n return this.singleState(query, attributes);\n }\n\n /**\n * Retrieves multiple materialized snapshots by their IDs.\n *\n * @param ids - An array of unique identifiers of the snapshots to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of materialized snapshots with the specified IDs\n *\n * @example\n * ```typescript\n * const snapshots = await snapshotQueryClient.getByIds(['snapshot-123', 'snapshot-456']);\n * for (const snapshot of snapshots) {\n * console.log('Snapshot:', snapshot);\n * }\n * ```\n */\n getByIds(\n ids: string[],\n @attribute() attributes?: Record<string, any>,\n ): Promise<MaterializedSnapshot<S>[]> {\n const query = listQuery<FIELDS>({\n condition: aggregateIds(ids),\n limit: ids.length,\n });\n return this.list(query, attributes);\n }\n\n /**\n * Retrieves multiple snapshot states by their IDs.\n *\n * @param ids - An array of unique identifiers of the snapshots whose states to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of snapshot states with the specified IDs\n *\n * @example\n * ```typescript\n * const states = await snapshotQueryClient.getStateByIds(['snapshot-123', 'snapshot-456']);\n * for (const state of states) {\n * console.log('State:', state);\n * }\n * ```\n */\n getStateByIds(\n ids: string[],\n @attribute() attributes?: Record<string, any>,\n ): Promise<S[]> {\n const query = listQuery<FIELDS>({\n condition: aggregateIds(ids),\n limit: ids.length,\n });\n return this.listState(query, attributes);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n get,\n path,\n} from '@ahoo-wang/fetcher-decorator';\n\nexport class LoadStateAggregateEndpointPaths {\n static readonly LOAD = '{id}/state';\n static readonly LOAD_VERSIONED = `${LoadStateAggregateEndpointPaths.LOAD}/{version}`;\n static readonly LOAD_TIME_BASED = `${LoadStateAggregateEndpointPaths.LOAD}/time/{createTime}`;\n}\n\n@api()\nexport class LoadStateAggregateClient<S> implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n\n }\n\n @get(LoadStateAggregateEndpointPaths.LOAD)\n load(@path('id') id: string, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(id, attributes);\n }\n\n @get(LoadStateAggregateEndpointPaths.LOAD_VERSIONED)\n loadVersioned(@path('id') id: string, @path('version') version: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(id, version, attributes);\n }\n\n @get(LoadStateAggregateEndpointPaths.LOAD_TIME_BASED)\n loadTimeBased(@path('id') id: string, @path('createTime') createTime: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(id, createTime, attributes);\n }\n\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n get,\n path,\n} from '@ahoo-wang/fetcher-decorator';\n\nexport class LoadOwnerStateAggregateEndpointPaths {\n static readonly LOAD = 'state';\n static readonly LOAD_VERSIONED = `${LoadOwnerStateAggregateEndpointPaths.LOAD}/{version}`;\n static readonly LOAD_TIME_BASED = `${LoadOwnerStateAggregateEndpointPaths.LOAD}/time/{createTime}`;\n}\n\n@api()\nexport class LoadOwnerStateAggregateClient<S> implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n }\n\n @get(LoadOwnerStateAggregateEndpointPaths.LOAD)\n load(@attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(attributes);\n }\n\n @get(LoadOwnerStateAggregateEndpointPaths.LOAD_VERSIONED)\n loadVersioned(@path('version') version: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(version, attributes);\n }\n\n @get(LoadOwnerStateAggregateEndpointPaths.LOAD_TIME_BASED)\n loadTimeBased(@path('createTime') createTime: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(createTime, attributes);\n }\n\n}","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FieldSort, SortDirection } from './sort';\nimport { ListQuery } from './queryable';\nimport { and, Condition, gt, lt } from './condition';\n\n/**\n * Represents a cursor-based pagination query configuration.\n * This interface defines the structure for implementing cursor-based pagination,\n * which is an efficient way to paginate through large datasets.\n */\nexport interface CursorQuery<FIELDS extends string = string> {\n /** Field name used for cursor-based sorting and filtering */\n field: FIELDS;\n /**\n * Cursor ID marking the starting point (exclusive)\n * Uses CURSOR_ID_START constant for initial query\n */\n cursorId?: string;\n /** Sort direction for pagination traversal (ascending or descending) */\n direction?: SortDirection;\n /** Base query object to be enhanced with cursor-based parameters */\n query: ListQuery;\n}\n\n/** Special cursor ID value representing the starting point of a dataset */\nexport const CURSOR_ID_START = '~';\n\n/**\n * Generates a cursor condition for filtering records relative to the cursor position\n * @param params - Cursor parameters excluding the base query\n * @param params.field - The field to apply the cursor condition on\n * @param params.cursorId - The cursor ID to compare against (defaults to CURSOR_ID_START)\n * @param params.direction - Sort direction which determines the comparison operator (defaults to SortDirection.DESC)\n * @returns Condition object for filtering records based on cursor position\n */\nexport function cursorCondition<FIELDS extends string = string>({\n field,\n cursorId = CURSOR_ID_START,\n direction = SortDirection.DESC,\n }: Omit<CursorQuery<FIELDS>, 'query'>): Condition<FIELDS> {\n // When sorting in ascending order, we want records greater than the cursor\n if (direction === SortDirection.ASC) {\n return gt(field, cursorId);\n } else {\n // When sorting in descending order, we want records less than the cursor\n return lt(field, cursorId);\n }\n}\n\n/**\n * Creates a sort configuration based on cursor parameters\n * @param params - Cursor parameters excluding the base query\n * @param params.field - The field to sort by\n * @param params.direction - Sort direction (defaults to SortDirection.DESC)\n * @returns FieldSort configuration for cursor-based pagination\n */\nexport function cursorSort<FIELDS extends string = string>({\n field,\n direction = SortDirection.DESC,\n }: Omit<CursorQuery<FIELDS>, 'query'>): FieldSort<FIELDS> {\n return { field, direction };\n}\n\n/**\n * Enhances a base query with cursor-based pagination parameters\n * This function combines the cursor condition with the existing query condition\n * and sets the sorting according to the cursor parameters.\n * @param options - Complete cursor query configuration\n * @param options.field - The field used for cursor-based sorting and filtering\n * @param options.cursorId - The cursor ID marking the starting point (exclusive)\n * @param options.direction - Sort direction for pagination traversal\n * @param options.query - Base query object to be enhanced with cursor-based parameters\n * @returns Enhanced query with cursor-based filtering and sorting\n */\nexport function cursorQuery<FIELDS extends string = string>(\n options: CursorQuery<FIELDS>,\n): ListQuery {\n const query = options.query;\n // Combine the cursor condition with the existing query condition\n const mergedCondition = and(cursorCondition(options), query.condition);\n // Apply cursor-based sorting\n const mergedSort = cursorSort(options);\n return {\n ...query,\n condition: mergedCondition,\n sort: [mergedSort],\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { combineURLs, PartialBy } from '@ahoo-wang/fetcher';\nimport { ApiMetadata } from '@ahoo-wang/fetcher-decorator';\nimport { AggregateNameCapable, AliasBoundedContext } from '../types';\nimport { ResourceAttributionPathSpec } from '../types';\nimport { SnapshotQueryClient } from './snapshot';\nimport { EventStreamQueryClient } from './event';\nimport { LoadStateAggregateClient } from './state';\nimport { LoadOwnerStateAggregateClient } from './state';\n\n/**\n * Configuration options for query clients.\n *\n * This interface extends ApiMetadata (without basePath), AliasBoundedContext, and AggregateNameCapable\n * to provide a complete configuration for query clients. It includes optional context alias and\n * resource attribution path specifications.\n */\nexport interface QueryClientOptions\n extends PartialBy<ApiMetadata, 'basePath'>,\n Partial<AliasBoundedContext>,\n Partial<AggregateNameCapable> {\n contextAlias?: string;\n resourceAttribution?: ResourceAttributionPathSpec;\n}\n\n/**\n * Creates API metadata for query clients by combining various path components.\n *\n * This function constructs a base path by combining the resource attribution path with the aggregate name,\n * and optionally prepending a context alias if provided.\n *\n * @param options - The query client options containing resource attribution, aggregate name, and optional context alias\n * @returns ApiMetadata object with the constructed base path\n */\nexport function createQueryApiMetadata(\n options: QueryClientOptions,\n): ApiMetadata {\n let basePath = combineURLs(\n options.resourceAttribution ?? '',\n options.aggregateName ?? '',\n );\n if (options.contextAlias) {\n basePath = combineURLs(options.contextAlias, basePath);\n }\n return { ...options, basePath };\n}\n\nexport class QueryClientFactory<\n S,\n FIELDS extends string = string,\n DomainEventBody = any,\n> {\n /**\n * Creates a new QueryClientFactory instance with the specified default options.\n *\n * @param defaultOptions - The default options to be used for all query clients created by this factory\n *\n * @example\n * ```typescript\n * import { QueryClientFactory, ResourceAttributionPathSpec } from '@ahoo-wang/fetcher-wow';\n *\n * const factory = new QueryClientFactory({\n * contextAlias: 'example',\n * aggregateName: 'cart',\n * resourceAttribution: ResourceAttributionPathSpec.OWNER,\n * });\n * ```\n */\n constructor(private readonly defaultOptions: QueryClientOptions) {\n }\n\n /**\n * Creates a snapshot query client for querying aggregate snapshots.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates a SnapshotQueryClient.\n *\n * @param options - The query client options used to configure the snapshot query client\n * @returns A new instance of SnapshotQueryClient\n *\n * @example\n * ```typescript\n * const snapshotClient = factory.createSnapshotQueryClient({\n * aggregateName: 'cart',\n * });\n *\n * const cartState = await snapshotClient.singleState({ condition: all() });\n * ```\n */\n createSnapshotQueryClient(\n options: QueryClientOptions,\n ): SnapshotQueryClient<S, FIELDS> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new SnapshotQueryClient(apiMetadata);\n }\n\n /**\n * Creates a client for loading aggregate state by ID.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates a LoadStateAggregateClient.\n * The client supports loading current state, versioned state, and time-based state.\n *\n * @param options - The query client options used to configure the state aggregate client\n * @returns A new instance of LoadStateAggregateClient\n *\n * @example\n * ```typescript\n * const stateClient = factory.createLoadStateAggregateClient({\n * aggregateName: 'cart',\n * });\n *\n * // Load current state\n * const currentState = await stateClient.load('cart-123');\n *\n * // Load specific version\n * const versionedState = await stateClient.loadVersioned('cart-123', 5);\n *\n * // Load state at specific time\n * const timeBasedState = await stateClient.loadTimeBased('cart-123', Date.now());\n * ```\n */\n createLoadStateAggregateClient(\n options: QueryClientOptions,\n ): LoadStateAggregateClient<S> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new LoadStateAggregateClient(apiMetadata);\n }\n\n /**\n * Creates a client for loading owner-specific aggregate state.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates a LoadOwnerStateAggregateClient.\n * Unlike the standard state client, this client loads state for the current owner\n * without requiring an explicit ID parameter.\n *\n * @param options - The query client options used to configure the owner state aggregate client\n * @returns A new instance of LoadOwnerStateAggregateClient\n *\n * @example\n * ```typescript\n * const ownerStateClient = factory.createOwnerLoadStateAggregateClient({\n * aggregateName: 'cart',\n * resourceAttribution: ResourceAttributionPathSpec.OWNER,\n * });\n *\n * // Load current owner's state\n * const currentState = await ownerStateClient.load();\n *\n * // Load specific version of owner's state\n * const versionedState = await ownerStateClient.loadVersioned(5);\n *\n * // Load owner's state at specific time\n * const timeBasedState = await ownerStateClient.loadTimeBased(Date.now());\n * ```\n */\n createOwnerLoadStateAggregateClient(\n options: QueryClientOptions,\n ): LoadOwnerStateAggregateClient<S> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new LoadOwnerStateAggregateClient(apiMetadata);\n }\n\n /**\n * Creates an event stream query client for querying domain event streams.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates an EventStreamQueryClient.\n *\n * @param options - The query client options used to configure the event stream query client\n * @returns A new instance of EventStreamQueryClient\n *\n * @example\n * ```typescript\n * const eventClient = factory.createEventStreamQueryClient({\n * aggregateName: 'cart',\n * });\n *\n * const events = await eventClient.list({ condition: all() });\n * ```\n */\n createEventStreamQueryClient<FIELDS extends string = string>(\n options: QueryClientOptions,\n ): EventStreamQueryClient<DomainEventBody, FIELDS> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new EventStreamQueryClient(apiMetadata);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for path parameters used in URL construction.\n * Defines common path parameters and allows for additional custom parameters.\n * This interface is used to provide path variables for URL templating.\n */\nexport interface UrlPathParams {\n /**\n * Tenant identifier parameter.\n * Used in multi-tenant applications to identify the tenant context.\n */\n tenantId?: string;\n /**\n * Owner identifier parameter.\n * Used to identify the owner or user context for the resource.\n */\n ownerId?: string;\n /**\n * Generic identifier parameter.\n * Used as a general purpose ID for resources when tenantId or ownerId are not appropriate.\n */\n id?: string;\n\n /**\n * Index signature for additional custom path parameters.\n * Allows for any additional string key-value pairs to be included as path parameters.\n */\n [key: string]: string | undefined;\n}\n\n/**\n * Enumeration of resource attribution path specifications.\n * Defines standard path patterns for accessing resources with different attribution scopes.\n * These paths are used to construct URLs that include tenant and/or owner identifiers.\n *\n * @example\n * ```typescript\n * // Using TENANT path spec\n * const path = ResourceAttributionPathSpec.TENANT; // '/tenant/{tenantId}'\n *\n * // Using TENANT_OWNER path spec\n * const path = ResourceAttributionPathSpec.TENANT_OWNER; // '/tenant/{tenantId}/owner/{ownerId}'\n * ```\n */\nexport enum ResourceAttributionPathSpec {\n NONE = '',\n TENANT = '/tenant/{tenantId}',\n OWNER = '/owner/{ownerId}',\n TENANT_OWNER = '/tenant/{tenantId}/owner/{ownerId}',\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Enumerates the types of recoverability for errors or operations, allowing for classification and handling based on whether an error is transient and can be resolved by retrying.\n *\n * The [RecoverableType] enum provides a way to categorize errors into three distinct categories: [RECOVERABLE], [UNRECOVERABLE], and [UNKNOWN].\n * This categorization is essential for implementing robust error handling and retry mechanisms in applications,\n * ensuring that temporary issues are retried while permanent or unknown issues are handled appropriately.\n *\n */\nexport enum RecoverableType {\n /**\n * Represents an error type that indicates the operation or error can be retried.\n *\n * This enum value is used to classify errors in a way that allows for the implementation of retry logic. When an error\n * is marked as [RECOVERABLE], it signifies that the error condition is temporary and might be resolved upon retrying the\n * operation. This is particularly useful in scenarios where network issues, transient server errors, or other temporary\n * conditions may cause an operation to fail, but with a high likelihood of success on subsequent attempts.\n */\n RECOVERABLE = 'RECOVERABLE',\n /**\n * Represents an error type that indicates the operation or error cannot be retried.\n *\n * This enum value is used to classify errors in a way that signifies the error condition is permanent and retrying the operation will not resolve the issue. It is particularly\n * useful for handling errors where the underlying problem is fundamental and cannot be resolved by simply retrying, such as invalid input, resource exhaustion, or other non-transient\n * issues.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * Represents an unknown type of recoverability for an error or operation.\n * This is used when the recoverability of an error cannot be determined or is not specified.\n */\n UNRECOVERABLE = 'UNRECOVERABLE',\n}\n\n/**\n * Represents an error that occurs during the binding process, typically when data is being mapped to or from an object.\n * This class extends the [Named] interface, inheriting the `name` property which can be used to identify the source or context of the error.\n *\n * @param name The name or identifier for the context in which the error occurred.\n * @param msg A message describing the error.\n */\nexport interface BindingError {\n name: string;\n msg: string;\n}\n\n/**\n * Represents the information about an error, including whether the operation succeeded, the error code, and any associated messages or binding errors.\n *\n * This interface is designed to provide a standardized way of handling and representing errors across different parts of an application. It includes methods to check if the operation was successful, retrieve the error code\n * , and access any additional error details such as messages or binding errors.\n */\nexport interface ErrorInfo {\n /**\n * Represents the error code associated with an error. This value is used to identify the type of error that has occurred,\n * which can be useful for debugging, logging, and handling errors in a standardized way.\n */\n errorCode: string;\n /**\n * Represents the message associated with an error. This message provides a human-readable description of the error, which can be used for logging, debugging, or displaying to the user\n * .\n */\n errorMsg: string;\n /**\n * Provides a list of [BindingError] instances that occurred during the binding process.\n * Each [BindingError] contains information about the error, including its name and a message describing the issue.\n * This property returns an empty list if no binding errors are present.\n */\n bindingErrors?: BindingError[];\n}\n\nexport class ErrorCodes {\n /**\n * A constant representing a successful operation or status.\n * This value is typically used in the context of error handling and response descriptions to indicate that an operation has been completed successfully.\n */\n static readonly SUCCEEDED = 'Ok';\n static readonly SUCCEEDED_MESSAGE = '';\n\n /**\n * Error code for when a requested resource is not found.\n */\n static readonly NOT_FOUND = 'NotFound';\n\n /**\n * Default message for NOT_FOUND error code.\n */\n static readonly NOT_FOUND_MESSAGE = 'Not found resource!';\n\n /**\n * Error code for bad request errors.\n */\n static readonly BAD_REQUEST = 'BadRequest';\n\n /**\n * Error code for illegal argument errors.\n */\n static readonly ILLEGAL_ARGUMENT = 'IllegalArgument';\n\n /**\n * Error code for illegal state errors.\n */\n static readonly ILLEGAL_STATE = 'IllegalState';\n\n /**\n * Error code for request timeout errors.\n */\n static readonly REQUEST_TIMEOUT = 'RequestTimeout';\n\n /**\n * Error code for too many requests errors (rate limiting).\n */\n static readonly TOO_MANY_REQUESTS = 'TooManyRequests';\n\n /**\n * Error code for duplicate request ID errors.\n */\n static readonly DUPLICATE_REQUEST_ID = 'DuplicateRequestId';\n\n /**\n * Error code for command validation errors.\n */\n static readonly COMMAND_VALIDATION = 'CommandValidation';\n\n /**\n * Error code for when no command is found to rewrite.\n */\n static readonly REWRITE_NO_COMMAND = 'RewriteNoCommand';\n\n /**\n * Error code for event version conflicts.\n */\n static readonly EVENT_VERSION_CONFLICT = 'EventVersionConflict';\n\n /**\n * Error code for duplicate aggregate ID errors.\n */\n static readonly DUPLICATE_AGGREGATE_ID = 'DuplicateAggregateId';\n\n /**\n * Error code for command expected version conflicts.\n */\n static readonly COMMAND_EXPECT_VERSION_CONFLICT =\n 'CommandExpectVersionConflict';\n\n /**\n * Error code for sourcing version conflicts.\n */\n static readonly SOURCING_VERSION_CONFLICT = 'SourcingVersionConflict';\n\n /**\n * Error code for illegal access to deleted aggregate errors.\n */\n static readonly ILLEGAL_ACCESS_DELETED_AGGREGATE =\n 'IllegalAccessDeletedAggregate';\n\n /**\n * Error code for illegal access to owner aggregate errors.\n */\n static readonly ILLEGAL_ACCESS_OWNER_AGGREGATE =\n 'IllegalAccessOwnerAggregate';\n\n /**\n * Error code for internal server errors.\n */\n static readonly INTERNAL_SERVER_ERROR = 'InternalServerError';\n\n /**\n * Checks if the provided error code represents a successful operation.\n *\n * @param errorCode The error code to check\n * @returns true if the error code is 'Ok', false otherwise\n */\n static isSucceeded(errorCode: string): boolean {\n return errorCode === ErrorCodes.SUCCEEDED;\n }\n\n /**\n * Checks if the provided error code represents an error condition.\n *\n * @param errorCode The error code to check\n * @returns true if the error code is not 'Ok', false otherwise\n */\n static isError(errorCode: string): boolean {\n return !ErrorCodes.isSucceeded(errorCode);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Named, NamedBoundedContext } from './naming';\n\n/**\n * Function kind enum\n *\n * Represents the different types of functions in the system.\n */\nexport enum FunctionKind {\n /**\n * Command function kind\n */\n COMMAND = 'COMMAND',\n\n /**\n * Error function kind\n */\n ERROR = 'ERROR',\n\n /**\n * Event function kind\n */\n EVENT = 'EVENT',\n\n /**\n * Sourcing function kind\n */\n SOURCING = 'SOURCING',\n\n /**\n * State event function kind\n */\n STATE_EVENT = 'STATE_EVENT',\n}\n\n/**\n * Interface for function information.\n */\nexport interface FunctionInfo extends NamedBoundedContext, Named {\n functionKind: FunctionKind;\n processorName: string;\n}\n\n/**\n * Interface for objects that have function information.\n */\nexport interface FunctionInfoCapable {\n function: FunctionInfo;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AliasBoundedContext, NamedBoundedContext } from './naming.ts';\n\n/**\n * Interface for classes that have a creation time.\n */\nexport interface CreateTimeCapable {\n /**\n * Gets the creation time in milliseconds since the Unix epoch.\n */\n createTime: number;\n}\n\n/**\n * Interface for objects that track deletion status.\n */\nexport interface DeletedCapable {\n /**\n * Whether the aggregate is deleted.\n */\n deleted: boolean;\n}\n\n/**\n * Interface for objects that track event IDs.\n */\nexport interface EventIdCapable {\n /**\n * The event id of the aggregate.\n */\n eventId: string;\n}\n\n/**\n * Interface for objects that track event times.\n */\nexport interface EventTimeCapable {\n /**\n * The last event time of the aggregate, represented as a Unix timestamp in milliseconds.\n */\n eventTime: number;\n}\n\n/**\n * Interface for objects that track the first event time.\n */\nexport interface FirstEventTimeCapable {\n /**\n * The first event time of the aggregate, represented as a Unix timestamp in milliseconds.\n */\n firstEventTime: number;\n}\n\n/**\n * Interface for objects that track the first operator.\n */\nexport interface FirstOperatorCapable {\n /**\n * The first operator of the aggregate.\n */\n firstOperator: string;\n}\n\n/**\n * Interface for objects that have an aggregate name.\n */\nexport interface AggregateNameCapable {\n /**\n * The name of the aggregate.\n */\n aggregateName: string;\n}\n\n/**\n * Interface for named aggregates that belong to a bounded context.\n */\nexport interface NamedAggregate\n extends NamedBoundedContext,\n AggregateNameCapable {\n}\n\nexport interface AliasAggregate\n extends AliasBoundedContext,\n AggregateNameCapable {\n}\n\n/**\n * Interface for aggregate IDs that combine tenant and named aggregate information.\n */\nexport interface AggregateId extends TenantId, NamedAggregate {\n aggregateId: string;\n}\n\n/**\n * Interface that provides the capability to contain an aggregate identifier.\n *\n * This interface is implemented by objects that need to reference an aggregate instance\n * through its unique identifier, which includes tenant, context, aggregate name and the\n * actual aggregate ID.\n */\nexport interface AggregateIdCapable {\n /**\n * The unique identifier of the aggregate instance.\n *\n * Contains information about the tenant, bounded context, aggregate name and the\n * actual aggregate ID string.\n */\n aggregateId: AggregateId;\n}\n\n/**\n * Interface for objects that track the last operator.\n */\nexport interface OperatorCapable {\n /**\n * The last operator of the aggregate.\n */\n operator: string;\n}\n\nexport const DEFAULT_OWNER_ID = '';\n\n/**\n * Interface for identifying resource owners.\n */\nexport interface OwnerId {\n /**\n * Unique identifier of the resource owner.\n */\n ownerId: string;\n}\n\n/**\n * Interface for objects that track snapshot times.\n */\nexport interface SnapshotTimeCapable {\n /**\n * The snapshot time of the aggregate, represented as a Unix timestamp in milliseconds.\n */\n snapshotTime: number;\n}\n\n/**\n * Interface for objects that have a tenant ID.\n */\nexport interface TenantId {\n tenantId: string;\n}\n\n/**\n * Interface for objects that hold state.\n */\nexport interface StateCapable<S> {\n state: S;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum MessageHeaderSqlType {\n MAP = 'MAP',\n STRING = 'STRING',\n}\n"],"names":["CommandClient","apiMetadata","commandRequest","attributes","autoGeneratedError","__decorateClass","endpoint","__decorateParam","request","attribute","ContentTypeValues","JsonEventStreamResultExtractor","api","_CommandHeaders","CommandHeaders","CommandStage","Operator","isValidateCondition","condition","_ConditionOptionKey","ConditionOptionKey","ignoreCaseOptions","ignoreCase","dateOptions","datePattern","zoneId","options","DeletionState","and","conditions","all","andChildren","or","validateConditions","nor","id","value","ids","aggregateId","aggregateIds","tenantId","ownerId","deleted","active","eq","field","ne","gt","lt","gte","lte","contains","isIn","notIn","between","start","end","allIn","startsWith","endsWith","elemMatch","isNull","notNull","isTrue","isFalse","exists","today","beforeToday","time","tomorrow","thisWeek","nextWeek","lastWeek","thisMonth","lastMonth","recentDays","days","earlierDays","raw","DEFAULT_PAGINATION","pagination","index","size","DEFAULT_PROJECTION","defaultProjection","projection","include","exclude","singleQuery","sort","listQuery","limit","pagedQuery","EMPTY_PAGED_LIST","pagedList","total","list","SortDirection","asc","desc","_DomainEventStreamMetadataFields","DomainEventStreamMetadataFields","_EventStreamQueryEndpointPaths","EventStreamQueryEndpointPaths","EventStreamQueryClient","post","body","_SnapshotMetadataFields","SnapshotMetadataFields","_SnapshotQueryEndpointPaths","SnapshotQueryEndpointPaths","SnapshotQueryClient","query","_LoadStateAggregateEndpointPaths","LoadStateAggregateEndpointPaths","LoadStateAggregateClient","version","createTime","get","_LoadOwnerStateAggregateEndpointPaths","LoadOwnerStateAggregateEndpointPaths","LoadOwnerStateAggregateClient","CURSOR_ID_START","cursorCondition","cursorId","direction","cursorSort","cursorQuery","mergedCondition","mergedSort","createQueryApiMetadata","basePath","combineURLs","QueryClientFactory","defaultOptions","ResourceAttributionPathSpec","RecoverableType","_ErrorCodes","errorCode","ErrorCodes","FunctionKind","DEFAULT_OWNER_ID","MessageHeaderSqlType"],"mappings":"yaA0EaA,QAAAA,cAAN,KACyB,CAC9B,YAA4BC,EAA2B,CAA3B,KAAA,YAAAA,CAC5B,CAuBA,KACaC,EACEC,EACW,CACxB,MAAMC,EAAAA,mBAAmBF,EAAgBC,CAAU,CACrD,CAkCA,kBACaD,EACEC,EACsB,CACnC,MAAMC,EAAAA,mBAAmBF,EAAgBC,CAAU,CACrD,CACF,EA7CEE,EAAA,CADCC,WAAA,EAEEC,EAAA,EAAAC,EAAAA,SAAQ,EACRD,EAAA,EAAAE,YAAA,CAAU,CAAA,EA5BFT,sBA0BX,UAAA,OAAA,CAAA,EAuCAK,EAAA,CAJCC,EAAAA,SAAS,OAAW,OAAW,CAC9B,QAAS,CAAE,OAAQI,EAAAA,kBAAkB,iBAAA,EACrC,gBAAiBC,EAAAA,8BAAA,CAClB,EAEEJ,EAAA,EAAAC,EAAAA,SAAQ,EACRD,EAAA,EAAAE,YAAA,CAAU,CAAA,EAnEFT,sBAiEX,UAAA,oBAAA,CAAA,EAjEWA,QAAAA,cAANK,EAAA,CADNO,EAAAA,IAAA,CAAI,EACQZ,qBAAA,EC1CN,MAAMa,E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,IAIVA,EAAA,QAAU,UAKVA,EAAA,MAAQ,QAKRA,EAAA,MAAQ,QAKRA,EAAA,SAAW,WAKXA,EAAA,YAAc,cAxBJA,IAAAA,IAAA,CAAA,CAAA,ECgHL,MAAMC,GAAmB,GCvHzB,IAAKC,IAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,OAAS,SAFCA,IAAAA,IAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/command/commandClient.ts","../src/command/commandHeaders.ts","../src/command/types.ts","../src/query/operator.ts","../src/query/condition.ts","../src/query/pagination.ts","../src/query/projection.ts","../src/query/queryable.ts","../src/query/sort.ts","../src/query/event/domainEventStream.ts","../src/query/event/eventStreamQueryApi.ts","../src/query/event/eventStreamQueryClient.ts","../src/query/snapshot/snapshot.ts","../src/query/snapshot/snapshotQueryApi.ts","../src/query/snapshot/snapshotQueryClient.ts","../src/query/state/loadStateAggregateClient.ts","../src/query/state/loadOwnerStateAggregateClient.ts","../src/query/cursorQuery.ts","../src/query/queryClients.ts","../src/types/endpoints.ts","../src/types/error.ts","../src/types/function.ts","../src/types/modeling.ts","../src/types/bi.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type CommandRequest } from './commandRequest';\nimport {\n type CommandResult,\n type CommandResultEventStream,\n} from './commandResult';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport { JsonEventStreamResultExtractor } from '@ahoo-wang/fetcher-eventstream';\n\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n endpoint,\n request,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * Command Client for sending commands to the server.\n *\n * The CommandClient is responsible for sending commands to the server and handling the responses.\n * It provides methods for both regular command execution and streaming command results.\n *\n * @example\n * ```typescript\n * // Create a client options configuration\n * const clientOptions: ClientOptions = {\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart'\n * };\n *\n * // Create a command client instance\n * const commandClient = new CommandClient(clientOptions);\n *\n * // Define command endpoint\n * const addCartItem = 'add_cart_item';\n *\n * // Create a command request\n * const addCartItemCommand: CommandRequest<AddCartItem> = {\n * method: HttpMethod.POST,\n * headers: {\n * [CommandHttpHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,\n * },\n * body: {\n * productId: 'productId',\n * quantity: 1,\n * }\n * };\n *\n * // Send command and get result\n * const commandResult = await commandClient.send(addCartItem, addCartItemCommand);\n *\n * // Send command and get result as stream\n * const commandResultStream = await commandClient.sendAndWaitStream(addCartItem, addCartItemCommand);\n * for await (const commandResultEvent of commandResultStream) {\n * console.log('Received:', commandResultEvent.data);\n * }\n * ```\n */\n@api()\nexport class CommandClient<C extends object = object>\n implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n }\n\n /**\n * Send a command to the server and wait for the result.\n *\n * @param commandRequest - The command request to send\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the command execution result\n *\n * @example\n * ```typescript\n * const commandResult = await commandClient.send('add_cart_item', {\n * method: HttpMethod.POST,\n * body: {\n * productId: 'product-1',\n * quantity: 2\n * }\n * });\n * ```\n */\n @endpoint()\n send(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<CommandResult> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n\n /**\n * Send a command to the server and wait for the result as a stream.\n * This is useful for long-running commands that produce multiple events.\n *\n * @param commandRequest - The command request to send\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a stream of command execution results\n *\n * @example\n * ```typescript\n * const commandResultStream = await commandClient.sendAndWaitStream('add_cart_item', {\n * method: HttpMethod.POST,\n * headers: {\n * Accept: ContentTypeValues.TEXT_EVENT_STREAM\n * },\n * body: {\n * productId: 'product-1',\n * quantity: 2\n * }\n * });\n *\n * for await (const commandResultEvent of commandResultStream) {\n * console.log('Received event:', commandResultEvent.data);\n * }\n * ```\n */\n @endpoint(undefined, undefined, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n sendAndWaitStream(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<CommandResultEventStream> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Command Header Constants\n *\n * Defines standard HTTP header constants used in command processing within the Wow framework.\n * These headers are used to pass metadata and control information between services.\n *\n * @example\n * ```typescript\n * // Using header constants in a request\n * const request = {\n * headers: {\n * [CommandHttpHeaders.TENANT_ID]: 'tenant-123',\n * [CommandHttpHeaders.AGGREGATE_ID]: 'aggregate-456',\n * [CommandHttpHeaders.REQUEST_ID]: 'request-789'\n * },\n * body: command\n * };\n * ```\n */\nexport class CommandHeaders {\n /**\n * Prefix for all command-related headers\n */\n static readonly COMMAND_HEADERS_PREFIX = 'Command-';\n\n /**\n * Tenant identifier header\n * Used to identify the tenant context for the command\n */\n static readonly TENANT_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Tenant-Id`;\n\n /**\n * Owner identifier header\n * Used to identify the owner context for the command\n */\n static readonly OWNER_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Owner-Id`;\n\n /**\n * Aggregate identifier header\n * Used to identify the aggregate root for the command\n */\n static readonly AGGREGATE_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Id`;\n\n /**\n * Aggregate version header\n * Used to specify the expected version of the aggregate root\n */\n static readonly AGGREGATE_VERSION = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Version`;\n\n /**\n * Wait prefix for wait-related headers\n */\n static readonly WAIT_PREFIX = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Wait-`;\n\n /**\n * Wait timeout header\n * Specifies the maximum time to wait for command processing\n */\n static readonly WAIT_TIME_OUT = `${CommandHeaders.WAIT_PREFIX}Timeout`;\n\n // region Wait Stage\n /**\n * Wait stage header\n * Specifies the processing stage to wait for\n */\n static readonly WAIT_STAGE = `${CommandHeaders.WAIT_PREFIX}Stage`;\n\n /**\n * Wait context header\n * Specifies the bounded context to wait for\n */\n static readonly WAIT_CONTEXT = `${CommandHeaders.WAIT_PREFIX}Context`;\n\n /**\n * Wait processor header\n * Specifies the processor to wait for\n */\n static readonly WAIT_PROCESSOR = `${CommandHeaders.WAIT_PREFIX}Processor`;\n\n /**\n * Wait function header\n * Specifies the function to wait for\n */\n static readonly WAIT_FUNCTION = `${CommandHeaders.WAIT_PREFIX}Function`;\n // endregion\n\n // region Wait Chain Tail\n /**\n * Wait tail prefix for wait chain tail-related headers\n */\n static readonly WAIT_TAIL_PREFIX = `${CommandHeaders.WAIT_PREFIX}Tail-`;\n\n /**\n * Wait tail stage header\n * Specifies the tail processing stage to wait for\n */\n static readonly WAIT_TAIL_STAGE = `${CommandHeaders.WAIT_TAIL_PREFIX}Stage`;\n\n /**\n * Wait tail context header\n * Specifies the tail bounded context to wait for\n */\n static readonly WAIT_TAIL_CONTEXT = `${CommandHeaders.WAIT_TAIL_PREFIX}Context`;\n\n /**\n * Wait tail processor header\n * Specifies the tail processor to wait for\n */\n static readonly WAIT_TAIL_PROCESSOR = `${CommandHeaders.WAIT_TAIL_PREFIX}Processor`;\n\n /**\n * Wait tail function header\n * Specifies the tail function to wait for\n */\n static readonly WAIT_TAIL_FUNCTION = `${CommandHeaders.WAIT_TAIL_PREFIX}Function`;\n // endregion\n\n /**\n * Request identifier header\n * Used to track the request ID for correlation\n */\n static readonly REQUEST_ID = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Request-Id`;\n\n /**\n * Local first header\n * Indicates whether to prefer local processing\n */\n static readonly LOCAL_FIRST = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Local-First`;\n\n /**\n * Command aggregate context header\n * Specifies the bounded context of the aggregate\n */\n static readonly COMMAND_AGGREGATE_CONTEXT = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Context`;\n\n /**\n * Command aggregate name header\n * Specifies the name of the aggregate\n */\n static readonly COMMAND_AGGREGATE_NAME = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Name`;\n\n /**\n * Command type header\n * Specifies the type of the command\n */\n static readonly COMMAND_TYPE = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Type`;\n\n /**\n * Command header prefix for custom headers\n * Used to prefix custom command headers\n */\n static readonly COMMAND_HEADER_X_PREFIX = `${CommandHeaders.COMMAND_HEADERS_PREFIX}Header-`;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorInfo, FunctionInfoCapable, Identifier } from '../types';\nimport { PartialBy } from '@ahoo-wang/fetcher';\n\n/**\n * Command identifier interface\n *\n * Represents the unique identifier for a command.\n */\nexport interface CommandId {\n commandId: string;\n}\n\n/**\n * Wait command identifier capable interface\n *\n * Represents the identifier of the command being waited for.\n */\nexport interface WaitCommandIdCapable {\n waitCommandId: string;\n}\n\n/**\n * Request identifier interface\n *\n * Represents the unique identifier for a request, used for idempotency control.\n */\nexport interface RequestId {\n requestId: string;\n}\n\n/**\n * Command execution stage enum\n *\n * Represents the different stages of command execution lifecycle.\n */\nexport enum CommandStage {\n /**\n * When the command is published to the command bus/queue, a completion signal is generated.\n */\n SENT = 'SENT',\n\n /**\n * When the command is processed by the aggregate root, a completion signal is generated.\n */\n PROCESSED = 'PROCESSED',\n\n /**\n * When the snapshot is generated, a completion signal is generated.\n */\n SNAPSHOT = 'SNAPSHOT',\n\n /**\n * When the events generated by the command are *projected*, a completion signal is generated.\n */\n PROJECTED = 'PROJECTED',\n\n /**\n * When the events generated by the command are processed by *event handlers*, a completion signal is generated.\n */\n EVENT_HANDLED = 'EVENT_HANDLED',\n\n /**\n * When the events generated by the command are processed by *Saga*, a completion signal is generated.\n */\n SAGA_HANDLED = 'SAGA_HANDLED',\n}\n\n/**\n * Command stage capable interface\n *\n * Represents an object that has a command execution stage.\n */\nexport interface CommandStageCapable {\n stage: CommandStage;\n}\n\n/**\n * Command result capable interface\n *\n * Represents an object that contains command execution results.\n */\nexport interface CommandResultCapable {\n result: Record<string, any>;\n}\n\n/**\n * Signal time capable interface\n *\n * Represents an object that has a signal time (timestamp).\n */\nexport interface SignalTimeCapable {\n signalTime: number;\n}\n\n/**\n * Nullable aggregate version capable interface\n *\n * Represents an object that may have an aggregate version for optimistic concurrency control.\n */\nexport interface NullableAggregateVersionCapable {\n /**\n * Aggregate root version number\n * - When command processing succeeds, this is the version number after the aggregate root has completed command processing\n * - When command validation fails at the command gateway, this is null\n * - When command execution fails in the command handler, this is the current version number of the aggregate root\n */\n aggregateVersion?: number;\n}\n\n/**\n * Represents a target for compensation operations.\n *\n * This interface extends Identifier (with optional id) and FunctionInfoCapable to define\n * the structure for objects that can be targeted for compensation operations. Compensation\n * targets typically represent entities that can have operations reversed or corrected.\n */\nexport interface CompensationTarget\n extends PartialBy<Identifier, 'id'>,\n FunctionInfoCapable {\n}\n\n/**\n * Represents a command to delete an aggregate.\n *\n * This interface defines the structure for commands that request the deletion of an aggregate.\n * It is typically used in conjunction with other command interfaces to provide a complete\n * command processing workflow.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DeleteAggregate {\n}\n\n/**\n * Represents a command to recover an aggregate.\n *\n * This interface defines the structure for commands that request the recovery of an aggregate,\n * typically used in scenarios where an aggregate needs to be restored to a previous state\n * or recovered from an error condition.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface RecoverAggregate {\n}\n\n/**\n * Represents the result of a batch operation, containing information about\n * the pagination and error status of the operation.\n *\n * Extends ErrorInfo to include error details if the batch operation failed.\n */\nexport interface BatchResult extends ErrorInfo {\n /**\n * The cursor or identifier for the next item after the current batch.\n * Used for pagination to continue fetching the next batch of items.\n */\n after: string;\n\n /**\n * The number of items in the current batch.\n */\n size: number;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum Operator {\n /**\n * Performs logical AND on the provided condition list\n */\n AND = 'AND',\n\n /**\n * Performs logical OR on the provided condition list\n */\n OR = 'OR',\n\n /**\n * Performs logical NOR on the provided condition list\n */\n NOR = 'NOR',\n\n /**\n * Matches all documents where the `id` field value equals the specified value\n */\n ID = 'ID',\n\n /**\n * Matches all documents where the `id` field value equals any value in the specified list\n */\n IDS = 'IDS',\n\n /**\n * Matches documents where the aggregate root ID equals the specified value\n */\n AGGREGATE_ID = 'AGGREGATE_ID',\n\n /**\n * Matches all documents where the aggregate root ID equals any value in the specified list\n */\n AGGREGATE_IDS = 'AGGREGATE_IDS',\n\n /**\n * Matches all documents where the `tenantId` field value equals the specified value\n */\n TENANT_ID = 'TENANT_ID',\n\n /**\n * Matches all documents where the `ownerId` field value equals the specified value\n */\n OWNER_ID = 'OWNER_ID',\n\n /**\n * Matches all documents where the `deleted` field value equals the specified value\n */\n DELETED = 'DELETED',\n\n /**\n * Matches all documents\n */\n ALL = 'ALL',\n\n /**\n * Matches all documents where the field name value equals the specified value\n */\n EQ = 'EQ',\n\n /**\n * Matches all documents where the field name value does not equal the specified value\n */\n NE = 'NE',\n\n /**\n * Matches all documents where the given field's value is greater than the specified value\n */\n GT = 'GT',\n\n /**\n * Matches all documents where the given field's value is less than the specified value\n */\n LT = 'LT',\n\n /**\n * Matches all documents where the given field's value is greater than or equal to the specified value\n */\n GTE = 'GTE',\n\n /**\n * Matches all documents where the given field's value is less than or equal to the specified value\n */\n LTE = 'LTE',\n\n /**\n * Matches all documents where the given field's value contains the specified value\n */\n CONTAINS = 'CONTAINS',\n\n /**\n * Matches all documents where the field value equals any value in the specified list\n */\n IN = 'IN',\n\n /**\n * Matches all documents where the field value does not equal any specified value or does not exist\n */\n NOT_IN = 'NOT_IN',\n\n /**\n * Matches all documents where the field value is within the specified range\n */\n BETWEEN = 'BETWEEN',\n\n /**\n * Matches all documents where the field value is an array containing all specified values\n */\n ALL_IN = 'ALL_IN',\n\n /**\n * Matches documents where the field value starts with the specified string\n */\n STARTS_WITH = 'STARTS_WITH',\n\n /**\n * Matches documents where the field value ends with the specified string\n */\n ENDS_WITH = 'ENDS_WITH',\n\n /**\n * Matches all documents where the condition includes an array field,\n * and at least one member of the array matches the given condition.\n */\n ELEM_MATCH = 'ELEM_MATCH',\n\n /**\n * Matches all documents where the field value is `null`\n */\n NULL = 'NULL',\n\n /**\n * Matches all documents where the field value is not `null`\n */\n NOT_NULL = 'NOT_NULL',\n\n /**\n * Matches all documents where the field value is `true`\n */\n TRUE = 'TRUE',\n\n /**\n * Matches all documents where the field value is `false`\n */\n FALSE = 'FALSE',\n\n /**\n * Matches documents based on whether the field exists\n */\n EXISTS = 'EXISTS',\n\n // #region Date filtering conditions, field requirement: `long` type timestamp in milliseconds\n /**\n * Matches all documents where the field is within today's range\n * > For example: if `today` is `2024-06-06`, matches documents in the range\n * `2024-06-06 00:00:00.000` ~ `2024-06-06 23:59:59.999`\n */\n TODAY = 'TODAY',\n\n /**\n * Matches all documents where the field is before today\n */\n BEFORE_TODAY = 'BEFORE_TODAY',\n\n /**\n * Matches all documents where the field is within yesterday's range\n * > For example: if `today` is `2024-06-06`, matches documents in the range\n * `2024-06-05 00:00:00.000` ~ `2024-06-05 23:59:59.999`\n */\n TOMORROW = 'TOMORROW',\n\n /**\n * Matches all documents where the field is within this week's range\n */\n THIS_WEEK = 'THIS_WEEK',\n\n /**\n * Matches all documents where the field is within next week's range\n */\n NEXT_WEEK = 'NEXT_WEEK',\n\n /**\n * Matches all documents where the field is within last week's range\n */\n LAST_WEEK = 'LAST_WEEK',\n\n /**\n * Matches all documents where the field is within this month's range\n * > For example:\n * - `today`: `2024-06-06`\n * - Matching range: `2024-06-01 00:00:00.000` ~ `2024-06-30 23:59:59.999`\n */\n THIS_MONTH = 'THIS_MONTH',\n\n /**\n * Matches all documents where the field is within last month's range\n * > For example:\n * - `today`: `2024-06-06`\n * - Matching range: `2024-05-01 00:00:00.000` ~ `2024-05-31 23:59:59.999`\n */\n LAST_MONTH = 'LAST_MONTH',\n\n /**\n * Matches all documents where the field is within the specified number of recent days\n * > For example: last 3 days\n * - `today`: `2024-06-06`\n * - Matching range: `2024-06-04 00:00:00.000` ~ `2024-06-06 23:59:59.999`\n * - That is: today, yesterday, the day before yesterday\n */\n RECENT_DAYS = 'RECENT_DAYS',\n\n /**\n * Matches all documents where the field is before the specified number of days\n *\n * > For example: before 3 days\n * - `today`: `2024-06-06`\n * - Matching range: all documents less than `2024-06-04 00:00:00.000`\n */\n EARLIER_DAYS = 'EARLIER_DAYS',\n // #endregion\n\n /**\n * Raw operator, uses the condition value directly as the raw database query condition\n */\n RAW = 'RAW',\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Operator } from './operator';\n\n/**\n * Helper function to detect condition is validate or not\n *\n * @param condition - Condition\n * @returns If condition is validate return true, otherwise return false\n */\nexport function isValidateCondition(\n condition: Condition | undefined | null,\n): condition is Condition {\n return !!condition;\n}\n\n/**\n * Condition option keys enumeration\n *\n * Defines standard option keys used in query conditions for special handling.\n */\nexport class ConditionOptionKey {\n /**\n * Ignore case option key for string comparisons\n */\n static readonly IGNORE_CASE_OPTION_KEY = 'ignoreCase';\n\n /**\n * Time zone ID option key for date operations\n */\n static readonly ZONE_ID_OPTION_KEY = 'zoneId';\n\n /**\n * Date pattern option key for date formatting\n */\n static readonly DATE_PATTERN_OPTION_KEY = 'datePattern';\n}\n\n/**\n * Condition options interface\n *\n * Represents additional options that can be applied to query conditions,\n * such as case sensitivity, date patterns, and time zones.\n */\nexport interface ConditionOptions {\n /**\n * Whether to ignore case in string comparisons\n */\n ignoreCase?: boolean;\n\n /**\n * Date pattern for date formatting\n */\n datePattern?: string;\n\n /**\n * Time zone ID for date operations\n */\n zoneId?: string;\n\n /**\n * Additional custom options\n */\n [key: string]: any;\n}\n\n/**\n * Helper function to create condition options with ignoreCase flag.\n *\n * @param ignoreCase - Whether to ignore case\n * @returns Condition options or undefined if ignoreCase is undefined\n */\nexport function ignoreCaseOptions(\n ignoreCase?: boolean,\n): ConditionOptions | undefined {\n if (typeof ignoreCase === 'undefined') {\n return undefined;\n }\n return { ignoreCase };\n}\n\n/**\n * Helper function to create condition options with date pattern and zone ID.\n *\n * @param datePattern - Date pattern\n * @param zoneId - Time zone ID\n * @returns Condition options or undefined if both parameters are undefined\n */\nexport function dateOptions(\n datePattern?: string,\n zoneId?: string,\n): ConditionOptions | undefined {\n if (typeof datePattern === 'undefined' && typeof zoneId === 'undefined') {\n return undefined;\n }\n const options: ConditionOptions = {};\n if (typeof datePattern !== 'undefined') {\n options.datePattern = datePattern;\n }\n if (typeof zoneId !== 'undefined') {\n options.zoneId = zoneId;\n }\n return options;\n}\n\n/**\n * Interface for query conditions.\n *\n * When `operator` is `AND` or `OR` or `NOR`, `children` cannot be empty.\n */\nexport interface Condition<FIELDS extends string = string> {\n /**\n * Field name for the condition\n */\n field?: FIELDS;\n\n /**\n * Operator for the condition\n */\n operator?: Operator;\n\n /**\n * Value for the condition\n */\n value?: any;\n\n /**\n * Child conditions for logical operators (AND, OR, NOR)\n */\n children?: Condition<FIELDS>[];\n\n /**\n * Additional options for the condition\n */\n options?: ConditionOptions;\n}\n\n/**\n * Interface for objects that have a condition.\n */\nexport interface ConditionCapable<FIELDS extends string = string> {\n condition: Condition<FIELDS>;\n}\n\n/**\n * Deletion state enumeration\n *\n * Represents the different states of deletion for entities.\n */\nexport enum DeletionState {\n /**\n * Active state - entity is not deleted\n */\n ACTIVE = 'ACTIVE',\n\n /**\n * Deleted state - entity is deleted\n */\n DELETED = 'DELETED',\n\n /**\n * All state - includes both active and deleted entities\n */\n ALL = 'ALL',\n}\n\n/**\n * Creates an AND condition with the specified conditions.\n *\n * This function combines multiple conditions using the logical AND operator.\n * It provides optimizations such as returning the condition directly when\n * only one is provided, and flattening nested AND conditions.\n *\n * @param conditions - Conditions to combine with AND. If empty, returns an ALL condition.\n * If exactly one, returns that condition directly.\n * If multiple, combines them into an AND condition with flattening optimization.\n * @returns A condition with AND operator or an optimized condition based on the input\n */\nexport function and<FIELDS extends string = string>(\n ...conditions: Array<Condition<FIELDS> | undefined | null>\n): Condition<FIELDS> {\n if (conditions.length === 0) {\n return all();\n }\n if (conditions.length === 1) {\n return isValidateCondition(conditions[0]) ? conditions[0] : all();\n }\n const andChildren: Condition<FIELDS>[] = [];\n conditions.forEach(condition => {\n if (\n condition?.operator === Operator.ALL ||\n !isValidateCondition(condition)\n ) {\n return;\n }\n if (condition.operator === Operator.AND && condition.children) {\n andChildren.push(...condition.children);\n } else {\n andChildren.push(condition);\n }\n });\n return { operator: Operator.AND, children: andChildren };\n}\n\n/**\n * Creates an OR condition with the specified conditions.\n *\n * @param conditions - Conditions to combine with OR\n * @returns A condition with OR operator\n */\nexport function or<FIELDS extends string = string>(\n ...conditions: Array<Condition<FIELDS> | undefined | null>\n): Condition<FIELDS> {\n const validateConditions = conditions?.filter(condition =>\n isValidateCondition(condition),\n );\n if (validateConditions.length === 0) {\n return all();\n }\n return { operator: Operator.OR, children: validateConditions };\n}\n\n/**\n * Creates a NOR condition with the specified conditions.\n *\n * @param conditions - Conditions to combine with NOR\n * @returns A condition with NOR operator\n */\nexport function nor<FIELDS extends string = string>(\n ...conditions: Condition<FIELDS>[]\n): Condition<FIELDS> {\n if (conditions.length === 0) {\n return all();\n }\n return { operator: Operator.NOR, children: conditions };\n}\n\n/**\n * Creates an ID condition with the specified value.\n *\n * @param value - The ID value to match\n * @returns A condition with ID operator\n */\nexport function id<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.ID, value: value };\n}\n\n/**\n * Creates an IDS condition with the specified values.\n *\n * @param value - The ID values to match\n * @returns A condition with IDS operator\n */\nexport function ids<FIELDS extends string = string>(\n value: string[],\n): Condition<FIELDS> {\n return { operator: Operator.IDS, value: value };\n}\n\n/**\n * Creates an AGGREGATE_ID condition with the specified value.\n *\n * @param value - The aggregate ID value to match\n * @returns A condition with AGGREGATE_ID operator\n */\nexport function aggregateId<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.AGGREGATE_ID, value: value };\n}\n\n/**\n * Creates an AGGREGATE_IDS condition with the specified values.\n *\n * @param value - The aggregate ID values to match\n * @returns A condition with AGGREGATE_IDS operator\n */\nexport function aggregateIds<FIELDS extends string = string>(\n value: string[],\n): Condition<FIELDS> {\n return { operator: Operator.AGGREGATE_IDS, value: value };\n}\n\n/**\n * Creates a TENANT_ID condition with the specified value.\n *\n * @param value - The tenant ID value to match\n * @returns A condition with TENANT_ID operator\n */\nexport function tenantId<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.TENANT_ID, value: value };\n}\n\n/**\n * Creates an OWNER_ID condition with the specified value.\n *\n * @param value - The owner ID value to match\n * @returns A condition with OWNER_ID operator\n */\nexport function ownerId<FIELDS extends string = string>(\n value: string,\n): Condition<FIELDS> {\n return { operator: Operator.OWNER_ID, value: value };\n}\n\n/**\n * Creates a DELETED condition with the specified value.\n *\n * @param value - The deletion state value to match\n * @returns A condition with DELETED operator\n */\nexport function deleted<FIELDS extends string = string>(\n value: DeletionState,\n): Condition<FIELDS> {\n return { operator: Operator.DELETED, value: value };\n}\n\n/**\n * Creates an ACTIVE deletion state condition.\n *\n * @returns A condition with DELETED operator set to ACTIVE\n */\nexport function active<FIELDS extends string = string>(): Condition<FIELDS> {\n return deleted(DeletionState.ACTIVE);\n}\n\n/**\n * Creates an ALL condition.\n *\n * @returns A condition with ALL operator\n */\nexport function all<FIELDS extends string = string>(): Condition<FIELDS> {\n return {\n operator: Operator.ALL,\n };\n}\n\n/**\n * Creates an EQ (equals) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with EQ operator\n */\nexport function eq<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.EQ, value };\n}\n\n/**\n * Creates a NE (not equals) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with NE operator\n */\nexport function ne<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.NE, value };\n}\n\n/**\n * Creates a GT (greater than) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with GT operator\n */\nexport function gt<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.GT, value };\n}\n\n/**\n * Creates a LT (less than) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with LT operator\n */\nexport function lt<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.LT, value };\n}\n\n/**\n * Creates a GTE (greater than or equal) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with GTE operator\n */\nexport function gte<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.GTE, value };\n}\n\n/**\n * Creates a LTE (less than or equal) condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @returns A condition with LTE operator\n */\nexport function lte<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.LTE, value };\n}\n\n/**\n * Creates a CONTAINS condition with the specified field and value.\n *\n * @param field - The field name to search in\n * @param value - The value to search for\n * @param ignoreCase - Whether to ignore case in the search\n * @returns A condition with CONTAINS operator\n */\nexport function contains<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n ignoreCase?: boolean,\n): Condition<FIELDS> {\n const options: Record<string, any> | undefined =\n ignoreCaseOptions(ignoreCase);\n return { field, operator: Operator.CONTAINS, value, options };\n}\n\n/**\n * Creates an IN condition with the specified field and values.\n *\n * @param field - The field name to compare\n * @param value - The values to compare against\n * @returns A condition with IN operator\n */\nexport function isIn<FIELDS extends string = string>(\n field: FIELDS,\n ...value: any[]\n): Condition<FIELDS> {\n return { field, operator: Operator.IN, value };\n}\n\n/**\n * Creates a NOT_IN condition with the specified field and values.\n *\n * @param field - The field name to compare\n * @param value - The values to compare against\n * @returns A condition with NOT_IN operator\n */\nexport function notIn<FIELDS extends string = string>(\n field: FIELDS,\n ...value: any[]\n): Condition<FIELDS> {\n return { field, operator: Operator.NOT_IN, value };\n}\n\n/**\n * Creates a BETWEEN condition with the specified field and range.\n *\n * @param field - The field name to compare\n * @param start - The start value of the range\n * @param end - The end value of the range\n * @returns A condition with BETWEEN operator\n */\nexport function between<FIELDS extends string = string>(\n field: FIELDS,\n start: any,\n end: any,\n): Condition<FIELDS> {\n return { field, operator: Operator.BETWEEN, value: [start, end] };\n}\n\n/**\n * Creates an ALL_IN condition with the specified field and values.\n *\n * @param field - The field name to compare\n * @param value - The values to compare against\n * @returns A condition with ALL_IN operator\n */\nexport function allIn<FIELDS extends string = string>(\n field: FIELDS,\n ...value: any[]\n): Condition<FIELDS> {\n return { field, operator: Operator.ALL_IN, value };\n}\n\n/**\n * Creates a STARTS_WITH condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @param ignoreCase - Whether to ignore case in the comparison\n * @returns A condition with STARTS_WITH operator\n */\nexport function startsWith<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n ignoreCase?: boolean,\n): Condition<FIELDS> {\n const options: Record<string, any> | undefined =\n ignoreCaseOptions(ignoreCase);\n return { field, operator: Operator.STARTS_WITH, value, options };\n}\n\n/**\n * Creates an ENDS_WITH condition with the specified field and value.\n *\n * @param field - The field name to compare\n * @param value - The value to compare against\n * @param ignoreCase - Whether to ignore case in the comparison\n * @returns A condition with ENDS_WITH operator\n */\nexport function endsWith<FIELDS extends string = string>(\n field: FIELDS,\n value: any,\n ignoreCase?: boolean,\n): Condition<FIELDS> {\n const options: Record<string, any> | undefined =\n ignoreCaseOptions(ignoreCase);\n return { field, operator: Operator.ENDS_WITH, value, options };\n}\n\n/**\n * Creates an ELEM_MATCH condition with the specified field and child condition.\n *\n * @param field - The field name to match elements in\n * @param value - The condition to match elements against\n * @returns A condition with ELEM_MATCH operator\n */\nexport function elemMatch<FIELDS extends string = string>(\n field: FIELDS,\n value: Condition<FIELDS>,\n): Condition<FIELDS> {\n return { field, operator: Operator.ELEM_MATCH, children: [value] };\n}\n\n/**\n * Creates a NULL condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with NULL operator\n */\nexport function isNull<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.NULL };\n}\n\n/**\n * Creates a NOT_NULL condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with NOT_NULL operator\n */\nexport function notNull<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.NOT_NULL };\n}\n\n/**\n * Creates a TRUE condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with TRUE operator\n */\nexport function isTrue<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.TRUE };\n}\n\n/**\n * Creates a FALSE condition with the specified field.\n *\n * @param field - The field name to check\n * @returns A condition with FALSE operator\n */\nexport function isFalse<FIELDS extends string = string>(\n field: FIELDS,\n): Condition<FIELDS> {\n return { field, operator: Operator.FALSE };\n}\n\n/**\n * Creates an EXISTS condition with the specified field and existence flag.\n *\n * @param field - The field name to check\n * @param exists - Whether the field should exist (default: true)\n * @returns A condition with EXISTS operator\n */\nexport function exists<FIELDS extends string = string>(\n field: FIELDS,\n exists: boolean = true,\n): Condition<FIELDS> {\n return { field, operator: Operator.EXISTS, value: exists };\n}\n\n/**\n * Creates a TODAY condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with TODAY operator\n */\nexport function today<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.TODAY, options };\n}\n\n/**\n * Creates a BEFORE_TODAY condition with the specified field and time.\n *\n * @param field - The field name to check\n * @param time - The time to compare against\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with BEFORE_TODAY operator\n */\nexport function beforeToday<FIELDS extends string = string>(\n field: FIELDS,\n time: any,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.BEFORE_TODAY, value: time, options };\n}\n\n/**\n * Creates a TOMORROW condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with TOMORROW operator\n */\nexport function tomorrow<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.TOMORROW, options };\n}\n\n/**\n * Creates a THIS_WEEK condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with THIS_WEEK operator\n */\nexport function thisWeek<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.THIS_WEEK, options };\n}\n\n/**\n * Creates a NEXT_WEEK condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with NEXT_WEEK operator\n */\nexport function nextWeek<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.NEXT_WEEK, options };\n}\n\n/**\n * Creates a LAST_WEEK condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with LAST_WEEK operator\n */\nexport function lastWeek<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.LAST_WEEK, options };\n}\n\n/**\n * Creates a THIS_MONTH condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with THIS_MONTH operator\n */\nexport function thisMonth<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.THIS_MONTH, options };\n}\n\n/**\n * Creates a LAST_MONTH condition with the specified field.\n *\n * @param field - The field name to check\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with LAST_MONTH operator\n */\nexport function lastMonth<FIELDS extends string = string>(\n field: FIELDS,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.LAST_MONTH, options };\n}\n\n/**\n * Creates a RECENT_DAYS condition with the specified field and number of days.\n *\n * @param field - The field name to check\n * @param days - The number of recent days to include\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with RECENT_DAYS operator\n */\nexport function recentDays<FIELDS extends string = string>(\n field: FIELDS,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.RECENT_DAYS, value: days, options };\n}\n\n/**\n * Creates an EARLIER_DAYS condition with the specified field and number of days.\n *\n * @param field - The field name to check\n * @param days - The number of days to look back\n * @param datePattern - The date pattern to use\n * @param zoneId - The time zone ID to use\n * @returns A condition with EARLIER_DAYS operator\n */\nexport function earlierDays<FIELDS extends string = string>(\n field: FIELDS,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition<FIELDS> {\n const options = dateOptions(datePattern, zoneId);\n return { field, operator: Operator.EARLIER_DAYS, value: days, options };\n}\n\n/**\n * Creates a RAW condition with the specified raw value.\n *\n * @param raw - The raw condition value\n * @returns A condition with RAW operator\n */\nexport function raw<FIELDS extends string = string>(\n raw: any,\n): Condition<FIELDS> {\n return { operator: Operator.RAW, value: raw };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for pagination information.\n *\n * Page number, starting from 1\n * Page size\n */\nexport interface Pagination {\n index: number;\n size: number;\n}\n\n/**\n * Default pagination configuration.\n * Page index starts at 1, page size is 10.\n */\nexport const DEFAULT_PAGINATION: Pagination = {\n index: 1,\n size: 10,\n};\n\n/**\n * Creates a Pagination object with the provided parameters.\n *\n * This function is a factory for creating Pagination objects, which represent\n * pagination information including page index and page size. It provides default\n * values for optional properties while allowing customization of index and size.\n *\n * @param options - The pagination options. Optional.\n * @param options.index - The page index, starting from 1. Defaults to DEFAULT_PAGINATION.index.\n * @param options.size - The page size. Defaults to DEFAULT_PAGINATION.size.\n * @returns A Pagination object with the specified parameters\n */\nexport function pagination({\n index = DEFAULT_PAGINATION.index,\n size = DEFAULT_PAGINATION.size,\n }: Partial<Pagination> = DEFAULT_PAGINATION): Pagination {\n return {\n index,\n size,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for field projection.\n */\nexport interface Projection<FIELDS extends string = string> {\n include?: FIELDS[];\n exclude?: FIELDS[];\n}\n\n/**\n * Default projection configuration.\n * Empty projection object includes all fields.\n */\nexport const DEFAULT_PROJECTION: Projection = {};\n\nexport function defaultProjection<\n FIELDS extends string = string,\n>(): Projection<FIELDS> {\n return DEFAULT_PROJECTION as Projection<FIELDS>;\n}\n\n/**\n * Creates a Projection object with the provided parameters.\n *\n * This function is a factory for creating Projection objects, which represent\n * field projection specifications for queries. It allows specifying which fields\n * to include or exclude in query results.\n *\n * @param options - The projection options. Defaults to DEFAULT_PROJECTION.\n * @param options.include - Array of field names to include in the projection. Optional.\n * @param options.exclude - Array of field names to exclude from the projection. Optional.\n * @returns A Projection object with the specified parameters\n */\nexport function projection<FIELDS extends string = string>(\n { include, exclude }: Projection<FIELDS> = defaultProjection(),\n): Projection<FIELDS> {\n return {\n include,\n exclude,\n };\n}\n\n/**\n * Interface for objects that support field projection.\n */\nexport interface ProjectionCapable<FIELDS extends string = string> {\n projection?: Projection<FIELDS>;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { all, type ConditionCapable } from './condition';\nimport { type SortCapable } from './sort';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination';\nimport { type ProjectionCapable } from './projection';\n\n/**\n * Interface for queryable objects that support conditions, projection, and sorting.\n */\nexport interface Queryable<FIELDS extends string = string>\n extends ConditionCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {\n}\n\n/**\n * Interface for single query objects.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface SingleQuery<FIELDS extends string = string>\n extends Queryable<FIELDS> {\n}\n\n/**\n * Creates a SingleQuery object with the provided parameters.\n *\n * This function is a factory for creating SingleQuery objects, which represent\n * queries that return a single result. It provides default values for optional\n * properties while allowing customization of condition, projection, and sort criteria.\n *\n * @param condition - The query condition. Defaults to an 'all' condition that matches everything.\n * @param projection - The field projection specification. Optional.\n * @param sort - The sort criteria. Optional.\n * @returns A SingleQuery object with the specified parameters\n */\nexport function singleQuery<FIELDS extends string = string>({\n condition = all(),\n projection,\n sort,\n }: Partial<SingleQuery<FIELDS>> = {}): SingleQuery<FIELDS> {\n return {\n condition,\n projection,\n sort,\n };\n}\n\n/**\n * Interface for list query objects.\n *\n * Limit the number of results. Default: DEFAULT_PAGINATION.size\n */\nexport interface ListQuery<FIELDS extends string = string>\n extends Queryable<FIELDS> {\n limit?: number;\n}\n\n/**\n * Creates a ListQuery object with the provided parameters.\n *\n * This function is a factory for creating ListQuery objects, which represent\n * queries that return a list of results. It provides default values for optional\n * properties while allowing customization of condition, projection, sort criteria,\n * and result limit.\n *\n * @param condition - The query condition. Defaults to an 'all' condition that matches everything.\n * @param projection - The field projection specification. Optional.\n * @param sort - The sort criteria. Optional.\n * @param limit - The maximum number of results to return. Defaults to DEFAULT_PAGINATION.size.\n * @returns A ListQuery object with the specified parameters\n */\nexport function listQuery<FIELDS extends string = string>({\n condition = all(),\n projection,\n sort,\n limit = DEFAULT_PAGINATION.size,\n }: Partial<ListQuery<FIELDS>> = {}): ListQuery<FIELDS> {\n return {\n condition,\n projection,\n sort,\n limit,\n };\n}\n\n/**\n * Interface for paged query objects.\n */\nexport interface PagedQuery<FIELDS extends string = string>\n extends Queryable<FIELDS> {\n pagination?: Pagination;\n}\n\n/**\n * Creates a PagedQuery object with the provided parameters.\n *\n * This function is a factory for creating PagedQuery objects, which represent\n * queries that return a paged list of results. It provides default values for optional\n * properties while allowing customization of condition, projection, sort criteria,\n * and pagination.\n *\n * @param condition - The query condition. Defaults to an 'all' condition that matches everything.\n * @param projection - The field projection specification. Optional.\n * @param sort - The sort criteria. Optional.\n * @param pagination - The pagination specification. Optional.\n *\n * @returns A PagedQuery object with the specified parameters\n */\nexport function pagedQuery<FIELDS extends string = string>({\n condition = all(),\n projection,\n sort,\n pagination = DEFAULT_PAGINATION,\n }: Partial<PagedQuery<FIELDS>> = {}): PagedQuery<FIELDS> {\n return {\n condition,\n projection,\n sort,\n pagination,\n };\n}\n\n/**\n * Interface for paged list results.\n */\nexport interface PagedList<T> {\n total: number;\n list: T[];\n}\n\nexport const EMPTY_PAGED_LIST: PagedList<any> = {\n total: 0,\n list: [],\n};\n\n/**\n * Creates a PagedList object with the provided parameters.\n *\n * This function is a factory for creating PagedList objects, which represent\n * a page of results with total count information. It provides default values\n * for optional properties while allowing customization of total count and list data.\n *\n * @param total - The total number of items. Defaults to 0.\n * @param list - The array of items in the current page. Defaults to an empty array.\n * @returns A PagedList object with the specified parameters\n */\nexport function pagedList<T>({\n total,\n list = [],\n }: Partial<PagedList<T>> = EMPTY_PAGED_LIST): PagedList<T> {\n if (total === undefined) {\n total = list.length;\n }\n return {\n total,\n list,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Enumeration of sort directions.\n * ASC for ascending order, DESC for descending order.\n */\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\n/**\n * Interface for sort criteria.\n */\nexport interface FieldSort<FIELDS extends string = string> {\n field: FIELDS;\n direction: SortDirection;\n}\n\n/**\n * Creates a sort object with ascending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and ascending direction\n */\nexport function asc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field,\n direction: SortDirection.ASC,\n };\n}\n\n/**\n * Creates a sort object with descending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and descending direction\n */\nexport function desc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field,\n direction: SortDirection.DESC,\n };\n}\n\n/**\n * Interface for objects that support sorting.\n */\nexport interface SortCapable<FIELDS extends string = string> {\n sort?: FieldSort<FIELDS>[];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateId,\n CreateTimeCapable,\n DeletedCapable,\n FirstEventTimeCapable,\n FirstOperatorCapable,\n Identifier,\n Named,\n OwnerId,\n StateCapable,\n Version,\n} from '../../types';\nimport type { CommandId, CommandStage, RequestId } from '../../command';\nimport type { BodyCapable } from '../../types';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\n\n/**\n * Represents a domain event with a specific body type.\n * Extends Identifier, Named, and BodyCapable interfaces to provide identification,\n * naming, and body capabilities for the domain event.\n * @template BODY - The type of the event content for this domain event\n */\nexport interface DomainEvent<BODY>\n extends Identifier,\n Named,\n BodyCapable<BODY> {\n /**\n * The type of the event content.\n */\n bodyType: string;\n /**\n * The revision of the domain event.\n */\n revision: string;\n}\n\n/**\n * Represents the header information for a domain event stream.\n * Contains metadata about the event stream such as command information,\n * network details, and tracing information.\n */\nexport interface DomainEventStreamHeader {\n /**\n * The operator that executed the command.\n */\n command_operator?: string;\n /**\n * The endpoint to wait for command completion.\n */\n command_wait_endpoint?: string;\n /**\n * The stage to wait for in command execution.\n */\n command_wait_stage?: CommandStage;\n\n local_first?: string;\n /**\n * The IP address of the remote client.\n */\n remote_ip: string;\n /**\n * The user agent of the client.\n */\n user_agent?: string;\n /**\n * The trace identifier for distributed tracing.\n */\n trace_id?: string;\n\n /**\n * Index signature for additional custom header properties.\n * Allows for any additional string key-value pairs to be included as header properties.\n */\n [key: string]: string | undefined;\n}\n\n/**\n * Represents a stream of domain events.\n * Combines multiple interfaces to provide a complete domain event stream,\n * including identification, aggregation, ownership, command information,\n * versioning, and the actual event data.\n */\nexport interface DomainEventStream<DomainEventBody = any>\n extends Identifier,\n AggregateId,\n OwnerId,\n CommandId,\n CreateTimeCapable,\n RequestId,\n Version,\n BodyCapable<DomainEvent<DomainEventBody>[]> {\n /**\n * The header information for the domain event stream.\n */\n header: DomainEventStreamHeader;\n}\n\nexport interface StateEvent<DomainEventBody = any, S = any>\n extends DomainEventStream<DomainEventBody>,\n StateCapable<S>,\n FirstOperatorCapable,\n FirstEventTimeCapable,\n DeletedCapable {\n}\n\n/**\n * Provides field names for domain event stream metadata.\n *\n * This class contains static readonly properties that define the field names used in domain event stream metadata.\n * These field names are used to access and manipulate domain event stream data in a consistent manner.\n * The fields include headers, identifiers, command information, versioning, body content, and creation time.\n */\nexport class DomainEventStreamMetadataFields {\n static readonly HEADER = 'header';\n static readonly COMMAND_OPERATOR = `${DomainEventStreamMetadataFields.HEADER}.command_operator`;\n static readonly AGGREGATE_ID = 'aggregateId';\n static readonly TENANT_ID = 'tenantId';\n static readonly OWNER_ID = 'ownerId';\n static readonly COMMAND_ID = 'commandId';\n static readonly REQUEST_ID = 'requestId';\n static readonly VERSION = 'version';\n static readonly BODY = 'body';\n static readonly BODY_ID = `${DomainEventStreamMetadataFields.BODY}.id`;\n static readonly BODY_NAME = `${DomainEventStreamMetadataFields.BODY}.name`;\n static readonly BODY_TYPE = `${DomainEventStreamMetadataFields.BODY}.bodyType`;\n static readonly BODY_REVISION = `${DomainEventStreamMetadataFields.BODY}.revision`;\n static readonly BODY_BODY = `${DomainEventStreamMetadataFields.BODY}.body`;\n static readonly CREATE_TIME = 'createTime';\n}\n\n/**\n * Represents a readable stream of domain event streams.\n *\n * This type defines a ReadableStream that emits JsonServerSentEvent objects containing DomainEventStream data.\n * It is used for streaming domain events in a server-sent event format.\n */\nexport type ReadableDomainEventStream = ReadableStream<\n JsonServerSentEvent<DomainEventStream>\n>;\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DomainEventStream } from './domainEventStream';\nimport type { QueryApi } from '../queryApi';\n\n/**\n * Interface for event stream query API operations.\n * Extends the base QueryApi interface but omits the 'single' method,\n * as event stream queries typically work with collections of events rather than single events.\n * @template DomainEventStream - The type of domain event stream this API works with\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface EventStreamQueryApi<\n DomainEventBody = any,\n FIELDS extends string = string,\n> extends Omit<\n QueryApi<DomainEventStream<DomainEventBody>, FIELDS>,\n 'single'\n> {\n}\n\n/**\n * Provides endpoint paths for event stream query operations.\n *\n * This class contains static readonly properties that define the endpoint paths used for various event stream query operations.\n * These paths are used when making API calls to retrieve event stream data in different formats such as counts, lists, and paged results.\n * The paths are constructed based on a base resource name and extended with specific operation identifiers.\n */\nexport class EventStreamQueryEndpointPaths {\n static readonly EVENT_STREAM_RESOURCE_NAME = 'event';\n static readonly COUNT = `${EventStreamQueryEndpointPaths.EVENT_STREAM_RESOURCE_NAME}/count`;\n static readonly LIST = `${EventStreamQueryEndpointPaths.EVENT_STREAM_RESOURCE_NAME}/list`;\n static readonly PAGED = `${EventStreamQueryEndpointPaths.EVENT_STREAM_RESOURCE_NAME}/paged`;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type EventStreamQueryApi,\n EventStreamQueryEndpointPaths,\n} from './eventStreamQueryApi';\nimport type { Condition } from '../condition';\nimport type { ListQuery, PagedList, PagedQuery } from '../queryable';\nimport type { DomainEventStream } from './domainEventStream';\nimport {\n JsonEventStreamResultExtractor,\n JsonServerSentEvent,\n} from '@ahoo-wang/fetcher-eventstream';\n\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n body,\n post,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * Client for querying event streams through HTTP endpoints.\n * Extends QueryClient and implements EventStreamQueryApi to provide methods\n * for querying domain event streams with different query patterns.\n * This client supports counting, listing, streaming, and paging operations on event streams.\n *\n * @example\n * ```typescript\n * // Create client options configuration\n * const clientOptions: ClientOptions = {\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart'\n * };\n *\n * // Create an event stream query client instance\n * const eventStreamQueryClient = new EventStreamQueryClient(clientOptions);\n *\n * // Count event streams\n * const count = await eventStreamQueryClient.count(all());\n *\n * // List event streams\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await eventStreamQueryClient.list(listQuery);\n *\n * // List event streams as stream\n * const listStream = await eventStreamQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const domainEventStream = event.data;\n * console.log('Received:', domainEventStream);\n * }\n *\n * // Paged event streams\n * const pagedQuery: PagedQuery = {\n * condition: all()\n * };\n * const paged = await eventStreamQueryClient.paged(pagedQuery);\n * ```\n */\n@api()\nexport class EventStreamQueryClient<\n DomainEventBody = any,\n FIELDS extends string = string,\n>\n implements EventStreamQueryApi<DomainEventBody, FIELDS>, ApiMetadataCapable {\n /**\n * Creates a new EventStreamQueryClient instance.\n */\n constructor(public readonly apiMetadata?: ApiMetadata) {\n }\n\n /**\n * Counts the number of domain event streams that match the given condition.\n *\n * @param condition - The condition to filter event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the count of matching event streams\n *\n * @example\n * ```typescript\n * const count = await eventStreamQueryClient.count(all());\n * console.log('Total event streams:', count);\n * ```\n */\n @post(EventStreamQueryEndpointPaths.COUNT)\n count(\n @body() condition: Condition<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<number> {\n throw autoGeneratedError(condition, attributes);\n }\n\n /**\n * Retrieves a list of domain event streams based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial domain event streams\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await eventStreamQueryClient.list(listQuery);\n * for (const domainEventStream of list) {\n * console.log('Event stream:', domainEventStream);\n * }\n * ```\n */\n @post(EventStreamQueryEndpointPaths.LIST)\n list<\n T extends Partial<\n DomainEventStream<DomainEventBody>\n > = DomainEventStream<DomainEventBody>,\n >(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T[]> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a stream of domain event streams based on the provided query parameters.\n * Sets the Accept header to text/event-stream to indicate that the response should be streamed.\n *\n * @param listQuery - The query parameters for listing event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial domain event streams\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const listStream = await eventStreamQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const domainEventStream = event.data;\n * console.log('Received event stream:', domainEventStream);\n * }\n * ```\n */\n @post(EventStreamQueryEndpointPaths.LIST, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n listStream<\n T extends Partial<\n DomainEventStream<DomainEventBody>\n > = DomainEventStream<DomainEventBody>,\n >(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a paged list of domain event streams based on the provided query parameters.\n *\n * @param pagedQuery - The query parameters for paging event streams\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial domain event streams\n *\n * @example\n * ```typescript\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const paged = await eventStreamQueryClient.paged(pagedQuery);\n * console.log('Total:', paged.total);\n * for (const domainEventStream of paged.list) {\n * console.log('Event stream:', domainEventStream);\n * }\n * ```\n */\n @post(EventStreamQueryEndpointPaths.PAGED)\n paged<\n T extends Partial<\n DomainEventStream<DomainEventBody>\n > = DomainEventStream<DomainEventBody>,\n >(\n @body() pagedQuery: PagedQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<PagedList<T>> {\n throw autoGeneratedError(pagedQuery, attributes);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateId,\n DeletedCapable,\n EventIdCapable,\n EventTimeCapable,\n FirstEventTimeCapable,\n FirstOperatorCapable,\n NamedAggregate,\n OperatorCapable,\n OwnerId,\n SnapshotTimeCapable,\n StateCapable,\n TenantId,\n Version,\n} from '../../types';\n\n/**\n * Interface for materialized snapshots with full capabilities.\n */\nexport interface MaterializedSnapshot<S>\n extends StateCapable<S>,\n AggregateId,\n TenantId,\n OwnerId,\n Version,\n EventIdCapable,\n FirstOperatorCapable,\n OperatorCapable,\n FirstEventTimeCapable,\n EventTimeCapable,\n SnapshotTimeCapable,\n DeletedCapable {\n}\n\n/**\n * Interface for materialized snapshots with medium capabilities.\n *\n * Represents a materialized snapshot for medium data, implementing multiple capabilities through inheritance.\n * This interface is designed to be generic, capable of holding state data of any type.\n * Each snapshot corresponds to a specific version of the state within a tenant and owner context,\n * and records information such as event IDs and operation times to support tracing and auditing.\n */\nexport interface MediumMaterializedSnapshot<S>\n extends StateCapable<S>,\n NamedAggregate,\n TenantId,\n OwnerId,\n Version,\n EventIdCapable,\n FirstOperatorCapable,\n OperatorCapable,\n FirstEventTimeCapable,\n EventTimeCapable {\n}\n\n/**\n * Interface for simplified materialized snapshots with generic state.\n *\n * This interface implements multiple interfaces to provide version, materialization, first event time, and state information.\n */\nexport interface SmallMaterializedSnapshot<S>\n extends StateCapable<S>,\n NamedAggregate,\n Version,\n FirstEventTimeCapable {\n}\n\n/**\n * Provides field names for snapshot metadata.\n *\n * This class contains static readonly properties that define the field names used in snapshot metadata.\n * These field names are used to access and manipulate snapshot data in a consistent manner.\n */\nexport class SnapshotMetadataFields {\n static readonly VERSION = 'version';\n static readonly TENANT_ID = 'tenantId';\n static readonly OWNER_ID = 'ownerId';\n static readonly EVENT_ID = 'eventId';\n static readonly FIRST_EVENT_TIME = 'firstEventTime';\n static readonly EVENT_TIME = 'eventTime';\n static readonly FIRST_OPERATOR = 'firstOperator';\n static readonly OPERATOR = 'operator';\n static readonly SNAPSHOT_TIME = 'snapshotTime';\n static readonly DELETED = 'deleted';\n static readonly STATE = 'state';\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QueryApi } from '../queryApi';\nimport type { MaterializedSnapshot } from './snapshot';\nimport type {\n ListQuery,\n PagedList,\n PagedQuery,\n SingleQuery,\n} from '../queryable';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\n\n/**\n * Interface for snapshot query API operations.\n * Extends the base QueryApi interface for MaterializedSnapshot and adds methods\n * for querying snapshot states directly without the full MaterializedSnapshot wrapper.\n * @template S - The type of the snapshot state\n */\nexport interface SnapshotQueryApi<S, FIELDS extends string = string>\n extends QueryApi<MaterializedSnapshot<S>, FIELDS> {\n /**\n * Retrieves a single snapshot state based on the provided query parameters.\n * @param singleQuery - The query parameters for retrieving a single snapshot state\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a partial snapshot state\n */\n singleState<T extends Partial<S> = S>(\n singleQuery: SingleQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<T>;\n\n /**\n * Retrieves a list of snapshot states based on the provided query parameters.\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial snapshot states\n */\n listState<T extends Partial<S> = S>(\n listQuery: ListQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<T[]>;\n\n /**\n * Retrieves a stream of snapshot states based on the provided query parameters.\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial snapshot states\n */\n listStateStream<T extends Partial<S> = S>(\n listQuery: ListQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>>;\n\n /**\n * Retrieves a paged list of snapshot states based on the provided query parameters.\n * @param pagedQuery - The query parameters for paging snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial snapshot states\n */\n pagedState<T extends Partial<S> = S>(\n pagedQuery: PagedQuery<FIELDS>,\n attributes?: Record<string, any>,\n ): Promise<PagedList<T>>;\n}\n\n/**\n * Provides endpoint paths for snapshot query operations.\n *\n * This class contains static readonly properties that define the endpoint paths used for various snapshot query operations.\n * These paths are used when making API calls to retrieve snapshot data in different formats such as counts, lists, paged results, and single items.\n * The paths are constructed based on a base resource name and extended with specific operation identifiers.\n */\nexport class SnapshotQueryEndpointPaths {\n static readonly SNAPSHOT_RESOURCE_NAME = 'snapshot';\n static readonly COUNT = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/count`;\n static readonly LIST = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/list`;\n static readonly LIST_STATE = `${SnapshotQueryEndpointPaths.LIST}/state`;\n static readonly PAGED = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/paged`;\n static readonly PAGED_STATE = `${SnapshotQueryEndpointPaths.PAGED}/state`;\n static readonly SINGLE = `${SnapshotQueryEndpointPaths.SNAPSHOT_RESOURCE_NAME}/single`;\n static readonly SINGLE_STATE = `${SnapshotQueryEndpointPaths.SINGLE}/state`;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type SnapshotQueryApi, SnapshotQueryEndpointPaths, } from './snapshotQueryApi';\nimport { aggregateId, aggregateIds, Condition } from '../condition';\nimport { listQuery, ListQuery, PagedList, PagedQuery, singleQuery, SingleQuery, } from '../queryable';\nimport type { MaterializedSnapshot } from './snapshot';\nimport { JsonEventStreamResultExtractor, JsonServerSentEvent, } from '@ahoo-wang/fetcher-eventstream';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport '@ahoo-wang/fetcher-eventstream';\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n body,\n post,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * A client for querying snapshot data through HTTP endpoints.\n * Provides methods for various query operations such as counting, listing, paging, and retrieving single snapshots.\n *\n * @example\n * ```typescript\n * // Define the state interface\n * interface CartItem {\n * productId: string;\n * quantity: number;\n * }\n *\n * interface CartState {\n * items: CartItem[];\n * }\n *\n * // Create client options configuration\n * const clientOptions: ClientOptions = {\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart'\n * };\n *\n * // Create a snapshot query client instance\n * const snapshotQueryClient = new SnapshotQueryClient<CartState>(clientOptions);\n *\n * // Count snapshots\n * const count = await snapshotQueryClient.count(all());\n *\n * // List snapshots\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await snapshotQueryClient.list(listQuery);\n *\n * // List snapshots as stream\n * const listStream = await snapshotQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const snapshot = event.data;\n * console.log('Received:', snapshot);\n * }\n *\n * // List snapshot states\n * const stateList = await snapshotQueryClient.listState(listQuery);\n *\n * // List snapshot states as stream\n * const stateListStream = await snapshotQueryClient.listStateStream(listQuery);\n * for await (const event of stateListStream) {\n * const state = event.data;\n * console.log('Received state:', state);\n * }\n *\n * // Paged snapshots\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const paged = await snapshotQueryClient.paged(pagedQuery);\n *\n * // Paged snapshot states\n * const pagedState = await snapshotQueryClient.pagedState(pagedQuery);\n *\n * // Single snapshot\n * const singleQuery: SingleQuery = {\n * condition: all()\n * };\n * const single = await snapshotQueryClient.single(singleQuery);\n *\n * // Single snapshot state\n * const singleState = await snapshotQueryClient.singleState(singleQuery);\n * ```\n *\n * @template S The type of the snapshot state\n */\n@api()\nexport class SnapshotQueryClient<S, FIELDS extends string = string>\n implements SnapshotQueryApi<S, FIELDS>, ApiMetadataCapable\n{\n /**\n * Creates a new SnapshotQueryClient instance.\n */\n constructor(public readonly apiMetadata?: ApiMetadata) {}\n\n /**\n * Counts the number of snapshots that match the given condition.\n *\n * @param condition - The condition to match snapshots against\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the count of matching snapshots\n *\n * @example\n * ```typescript\n * const count = await snapshotQueryClient.count(all());\n * console.log('Total snapshots:', count);\n * ```\n */\n @post(SnapshotQueryEndpointPaths.COUNT)\n count(\n @body() condition: Condition<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<number> {\n throw autoGeneratedError(condition, attributes);\n }\n\n /**\n * Retrieves a list of materialized snapshots based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshots\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial materialized snapshots\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await snapshotQueryClient.list(listQuery);\n * for (const snapshot of list) {\n * console.log('Snapshot:', snapshot);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST)\n list<T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>>(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T[]> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a stream of materialized snapshots based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshots\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial materialized snapshots\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const listStream = await snapshotQueryClient.listStream(listQuery);\n * for await (const event of listStream) {\n * const snapshot = event.data;\n * console.log('Received snapshot:', snapshot);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n listStream<\n T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>,\n >(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a list of snapshot states based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of partial snapshot states\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const list = await snapshotQueryClient.listState(listQuery);\n * for (const state of list) {\n * console.log('State:', state);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST_STATE)\n listState<T extends Partial<S> = S>(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T[]> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a stream of snapshot states based on the provided query parameters.\n *\n * @param listQuery - The query parameters for listing snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial snapshot states\n *\n * @example\n * ```typescript\n * const listQuery: ListQuery = {\n * condition: all()\n * };\n * const listStream = await snapshotQueryClient.listStateStream(listQuery);\n * for await (const event of listStream) {\n * const state = event.data;\n * console.log('Received state:', state);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.LIST_STATE, {\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n })\n listStateStream<T extends Partial<S> = S>(\n @body() listQuery: ListQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n throw autoGeneratedError(listQuery, attributes);\n }\n\n /**\n * Retrieves a paged list of materialized snapshots based on the provided query parameters.\n *\n * @param pagedQuery - The query parameters for paging snapshots\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial materialized snapshots\n *\n * @example\n * ```typescript\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const paged = await snapshotQueryClient.paged(pagedQuery);\n * console.log('Total:', paged.total);\n * for (const snapshot of paged.list) {\n * console.log('Snapshot:', snapshot);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.PAGED)\n paged<T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>>(\n @body() pagedQuery: PagedQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<PagedList<T>> {\n throw autoGeneratedError(pagedQuery, attributes);\n }\n\n /**\n * Retrieves a paged list of snapshot states based on the provided query parameters.\n *\n * @param pagedQuery - The query parameters for paging snapshot states\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a paged list of partial snapshot states\n *\n * @example\n * ```typescript\n * const pagedQuery: PagedQuery = {\n * condition: all(),\n * limit: 10,\n * offset: 0\n * };\n * const pagedState = await snapshotQueryClient.pagedState(pagedQuery);\n * for (const state of pagedState.list) {\n * console.log('State:', state);\n * }\n * ```\n */\n @post(SnapshotQueryEndpointPaths.PAGED_STATE)\n pagedState<T extends Partial<S> = S>(\n @body() pagedQuery: PagedQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<PagedList<T>> {\n throw autoGeneratedError(pagedQuery, attributes);\n }\n\n /**\n * Retrieves a single materialized snapshot based on the provided query parameters.\n *\n * @param singleQuery - The query parameters for retrieving a single snapshot\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a partial materialized snapshot\n *\n * @example\n * ```typescript\n * const singleQuery: SingleQuery = {\n * condition: all()\n * };\n * const single = await snapshotQueryClient.single(singleQuery);\n * console.log('Snapshot:', single);\n * ```\n */\n @post(SnapshotQueryEndpointPaths.SINGLE)\n single<T extends Partial<MaterializedSnapshot<S>> = MaterializedSnapshot<S>>(\n @body() singleQuery: SingleQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T> {\n throw autoGeneratedError(singleQuery, attributes);\n }\n\n /**\n * Retrieves a single snapshot state based on the provided query parameters.\n *\n * @param singleQuery - The query parameters for retrieving a single snapshot state\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to a partial snapshot state\n *\n * @example\n * ```typescript\n * const singleQuery: SingleQuery = {\n * condition: all()\n * };\n * const singleState = await snapshotQueryClient.singleState(singleQuery);\n * console.log('State:', singleState);\n * ```\n */\n @post(SnapshotQueryEndpointPaths.SINGLE_STATE)\n singleState<T extends Partial<S> = S>(\n @body() singleQuery: SingleQuery<FIELDS>,\n @attribute() attributes?: Record<string, any>,\n ): Promise<T> {\n throw autoGeneratedError(singleQuery, attributes);\n }\n\n /**\n * Retrieves a single materialized snapshot by its ID.\n *\n * @param id - The unique identifier of the snapshot to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the materialized snapshot with the specified ID\n *\n * @example\n * ```typescript\n * const snapshot = await snapshotQueryClient.getById('snapshot-123');\n * console.log('Snapshot:', snapshot);\n * ```\n */\n getById(\n id: string,\n @attribute() attributes?: Record<string, any>,\n ): Promise<MaterializedSnapshot<S>> {\n const query = singleQuery<FIELDS>({\n condition: aggregateId(id),\n });\n return this.single(query, attributes);\n }\n\n /**\n * Retrieves a single snapshot state by its ID.\n *\n * @param id - The unique identifier of the snapshot whose state to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to the snapshot state with the specified ID\n *\n * @example\n * ```typescript\n * const state = await snapshotQueryClient.getStateById('snapshot-123');\n * console.log('State:', state);\n * ```\n */\n getStateById(\n id: string,\n @attribute() attributes?: Record<string, any>,\n ): Promise<S> {\n const query = singleQuery<FIELDS>({\n condition: aggregateId(id),\n });\n return this.singleState(query, attributes);\n }\n\n /**\n * Retrieves multiple materialized snapshots by their IDs.\n *\n * @param ids - An array of unique identifiers of the snapshots to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of materialized snapshots with the specified IDs\n *\n * @example\n * ```typescript\n * const snapshots = await snapshotQueryClient.getByIds(['snapshot-123', 'snapshot-456']);\n * for (const snapshot of snapshots) {\n * console.log('Snapshot:', snapshot);\n * }\n * ```\n */\n getByIds(\n ids: string[],\n @attribute() attributes?: Record<string, any>,\n ): Promise<MaterializedSnapshot<S>[]> {\n const query = listQuery<FIELDS>({\n condition: aggregateIds(ids),\n limit: ids.length,\n });\n return this.list(query, attributes);\n }\n\n /**\n * Retrieves multiple snapshot states by their IDs.\n *\n * @param ids - An array of unique identifiers of the snapshots whose states to retrieve\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @returns A promise that resolves to an array of snapshot states with the specified IDs\n *\n * @example\n * ```typescript\n * const states = await snapshotQueryClient.getStateByIds(['snapshot-123', 'snapshot-456']);\n * for (const state of states) {\n * console.log('State:', state);\n * }\n * ```\n */\n getStateByIds(\n ids: string[],\n @attribute() attributes?: Record<string, any>,\n ): Promise<S[]> {\n const query = listQuery<FIELDS>({\n condition: aggregateIds(ids),\n limit: ids.length,\n });\n return this.listState(query, attributes);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n get,\n path,\n} from '@ahoo-wang/fetcher-decorator';\n\nexport class LoadStateAggregateEndpointPaths {\n static readonly LOAD = '{id}/state';\n static readonly LOAD_VERSIONED = `${LoadStateAggregateEndpointPaths.LOAD}/{version}`;\n static readonly LOAD_TIME_BASED = `${LoadStateAggregateEndpointPaths.LOAD}/time/{createTime}`;\n}\n\n@api()\nexport class LoadStateAggregateClient<S> implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n\n }\n\n @get(LoadStateAggregateEndpointPaths.LOAD)\n load(@path('id') id: string, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(id, attributes);\n }\n\n @get(LoadStateAggregateEndpointPaths.LOAD_VERSIONED)\n loadVersioned(@path('id') id: string, @path('version') version: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(id, version, attributes);\n }\n\n @get(LoadStateAggregateEndpointPaths.LOAD_TIME_BASED)\n loadTimeBased(@path('id') id: string, @path('createTime') createTime: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(id, createTime, attributes);\n }\n\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n api,\n ApiMetadata,\n ApiMetadataCapable,\n attribute,\n autoGeneratedError,\n get,\n path,\n} from '@ahoo-wang/fetcher-decorator';\n\nexport class LoadOwnerStateAggregateEndpointPaths {\n static readonly LOAD = 'state';\n static readonly LOAD_VERSIONED = `${LoadOwnerStateAggregateEndpointPaths.LOAD}/{version}`;\n static readonly LOAD_TIME_BASED = `${LoadOwnerStateAggregateEndpointPaths.LOAD}/time/{createTime}`;\n}\n\n@api()\nexport class LoadOwnerStateAggregateClient<S> implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n }\n\n @get(LoadOwnerStateAggregateEndpointPaths.LOAD)\n load(@attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(attributes);\n }\n\n @get(LoadOwnerStateAggregateEndpointPaths.LOAD_VERSIONED)\n loadVersioned(@path('version') version: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(version, attributes);\n }\n\n @get(LoadOwnerStateAggregateEndpointPaths.LOAD_TIME_BASED)\n loadTimeBased(@path('createTime') createTime: number, @attribute() attributes?: Record<string, any>): Promise<S> {\n throw autoGeneratedError(createTime, attributes);\n }\n\n}","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FieldSort, SortDirection } from './sort';\nimport { ListQuery } from './queryable';\nimport { and, Condition, gt, lt } from './condition';\n\n/**\n * Represents a cursor-based pagination query configuration.\n * This interface defines the structure for implementing cursor-based pagination,\n * which is an efficient way to paginate through large datasets.\n */\nexport interface CursorQuery<FIELDS extends string = string> {\n /** Field name used for cursor-based sorting and filtering */\n field: FIELDS;\n /**\n * Cursor ID marking the starting point (exclusive)\n * Uses CURSOR_ID_START constant for initial query\n */\n cursorId?: string;\n /** Sort direction for pagination traversal (ascending or descending) */\n direction?: SortDirection;\n /** Base query object to be enhanced with cursor-based parameters */\n query: ListQuery;\n}\n\n/** Special cursor ID value representing the starting point of a dataset */\nexport const CURSOR_ID_START = '~';\n\n/**\n * Generates a cursor condition for filtering records relative to the cursor position\n * @param params - Cursor parameters excluding the base query\n * @param params.field - The field to apply the cursor condition on\n * @param params.cursorId - The cursor ID to compare against (defaults to CURSOR_ID_START)\n * @param params.direction - Sort direction which determines the comparison operator (defaults to SortDirection.DESC)\n * @returns Condition object for filtering records based on cursor position\n */\nexport function cursorCondition<FIELDS extends string = string>({\n field,\n cursorId = CURSOR_ID_START,\n direction = SortDirection.DESC,\n }: Omit<CursorQuery<FIELDS>, 'query'>): Condition<FIELDS> {\n // When sorting in ascending order, we want records greater than the cursor\n if (direction === SortDirection.ASC) {\n return gt(field, cursorId);\n } else {\n // When sorting in descending order, we want records less than the cursor\n return lt(field, cursorId);\n }\n}\n\n/**\n * Creates a sort configuration based on cursor parameters\n * @param params - Cursor parameters excluding the base query\n * @param params.field - The field to sort by\n * @param params.direction - Sort direction (defaults to SortDirection.DESC)\n * @returns FieldSort configuration for cursor-based pagination\n */\nexport function cursorSort<FIELDS extends string = string>({\n field,\n direction = SortDirection.DESC,\n }: Omit<CursorQuery<FIELDS>, 'query'>): FieldSort<FIELDS> {\n return { field, direction };\n}\n\n/**\n * Enhances a base query with cursor-based pagination parameters\n * This function combines the cursor condition with the existing query condition\n * and sets the sorting according to the cursor parameters.\n * @param options - Complete cursor query configuration\n * @param options.field - The field used for cursor-based sorting and filtering\n * @param options.cursorId - The cursor ID marking the starting point (exclusive)\n * @param options.direction - Sort direction for pagination traversal\n * @param options.query - Base query object to be enhanced with cursor-based parameters\n * @returns Enhanced query with cursor-based filtering and sorting\n */\nexport function cursorQuery<FIELDS extends string = string>(\n options: CursorQuery<FIELDS>,\n): ListQuery {\n const query = options.query;\n // Combine the cursor condition with the existing query condition\n const mergedCondition = and(cursorCondition(options), query.condition);\n // Apply cursor-based sorting\n const mergedSort = cursorSort(options);\n return {\n ...query,\n condition: mergedCondition,\n sort: [mergedSort],\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { combineURLs, PartialBy } from '@ahoo-wang/fetcher';\nimport { ApiMetadata } from '@ahoo-wang/fetcher-decorator';\nimport { AggregateNameCapable, AliasBoundedContext } from '../types';\nimport { ResourceAttributionPathSpec } from '../types';\nimport { SnapshotQueryClient } from './snapshot';\nimport { EventStreamQueryClient } from './event';\nimport { LoadStateAggregateClient } from './state';\nimport { LoadOwnerStateAggregateClient } from './state';\n\n/**\n * Configuration options for query clients.\n *\n * This interface extends ApiMetadata (without basePath), AliasBoundedContext, and AggregateNameCapable\n * to provide a complete configuration for query clients. It includes optional context alias and\n * resource attribution path specifications.\n */\nexport interface QueryClientOptions\n extends PartialBy<ApiMetadata, 'basePath'>,\n Partial<AliasBoundedContext>,\n Partial<AggregateNameCapable> {\n contextAlias?: string;\n resourceAttribution?: ResourceAttributionPathSpec;\n}\n\n/**\n * Creates API metadata for query clients by combining various path components.\n *\n * This function constructs a base path by combining the resource attribution path with the aggregate name,\n * and optionally prepending a context alias if provided.\n *\n * @param options - The query client options containing resource attribution, aggregate name, and optional context alias\n * @returns ApiMetadata object with the constructed base path\n */\nexport function createQueryApiMetadata(\n options: QueryClientOptions,\n): ApiMetadata {\n let basePath = combineURLs(\n options.resourceAttribution ?? '',\n options.aggregateName ?? '',\n );\n if (options.contextAlias) {\n basePath = combineURLs(options.contextAlias, basePath);\n }\n return { ...options, basePath };\n}\n\nexport class QueryClientFactory<\n S,\n FIELDS extends string = string,\n DomainEventBody = any,\n> {\n /**\n * Creates a new QueryClientFactory instance with the specified default options.\n *\n * @param defaultOptions - The default options to be used for all query clients created by this factory\n *\n * @example\n * ```typescript\n * import { QueryClientFactory, ResourceAttributionPathSpec } from '@ahoo-wang/fetcher-wow';\n *\n * const factory = new QueryClientFactory({\n * contextAlias: 'example',\n * aggregateName: 'cart',\n * resourceAttribution: ResourceAttributionPathSpec.OWNER,\n * });\n * ```\n */\n constructor(private readonly defaultOptions: QueryClientOptions) {\n }\n\n /**\n * Creates a snapshot query client for querying aggregate snapshots.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates a SnapshotQueryClient.\n *\n * @param options - The query client options used to configure the snapshot query client\n * @returns A new instance of SnapshotQueryClient\n *\n * @example\n * ```typescript\n * const snapshotClient = factory.createSnapshotQueryClient({\n * aggregateName: 'cart',\n * });\n *\n * const cartState = await snapshotClient.singleState({ condition: all() });\n * ```\n */\n createSnapshotQueryClient(\n options?: QueryClientOptions,\n ): SnapshotQueryClient<S, FIELDS> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new SnapshotQueryClient(apiMetadata);\n }\n\n /**\n * Creates a client for loading aggregate state by ID.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates a LoadStateAggregateClient.\n * The client supports loading current state, versioned state, and time-based state.\n *\n * @param options - The query client options used to configure the state aggregate client\n * @returns A new instance of LoadStateAggregateClient\n *\n * @example\n * ```typescript\n * const stateClient = factory.createLoadStateAggregateClient({\n * aggregateName: 'cart',\n * });\n *\n * // Load current state\n * const currentState = await stateClient.load('cart-123');\n *\n * // Load specific version\n * const versionedState = await stateClient.loadVersioned('cart-123', 5);\n *\n * // Load state at specific time\n * const timeBasedState = await stateClient.loadTimeBased('cart-123', Date.now());\n * ```\n */\n createLoadStateAggregateClient(\n options?: QueryClientOptions,\n ): LoadStateAggregateClient<S> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new LoadStateAggregateClient(apiMetadata);\n }\n\n /**\n * Creates a client for loading owner-specific aggregate state.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates a LoadOwnerStateAggregateClient.\n * Unlike the standard state client, this client loads state for the current owner\n * without requiring an explicit ID parameter.\n *\n * @param options - The query client options used to configure the owner state aggregate client\n * @returns A new instance of LoadOwnerStateAggregateClient\n *\n * @example\n * ```typescript\n * const ownerStateClient = factory.createOwnerLoadStateAggregateClient({\n * aggregateName: 'cart',\n * resourceAttribution: ResourceAttributionPathSpec.OWNER,\n * });\n *\n * // Load current owner's state\n * const currentState = await ownerStateClient.load();\n *\n * // Load specific version of owner's state\n * const versionedState = await ownerStateClient.loadVersioned(5);\n *\n * // Load owner's state at specific time\n * const timeBasedState = await ownerStateClient.loadTimeBased(Date.now());\n * ```\n */\n createOwnerLoadStateAggregateClient(\n options?: QueryClientOptions,\n ): LoadOwnerStateAggregateClient<S> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new LoadOwnerStateAggregateClient(apiMetadata);\n }\n\n /**\n * Creates an event stream query client for querying domain event streams.\n *\n * This method merges the provided options with the factory's default options,\n * then creates API metadata and instantiates an EventStreamQueryClient.\n *\n * @param options - The query client options used to configure the event stream query client\n * @returns A new instance of EventStreamQueryClient\n *\n * @example\n * ```typescript\n * const eventClient = factory.createEventStreamQueryClient({\n * aggregateName: 'cart',\n * });\n *\n * const events = await eventClient.list({ condition: all() });\n * ```\n */\n createEventStreamQueryClient<FIELDS extends string = string>(\n options?: QueryClientOptions,\n ): EventStreamQueryClient<DomainEventBody, FIELDS> {\n const apiMetadata = createQueryApiMetadata({\n ...this.defaultOptions,\n ...options,\n });\n return new EventStreamQueryClient(apiMetadata);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Interface for path parameters used in URL construction.\n * Defines common path parameters and allows for additional custom parameters.\n * This interface is used to provide path variables for URL templating.\n */\nexport interface UrlPathParams {\n /**\n * Tenant identifier parameter.\n * Used in multi-tenant applications to identify the tenant context.\n */\n tenantId?: string;\n /**\n * Owner identifier parameter.\n * Used to identify the owner or user context for the resource.\n */\n ownerId?: string;\n /**\n * Generic identifier parameter.\n * Used as a general purpose ID for resources when tenantId or ownerId are not appropriate.\n */\n id?: string;\n\n /**\n * Index signature for additional custom path parameters.\n * Allows for any additional string key-value pairs to be included as path parameters.\n */\n [key: string]: string | undefined;\n}\n\n/**\n * Enumeration of resource attribution path specifications.\n * Defines standard path patterns for accessing resources with different attribution scopes.\n * These paths are used to construct URLs that include tenant and/or owner identifiers.\n *\n * @example\n * ```typescript\n * // Using TENANT path spec\n * const path = ResourceAttributionPathSpec.TENANT; // '/tenant/{tenantId}'\n *\n * // Using TENANT_OWNER path spec\n * const path = ResourceAttributionPathSpec.TENANT_OWNER; // '/tenant/{tenantId}/owner/{ownerId}'\n * ```\n */\nexport enum ResourceAttributionPathSpec {\n NONE = '',\n TENANT = '/tenant/{tenantId}',\n OWNER = '/owner/{ownerId}',\n TENANT_OWNER = '/tenant/{tenantId}/owner/{ownerId}',\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Enumerates the types of recoverability for errors or operations, allowing for classification and handling based on whether an error is transient and can be resolved by retrying.\n *\n * The [RecoverableType] enum provides a way to categorize errors into three distinct categories: [RECOVERABLE], [UNRECOVERABLE], and [UNKNOWN].\n * This categorization is essential for implementing robust error handling and retry mechanisms in applications,\n * ensuring that temporary issues are retried while permanent or unknown issues are handled appropriately.\n *\n */\nexport enum RecoverableType {\n /**\n * Represents an error type that indicates the operation or error can be retried.\n *\n * This enum value is used to classify errors in a way that allows for the implementation of retry logic. When an error\n * is marked as [RECOVERABLE], it signifies that the error condition is temporary and might be resolved upon retrying the\n * operation. This is particularly useful in scenarios where network issues, transient server errors, or other temporary\n * conditions may cause an operation to fail, but with a high likelihood of success on subsequent attempts.\n */\n RECOVERABLE = 'RECOVERABLE',\n /**\n * Represents an error type that indicates the operation or error cannot be retried.\n *\n * This enum value is used to classify errors in a way that signifies the error condition is permanent and retrying the operation will not resolve the issue. It is particularly\n * useful for handling errors where the underlying problem is fundamental and cannot be resolved by simply retrying, such as invalid input, resource exhaustion, or other non-transient\n * issues.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * Represents an unknown type of recoverability for an error or operation.\n * This is used when the recoverability of an error cannot be determined or is not specified.\n */\n UNRECOVERABLE = 'UNRECOVERABLE',\n}\n\n/**\n * Represents an error that occurs during the binding process, typically when data is being mapped to or from an object.\n * This class extends the [Named] interface, inheriting the `name` property which can be used to identify the source or context of the error.\n *\n * @param name The name or identifier for the context in which the error occurred.\n * @param msg A message describing the error.\n */\nexport interface BindingError {\n name: string;\n msg: string;\n}\n\n/**\n * Represents the information about an error, including whether the operation succeeded, the error code, and any associated messages or binding errors.\n *\n * This interface is designed to provide a standardized way of handling and representing errors across different parts of an application. It includes methods to check if the operation was successful, retrieve the error code\n * , and access any additional error details such as messages or binding errors.\n */\nexport interface ErrorInfo {\n /**\n * Represents the error code associated with an error. This value is used to identify the type of error that has occurred,\n * which can be useful for debugging, logging, and handling errors in a standardized way.\n */\n errorCode: string;\n /**\n * Represents the message associated with an error. This message provides a human-readable description of the error, which can be used for logging, debugging, or displaying to the user\n * .\n */\n errorMsg: string;\n /**\n * Provides a list of [BindingError] instances that occurred during the binding process.\n * Each [BindingError] contains information about the error, including its name and a message describing the issue.\n * This property returns an empty list if no binding errors are present.\n */\n bindingErrors?: BindingError[];\n}\n\nexport class ErrorCodes {\n /**\n * A constant representing a successful operation or status.\n * This value is typically used in the context of error handling and response descriptions to indicate that an operation has been completed successfully.\n */\n static readonly SUCCEEDED = 'Ok';\n static readonly SUCCEEDED_MESSAGE = '';\n\n /**\n * Error code for when a requested resource is not found.\n */\n static readonly NOT_FOUND = 'NotFound';\n\n /**\n * Default message for NOT_FOUND error code.\n */\n static readonly NOT_FOUND_MESSAGE = 'Not found resource!';\n\n /**\n * Error code for bad request errors.\n */\n static readonly BAD_REQUEST = 'BadRequest';\n\n /**\n * Error code for illegal argument errors.\n */\n static readonly ILLEGAL_ARGUMENT = 'IllegalArgument';\n\n /**\n * Error code for illegal state errors.\n */\n static readonly ILLEGAL_STATE = 'IllegalState';\n\n /**\n * Error code for request timeout errors.\n */\n static readonly REQUEST_TIMEOUT = 'RequestTimeout';\n\n /**\n * Error code for too many requests errors (rate limiting).\n */\n static readonly TOO_MANY_REQUESTS = 'TooManyRequests';\n\n /**\n * Error code for duplicate request ID errors.\n */\n static readonly DUPLICATE_REQUEST_ID = 'DuplicateRequestId';\n\n /**\n * Error code for command validation errors.\n */\n static readonly COMMAND_VALIDATION = 'CommandValidation';\n\n /**\n * Error code for when no command is found to rewrite.\n */\n static readonly REWRITE_NO_COMMAND = 'RewriteNoCommand';\n\n /**\n * Error code for event version conflicts.\n */\n static readonly EVENT_VERSION_CONFLICT = 'EventVersionConflict';\n\n /**\n * Error code for duplicate aggregate ID errors.\n */\n static readonly DUPLICATE_AGGREGATE_ID = 'DuplicateAggregateId';\n\n /**\n * Error code for command expected version conflicts.\n */\n static readonly COMMAND_EXPECT_VERSION_CONFLICT =\n 'CommandExpectVersionConflict';\n\n /**\n * Error code for sourcing version conflicts.\n */\n static readonly SOURCING_VERSION_CONFLICT = 'SourcingVersionConflict';\n\n /**\n * Error code for illegal access to deleted aggregate errors.\n */\n static readonly ILLEGAL_ACCESS_DELETED_AGGREGATE =\n 'IllegalAccessDeletedAggregate';\n\n /**\n * Error code for illegal access to owner aggregate errors.\n */\n static readonly ILLEGAL_ACCESS_OWNER_AGGREGATE =\n 'IllegalAccessOwnerAggregate';\n\n /**\n * Error code for internal server errors.\n */\n static readonly INTERNAL_SERVER_ERROR = 'InternalServerError';\n\n /**\n * Checks if the provided error code represents a successful operation.\n *\n * @param errorCode The error code to check\n * @returns true if the error code is 'Ok', false otherwise\n */\n static isSucceeded(errorCode: string): boolean {\n return errorCode === ErrorCodes.SUCCEEDED;\n }\n\n /**\n * Checks if the provided error code represents an error condition.\n *\n * @param errorCode The error code to check\n * @returns true if the error code is not 'Ok', false otherwise\n */\n static isError(errorCode: string): boolean {\n return !ErrorCodes.isSucceeded(errorCode);\n }\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Named, NamedBoundedContext } from './naming';\n\n/**\n * Function kind enum\n *\n * Represents the different types of functions in the system.\n */\nexport enum FunctionKind {\n /**\n * Command function kind\n */\n COMMAND = 'COMMAND',\n\n /**\n * Error function kind\n */\n ERROR = 'ERROR',\n\n /**\n * Event function kind\n */\n EVENT = 'EVENT',\n\n /**\n * Sourcing function kind\n */\n SOURCING = 'SOURCING',\n\n /**\n * State event function kind\n */\n STATE_EVENT = 'STATE_EVENT',\n}\n\n/**\n * Interface for function information.\n */\nexport interface FunctionInfo extends NamedBoundedContext, Named {\n functionKind: FunctionKind;\n processorName: string;\n}\n\n/**\n * Interface for objects that have function information.\n */\nexport interface FunctionInfoCapable {\n function: FunctionInfo;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AliasBoundedContext, NamedBoundedContext } from './naming.ts';\n\n/**\n * Interface for classes that have a creation time.\n */\nexport interface CreateTimeCapable {\n /**\n * Gets the creation time in milliseconds since the Unix epoch.\n */\n createTime: number;\n}\n\n/**\n * Interface for objects that track deletion status.\n */\nexport interface DeletedCapable {\n /**\n * Whether the aggregate is deleted.\n */\n deleted: boolean;\n}\n\n/**\n * Interface for objects that track event IDs.\n */\nexport interface EventIdCapable {\n /**\n * The event id of the aggregate.\n */\n eventId: string;\n}\n\n/**\n * Interface for objects that track event times.\n */\nexport interface EventTimeCapable {\n /**\n * The last event time of the aggregate, represented as a Unix timestamp in milliseconds.\n */\n eventTime: number;\n}\n\n/**\n * Interface for objects that track the first event time.\n */\nexport interface FirstEventTimeCapable {\n /**\n * The first event time of the aggregate, represented as a Unix timestamp in milliseconds.\n */\n firstEventTime: number;\n}\n\n/**\n * Interface for objects that track the first operator.\n */\nexport interface FirstOperatorCapable {\n /**\n * The first operator of the aggregate.\n */\n firstOperator: string;\n}\n\n/**\n * Interface for objects that have an aggregate name.\n */\nexport interface AggregateNameCapable {\n /**\n * The name of the aggregate.\n */\n aggregateName: string;\n}\n\n/**\n * Interface for named aggregates that belong to a bounded context.\n */\nexport interface NamedAggregate\n extends NamedBoundedContext,\n AggregateNameCapable {\n}\n\nexport interface AliasAggregate\n extends AliasBoundedContext,\n AggregateNameCapable {\n}\n\n/**\n * Interface for aggregate IDs that combine tenant and named aggregate information.\n */\nexport interface AggregateId extends TenantId, NamedAggregate {\n aggregateId: string;\n}\n\n/**\n * Interface that provides the capability to contain an aggregate identifier.\n *\n * This interface is implemented by objects that need to reference an aggregate instance\n * through its unique identifier, which includes tenant, context, aggregate name and the\n * actual aggregate ID.\n */\nexport interface AggregateIdCapable {\n /**\n * The unique identifier of the aggregate instance.\n *\n * Contains information about the tenant, bounded context, aggregate name and the\n * actual aggregate ID string.\n */\n aggregateId: AggregateId;\n}\n\n/**\n * Interface for objects that track the last operator.\n */\nexport interface OperatorCapable {\n /**\n * The last operator of the aggregate.\n */\n operator: string;\n}\n\nexport const DEFAULT_OWNER_ID = '';\n\n/**\n * Interface for identifying resource owners.\n */\nexport interface OwnerId {\n /**\n * Unique identifier of the resource owner.\n */\n ownerId: string;\n}\n\n/**\n * Interface for objects that track snapshot times.\n */\nexport interface SnapshotTimeCapable {\n /**\n * The snapshot time of the aggregate, represented as a Unix timestamp in milliseconds.\n */\n snapshotTime: number;\n}\n\n/**\n * Interface for objects that have a tenant ID.\n */\nexport interface TenantId {\n tenantId: string;\n}\n\n/**\n * Interface for objects that hold state.\n */\nexport interface StateCapable<S> {\n state: S;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum MessageHeaderSqlType {\n MAP = 'MAP',\n STRING = 'STRING',\n}\n"],"names":["CommandClient","apiMetadata","commandRequest","attributes","autoGeneratedError","__decorateClass","endpoint","__decorateParam","request","attribute","ContentTypeValues","JsonEventStreamResultExtractor","api","_CommandHeaders","CommandHeaders","CommandStage","Operator","isValidateCondition","condition","_ConditionOptionKey","ConditionOptionKey","ignoreCaseOptions","ignoreCase","dateOptions","datePattern","zoneId","options","DeletionState","and","conditions","all","andChildren","or","validateConditions","nor","id","value","ids","aggregateId","aggregateIds","tenantId","ownerId","deleted","active","eq","field","ne","gt","lt","gte","lte","contains","isIn","notIn","between","start","end","allIn","startsWith","endsWith","elemMatch","isNull","notNull","isTrue","isFalse","exists","today","beforeToday","time","tomorrow","thisWeek","nextWeek","lastWeek","thisMonth","lastMonth","recentDays","days","earlierDays","raw","DEFAULT_PAGINATION","pagination","index","size","DEFAULT_PROJECTION","defaultProjection","projection","include","exclude","singleQuery","sort","listQuery","limit","pagedQuery","EMPTY_PAGED_LIST","pagedList","total","list","SortDirection","asc","desc","_DomainEventStreamMetadataFields","DomainEventStreamMetadataFields","_EventStreamQueryEndpointPaths","EventStreamQueryEndpointPaths","EventStreamQueryClient","post","body","_SnapshotMetadataFields","SnapshotMetadataFields","_SnapshotQueryEndpointPaths","SnapshotQueryEndpointPaths","SnapshotQueryClient","query","_LoadStateAggregateEndpointPaths","LoadStateAggregateEndpointPaths","LoadStateAggregateClient","version","createTime","get","_LoadOwnerStateAggregateEndpointPaths","LoadOwnerStateAggregateEndpointPaths","LoadOwnerStateAggregateClient","CURSOR_ID_START","cursorCondition","cursorId","direction","cursorSort","cursorQuery","mergedCondition","mergedSort","createQueryApiMetadata","basePath","combineURLs","QueryClientFactory","defaultOptions","ResourceAttributionPathSpec","RecoverableType","_ErrorCodes","errorCode","ErrorCodes","FunctionKind","DEFAULT_OWNER_ID","MessageHeaderSqlType"],"mappings":"yaA0EaA,QAAAA,cAAN,KACyB,CAC9B,YAA4BC,EAA2B,CAA3B,KAAA,YAAAA,CAC5B,CAuBA,KACaC,EACEC,EACW,CACxB,MAAMC,EAAAA,mBAAmBF,EAAgBC,CAAU,CACrD,CAkCA,kBACaD,EACEC,EACsB,CACnC,MAAMC,EAAAA,mBAAmBF,EAAgBC,CAAU,CACrD,CACF,EA7CEE,EAAA,CADCC,WAAA,EAEEC,EAAA,EAAAC,EAAAA,SAAQ,EACRD,EAAA,EAAAE,YAAA,CAAU,CAAA,EA5BFT,sBA0BX,UAAA,OAAA,CAAA,EAuCAK,EAAA,CAJCC,EAAAA,SAAS,OAAW,OAAW,CAC9B,QAAS,CAAE,OAAQI,EAAAA,kBAAkB,iBAAA,EACrC,gBAAiBC,EAAAA,8BAAA,CAClB,EAEEJ,EAAA,EAAAC,EAAAA,SAAQ,EACRD,EAAA,EAAAE,YAAA,CAAU,CAAA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