@lde/search 0.34.0 → 0.36.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/adapter.d.ts CHANGED
@@ -6,8 +6,8 @@
6
6
  * deployment author declaring a schema and running searches needs none of
7
7
  * this; the main entry point carries that (small) authoring surface.
8
8
  */
9
- export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName, localLookupTargetsOf, referencedTargetsOf, storedTargetOf, TARGET_FIELD, identityFieldOf, identityFieldName, inheritedFacetPolicies, referenceFields, referenceTypeNamed, rootTypeNamed, inlineFramingDepth, fieldNamed, datasetField, ID_FIELD, AND_KEY, OR_KEY, labelFieldOf, labelFieldNameOf, labelSourceNamesOf, labelTargetNamesOf, documentKeyOf, DEFAULT_LABEL_FIELD, isRangeFacet, isBinnedRangeFacet, isAbsoluteIri, isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
10
- export type { PhysicalFields } from './schema.js';
9
+ export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName, localLookupTargetsOf, referencedTargetsOf, storedTargetOf, TARGET_FIELD, identityFieldOf, identityFieldName, inheritedFacetPolicies, referenceFields, referenceTypeNamed, rootTypeNamed, inlineFramingDepth, fieldNamed, datasetField, ID_FIELD, AND_KEY, OR_KEY, labelFieldOf, labelFieldNameOf, labelSourceNamesOf, labelTargetNamesOf, documentKeyOf, DEFAULT_LABEL_FIELD, isRangeFacet, isBinnedRangeFacet, storedFacetRanges, isAbsoluteIri, isoToUnixSeconds, lastSecondOf, unixSecondsToIso, isDatePrecision, } from './schema.js';
10
+ export type { PhysicalFields, DatePrecision, StoredDate } from './schema.js';
11
11
  export { missingRequiredFields } from './project.js';
12
12
  export { physicalNameTokens } from './physical-name.js';
13
13
  export { matchLanguage } from './language.js';
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/adapter.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * deployment author declaring a schema and running searches needs none of
7
7
  * this; the main entry point carries that (small) authoring surface.
8
8
  */
9
- export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName, localLookupTargetsOf, referencedTargetsOf, storedTargetOf, TARGET_FIELD, identityFieldOf, identityFieldName, inheritedFacetPolicies, referenceFields, referenceTypeNamed, rootTypeNamed, inlineFramingDepth, fieldNamed, datasetField, ID_FIELD, AND_KEY, OR_KEY, labelFieldOf, labelFieldNameOf, labelSourceNamesOf, labelTargetNamesOf, documentKeyOf, DEFAULT_LABEL_FIELD, isRangeFacet, isBinnedRangeFacet, isAbsoluteIri, isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
9
+ export { assertTypeInSchema, physicalFields, irAlias, displayFieldName, displayFieldPattern, displayLangOf, searchableFields, facetableFields, filterableFields, sortableFields, outputFields, isInternalField, isInlineReference, nestedReferenceType, nestedFieldName, localLookupTargetsOf, referencedTargetsOf, storedTargetOf, TARGET_FIELD, identityFieldOf, identityFieldName, inheritedFacetPolicies, referenceFields, referenceTypeNamed, rootTypeNamed, inlineFramingDepth, fieldNamed, datasetField, ID_FIELD, AND_KEY, OR_KEY, labelFieldOf, labelFieldNameOf, labelSourceNamesOf, labelTargetNamesOf, documentKeyOf, DEFAULT_LABEL_FIELD, isRangeFacet, isBinnedRangeFacet, storedFacetRanges, isAbsoluteIri, isoToUnixSeconds, lastSecondOf, unixSecondsToIso, isDatePrecision, } from './schema.js';
10
10
  export { missingRequiredFields } from './project.js';
11
11
  export { physicalNameTokens } from './physical-name.js';
12
12
  export { matchLanguage } from './language.js';
package/dist/engine.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { SearchQuery } from './query.js';
2
- import type { RootType, RootTypeOf, SearchSchema, SearchType } from './schema.js';
2
+ import type { RootType, RootTypeOf, SearchSchema, SearchType, StoredDate } from './schema.js';
3
3
  /**
4
4
  * The engine port: the boundary a concrete engine adapter (e.g. the engine
5
5
  * `@lde/search-typesense`’s `createTypesenseSearchEngine` returns) implements.
@@ -157,8 +157,14 @@ export interface SearchHit<OutputField extends string = string> {
157
157
  * deployment narrows it via {@link OutputFieldsOf} for typo-safe field access.
158
158
  */
159
159
  export type ResultDocument<OutputField extends string = string> = Readonly<Partial<Record<OutputField, SearchValue>>>;
