@spotto/contract 1.0.70-alpha.23 → 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.
@@ -22,6 +22,19 @@ export interface GetEventsQuery extends EventFilters {
22
22
  * accepting it and silently ignoring it.
23
23
  */
24
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;
25
38
  /** IANA zone for the query's relative dates; the record's own wins if set. */
26
39
  timezone?: string;
27
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
  }
@@ -3,6 +3,8 @@ import { AssetSortField } from '../assets/get/query';
3
3
  import { LocationSortField } from '../locations/get/query';
4
4
  import { LocationStatus, LocationType } from '../locations/constants';
5
5
  import { EventType } from '../events/constants';
6
+ import { DeviceType, ReaderType } from '../readers/constants';
7
+ import { SnapshotSortField, SnapshotTypeEnum } from '../snapshots/get/query';
6
8
  import { FieldDataType } from '../fields/constants';
7
9
  /**
8
10
  * SEMANTIC QUERIES — the portable query language.
@@ -31,9 +33,9 @@ import { FieldDataType } from '../fields/constants';
31
33
  * TECHNICAL_DECISIONS.md) and the semantic-query specification errata.
32
34
  */
33
35
  /**
34
- * What a semantic query targets. `asset`, `location` and `event` execute;
35
- * the rest are recorded from day one so a stored query never needs
36
- * retrofitting when its entity learns to speak.
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.
37
39
  */
38
40
  export declare const semanticQueryEntityTypes: readonly ["asset", "location", "event", "reader", "snapshot", "manifest"];
39
41
  export declare type SemanticQueryEntityType = (typeof semanticQueryEntityTypes)[number];
