@spotto/contract 1.0.70-alpha.37 → 1.0.70-alpha.39

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.
@@ -10,9 +10,28 @@ export declare type SnapshotCrudEventType = 'SnapshotCreated' | 'SnapshotDeleted
10
10
  * authored option list a propagation rewrote (`payload.propagation`).
11
11
  */
12
12
  export declare type TypeCrudEventType = 'TypeCreated' | 'TypeUpdated' | 'TypeDeleted';
13
+ /**
14
+ * A readiness transition: the asset's verdict (green / amber / red) moved.
15
+ * Stored only — never published to Slate. Written by every path that
16
+ * re-derives readiness — an asset write, a kit re-roll, a type-rule edit and
17
+ * the scheduled refresh — so the log records the move whoever or whatever
18
+ * caused it, and a user is present only when a person's action led there.
19
+ */
20
+ export declare type ReadinessEventType = 'AssetReadinessChanged';
21
+ /**
22
+ * What moved an asset's readiness verdict.
23
+ * - `edit`: the asset itself was written — an edit, a form write-back, a
24
+ * stocktake's manifest verdict on a kit.
25
+ * - `rules`: its type's readiness rules or bindings changed and every asset
26
+ * of the type was re-evaluated.
27
+ * - `members`: a kit re-rolled because a member changed, joined or left.
28
+ * - `schedule`: the scheduled refresh noticed the date moved.
29
+ */
30
+ export declare type ReadinessChangeCause = 'edit' | 'rules' | 'members' | 'schedule';
31
+ export declare const READINESS_CHANGE_CAUSES: ReadinessChangeCause[];
13
32
  export declare type FormEventType = 'FormSubmitted' | 'FormSubmissionVoided';
14
33
  export declare type SlateEventType = 'ReaderArrived' | 'ReaderExited' | 'Arrived' | 'Moved' | 'Exited' | 'ReaderOnline' | 'ReaderOffline' | 'AssetDispatch';
15
- export declare type EventType = SlateEventType | AssetCrudEventType | LocationCrudEventType | ReaderCrudEventType | SnapshotCrudEventType | TypeCrudEventType | FormEventType | 'UserSearch' | 'WorkflowActionExecuted';
34
+ export declare type EventType = SlateEventType | AssetCrudEventType | LocationCrudEventType | ReaderCrudEventType | SnapshotCrudEventType | TypeCrudEventType | ReadinessEventType | FormEventType | 'UserSearch' | 'WorkflowActionExecuted';
16
35
  export declare const EVENT_TYPES: EventType[];
17
36
  /** The asset-type CRUD events as a value, for the surfaces that list them. */
18
37
  export declare const TYPE_CRUD_EVENT_TYPES: TypeCrudEventType[];
@@ -30,3 +49,12 @@ export declare const TYPE_CRUD_EVENT_TYPES: TypeCrudEventType[];
30
49
  * Typed as `AssetCrudEventType[]` so the list cannot diverge from the union.
31
50
  */
32
51
  export declare const ASSET_CRUD_EVENT_TYPES: AssetCrudEventType[];
