@spotto/contract 1.0.70-alpha.22 → 1.0.70-alpha.24

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.
@@ -12,4 +12,29 @@ export interface GetEventsQuery extends EventFilters {
12
12
  page?: number;
13
13
  limit?: number;
14
14
  sortOrder?: SortOrders;
15
+ /**
16
+ * Run a stored semantic query instead of the filters above. The stored query
17
+ * REPLACES them — it is not merged, because two filter systems combined
18
+ * produce rows nobody asked for.
19
+ *
20
+ * Deliberately on the QUERY and not on `EventFilters`: download and count
21
+ * extend that interface, and inheriting an id they do not execute would mean
22
+ * accepting it and silently ignoring it.
23
+ */
24
+ semanticQueryId?: string;
25
+ /**
26
+ * A semantic query serialised as JSON, run WITHOUT being stored.
27
+ *
28
+ * Activity is the one entity with no offline corpus, so unlike assets and
29
+ * locations its filters must reach the server. Sending the conditions rather
30
+ * than a reference is what lets an AI answer and a hand-built picker be the
31
+ * same thing: a chip removal edits the query in the URL and re-runs it, with
32
+ * no draft minted per interaction and no link that expires when a 24h draft
33
+ * does.
34
+ *
35
+ * Mutually exclusive with `semanticQueryId` — two queries is not a question.
36
+ */
37
+ semanticQuery?: string;
38
+ /** IANA zone for the query's relative dates; the record's own wins if set. */
39
+ timezone?: string;
15
40
  }
@@ -21,4 +21,16 @@ export interface GetReadersQuery extends ReaderFilters {
21
21
  sort?: SearchableSortFields;
22
22
  sortOrder?: SortOrders;
23
23
  embed?: ReaderEmbedField[];
24
+ /**
25
+ * Run a stored semantic query instead of the filters above. The stored query
26
+ * is the WHOLE filter — combining it with any filter parameter is rejected,
27
+ * never merged.
28
+ *
29
+ * No serialised counterpart, as on snapshots and unlike `GET /events`:
30
+ * readers are cached whole and the list filters them in the browser, so this
31
+ * path serves saved queries and widgets rather than every keystroke.
32
+ */
33
+ semanticQueryId?: string;
34
+ /** IANA zone for the query's relative dates; the record's own wins if set. */
35
+ timezone?: string;
24
36
  }
@@ -2,6 +2,9 @@ import { SortOrders } from '../shared';
2
2
  import { AssetSortField } from '../assets/get/query';
3
3
  import { LocationSortField } from '../locations/get/query';
4
4
  import { LocationStatus, LocationType } from '../locations/constants';
5
+ import { EventType } from '../events/constants';
6
+ import { DeviceType, ReaderType } from '../readers/constants';
7
+ import { SnapshotSortField, SnapshotTypeEnum } from '../snapshots/get/query';
5
8
  import { FieldDataType } from '../fields/constants';
6
9
  /**
7
10
  * SEMANTIC QUERIES — the portable query language.
@@ -30,8 +33,9 @@ import { FieldDataType } from '../fields/constants';
30
33
  * TECHNICAL_DECISIONS.md) and the semantic-query specification errata.
31
34
  */
32
35
  /**
33
- * What a semantic query targets. Only `asset` executes today; recorded on
34
- * every stored query from day one so saved records never need retrofitting.
36
+ * What a semantic query targets. All but `manifest` execute; it is recorded so
37
+ * the classifier can name what it is declining, and so a stored query would
38
+ * never need retrofitting if it ever learns to speak.
35
39
  */
36
40
  export declare const semanticQueryEntityTypes: readonly ["asset", "location", "event", "reader", "snapshot", "manifest"];
37
41
  export declare type SemanticQueryEntityType = (typeof semanticQueryEntityTypes)[number];
@@ -344,6 +348,284 @@ export declare type SemanticLocationTimestampCondition = Omit<SemanticTimestampC
344
348
  type: 'createdDate' | 'lastUpdated' | 'lastChanged';
345
349
  };
346
350
  export declare type SemanticLocationCondition = SemanticAndCondition | SemanticOrCondition | SemanticLocationPathCondition | SemanticLocationTypeCondition | SemanticLocationHasReadersCondition | SemanticLocationGeofenceCondition | SemanticLocationManifestCondition | SemanticTagsCondition | SemanticGeolocationCondition | SemanticLocationTimestampCondition;