@@ -454,6 +456,176 @@ export interface SemanticEventActionCondition {
454
456
  */
455
457
  export declare const semanticEventConditionTypes: readonly ["and", "or", "occurred", "eventType", "location", "reader", "user", "action"];
456
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;
457
629
  /**
458
630
  * WHICH WORDS EACH ENTITY KNOWS — the closed vocabulary, per entity.
459
631
  *
@@ -486,7 +658,7 @@ export declare const semanticConditionTypesByEntity: Record<SemanticQueryEntityT
486
658
  * validator, which knows the entity and can say "'readiness' is an asset
487
659
  * condition" instead of "not allowed".
488
660
  */
489
- export declare const semanticConditionTypes: readonly ("telemetry" | "readiness" | "path" | "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")[];
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")[];
490
662
  export declare type SemanticConditionType = (typeof semanticConditionTypes)[number];
491
663
  /**
492
664
  * Query size bounds, shared by the boundary schema (which refuses an oversized
@@ -510,7 +682,7 @@ export declare type SemanticAssetCondition = SemanticAndCondition | SemanticOrCo
510
682
  * Any condition, whatever the entity. Widens as entities are added; the
511
683
  * envelope and everything generic over it stay unchanged when they are.
512
684
  */
513
- export declare type SemanticQueryCondition = SemanticAssetCondition | SemanticLocationCondition | SemanticEventCondition;
685
+ export declare type SemanticQueryCondition = SemanticAssetCondition | SemanticLocationCondition | SemanticEventCondition | SemanticSnapshotCondition | SemanticReaderCondition;
514
686
  /** Current wire version of the condition vocabulary. */
515
687
  export declare const SEMANTIC_QUERY_VERSION = 2;
516
688
  export interface SemanticQuery {
@@ -614,7 +786,7 @@ export declare type SemanticQueryViewType = (typeof semanticQueryViewTypes)[numb
614
786
  * harmless odd ordering would cost a discriminated union on every read path
615
787
  * for no safety gained.
616
788
  */
617
- export declare type SemanticQuerySortField = AssetSortField | LocationSortField;
789
+ export declare type SemanticQuerySortField = AssetSortField | LocationSortField | SnapshotSortField;
618
790
  export declare const semanticQuerySortFields: SemanticQuerySortField[];
619
791
  export interface SemanticQueryDisplay {
620
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.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;
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,9 +29,9 @@ exports.semanticQuerySortFields = exports.semanticQueryViewTypes = exports.SEMAN
29
29
  */
30
30
  // --- Entity + record kind -------------------------------------------------
31
31
  /**
32
- * What a semantic query targets. `asset`, `location` and `event` execute;
33
- * the rest are recorded from day one so a stored query never needs
34
- * retrofitting when its entity learns to speak.
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.
35
35
  */
36
36
  exports.semanticQueryEntityTypes = [
37
37
  'asset',
@@ -180,6 +180,54 @@ exports.semanticEventConditionTypes = [
180
180
  'user',
181
181
  'action',
182
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
+ ];
183
231
  /**
184
232
  * WHICH WORDS EACH ENTITY KNOWS — the closed vocabulary, per entity.
185
233
  *
@@ -207,8 +255,8 @@ exports.semanticConditionTypesByEntity = {
207
255
  asset: exports.semanticAssetConditionTypes,
208
256
  location: exports.semanticLocationConditionTypes,
209
257
  event: exports.semanticEventConditionTypes,
210
- reader: [],
211
- snapshot: [],
258
+ snapshot: exports.semanticSnapshotConditionTypes,
259
+ reader: exports.semanticReaderConditionTypes,
212
260
  manifest: [],
213
261
  };
214
262
  /**
@@ -224,6 +272,8 @@ exports.semanticConditionTypes = [
224
272
  ...exports.semanticAssetConditionTypes,
225
273
  ...exports.semanticLocationConditionTypes,
226
274
  ...exports.semanticEventConditionTypes,
275
+ ...exports.semanticSnapshotConditionTypes,
276
+ ...exports.semanticReaderConditionTypes,
227
277
  ]),
228
278
  ];
229
279
  /**
@@ -261,6 +311,7 @@ const SEMANTIC_QUERY_SORT_FIELD_SET = {
261
311
  battery: true,
262
312
  ready: true,
263
313
  path: true,
314
+ submitted: true,
264
315
  };
265
316
  exports.semanticQuerySortFields = Object.keys(SEMANTIC_QUERY_SORT_FIELD_SET);
266
317
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/semantic-queries/shared.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,6EAA6E;AAE7E;;;;GAIG;AACU,QAAA,wBAAwB,GAAG;IACtC,OAAO;IACP,UAAU;IACV,OAAO;IACP,QAAQ;IACR,UAAU;IACV,UAAU;CACF,CAAA;AAGV;;;;;;GAMG;AACU,QAAA,kBAAkB,GAAG,CAAC,OAAO,EAAE,WAAW,CAAU,CAAA;AAGpD,QAAA,yBAAyB,GAAG,CAAC,SAAS,EAAE,cAAc,CAAU,CAAA;AAG7E,6EAA6E;AAEhE,QAAA,yBAAyB,GAAG;IACvC,KAAK;IACL,MAAM;IACN,OAAO;IACP,SAAS;IACT,MAAM;CACE,CAAA;AAGG,QAAA,6BAA6B,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAU,CAAA;AAwC9E,6EAA6E;AAEhE,QAAA,sBAAsB,GAAG;IACpC,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,UAAU;IACV,QAAQ;IACR,WAAW;CACH,CAAA;AAGG,QAAA,0BAA0B,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAU,CAAA;AAIhE,QAAA,2BAA2B,GAAG;IACzC,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;CACG,CAAA;AAIG,QAAA,oBAAoB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAA;AA+H9C,QAAA,uBAAuB,GAAG;IACrC,SAAS;IACT,aAAa;IACb,SAAS;CACD,CAAA;AAUV,wF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uB,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.23",
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": "98f55f8c8aed87a8a889a8f4809a51edc9afc5b4"
21
+ "gitHead": "d90ad98fb1929f252919e408015f7ab8b71c6fbc"
22
22
  }