@spotto/contract 1.0.70-alpha.28 → 1.0.70-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/users/current.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IEntityMeta, IEmbeddedEntity } from '../shared';
|
|
|
2
2
|
import { Preferences } from '../organisations/constants';
|
|
3
3
|
import { Integrations } from '../integrations/constants';
|
|
4
4
|
import { System } from '../system';
|
|
5
|
-
import {
|
|
5
|
+
import { StoredHomeLayout } from './home-layout';
|
|
6
6
|
import { PermissionGrantLevel, UsergroupsScope } from '../usergroups/shared';
|
|
7
7
|
/** One entry of the §1.7 field access list — every org field appears. */
|
|
8
8
|
export interface FieldAccessEntry {
|
|
@@ -34,11 +34,16 @@ export interface CurrentUserResponse {
|
|
|
34
34
|
*/
|
|
35
35
|
authProvider?: 'sso' | 'native';
|
|
36
36
|
/**
|
|
37
|
-
* Personal Home-screen
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Personal Home-screen layouts (the user's named widget arrangements).
|
|
38
|
+
* Persisted on the user doc and written via
|
|
39
|
+
* `POST /users/current/home-layout`. `undefined` until the user customises —
|
|
40
|
+
* the client then renders its built-in default layout.
|
|
41
|
+
*
|
|
42
|
+
* Typed as STORED, not as the current shape: a document written by an earlier
|
|
43
|
+
* client still carries the pre-v5 single-layout form until that user next
|
|
44
|
+
* saves, and readers have to handle it rather than assume it away.
|
|
40
45
|
*/
|
|
41
|
-
homeLayout?:
|
|
46
|
+
homeLayout?: StoredHomeLayout;
|
|
42
47
|
/**
|
|
43
48
|
* UI-only visibility lists (usergroups feature) — COMPLETE: every org
|
|
44
49
|
* field appears with the caller's effective level (grant-less ⇒ EDIT;
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-user Home screen
|
|
3
|
-
* Home widgets. Stored directly on the user document (like
|
|
4
|
-
* returned on `GET /users/current`, and written
|
|
5
|
-
* `POST /users/current/home-layout`.
|
|
2
|
+
* Per-user Home screen layouts — a personal, server-persisted set of named
|
|
3
|
+
* arrangements of Home widgets. Stored directly on the user document (like
|
|
4
|
+
* `homeLocationId`), returned on `GET /users/current`, and written wholesale
|
|
5
|
+
* via `POST /users/current/home-layout`.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
7
|
+
* Since v5 a user has SEVERAL named layouts and switches between them — the
|
|
8
|
+
* same want saved views answer for a list, applied to the Home. They exist
|
|
9
|
+
* because the thing that changes what a Home should show is the TASK (admin
|
|
10
|
+
* this morning, dispatch this afternoon), not the hardware; a layout that
|
|
11
|
+
* differs by device splits when the task doesn't and fails to split when it
|
|
12
|
+
* does. What device legitimately owns is per-widget (`showOn`).
|
|
13
|
+
*
|
|
14
|
+
* Each layout is a flat, ordered list of widgets, every one pinned to a rect on
|
|
15
|
+
* a 4-column grid (`gridPos`). The widget `type` is a closed union (below):
|
|
16
|
+
* adding a new kind is a contract change + republish + client bump. Per-widget
|
|
17
|
+
* `config` carries widget *behaviour* only (a saved-view id, an action id, a
|
|
18
|
+
* heading's text) — never geometry. Since 2026-07-30 the API validates each
|
|
19
|
+
* kind's KNOWN config keys on write (the per-kind `*WidgetConfig` shapes below)
|
|
20
|
+
* while tolerating unknown keys, so the client can still add config keys
|
|
21
|
+
* without an API deploy ordering — only changing a known key's meaning needs
|
|
22
|
+
* one.
|
|
15
23
|
*
|
|
16
24
|
* `version` discriminates stored layouts so the client can detect and
|
|
17
|
-
* reset/migrate an older one on read
|
|
25
|
+
* reset/migrate an older one on read — including the pre-v5 single-layout
|
|
26
|
+
* shape, which is still readable as `LegacyHomeLayout`.
|
|
18
27
|
*/
|
|
19
28
|
/**
|
|
20
29
|
* The kinds of Home widget. Closed set — adding one is a contract change.
|
|
@@ -103,6 +112,19 @@ export interface HomeWidgetGridPos {
|
|
|
103
112
|
/** Height in row-units (>= 1). */
|
|
104
113
|
h: number;
|
|
105
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Which form factors a widget appears on. Absent means every width — the
|
|
117
|
+
* normal case, and the only shape stored layouts carried before 2026-08-18.
|
|
118
|
+
*
|
|
119
|
+
* `mobile` means every NARROW layout, tablets included: they share the same
|
|
120
|
+
* two-column grid, so there is no third thing to name. This exists because a
|
|
121
|
+
* device genuinely owns one question a layout cannot answer for it — whether a
|
|
122
|
+
* widget is usable at all in the room a phone gives it. It deliberately does
|
|
123
|
+
* NOT let a widget sit in a different PLACE per device; a layout that reorders
|
|
124
|
+
* itself by hardware is two layouts to keep in sync, which is what named
|
|
125
|
+
* layouts are for.
|
|
126
|
+
*/
|
|
127
|
+
export declare type HomeWidgetShowOn = 'desktop' | 'mobile';
|
|
106
128
|
export interface HomeWidget {
|
|
107
129
|
/** Stable client-generated id (ulid) — the reorder / remove key. */
|
|
108
130
|
id: string;
|
|
@@ -110,12 +132,90 @@ export interface HomeWidget {
|
|
|
110
132
|
type: HomeWidgetType;
|
|
111
133
|
/** Position + size on the 4-column grid. */
|
|
112
134
|
gridPos: HomeWidgetGridPos;
|
|
135
|
+
/** Restrict the widget to one form factor; absent means every width. */
|
|
136
|
+
showOn?: HomeWidgetShowOn;
|
|
113
137
|
/** Widget-specific *behaviour* config (e.g. a saved-view id, a heading's text) — never geometry. Known keys are validated per kind (see the `*WidgetConfig` shapes); unknown keys pass through. */
|
|
114
138
|
config?: Record<string, unknown>;
|
|
115
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* One named layout — a user-authored arrangement they can switch to.
|
|
142
|
+
*
|
|
143
|
+
* Layouts are INDEPENDENT: each owns its widgets outright, the way a saved view
|
|
144
|
+
* owns its query. A widget placed in two layouts is two records, and diverging
|
|
145
|
+
* is the point — the alternative (one widget set with per-layout placement)
|
|
146
|
+
* buys "rename the hero once" at the price of splitting a widget's lifetime
|
|
147
|
+
* from its placement everywhere else in the system.
|
|
148
|
+
*/
|
|
149
|
+
export interface NamedHomeLayout {
|
|
150
|
+
/** Stable client-generated id (ulid). */
|
|
151
|
+
id: string;
|
|
152
|
+
/** User-authored name, shown in the Home's layout switcher. */
|
|
153
|
+
name: string;
|
|
154
|
+
/** Flat, ordered widget list; geometry lives on each widget's `gridPos`. */
|
|
155
|
+
widgets: HomeWidget[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The size of screen a Home is being opened on.
|
|
159
|
+
*
|
|
160
|
+
* Three classes, where `showOn` has two, and the difference is deliberate: they
|
|
161
|
+
* answer different questions. Whether a widget is USABLE in the room it gets is
|
|
162
|
+
* a question about the grid, and a tablet's grid is a phone's (two columns) —
|
|
163
|
+
* hence `desktop | mobile` there. Which layout you want to LAND on is a
|
|
164
|
+
* question about what you are doing, and someone carrying a tablet round a yard
|
|
165
|
+
* is doing neither of the other two jobs.
|
|
166
|
+
*/
|
|
167
|
+
export declare type HomeDeviceClass = 'mobile' | 'tablet' | 'desktop';
|
|
168
|
+
/**
|
|
169
|
+
* Which layout each size of screen opens on — the user's own explicit "land me
|
|
170
|
+
* here" per device, keyed class → layout id.
|
|
171
|
+
*
|
|
172
|
+
* This is the ONE place device legitimately picks a layout, and it does so
|
|
173
|
+
* without splitting anything: the layouts themselves are still task-shaped and
|
|
174
|
+
* available on every device, and this only decides which one is in front of you
|
|
175
|
+
* when you arrive. A class with no entry falls back to whatever that device was
|
|
176
|
+
* last switched to, then to the first layout.
|
|
177
|
+
*
|
|
178
|
+
* A class maps to exactly one layout BY CONSTRUCTION (that is why this is a map
|
|
179
|
+
* and not a flag on each layout — two layouts claiming the phone is not a state
|
|
180
|
+
* worth being able to represent). An id naming a layout that has since been
|
|
181
|
+
* deleted is harmless and deliberately not rejected: the set is edited from
|
|
182
|
+
* several devices, and the client falls through as if the entry were absent.
|
|
183
|
+
*/
|
|
184
|
+
export interface HomeLayoutDeviceDefaults {
|
|
185
|
+
mobile?: string;
|
|
186
|
+
tablet?: string;
|
|
187
|
+
desktop?: string;
|
|
188
|
+
}
|
|
116
189
|
export interface HomeLayout {
|
|
117
190
|
/** Layout schema version, so the client can detect + migrate/reset older stored layouts. */
|
|
118
191
|
version: number;
|
|
119
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* The user's layouts, in their own order — at least one, never empty.
|
|
194
|
+
*
|
|
195
|
+
* WHICH one is showing is deliberately not stored here: it is remembered per
|
|
196
|
+
* device by the client, so switching to a scanning layout on a phone doesn't
|
|
197
|
+
* change what the same user's desk opens on. `deviceDefaults` is the one
|
|
198
|
+
* stored part of that answer, and it is a landing preference, not a state.
|
|
199
|
+
*/
|
|
200
|
+
layouts: NamedHomeLayout[];
|
|
201
|
+
/** Per-device landing preference. Absent means "no preference" — the client's
|
|
202
|
+
* per-device memory decides, as it did before this existed. */
|
|
203
|
+
deviceDefaults?: HomeLayoutDeviceDefaults;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The pre-v5 shape: a single, unnamed layout.
|
|
207
|
+
*
|
|
208
|
+
* Read-only. A current client never writes it, but stored documents keep
|
|
209
|
+
* carrying it until each user's next save rewrites them, so anything that READS
|
|
210
|
+
* a persisted layout must still accept it. Delete once no stored document has
|
|
211
|
+
* it.
|
|
212
|
+
*/
|
|
213
|
+
export interface LegacyHomeLayout {
|
|
214
|
+
/** Layout schema version (< 5). */
|
|
215
|
+
version: number;
|
|
216
|
+
/** Flat, ordered widget list. */
|
|
120
217
|
widgets: HomeWidget[];
|
|
121
218
|
}
|
|
219
|
+
/** A layout as it may arrive FROM storage — current shape or legacy. Writes are
|
|
220
|
+
* always `HomeLayout`; the client migrates a legacy one on read. */
|
|
221
|
+
export declare type StoredHomeLayout = HomeLayout | LegacyHomeLayout;
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Per-user Home screen
|
|
4
|
-
* Home widgets. Stored directly on the user document (like
|
|
5
|
-
* returned on `GET /users/current`, and written
|
|
6
|
-
* `POST /users/current/home-layout`.
|
|
3
|
+
* Per-user Home screen layouts — a personal, server-persisted set of named
|
|
4
|
+
* arrangements of Home widgets. Stored directly on the user document (like
|
|
5
|
+
* `homeLocationId`), returned on `GET /users/current`, and written wholesale
|
|
6
|
+
* via `POST /users/current/home-layout`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* Since v5 a user has SEVERAL named layouts and switches between them — the
|
|
9
|
+
* same want saved views answer for a list, applied to the Home. They exist
|
|
10
|
+
* because the thing that changes what a Home should show is the TASK (admin
|
|
11
|
+
* this morning, dispatch this afternoon), not the hardware; a layout that
|
|
12
|
+
* differs by device splits when the task doesn't and fails to split when it
|
|
13
|
+
* does. What device legitimately owns is per-widget (`showOn`).
|
|
14
|
+
*
|
|
15
|
+
* Each layout is a flat, ordered list of widgets, every one pinned to a rect on
|
|
16
|
+
* a 4-column grid (`gridPos`). The widget `type` is a closed union (below):
|
|
17
|
+
* adding a new kind is a contract change + republish + client bump. Per-widget
|
|
18
|
+
* `config` carries widget *behaviour* only (a saved-view id, an action id, a
|
|
19
|
+
* heading's text) — never geometry. Since 2026-07-30 the API validates each
|
|
20
|
+
* kind's KNOWN config keys on write (the per-kind `*WidgetConfig` shapes below)
|
|
21
|
+
* while tolerating unknown keys, so the client can still add config keys
|
|
22
|
+
* without an API deploy ordering — only changing a known key's meaning needs
|
|
23
|
+
* one.
|
|
16
24
|
*
|
|
17
25
|
* `version` discriminates stored layouts so the client can detect and
|
|
18
|
-
* reset/migrate an older one on read
|
|
26
|
+
* reset/migrate an older one on read — including the pre-v5 single-layout
|
|
27
|
+
* shape, which is still readable as `LegacyHomeLayout`.
|
|
19
28
|
*/
|
|
20
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
30
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/users/home-layout/shared.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/users/home-layout/shared.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
|
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.29",
|
|
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": "d7d6135f89c2a6c0eb1c3cf1476a7d6fab481750"
|
|
22
22
|
}
|