@dcupl/common 1.11.11 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/attribute-dependency-graph.d.ts +119 -0
- package/dist/esm/cache.controller.d.ts +56 -1
- package/dist/esm/changeDetection.d.ts +1 -1
- package/dist/esm/date-utils.d.ts +50 -0
- package/dist/esm/deep-query.service.d.ts +133 -0
- package/dist/esm/dependency-graph.d.ts +102 -3
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +3096 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/indices.controller.d.ts +92 -0
- package/dist/esm/logger/index.d.ts +2 -0
- package/dist/esm/logger/logger.d.ts +101 -0
- package/dist/esm/pivot.d.ts +2 -1
- package/dist/esm/query-builder.d.ts +435 -2
- package/dist/esm/queryData.d.ts +9 -4
- package/dist/esm/types/dcupl.types.d.ts +80 -0
- package/dist/esm/types/internal.types.d.ts +1 -1
- package/dist/esm/types/list.types.d.ts +10 -0
- package/dist/esm/types/model.types.d.ts +49 -12
- package/dist/esm/types/query.types.d.ts +500 -2
- package/dist/node/index.cjs +5 -0
- package/dist/node/index.cjs.map +1 -0
- package/package.json +7 -8
- package/dist/browser/common.umd.js +0 -2
- package/dist/browser/common.umd.js.map +0 -1
- package/dist/esm/analytics.controller.js +0 -105
- package/dist/esm/analytics.controller.js.map +0 -1
- package/dist/esm/cache.controller.js +0 -40
- package/dist/esm/cache.controller.js.map +0 -1
- package/dist/esm/changeDetection.js +0 -179
- package/dist/esm/changeDetection.js.map +0 -1
- package/dist/esm/computeSuggestions.js +0 -38
- package/dist/esm/computeSuggestions.js.map +0 -1
- package/dist/esm/dependency-graph.js +0 -136
- package/dist/esm/dependency-graph.js.map +0 -1
- package/dist/esm/getAggregation.js +0 -170
- package/dist/esm/getAggregation.js.map +0 -1
- package/dist/esm/getFacets.js +0 -67
- package/dist/esm/getFacets.js.map +0 -1
- package/dist/esm/helper.js +0 -102
- package/dist/esm/helper.js.map +0 -1
- package/dist/esm/indices.controller.js +0 -97
- package/dist/esm/indices.controller.js.map +0 -1
- package/dist/esm/object-hash.js +0 -33
- package/dist/esm/object-hash.js.map +0 -1
- package/dist/esm/performance.js +0 -33
- package/dist/esm/performance.js.map +0 -1
- package/dist/esm/pivot.js +0 -132
- package/dist/esm/pivot.js.map +0 -1
- package/dist/esm/property-parser.js +0 -57
- package/dist/esm/property-parser.js.map +0 -1
- package/dist/esm/query-builder.js +0 -233
- package/dist/esm/query-builder.js.map +0 -1
- package/dist/esm/query.helper.js +0 -172
- package/dist/esm/query.helper.js.map +0 -1
- package/dist/esm/queryData.js +0 -360
- package/dist/esm/queryData.js.map +0 -1
- package/dist/esm/script.controller.js +0 -54
- package/dist/esm/script.controller.js.map +0 -1
- package/dist/esm/template-parser.js +0 -22
- package/dist/esm/template-parser.js.map +0 -1
- package/dist/esm/types/aggregation.types.js +0 -2
- package/dist/esm/types/aggregation.types.js.map +0 -1
- package/dist/esm/types/app-loader.types.js +0 -2
- package/dist/esm/types/app-loader.types.js.map +0 -1
- package/dist/esm/types/data.types.js +0 -2
- package/dist/esm/types/data.types.js.map +0 -1
- package/dist/esm/types/dcupl.types.js +0 -2
- package/dist/esm/types/dcupl.types.js.map +0 -1
- package/dist/esm/types/facets.types.js +0 -2
- package/dist/esm/types/facets.types.js.map +0 -1
- package/dist/esm/types/filter.types.js +0 -2
- package/dist/esm/types/filter.types.js.map +0 -1
- package/dist/esm/types/group-by.types.js +0 -2
- package/dist/esm/types/group-by.types.js.map +0 -1
- package/dist/esm/types/index.js +0 -17
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/internal.types.js +0 -2
- package/dist/esm/types/internal.types.js.map +0 -1
- package/dist/esm/types/list.types.js +0 -2
- package/dist/esm/types/list.types.js.map +0 -1
- package/dist/esm/types/model.types.js +0 -16
- package/dist/esm/types/model.types.js.map +0 -1
- package/dist/esm/types/projection.types.js +0 -2
- package/dist/esm/types/projection.types.js.map +0 -1
- package/dist/esm/types/quality.types.js +0 -2
- package/dist/esm/types/quality.types.js.map +0 -1
- package/dist/esm/types/query.types.js +0 -12
- package/dist/esm/types/query.types.js.map +0 -1
- package/dist/esm/types/section.types.js +0 -2
- package/dist/esm/types/section.types.js.map +0 -1
- package/dist/esm/types/suggestion.types.js +0 -2
- package/dist/esm/types/suggestion.types.js.map +0 -1
- package/dist/esm/types/testing.types.js +0 -2
- package/dist/esm/types/testing.types.js.map +0 -1
- package/dist/node/index.cjs.js +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { InverseIndexValuesMap, InverseIndexDataValuesMap, ListItem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Statistics about indices for monitoring
|
|
4
|
+
*/
|
|
5
|
+
export interface IndexStats {
|
|
6
|
+
shallow: number;
|
|
7
|
+
deep: number;
|
|
8
|
+
total: number;
|
|
9
|
+
oldestAge: number;
|
|
10
|
+
avgAge: number;
|
|
11
|
+
}
|
|
2
12
|
export declare class IndicesController {
|
|
3
13
|
private indexMap;
|
|
4
14
|
private dataMap;
|
|
15
|
+
private indexMetadata;
|
|
5
16
|
constructor();
|
|
6
17
|
reset(attributeKey?: string): void;
|
|
7
18
|
fillDataMap(attributeKey: string, attributeValue: Array<string | undefined | ListItem>): void;
|
|
@@ -10,4 +21,85 @@ export declare class IndicesController {
|
|
|
10
21
|
getData(attributeKey: string, context?: any): InverseIndexDataValuesMap | undefined;
|
|
11
22
|
getOrCreateIndex(attributeKey: string, relevantData: Map<string, ListItem>, context?: any): InverseIndexValuesMap;
|
|
12
23
|
getIndexName(attributeKey: string, context?: any): string;
|
|
24
|
+
/**
|
|
25
|
+
* Removes a specific item from an inverse index
|
|
26
|
+
* @param attributeKey - The attribute key
|
|
27
|
+
* @param itemKey - The item key to remove
|
|
28
|
+
* @param oldValues - The old attribute values to remove from the index
|
|
29
|
+
*/
|
|
30
|
+
removeFromInverseIndex(attributeKey: string, itemKey: string, oldValues: Array<string | undefined | ListItem>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Updates inverse index for a specific item by removing old values and adding new ones
|
|
33
|
+
* @param attributeKey - The attribute key
|
|
34
|
+
* @param itemKey - The item key being updated
|
|
35
|
+
* @param oldValues - The old attribute values to remove
|
|
36
|
+
* @param newValues - The new attribute values to add
|
|
37
|
+
*/
|
|
38
|
+
updateInverseIndex(attributeKey: string, itemKey: string, oldValues: Array<string | undefined | ListItem>, newValues: Array<string | undefined | ListItem>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Removes a specific item from the data map
|
|
41
|
+
* @param attributeKey - The attribute key
|
|
42
|
+
* @param values - The values to remove
|
|
43
|
+
*/
|
|
44
|
+
removeFromDataMap(attributeKey: string, values: Array<string | undefined | ListItem>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Updates data map for a specific item by removing old values and adding new ones
|
|
47
|
+
* @param attributeKey - The attribute key
|
|
48
|
+
* @param oldValues - The old values to remove
|
|
49
|
+
* @param newValues - The new values to add
|
|
50
|
+
*/
|
|
51
|
+
updateDataMap(attributeKey: string, oldValues: Array<string | undefined | ListItem>, newValues: Array<string | undefined | ListItem>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Completely removes an item from all indices
|
|
54
|
+
* Used when an item is deleted
|
|
55
|
+
* @param itemKey - The item key to remove
|
|
56
|
+
*/
|
|
57
|
+
removeItemFromAllIndices(itemKey: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Resets indices for specific attributes only
|
|
60
|
+
* Useful for partial updates when only certain attributes changed
|
|
61
|
+
* @param attributeKeys - Array of attribute keys to reset
|
|
62
|
+
*/
|
|
63
|
+
resetAttributes(attributeKeys: string[]): void;
|
|
64
|
+
/**
|
|
65
|
+
* Checks if an index key represents a deep query (contains dots in the attribute path)
|
|
66
|
+
* Uses deep query service for accurate detection
|
|
67
|
+
* @param indexKey - The index key to check
|
|
68
|
+
* @returns true if the index is for a deep query attribute
|
|
69
|
+
*/
|
|
70
|
+
private isDeepQueryIndex;
|
|
71
|
+
/**
|
|
72
|
+
* Gets all deep query index keys currently in the index map
|
|
73
|
+
* @returns Array of index keys that represent deep queries
|
|
74
|
+
*/
|
|
75
|
+
getDeepIndexKeys(): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Resets all deep query indices (e.g., "customer.country", "order.customer.address.city")
|
|
78
|
+
* This is critical for data updates as deep query indices need to be rebuilt
|
|
79
|
+
* when underlying data changes.
|
|
80
|
+
*
|
|
81
|
+
* Shallow indices (direct attributes) are preserved as they're updated incrementally.
|
|
82
|
+
*/
|
|
83
|
+
resetAllDeepIndices(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Gets count of indices by type for monitoring and debugging
|
|
86
|
+
* @returns Object with counts of shallow and deep indices
|
|
87
|
+
*/
|
|
88
|
+
getIndexCount(): {
|
|
89
|
+
shallow: number;
|
|
90
|
+
deep: number;
|
|
91
|
+
total: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Removes stale indices that haven't been accessed recently
|
|
95
|
+
* This helps prevent memory buildup from indices with varying contexts
|
|
96
|
+
* @param maxAge - Maximum age in milliseconds (default: 5 minutes)
|
|
97
|
+
* @returns Number of indices cleaned up
|
|
98
|
+
*/
|
|
99
|
+
cleanupStaleIndices(maxAge?: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* Gets comprehensive statistics about indices for monitoring
|
|
102
|
+
* @returns IndexStats object with counts and age information
|
|
103
|
+
*/
|
|
104
|
+
getStats(): IndexStats;
|
|
13
105
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
2
|
+
export interface LoggerConfig {
|
|
3
|
+
/** Minimum log level to output */
|
|
4
|
+
level?: LogLevel;
|
|
5
|
+
/** Output format: 'json' for production/cloud, 'pretty' for development */
|
|
6
|
+
format?: 'json' | 'pretty';
|
|
7
|
+
/** Optional prefix for all log messages (useful for module identification) */
|
|
8
|
+
prefix?: string;
|
|
9
|
+
/** Custom log handler (useful for sending logs to external services) */
|
|
10
|
+
onLog?: (entry: LogEntry) => void;
|
|
11
|
+
/** Handler for tracked errors (integrates with QualityController) */
|
|
12
|
+
onTrackError?: (entry: TrackedErrorEntry) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface LogEntry {
|
|
15
|
+
level: LogLevel;
|
|
16
|
+
message: string;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
prefix?: string;
|
|
19
|
+
context?: Record<string, any>;
|
|
20
|
+
error?: Error;
|
|
21
|
+
}
|
|
22
|
+
export interface TrackedErrorEntry extends LogEntry {
|
|
23
|
+
level: 'error';
|
|
24
|
+
errorType?: string;
|
|
25
|
+
errorGroup?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class Logger {
|
|
28
|
+
private config;
|
|
29
|
+
private static globalConfig;
|
|
30
|
+
constructor(config?: LoggerConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Set global logger configuration (affects all logger instances)
|
|
33
|
+
*/
|
|
34
|
+
static setGlobalConfig(config: Partial<LoggerConfig>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get the global logger configuration
|
|
37
|
+
*/
|
|
38
|
+
static getGlobalConfig(): Partial<LoggerConfig>;
|
|
39
|
+
/**
|
|
40
|
+
* Configure module-specific log levels
|
|
41
|
+
* @example
|
|
42
|
+
* logger.setModuleLevel('ModelParser', 'debug');
|
|
43
|
+
* logger.setModuleLevel('Catalog', 'warn');
|
|
44
|
+
*/
|
|
45
|
+
static setModuleLevel(module: string, level: LogLevel): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get module-specific log level
|
|
48
|
+
*/
|
|
49
|
+
private static getModuleLevel;
|
|
50
|
+
private getDefaultLevel;
|
|
51
|
+
private getDefaultFormat;
|
|
52
|
+
private getEffectiveLevel;
|
|
53
|
+
private shouldLog;
|
|
54
|
+
private formatMessage;
|
|
55
|
+
private getLevelIcon;
|
|
56
|
+
private log;
|
|
57
|
+
/**
|
|
58
|
+
* Log an error message
|
|
59
|
+
*/
|
|
60
|
+
error(message: string, errorOrContext?: Error | Record<string, any>, context?: Record<string, any>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Log and track an error (integrates with QualityController)
|
|
63
|
+
* @param message Error message
|
|
64
|
+
* @param error Error object
|
|
65
|
+
* @param options Additional context and error classification
|
|
66
|
+
*/
|
|
67
|
+
trackError(message: string, error?: Error, options?: {
|
|
68
|
+
context?: Record<string, any>;
|
|
69
|
+
errorType?: string;
|
|
70
|
+
errorGroup?: string;
|
|
71
|
+
}): void;
|
|
72
|
+
/**
|
|
73
|
+
* Log a warning message
|
|
74
|
+
*/
|
|
75
|
+
warn(message: string, context?: Record<string, any>): void;
|
|
76
|
+
/**
|
|
77
|
+
* Log an info message
|
|
78
|
+
*/
|
|
79
|
+
info(message: string, context?: Record<string, any>): void;
|
|
80
|
+
/**
|
|
81
|
+
* Log a debug message
|
|
82
|
+
*/
|
|
83
|
+
debug(message: string, context?: Record<string, any>): void;
|
|
84
|
+
/**
|
|
85
|
+
* Create a child logger with additional context or configuration
|
|
86
|
+
* Child loggers inherit parent config but can override specific settings
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* const modelLogger = logger.child({ prefix: 'ModelParser' });
|
|
90
|
+
* modelLogger.info('Processing data'); // [ModelParser] Processing data
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* const debugLogger = logger.child({ prefix: 'Catalog', level: 'debug' });
|
|
94
|
+
*/
|
|
95
|
+
child(childConfig: Partial<LoggerConfig>): Logger;
|
|
96
|
+
/**
|
|
97
|
+
* Update this logger's configuration
|
|
98
|
+
*/
|
|
99
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
100
|
+
}
|
|
101
|
+
export declare const logger: Logger;
|
package/dist/esm/pivot.d.ts
CHANGED
|
@@ -19,10 +19,11 @@ export type PivotOptions = {
|
|
|
19
19
|
};
|
|
20
20
|
type PivotResponseItem = {
|
|
21
21
|
key: string;
|
|
22
|
+
value?: any;
|
|
22
23
|
values?: Aggregation[];
|
|
23
24
|
columns?: Omit<PivotResponseItem, 'rows'>[];
|
|
24
25
|
rows?: PivotResponseItem[];
|
|
25
26
|
};
|
|
26
27
|
export type PivotResponse = PivotResponseItem;
|
|
27
|
-
export declare function pivot<ListType extends ListItem = ListItem>(relevantData: Map<string, ListType>, options: PivotOptions, response?: PivotResponse, parentPath?: string, indicesCtrl?: IndicesController): PivotResponse;
|
|
28
|
+
export declare function pivot<ListType extends ListItem = ListItem>(relevantData: Map<string, ListType>, options: PivotOptions, response?: PivotResponse, parentPath?: string, indicesCtrl?: IndicesController, projectedData?: Map<string, ListType>): PivotResponse;
|
|
28
29
|
export {};
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { DcuplGlobalQueryOptions, DcuplItemsOptions, DcuplQuery, DcuplQueryGroup } from './types';
|
|
2
|
+
import { DeepQueryService } from './deep-query.service';
|
|
3
|
+
export type QueryAttributeEntry = {
|
|
4
|
+
attribute: string;
|
|
5
|
+
reference?: string;
|
|
6
|
+
referenceAttribute?: string;
|
|
7
|
+
isDeepQuery?: boolean;
|
|
8
|
+
};
|
|
2
9
|
export declare class DcuplQueryBuilder {
|
|
3
10
|
private _defaultQueryOptions;
|
|
4
11
|
private _initOptions;
|
|
5
12
|
private currentQuery;
|
|
6
|
-
|
|
13
|
+
private deepQueryService;
|
|
14
|
+
constructor(deepQueryServiceInstance?: DeepQueryService);
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the query builder.
|
|
17
|
+
* Accepts either minimal options with just modelKey, or a complete query object.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Minimal { modelKey } or full DcuplGlobalQueryOptions
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Minimal initialization
|
|
23
|
+
* builder.init({ modelKey: 'Product' });
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Full query initialization
|
|
27
|
+
* builder.init({
|
|
28
|
+
* modelKey: 'Product',
|
|
29
|
+
* groupType: 'and',
|
|
30
|
+
* queries: [
|
|
31
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
32
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
33
|
+
* ],
|
|
34
|
+
* count: 10,
|
|
35
|
+
* sort: { price: 'asc' }
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
7
38
|
init(options: {
|
|
8
39
|
modelKey: string;
|
|
9
|
-
}): void;
|
|
40
|
+
} | DcuplGlobalQueryOptions<any>): void;
|
|
10
41
|
reset(): DcuplGlobalQueryOptions<any>;
|
|
11
42
|
isQuery(query: Partial<DcuplQuery> | Partial<DcuplQueryGroup>): query is DcuplQuery;
|
|
12
43
|
isQueryGroup(query: Partial<DcuplQuery> | Partial<DcuplQueryGroup>): query is DcuplQueryGroup;
|
|
@@ -23,10 +54,412 @@ export declare class DcuplQueryBuilder {
|
|
|
23
54
|
errors?: Error[];
|
|
24
55
|
};
|
|
25
56
|
applyOptions(options: DcuplItemsOptions<any>, mode?: 'set' | 'update'): DcuplGlobalQueryOptions<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Apply query conditions, groups, or complete queries.
|
|
59
|
+
* This method has implicit behavior based on input type.
|
|
60
|
+
*
|
|
61
|
+
* @deprecated Use explicit methods instead for clearer intent:
|
|
62
|
+
* - {@link addCondition} - Add single condition
|
|
63
|
+
* - {@link addConditions} - Add multiple conditions
|
|
64
|
+
* - {@link addGroup} - Add query group
|
|
65
|
+
* - {@link setCondition} - Replace condition
|
|
66
|
+
* - {@link setConditions} - Replace conditions
|
|
67
|
+
* - {@link setGroup} - Replace query group
|
|
68
|
+
* - {@link mergeQuery} - Merge complete query
|
|
69
|
+
* - {@link replaceQuery} - Replace complete query
|
|
70
|
+
*
|
|
71
|
+
* @param queryToApply - Query, condition, or array to apply
|
|
72
|
+
* @param options - Mode: 'add' (default) or 'set' (replace)
|
|
73
|
+
* @param relevantQuery - Target query (defaults to current)
|
|
74
|
+
* @returns Updated query
|
|
75
|
+
*/
|
|
26
76
|
applyQuery(queryToApply: DcuplGlobalQueryOptions<any> | DcuplQueryGroup | DcuplQuery | DcuplQuery[] | DcuplQueryGroup[], options?: {
|
|
27
77
|
mode?: 'set' | 'add';
|
|
28
78
|
}, relevantQuery?: DcuplGlobalQueryOptions<any>): DcuplGlobalQueryOptions<any>;
|
|
79
|
+
/**
|
|
80
|
+
* Remove all query conditions.
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Use {@link clearConditions} for clearer intent.
|
|
83
|
+
* @returns Query with no conditions
|
|
84
|
+
*/
|
|
29
85
|
removeAllQueries(): DcuplGlobalQueryOptions<any>;
|
|
86
|
+
/**
|
|
87
|
+
* Remove a specific query or query group.
|
|
88
|
+
*
|
|
89
|
+
* @param queryToRemove - Query or group to remove (partial match)
|
|
90
|
+
* @param relevantQuery - Target query (defaults to current)
|
|
91
|
+
* @returns Updated query
|
|
92
|
+
*/
|
|
30
93
|
removeQuery(queryToRemove: Partial<DcuplQueryGroup | DcuplQuery>, relevantQuery?: DcuplGlobalQueryOptions<any>): DcuplGlobalQueryOptions<any>;
|
|
31
94
|
private validateQuery;
|
|
95
|
+
/**
|
|
96
|
+
* Get all attribute names used in the query.
|
|
97
|
+
*
|
|
98
|
+
* @deprecated Use {@link getAttributeNames} for clearer naming.
|
|
99
|
+
* @param query - Optional query to analyze
|
|
100
|
+
* @returns Array of attribute names
|
|
101
|
+
*/
|
|
102
|
+
getQueryAttributes(query?: DcuplGlobalQueryOptions<any>): string[];
|
|
103
|
+
/**
|
|
104
|
+
* Extract detailed attribute information from query.
|
|
105
|
+
*
|
|
106
|
+
* @deprecated Use {@link getAttributeDetails} for clearer naming.
|
|
107
|
+
* @param query - Query to analyze
|
|
108
|
+
* @returns Array of QueryAttributeEntry objects
|
|
109
|
+
*/
|
|
110
|
+
extractQueryAttributes(query: DcuplGlobalQueryOptions<any>): QueryAttributeEntry[];
|
|
111
|
+
/**
|
|
112
|
+
* Parse an attribute string into its components using the DeepQueryService
|
|
113
|
+
* This method now delegates to the centralized DeepQueryService for consistent
|
|
114
|
+
* parsing, caching, and validation across the codebase.
|
|
115
|
+
*
|
|
116
|
+
* @param attribute - The attribute path to parse (e.g., 'customer.name', 'items[0].price')
|
|
117
|
+
* @returns QueryAttributeEntry with isDeepQuery, reference, referenceAttribute
|
|
118
|
+
*/
|
|
119
|
+
getQueryAttributeForString(attribute: string): QueryAttributeEntry;
|
|
120
|
+
/**
|
|
121
|
+
* Get the DeepQueryService instance used by this query builder
|
|
122
|
+
* Useful for accessing cache statistics and other service methods
|
|
123
|
+
*
|
|
124
|
+
* @returns The DeepQueryService instance
|
|
125
|
+
*/
|
|
126
|
+
getDeepQueryService(): DeepQueryService;
|
|
127
|
+
getProjectionForAttributes(attributes: string[]): Record<string, boolean>;
|
|
128
|
+
getProjectionForAttributeEntries(attributes: QueryAttributeEntry[]): Record<string, boolean | Record<string, boolean>>;
|
|
129
|
+
/**
|
|
130
|
+
* Get all attribute names used in the query.
|
|
131
|
+
* Returns a simple array of unique attribute names.
|
|
132
|
+
*
|
|
133
|
+
* Clearer alternative to {@link getQueryAttributes}.
|
|
134
|
+
*
|
|
135
|
+
* @param query - Optional query to analyze. If not provided, uses current query.
|
|
136
|
+
* @returns Array of attribute names used in the query
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* builder.addCondition({ operator: 'eq', attribute: 'status', value: 'active' });
|
|
141
|
+
* builder.addCondition({ operator: 'gte', attribute: 'price', value: 100 });
|
|
142
|
+
* const attrs = builder.getAttributeNames(); // ['status', 'price']
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
getAttributeNames(query?: DcuplGlobalQueryOptions<any>): string[];
|
|
146
|
+
/**
|
|
147
|
+
* Get detailed information about attributes used in the query.
|
|
148
|
+
* Returns entries with deep query information (reference, referenceAttribute).
|
|
149
|
+
*
|
|
150
|
+
* Clearer alternative to {@link extractQueryAttributes}.
|
|
151
|
+
*
|
|
152
|
+
* @param query - Query to analyze. Defaults to current query if not provided.
|
|
153
|
+
* @returns Array of QueryAttributeEntry objects with details about each attribute
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* builder.addCondition({ operator: 'eq', attribute: 'customer.name', value: 'John' });
|
|
158
|
+
* const details = builder.getAttributeDetails();
|
|
159
|
+
* // [{ attribute: 'customer.name', isDeepQuery: true, reference: 'customer', referenceAttribute: 'name' }]
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
getAttributeDetails(query?: DcuplGlobalQueryOptions<any>): QueryAttributeEntry[];
|
|
163
|
+
/**
|
|
164
|
+
* Get attribute names from the current query state.
|
|
165
|
+
* Convenience method that operates on the current query.
|
|
166
|
+
*
|
|
167
|
+
* @returns Array of attribute names in current query
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const attrs = builder.getCurrentAttributeNames();
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
getCurrentAttributeNames(): string[];
|
|
175
|
+
/**
|
|
176
|
+
* Get detailed attribute information from the current query state.
|
|
177
|
+
* Convenience method that operates on the current query.
|
|
178
|
+
*
|
|
179
|
+
* @returns Array of QueryAttributeEntry objects from current query
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const details = builder.getCurrentAttributeDetails();
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
getCurrentAttributeDetails(): QueryAttributeEntry[];
|
|
187
|
+
/**
|
|
188
|
+
* Add query condition(s) to the current query.
|
|
189
|
+
* Accepts single condition or array of conditions.
|
|
190
|
+
* Each condition is added to its respective attribute group.
|
|
191
|
+
*
|
|
192
|
+
* Clearer alternative to `applyQuery(condition, { mode: 'add' })`.
|
|
193
|
+
*
|
|
194
|
+
* @param condition - Single query condition or array of conditions to add
|
|
195
|
+
* @returns Updated query
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* // Add single condition
|
|
200
|
+
* builder.addCondition({ operator: 'eq', attribute: 'status', value: 'active' });
|
|
201
|
+
*
|
|
202
|
+
* // Add multiple conditions
|
|
203
|
+
* builder.addCondition([
|
|
204
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
205
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
206
|
+
* ]);
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
addCondition(condition: DcuplQuery | DcuplQuery[]): DcuplGlobalQueryOptions<any>;
|
|
210
|
+
/**
|
|
211
|
+
* Add a query group to the current query.
|
|
212
|
+
* If a group with the same groupKey exists, extends it; otherwise creates new group.
|
|
213
|
+
*
|
|
214
|
+
* @param group - Query group to add
|
|
215
|
+
* @returns Updated query
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* builder.addGroup({
|
|
220
|
+
* groupKey: 'priceRange',
|
|
221
|
+
* groupType: 'and',
|
|
222
|
+
* queries: [
|
|
223
|
+
* { operator: 'gte', attribute: 'price', value: 50 },
|
|
224
|
+
* { operator: 'lte', attribute: 'price', value: 100 }
|
|
225
|
+
* ]
|
|
226
|
+
* });
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
addGroup(group: DcuplQueryGroup): DcuplGlobalQueryOptions<any>;
|
|
230
|
+
/**
|
|
231
|
+
* Replace query with new condition(s).
|
|
232
|
+
* Accepts single condition or array of conditions.
|
|
233
|
+
* Each condition replaces all existing conditions for its attribute.
|
|
234
|
+
*
|
|
235
|
+
* Clearer alternative to `applyQuery(condition, { mode: 'set' })`.
|
|
236
|
+
*
|
|
237
|
+
* @param condition - Single query condition or array of conditions to set
|
|
238
|
+
* @returns Updated query
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // Replace with single condition
|
|
243
|
+
* builder.setCondition({ operator: 'eq', attribute: 'status', value: 'active' });
|
|
244
|
+
*
|
|
245
|
+
* // Replace with multiple conditions
|
|
246
|
+
* builder.setCondition([
|
|
247
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
248
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
249
|
+
* ]);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
setCondition(condition: DcuplQuery | DcuplQuery[]): DcuplGlobalQueryOptions<any>;
|
|
253
|
+
/**
|
|
254
|
+
* Replace a query group with new definition.
|
|
255
|
+
* If group exists, replaces it; otherwise creates new group.
|
|
256
|
+
*
|
|
257
|
+
* @param group - Query group to set
|
|
258
|
+
* @returns Updated query
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* builder.setGroup({
|
|
263
|
+
* groupKey: 'priceRange',
|
|
264
|
+
* groupType: 'and',
|
|
265
|
+
* queries: [
|
|
266
|
+
* { operator: 'gte', attribute: 'price', value: 100 },
|
|
267
|
+
* { operator: 'lte', attribute: 'price', value: 200 }
|
|
268
|
+
* ]
|
|
269
|
+
* });
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
setGroup(group: DcuplQueryGroup): DcuplGlobalQueryOptions<any>;
|
|
273
|
+
/**
|
|
274
|
+
* Merge a complete query into the current query.
|
|
275
|
+
* Adds all conditions and groups from the provided query.
|
|
276
|
+
*
|
|
277
|
+
* @param query - Complete query to merge
|
|
278
|
+
* @returns Updated query
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* builder.mergeQuery({
|
|
283
|
+
* modelKey: 'Product',
|
|
284
|
+
* groupType: 'and',
|
|
285
|
+
* queries: [
|
|
286
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
287
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
288
|
+
* ]
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
mergeQuery(query: DcuplGlobalQueryOptions<any>): DcuplGlobalQueryOptions<any>;
|
|
293
|
+
/**
|
|
294
|
+
* Replace the entire current query with a new query.
|
|
295
|
+
* Completely replaces all conditions, groups, and options.
|
|
296
|
+
*
|
|
297
|
+
* @param query - Complete query to replace with
|
|
298
|
+
* @returns Updated query
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* builder.replaceQuery({
|
|
303
|
+
* modelKey: 'Product',
|
|
304
|
+
* groupType: 'or',
|
|
305
|
+
* queries: [
|
|
306
|
+
* { operator: 'eq', attribute: 'featured', value: true },
|
|
307
|
+
* { operator: 'gte', attribute: 'rating', value: 4.5 }
|
|
308
|
+
* ]
|
|
309
|
+
* });
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
replaceQuery(query: DcuplGlobalQueryOptions<any>): DcuplGlobalQueryOptions<any>;
|
|
313
|
+
/**
|
|
314
|
+
* Clear all query conditions and reset to initial state.
|
|
315
|
+
* Alias for {@link reset} with clearer intent.
|
|
316
|
+
*
|
|
317
|
+
* @returns Empty query
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* builder.addCondition({ operator: 'eq', attribute: 'status', value: 'active' });
|
|
322
|
+
* builder.clear(); // Removes all conditions
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
clear(): DcuplGlobalQueryOptions<any>;
|
|
326
|
+
/**
|
|
327
|
+
* Remove all query conditions but keep query structure.
|
|
328
|
+
* Alias for {@link removeAllQueries} with clearer intent.
|
|
329
|
+
*
|
|
330
|
+
* @returns Query with no conditions
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* builder.clearConditions(); // Remove all conditions but keep modelKey, etc.
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
clearConditions(): DcuplGlobalQueryOptions<any>;
|
|
338
|
+
/**
|
|
339
|
+
* Get an immutable copy of the current query state.
|
|
340
|
+
* Alias for {@link getQuery} with clearer intent.
|
|
341
|
+
*
|
|
342
|
+
* @returns Deep clone of current query
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```typescript
|
|
346
|
+
* const snapshot = builder.getCurrentQuery();
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
getCurrentQuery(): DcuplGlobalQueryOptions<any>;
|
|
350
|
+
/**
|
|
351
|
+
* Check if the query has any conditions.
|
|
352
|
+
*
|
|
353
|
+
* @returns true if query has no conditions, false otherwise
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* if (builder.isEmpty()) {
|
|
358
|
+
* console.log('No filters applied');
|
|
359
|
+
* }
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
isEmpty(): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Check if a specific condition exists in the query.
|
|
365
|
+
*
|
|
366
|
+
* @param condition - Condition to check for (partial match)
|
|
367
|
+
* @returns true if condition exists
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* const hasStatus = builder.hasCondition({ attribute: 'status', value: 'active' });
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
hasCondition(condition: Partial<DcuplQuery>): boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Check if a query group with the given key exists.
|
|
377
|
+
* Alias for {@link hasQueryGroup} with consistent naming.
|
|
378
|
+
*
|
|
379
|
+
* @param groupKey - Group key to check
|
|
380
|
+
* @returns true if group exists
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* if (builder.hasGroup('priceRange')) {
|
|
385
|
+
* console.log('Price range filter is active');
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
hasGroup(groupKey: string): boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Get all unique attribute names used in the query.
|
|
392
|
+
* Convenience alias for {@link getAttributeNames}.
|
|
393
|
+
*
|
|
394
|
+
* @returns Array of attribute names
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```typescript
|
|
398
|
+
* const attrs = builder.getUsedAttributes(); // ['status', 'price', 'customer.name']
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
getUsedAttributes(): string[];
|
|
402
|
+
/**
|
|
403
|
+
* Get only deep query attributes (e.g., 'customer.name', 'items[0].price').
|
|
404
|
+
* Filters out simple attributes and returns only those with references.
|
|
405
|
+
*
|
|
406
|
+
* @returns Array of deep query attribute details
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* const deepAttrs = builder.getDeepQueryAttributes();
|
|
411
|
+
* // [{ attribute: 'customer.name', isDeepQuery: true, reference: 'customer', referenceAttribute: 'name' }]
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
getDeepQueryAttributes(): QueryAttributeEntry[];
|
|
415
|
+
/**
|
|
416
|
+
* Get all query groups in the current query.
|
|
417
|
+
*
|
|
418
|
+
* @returns Array of query groups
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const groups = builder.getGroups();
|
|
423
|
+
* // [{ groupKey: 'priceRange', groupType: 'and', queries: [...] }]
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
getGroups(): DcuplQueryGroup[];
|
|
427
|
+
/**
|
|
428
|
+
* Get top-level conditions (queries not inside groups).
|
|
429
|
+
*
|
|
430
|
+
* @returns Array of top-level query conditions
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* const topLevel = builder.getTopLevelConditions();
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
getTopLevelConditions(): DcuplQuery[];
|
|
438
|
+
/**
|
|
439
|
+
* Get a specific query group by its key.
|
|
440
|
+
* Alias for {@link getQueryGroup} with consistent naming.
|
|
441
|
+
*
|
|
442
|
+
* @param groupKey - Key of the group to retrieve
|
|
443
|
+
* @returns Query group or undefined if not found
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* const group = builder.getGroup('priceRange');
|
|
448
|
+
* if (group) {
|
|
449
|
+
* console.log('Price range:', group.queries);
|
|
450
|
+
* }
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
getGroup(groupKey?: string): DcuplQueryGroup | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* Count total number of conditions in the query (including nested).
|
|
456
|
+
*
|
|
457
|
+
* @returns Total count of query conditions
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const count = builder.getConditionCount(); // 5
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
getConditionCount(): number;
|
|
32
465
|
}
|