farseer-cli 1.11.0 → 1.11.2

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.
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var nameResolver_exports = {};
20
+ __export(nameResolver_exports, {
21
+ formatAmbiguous: () => formatAmbiguous,
22
+ matchByName: () => matchByName,
23
+ selectByNameOrId: () => selectByNameOrId
24
+ });
25
+ module.exports = __toCommonJS(nameResolver_exports);
26
+ function matchByName(items, name) {
27
+ const needle = name.trim().toLowerCase();
28
+ return items.filter((item) => item.name.toLowerCase() === needle);
29
+ }
30
+ function selectByNameOrId(items, selector, idOf) {
31
+ const id = selector.id?.trim();
32
+ if (id) {
33
+ const entity = items.find((item) => idOf(item) === id);
34
+ if (!entity) {
35
+ return { kind: "notFound" };
36
+ }
37
+ const name = selector.name?.trim();
38
+ if (name && matchByName([entity], name).length === 0) {
39
+ return { kind: "conflict", entity, name };
40
+ }
41
+ return { kind: "found", entity };
42
+ }
43
+ const matches = matchByName(items, selector.name ?? "");
44
+ if (matches.length === 1) {
45
+ return { kind: "found", entity: matches[0] };
46
+ }
47
+ if (matches.length === 0) {
48
+ return { kind: "notFound" };
49
+ }
50
+ return { kind: "ambiguous", matches };
51
+ }
52
+ function formatAmbiguous(plural, name, matches, idOf) {
53
+ const lines = matches.map((item) => ` id ${idOf(item)} ${item.name}`);
54
+ return `Multiple ${plural} named "${name}" (${matches.length}). Specify one by id:
55
+ ${lines.join("\n")}`;
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ formatAmbiguous,
60
+ matchByName,
61
+ selectByNameOrId
62
+ });
63
+ //# sourceMappingURL=nameResolver.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/nameResolver.ts"],
4
+ "sourcesContent": ["/**\n * Resolving a user-typed name to one thing.\n *\n * The backend enforces name uniqueness per folder, not per tenant, so any\n * lookup that searches a whole tenant can find more than one match. Picking the\n * first is the bug this exists to prevent: it acts on an arbitrary one of them\n * and leaves the others unreachable by name.\n *\n * Pure. Each surface renders the outcome its own way \u2014 the CLI exits, the MCP\n * tools return an error response.\n */\n\nexport type Selection<T> =\n | { kind: 'found'; entity: T }\n | { kind: 'notFound' }\n | { kind: 'ambiguous'; matches: T[] }\n // Only when both a name and an id were given; see selectByNameOrId.\n | { kind: 'conflict'; entity: T; name: string };\n\n/** Every entity whose name matches, case-insensitively. */\nexport function matchByName<T extends { name: string }>(items: readonly T[], name: string): T[] {\n const needle = name.trim().toLowerCase();\n return items.filter((item) => item.name.toLowerCase() === needle);\n}\n\n/**\n * An id (unique) decides over a name (may collide). `idOf` reads whichever id\n * the caller disambiguates by, which is not always the one used to address the\n * entity afterwards \u2014 an app is selected by its Remote Job id but deleted by\n * its folder-item id.\n *\n * A name given alongside the id is a claim about which entity that is, and one\n * that does not hold is a conflict rather than something the id overrides: on\n * the CLI it is a tenant name read as an app name, and dropping it acts on the\n * id in the wrong tenant.\n */\nexport function selectByNameOrId<T extends { name: string }>(\n items: readonly T[],\n selector: { name?: string; id?: string },\n idOf: (item: T) => string,\n): Selection<T> {\n const id = selector.id?.trim();\n if (id) {\n const entity = items.find((item) => idOf(item) === id);\n if (!entity) {\n return { kind: 'notFound' };\n }\n const name = selector.name?.trim();\n if (name && matchByName([entity], name).length === 0) {\n return { kind: 'conflict', entity, name };\n }\n return { kind: 'found', entity };\n }\n\n const matches = matchByName(items, selector.name ?? '');\n if (matches.length === 1) {\n return { kind: 'found', entity: matches[0] };\n }\n if (matches.length === 0) {\n return { kind: 'notFound' };\n }\n return { kind: 'ambiguous', matches };\n}\n\n/**\n * Lists each candidate's id. Deliberately free of `--id` wording so it reads\n * correctly from the MCP tools too; the CLI appends its own hint.\n */\nexport function formatAmbiguous<T extends { name: string }>(\n plural: string,\n name: string,\n matches: readonly T[],\n idOf: (item: T) => string,\n): string {\n const lines = matches.map((item) => ` id ${idOf(item)} ${item.name}`);\n return `Multiple ${plural} named \"${name}\" (${matches.length}). Specify one by id:\\n${lines.join('\\n')}`;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,YAAwC,OAAqB,MAAmB;AAC5F,QAAM,SAAS,KAAK,KAAK,EAAE,YAAY;AACvC,SAAO,MAAM,OAAO,CAAC,SAAS,KAAK,KAAK,YAAY,MAAM,MAAM;AACpE;AAaO,SAAS,iBACZ,OACA,UACA,MACY;AACZ,QAAM,KAAK,SAAS,IAAI,KAAK;AAC7B,MAAI,IAAI;AACJ,UAAM,SAAS,MAAM,KAAK,CAAC,SAAS,KAAK,IAAI,MAAM,EAAE;AACrD,QAAI,CAAC,QAAQ;AACT,aAAO,EAAE,MAAM,WAAW;AAAA,IAC9B;AACA,UAAM,OAAO,SAAS,MAAM,KAAK;AACjC,QAAI,QAAQ,YAAY,CAAC,MAAM,GAAG,IAAI,EAAE,WAAW,GAAG;AAClD,aAAO,EAAE,MAAM,YAAY,QAAQ,KAAK;AAAA,IAC5C;AACA,WAAO,EAAE,MAAM,SAAS,OAAO;AAAA,EACnC;AAEA,QAAM,UAAU,YAAY,OAAO,SAAS,QAAQ,EAAE;AACtD,MAAI,QAAQ,WAAW,GAAG;AACtB,WAAO,EAAE,MAAM,SAAS,QAAQ,QAAQ,CAAC,EAAE;AAAA,EAC/C;AACA,MAAI,QAAQ,WAAW,GAAG;AACtB,WAAO,EAAE,MAAM,WAAW;AAAA,EAC9B;AACA,SAAO,EAAE,MAAM,aAAa,QAAQ;AACxC;AAMO,SAAS,gBACZ,QACA,MACA,SACA,MACM;AACN,QAAM,QAAQ,QAAQ,IAAI,CAAC,SAAS,QAAQ,KAAK,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;AACxE,SAAO,YAAY,MAAM,WAAW,IAAI,MAAM,QAAQ,MAAM;AAAA,EAA0B,MAAM,KAAK,IAAI,CAAC;AAC1G;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "farseer-cli",
3
- "version": "1.11.0",
3
+ "version": "1.11.2",
4
4
  "description": "CLI tool for syncing Farseer App scripts between local folder and Farseer instances",
5
5
  "main": "dist/index.js",
6
6
  "bin": {