@spotto/contract 1.0.70-alpha.22 → 1.0.70-alpha.23
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,16 @@ 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
|
+
/** IANA zone for the query's relative dates; the record's own wins if set. */
|
|
26
|
+
timezone?: string;
|
|
15
27
|
}
|
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { FieldDataType } from '../fields/constants';
|
|
6
7
|
/**
|
|
7
8
|
* SEMANTIC QUERIES — the portable query language.
|
|
@@ -30,8 +31,9 @@ import { FieldDataType } from '../fields/constants';
|
|
|
30
31
|
* TECHNICAL_DECISIONS.md) and the semantic-query specification errata.
|
|
31
32
|
*/
|
|
32
33
|
/**
|
|
33
|
-
* What a semantic query targets.
|
|
34
|
-
*
|
|
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.
|
|
35
37
|
*/
|
|
36
38
|
export declare const semanticQueryEntityTypes: readonly ["asset", "location", "event", "reader", "snapshot", "manifest"];
|
|
37
39
|
export declare type SemanticQueryEntityType = (typeof semanticQueryEntityTypes)[number];
|
|
@@ -344,6 +346,114 @@ export declare type SemanticLocationTimestampCondition = Omit<SemanticTimestampC
|
|
|
344
346
|
type: 'createdDate' | 'lastUpdated' | 'lastChanged';
|
|
345
347
|
};
|
|
346
348
|
export declare type SemanticLocationCondition = SemanticAndCondition | SemanticOrCondition | SemanticLocationPathCondition | SemanticLocationTypeCondition | SemanticLocationHasReadersCondition | SemanticLocationGeofenceCondition | SemanticLocationManifestCondition | SemanticTagsCondition | SemanticGeolocationCondition | SemanticLocationTimestampCondition;
|
|
349
|
+
/** WHEN it happened. Events are always in the past. */
|
|
350
|
+
export interface SemanticEventOccurredCondition {
|
|
351
|
+
type: 'occurred';
|
|
352
|
+
operator: SemanticTimestampOperator;
|
|
353
|
+
value: SemanticDateValue;
|
|
354
|
+
}
|
|
355
|
+
/** WHAT KIND of event. One or more of the platform's closed set. */
|
|
356
|
+
export interface SemanticEventTypeCondition {
|
|
357
|
+
type: 'eventType';
|
|
358
|
+
values: EventType[];
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* WHERE it happened, by pipe-delimited path — the same path vocabulary the
|
|
362
|
+
* location entity uses, matched as a prefix so a parent covers its subtree.
|
|
363
|
+
* Events embed the location's stored path in `location.name`, exactly as a
|
|
364
|
+
* location document does.
|
|
365
|
+
*
|
|
366
|
+
* PARTIAL BY CONSTRUCTION, and the line between this and the withheld
|
|
367
|
+
* `assetType` is worth stating because it is fine.
|
|
368
|
+
*
|
|
369
|
+
* Most event types embed `location`; several do not. For most of those the
|
|
370
|
+
* omission is honest — a `UserSearch` or a `ReaderOnline` has no place it
|
|
371
|
+
* happened. `assetType` was withheld because the events missing `thing
|
|
372
|
+
* .typePath` DO have an asset type; it simply is not stored, so the filter
|
|
373
|
+
* would be silently wrong about real data.
|
|
374
|
+
*
|
|
375
|
+
* ONE case here is on the wrong side of that line: a `FormSubmitted` event
|
|
376
|
+
* embeds `location` only for a LOCATION-target run. An asset-target
|
|
377
|
+
* submission made at the same place embeds `thing` instead, so "submissions at
|
|
378
|
+
* Brisbane" returns the location-target subset and drops the rest without
|
|
379
|
+
* saying so. That is the identical failure `assetType` was withheld for, and
|
|
380
|
+
* it survives here for one reason: the flat `locations` filter on
|
|
381
|
+
* `GET /events` has always behaved this way, so removing it from the language
|
|
382
|
+
* would make the two paths disagree about the same word. Fixing it properly
|
|
383
|
+
* means embedding the location on asset-target submissions — a write-path
|
|
384
|
+
* change, not a query one. Until then the preamble says so out loud.
|
|
385
|
+
*/
|
|
386
|
+
export interface SemanticEventLocationCondition {
|
|
387
|
+
type: 'location';
|
|
388
|
+
path: string;
|
|
389
|
+
/**
|
|
390
|
+
* Default true, matching the location entity. Carried rather than omitted
|
|
391
|
+
* because the boundary's property table is per-WORD, not per-entity: it
|
|
392
|
+
* already accepts `includeSublocations` on `location`, so leaving it
|
|
393
|
+
* unhandled here would mean an explicit `false` was accepted and silently
|
|
394
|
+
* behaved as `true` — a narrower query than asked for, quietly widened.
|
|
395
|
+
*/
|
|
396
|
+
includeSublocations?: boolean;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* WHICH READER saw it, by name.
|
|
400
|
+
*
|
|
401
|
+
* A name rather than an id, and that is safe here in a way it is not for
|
|
402
|
+
* assets: readers are a small named catalogue, so the name RESOLVES against
|
|
403
|
+
* real records at compile time and an unknown or ambiguous one is a loud
|
|
404
|
+
* failure. Nothing is guessed and no regex is left to match whatever it
|
|
405
|
+
* happens to match.
|
|
406
|
+
*/
|
|
407
|
+
export interface SemanticEventReaderCondition {
|
|
408
|
+
type: 'reader';
|
|
409
|
+
name: string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* WHO did it, by name — resolved the same way, against the organisation's
|
|
413
|
+
* users.
|
|
414
|
+
*
|
|
415
|
+
* Matching on a resolved user id inherently excludes system-generated events:
|
|
416
|
+
* Slate movements and arrivals carry no user at all. That is correct and worth
|
|
417
|
+
* stating, because "what did Sarah do" should never sweep in a reader
|
|
418
|
+
* detection.
|
|
419
|
+
*/
|
|
420
|
+
export interface SemanticEventUserCondition {
|
|
421
|
+
type: 'user';
|
|
422
|
+
name: string;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* WHICH ACTION a form submission belongs to, by name.
|
|
426
|
+
*
|
|
427
|
+
* The action is the useful handle and the form behind it is an implementation
|
|
428
|
+
* detail (ruled by Steve Mann, 2026-07-29, carried over from the prototype).
|
|
429
|
+
* An action condition already implies a submission, so it constrains the event
|
|
430
|
+
* type too and needs no pairing with `eventType`.
|
|
431
|
+
*
|
|
432
|
+
* It constrains to BOTH submission types — `FormSubmitted` and
|
|
433
|
+
* `FormSubmissionVoided`, which also carries `actionName`. Pinning it to
|
|
434
|
+
* `FormSubmitted` alone read as the tighter, safer choice and was the opposite:
|
|
435
|
+
* pairing it with `eventType: ['FormSubmissionVoided']` to ask for voided
|
|
436
|
+
* pre-start checks then produced two contradictory type constraints, which
|
|
437
|
+
* compiles cleanly and returns zero rows forever. Narrowing to just submitted
|
|
438
|
+
* ones stays possible — that is what the `eventType` pairing is for.
|
|
439
|
+
*/
|
|
440
|
+
export interface SemanticEventActionCondition {
|
|
441
|
+
type: 'action';
|
|
442
|
+
name: string;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* The EVENT vocabulary.
|
|
446
|
+
*
|
|
447
|
+
* `location` borrows its WORD from the asset vocabulary but not its meaning:
|
|
448
|
+
* an asset's `location` is where the asset is now, an event's is where the
|
|
449
|
+
* event happened. Same name for the same kind of question, different subject —
|
|
450
|
+
* which is why each entity compiles it against its own field.
|
|
451
|
+
* `occurred` is its own word rather than reusing a timestamp
|
|
452
|
+
* name, because an event has exactly ONE time and calling it `createdDate`
|
|
453
|
+
* would invite the reading that events have several dates the way assets do.
|
|
454
|
+
*/
|
|
455
|
+
export declare const semanticEventConditionTypes: readonly ["and", "or", "occurred", "eventType", "location", "reader", "user", "action"];
|
|
456
|
+
export declare type SemanticEventCondition = SemanticAndCondition | SemanticOrCondition | SemanticEventOccurredCondition | SemanticEventTypeCondition | SemanticEventLocationCondition | SemanticEventReaderCondition | SemanticEventUserCondition | SemanticEventActionCondition;
|
|
347
457
|
/**
|
|
348
458
|
* WHICH WORDS EACH ENTITY KNOWS — the closed vocabulary, per entity.
|
|
349
459
|
*
|
|
@@ -376,7 +486,7 @@ export declare const semanticConditionTypesByEntity: Record<SemanticQueryEntityT
|
|
|
376
486
|
* validator, which knows the entity and can say "'readiness' is an asset
|
|
377
487
|
* condition" instead of "not allowed".
|
|
378
488
|
*/
|
|
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")[];
|
|
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")[];
|
|
380
490
|
export declare type SemanticConditionType = (typeof semanticConditionTypes)[number];
|
|
381
491
|
/**
|
|
382
492
|
* Query size bounds, shared by the boundary schema (which refuses an oversized
|
|
@@ -400,7 +510,7 @@ export declare type SemanticAssetCondition = SemanticAndCondition | SemanticOrCo
|
|
|
400
510
|
* Any condition, whatever the entity. Widens as entities are added; the
|
|
401
511
|
* envelope and everything generic over it stay unchanged when they are.
|
|
402
512
|
*/
|
|
403
|
-
export declare type SemanticQueryCondition = SemanticAssetCondition | SemanticLocationCondition;
|
|
513
|
+
export declare type SemanticQueryCondition = SemanticAssetCondition | SemanticLocationCondition | SemanticEventCondition;
|
|
404
514
|
/** Current wire version of the condition vocabulary. */
|
|
405
515
|
export declare const SEMANTIC_QUERY_VERSION = 2;
|
|
406
516
|
export interface SemanticQuery {
|
|
@@ -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.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.
|
|
33
|
-
*
|
|
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.
|
|
34
35
|
*/
|
|
35
36
|
exports.semanticQueryEntityTypes = [
|
|
36
37
|
'asset',
|
|
@@ -159,6 +160,26 @@ 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
|
+
];
|
|
162
183
|
/**
|
|
163
184
|
* WHICH WORDS EACH ENTITY KNOWS — the closed vocabulary, per entity.
|
|
164
185
|
*
|
|
@@ -185,7 +206,7 @@ exports.semanticLocationConditionTypes = [
|
|
|
185
206
|
exports.semanticConditionTypesByEntity = {
|
|
186
207
|
asset: exports.semanticAssetConditionTypes,
|
|
187
208
|
location: exports.semanticLocationConditionTypes,
|
|
188
|
-
event:
|
|
209
|
+
event: exports.semanticEventConditionTypes,
|
|
189
210
|
reader: [],
|
|
190
211
|
snapshot: [],
|
|
191
212
|
manifest: [],
|
|
@@ -202,6 +223,7 @@ exports.semanticConditionTypes = [
|
|
|
202
223
|
...new Set([
|
|
203
224
|
...exports.semanticAssetConditionTypes,
|
|
204
225
|
...exports.semanticLocationConditionTypes,
|
|
226
|
+
...exports.semanticEventConditionTypes,
|
|
205
227
|
]),
|
|
206
228
|
];
|
|
207
229
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/semantic-queries/shared.ts"],"names":[],"mappings":";;;
|
|
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,o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;QAC9B,GAAG,sCAA8B;QACjC,GAAG,mCAA2B;KAC/B,CAAC;CAKH,CAAA;AAGD;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG;IACnC,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,CAAC;CACH,CAAA;AAgCV,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;AAsCvE;;;;;;;;;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;CACX,CAAA;AACY,QAAA,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAChD,6BAA6B,CACF,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.
|
|
4
|
+
"version": "1.0.70-alpha.23",
|
|
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": "
|
|
21
|
+
"gitHead": "98f55f8c8aed87a8a889a8f4809a51edc9afc5b4"
|
|
22
22
|
}
|