@colixsystems/widget-sdk 0.305.0 → 0.306.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 +6 -2
- package/dist/contract.cjs +8 -6
- package/dist/contract.js +8 -6
- package/dist/linter.cjs +69 -0
- package/dist/linter.js +69 -0
- package/package.json +1 -1
- package/src/contract.js +8 -6
package/README.md
CHANGED
|
@@ -90,7 +90,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
90
90
|
|
|
91
91
|
## Status
|
|
92
92
|
|
|
93
|
-
`v0.
|
|
93
|
+
`v0.306.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**.
|
|
94
|
+
|
|
95
|
+
### What's new in 0.306.0 (contract 1.250.0)
|
|
96
|
+
|
|
97
|
+
**New linter rule `read-error-not-branched` (severity `warning`).** A read that the viewer may not make never succeeds on a retry. A signed-out visitor reading a table only members may read gets a `DatastoreError` with `code: "NOT_FOUND"`; a signed-in user the table's grants leave out gets `FORBIDDEN` or no rows. Both carry `retryable: false`. A widget that shows "could not be loaded" with a Retry for every read error loops that visitor forever. The read hooks' `error` (`useDatastoreQuery`, `usePagedDatastoreQuery`, `useDatastoreRecord`, `useDatastoreAggregate`, `useDatastoreFigure`) has always carried `{ code, message, retryable }`, and the contract now says so. Offer Retry only when `error.retryable` (a dropped connection, a timeout, a rate limit, a 5xx). Otherwise show a calm signed-out state to a visitor with no `useUser().id` ("Sign in to see the recipes"), and `error.message` to a signed-in user, with no Retry. The rule fires when a read hook's `refetch` or `retry` is bound to an `onPress` in the statement that handles its `error`, and that error's `retryable` and `code ===` are never read and the signed-in user's id is never checked. A bare `useUser()` call does not satisfy it.
|
|
94
98
|
|
|
95
99
|
### What's new in 0.305.0 (contract 1.249.0)
|
|
96
100
|
|
|
@@ -3834,7 +3838,7 @@ export default function ContactList({ tableId, pageSize }) {
|
|
|
3834
3838
|
<TextInput value={draft} onChangeText={setDraft} placeholder="Search" />
|
|
3835
3839
|
<Pressable onPress={() => setStatus(status === "Won" ? "" : "Won")}><Text>Won</Text></Pressable>
|
|
3836
3840
|
{loading ? <Text>Loading…</Text> : data.map((row) => <Text key={row.id}>{row.name}</Text>)}
|
|
3837
|
-
{error ? <Button variant="ghost" title="Retry" onPress={retry} /> : null}
|
|
3841
|
+
{error ? (error.retryable ? <Button variant="ghost" title="Retry" onPress={retry} /> : <Text>{error.message}</Text>) : null}
|
|
3838
3842
|
<Text>{total ?? 0} contacts</Text>
|
|
3839
3843
|
{hasMore ? <Button variant="ghost" title="Load more" busy={loadingMore} onPress={loadMore} /> : null}
|
|
3840
3844
|
</View>
|
package/dist/contract.cjs
CHANGED
|
@@ -1407,7 +1407,7 @@ const HOOKS = [
|
|
|
1407
1407
|
data: "Record | null",
|
|
1408
1408
|
loading: "boolean",
|
|
1409
1409
|
fetching: "boolean",
|
|
1410
|
-
error: "DatastoreError | null",
|
|
1410
|
+
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",
|
|
1411
1411
|
refetch: "() => Promise<void>",
|
|
1412
1412
|
},
|
|
1413
1413
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2000,7 +2000,7 @@ const HOOKS = [
|
|
|
2000
2000
|
total: "number | null",
|
|
2001
2001
|
loading: "boolean",
|
|
2002
2002
|
fetching: "boolean",
|
|
2003
|
-
error: "DatastoreError | null",
|
|
2003
|
+
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",
|
|
2004
2004
|
refetch: "() => Promise<void>",
|
|
2005
2005
|
},
|
|
2006
2006
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2034,7 +2034,7 @@ const HOOKS = [
|
|
|
2034
2034
|
loading: "boolean",
|
|
2035
2035
|
fetching: "boolean",
|
|
2036
2036
|
loadingMore: "boolean",
|
|
2037
|
-
error: "DatastoreError | null",
|
|
2037
|
+
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",
|
|
2038
2038
|
loadMore: "() => void",
|
|
2039
2039
|
retry: "() => void",
|
|
2040
2040
|
refetch: "() => Promise<void>",
|
|
@@ -2068,7 +2068,7 @@ const HOOKS = [
|
|
|
2068
2068
|
truncated: "boolean",
|
|
2069
2069
|
loading: "boolean",
|
|
2070
2070
|
fetching: "boolean",
|
|
2071
|
-
error: "DatastoreError | null",
|
|
2071
|
+
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",
|
|
2072
2072
|
refetch: "() => Promise<void>",
|
|
2073
2073
|
},
|
|
2074
2074
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2108,7 +2108,7 @@ const HOOKS = [
|
|
|
2108
2108
|
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id",
|
|
2109
2109
|
loading: "boolean",
|
|
2110
2110
|
fetching: "boolean",
|
|
2111
|
-
error: "DatastoreError | null",
|
|
2111
|
+
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",
|
|
2112
2112
|
refetch: "() => Promise<void>",
|
|
2113
2113
|
},
|
|
2114
2114
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -6919,7 +6919,9 @@ const CONTRACT = deepFreeze({
|
|
|
6919
6919
|
// the web for pointer devices when it overflows; `showsScrollAffordance` turns it off.
|
|
6920
6920
|
// 1.249.0: a `<Button>` follows its parent's cross-axis alignment instead
|
|
6921
6921
|
// of forcing `alignSelf: "flex-start"`; it still hugs its label.
|
|
6922
|
-
|
|
6922
|
+
// 1.250.0: documentation (sc-16511) — the read hooks' `error` names the
|
|
6923
|
+
// `{ code, message, retryable }` it has always carried; Retry only when retryable.
|
|
6924
|
+
version: "1.250.0",
|
|
6923
6925
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6924
6926
|
hooks: HOOKS,
|
|
6925
6927
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -1402,7 +1402,7 @@ const HOOKS = [
|
|
|
1402
1402
|
data: "Record | null",
|
|
1403
1403
|
loading: "boolean",
|
|
1404
1404
|
fetching: "boolean",
|
|
1405
|
-
error: "DatastoreError | null",
|
|
1405
|
+
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",
|
|
1406
1406
|
refetch: "() => Promise<void>",
|
|
1407
1407
|
},
|
|
1408
1408
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -1995,7 +1995,7 @@ const HOOKS = [
|
|
|
1995
1995
|
total: "number | null",
|
|
1996
1996
|
loading: "boolean",
|
|
1997
1997
|
fetching: "boolean",
|
|
1998
|
-
error: "DatastoreError | null",
|
|
1998
|
+
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",
|
|
1999
1999
|
refetch: "() => Promise<void>",
|
|
2000
2000
|
},
|
|
2001
2001
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2029,7 +2029,7 @@ const HOOKS = [
|
|
|
2029
2029
|
loading: "boolean",
|
|
2030
2030
|
fetching: "boolean",
|
|
2031
2031
|
loadingMore: "boolean",
|
|
2032
|
-
error: "DatastoreError | null",
|
|
2032
|
+
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",
|
|
2033
2033
|
loadMore: "() => void",
|
|
2034
2034
|
retry: "() => void",
|
|
2035
2035
|
refetch: "() => Promise<void>",
|
|
@@ -2063,7 +2063,7 @@ const HOOKS = [
|
|
|
2063
2063
|
truncated: "boolean",
|
|
2064
2064
|
loading: "boolean",
|
|
2065
2065
|
fetching: "boolean",
|
|
2066
|
-
error: "DatastoreError | null",
|
|
2066
|
+
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",
|
|
2067
2067
|
refetch: "() => Promise<void>",
|
|
2068
2068
|
},
|
|
2069
2069
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2103,7 +2103,7 @@ const HOOKS = [
|
|
|
2103
2103
|
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id",
|
|
2104
2104
|
loading: "boolean",
|
|
2105
2105
|
fetching: "boolean",
|
|
2106
|
-
error: "DatastoreError | null",
|
|
2106
|
+
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",
|
|
2107
2107
|
refetch: "() => Promise<void>",
|
|
2108
2108
|
},
|
|
2109
2109
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -6914,7 +6914,9 @@ const CONTRACT = deepFreeze({
|
|
|
6914
6914
|
// the web for pointer devices when it overflows; `showsScrollAffordance` turns it off.
|
|
6915
6915
|
// 1.249.0: a `<Button>` follows its parent's cross-axis alignment instead
|
|
6916
6916
|
// of forcing `alignSelf: "flex-start"`; it still hugs its label.
|
|
6917
|
-
|
|
6917
|
+
// 1.250.0: documentation (sc-16511) — the read hooks' `error` names the
|
|
6918
|
+
// `{ code, message, retryable }` it has always carried; Retry only when retryable.
|
|
6919
|
+
version: "1.250.0",
|
|
6918
6920
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6919
6921
|
hooks: HOOKS,
|
|
6920
6922
|
primitives: PRIMITIVES,
|
package/dist/linter.cjs
CHANGED
|
@@ -1668,6 +1668,74 @@ function _datastoreErrorHandlingRules(source) {
|
|
|
1668
1668
|
];
|
|
1669
1669
|
}
|
|
1670
1670
|
|
|
1671
|
+
// sc-16511 — soft warning, the read twin of `datastore-error-not-branched`.
|
|
1672
|
+
// A read refused because the viewer may not see the table (a signed-out
|
|
1673
|
+
// visitor gets NOT_FOUND, a signed-in one FORBIDDEN) never clears on a retry,
|
|
1674
|
+
// so a Retry bound to every read error loops the visitor forever. Reading the
|
|
1675
|
+
// read error's `retryable`, branching on its `code ===`, or guarding on the
|
|
1676
|
+
// signed-in user's id satisfies it. A bare `useUser()` call does not: widgets
|
|
1677
|
+
// call it for a greeting, and that is exactly the widget this rule exists for.
|
|
1678
|
+
const READ_HOOK = String.raw`use(?:PagedDatastoreQuery|Datastore(?:Query|Record|Aggregate|Figure)\w*)`;
|
|
1679
|
+
const READ_HOOK_CALL_RE = new RegExp(String.raw`\b${READ_HOOK}\s*\(`);
|
|
1680
|
+
const READ_HOOK_DESTRUCTURE_RE = new RegExp(String.raw`\{([^{}]*)\}\s*=\s*${READ_HOOK}\s*\(`, "g");
|
|
1681
|
+
const RETRY_CONTROL_RE = /\bonPress\s*(?:=\s*\{|:)\s*(?:\(\s*\)\s*=>\s*\{?\s*)?(?:refetch|retry)\b/g;
|
|
1682
|
+
// How far before a retry control, within one statement, its error check may sit.
|
|
1683
|
+
const RETRY_ERROR_WINDOW = 400;
|
|
1684
|
+
|
|
1685
|
+
function _statementBefore(code, index) {
|
|
1686
|
+
const window = code.slice(Math.max(0, index - RETRY_ERROR_WINDOW), index);
|
|
1687
|
+
return window.slice(window.lastIndexOf(";") + 1);
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/** The names the read hooks' `error` is bound to; `error` when none is destructured. */
|
|
1691
|
+
function _readErrorNames(code) {
|
|
1692
|
+
const names = new Set();
|
|
1693
|
+
for (const m of code.matchAll(READ_HOOK_DESTRUCTURE_RE)) {
|
|
1694
|
+
const bound = /(?:^|,)\s*error\s*(?::\s*([A-Za-z_$][\w$]*))?\s*(?:=[^,]*)?(?:,|$)/.exec(m[1]);
|
|
1695
|
+
if (bound) names.add(bound[1] || "error");
|
|
1696
|
+
}
|
|
1697
|
+
return names.size > 0 ? [...names] : ["error"];
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
function _signedInGuardRes(code) {
|
|
1701
|
+
const res = [/\buseUser\s*\(\s*\)\s*\??\.id\b/];
|
|
1702
|
+
const guardOn = (name) => {
|
|
1703
|
+
const n = name.replace(/\$/g, "\\$");
|
|
1704
|
+
return [new RegExp(`!\\s*${n}\\b(?!\\s*\\.)`), new RegExp(`(?<![\\w$.])${n}\\s*(?:\\?[^.?]|&&|\\|\\|)`)];
|
|
1705
|
+
};
|
|
1706
|
+
const named = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1707
|
+
if (named) res.push(...guardOn(`${named[1]}\\??\\.id`));
|
|
1708
|
+
const destructured = /\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1709
|
+
const idName = destructured && /(?:^|,)\s*id\s*(?::\s*([A-Za-z_$][\w$]*))?\s*(?:,|$)/.exec(destructured[1]);
|
|
1710
|
+
if (idName) res.push(...guardOn(idName[1] || "id"));
|
|
1711
|
+
return res;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
function _readErrorHandlingRules(source) {
|
|
1715
|
+
const code = _stripNonCode(source);
|
|
1716
|
+
if (!READ_HOOK_CALL_RE.test(code)) return [];
|
|
1717
|
+
const errorNames = _readErrorNames(code).map((n) => n.replace(/\$/g, "\\$"));
|
|
1718
|
+
const nearError = new RegExp(String.raw`(?<![\w$.])(?:${errorNames.join("|")})(?![\w$])`);
|
|
1719
|
+
const retry = [...code.matchAll(RETRY_CONTROL_RE)].find((m) => nearError.test(_statementBefore(code, m.index)));
|
|
1720
|
+
if (!retry) return [];
|
|
1721
|
+
const branched = new RegExp(String.raw`(?<![\w$.])(?:${errorNames.join("|")})\??\.(?:retryable\b|code\s*===)`);
|
|
1722
|
+
if (branched.test(code)) return [];
|
|
1723
|
+
if (_signedInGuardRes(code).some((re) => re.test(code))) return [];
|
|
1724
|
+
const line = code.slice(0, retry.index).split(/\r?\n/).length;
|
|
1725
|
+
return [
|
|
1726
|
+
{
|
|
1727
|
+
rule: "read-error-not-branched",
|
|
1728
|
+
severity: "warning",
|
|
1729
|
+
label:
|
|
1730
|
+
`offers Retry on every read error - a viewer who may not read the ` +
|
|
1731
|
+
`table (signed out: NOT_FOUND) can never succeed. Show Retry only when ` +
|
|
1732
|
+
`error.retryable; otherwise a signed-out state or error.message.`,
|
|
1733
|
+
line,
|
|
1734
|
+
snippet: (source.split(/\r?\n/)[line - 1] || "").trim().slice(0, 200),
|
|
1735
|
+
},
|
|
1736
|
+
];
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1671
1739
|
// sc-5206 — soft warning: a `useDatastoreQuery` argument built from a raw
|
|
1672
1740
|
// `const q = useMemo(() => ({...}), [...])` re-fetches in a loop the moment
|
|
1673
1741
|
// the deps array is wrong (sc-1579's volatile-query gate exists because of
|
|
@@ -3208,6 +3276,7 @@ function lintSource(source, options) {
|
|
|
3208
3276
|
findings.push(..._hardcodedCurrencyLabelRules(source));
|
|
3209
3277
|
findings.push(..._paymentErrorHandlingRules(source));
|
|
3210
3278
|
findings.push(..._datastoreErrorHandlingRules(source));
|
|
3279
|
+
findings.push(..._readErrorHandlingRules(source));
|
|
3211
3280
|
// sc-5206 — soft warnings steering a widget toward the two new hooks.
|
|
3212
3281
|
findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
|
|
3213
3282
|
findings.push(..._handRolledWriteGateRules(source));
|
package/dist/linter.js
CHANGED
|
@@ -1663,6 +1663,74 @@ function _datastoreErrorHandlingRules(source) {
|
|
|
1663
1663
|
];
|
|
1664
1664
|
}
|
|
1665
1665
|
|
|
1666
|
+
// sc-16511 — soft warning, the read twin of `datastore-error-not-branched`.
|
|
1667
|
+
// A read refused because the viewer may not see the table (a signed-out
|
|
1668
|
+
// visitor gets NOT_FOUND, a signed-in one FORBIDDEN) never clears on a retry,
|
|
1669
|
+
// so a Retry bound to every read error loops the visitor forever. Reading the
|
|
1670
|
+
// read error's `retryable`, branching on its `code ===`, or guarding on the
|
|
1671
|
+
// signed-in user's id satisfies it. A bare `useUser()` call does not: widgets
|
|
1672
|
+
// call it for a greeting, and that is exactly the widget this rule exists for.
|
|
1673
|
+
const READ_HOOK = String.raw`use(?:PagedDatastoreQuery|Datastore(?:Query|Record|Aggregate|Figure)\w*)`;
|
|
1674
|
+
const READ_HOOK_CALL_RE = new RegExp(String.raw`\b${READ_HOOK}\s*\(`);
|
|
1675
|
+
const READ_HOOK_DESTRUCTURE_RE = new RegExp(String.raw`\{([^{}]*)\}\s*=\s*${READ_HOOK}\s*\(`, "g");
|
|
1676
|
+
const RETRY_CONTROL_RE = /\bonPress\s*(?:=\s*\{|:)\s*(?:\(\s*\)\s*=>\s*\{?\s*)?(?:refetch|retry)\b/g;
|
|
1677
|
+
// How far before a retry control, within one statement, its error check may sit.
|
|
1678
|
+
const RETRY_ERROR_WINDOW = 400;
|
|
1679
|
+
|
|
1680
|
+
function _statementBefore(code, index) {
|
|
1681
|
+
const window = code.slice(Math.max(0, index - RETRY_ERROR_WINDOW), index);
|
|
1682
|
+
return window.slice(window.lastIndexOf(";") + 1);
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/** The names the read hooks' `error` is bound to; `error` when none is destructured. */
|
|
1686
|
+
function _readErrorNames(code) {
|
|
1687
|
+
const names = new Set();
|
|
1688
|
+
for (const m of code.matchAll(READ_HOOK_DESTRUCTURE_RE)) {
|
|
1689
|
+
const bound = /(?:^|,)\s*error\s*(?::\s*([A-Za-z_$][\w$]*))?\s*(?:=[^,]*)?(?:,|$)/.exec(m[1]);
|
|
1690
|
+
if (bound) names.add(bound[1] || "error");
|
|
1691
|
+
}
|
|
1692
|
+
return names.size > 0 ? [...names] : ["error"];
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
function _signedInGuardRes(code) {
|
|
1696
|
+
const res = [/\buseUser\s*\(\s*\)\s*\??\.id\b/];
|
|
1697
|
+
const guardOn = (name) => {
|
|
1698
|
+
const n = name.replace(/\$/g, "\\$");
|
|
1699
|
+
return [new RegExp(`!\\s*${n}\\b(?!\\s*\\.)`), new RegExp(`(?<![\\w$.])${n}\\s*(?:\\?[^.?]|&&|\\|\\|)`)];
|
|
1700
|
+
};
|
|
1701
|
+
const named = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1702
|
+
if (named) res.push(...guardOn(`${named[1]}\\??\\.id`));
|
|
1703
|
+
const destructured = /\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1704
|
+
const idName = destructured && /(?:^|,)\s*id\s*(?::\s*([A-Za-z_$][\w$]*))?\s*(?:,|$)/.exec(destructured[1]);
|
|
1705
|
+
if (idName) res.push(...guardOn(idName[1] || "id"));
|
|
1706
|
+
return res;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
function _readErrorHandlingRules(source) {
|
|
1710
|
+
const code = _stripNonCode(source);
|
|
1711
|
+
if (!READ_HOOK_CALL_RE.test(code)) return [];
|
|
1712
|
+
const errorNames = _readErrorNames(code).map((n) => n.replace(/\$/g, "\\$"));
|
|
1713
|
+
const nearError = new RegExp(String.raw`(?<![\w$.])(?:${errorNames.join("|")})(?![\w$])`);
|
|
1714
|
+
const retry = [...code.matchAll(RETRY_CONTROL_RE)].find((m) => nearError.test(_statementBefore(code, m.index)));
|
|
1715
|
+
if (!retry) return [];
|
|
1716
|
+
const branched = new RegExp(String.raw`(?<![\w$.])(?:${errorNames.join("|")})\??\.(?:retryable\b|code\s*===)`);
|
|
1717
|
+
if (branched.test(code)) return [];
|
|
1718
|
+
if (_signedInGuardRes(code).some((re) => re.test(code))) return [];
|
|
1719
|
+
const line = code.slice(0, retry.index).split(/\r?\n/).length;
|
|
1720
|
+
return [
|
|
1721
|
+
{
|
|
1722
|
+
rule: "read-error-not-branched",
|
|
1723
|
+
severity: "warning",
|
|
1724
|
+
label:
|
|
1725
|
+
`offers Retry on every read error - a viewer who may not read the ` +
|
|
1726
|
+
`table (signed out: NOT_FOUND) can never succeed. Show Retry only when ` +
|
|
1727
|
+
`error.retryable; otherwise a signed-out state or error.message.`,
|
|
1728
|
+
line,
|
|
1729
|
+
snippet: (source.split(/\r?\n/)[line - 1] || "").trim().slice(0, 200),
|
|
1730
|
+
},
|
|
1731
|
+
];
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1666
1734
|
// sc-5206 — soft warning: a `useDatastoreQuery` argument built from a raw
|
|
1667
1735
|
// `const q = useMemo(() => ({...}), [...])` re-fetches in a loop the moment
|
|
1668
1736
|
// the deps array is wrong (sc-1579's volatile-query gate exists because of
|
|
@@ -3203,6 +3271,7 @@ export function lintSource(source, options) {
|
|
|
3203
3271
|
findings.push(..._hardcodedCurrencyLabelRules(source));
|
|
3204
3272
|
findings.push(..._paymentErrorHandlingRules(source));
|
|
3205
3273
|
findings.push(..._datastoreErrorHandlingRules(source));
|
|
3274
|
+
findings.push(..._readErrorHandlingRules(source));
|
|
3206
3275
|
// sc-5206 — soft warnings steering a widget toward the two new hooks.
|
|
3207
3276
|
findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
|
|
3208
3277
|
findings.push(..._handRolledWriteGateRules(source));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.306.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"homepage": "https://github.com/Colix-AB/AppStudio",
|
|
6
6
|
"type": "module",
|
package/src/contract.js
CHANGED
|
@@ -1402,7 +1402,7 @@ const HOOKS = [
|
|
|
1402
1402
|
data: "Record | null",
|
|
1403
1403
|
loading: "boolean",
|
|
1404
1404
|
fetching: "boolean",
|
|
1405
|
-
error: "DatastoreError | null",
|
|
1405
|
+
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",
|
|
1406
1406
|
refetch: "() => Promise<void>",
|
|
1407
1407
|
},
|
|
1408
1408
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -1995,7 +1995,7 @@ const HOOKS = [
|
|
|
1995
1995
|
total: "number | null",
|
|
1996
1996
|
loading: "boolean",
|
|
1997
1997
|
fetching: "boolean",
|
|
1998
|
-
error: "DatastoreError | null",
|
|
1998
|
+
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",
|
|
1999
1999
|
refetch: "() => Promise<void>",
|
|
2000
2000
|
},
|
|
2001
2001
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2029,7 +2029,7 @@ const HOOKS = [
|
|
|
2029
2029
|
loading: "boolean",
|
|
2030
2030
|
fetching: "boolean",
|
|
2031
2031
|
loadingMore: "boolean",
|
|
2032
|
-
error: "DatastoreError | null",
|
|
2032
|
+
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",
|
|
2033
2033
|
loadMore: "() => void",
|
|
2034
2034
|
retry: "() => void",
|
|
2035
2035
|
refetch: "() => Promise<void>",
|
|
@@ -2063,7 +2063,7 @@ const HOOKS = [
|
|
|
2063
2063
|
truncated: "boolean",
|
|
2064
2064
|
loading: "boolean",
|
|
2065
2065
|
fetching: "boolean",
|
|
2066
|
-
error: "DatastoreError | null",
|
|
2066
|
+
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",
|
|
2067
2067
|
refetch: "() => Promise<void>",
|
|
2068
2068
|
},
|
|
2069
2069
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -2103,7 +2103,7 @@ const HOOKS = [
|
|
|
2103
2103
|
"Array<{ group, count, sum }> // by a column; a USER column's group is the user id",
|
|
2104
2104
|
loading: "boolean",
|
|
2105
2105
|
fetching: "boolean",
|
|
2106
|
-
error: "DatastoreError | null",
|
|
2106
|
+
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",
|
|
2107
2107
|
refetch: "() => Promise<void>",
|
|
2108
2108
|
},
|
|
2109
2109
|
requiredContextSlice: ["datastore.records"],
|
|
@@ -6914,7 +6914,9 @@ const CONTRACT = deepFreeze({
|
|
|
6914
6914
|
// the web for pointer devices when it overflows; `showsScrollAffordance` turns it off.
|
|
6915
6915
|
// 1.249.0: a `<Button>` follows its parent's cross-axis alignment instead
|
|
6916
6916
|
// of forcing `alignSelf: "flex-start"`; it still hugs its label.
|
|
6917
|
-
|
|
6917
|
+
// 1.250.0: documentation (sc-16511) — the read hooks' `error` names the
|
|
6918
|
+
// `{ code, message, retryable }` it has always carried; Retry only when retryable.
|
|
6919
|
+
version: "1.250.0",
|
|
6918
6920
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6919
6921
|
hooks: HOOKS,
|
|
6920
6922
|
primitives: PRIMITIVES,
|