pairit 0.3.5 → 0.3.6
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/dist/index.js +90 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9808,6 +9808,94 @@ async function loadKeytar() {
|
|
|
9808
9808
|
}
|
|
9809
9809
|
}
|
|
9810
9810
|
|
|
9811
|
+
// src/group-lint.ts
|
|
9812
|
+
var GROUP_PATH = /^group(?:\.[A-Za-z0-9_]+)*/;
|
|
9813
|
+
var TEMPLATE = /\{\{\s*(group\.[A-Za-z0-9_.]+)\s*\}\}/g;
|
|
9814
|
+
function lintGroupView(config) {
|
|
9815
|
+
const errors = [];
|
|
9816
|
+
const shared = new Set;
|
|
9817
|
+
if (Array.isArray(config.matchmaking)) {
|
|
9818
|
+
config.matchmaking.forEach((pool, index) => {
|
|
9819
|
+
const share = pool?.share;
|
|
9820
|
+
if (share === undefined)
|
|
9821
|
+
return;
|
|
9822
|
+
if (!Array.isArray(share) || !share.every((key) => typeof key === "string" && /^\w+$/.test(key))) {
|
|
9823
|
+
errors.push(`matchmaking[${index}].share must be a list of session_state keys`);
|
|
9824
|
+
return;
|
|
9825
|
+
}
|
|
9826
|
+
for (const key of share)
|
|
9827
|
+
shared.add(key);
|
|
9828
|
+
});
|
|
9829
|
+
}
|
|
9830
|
+
const fields = new Map;
|
|
9831
|
+
for (const page of config.pages ?? []) {
|
|
9832
|
+
for (const component of page.components ?? []) {
|
|
9833
|
+
const c = component;
|
|
9834
|
+
if (c?.type !== "live-workspace" || c.props?.scope !== "group" || c.props?.mode !== "structured" || !Array.isArray(c.props.fields))
|
|
9835
|
+
continue;
|
|
9836
|
+
for (const field of c.props.fields) {
|
|
9837
|
+
const id = field?.id;
|
|
9838
|
+
if (typeof id !== "string")
|
|
9839
|
+
continue;
|
|
9840
|
+
const other = fields.get(id);
|
|
9841
|
+
if (other && other !== page.id) {
|
|
9842
|
+
errors.push(`group workspace field ${id} is on both ${other} and ${page.id}; group.ws needs unique field ids`);
|
|
9843
|
+
}
|
|
9844
|
+
fields.set(id, page.id ?? "");
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
}
|
|
9848
|
+
const checkPath = (where, path2) => {
|
|
9849
|
+
const [, part, ...rest] = path2.split(".");
|
|
9850
|
+
if (part === "ws") {
|
|
9851
|
+
const field = rest[0];
|
|
9852
|
+
if (field && !fields.has(field)) {
|
|
9853
|
+
errors.push(`${where}: ${path2} is not a field of a structured group workspace`);
|
|
9854
|
+
}
|
|
9855
|
+
return;
|
|
9856
|
+
}
|
|
9857
|
+
if (part === "others") {
|
|
9858
|
+
const [index, key] = rest;
|
|
9859
|
+
if (index !== undefined && !/^\d+$/.test(index)) {
|
|
9860
|
+
errors.push(`${where}: ${path2} needs a member number, like group.others.0`);
|
|
9861
|
+
} else if (key && !shared.has(key)) {
|
|
9862
|
+
errors.push(`${where}: ${path2} reads ${key}, which no matchmaking pool lists in share`);
|
|
9863
|
+
}
|
|
9864
|
+
return;
|
|
9865
|
+
}
|
|
9866
|
+
errors.push(`${where}: ${path2} should start with group.ws or group.others`);
|
|
9867
|
+
};
|
|
9868
|
+
const walk = (where, value, key) => {
|
|
9869
|
+
if (typeof value === "string") {
|
|
9870
|
+
if (key === "when") {
|
|
9871
|
+
const path2 = value.trim().match(GROUP_PATH)?.[0];
|
|
9872
|
+
if (path2 && path2 !== "group")
|
|
9873
|
+
checkPath(where, path2);
|
|
9874
|
+
}
|
|
9875
|
+
for (const match of value.matchAll(TEMPLATE))
|
|
9876
|
+
checkPath(where, match[1]);
|
|
9877
|
+
return;
|
|
9878
|
+
}
|
|
9879
|
+
if (Array.isArray(value)) {
|
|
9880
|
+
for (const item of value)
|
|
9881
|
+
walk(where, item);
|
|
9882
|
+
return;
|
|
9883
|
+
}
|
|
9884
|
+
if (value && typeof value === "object") {
|
|
9885
|
+
for (const [k, v] of Object.entries(value))
|
|
9886
|
+
walk(where, v, k);
|
|
9887
|
+
}
|
|
9888
|
+
};
|
|
9889
|
+
config.pages?.forEach((page, index) => {
|
|
9890
|
+
walk(page.id ?? `pages[${index}]`, page);
|
|
9891
|
+
});
|
|
9892
|
+
config.agents?.forEach((agent, index) => {
|
|
9893
|
+
const id = agent?.id;
|
|
9894
|
+
walk(typeof id === "string" ? `agent ${id}` : `agents[${index}]`, agent);
|
|
9895
|
+
});
|
|
9896
|
+
return errors;
|
|
9897
|
+
}
|
|
9898
|
+
|
|
9811
9899
|
// src/html-assets.ts
|
|
9812
9900
|
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
9813
9901
|
import path2 from "node:path";
|
|
@@ -10027,7 +10115,7 @@ function singleGroupSize(config) {
|
|
|
10027
10115
|
|
|
10028
10116
|
// src/index.ts
|
|
10029
10117
|
var program2 = new Command;
|
|
10030
|
-
program2.name("pairit").description("CLI for Pairit experiment configs").version("0.3.
|
|
10118
|
+
program2.name("pairit").description("CLI for Pairit experiment configs").version("0.3.6").option("--env <name>", "Target environment: staging or production", (value) => {
|
|
10031
10119
|
try {
|
|
10032
10120
|
return parseEnvName(value);
|
|
10033
10121
|
} catch (error) {
|
|
@@ -10346,6 +10434,7 @@ async function lintConfig(configPath) {
|
|
|
10346
10434
|
});
|
|
10347
10435
|
}
|
|
10348
10436
|
errors.push(...lintRandomization(config));
|
|
10437
|
+
errors.push(...lintGroupView(config));
|
|
10349
10438
|
if (errors.length) {
|
|
10350
10439
|
throw new Error(errors.join(", "));
|
|
10351
10440
|
}
|