@colixsystems/widget-sdk 0.277.0 → 0.277.1
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 +5 -1
- package/dist/linter.cjs +11 -2
- package/dist/linter.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,7 +86,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
86
86
|
|
|
87
87
|
## Status
|
|
88
88
|
|
|
89
|
-
`v0.277.
|
|
89
|
+
`v0.277.1` — 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**.
|
|
90
|
+
|
|
91
|
+
### What's new in 0.277.1
|
|
92
|
+
|
|
93
|
+
**`hand-rolled-write-gate` no longer fires on `theme.typography.roles`.** The rule looked for `.roles` / `.groupIds` anywhere in the file, so a writing widget that called `useUser()` and styled its text with `theme.typography.roles[name]` was flagged on the `useUser()` line and, through the publish gate, refused. It now reads only the value `useUser()` returns: the identifier it is assigned to (`user.roles`, `user?.groupIds`), a destructured `{ roles }` or `{ groupIds }`, or `useUser().roles` inline. Gating a write on `user.roles` without `useCanWrite` still warns.
|
|
90
94
|
|
|
91
95
|
### What's new in 0.277.0
|
|
92
96
|
|
package/dist/linter.cjs
CHANGED
|
@@ -1589,13 +1589,22 @@ function _rawUseMemoIntoDatastoreQueryRules(source) {
|
|
|
1589
1589
|
// `.roles` re-implements the table ACL client-side and drifts from it the
|
|
1590
1590
|
// moment the ACL changes; `useCanWrite(tableId)` reads the same rule the
|
|
1591
1591
|
// write endpoint enforces. Flags only when the file has NOT already reached
|
|
1592
|
-
// for it.
|
|
1592
|
+
// for it, and only on useUser()'s own value: `theme.typography.roles` is a
|
|
1593
|
+
// style read (sc-15204).
|
|
1594
|
+
function _readsUserRoles(code) {
|
|
1595
|
+
const named = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1596
|
+
if (named && new RegExp(`\\b${named[1].replace(/\$/g, "\\$")}\\??\\.(groupIds|roles)\\b`).test(code)) return true;
|
|
1597
|
+
const destructured = /\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1598
|
+
if (destructured && /\b(groupIds|roles)\b/.test(destructured[1])) return true;
|
|
1599
|
+
return /\buseUser\s*\(\s*\)\s*\??\.(groupIds|roles)\b/.test(code);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1593
1602
|
function _handRolledWriteGateRules(source) {
|
|
1594
1603
|
const code = _stripNonCode(source);
|
|
1595
1604
|
if (/\buseCanWrite\s*\(/.test(code)) return [];
|
|
1596
1605
|
const userCall = /\buseUser\s*\(\s*\)/.exec(code);
|
|
1597
1606
|
if (!userCall) return [];
|
|
1598
|
-
if (
|
|
1607
|
+
if (!_readsUserRoles(code)) return [];
|
|
1599
1608
|
const hasWrite =
|
|
1600
1609
|
/\.(create|update)\s*\(/.test(code) ||
|
|
1601
1610
|
/\buseDatastoreMutation\s*\(/.test(code);
|
package/dist/linter.js
CHANGED
|
@@ -1584,13 +1584,22 @@ function _rawUseMemoIntoDatastoreQueryRules(source) {
|
|
|
1584
1584
|
// `.roles` re-implements the table ACL client-side and drifts from it the
|
|
1585
1585
|
// moment the ACL changes; `useCanWrite(tableId)` reads the same rule the
|
|
1586
1586
|
// write endpoint enforces. Flags only when the file has NOT already reached
|
|
1587
|
-
// for it.
|
|
1587
|
+
// for it, and only on useUser()'s own value: `theme.typography.roles` is a
|
|
1588
|
+
// style read (sc-15204).
|
|
1589
|
+
function _readsUserRoles(code) {
|
|
1590
|
+
const named = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1591
|
+
if (named && new RegExp(`\\b${named[1].replace(/\$/g, "\\$")}\\??\\.(groupIds|roles)\\b`).test(code)) return true;
|
|
1592
|
+
const destructured = /\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*useUser\s*\(\s*\)/.exec(code);
|
|
1593
|
+
if (destructured && /\b(groupIds|roles)\b/.test(destructured[1])) return true;
|
|
1594
|
+
return /\buseUser\s*\(\s*\)\s*\??\.(groupIds|roles)\b/.test(code);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1588
1597
|
function _handRolledWriteGateRules(source) {
|
|
1589
1598
|
const code = _stripNonCode(source);
|
|
1590
1599
|
if (/\buseCanWrite\s*\(/.test(code)) return [];
|
|
1591
1600
|
const userCall = /\buseUser\s*\(\s*\)/.exec(code);
|
|
1592
1601
|
if (!userCall) return [];
|
|
1593
|
-
if (
|
|
1602
|
+
if (!_readsUserRoles(code)) return [];
|
|
1594
1603
|
const hasWrite =
|
|
1595
1604
|
/\.(create|update)\s*\(/.test(code) ||
|
|
1596
1605
|
/\buseDatastoreMutation\s*\(/.test(code);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.277.
|
|
3
|
+
"version": "0.277.1",
|
|
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",
|