351
+ /** WHEN it happened. Events are always in the past. */
352
+ export interface SemanticEventOccurredCondition {
353
+ type: 'occurred';
354
+ operator: SemanticTimestampOperator;
355
+ value: SemanticDateValue;
356
+ }
357
+ /** WHAT KIND of event. One or more of the platform's closed set. */
358
+ export interface SemanticEventTypeCondition {
359
+ type: 'eventType';
360
+ values: EventType[];
361
+ }
362
+ /**
363
+ * WHERE it happened, by pipe-delimited path — the same path vocabulary the
364
+ * location entity uses, matched as a prefix so a parent covers its subtree.
365
+ * Events embed the location's stored path in `location.name`, exactly as a
366
+ * location document does.
367
+ *
368
+ * PARTIAL BY CONSTRUCTION, and the line between this and the withheld
369
+ * `assetType` is worth stating because it is fine.
370
+ *
371
+ * Most event types embed `location`; several do not. For most of those the
372
+ * omission is honest — a `UserSearch` or a `ReaderOnline` has no place it
373
+ * happened. `assetType` was withheld because the events missing `thing
374
+ * .typePath` DO have an asset type; it simply is not stored, so the filter
375
+ * would be silently wrong about real data.
376
+ *
377
+ * ONE case here is on the wrong side of that line: a `FormSubmitted` event
378
+ * embeds `location` only for a LOCATION-target run. An asset-target
379
+ * submission made at the same place embeds `thing` instead, so "submissions at
380
+ * Brisbane" returns the location-target subset and drops the rest without
381
+ * saying so. That is the identical failure `assetType` was withheld for, and
382
+ * it survives here for one reason: the flat `locations` filter on
383
+ * `GET /events` has always behaved this way, so removing it from the language
384
+ * would make the two paths disagree about the same word. Fixing it properly
385
+ * means embedding the location on asset-target submissions — a write-path
386
+ * change, not a query one. Until then the preamble says so out loud.
387
+ */
388
+ export interface SemanticEventLocationCondition {
389
+ type: 'location';
390
+ path: string;
391
+ /**
392
+ * Default true, matching the location entity. Carried rather than omitted
393
+ * because the boundary's property table is per-WORD, not per-entity: it
394
+ * already accepts `includeSublocations` on `location`, so leaving it
395
+ * unhandled here would mean an explicit `false` was accepted and silently
396
+ * behaved as `true` — a narrower query than asked for, quietly widened.
397
+ */
398
+ includeSublocations?: boolean;
399
+ }
400
+ /**
401
+ * WHICH READER saw it, by name.
402
+ *
403
+ * A name rather than an id, and that is safe here in a way it is not for
404
+ * assets: readers are a small named catalogue, so the name RESOLVES against
405
+ * real records at compile time and an unknown or ambiguous one is a loud
406
+ * failure. Nothing is guessed and no regex is left to match whatever it
407
+ * happens to match.
408
+ */
409
+ export interface SemanticEventReaderCondition {
410
+ type: 'reader';
411
+ name: string;
412
+ }
413
+ /**
414
+ * WHO did it, by name — resolved the same way, against the organisation's
415
+ * users.
416
+ *
417
+ * Matching on a resolved user id inherently excludes system-generated events:
418
+ * Slate movements and arrivals carry no user at all. That is correct and worth
419
+ * stating, because "what did Sarah do" should never sweep in a reader
420
+ * detection.
421
+ */
422
+ export interface SemanticEventUserCondition {
423
+ type: 'user';
424
+ name: string;
425
+ }
426
+ /**
427
+ * WHICH ACTION a form submission belongs to, by name.
428
+ *
429
+ * The action is the useful handle and the form behind it is an implementation
430
+ * detail (ruled by Steve Mann, 2026-07-29, carried over from the prototype).
431
+ * An action condition already implies a submission, so it constrains the event
432
+ * type too and needs no pairing with `eventType`.
433
+ *
434
+ * It constrains to BOTH submission types — `FormSubmitted` and
435
+ * `FormSubmissionVoided`, which also carries `actionName`. Pinning it to
436
+ * `FormSubmitted` alone read as the tighter, safer choice and was the opposite:
437
+ * pairing it with `eventType: ['FormSubmissionVoided']` to ask for voided
438
+ * pre-start checks then produced two contradictory type constraints, which
439
+ * compiles cleanly and returns zero rows forever. Narrowing to just submitted
440
+ * ones stays possible — that is what the `eventType` pairing is for.
441
+ */
442
+ export interface SemanticEventActionCondition {
443
+ type: 'action';
444
+ name: string;
445
+ }
446
+ /**
447
+ * The EVENT vocabulary.
448
+ *
449
+ * `location` borrows its WORD from the asset vocabulary but not its meaning:
450
+ * an asset's `location` is where the asset is now, an event's is where the
451
+ * event happened. Same name for the same kind of question, different subject —
452
+ * which is why each entity compiles it against its own field.
453
+ * `occurred` is its own word rather than reusing a timestamp
454
+ * name, because an event has exactly ONE time and calling it `createdDate`
455
+ * would invite the reading that events have several dates the way assets do.
456
+ */
457
+ export declare const semanticEventConditionTypes: readonly ["and", "or", "occurred", "eventType", "location", "reader", "user", "action"];
458
+ export declare type SemanticEventCondition = SemanticAndCondition | SemanticOrCondition | SemanticEventOccurredCondition | SemanticEventTypeCondition | SemanticEventLocationCondition | SemanticEventReaderCondition | SemanticEventUserCondition | SemanticEventActionCondition;
459
+ /**
460
+ * WHEN the snapshot happened.
461
+ *
462
+ * Compiles to `submitted`, NOT `created` — and that is a deliberate departure
463
+ * from the prototype, which used `created`. The platform's own time filter
464
+ * (`timeFrom`/`timeTo` on `GET /snapshots`) bounds `submitted`, so compiling
465
+ * to `created` would mean the Date chip and an `occurred` condition disagreed
466
+ * about "snapshots last week" while both looked right.
467
+ *
468
+ * The cost, stated because it is silent: `submitted` is optional, so a
469
+ * snapshot that was never submitted matches NO `occurred` bound. That is
470
+ * exactly how the existing Date chip already behaves — this condition inherits
471
+ * the gap rather than introducing it. Sorting still offers both fields
472
+ * (`snapshotSortFields`), because sorting cannot hide a row.
473
+ */
474
+ export declare type SemanticSnapshotOccurredCondition = SemanticEventOccurredCondition;
475
+ /**
476
+ * WHICH KIND of field operation.
477
+ *
478
+ * Not a plain equality. `type` was added after the fact, so a legacy snapshot
479
+ * has none and is classified by whether it carries a manifest: no manifest
480
+ * means Stocktake, a manifest means Inventory. Dispatch always carries an
481
+ * explicit type. `snapshots/filters.ts` encodes exactly this, and the compiler
482
+ * reproduces it — matching on `type` alone would return zero legacy rows while
483
+ * the chip beside it returned them.
484
+ */
485
+ export interface SemanticSnapshotTypeCondition {
486
+ type: 'snapshotType';
487
+ values: SnapshotTypeEnum[];
488
+ }
489
+ /**
490
+ * The asset the snapshot was taken AGAINST, by id.
491
+ *
492
+ * Named `asset` rather than reusing `withAsset` because the fact differs: an
493
+ * asset's `withAsset` asks what a kit CONTAINS, while this asks what this
494
+ * operation was ABOUT.
495
+ *
496
+ * Read the field before believing the flat filter's own description. A
497
+ * snapshot embeds a single optional `asset` — its SUBJECT — while its contents
498
+ * live in `detectedAssets` / `sightedAssets` / `undetectedAssets`. The
499
+ * `assetIds` filter is documented as "snapshots containing specific assets"
500
+ * and does nothing of the kind: it matches `asset._id`, the subject. This
501
+ * condition means the subject too, so chip and query agree; asking what a
502
+ * snapshot CONTAINED is a different question that neither can answer yet.
503
+ *
504
+ * An id, not a name — the §B1 refusal. The AI cannot produce one (it never
505
+ * sees ids), so this is a chip-built condition, exactly as `withAsset` is.
506
+ */
507
+ export interface SemanticSnapshotAssetCondition {
508
+ type: 'asset';
509
+ assetId: string;
510
+ }
511
+ /**
512
+ * The TYPE of the snapshot's subject asset, by pipe-delimited path.
513
+ *
514
+ * Same word and same meaning as the asset vocabulary's `assetType`, applied to
515
+ * the subject asset (`asset.typePath`). Carries the subject-not-contents
516
+ * caveat above.
517
+ */
518
+ export declare type SemanticSnapshotAssetTypeCondition = SemanticAssetTypeCondition;
519
+ /**
520
+ * WHERE the snapshot was taken, by pipe-delimited path.
521
+ *
522
+ * `location.path` is absent on legacy snapshots, so a path condition does not
523
+ * see them. That is the same acceptance already recorded for record scope
524
+ * (usergroups S7: "Legacy snapshots pre-date that field and stay hidden to
525
+ * scoped callers"), so the language matches the platform rather than inventing
526
+ * a second answer. The flat filter softens it only when BOTH `locationIds` and
527
+ * `locationPathBeginsWith` are supplied — a semantic condition carries one
528
+ * path and has no id to pair with it.
529
+ */
530
+ export declare type SemanticSnapshotLocationCondition = SemanticEventLocationCondition;
531
+ /** The manifest the operation ran against. Ids point; paths match. */
532
+ export declare type SemanticSnapshotManifestCondition = SemanticLocationManifestCondition;
533
+ /** WHO ran it, by name — resolved against the org's users, as events do. */
534
+ export declare type SemanticSnapshotUserCondition = SemanticEventUserCondition;
535
+ /** WHICH READER took it, by name — resolved the same way. */
536
+ export declare type SemanticSnapshotReaderCondition = SemanticEventReaderCondition;
537
+ /**
538
+ * The SNAPSHOT vocabulary.
539
+ *
540
+ * Full parity with the prototype's six words, plus `assetType` and `reader`,
541
+ * which its descriptor lacked and the platform's flat filters already support.
542
+ *
543
+ * Nothing is withheld here, and that is worth contrasting with events. The
544
+ * prototype matched `asset`, `user` and `manifest` by case-insensitive regex
545
+ * over a denormalised name — the failure the asset vocabulary refuses, three
546
+ * times over. It survives translation intact only because this entity stores
547
+ * real ids for all three, so the honest form costs no capability. Where it
548
+ * could not (a name for `user`), the event ladder already solved it.
549
+ *
550
+ * Absent for the standing reason: free text. No `nameContains` — search is a
551
+ * view option platform-wide, never a stored condition.
552
+ */
553
+ export declare const semanticSnapshotConditionTypes: readonly ["and", "or", "occurred", "snapshotType", "asset", "assetType", "location", "manifest", "user", "reader"];
554
+ export declare type SemanticSnapshotCondition = SemanticAndCondition | SemanticOrCondition | SemanticSnapshotOccurredCondition | SemanticSnapshotTypeCondition | SemanticSnapshotAssetCondition | SemanticSnapshotAssetTypeCondition | SemanticSnapshotLocationCondition | SemanticSnapshotManifestCondition | SemanticSnapshotUserCondition | SemanticSnapshotReaderCondition;
555
+ /** The hardware model. A closed platform set (`DEVICE_TYPES`). */
556
+ export interface SemanticReaderDeviceTypeCondition {
557
+ type: 'deviceType';
558
+ values: DeviceType[];
559
+ }
560
+ /**
561
+ * The reader's BEHAVIOUR — fixed in place, roving, or itself moving
562
+ * (`READER_TYPES`). Named `readerType` rather than `type`, which is the wire
563
+ * key every condition already uses for its own discriminator.
564
+ */
565
+ export interface SemanticReaderTypeCondition {
566
+ type: 'readerType';
567
+ values: ReaderType[];
568
+ }
569
+ /**
570
+ * WHERE the reader is installed, by pipe-delimited path.
571
+ *
572
+ * Compiles against `locationName`, which holds the location's FULL
573
+ * pipe-terminated path (`readers/helpers.ts` copies `location.name`, and a
574
+ * location document's `name` is its path). The flat `locationIds` filter
575
+ * answers a different question — these exact locations — and the two coexist,
576
+ * exactly as they do for assets.
577
+ */
578
+ export declare type SemanticReaderLocationCondition = SemanticEventLocationCondition;
579
+ /**
580
+ * The asset this reader is attached to, by id.
581
+ *
582
+ * An id, never a name. The prototype matched `assetName` with a
583
+ * case-insensitive regex, which is the failure that makes "BC-A1" also return
584
+ * "BC-A10".
585
+ */
586
+ export interface SemanticReaderAttachedAssetCondition {
587
+ type: 'attachedAsset';
588
+ assetId: string;
589
+ }
590
+ /**
591
+ * Whether the reader is online RIGHT NOW.
592
+ *
593
+ * Split from `hasReported`, and this is where we do better than the prototype
594
+ * rather than merely differently. Its `online` condition folded the two
595
+ * together — its own comment concedes why: "`state` is absent on readers in
596
+ * several dev orgs, so 'offline' must also match readers that have never
597
+ * reported". So asking for offline readers returned the genuinely-offline AND
598
+ * the never-installed, with no way to tell them apart or to ask for either
599
+ * alone. The platform's flat filters have always kept them separate
600
+ * (`isOnline` vs `hasReported`); the language now does too.
601
+ */
602
+ export interface SemanticReaderOnlineCondition {
603
+ type: 'online';
604
+ value: boolean;
605
+ }
606
+ /** Whether the reader has EVER reported. See `online` for why this is its own word. */
607
+ export interface SemanticReaderHasReportedCondition {
608
+ type: 'hasReported';
609
+ value: boolean;
610
+ }
611
+ /** Whether the reader has reported map coordinates. */
612
+ export interface SemanticReaderHasGeolocationCondition {
613
+ type: 'hasGeolocation';
614
+ value: boolean;
615
+ }
616
+ /**
617
+ * The READER vocabulary.
618
+ *
619
+ * Five of the prototype's six words, plus `hasReported` and `hasGeolocation`
620
+ * that it had no form for. The sixth (`nameContains`) is refused above.
621
+ *
622
+ * Note what is NOT here: readers carry no user-group scope, and this
623
+ * vocabulary does not add one. `usergroups/scope.ts` lists them among the
624
+ * surfaces deliberately unscoped in v1, and filtering a set the caller can
625
+ * already read in full reveals nothing new.
626
+ */
627
+ export declare const semanticReaderConditionTypes: readonly ["and", "or", "deviceType", "readerType", "location", "attachedAsset", "online", "hasReported", "hasGeolocation"];
628
+ export declare type SemanticReaderCondition = SemanticAndCondition | SemanticOrCondition | SemanticReaderDeviceTypeCondition | SemanticReaderTypeCondition | SemanticReaderLocationCondition | SemanticReaderAttachedAssetCondition | SemanticReaderOnlineCondition | SemanticReaderHasReportedCondition | SemanticReaderHasGeolocationCondition;
347
629
  /**
348
630
  * WHICH WORDS EACH ENTITY KNOWS — the closed vocabulary, per entity.
349
631
  *
@@ -376,7 +658,7 @@ export declare const semanticConditionTypesByEntity: Record<SemanticQueryEntityT
376
658
  * validator, which knows the entity and can say "'readiness' is an asset
377
659
  * condition" instead of "not allowed".
378
660
  */
