fsanyoto commited on
Commit
c17d124
·
verified ·
1 Parent(s): 8ae8b4d

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "dd1b062",
3
  "releases": [
4
  {
5
  "version": "v60",
 
1
  {
2
+ "current": "bbc4c07",
3
  "releases": [
4
  {
5
  "version": "v60",
VERSION CHANGED
@@ -1 +1 @@
1
- dd1b062
 
1
+ bbc4c07
api/routes_customers.py CHANGED
The diff for this file is too large to render. See raw diff
 
api/routes_products.py CHANGED
@@ -525,6 +525,24 @@ def product_assembly(session: Session, scope: str = "product", storage_key: str
525
  # choice hydration. Build their effective, already-walled row values before returning the
526
  # field contract so a populated select never opens as "no choices yet".
527
  fields = _hydrate_effective_choice_options(fields, rows_src, ws.get("overlays"), derived)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
529
  "fields": fields, "views": views, "lists": lists,
530
  "derived": derived,
 
525
  # choice hydration. Build their effective, already-walled row values before returning the
526
  # field contract so a populated select never opens as "no choices yet".
527
  fields = _hydrate_effective_choice_options(fields, rows_src, ws.get("overlays"), derived)
528
+ # ⭐⭐ D-590 (wave 46 hotfix) — **THE PER-TENANT SCHEMA OVERLAY, APPLIED TO THE GRID READ.**
529
+ # ⛔ THIS SURFACE IS THE ONE W46-T40 FAILED ON, and the staged spec named only the customer and
530
+ # user-table assemblies because lane E traced `routes_grid.py::workspace` alone. T40's evidence
531
+ # is `GET /api/v1/products` — which is THIS builder, through its own `workspace_wire` call — so
532
+ # wiring the other two would have left the ticket that reported the defect still failing.
533
+ # The seam, the polarity of a failed read and the `st` rule are in `core/schema_overlay.py`'s
534
+ # "THE GRID SEAM" header; `grid_assembly` carries the same block for the customer topic.
535
+ # ⚠ `fields_base` IS THE CANONICAL CONTRACT here (`scoped_pool` built it from `pd_fields`), so
536
+ # the locked set is derived from the same stratum `routes_admin._overlay_view` reads.
537
+ import core.schema_overlay as schema_overlay
538
+ fields, _ov_hidden = schema_overlay.for_grid(MODULE, fields, st=session.runtime,
539
+ contract=fields_base)
540
+ if _ov_hidden:
541
+ _ovc = ws.get("overlays") or {}
542
+ if _ovc:
543
+ ws["overlays"] = {str(pid): {k: v for k, v in (row or {}).items()
544
+ if k not in _ov_hidden}
545
+ for pid, row in _ovc.items()}
546
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
547
  "fields": fields, "views": views, "lists": lists,
548
  "derived": derived,
api/routes_tables.py CHANGED
@@ -1430,6 +1430,29 @@ def ut_assembly(session: Session, table_key: str, storage_key: str = "",
1430
  session.runtime.measure_memo).items():
1431
  derived.setdefault(_pid, {}).update(_cells)
1432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1433
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
1434
  "fields": fields, "views": views, "lists": lists, "hidden": hidden,
1435
  "derived": derived,
 
1430
  session.runtime.measure_memo).items():
1431
  derived.setdefault(_pid, {}).update(_cells)
1432
 
1433
+ # ⭐⭐ D-590 (wave 46 hotfix) — **THE PER-TENANT SCHEMA OVERLAY, APPLIED TO THE GRID READ.**
1434
+ # The third of the three assemblies; `grid_assembly` and `product_assembly` carry the same
1435
+ # block. Manage Database lists a `ut_*` database under its own table key, so that key IS the
1436
+ # overlay's database key here — the same string `_perm_modules` yields from `nav_entries`.
1437
+ # See `core/schema_overlay.py`'s "THE GRID SEAM" header for the fail-open polarity and why
1438
+ # `st` is keyword-only with no default.
1439
+ # ⚠ `session.runtime` AND NOT THE LEND, so the handle is the same tenant-runtime object the
1440
+ # admin route passes and the gate can assert identity rather than mere tenancy.
1441
+ # ⚠ `fields_base` is this table's canonical definition, so the locked set matches the panel's.
1442
+ import core.schema_overlay as schema_overlay
1443
+ fields, _ov_hidden = schema_overlay.for_grid(table_key, fields, st=session.runtime,
1444
+ contract=fields_base)
1445
+ if _ov_hidden:
1446
+ # Both cell wires, exactly as the `hidden` block above narrows them: `/workspace` serves
1447
+ # `ws["overlays"]` verbatim and `table_rows` layers `shared_cells` on top.
1448
+ _ovc = ws.get("overlays") or {}
1449
+ if _ovc:
1450
+ ws["overlays"] = {pid: {k: v for k, v in (cells or {}).items()
1451
+ if k not in _ov_hidden}
1452
+ for pid, cells in _ovc.items()}
1453
+ if shared_cells:
1454
+ shared_cells = {pid: {k: v for k, v in cells.items() if k not in _ov_hidden}
1455
+ for pid, cells in shared_cells.items()}
1456
  return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace,
1457
  "fields": fields, "views": views, "lists": lists, "hidden": hidden,
1458
  "derived": derived,
platform/core/route_system.py CHANGED
@@ -196,6 +196,26 @@ def _route(raw, *, ordinal=0, created_by="", tenant_id="", prior=None):
196
  # appear at an unknowable time or for nobody, and a later PATCH could accidentally
197
  # complete a schedule the user never submitted together.
198
  return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  stops_raw = raw.get("stops") if "stops" in raw else prior.get("stops")
200
  maps_url = str(raw.get("mapsUrl", prior.get("mapsUrl")) or "").strip()[:2048]
201
  if maps_url and not _GOOGLE_MAPS_URL_RE.match(maps_url):
@@ -208,7 +228,7 @@ def _route(raw, *, ordinal=0, created_by="", tenant_id="", prior=None):
208
  "sourceViewRevision": revision, "stops": _stops(stops_raw), "managedBy": MANAGED_BY,
209
  "createdBy": str(prior.get("createdBy") or created_by or "")[:120],
210
  "shareKey": share_key,
211
- "assignee": assignee, "date": route_date,
212
  "starred": raw.get("starred", prior.get("starred", False)) is True,
213
  "createdAt": prior.get("createdAt") or stamp, "updatedAt": stamp}
214
  if maps_url:
@@ -220,6 +240,18 @@ def _route(raw, *, ordinal=0, created_by="", tenant_id="", prior=None):
220
  return out
221
 
222
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  def _point_in_ring(lon, lat, ring):
224
  inside = False
225
  if len(ring) < 4:
@@ -948,6 +980,14 @@ def delete_zone(st, zone_id, *, table_key=DEFAULT_ZONE_TABLE):
948
  state["zones"] = [item for item in prior if not (
949
  isinstance(item, dict) and item.get("id") == zone_id
950
  and _zone_table_key(item) == table_key)]
 
 
 
 
 
 
 
 
951
  return state, len(prior) != len(state["zones"])
952
 
953
  return bool(_persist(st, mutate))
@@ -963,6 +1003,14 @@ def delete_zones_for_table(st, table_key):
963
  prior = list(state.get("zones") or [])
964
  state["zones"] = [item for item in prior if not (
965
  isinstance(item, dict) and _zone_table_key(item) == table_key)]
 
 
 
 
 
 
 
 
966
  return state, len(prior) - len(state["zones"])
967
 
968
  return int(_persist(st, mutate) or 0)
 
196
  # appear at an unknowable time or for nobody, and a later PATCH could accidentally
197
  # complete a schedule the user never submitted together.
198
  return None
199
+ # ⭐⭐ D-599 (wave 46 hotfix) — **THE ROUTE→ZONE ASSOCIATION.** Until this line no route record
200
+ # carried one: `ROUTES_KEY` and `ZONES_KEY` are two separate top-level tables, `ZONE_FIELD_KEY`
201
+ # is a field on a CUSTOMER row, and `customer_projections` attaches Routes and Zone to a
202
+ # customer INDEPENDENTLY. So a route's zone could not be changed because there was nothing to
203
+ # change (W46-T22, whose stop-delete half already worked).
204
+ #
205
+ # ⭐ THE MIGRATION FOR EXISTING SAVED ROUTES IS **NOTHING TO RUN**, and that is a decision
206
+ # rather than an omission. An absent key reads as `prior.get("zoneId")` -> `None`, so every
207
+ # route saved before this change has a null zone the first time it is read and keeps it until
208
+ # somebody sets one. No backfill script, no dry-run/apply pass, nothing deleted. The
209
+ # `ops/migrate_legacy_routes.py` shape was the precedent to reach for and it is not needed:
210
+ # that one moved DATA between representations; this adds an optional scalar with a safe null.
211
+ #
212
+ # ⚠ ABSENT INHERITS, EXPLICIT `null` CLEARS — the same polarity `assignee` and `date` above
213
+ # already use, so a PATCH carrying only `{"name": ...}` cannot silently unset a zone.
214
+ # ⛔ THE ID IS NOT VALIDATED HERE. This normaliser sees one route and never the zone table;
215
+ # the caller checks it against `zone_ids()` and refuses with a named 400, and `delete_zone`
216
+ # detaches the id from every route so a dangling reference cannot outlive its zone.
217
+ zone_id = str(raw.get("zoneId", raw.get("zone_id", prior.get("zoneId")))
218
+ or "").strip()[:96] or None
219
  stops_raw = raw.get("stops") if "stops" in raw else prior.get("stops")
220
  maps_url = str(raw.get("mapsUrl", prior.get("mapsUrl")) or "").strip()[:2048]
221
  if maps_url and not _GOOGLE_MAPS_URL_RE.match(maps_url):
 
228
  "sourceViewRevision": revision, "stops": _stops(stops_raw), "managedBy": MANAGED_BY,
229
  "createdBy": str(prior.get("createdBy") or created_by or "")[:120],
230
  "shareKey": share_key,
231
+ "assignee": assignee, "date": route_date, "zoneId": zone_id,
232
  "starred": raw.get("starred", prior.get("starred", False)) is True,
233
  "createdAt": prior.get("createdAt") or stamp, "updatedAt": stamp}
234
  if maps_url:
 
240
  return out
241
 
242
 
243
+ def zone_ids(st, *, table_key=DEFAULT_ZONE_TABLE):
244
+ """Every Zone id one database currently has — the vocabulary a route's `zoneId` may name.
245
+
246
+ ⭐ D-599 (wave 46 hotfix). Cheaper than `list_zones` for the one question the Route writer's
247
+ caller asks, because it never deep-copies a geometry or refreshes a membership.
248
+ """
249
+ wanted = str(table_key or DEFAULT_ZONE_TABLE).strip()
250
+ return {str(zone.get("id")) for zone in read(st).get("zones") or []
251
+ if isinstance(zone, dict) and zone.get("id")
252
+ and _zone_table_key(zone) == wanted}
253
+
254
+
255
  def _point_in_ring(lon, lat, ring):
256
  inside = False
257
  if len(ring) < 4:
 
980
  state["zones"] = [item for item in prior if not (
981
  isinstance(item, dict) and item.get("id") == zone_id
982
  and _zone_table_key(item) == table_key)]
983
+ # ⭐ D-599 — A DELETED ZONE TAKES ITS ROUTE ASSOCIATIONS WITH IT, in the SAME mutation.
984
+ # A route pointing at a zone that no longer exists would render as a blank selector that
985
+ # nothing explains, and the id would silently reappear in the wire. Detaching here rather
986
+ # than resolving leniently at every read means one place knows the rule.
987
+ # ⚠ IT DETACHES, IT NEVER DELETES A ROUTE. A zone is a grouping; a route is the work.
988
+ state["routes"] = [dict(item, zoneId=None)
989
+ if isinstance(item, dict) and item.get("zoneId") == zone_id else item
990
+ for item in (state.get("routes") or [])]
991
  return state, len(prior) != len(state["zones"])
992
 
993
  return bool(_persist(st, mutate))
 
1003
  prior = list(state.get("zones") or [])
1004
  state["zones"] = [item for item in prior if not (
1005
  isinstance(item, dict) and _zone_table_key(item) == table_key)]
1006
+ # D-599, the same rule as `delete_zone`: a zone that is gone leaves no route pointing at
1007
+ # it. Written here too rather than left to the single-zone door, because a database
1008
+ # deletion removes a whole family at once and is exactly when a dangling id would survive.
1009
+ gone = {str(item.get("id")) for item in prior
1010
+ if isinstance(item, dict) and _zone_table_key(item) == table_key}
1011
+ state["routes"] = [dict(item, zoneId=None)
1012
+ if isinstance(item, dict) and str(item.get("zoneId")) in gone else item
1013
+ for item in (state.get("routes") or [])]
1014
  return state, len(prior) - len(state["zones"])
1015
 
1016
  return int(_persist(st, mutate) or 0)
platform/core/schema_overlay.py CHANGED
@@ -366,3 +366,75 @@ def write(doc, st=None):
366
  type(doc).__name__, reason="the overlay document must be an object.")
367
  (st or _store()).put(STORE_KEY, doc)
368
  return doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  type(doc).__name__, reason="the overlay document must be an object.")
367
  (st or _store()).put(STORE_KEY, doc)
368
  return doc
369
+
370
+
371
+ # =================================================================================================
372
+ # THE GRID SEAM — D-590 (wave 46 hotfix, 2026-08-30)
373
+ #
374
+ # ⛔ WHY THIS FUNCTION EXISTS AT ALL. Wave 46 shipped the overlay end to end — the store, the R12
375
+ # wall, the merge, `GET/PATCH /api/v1/admin/schema-overlay`, and the Manage Database panel — and
376
+ # then nothing on the GRID read ever called `merge()`. An admin hid `price_1`, the panel saved it,
377
+ # a reload showed it hidden, and the column was still on the grid. `schema_overlay` grepped ZERO
378
+ # in all five candidate read paths. So the last wire is this: ONE function, called by all three
379
+ # assemblies (`routes_customers.grid_assembly`, `routes_products.product_assembly`,
380
+ # `routes_tables.ut_assembly`), which are the only builders of a served field list.
381
+ #
382
+ # ⛔⛔ `st` IS REQUIRED AND `None` IS REFUSED, WHICH IS THE POINT OF THE SIGNATURE. `read()`'s own
383
+ # default resolves through `core.store`'s module default — tenant #0's repo under `hf`, `AIOS_TENANT`
384
+ # or a hardcoded `royal-imports` under `pg` — so a dropped handle here would be a SILENT
385
+ # CROSS-TENANT READ: one tenant's hides applied to another tenant's grid. Lane E's own words about
386
+ # that discipline on this path were "documented and ENFORCED BY NOTHING". A keyword-only argument
387
+ # with no default makes the omission a `TypeError` at the call site, and the explicit `None` check
388
+ # makes the other spelling of the same mistake a refusal rather than a 200 off the wrong document.
389
+ # The gate's static leg over the three route files is the second lock, not the only one.
390
+ #
391
+ # ⚠ A FAILED READ FAILS **OPEN**, DELIBERATELY, AND IT IS NOT THE ADMIN ROUTE'S POLARITY.
392
+ # `read()` resolves a store failure to `{}`, which here means "no hides" — a column the admin hid
393
+ # stays visible for that request. The admin route 503s on the same condition (leg 17) because
394
+ # serving the bare contract there reads as "my overlay was never saved" and costs re-done work.
395
+ # On the GRID the trade is the other way: refusing the whole table over a DISPLAY preference would
396
+ # take the product down for an outage that costs, at worst, a visible column. Stated because a
397
+ # polarity nobody wrote down is a polarity nobody can review.
398
+ #
399
+ # ⚠ AN ABSENT DATABASE KEY RETURNS THE CALLER'S OWN LIST, UNCOPIED AND UNSORTED. C1's "an absent
400
+ # key means inherit" has to be free: the overwhelming majority of requests carry no overlay for the
401
+ # database being read, and a merge that rebuilt every dict on every one of them would be a cost
402
+ # with no behaviour attached.
403
+ # =================================================================================================
404
+
405
+ def for_grid(database_key, fields, *, st, contract=None, doc=None):
406
+ """`(fields, removed)` — this tenant's overlay applied to an ASSEMBLED grid field list.
407
+
408
+ `database_key` is the key Manage Database writes under, which is `_perm_modules`' key: the
409
+ registry topic (`customer_data`, `product_data`) or the `ut_*` table key. A mismatch here is
410
+ the silent no-op this whole item exists to remove, so the assemblies pass the same constant
411
+ they already use as their permission topic.
412
+
413
+ `contract` is the CANONICAL field contract, used only to derive the locked set. It defaults to
414
+ the assembled list, but a caller that holds the canonical one should pass it: `locked_keys`
415
+ reads `derived`/`pinned`, and the admin panel derives its own locked set from the canonical
416
+ contract. If the two disagree, the panel reports a field locked while the grid honours a hide
417
+ of it — a screen contradicting itself about a join key.
418
+
419
+ `doc` lets a caller that already read the document this request reuse it. `core.store.get`
420
+ deep-copies on every call, so a second read is a second copy of the whole document.
421
+
422
+ `removed` is the set of keys the overlay took OUT of the list. The caller needs it because the
423
+ field list is not the only wire: `/workspace` serves `ws["overlays"]` raw, and a hidden
424
+ column's cells would still ride that dict. One narrowing cannot speak for a wire it never
425
+ touches — the sentence the perm wall already writes three times over the same dict.
426
+ """
427
+ if st is None:
428
+ raise SchemaOverlayUnsupported(
429
+ "st", reason="the grid read needs this tenant's own store handle; the default lands "
430
+ "on another tenant.")
431
+ if doc is None:
432
+ doc = read(st=st)
433
+ per_db = (doc or {}).get(database_key) if isinstance(doc, dict) else None
434
+ if not isinstance(per_db, dict) or not per_db:
435
+ return fields, frozenset()
436
+ before = [f.get("key") for f in fields if isinstance(f, dict)]
437
+ locked = locked_keys(database_key, contract if contract is not None else fields)
438
+ merged = merge(fields, per_db, database_key, locked=locked)
439
+ after = {f.get("key") for f in merged if isinstance(f, dict)}
440
+ return merged, frozenset(k for k in before if k not in after)
web/src/customer-grid/MapView.tsx CHANGED
The diff for this file is too large to render. See raw diff
 
web/src/customer-grid/RouteNav.tsx CHANGED
The diff for this file is too large to render. See raw diff
 
web/src/customer-grid/routeZoneTypes.ts CHANGED
@@ -1,134 +1,140 @@
1
- // Wave 44 Route / Zone wire model. MapView never writes a legacy Destination N field.
2
- export type ZoneGeometry =
3
- | { type: "Polygon"; coordinates: number[][][] }
4
- | { type: "MultiPolygon"; coordinates: number[][][][] }
5
- | { type: "Circle"; center: [number, number]; radiusMeters: number };
6
-
7
- export interface MapZoneDto {
8
- id: string; name: string; color: string; geometryGeoJson: ZoneGeometry | null;
9
- zipCodes: string[]; visible: boolean; memberships: number[];
10
- geographicField?: string;
11
- membershipRevision?: number;
12
- sourceViewId?: string | null;
13
- createdBy?: string;
14
- createdAt?: string;
15
- permission?: { canEdit?: boolean; canDelete?: boolean };
16
- }
17
-
18
- export interface RouteDeliveryDto {
19
- id: string;
20
- name: string;
21
- recipient: string;
22
- schedule: { cron?: string; enabled?: boolean; timezone?: string };
23
- snapshot: {
24
- routeId: string;
25
- sourceViewId: string;
26
- sourceViewRevision: string;
27
- sourceViewName: string;
28
- timezone: string;
29
- routeField: string;
30
- orderedStopIds: number[];
31
- mapsPerLink: number;
32
- };
33
- createdBy?: string;
34
- created?: string;
35
- }
36
-
37
- export interface RouteDeliveryRequest {
38
- recipient: string;
39
- timezone: string;
40
- mapsPerLink: number;
41
- }
42
-
43
- export interface RouteAssignee {
44
- username: string;
45
- name: string;
46
- }
47
-
48
- export interface RouteAssigneeDirectory {
49
- today: string;
50
- people: RouteAssignee[];
51
- }
52
-
53
- export interface MapRouteDto {
54
- id: string; name: string; color: string; number: number; visibleStopIds: number[];
55
- outsideFilter: boolean;
56
- permission: { canEdit: boolean; sourceViewId: string | null };
57
- source: { viewId: string | null; revision: string | null };
58
- /** Read-through of a saved route-order field. It remains visible without mutating on GET. */
59
- compatibility?: "legacy-route-order";
60
- mapsUrl?: string;
61
- owner: string;
62
- shared: boolean;
63
- sharedOut: boolean;
64
- hasShares: boolean;
65
- sharedRole: "view" | "edit" | null;
66
- /** Generic field bridge address consumed by the established Share dialog. */
67
- shareId: string;
68
- /** This reader's personal Route filing; it never changes the shared Route object. */
69
- folderId: string | null;
70
- navOrder: number;
71
- assignee: string | null;
72
- date: string | null;
73
- starred?: boolean;
74
- capabilities?: Partial<Record<"rename" | "duplicate" | "star" | "share" | "delete", boolean>>;
75
- }
76
-
77
- export interface MapRouteFolderDto {
78
- id: string;
79
- name: string;
80
- parent: string | null;
81
- order: number;
82
- }
83
-
84
- export type MapRouteUpdate = {
85
- name?: string;
86
- mapsUrl?: string;
87
- starred?: boolean;
88
- assignee?: string | null;
89
- date?: string | null;
90
- };
91
-
92
- export interface RouteSelectionRequest { routeIds: string[]; viewState: Record<string, unknown>; }
93
-
94
- export interface RouteSelectionResponse {
95
- managedBy: "loopable";
96
- viewState: Record<string, unknown>;
97
- }
98
-
99
- /** The two authored sources that can become a named Route. */
100
- export type MapRouteSource = {
101
- id: "selection" | "zones";
102
- label: string;
103
- pids: number[];
104
- };
105
-
106
- /** A map may show one navigator at a time. The Routes rail wins when its host toggle is open. */
107
- export function mapNavigatorMode(routeOpen: boolean, zoneOpen: boolean): "routes" | "zones" | null {
108
- if (!routeOpen) return null;
109
- return zoneOpen ? "zones" : "routes";
110
- }
111
-
112
- /** Toggle exactly one named Route while preserving the existing multi-selection. */
113
- export function toggleRouteSelection(selected: ReadonlySet<string>, routeId: string): Set<string> {
114
- const next = new Set(selected);
115
- if (next.has(routeId)) next.delete(routeId);
116
- else next.add(routeId);
117
- return next;
118
- }
119
-
120
- /** Route creation never submits duplicate, empty, or non-customer IDs from either source. */
121
- export function routeSourceStopIds(pids: Iterable<number>): number[] {
122
- return [...new Set([...pids].filter((pid) => Number.isSafeInteger(pid) && pid > 0))];
123
- }
124
-
125
- /** Only a bounded HTTPS Google Maps link may leave the in-app Route detail. */
126
- export function boundedGoogleMapsUrl(value: string | undefined): string | null {
127
- if (!value || value.length > 2_048) return null;
128
- try {
129
- const url = new URL(value);
130
- return url.protocol === "https:" && /(^|\.)google\.[a-z.]+$/i.test(url.hostname) ? url.href : null;
131
- } catch {
132
- return null;
133
- }
134
- }
 
 
 
 
 
 
 
1
+ // Wave 44 Route / Zone wire model. MapView never writes a legacy Destination N field.
2
+ export type ZoneGeometry =
3
+ | { type: "Polygon"; coordinates: number[][][] }
4
+ | { type: "MultiPolygon"; coordinates: number[][][][] }
5
+ | { type: "Circle"; center: [number, number]; radiusMeters: number };
6
+
7
+ export interface MapZoneDto {
8
+ id: string; name: string; color: string; geometryGeoJson: ZoneGeometry | null;
9
+ zipCodes: string[]; visible: boolean; memberships: number[];
10
+ geographicField?: string;
11
+ membershipRevision?: number;
12
+ sourceViewId?: string | null;
13
+ createdBy?: string;
14
+ createdAt?: string;
15
+ permission?: { canEdit?: boolean; canDelete?: boolean };
16
+ }
17
+
18
+ export interface RouteDeliveryDto {
19
+ id: string;
20
+ name: string;
21
+ recipient: string;
22
+ schedule: { cron?: string; enabled?: boolean; timezone?: string };
23
+ snapshot: {
24
+ routeId: string;
25
+ sourceViewId: string;
26
+ sourceViewRevision: string;
27
+ sourceViewName: string;
28
+ timezone: string;
29
+ routeField: string;
30
+ orderedStopIds: number[];
31
+ mapsPerLink: number;
32
+ };
33
+ createdBy?: string;
34
+ created?: string;
35
+ }
36
+
37
+ export interface RouteDeliveryRequest {
38
+ recipient: string;
39
+ timezone: string;
40
+ mapsPerLink: number;
41
+ }
42
+
43
+ export interface RouteAssignee {
44
+ username: string;
45
+ name: string;
46
+ }
47
+
48
+ export interface RouteAssigneeDirectory {
49
+ today: string;
50
+ people: RouteAssignee[];
51
+ }
52
+
53
+ export interface MapRouteDto {
54
+ id: string; name: string; color: string; number: number; visibleStopIds: number[];
55
+ outsideFilter: boolean;
56
+ permission: { canEdit: boolean; sourceViewId: string | null };
57
+ source: { viewId: string | null; revision: string | null };
58
+ /** Read-through of a saved route-order field. It remains visible without mutating on GET. */
59
+ compatibility?: "legacy-route-order";
60
+ mapsUrl?: string;
61
+ owner: string;
62
+ shared: boolean;
63
+ sharedOut: boolean;
64
+ hasShares: boolean;
65
+ sharedRole: "view" | "edit" | null;
66
+ /** Generic field bridge address consumed by the established Share dialog. */
67
+ shareId: string;
68
+ /** This reader's personal Route filing; it never changes the shared Route object. */
69
+ folderId: string | null;
70
+ navOrder: number;
71
+ assignee: string | null;
72
+ date: string | null;
73
+ /** D-599: the Zone this Route belongs to, or null. Always present on the wire; every Route
74
+ * saved before wave 46's hotfix legitimately has none, so null is data and not an error. */
75
+ zoneId: string | null;
76
+ starred?: boolean;
77
+ capabilities?: Partial<Record<"rename" | "duplicate" | "star" | "share" | "delete", boolean>>;
78
+ }
79
+
80
+ export interface MapRouteFolderDto {
81
+ id: string;
82
+ name: string;
83
+ parent: string | null;
84
+ order: number;
85
+ }
86
+
87
+ export type MapRouteUpdate = {
88
+ name?: string;
89
+ mapsUrl?: string;
90
+ starred?: boolean;
91
+ assignee?: string | null;
92
+ date?: string | null;
93
+ /** D-599. Absent inherits the stored Zone; an explicit null clears it. The server refuses an
94
+ * id no Zone on this database carries, with `unknown_zone`. */
95
+ zoneId?: string | null;
96
+ };
97
+
98
+ export interface RouteSelectionRequest { routeIds: string[]; viewState: Record<string, unknown>; }
99
+
100
+ export interface RouteSelectionResponse {
101
+ managedBy: "loopable";
102
+ viewState: Record<string, unknown>;
103
+ }
104
+
105
+ /** The two authored sources that can become a named Route. */
106
+ export type MapRouteSource = {
107
+ id: "selection" | "zones";
108
+ label: string;
109
+ pids: number[];
110
+ };
111
+
112
+ /** A map may show one navigator at a time. The Routes rail wins when its host toggle is open. */
113
+ export function mapNavigatorMode(routeOpen: boolean, zoneOpen: boolean): "routes" | "zones" | null {
114
+ if (!routeOpen) return null;
115
+ return zoneOpen ? "zones" : "routes";
116
+ }
117
+
118
+ /** Toggle exactly one named Route while preserving the existing multi-selection. */
119
+ export function toggleRouteSelection(selected: ReadonlySet<string>, routeId: string): Set<string> {
120
+ const next = new Set(selected);
121
+ if (next.has(routeId)) next.delete(routeId);
122
+ else next.add(routeId);
123
+ return next;
124
+ }
125
+
126
+ /** Route creation never submits duplicate, empty, or non-customer IDs from either source. */
127
+ export function routeSourceStopIds(pids: Iterable<number>): number[] {
128
+ return [...new Set([...pids].filter((pid) => Number.isSafeInteger(pid) && pid > 0))];
129
+ }
130
+
131
+ /** Only a bounded HTTPS Google Maps link may leave the in-app Route detail. */
132
+ export function boundedGoogleMapsUrl(value: string | undefined): string | null {
133
+ if (!value || value.length > 2_048) return null;
134
+ try {
135
+ const url = new URL(value);
136
+ return url.protocol === "https:" && /(^|\.)google\.[a-z.]+$/i.test(url.hostname) ? url.href : null;
137
+ } catch {
138
+ return null;
139
+ }
140
+ }
web/src/styles/wave45/data-applications.css CHANGED
@@ -1,155 +1,152 @@
1
- /* Wave 45 Data, Map, Application, Fields, and Export surfaces.
2
- This sheet consumes the root token dialect and is imported by CustomerGrid so lane D does not
3
- create another global token seam. */
4
-
5
- .cg-map-settings > .cg-map-route-toggle {
6
- display: inline-flex;
7
- align-items: center;
8
- gap: 6px;
9
- }
10
-
11
- .cg-map-settings > .cg-map-route-toggle svg {
12
- flex: 0 0 auto;
13
- }
14
-
15
- .cg-mapview > .cg-map-bar > .cg-route-popover.cg-route-nav-panel {
16
- inset: 0 0 0 auto;
17
- width: min(360px, 100%);
18
- border-left: 1px solid var(--lp-line);
19
- border-right: 0;
20
- border-radius: 0;
21
- background: var(--lp-surface);
22
- color: var(--lp-ink);
23
- z-index: var(--cg-z-mapchrome);
24
- }
25
-
26
- .cg-map-navigator-tabs {
27
- display: grid;
28
- grid-template-columns: 1fr 1fr;
29
- gap: 4px;
30
- margin-bottom: 8px;
31
- padding: 3px;
32
- border: 1px solid var(--lp-line);
33
- border-radius: var(--lp-r-sm);
34
- background: var(--lp-surface-2);
35
- }
36
-
37
- .cg-map-navigator-tabs > button,
38
- .cg-zone-shape-picker button {
39
- border: 0;
40
- background: transparent;
41
- font: inherit;
42
- color: inherit;
43
- min-height: 32px;
44
- border-radius: var(--lp-r-sm);
45
- cursor: pointer;
46
- }
47
-
48
- .cg-map-navigator-tabs > button[aria-selected="true"],
49
- .cg-zone-shape-picker button[aria-pressed="true"] {
50
- background: var(--lp-primary-tint);
51
- color: var(--lp-primary);
52
- font-weight: 600;
53
- }
54
-
55
- .cg-map-navigator-tabs > button:focus-visible,
56
- .cg-zone-shape-picker button:focus-visible {
57
- outline: 2px solid var(--lp-blue-deep);
58
- outline-offset: 2px;
59
- }
60
-
61
- .cg-map-zone-option {
62
- min-height: 42px;
63
- }
64
-
65
- .cg-map-zone-edit {
66
- border: 0;
67
- background: transparent;
68
- font: inherit;
69
- color: var(--lp-blue-deep);
70
- cursor: pointer;
71
- }
72
-
73
- .cg-map-zone-edit:focus-visible {
74
- outline: 2px solid var(--lp-blue-deep);
75
- outline-offset: 2px;
76
- }
77
-
78
- .cg-zone-shape-picker {
79
- display: grid;
80
- gap: 6px;
81
- margin: 0;
82
- padding: 0;
83
- border: 0;
84
- }
85
-
86
- .cg-zone-shape-picker legend {
87
- padding: 0;
88
- font-size: var(--lp-fs-xs);
89
- font-weight: 600;
90
- }
91
-
92
- .cg-zone-shape-picker > div {
93
- display: grid;
94
- grid-template-columns: 1fr 1fr;
95
- gap: 4px;
96
- padding: 3px;
97
- border: 1px solid var(--lp-line);
98
- border-radius: var(--lp-r-sm);
99
- background: var(--lp-surface-2);
100
- }
101
-
102
- .cg-zone-shape-picker > span {
103
- color: var(--lp-muted);
104
- font-size: var(--lp-fs-2xs);
105
- }
106
-
107
- .cg-map-zone {
108
- fill-opacity: 0.18;
109
- stroke-opacity: 0.9;
110
- cursor: grab;
111
- }
112
-
113
- .cg-map-zone:active {
114
- cursor: grabbing;
115
- }
116
-
117
- @media (max-width: 1000px) {
118
- .cg-mapview > .cg-map-bar > .cg-route-popover.cg-route-nav-panel {
119
- width: min(336px, calc(100% - 48px));
120
- }
121
- }
122
-
123
- @media (prefers-reduced-motion: reduce) {
124
- .cg-mapview > .cg-map-bar > .cg-route-popover.cg-route-nav-panel {
125
- transition: none;
126
- }
127
- }
128
- .cg-date-boundary { display:grid; gap:6px; padding:10px 12px; font-size:var(--lp-fs-2xs); color:var(--lp-ink-muted); border-bottom:1px solid var(--lp-line); }
129
- .cg-date-boundary .cg-input,.cg-date-boundary .cg-select { width:100%; box-sizing:border-box; }
130
- .cg-top-n { display:flex; align-items:center; gap:10px; margin:0 0 10px; padding:8px 0; border:0; border-bottom:1px solid var(--lp-line); }
131
- .cg-top-n legend { font-size:var(--lp-fs-3xs); font-weight:650; color:var(--lp-ink-muted); }
132
- .cg-top-n label { display:flex; align-items:center; gap:4px; white-space:nowrap; }
133
- .cg-top-n .cg-input { width:62px; }
134
- .cg-drawer-launchers { position:absolute; z-index:3; right:12px; top:7px; display:flex; gap:6px; }
135
- .cg-workspace-drawer { position:absolute; z-index:30; top:0; right:0; bottom:0; width:min(360px,42vw); padding:16px; box-sizing:border-box; overflow:auto; background:var(--lp-surface); border-left:1px solid var(--lp-line); box-shadow:-12px 0 30px rgb(34 25 74 / 12%); }
136
- .cg-workspace-drawer header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
137
- .cg-workspace-drawer textarea { width:100%; min-height:220px; box-sizing:border-box; resize:vertical; margin-bottom:10px; }
138
- .cg-history-list { display:grid; gap:8px; padding:0; list-style:none; }
139
- .cg-history-list li { display:grid; grid-template-columns:1fr auto; gap:4px 10px; padding:10px; border:1px solid var(--lp-line); border-radius:8px; }
140
- @media (max-width:1050px) { .cg-workspace-drawer { width:min(330px,48vw); } .cg-drawer-launchers .cg-btn { padding-inline:8px; } }
141
- .cg-application-rail { flex:0 0 256px; width:256px; min-width:0; overflow:auto; padding:14px 12px; box-sizing:border-box; background:var(--lp-surface); border-left:1px solid var(--lp-line); border-right:1px solid var(--lp-line); }
142
- .cg-application-rail header { display:flex; align-items:center; justify-content:space-between; }
143
- .cg-application-context { color:var(--lp-ink-muted); font-size:var(--lp-fs-3xs); line-height:1.45; }
144
- .cg-application-list { display:grid; gap:8px; }
145
- .cg-application-card { border:1px solid var(--lp-line); border-radius:9px; padding:8px; background:var(--lp-surface); }
146
- .cg-application-open { display:grid; width:100%; gap:2px; padding:2px; border:0; background:none; color:inherit; font:inherit; text-align:left; cursor:pointer; }
147
- .cg-application-open small { color:var(--lp-ink-muted); text-transform:capitalize; }
148
- .cg-application-actions { display:flex; align-items:center; flex-wrap:wrap; gap:5px; margin-top:7px; }
149
- /* W45-T14/C6: one folder, one meaning. Legacy shape/tone metadata never changes this glyph. */
150
- .cg-folder-mark path { fill:var(--lp-purple-deep); stroke:var(--lp-purple-deep); }
151
- .home-app-glyph { background:var(--lp-primary); color:#fff; font-weight:700; }
152
- .cg-semantic-profile { margin:10px 12px 0; padding:8px 10px; border:1px solid var(--lp-line); border-radius:8px; font-size:var(--lp-fs-3xs); }
153
- .cg-semantic-row { display:grid; grid-template-columns:minmax(100px,1fr) minmax(130px,1.3fr); gap:4px 12px; padding:7px 0; border-top:1px solid var(--lp-line); }
154
- .cg-redacted { color:var(--lp-ink-muted); font-style:italic; }
155
- .cg-formula-help { max-width:340px; color:var(--lp-ink-muted); font-size:var(--lp-fs-3xs); }
 
1
+ /* Wave 45 Data, Map, Application, Fields, and Export surfaces.
2
+ This sheet consumes the root token dialect and is imported by CustomerGrid so lane D does not
3
+ create another global token seam. */
4
+
5
+ .cg-map-settings > .cg-map-route-toggle {
6
+ display: inline-flex;
7
+ align-items: center;
8
+ gap: 6px;
9
+ }
10
+
11
+ .cg-map-settings > .cg-map-route-toggle svg {
12
+ flex: 0 0 auto;
13
+ }
14
+
15
+ .cg-mapview > .cg-map-bar > .cg-route-popover.cg-route-nav-panel {
16
+ inset: 0 0 0 auto;
17
+ width: min(360px, 100%);
18
+ border-left: 1px solid var(--lp-line);
19
+ border-right: 0;
20
+ border-radius: 0;
21
+ background: var(--lp-surface);
22
+ color: var(--lp-ink);
23
+ z-index: var(--cg-z-mapchrome);
24
+ }
25
+
26
+ .cg-map-navigator-tabs {
27
+ display: grid;
28
+ grid-template-columns: 1fr 1fr;
29
+ gap: 4px;
30
+ margin-bottom: 8px;
31
+ padding: 3px;
32
+ border: 1px solid var(--lp-line);
33
+ border-radius: var(--lp-r-sm);
34
+ background: var(--lp-surface-2);
35
+ }
36
+
37
+ .cg-map-navigator-tabs > button,
38
+ .cg-zone-shape-picker button {
39
+ border: 0;
40
+ background: transparent;
41
+ font: inherit;
42
+ color: inherit;
43
+ min-height: 32px;
44
+ border-radius: var(--lp-r-sm);
45
+ cursor: pointer;
46
+ }
47
+
48
+ .cg-map-navigator-tabs > button[aria-selected="true"],
49
+ .cg-zone-shape-picker button[aria-pressed="true"] {
50
+ background: var(--lp-primary-tint);
51
+ color: var(--lp-primary);
52
+ font-weight: 600;
53
+ }
54
+
55
+ .cg-map-navigator-tabs > button:focus-visible,
56
+ .cg-zone-shape-picker button:focus-visible {
57
+ outline: 2px solid var(--lp-blue-deep);
58
+ outline-offset: 2px;
59
+ }
60
+
61
+ .cg-map-zone-option {
62
+ min-height: 42px;
63
+ }
64
+
65
+ .cg-map-zone-edit {
66
+ border: 0;
67
+ background: transparent;
68
+ font: inherit;
69
+ color: var(--lp-blue-deep);
70
+ cursor: pointer;
71
+ }
72
+
73
+ .cg-map-zone-edit:focus-visible {
74
+ outline: 2px solid var(--lp-blue-deep);
75
+ outline-offset: 2px;
76
+ }
77
+
78
+ .cg-zone-shape-picker {
79
+ display: grid;
80
+ gap: 6px;
81
+ margin: 0;
82
+ padding: 0;
83
+ border: 0;
84
+ }
85
+
86
+ .cg-zone-shape-picker legend {
87
+ padding: 0;
88
+ font-size: var(--lp-fs-xs);
89
+ font-weight: 600;
90
+ }
91
+
92
+ .cg-zone-shape-picker > div {
93
+ display: grid;
94
+ grid-template-columns: 1fr 1fr;
95
+ gap: 4px;
96
+ padding: 3px;
97
+ border: 1px solid var(--lp-line);
98
+ border-radius: var(--lp-r-sm);
99
+ background: var(--lp-surface-2);
100
+ }
101
+
102
+ .cg-zone-shape-picker > span {
103
+ color: var(--lp-muted);
104
+ font-size: var(--lp-fs-2xs);
105
+ }
106
+
107
+ .cg-map-zone {
108
+ fill-opacity: 0.18;
109
+ stroke-opacity: 0.9;
110
+ cursor: grab;
111
+ }
112
+
113
+ .cg-map-zone:active {
114
+ cursor: grabbing;
115
+ }
116
+
117
+ @media (max-width: 1000px) {
118
+ .cg-mapview > .cg-map-bar > .cg-route-popover.cg-route-nav-panel {
119
+ width: min(336px, calc(100% - 48px));
120
+ }
121
+ }
122
+
123
+ @media (prefers-reduced-motion: reduce) {
124
+ .cg-mapview > .cg-map-bar > .cg-route-popover.cg-route-nav-panel {
125
+ transition: none;
126
+ }
127
+ }
128
+ .cg-date-boundary { display:grid; gap:6px; padding:10px 12px; font-size:var(--lp-fs-2xs); color:var(--lp-ink-muted); border-bottom:1px solid var(--lp-line); }
129
+ .cg-date-boundary .cg-input,.cg-date-boundary .cg-select { width:100%; box-sizing:border-box; }
130
+ .cg-top-n { display:flex; align-items:center; gap:10px; margin:0 0 10px; padding:8px 0; border:0; border-bottom:1px solid var(--lp-line); }
131
+ .cg-top-n legend { font-size:var(--lp-fs-3xs); font-weight:650; color:var(--lp-ink-muted); }
132
+ .cg-top-n label { display:flex; align-items:center; gap:4px; white-space:nowrap; }
133
+ .cg-top-n .cg-input { width:62px; }
134
+ .cg-drawer-launchers { position:absolute; z-index:3; right:12px; top:7px; display:flex; gap:6px; }
135
+ .cg-workspace-drawer { position:absolute; z-index:30; top:0; right:0; bottom:0; width:min(360px,42vw); padding:16px; box-sizing:border-box; overflow:auto; background:var(--lp-surface); border-left:1px solid var(--lp-line); box-shadow:-12px 0 30px rgb(34 25 74 / 12%); }
136
+ .cg-workspace-drawer header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
137
+ .cg-workspace-drawer textarea { width:100%; min-height:220px; box-sizing:border-box; resize:vertical; margin-bottom:10px; }
138
+ .cg-history-list { display:grid; gap:8px; padding:0; list-style:none; }
139
+ .cg-history-list li { display:grid; grid-template-columns:1fr auto; gap:4px 10px; padding:10px; border:1px solid var(--lp-line); border-radius:8px; }
140
+ @media (max-width:1050px) { .cg-workspace-drawer { width:min(330px,48vw); } .cg-drawer-launchers .cg-btn { padding-inline:8px; } }
141
+ /* D-602 / W46-T10 (wave 46 hotfix, 2026-08-30) - the Applications RAIL's six rules are
142
+ deleted here. The rail itself was removed in wave 46 and its stylesheet outlived it:
143
+ `.cg-application-rail`, `-context`, `-list`, `-card`, `-open` and `-actions` matched
144
+ nothing in `src/` and nothing on the deployed build (0 `.cg-application-rail` nodes,
145
+ 0 "Applications" text nodes). The rest of this sheet is live and untouched. */
146
+ /* W45-T14/C6: one folder, one meaning. Legacy shape/tone metadata never changes this glyph. */
147
+ .cg-folder-mark path { fill:var(--lp-purple-deep); stroke:var(--lp-purple-deep); }
148
+ .home-app-glyph { background:var(--lp-primary); color:#fff; font-weight:700; }
149
+ .cg-semantic-profile { margin:10px 12px 0; padding:8px 10px; border:1px solid var(--lp-line); border-radius:8px; font-size:var(--lp-fs-3xs); }
150
+ .cg-semantic-row { display:grid; grid-template-columns:minmax(100px,1fr) minmax(130px,1.3fr); gap:4px 12px; padding:7px 0; border-top:1px solid var(--lp-line); }
151
+ .cg-redacted { color:var(--lp-ink-muted); font-style:italic; }
152
+ .cg-formula-help { max-width:340px; color:var(--lp-ink-muted); font-size:var(--lp-fs-3xs); }