@colixsystems/widget-sdk 0.331.1 → 0.333.0
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/README.md +17 -3
- package/dist/contract.cjs +13 -7
- package/dist/contract.js +13 -7
- package/dist/host.d.ts +12 -39
- package/dist/host.js +12 -8
- package/dist/index.d.ts +7 -3
- package/dist/linter.cjs +53 -0
- package/dist/linter.js +53 -0
- package/dist/navigation.cjs +164 -127
- package/dist/navigation.js +156 -126
- package/dist/stats-hooks.js +5 -2
- package/package.json +1 -1
- package/src/contract.js +13 -7
package/README.md
CHANGED
|
@@ -91,7 +91,21 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.333.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
95
|
+
|
|
96
|
+
### What's new in 0.332.0 (contract 1.271.0)
|
|
97
|
+
|
|
98
|
+
**Count rows per related row: `useDatastoreAggregate` groups by a relation column.** `groupBy` may now name a RELATION column, so "how many recipes per category" is one call. Each entry's `group` is the related row's id: match it to that table's `row.id` to show its name. A MANY_TO_MANY relation counts a row once per row it links to. Rows with no related row, or whose related row was deleted, form the `Uncategorized` group. Encrypted, array and file columns still cannot be grouped.
|
|
99
|
+
|
|
100
|
+
**New linter rule `aggregate-error-not-read` (severity `warning`).** A widget that reads an aggregate's `groups` or `buckets` but never its `error` shows a zero per group when the aggregate is refused or fails. Render `error.message` instead. Reading `error` under another name, or as `result.error`, satisfies it.
|
|
101
|
+
|
|
102
|
+
```jsx
|
|
103
|
+
const { groups, error } = useDatastoreAggregate(props.recipesTable, { groupBy: "category" });
|
|
104
|
+
const { data: categories } = useDatastoreQuery(props.categoriesTable);
|
|
105
|
+
if (error) return <Banner tone="error" message={error.message} />;
|
|
106
|
+
const countOf = (id) => groups.find((g) => g.group === id)?.count ?? 0;
|
|
107
|
+
// categories.map((c) => `${c.name}: ${countOf(c.id)}`)
|
|
108
|
+
```
|
|
95
109
|
|
|
96
110
|
### What's new in 0.331.1 (contract 1.270.0)
|
|
97
111
|
|
|
@@ -658,8 +672,8 @@ export default function DarkSwitch() {
|
|
|
658
672
|
**A themed chart: `<Chart>` and Design > Components > Charts.** `<Chart type data />` draws a bar (default), horizontal bar (`hbar`), line, area, donut or sparkline chart whose series colours, axis and gridline colours and bar corners come from the new `chart` theme scope; colours left unset follow the theme, primary first. It measures its own width, holds its place with a `Skeleton` while `loading`, shows an `EmptyState` when there is nothing to plot, adds a legend for a donut or several `series`, thins crowded labels, groups numbers for the app's language, and reads to a screen reader as one image with a summary and the values (`accessibilityLabel` replaces the summary, `moreText` translates its tail). `valueFormat="percent"` expects values already in percent. A chart type it does not draw (a scatter plot, a timeline) is still yours to draw with `react-native-svg`, in the same colours through `chartColors(theme)`.
|
|
659
673
|
|
|
660
674
|
```jsx
|
|
661
|
-
const { groups, loading } = useDatastoreAggregate(tableId, { groupBy: "city", sumColumn: "visits", order: "sum:desc", limit: 10 });
|
|
662
|
-
<Chart type="bar" loading={loading} valueFormat="compact"
|
|
675
|
+
const { groups, loading, error } = useDatastoreAggregate(tableId, { groupBy: "city", sumColumn: "visits", order: "sum:desc", limit: 10 });
|
|
676
|
+
error ? <Banner tone="error" message={error.message} /> : <Chart type="bar" loading={loading} valueFormat="compact"
|
|
663
677
|
data={groups.map((g) => ({ label: String(g.group), value: Number(g.sum) || 0 }))} />
|
|
664
678
|
```
|
|
665
679
|
|
package/dist/contract.cjs
CHANGED
|
@@ -2103,14 +2103,18 @@ const HOOKS = [
|
|
|
2103
2103
|
"(Monday) in `buckets`; `bucket` is \"day\" (default) or \"week\"; " +
|
|
2104
2104
|
"`from` / `to` are ISO dates (default: the 30 days, or 12 weeks, up to " +
|
|
2105
2105
|
"now), at most 31 buckets, empty ones as count 0 so a chart has no gaps. " +
|
|
2106
|
-
"BY A COLUMN (any other `groupBy`: a text, number, yes/no, date or
|
|
2107
|
-
"column): one entry per value in `groups`. A
|
|
2106
|
+
"BY A COLUMN (any other `groupBy`: a text, number, yes/no, date, user or " +
|
|
2107
|
+
"relation column): one entry per value in `groups`. A RELATION column's " +
|
|
2108
|
+
"`group` is the related row's id (match it to that table's row.id); a " +
|
|
2109
|
+
"MANY_TO_MANY row counts once per linked row. A USER column's `group` is the " +
|
|
2108
2110
|
"user id (resolve names with useDirectory({ ids })), so `order: \"count:desc\", " +
|
|
2109
2111
|
"limit: 10` ranks the ten people with the most rows. `order` is count, sum " +
|
|
2110
2112
|
"or group, then :asc or :desc (default: by value); `limit` is 1-1000. Rows " +
|
|
2111
2113
|
"with no value form one \"Uncategorized\" group; on a user column, leave " +
|
|
2112
|
-
"them out with a `nempty:` filter. Encrypted, array
|
|
2113
|
-
"
|
|
2114
|
+
"them out with a `nempty:` filter. Encrypted, array and file columns " +
|
|
2115
|
+
"cannot be grouped (VALIDATION). Check `error` first and render it: after " +
|
|
2116
|
+
"a refused or failed read `groups` may be empty or still hold the last " +
|
|
2117
|
+
"result, so never show it as a zero per group. `filter` takes the same shapes " +
|
|
2114
2118
|
"as useDatastoreQuery's, created_at ranges included. Pass null as the " +
|
|
2115
2119
|
"table until a bound table is known. `live: true` re-reads it when " +
|
|
2116
2120
|
"anyone else changes the table.",
|
|
@@ -2118,7 +2122,7 @@ const HOOKS = [
|
|
|
2118
2122
|
buckets:
|
|
2119
2123
|
"Array<{ date, count, sum }> // date = the bucket's start, YYYY-MM-DD; sum is 0 without sumColumn",
|
|
2120
2124
|
groups:
|
|
2121
|
-
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id",
|
|
2125
|
+
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id, a RELATION column's the related row id",
|
|
2122
2126
|
loading: "boolean",
|
|
2123
2127
|
fetching: "boolean",
|
|
2124
2128
|
error: "DatastoreError | null // { code, message, retryable } — offer Retry only when retryable; a signed-out viewer of a table only members read gets NOT_FOUND, retryable false",
|
|
@@ -6466,7 +6470,7 @@ const CONTRACT = deepFreeze({
|
|
|
6466
6470
|
// it. The app's global mobile quick bar is retired: it was a SELECTION
|
|
6467
6471
|
// over the global menu, and the rail and drawer list every menu page
|
|
6468
6472
|
// regardless, so nothing was reachable only through it. The bottom edge
|
|
6469
|
-
// belongs to a
|
|
6473
|
+
// belongs to a section menu's bottom navigation bar (`layout = BOTTOM_BAR`,
|
|
6470
6474
|
// REQ-NAV-LOCAL), chosen per page. `resolveFooterTokens` is unchanged —
|
|
6471
6475
|
// it is the bottom edge's token set and the surviving bar reads it.
|
|
6472
6476
|
// 1.113.0: additive (sc-7951) — `resolveFooterTokens` gains the bottom
|
|
@@ -7067,7 +7071,9 @@ const CONTRACT = deepFreeze({
|
|
|
7067
7071
|
// 1.270.0: additive (sc-17197) — a `datastoreTemplate` column may declare
|
|
7068
7072
|
// `defaultOnCreate: true`: a create stamps its default over any client
|
|
7069
7073
|
// value, and an update may still change it.
|
|
7070
|
-
|
|
7074
|
+
// 1.271.0: additive (sc-17551) — `useDatastoreAggregate` groups by a
|
|
7075
|
+
// relation column; new warning lint `aggregate-error-not-read`.
|
|
7076
|
+
version: "1.271.0",
|
|
7071
7077
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7072
7078
|
hooks: HOOKS,
|
|
7073
7079
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2098,14 +2098,18 @@ const HOOKS = [
|
|
|
2098
2098
|
"(Monday) in `buckets`; `bucket` is \"day\" (default) or \"week\"; " +
|
|
2099
2099
|
"`from` / `to` are ISO dates (default: the 30 days, or 12 weeks, up to " +
|
|
2100
2100
|
"now), at most 31 buckets, empty ones as count 0 so a chart has no gaps. " +
|
|
2101
|
-
"BY A COLUMN (any other `groupBy`: a text, number, yes/no, date or
|
|
2102
|
-
"column): one entry per value in `groups`. A
|
|
2101
|
+
"BY A COLUMN (any other `groupBy`: a text, number, yes/no, date, user or " +
|
|
2102
|
+
"relation column): one entry per value in `groups`. A RELATION column's " +
|
|
2103
|
+
"`group` is the related row's id (match it to that table's row.id); a " +
|
|
2104
|
+
"MANY_TO_MANY row counts once per linked row. A USER column's `group` is the " +
|
|
2103
2105
|
"user id (resolve names with useDirectory({ ids })), so `order: \"count:desc\", " +
|
|
2104
2106
|
"limit: 10` ranks the ten people with the most rows. `order` is count, sum " +
|
|
2105
2107
|
"or group, then :asc or :desc (default: by value); `limit` is 1-1000. Rows " +
|
|
2106
2108
|
"with no value form one \"Uncategorized\" group; on a user column, leave " +
|
|
2107
|
-
"them out with a `nempty:` filter. Encrypted, array
|
|
2108
|
-
"
|
|
2109
|
+
"them out with a `nempty:` filter. Encrypted, array and file columns " +
|
|
2110
|
+
"cannot be grouped (VALIDATION). Check `error` first and render it: after " +
|
|
2111
|
+
"a refused or failed read `groups` may be empty or still hold the last " +
|
|
2112
|
+
"result, so never show it as a zero per group. `filter` takes the same shapes " +
|
|
2109
2113
|
"as useDatastoreQuery's, created_at ranges included. Pass null as the " +
|
|
2110
2114
|
"table until a bound table is known. `live: true` re-reads it when " +
|
|
2111
2115
|
"anyone else changes the table.",
|
|
@@ -2113,7 +2117,7 @@ const HOOKS = [
|
|
|
2113
2117
|
buckets:
|
|
2114
2118
|
"Array<{ date, count, sum }> // date = the bucket's start, YYYY-MM-DD; sum is 0 without sumColumn",
|
|
2115
2119
|
groups:
|
|
2116
|
-
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id",
|
|
2120
|
+
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id, a RELATION column's the related row id",
|
|
2117
2121
|
loading: "boolean",
|
|
2118
2122
|
fetching: "boolean",
|
|
2119
2123
|
error: "DatastoreError | null // { code, message, retryable } — offer Retry only when retryable; a signed-out viewer of a table only members read gets NOT_FOUND, retryable false",
|
|
@@ -6461,7 +6465,7 @@ const CONTRACT = deepFreeze({
|
|
|
6461
6465
|
// it. The app's global mobile quick bar is retired: it was a SELECTION
|
|
6462
6466
|
// over the global menu, and the rail and drawer list every menu page
|
|
6463
6467
|
// regardless, so nothing was reachable only through it. The bottom edge
|
|
6464
|
-
// belongs to a
|
|
6468
|
+
// belongs to a section menu's bottom navigation bar (`layout = BOTTOM_BAR`,
|
|
6465
6469
|
// REQ-NAV-LOCAL), chosen per page. `resolveFooterTokens` is unchanged —
|
|
6466
6470
|
// it is the bottom edge's token set and the surviving bar reads it.
|
|
6467
6471
|
// 1.113.0: additive (sc-7951) — `resolveFooterTokens` gains the bottom
|
|
@@ -7062,7 +7066,9 @@ const CONTRACT = deepFreeze({
|
|
|
7062
7066
|
// 1.270.0: additive (sc-17197) — a `datastoreTemplate` column may declare
|
|
7063
7067
|
// `defaultOnCreate: true`: a create stamps its default over any client
|
|
7064
7068
|
// value, and an update may still change it.
|
|
7065
|
-
|
|
7069
|
+
// 1.271.0: additive (sc-17551) — `useDatastoreAggregate` groups by a
|
|
7070
|
+
// relation column; new warning lint `aggregate-error-not-read`.
|
|
7071
|
+
version: "1.271.0",
|
|
7066
7072
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7067
7073
|
hooks: HOOKS,
|
|
7068
7074
|
primitives: PRIMITIVES,
|
package/dist/host.d.ts
CHANGED
|
@@ -395,45 +395,18 @@ export interface SidebarTokens {
|
|
|
395
395
|
*/
|
|
396
396
|
export function resolveSidebarTokens(theme: unknown): SidebarTokens;
|
|
397
397
|
|
|
398
|
-
/**
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
items: Array<SidebarUnfoldItem & { current: boolean }>;
|
|
411
|
-
standalone: boolean;
|
|
412
|
-
inside: boolean;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/** Where a page's `SIDEBAR` local menu unfolds (REQ-NAV-LOCAL, sc-7696).
|
|
416
|
-
* `under` is the global menu entry the visitor's own section hangs beneath,
|
|
417
|
-
* or null when they are in none. `standalone` marks the case where the global
|
|
418
|
-
* menu does not list the page, so the page itself is the entry. `trees` is
|
|
419
|
-
* every section an entry carries, in menu order, so an entry can offer its
|
|
420
|
-
* menu from any page; a `standalone` tree comes last. */
|
|
421
|
-
export interface SidebarUnfold {
|
|
422
|
-
under: string | null;
|
|
423
|
-
items: Array<SidebarUnfoldItem & { current: boolean }>;
|
|
424
|
-
standalone: boolean;
|
|
425
|
-
trees: SidebarUnfoldTree[];
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/** Resolve where the viewed page's local menu unfolds in the sidebar and the
|
|
429
|
-
* drawer. The one derivation both hosts read: the Player calls it per render,
|
|
430
|
-
* the compiler once per screen, so the rail and the exported drawer cannot
|
|
431
|
-
* disagree. */
|
|
432
|
-
export function resolveSidebarUnfold(input: {
|
|
433
|
-
entries?: readonly string[];
|
|
434
|
-
active?: string | null;
|
|
435
|
-
sections?: Record<string, { menu?: unknown; items?: readonly unknown[] }>;
|
|
436
|
-
}): SidebarUnfold;
|
|
398
|
+
/** A stored menu item with neither a page nor a link: a sub-menu (sc-14098). */
|
|
399
|
+
export function isSubMenuItem(item: unknown): boolean;
|
|
400
|
+
|
|
401
|
+
/** A menu's flat entries as both hosts draw them (sc-14098): the top-level
|
|
402
|
+
* ones in order, a sub-menu returned with its own entries as `children`.
|
|
403
|
+
* An empty sub-menu is dropped; an entry naming no sub-menu of the list
|
|
404
|
+
* stands at the top level. `of` reads `id`, `parent_id` and `submenu` when
|
|
405
|
+
* they live inside the entry. */
|
|
406
|
+
export function menuTree<T extends object>(
|
|
407
|
+
entries: readonly T[],
|
|
408
|
+
options?: { of?: (entry: T) => { id?: unknown; parent_id?: unknown; submenu?: unknown } },
|
|
409
|
+
): Array<T | (T & { children: T[] })>;
|
|
437
410
|
|
|
438
411
|
|
|
439
412
|
/** The top app bar's resolved tokens. `tintColor` and `titleColor` are separate
|
package/dist/host.js
CHANGED
|
@@ -93,13 +93,9 @@ export { bannerScopeDefaults } from "./banner-tokens.js";
|
|
|
93
93
|
// row above the side panel holds, in what order, and the box it sits in. The
|
|
94
94
|
// same bar is drawn by the desktop top bar, the phone header and the exported
|
|
95
95
|
// app's screen header, and each hard-coded its own row before this.
|
|
96
|
-
// REQ-NAV-LOCAL (sc-
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
// chromes derive the same tree from the same code.
|
|
100
|
-
// REQ-NAV-LOCAL (sc-8901): `resolveLocalNavModel` answers WHICH model a page
|
|
101
|
-
// wears in one device view, so the same menu can be a bottom bar on a phone and
|
|
102
|
-
// unfold in the rail on a desktop.
|
|
96
|
+
// REQ-NAV-LOCAL (sc-8901, sc-12397): `resolveLocalNavModel` answers WHICH
|
|
97
|
+
// model a menu wears in one device view, so the same menu can be a bottom
|
|
98
|
+
// bar on a phone and a tab row on a desktop.
|
|
103
99
|
export {
|
|
104
100
|
normaliseNavigation,
|
|
105
101
|
menuItemCap,
|
|
@@ -122,9 +118,17 @@ export {
|
|
|
122
118
|
MAX_TOP_STRIPE_OFFSET_Y_PX,
|
|
123
119
|
DEFAULT_TOP_STRIPE_HEIGHT_PX,
|
|
124
120
|
DEFAULT_TOP_STRIPE_PADDING_X_PX,
|
|
125
|
-
|
|
121
|
+
// sc-14098: a menu's sub-menus, grouped the one way both hosts draw them.
|
|
122
|
+
isSubMenuItem,
|
|
123
|
+
menuTree,
|
|
126
124
|
resolveLocalNavModel,
|
|
127
125
|
drawsLocalNavAnywhere,
|
|
126
|
+
mainMenuAppearsOn,
|
|
127
|
+
LOCAL_NAV_POSITIONS,
|
|
128
|
+
localNavPosition,
|
|
129
|
+
resolvePageBars,
|
|
130
|
+
drawsTopNavigation,
|
|
131
|
+
topNavigationPageIds,
|
|
128
132
|
isDarkSurface,
|
|
129
133
|
resolveAppLogo,
|
|
130
134
|
} from "./navigation.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1312,7 +1312,7 @@ export interface AggregateBucketSpec {
|
|
|
1312
1312
|
}
|
|
1313
1313
|
|
|
1314
1314
|
export interface AggregateGroupSpec {
|
|
1315
|
-
/** A text, number, yes/no, date or
|
|
1315
|
+
/** A text, number, yes/no, date, user or relation column. */
|
|
1316
1316
|
groupBy: string;
|
|
1317
1317
|
/** A plain number column to add up per group. */
|
|
1318
1318
|
sumColumn?: string;
|
|
@@ -1334,7 +1334,10 @@ export interface AggregateBucket {
|
|
|
1334
1334
|
}
|
|
1335
1335
|
|
|
1336
1336
|
export interface AggregateGroup {
|
|
1337
|
-
/**
|
|
1337
|
+
/**
|
|
1338
|
+
* The value; a user column's user id; a relation column's related row id
|
|
1339
|
+
* (match it to that table's `row.id`); "Uncategorized" for rows with none.
|
|
1340
|
+
*/
|
|
1338
1341
|
group: string;
|
|
1339
1342
|
count: number;
|
|
1340
1343
|
/** 0 unless `sumColumn` was given. */
|
|
@@ -5578,7 +5581,8 @@ export interface ChartSeries {
|
|
|
5578
5581
|
* for several series, and gives a screen reader a summary and the values.
|
|
5579
5582
|
*
|
|
5580
5583
|
* @example
|
|
5581
|
-
* const { groups, loading } = useDatastoreAggregate(tableId, { groupBy: "city", sumColumn: "visits" });
|
|
5584
|
+
* const { groups, loading, error } = useDatastoreAggregate(tableId, { groupBy: "city", sumColumn: "visits" });
|
|
5585
|
+
* if (error) return <Banner tone="error" message={error.message} />;
|
|
5582
5586
|
* <Chart type="bar" loading={loading}
|
|
5583
5587
|
* data={groups.map((g) => ({ label: String(g.group), value: Number(g.sum) || 0 }))} />
|
|
5584
5588
|
*/
|
package/dist/linter.cjs
CHANGED
|
@@ -2037,6 +2037,58 @@ function _readErrorHandlingRules(source) {
|
|
|
2037
2037
|
];
|
|
2038
2038
|
}
|
|
2039
2039
|
|
|
2040
|
+
// sc-17551 — soft warning: an aggregate a widget reads without its `error`
|
|
2041
|
+
// shows a zero per group, or stale counts, when the server refuses or fails it.
|
|
2042
|
+
// Reading `error` (renamed, as `agg.error`, or re-destructured from `agg`),
|
|
2043
|
+
// handing the whole result on, or a rest spread satisfies it. One pass indexes
|
|
2044
|
+
// the reads, so many bindings stay linear. Known limits: `.groups` read
|
|
2045
|
+
// straight off the call, `catch (error)`, and one file's two components.
|
|
2046
|
+
const AGGREGATE_BINDING_RE = /\b(?:const|let|var)\s+([\w$]+|\{[^{}]*\})\s*=\s*useDatastoreAggregate\s*\(/g;
|
|
2047
|
+
const IDENT = String.raw`[A-Za-z_$][\w$]*`;
|
|
2048
|
+
|
|
2049
|
+
function _aggregateErrorRules(source) {
|
|
2050
|
+
const code = _stripNonCode(source);
|
|
2051
|
+
const calls = [...code.matchAll(AGGREGATE_BINDING_RE)];
|
|
2052
|
+
if (calls.length === 0) return [];
|
|
2053
|
+
// Every hook destructure blanked: another hook's own `error`, and a
|
|
2054
|
+
// binding's own field names, are not reads.
|
|
2055
|
+
const body = code.replace(/\{[^{}]*\}\s*=\s*use\w+\s*\(/g, (m) => " ".repeat(m.length));
|
|
2056
|
+
const words = new Set(body.match(new RegExp(String.raw`(?<![\w$.])${IDENT}`, "g")));
|
|
2057
|
+
const members = new Set(
|
|
2058
|
+
[...body.matchAll(new RegExp(String.raw`(?<![\w$.])(${IDENT})\s*\??\.\s*(${IDENT})`, "g"))].map((m) => `${m[1]}.${m[2]}`),
|
|
2059
|
+
);
|
|
2060
|
+
// `={agg}`, `...agg`, or `= agg;` (an alias or a re-destructure).
|
|
2061
|
+
const handedOn = new Set(
|
|
2062
|
+
[
|
|
2063
|
+
...body.matchAll(
|
|
2064
|
+
new RegExp(String.raw`=\{\s*(${IDENT})\s*\}|\.\.\.\s*(${IDENT})|(?<![=!<>])=\s*(${IDENT})\s*(?:;|$)`, "gm"),
|
|
2065
|
+
),
|
|
2066
|
+
].map((m) => m[1] || m[2] || m[3]),
|
|
2067
|
+
);
|
|
2068
|
+
const findings = [];
|
|
2069
|
+
const lineAt = _lineCounter(code);
|
|
2070
|
+
const sourceLines = source.split(/\r?\n/);
|
|
2071
|
+
for (const call of calls) {
|
|
2072
|
+
const binding = call[1];
|
|
2073
|
+
if (binding.includes("...") || handedOn.has(binding)) continue;
|
|
2074
|
+
const locals = binding.startsWith("{") ? _destructuredLocals(binding) : null;
|
|
2075
|
+
const reads = (field) => (locals ? !!locals[field] && words.has(locals[field]) : members.has(`${binding}.${field}`));
|
|
2076
|
+
if ((!reads("groups") && !reads("buckets")) || reads("error")) continue;
|
|
2077
|
+
const line = lineAt(call.index);
|
|
2078
|
+
findings.push({
|
|
2079
|
+
rule: "aggregate-error-not-read",
|
|
2080
|
+
severity: "warning",
|
|
2081
|
+
label:
|
|
2082
|
+
`reads useDatastoreAggregate() without its error, so a refused or failed ` +
|
|
2083
|
+
`aggregate shows a zero per group. Render error.message (a Banner) in ` +
|
|
2084
|
+
`place of the counts when error is set.`,
|
|
2085
|
+
line,
|
|
2086
|
+
snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
return findings;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2040
2092
|
// sc-5206 — soft warning: a `useDatastoreQuery` argument built from a raw
|
|
2041
2093
|
// `const q = useMemo(() => ({...}), [...])` re-fetches in a loop the moment
|
|
2042
2094
|
// the deps array is wrong (sc-1579's volatile-query gate exists because of
|
|
@@ -3748,6 +3800,7 @@ function lintSource(source, options) {
|
|
|
3748
3800
|
findings.push(..._paymentErrorHandlingRules(source));
|
|
3749
3801
|
findings.push(..._datastoreErrorHandlingRules(source));
|
|
3750
3802
|
findings.push(..._readErrorHandlingRules(source));
|
|
3803
|
+
findings.push(..._aggregateErrorRules(source));
|
|
3751
3804
|
findings.push(..._bankIdOrderRules(source));
|
|
3752
3805
|
// sc-5206 — soft warnings steering a widget toward the two new hooks.
|
|
3753
3806
|
findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
|
package/dist/linter.js
CHANGED
|
@@ -2032,6 +2032,58 @@ function _readErrorHandlingRules(source) {
|
|
|
2032
2032
|
];
|
|
2033
2033
|
}
|
|
2034
2034
|
|
|
2035
|
+
// sc-17551 — soft warning: an aggregate a widget reads without its `error`
|
|
2036
|
+
// shows a zero per group, or stale counts, when the server refuses or fails it.
|
|
2037
|
+
// Reading `error` (renamed, as `agg.error`, or re-destructured from `agg`),
|
|
2038
|
+
// handing the whole result on, or a rest spread satisfies it. One pass indexes
|
|
2039
|
+
// the reads, so many bindings stay linear. Known limits: `.groups` read
|
|
2040
|
+
// straight off the call, `catch (error)`, and one file's two components.
|
|
2041
|
+
const AGGREGATE_BINDING_RE = /\b(?:const|let|var)\s+([\w$]+|\{[^{}]*\})\s*=\s*useDatastoreAggregate\s*\(/g;
|
|
2042
|
+
const IDENT = String.raw`[A-Za-z_$][\w$]*`;
|
|
2043
|
+
|
|
2044
|
+
function _aggregateErrorRules(source) {
|
|
2045
|
+
const code = _stripNonCode(source);
|
|
2046
|
+
const calls = [...code.matchAll(AGGREGATE_BINDING_RE)];
|
|
2047
|
+
if (calls.length === 0) return [];
|
|
2048
|
+
// Every hook destructure blanked: another hook's own `error`, and a
|
|
2049
|
+
// binding's own field names, are not reads.
|
|
2050
|
+
const body = code.replace(/\{[^{}]*\}\s*=\s*use\w+\s*\(/g, (m) => " ".repeat(m.length));
|
|
2051
|
+
const words = new Set(body.match(new RegExp(String.raw`(?<![\w$.])${IDENT}`, "g")));
|
|
2052
|
+
const members = new Set(
|
|
2053
|
+
[...body.matchAll(new RegExp(String.raw`(?<![\w$.])(${IDENT})\s*\??\.\s*(${IDENT})`, "g"))].map((m) => `${m[1]}.${m[2]}`),
|
|
2054
|
+
);
|
|
2055
|
+
// `={agg}`, `...agg`, or `= agg;` (an alias or a re-destructure).
|
|
2056
|
+
const handedOn = new Set(
|
|
2057
|
+
[
|
|
2058
|
+
...body.matchAll(
|
|
2059
|
+
new RegExp(String.raw`=\{\s*(${IDENT})\s*\}|\.\.\.\s*(${IDENT})|(?<![=!<>])=\s*(${IDENT})\s*(?:;|$)`, "gm"),
|
|
2060
|
+
),
|
|
2061
|
+
].map((m) => m[1] || m[2] || m[3]),
|
|
2062
|
+
);
|
|
2063
|
+
const findings = [];
|
|
2064
|
+
const lineAt = _lineCounter(code);
|
|
2065
|
+
const sourceLines = source.split(/\r?\n/);
|
|
2066
|
+
for (const call of calls) {
|
|
2067
|
+
const binding = call[1];
|
|
2068
|
+
if (binding.includes("...") || handedOn.has(binding)) continue;
|
|
2069
|
+
const locals = binding.startsWith("{") ? _destructuredLocals(binding) : null;
|
|
2070
|
+
const reads = (field) => (locals ? !!locals[field] && words.has(locals[field]) : members.has(`${binding}.${field}`));
|
|
2071
|
+
if ((!reads("groups") && !reads("buckets")) || reads("error")) continue;
|
|
2072
|
+
const line = lineAt(call.index);
|
|
2073
|
+
findings.push({
|
|
2074
|
+
rule: "aggregate-error-not-read",
|
|
2075
|
+
severity: "warning",
|
|
2076
|
+
label:
|
|
2077
|
+
`reads useDatastoreAggregate() without its error, so a refused or failed ` +
|
|
2078
|
+
`aggregate shows a zero per group. Render error.message (a Banner) in ` +
|
|
2079
|
+
`place of the counts when error is set.`,
|
|
2080
|
+
line,
|
|
2081
|
+
snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
return findings;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2035
2087
|
// sc-5206 — soft warning: a `useDatastoreQuery` argument built from a raw
|
|
2036
2088
|
// `const q = useMemo(() => ({...}), [...])` re-fetches in a loop the moment
|
|
2037
2089
|
// the deps array is wrong (sc-1579's volatile-query gate exists because of
|
|
@@ -3743,6 +3795,7 @@ export function lintSource(source, options) {
|
|
|
3743
3795
|
findings.push(..._paymentErrorHandlingRules(source));
|
|
3744
3796
|
findings.push(..._datastoreErrorHandlingRules(source));
|
|
3745
3797
|
findings.push(..._readErrorHandlingRules(source));
|
|
3798
|
+
findings.push(..._aggregateErrorRules(source));
|
|
3746
3799
|
findings.push(..._bankIdOrderRules(source));
|
|
3747
3800
|
// sc-5206 — soft warnings steering a widget toward the two new hooks.
|
|
3748
3801
|
findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
|
package/dist/navigation.cjs
CHANGED
|
@@ -67,7 +67,7 @@ function menuItemCap(menuType) {
|
|
|
67
67
|
// navigation bar is drawn from.
|
|
68
68
|
//
|
|
69
69
|
// sc-7753: the global quick bar these tokens were introduced for is retired;
|
|
70
|
-
// the bar that reads them now is
|
|
70
|
+
// the bar that reads them now is a section menu's (`layout = BOTTOM_BAR`).
|
|
71
71
|
//
|
|
72
72
|
// sc-8033: the block is SELF-CONTAINED — it reads `theme.footer` and nothing
|
|
73
73
|
// else. Every colour used to fall back to the rail's, so restyling the sidebar
|
|
@@ -688,121 +688,59 @@ function resolveTopBarTokens(theme) {
|
|
|
688
688
|
}
|
|
689
689
|
|
|
690
690
|
/**
|
|
691
|
-
*
|
|
691
|
+
* sc-14098 — is this stored menu item a sub-menu? One with neither a page nor
|
|
692
|
+
* a link; it holds the items whose `parent_id` names it.
|
|
692
693
|
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
* saved menu, so the tree hangs in the same place from every page of the
|
|
706
|
-
* section. When the global menu lists no such page, the section's own page
|
|
707
|
-
* becomes a top-level entry (`standalone`) for as long as the visitor is
|
|
708
|
-
* inside it, so the menu is never lost — a section off the menu is exactly
|
|
709
|
-
* the case that would otherwise render blank.
|
|
694
|
+
* @param {object|null|undefined} item — a menu item as the API serves it.
|
|
695
|
+
* @returns {boolean}
|
|
696
|
+
*/
|
|
697
|
+
function isSubMenuItem(item) {
|
|
698
|
+
return isPlainObject(item) && !item.page_id && !item.url;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* sc-14098 — a menu's flat entries as both hosts draw them: the top-level
|
|
703
|
+
* ones in order, each sub-menu carrying its own as `children`. The one
|
|
704
|
+
* grouping the web chrome and the compiler read, so a page cannot sit in a
|
|
705
|
+
* sub-menu on one host and at the top level on the other (§8).
|
|
710
706
|
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
707
|
+
* An entry naming no sub-menu of the list stands at the top level; a
|
|
708
|
+
* sub-menu left with nothing in it (its pages hidden from this visitor, say)
|
|
709
|
+
* is dropped rather than drawn as a heading over nothing.
|
|
714
710
|
*
|
|
715
|
-
* @param {
|
|
716
|
-
*
|
|
717
|
-
* `
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
* `under` is null when the visitor is in no section; when `standalone` it
|
|
722
|
-
* names the section's own page, which the host draws as the entry. Each
|
|
723
|
-
* item is returned with a `current` flag rather than leaving each host to
|
|
724
|
-
* recompute it. `trees` lists `{ under, items, standalone, inside }` in menu
|
|
725
|
-
* order, a `standalone` one last; `inside` marks the visitor's own.
|
|
711
|
+
* @param {Array<object>} entries — in menu order, each with an `id`.
|
|
712
|
+
* @param {{ of?: (entry: object) => { id?: unknown, parent_id?: unknown, submenu?: unknown } }} [options]
|
|
713
|
+
* `of` reads an entry's `id`, `parent_id` and `submenu` flag when they
|
|
714
|
+
* live inside it (the web chrome's `{ page, isActive }` rows).
|
|
715
|
+
* @returns {Array<object>} the top-level entries; a sub-menu is returned as
|
|
716
|
+
* `{ ...entry, children }`, every other entry as it came.
|
|
726
717
|
*/
|
|
727
|
-
function
|
|
728
|
-
const
|
|
729
|
-
const
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
const
|
|
735
|
-
return
|
|
736
|
-
};
|
|
737
|
-
const lists = (key) => {
|
|
738
|
-
const candidate = sectionAt(key);
|
|
739
|
-
return (
|
|
740
|
-
Boolean(candidate) &&
|
|
741
|
-
candidate.items.some(
|
|
742
|
-
(item) => isPlainObject(item) && item.key === viewed,
|
|
743
|
-
)
|
|
744
|
-
);
|
|
745
|
-
};
|
|
746
|
-
// The page's own section wins; otherwise the section whose menu lists it,
|
|
747
|
-
// preferring one a global entry carries so the tree hangs where it always
|
|
748
|
-
// does. Both are the same section from the visitor's side.
|
|
749
|
-
const section = viewed
|
|
750
|
-
? sectionAt(viewed) ||
|
|
751
|
-
sectionAt(order.find(lists)) ||
|
|
752
|
-
sectionAt(Object.keys(bank).find(lists))
|
|
753
|
-
: null;
|
|
754
|
-
const mark = (items) =>
|
|
755
|
-
items.map((item) => ({
|
|
756
|
-
...(isPlainObject(item) ? item : {}),
|
|
757
|
-
current:
|
|
758
|
-
viewed !== null &&
|
|
759
|
-
isPlainObject(item) &&
|
|
760
|
-
typeof item.key === "string" &&
|
|
761
|
-
item.key === viewed,
|
|
762
|
-
}));
|
|
763
|
-
// A saved menu hangs under the FIRST global entry carrying it, so two
|
|
764
|
-
// entries sharing one menu never draw it twice.
|
|
765
|
-
const claimed = [];
|
|
766
|
-
const trees = [];
|
|
767
|
-
for (const key of order) {
|
|
768
|
-
if (!isPlainObject(bank[key])) continue;
|
|
769
|
-
const { menu } = bank[key];
|
|
770
|
-
if (claimed.includes(menu)) continue;
|
|
771
|
-
claimed.push(menu);
|
|
772
|
-
// An unusable key still owns its menu: nothing may hang it elsewhere.
|
|
773
|
-
if (typeof key !== "string" || !key) continue;
|
|
774
|
-
const inside = Boolean(section) && menu === section.menu;
|
|
775
|
-
const own = inside ? section : sectionAt(key);
|
|
776
|
-
if (!own) continue;
|
|
777
|
-
trees.push({ under: key, items: mark(own.items), standalone: false, inside });
|
|
778
|
-
}
|
|
779
|
-
if (!section) return { under: null, items: [], standalone: false, trees };
|
|
780
|
-
const owned = trees.find((tree) => tree.inside);
|
|
781
|
-
if (owned) {
|
|
782
|
-
return { under: owned.under, items: owned.items, standalone: false, trees };
|
|
783
|
-
}
|
|
784
|
-
const alone = {
|
|
785
|
-
under: section.key,
|
|
786
|
-
items: mark(section.items),
|
|
787
|
-
standalone: true,
|
|
788
|
-
inside: true,
|
|
789
|
-
};
|
|
790
|
-
return {
|
|
791
|
-
under: alone.under,
|
|
792
|
-
items: alone.items,
|
|
793
|
-
standalone: true,
|
|
794
|
-
trees: [...trees, alone],
|
|
718
|
+
function menuTree(entries, { of = (entry) => entry } = {}) {
|
|
719
|
+
const list = Array.isArray(entries) ? entries.filter(isPlainObject) : [];
|
|
720
|
+
const read = (entry) => (isPlainObject(of(entry)) ? of(entry) : {});
|
|
721
|
+
const subMenuIds = new Set(
|
|
722
|
+
list.filter((entry) => read(entry).submenu === true).map((entry) => read(entry).id),
|
|
723
|
+
);
|
|
724
|
+
const parentOf = (entry) => {
|
|
725
|
+
const { parent_id: parent, submenu } = read(entry);
|
|
726
|
+
return submenu !== true && typeof parent === "string" && subMenuIds.has(parent) ? parent : null;
|
|
795
727
|
};
|
|
728
|
+
return list
|
|
729
|
+
.filter((entry) => parentOf(entry) === null)
|
|
730
|
+
.flatMap((entry) => {
|
|
731
|
+
if (read(entry).submenu !== true) return [entry];
|
|
732
|
+
const children = list.filter((child) => parentOf(child) === read(entry).id);
|
|
733
|
+
return children.length ? [{ ...entry, children }] : [];
|
|
734
|
+
});
|
|
796
735
|
}
|
|
797
736
|
|
|
798
737
|
/**
|
|
799
|
-
* REQ-NAV-LOCAL (sc-8901) —
|
|
800
|
-
*
|
|
801
|
-
*
|
|
738
|
+
* REQ-NAV-LOCAL (sc-8901, sc-12397) — how a menu is drawn in ONE device
|
|
739
|
+
* view, so the same menu can be a bottom bar on a phone and a tab row on a
|
|
740
|
+
* desktop. Since sc-12397 the MENU owns this, not each page.
|
|
802
741
|
*
|
|
803
|
-
* `
|
|
804
|
-
*
|
|
805
|
-
* renders identically at every width. The cascade is REQ-LAY-07's — the one the
|
|
742
|
+
* `layout` is the MOBILE value and the base of the cascade; a wider view left
|
|
743
|
+
* null follows the narrower one. The cascade is REQ-LAY-07's — the one the
|
|
806
744
|
* layout grid and every responsive widget prop already use — because a page's
|
|
807
745
|
* chrome and its content must not disagree about what a tablet is.
|
|
808
746
|
*
|
|
@@ -810,21 +748,21 @@ function resolveSidebarUnfold(input) {
|
|
|
810
748
|
* host's own switch decides what it can draw, so a kind a newer backend allows
|
|
811
749
|
* cascades correctly here instead of being flattened to `NONE` on the way.
|
|
812
750
|
*
|
|
813
|
-
* @param {object|null|undefined}
|
|
814
|
-
* optionally, `
|
|
751
|
+
* @param {object|null|undefined} menu — a menu carrying `layout` and,
|
|
752
|
+
* optionally, `layout_tablet` / `layout_desktop`. No menu draws nothing.
|
|
815
753
|
* @param {"mobile"|"tablet"|"desktop"} view — the device view being drawn.
|
|
816
|
-
* @returns {string} the model for that view; `NONE` when the
|
|
754
|
+
* @returns {string} the model for that view; `NONE` when the menu sets none.
|
|
817
755
|
*/
|
|
818
|
-
function resolveLocalNavModel(
|
|
756
|
+
function resolveLocalNavModel(menu, view) {
|
|
819
757
|
const at = (key) => {
|
|
820
|
-
const value = isPlainObject(
|
|
758
|
+
const value = isPlainObject(menu) ? menu[key] : null;
|
|
821
759
|
return typeof value === "string" && value ? value : null;
|
|
822
760
|
};
|
|
823
|
-
const mobile = at("
|
|
761
|
+
const mobile = at("layout") || "NONE";
|
|
824
762
|
if (view === "desktop") {
|
|
825
|
-
return at("
|
|
763
|
+
return at("layout_desktop") || at("layout_tablet") || mobile;
|
|
826
764
|
}
|
|
827
|
-
if (view === "tablet") return at("
|
|
765
|
+
if (view === "tablet") return at("layout_tablet") || mobile;
|
|
828
766
|
return mobile;
|
|
829
767
|
}
|
|
830
768
|
|
|
@@ -834,25 +772,117 @@ function resolveLocalNavModel(page, view) {
|
|
|
834
772
|
const LOCAL_NAV_VIEWS = ["mobile", "tablet", "desktop"];
|
|
835
773
|
|
|
836
774
|
/**
|
|
837
|
-
* REQ-NAV-LOCAL (sc-8901) — does this
|
|
775
|
+
* REQ-NAV-LOCAL (sc-8901) — does this menu draw a bar in ANY device view?
|
|
838
776
|
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
* `local_nav !== "NONE"` alone would miss a page that carries a bar only on the
|
|
842
|
-
* wider views.
|
|
777
|
+
* Beside the cascade it is derived from, so the API, the export's screen bake
|
|
778
|
+
* and the Studio cannot disagree about which pages show a bar.
|
|
843
779
|
*
|
|
844
|
-
*
|
|
845
|
-
* bake and Copy Workspace cannot disagree about which pages have a bar.
|
|
846
|
-
*
|
|
847
|
-
* @param {object|null|undefined} page — a page row.
|
|
780
|
+
* @param {object|null|undefined} menu — a menu row, or its layout fields.
|
|
848
781
|
* @returns {boolean}
|
|
849
782
|
*/
|
|
850
|
-
function drawsLocalNavAnywhere(
|
|
783
|
+
function drawsLocalNavAnywhere(menu) {
|
|
851
784
|
return LOCAL_NAV_VIEWS.some(
|
|
852
|
-
(view) => resolveLocalNavModel(
|
|
785
|
+
(view) => resolveLocalNavModel(menu, view) !== "NONE",
|
|
853
786
|
);
|
|
854
787
|
}
|
|
855
788
|
|
|
789
|
+
/**
|
|
790
|
+
* sc-12426 — does the app's main menu frame this page? A page it leaves out
|
|
791
|
+
* is full screen. Asked by the Player per render and by the compiler per
|
|
792
|
+
* screen, so both hosts frame the same pages (§8).
|
|
793
|
+
*
|
|
794
|
+
* @param {{appears_on?: string, page_ids?: string[]}|null|undefined} menu —
|
|
795
|
+
* the main menu; absent frames every page.
|
|
796
|
+
* @param {string} pageId
|
|
797
|
+
* @returns {boolean}
|
|
798
|
+
*/
|
|
799
|
+
function mainMenuAppearsOn(menu, pageId) {
|
|
800
|
+
if (!isPlainObject(menu) || menu.appears_on !== "ALL_EXCEPT") return true;
|
|
801
|
+
return !(Array.isArray(menu.page_ids) && menu.page_ids.includes(pageId));
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* sc-12530 — the place on the page each layout draws in. Two menus in one
|
|
806
|
+
* place would stack, so a page shows at most one per place per view.
|
|
807
|
+
*/
|
|
808
|
+
const LOCAL_NAV_POSITIONS = Object.freeze({
|
|
809
|
+
TOP_BAR: "top",
|
|
810
|
+
BOTTOM_BAR: "bottom",
|
|
811
|
+
SIDEBAR: "side",
|
|
812
|
+
HEADER: "header",
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* sc-12530 — where a model draws; null for `NONE`. A kind this SDK does not
|
|
817
|
+
* know is its own place, so two of them still never stack.
|
|
818
|
+
*
|
|
819
|
+
* @param {string} model — from resolveLocalNavModel.
|
|
820
|
+
* @returns {string|null}
|
|
821
|
+
*/
|
|
822
|
+
function localNavPosition(model) {
|
|
823
|
+
if (!model || model === "NONE") return null;
|
|
824
|
+
return LOCAL_NAV_POSITIONS[model] || model;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* sc-12530 — the section menus a page draws in ONE device view, at most one
|
|
829
|
+
* per position. A menu picked for this page (`appears_on: "SELECTED"`) wins
|
|
830
|
+
* its position over one shown on all pages; between equals the first listed
|
|
831
|
+
* wins. The server refuses a save that would leave a tie (409
|
|
832
|
+
* MENU_POSITION_CLASH), so the tie-break only steadies older data. Asked by
|
|
833
|
+
* the Player per render and by the compiler per screen (§8).
|
|
834
|
+
*
|
|
835
|
+
* @param {Array<object>|null|undefined} menus — the page's `local_nav_menus`.
|
|
836
|
+
* @param {"mobile"|"tablet"|"desktop"} view
|
|
837
|
+
* @returns {Object<string, {menu: object, model: string}>} by position.
|
|
838
|
+
*/
|
|
839
|
+
function resolvePageBars(menus, view) {
|
|
840
|
+
const bars = {};
|
|
841
|
+
const specific = (menu) => menu.appears_on === "SELECTED";
|
|
842
|
+
for (const menu of Array.isArray(menus) ? menus : []) {
|
|
843
|
+
if (!isPlainObject(menu)) continue;
|
|
844
|
+
const model = resolveLocalNavModel(menu, view);
|
|
845
|
+
const position = localNavPosition(model);
|
|
846
|
+
if (!position) continue;
|
|
847
|
+
const held = bars[position];
|
|
848
|
+
if (held && (specific(held.menu) || !specific(menu))) continue;
|
|
849
|
+
bars[position] = { menu, model };
|
|
850
|
+
}
|
|
851
|
+
return bars;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* sc-12427 — whether a menu is a Top navigation bar at any view. The Studio
|
|
856
|
+
* styles that bar only for an app that draws one.
|
|
857
|
+
*
|
|
858
|
+
* @param {object|null|undefined} menu
|
|
859
|
+
* @returns {boolean}
|
|
860
|
+
*/
|
|
861
|
+
function drawsTopNavigation(menu) {
|
|
862
|
+
return ["mobile", "tablet", "desktop"].some(
|
|
863
|
+
(view) => resolveLocalNavModel(menu, view) === "HEADER",
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* sc-12427 — the pages a Top navigation bar links to, at any view: they are
|
|
869
|
+
* top-level destinations, as the main menu's are, so neither host offers a
|
|
870
|
+
* back control on them.
|
|
871
|
+
*
|
|
872
|
+
* @param {Array<object>|null|undefined} menus — every menu a page may draw.
|
|
873
|
+
* @returns {Set<string>} page ids.
|
|
874
|
+
*/
|
|
875
|
+
function topNavigationPageIds(menus) {
|
|
876
|
+
const ids = new Set();
|
|
877
|
+
for (const menu of Array.isArray(menus) ? menus : []) {
|
|
878
|
+
if (!isPlainObject(menu) || !drawsTopNavigation(menu)) continue;
|
|
879
|
+
for (const item of Array.isArray(menu.items) ? menu.items : []) {
|
|
880
|
+
if (isPlainObject(item) && typeof item.page_id === "string") ids.add(item.page_id);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return ids;
|
|
884
|
+
}
|
|
885
|
+
|
|
856
886
|
// REQ-THEME-LOOK: the divider's width in px, bounded HERE so both hosts inherit
|
|
857
887
|
// one range. The export clamped it on its way into the StyleSheet
|
|
858
888
|
// (`coerceBorderWidth(...) ?? 1`) where the Player passed any finite number
|
|
@@ -910,7 +940,14 @@ module.exports = {
|
|
|
910
940
|
isDarkSurface,
|
|
911
941
|
resolveAppLogo,
|
|
912
942
|
resolveTopBarTokens,
|
|
913
|
-
|
|
943
|
+
isSubMenuItem,
|
|
944
|
+
menuTree,
|
|
914
945
|
resolveLocalNavModel,
|
|
915
946
|
drawsLocalNavAnywhere,
|
|
947
|
+
mainMenuAppearsOn,
|
|
948
|
+
LOCAL_NAV_POSITIONS,
|
|
949
|
+
localNavPosition,
|
|
950
|
+
resolvePageBars,
|
|
951
|
+
drawsTopNavigation,
|
|
952
|
+
topNavigationPageIds,
|
|
916
953
|
};
|
package/dist/navigation.js
CHANGED
|
@@ -62,7 +62,7 @@ export function menuItemCap(menuType) {
|
|
|
62
62
|
// navigation bar is drawn from.
|
|
63
63
|
//
|
|
64
64
|
// sc-7753: the global quick bar these tokens were introduced for is retired;
|
|
65
|
-
// the bar that reads them now is
|
|
65
|
+
// the bar that reads them now is a section menu's (`layout = BOTTOM_BAR`).
|
|
66
66
|
//
|
|
67
67
|
// sc-8033: the block is SELF-CONTAINED — it reads `theme.footer` and nothing
|
|
68
68
|
// else. Every colour used to fall back to the rail's, so restyling the sidebar
|
|
@@ -683,121 +683,59 @@ export function resolveTopBarTokens(theme) {
|
|
|
683
683
|
}
|
|
684
684
|
|
|
685
685
|
/**
|
|
686
|
-
*
|
|
686
|
+
* sc-14098 — is this stored menu item a sub-menu? One with neither a page nor
|
|
687
|
+
* a link; it holds the items whose `parent_id` names it.
|
|
687
688
|
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
* saved menu, so the tree hangs in the same place from every page of the
|
|
701
|
-
* section. When the global menu lists no such page, the section's own page
|
|
702
|
-
* becomes a top-level entry (`standalone`) for as long as the visitor is
|
|
703
|
-
* inside it, so the menu is never lost — a section off the menu is exactly
|
|
704
|
-
* the case that would otherwise render blank.
|
|
689
|
+
* @param {object|null|undefined} item — a menu item as the API serves it.
|
|
690
|
+
* @returns {boolean}
|
|
691
|
+
*/
|
|
692
|
+
export function isSubMenuItem(item) {
|
|
693
|
+
return isPlainObject(item) && !item.page_id && !item.url;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* sc-14098 — a menu's flat entries as both hosts draw them: the top-level
|
|
698
|
+
* ones in order, each sub-menu carrying its own as `children`. The one
|
|
699
|
+
* grouping the web chrome and the compiler read, so a page cannot sit in a
|
|
700
|
+
* sub-menu on one host and at the top level on the other (§8).
|
|
705
701
|
*
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
702
|
+
* An entry naming no sub-menu of the list stands at the top level; a
|
|
703
|
+
* sub-menu left with nothing in it (its pages hidden from this visitor, say)
|
|
704
|
+
* is dropped rather than drawn as a heading over nothing.
|
|
709
705
|
*
|
|
710
|
-
* @param {
|
|
711
|
-
*
|
|
712
|
-
* `
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* `under` is null when the visitor is in no section; when `standalone` it
|
|
717
|
-
* names the section's own page, which the host draws as the entry. Each
|
|
718
|
-
* item is returned with a `current` flag rather than leaving each host to
|
|
719
|
-
* recompute it. `trees` lists `{ under, items, standalone, inside }` in menu
|
|
720
|
-
* order, a `standalone` one last; `inside` marks the visitor's own.
|
|
706
|
+
* @param {Array<object>} entries — in menu order, each with an `id`.
|
|
707
|
+
* @param {{ of?: (entry: object) => { id?: unknown, parent_id?: unknown, submenu?: unknown } }} [options]
|
|
708
|
+
* `of` reads an entry's `id`, `parent_id` and `submenu` flag when they
|
|
709
|
+
* live inside it (the web chrome's `{ page, isActive }` rows).
|
|
710
|
+
* @returns {Array<object>} the top-level entries; a sub-menu is returned as
|
|
711
|
+
* `{ ...entry, children }`, every other entry as it came.
|
|
721
712
|
*/
|
|
722
|
-
export function
|
|
723
|
-
const
|
|
724
|
-
const
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
const
|
|
730
|
-
return
|
|
731
|
-
};
|
|
732
|
-
const lists = (key) => {
|
|
733
|
-
const candidate = sectionAt(key);
|
|
734
|
-
return (
|
|
735
|
-
Boolean(candidate) &&
|
|
736
|
-
candidate.items.some(
|
|
737
|
-
(item) => isPlainObject(item) && item.key === viewed,
|
|
738
|
-
)
|
|
739
|
-
);
|
|
740
|
-
};
|
|
741
|
-
// The page's own section wins; otherwise the section whose menu lists it,
|
|
742
|
-
// preferring one a global entry carries so the tree hangs where it always
|
|
743
|
-
// does. Both are the same section from the visitor's side.
|
|
744
|
-
const section = viewed
|
|
745
|
-
? sectionAt(viewed) ||
|
|
746
|
-
sectionAt(order.find(lists)) ||
|
|
747
|
-
sectionAt(Object.keys(bank).find(lists))
|
|
748
|
-
: null;
|
|
749
|
-
const mark = (items) =>
|
|
750
|
-
items.map((item) => ({
|
|
751
|
-
...(isPlainObject(item) ? item : {}),
|
|
752
|
-
current:
|
|
753
|
-
viewed !== null &&
|
|
754
|
-
isPlainObject(item) &&
|
|
755
|
-
typeof item.key === "string" &&
|
|
756
|
-
item.key === viewed,
|
|
757
|
-
}));
|
|
758
|
-
// A saved menu hangs under the FIRST global entry carrying it, so two
|
|
759
|
-
// entries sharing one menu never draw it twice.
|
|
760
|
-
const claimed = [];
|
|
761
|
-
const trees = [];
|
|
762
|
-
for (const key of order) {
|
|
763
|
-
if (!isPlainObject(bank[key])) continue;
|
|
764
|
-
const { menu } = bank[key];
|
|
765
|
-
if (claimed.includes(menu)) continue;
|
|
766
|
-
claimed.push(menu);
|
|
767
|
-
// An unusable key still owns its menu: nothing may hang it elsewhere.
|
|
768
|
-
if (typeof key !== "string" || !key) continue;
|
|
769
|
-
const inside = Boolean(section) && menu === section.menu;
|
|
770
|
-
const own = inside ? section : sectionAt(key);
|
|
771
|
-
if (!own) continue;
|
|
772
|
-
trees.push({ under: key, items: mark(own.items), standalone: false, inside });
|
|
773
|
-
}
|
|
774
|
-
if (!section) return { under: null, items: [], standalone: false, trees };
|
|
775
|
-
const owned = trees.find((tree) => tree.inside);
|
|
776
|
-
if (owned) {
|
|
777
|
-
return { under: owned.under, items: owned.items, standalone: false, trees };
|
|
778
|
-
}
|
|
779
|
-
const alone = {
|
|
780
|
-
under: section.key,
|
|
781
|
-
items: mark(section.items),
|
|
782
|
-
standalone: true,
|
|
783
|
-
inside: true,
|
|
784
|
-
};
|
|
785
|
-
return {
|
|
786
|
-
under: alone.under,
|
|
787
|
-
items: alone.items,
|
|
788
|
-
standalone: true,
|
|
789
|
-
trees: [...trees, alone],
|
|
713
|
+
export function menuTree(entries, { of = (entry) => entry } = {}) {
|
|
714
|
+
const list = Array.isArray(entries) ? entries.filter(isPlainObject) : [];
|
|
715
|
+
const read = (entry) => (isPlainObject(of(entry)) ? of(entry) : {});
|
|
716
|
+
const subMenuIds = new Set(
|
|
717
|
+
list.filter((entry) => read(entry).submenu === true).map((entry) => read(entry).id),
|
|
718
|
+
);
|
|
719
|
+
const parentOf = (entry) => {
|
|
720
|
+
const { parent_id: parent, submenu } = read(entry);
|
|
721
|
+
return submenu !== true && typeof parent === "string" && subMenuIds.has(parent) ? parent : null;
|
|
790
722
|
};
|
|
723
|
+
return list
|
|
724
|
+
.filter((entry) => parentOf(entry) === null)
|
|
725
|
+
.flatMap((entry) => {
|
|
726
|
+
if (read(entry).submenu !== true) return [entry];
|
|
727
|
+
const children = list.filter((child) => parentOf(child) === read(entry).id);
|
|
728
|
+
return children.length ? [{ ...entry, children }] : [];
|
|
729
|
+
});
|
|
791
730
|
}
|
|
792
731
|
|
|
793
732
|
/**
|
|
794
|
-
* REQ-NAV-LOCAL (sc-8901) —
|
|
795
|
-
*
|
|
796
|
-
*
|
|
733
|
+
* REQ-NAV-LOCAL (sc-8901, sc-12397) — how a menu is drawn in ONE device
|
|
734
|
+
* view, so the same menu can be a bottom bar on a phone and a tab row on a
|
|
735
|
+
* desktop. Since sc-12397 the MENU owns this, not each page.
|
|
797
736
|
*
|
|
798
|
-
* `
|
|
799
|
-
*
|
|
800
|
-
* renders identically at every width. The cascade is REQ-LAY-07's — the one the
|
|
737
|
+
* `layout` is the MOBILE value and the base of the cascade; a wider view left
|
|
738
|
+
* null follows the narrower one. The cascade is REQ-LAY-07's — the one the
|
|
801
739
|
* layout grid and every responsive widget prop already use — because a page's
|
|
802
740
|
* chrome and its content must not disagree about what a tablet is.
|
|
803
741
|
*
|
|
@@ -805,21 +743,21 @@ export function resolveSidebarUnfold(input) {
|
|
|
805
743
|
* host's own switch decides what it can draw, so a kind a newer backend allows
|
|
806
744
|
* cascades correctly here instead of being flattened to `NONE` on the way.
|
|
807
745
|
*
|
|
808
|
-
* @param {object|null|undefined}
|
|
809
|
-
* optionally, `
|
|
746
|
+
* @param {object|null|undefined} menu — a menu carrying `layout` and,
|
|
747
|
+
* optionally, `layout_tablet` / `layout_desktop`. No menu draws nothing.
|
|
810
748
|
* @param {"mobile"|"tablet"|"desktop"} view — the device view being drawn.
|
|
811
|
-
* @returns {string} the model for that view; `NONE` when the
|
|
749
|
+
* @returns {string} the model for that view; `NONE` when the menu sets none.
|
|
812
750
|
*/
|
|
813
|
-
export function resolveLocalNavModel(
|
|
751
|
+
export function resolveLocalNavModel(menu, view) {
|
|
814
752
|
const at = (key) => {
|
|
815
|
-
const value = isPlainObject(
|
|
753
|
+
const value = isPlainObject(menu) ? menu[key] : null;
|
|
816
754
|
return typeof value === "string" && value ? value : null;
|
|
817
755
|
};
|
|
818
|
-
const mobile = at("
|
|
756
|
+
const mobile = at("layout") || "NONE";
|
|
819
757
|
if (view === "desktop") {
|
|
820
|
-
return at("
|
|
758
|
+
return at("layout_desktop") || at("layout_tablet") || mobile;
|
|
821
759
|
}
|
|
822
|
-
if (view === "tablet") return at("
|
|
760
|
+
if (view === "tablet") return at("layout_tablet") || mobile;
|
|
823
761
|
return mobile;
|
|
824
762
|
}
|
|
825
763
|
|
|
@@ -829,25 +767,117 @@ export function resolveLocalNavModel(page, view) {
|
|
|
829
767
|
const LOCAL_NAV_VIEWS = ["mobile", "tablet", "desktop"];
|
|
830
768
|
|
|
831
769
|
/**
|
|
832
|
-
* REQ-NAV-LOCAL (sc-8901) — does this
|
|
770
|
+
* REQ-NAV-LOCAL (sc-8901) — does this menu draw a bar in ANY device view?
|
|
833
771
|
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
* `local_nav !== "NONE"` alone would miss a page that carries a bar only on the
|
|
837
|
-
* wider views.
|
|
772
|
+
* Beside the cascade it is derived from, so the API, the export's screen bake
|
|
773
|
+
* and the Studio cannot disagree about which pages show a bar.
|
|
838
774
|
*
|
|
839
|
-
*
|
|
840
|
-
* bake and Copy Workspace cannot disagree about which pages have a bar.
|
|
841
|
-
*
|
|
842
|
-
* @param {object|null|undefined} page — a page row.
|
|
775
|
+
* @param {object|null|undefined} menu — a menu row, or its layout fields.
|
|
843
776
|
* @returns {boolean}
|
|
844
777
|
*/
|
|
845
|
-
export function drawsLocalNavAnywhere(
|
|
778
|
+
export function drawsLocalNavAnywhere(menu) {
|
|
846
779
|
return LOCAL_NAV_VIEWS.some(
|
|
847
|
-
(view) => resolveLocalNavModel(
|
|
780
|
+
(view) => resolveLocalNavModel(menu, view) !== "NONE",
|
|
848
781
|
);
|
|
849
782
|
}
|
|
850
783
|
|
|
784
|
+
/**
|
|
785
|
+
* sc-12426 — does the app's main menu frame this page? A page it leaves out
|
|
786
|
+
* is full screen. Asked by the Player per render and by the compiler per
|
|
787
|
+
* screen, so both hosts frame the same pages (§8).
|
|
788
|
+
*
|
|
789
|
+
* @param {{appears_on?: string, page_ids?: string[]}|null|undefined} menu —
|
|
790
|
+
* the main menu; absent frames every page.
|
|
791
|
+
* @param {string} pageId
|
|
792
|
+
* @returns {boolean}
|
|
793
|
+
*/
|
|
794
|
+
export function mainMenuAppearsOn(menu, pageId) {
|
|
795
|
+
if (!isPlainObject(menu) || menu.appears_on !== "ALL_EXCEPT") return true;
|
|
796
|
+
return !(Array.isArray(menu.page_ids) && menu.page_ids.includes(pageId));
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* sc-12530 — the place on the page each layout draws in. Two menus in one
|
|
801
|
+
* place would stack, so a page shows at most one per place per view.
|
|
802
|
+
*/
|
|
803
|
+
export const LOCAL_NAV_POSITIONS = Object.freeze({
|
|
804
|
+
TOP_BAR: "top",
|
|
805
|
+
BOTTOM_BAR: "bottom",
|
|
806
|
+
SIDEBAR: "side",
|
|
807
|
+
HEADER: "header",
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* sc-12530 — where a model draws; null for `NONE`. A kind this SDK does not
|
|
812
|
+
* know is its own place, so two of them still never stack.
|
|
813
|
+
*
|
|
814
|
+
* @param {string} model — from resolveLocalNavModel.
|
|
815
|
+
* @returns {string|null}
|
|
816
|
+
*/
|
|
817
|
+
export function localNavPosition(model) {
|
|
818
|
+
if (!model || model === "NONE") return null;
|
|
819
|
+
return LOCAL_NAV_POSITIONS[model] || model;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* sc-12530 — the section menus a page draws in ONE device view, at most one
|
|
824
|
+
* per position. A menu picked for this page (`appears_on: "SELECTED"`) wins
|
|
825
|
+
* its position over one shown on all pages; between equals the first listed
|
|
826
|
+
* wins. The server refuses a save that would leave a tie (409
|
|
827
|
+
* MENU_POSITION_CLASH), so the tie-break only steadies older data. Asked by
|
|
828
|
+
* the Player per render and by the compiler per screen (§8).
|
|
829
|
+
*
|
|
830
|
+
* @param {Array<object>|null|undefined} menus — the page's `local_nav_menus`.
|
|
831
|
+
* @param {"mobile"|"tablet"|"desktop"} view
|
|
832
|
+
* @returns {Object<string, {menu: object, model: string}>} by position.
|
|
833
|
+
*/
|
|
834
|
+
export function resolvePageBars(menus, view) {
|
|
835
|
+
const bars = {};
|
|
836
|
+
const specific = (menu) => menu.appears_on === "SELECTED";
|
|
837
|
+
for (const menu of Array.isArray(menus) ? menus : []) {
|
|
838
|
+
if (!isPlainObject(menu)) continue;
|
|
839
|
+
const model = resolveLocalNavModel(menu, view);
|
|
840
|
+
const position = localNavPosition(model);
|
|
841
|
+
if (!position) continue;
|
|
842
|
+
const held = bars[position];
|
|
843
|
+
if (held && (specific(held.menu) || !specific(menu))) continue;
|
|
844
|
+
bars[position] = { menu, model };
|
|
845
|
+
}
|
|
846
|
+
return bars;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* sc-12427 — whether a menu is a Top navigation bar at any view. The Studio
|
|
851
|
+
* styles that bar only for an app that draws one.
|
|
852
|
+
*
|
|
853
|
+
* @param {object|null|undefined} menu
|
|
854
|
+
* @returns {boolean}
|
|
855
|
+
*/
|
|
856
|
+
export function drawsTopNavigation(menu) {
|
|
857
|
+
return ["mobile", "tablet", "desktop"].some(
|
|
858
|
+
(view) => resolveLocalNavModel(menu, view) === "HEADER",
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* sc-12427 — the pages a Top navigation bar links to, at any view: they are
|
|
864
|
+
* top-level destinations, as the main menu's are, so neither host offers a
|
|
865
|
+
* back control on them.
|
|
866
|
+
*
|
|
867
|
+
* @param {Array<object>|null|undefined} menus — every menu a page may draw.
|
|
868
|
+
* @returns {Set<string>} page ids.
|
|
869
|
+
*/
|
|
870
|
+
export function topNavigationPageIds(menus) {
|
|
871
|
+
const ids = new Set();
|
|
872
|
+
for (const menu of Array.isArray(menus) ? menus : []) {
|
|
873
|
+
if (!isPlainObject(menu) || !drawsTopNavigation(menu)) continue;
|
|
874
|
+
for (const item of Array.isArray(menu.items) ? menu.items : []) {
|
|
875
|
+
if (isPlainObject(item) && typeof item.page_id === "string") ids.add(item.page_id);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return ids;
|
|
879
|
+
}
|
|
880
|
+
|
|
851
881
|
// REQ-THEME-LOOK: the divider's width in px, bounded HERE so both hosts inherit
|
|
852
882
|
// one range. The export clamped it on its way into the StyleSheet
|
|
853
883
|
// (`coerceBorderWidth(...) ?? 1`) where the Player passed any finite number
|
package/dist/stats-hooks.js
CHANGED
|
@@ -86,8 +86,11 @@ function useKeyedRead(read, identity, key, mapError, fetchStartRef) {
|
|
|
86
86
|
* (1–1000). Returns `{ buckets, groups, loading, fetching, error, refetch }`:
|
|
87
87
|
* by date, `buckets` is `[{ date, count, sum }]` with every bucket of the range
|
|
88
88
|
* present (empty ones as 0); by a column, `groups` is `[{ group, count, sum }]`,
|
|
89
|
-
* a user column's `group` being the user id
|
|
90
|
-
*
|
|
89
|
+
* a user column's `group` being the user id, a relation column's the related
|
|
90
|
+
* row's id (a MANY_TO_MANY row counts once per linked row), and rows with no
|
|
91
|
+
* value one "Uncategorized" group. Check `error` first: after a refused or
|
|
92
|
+
* failed read `groups` may be empty or still hold the last result. A falsy
|
|
93
|
+
* `table` settles to nothing.
|
|
91
94
|
*/
|
|
92
95
|
export function useDatastoreAggregate(table, spec) {
|
|
93
96
|
const ctx = useWidgetContextOrThrow("useDatastoreAggregate");
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2098,14 +2098,18 @@ const HOOKS = [
|
|
|
2098
2098
|
"(Monday) in `buckets`; `bucket` is \"day\" (default) or \"week\"; " +
|
|
2099
2099
|
"`from` / `to` are ISO dates (default: the 30 days, or 12 weeks, up to " +
|
|
2100
2100
|
"now), at most 31 buckets, empty ones as count 0 so a chart has no gaps. " +
|
|
2101
|
-
"BY A COLUMN (any other `groupBy`: a text, number, yes/no, date or
|
|
2102
|
-
"column): one entry per value in `groups`. A
|
|
2101
|
+
"BY A COLUMN (any other `groupBy`: a text, number, yes/no, date, user or " +
|
|
2102
|
+
"relation column): one entry per value in `groups`. A RELATION column's " +
|
|
2103
|
+
"`group` is the related row's id (match it to that table's row.id); a " +
|
|
2104
|
+
"MANY_TO_MANY row counts once per linked row. A USER column's `group` is the " +
|
|
2103
2105
|
"user id (resolve names with useDirectory({ ids })), so `order: \"count:desc\", " +
|
|
2104
2106
|
"limit: 10` ranks the ten people with the most rows. `order` is count, sum " +
|
|
2105
2107
|
"or group, then :asc or :desc (default: by value); `limit` is 1-1000. Rows " +
|
|
2106
2108
|
"with no value form one \"Uncategorized\" group; on a user column, leave " +
|
|
2107
|
-
"them out with a `nempty:` filter. Encrypted, array
|
|
2108
|
-
"
|
|
2109
|
+
"them out with a `nempty:` filter. Encrypted, array and file columns " +
|
|
2110
|
+
"cannot be grouped (VALIDATION). Check `error` first and render it: after " +
|
|
2111
|
+
"a refused or failed read `groups` may be empty or still hold the last " +
|
|
2112
|
+
"result, so never show it as a zero per group. `filter` takes the same shapes " +
|
|
2109
2113
|
"as useDatastoreQuery's, created_at ranges included. Pass null as the " +
|
|
2110
2114
|
"table until a bound table is known. `live: true` re-reads it when " +
|
|
2111
2115
|
"anyone else changes the table.",
|
|
@@ -2113,7 +2117,7 @@ const HOOKS = [
|
|
|
2113
2117
|
buckets:
|
|
2114
2118
|
"Array<{ date, count, sum }> // date = the bucket's start, YYYY-MM-DD; sum is 0 without sumColumn",
|
|
2115
2119
|
groups:
|
|
2116
|
-
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id",
|
|
2120
|
+
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id, a RELATION column's the related row id",
|
|
2117
2121
|
loading: "boolean",
|
|
2118
2122
|
fetching: "boolean",
|
|
2119
2123
|
error: "DatastoreError | null // { code, message, retryable } — offer Retry only when retryable; a signed-out viewer of a table only members read gets NOT_FOUND, retryable false",
|
|
@@ -6461,7 +6465,7 @@ const CONTRACT = deepFreeze({
|
|
|
6461
6465
|
// it. The app's global mobile quick bar is retired: it was a SELECTION
|
|
6462
6466
|
// over the global menu, and the rail and drawer list every menu page
|
|
6463
6467
|
// regardless, so nothing was reachable only through it. The bottom edge
|
|
6464
|
-
// belongs to a
|
|
6468
|
+
// belongs to a section menu's bottom navigation bar (`layout = BOTTOM_BAR`,
|
|
6465
6469
|
// REQ-NAV-LOCAL), chosen per page. `resolveFooterTokens` is unchanged —
|
|
6466
6470
|
// it is the bottom edge's token set and the surviving bar reads it.
|
|
6467
6471
|
// 1.113.0: additive (sc-7951) — `resolveFooterTokens` gains the bottom
|
|
@@ -7062,7 +7066,9 @@ const CONTRACT = deepFreeze({
|
|
|
7062
7066
|
// 1.270.0: additive (sc-17197) — a `datastoreTemplate` column may declare
|
|
7063
7067
|
// `defaultOnCreate: true`: a create stamps its default over any client
|
|
7064
7068
|
// value, and an update may still change it.
|
|
7065
|
-
|
|
7069
|
+
// 1.271.0: additive (sc-17551) — `useDatastoreAggregate` groups by a
|
|
7070
|
+
// relation column; new warning lint `aggregate-error-not-read`.
|
|
7071
|
+
version: "1.271.0",
|
|
7066
7072
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7067
7073
|
hooks: HOOKS,
|
|
7068
7074
|
primitives: PRIMITIVES,
|