379
- export declare const semanticConditionTypes: readonly ("telemetry" | "readiness" | "path" | "location" | "manifest" | "and" | "or" | "assetType" | "homeLocation" | "withAsset" | "customField" | "createdDate" | "lastUpdated" | "lastChanged" | "lastSeen" | "firstSeen" | "geolocation" | "tags" | "kit" | "locationStatus" | "locationType" | "hasReaders" | "geofence")[];
661
+ export declare const semanticConditionTypes: readonly ("telemetry" | "readiness" | "path" | "asset" | "location" | "reader" | "manifest" | "and" | "or" | "assetType" | "homeLocation" | "withAsset" | "customField" | "createdDate" | "lastUpdated" | "lastChanged" | "lastSeen" | "firstSeen" | "geolocation" | "tags" | "kit" | "locationStatus" | "locationType" | "hasReaders" | "geofence" | "occurred" | "eventType" | "user" | "action" | "snapshotType" | "deviceType" | "readerType" | "attachedAsset" | "online" | "hasReported" | "hasGeolocation")[];
380
662
  export declare type SemanticConditionType = (typeof semanticConditionTypes)[number];
381
663
  /**
382
664
  * Query size bounds, shared by the boundary schema (which refuses an oversized
@@ -400,7 +682,7 @@ export declare type SemanticAssetCondition = SemanticAndCondition | SemanticOrCo
400
682
  * Any condition, whatever the entity. Widens as entities are added; the
401
683
  * envelope and everything generic over it stay unchanged when they are.
402
684
  */
