@dcupl/common 1.11.10 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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,80 +1,578 @@
|
|
|
1
1
|
import { ListItem } from './data.types';
|
|
2
2
|
import { Projection, SortingProjection } from './projection.types';
|
|
3
|
+
/**
|
|
4
|
+
* Transform options for query values.
|
|
5
|
+
* - `lowercase`: Convert value to lowercase before comparison
|
|
6
|
+
* - `trim`: Remove leading/trailing whitespace
|
|
7
|
+
* - `removeWhitespace`: Remove all whitespace characters
|
|
8
|
+
*/
|
|
3
9
|
export type DcuplQueryTransformOptions = 'lowercase' | 'trim' | 'removeWhitespace';
|
|
4
10
|
export declare const DcuplQueryOperatorsAsArray: readonly ["eq", "find", "gt", "gte", "lt", "lte", "typeof", "isTruthy", "size"];
|
|
11
|
+
/**
|
|
12
|
+
* Query operators for filtering data.
|
|
13
|
+
*
|
|
14
|
+
* Available operators:
|
|
15
|
+
* - `eq`: Equality check - matches exact values
|
|
16
|
+
* - `find`: Partial text or object match - searches within strings or objects
|
|
17
|
+
* - `gt`: Greater than - numeric/date comparison (exclusive)
|
|
18
|
+
* - `gte`: Greater than or equal - numeric/date comparison (inclusive)
|
|
19
|
+
* - `lt`: Less than - numeric/date comparison (exclusive)
|
|
20
|
+
* - `lte`: Less than or equal - numeric/date comparison (inclusive)
|
|
21
|
+
* - `typeof`: Type check - validates data type
|
|
22
|
+
* - `isTruthy`: Boolean check - evaluates truthiness
|
|
23
|
+
* - `size`: Array/string length check - matches collection size
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Equality
|
|
28
|
+
* { operator: 'eq', attribute: 'status', value: 'active' }
|
|
29
|
+
*
|
|
30
|
+
* // Numeric comparison
|
|
31
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
32
|
+
*
|
|
33
|
+
* // Text search
|
|
34
|
+
* { operator: 'find', attribute: 'name', value: 'search term' }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
5
37
|
export type DcuplQueryOperator = (typeof DcuplQueryOperatorsAsArray)[number];
|
|
38
|
+
/**
|
|
39
|
+
* Query combination logic.
|
|
40
|
+
* - `and`: All conditions must match (intersection)
|
|
41
|
+
* - `or`: At least one condition must match (union)
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // AND logic - both conditions must be true
|
|
46
|
+
* { groupType: 'and', queries: [condition1, condition2] }
|
|
47
|
+
*
|
|
48
|
+
* // OR logic - either condition can be true
|
|
49
|
+
* { groupType: 'or', queries: [condition1, condition2] }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
6
52
|
export type DcuplQueryType = 'and' | 'or';
|
|
53
|
+
/**
|
|
54
|
+
* Base query properties shared by all query types.
|
|
55
|
+
*/
|
|
7
56
|
type DcuplQueryBase = {
|
|
57
|
+
/**
|
|
58
|
+
* The attribute/property name to query against.
|
|
59
|
+
* Can reference nested properties using dot notation (e.g., 'user.email').
|
|
60
|
+
*/
|
|
8
61
|
attribute: string;
|
|
62
|
+
/**
|
|
63
|
+
* Optional identifier for this query condition.
|
|
64
|
+
* Useful for tracking or removing specific queries.
|
|
65
|
+
*/
|
|
9
66
|
queryKey?: any;
|
|
67
|
+
/**
|
|
68
|
+
* Optional discriminator for type narrowing.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
__type?: 'query';
|
|
72
|
+
/**
|
|
73
|
+
* Query behavior modifiers.
|
|
74
|
+
*/
|
|
10
75
|
options?: {
|
|
76
|
+
/**
|
|
77
|
+
* Transform value before comparison.
|
|
78
|
+
* Applied in order: ['lowercase', 'trim'] applies lowercase first, then trim.
|
|
79
|
+
*/
|
|
11
80
|
transform?: DcuplQueryTransformOptions[];
|
|
81
|
+
/**
|
|
82
|
+
* Invert the query result (NOT operation).
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Find items where status is NOT 'active'
|
|
86
|
+
* { operator: 'eq', attribute: 'status', value: 'active', options: { invert: true } }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
12
89
|
invert?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* When querying array values, determines match behavior.
|
|
92
|
+
* - `some`: Match if at least one array element matches (default)
|
|
93
|
+
* - `every`: Match only if all array elements match
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // Match items where ANY tag equals 'featured'
|
|
98
|
+
* { operator: 'eq', attribute: 'tags', value: 'featured', options: { arrayValueHandling: 'some' } }
|
|
99
|
+
*
|
|
100
|
+
* // Match items where ALL tags equal 'featured'
|
|
101
|
+
* { operator: 'eq', attribute: 'tags', value: 'featured', options: { arrayValueHandling: 'every' } }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
13
104
|
arrayValueHandling?: 'some' | 'every';
|
|
14
105
|
};
|
|
15
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Equality query - matches exact values.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Match items with status 'active'
|
|
113
|
+
* { operator: 'eq', attribute: 'status', value: 'active' }
|
|
114
|
+
*
|
|
115
|
+
* // Match items with a reference key
|
|
116
|
+
* { operator: 'eq', attribute: 'categoryId', value: { key: 'cat-123' } }
|
|
117
|
+
*
|
|
118
|
+
* // Case-insensitive match
|
|
119
|
+
* { operator: 'eq', attribute: 'name', value: 'john', options: { transform: ['lowercase'] } }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
16
122
|
type DcuplQueryEq = DcuplQueryBase & {
|
|
17
123
|
operator: 'eq';
|
|
18
124
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
125
|
+
* Value to match against.
|
|
126
|
+
* Note: For indexed search optimization, use string or { key: string } values.
|
|
21
127
|
*/
|
|
22
128
|
value: any;
|
|
23
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Find query - partial text or object match.
|
|
132
|
+
* Searches within strings (substring match) or checks object property existence.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* // Find items containing 'search' in description
|
|
137
|
+
* { operator: 'find', attribute: 'description', value: 'search' }
|
|
138
|
+
*
|
|
139
|
+
* // Find items with specific nested property
|
|
140
|
+
* { operator: 'find', attribute: 'metadata', value: { key: 'value' } }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
24
143
|
type DcuplQueryFind = DcuplQueryBase & {
|
|
25
144
|
operator: 'find';
|
|
145
|
+
/**
|
|
146
|
+
* Text to search for (substring) or object with properties to match.
|
|
147
|
+
*/
|
|
26
148
|
value: Record<string, unknown> | string;
|
|
27
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* Numeric/date comparison queries.
|
|
152
|
+
* Supports greater than, less than, and inclusive variants.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* // Items with price greater than 100
|
|
157
|
+
* { operator: 'gt', attribute: 'price', value: 100 }
|
|
158
|
+
*
|
|
159
|
+
* // Items created after a date
|
|
160
|
+
* { operator: 'gte', attribute: 'createdAt', value: new Date('2024-01-01') }
|
|
161
|
+
*
|
|
162
|
+
* // Items with quantity less than or equal to 10
|
|
163
|
+
* { operator: 'lte', attribute: 'quantity', value: 10 }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
28
166
|
type DcuplQueryNumbers = DcuplQueryBase & {
|
|
29
167
|
operator: 'gt' | 'lt' | 'gte' | 'lte';
|
|
168
|
+
/**
|
|
169
|
+
* Numeric value, date, or string representation for comparison.
|
|
170
|
+
*/
|
|
30
171
|
value: string | number | Date;
|
|
31
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Type check query - validates data type.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* // Match items where price is a number
|
|
179
|
+
* { operator: 'typeof', attribute: 'price', value: 'number' }
|
|
180
|
+
*
|
|
181
|
+
* // Match items where tags is an array
|
|
182
|
+
* { operator: 'typeof', attribute: 'tags', value: 'object' }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
32
185
|
type DcuplQueryTypeOf = DcuplQueryBase & {
|
|
33
186
|
operator: 'typeof';
|
|
187
|
+
/**
|
|
188
|
+
* JavaScript type name: 'string', 'number', 'boolean', 'object', 'undefined', 'function', 'symbol'
|
|
189
|
+
*/
|
|
34
190
|
value: string;
|
|
35
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* Truthiness check query - evaluates boolean truthiness.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // Match items where isActive is truthy
|
|
198
|
+
* { operator: 'isTruthy', attribute: 'isActive', value: true }
|
|
199
|
+
*
|
|
200
|
+
* // Match items where isDeleted is falsy
|
|
201
|
+
* { operator: 'isTruthy', attribute: 'isDeleted', value: false }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
36
204
|
type DcuplQueryIsTruthy = DcuplQueryBase & {
|
|
37
205
|
operator: 'isTruthy';
|
|
206
|
+
/**
|
|
207
|
+
* Expected truthiness: true for truthy values, false for falsy values.
|
|
208
|
+
*/
|
|
38
209
|
value: boolean;
|
|
39
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Size check query - matches array length or string length.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* // Match items with exactly 3 tags
|
|
217
|
+
* { operator: 'size', attribute: 'tags', value: 3 }
|
|
218
|
+
*
|
|
219
|
+
* // Match items with name exactly 10 characters long
|
|
220
|
+
* { operator: 'size', attribute: 'name', value: 10 }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
40
223
|
type DcuplQuerySize = DcuplQueryBase & {
|
|
41
224
|
operator: 'size';
|
|
225
|
+
/**
|
|
226
|
+
* Expected length/size of the array or string.
|
|
227
|
+
*/
|
|
42
228
|
value: number;
|
|
43
229
|
};
|
|
230
|
+
/**
|
|
231
|
+
* Query condition - represents a single filter criterion.
|
|
232
|
+
* Use this to filter items based on attribute values.
|
|
233
|
+
*
|
|
234
|
+
* @see QueryCondition - Type alias with clearer naming
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* // Simple equality check
|
|
239
|
+
* const query: DcuplQuery = {
|
|
240
|
+
* operator: 'eq',
|
|
241
|
+
* attribute: 'status',
|
|
242
|
+
* value: 'active'
|
|
243
|
+
* };
|
|
244
|
+
*
|
|
245
|
+
* // Numeric comparison with options
|
|
246
|
+
* const priceQuery: DcuplQuery = {
|
|
247
|
+
* operator: 'gte',
|
|
248
|
+
* attribute: 'price',
|
|
249
|
+
* value: 100,
|
|
250
|
+
* options: { invert: false }
|
|
251
|
+
* };
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
44
254
|
export type DcuplQuery = DcuplQueryEq | DcuplQueryNumbers | DcuplQueryTypeOf | DcuplQueryIsTruthy | DcuplQuerySize | DcuplQueryFind;
|
|
255
|
+
/**
|
|
256
|
+
* Query group - combines multiple conditions with AND/OR logic.
|
|
257
|
+
* Groups can be nested to create complex filter expressions.
|
|
258
|
+
*
|
|
259
|
+
* @see QueryConditionGroup - Type alias with clearer naming
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* // AND group - all conditions must match
|
|
264
|
+
* const andGroup: DcuplQueryGroup = {
|
|
265
|
+
* groupType: 'and',
|
|
266
|
+
* groupKey: 'active-products',
|
|
267
|
+
* queries: [
|
|
268
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
269
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
270
|
+
* ]
|
|
271
|
+
* };
|
|
272
|
+
*
|
|
273
|
+
* // OR group - at least one condition must match
|
|
274
|
+
* const orGroup: DcuplQueryGroup = {
|
|
275
|
+
* groupType: 'or',
|
|
276
|
+
* queries: [
|
|
277
|
+
* { operator: 'eq', attribute: 'category', value: 'electronics' },
|
|
278
|
+
* { operator: 'eq', attribute: 'category', value: 'books' }
|
|
279
|
+
* ]
|
|
280
|
+
* };
|
|
281
|
+
*
|
|
282
|
+
* // Nested groups
|
|
283
|
+
* const nestedGroup: DcuplQueryGroup = {
|
|
284
|
+
* groupType: 'and',
|
|
285
|
+
* queries: [
|
|
286
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
287
|
+
* {
|
|
288
|
+
* groupType: 'or',
|
|
289
|
+
* queries: [
|
|
290
|
+
* { operator: 'eq', attribute: 'featured', value: true },
|
|
291
|
+
* { operator: 'gte', attribute: 'rating', value: 4.5 }
|
|
292
|
+
* ]
|
|
293
|
+
* }
|
|
294
|
+
* ]
|
|
295
|
+
* };
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
45
298
|
export type DcuplQueryGroup<ChildQuery extends DcuplQuery | DcuplQueryGroup = any> = {
|
|
299
|
+
/**
|
|
300
|
+
* Optional discriminator for type narrowing.
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
303
|
+
__type?: 'group';
|
|
304
|
+
/**
|
|
305
|
+
* Combination logic for conditions in this group.
|
|
306
|
+
* Defaults to 'and' if not specified.
|
|
307
|
+
*/
|
|
46
308
|
groupType?: DcuplQueryType;
|
|
309
|
+
/**
|
|
310
|
+
* Optional identifier for this group.
|
|
311
|
+
* Useful for tracking or removing specific query groups.
|
|
312
|
+
*/
|
|
47
313
|
groupKey?: string;
|
|
314
|
+
/**
|
|
315
|
+
* Array of query conditions or nested groups.
|
|
316
|
+
*/
|
|
48
317
|
queries: Array<ChildQuery>;
|
|
49
318
|
};
|
|
319
|
+
/**
|
|
320
|
+
* Common options for data retrieval operations.
|
|
321
|
+
* Controls pagination, projection, and sorting.
|
|
322
|
+
*
|
|
323
|
+
* @see ItemDataOptions - Type alias with clearer naming
|
|
324
|
+
*/
|
|
50
325
|
type DcuplItemOptions<T> = {
|
|
326
|
+
/**
|
|
327
|
+
* Starting index for pagination (0-based).
|
|
328
|
+
* @example start: 10 // Skip first 10 items
|
|
329
|
+
*/
|
|
51
330
|
start?: number;
|
|
331
|
+
/**
|
|
332
|
+
* Maximum number of items to return.
|
|
333
|
+
* @example count: 20 // Return up to 20 items
|
|
334
|
+
*/
|
|
52
335
|
count?: number;
|
|
336
|
+
/**
|
|
337
|
+
* Specify which properties to include/exclude in results.
|
|
338
|
+
*/
|
|
53
339
|
projection?: Projection<T>;
|
|
340
|
+
/**
|
|
341
|
+
* Define sorting order for results.
|
|
342
|
+
*/
|
|
54
343
|
sort?: SortingProjection<T>;
|
|
55
344
|
};
|
|
345
|
+
/**
|
|
346
|
+
* Options for executing queries across the global dcupl instance.
|
|
347
|
+
* Combines model specification, query conditions, and data retrieval options.
|
|
348
|
+
*
|
|
349
|
+
* @see QueryExecutionContext - Type alias with clearer naming
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const options: DcuplGlobalQueryOptions<Product> = {
|
|
354
|
+
* modelKey: 'Product',
|
|
355
|
+
* queries: [
|
|
356
|
+
* { operator: 'eq', attribute: 'status', value: 'active' }
|
|
357
|
+
* ],
|
|
358
|
+
* start: 0,
|
|
359
|
+
* count: 20,
|
|
360
|
+
* sort: { price: 'asc' }
|
|
361
|
+
* };
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
56
364
|
export type DcuplGlobalQueryOptions<T> = {
|
|
365
|
+
/**
|
|
366
|
+
* Model identifier to query against.
|
|
367
|
+
*/
|
|
57
368
|
modelKey: string;
|
|
58
369
|
} & DcuplItemOptions<T> & DcuplQueryGroup;
|
|
370
|
+
/**
|
|
371
|
+
* Options for retrieving a single item from the global dcupl instance.
|
|
372
|
+
*/
|
|
59
373
|
export type DcuplGlobalItemOptions<T> = {
|
|
374
|
+
/**
|
|
375
|
+
* Model identifier.
|
|
376
|
+
*/
|
|
60
377
|
modelKey: string;
|
|
378
|
+
/**
|
|
379
|
+
* Item identifier.
|
|
380
|
+
*/
|
|
61
381
|
itemKey: string;
|
|
382
|
+
/**
|
|
383
|
+
* Optional projection to control returned properties.
|
|
384
|
+
*/
|
|
62
385
|
projection?: Projection<T>;
|
|
63
386
|
};
|
|
387
|
+
/**
|
|
388
|
+
* Options for retrieving multiple specific items from the global dcupl instance.
|
|
389
|
+
*/
|
|
64
390
|
export type DcuplGlobalManyItemOptions<T> = {
|
|
391
|
+
/**
|
|
392
|
+
* Model identifier.
|
|
393
|
+
*/
|
|
65
394
|
modelKey: string;
|
|
395
|
+
/**
|
|
396
|
+
* Array of item identifiers.
|
|
397
|
+
*/
|
|
66
398
|
itemKeys: string[];
|
|
399
|
+
/**
|
|
400
|
+
* Optional projection to control returned properties.
|
|
401
|
+
*/
|
|
67
402
|
projection?: Projection<T>;
|
|
68
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* Options for executing queries on a list instance.
|
|
406
|
+
* Combines query conditions with data retrieval options.
|
|
407
|
+
*
|
|
408
|
+
* @see ListQueryOptions - Type alias with clearer naming
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const options: DcuplListQueryOptions<Product> = {
|
|
413
|
+
* queries: [
|
|
414
|
+
* { operator: 'gte', attribute: 'price', value: 50 }
|
|
415
|
+
* ],
|
|
416
|
+
* groupType: 'and',
|
|
417
|
+
* count: 10
|
|
418
|
+
* };
|
|
419
|
+
* const results = list.catalog.query.execute(options);
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
69
422
|
export type DcuplListQueryOptions<T> = DcuplItemOptions<T> & DcuplQueryGroup;
|
|
423
|
+
/**
|
|
424
|
+
* Options for retrieving a specific item from a list instance.
|
|
425
|
+
*/
|
|
70
426
|
export type DcuplListItemOptions<T> = DcuplItemOptions<T> & {
|
|
427
|
+
/**
|
|
428
|
+
* Item identifier.
|
|
429
|
+
*/
|
|
71
430
|
itemKey: string;
|
|
72
431
|
};
|
|
432
|
+
/**
|
|
433
|
+
* Custom operator function for extending query capabilities.
|
|
434
|
+
* Receives a query condition and list item, returns whether the item matches.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* const customOperator: CustomOperatorFn = (query, listItem) => {
|
|
439
|
+
* const value = listItem.data[query.attribute];
|
|
440
|
+
* return value !== undefined;
|
|
441
|
+
* };
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
73
444
|
export type CustomOperatorFn = (query: DcuplQuery, listItem: ListItem) => boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Map of custom operator names to their implementation functions.
|
|
447
|
+
*/
|
|
74
448
|
export type CustomOperatorFnMap = Map<string, CustomOperatorFn>;
|
|
449
|
+
/**
|
|
450
|
+
* Internal query statement representation.
|
|
451
|
+
* Used for query execution and optimization.
|
|
452
|
+
*
|
|
453
|
+
* @internal
|
|
454
|
+
*/
|
|
75
455
|
export type DcuplQueryStatement<T = any> = DcuplItemOptions<T> & {
|
|
76
456
|
modelKey: string;
|
|
77
457
|
groupType?: DcuplQueryType;
|
|
78
458
|
queries: DcuplQuery[] | DcuplQueryGroup<DcuplQuery>[] | DcuplQueryGroup<DcuplQueryGroup<DcuplQuery>>[];
|
|
79
459
|
};
|
|
460
|
+
/**
|
|
461
|
+
* Query condition - represents a single filter criterion.
|
|
462
|
+
* Alias for {@link DcuplQuery} with clearer naming.
|
|
463
|
+
*
|
|
464
|
+
* Use this to filter items based on attribute values using various operators.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* // Equality check
|
|
469
|
+
* const condition: QueryCondition = {
|
|
470
|
+
* operator: 'eq',
|
|
471
|
+
* attribute: 'status',
|
|
472
|
+
* value: 'active'
|
|
473
|
+
* };
|
|
474
|
+
*
|
|
475
|
+
* // Numeric comparison
|
|
476
|
+
* const priceCondition: QueryCondition = {
|
|
477
|
+
* operator: 'gte',
|
|
478
|
+
* attribute: 'price',
|
|
479
|
+
* value: 100
|
|
480
|
+
* };
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
export type QueryCondition = DcuplQuery;
|
|
484
|
+
/**
|
|
485
|
+
* Query group - combines multiple conditions with AND/OR logic.
|
|
486
|
+
* Alias for {@link DcuplQueryGroup} with clearer naming.
|
|
487
|
+
*
|
|
488
|
+
* Groups can be nested to create complex filter expressions.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* // AND group
|
|
493
|
+
* const group: QueryConditionGroup = {
|
|
494
|
+
* groupType: 'and',
|
|
495
|
+
* queries: [
|
|
496
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
497
|
+
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
498
|
+
* ]
|
|
499
|
+
* };
|
|
500
|
+
*
|
|
501
|
+
* // Nested groups
|
|
502
|
+
* const nested: QueryConditionGroup = {
|
|
503
|
+
* groupType: 'and',
|
|
504
|
+
* queries: [
|
|
505
|
+
* { operator: 'eq', attribute: 'status', value: 'active' },
|
|
506
|
+
* {
|
|
507
|
+
* groupType: 'or',
|
|
508
|
+
* queries: [
|
|
509
|
+
* { operator: 'eq', attribute: 'featured', value: true },
|
|
510
|
+
* { operator: 'gte', attribute: 'rating', value: 4.5 }
|
|
511
|
+
* ]
|
|
512
|
+
* }
|
|
513
|
+
* ]
|
|
514
|
+
* };
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
export type QueryConditionGroup<ChildQuery extends DcuplQuery | DcuplQueryGroup = any> = DcuplQueryGroup<ChildQuery>;
|
|
518
|
+
/**
|
|
519
|
+
* Query execution context for global dcupl operations.
|
|
520
|
+
* Alias for {@link DcuplGlobalQueryOptions} with clearer naming.
|
|
521
|
+
*
|
|
522
|
+
* Combines model specification, query conditions, and data retrieval options.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```typescript
|
|
526
|
+
* const context: QueryExecutionContext<Product> = {
|
|
527
|
+
* modelKey: 'Product',
|
|
528
|
+
* queries: [
|
|
529
|
+
* { operator: 'eq', attribute: 'status', value: 'active' }
|
|
530
|
+
* ],
|
|
531
|
+
* groupType: 'and',
|
|
532
|
+
* start: 0,
|
|
533
|
+
* count: 20,
|
|
534
|
+
* sort: { price: 'asc' }
|
|
535
|
+
* };
|
|
536
|
+
* const results = dcupl.data.query(context);
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
export type QueryExecutionContext<T> = DcuplGlobalQueryOptions<T>;
|
|
540
|
+
/**
|
|
541
|
+
* Options for executing queries on a list instance.
|
|
542
|
+
* Alias for {@link DcuplListQueryOptions} with clearer naming.
|
|
543
|
+
*
|
|
544
|
+
* Combines query conditions with pagination, projection, and sorting options.
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```typescript
|
|
548
|
+
* const options: ListQueryOptions<Product> = {
|
|
549
|
+
* queries: [
|
|
550
|
+
* { operator: 'gte', attribute: 'price', value: 50 }
|
|
551
|
+
* ],
|
|
552
|
+
* groupType: 'and',
|
|
553
|
+
* start: 0,
|
|
554
|
+
* count: 10,
|
|
555
|
+
* sort: { name: 'asc' }
|
|
556
|
+
* };
|
|
557
|
+
* const results = list.catalog.query.execute(options);
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
export type ListQueryOptions<T> = DcuplListQueryOptions<T>;
|
|
561
|
+
/**
|
|
562
|
+
* Common data retrieval options.
|
|
563
|
+
* Alias for {@link DcuplItemOptions} with clearer naming.
|
|
564
|
+
*
|
|
565
|
+
* Controls pagination, projection, and sorting for data operations.
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```typescript
|
|
569
|
+
* const options: ItemDataOptions<Product> = {
|
|
570
|
+
* start: 0,
|
|
571
|
+
* count: 20,
|
|
572
|
+
* projection: { name: true, price: true },
|
|
573
|
+
* sort: { price: 'desc' }
|
|
574
|
+
* };
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
export type ItemDataOptions<T> = DcuplItemOptions<T>;
|
|
80
578
|
export {};
|