52
+ /**
53
+ * The events whose embedded asset records its TYPE PATH (`thing.typePath`
54
+ * in storage): the CRUD trio, which embeds the whole asset, and the
55
+ * readiness transition, which embeds the asset's identity, type path and
56
+ * verdict. The `assetType` condition on activity is scoped to exactly these
57
+ * — the compiler, the evaluator, the validator's pairing guard and the AI
58
+ * preamble all read THIS list, for the reason `ASSET_CRUD_EVENT_TYPES` gives.
59
+ */
60
+ export declare const TYPED_ASSET_EVENT_TYPES: (AssetCrudEventType | ReadinessEventType)[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ASSET_CRUD_EVENT_TYPES = exports.TYPE_CRUD_EVENT_TYPES = exports.EVENT_TYPES = exports.EVENT_COUNT_BREAKDOWN = void 0;
3
+ exports.TYPED_ASSET_EVENT_TYPES = exports.ASSET_CRUD_EVENT_TYPES = exports.TYPE_CRUD_EVENT_TYPES = exports.EVENT_TYPES = exports.READINESS_CHANGE_CAUSES = exports.EVENT_COUNT_BREAKDOWN = void 0;
4
4
  exports.EVENT_COUNT_BREAKDOWN = [
5
5
  'year',
6
6
  'week',
@@ -8,6 +8,12 @@ exports.EVENT_COUNT_BREAKDOWN = [
8
8
  'day',
9
9
  'hour',
10
10
  ];
11
+ exports.READINESS_CHANGE_CAUSES = [
12
+ 'edit',
13
+ 'rules',
14
+ 'members',
15
+ 'schedule',
16
+ ];
11
17
  exports.EVENT_TYPES = [
12
18
  'ReaderArrived',
13
19
  'ReaderExited',
@@ -31,6 +37,7 @@ exports.EVENT_TYPES = [
31
37
  'TypeCreated',
32
38
  'TypeUpdated',
33
39
  'TypeDeleted',
40
+ 'AssetReadinessChanged',
34
41
  'FormSubmitted',
35
42
  'FormSubmissionVoided',
36
43
  'UserSearch',
@@ -60,4 +67,13 @@ exports.ASSET_CRUD_EVENT_TYPES = [
60
67
  'AssetUpdated',
61
68
  'AssetDeleted',
62
69
  ];
70
+ /**
71
+ * The events whose embedded asset records its TYPE PATH (`thing.typePath`
72
+ * in storage): the CRUD trio, which embeds the whole asset, and the
73
+ * readiness transition, which embeds the asset's identity, type path and
74
+ * verdict. The `assetType` condition on activity is scoped to exactly these
75
+ * — the compiler, the evaluator, the validator's pairing guard and the AI
76
+ * preamble all read THIS list, for the reason `ASSET_CRUD_EVENT_TYPES` gives.
77
+ */
78
+ exports.TYPED_ASSET_EVENT_TYPES = [...exports.ASSET_CRUD_EVENT_TYPES, 'AssetReadinessChanged'];
63
79
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/events/constants.ts"],"names":[],"mappings":";;;AACa,QAAA,qBAAqB,GAA0B;IAC1D,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;CACP,CAAA;AAiDY,QAAA,WAAW,GAAgB;IACtC,eAAe;IACf,cAAc;IACd,SAAS;IACT,OAAO;IACP,QAAQ;IACR,cAAc;IACd,eAAe;IACf,eAAe;IACf,cAAc;IACd,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,aAAa;IACb,eAAe;IACf,sBAAsB;IACtB,YAAY;IACZ,wBAAwB;CACzB,CAAA;AAED,8EAA8E;AACjE,QAAA,qBAAqB,GAAwB;IACxD,aAAa;IACb,aAAa;IACb,aAAa;CACd,CAAA;AAED;;;;;;;;;;;;GAYG;AACU,QAAA,sBAAsB,GAAyB;IAC1D,cAAc;IACd,cAAc;IACd,cAAc;CACf,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/events/constants.ts"],"names":[],"mappings":";;;AACa,QAAA,qBAAqB,GAA0B;IAC1D,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;CACP,CAAA;AA8CY,QAAA,uBAAuB,GAA2B;IAC7D,MAAM;IACN,OAAO;IACP,SAAS;IACT,UAAU;CACX,CAAA;AA0BY,QAAA,WAAW,GAAgB;IACtC,eAAe;IACf,cAAc;IACd,SAAS;IACT,OAAO;IACP,QAAQ;IACR,cAAc;IACd,eAAe;IACf,eAAe;IACf,cAAc;IACd,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,aAAa;IACb,uBAAuB;IACvB,eAAe;IACf,sBAAsB;IACtB,YAAY;IACZ,wBAAwB;CACzB,CAAA;AAED,8EAA8E;AACjE,QAAA,qBAAqB,GAAwB;IACxD,aAAa;IACb,aAAa;IACb,aAAa;CACd,CAAA;AAED;;;;;;;;;;;;GAYG;AACU,QAAA,sBAAsB,GAAyB;IAC1D,cAAc;IACd,cAAc;IACd,cAAc;CACf,CAAA;AAED;;;;;;;GAOG;AACU,QAAA,uBAAuB,GAClC,CAAC,GAAG,8BAAsB,EAAE,uBAAuB,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
- import { IEmbeddedEntity } from '../../shared';
2
- import { AssetCrudEventType, EventType, LocationCrudEventType, ReaderCrudEventType, SnapshotCrudEventType, TypeCrudEventType } from '../constants';
1
+ import { IEmbeddedEntity, IReadiness, ReadinessState } from '../../shared';
2
+ import { AssetCrudEventType, EventType, LocationCrudEventType, ReaderCrudEventType, ReadinessChangeCause, ReadinessEventType, SnapshotCrudEventType, TypeCrudEventType } from '../constants';
3
3
  import { GetEventsQuery } from './query';
4
4
  import { DeviceType, ReaderType } from '../../readers/constants';
5
5
  import { LocationType } from '../../locations/constants';
@@ -96,7 +96,13 @@ export interface ITypeEventPropagation {
96
96
  origin: IEmbeddedEntity;
97
97
  }
98
98
  export interface ITypeEventPayload {
99
- /** Top-level keys the request set on the type; empty on a propagated write. */
99
+ /**
100
+ * The authored keys whose stored value differs between the states the
101
+ * event records (`previousTypeState` → `newTypeState`; nothing → the new
102
+ * state on a create), in authored order. Not the keys the request sent: an
103
+ * editor re-sends a whole section, and a key re-sent unchanged is no
104
+ * change. Empty on a propagated write.
105
+ */
100
106
  changed: string[];
101
107
  /** Present only on a write made by propagation from another type's edit. */
102
108
  propagation?: ITypeEventPropagation;
@@ -108,8 +114,55 @@ export interface ITypeCrudEvent extends IBaseEvent {
108
114
  assetType: IEventAssetType;
109
115
  user: IEmbeddedEntity;
110
116
  payload: ITypeEventPayload;
111
- /** `TypeUpdated` — the type's authored keys before the write (no resolved `*All` caches). */
117
+ /** `TypeUpdated` / `TypeDeleted` — the type's authored keys before the write (no resolved `*All` caches). */
112
118
  previousTypeState?: GetTypeResponse;
119
+ /**
120
+ * `TypeUpdated` / `TypeCreated` — the type's authored keys after the write,
121
+ * in the same shape. Diff the two for what changed, as `asset` and
122
+ * `previousAssetState` on an asset event.
123
+ */
124
+ newTypeState?: GetTypeResponse;
125
+ }
126
+ /**
127
+ * The subject of a readiness transition: the asset's identity, its type path
128
+ * at the time, and its verdict after the move. Not the whole asset — the
129
+ * values a person authored are on the `AssetUpdated` beside an edit, and on
130
+ * the other causes nothing authored changed.
131
+ */
132
+ export interface IReadinessEventAsset extends IEmbeddedEntity {
133
+ /** Pipe-delimited path of the asset's type at the time. */
134
+ typePath?: string;
135
+ /** The verdict and the issues firing after the move. */
136
+ readiness: IReadiness;
137
+ }
138
+ export interface IAssetReadinessChangedPayload {
139
+ /**
140
+ * The verdict the asset moved to — the same value as
141
+ * `asset.readiness.ready`, at the top so a filter never opens the embed.
142
+ */
143
+ ready: ReadinessState;
144
+ /**
145
+ * The verdict it moved from. Absent when the asset had never been
146
+ * evaluated: its first verdict, which is recorded only when it lands amber
147
+ * or red, is not a move from green.
148
+ */
149
+ previousReady?: ReadinessState;
150
+ cause: ReadinessChangeCause;
151
+ /** `members` — the member whose change re-rolled this kit, when one asset was the cause. */
152
+ origin?: IEmbeddedEntity;
153
+ /** The stocktake the change came through, when it did. */
154
+ snapshotId?: string;
155
+ /** The form submission whose write-back caused the change, when one did. */
156
+ submissionId?: string;
157
+ }
158
+ export interface IAssetReadinessChangedEvent extends IBaseEvent {
159
+ type: ReadinessEventType;
160
+ asset: IReadinessEventAsset;
161
+ /** The person whose action led to the move. Absent on the scheduled refresh. */
162
+ user?: IEmbeddedEntity;
163
+ /** The verdict and issues before the move. Absent on a first evaluation. */
164
+ previousReadiness?: IReadiness;
165
+ payload: IAssetReadinessChangedPayload;
113
166
  }
114
167
  export interface IUserSearchEvent extends IBaseEvent {
115
168
  type: 'UserSearch';
@@ -188,7 +241,7 @@ export interface IAssetDispatchEvent extends IBaseEvent {
188
241
  location?: AssetEventLocation;
189
242
  dispatchExpires: number;
190
243
  }
191
- export declare type GetEventResponse = IAssetCrudEvent | ILocationCrudEvent | IReaderCrudEvent | ISnapshotCrudEvent | ITypeCrudEvent | IUserSearchEvent | IReaderArrivedEvent | IReaderExitedEvent | IArrivedEvent | IMovedEvent | IExitedEvent | IReaderOnlineEvent | IReaderOfflineEvent | IAssetDispatchEvent | IWorkflowActionExecutedEvent | IFormSubmittedEvent | IFormSubmissionVoidedEvent;
244
+ export declare type GetEventResponse = IAssetCrudEvent | ILocationCrudEvent | IReaderCrudEvent | ISnapshotCrudEvent | ITypeCrudEvent | IAssetReadinessChangedEvent | IUserSearchEvent | IReaderArrivedEvent | IReaderExitedEvent | IArrivedEvent | IMovedEvent | IExitedEvent | IReaderOnlineEvent | IReaderOfflineEvent | IAssetDispatchEvent | IWorkflowActionExecutedEvent | IFormSubmittedEvent | IFormSubmissionVoidedEvent;
192
245
  export interface GetEventsResponse {
193
246
  query: GetEventsQuery | null;
194
247
  items: GetEventResponse[];
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.37",
4
+ "version": "1.0.70-alpha.39",
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": "55a29affe0ebc09495a381fd90a9eb92ba0155b0"
21
+ "gitHead": "714f1f328b0b4ea887deb91b84a7e008204c8ee7"
22
22
  }