403
- export declare type SemanticQueryCondition = SemanticAssetCondition | SemanticLocationCondition;
685
+ export declare type SemanticQueryCondition = SemanticAssetCondition | SemanticLocationCondition | SemanticEventCondition | SemanticSnapshotCondition | SemanticReaderCondition;
404
686
  /** Current wire version of the condition vocabulary. */
405
687
  export declare const SEMANTIC_QUERY_VERSION = 2;
406
688
  export interface SemanticQuery {
@@ -504,7 +786,7 @@ export declare type SemanticQueryViewType = (typeof semanticQueryViewTypes)[numb
504
786
  * harmless odd ordering would cost a discriminated union on every read path
505
787
  * for no safety gained.
506
788
  */
507
- export declare type SemanticQuerySortField = AssetSortField | LocationSortField;
789
+ export declare type SemanticQuerySortField = AssetSortField | LocationSortField | SnapshotSortField;
508
790
  export declare const semanticQuerySortFields: SemanticQuerySortField[];
509
791
  export interface SemanticQueryDisplay {
510
792
  columnVisibility?: Record<string, boolean>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.semanticQuerySortFields = exports.semanticQueryViewTypes = exports.SEMANTIC_QUERY_VERSION = exports.SEMANTIC_QUERY_LIMITS = exports.semanticConditionTypes = exports.semanticConditionTypesByEntity = exports.semanticLocationConditionTypes = exports.semanticAssetConditionTypes = exports.semanticGroupConditionTypes = exports.semanticReadinessLevels = exports.semanticTelemetryFields = exports.semanticSetOperators = exports.semanticComparisonOperators = exports.semanticTimestampOperators = exports.semanticFieldOperators = exports.semanticRelativeDatePositions = exports.semanticRelativeDateBases = exports.semanticQueryVisibilities = exports.semanticQueryKinds = exports.semanticQueryEntityTypes = void 0;
3
+ exports.semanticQuerySortFields = exports.semanticQueryViewTypes = exports.SEMANTIC_QUERY_VERSION = exports.SEMANTIC_QUERY_LIMITS = exports.semanticConditionTypes = exports.semanticConditionTypesByEntity = exports.semanticReaderConditionTypes = exports.semanticSnapshotConditionTypes = exports.semanticEventConditionTypes = exports.semanticLocationConditionTypes = exports.semanticAssetConditionTypes = exports.semanticGroupConditionTypes = exports.semanticReadinessLevels = exports.semanticTelemetryFields = exports.semanticSetOperators = exports.semanticComparisonOperators = exports.semanticTimestampOperators = exports.semanticFieldOperators = exports.semanticRelativeDatePositions = exports.semanticRelativeDateBases = exports.semanticQueryVisibilities = exports.semanticQueryKinds = exports.semanticQueryEntityTypes = void 0;
4
4
  /**
5
5
  * SEMANTIC QUERIES — the portable query language.
6
6
  *
@@ -29,8 +29,9 @@ exports.semanticQuerySortFields = exports.semanticQueryViewTypes = exports.SEMAN
29
29
  */
30
30
  // --- Entity + record kind -------------------------------------------------
31
31
  /**
32
- * What a semantic query targets. Only `asset` executes today; recorded on
33
- * every stored query from day one so saved records never need retrofitting.
32
+ * What a semantic query targets. All but `manifest` execute; it is recorded so
33
+ * the classifier can name what it is declining, and so a stored query would
34
+ * never need retrofitting if it ever learns to speak.
34
35
  */
35
36
  exports.semanticQueryEntityTypes = [
36
37
  'asset',
@@ -159,6 +160,74 @@ exports.semanticLocationConditionTypes = [
159
160
  'lastUpdated',
160
161
  'lastChanged',
161
162
  ];
163
+ /**
164
+ * The EVENT vocabulary.
165
+ *
166
+ * `location` borrows its WORD from the asset vocabulary but not its meaning:
167
+ * an asset's `location` is where the asset is now, an event's is where the
168
+ * event happened. Same name for the same kind of question, different subject —
169
+ * which is why each entity compiles it against its own field.
170
+ * `occurred` is its own word rather than reusing a timestamp
171
+ * name, because an event has exactly ONE time and calling it `createdDate`
172
+ * would invite the reading that events have several dates the way assets do.
173
+ */
174
+ exports.semanticEventConditionTypes = [
175
+ ...exports.semanticGroupConditionTypes,
176
+ 'occurred',
177
+ 'eventType',
178
+ 'location',
179
+ 'reader',
180
+ 'user',
181
+ 'action',
182
+ ];
183
+ /**
184
+ * The SNAPSHOT vocabulary.
185
+ *
186
+ * Full parity with the prototype's six words, plus `assetType` and `reader`,
187
+ * which its descriptor lacked and the platform's flat filters already support.
188
+ *
189
+ * Nothing is withheld here, and that is worth contrasting with events. The
190
+ * prototype matched `asset`, `user` and `manifest` by case-insensitive regex
191
+ * over a denormalised name — the failure the asset vocabulary refuses, three
192
+ * times over. It survives translation intact only because this entity stores
193
+ * real ids for all three, so the honest form costs no capability. Where it
194
+ * could not (a name for `user`), the event ladder already solved it.
195
+ *
196
+ * Absent for the standing reason: free text. No `nameContains` — search is a
197
+ * view option platform-wide, never a stored condition.
198
+ */
199
+ exports.semanticSnapshotConditionTypes = [
200
+ ...exports.semanticGroupConditionTypes,
201
+ 'occurred',
202
+ 'snapshotType',
203
+ 'asset',
204
+ 'assetType',
205
+ 'location',
206
+ 'manifest',
207
+ 'user',
208
+ 'reader',
209
+ ];
210
+ /**
211
+ * The READER vocabulary.
212
+ *
213
+ * Five of the prototype's six words, plus `hasReported` and `hasGeolocation`
214
+ * that it had no form for. The sixth (`nameContains`) is refused above.
215
+ *
216
+ * Note what is NOT here: readers carry no user-group scope, and this
217
+ * vocabulary does not add one. `usergroups/scope.ts` lists them among the
218
+ * surfaces deliberately unscoped in v1, and filtering a set the caller can
219
+ * already read in full reveals nothing new.
220
+ */
221
+ exports.semanticReaderConditionTypes = [
222
+ ...exports.semanticGroupConditionTypes,
223
+ 'deviceType',
224
+ 'readerType',
225
+ 'location',
226
+ 'attachedAsset',
227
+ 'online',
228
+ 'hasReported',
229
+ 'hasGeolocation',
230
+ ];
162
231
  /**
163
232
  * WHICH WORDS EACH ENTITY KNOWS — the closed vocabulary, per entity.
164
233
  *
@@ -185,9 +254,9 @@ exports.semanticLocationConditionTypes = [
185
254
  exports.semanticConditionTypesByEntity = {
186
255
  asset: exports.semanticAssetConditionTypes,
187
256
  location: exports.semanticLocationConditionTypes,
188
- event: [],
189
- reader: [],
190
- snapshot: [],
257
+ event: exports.semanticEventConditionTypes,
258
+ snapshot: exports.semanticSnapshotConditionTypes,
259
+ reader: exports.semanticReaderConditionTypes,
191
260
  manifest: [],
192
261
  };
193
262
  /**
@@ -202,6 +271,9 @@ exports.semanticConditionTypes = [
202
271
  ...new Set([
203
272
  ...exports.semanticAssetConditionTypes,
204
273
  ...exports.semanticLocationConditionTypes,
274
+ ...exports.semanticEventConditionTypes,
275
+ ...exports.semanticSnapshotConditionTypes,
276
+ ...exports.semanticReaderConditionTypes,
205
277
  ]),
206
278
  ];
207
279
  /**
@@ -239,6 +311,7 @@ const SEMANTIC_QUERY_SORT_FIELD_SET = {
239
311
  battery: true,
240
312
  ready: true,
241
313
  path: true,
314
+ submitted: true,
242
315
  };
243
316
  exports.semanticQuerySortFields = Object.keys(SEMANTIC_QUERY_SORT_FIELD_SET);
244
317
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/semantic-queries/shared.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,6EAA6E;AAE7E;;;GAGG;AACU,QAAA,wBAAwB,GAAG;IACtC,OAAO;IACP,UAAU;IACV,OAAO;IACP,QAAQ;IACR,UAAU;IACV,UAAU;CAC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,mCAA2B;QAC9B,GAAG,sCAA8B;QACjC,GAAG,mCAA2B;QAC9B,GAAG,sCAA8B;QACjC,GAAG,oCAA4B;KAChC,CAAC;CAOH,CAAA;AAGD;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG;IACnC,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,CAAC;CACH,CAAA;AAkCV,6EAA6E;AAE7E,wDAAwD;AAC3C,QAAA,sBAAsB,GAAG,CAAC,CAAA;AAyDvC,6EAA6E;AAE7E,gEAAgE;AACnD,QAAA,sBAAsB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAU,CAAA;AAyCvE;;;;;;;;;GASG;AACH,MAAM,6BAA6B,GAAyC;IAC1E,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,IAAI;CAChB,CAAA;AACY,QAAA,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAChD,6BAA6B,CACF,CAAA"}
@@ -3,6 +3,33 @@ export declare type SnapshotSortField = 'created' | 'submitted';
3
3
  export declare const snapshotSortFields: SnapshotSortField[];
4
4
  export declare type SnapshotEmbedField = 'meta';
5
5
  export declare type SnapshotTypeEnum = 'Inventory' | 'Stocktake' | 'Dispatch';
6
+ export declare const SNAPSHOT_TYPES: SnapshotTypeEnum[];
7
+ /**
8
+ * How each kind is IDENTIFIED on a stored document — including the legacy
9
+ * snapshots that pre-date the `type` field entirely.
10
+ *
11
+ * `type` was added after the fact. A document without one is classified by
12
+ * whether it carries a manifest: none means a Stocktake, one means an
13
+ * Inventory. Dispatch has no legacy form — it never existed before `type` did.
14
+ *
15
+ * Stated ONCE, as data, because three separate places need the same answer:
16
+ * the flat Mongo filter (`snapshots/filters.ts`), the semantic compiler, and
17
+ * the semantic evaluator that runs in the browser. Two of those are supposed
18
+ * to agree exactly; a rule written out three times is a rule with three
19
+ * chances to drift, and the failure would be silent — a chip and a saved query
20
+ * returning different rows for the same question.
21
+ */
22
+ export interface SnapshotTypeRule {
23
+ /** Matches a document whose `type` is set to this. */
24
+ explicit: SnapshotTypeEnum;
25
+ /**
26
+ * How a LEGACY document (no `type` at all) is recognised as this kind:
27
+ * `true` = it carries a manifest, `false` = it does not. Absent means the
28
+ * kind has no legacy form and only ever matches an explicit `type`.
29
+ */
30
+ legacyHasManifest?: boolean;
31
+ }
32
+ export declare const SNAPSHOT_TYPE_RULES: Record<SnapshotTypeEnum, SnapshotTypeRule>;
6
33
  export interface SnapshotFilters {
7
34
  ids?: string[];
8
35
  locationIds?: string[];
@@ -22,4 +49,16 @@ export interface GetSnapshotsQuery extends SnapshotFilters {
22
49
  sort?: SnapshotSortField;
23
50
  sortOrder?: SortOrders;
24
51
  embed?: Array<SnapshotEmbedField>;
52
+ /**
53
+ * Run a stored semantic query instead of the filters above. The stored query
54
+ * is the WHOLE filter — combining it with any filter parameter is rejected,
55
+ * never merged.
56
+ *
57
+ * No serialised counterpart here, unlike `GET /events`: snapshots are cached
58
+ * whole and the list filters them in the browser, so the server path exists
59
+ * for saved queries and widgets rather than for every keystroke.
60
+ */
61
+ semanticQueryId?: string;
62
+ /** IANA zone for the query's relative dates; the record's own wins if set. */
63
+ timezone?: string;
25
64
  }
@@ -1,5 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snapshotSortFields = void 0;
3
+ exports.SNAPSHOT_TYPE_RULES = exports.SNAPSHOT_TYPES = exports.snapshotSortFields = void 0;
4
4
  exports.snapshotSortFields = ['created', 'submitted'];
5
+ /**
6
+ * The same three as VALUES, for the boundary schema and the semantic
7
+ * vocabulary.
8
+ *
9
+ * Keyed as a Record so the compiler enforces it BOTH ways: a kind missing here
10
+ * is a build error, and one that is not a real kind is too. Two hand-kept
11
+ * copies of this list already existed — the Joi validator's `.valid(...)` and
12
+ * the chat prototype's `KNOWN_SNAPSHOT_TYPES` — and a hand-kept copy of a type
13
+ * is a copy that drifts. That is not hypothetical here: the identical pattern
14
+ * on sort fields rejected every saved location view the day locations shipped.
15
+ */
16
+ const SNAPSHOT_TYPE_SET = {
17
+ Inventory: true,
18
+ Stocktake: true,
19
+ Dispatch: true,
20
+ };
21
+ exports.SNAPSHOT_TYPES = Object.keys(SNAPSHOT_TYPE_SET);
22
+ exports.SNAPSHOT_TYPE_RULES = {
23
+ Stocktake: { explicit: 'Stocktake', legacyHasManifest: false },
24
+ Inventory: { explicit: 'Inventory', legacyHasManifest: true },
25
+ Dispatch: { explicit: 'Dispatch' },
26
+ };
5
27
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/snapshots/get/query.ts"],"names":[],"mappings":";;;AAGa,QAAA,kBAAkB,GAAwB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA"}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/snapshots/get/query.ts"],"names":[],"mappings":";;;AAGa,QAAA,kBAAkB,GAAwB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAI/E;;;;;;;;;;GAUG;AACH,MAAM,iBAAiB,GAAmC;IACxD,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;CACf,CAAA;AACY,QAAA,cAAc,GAAG,MAAM,CAAC,IAAI,CACvC,iBAAiB,CACI,CAAA;AA4BV,QAAA,mBAAmB,GAA+C;IAC7E,SAAS,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,EAAE;IAC9D,SAAS,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAC7D,QAAQ,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;CACnC,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotto/contract",
3
3
  "license": "ISC",
4
- "version": "1.0.70-alpha.22",
4
+ "version": "1.0.70-alpha.24",
5
5
  "description": "Spotto's API Contract type definitions",
6
6
  "main": "./dist/index.js",
7
7
  "files": [
@@ -18,5 +18,5 @@
18
18
  "@types/geojson": "^7946.0.11",
19
19
  "shx": "^0.3.4"
20
20
  },
21
- "gitHead": "408ff86c771a08a0212019f79fb80bea2902587b"
21
+ "gitHead": "d90ad98fb1929f252919e408015f7ab8b71c6fbc"
22
22
  }