@ahoo-wang/wow-client 9.2.0-rc.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/LICENSE +201 -0
- package/README.md +291 -0
- package/README.zh-CN.md +267 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.es.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.es.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.es.js +8 -0
- package/dist/client/bindMethods.cjs +2 -0
- package/dist/client/bindMethods.cjs.map +1 -0
- package/dist/client/bindMethods.d.cts +13 -0
- package/dist/client/bindMethods.d.ts +13 -0
- package/dist/client/bindMethods.es.js +19 -0
- package/dist/client/bindMethods.es.js.map +1 -0
- package/dist/client/command/commandClient.cjs +2 -0
- package/dist/client/command/commandClient.cjs.map +1 -0
- package/dist/client/command/commandClient.d.cts +67 -0
- package/dist/client/command/commandClient.d.ts +67 -0
- package/dist/client/command/commandClient.es.js +38 -0
- package/dist/client/command/commandClient.es.js.map +1 -0
- package/dist/client/command/commandHeaders.cjs +2 -0
- package/dist/client/command/commandHeaders.cjs.map +1 -0
- package/dist/client/command/commandHeaders.d.cts +75 -0
- package/dist/client/command/commandHeaders.d.ts +75 -0
- package/dist/client/command/commandHeaders.es.js +31 -0
- package/dist/client/command/commandHeaders.es.js.map +1 -0
- package/dist/client/command/commandRequest.cjs +2 -0
- package/dist/client/command/commandRequest.cjs.map +1 -0
- package/dist/client/command/commandRequest.d.cts +180 -0
- package/dist/client/command/commandRequest.d.ts +180 -0
- package/dist/client/command/commandRequest.es.js +31 -0
- package/dist/client/command/commandRequest.es.js.map +1 -0
- package/dist/client/command/commandResult.d.cts +15 -0
- package/dist/client/command/commandResult.d.ts +15 -0
- package/dist/client/command/index.d.cts +5 -0
- package/dist/client/command/index.d.ts +5 -0
- package/dist/client/command/types.d.cts +71 -0
- package/dist/client/command/types.d.ts +71 -0
- package/dist/client/metadata/index.d.cts +2 -0
- package/dist/client/metadata/index.d.ts +2 -0
- package/dist/client/metadata/wowMetadata.d.cts +48 -0
- package/dist/client/metadata/wowMetadata.d.ts +48 -0
- package/dist/client/metadata/wowMetadataClient.cjs +2 -0
- package/dist/client/metadata/wowMetadataClient.cjs.map +1 -0
- package/dist/client/metadata/wowMetadataClient.d.cts +23 -0
- package/dist/client/metadata/wowMetadataClient.d.ts +23 -0
- package/dist/client/metadata/wowMetadataClient.es.js +25 -0
- package/dist/client/metadata/wowMetadataClient.es.js.map +1 -0
- package/dist/client/query/descriptor/descriptorEndpoints.cjs +2 -0
- package/dist/client/query/descriptor/descriptorEndpoints.cjs.map +1 -0
- package/dist/client/query/descriptor/descriptorEndpoints.d.cts +29 -0
- package/dist/client/query/descriptor/descriptorEndpoints.d.ts +29 -0
- package/dist/client/query/descriptor/descriptorEndpoints.es.js +69 -0
- package/dist/client/query/descriptor/descriptorEndpoints.es.js.map +1 -0
- package/dist/client/query/descriptor/endpointPaths.cjs +2 -0
- package/dist/client/query/descriptor/endpointPaths.cjs.map +1 -0
- package/dist/client/query/descriptor/endpointPaths.d.cts +4 -0
- package/dist/client/query/descriptor/endpointPaths.d.ts +4 -0
- package/dist/client/query/descriptor/endpointPaths.es.js +9 -0
- package/dist/client/query/descriptor/endpointPaths.es.js.map +1 -0
- package/dist/client/query/descriptor/index.d.cts +2 -0
- package/dist/client/query/descriptor/index.d.ts +2 -0
- package/dist/client/query/descriptor/queryDescriptorApi.d.cts +58 -0
- package/dist/client/query/descriptor/queryDescriptorApi.d.ts +58 -0
- package/dist/client/query/descriptor/queryDescriptorClient.cjs +2 -0
- package/dist/client/query/descriptor/queryDescriptorClient.cjs.map +1 -0
- package/dist/client/query/descriptor/queryDescriptorClient.d.cts +61 -0
- package/dist/client/query/descriptor/queryDescriptorClient.d.ts +61 -0
- package/dist/client/query/descriptor/queryDescriptorClient.es.js +20 -0
- package/dist/client/query/descriptor/queryDescriptorClient.es.js.map +1 -0
- package/dist/client/query/event/domainEventStream.cjs +2 -0
- package/dist/client/query/event/domainEventStream.cjs.map +1 -0
- package/dist/client/query/event/domainEventStream.d.cts +105 -0
- package/dist/client/query/event/domainEventStream.d.ts +105 -0
- package/dist/client/query/event/domainEventStream.es.js +23 -0
- package/dist/client/query/event/domainEventStream.es.js.map +1 -0
- package/dist/client/query/event/endpointPaths.cjs +2 -0
- package/dist/client/query/event/endpointPaths.cjs.map +1 -0
- package/dist/client/query/event/endpointPaths.d.cts +8 -0
- package/dist/client/query/event/endpointPaths.d.ts +8 -0
- package/dist/client/query/event/endpointPaths.es.js +13 -0
- package/dist/client/query/event/endpointPaths.es.js.map +1 -0
- package/dist/client/query/event/eventStreamQueryApi.d.cts +29 -0
- package/dist/client/query/event/eventStreamQueryApi.d.ts +29 -0
- package/dist/client/query/event/eventStreamQueryClient.cjs +2 -0
- package/dist/client/query/event/eventStreamQueryClient.cjs.map +1 -0
- package/dist/client/query/event/eventStreamQueryClient.d.cts +190 -0
- package/dist/client/query/event/eventStreamQueryClient.d.ts +190 -0
- package/dist/client/query/event/eventStreamQueryClient.es.js +160 -0
- package/dist/client/query/event/eventStreamQueryClient.es.js.map +1 -0
- package/dist/client/query/event/index.d.cts +3 -0
- package/dist/client/query/event/index.d.ts +3 -0
- package/dist/client/query/factory.cjs +2 -0
- package/dist/client/query/factory.cjs.map +1 -0
- package/dist/client/query/factory.d.cts +165 -0
- package/dist/client/query/factory.d.ts +165 -0
- package/dist/client/query/factory.es.js +45 -0
- package/dist/client/query/factory.es.js.map +1 -0
- package/dist/client/query/index.d.cts +6 -0
- package/dist/client/query/index.d.ts +6 -0
- package/dist/client/query/queryApi.d.cts +68 -0
- package/dist/client/query/queryApi.d.ts +68 -0
- package/dist/client/query/requests.d.cts +24 -0
- package/dist/client/query/requests.d.ts +24 -0
- package/dist/client/query/snapshot/endpointPaths.cjs +2 -0
- package/dist/client/query/snapshot/endpointPaths.cjs.map +1 -0
- package/dist/client/query/snapshot/endpointPaths.d.cts +12 -0
- package/dist/client/query/snapshot/endpointPaths.d.ts +12 -0
- package/dist/client/query/snapshot/endpointPaths.es.js +17 -0
- package/dist/client/query/snapshot/endpointPaths.es.js.map +1 -0
- package/dist/client/query/snapshot/index.d.cts +3 -0
- package/dist/client/query/snapshot/index.d.ts +3 -0
- package/dist/client/query/snapshot/snapshot.cjs +2 -0
- package/dist/client/query/snapshot/snapshot.cjs.map +1 -0
- package/dist/client/query/snapshot/snapshot.d.cts +51 -0
- package/dist/client/query/snapshot/snapshot.d.ts +51 -0
- package/dist/client/query/snapshot/snapshot.es.js +20 -0
- package/dist/client/query/snapshot/snapshot.es.js.map +1 -0
- package/dist/client/query/snapshot/snapshotQueryApi.d.cts +101 -0
- package/dist/client/query/snapshot/snapshotQueryApi.d.ts +101 -0
- package/dist/client/query/snapshot/snapshotQueryClient.cjs +2 -0
- package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +1 -0
- package/dist/client/query/snapshot/snapshotQueryClient.d.cts +369 -0
- package/dist/client/query/snapshot/snapshotQueryClient.d.ts +369 -0
- package/dist/client/query/snapshot/snapshotQueryClient.es.js +239 -0
- package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +1 -0
- package/dist/client/query/state/endpointPaths.cjs +2 -0
- package/dist/client/query/state/endpointPaths.cjs.map +1 -0
- package/dist/client/query/state/endpointPaths.d.cts +10 -0
- package/dist/client/query/state/endpointPaths.d.ts +10 -0
- package/dist/client/query/state/endpointPaths.es.js +14 -0
- package/dist/client/query/state/endpointPaths.es.js.map +1 -0
- package/dist/client/query/state/index.d.cts +4 -0
- package/dist/client/query/state/index.d.ts +4 -0
- package/dist/client/query/state/loadOwnerStateAggregateApi.d.cts +36 -0
- package/dist/client/query/state/loadOwnerStateAggregateApi.d.ts +36 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +2 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs.map +1 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.d.cts +58 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.d.ts +58 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +56 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js.map +1 -0
- package/dist/client/query/state/loadStateAggregateApi.d.cts +37 -0
- package/dist/client/query/state/loadStateAggregateApi.d.ts +37 -0
- package/dist/client/query/state/loadStateAggregateClient.cjs +2 -0
- package/dist/client/query/state/loadStateAggregateClient.cjs.map +1 -0
- package/dist/client/query/state/loadStateAggregateClient.d.cts +62 -0
- package/dist/client/query/state/loadStateAggregateClient.d.ts +62 -0
- package/dist/client/query/state/loadStateAggregateClient.es.js +65 -0
- package/dist/client/query/state/loadStateAggregateClient.es.js.map +1 -0
- package/dist/client/routing.cjs +2 -0
- package/dist/client/routing.cjs.map +1 -0
- package/dist/client/routing.d.cts +47 -0
- package/dist/client/routing.d.ts +47 -0
- package/dist/client/routing.es.js +8 -0
- package/dist/client/routing.es.js.map +1 -0
- package/dist/dsl/aggregation/admit.cjs +2 -0
- package/dist/dsl/aggregation/admit.cjs.map +1 -0
- package/dist/dsl/aggregation/admit.d.cts +6 -0
- package/dist/dsl/aggregation/admit.d.ts +6 -0
- package/dist/dsl/aggregation/admit.es.js +142 -0
- package/dist/dsl/aggregation/admit.es.js.map +1 -0
- package/dist/dsl/aggregation/builders.cjs +2 -0
- package/dist/dsl/aggregation/builders.cjs.map +1 -0
- package/dist/dsl/aggregation/builders.d.cts +309 -0
- package/dist/dsl/aggregation/builders.d.ts +309 -0
- package/dist/dsl/aggregation/builders.es.js +188 -0
- package/dist/dsl/aggregation/builders.es.js.map +1 -0
- package/dist/dsl/aggregation/derived.cjs +2 -0
- package/dist/dsl/aggregation/derived.cjs.map +1 -0
- package/dist/dsl/aggregation/derived.d.cts +33 -0
- package/dist/dsl/aggregation/derived.d.ts +33 -0
- package/dist/dsl/aggregation/derived.es.js +31 -0
- package/dist/dsl/aggregation/derived.es.js.map +1 -0
- package/dist/dsl/aggregation/expressionTrees.cjs +2 -0
- package/dist/dsl/aggregation/expressionTrees.cjs.map +1 -0
- package/dist/dsl/aggregation/expressionTrees.d.cts +10 -0
- package/dist/dsl/aggregation/expressionTrees.d.ts +10 -0
- package/dist/dsl/aggregation/expressionTrees.es.js +44 -0
- package/dist/dsl/aggregation/expressionTrees.es.js.map +1 -0
- package/dist/dsl/aggregation/having.cjs +2 -0
- package/dist/dsl/aggregation/having.cjs.map +1 -0
- package/dist/dsl/aggregation/having.d.cts +94 -0
- package/dist/dsl/aggregation/having.d.ts +94 -0
- package/dist/dsl/aggregation/having.es.js +62 -0
- package/dist/dsl/aggregation/having.es.js.map +1 -0
- package/dist/dsl/aggregation/index.d.cts +4 -0
- package/dist/dsl/aggregation/index.d.ts +4 -0
- package/dist/dsl/aggregation/sort.cjs +2 -0
- package/dist/dsl/aggregation/sort.cjs.map +1 -0
- package/dist/dsl/aggregation/sort.d.cts +7 -0
- package/dist/dsl/aggregation/sort.d.ts +7 -0
- package/dist/dsl/aggregation/sort.es.js +10 -0
- package/dist/dsl/aggregation/sort.es.js.map +1 -0
- package/dist/dsl/aggregation/types.cjs +2 -0
- package/dist/dsl/aggregation/types.cjs.map +1 -0
- package/dist/dsl/aggregation/types.d.cts +608 -0
- package/dist/dsl/aggregation/types.d.ts +608 -0
- package/dist/dsl/aggregation/types.es.js +37 -0
- package/dist/dsl/aggregation/types.es.js.map +1 -0
- package/dist/dsl/cursorQuery.cjs +2 -0
- package/dist/dsl/cursorQuery.cjs.map +1 -0
- package/dist/dsl/cursorQuery.d.cts +69 -0
- package/dist/dsl/cursorQuery.d.ts +69 -0
- package/dist/dsl/cursorQuery.es.js +19 -0
- package/dist/dsl/cursorQuery.es.js.map +1 -0
- package/dist/dsl/deletionState.cjs +2 -0
- package/dist/dsl/deletionState.cjs.map +1 -0
- package/dist/dsl/deletionState.d.cts +19 -0
- package/dist/dsl/deletionState.d.ts +19 -0
- package/dist/dsl/deletionState.es.js +8 -0
- package/dist/dsl/deletionState.es.js.map +1 -0
- package/dist/dsl/descriptor.cjs +2 -0
- package/dist/dsl/descriptor.cjs.map +1 -0
- package/dist/dsl/descriptor.d.cts +629 -0
- package/dist/dsl/descriptor.d.ts +629 -0
- package/dist/dsl/descriptor.es.js +37 -0
- package/dist/dsl/descriptor.es.js.map +1 -0
- package/dist/dsl/documents.d.cts +8 -0
- package/dist/dsl/documents.d.ts +8 -0
- package/dist/dsl/field.cjs +2 -0
- package/dist/dsl/field.cjs.map +1 -0
- package/dist/dsl/field.d.cts +2 -0
- package/dist/dsl/field.d.ts +2 -0
- package/dist/dsl/field.es.js +10 -0
- package/dist/dsl/field.es.js.map +1 -0
- package/dist/dsl/filter/builders.cjs +2 -0
- package/dist/dsl/filter/builders.cjs.map +1 -0
- package/dist/dsl/filter/builders.d.cts +962 -0
- package/dist/dsl/filter/builders.d.ts +962 -0
- package/dist/dsl/filter/builders.es.js +289 -0
- package/dist/dsl/filter/builders.es.js.map +1 -0
- package/dist/dsl/filter/datePattern.cjs +2 -0
- package/dist/dsl/filter/datePattern.cjs.map +1 -0
- package/dist/dsl/filter/datePattern.d.cts +8 -0
- package/dist/dsl/filter/datePattern.d.ts +8 -0
- package/dist/dsl/filter/datePattern.es.js +100 -0
- package/dist/dsl/filter/datePattern.es.js.map +1 -0
- package/dist/dsl/filter/index.d.cts +3 -0
- package/dist/dsl/filter/index.d.ts +3 -0
- package/dist/dsl/filter/operator.cjs +2 -0
- package/dist/dsl/filter/operator.cjs.map +1 -0
- package/dist/dsl/filter/operator.d.cts +113 -0
- package/dist/dsl/filter/operator.d.ts +113 -0
- package/dist/dsl/filter/operator.es.js +14 -0
- package/dist/dsl/filter/operator.es.js.map +1 -0
- package/dist/dsl/filter/scope.cjs +2 -0
- package/dist/dsl/filter/scope.cjs.map +1 -0
- package/dist/dsl/filter/scope.d.cts +15 -0
- package/dist/dsl/filter/scope.d.ts +15 -0
- package/dist/dsl/filter/scope.es.js +32 -0
- package/dist/dsl/filter/scope.es.js.map +1 -0
- package/dist/dsl/filter/types.d.cts +274 -0
- package/dist/dsl/filter/types.d.ts +274 -0
- package/dist/dsl/filter/validate.cjs +2 -0
- package/dist/dsl/filter/validate.cjs.map +1 -0
- package/dist/dsl/filter/validate.d.cts +18 -0
- package/dist/dsl/filter/validate.d.ts +18 -0
- package/dist/dsl/filter/validate.es.js +56 -0
- package/dist/dsl/filter/validate.es.js.map +1 -0
- package/dist/dsl/pagination.cjs +2 -0
- package/dist/dsl/pagination.cjs.map +1 -0
- package/dist/dsl/pagination.d.cts +28 -0
- package/dist/dsl/pagination.d.ts +28 -0
- package/dist/dsl/pagination.es.js +15 -0
- package/dist/dsl/pagination.es.js.map +1 -0
- package/dist/dsl/projection.cjs +2 -0
- package/dist/dsl/projection.cjs.map +1 -0
- package/dist/dsl/projection.d.cts +27 -0
- package/dist/dsl/projection.d.ts +27 -0
- package/dist/dsl/projection.es.js +12 -0
- package/dist/dsl/projection.es.js.map +1 -0
- package/dist/dsl/queryable.cjs +2 -0
- package/dist/dsl/queryable.cjs.map +1 -0
- package/dist/dsl/queryable.d.cts +101 -0
- package/dist/dsl/queryable.d.ts +101 -0
- package/dist/dsl/queryable.es.js +40 -0
- package/dist/dsl/queryable.es.js.map +1 -0
- package/dist/dsl/sort.cjs +2 -0
- package/dist/dsl/sort.cjs.map +1 -0
- package/dist/dsl/sort.d.cts +33 -0
- package/dist/dsl/sort.d.ts +33 -0
- package/dist/dsl/sort.es.js +21 -0
- package/dist/dsl/sort.es.js.map +1 -0
- package/dist/dsl.cjs +1 -0
- package/dist/dsl.d.cts +23 -0
- package/dist/dsl.d.ts +23 -0
- package/dist/dsl.es.js +14 -0
- package/dist/error/errorInfo.cjs +2 -0
- package/dist/error/errorInfo.cjs.map +1 -0
- package/dist/error/errorInfo.d.cts +139 -0
- package/dist/error/errorInfo.d.ts +139 -0
- package/dist/error/errorInfo.es.js +32 -0
- package/dist/error/errorInfo.es.js.map +1 -0
- package/dist/error/headers.cjs +2 -0
- package/dist/error/headers.cjs.map +1 -0
- package/dist/error/headers.d.cts +38 -0
- package/dist/error/headers.d.ts +38 -0
- package/dist/error/headers.es.js +10 -0
- package/dist/error/headers.es.js.map +1 -0
- package/dist/error/index.d.cts +21 -0
- package/dist/error/index.d.ts +21 -0
- package/dist/error/queryErrorCodes.cjs +2 -0
- package/dist/error/queryErrorCodes.cjs.map +1 -0
- package/dist/error/queryErrorCodes.d.cts +199 -0
- package/dist/error/queryErrorCodes.d.ts +199 -0
- package/dist/error/queryErrorCodes.es.js +53 -0
- package/dist/error/queryErrorCodes.es.js.map +1 -0
- package/dist/error/wowError.cjs +2 -0
- package/dist/error/wowError.cjs.map +1 -0
- package/dist/error/wowError.d.cts +99 -0
- package/dist/error/wowError.d.ts +99 -0
- package/dist/error/wowError.es.js +53 -0
- package/dist/error/wowError.es.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.es.js +34 -0
- package/dist/legacy/condition.cjs +2 -0
- package/dist/legacy/condition.cjs.map +1 -0
- package/dist/legacy/condition.d.cts +517 -0
- package/dist/legacy/condition.d.ts +517 -0
- package/dist/legacy/condition.es.js +338 -0
- package/dist/legacy/condition.es.js.map +1 -0
- package/dist/legacy/index.d.cts +16 -0
- package/dist/legacy/index.d.ts +16 -0
- package/dist/legacy/locale/en_US.cjs +2 -0
- package/dist/legacy/locale/en_US.cjs.map +1 -0
- package/dist/legacy/locale/en_US.d.cts +7 -0
- package/dist/legacy/locale/en_US.d.ts +7 -0
- package/dist/legacy/locale/en_US.es.js +50 -0
- package/dist/legacy/locale/en_US.es.js.map +1 -0
- package/dist/legacy/locale/operatorLocale.d.cts +10 -0
- package/dist/legacy/locale/operatorLocale.d.ts +10 -0
- package/dist/legacy/locale/zh_CN.cjs +2 -0
- package/dist/legacy/locale/zh_CN.cjs.map +1 -0
- package/dist/legacy/locale/zh_CN.d.cts +7 -0
- package/dist/legacy/locale/zh_CN.d.ts +7 -0
- package/dist/legacy/locale/zh_CN.es.js +50 -0
- package/dist/legacy/locale/zh_CN.es.js.map +1 -0
- package/dist/legacy/operator.cjs +2 -0
- package/dist/legacy/operator.cjs.map +1 -0
- package/dist/legacy/operator.d.cts +218 -0
- package/dist/legacy/operator.d.ts +218 -0
- package/dist/legacy/operator.es.js +25 -0
- package/dist/legacy/operator.es.js.map +1 -0
- package/dist/legacy/queryable.cjs +2 -0
- package/dist/legacy/queryable.cjs.map +1 -0
- package/dist/legacy/queryable.d.cts +61 -0
- package/dist/legacy/queryable.d.ts +61 -0
- package/dist/legacy/queryable.es.js +34 -0
- package/dist/legacy/queryable.es.js.map +1 -0
- package/dist/legacy.cjs +1 -0
- package/dist/legacy.es.js +6 -0
- package/dist/model/abac.cjs +2 -0
- package/dist/model/abac.cjs.map +1 -0
- package/dist/model/abac.d.cts +33 -0
- package/dist/model/abac.d.ts +33 -0
- package/dist/model/abac.es.js +6 -0
- package/dist/model/abac.es.js.map +1 -0
- package/dist/model/bi.cjs +2 -0
- package/dist/model/bi.cjs.map +1 -0
- package/dist/model/bi.d.cts +12 -0
- package/dist/model/bi.d.ts +12 -0
- package/dist/model/bi.es.js +8 -0
- package/dist/model/bi.es.js.map +1 -0
- package/dist/model/command.cjs +2 -0
- package/dist/model/command.cjs.map +1 -0
- package/dist/model/command.d.cts +137 -0
- package/dist/model/command.d.ts +137 -0
- package/dist/model/command.es.js +8 -0
- package/dist/model/command.es.js.map +1 -0
- package/dist/model/common.d.cts +19 -0
- package/dist/model/common.d.ts +19 -0
- package/dist/model/function.cjs +2 -0
- package/dist/model/function.cjs.map +1 -0
- package/dist/model/function.d.cts +41 -0
- package/dist/model/function.d.ts +41 -0
- package/dist/model/function.es.js +8 -0
- package/dist/model/function.es.js.map +1 -0
- package/dist/model/index.d.cts +22 -0
- package/dist/model/index.d.ts +22 -0
- package/dist/model/messaging.d.cts +5 -0
- package/dist/model/messaging.d.ts +5 -0
- package/dist/model/modeling.d.cts +145 -0
- package/dist/model/modeling.d.ts +145 -0
- package/dist/model/naming.d.cts +27 -0
- package/dist/model/naming.d.ts +27 -0
- package/dist/transport/endpoints.cjs +2 -0
- package/dist/transport/endpoints.cjs.map +1 -0
- package/dist/transport/endpoints.d.cts +79 -0
- package/dist/transport/endpoints.d.ts +79 -0
- package/dist/transport/endpoints.es.js +14 -0
- package/dist/transport/endpoints.es.js.map +1 -0
- package/dist/transport/eventStreams.cjs +2 -0
- package/dist/transport/eventStreams.cjs.map +1 -0
- package/dist/transport/eventStreams.d.cts +23 -0
- package/dist/transport/eventStreams.d.ts +23 -0
- package/dist/transport/eventStreams.es.js +22 -0
- package/dist/transport/eventStreams.es.js.map +1 -0
- package/dist/transport/index.d.cts +1 -0
- package/dist/transport/index.d.ts +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { bindMethods as e } from "../../bindMethods.es.js";
|
|
2
|
+
import t from "../../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.es.js";
|
|
3
|
+
import n from "../../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.es.js";
|
|
4
|
+
import r from "../../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.es.js";
|
|
5
|
+
import { LoadStateAggregateEndpointPaths as i } from "./endpointPaths.es.js";
|
|
6
|
+
import { api as a, attribute as o, autoGeneratedError as s, get as c, path as l } from "@ahoo-wang/fetcher-decorator";
|
|
7
|
+
//#region src/client/query/state/loadStateAggregateClient.ts
|
|
8
|
+
var u = class {
|
|
9
|
+
constructor(t) {
|
|
10
|
+
this.apiMetadata = t, e(this);
|
|
11
|
+
}
|
|
12
|
+
load(e, t, n) {
|
|
13
|
+
throw s(e, t, n);
|
|
14
|
+
}
|
|
15
|
+
/* v8 ignore stop */
|
|
16
|
+
loadVersioned(e, t, n, r) {
|
|
17
|
+
throw s(e, t, n, r);
|
|
18
|
+
}
|
|
19
|
+
/* v8 ignore stop */
|
|
20
|
+
loadTimeBased(e, t, n, r) {
|
|
21
|
+
throw s(e, t, n, r);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
r([
|
|
25
|
+
c(i.LOAD),
|
|
26
|
+
n(0, l("id")),
|
|
27
|
+
n(1, o()),
|
|
28
|
+
t("design:type", Function),
|
|
29
|
+
t("design:paramtypes", [
|
|
30
|
+
String,
|
|
31
|
+
typeof Record > "u" ? Object : Record,
|
|
32
|
+
Object
|
|
33
|
+
]),
|
|
34
|
+
t("design:returntype", typeof Promise > "u" ? Object : Promise)
|
|
35
|
+
], u.prototype, "load", null), r([
|
|
36
|
+
c(i.LOAD_VERSIONED),
|
|
37
|
+
n(0, l("id")),
|
|
38
|
+
n(1, l("version")),
|
|
39
|
+
n(2, o()),
|
|
40
|
+
t("design:type", Function),
|
|
41
|
+
t("design:paramtypes", [
|
|
42
|
+
String,
|
|
43
|
+
Number,
|
|
44
|
+
typeof Record > "u" ? Object : Record,
|
|
45
|
+
Object
|
|
46
|
+
]),
|
|
47
|
+
t("design:returntype", typeof Promise > "u" ? Object : Promise)
|
|
48
|
+
], u.prototype, "loadVersioned", null), r([
|
|
49
|
+
c(i.LOAD_TIME_BASED),
|
|
50
|
+
n(0, l("id")),
|
|
51
|
+
n(1, l("createTime")),
|
|
52
|
+
n(2, o()),
|
|
53
|
+
t("design:type", Function),
|
|
54
|
+
t("design:paramtypes", [
|
|
55
|
+
String,
|
|
56
|
+
Number,
|
|
57
|
+
typeof Record > "u" ? Object : Record,
|
|
58
|
+
Object
|
|
59
|
+
]),
|
|
60
|
+
t("design:returntype", typeof Promise > "u" ? Object : Promise)
|
|
61
|
+
], u.prototype, "loadTimeBased", null), u = r([a(), t("design:paramtypes", [Object])], u);
|
|
62
|
+
//#endregion
|
|
63
|
+
export { u as LoadStateAggregateClient };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=loadStateAggregateClient.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadStateAggregateClient.es.js","names":["_decorate","_decorateParam","_decorateMetadata","__decorateMetadata","__decorateParam","__decorate","LoadStateAggregateClient","apiMetadata","bindMethods","autoGeneratedError","id","attributes","abort","version","createTime","get","LoadStateAggregateEndpointPaths","path","attribute","api"],"sources":["../../../../src/client/query/state/loadStateAggregateClient.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 {\n ApiMetadata,\n ApiMetadataCapable,\n} from '@ahoo-wang/fetcher-decorator';\nimport type { LoadStateAggregateApi } from './loadStateAggregateApi.js';\nimport {\n api,\n attribute,\n autoGeneratedError,\n get,\n path,\n} from '@ahoo-wang/fetcher-decorator';\nimport { LoadStateAggregateEndpointPaths } from './endpointPaths.js';\nimport { bindMethods } from '../../bindMethods.js';\n\n/**\n * Loads the state of an aggregate by its ID, as the server's aggregate\n * repository loads it: the latest snapshot and the events after it, so the\n * state is current even when snapshots lag. `GET {basePath}/{id}/state` for\n * the current state, or the state at a version or a point in time. An\n * aggregate that does not exist or is deleted answers 404. It takes no\n * filter; to search, use a `SnapshotQueryClient`. Create it with\n * `QueryClientFactory.createLoadStateAggregateClient`, or with the\n * `ApiMetadata` of the aggregate's base path.\n *\n * @template S - The type of the aggregate state\n *\n * @example\n * ```typescript\n * const orders = new LoadStateAggregateClient<{ status: string }>({\n * basePath: 'order',\n * });\n * const order = await orders.load('order-1');\n * const third = await orders.loadVersioned('order-1', 3);\n * ```\n */\n@api()\nexport class LoadStateAggregateClient<S>\n implements LoadStateAggregateApi<S>, ApiMetadataCapable\n{\n constructor(public readonly apiMetadata?: ApiMetadata) {\n bindMethods(this);\n }\n\n /**\n * Loads the current state of the aggregate by its ID.\n *\n * @param id - The unique identifier of the aggregate to load\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @param abort - Cancels the request: an `AbortController`, or an `AbortSignal` such as `AbortSignal.timeout(ms)` or the `signal` a data-fetching library passes.\n * @returns A promise that resolves to the current state of the aggregate\n */\n @get(LoadStateAggregateEndpointPaths.LOAD)\n /* v8 ignore start */\n load(\n @path('id') id: string,\n @attribute() attributes?: Record<string, unknown>,\n abort?: AbortController | AbortSignal,\n ): Promise<S> {\n throw autoGeneratedError(id, attributes, abort);\n }\n /* v8 ignore stop */\n\n /**\n * Loads the state of the aggregate at a specific version by its ID.\n *\n * @param id - The unique identifier of the aggregate to load\n * @param version - The version number of the aggregate state to load\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @param abort - Cancels the request: an `AbortController`, or an `AbortSignal` such as `AbortSignal.timeout(ms)` or the `signal` a data-fetching library passes.\n * @returns A promise that resolves to the state of the aggregate at the specified version\n */\n @get(LoadStateAggregateEndpointPaths.LOAD_VERSIONED)\n /* v8 ignore start */\n loadVersioned(\n @path('id') id: string,\n @path('version') version: number,\n @attribute() attributes?: Record<string, unknown>,\n abort?: AbortController | AbortSignal,\n ): Promise<S> {\n throw autoGeneratedError(id, version, attributes, abort);\n }\n /* v8 ignore stop */\n\n /**\n * Loads the state of the aggregate at a specific point in time by its ID.\n *\n * @param id - The unique identifier of the aggregate to load\n * @param createTime - The creation timestamp to load the aggregate state for\n * @param attributes - Optional shared attributes that can be accessed by interceptors\n * throughout the request lifecycle. These attributes allow passing\n * custom data between different interceptors.\n * @param abort - Cancels the request: an `AbortController`, or an `AbortSignal` such as `AbortSignal.timeout(ms)` or the `signal` a data-fetching library passes.\n * @returns A promise that resolves to the state of the aggregate at the specified time\n */\n @get(LoadStateAggregateEndpointPaths.LOAD_TIME_BASED)\n /* v8 ignore start */\n loadTimeBased(\n @path('id') id: string,\n @path('createTime') createTime: number,\n @attribute() attributes?: Record<string, unknown>,\n abort?: AbortController | AbortSignal,\n ): Promise<S> {\n throw autoGeneratedError(id, createTime, attributes, abort);\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;AAkDO,IAAMM,IAAN,MAEP;CACE,YAAY,GAA2C;EACrD,AAD0B,KAAA,cAAAC,GAC1BC,EAAY,IAAI;CAClB;CAYA,KAGE,GACA,GACA,GACY;EACZ,MAAMC,EAAmBC,GAAIC,GAAYC,CAAK;CAChD;;CAcA,cAGE,GACA,GACA,GACA,GACY;EACZ,MAAMH,EAAmBC,GAAIG,GAASF,GAAYC,CAAK;CACzD;;CAcA,cAGE,GACA,GACA,GACA,GACY;EACZ,MAAMH,EAAmBC,GAAII,GAAYH,GAAYC,CAAK;CAC5D;AAEF;;CAxDGG,EAAIC,EAAgC,IAAI;CAGtCf,EAAA,GAAAgB,EAAK,IAAI,CAAA;CACThB,EAAA,GAAAiB,EAAU,CAAA;;;;;;;;;CAkBZH,EAAIC,EAAgC,cAAc;CAGhDf,EAAA,GAAAgB,EAAK,IAAI,CAAA;CACThB,EAAA,GAAAgB,EAAK,SAAS,CAAA;CACdhB,EAAA,GAAAiB,EAAU,CAAA;;;;;;;;;;CAkBZH,EAAIC,EAAgC,eAAe;CAGjDf,EAAA,GAAAgB,EAAK,IAAI,CAAA;CACThB,EAAA,GAAAgB,EAAK,YAAY,CAAA;CACjBhB,EAAA,GAAAiB,EAAU,CAAA;;;;;;;;;wCApEd,IAAAlB,EAAA,CAAAmB,EAAI,GAAAjB,EAAA,qBAAA,CAAA,MAAA,CAAA,CAAA,GAAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.cjs","names":["ResourceAttributionPathSpec","\"NONE\"","\"TENANT\"","\"OWNER\"","\"TENANT_OWNER\""],"sources":["../../src/client/routing.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\n/**\n * Interface for path parameters used in URL construction.\n * Defines common path parameters and allows for additional custom parameters.\n * This interface is used to provide path variables for URL templating.\n */\nexport interface UrlPathParams {\n /**\n * Tenant identifier parameter.\n * Used in multi-tenant applications to identify the tenant context.\n */\n tenantId?: string;\n /**\n * Owner identifier parameter.\n * Used to identify the owner or user context for the resource.\n */\n ownerId?: string;\n /**\n * Generic identifier parameter.\n * Used as a general purpose ID for resources when tenantId or ownerId are not appropriate.\n */\n id?: string;\n\n /**\n * Index signature for additional custom path parameters.\n * Allows for any additional string key-value pairs to be included as path parameters.\n */\n [key: string]: string | undefined;\n}\n\n/**\n * Enumeration of resource attribution path specifications.\n * Defines standard path patterns for accessing resources with different attribution scopes.\n * These paths are used to construct URLs that include tenant and/or owner identifiers.\n *\n * @example\n * ```typescript\n * // Using TENANT path spec\n * const path = ResourceAttributionPathSpec.TENANT; // '/tenant/{tenantId}'\n *\n * // Using TENANT_OWNER path spec\n * const path = ResourceAttributionPathSpec.TENANT_OWNER; // '/tenant/{tenantId}/owner/{ownerId}'\n * ```\n */\nexport enum ResourceAttributionPathSpec {\n NONE = '',\n TENANT = '/tenant/{tenantId}',\n OWNER = '/owner/{ownerId}',\n TENANT_OWNER = '/tenant/{tenantId}/owner/{ownerId}',\n}\n"],"mappings":"AAwDA,IAAYA,EAAL,SAAA,EAAA,OACL,GAAAC,KAAA,GACA,EAAAC,OAAA,qBACA,EAAAC,MAAA,mBACA,EAAAC,aAAA,sCACF,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for path parameters used in URL construction.
|
|
3
|
+
* Defines common path parameters and allows for additional custom parameters.
|
|
4
|
+
* This interface is used to provide path variables for URL templating.
|
|
5
|
+
*/
|
|
6
|
+
export interface UrlPathParams {
|
|
7
|
+
/**
|
|
8
|
+
* Tenant identifier parameter.
|
|
9
|
+
* Used in multi-tenant applications to identify the tenant context.
|
|
10
|
+
*/
|
|
11
|
+
tenantId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Owner identifier parameter.
|
|
14
|
+
* Used to identify the owner or user context for the resource.
|
|
15
|
+
*/
|
|
16
|
+
ownerId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Generic identifier parameter.
|
|
19
|
+
* Used as a general purpose ID for resources when tenantId or ownerId are not appropriate.
|
|
20
|
+
*/
|
|
21
|
+
id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Index signature for additional custom path parameters.
|
|
24
|
+
* Allows for any additional string key-value pairs to be included as path parameters.
|
|
25
|
+
*/
|
|
26
|
+
[key: string]: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enumeration of resource attribution path specifications.
|
|
30
|
+
* Defines standard path patterns for accessing resources with different attribution scopes.
|
|
31
|
+
* These paths are used to construct URLs that include tenant and/or owner identifiers.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Using TENANT path spec
|
|
36
|
+
* const path = ResourceAttributionPathSpec.TENANT; // '/tenant/{tenantId}'
|
|
37
|
+
*
|
|
38
|
+
* // Using TENANT_OWNER path spec
|
|
39
|
+
* const path = ResourceAttributionPathSpec.TENANT_OWNER; // '/tenant/{tenantId}/owner/{ownerId}'
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare enum ResourceAttributionPathSpec {
|
|
43
|
+
NONE = "",
|
|
44
|
+
TENANT = "/tenant/{tenantId}",
|
|
45
|
+
OWNER = "/owner/{ownerId}",
|
|
46
|
+
TENANT_OWNER = "/tenant/{tenantId}/owner/{ownerId}"
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for path parameters used in URL construction.
|
|
3
|
+
* Defines common path parameters and allows for additional custom parameters.
|
|
4
|
+
* This interface is used to provide path variables for URL templating.
|
|
5
|
+
*/
|
|
6
|
+
export interface UrlPathParams {
|
|
7
|
+
/**
|
|
8
|
+
* Tenant identifier parameter.
|
|
9
|
+
* Used in multi-tenant applications to identify the tenant context.
|
|
10
|
+
*/
|
|
11
|
+
tenantId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Owner identifier parameter.
|
|
14
|
+
* Used to identify the owner or user context for the resource.
|
|
15
|
+
*/
|
|
16
|
+
ownerId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Generic identifier parameter.
|
|
19
|
+
* Used as a general purpose ID for resources when tenantId or ownerId are not appropriate.
|
|
20
|
+
*/
|
|
21
|
+
id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Index signature for additional custom path parameters.
|
|
24
|
+
* Allows for any additional string key-value pairs to be included as path parameters.
|
|
25
|
+
*/
|
|
26
|
+
[key: string]: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enumeration of resource attribution path specifications.
|
|
30
|
+
* Defines standard path patterns for accessing resources with different attribution scopes.
|
|
31
|
+
* These paths are used to construct URLs that include tenant and/or owner identifiers.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Using TENANT path spec
|
|
36
|
+
* const path = ResourceAttributionPathSpec.TENANT; // '/tenant/{tenantId}'
|
|
37
|
+
*
|
|
38
|
+
* // Using TENANT_OWNER path spec
|
|
39
|
+
* const path = ResourceAttributionPathSpec.TENANT_OWNER; // '/tenant/{tenantId}/owner/{ownerId}'
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare enum ResourceAttributionPathSpec {
|
|
43
|
+
NONE = "",
|
|
44
|
+
TENANT = "/tenant/{tenantId}",
|
|
45
|
+
OWNER = "/owner/{ownerId}",
|
|
46
|
+
TENANT_OWNER = "/tenant/{tenantId}/owner/{ownerId}"
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/client/routing.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.NONE = "", e.TENANT = "/tenant/{tenantId}", e.OWNER = "/owner/{ownerId}", e.TENANT_OWNER = "/tenant/{tenantId}/owner/{ownerId}", e;
|
|
4
|
+
}({});
|
|
5
|
+
//#endregion
|
|
6
|
+
export { e as ResourceAttributionPathSpec };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=routing.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.es.js","names":["ResourceAttributionPathSpec","\"NONE\"","\"TENANT\"","\"OWNER\"","\"TENANT_OWNER\""],"sources":["../../src/client/routing.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\n/**\n * Interface for path parameters used in URL construction.\n * Defines common path parameters and allows for additional custom parameters.\n * This interface is used to provide path variables for URL templating.\n */\nexport interface UrlPathParams {\n /**\n * Tenant identifier parameter.\n * Used in multi-tenant applications to identify the tenant context.\n */\n tenantId?: string;\n /**\n * Owner identifier parameter.\n * Used to identify the owner or user context for the resource.\n */\n ownerId?: string;\n /**\n * Generic identifier parameter.\n * Used as a general purpose ID for resources when tenantId or ownerId are not appropriate.\n */\n id?: string;\n\n /**\n * Index signature for additional custom path parameters.\n * Allows for any additional string key-value pairs to be included as path parameters.\n */\n [key: string]: string | undefined;\n}\n\n/**\n * Enumeration of resource attribution path specifications.\n * Defines standard path patterns for accessing resources with different attribution scopes.\n * These paths are used to construct URLs that include tenant and/or owner identifiers.\n *\n * @example\n * ```typescript\n * // Using TENANT path spec\n * const path = ResourceAttributionPathSpec.TENANT; // '/tenant/{tenantId}'\n *\n * // Using TENANT_OWNER path spec\n * const path = ResourceAttributionPathSpec.TENANT_OWNER; // '/tenant/{tenantId}/owner/{ownerId}'\n * ```\n */\nexport enum ResourceAttributionPathSpec {\n NONE = '',\n TENANT = '/tenant/{tenantId}',\n OWNER = '/owner/{ownerId}',\n TENANT_OWNER = '/tenant/{tenantId}/owner/{ownerId}',\n}\n"],"mappings":";AAwDA,IAAYA,IAAL,yBAAA,GAAA;QACL,EAAAC,OAAA,IACA,EAAAC,SAAA,sBACA,EAAAC,QAAA,oBACA,EAAAC,eAAA;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../filter/operator.cjs"),t=require("./types.cjs"),n=require("./expressionTrees.cjs"),r=require("./sort.cjs");function i(e,t,n,r){if(n.length>r)throw TypeError(`${e} must contain at most ${r} ${t}.`)}function a(t){switch(t.op){case e.FilterOperator.SEARCH:throw TypeError(`Aggregation metric filters do not support search filters.`);case e.FilterOperator.ELEMENT_MATCH:throw TypeError(`Aggregation metric filters do not support [ELEMENT_MATCH].`);case e.FilterOperator.AND:case e.FilterOperator.OR:case e.FilterOperator.NOR:t.operands.forEach(a)}}function o(e,r){n.requireValidExpressionTrees(e.flatMap(e=>e.type===t.AggregationMetricType.NUMERIC||e.type===t.AggregationMetricType.DISTINCT_COUNT||e.type===t.AggregationMetricType.PERCENTILE?[e.expression]:[])),r.forEach(e=>{if(e.type===t.AggregationGroupType.TERMS||e.type===t.AggregationGroupType.HISTOGRAM){if(e.field===void 0==(e.expression===void 0))throw TypeError(`${e.type} group requires exactly one of field and expression.`);if(e.expression&&n.requireValidExpressionTrees([e.expression]),e.type===t.AggregationGroupType.TERMS&&e.missingKey!==void 0&&e.expression)throw TypeError(`terms missingKey requires a field input.`)}})}var s=new Set([t.AggregationMetricType.ANY,t.AggregationMetricType.FIRST,t.AggregationMetricType.LAST]);function c(e){let n=new Map,r=0;e.forEach(e=>{e.type===t.AggregationMetricType.DERIVED&&(r=l(e,n,r)),n.set(e.alias,s.has(e.type)?e.type:void 0)})}function l(e,n,r){let i=[{expression:e.expression,depth:1}],a=r;for(;i.length>0;){let{expression:r,depth:o}=i.pop();if(o>t.AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH)throw TypeError(`derived expression depth must be at most ${t.AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH}.`);if(a++,a>t.AGGREGATION_LIMITS.MAX_EXPRESSION_NODES)throw TypeError(`derived expressions must contain at most ${t.AGGREGATION_LIMITS.MAX_EXPRESSION_NODES} nodes.`);switch(r.type){case t.DerivedExpressionType.METRIC_REF:{let t=r.metric;if(!n.has(t))throw TypeError(`derived metric [${e.alias}] must reference a metric declared before it, but was [${t}].`);let i=n.get(t);if(i!==void 0)throw TypeError(`derived metric [${e.alias}] cannot reference ${i} metric [${t}].`);break}case t.DerivedExpressionType.CONSTANT:if(!Number.isFinite(r.value))throw TypeError(`derived constant must be finite.`);break;case t.DerivedExpressionType.BINARY:i.push({expression:r.left,depth:o+1}),i.push({expression:r.right,depth:o+1});break;default:throw TypeError(`Unsupported derived expression: ${String(r.type)}.`)}}return a}function u(e,t,n,r){if(!t.has(e))throw TypeError(`having condition [${e}] must reference a declared metric alias.`);if(n.has(e))throw TypeError(`having condition [${e}] cannot reference ANY metric.`);if(r.has(e))throw TypeError(`having condition [${e}] cannot reference FIRST or LAST metric.`)}function d(e,n,r){if(e===void 0)return;if(n.length===0)throw TypeError(`having requires at least one groupBy.`);let i=new Set(r.map(e=>e.alias)),a=new Set(r.filter(e=>e.type===t.AggregationMetricType.ANY).map(e=>e.alias)),o=new Set(r.filter(e=>e.type===t.AggregationMetricType.FIRST||e.type===t.AggregationMetricType.LAST).map(e=>e.alias)),s=[{expression:e,depth:1}];for(;s.length>0;){let{expression:e,depth:n}=s.pop();if(n>t.AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH)throw TypeError(`having expression depth must be at most ${t.AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH}.`);switch(e.type){case t.HavingExpressionType.CONDITION:if(u(e.metric,i,a,o),!Number.isFinite(e.value))throw TypeError(`having condition [${e.metric}] value must be finite.`);break;case t.HavingExpressionType.BETWEEN:if(u(e.metric,i,a,o),!Number.isFinite(e.lower)||!Number.isFinite(e.upper))throw TypeError(`having between [${e.metric}] bounds must be finite.`);if(e.lower>e.upper)throw TypeError(`having between [${e.metric}] lower bound must not exceed upper bound.`);break;case t.HavingExpressionType.IN:if(u(e.metric,i,a,o),e.values.length===0)throw TypeError(`having in [${e.metric}] values must not be empty.`);if(!e.values.every(Number.isFinite))throw TypeError(`having in [${e.metric}] values must be finite.`);break;case t.HavingExpressionType.IS_NULL:u(e.metric,i,a,o);break;case t.HavingExpressionType.AND:case t.HavingExpressionType.OR:if(e.operands.length===0)throw TypeError(`having ${e.type} operands must not be empty.`);e.operands.forEach(e=>s.push({expression:e,depth:n+1}));break;default:throw TypeError(`Unsupported having expression: ${String(e.type)}.`)}}}function f(e,n,a){if(i(`sort`,`fields`,e,t.AGGREGATION_LIMITS.MAX_SORT_FIELDS),n.length===0&&e.length>0)throw TypeError(`sort requires at least one groupBy.`);let o=e.map(e=>e.field);if(new Set(o).size!==o.length)throw TypeError(`sort fields must be unique.`);if(!o.every(e=>a.includes(e)))throw TypeError(`sort fields must reference aggregation aliases.`);i(`effective sort`,`fields`,r.effectiveSort({groupBy:[...n],sort:[...e]}),t.AGGREGATION_LIMITS.MAX_SORT_FIELDS)}function p(e){let n=e.elements??[],r=e.groupBy??[],s=e.metrics,l=e.sort??[];if(i(`elements`,`paths`,n,t.AGGREGATION_LIMITS.MAX_ELEMENTS),i(`groupBy`,`dimensions`,r,t.AGGREGATION_LIMITS.MAX_GROUPS),!Array.isArray(s)||s.length===0)throw TypeError(`metrics must not be empty.`);if(i(`metrics`,`entries`,s,t.AGGREGATION_LIMITS.MAX_METRICS),e.limit!==void 0&&(!Number.isInteger(e.limit)||e.limit<1||e.limit>t.AGGREGATION_LIMITS.MAX_LIMIT))throw TypeError(`limit must be between 1 and ${t.AGGREGATION_LIMITS.MAX_LIMIT}.`);o(s,r),c(s),d(e.having,r,s),s.forEach(e=>{`filter`in e&&e.filter&&a(e.filter)}),r.forEach(e=>{if((e.type===t.AggregationGroupType.DATE_HISTOGRAM||e.type===t.AggregationGroupType.DATE_PART)&&e.dense===!0&&r.length!==1)throw TypeError(`dense requires ${e.type} to be the only groupBy.`)});let u=[...r.map(e=>e.alias),...s.map(e=>e.alias)];if(new Set(u).size!==u.length)throw TypeError(`aggregation aliases must be unique.`);return f(l,r,u),{...e,metrics:[...s]}}exports.admitAggregationQuery=p;
|
|
2
|
+
//# sourceMappingURL=admit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admit.cjs","names":["FilterOperator","AggregationMetricType","AggregationGroupType","AGGREGATION_LIMITS","DerivedExpressionType","HavingExpressionType","effectiveSort","require_operator","require_types","require_expressionTrees","require_sort","requireAtMost","items","max","name","noun","validateMetricFilter","filter","validateExpressions","metrics","metric","groupBy","group","NON_NUMERIC","validateDerivedMetrics","declared","nodes","validateDerivedExpression","pending","visitedNodes","depth","expression","reference","nonNumeric","requireValidHavingMetric","metricAliases","anyAliases","edgeAliases","validateHaving","having","operand","validateSort","sort","fields","entry","aliases","field","admitAggregationQuery","elements","query"],"sources":["../../../src/dsl/aggregation/admit.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 { FilterOperator, type FilterExpression } from '../filter/index.js';\nimport type { FieldSort } from '../sort.js';\nimport { requireValidExpressionTrees } from './expressionTrees.js';\nimport { effectiveSort } from './sort.js';\nimport {\n AGGREGATION_LIMITS,\n AggregationGroupType,\n AggregationMetricType,\n DerivedExpressionType,\n HavingExpressionType,\n type AggregationGroup,\n type AggregationMetric,\n type AggregationQuery,\n type DerivedAggregationMetric,\n type DerivedExpression,\n type HavingExpression,\n} from './types.js';\n\n// Internal: the rules `aggregation.query()` checks across the parts of a\n// query. index.ts does not re-export this file.\n\nfunction requireAtMost(\n name: string,\n noun: string,\n items: readonly unknown[],\n max: number,\n): void {\n if (items.length > max) {\n throw new TypeError(`${name} must contain at most ${max} ${noun}.`);\n }\n}\n\n/**\n * Refuses the filters a metric cannot carry, whatever the aggregate holds.\n *\n * A metric filter is a whole-value predicate on one record — MongoDB turns it\n * into a `$cond` guard and Elasticsearch into a filter aggregation — and\n * element matching and full text have no whole-value reading. Both backends\n * refuse them before touching a schema, so the shape alone settles it. What a\n * schema would add, refusing an array-valued field, stays on the server.\n */\nfunction validateMetricFilter(filter: FilterExpression): void {\n switch (filter.op) {\n case FilterOperator.SEARCH:\n throw new TypeError(\n 'Aggregation metric filters do not support search filters.',\n );\n case FilterOperator.ELEMENT_MATCH:\n throw new TypeError(\n 'Aggregation metric filters do not support [ELEMENT_MATCH].',\n );\n case FilterOperator.AND:\n case FilterOperator.OR:\n case FilterOperator.NOR:\n filter.operands.forEach(validateMetricFilter);\n break;\n }\n}\n\n/**\n * Walks the arithmetic of every metric that carries an expression, as one\n * budget, and of each expression group on its own, as Wow does.\n */\nfunction validateExpressions(\n metrics: readonly AggregationMetric[],\n groupBy: readonly AggregationGroup[],\n): void {\n requireValidExpressionTrees(\n metrics.flatMap(metric =>\n metric.type === AggregationMetricType.NUMERIC ||\n metric.type === AggregationMetricType.DISTINCT_COUNT ||\n metric.type === AggregationMetricType.PERCENTILE\n ? [metric.expression]\n : [],\n ),\n );\n groupBy.forEach(group => {\n if (\n group.type !== AggregationGroupType.TERMS &&\n group.type !== AggregationGroupType.HISTOGRAM\n )\n return;\n if ((group.field === undefined) === (group.expression === undefined)) {\n throw new TypeError(\n `${group.type} group requires exactly one of field and expression.`,\n );\n }\n if (group.expression) requireValidExpressionTrees([group.expression]);\n if (\n group.type === AggregationGroupType.TERMS &&\n group.missingKey !== undefined &&\n group.expression\n ) {\n throw new TypeError('terms missingKey requires a field input.');\n }\n });\n}\n\n/** The metric types whose value is not a number: derived and having refuse them. */\nconst NON_NUMERIC: ReadonlySet<string> = new Set([\n AggregationMetricType.ANY,\n AggregationMetricType.FIRST,\n AggregationMetricType.LAST,\n]);\n\n/**\n * Admits the derived metrics against what was declared before each of them.\n *\n * Derived arithmetic runs after the aggregation, over values the query has\n * already produced, so a reference may only name a metric declared earlier —\n * that is what makes the list evaluable in one pass — and never an `ANY`,\n * `FIRST` or `LAST` metric, whose value is a field's value rather than a\n * number.\n */\nfunction validateDerivedMetrics(metrics: readonly AggregationMetric[]): void {\n // Each earlier alias, with its type when that is not a number.\n const declared = new Map<string, string | undefined>();\n let nodes = 0;\n metrics.forEach(metric => {\n if (metric.type === AggregationMetricType.DERIVED) {\n nodes = validateDerivedExpression(metric, declared, nodes);\n }\n declared.set(\n metric.alias,\n NON_NUMERIC.has(metric.type) ? metric.type : undefined,\n );\n });\n}\n\nfunction validateDerivedExpression(\n metric: DerivedAggregationMetric,\n declared: ReadonlyMap<string, string | undefined>,\n visitedNodes: number,\n): number {\n const pending: { expression: DerivedExpression; depth: number }[] = [\n { expression: metric.expression, depth: 1 },\n ];\n let nodes = visitedNodes;\n while (pending.length > 0) {\n const { expression, depth } = pending.pop()!;\n if (depth > AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH) {\n throw new TypeError(\n `derived expression depth must be at most ${AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH}.`,\n );\n }\n nodes++;\n if (nodes > AGGREGATION_LIMITS.MAX_EXPRESSION_NODES) {\n throw new TypeError(\n `derived expressions must contain at most ${AGGREGATION_LIMITS.MAX_EXPRESSION_NODES} nodes.`,\n );\n }\n switch (expression.type) {\n case DerivedExpressionType.METRIC_REF: {\n const reference = expression.metric;\n if (!declared.has(reference)) {\n throw new TypeError(\n `derived metric [${metric.alias}] must reference a metric declared before it, but was [${reference}].`,\n );\n }\n const nonNumeric = declared.get(reference);\n if (nonNumeric !== undefined) {\n throw new TypeError(\n `derived metric [${metric.alias}] cannot reference ${nonNumeric} metric [${reference}].`,\n );\n }\n break;\n }\n case DerivedExpressionType.CONSTANT:\n if (!Number.isFinite(expression.value)) {\n throw new TypeError('derived constant must be finite.');\n }\n break;\n case DerivedExpressionType.BINARY:\n pending.push({ expression: expression.left, depth: depth + 1 });\n pending.push({ expression: expression.right, depth: depth + 1 });\n break;\n default:\n throw new TypeError(\n `Unsupported derived expression: ${String((expression as { type: unknown }).type)}.`,\n );\n }\n }\n return nodes;\n}\n\nfunction requireValidHavingMetric(\n metric: string,\n metricAliases: ReadonlySet<string>,\n anyAliases: ReadonlySet<string>,\n edgeAliases: ReadonlySet<string>,\n): void {\n if (!metricAliases.has(metric)) {\n throw new TypeError(\n `having condition [${metric}] must reference a declared metric alias.`,\n );\n }\n if (anyAliases.has(metric)) {\n throw new TypeError(\n `having condition [${metric}] cannot reference ANY metric.`,\n );\n }\n if (edgeAliases.has(metric)) {\n throw new TypeError(\n `having condition [${metric}] cannot reference FIRST or LAST metric.`,\n );\n }\n}\n\n/**\n * `having` filters the grouped rows, so it needs rows to filter: a query with\n * no `groupBy` produces one row and has nothing to select from.\n */\nfunction validateHaving(\n having: HavingExpression | undefined,\n groupBy: readonly AggregationGroup[],\n metrics: readonly AggregationMetric[],\n): void {\n if (having === undefined) return;\n if (groupBy.length === 0) {\n throw new TypeError('having requires at least one groupBy.');\n }\n const metricAliases = new Set(metrics.map(metric => metric.alias));\n const anyAliases = new Set(\n metrics\n .filter(metric => metric.type === AggregationMetricType.ANY)\n .map(metric => metric.alias),\n );\n const edgeAliases = new Set(\n metrics\n .filter(\n metric =>\n metric.type === AggregationMetricType.FIRST ||\n metric.type === AggregationMetricType.LAST,\n )\n .map(metric => metric.alias),\n );\n\n const pending: { expression: HavingExpression; depth: number }[] = [\n { expression: having, depth: 1 },\n ];\n while (pending.length > 0) {\n const { expression, depth } = pending.pop()!;\n if (depth > AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH) {\n throw new TypeError(\n `having expression depth must be at most ${AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH}.`,\n );\n }\n switch (expression.type) {\n case HavingExpressionType.CONDITION:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n if (!Number.isFinite(expression.value)) {\n throw new TypeError(\n `having condition [${expression.metric}] value must be finite.`,\n );\n }\n break;\n case HavingExpressionType.BETWEEN:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n if (\n !Number.isFinite(expression.lower) ||\n !Number.isFinite(expression.upper)\n ) {\n throw new TypeError(\n `having between [${expression.metric}] bounds must be finite.`,\n );\n }\n if (expression.lower > expression.upper) {\n throw new TypeError(\n `having between [${expression.metric}] lower bound must not exceed upper bound.`,\n );\n }\n break;\n case HavingExpressionType.IN:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n if (expression.values.length === 0) {\n throw new TypeError(\n `having in [${expression.metric}] values must not be empty.`,\n );\n }\n if (!expression.values.every(Number.isFinite)) {\n throw new TypeError(\n `having in [${expression.metric}] values must be finite.`,\n );\n }\n break;\n case HavingExpressionType.IS_NULL:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n break;\n case HavingExpressionType.AND:\n case HavingExpressionType.OR:\n if (expression.operands.length === 0) {\n throw new TypeError(\n `having ${expression.type} operands must not be empty.`,\n );\n }\n expression.operands.forEach(operand =>\n pending.push({ expression: operand, depth: depth + 1 }),\n );\n break;\n default:\n throw new TypeError(\n `Unsupported having expression: ${String((expression as { type: unknown }).type)}.`,\n );\n }\n }\n}\n\nfunction validateSort(\n sort: readonly FieldSort[],\n groupBy: readonly AggregationGroup[],\n aliases: readonly string[],\n): void {\n requireAtMost('sort', 'fields', sort, AGGREGATION_LIMITS.MAX_SORT_FIELDS);\n if (groupBy.length === 0 && sort.length > 0) {\n throw new TypeError('sort requires at least one groupBy.');\n }\n const fields = sort.map(entry => entry.field);\n if (new Set(fields).size !== fields.length) {\n throw new TypeError('sort fields must be unique.');\n }\n if (!fields.every(field => aliases.includes(field))) {\n throw new TypeError('sort fields must reference aggregation aliases.');\n }\n requireAtMost(\n 'effective sort',\n 'fields',\n effectiveSort({ groupBy: [...groupBy], sort: [...sort] }),\n AGGREGATION_LIMITS.MAX_SORT_FIELDS,\n );\n}\n\n/**\n * Admits a whole aggregation query against the rules Wow enforces on arrival;\n * {@link aggregation.query} is its public face.\n */\nexport function admitAggregationQuery<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n>(\n query: AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>,\n): AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS> {\n const elements = query.elements ?? [];\n const groupBy = query.groupBy ?? [];\n const metrics = query.metrics;\n const sort = query.sort ?? [];\n\n requireAtMost('elements', 'paths', elements, AGGREGATION_LIMITS.MAX_ELEMENTS);\n requireAtMost(\n 'groupBy',\n 'dimensions',\n groupBy,\n AGGREGATION_LIMITS.MAX_GROUPS,\n );\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new TypeError('metrics must not be empty.');\n }\n requireAtMost('metrics', 'entries', metrics, AGGREGATION_LIMITS.MAX_METRICS);\n if (query.limit !== undefined) {\n if (\n !Number.isInteger(query.limit) ||\n query.limit < 1 ||\n query.limit > AGGREGATION_LIMITS.MAX_LIMIT\n ) {\n throw new TypeError(\n `limit must be between 1 and ${AGGREGATION_LIMITS.MAX_LIMIT}.`,\n );\n }\n }\n\n validateExpressions(metrics, groupBy);\n validateDerivedMetrics(metrics);\n validateHaving(query.having, groupBy, metrics);\n metrics.forEach(metric => {\n if ('filter' in metric && metric.filter)\n validateMetricFilter(metric.filter);\n });\n\n // A dense DATE_HISTOGRAM fills in the buckets its range implies, and a\n // dense DATE_PART every key of its part's domain, rather than only the ones\n // with rows; a second dimension would multiply that filling out across\n // every one of its own keys.\n groupBy.forEach(group => {\n if (\n (group.type === AggregationGroupType.DATE_HISTOGRAM ||\n group.type === AggregationGroupType.DATE_PART) &&\n group.dense === true &&\n groupBy.length !== 1\n ) {\n throw new TypeError(\n `dense requires ${group.type} to be the only groupBy.`,\n );\n }\n });\n\n const aliases = [\n ...groupBy.map(group => group.alias),\n ...metrics.map(metric => metric.alias),\n ];\n if (new Set(aliases).size !== aliases.length) {\n throw new TypeError('aggregation aliases must be unique.');\n }\n validateSort(sort, groupBy, aliases);\n\n return {\n ...query,\n metrics: [...metrics] as typeof query.metrics,\n };\n}\n"],"mappings":"8HAkCA,SAASW,EACP,EACA,EACA,EACA,EACM,CACN,GAAIC,EAAM,OAASC,EACjB,MAAU,UAAU,GAAGC,EAAK,wBAAwBD,EAAI,GAAGE,EAAK,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O,KAAK,CACvC,EACA,GAAI,IAAI,IAAIyB,CAAO,CAAC,CAAC,OAASA,EAAQ,OACpC,MAAU,UAAU,qCAAqC,EAI3D,OAFAJ,EAAaC,EAAMrB,EAASwB,CAAO,EAE5B,CACL,GAAGI,EACH,QAAS,CAAC,GAAG9B,CAAO,CACtB,CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AggregationQuery } from './types.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Admits a whole aggregation query against the rules Wow enforces on arrival;
|
|
4
|
+
* {@link aggregation.query} is its public face.
|
|
5
|
+
*/
|
|
6
|
+
export declare function admitAggregationQuery<ROOT_FIELDS extends string = string, AGGREGATION_FIELDS extends string = ROOT_FIELDS>(query: AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>): AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AggregationQuery } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Admits a whole aggregation query against the rules Wow enforces on arrival;
|
|
4
|
+
* {@link aggregation.query} is its public face.
|
|
5
|
+
*/
|
|
6
|
+
export declare function admitAggregationQuery<ROOT_FIELDS extends string = string, AGGREGATION_FIELDS extends string = ROOT_FIELDS>(query: AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>): AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { FilterOperator as e } from "../filter/operator.es.js";
|
|
2
|
+
import { AGGREGATION_LIMITS as t, AggregationGroupType as n, AggregationMetricType as r, DerivedExpressionType as i, HavingExpressionType as a } from "./types.es.js";
|
|
3
|
+
import { requireValidExpressionTrees as o } from "./expressionTrees.es.js";
|
|
4
|
+
import { effectiveSort as s } from "./sort.es.js";
|
|
5
|
+
//#region src/dsl/aggregation/admit.ts
|
|
6
|
+
function c(e, t, n, r) {
|
|
7
|
+
if (n.length > r) throw TypeError(`${e} must contain at most ${r} ${t}.`);
|
|
8
|
+
}
|
|
9
|
+
function l(t) {
|
|
10
|
+
switch (t.op) {
|
|
11
|
+
case e.SEARCH: throw TypeError("Aggregation metric filters do not support search filters.");
|
|
12
|
+
case e.ELEMENT_MATCH: throw TypeError("Aggregation metric filters do not support [ELEMENT_MATCH].");
|
|
13
|
+
case e.AND:
|
|
14
|
+
case e.OR:
|
|
15
|
+
case e.NOR: t.operands.forEach(l);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function u(e, t) {
|
|
19
|
+
o(e.flatMap((e) => e.type === r.NUMERIC || e.type === r.DISTINCT_COUNT || e.type === r.PERCENTILE ? [e.expression] : [])), t.forEach((e) => {
|
|
20
|
+
if (e.type === n.TERMS || e.type === n.HISTOGRAM) {
|
|
21
|
+
if (e.field === void 0 == (e.expression === void 0)) throw TypeError(`${e.type} group requires exactly one of field and expression.`);
|
|
22
|
+
if (e.expression && o([e.expression]), e.type === n.TERMS && e.missingKey !== void 0 && e.expression) throw TypeError("terms missingKey requires a field input.");
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
var d = /* @__PURE__ */ new Set([
|
|
27
|
+
r.ANY,
|
|
28
|
+
r.FIRST,
|
|
29
|
+
r.LAST
|
|
30
|
+
]);
|
|
31
|
+
function f(e) {
|
|
32
|
+
let t = /* @__PURE__ */ new Map(), n = 0;
|
|
33
|
+
e.forEach((e) => {
|
|
34
|
+
e.type === r.DERIVED && (n = p(e, t, n)), t.set(e.alias, d.has(e.type) ? e.type : void 0);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function p(e, n, r) {
|
|
38
|
+
let a = [{
|
|
39
|
+
expression: e.expression,
|
|
40
|
+
depth: 1
|
|
41
|
+
}], o = r;
|
|
42
|
+
for (; a.length > 0;) {
|
|
43
|
+
let { expression: r, depth: s } = a.pop();
|
|
44
|
+
if (s > t.MAX_EXPRESSION_DEPTH) throw TypeError(`derived expression depth must be at most ${t.MAX_EXPRESSION_DEPTH}.`);
|
|
45
|
+
if (o++, o > t.MAX_EXPRESSION_NODES) throw TypeError(`derived expressions must contain at most ${t.MAX_EXPRESSION_NODES} nodes.`);
|
|
46
|
+
switch (r.type) {
|
|
47
|
+
case i.METRIC_REF: {
|
|
48
|
+
let t = r.metric;
|
|
49
|
+
if (!n.has(t)) throw TypeError(`derived metric [${e.alias}] must reference a metric declared before it, but was [${t}].`);
|
|
50
|
+
let i = n.get(t);
|
|
51
|
+
if (i !== void 0) throw TypeError(`derived metric [${e.alias}] cannot reference ${i} metric [${t}].`);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case i.CONSTANT:
|
|
55
|
+
if (!Number.isFinite(r.value)) throw TypeError("derived constant must be finite.");
|
|
56
|
+
break;
|
|
57
|
+
case i.BINARY:
|
|
58
|
+
a.push({
|
|
59
|
+
expression: r.left,
|
|
60
|
+
depth: s + 1
|
|
61
|
+
}), a.push({
|
|
62
|
+
expression: r.right,
|
|
63
|
+
depth: s + 1
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
default: throw TypeError(`Unsupported derived expression: ${String(r.type)}.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return o;
|
|
70
|
+
}
|
|
71
|
+
function m(e, t, n, r) {
|
|
72
|
+
if (!t.has(e)) throw TypeError(`having condition [${e}] must reference a declared metric alias.`);
|
|
73
|
+
if (n.has(e)) throw TypeError(`having condition [${e}] cannot reference ANY metric.`);
|
|
74
|
+
if (r.has(e)) throw TypeError(`having condition [${e}] cannot reference FIRST or LAST metric.`);
|
|
75
|
+
}
|
|
76
|
+
function h(e, n, i) {
|
|
77
|
+
if (e === void 0) return;
|
|
78
|
+
if (n.length === 0) throw TypeError("having requires at least one groupBy.");
|
|
79
|
+
let o = new Set(i.map((e) => e.alias)), s = new Set(i.filter((e) => e.type === r.ANY).map((e) => e.alias)), c = new Set(i.filter((e) => e.type === r.FIRST || e.type === r.LAST).map((e) => e.alias)), l = [{
|
|
80
|
+
expression: e,
|
|
81
|
+
depth: 1
|
|
82
|
+
}];
|
|
83
|
+
for (; l.length > 0;) {
|
|
84
|
+
let { expression: e, depth: n } = l.pop();
|
|
85
|
+
if (n > t.MAX_EXPRESSION_DEPTH) throw TypeError(`having expression depth must be at most ${t.MAX_EXPRESSION_DEPTH}.`);
|
|
86
|
+
switch (e.type) {
|
|
87
|
+
case a.CONDITION:
|
|
88
|
+
if (m(e.metric, o, s, c), !Number.isFinite(e.value)) throw TypeError(`having condition [${e.metric}] value must be finite.`);
|
|
89
|
+
break;
|
|
90
|
+
case a.BETWEEN:
|
|
91
|
+
if (m(e.metric, o, s, c), !Number.isFinite(e.lower) || !Number.isFinite(e.upper)) throw TypeError(`having between [${e.metric}] bounds must be finite.`);
|
|
92
|
+
if (e.lower > e.upper) throw TypeError(`having between [${e.metric}] lower bound must not exceed upper bound.`);
|
|
93
|
+
break;
|
|
94
|
+
case a.IN:
|
|
95
|
+
if (m(e.metric, o, s, c), e.values.length === 0) throw TypeError(`having in [${e.metric}] values must not be empty.`);
|
|
96
|
+
if (!e.values.every(Number.isFinite)) throw TypeError(`having in [${e.metric}] values must be finite.`);
|
|
97
|
+
break;
|
|
98
|
+
case a.IS_NULL:
|
|
99
|
+
m(e.metric, o, s, c);
|
|
100
|
+
break;
|
|
101
|
+
case a.AND:
|
|
102
|
+
case a.OR:
|
|
103
|
+
if (e.operands.length === 0) throw TypeError(`having ${e.type} operands must not be empty.`);
|
|
104
|
+
e.operands.forEach((e) => l.push({
|
|
105
|
+
expression: e,
|
|
106
|
+
depth: n + 1
|
|
107
|
+
}));
|
|
108
|
+
break;
|
|
109
|
+
default: throw TypeError(`Unsupported having expression: ${String(e.type)}.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function g(e, n, r) {
|
|
114
|
+
if (c("sort", "fields", e, t.MAX_SORT_FIELDS), n.length === 0 && e.length > 0) throw TypeError("sort requires at least one groupBy.");
|
|
115
|
+
let i = e.map((e) => e.field);
|
|
116
|
+
if (new Set(i).size !== i.length) throw TypeError("sort fields must be unique.");
|
|
117
|
+
if (!i.every((e) => r.includes(e))) throw TypeError("sort fields must reference aggregation aliases.");
|
|
118
|
+
c("effective sort", "fields", s({
|
|
119
|
+
groupBy: [...n],
|
|
120
|
+
sort: [...e]
|
|
121
|
+
}), t.MAX_SORT_FIELDS);
|
|
122
|
+
}
|
|
123
|
+
function _(e) {
|
|
124
|
+
let r = e.elements ?? [], i = e.groupBy ?? [], a = e.metrics, o = e.sort ?? [];
|
|
125
|
+
if (c("elements", "paths", r, t.MAX_ELEMENTS), c("groupBy", "dimensions", i, t.MAX_GROUPS), !Array.isArray(a) || a.length === 0) throw TypeError("metrics must not be empty.");
|
|
126
|
+
if (c("metrics", "entries", a, t.MAX_METRICS), e.limit !== void 0 && (!Number.isInteger(e.limit) || e.limit < 1 || e.limit > t.MAX_LIMIT)) throw TypeError(`limit must be between 1 and ${t.MAX_LIMIT}.`);
|
|
127
|
+
u(a, i), f(a), h(e.having, i, a), a.forEach((e) => {
|
|
128
|
+
"filter" in e && e.filter && l(e.filter);
|
|
129
|
+
}), i.forEach((e) => {
|
|
130
|
+
if ((e.type === n.DATE_HISTOGRAM || e.type === n.DATE_PART) && e.dense === !0 && i.length !== 1) throw TypeError(`dense requires ${e.type} to be the only groupBy.`);
|
|
131
|
+
});
|
|
132
|
+
let s = [...i.map((e) => e.alias), ...a.map((e) => e.alias)];
|
|
133
|
+
if (new Set(s).size !== s.length) throw TypeError("aggregation aliases must be unique.");
|
|
134
|
+
return g(o, i, s), {
|
|
135
|
+
...e,
|
|
136
|
+
metrics: [...a]
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
export { _ as admitAggregationQuery };
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=admit.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admit.es.js","names":["requireAtMost","items","max","name","noun","validateMetricFilter","filter","FilterOperator","validateExpressions","requireValidExpressionTrees","metrics","metric","AggregationMetricType","groupBy","group","AggregationGroupType","NON_NUMERIC","validateDerivedMetrics","declared","nodes","validateDerivedExpression","pending","visitedNodes","depth","AGGREGATION_LIMITS","expression","DerivedExpressionType","reference","nonNumeric","requireValidHavingMetric","metricAliases","anyAliases","edgeAliases","validateHaving","having","HavingExpressionType","operand","validateSort","sort","fields","entry","aliases","field","effectiveSort","admitAggregationQuery","elements","query"],"sources":["../../../src/dsl/aggregation/admit.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 { FilterOperator, type FilterExpression } from '../filter/index.js';\nimport type { FieldSort } from '../sort.js';\nimport { requireValidExpressionTrees } from './expressionTrees.js';\nimport { effectiveSort } from './sort.js';\nimport {\n AGGREGATION_LIMITS,\n AggregationGroupType,\n AggregationMetricType,\n DerivedExpressionType,\n HavingExpressionType,\n type AggregationGroup,\n type AggregationMetric,\n type AggregationQuery,\n type DerivedAggregationMetric,\n type DerivedExpression,\n type HavingExpression,\n} from './types.js';\n\n// Internal: the rules `aggregation.query()` checks across the parts of a\n// query. index.ts does not re-export this file.\n\nfunction requireAtMost(\n name: string,\n noun: string,\n items: readonly unknown[],\n max: number,\n): void {\n if (items.length > max) {\n throw new TypeError(`${name} must contain at most ${max} ${noun}.`);\n }\n}\n\n/**\n * Refuses the filters a metric cannot carry, whatever the aggregate holds.\n *\n * A metric filter is a whole-value predicate on one record — MongoDB turns it\n * into a `$cond` guard and Elasticsearch into a filter aggregation — and\n * element matching and full text have no whole-value reading. Both backends\n * refuse them before touching a schema, so the shape alone settles it. What a\n * schema would add, refusing an array-valued field, stays on the server.\n */\nfunction validateMetricFilter(filter: FilterExpression): void {\n switch (filter.op) {\n case FilterOperator.SEARCH:\n throw new TypeError(\n 'Aggregation metric filters do not support search filters.',\n );\n case FilterOperator.ELEMENT_MATCH:\n throw new TypeError(\n 'Aggregation metric filters do not support [ELEMENT_MATCH].',\n );\n case FilterOperator.AND:\n case FilterOperator.OR:\n case FilterOperator.NOR:\n filter.operands.forEach(validateMetricFilter);\n break;\n }\n}\n\n/**\n * Walks the arithmetic of every metric that carries an expression, as one\n * budget, and of each expression group on its own, as Wow does.\n */\nfunction validateExpressions(\n metrics: readonly AggregationMetric[],\n groupBy: readonly AggregationGroup[],\n): void {\n requireValidExpressionTrees(\n metrics.flatMap(metric =>\n metric.type === AggregationMetricType.NUMERIC ||\n metric.type === AggregationMetricType.DISTINCT_COUNT ||\n metric.type === AggregationMetricType.PERCENTILE\n ? [metric.expression]\n : [],\n ),\n );\n groupBy.forEach(group => {\n if (\n group.type !== AggregationGroupType.TERMS &&\n group.type !== AggregationGroupType.HISTOGRAM\n )\n return;\n if ((group.field === undefined) === (group.expression === undefined)) {\n throw new TypeError(\n `${group.type} group requires exactly one of field and expression.`,\n );\n }\n if (group.expression) requireValidExpressionTrees([group.expression]);\n if (\n group.type === AggregationGroupType.TERMS &&\n group.missingKey !== undefined &&\n group.expression\n ) {\n throw new TypeError('terms missingKey requires a field input.');\n }\n });\n}\n\n/** The metric types whose value is not a number: derived and having refuse them. */\nconst NON_NUMERIC: ReadonlySet<string> = new Set([\n AggregationMetricType.ANY,\n AggregationMetricType.FIRST,\n AggregationMetricType.LAST,\n]);\n\n/**\n * Admits the derived metrics against what was declared before each of them.\n *\n * Derived arithmetic runs after the aggregation, over values the query has\n * already produced, so a reference may only name a metric declared earlier —\n * that is what makes the list evaluable in one pass — and never an `ANY`,\n * `FIRST` or `LAST` metric, whose value is a field's value rather than a\n * number.\n */\nfunction validateDerivedMetrics(metrics: readonly AggregationMetric[]): void {\n // Each earlier alias, with its type when that is not a number.\n const declared = new Map<string, string | undefined>();\n let nodes = 0;\n metrics.forEach(metric => {\n if (metric.type === AggregationMetricType.DERIVED) {\n nodes = validateDerivedExpression(metric, declared, nodes);\n }\n declared.set(\n metric.alias,\n NON_NUMERIC.has(metric.type) ? metric.type : undefined,\n );\n });\n}\n\nfunction validateDerivedExpression(\n metric: DerivedAggregationMetric,\n declared: ReadonlyMap<string, string | undefined>,\n visitedNodes: number,\n): number {\n const pending: { expression: DerivedExpression; depth: number }[] = [\n { expression: metric.expression, depth: 1 },\n ];\n let nodes = visitedNodes;\n while (pending.length > 0) {\n const { expression, depth } = pending.pop()!;\n if (depth > AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH) {\n throw new TypeError(\n `derived expression depth must be at most ${AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH}.`,\n );\n }\n nodes++;\n if (nodes > AGGREGATION_LIMITS.MAX_EXPRESSION_NODES) {\n throw new TypeError(\n `derived expressions must contain at most ${AGGREGATION_LIMITS.MAX_EXPRESSION_NODES} nodes.`,\n );\n }\n switch (expression.type) {\n case DerivedExpressionType.METRIC_REF: {\n const reference = expression.metric;\n if (!declared.has(reference)) {\n throw new TypeError(\n `derived metric [${metric.alias}] must reference a metric declared before it, but was [${reference}].`,\n );\n }\n const nonNumeric = declared.get(reference);\n if (nonNumeric !== undefined) {\n throw new TypeError(\n `derived metric [${metric.alias}] cannot reference ${nonNumeric} metric [${reference}].`,\n );\n }\n break;\n }\n case DerivedExpressionType.CONSTANT:\n if (!Number.isFinite(expression.value)) {\n throw new TypeError('derived constant must be finite.');\n }\n break;\n case DerivedExpressionType.BINARY:\n pending.push({ expression: expression.left, depth: depth + 1 });\n pending.push({ expression: expression.right, depth: depth + 1 });\n break;\n default:\n throw new TypeError(\n `Unsupported derived expression: ${String((expression as { type: unknown }).type)}.`,\n );\n }\n }\n return nodes;\n}\n\nfunction requireValidHavingMetric(\n metric: string,\n metricAliases: ReadonlySet<string>,\n anyAliases: ReadonlySet<string>,\n edgeAliases: ReadonlySet<string>,\n): void {\n if (!metricAliases.has(metric)) {\n throw new TypeError(\n `having condition [${metric}] must reference a declared metric alias.`,\n );\n }\n if (anyAliases.has(metric)) {\n throw new TypeError(\n `having condition [${metric}] cannot reference ANY metric.`,\n );\n }\n if (edgeAliases.has(metric)) {\n throw new TypeError(\n `having condition [${metric}] cannot reference FIRST or LAST metric.`,\n );\n }\n}\n\n/**\n * `having` filters the grouped rows, so it needs rows to filter: a query with\n * no `groupBy` produces one row and has nothing to select from.\n */\nfunction validateHaving(\n having: HavingExpression | undefined,\n groupBy: readonly AggregationGroup[],\n metrics: readonly AggregationMetric[],\n): void {\n if (having === undefined) return;\n if (groupBy.length === 0) {\n throw new TypeError('having requires at least one groupBy.');\n }\n const metricAliases = new Set(metrics.map(metric => metric.alias));\n const anyAliases = new Set(\n metrics\n .filter(metric => metric.type === AggregationMetricType.ANY)\n .map(metric => metric.alias),\n );\n const edgeAliases = new Set(\n metrics\n .filter(\n metric =>\n metric.type === AggregationMetricType.FIRST ||\n metric.type === AggregationMetricType.LAST,\n )\n .map(metric => metric.alias),\n );\n\n const pending: { expression: HavingExpression; depth: number }[] = [\n { expression: having, depth: 1 },\n ];\n while (pending.length > 0) {\n const { expression, depth } = pending.pop()!;\n if (depth > AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH) {\n throw new TypeError(\n `having expression depth must be at most ${AGGREGATION_LIMITS.MAX_EXPRESSION_DEPTH}.`,\n );\n }\n switch (expression.type) {\n case HavingExpressionType.CONDITION:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n if (!Number.isFinite(expression.value)) {\n throw new TypeError(\n `having condition [${expression.metric}] value must be finite.`,\n );\n }\n break;\n case HavingExpressionType.BETWEEN:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n if (\n !Number.isFinite(expression.lower) ||\n !Number.isFinite(expression.upper)\n ) {\n throw new TypeError(\n `having between [${expression.metric}] bounds must be finite.`,\n );\n }\n if (expression.lower > expression.upper) {\n throw new TypeError(\n `having between [${expression.metric}] lower bound must not exceed upper bound.`,\n );\n }\n break;\n case HavingExpressionType.IN:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n if (expression.values.length === 0) {\n throw new TypeError(\n `having in [${expression.metric}] values must not be empty.`,\n );\n }\n if (!expression.values.every(Number.isFinite)) {\n throw new TypeError(\n `having in [${expression.metric}] values must be finite.`,\n );\n }\n break;\n case HavingExpressionType.IS_NULL:\n requireValidHavingMetric(\n expression.metric,\n metricAliases,\n anyAliases,\n edgeAliases,\n );\n break;\n case HavingExpressionType.AND:\n case HavingExpressionType.OR:\n if (expression.operands.length === 0) {\n throw new TypeError(\n `having ${expression.type} operands must not be empty.`,\n );\n }\n expression.operands.forEach(operand =>\n pending.push({ expression: operand, depth: depth + 1 }),\n );\n break;\n default:\n throw new TypeError(\n `Unsupported having expression: ${String((expression as { type: unknown }).type)}.`,\n );\n }\n }\n}\n\nfunction validateSort(\n sort: readonly FieldSort[],\n groupBy: readonly AggregationGroup[],\n aliases: readonly string[],\n): void {\n requireAtMost('sort', 'fields', sort, AGGREGATION_LIMITS.MAX_SORT_FIELDS);\n if (groupBy.length === 0 && sort.length > 0) {\n throw new TypeError('sort requires at least one groupBy.');\n }\n const fields = sort.map(entry => entry.field);\n if (new Set(fields).size !== fields.length) {\n throw new TypeError('sort fields must be unique.');\n }\n if (!fields.every(field => aliases.includes(field))) {\n throw new TypeError('sort fields must reference aggregation aliases.');\n }\n requireAtMost(\n 'effective sort',\n 'fields',\n effectiveSort({ groupBy: [...groupBy], sort: [...sort] }),\n AGGREGATION_LIMITS.MAX_SORT_FIELDS,\n );\n}\n\n/**\n * Admits a whole aggregation query against the rules Wow enforces on arrival;\n * {@link aggregation.query} is its public face.\n */\nexport function admitAggregationQuery<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n>(\n query: AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>,\n): AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS> {\n const elements = query.elements ?? [];\n const groupBy = query.groupBy ?? [];\n const metrics = query.metrics;\n const sort = query.sort ?? [];\n\n requireAtMost('elements', 'paths', elements, AGGREGATION_LIMITS.MAX_ELEMENTS);\n requireAtMost(\n 'groupBy',\n 'dimensions',\n groupBy,\n AGGREGATION_LIMITS.MAX_GROUPS,\n );\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new TypeError('metrics must not be empty.');\n }\n requireAtMost('metrics', 'entries', metrics, AGGREGATION_LIMITS.MAX_METRICS);\n if (query.limit !== undefined) {\n if (\n !Number.isInteger(query.limit) ||\n query.limit < 1 ||\n query.limit > AGGREGATION_LIMITS.MAX_LIMIT\n ) {\n throw new TypeError(\n `limit must be between 1 and ${AGGREGATION_LIMITS.MAX_LIMIT}.`,\n );\n }\n }\n\n validateExpressions(metrics, groupBy);\n validateDerivedMetrics(metrics);\n validateHaving(query.having, groupBy, metrics);\n metrics.forEach(metric => {\n if ('filter' in metric && metric.filter)\n validateMetricFilter(metric.filter);\n });\n\n // A dense DATE_HISTOGRAM fills in the buckets its range implies, and a\n // dense DATE_PART every key of its part's domain, rather than only the ones\n // with rows; a second dimension would multiply that filling out across\n // every one of its own keys.\n groupBy.forEach(group => {\n if (\n (group.type === AggregationGroupType.DATE_HISTOGRAM ||\n group.type === AggregationGroupType.DATE_PART) &&\n group.dense === true &&\n groupBy.length !== 1\n ) {\n throw new TypeError(\n `dense requires ${group.type} to be the only groupBy.`,\n );\n }\n });\n\n const aliases = [\n ...groupBy.map(group => group.alias),\n ...metrics.map(metric => metric.alias),\n ];\n if (new Set(aliases).size !== aliases.length) {\n throw new TypeError('aggregation aliases must be unique.');\n }\n validateSort(sort, groupBy, aliases);\n\n return {\n ...query,\n metrics: [...metrics] as typeof query.metrics,\n };\n}\n"],"mappings":";;;;;AAkCA,SAASA,EACP,GACA,GACA,GACA,GACM;CACN,IAAIC,EAAM,SAASC,GACjB,MAAU,UAAU,GAAGC,EAAK,wBAAwBD,EAAI,GAAGE,EAAK,EAAE;AAEtE;AAWA,SAASC,EAAqB,GAAgC;CAC5D,QAAQC,EAAO,IAAf;EACE,KAAKC,EAAe,QAClB,MAAU,UACR,2DACF;EACF,KAAKA,EAAe,eAClB,MAAU,UACR,4DACF;EACF,KAAKA,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe,KAClB,EAAO,SAAS,QAAQF,CAAoB;CAEhD;AACF;AAMA,SAASG,EACP,GACA,GACM;CAUN,AATAC,EACEC,EAAQ,SAAQ,MACdC,EAAO,SAASC,EAAsB,WACtCD,EAAO,SAASC,EAAsB,kBACtCD,EAAO,SAASC,EAAsB,aAClC,CAACD,EAAO,UAAU,IAClB,CAAC,CACP,CACF,GACAE,EAAQ,SAAQ,MAAS;EACvB,IACEC,EAAM,SAASC,EAAqB,SACpCD,EAAM,SAASC,EAAqB,WAGtC;OAAKD,EAAM,UAAU,KAAA,MAAgBA,EAAM,eAAe,KAAA,IACxD,MAAU,UACR,GAAGA,EAAM,KAAK,qDAChB;GAGF,IADIA,EAAM,cAAYL,EAA4B,CAACK,EAAM,UAAU,CAAC,GAElEA,EAAM,SAASC,EAAqB,SACpCD,EAAM,eAAe,KAAA,KACrBA,EAAM,YAEN,MAAU,UAAU,0CAA0C;EAR9D;CAUJ,CAAC;AACH;AAGA,IAAME,oBAAmC,IAAI,IAAI;CAC/CJ,EAAsB;CACtBA,EAAsB;CACtBA,EAAsB;AACxB,CAAC;AAWD,SAASK,EAAuB,GAA6C;CAE3E,IAAMC,oBAAW,IAAI,IAAgC,GACjDC,IAAQ;CACZ,EAAQ,SAAQ,MAAU;EAIxB,AAHIR,EAAO,SAASC,EAAsB,YACxC,IAAQQ,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ACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./types.cjs"),t=require("./expressionTrees.cjs"),n=require("../field.cjs"),r=require("../filter/scope.cjs"),i=require("./admit.cjs"),a=require("./derived.cjs"),o=require("./having.cjs");function s(e){return n.queryField(e)}function c(e){if(s(e),e.includes(`.`))throw TypeError(`aggregation alias must contain one segment.`);if(e.startsWith(`__wow`))throw TypeError(`aggregation alias must not use the reserved __wow prefix.`);return e}function l(t,n,r){return{type:e.AggregationExpressionType.BINARY,operator:t,left:n,right:r}}function u(t,n,r,{filter:i}={}){return{type:e.AggregationMetricType.NUMERIC,...i===void 0?{}:{filter:i},function:t,expression:n,alias:c(r)}}function d(e,t,n,{orderBy:r,filter:i}){return{type:e,field:s(t),alias:c(n),...r===void 0?{}:{orderBy:s(r)},...i===void 0?{}:{filter:i}}}function f(e,n){if(typeof e==`string`)return{field:s(e)};if(typeof e!=`object`||!e)throw TypeError(`${n} group requires exactly one of field and expression.`);return t.requireValidExpressionTrees([e]),{expression:e}}var p={element(e,t){let n=s(e);return t===void 0?{path:n}:(r.requireElementScopedFilter(t,`Aggregation element filter`,!1),{path:n,filter:t})},field(t){return{type:e.AggregationExpressionType.FIELD,field:s(t)}},constant(t){if(!Number.isFinite(t))throw TypeError(`aggregation constant must be finite.`);return{type:e.AggregationExpressionType.CONSTANT,value:t}},dateDiff(t,n,r){if(!Object.values(e.DateDiffUnit).includes(r))throw TypeError(`date diff unit is invalid.`);return{type:e.AggregationExpressionType.DATE_DIFF,from:s(t),to:s(n),unit:r}},add:(t,n)=>l(e.AggregationExpressionOperator.ADD,t,n),subtract:(t,n)=>l(e.AggregationExpressionOperator.SUBTRACT,t,n),multiply:(t,n)=>l(e.AggregationExpressionOperator.MULTIPLY,t,n),divide:(t,n)=>l(e.AggregationExpressionOperator.DIVIDE,t,n),terms(t,n,{missingKey:r}={}){if(r!==void 0&&(typeof r!=`string`||!r.trim()))throw TypeError(`terms missingKey must not be blank.`);let i=f(t,`TERMS`);if(r!==void 0&&i.expression)throw TypeError(`terms missingKey requires a field input.`);return{type:e.AggregationGroupType.TERMS,...r===void 0?{}:{missingKey:r},...i,alias:c(n)}},histogram(t,n,{interval:r}){if(!Number.isFinite(r)||r<=0)throw TypeError(`histogram interval must be finite and greater than 0.`);return{type:e.AggregationGroupType.HISTOGRAM,...f(t,`HISTOGRAM`),interval:r,alias:c(n)}},dateHistogram(t,n,{unit:r,timeZone:i=`UTC`,dense:a}){if(a!==void 0&&typeof a!=`boolean`)throw TypeError(`date histogram dense must be boolean.`);if(!Object.values(e.AggregationDateUnit).includes(r))throw TypeError(`date histogram unit is invalid.`);if(typeof i!=`string`||!i.trim())throw TypeError(`date histogram timeZone cannot be blank.`);return{type:e.AggregationGroupType.DATE_HISTOGRAM,...a===void 0?{}:{dense:a},field:s(t),unit:r,alias:c(n),timeZone:i}},datePart(t,n,{part:r,timeZone:i=`UTC`,dense:a}){if(a!==void 0&&typeof a!=`boolean`)throw TypeError(`date part dense must be boolean.`);if(!Object.values(e.AggregationDatePart).includes(r))throw TypeError(`date part is invalid.`);if(typeof i!=`string`||!i.trim())throw TypeError(`date part timeZone cannot be blank.`);return{type:e.AggregationGroupType.DATE_PART,...a===void 0?{}:{dense:a},field:s(t),part:r,alias:c(n),timeZone:i}},any(t,n,{filter:r}={}){return{type:e.AggregationMetricType.ANY,...r===void 0?{}:{filter:r},field:s(t),alias:c(n)}},first(t,n,r={}){return d(e.AggregationMetricType.FIRST,t,n,r)},last(t,n,r={}){return d(e.AggregationMetricType.LAST,t,n,r)},count(t,{filter:n}={}){return{type:e.AggregationMetricType.COUNT,...n===void 0?{}:{filter:n},alias:c(t)}},sum:(t,n,r)=>u(e.AggregationFunction.SUM,t,n,r),avg:(t,n,r)=>u(e.AggregationFunction.AVG,t,n,r),min:(t,n,r)=>u(e.AggregationFunction.MIN,t,n,r),max:(t,n,r)=>u(e.AggregationFunction.MAX,t,n,r),stddev:(t,n,r)=>u(e.AggregationFunction.STDDEV,t,n,r),variance:(t,n,r)=>u(e.AggregationFunction.VARIANCE,t,n,r),distinctCount(t,n,{filter:r}={}){return{type:e.AggregationMetricType.DISTINCT_COUNT,expression:t,alias:c(n),...r===void 0?{}:{filter:r}}},percentile(t,n,{percentile:r,filter:i}){if(!Number.isFinite(r)||r<=0||r>=100)throw TypeError(`percentile must be finite and within (0, 100).`);return{type:e.AggregationMetricType.PERCENTILE,expression:t,percentile:r,alias:c(n),...i===void 0?{}:{filter:i}}},derived(t,n){return{type:e.AggregationMetricType.DERIVED,expression:typeof t==`function`?t(a.derivedExpressionDsl):t,alias:c(n)}},having:o.havingDsl,query(e){return i.admitAggregationQuery(e)}};exports.aggregation=p;
|
|
2
|
+
//# sourceMappingURL=builders.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.cjs","names":["queryField","AggregationExpressionType","AggregationMetricType","DateDiffUnit","AggregationExpressionOperator","AggregationGroupType","AggregationDateUnit","AggregationDatePart","AggregationFunction","derivedExpressionDsl","havingDsl","admitAggregationQuery","require_types","require_expressionTrees","require_field","require_scope","require_admit","require_derived","require_having","aggregationField","field","aggregationAlias","alias","binary","numeric","predicate","fn","edge","orderBy","groupInput","input","type","aggregation","validPath","path","value","unit","from","to","left","right","missingKey","source","interval","dense","timeZone","part","options","expression","percentile","query"],"sources":["../../../src/dsl/aggregation/builders.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 { queryField } from '../field.js';\nimport type {\n ElementFilterExpression,\n ExpressionFilter,\n} from '../filter/index.js';\nimport { requireElementScopedFilter } from '../filter/scope.js';\nimport { admitAggregationQuery } from './admit.js';\nimport { requireValidExpressionTrees } from './expressionTrees.js';\nimport { derivedExpressionDsl, type DerivedExpressionDsl } from './derived.js';\nimport { havingDsl } from './having.js';\nimport {\n DateDiffUnit,\n AggregationDatePart,\n AggregationDateUnit,\n AggregationExpressionOperator,\n AggregationExpressionType,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n type AggregationElement,\n type AggregationExpression,\n type AggregationGroupInput,\n type DateDiffAggregationExpression,\n type AggregationMetricOptions,\n type AggregationQuery,\n type AnyAggregationMetric,\n type EdgeAggregationMetric,\n type EdgeAggregationOptions,\n type BinaryAggregationExpression,\n type ConstantAggregationExpression,\n type CountAggregationMetric,\n type DateHistogramAggregationGroup,\n type DateHistogramAggregationOptions,\n type DatePartAggregationGroup,\n type DatePartAggregationOptions,\n type DerivedAggregationMetric,\n type DerivedExpression,\n type DistinctCountAggregationMetric,\n type FieldAggregationExpression,\n type HistogramAggregationGroup,\n type HistogramAggregationOptions,\n type NumericAggregationMetric,\n type PercentileAggregationMetric,\n type PercentileAggregationOptions,\n type TermsAggregationGroup,\n type TermsAggregationOptions,\n} from './types.js';\n\nfunction aggregationField<FIELDS extends string>(field: FIELDS): FIELDS {\n return queryField(field);\n}\n\nfunction aggregationAlias(alias: string): string {\n aggregationField(alias);\n if (alias.includes('.')) {\n throw new TypeError('aggregation alias must contain one segment.');\n }\n if (alias.startsWith('__wow')) {\n throw new TypeError(\n 'aggregation alias must not use the reserved __wow prefix.',\n );\n }\n return alias;\n}\n\nfunction binary<FIELDS extends string>(\n operator: AggregationExpressionOperator,\n left: AggregationExpression<FIELDS>,\n right: AggregationExpression<FIELDS>,\n): BinaryAggregationExpression<FIELDS> {\n return { type: AggregationExpressionType.BINARY, operator, left, right };\n}\n\nfunction numeric<FIELDS extends string>(\n fn: AggregationFunction,\n expression: AggregationExpression<FIELDS>,\n alias: string,\n { filter: predicate }: AggregationMetricOptions<FIELDS> = {},\n): NumericAggregationMetric<FIELDS> {\n return {\n type: AggregationMetricType.NUMERIC,\n ...(predicate === undefined ? {} : { filter: predicate }),\n function: fn,\n expression,\n alias: aggregationAlias(alias),\n };\n}\n\n/** Builds a `FIRST` or `LAST` metric; {@link aggregation.first}. */\nfunction edge<FIELDS extends string>(\n type: AggregationMetricType.FIRST | AggregationMetricType.LAST,\n field: FIELDS,\n alias: string,\n { orderBy, filter: predicate }: EdgeAggregationOptions<FIELDS>,\n): EdgeAggregationMetric<FIELDS> {\n return {\n type,\n field: aggregationField(field),\n alias: aggregationAlias(alias),\n ...(orderBy === undefined ? {} : { orderBy: aggregationField(orderBy) }),\n ...(predicate === undefined ? {} : { filter: predicate }),\n };\n}\n\n/**\n * The input of a TERMS or HISTOGRAM group: a field path, or an expression in\n * its place, never both, as Wow's `requireGroupInput` has it.\n */\nfunction groupInput<FIELDS extends string>(\n input: FIELDS | AggregationExpression<FIELDS>,\n type: string,\n): AggregationGroupInput<FIELDS> {\n if (typeof input === 'string') return { field: aggregationField(input) };\n if (input === null || typeof input !== 'object') {\n throw new TypeError(\n `${type} group requires exactly one of field and expression.`,\n );\n }\n requireValidExpressionTrees([input]);\n return { expression: input };\n}\n\n/**\n * Builders of an `AggregationQuery`: its elements, groups, metrics and the\n * arithmetic expressions metrics compute over. Each builder checks its own\n * part and throws a `TypeError` naming what is wrong; {@link aggregation.query}\n * checks the parts against each other.\n *\n * Every group and metric takes its target first, its alias second, and any\n * further options as a trailing object.\n */\nexport const aggregation = {\n /**\n * Aggregates over the elements of an array field instead of the root\n * documents. `{ path, filter? }`.\n *\n * @param path - The array field, a query field path.\n * @param predicate - Keeps only the elements that match; may not contain\n * root filters (id, owner, tenant, space, deletion) or any search, even\n * one that names its fields. An `EXPRESSION` filter is allowed.\n * @throws TypeError when `path` is not a valid field path or `predicate`\n * contains a root filter.\n * @example\n * ```typescript\n * aggregation.element('items', filter.gt('quantity', 0));\n * ```\n */\n element(\n path: string,\n predicate?: ElementFilterExpression | ExpressionFilter,\n ): AggregationElement {\n const validPath = aggregationField(path);\n if (predicate === undefined) return { path: validPath };\n requireElementScopedFilter(predicate, 'Aggregation element filter', false);\n return { path: validPath, filter: predicate };\n },\n /**\n * The value of a field, as an operand. `{ type: 'FIELD', field }`.\n *\n * @throws TypeError when `field` is not a valid field path.\n * @example\n * ```typescript\n * aggregation.sum(aggregation.field('state.amount'), 'amount');\n * ```\n */\n field<FIELDS extends string>(\n field: FIELDS,\n ): FieldAggregationExpression<FIELDS> {\n return {\n type: AggregationExpressionType.FIELD,\n field: aggregationField(field),\n };\n },\n /**\n * A number, as an operand. `{ type: 'CONSTANT', value }`.\n *\n * @throws TypeError when `value` is not finite.\n * @example\n * ```typescript\n * aggregation.multiply(aggregation.field('price'), aggregation.constant(100));\n * ```\n */\n constant(value: number): ConstantAggregationExpression {\n if (!Number.isFinite(value)) {\n throw new TypeError('aggregation constant must be finite.');\n }\n return { type: AggregationExpressionType.CONSTANT, value };\n },\n /**\n * The time from the instant in `from` to the instant in `to`, `to − from`,\n * in `unit`, as a signed decimal: negative when `to` is earlier, and no\n * value when either instant is absent. A `DAY` is exactly 24 hours.\n * `{ type: 'DATE_DIFF', from, to, unit }`. Both fields must be\n * single-valued time fields, those whose `aggregate.groups` list\n * `DATE_HISTOGRAM` in the descriptor, and `unit` one of its\n * `analysis.dateDiffUnits`. Wow 9.2 and later.\n *\n * @throws TypeError when `from` or `to` is not a valid field path, or\n * `unit` is not a {@link DateDiffUnit}.\n * @example\n * ```typescript\n * // Hours from payment to shipping, averaged per warehouse.\n * aggregation.avg(\n * aggregation.dateDiff('state.paidAt', 'state.shippedAt', DateDiffUnit.HOUR),\n * 'hoursToShip',\n * );\n * ```\n */\n dateDiff<FIELDS extends string>(\n from: FIELDS,\n to: FIELDS,\n unit: DateDiffUnit,\n ): DateDiffAggregationExpression<FIELDS> {\n if (!Object.values(DateDiffUnit).includes(unit)) {\n throw new TypeError('date diff unit is invalid.');\n }\n return {\n type: AggregationExpressionType.DATE_DIFF,\n from: aggregationField(from),\n to: aggregationField(to),\n unit,\n };\n },\n /** `left + right`. `{ type: 'BINARY', operator: 'ADD', left, right }`. */\n add: <FIELDS extends string>(\n left: AggregationExpression<FIELDS>,\n right: AggregationExpression<FIELDS>,\n ) => binary(AggregationExpressionOperator.ADD, left, right),\n /** `left - right`. `{ type: 'BINARY', operator: 'SUBTRACT', left, right }`. */\n subtract: <FIELDS extends string>(\n left: AggregationExpression<FIELDS>,\n right: AggregationExpression<FIELDS>,\n ) => binary(AggregationExpressionOperator.SUBTRACT, left, right),\n /** `left * right`. `{ type: 'BINARY', operator: 'MULTIPLY', left, right }`. */\n multiply: <FIELDS extends string>(\n left: AggregationExpression<FIELDS>,\n right: AggregationExpression<FIELDS>,\n ) => binary(AggregationExpressionOperator.MULTIPLY, left, right),\n /** `left / right`. `{ type: 'BINARY', operator: 'DIVIDE', left, right }`. */\n divide: <FIELDS extends string>(\n left: AggregationExpression<FIELDS>,\n right: AggregationExpression<FIELDS>,\n ) => binary(AggregationExpressionOperator.DIVIDE, left, right),\n /**\n * Groups by each distinct value of a field, or of a computed expression.\n * `{ type: 'TERMS', field, alias, missingKey? }`, or\n * `{ type: 'TERMS', expression, alias }`.\n *\n * @param input - The field to group by, or an expression in its place\n * (Wow 9.2 and later, an expensive computation).\n * @param alias - The name of the group column in the result rows.\n * @param options.missingKey - The key of the rows without a value; only\n * with a field.\n * @throws TypeError when `input` or `alias` is invalid, `missingKey` is\n * blank, or `missingKey` is given with an expression.\n * @example\n * ```typescript\n * aggregation.terms('state.status', 'status', { missingKey: 'NONE' });\n * aggregation.terms(\n * aggregation.dateDiff('state.paidAt', 'state.shippedAt', DateDiffUnit.DAY),\n * 'daysToShip',\n * );\n * ```\n */\n terms<FIELDS extends string>(\n input: FIELDS | AggregationExpression<FIELDS>,\n alias: string,\n { missingKey }: TermsAggregationOptions = {},\n ): TermsAggregationGroup<FIELDS> {\n if (\n missingKey !== undefined &&\n (typeof missingKey !== 'string' || !missingKey.trim())\n ) {\n throw new TypeError('terms missingKey must not be blank.');\n }\n const source = groupInput(input, 'TERMS');\n if (missingKey !== undefined && source.expression) {\n throw new TypeError('terms missingKey requires a field input.');\n }\n return {\n type: AggregationGroupType.TERMS,\n ...(missingKey === undefined ? {} : { missingKey }),\n ...source,\n alias: aggregationAlias(alias),\n };\n },\n /**\n * Groups a number field, or a computed expression, into buckets of equal\n * width. `{ type: 'HISTOGRAM', field | expression, interval, alias }`.\n *\n * @param input - The number field to bucket, or an expression in its\n * place (Wow 9.2 and later, an expensive computation).\n * @param alias - The name of the bucket column in the result rows.\n * @param options.interval - The bucket width.\n * @throws TypeError when `interval` is not finite and greater than 0, or\n * `field` or `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.histogram('state.amount', 'amountBand', { interval: 100 });\n * ```\n */\n histogram<FIELDS extends string>(\n input: FIELDS | AggregationExpression<FIELDS>,\n alias: string,\n { interval }: HistogramAggregationOptions,\n ): HistogramAggregationGroup<FIELDS> {\n if (!Number.isFinite(interval) || interval <= 0) {\n throw new TypeError(\n 'histogram interval must be finite and greater than 0.',\n );\n }\n return {\n type: AggregationGroupType.HISTOGRAM,\n ...groupInput(input, 'HISTOGRAM'),\n interval,\n alias: aggregationAlias(alias),\n };\n },\n /**\n * Groups a time field into calendar buckets.\n * `{ type: 'DATE_HISTOGRAM', field, unit, alias, timeZone, dense? }`.\n *\n * @param field - The time field (epoch milliseconds) to bucket.\n * @param alias - The name of the bucket column in the result rows.\n * @param options.unit - The calendar unit of a bucket.\n * @param options.timeZone - The zone buckets are cut in. Defaults to `UTC`.\n * @param options.dense - Whether the empty buckets of the range are filled\n * in.\n * @throws TypeError when `unit` is not an `AggregationDateUnit`,\n * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is\n * invalid.\n * @example\n * ```typescript\n * aggregation.dateHistogram('createTime', 'day', {\n * unit: AggregationDateUnit.DAY,\n * timeZone: 'Asia/Shanghai',\n * });\n * ```\n */\n dateHistogram<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n { unit, timeZone = 'UTC', dense }: DateHistogramAggregationOptions,\n ): DateHistogramAggregationGroup<FIELDS> {\n if (dense !== undefined && typeof dense !== 'boolean') {\n throw new TypeError('date histogram dense must be boolean.');\n }\n if (!Object.values(AggregationDateUnit).includes(unit)) {\n throw new TypeError('date histogram unit is invalid.');\n }\n if (typeof timeZone !== 'string' || !timeZone.trim()) {\n throw new TypeError('date histogram timeZone cannot be blank.');\n }\n return {\n type: AggregationGroupType.DATE_HISTOGRAM,\n ...(dense === undefined ? {} : { dense }),\n field: aggregationField(field),\n unit,\n alias: aggregationAlias(alias),\n timeZone,\n };\n },\n /**\n * Groups a time field by one calendar part of each instant, such as the\n * weekday or the hour, so records from different days share a bucket.\n * `{ type: 'DATE_PART', field, part, alias, timeZone, dense? }`.\n *\n * The group's keys in the result rows are integers: `DAY_OF_WEEK` is the\n * ISO weekday, 1 (Monday) to 7 (Sunday); `DAY_OF_MONTH` 1 to 31;\n * `HOUR_OF_DAY` 0 to 23 on the wall clock of `timeZone`; `MONTH_OF_YEAR`\n * 1 to 12. With `dense`, every key of that domain comes back, those\n * without records carrying each metric's empty value; `dense` needs the\n * group to be the query's only one. Wow 9.2 and later.\n *\n * @param field - The time field (epoch milliseconds) to read the part of.\n * @param alias - The name of the part column in the result rows.\n * @param options.part - The calendar part to group by.\n * @param options.timeZone - The zone the part is read in. Defaults to\n * `UTC`.\n * @param options.dense - Whether every key of the part's domain is\n * returned.\n * @throws TypeError when `part` is not an `AggregationDatePart`,\n * `timeZone` is blank, `dense` is not a boolean, or `field` or `alias` is\n * invalid.\n * @example\n * ```typescript\n * aggregation.datePart('createTime', 'weekday', {\n * part: AggregationDatePart.DAY_OF_WEEK,\n * timeZone: 'Asia/Shanghai',\n * });\n * ```\n */\n datePart<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n { part, timeZone = 'UTC', dense }: DatePartAggregationOptions,\n ): DatePartAggregationGroup<FIELDS> {\n if (dense !== undefined && typeof dense !== 'boolean') {\n throw new TypeError('date part dense must be boolean.');\n }\n if (!Object.values(AggregationDatePart).includes(part)) {\n throw new TypeError('date part is invalid.');\n }\n if (typeof timeZone !== 'string' || !timeZone.trim()) {\n throw new TypeError('date part timeZone cannot be blank.');\n }\n return {\n type: AggregationGroupType.DATE_PART,\n ...(dense === undefined ? {} : { dense }),\n field: aggregationField(field),\n part,\n alias: aggregationAlias(alias),\n timeZone,\n };\n },\n /**\n * Any one value of a field within each group, of any type.\n * `{ type: 'ANY', field, alias, filter? }`.\n *\n * @throws TypeError when `field` or `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.any('state.customerName', 'customer');\n * ```\n */\n any<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n { filter: predicate }: AggregationMetricOptions<FIELDS> = {},\n ): AnyAggregationMetric<FIELDS> {\n return {\n type: AggregationMetricType.ANY,\n ...(predicate === undefined ? {} : { filter: predicate }),\n field: aggregationField(field),\n alias: aggregationAlias(alias),\n };\n },\n /**\n * The value of `field` on each group's earliest record by `orderBy`.\n * `{ type: 'FIRST', field, alias, orderBy?, filter? }`.\n *\n * The value comes back in the field's own type, or `null` when no record\n * of the group has both a value and an `orderBy` position. Without\n * `orderBy` the server orders by the model's event time, which the\n * descriptor names as `analysis.firstLastOrderBy`. Neither a derived\n * metric nor `having` may refer to it. Wow 9.2 and later.\n *\n * @throws TypeError when `field`, `orderBy` or `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.first('state.price', 'open', { orderBy: 'createTime' });\n * ```\n */\n first<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n options: EdgeAggregationOptions<FIELDS> = {},\n ): EdgeAggregationMetric<FIELDS> {\n return edge(AggregationMetricType.FIRST, field, alias, options);\n },\n /**\n * The value of `field` on each group's latest record by `orderBy`.\n * `{ type: 'LAST', field, alias, orderBy?, filter? }`. As\n * {@link aggregation.first}, from the other end.\n *\n * @throws TypeError when `field`, `orderBy` or `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.last('state.price', 'close', { orderBy: 'createTime' });\n * ```\n */\n last<FIELDS extends string>(\n field: FIELDS,\n alias: string,\n options: EdgeAggregationOptions<FIELDS> = {},\n ): EdgeAggregationMetric<FIELDS> {\n return edge(AggregationMetricType.LAST, field, alias, options);\n },\n /**\n * The number of rows in each group. `{ type: 'COUNT', alias, filter? }`.\n *\n * @param alias - The name of the metric column in the result rows.\n * @param options.filter - Counts only the rows that match.\n * @throws TypeError when `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.count('paid', { filter: filter.eq('state.status', 'PAID') });\n * ```\n */\n count<FIELDS extends string = string>(\n alias: string,\n { filter: predicate }: AggregationMetricOptions<FIELDS> = {},\n ): CountAggregationMetric<FIELDS> {\n return {\n type: AggregationMetricType.COUNT,\n ...(predicate === undefined ? {} : { filter: predicate }),\n alias: aggregationAlias(alias),\n };\n },\n /**\n * The sum of an expression. `{ type: 'NUMERIC', function: 'SUM',\n * expression, alias, filter? }`.\n *\n * @example\n * ```typescript\n * aggregation.sum(aggregation.field('state.amount'), 'revenue');\n * ```\n */\n sum: <FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n options?: AggregationMetricOptions<FIELDS>,\n ) => numeric(AggregationFunction.SUM, expression, alias, options),\n /** The average of an expression; see {@link aggregation.sum}. */\n avg: <FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n options?: AggregationMetricOptions<FIELDS>,\n ) => numeric(AggregationFunction.AVG, expression, alias, options),\n /** The least value of an expression; see {@link aggregation.sum}. */\n min: <FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n options?: AggregationMetricOptions<FIELDS>,\n ) => numeric(AggregationFunction.MIN, expression, alias, options),\n /** The greatest value of an expression; see {@link aggregation.sum}. */\n max: <FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n options?: AggregationMetricOptions<FIELDS>,\n ) => numeric(AggregationFunction.MAX, expression, alias, options),\n /** The standard deviation of an expression; see {@link aggregation.sum}. */\n stddev: <FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n options?: AggregationMetricOptions<FIELDS>,\n ) => numeric(AggregationFunction.STDDEV, expression, alias, options),\n /** The variance of an expression; see {@link aggregation.sum}. */\n variance: <FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n options?: AggregationMetricOptions<FIELDS>,\n ) => numeric(AggregationFunction.VARIANCE, expression, alias, options),\n /**\n * The number of distinct values of an expression.\n * `{ type: 'DISTINCT_COUNT', expression, alias, filter? }`.\n *\n * @example\n * ```typescript\n * aggregation.distinctCount(aggregation.field('ownerId'), 'customers');\n * ```\n */\n distinctCount<FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n { filter: predicate }: AggregationMetricOptions<FIELDS> = {},\n ): DistinctCountAggregationMetric<FIELDS> {\n return {\n type: AggregationMetricType.DISTINCT_COUNT,\n expression,\n alias: aggregationAlias(alias),\n ...(predicate === undefined ? {} : { filter: predicate }),\n };\n },\n /**\n * A percentile of an expression.\n * `{ type: 'PERCENTILE', expression, percentile, alias, filter? }`.\n *\n * @param options.percentile - Which percentile, within (0, 100).\n * @throws TypeError when `percentile` is not finite and within (0, 100), or\n * `alias` is invalid.\n * @example\n * ```typescript\n * aggregation.percentile(aggregation.field('latency'), 'p95', { percentile: 95 });\n * ```\n */\n percentile<FIELDS extends string>(\n expression: AggregationExpression<FIELDS>,\n alias: string,\n { percentile, filter: predicate }: PercentileAggregationOptions<FIELDS>,\n ): PercentileAggregationMetric<FIELDS> {\n if (!Number.isFinite(percentile) || percentile <= 0 || percentile >= 100) {\n throw new TypeError('percentile must be finite and within (0, 100).');\n }\n return {\n type: AggregationMetricType.PERCENTILE,\n expression,\n percentile,\n alias: aggregationAlias(alias),\n ...(predicate === undefined ? {} : { filter: predicate }),\n };\n },\n /**\n * A metric computed from other metrics of the same row, by their aliases.\n * `{ type: 'DERIVED', expression, alias }`. `aggregation.query()` checks\n * that it refers only to metrics declared before it.\n *\n * @param expression - The arithmetic: a callback that builds it from the\n * {@link DerivedExpressionDsl} it is handed (`ref`, `constant`, `add`,\n * `subtract`, `multiply`, `divide`), or an already-built tree.\n * @throws TypeError when `alias` is invalid, or a `constant` is not finite.\n * @example\n * ```typescript\n * aggregation.derived(\n * d => d.divide(d.ref('revenue'), d.ref('orders')),\n * 'averageOrder',\n * );\n * ```\n */\n derived(\n expression:\n DerivedExpression | ((d: DerivedExpressionDsl) => DerivedExpression),\n alias: string,\n ): DerivedAggregationMetric {\n return {\n type: AggregationMetricType.DERIVED,\n expression:\n typeof expression === 'function'\n ? expression(derivedExpressionDsl)\n : expression,\n alias: aggregationAlias(alias),\n };\n },\n /**\n * The builders of the query's `having`: conditions on the metric columns of\n * the grouped rows (`eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `between`, `isIn`,\n * `isNull`, `isNotNull`) and their `and`/`or`. See `HavingDsl`.\n *\n * @example\n * ```typescript\n * aggregation.query({\n * groupBy: [aggregation.terms('state.status', 'status')],\n * metrics: [aggregation.count('orders')],\n * having: aggregation.having.gt('orders', 10),\n * });\n * ```\n */\n having: havingDsl,\n\n /**\n * Admits a whole aggregation query against the rules Wow enforces on arrival.\n *\n * The factories above each check their own part; only the assembled query\n * can answer the questions that span parts — whether two aliases collide,\n * whether a sort names one of them, whether `having` has rows to filter.\n * Wow checks all of it in `AggregationQuery`'s constructor and answers a\n * query that fails with a 400, so the same rules run here against the object\n * about to be sent.\n */\n query<\n ROOT_FIELDS extends string = string,\n AGGREGATION_FIELDS extends string = ROOT_FIELDS,\n >(\n query: AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS>,\n ): AggregationQuery<ROOT_FIELDS, AGGREGATION_FIELDS> {\n return admitAggregationQuery(query);\n },\n};\n"],"mappings":"2MA6DA,SAASmB,EAAwC,EAAuB,CACtE,OAAOnB,EAAAA,WAAWoB,CAAK,CACzB,CAEA,SAASC,EAAiB,EAAuB,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