@colixsystems/widget-sdk 0.322.0 → 0.323.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 +5 -1
- package/dist/contract.cjs +3 -1
- package/dist/contract.js +3 -1
- package/dist/linter.cjs +43 -0
- package/dist/linter.js +43 -0
- package/package.json +1 -1
- package/src/contract.js +3 -1
package/README.md
CHANGED
|
@@ -91,7 +91,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.323.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.323.0 (contract 1.263.0)
|
|
97
|
+
|
|
98
|
+
**The linter refuses a setting that takes group ids as typed text.** A maker cannot see which groups a pasted id names, and Copy Workspace swaps a group id only when the setting holds exactly that id, so a list of ids in one string still points at the old workspace's groups after a copy. A `propertySchema` field of type `string` (or an array of strings), at the top level or inside an object or an array item, whose name contains `group` (not a display-text name such as `groupLabel` / `groupTitle`, nor `groupBy`), or whose label or description pairs group with id, uuid, list or comma wording, is now the publish-blocking `group-ids-as-text` finding, in a widget that works with the app's user groups (its source reads `groupIds`, as in `useUser().groupIds`, or calls `useGroups(`). Declare `{ type: "groupRef", label }` for one group, or `{ type: "array", label, items: { type: "groupRef", label } }` for several: the Studio renders a group picker per item, and the widget receives the id or an array of ids. Settings saved before the change still hold the old comma-separated string, so read both forms (split a string on commas), and the maker re-picks the groups in the Studio. Widgets already published keep working; the check runs on their next submit.
|
|
95
99
|
|
|
96
100
|
### What's new in 0.322.0 (contract 1.262.0)
|
|
97
101
|
|
package/dist/contract.cjs
CHANGED
|
@@ -7025,7 +7025,9 @@ const CONTRACT = deepFreeze({
|
|
|
7025
7025
|
// publish-blocking `bankid-order-not-shown` finding.
|
|
7026
7026
|
// 1.262.0: stricter lint (sc-16000) — a charging widget whose create or
|
|
7027
7027
|
// update writes a paid status is the `payment-status-written` warning.
|
|
7028
|
-
|
|
7028
|
+
// 1.263.0: stricter lint — in a widget reading groupIds or useGroups(), a
|
|
7029
|
+
// propertySchema text field holding group ids is `group-ids-as-text`.
|
|
7030
|
+
version: "1.263.0",
|
|
7029
7031
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7030
7032
|
hooks: HOOKS,
|
|
7031
7033
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -7020,7 +7020,9 @@ const CONTRACT = deepFreeze({
|
|
|
7020
7020
|
// publish-blocking `bankid-order-not-shown` finding.
|
|
7021
7021
|
// 1.262.0: stricter lint (sc-16000) — a charging widget whose create or
|
|
7022
7022
|
// update writes a paid status is the `payment-status-written` warning.
|
|
7023
|
-
|
|
7023
|
+
// 1.263.0: stricter lint — in a widget reading groupIds or useGroups(), a
|
|
7024
|
+
// propertySchema text field holding group ids is `group-ids-as-text`.
|
|
7025
|
+
version: "1.263.0",
|
|
7024
7026
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7025
7027
|
hooks: HOOKS,
|
|
7026
7028
|
primitives: PRIMITIVES,
|
package/dist/linter.cjs
CHANGED
|
@@ -1035,6 +1035,48 @@ function _manifestActionRules(manifest) {
|
|
|
1035
1035
|
return findings;
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
1038
|
+
// Typed group ids hide the groups and break on Copy Workspace.
|
|
1039
|
+
const READS_USER_GROUPS = /\bgroupIds\b|\buseGroups\s*\(/;
|
|
1040
|
+
const GROUP_WORD = /group|grupp/i;
|
|
1041
|
+
const ID_LIST_WORDING = /\b(?:ids?|uuids?|list)\b|comma|komma/i;
|
|
1042
|
+
const NOT_A_GROUP_REF_NAME = /group(?:by|ing|ed)|(?:label|title|heading|header|caption|text)$/i;
|
|
1043
|
+
|
|
1044
|
+
function _holdsGroupIds(name, def) {
|
|
1045
|
+
if (GROUP_WORD.test(name) && !NOT_A_GROUP_REF_NAME.test(name)) return true;
|
|
1046
|
+
const wording = `${def.label ?? ""} ${def.description ?? ""}`;
|
|
1047
|
+
return GROUP_WORD.test(wording) && ID_LIST_WORDING.test(wording);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function _groupIdTextFields(schema, prefix, out) {
|
|
1051
|
+
if (!schema || typeof schema !== "object") return out;
|
|
1052
|
+
for (const [name, def] of Object.entries(schema)) {
|
|
1053
|
+
if (!def || typeof def !== "object") continue;
|
|
1054
|
+
const path = prefix + name;
|
|
1055
|
+
const items = def.items && typeof def.items === "object" ? def.items : null;
|
|
1056
|
+
const isText = def.type === "string" || (def.type === "array" && items !== null && items.type === "string");
|
|
1057
|
+
if (isText && _holdsGroupIds(name, def)) out.push(path);
|
|
1058
|
+
if (def.type === "object") _groupIdTextFields(def.properties, `${path}.`, out);
|
|
1059
|
+
if (items !== null && items.type === "object") _groupIdTextFields(items.properties, `${path}[].`, out);
|
|
1060
|
+
}
|
|
1061
|
+
return out;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
function _groupIdTextRules(source, manifest) {
|
|
1065
|
+
if (!manifest || typeof manifest !== "object") return [];
|
|
1066
|
+
if (!READS_USER_GROUPS.test(_stripNonCode(source))) return [];
|
|
1067
|
+
return _groupIdTextFields(manifest.propertySchema, "", []).map((path) => ({
|
|
1068
|
+
rule: "group-ids-as-text",
|
|
1069
|
+
severity: "error",
|
|
1070
|
+
label:
|
|
1071
|
+
`propertySchema.${path} takes the app's user groups as typed text: makers cannot see which groups they chose, ` +
|
|
1072
|
+
"and a workspace copy cannot carry them over. Declare { type: \"groupRef\", label } for one group, or " +
|
|
1073
|
+
"{ type: \"array\", label, items: { type: \"groupRef\", label } } for several. Saved settings keep the old text, " +
|
|
1074
|
+
"so read both forms (split a string on commas); the maker re-picks the groups in the Studio.",
|
|
1075
|
+
line: 0,
|
|
1076
|
+
snippet: "",
|
|
1077
|
+
}));
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1038
1080
|
// sc-1366 — invalid lucide icon import gate. lucide-react-native is a vetted
|
|
1039
1081
|
// import that the bundler EXTERNALISES, so esbuild never checks the named
|
|
1040
1082
|
// imports; a name that does not exist in the pinned version (`House` was added
|
|
@@ -3669,6 +3711,7 @@ function lintSource(source, options) {
|
|
|
3669
3711
|
);
|
|
3670
3712
|
// REQ-WIDGET-ACTION — structural validation of manifest-declared actions.
|
|
3671
3713
|
findings.push(..._manifestActionRules(options && options.manifest));
|
|
3714
|
+
findings.push(..._groupIdTextRules(source, options && options.manifest));
|
|
3672
3715
|
findings.push(..._badgeCounterRules(source, options && options.manifest));
|
|
3673
3716
|
const hasErrors = findings.some((f) => f.severity !== "warning");
|
|
3674
3717
|
return { ok: !hasErrors, findings };
|
package/dist/linter.js
CHANGED
|
@@ -1030,6 +1030,48 @@ function _manifestActionRules(manifest) {
|
|
|
1030
1030
|
return findings;
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
1033
|
+
// Typed group ids hide the groups and break on Copy Workspace.
|
|
1034
|
+
const READS_USER_GROUPS = /\bgroupIds\b|\buseGroups\s*\(/;
|
|
1035
|
+
const GROUP_WORD = /group|grupp/i;
|
|
1036
|
+
const ID_LIST_WORDING = /\b(?:ids?|uuids?|list)\b|comma|komma/i;
|
|
1037
|
+
const NOT_A_GROUP_REF_NAME = /group(?:by|ing|ed)|(?:label|title|heading|header|caption|text)$/i;
|
|
1038
|
+
|
|
1039
|
+
function _holdsGroupIds(name, def) {
|
|
1040
|
+
if (GROUP_WORD.test(name) && !NOT_A_GROUP_REF_NAME.test(name)) return true;
|
|
1041
|
+
const wording = `${def.label ?? ""} ${def.description ?? ""}`;
|
|
1042
|
+
return GROUP_WORD.test(wording) && ID_LIST_WORDING.test(wording);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
function _groupIdTextFields(schema, prefix, out) {
|
|
1046
|
+
if (!schema || typeof schema !== "object") return out;
|
|
1047
|
+
for (const [name, def] of Object.entries(schema)) {
|
|
1048
|
+
if (!def || typeof def !== "object") continue;
|
|
1049
|
+
const path = prefix + name;
|
|
1050
|
+
const items = def.items && typeof def.items === "object" ? def.items : null;
|
|
1051
|
+
const isText = def.type === "string" || (def.type === "array" && items !== null && items.type === "string");
|
|
1052
|
+
if (isText && _holdsGroupIds(name, def)) out.push(path);
|
|
1053
|
+
if (def.type === "object") _groupIdTextFields(def.properties, `${path}.`, out);
|
|
1054
|
+
if (items !== null && items.type === "object") _groupIdTextFields(items.properties, `${path}[].`, out);
|
|
1055
|
+
}
|
|
1056
|
+
return out;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
function _groupIdTextRules(source, manifest) {
|
|
1060
|
+
if (!manifest || typeof manifest !== "object") return [];
|
|
1061
|
+
if (!READS_USER_GROUPS.test(_stripNonCode(source))) return [];
|
|
1062
|
+
return _groupIdTextFields(manifest.propertySchema, "", []).map((path) => ({
|
|
1063
|
+
rule: "group-ids-as-text",
|
|
1064
|
+
severity: "error",
|
|
1065
|
+
label:
|
|
1066
|
+
`propertySchema.${path} takes the app's user groups as typed text: makers cannot see which groups they chose, ` +
|
|
1067
|
+
"and a workspace copy cannot carry them over. Declare { type: \"groupRef\", label } for one group, or " +
|
|
1068
|
+
"{ type: \"array\", label, items: { type: \"groupRef\", label } } for several. Saved settings keep the old text, " +
|
|
1069
|
+
"so read both forms (split a string on commas); the maker re-picks the groups in the Studio.",
|
|
1070
|
+
line: 0,
|
|
1071
|
+
snippet: "",
|
|
1072
|
+
}));
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1033
1075
|
// sc-1366 — invalid lucide icon import gate. lucide-react-native is a vetted
|
|
1034
1076
|
// import that the bundler EXTERNALISES, so esbuild never checks the named
|
|
1035
1077
|
// imports; a name that does not exist in the pinned version (`House` was added
|
|
@@ -3664,6 +3706,7 @@ export function lintSource(source, options) {
|
|
|
3664
3706
|
);
|
|
3665
3707
|
// REQ-WIDGET-ACTION — structural validation of manifest-declared actions.
|
|
3666
3708
|
findings.push(..._manifestActionRules(options && options.manifest));
|
|
3709
|
+
findings.push(..._groupIdTextRules(source, options && options.manifest));
|
|
3667
3710
|
findings.push(..._badgeCounterRules(source, options && options.manifest));
|
|
3668
3711
|
const hasErrors = findings.some((f) => f.severity !== "warning");
|
|
3669
3712
|
return { ok: !hasErrors, findings };
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -7020,7 +7020,9 @@ const CONTRACT = deepFreeze({
|
|
|
7020
7020
|
// publish-blocking `bankid-order-not-shown` finding.
|
|
7021
7021
|
// 1.262.0: stricter lint (sc-16000) — a charging widget whose create or
|
|
7022
7022
|
// update writes a paid status is the `payment-status-written` warning.
|
|
7023
|
-
|
|
7023
|
+
// 1.263.0: stricter lint — in a widget reading groupIds or useGroups(), a
|
|
7024
|
+
// propertySchema text field holding group ids is `group-ids-as-text`.
|
|
7025
|
+
version: "1.263.0",
|
|
7024
7026
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7025
7027
|
hooks: HOOKS,
|
|
7026
7028
|
primitives: PRIMITIVES,
|