@dcupl/common 2.0.0-beta.2 → 2.0.0-beta.21
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/analytics.controller.d.ts +1 -1
- package/dist/esm/changeDetection.d.ts +2 -2
- package/dist/esm/computeSuggestions.d.ts +2 -2
- package/dist/esm/deep-query.service.d.ts +1 -1
- package/dist/esm/getAggregation.d.ts +1 -1
- package/dist/esm/getFacets.d.ts +26 -3
- package/dist/esm/helper.d.ts +11 -1
- package/dist/esm/index.d.ts +25 -22
- package/dist/esm/index.js +1004 -690
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/indices.controller.d.ts +7 -1
- package/dist/esm/logger/index.d.ts +2 -2
- package/dist/esm/pivot.d.ts +2 -2
- package/dist/esm/property-parser.d.ts +27 -2
- package/dist/esm/query-builder.d.ts +15 -5
- package/dist/esm/query.helper.d.ts +1 -1
- package/dist/esm/queryData.d.ts +53 -3
- package/dist/esm/redact-url.d.ts +9 -0
- package/dist/esm/resource-id.d.ts +43 -0
- package/dist/esm/scheduling.d.ts +17 -0
- package/dist/esm/types/app-loader.types.d.ts +94 -4
- package/dist/esm/types/data.types.d.ts +7 -3
- package/dist/esm/types/dcupl.types.d.ts +26 -12
- package/dist/esm/types/facets.types.d.ts +14 -1
- package/dist/esm/types/filter.types.d.ts +3 -3
- package/dist/esm/types/group-by.types.d.ts +2 -2
- package/dist/esm/types/index.d.ts +17 -16
- package/dist/esm/types/internal.types.d.ts +1 -1
- package/dist/esm/types/key-property.types.d.ts +11 -0
- package/dist/esm/types/list.types.d.ts +25 -4
- package/dist/esm/types/model.types.d.ts +54 -5
- package/dist/esm/types/quality.types.d.ts +87 -1
- package/dist/esm/types/query.types.d.ts +115 -20
- package/dist/esm/types/section.types.d.ts +2 -2
- package/dist/esm/types/suggestion.types.d.ts +6 -1
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/package.json +2 -4
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import { AggregationOptions, DcuplGlobalQueryOptions, DcuplQuery, DcuplQueryGroup, RawItem } from '.';
|
|
2
|
-
import {
|
|
1
|
+
import { AggregationOptions, DcuplGlobalQueryOptions, DcuplQuery, DcuplQueryGroup, RawItem } from './index.js';
|
|
2
|
+
import { KeyPropertySpec } from './key-property.types.js';
|
|
3
|
+
import { PivotOptions } from '../pivot.js';
|
|
3
4
|
type AggregationOptionsModel = Omit<AggregationOptions, 'attribute'>;
|
|
4
5
|
export type PropertyType = 'any' | 'Array<date>' | 'Array<float>' | 'Array<int>' | 'Array<string>' | 'boolean' | 'date' | 'float' | 'int' | 'json' | 'string';
|
|
5
6
|
export declare const PropertyTypesAsArray: PropertyType[];
|
|
6
7
|
export declare const NumberPropertyTypes: PropertyType[];
|
|
7
8
|
export declare const DatePropertyTypes: PropertyType[];
|
|
9
|
+
/**
|
|
10
|
+
* Configures how property auto-generation inspects input data.
|
|
11
|
+
*
|
|
12
|
+
* - `true` / `false`: enable/disable auto-generation. When enabled with `true`,
|
|
13
|
+
* only the first row of input data is inspected (fast, default behavior).
|
|
14
|
+
* - Object form lets you scan more rows:
|
|
15
|
+
* - `deep: true` walks every row and reconciles types across them.
|
|
16
|
+
* - `sampleSize: N` walks at most N rows (implies deep). Useful for large datasets
|
|
17
|
+
* where row 1 alone may not represent the schema.
|
|
18
|
+
*
|
|
19
|
+
* When more than one row is scanned, empty values (`null`, `undefined`, `''`)
|
|
20
|
+
* are ignored during inference so a single blank cell does not poison a column's type.
|
|
21
|
+
*/
|
|
22
|
+
export type AutoGeneratePropertiesOption = boolean | {
|
|
23
|
+
deep?: boolean;
|
|
24
|
+
sampleSize?: number;
|
|
25
|
+
};
|
|
8
26
|
/**
|
|
9
27
|
* must be singleValued or multiValued
|
|
10
28
|
* singleValued contains only one key to an object
|
|
@@ -308,8 +326,19 @@ export type ValueMappingConfig = {
|
|
|
308
326
|
};
|
|
309
327
|
export type ModelAttribute = Property | Reference;
|
|
310
328
|
export type ModelQualityConfig = {
|
|
329
|
+
/**
|
|
330
|
+
* Master switch for quality checks on this model. Default: true.
|
|
331
|
+
* Checks only run when error tracking is also enabled globally
|
|
332
|
+
* (two-tier enablement).
|
|
333
|
+
*/
|
|
311
334
|
enabled?: boolean;
|
|
312
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Model-wide defaults for the attribute quality FLAGS
|
|
337
|
+
* (required / nullable / forceStrictDataType / validatorHandling),
|
|
338
|
+
* merged under each attribute's own `quality`.
|
|
339
|
+
* Concrete `validators` are per-attribute only and cannot be set here.
|
|
340
|
+
*/
|
|
341
|
+
attributes?: Omit<AttributeQualityConfig, 'validators'>;
|
|
313
342
|
};
|
|
314
343
|
export type ValidatorErrorType = 'loose' | 'strict';
|
|
315
344
|
export type ValidatorConfig = {
|
|
@@ -333,6 +362,18 @@ export type AttributeValidatorConfig = {
|
|
|
333
362
|
unique?: ValidatorConfig;
|
|
334
363
|
startsWith?: ValidatorConfig;
|
|
335
364
|
};
|
|
365
|
+
/**
|
|
366
|
+
* Quality rules for a single property or reference.
|
|
367
|
+
*
|
|
368
|
+
* Defaults: required: true, nullable: false, forceStrictDataType: false,
|
|
369
|
+
* validatorHandling: 'loose'.
|
|
370
|
+
*
|
|
371
|
+
* validatorHandling decides what happens when a validator fails:
|
|
372
|
+
* 'loose' (default) reports an InvalidValidator error and keeps the value;
|
|
373
|
+
* 'strict' reports AND drops the value from the loaded data.
|
|
374
|
+
* forceStrictDataType: true disables type coercion — wrong-typed raw
|
|
375
|
+
* values are reported as WrongDataType and dropped.
|
|
376
|
+
*/
|
|
336
377
|
export type AttributeQualityConfig = {
|
|
337
378
|
required?: boolean;
|
|
338
379
|
nullable?: boolean;
|
|
@@ -355,9 +396,17 @@ export type ModelDefinition<ModelNames extends string = string> = {
|
|
|
355
396
|
properties?: Property[];
|
|
356
397
|
references?: Reference[];
|
|
357
398
|
data?: RawItem[];
|
|
358
|
-
|
|
399
|
+
/**
|
|
400
|
+
* Property name(s) on each row that uniquely identify it.
|
|
401
|
+
* See `KeyPropertySpec` for composite-key behavior.
|
|
402
|
+
*/
|
|
403
|
+
keyProperty?: KeyPropertySpec;
|
|
404
|
+
/**
|
|
405
|
+
* Separator joining composite `keyProperty` parts. Default `'::'`.
|
|
406
|
+
*/
|
|
407
|
+
keyPropertySeparator?: string;
|
|
359
408
|
autoGenerateKey?: boolean;
|
|
360
|
-
autoGenerateProperties?:
|
|
409
|
+
autoGenerateProperties?: AutoGeneratePropertiesOption;
|
|
361
410
|
supportsAutoCreation?: boolean;
|
|
362
411
|
valueMappings?: ValueMappingConfig[];
|
|
363
412
|
meta?: ModelMetadata;
|
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
export declare namespace QualityAnalyzer {
|
|
2
2
|
type ModelErrorGroup = 'ReferenceDataError' | 'PropertyDataError' | 'DataContainerError' | 'ModelDefinitionError';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Error types emitted by the quality controller during model registration
|
|
5
|
+
* and data ingest.
|
|
6
|
+
*
|
|
7
|
+
* - `UndefinedAttribute` — A declared attribute has no corresponding column /
|
|
8
|
+
* field in an ingested data container. Fires once per (model, attribute).
|
|
9
|
+
* - `InvalidValidator` — A validator on a property could not be parsed or
|
|
10
|
+
* evaluated against the data.
|
|
11
|
+
* - `UndefinedValue` — A required property has no value on a specific
|
|
12
|
+
* data entry (the cell is `undefined`). Fires per-row.
|
|
13
|
+
* - `NullValue` — A non-nullable property has an explicit `null` on
|
|
14
|
+
* a specific data entry. Fires per-row.
|
|
15
|
+
* - `WrongDataType` — A value present on a data entry could not be
|
|
16
|
+
* coerced to the declared property type. Fires per-row. Also covers *lossy*
|
|
17
|
+
* numeric coercions where coercion succeeds but silently drops information —
|
|
18
|
+
* trailing/embedded non-numeric content (e.g. `"1.2 lbs"` → `1.2`) or
|
|
19
|
+
* fractional truncation for `int` properties (e.g. `"1.2"` → `1`). Lossy
|
|
20
|
+
* records carry `meta.lossy: true` plus `meta.rawValue` and
|
|
21
|
+
* `meta.coercedValue`; the coerced value is still kept on the data entry.
|
|
22
|
+
* Representation-only differences that preserve the value (leading/trailing
|
|
23
|
+
* zeros, surrounding whitespace, `"4.0"` → `4`) are not flagged.
|
|
24
|
+
* Aggregation (#197): when one or more cells of a typed column fail to coerce,
|
|
25
|
+
* the per-row signals are consolidated into a single `WrongDataType` per
|
|
26
|
+
* `(model, attribute)` with `meta.rowCount` = the number of failing rows
|
|
27
|
+
* (exact and cap-independent for loader/CSV sources; bounded by
|
|
28
|
+
* `maxErrorsPerGroup` for inline data). `getErrorCounts()` reports the stored
|
|
29
|
+
* *record* count (1 for an aggregated column), which is intentionally distinct
|
|
30
|
+
* from `meta.rowCount`. A column entirely absent from the source still
|
|
31
|
+
* produces `UndefinedAttribute`, not `WrongDataType`.
|
|
32
|
+
* - `NonUniqueKey` — Two or more data entries share the same key value
|
|
33
|
+
* in the same model; later rows are dropped.
|
|
34
|
+
* - `MissingKey` — A data row has no value for the model's key
|
|
35
|
+
* attribute, so it cannot be identified; the row is dropped on ingest.
|
|
36
|
+
* - `DuplicatePropertyKey` — A model definition declares the same property
|
|
37
|
+
* key more than once; the first definition is kept, the duplicate ignored.
|
|
38
|
+
* - `MissingModel` — A reference points to a model key that has not
|
|
39
|
+
* been registered.
|
|
40
|
+
* - `MissingProperty` — Emitted only during model-definition validation
|
|
41
|
+
* when a *derived property* declares `derive.remoteProperty` pointing to a
|
|
42
|
+
* property that does not exist on the remote model. Not used in any
|
|
43
|
+
* CSV/JSON data-ingest path — those are covered by `UndefinedAttribute`,
|
|
44
|
+
* `UndefinedValue`, and `WrongDataType`. See model.helper.ts (derived-
|
|
45
|
+
* property validator) for the sole emit site.
|
|
46
|
+
* - `MissingReference` — A derived property's `derive.localReference` names
|
|
47
|
+
* a reference that does not exist on the local model.
|
|
48
|
+
* - `UnknownExpressionVariable` — An expression property references a
|
|
49
|
+
* variable that is neither a property nor a reference on the local model.
|
|
50
|
+
* - `RemoteReferenceKeyNotFound` — A foreign-key value does not match any
|
|
51
|
+
* key in the referenced remote model. Fires per-row.
|
|
52
|
+
* - `InvalidModelDefinition` — Catch-all for structural problems detected
|
|
53
|
+
* when registering a model.
|
|
54
|
+
* - `UnknownColumn` — A CSV (or otherwise source-tracked) data
|
|
55
|
+
* container contains a column / attribute that is not declared on the
|
|
56
|
+
* target model. Values for the column are silently dropped during ingest;
|
|
57
|
+
* this error surfaces that data loss without failing the load. Fires once
|
|
58
|
+
* per (model, attribute). Only emitted when the loader registers source
|
|
59
|
+
* metadata for the container (so inline `model.data` is unaffected).
|
|
60
|
+
*/
|
|
61
|
+
type ModelErrorType = 'UndefinedAttribute' | 'InvalidValidator' | 'UndefinedValue' | 'NullValue' | 'WrongDataType' | 'NonUniqueKey' | 'MissingKey' | 'DuplicatePropertyKey' | 'MissingModel' | 'MissingProperty' | 'MissingReference' | 'UnknownExpressionVariable' | 'RemoteReferenceKeyNotFound' | 'InvalidModelDefinition' | 'UnknownColumn';
|
|
4
62
|
type DcuplErrorType = 'model' | 'loader';
|
|
5
63
|
type DcuplErrorBase = {
|
|
6
64
|
key?: string;
|
|
@@ -10,6 +68,34 @@ export declare namespace QualityAnalyzer {
|
|
|
10
68
|
type: DcuplErrorType;
|
|
11
69
|
description?: string;
|
|
12
70
|
meta?: any;
|
|
71
|
+
/**
|
|
72
|
+
* Exact number of occurrences in this error's (model, attribute, errorType)
|
|
73
|
+
* group, stamped when the error set is published (#204). Can exceed the
|
|
74
|
+
* number of stored records when the group hit `maxErrorsPerGroup`.
|
|
75
|
+
*/
|
|
76
|
+
groupTotal?: number;
|
|
77
|
+
/** True when this error's group holds fewer stored records than `groupTotal`. */
|
|
78
|
+
truncated?: boolean;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Per-group error totals, independent of the `maxErrorsPerGroup` record cap
|
|
82
|
+
* (#204). Available via `dcupl.quality.errors.summary()` and as the
|
|
83
|
+
* `$DcuplErrorTrackingSummary` model.
|
|
84
|
+
*/
|
|
85
|
+
type ErrorGroupSummary = {
|
|
86
|
+
/** `model::attribute::errorType` */
|
|
87
|
+
key: string;
|
|
88
|
+
model?: string;
|
|
89
|
+
attribute?: string;
|
|
90
|
+
errorGroup: string;
|
|
91
|
+
errorType: string;
|
|
92
|
+
type: DcuplErrorType;
|
|
93
|
+
/** Exact occurrence count. */
|
|
94
|
+
totalCount: number;
|
|
95
|
+
/** Records retained in `$DcuplErrorTrackingErrors` (≤ maxErrorsPerGroup). */
|
|
96
|
+
storedCount: number;
|
|
97
|
+
/** `totalCount > storedCount` */
|
|
98
|
+
truncated: boolean;
|
|
13
99
|
};
|
|
14
100
|
type InternalModelError = DcuplErrorBase & {
|
|
15
101
|
type: 'model';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ListItem } from './data.types';
|
|
2
|
-
import { Projection, SortingProjection } from './projection.types';
|
|
1
|
+
import { ListItem } from './data.types.js';
|
|
2
|
+
import { Projection, SortingProjection } from './projection.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Transform options for query values.
|
|
5
5
|
* - `lowercase`: Convert value to lowercase before comparison
|
|
@@ -7,13 +7,14 @@ import { Projection, SortingProjection } from './projection.types';
|
|
|
7
7
|
* - `removeWhitespace`: Remove all whitespace characters
|
|
8
8
|
*/
|
|
9
9
|
export type DcuplQueryTransformOptions = 'lowercase' | 'trim' | 'removeWhitespace';
|
|
10
|
-
export declare const DcuplQueryOperatorsAsArray: readonly ["eq", "find", "gt", "gte", "lt", "lte", "typeof", "isTruthy", "size"];
|
|
10
|
+
export declare const DcuplQueryOperatorsAsArray: readonly ["eq", "in", "find", "gt", "gte", "lt", "lte", "typeof", "isTruthy", "size"];
|
|
11
11
|
/**
|
|
12
12
|
* Query operators for filtering data.
|
|
13
13
|
*
|
|
14
14
|
* Available operators:
|
|
15
15
|
* - `eq`: Equality check - matches exact values
|
|
16
|
-
* - `
|
|
16
|
+
* - `in`: Membership check - matches if the value equals any value of a list (`eq`'s equality)
|
|
17
|
+
* - `find`: Regex / exact / object match - bare string is exact-equality, `/regex/` for substring/pattern, object for property match
|
|
17
18
|
* - `gt`: Greater than - numeric/date comparison (exclusive)
|
|
18
19
|
* - `gte`: Greater than or equal - numeric/date comparison (inclusive)
|
|
19
20
|
* - `lt`: Less than - numeric/date comparison (exclusive)
|
|
@@ -27,11 +28,14 @@ export declare const DcuplQueryOperatorsAsArray: readonly ["eq", "find", "gt", "
|
|
|
27
28
|
* // Equality
|
|
28
29
|
* { operator: 'eq', attribute: 'status', value: 'active' }
|
|
29
30
|
*
|
|
31
|
+
* // Any of several values
|
|
32
|
+
* { operator: 'in', attribute: 'status', value: ['active', 'pending'] }
|
|
33
|
+
*
|
|
30
34
|
* // Numeric comparison
|
|
31
35
|
* { operator: 'gte', attribute: 'price', value: 100 }
|
|
32
36
|
*
|
|
33
|
-
* //
|
|
34
|
-
* { operator: 'find', attribute: 'name', value: 'search term' }
|
|
37
|
+
* // Substring search (slash-delimited regex; bare string would be exact-match)
|
|
38
|
+
* { operator: 'find', attribute: 'name', value: '/search term/' }
|
|
35
39
|
* ```
|
|
36
40
|
*/
|
|
37
41
|
export type DcuplQueryOperator = (typeof DcuplQueryOperatorsAsArray)[number];
|
|
@@ -79,7 +83,13 @@ type DcuplQueryBase = {
|
|
|
79
83
|
*/
|
|
80
84
|
transform?: DcuplQueryTransformOptions[];
|
|
81
85
|
/**
|
|
82
|
-
* Invert the query result (NOT operation).
|
|
86
|
+
* Invert the query result (NOT operation). Applies to every built-in operator.
|
|
87
|
+
* A missing (`undefined`/`null`) value matches neither way, except for `eq`,
|
|
88
|
+
* `in`, `typeof` and `isTruthy`, which compare against it. A list of values (an
|
|
89
|
+
* `Array<…>` property or a dotted path through a multi-valued reference) is
|
|
90
|
+
* checked per value instead: an empty list, or a `null` in it, simply does not
|
|
91
|
+
* match, so `invert` does match it (`memberships.user.daysInactive gte 60`
|
|
92
|
+
* inverted includes items with no memberships).
|
|
83
93
|
* @example
|
|
84
94
|
* ```typescript
|
|
85
95
|
* // Find items where status is NOT 'active'
|
|
@@ -88,9 +98,14 @@ type DcuplQueryBase = {
|
|
|
88
98
|
*/
|
|
89
99
|
invert?: boolean;
|
|
90
100
|
/**
|
|
91
|
-
* When querying array values, determines match behavior.
|
|
101
|
+
* When querying array values, determines match behavior. Array values are
|
|
102
|
+
* `Array<…>` properties and dotted paths through a multi-valued reference
|
|
103
|
+
* (`memberships.role` compares the `role` of every membership).
|
|
92
104
|
* - `some`: Match if at least one array element matches (default)
|
|
93
|
-
* - `every`: Match only if all array elements match
|
|
105
|
+
* - `every`: Match only if all array elements match — and there is at least
|
|
106
|
+
* one: an empty array (or a reference with no items) never matches
|
|
107
|
+
*
|
|
108
|
+
* On a reference path, leaves that are `undefined` are skipped.
|
|
94
109
|
*
|
|
95
110
|
* @example
|
|
96
111
|
* ```typescript
|
|
@@ -128,13 +143,69 @@ type DcuplQueryEq = DcuplQueryBase & {
|
|
|
128
143
|
value: any;
|
|
129
144
|
};
|
|
130
145
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
146
|
+
* Membership query - matches if the attribute's value equals **any** value of
|
|
147
|
+
* the list, using the same equality as `eq`: a string (or `{ key }`) matches a
|
|
148
|
+
* reference by its key and a date by its ISO string. It answers like an `or`
|
|
149
|
+
* group of one `eq` condition per listed value.
|
|
150
|
+
*
|
|
151
|
+
* - On an `Array<…>` property or a dotted path through a multi-valued
|
|
152
|
+
* reference, `arrayValueHandling: 'some'` (default) matches if at least one
|
|
153
|
+
* value is listed; `'every'` if every value is listed (and there is at least one).
|
|
154
|
+
* - `options.invert` is NOT IN; like `eq`, a missing value then matches.
|
|
155
|
+
* - `options.transform` applies to the attribute value and to every listed value.
|
|
156
|
+
* - `null` in the list matches `null`, like `eq` with `null`.
|
|
157
|
+
* - An empty list matches nothing (and everything under `invert`).
|
|
158
|
+
* - `value` must be an array; anything else throws. (`eq` with an array value
|
|
159
|
+
* compares the whole array instead.)
|
|
133
160
|
*
|
|
134
161
|
* @example
|
|
135
162
|
* ```typescript
|
|
136
|
-
* //
|
|
137
|
-
* { operator: '
|
|
163
|
+
* // Items whose status is 'active' or 'pending'
|
|
164
|
+
* { operator: 'in', attribute: 'status', value: ['active', 'pending'] }
|
|
165
|
+
*
|
|
166
|
+
* // Through references (2 hops)
|
|
167
|
+
* { operator: 'in', attribute: 'customer.address.city', value: ['Vienna', 'Graz'] }
|
|
168
|
+
*
|
|
169
|
+
* // Reference keys, as strings or { key }
|
|
170
|
+
* { operator: 'in', attribute: 'category', value: ['cat-1', { key: 'cat-2' }] }
|
|
171
|
+
*
|
|
172
|
+
* // Every tag is one of the listed ones
|
|
173
|
+
* { operator: 'in', attribute: 'tags', value: ['sale', 'new'], options: { arrayValueHandling: 'every' } }
|
|
174
|
+
*
|
|
175
|
+
* // NOT IN
|
|
176
|
+
* { operator: 'in', attribute: 'status', value: ['archived', 'deleted'], options: { invert: true } }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
type DcuplQueryIn = DcuplQueryBase & {
|
|
180
|
+
operator: 'in';
|
|
181
|
+
/**
|
|
182
|
+
* The values to match; any one of them matching is enough.
|
|
183
|
+
* Note: For indexed search optimization, use string or { key: string } values.
|
|
184
|
+
*/
|
|
185
|
+
value: unknown[];
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Find query - regex / exact / object match.
|
|
189
|
+
*
|
|
190
|
+
* Matching depends on the shape of `value`:
|
|
191
|
+
* - **Bare string** (e.g. `'search'`) — exact-equality against the *whole* field
|
|
192
|
+
* value, NOT a substring. `find` with `'Ball'` does not match `'Soccer Ball'`.
|
|
193
|
+
* - **Slash-delimited regex** (e.g. `'/search/'`, `'/^foo/'`) — the text between the
|
|
194
|
+
* slashes is a JS regex; use this for substring and pattern matching. Flags go in
|
|
195
|
+
* `options.regexFlags` (`'/^foo/'` + `regexFlags: 'i'`), not after the closing
|
|
196
|
+
* slash: `'/^foo/i'` is a bare string and matches exactly.
|
|
197
|
+
* - **Object** (e.g. `{ key: 'value' }`) — property matching against the field.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* // Substring search — slash-delimited regex (bare string would be exact-match)
|
|
202
|
+
* { operator: 'find', attribute: 'description', value: '/search/' }
|
|
203
|
+
*
|
|
204
|
+
* // Case-insensitive substring search
|
|
205
|
+
* { operator: 'find', attribute: 'description', value: '/search/', options: { regexFlags: 'i' } }
|
|
206
|
+
*
|
|
207
|
+
* // Exact-match the whole field value
|
|
208
|
+
* { operator: 'find', attribute: 'status', value: 'active' }
|
|
138
209
|
*
|
|
139
210
|
* // Find items with specific nested property
|
|
140
211
|
* { operator: 'find', attribute: 'metadata', value: { key: 'value' } }
|
|
@@ -143,9 +214,16 @@ type DcuplQueryEq = DcuplQueryBase & {
|
|
|
143
214
|
type DcuplQueryFind = DcuplQueryBase & {
|
|
144
215
|
operator: 'find';
|
|
145
216
|
/**
|
|
146
|
-
*
|
|
217
|
+
* Bare string (exact-match), `/regex/` (substring/pattern), or object (property match).
|
|
147
218
|
*/
|
|
148
219
|
value: Record<string, unknown> | string;
|
|
220
|
+
options?: {
|
|
221
|
+
/**
|
|
222
|
+
* Flags for a `/regex/` value, e.g. `'i'` for case-insensitive. Ignored for any
|
|
223
|
+
* other value; invalid flags match nothing.
|
|
224
|
+
*/
|
|
225
|
+
regexFlags?: string;
|
|
226
|
+
};
|
|
149
227
|
};
|
|
150
228
|
/**
|
|
151
229
|
* Numeric/date comparison queries.
|
|
@@ -251,7 +329,7 @@ type DcuplQuerySize = DcuplQueryBase & {
|
|
|
251
329
|
* };
|
|
252
330
|
* ```
|
|
253
331
|
*/
|
|
254
|
-
export type DcuplQuery = DcuplQueryEq | DcuplQueryNumbers | DcuplQueryTypeOf | DcuplQueryIsTruthy | DcuplQuerySize | DcuplQueryFind;
|
|
332
|
+
export type DcuplQuery = DcuplQueryEq | DcuplQueryIn | DcuplQueryNumbers | DcuplQueryTypeOf | DcuplQueryIsTruthy | DcuplQuerySize | DcuplQueryFind;
|
|
255
333
|
/**
|
|
256
334
|
* Query group - combines multiple conditions with AND/OR logic.
|
|
257
335
|
* Groups can be nested to create complex filter expressions.
|
|
@@ -302,13 +380,24 @@ export type DcuplQueryGroup<ChildQuery extends DcuplQuery | DcuplQueryGroup = an
|
|
|
302
380
|
*/
|
|
303
381
|
__type?: 'group';
|
|
304
382
|
/**
|
|
305
|
-
* Combination logic for conditions in this group.
|
|
306
|
-
*
|
|
383
|
+
* Combination logic for conditions in this group. Set it explicitly; when omitted,
|
|
384
|
+
* the effective behaviour depends on where the group ends up:
|
|
385
|
+
* - Groups created by the query builder (`addGroup` / `setGroup` / `apply(group)` for a
|
|
386
|
+
* group not yet present) are stored as `'or'`. When `addGroup` extends an existing keyed
|
|
387
|
+
* group, that group keeps its current groupType.
|
|
388
|
+
* - The root query (`groupKey: 'root'`) is evaluated as `'and'`.
|
|
389
|
+
* - A nested group that reaches evaluation without a groupType (e.g. passed inside a full
|
|
390
|
+
* query via `apply({ groupKey: 'root', ... })`, `init` or `execute`, or stored by
|
|
391
|
+
* `setGroup` replacing an existing group) is intersected like `'and'`, with one
|
|
392
|
+
* difference: if the running intersection becomes empty, the matches of the next
|
|
393
|
+
* condition replace it instead of the result staying empty.
|
|
307
394
|
*/
|
|
308
395
|
groupType?: DcuplQueryType;
|
|
309
396
|
/**
|
|
310
397
|
* Optional identifier for this group.
|
|
311
|
-
* Useful for tracking or removing specific query groups.
|
|
398
|
+
* Useful for tracking or removing specific query groups. Adding a group with an
|
|
399
|
+
* existing groupKey extends that group; a group without groupKey is always added
|
|
400
|
+
* as a new group.
|
|
312
401
|
*/
|
|
313
402
|
groupKey?: string;
|
|
314
403
|
/**
|
|
@@ -403,7 +492,10 @@ export type DcuplGlobalManyItemOptions<T> = {
|
|
|
403
492
|
};
|
|
404
493
|
/**
|
|
405
494
|
* Options for executing queries on a list instance.
|
|
406
|
-
* Combines query conditions with data retrieval options.
|
|
495
|
+
* Combines optional query conditions with data retrieval options.
|
|
496
|
+
*
|
|
497
|
+
* `queries` is optional: without it the list's own (live) query is used, so
|
|
498
|
+
* item options alone (`projection`, `start`, `count`, `sort`) are valid.
|
|
407
499
|
*
|
|
408
500
|
* @see ListQueryOptions - Type alias with clearer naming
|
|
409
501
|
*
|
|
@@ -417,9 +509,12 @@ export type DcuplGlobalManyItemOptions<T> = {
|
|
|
417
509
|
* count: 10
|
|
418
510
|
* };
|
|
419
511
|
* const results = list.catalog.query.execute(options);
|
|
512
|
+
*
|
|
513
|
+
* // The list's own query, projected
|
|
514
|
+
* const projected = list.catalog.query.execute({ projection: { $: false, name: true } });
|
|
420
515
|
* ```
|
|
421
516
|
*/
|
|
422
|
-
export type DcuplListQueryOptions<T> = DcuplItemOptions<T> & DcuplQueryGroup
|
|
517
|
+
export type DcuplListQueryOptions<T> = DcuplItemOptions<T> & Partial<DcuplQueryGroup>;
|
|
423
518
|
/**
|
|
424
519
|
* Options for retrieving a specific item from a list instance.
|
|
425
520
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DcuplQuery, DcuplQueryGroup, DcuplQueryTransformOptions } from './query.types';
|
|
1
|
+
import { DcuplQuery, DcuplQueryGroup, DcuplQueryTransformOptions } from './query.types.js';
|
|
2
2
|
type SuggestionOptionsBase = {
|
|
3
3
|
attribute: string;
|
|
4
4
|
value: any;
|
|
@@ -7,6 +7,11 @@ type SuggestionOptionsBase = {
|
|
|
7
7
|
excludeUndefineds?: boolean;
|
|
8
8
|
excludeNulls?: boolean;
|
|
9
9
|
transform?: DcuplQueryTransformOptions[];
|
|
10
|
+
/**
|
|
11
|
+
* Flags for a `/pattern/` value, e.g. `'i'` for case-insensitive. Ignored for any
|
|
12
|
+
* other value; invalid flags suggest nothing.
|
|
13
|
+
*/
|
|
14
|
+
regexFlags?: string;
|
|
10
15
|
};
|
|
11
16
|
type SuggestionOptionsFiltered = SuggestionOptionsBase & {
|
|
12
17
|
relevantData?: 'filtered';
|