@spotto/semantic-query 1.0.70-alpha.34 → 1.0.70-alpha.35
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/dates.d.ts +32 -32
- package/dist/dates.js +104 -104
- package/dist/evaluate.d.ts +28 -28
- package/dist/evaluate.js +576 -545
- package/dist/evaluate.js.map +1 -1
- package/dist/fixtures.d.ts +277 -277
- package/dist/fixtures.js +175 -175
- package/dist/index.d.ts +32 -32
- package/dist/index.js +48 -48
- package/dist/resolve-name.d.ts +9 -9
- package/dist/resolve-name.js +90 -90
- package/dist/suggest.d.ts +12 -12
- package/dist/suggest.js +69 -69
- package/dist/types.d.ts +111 -111
- package/dist/types.js +23 -23
- package/dist/validate.d.ts +33 -33
- package/dist/validate.js +821 -795
- package/dist/validate.js.map +1 -1
- package/package.json +3 -3
package/dist/validate.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { FieldDataType, SemanticQuery } from '@spotto/contract';
|
|
2
|
-
import { SemanticCompileOptions, SemanticFieldCatalogue, SemanticFieldDef, SemanticValidationIssue } from './types';
|
|
3
|
-
/** The live storage slots. `valueBool` does not exist; the live key is `valueBoolean`. */
|
|
4
|
-
export declare const SEMANTIC_VALUE_SLOT: Record<string, string>;
|
|
5
|
-
/** Millisecond-timestamp fields, by condition type. `createdDate` uses the ObjectId. */
|
|
6
|
-
export declare const SEMANTIC_TIMESTAMP_FIELD: Record<string, string>;
|
|
7
|
-
/**
|
|
8
|
-
* Find a field by name, case-insensitively — the one lookup both back-ends
|
|
9
|
-
* use, so neither can resolve a name to a different field than the other.
|
|
10
|
-
*/
|
|
11
|
-
export declare function findSemanticField(catalogue: SemanticFieldCatalogue, fieldName: unknown): SemanticFieldDef | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Turn a written value into the form its storage slot actually holds.
|
|
14
|
-
*
|
|
15
|
-
* Shared deliberately: the Mongo compiler and the in-memory evaluator must
|
|
16
|
-
* compare against the SAME value, and this is where a numeric literal for a
|
|
17
|
-
* text field, or a relative date for a DATE field, becomes one concrete thing.
|
|
18
|
-
* Two copies of this would classify the same document differently.
|
|
19
|
-
*
|
|
20
|
-
* Throws a plain Error — the caller decides whether that is a validation issue
|
|
21
|
-
* (it is, at the gate) or an impossible state (it is, after the gate).
|
|
22
|
-
*/
|
|
23
|
-
export declare function coerceSemanticValue(value: unknown, dataType: FieldDataType, now: Date, tz: string): string | number | boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Assert a query is valid, throwing `SemanticQueryValidationError` on the
|
|
26
|
-
* first problem. This is the gate: a back-end may assume anything that passed
|
|
27
|
-
* through it is safe to execute.
|
|
28
|
-
*/
|
|
29
|
-
export declare function assertSemanticQuery(semanticQuery: SemanticQuery, catalogue: SemanticFieldCatalogue, opts?: SemanticCompileOptions): void;
|
|
30
|
-
/** Validate without throwing. Empty array = valid. */
|
|
31
|
-
export declare function validateSemanticQuery(semanticQuery: SemanticQuery, catalogue: SemanticFieldCatalogue, opts?: SemanticCompileOptions): SemanticValidationIssue[];
|
|
32
|
-
/** True when any condition touches a custom field — both back-ends need to know. */
|
|
33
|
-
export declare function queryUsesCustomFields(semanticQuery: SemanticQuery): boolean;
|
|
1
|
+
import { FieldDataType, SemanticQuery } from '@spotto/contract';
|
|
2
|
+
import { SemanticCompileOptions, SemanticFieldCatalogue, SemanticFieldDef, SemanticValidationIssue } from './types';
|
|
3
|
+
/** The live storage slots. `valueBool` does not exist; the live key is `valueBoolean`. */
|
|
4
|
+
export declare const SEMANTIC_VALUE_SLOT: Record<string, string>;
|
|
5
|
+
/** Millisecond-timestamp fields, by condition type. `createdDate` uses the ObjectId. */
|
|
6
|
+
export declare const SEMANTIC_TIMESTAMP_FIELD: Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Find a field by name, case-insensitively — the one lookup both back-ends
|
|
9
|
+
* use, so neither can resolve a name to a different field than the other.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findSemanticField(catalogue: SemanticFieldCatalogue, fieldName: unknown): SemanticFieldDef | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Turn a written value into the form its storage slot actually holds.
|
|
14
|
+
*
|
|
15
|
+
* Shared deliberately: the Mongo compiler and the in-memory evaluator must
|
|
16
|
+
* compare against the SAME value, and this is where a numeric literal for a
|
|
17
|
+
* text field, or a relative date for a DATE field, becomes one concrete thing.
|
|
18
|
+
* Two copies of this would classify the same document differently.
|
|
19
|
+
*
|
|
20
|
+
* Throws a plain Error — the caller decides whether that is a validation issue
|
|
21
|
+
* (it is, at the gate) or an impossible state (it is, after the gate).
|
|
22
|
+
*/
|
|
23
|
+
export declare function coerceSemanticValue(value: unknown, dataType: FieldDataType, now: Date, tz: string): string | number | boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Assert a query is valid, throwing `SemanticQueryValidationError` on the
|
|
26
|
+
* first problem. This is the gate: a back-end may assume anything that passed
|
|
27
|
+
* through it is safe to execute.
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertSemanticQuery(semanticQuery: SemanticQuery, catalogue: SemanticFieldCatalogue, opts?: SemanticCompileOptions): void;
|
|
30
|
+
/** Validate without throwing. Empty array = valid. */
|
|
31
|
+
export declare function validateSemanticQuery(semanticQuery: SemanticQuery, catalogue: SemanticFieldCatalogue, opts?: SemanticCompileOptions): SemanticValidationIssue[];
|
|
32
|
+
/** True when any condition touches a custom field — both back-ends need to know. */
|
|
33
|
+
export declare function queryUsesCustomFields(semanticQuery: SemanticQuery): boolean;
|