@ahoo-wang/fetcher-wow 1.2.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -106,7 +106,7 @@ function v(...t) {
106
106
  return t[0];
107
107
  const E = [];
108
108
  return t.forEach((T) => {
109
- T.operator === A.AND && T.children ? E.push(...T.children) : E.push(T);
109
+ T.operator !== A.ALL && (T.operator === A.AND && T.children ? E.push(...T.children) : E.push(T));
110
110
  }), { operator: A.AND, children: E };
111
111
  }
112
112
  function K(...t) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/command/commandClient.ts","../src/command/commandHttpHeaders.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/queryApi.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/types/error.ts","../src/types/function.ts","../src/types/modeling.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 ClientOptions } from '../types';\nimport { type CommandRequest } from './commandRequest';\nimport {\n type CommandResult,\n type CommandResultEventStream,\n} from './commandResult';\nimport {\n type ResultExtractor,\n ResultExtractors,\n} from '@ahoo-wang/fetcher-decorator';\nimport { combineURLs, ContentTypeValues } from '@ahoo-wang/fetcher';\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 */\nexport class CommandClient {\n constructor(protected readonly options: ClientOptions) {\n }\n\n /**\n * Sends a command to the specified path and returns the result.\n * This is a protected generic method that handles the common logic for sending commands.\n * @template R The type of the result to be returned\n * @param path - The endpoint path to send the command to\n * @param commandHttpRequest - The command HTTP request containing headers, method, and body\n * @param extractor - Function to extract the result from the response, defaults to JSON extractor\n * @returns A promise that resolves to the extracted result of type R\n */\n protected async sendCommand<R>(\n path: string,\n commandHttpRequest: CommandRequest,\n extractor: ResultExtractor = ResultExtractors.Json,\n ): Promise<R> {\n const url = combineURLs(this.options.basePath, path);\n const request = {\n ...commandHttpRequest,\n url: url,\n };\n const exchange = await this.options.fetcher.request(request);\n return extractor(exchange);\n }\n\n /**\n * Send a command to the server and wait for the result.\n *\n * @param path - The endpoint path to send the command to\n * @param commandHttpRequest - The command request to send\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 send(\n path: string,\n commandHttpRequest: CommandRequest,\n ): Promise<CommandResult> {\n return this.sendCommand(path, commandHttpRequest);\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 path - The endpoint path to send the command to\n * @param commandHttpRequest - The command request to send\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 async sendAndWaitStream(\n path: string,\n commandHttpRequest: CommandRequest,\n ): Promise<CommandResultEventStream> {\n commandHttpRequest.headers = {\n ...commandHttpRequest.headers,\n Accept: ContentTypeValues.TEXT_EVENT_STREAM,\n };\n return this.sendCommand(\n path,\n commandHttpRequest,\n ResultExtractors.JsonEventStream,\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\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 CommandHttpHeaders {\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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Version`;\n\n /**\n * Wait prefix for wait-related headers\n */\n static readonly WAIT_PREFIX = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.WAIT_PREFIX}Stage`;\n\n /**\n * Wait context header\n * Specifies the bounded context to wait for\n */\n static readonly WAIT_CONTEXT = `${CommandHttpHeaders.WAIT_PREFIX}Context`;\n\n /**\n * Wait processor header\n * Specifies the processor to wait for\n */\n static readonly WAIT_PROCESSOR = `${CommandHttpHeaders.WAIT_PREFIX}Processor`;\n\n /**\n * Wait function header\n * Specifies the function to wait for\n */\n static readonly WAIT_FUNCTION = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.COMMAND_HEADERS_PREFIX}Request-Id`;\n\n /**\n * Local first header\n * Indicates whether to prefer local processing\n */\n static readonly LOCAL_FIRST = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Name`;\n\n /**\n * Command type header\n * Specifies the type of the command\n */\n static readonly COMMAND_TYPE = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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\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 * The aggregate version of the aggregate.\n */\n aggregateVersion?: 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 * 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 {\n /**\n * Field name for the condition\n */\n field?: string;\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[];\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 {\n condition: Condition;\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(...conditions: Condition[]): Condition {\n if (conditions.length === 0) {\n return all();\n }\n if (conditions.length === 1) {\n return conditions[0];\n }\n const andChildren: Condition[] = [];\n conditions.forEach(condition => {\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(...conditions: Condition[]): Condition {\n if (conditions.length === 0) {\n return all();\n }\n return { operator: Operator.OR, children: conditions };\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(...conditions: Condition[]): Condition {\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(value: string): Condition {\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(value: string[]): Condition {\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(value: string): Condition {\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(...value: string[]): Condition {\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(value: string): Condition {\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(value: string): Condition {\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(value: DeletionState): Condition {\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(): Condition {\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(): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(\n field: string,\n value: any,\n ignoreCase?: boolean,\n): Condition {\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(field: string, ...value: any[]): Condition {\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(field: string, ...value: any[]): Condition {\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(field: string, start: any, end: any): Condition {\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(field: string, ...value: any[]): Condition {\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(\n field: string,\n value: any,\n ignoreCase?: boolean,\n): Condition {\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(\n field: string,\n value: any,\n ignoreCase?: boolean,\n): Condition {\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(field: string, value: Condition): Condition {\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(field: string): Condition {\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(field: string): Condition {\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(field: string): Condition {\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(field: string): Condition {\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(field: string, exists: boolean = true): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n time: any,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(raw: any): Condition {\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 {\n include?: string[];\n exclude?: string[];\n}\n\n/**\n * Default projection configuration.\n * Empty projection object includes all fields.\n */\nexport const DEFAULT_PROJECTION: Projection = {};\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({\n include,\n exclude,\n }: Projection = DEFAULT_PROJECTION): Projection {\n return {\n include,\n exclude,\n };\n}\n\n/**\n * Interface for objects that support field projection.\n */\nexport interface ProjectionCapable {\n projection?: Projection;\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\n extends ConditionCapable,\n ProjectionCapable,\n SortCapable {\n}\n\n/**\n * Interface for single query objects.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface SingleQuery extends Queryable {\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({\n condition = all(),\n projection,\n sort,\n }: Partial<SingleQuery> = {}): SingleQuery {\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 extends Queryable {\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({\n condition = all(),\n projection,\n sort,\n limit = DEFAULT_PAGINATION.size,\n }: Partial<ListQuery> = {}): ListQuery {\n return {\n condition,\n projection,\n sort,\n limit,\n };\n}\n\n/**\n * Interface for paged query objects.\n */\nexport interface PagedQuery extends Queryable {\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({\n condition = all(),\n projection,\n sort,\n pagination = DEFAULT_PAGINATION,\n }: Partial<PagedQuery> = {}): PagedQuery {\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","/*\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 ListQuery,\n PagedList,\n PagedQuery,\n SingleQuery,\n} from './queryable';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport type { Condition } from './condition';\nimport type { ClientOptions } from '../types';\nimport { combineURLs, ContentTypeValues, HttpMethod } from '@ahoo-wang/fetcher';\nimport {\n type ResultExtractor,\n ResultExtractors,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * Interface for generic query API operations.\n * Provides methods for querying resources in different ways including single item retrieval,\n * list retrieval, streaming lists, paged retrieval, and counting.\n *\n * @see {@link EventStreamQueryApi}\n * @see {@link SnapshotQueryApi}\n * @template R - The type of resource being queried\n */\nexport interface QueryApi<R> {\n /**\n * Retrieves a single resource based on the provided query parameters.\n * @param singleQuery - The query parameters for retrieving a single resource\n * @returns A promise that resolves to a partial resource\n */\n single<T extends Partial<R> = Partial<R>>(\n singleQuery: SingleQuery,\n ): Promise<T>;\n\n /**\n * Retrieves a list of resources based on the provided query parameters.\n * @param listQuery - The query parameters for listing resources\n * @returns A promise that resolves to an array of partial resources\n */\n list<T extends Partial<R> = Partial<R>>(listQuery: ListQuery): Promise<T[]>;\n\n /**\n * Retrieves a stream of resources based on the provided query parameters.\n * @param listQuery - The query parameters for listing resources\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial resources\n */\n listStream<T extends Partial<R> = Partial<R>>(\n listQuery: ListQuery,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>>;\n\n /**\n * Retrieves a paged list of resources based on the provided query parameters.\n * @param pagedQuery - The query parameters for paging resources\n * @returns A promise that resolves to a paged list of partial resources\n */\n paged<T extends Partial<R> = Partial<R>>(\n pagedQuery: PagedQuery,\n ): Promise<PagedList<T>>;\n\n /**\n * Counts the number of resources that match the given condition.\n * @param condition - The condition to filter resources\n * @returns A promise that resolves to the count of matching resources\n */\n count(condition: Condition): Promise<number>;\n}\n\n/**\n * Base client for performing query operations.\n * Provides a generic query method that handles the common logic for sending requests\n * and processing responses for different types of queries.\n *\n * @see {@link EventStreamQueryClient}\n * @see {@link SnapshotQueryClient}\n */\nexport class QueryClient {\n /**\n * Creates a new QueryClient instance.\n * @param options - The client configuration options including fetcher and base path\n */\n constructor(protected readonly options: ClientOptions) {\n }\n\n /**\n * Performs a generic query operation by sending a request to the specified path.\n * @template R The return type of the query\n * @param path - The endpoint path to query\n * @param query - The query parameters to send\n * @param accept - The content type to accept from the server, defaults to application/json\n * @param extractor - Function to extract the result from the response, defaults to JSON extractor\n * @returns A promise that resolves to the query result\n */\n protected async query<R>(\n path: string,\n query: Condition | ListQuery | PagedQuery | SingleQuery,\n accept: string = ContentTypeValues.APPLICATION_JSON,\n extractor: ResultExtractor = ResultExtractors.Json,\n ): Promise<R> {\n const url = combineURLs(this.options.basePath, path);\n const request = {\n url: url,\n method: HttpMethod.POST,\n headers: {\n Accept: accept,\n },\n body: query,\n };\n const exchange = await this.options.fetcher.request(request);\n return extractor(exchange);\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 {\n field: string;\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(field: string): FieldSort {\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(field: string): FieldSort {\n return {\n field,\n direction: SortDirection.DESC,\n };\n}\n\n/**\n * Interface for objects that support sorting.\n */\nexport interface SortCapable {\n sort?: FieldSort[];\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 Identifier,\n Named,\n OwnerId,\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\n extends Identifier,\n AggregateId,\n OwnerId,\n CommandId,\n CreateTimeCapable,\n RequestId,\n Version,\n BodyCapable<DomainEvent<any>[]> {\n /**\n * The header information for the domain event stream.\n */\n header: DomainEventStreamHeader;\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 extends Omit<QueryApi<DomainEventStream>, 'single'> {\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 type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport { QueryClient } from '../queryApi';\nimport type { ClientOptions } from '../../types';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport { ResultExtractors } 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 */\nexport class EventStreamQueryClient\n extends QueryClient\n implements EventStreamQueryApi {\n /**\n * Creates a new EventStreamQueryClient instance.\n * @param options - The client configuration options including fetcher and base path\n */\n constructor(options: ClientOptions) {\n super(options);\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 * @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 count(condition: Condition): Promise<number> {\n return this.query(EventStreamQueryEndpointPaths.COUNT, condition);\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 * @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 list<T extends Partial<DomainEventStream> = Partial<DomainEventStream>>(\n listQuery: ListQuery,\n ): Promise<T[]> {\n return this.query(EventStreamQueryEndpointPaths.LIST, listQuery);\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 * @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 listStream<T extends Partial<DomainEventStream> = Partial<DomainEventStream>>(\n listQuery: ListQuery,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n return this.query(\n EventStreamQueryEndpointPaths.LIST,\n listQuery,\n ContentTypeValues.TEXT_EVENT_STREAM,\n ResultExtractors.JsonEventStream,\n );\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 * @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 paged<T extends Partial<DomainEventStream> = Partial<DomainEventStream>>(\n pagedQuery: PagedQuery,\n ): Promise<PagedList<T>> {\n return this.query(EventStreamQueryEndpointPaths.PAGED, pagedQuery);\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 MaterializedSnapshot<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> extends QueryApi<MaterializedSnapshot<S>> {\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 * @returns A promise that resolves to a partial snapshot state\n */\n singleState<T extends Partial<S> = Partial<S>>(\n singleQuery: SingleQuery,\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 * @returns A promise that resolves to an array of partial snapshot states\n */\n listState<T extends Partial<S> = Partial<S>>(\n listQuery: ListQuery,\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 * @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> = Partial<S>>(\n listQuery: ListQuery,\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 * @returns A promise that resolves to a paged list of partial snapshot states\n */\n pagedState<T extends Partial<S> = Partial<S>>(\n pagedQuery: PagedQuery,\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 {\n type SnapshotQueryApi,\n SnapshotQueryEndpointPaths,\n} from './snapshotQueryApi';\nimport type { Condition } from '../condition';\nimport type {\n ListQuery,\n PagedList,\n PagedQuery,\n SingleQuery,\n} from '../queryable';\nimport type { MaterializedSnapshot } from './snapshot';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport { ResultExtractors } from '@ahoo-wang/fetcher-decorator';\nimport '@ahoo-wang/fetcher-eventstream';\nimport type { ClientOptions } from '../../types';\nimport { QueryClient } from '../queryApi';\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 */\nexport class SnapshotQueryClient<S>\n extends QueryClient\n implements SnapshotQueryApi<S> {\n /**\n * Creates a new SnapshotQueryClient instance.\n * @param options - The configuration options for the client\n */\n constructor(options: ClientOptions) {\n super(options);\n }\n\n /**\n * Counts the number of snapshots that match the given condition.\n *\n * @param condition - The condition to match snapshots against\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 async count(condition: Condition): Promise<number> {\n return this.query(SnapshotQueryEndpointPaths.COUNT, condition);\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 * @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 list<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(listQuery: ListQuery): Promise<T[]> {\n return this.query(SnapshotQueryEndpointPaths.LIST, listQuery);\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 * @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 listStream<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(listQuery: ListQuery): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n return this.query(\n SnapshotQueryEndpointPaths.LIST,\n listQuery,\n ContentTypeValues.TEXT_EVENT_STREAM,\n ResultExtractors.JsonEventStream,\n );\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 * @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 listState<T extends Partial<S> = Partial<S>>(\n listQuery: ListQuery,\n ): Promise<T[]> {\n return this.query(SnapshotQueryEndpointPaths.LIST_STATE, listQuery);\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 * @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 listStateStream<T extends Partial<S> = Partial<S>>(\n listQuery: ListQuery,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n return this.query(\n SnapshotQueryEndpointPaths.LIST_STATE,\n listQuery,\n ContentTypeValues.TEXT_EVENT_STREAM,\n ResultExtractors.JsonEventStream,\n );\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 * @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 paged<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(pagedQuery: PagedQuery): Promise<PagedList<T>> {\n return this.query(SnapshotQueryEndpointPaths.PAGED, pagedQuery);\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 * @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 pagedState<T extends Partial<S> = Partial<S>>(\n pagedQuery: PagedQuery,\n ): Promise<PagedList<T>> {\n return this.query(SnapshotQueryEndpointPaths.PAGED_STATE, pagedQuery);\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 * @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 single<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(singleQuery: SingleQuery): Promise<T> {\n return this.query(SnapshotQueryEndpointPaths.SINGLE, singleQuery);\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 * @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 singleState<T extends Partial<S> = Partial<S>>(\n singleQuery: SingleQuery,\n ): Promise<T> {\n return this.query(SnapshotQueryEndpointPaths.SINGLE_STATE, singleQuery);\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 * 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\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 {\n functionKind: FunctionKind;\n contextName: string;\n processorName: string;\n name: 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 { 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/**\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 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\nexport const DEFAULT_TENANT_ID = '(0)';\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"],"names":["CommandClient","options","path","commandHttpRequest","extractor","ResultExtractors","url","combineURLs","request","exchange","ContentTypeValues","_CommandHttpHeaders","CommandHttpHeaders","CommandStage","Operator","_ConditionOptionKey","ConditionOptionKey","ignoreCaseOptions","ignoreCase","dateOptions","datePattern","zoneId","DeletionState","and","conditions","all","andChildren","condition","or","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","projection","include","exclude","singleQuery","sort","listQuery","limit","pagedQuery","QueryClient","query","accept","HttpMethod","SortDirection","asc","desc","_DomainEventStreamMetadataFields","DomainEventStreamMetadataFields","_EventStreamQueryEndpointPaths","EventStreamQueryEndpointPaths","EventStreamQueryClient","_SnapshotMetadataFields","SnapshotMetadataFields","_SnapshotQueryEndpointPaths","SnapshotQueryEndpointPaths","SnapshotQueryClient","RecoverableType","_ErrorCodes","errorCode","ErrorCodes","FunctionKind","DEFAULT_OWNER_ID","DEFAULT_TENANT_ID"],"mappings":";;;AAmEO,MAAMA,EAAc;AAAA,EACzB,YAA+BC,GAAwB;AAAxB,SAAA,UAAAA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAgB,YACdC,GACAC,GACAC,IAA6BC,EAAiB,MAClC;AACZ,UAAMC,IAAMC,EAAY,KAAK,QAAQ,UAAUL,CAAI,GAC7CM,IAAU;AAAA,MACd,GAAGL;AAAA,MACH,KAAAG;AAAA,IAAA,GAEIG,IAAW,MAAM,KAAK,QAAQ,QAAQ,QAAQD,CAAO;AAC3D,WAAOJ,EAAUK,CAAQ;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,KACEP,GACAC,GACwB;AACxB,WAAO,KAAK,YAAYD,GAAMC,CAAkB;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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mBAKnCA,EAAgB,gBAAgB,gBAKhCA,EAAgB,kBAAkB,kBAKlCA,EAAgB,oBAAoB,mBAKpCA,EAAgB,uBAAuB,sBAKvCA,EAAgB,qBAAqB,qBAKrCA,EAAgB,qBAAqB,oBAKrCA,EAAgB,yBAAyB,wBAKzCA,EAAgB,yBAAyB,wBAKzCA,EAAgB,kCACd,gCAKFA,EAAgB,4BAA4B,2BAK5CA,EAAgB,mCACd,iCAKFA,EAAgB,iCACd,+BAKFA,EAAgB,wBAAwB;AA9FnC,IAAME,IAANF;AClEA,IAAKG,sBAAAA,OAIVA,EAAA,UAAU,WAKVA,EAAA,QAAQ,SAKRA,EAAA,QAAQ,SAKRA,EAAA,WAAW,YAKXA,EAAA,cAAc,eAxBJA,IAAAA,KAAA,CAAA,CAAA;AC2FL,MAAMC,KAAmB,IAsBnBC,KAAoB;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/command/commandClient.ts","../src/command/commandHttpHeaders.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/queryApi.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/types/error.ts","../src/types/function.ts","../src/types/modeling.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 ClientOptions } from '../types';\nimport { type CommandRequest } from './commandRequest';\nimport {\n type CommandResult,\n type CommandResultEventStream,\n} from './commandResult';\nimport {\n type ResultExtractor,\n ResultExtractors,\n} from '@ahoo-wang/fetcher-decorator';\nimport { combineURLs, ContentTypeValues } from '@ahoo-wang/fetcher';\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 */\nexport class CommandClient {\n constructor(protected readonly options: ClientOptions) {\n }\n\n /**\n * Sends a command to the specified path and returns the result.\n * This is a protected generic method that handles the common logic for sending commands.\n * @template R The type of the result to be returned\n * @param path - The endpoint path to send the command to\n * @param commandHttpRequest - The command HTTP request containing headers, method, and body\n * @param extractor - Function to extract the result from the response, defaults to JSON extractor\n * @returns A promise that resolves to the extracted result of type R\n */\n protected async sendCommand<R>(\n path: string,\n commandHttpRequest: CommandRequest,\n extractor: ResultExtractor = ResultExtractors.Json,\n ): Promise<R> {\n const url = combineURLs(this.options.basePath, path);\n const request = {\n ...commandHttpRequest,\n url: url,\n };\n const exchange = await this.options.fetcher.request(request);\n return extractor(exchange);\n }\n\n /**\n * Send a command to the server and wait for the result.\n *\n * @param path - The endpoint path to send the command to\n * @param commandHttpRequest - The command request to send\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 send(\n path: string,\n commandHttpRequest: CommandRequest,\n ): Promise<CommandResult> {\n return this.sendCommand(path, commandHttpRequest);\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 path - The endpoint path to send the command to\n * @param commandHttpRequest - The command request to send\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 async sendAndWaitStream(\n path: string,\n commandHttpRequest: CommandRequest,\n ): Promise<CommandResultEventStream> {\n commandHttpRequest.headers = {\n ...commandHttpRequest.headers,\n Accept: ContentTypeValues.TEXT_EVENT_STREAM,\n };\n return this.sendCommand(\n path,\n commandHttpRequest,\n ResultExtractors.JsonEventStream,\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\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 CommandHttpHeaders {\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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Version`;\n\n /**\n * Wait prefix for wait-related headers\n */\n static readonly WAIT_PREFIX = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.WAIT_PREFIX}Stage`;\n\n /**\n * Wait context header\n * Specifies the bounded context to wait for\n */\n static readonly WAIT_CONTEXT = `${CommandHttpHeaders.WAIT_PREFIX}Context`;\n\n /**\n * Wait processor header\n * Specifies the processor to wait for\n */\n static readonly WAIT_PROCESSOR = `${CommandHttpHeaders.WAIT_PREFIX}Processor`;\n\n /**\n * Wait function header\n * Specifies the function to wait for\n */\n static readonly WAIT_FUNCTION = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.COMMAND_HEADERS_PREFIX}Request-Id`;\n\n /**\n * Local first header\n * Indicates whether to prefer local processing\n */\n static readonly LOCAL_FIRST = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.COMMAND_HEADERS_PREFIX}Aggregate-Name`;\n\n /**\n * Command type header\n * Specifies the type of the command\n */\n static readonly COMMAND_TYPE = `${CommandHttpHeaders.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 = `${CommandHttpHeaders.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\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 * The aggregate version of the aggregate.\n */\n aggregateVersion?: 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 * 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 {\n /**\n * Field name for the condition\n */\n field?: string;\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[];\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 {\n condition: Condition;\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(...conditions: Condition[]): Condition {\n if (conditions.length === 0) {\n return all();\n }\n if (conditions.length === 1) {\n return conditions[0];\n }\n const andChildren: Condition[] = [];\n conditions.forEach(condition => {\n if (condition.operator === Operator.ALL) {\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(...conditions: Condition[]): Condition {\n if (conditions.length === 0) {\n return all();\n }\n return { operator: Operator.OR, children: conditions };\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(...conditions: Condition[]): Condition {\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(value: string): Condition {\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(value: string[]): Condition {\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(value: string): Condition {\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(...value: string[]): Condition {\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(value: string): Condition {\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(value: string): Condition {\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(value: DeletionState): Condition {\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(): Condition {\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(): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(field: string, value: any): Condition {\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(\n field: string,\n value: any,\n ignoreCase?: boolean,\n): Condition {\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(field: string, ...value: any[]): Condition {\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(field: string, ...value: any[]): Condition {\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(field: string, start: any, end: any): Condition {\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(field: string, ...value: any[]): Condition {\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(\n field: string,\n value: any,\n ignoreCase?: boolean,\n): Condition {\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(\n field: string,\n value: any,\n ignoreCase?: boolean,\n): Condition {\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(field: string, value: Condition): Condition {\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(field: string): Condition {\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(field: string): Condition {\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(field: string): Condition {\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(field: string): Condition {\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(field: string, exists: boolean = true): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n time: any,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(\n field: string,\n days: number,\n datePattern?: string,\n zoneId?: string,\n): Condition {\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(raw: any): Condition {\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 {\n include?: string[];\n exclude?: string[];\n}\n\n/**\n * Default projection configuration.\n * Empty projection object includes all fields.\n */\nexport const DEFAULT_PROJECTION: Projection = {};\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({\n include,\n exclude,\n }: Projection = DEFAULT_PROJECTION): Projection {\n return {\n include,\n exclude,\n };\n}\n\n/**\n * Interface for objects that support field projection.\n */\nexport interface ProjectionCapable {\n projection?: Projection;\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\n extends ConditionCapable,\n ProjectionCapable,\n SortCapable {\n}\n\n/**\n * Interface for single query objects.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface SingleQuery extends Queryable {\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({\n condition = all(),\n projection,\n sort,\n }: Partial<SingleQuery> = {}): SingleQuery {\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 extends Queryable {\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({\n condition = all(),\n projection,\n sort,\n limit = DEFAULT_PAGINATION.size,\n }: Partial<ListQuery> = {}): ListQuery {\n return {\n condition,\n projection,\n sort,\n limit,\n };\n}\n\n/**\n * Interface for paged query objects.\n */\nexport interface PagedQuery extends Queryable {\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({\n condition = all(),\n projection,\n sort,\n pagination = DEFAULT_PAGINATION,\n }: Partial<PagedQuery> = {}): PagedQuery {\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","/*\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 ListQuery,\n PagedList,\n PagedQuery,\n SingleQuery,\n} from './queryable';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport type { Condition } from './condition';\nimport type { ClientOptions } from '../types';\nimport { combineURLs, ContentTypeValues, HttpMethod } from '@ahoo-wang/fetcher';\nimport {\n type ResultExtractor,\n ResultExtractors,\n} from '@ahoo-wang/fetcher-decorator';\n\n/**\n * Interface for generic query API operations.\n * Provides methods for querying resources in different ways including single item retrieval,\n * list retrieval, streaming lists, paged retrieval, and counting.\n *\n * @see {@link EventStreamQueryApi}\n * @see {@link SnapshotQueryApi}\n * @template R - The type of resource being queried\n */\nexport interface QueryApi<R> {\n /**\n * Retrieves a single resource based on the provided query parameters.\n * @param singleQuery - The query parameters for retrieving a single resource\n * @returns A promise that resolves to a partial resource\n */\n single<T extends Partial<R> = Partial<R>>(\n singleQuery: SingleQuery,\n ): Promise<T>;\n\n /**\n * Retrieves a list of resources based on the provided query parameters.\n * @param listQuery - The query parameters for listing resources\n * @returns A promise that resolves to an array of partial resources\n */\n list<T extends Partial<R> = Partial<R>>(listQuery: ListQuery): Promise<T[]>;\n\n /**\n * Retrieves a stream of resources based on the provided query parameters.\n * @param listQuery - The query parameters for listing resources\n * @returns A promise that resolves to a readable stream of JSON server-sent events containing partial resources\n */\n listStream<T extends Partial<R> = Partial<R>>(\n listQuery: ListQuery,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>>;\n\n /**\n * Retrieves a paged list of resources based on the provided query parameters.\n * @param pagedQuery - The query parameters for paging resources\n * @returns A promise that resolves to a paged list of partial resources\n */\n paged<T extends Partial<R> = Partial<R>>(\n pagedQuery: PagedQuery,\n ): Promise<PagedList<T>>;\n\n /**\n * Counts the number of resources that match the given condition.\n * @param condition - The condition to filter resources\n * @returns A promise that resolves to the count of matching resources\n */\n count(condition: Condition): Promise<number>;\n}\n\n/**\n * Base client for performing query operations.\n * Provides a generic query method that handles the common logic for sending requests\n * and processing responses for different types of queries.\n *\n * @see {@link EventStreamQueryClient}\n * @see {@link SnapshotQueryClient}\n */\nexport class QueryClient {\n /**\n * Creates a new QueryClient instance.\n * @param options - The client configuration options including fetcher and base path\n */\n constructor(protected readonly options: ClientOptions) {\n }\n\n /**\n * Performs a generic query operation by sending a request to the specified path.\n * @template R The return type of the query\n * @param path - The endpoint path to query\n * @param query - The query parameters to send\n * @param accept - The content type to accept from the server, defaults to application/json\n * @param extractor - Function to extract the result from the response, defaults to JSON extractor\n * @returns A promise that resolves to the query result\n */\n protected async query<R>(\n path: string,\n query: Condition | ListQuery | PagedQuery | SingleQuery,\n accept: string = ContentTypeValues.APPLICATION_JSON,\n extractor: ResultExtractor = ResultExtractors.Json,\n ): Promise<R> {\n const url = combineURLs(this.options.basePath, path);\n const request = {\n url: url,\n method: HttpMethod.POST,\n headers: {\n Accept: accept,\n },\n body: query,\n };\n const exchange = await this.options.fetcher.request(request);\n return extractor(exchange);\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 {\n field: string;\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(field: string): FieldSort {\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(field: string): FieldSort {\n return {\n field,\n direction: SortDirection.DESC,\n };\n}\n\n/**\n * Interface for objects that support sorting.\n */\nexport interface SortCapable {\n sort?: FieldSort[];\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 Identifier,\n Named,\n OwnerId,\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\n extends Identifier,\n AggregateId,\n OwnerId,\n CommandId,\n CreateTimeCapable,\n RequestId,\n Version,\n BodyCapable<DomainEvent<any>[]> {\n /**\n * The header information for the domain event stream.\n */\n header: DomainEventStreamHeader;\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 extends Omit<QueryApi<DomainEventStream>, 'single'> {\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 type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport { QueryClient } from '../queryApi';\nimport type { ClientOptions } from '../../types';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport { ResultExtractors } 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 */\nexport class EventStreamQueryClient\n extends QueryClient\n implements EventStreamQueryApi {\n /**\n * Creates a new EventStreamQueryClient instance.\n * @param options - The client configuration options including fetcher and base path\n */\n constructor(options: ClientOptions) {\n super(options);\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 * @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 count(condition: Condition): Promise<number> {\n return this.query(EventStreamQueryEndpointPaths.COUNT, condition);\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 * @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 list<T extends Partial<DomainEventStream> = Partial<DomainEventStream>>(\n listQuery: ListQuery,\n ): Promise<T[]> {\n return this.query(EventStreamQueryEndpointPaths.LIST, listQuery);\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 * @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 listStream<T extends Partial<DomainEventStream> = Partial<DomainEventStream>>(\n listQuery: ListQuery,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n return this.query(\n EventStreamQueryEndpointPaths.LIST,\n listQuery,\n ContentTypeValues.TEXT_EVENT_STREAM,\n ResultExtractors.JsonEventStream,\n );\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 * @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 paged<T extends Partial<DomainEventStream> = Partial<DomainEventStream>>(\n pagedQuery: PagedQuery,\n ): Promise<PagedList<T>> {\n return this.query(EventStreamQueryEndpointPaths.PAGED, pagedQuery);\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 MaterializedSnapshot<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> extends QueryApi<MaterializedSnapshot<S>> {\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 * @returns A promise that resolves to a partial snapshot state\n */\n singleState<T extends Partial<S> = Partial<S>>(\n singleQuery: SingleQuery,\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 * @returns A promise that resolves to an array of partial snapshot states\n */\n listState<T extends Partial<S> = Partial<S>>(\n listQuery: ListQuery,\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 * @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> = Partial<S>>(\n listQuery: ListQuery,\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 * @returns A promise that resolves to a paged list of partial snapshot states\n */\n pagedState<T extends Partial<S> = Partial<S>>(\n pagedQuery: PagedQuery,\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 {\n type SnapshotQueryApi,\n SnapshotQueryEndpointPaths,\n} from './snapshotQueryApi';\nimport type { Condition } from '../condition';\nimport type {\n ListQuery,\n PagedList,\n PagedQuery,\n SingleQuery,\n} from '../queryable';\nimport type { MaterializedSnapshot } from './snapshot';\nimport type { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';\nimport { ContentTypeValues } from '@ahoo-wang/fetcher';\nimport { ResultExtractors } from '@ahoo-wang/fetcher-decorator';\nimport '@ahoo-wang/fetcher-eventstream';\nimport type { ClientOptions } from '../../types';\nimport { QueryClient } from '../queryApi';\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 */\nexport class SnapshotQueryClient<S>\n extends QueryClient\n implements SnapshotQueryApi<S> {\n /**\n * Creates a new SnapshotQueryClient instance.\n * @param options - The configuration options for the client\n */\n constructor(options: ClientOptions) {\n super(options);\n }\n\n /**\n * Counts the number of snapshots that match the given condition.\n *\n * @param condition - The condition to match snapshots against\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 async count(condition: Condition): Promise<number> {\n return this.query(SnapshotQueryEndpointPaths.COUNT, condition);\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 * @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 list<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(listQuery: ListQuery): Promise<T[]> {\n return this.query(SnapshotQueryEndpointPaths.LIST, listQuery);\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 * @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 listStream<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(listQuery: ListQuery): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n return this.query(\n SnapshotQueryEndpointPaths.LIST,\n listQuery,\n ContentTypeValues.TEXT_EVENT_STREAM,\n ResultExtractors.JsonEventStream,\n );\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 * @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 listState<T extends Partial<S> = Partial<S>>(\n listQuery: ListQuery,\n ): Promise<T[]> {\n return this.query(SnapshotQueryEndpointPaths.LIST_STATE, listQuery);\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 * @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 listStateStream<T extends Partial<S> = Partial<S>>(\n listQuery: ListQuery,\n ): Promise<ReadableStream<JsonServerSentEvent<T>>> {\n return this.query(\n SnapshotQueryEndpointPaths.LIST_STATE,\n listQuery,\n ContentTypeValues.TEXT_EVENT_STREAM,\n ResultExtractors.JsonEventStream,\n );\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 * @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 paged<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(pagedQuery: PagedQuery): Promise<PagedList<T>> {\n return this.query(SnapshotQueryEndpointPaths.PAGED, pagedQuery);\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 * @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 pagedState<T extends Partial<S> = Partial<S>>(\n pagedQuery: PagedQuery,\n ): Promise<PagedList<T>> {\n return this.query(SnapshotQueryEndpointPaths.PAGED_STATE, pagedQuery);\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 * @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 single<\n T extends Partial<MaterializedSnapshot<S>> = Partial<\n MaterializedSnapshot<S>\n >,\n >(singleQuery: SingleQuery): Promise<T> {\n return this.query(SnapshotQueryEndpointPaths.SINGLE, singleQuery);\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 * @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 singleState<T extends Partial<S> = Partial<S>>(\n singleQuery: SingleQuery,\n ): Promise<T> {\n return this.query(SnapshotQueryEndpointPaths.SINGLE_STATE, singleQuery);\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 * 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\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 {\n functionKind: FunctionKind;\n contextName: string;\n processorName: string;\n name: 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 { 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/**\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 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\nexport const DEFAULT_TENANT_ID = '(0)';\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"],"names":["CommandClient","options","path","commandHttpRequest","extractor","ResultExtractors","url","combineURLs","request","exchange","ContentTypeValues","_CommandHttpHeaders","CommandHttpHeaders","CommandStage","Operator","_ConditionOptionKey","ConditionOptionKey","ignoreCaseOptions","ignoreCase","dateOptions","datePattern","zoneId","DeletionState","and","conditions","all","andChildren","condition","or","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","projection","include","exclude","singleQuery","sort","listQuery","limit","pagedQuery","QueryClient","query","accept","HttpMethod","SortDirection","asc","desc","_DomainEventStreamMetadataFields","DomainEventStreamMetadataFields","_EventStreamQueryEndpointPaths","EventStreamQueryEndpointPaths","EventStreamQueryClient","_SnapshotMetadataFields","SnapshotMetadataFields","_SnapshotQueryEndpointPaths","SnapshotQueryEndpointPaths","SnapshotQueryClient","RecoverableType","_ErrorCodes","errorCode","ErrorCodes","FunctionKind","DEFAULT_OWNER_ID","DEFAULT_TENANT_ID"],"mappings":";;;AAmEO,MAAMA,EAAc;AAAA,EACzB,YAA+BC,GAAwB;AAAxB,SAAA,UAAAA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAgB,YACdC,GACAC,GACAC,IAA6BC,EAAiB,MAClC;AACZ,UAAMC,IAAMC,EAAY,KAAK,QAAQ,UAAUL,CAAI,GAC7CM,IAAU;AAAA,MACd,GAAGL;AAAA,MACH,KAAAG;AAAA,IAAA,GAEIG,IAAW,MAAM,KAAK,QAAQ,QAAQ,QAAQD,CAAO;AAC3D,WAAOJ,EAAUK,CAAQ;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,KACEP,GACAC,GACwB;AAC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