160
- /** A logical field value. */
161
- export type SearchValue = string | number | boolean | readonly string[] | LocalizedValue | Reference | readonly Reference[] | NestedDocument | readonly NestedDocument[];
160
+ /**
161
+ * A logical field value. A `date` is a {@link StoredDate} – stored terms like
162
+ * every other value at this seam: the Unix seconds the index sorts and filters
163
+ * on, plus the precision its source gave, which a surface needs to serve it in
164
+ * that precision’s canonical form. An index built before precision was stored
165
+ * reports `dateTime`, the one form the seconds alone can always be read as.
166
+ */
167
+ export type SearchValue = string | number | StoredDate | boolean | readonly string[] | LocalizedValue | Reference | readonly Reference[] | NestedDocument | readonly NestedDocument[];
162
168
  /**
163
169
  * A **nested Search Document**: the referent of a surfaced (`output`) inline
164
170
  * reference, carrying its Reference Type’s own output fields – each referent’s
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Roots } from './project.js';
2
2
  export type { ProjectedNode, ProjectionContext, SearchDocument, } from './project.js';
3
- export { defineSearchType, searchSchema, validateSearchType, assertValidSearchType, ID_FIELD, AND_KEY, OR_KEY, isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
4
- export type { FieldKind, SearchField, SearchFieldBase, TextField, KeywordField, ReferenceField, ReferenceStrategy, NumericField, BooleanField, SearchType, SearchTypeBase, RootType, ReferenceType, RootTypeOf, SearchTypeIssue, KeyField, FacetKeys, SearchSchema, FacetRange, ProjectionValue, } from './schema.js';
3
+ export { defineSearchType, searchSchema, validateSearchType, assertValidSearchType, ID_FIELD, AND_KEY, OR_KEY, isoToUnixSeconds, lastSecondOf, unixSecondsToIso, isDatePrecision, } from './schema.js';
4
+ export type { FieldKind, SearchField, SearchFieldBase, TextField, KeywordField, ReferenceField, ReferenceStrategy, NumericField, NumberField, DateField, BooleanField, SearchType, SearchTypeBase, RootType, ReferenceType, RootTypeOf, SearchTypeIssue, KeyField, FacetKeys, SearchSchema, FacetRange, DateFacetRange, ProjectionValue, DatePrecision, StoredDate, } from './schema.js';
5
5
  export { joinGraph, MAX_JOIN_DEPTH } from './join-graph.js';
6
6
  export type { JoinGraph } from './join-graph.js';
7
7
  export { filterOn } from './query.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,MAAM,EAMN,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,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S,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,aAAa,EACb,eAAe,EACf,IAAI,GACL,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ export { defineSearchType, searchSchema, validateSearchType, assertValidSearchTy
16
16
  // projection, or a derive that computes seconds from something other than an
17
17
  // ISO string – so it belongs on the authoring surface, not only the adapter
18
18
  // one.
19
- isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
19
+ isoToUnixSeconds, lastSecondOf, unixSecondsToIso, isDatePrecision, } from './schema.js';
20
20
  // The declared join edges between root types: which types a query can filter
21
21
  // across, and which collections must be rebuilt together. Built eagerly by
22
22
  // `searchSchema`, so declaring a schema is what validates the joins.
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAsBL,KAAK,eAAe,EAIpB,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,+DAA+D;AAC/D,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAChD,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAC1C;IACC,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,YAAY,EACrB,OAAO,GAAE,iBAAyC,GACjD,cAAc,CAgBhB;AAmLD;;;;;;;;;;;;GAYG;AACH,wBAAuB,YAAY,CACjC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EACrB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,QAAQ,EACpB,OAAO,GAAE,iBAAyC,GACjD,aAAa,CAAC,cAAc,CAAC,CAc/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,aAAa,EACvB,UAAU,EA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,EAAE,aAAa,EACvB,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,YAAY,GACpB,SAAS,MAAM,EAAE,CAmCnB"}
package/dist/project.js CHANGED
@@ -266,21 +266,12 @@ function applyField(document, node, field, searchType, schema, context, nested)
266
266
  // this is the busiest way a non-IRI could otherwise reach the index. A
267
267
  // value that survives nothing leaves the field absent, exactly as a derive
268
268
  // returning `undefined` does.
269
+ if (field.kind === 'date') {
270
+ return applyDerivedDate(document, field, derived);
271
+ }
269
272
  const value = field.kind === 'reference' && derived !== undefined
270
273
  ? derivedIris(derived)
271
- : // A derived `date` goes through the same storage codec as a read one:
272
- // the field is stored as Unix seconds, so an ISO string returned here
273
- // would otherwise land as a string in an int64 field.
274
- field.kind === 'date' && typeof derived === 'string'
275
- ? isoToUnixSeconds(derived)
276
- : // A derive that computed seconds itself returns a number, which the
277
- // codec never saw and so never range-checked. Seconds outside the
278
- // int64 a `date` field is stored in would be refused by the
279
- // engine, where an unparseable string merely leaves the field
280
- // absent. Drop it too.
281
- field.kind === 'date' && typeof derived === 'number'
282
- ? storableUnixSeconds(derived)
283
- : derived;
274
+ : derived;
284
275
  // NaN is not a value any kind stores, and a derive is the only route that
285
276
  // can produce one (`setNumber` guards the read route). It serializes as
286
277
  // `null`, which an engine rejects for a numeric field – so drop it, leaving
@@ -344,7 +335,7 @@ function applyField(document, node, field, searchType, schema, context, nested)
344
335
  return setNumber(document, field.name, toNumber(firstLiteralOf(node, alias)));
345
336
  case 'date': {
346
337
  const literal = firstLiteralOf(node, alias);
347
- return setNumber(document, field.name, literal === undefined ? undefined : isoToUnixSeconds(literal));
338
+ return setDate(document, field, literal === undefined ? undefined : isoToUnixSeconds(literal));
348
339
  }
349
340
  case 'boolean': {
350
341
  // The xsd:boolean lexical space: true/false/1/0.
@@ -1015,6 +1006,37 @@ function toInteger(literal) {
1015
1006
  function toNumber(literal) {
1016
1007
  return literal === undefined ? undefined : Number(literal);
1017
1008
  }
1009
+ /**
1010
+ * A derived `date` goes through the same storage codec as a read one: the field
1011
+ * is stored as Unix seconds, so an ISO string returned here would otherwise
1012
+ * land as a string in an int64 field – and it is parsed like any literal, its
1013
+ * precision included. A derive that computed seconds itself returns a number,
1014
+ * which states no precision and so is stored as a date-time; the codec never
1015
+ * saw it and so never range-checked it, and seconds outside the int64 a `date`
1016
+ * field is stored in would be refused by the engine where an unparseable
1017
+ * string merely leaves the field absent – so drop those too.
1018
+ */
1019
+ function applyDerivedDate(document, field, derived) {
1020
+ if (typeof derived === 'string') {
1021
+ return setDate(document, field, isoToUnixSeconds(derived));
1022
+ }
1023
+ if (typeof derived === 'number') {
1024
+ // Truncated, as the codec truncates a string’s fractional seconds: the
1025
+ // field is an int64. `storableUnixSeconds` drops NaN.
1026
+ const seconds = storableUnixSeconds(Math.trunc(derived));
1027
+ return setDate(document, field, seconds === undefined ? undefined : { seconds, precision: 'dateTime' });
1028
+ }
1029
+ }
1030
+ /** Store a `date` field’s seconds, and its precision in the companion beside
1031
+ * them ({@link physicalFields}), so the surface can serve the value in the
1032
+ * form its source gave. */
1033
+ function setDate(document, field, stored) {
1034
+ if (stored === undefined) {
1035
+ return;
1036
+ }
1037
+ document[field.name] = stored.seconds;
1038
+ document[physicalFields(field).precision] = stored.precision;
1039
+ }
1018
1040
  function setNumber(document, field, value) {
1019
1041
  if (value !== undefined && !Number.isNaN(value)) {
1020
1042
  document[field] = value;
package/dist/query.d.ts CHANGED
@@ -84,7 +84,9 @@ export type ReferenceProjection = Readonly<Record<string, {
84
84
  * One criterion on one field. The operator is fixed by that field’s
85
85
  * {@link FieldKind} ({@link filterOperatorFor}): keyword/reference use `in` (OR
86
86
  * within the value list), the numeric/date kinds use an inclusive `range`,
87
- * boolean uses `is`. Bounds are inclusive only – no `gt`/`gte`/`lt`/`lte`.
87
+ * boolean uses `is`. Bounds are inclusive only – no `gt`/`gte`/`lt`/`lte` – and
88
+ * a `date` bound includes the whole period it names, so `max: '1999'` runs
89
+ * through the end of 1999 (`lastSecondOf`).
88
90
  *
89
91
  * Criteria are the atoms a {@link Filter} is built from, so each carries its own
90
92
  * field AND its own operator: one clause may range over a `reference` and a
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAClC,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;gEAC4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,MAAM,CACJ,MAAM,EACN;IACE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAA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;;;;;;;;;;GAgCG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,SAAS,GAChB,SAAS,UAAU,EAAE,CA+FvB;AAqFD;yEACyE;AACzE,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,SAAS,GAChB,IAAI,CAaN;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE"}
package/dist/schema.d.ts CHANGED
@@ -341,25 +341,35 @@ export interface ReferenceField extends SearchFieldBase, Searchable {
341
341
  }
342
342
  /**
343
343
  * Range-facet bins for a numeric (`integer`/`number`/`date`) facetable field.
344
- * When set, the field’s range facet buckets into these fixed half-open
345
- * `[min, max)` ranges rather than one bucket per distinct value – the
346
- * per-bucket counts a UI slider draws over the extent the facet reports
347
- * either way. Changing the bins needs no reindex, though a field’s first bins
344
+ * When set, the field’s range facet buckets into these fixed ranges – half-open
345
+ * `[min, max)` on a number, whole periods on a date ({@link DateFacetRange}) –
346
+ * rather than one bucket per distinct value. They are the per-bucket counts a
347
+ * UI slider draws over the extent the facet reports either way. Changing the bins needs no reindex, though a field’s first bins
348
348
  * may (the Typesense adapter indexes a binned field for sorting). Bins are
349
349
  * engine-neutral: the Typesense adapter emits a `facet_by` range, an
350
350
  * OpenSearch adapter a `range` aggregation. See {@link FacetRange}.
351
351
  */
352
- export interface RangeFacetable {
353
- readonly facetRanges?: readonly FacetRange[];
352
+ export interface RangeFacetable<Range = FacetRange> {
353
+ readonly facetRanges?: readonly Range[];
354
354
  }
355
355
  /**
356
- * A numeric value: range-filtered, range-faceted, sortable.
357
- * `integer` is a whole number, `number` a float, `date` a point in time
358
- * (ISO 8601 at the edges, Unix seconds in the index) – identical capabilities,
359
- * so one interface serves all three kinds; `field.kind` still narrows.
356
+ * A field the `range` operator applies to: range-filtered, range-faceted,
357
+ * sortable. The kinds share every capability and differ only in how a bound is
358
+ * written, so `field.kind` narrows to the one that tells.
360
359
  */
361
- export interface NumericField extends SearchFieldBase, RangeFacetable {
362
- readonly kind: 'integer' | 'number' | 'date';
360
+ export type NumericField = NumberField | DateField;
361
+ /** A number: `integer` a whole number, `number` a float. */
362
+ export interface NumberField extends SearchFieldBase, RangeFacetable {
363
+ readonly kind: 'integer' | 'number';
364
+ readonly searchable?: never;
365
+ }
366
+ /**
367
+ * A point in time: ISO 8601 at the edges, Unix seconds in the index. Its bins
368
+ * are ISO 8601 too ({@link DateFacetRange}), like every other date a caller
369
+ * writes.
370
+ */
371
+ export interface DateField extends SearchFieldBase, RangeFacetable<DateFacetRange> {
372
+ readonly kind: 'date';
363
373
  readonly searchable?: never;
364
374
  }
365
375
  /** A boolean flag; absent in a document means `false`. */
@@ -379,6 +389,21 @@ export interface FacetRange {
379
389
  readonly min?: number;
380
390
  readonly max?: number;
381
391
  }
392
+ /**
393
+ * A range-facet bin on a `date` field, its bounds ISO 8601 as the codec reads
394
+ * them ({@link isoToUnixSeconds}). Both bounds are inclusive of the whole
395
+ * period they name, as a `date` range filter’s are: `{ min: '1900', max:
396
+ * '1999' }` is the years 1900 to 1999, and the next bin starts at `2000`.
397
+ * Contiguous periods still partition cleanly, since one ends before the next
398
+ * begins – which is why a date bin need not be half-open like a
399
+ * {@link FacetRange}. A bound the codec cannot read fails
400
+ * {@link validateSearchType}.
401
+ */
402
+ export interface DateFacetRange {
403
+ readonly key: string;
404
+ readonly min?: string;
405
+ readonly max?: string;
406
+ }
382
407
  /** The declaration members every {@link SearchType} shares. */
383
408
  export interface SearchTypeBase {
384
409
  /** Logical API name (PascalCase, e.g. `Dataset`) – names the type in the API
@@ -728,7 +753,7 @@ export declare function storedTargetOf(entry: Readonly<Record<string, unknown>>,
728
753
  */
729
754
  export interface SearchTypeIssue {
730
755
  readonly field: string;
731
- readonly reason: 'duplicate-field-name' | 'invalid-field-name' | 'unknown-kind' | 'invalid-locale' | 'missing-ref' | 'missing-ref-type-name' | 'ref-not-allowed' | 'text-requires-locales' | 'locales-not-allowed' | 'facet-ranges-not-allowed' | 'searchable-not-allowed' | 'transform-not-allowed' | 'derive-with-path' | 'from-not-allowed' | 'from-with-path' | 'from-with-derive' | 'from-with-inline-ref' | 'unknown-projection-value' | 'duplicate-projection-value' | 'text-not-filterable' | 'text-not-facetable' | 'joinable-not-allowed' | 'joinable-without-label-source' | 'joinable-with-inline-ref' | 'joinable-with-several-targets' | 'duplicate-target' | 'empty-target' | 'reserved-field-name' | 'key-field-unknown' | 'key-field-not-reference' | 'key-field-without-path' | 'key-field-not-array' | 'key-field-inline' | 'key-pick-not-a-function' | 'key-not-allowed' | 'facet-keys-only-not-a-function' | 'facet-keys-not-allowed';
756
+ readonly reason: 'duplicate-field-name' | 'invalid-field-name' | 'unknown-kind' | 'invalid-locale' | 'missing-ref' | 'missing-ref-type-name' | 'ref-not-allowed' | 'text-requires-locales' | 'locales-not-allowed' | 'facet-ranges-not-allowed' | 'unparseable-facet-range' | 'searchable-not-allowed' | 'transform-not-allowed' | 'derive-with-path' | 'from-not-allowed' | 'from-with-path' | 'from-with-derive' | 'from-with-inline-ref' | 'unknown-projection-value' | 'duplicate-projection-value' | 'text-not-filterable' | 'text-not-facetable' | 'joinable-not-allowed' | 'joinable-without-label-source' | 'joinable-with-inline-ref' | 'joinable-with-several-targets' | 'duplicate-target' | 'empty-target' | 'reserved-field-name' | 'key-field-unknown' | 'key-field-not-reference' | 'key-field-without-path' | 'key-field-not-array' | 'key-field-inline' | 'key-pick-not-a-function' | 'key-not-allowed' | 'facet-keys-only-not-a-function' | 'facet-keys-not-allowed';
732
757
  }
733
758
  /**
734
759
  * The reserved logical name of a document’s IRI – the one field every indexed
@@ -780,7 +805,9 @@ export declare const TARGET_FIELD = "_target";
780
805
  * - field names are unique (a duplicate would silently shadow in every
781
806
  * consumer, each picking a different winner) and a metacharacter-free
782
807
  * identifier (the name is interpolated into physical field names and the
783
- * display RE2 pattern), and is not the reserved {@link ID_FIELD};
808
+ * display RE2 pattern), and is not the reserved {@link ID_FIELD}, nor the
809
+ * precision companion a `date` field stores beside itself
810
+ * ({@link PhysicalFields.precision});
784
811
  * - a `text` field’s declared locales are BCP-47-shaped (no `_`, which is the
785
812
  * reserved name↔locale separator);
786
813
  * - a `reference` field that is `output` declares `ref` (the API surfaces
@@ -800,7 +827,8 @@ export declare const TARGET_FIELD = "_target";
800
827
  * meaningless;
801
828
  * - a kind without a `where` operator (`text` – it feeds the free-text query)
802
829
  * is neither `filterable` nor `facetable`;
803
- * - `facetRanges` only on the `range`-operator kinds (`integer`/`number`/`date`);
830
+ * - `facetRanges` only on the `range`-operator kinds (`integer`/`number`/`date`),
831
+ * and a `date` bin’s bounds ISO 8601 the codec can read;
804
832
  * - `searchable` only on `text`/`keyword`/`reference` (projection emits no
805
833
  * folded search field for the other kinds);
806
834
  * - `transform` only on `keyword`/`reference` (the only kinds whose
@@ -863,6 +891,16 @@ export interface PhysicalFields {
863
891
  * name at the surface; only the physical fanout knows there are two.
864
892
  */
865
893
  readonly identity: string | undefined;
894
+ /**
895
+ * The **precision companion** of a `date` field: `${name}_precision`,
896
+ * holding the {@link DatePrecision} its source gave beside the Unix seconds
897
+ * the field itself stores. Stored, never indexed: sorting and filtering read
898
+ * the seconds alone, and only output reads this, to serve the value in the
899
+ * canonical form of its precision ({@link unixSecondsToIso}). Not part of the
900
+ * field model, so it never reaches a client’s schema. `undefined` for every
901
+ * other kind.
902
+ */
903
+ readonly precision: string | undefined;
866
904
  }
867
905
  /** The physical name of an inline reference’s
868
906
  * {@link ReferenceStrategy.identity identity companion}. */
@@ -1057,9 +1095,22 @@ export declare function isRangeFacet(field: SearchField): field is NumericField;
1057
1095
  * facet type, the adapter’s facet clause and the bucket reconstruction, so
1058
1096
  * they cannot disagree.
1059
1097
  */
1060
- export declare function isBinnedRangeFacet(field: SearchField): field is NumericField & {
1098
+ export declare function isBinnedRangeFacet(field: SearchField): field is (NumberField & {
1061
1099
  readonly facetRanges: readonly FacetRange[];
1062
- };
1100
+ }) | (DateField & {
1101
+ readonly facetRanges: readonly DateFacetRange[];
1102
+ });
1103
+ /**
1104
+ * A binned field’s bins in stored terms, for an adapter to compile and echo:
1105
+ * half-open `[min, max)` Unix seconds. A number’s pass as declared. A date’s
1106
+ * `min` is its period’s first second and its `max` the first second after its
1107
+ * period ({@link lastSecondOf}), since a date bin includes the whole period its
1108
+ * `max` names. The one place a date bin is parsed, so the facet clause and the
1109
+ * bounds a bucket echoes cannot disagree. Empty for a field that declares no
1110
+ * bins; a bound the codec cannot read is left open, which
1111
+ * {@link validateSearchType} rules out before a query is ever compiled.
1112
+ */
1113
+ export declare function storedFacetRanges(field: SearchField): readonly FacetRange[];
1063
1114
  /**
1064
1115
  * Whether a value is an **absolute IRI**: a scheme, then anything with no
1065
1116
  * whitespace. The single definition the projection (which
@@ -1078,25 +1129,69 @@ export declare function isBinnedRangeFacet(field: SearchField): field is Numeric
1078
1129
  * someone forgot to percent-encode.
1079
1130
  */
1080
1131
  export declare function isAbsoluteIri(value: string): boolean;
1132
+ /**
1133
+ * How finely a `date` value’s source stated it: a year (`xsd:gYear`), a month
1134
+ * (`xsd:gYearMonth`), a day (`xsd:date`) or a point in time (`xsd:dateTime`).
1135
+ * Stored beside the Unix seconds ({@link PhysicalFields.precision}), because
1136
+ * the seconds alone cannot tell a year from the first second of it.
1137
+ */
1138
+ export type DatePrecision = 'year' | 'month' | 'day' | 'dateTime';
1139
+ /** A `date` value as it is stored: Unix seconds, and the precision its source
1140
+ * gave ({@link isoToUnixSeconds}). */
1141
+ export interface StoredDate {
1142
+ readonly seconds: number;
1143
+ readonly precision: DatePrecision;
1144
+ }
1145
+ /** Whether a stored value is a {@link DatePrecision} – what an adapter checks
1146
+ * before trusting the precision companion it reads back. */
1147
+ export declare function isDatePrecision(value: unknown): value is DatePrecision;
1081
1148
  /**
1082
1149
  * The engine storage codec for `date` fields: stored as Unix seconds (a
1083
- * sortable, range-filterable int64), ISO 8601 at the API edges. One pair for
1084
- * the projection (writes), the query compiler (filter bounds) and the surface
1085
- * (output), so the three cannot disagree. Returns `undefined` for an
1086
- * unparseable value.
1150
+ * sortable, range-filterable int64) plus the precision the source gave, ISO
1151
+ * 8601 at the API edges. One pair for the projection (writes), the query
1152
+ * compiler and `validateQuery` (filter bounds) and the surface (output), so
1153
+ * they cannot disagree. Returns `undefined` for an unparseable value.
1154
+ *
1155
+ * - A **year, month or day** names a calendar period, so its timezone is
1156
+ * ignored and it is stored at that period’s first second in UTC.
1157
+ * - A **date-time** is normalised to UTC; one without a timezone is read as
1158
+ * UTC, so what the index holds never depends on the host that built it.
1159
+ * Fractional seconds are truncated.
1160
+ * - A year beyond what `Date` can represent (±271,821 years around 1970) is
1161
+ * **deep time**, and deep time has no months or days: there the value is
1162
+ * read as an `xsd:gYear` – a bare year, such as a Carboniferous fossil’s
1163
+ * `-318000000` – and stored as that many average Gregorian years from 1970.
1164
+ * Anything finer at that depth is unparseable.
1165
+ *
1166
+ * A year may carry a sign and any number of digits, so the expanded form
1167
+ * `Date` itself emits (`+025000`, `-001100`) reads the same as `25000` and
1168
+ * `-1100`.
1169
+ */
1170
+ export declare function isoToUnixSeconds(iso: string): StoredDate | undefined;
1171
+ /**
1172
+ * The inverse of {@link isoToUnixSeconds}: stored Unix seconds → the canonical
1173
+ * ISO 8601 form of `precision`, so a client parses one shape per precision
1174
+ * whatever lexical variant the source used:
1175
+ *
1176
+ * | Precision | Canonical form |
1177
+ * | ---------- | -------------------------------------- |
1178
+ * | `year` | `1999`, `-0044`, `-250000` |
1179
+ * | `month` | `1999-05` |
1180
+ * | `day` | `1999-05-03` |
1181
+ * | `dateTime` | `1999-05-03T12:30:00Z` (always UTC) |
1087
1182
  *
1088
- * A year beyond what `Date` can represent (±271,821 years around 1970) is
1089
- * deep time, and deep time has no months or days: there the value is read as
1090
- * an `xsd:gYear` – a bare year, such as a Carboniferous fossil’s `-318000000` –
1091
- * and stored as that many average Gregorian years from 1970. Anything finer at
1092
- * that depth is unparseable.
1183
+ * A year has at least four digits and no `+`. Seconds beyond what `Date` can
1184
+ * represent are deep time, served as an `xsd:gYear` whatever `precision` says.
1093
1185
  */
1094
- export declare function isoToUnixSeconds(iso: string): number | undefined;
1186
+ export declare function unixSecondsToIso(seconds: number, precision: DatePrecision): string;
1095
1187
  /**
1096
- * The inverse of {@link isoToUnixSeconds}: stored Unix seconds → ISO 8601, or
1097
- * an `xsd:gYear` for seconds beyond what `Date` can represent.
1188
+ * The last stored second of the period a date names: the end of its year,
1189
+ * month or day, or the date-time itself. What an upper bound reaches up to and
1190
+ * including, so `max: '1999'` means through 1999, as a person reading it would
1191
+ * say – where the period’s first second would admit every record dated just
1192
+ * `2000` to a range that stops at `2000`, since those are stored there too.
1098
1193
  */
1099
- export declare function unixSecondsToIso(seconds: number): string;
1194
+ export declare function lastSecondOf(stored: StoredDate): number;
1100
1195
  /** `seconds` if a `date` field can store it – the int64 the engine keeps
1101
1196
  * Unix seconds in – or `undefined`, the same answer {@link isoToUnixSeconds}
1102
1197
  * gives a string it cannot parse. */
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACnB,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/E;oEACoE;AACpE,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAcnD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS,CAE7E;AAED;;;;;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AAC;CACnC;AAED;6DAC6D;AAC7D,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAOtE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CA6CpE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,aAAa,GACvB,MAAM,CAyBR;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAsBvD;AAED;;sCAEsC;AACtC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvE;AAsGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,YAAY,GACpB,cAAc,CAwChB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,GAAG,SAAS,GAC/B,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAiBhC"}
package/dist/schema.js CHANGED
@@ -861,7 +861,9 @@ const LOCALE_PATTERN = /^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$/;
861
861
  * - field names are unique (a duplicate would silently shadow in every
862
862
  * consumer, each picking a different winner) and a metacharacter-free
863
863
  * identifier (the name is interpolated into physical field names and the
864
- * display RE2 pattern), and is not the reserved {@link ID_FIELD};
864
+ * display RE2 pattern), and is not the reserved {@link ID_FIELD}, nor the
865
+ * precision companion a `date` field stores beside itself
866
+ * ({@link PhysicalFields.precision});
865
867
  * - a `text` field’s declared locales are BCP-47-shaped (no `_`, which is the
866
868
  * reserved name↔locale separator);
867
869
  * - a `reference` field that is `output` declares `ref` (the API surfaces
@@ -881,7 +883,8 @@ const LOCALE_PATTERN = /^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$/;
881
883
  * meaningless;
882
884
  * - a kind without a `where` operator (`text` – it feeds the free-text query)
883
885
  * is neither `filterable` nor `facetable`;
884
- * - `facetRanges` only on the `range`-operator kinds (`integer`/`number`/`date`);
886
+ * - `facetRanges` only on the `range`-operator kinds (`integer`/`number`/`date`),
887
+ * and a `date` bin’s bounds ISO 8601 the codec can read;
885
888
  * - `searchable` only on `text`/`keyword`/`reference` (projection emits no
886
889
  * folded search field for the other kinds);
887
890
  * - `transform` only on `keyword`/`reference` (the only kinds whose
@@ -908,6 +911,11 @@ export function validateSearchType(searchType) {
908
911
  const issues = [];
909
912
  const seen = new Set();
910
913
  const seenProjectionValues = new Set();
914
+ // A `date` field stores its precision under `${name}_precision`, so a
915
+ // declared field of that name would overwrite it, and be overwritten.
916
+ const precisionCompanions = new Set(searchType.fields
917
+ .filter((field) => field.kind === 'date')
918
+ .map((field) => physicalFields(field).precision));
911
919
  for (const declared of searchType.fields) {
912
920
  // Validation guards declarations built OUTSIDE TypeScript (a SHACL
913
921
  // generator, plain JS), so it inspects the uniform flat shape rather
@@ -927,7 +935,8 @@ export function validateSearchType(searchType) {
927
935
  // `and`/`or` are the `where` combinators; a declared field of any of those
928
936
  // names would shadow it in the API output or in `where`, silently
929
937
  // answering a different question.
930
- if (RESERVED_FIELD_NAMES.includes(field.name)) {
938
+ if (RESERVED_FIELD_NAMES.includes(field.name) ||
939
+ precisionCompanions.has(field.name)) {
931
940
  issue('reserved-field-name');
932
941
  }
933
942
  // Every kind-dependent rule below would silently pass for a kind outside
@@ -1027,6 +1036,15 @@ export function validateSearchType(searchType) {
1027
1036
  filterOperatorFor(field.kind) !== 'range') {
1028
1037
  issue('facet-ranges-not-allowed');
1029
1038
  }
1039
+ if (field.kind === 'date' &&
1040
+ field.facetRanges?.some((range) =>
1041
+ // A number here is a bound written in stored seconds, which a date
1042
+ // bin does not take – so it is as unreadable as a malformed string.
1043
+ [range.min, range.max].some((bound) => bound !== undefined &&
1044
+ (typeof bound !== 'string' ||
1045
+ isoToUnixSeconds(bound) === undefined)))) {
1046
+ issue('unparseable-facet-range');
1047
+ }
1030
1048
  if (field.searchable !== undefined &&
1031
1049
  !SEARCHABLE_KINDS.includes(field.kind)) {
1032
1050
  issue('searchable-not-allowed');
@@ -1462,6 +1480,36 @@ export function isRangeFacet(field) {
1462
1480
  export function isBinnedRangeFacet(field) {
1463
1481
  return field.facetRanges !== undefined && field.facetRanges.length > 0;
1464
1482
  }
1483
+ /**
1484
+ * A binned field’s bins in stored terms, for an adapter to compile and echo:
1485
+ * half-open `[min, max)` Unix seconds. A number’s pass as declared. A date’s
1486
+ * `min` is its period’s first second and its `max` the first second after its
1487
+ * period ({@link lastSecondOf}), since a date bin includes the whole period its
1488
+ * `max` names. The one place a date bin is parsed, so the facet clause and the
1489
+ * bounds a bucket echoes cannot disagree. Empty for a field that declares no
1490
+ * bins; a bound the codec cannot read is left open, which
1491
+ * {@link validateSearchType} rules out before a query is ever compiled.
1492
+ */
1493
+ export function storedFacetRanges(field) {
1494
+ if (!isBinnedRangeFacet(field)) {
1495
+ return [];
1496
+ }
1497
+ if (field.kind !== 'date') {
1498
+ return field.facetRanges;
1499
+ }
1500
+ return field.facetRanges.map(({ key, min, max }) => ({
1501
+ key,
1502
+ ...storedBound('min', min),
1503
+ ...storedBound('max', max),
1504
+ }));
1505
+ }
1506
+ function storedBound(name, bound) {
1507
+ const stored = bound === undefined ? undefined : isoToUnixSeconds(bound);
1508
+ if (stored === undefined) {
1509
+ return {};
1510
+ }
1511
+ return { [name]: name === 'min' ? stored.seconds : lastSecondOf(stored) + 1 };
1512
+ }
1465
1513
  /**
1466
1514
  * Whether a value is an **absolute IRI**: a scheme, then anything with no
1467
1515
  * whitespace. The single definition the projection (which
@@ -1486,43 +1534,136 @@ export function isAbsoluteIri(value) {
1486
1534
  * run of non-whitespace. Non-ASCII is deliberately allowed: an IRI is not
1487
1535
  * restricted to ASCII. */
1488
1536
  const ABSOLUTE_IRI = /^[A-Za-z][A-Za-z0-9+.-]*:\S*$/;
1537
+ /** Whether a stored value is a {@link DatePrecision} – what an adapter checks
1538
+ * before trusting the precision companion it reads back. */
1539
+ export function isDatePrecision(value) {
1540
+ return (value === 'year' ||
1541
+ value === 'month' ||
1542
+ value === 'day' ||
1543
+ value === 'dateTime');
1544
+ }
1489
1545
  /**
1490
1546
  * The engine storage codec for `date` fields: stored as Unix seconds (a
1491
- * sortable, range-filterable int64), ISO 8601 at the API edges. One pair for
1492
- * the projection (writes), the query compiler (filter bounds) and the surface
1493
- * (output), so the three cannot disagree. Returns `undefined` for an
1494
- * unparseable value.
1547
+ * sortable, range-filterable int64) plus the precision the source gave, ISO
1548
+ * 8601 at the API edges. One pair for the projection (writes), the query
1549
+ * compiler and `validateQuery` (filter bounds) and the surface (output), so
1550
+ * they cannot disagree. Returns `undefined` for an unparseable value.
1495
1551
  *
1496
- * A year beyond what `Date` can represent (±271,821 years around 1970) is
1497
- * deep time, and deep time has no months or days: there the value is read as
1498
- * an `xsd:gYear` – a bare year, such as a Carboniferous fossil’s `-318000000` –
1499
- * and stored as that many average Gregorian years from 1970. Anything finer at
1500
- * that depth is unparseable.
1552
+ * - A **year, month or day** names a calendar period, so its timezone is
1553
+ * ignored and it is stored at that period’s first second in UTC.
1554
+ * - A **date-time** is normalised to UTC; one without a timezone is read as
1555
+ * UTC, so what the index holds never depends on the host that built it.
1556
+ * Fractional seconds are truncated.
1557
+ * - A year beyond what `Date` can represent (±271,821 years around 1970) is
1558
+ * **deep time**, and deep time has no months or days: there the value is
1559
+ * read as an `xsd:gYear` – a bare year, such as a Carboniferous fossil’s
1560
+ * `-318000000` – and stored as that many average Gregorian years from 1970.
1561
+ * Anything finer at that depth is unparseable.
1562
+ *
1563
+ * A year may carry a sign and any number of digits, so the expanded form
1564
+ * `Date` itself emits (`+025000`, `-001100`) reads the same as `25000` and
1565
+ * `-1100`.
1501
1566
  */
1502
1567
  export function isoToUnixSeconds(iso) {
1503
1568
  // Trim first: XSD collapses whitespace around a date literal before parsing,
1504
- // so a padded lexical form is legal and reaches here verbatim. Left in place
1505
- // it defeats the year expansion below in both directions – a leading space
1506
- // stops the match, a trailing one survives it into the legacy parser – and
1507
- // each lands the value in a different year than it reads.
1569
+ // so a padded lexical form is legal and reaches here verbatim.
1508
1570
  const trimmed = iso.trim();
1509
- const millis = new Date(expandYear(trimmed)).getTime();
1510
- return Number.isNaN(millis)
1511
- ? deepTimeSeconds(trimmed)
1512
- : Math.trunc(millis / 1000);
1571
+ const calendar = CALENDAR_DATE.exec(trimmed);
1572
+ if (calendar !== null) {
1573
+ const [, year, month, day] = calendar;
1574
+ const precision = day !== undefined ? 'day' : month !== undefined ? 'month' : 'year';
1575
+ const millis = utcMillis(Number(year), Number(month ?? 1), Number(day ?? 1));
1576
+ if (millis === 'invalid') {
1577
+ return undefined;
1578
+ }
1579
+ if (millis === 'out of range') {
1580
+ // Only a year takes the deep-time route: deep time has no months or days.
1581
+ return precision === 'year' ? deepTimeDate(Number(year)) : undefined;
1582
+ }
1583
+ return { seconds: millis / 1000, precision };
1584
+ }
1585
+ const dateTime = DATE_TIME.exec(trimmed);
1586
+ if (dateTime === null) {
1587
+ return undefined;
1588
+ }
1589
+ const [, year, month, day, hour, minute, second, offset] = dateTime;
1590
+ const millis = utcMillis(Number(year), Number(month), Number(day), Number(hour), Number(minute), Number(second ?? 0));
1591
+ if (typeof millis !== 'number') {
1592
+ return undefined;
1593
+ }
1594
+ const seconds = millis / 1000 - offsetSeconds(offset);
1595
+ // The offset can carry a date-time at `Date`’s edge out of its range, where
1596
+ // the surface could no longer give it back as one.
1597
+ return Number.isNaN(new Date(seconds * 1000).getTime())
1598
+ ? undefined
1599
+ : { seconds, precision: 'dateTime' };
1513
1600
  }
1514
1601
  /**
1515
- * The inverse of {@link isoToUnixSeconds}: stored Unix seconds → ISO 8601, or
1516
- * an `xsd:gYear` for seconds beyond what `Date` can represent.
1602
+ * The inverse of {@link isoToUnixSeconds}: stored Unix seconds → the canonical
1603
+ * ISO 8601 form of `precision`, so a client parses one shape per precision
1604
+ * whatever lexical variant the source used:
1605
+ *
1606
+ * | Precision | Canonical form |
1607
+ * | ---------- | -------------------------------------- |
1608
+ * | `year` | `1999`, `-0044`, `-250000` |
1609
+ * | `month` | `1999-05` |
1610
+ * | `day` | `1999-05-03` |
1611
+ * | `dateTime` | `1999-05-03T12:30:00Z` (always UTC) |
1612
+ *
1613
+ * A year has at least four digits and no `+`. Seconds beyond what `Date` can
1614
+ * represent are deep time, served as an `xsd:gYear` whatever `precision` says.
1517
1615
  */
1518
- export function unixSecondsToIso(seconds) {
1616
+ export function unixSecondsToIso(seconds, precision) {
1519
1617
  if (!Number.isFinite(seconds)) {
1520
1618
  throw new RangeError(`Not a number of Unix seconds: ${seconds}`);
1521
1619
  }
1522
- const date = new Date(seconds * 1000);
1523
- return Number.isNaN(date.getTime())
1524
- ? String(Math.round(seconds / GREGORIAN_YEAR_SECONDS) + 1970)
1525
- : date.toISOString();
1620
+ const date = new Date(Math.trunc(seconds) * 1000);
1621
+ if (Number.isNaN(date.getTime())) {
1622
+ return String(Math.round(seconds / GREGORIAN_YEAR_SECONDS) + 1970);
1623
+ }
1624
+ const year = formatYear(date.getUTCFullYear());
1625
+ const month = twoDigits(date.getUTCMonth() + 1);
1626
+ const day = twoDigits(date.getUTCDate());
1627
+ switch (precision) {
1628
+ case 'year':
1629
+ return year;
1630
+ case 'month':
1631
+ return `${year}-${month}`;
1632
+ case 'day':
1633
+ return `${year}-${month}-${day}`;
1634
+ case 'dateTime':
1635
+ return `${year}-${month}-${day}T${twoDigits(date.getUTCHours())}:${twoDigits(date.getUTCMinutes())}:${twoDigits(date.getUTCSeconds())}Z`;
1636
+ }
1637
+ }
1638
+ /**
1639
+ * The last stored second of the period a date names: the end of its year,
1640
+ * month or day, or the date-time itself. What an upper bound reaches up to and
1641
+ * including, so `max: '1999'` means through 1999, as a person reading it would
1642
+ * say – where the period’s first second would admit every record dated just
1643
+ * `2000` to a range that stops at `2000`, since those are stored there too.
1644
+ */
1645
+ export function lastSecondOf(stored) {
1646
+ const { seconds, precision } = stored;
1647
+ if (precision === 'dateTime') {
1648
+ return seconds;
1649
+ }
1650
+ if (precision === 'day') {
1651
+ return seconds + 86_400 - 1;
1652
+ }
1653
+ const next = new Date(seconds * 1000);
1654
+ if (precision === 'year') {
1655
+ next.setUTCFullYear(next.getUTCFullYear() + 1);
1656
+ }
1657
+ else {
1658
+ next.setUTCMonth(next.getUTCMonth() + 1);
1659
+ }
1660
+ // Past `Date`’s range (a deep-time year, or the last month or year it holds)
1661
+ // a period spans the average Gregorian year deep time is stored in, or a
1662
+ // twelfth of it.
1663
+ const span = precision === 'year' ? GREGORIAN_YEAR_SECONDS : GREGORIAN_YEAR_SECONDS / 12;
1664
+ return Number.isNaN(next.getTime())
1665
+ ? seconds + span - 1
1666
+ : next.getTime() / 1000 - 1;
1526
1667
  }
1527
1668
  /** `seconds` if a `date` field can store it – the int64 the engine keeps
1528
1669
  * Unix seconds in – or `undefined`, the same answer {@link isoToUnixSeconds}
@@ -1530,42 +1671,82 @@ export function unixSecondsToIso(seconds) {
1530
1671
  export function storableUnixSeconds(seconds) {
1531
1672
  return Math.abs(seconds) < 2 ** 63 ? seconds : undefined;
1532
1673
  }
1674
+ /** A timezone: `Z` or a `±hh:mm` offset no further from UTC than XSD allows
1675
+ * (±14:00), so an impossible one such as `+99:99` leaves the value
1676
+ * unparseable rather than shifting it by days. */
1677
+ const TIMEZONE = '(Z|[+-](?:(?:0\\d|1[0-3]):[0-5]\\d|14:00))?';
1678
+ /** A year, month or day (`xsd:gYear`, `xsd:gYearMonth`, `xsd:date`), with an
1679
+ * optional timezone the codec ignores. The year is signed and of any length,
1680
+ * so deep time and the expanded `±YYYYYY` form `Date` emits both read as the
1681
+ * year they spell. Deep time is real data, not a corner case: SCHEMA-AP-NDE
1682
+ * blesses years beyond four digits for `schema:dateCreated`. */
1683
+ const CALENDAR_DATE = new RegExp(`^([+-]?\\d+)(?:-(\\d{2})(?:-(\\d{2}))?)?${TIMEZONE}$`);
1684
+ /** An `xsd:dateTime`, its seconds optional and fraction ignored. */
1685
+ const DATE_TIME = new RegExp(`^([+-]?\\d+)-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?${TIMEZONE}$`);
1533
1686
  /**
1534
- * Pad a year outside the plain four-digit form to the signed six digits ISO
1535
- * 8601 expects, so `Date` reads it as a year at all. Deep time is real data,
1536
- * not a corner case: SCHEMA-AP-NDE blesses years beyond four digits for
1537
- * `schema:dateCreated`. Left unexpanded, neither era parses as written and
1538
- * neither fails loudly – `-1100` is read as a bare UTC offset and lands
1539
- * around 1100 **CE** (shifted by the host’s offset), `25000` is read as a
1540
- * legacy local-time date and lands a year early, on a boundary that moves
1541
- * with the host’s timezone. Either way nothing throws, no field is left
1542
- * absent, and the value sorts and filters as if it were another date
1543
- * entirely. A plain four-digit year and an already-expanded one pass through
1544
- * unchanged, so the form the API itself emits round-trips.
1687
+ * Milliseconds since the epoch of a UTC calendar moment, read without `Date`’s
1688
+ * string parser – which reads an untimezoned date-time in the host’s local
1689
+ * time and a short or long year as something else entirely. `'invalid'` for a
1690
+ * moment the calendar does not have (month 13, 30 February, 25:00), and
1691
+ * `'out of range'` for a valid one beyond what `Date` can represent.
1692
+ * `24:00:00` is the end of the day, which XSD allows: the next day’s midnight.
1545
1693
  */
1546
- function expandYear(iso) {
1547
- // The year, then the rest: a non-digit stops the run, so a longer digit
1548
- // string (epoch millis, say) is left alone rather than cut into a year.
1549
- const year = /^([+-]?)(\d{1,6})(\D.*|)$/.exec(iso);
1550
- if (year === null || (year[1] === '' && year[2].length === 4)) {
1551
- return iso;
1694
+ function utcMillis(year, month, day, hour = 0, minute = 0, second = 0) {
1695
+ if (month < 1 ||
1696
+ month > 12 ||
1697
+ day < 1 ||
1698
+ day > daysInMonth(year, month) ||
1699
+ hour > 24 ||
1700
+ minute > 59 ||
1701
+ second > 59 ||
1702
+ (hour === 24 && (minute !== 0 || second !== 0))) {
1703
+ return 'invalid';
1552
1704
  }
1553
- return `${year[1] || '+'}${year[2].padStart(6, '0')}${year[3]}`;
1705
+ const date = new Date(0);
1706
+ // `setUTCFullYear` rather than `Date.UTC`, which maps years 0–99 to 1900–1999.
1707
+ date.setUTCFullYear(year, month - 1, day);
1708
+ date.setUTCHours(hour, minute, second, 0);
1709
+ const millis = date.getTime();
1710
+ return Number.isNaN(millis) ? 'out of range' : millis;
1711
+ }
1712
+ /** Days in a month of the proleptic Gregorian calendar, for any year. */
1713
+ function daysInMonth(year, month) {
1714
+ if (month === 2) {
1715
+ const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
1716
+ return leap ? 29 : 28;
1717
+ }
1718
+ return [4, 6, 9, 11].includes(month) ? 30 : 31;
1719
+ }
1720
+ /** Seconds east of UTC a timezone states; `0` for `Z` or none, which is what
1721
+ * makes an untimezoned date-time read as UTC. */
1722
+ function offsetSeconds(timezone) {
1723
+ if (timezone === undefined || timezone === 'Z') {
1724
+ return 0;
1725
+ }
1726
+ const sign = timezone.startsWith('-') ? -1 : 1;
1727
+ const [hours, minutes] = timezone.slice(1).split(':').map(Number);
1728
+ return sign * (hours * 3600 + minutes * 60);
1729
+ }
1730
+ /** A year in its canonical form: at least four digits, signed only when
1731
+ * negative (`1999`, `0800`, `-0044`, `-250000`). */
1732
+ function formatYear(year) {
1733
+ const digits = String(Math.abs(year)).padStart(4, '0');
1734
+ return year < 0 ? `-${digits}` : digits;
1735
+ }
1736
+ function twoDigits(value) {
1737
+ return String(value).padStart(2, '0');
1554
1738
  }
1555
1739
  /** The average Gregorian year: 146 097 days per 400 years. */
1556
1740
  const GREGORIAN_YEAR_SECONDS = (146_097 * 86_400) / 400;
1557
- /** Unix seconds of a deep-time `xsd:gYear` – a bare year `Date` could not
1558
- * hold, its timezone ignored as meaningless at that scale – or `undefined`
1559
- * for anything else. An average year is at most two
1741
+ /** The stored form of a deep-time `xsd:gYear` – a year `Date` could not hold –
1742
+ * or `undefined` beyond the int64 of seconds. An average year is at most two
1560
1743
  * days off the calendar’s 1 January, far less than the year between
1561
1744
  * neighbours, so deep time still sorts before (or after) the dates `Date`
1562
1745
  * holds; and it lands beyond `Date`’s range, so {@link unixSecondsToIso}
1563
1746
  * gives the year back. */
1564
- function deepTimeSeconds(iso) {
1565
- const year = /^(-?[1-9]\d*)(?:Z|[+-]\d{2}:\d{2})?$/.exec(iso);
1566
- return year === null
1567
- ? undefined
1568
- : storableUnixSeconds((Number(year[1]) - 1970) * GREGORIAN_YEAR_SECONDS);
1747
+ function deepTimeDate(year) {
1748
+ const seconds = storableUnixSeconds((year - 1970) * GREGORIAN_YEAR_SECONDS);
1749
+ return seconds === undefined ? undefined : { seconds, precision: 'year' };
1569
1750
  }
1570
1751
  /**
1571
1752
  * Derive the **indexed** physical engine field names a declaration produces:
@@ -1593,6 +1774,7 @@ export function physicalFields(field, schema) {
1593
1774
  // Text is never facetable (`validateSearchType`).
1594
1775
  facet: undefined,
1595
1776
  identity: undefined,
1777
+ precision: undefined,
1596
1778
  };
1597
1779
  }
1598
1780
  // A field storing a nested OBJECT cannot be filtered or faceted as itself, so
@@ -1615,6 +1797,7 @@ export function physicalFields(field, schema) {
1615
1797
  ? filtered
1616
1798
  : `${filtered}_facet`,
1617
1799
  identity,
1800
+ precision: field.kind === 'date' ? `${field.name}_precision` : undefined,
1618
1801
  };
1619
1802
  }
1620
1803
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "Engine- and domain-agnostic core for RDF-backed search: a unified declarative field model (SearchField/SearchType/SearchSchema), a neutral query IR, the SearchEngine port with logical result types, and a streaming CONSTRUCT-to-document projection. Bakes in no engine, protocol, or domain.",
5
5
  "repository": {
6
6
  "url": "git+https://github.com/ldelements/lde.git",