@wrangled/cli 0.3.25 → 0.3.26
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/main.js +26 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1326,7 +1326,11 @@ const commands = {
|
|
|
1326
1326
|
const { fact } = await api(await resolveConnection(options.apiUrl), `${FACTS_PATH}/${encodeURIComponent(args[0])}`);
|
|
1327
1327
|
if (options.format === "json")
|
|
1328
1328
|
return printJson({ fact });
|
|
1329
|
-
|
|
1329
|
+
const nameKey = fact.key === NAME_KEY ? nameKeyLines(fact.value) : null;
|
|
1330
|
+
const value = nameKey ? { means: fact.value.means } : { value: fact.value };
|
|
1331
|
+
printFields({ ...factRow(fact), summary: fact.summary, ...value, evidence: fact.evidence, author: fact.author, "confirmed by": fact.confirmedBy, "decided by": fact.decidedBy, replaces: fact.replaces });
|
|
1332
|
+
if (nameKey)
|
|
1333
|
+
console.log(nameKey.join("\n"));
|
|
1330
1334
|
},
|
|
1331
1335
|
},
|
|
1332
1336
|
"facts propose": {
|
|
@@ -1948,6 +1952,27 @@ function voiceLineRow(l) {
|
|
|
1948
1952
|
function factRow(f) {
|
|
1949
1953
|
return { id: f.id, kind: f.kind, subject: `${f.subjectType}:${f.subjectRef}`, key: f.key, status: f.status, summary: excerpt(f.summary, 80) };
|
|
1950
1954
|
}
|
|
1955
|
+
/** The definition key that holds a workspace's name key: the server's NameKey, read here without its schema. */
|
|
1956
|
+
const NAME_KEY = "ad_name_key";
|
|
1957
|
+
const NAME_LEVELS = { campaign: "campaign", ad_set: "ad set", ad: "ad" };
|
|
1958
|
+
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1959
|
+
const arrayOf = (v) => (Array.isArray(v) ? v.filter(isObject) : []);
|
|
1960
|
+
/** A name key as lines a person reads: each pattern with an example name and what its segments mean, then the questions left. Null when the value holds none. */
|
|
1961
|
+
function nameKeyLines(value) {
|
|
1962
|
+
const nameKey = isObject(value) && isObject(value.name_key) ? value.name_key : null;
|
|
1963
|
+
if (!nameKey || !isObject(nameKey.levels))
|
|
1964
|
+
return null;
|
|
1965
|
+
const levels = nameKey.levels;
|
|
1966
|
+
const patterns = Object.entries(NAME_LEVELS).flatMap(([level, label]) => arrayOf(levels[level]).map((pattern) => {
|
|
1967
|
+
const segments = arrayOf(pattern.segments).map((s) => {
|
|
1968
|
+
const meaning = typeof s.label === "string" ? s.label : String(s.meaning ?? "unknown").replaceAll("_", " ");
|
|
1969
|
+
return `${String(s.name)} = ${meaning}${s.certainty === "guess" ? " (a guess)" : ""}`;
|
|
1970
|
+
});
|
|
1971
|
+
return `- ${label} names like ${String(pattern.example)}: ${segments.join("; ")}`;
|
|
1972
|
+
}));
|
|
1973
|
+
const questions = arrayOf(nameKey.open_questions).map((q) => `- ${String(q.text)}`);
|
|
1974
|
+
return ["", "Name patterns:", ...(patterns.length > 0 ? patterns : ["- none yet"]), "", "Open questions:", ...(questions.length > 0 ? questions : ["- none"])];
|
|
1975
|
+
}
|
|
1951
1976
|
const STORIES_PATH = "/api/v1/stories";
|
|
1952
1977
|
function printStory(story) {
|
|
1953
1978
|
const corrects = story.previousId ? `, correcting ${story.previousId}` : "";
|