@sortlist/cli 0.51.0 → 0.53.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 +17 -31
- package/dist/index.js +149 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ sl token # prints access token to stdout (useful for curl/scripts)
|
|
|
37
37
|
|
|
38
38
|
### When commands are missing
|
|
39
39
|
|
|
40
|
-
The CLI builds its commands from the schema the federation router returns, and the router filters that schema by the scopes in your token. A service you hold no scope for therefore has **no commands at all** — `sl organizations` reports `unknown command`, not a permission error.
|
|
40
|
+
The CLI builds its commands from the schema the federation router returns, and the router filters that schema by the scopes in your token. A service you hold no scope for therefore has **no commands at all** — `sl atlas find-organizations` reports `unknown command`, not a permission error.
|
|
41
41
|
|
|
42
42
|
`sl login` warns when a service came back with nothing:
|
|
43
43
|
|
|
@@ -65,36 +65,21 @@ A person can belong to several companies, and a subgraph that counts usage — A
|
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
sl config set company spin42 # for every command from now on
|
|
68
|
-
sl contacts --company spin42 … # for one call
|
|
68
|
+
sl atlas find-contacts --company spin42 … # for one call
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
## Revealing contact details
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
Finding a contact shows only the reach details your company already owns — a name, an email, a phone, a LinkedIn profile each come back empty until revealed — and Atlas says so beside every row. Revealing is explicit, in the same command, with `--reveal`: a comma-separated list of dimensions named after what they unlock (`contactIdentity`, `contactEmailAddress`, `contactPhoneNumber`, `contactLinkedinUrl`, and `organization…` for organizations). Whoever may read contacts may reveal them: nothing beyond `atlas/organization:read` is needed. Every Atlas command is checked with Hermes first: you must still be a member of the company you act for, or the application must belong to it, otherwise the whole command is refused with a 403 and nothing is recorded — the token's claim was stamped at login and can outlive a membership.
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
sl contacts --first
|
|
77
|
-
|
|
76
|
+
sl atlas find-contacts --page '{"first":5}' --wait \
|
|
77
|
+
--fields contacts.nodes.firstName,contacts.nodes.emailAddress # what you own
|
|
78
|
+
sl atlas find-contacts --page '{"first":5}' --wait --reveal contactIdentity,contactEmailAddress \
|
|
79
|
+
--fields contacts.nodes.firstName,contacts.nodes.emailAddress # reveal, once per window
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
Q29udGFjdC8wMTllZGE0Mi1lYTAyLTc0YTAtYTgyMS0wZmIxNmUwNWQzZmY
|
|
82
|
-
firstName Ada
|
|
83
|
-
lastName Lovelace
|
|
84
|
-
emailAddress ada@acme.com
|
|
85
|
-
reveals CONTACT_IDENTITY REVEALED until 2026-12-11 23:59:59
|
|
86
|
-
CONTACT_EMAIL_ADDRESS REVEALED until 2026-12-11 23:59:59
|
|
87
|
-
|
|
88
|
-
credits
|
|
89
|
-
held 2
|
|
90
|
-
used 2
|
|
91
|
-
byDimension CONTACT_IDENTITY 1
|
|
92
|
-
CONTACT_EMAIL_ADDRESS 1
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Every row in a list is titled by its id, selected whether or not `--fields` names it, so a locked contact still has a handle to reveal it by. The `credits` block after the list is the bill of the command: `held` is the ceiling reserved before the page was read (rows × dimensions asked), `used` what it actually consumed, one unit per dimension revealed on one row; owned and unavailable cost nothing. Nothing is charged yet — these are the figures that would be.
|
|
96
|
-
|
|
97
|
-
`OWNED` means the window is still running and nothing was counted again; `LOCKED` means Atlas has it and nobody asked; `UNAVAILABLE` means Atlas has nothing, and nothing is counted. Every list argument typed as an enum accepts the same shorthand.
|
|
82
|
+
The finds are searches: the mutation is acknowledged at once and the page arrives on a subscription, which `--wait` listens to. Atlas sends a page again as it fills it, and `--wait` prints its last, `COMPLETE`, version. Each edge's `reveals` says what happened to every dimension: `REVEALED` was recorded by this call, `OWNED` means the window is still running and nothing was counted again, `LOCKED` means Atlas has it and nobody asked, `UNAVAILABLE` means Atlas has nothing, and nothing is counted. The page's `credits` is the bill: `held` is the ceiling reserved before the page was read (rows × dimensions asked), `used` what it actually consumed, one unit per dimension revealed on one row. Nothing is charged yet — these are the figures that would be. Every list argument typed as an enum accepts the same comma-separated shorthand.
|
|
98
83
|
|
|
99
84
|
## Unattended authentication
|
|
100
85
|
|
|
@@ -118,19 +103,20 @@ The token endpoint is a different host from the federation endpoint, so it canno
|
|
|
118
103
|
|
|
119
104
|
## Federation operations
|
|
120
105
|
|
|
121
|
-
|
|
106
|
+
The CLI offers an operation only when its subgraph tags the root field for it, with `@tag(name: "cli")` (`tags: [{ name: "cli" }]` on the Ruby field). Every other query, mutation and subscription stays reachable through the API, but has no command. Exposing one more is a backend change: tag the field, and the command appears within the hour, with no CLI release.
|
|
107
|
+
|
|
108
|
+
Commands are discovered at runtime through introspection and grouped under the subgraph that serves them. Hermes's account and company operations are the exception and stay at the top level, beside `login` and `config`:
|
|
122
109
|
|
|
123
110
|
```bash
|
|
124
|
-
sl operations
|
|
125
|
-
sl operations --search
|
|
126
|
-
sl <operation> --help
|
|
111
|
+
sl operations # list them all, grouped by queries, mutations and subscriptions
|
|
112
|
+
sl operations --search organization # filter by operation or subgraph name
|
|
113
|
+
sl <service> <operation> --help # flags for one operation
|
|
127
114
|
```
|
|
128
115
|
|
|
129
|
-
They are hidden from the root help — listing seventy-odd entries there would bury the curated commands above — but they are ordinary top-level commands:
|
|
130
|
-
|
|
131
116
|
```bash
|
|
132
|
-
sl
|
|
133
|
-
sl
|
|
117
|
+
sl companies
|
|
118
|
+
sl atlas find-organizations --help
|
|
119
|
+
sl mercator resolve-locations --query brussels
|
|
134
120
|
```
|
|
135
121
|
|
|
136
122
|
Output is JSON when piped or with `--json`, and aligned key/value blocks in a terminal. Ids are never truncated — they are what you paste into the next command — so records are printed as blocks rather than a table.
|
package/dist/index.js
CHANGED
|
@@ -1106,6 +1106,21 @@ function buildSelections(type, schema, depth, exclude, prefix, totalCount, visit
|
|
|
1106
1106
|
const namedType = unwrap(field.type);
|
|
1107
1107
|
if (isLeaf(namedType)) {
|
|
1108
1108
|
lines.push(name);
|
|
1109
|
+
} else if (isObjectType(namedType) && isConnection(namedType) && field.args.length === 0) {
|
|
1110
|
+
const pageSelections = buildSelections(
|
|
1111
|
+
namedType,
|
|
1112
|
+
schema,
|
|
1113
|
+
depth,
|
|
1114
|
+
exclude,
|
|
1115
|
+
`${fullPath}.`,
|
|
1116
|
+
totalCount,
|
|
1117
|
+
new Set(visited)
|
|
1118
|
+
);
|
|
1119
|
+
if (pageSelections.length > 0) {
|
|
1120
|
+
lines.push(`${name} {`);
|
|
1121
|
+
for (const sel of pageSelections) lines.push(` ${sel}`);
|
|
1122
|
+
lines.push(`}`);
|
|
1123
|
+
}
|
|
1109
1124
|
} else if (isObjectType(namedType) && depth > 0) {
|
|
1110
1125
|
const subSelections = buildSelections(
|
|
1111
1126
|
namedType,
|
|
@@ -1156,9 +1171,16 @@ function fieldCall(name, field) {
|
|
|
1156
1171
|
const pageable = isObjectType(named) && isConnection(named) && field.args.some((a) => a.name === "first");
|
|
1157
1172
|
return pageable ? `${name}(first: ${NESTED_PAGE_SIZE})` : name;
|
|
1158
1173
|
}
|
|
1174
|
+
function deliveredPageField(type) {
|
|
1175
|
+
const pages = Object.values(type.getFields()).filter((field) => {
|
|
1176
|
+
const named = unwrap(field.type);
|
|
1177
|
+
return isObjectType(named) && isConnection(named) && field.args.length === 0;
|
|
1178
|
+
});
|
|
1179
|
+
return pages.length === 1 ? pages[0] : null;
|
|
1180
|
+
}
|
|
1159
1181
|
function isConnection(type) {
|
|
1160
1182
|
const fields = type.getFields();
|
|
1161
|
-
return
|
|
1183
|
+
return Boolean(fields.nodes) && Boolean(fields.pageInfo);
|
|
1162
1184
|
}
|
|
1163
1185
|
function isAutoSelectable(field) {
|
|
1164
1186
|
if (field.name.startsWith("__") || field.deprecationReason != null) return false;
|
|
@@ -1297,9 +1319,11 @@ ${selectionBody}
|
|
|
1297
1319
|
}`;
|
|
1298
1320
|
return { query, variables, fieldName };
|
|
1299
1321
|
}
|
|
1300
|
-
function buildFieldsFromList(type, schema,
|
|
1322
|
+
function buildFieldsFromList(type, schema, requestedPaths, totalCount) {
|
|
1301
1323
|
if (!isObjectType(type)) return [];
|
|
1302
1324
|
const fields = type.getFields();
|
|
1325
|
+
const page = deliveredPageField(type);
|
|
1326
|
+
const fieldPaths = page ? requestedPaths.map((path7) => fields[path7.split(".")[0]] ? path7 : `${page.name}.${path7}`) : requestedPaths;
|
|
1303
1327
|
if (isConnection(type)) {
|
|
1304
1328
|
const nodesType = unwrap(fields.nodes.type);
|
|
1305
1329
|
const withId = isObjectType(nodesType) && nodesType.getFields().id && !fieldPaths.includes("id");
|
|
@@ -1729,6 +1753,38 @@ function resultSubscriptions(schema) {
|
|
|
1729
1753
|
}
|
|
1730
1754
|
return pairs;
|
|
1731
1755
|
}
|
|
1756
|
+
function isRecord2(value) {
|
|
1757
|
+
return typeof value === "object" && value !== null;
|
|
1758
|
+
}
|
|
1759
|
+
function isStillFilling(result) {
|
|
1760
|
+
return isRecord2(result) && result.status === "FILLING";
|
|
1761
|
+
}
|
|
1762
|
+
var PAGE_STATUS_FIELD = "status";
|
|
1763
|
+
function deliversFillingPages(schema, subscriptionName) {
|
|
1764
|
+
const field = schema.getSubscriptionType()?.getFields()[subscriptionName];
|
|
1765
|
+
const returnType = field ? unwrap2(field.type) : null;
|
|
1766
|
+
const status = returnType && isObjectType2(returnType) ? returnType.getFields()[PAGE_STATUS_FIELD] : void 0;
|
|
1767
|
+
const statusType = status ? unwrap2(status.type) : null;
|
|
1768
|
+
return Boolean(statusType && isEnumType2(statusType) && statusType.getValue("FILLING"));
|
|
1769
|
+
}
|
|
1770
|
+
function shellWord(value) {
|
|
1771
|
+
if (/^[\w.:/@=+-]+$/.test(value)) return value;
|
|
1772
|
+
return "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1773
|
+
}
|
|
1774
|
+
function nextPageCursor(result) {
|
|
1775
|
+
if (!isRecord2(result)) return null;
|
|
1776
|
+
for (const value of Object.values(result)) {
|
|
1777
|
+
const pageInfo = isRecord2(value) && isRecord2(value.pageInfo) ? value.pageInfo : null;
|
|
1778
|
+
if (pageInfo?.hasNextPage === true && typeof pageInfo.endCursor === "string") return pageInfo.endCursor;
|
|
1779
|
+
}
|
|
1780
|
+
return null;
|
|
1781
|
+
}
|
|
1782
|
+
function nextPageHint(commandName, externalId, page, result) {
|
|
1783
|
+
const cursor = nextPageCursor(result);
|
|
1784
|
+
if (!cursor) return null;
|
|
1785
|
+
const nextPage = JSON.stringify({ ...page ?? {}, after: cursor });
|
|
1786
|
+
return `Next page: sl ${commandName} --external-id ${shellWord(externalId)} --page ${shellWord(nextPage)} --wait`;
|
|
1787
|
+
}
|
|
1732
1788
|
function printResult(fieldName, result, opts) {
|
|
1733
1789
|
if (result == null) {
|
|
1734
1790
|
if (actingAsApplication()) {
|
|
@@ -1793,7 +1849,7 @@ function isDroppedStream(err) {
|
|
|
1793
1849
|
const code = err.cause?.code;
|
|
1794
1850
|
return err.message === "terminated" || code === "UND_ERR_SOCKET" || code === "ECONNRESET";
|
|
1795
1851
|
}
|
|
1796
|
-
function buildCommand(schema, fieldName, kind, description, service, resultSubscription) {
|
|
1852
|
+
function buildCommand(schema, fieldName, kind, description, service, resultSubscription, resultCommand) {
|
|
1797
1853
|
const rootType = rootTypeOf(schema, kind);
|
|
1798
1854
|
if (!rootType) throw new Error(`No ${kind} type in schema`);
|
|
1799
1855
|
const field = rootType.getFields()[fieldName];
|
|
@@ -1914,23 +1970,46 @@ function buildCommand(schema, fieldName, kind, description, service, resultSubsc
|
|
|
1914
1970
|
}
|
|
1915
1971
|
const externalId = opts.externalId;
|
|
1916
1972
|
const subscriptionVariables = { externalId };
|
|
1973
|
+
if (selection.fields && !selection.fields.includes(PAGE_STATUS_FIELD) && deliversFillingPages(schema, resultSubscription)) {
|
|
1974
|
+
selection.fields = [...selection.fields, PAGE_STATUS_FIELD];
|
|
1975
|
+
}
|
|
1917
1976
|
const { query: subscriptionQuery, fieldName: subscriptionField } = build2(
|
|
1918
1977
|
"subscription",
|
|
1919
1978
|
resultSubscription,
|
|
1920
1979
|
subscriptionVariables
|
|
1921
1980
|
);
|
|
1922
1981
|
const stream = await listen(subscriptionQuery, subscriptionVariables, requestOptions, seconds);
|
|
1982
|
+
let delivered;
|
|
1923
1983
|
try {
|
|
1924
1984
|
const { query: query2 } = build2(kind, fieldName, variables, false);
|
|
1925
1985
|
await graphqlRaw(query2, variables, requestOptions);
|
|
1926
1986
|
for await (const data2 of stream.events) {
|
|
1927
|
-
|
|
1928
|
-
|
|
1987
|
+
delivered = data2[subscriptionField];
|
|
1988
|
+
if (!isStillFilling(delivered)) break;
|
|
1929
1989
|
}
|
|
1930
|
-
|
|
1931
|
-
|
|
1990
|
+
if (delivered === void 0) {
|
|
1991
|
+
warn(`${resultSubscription} closed without delivering a result.`);
|
|
1992
|
+
process.exit(1);
|
|
1993
|
+
}
|
|
1994
|
+
printResult(resultSubscription, delivered, opts);
|
|
1995
|
+
const pageArgument = useInputWrapper ? variables.input.page : variables.page;
|
|
1996
|
+
const takesPage = cliArgs.some((a) => a.name === "page");
|
|
1997
|
+
const pageHint = takesPage ? nextPageHint(
|
|
1998
|
+
invocation(service, this.name()),
|
|
1999
|
+
externalId,
|
|
2000
|
+
pageArgument,
|
|
2001
|
+
delivered
|
|
2002
|
+
) : null;
|
|
2003
|
+
if (pageHint) hint(pageHint);
|
|
2004
|
+
return;
|
|
1932
2005
|
} catch (err) {
|
|
1933
2006
|
if (!isAbort(err) || !stream.timedOut()) throw err;
|
|
2007
|
+
if (delivered !== void 0) {
|
|
2008
|
+
printResult(resultSubscription, delivered, opts);
|
|
2009
|
+
warn(`Still filling after ${seconds}s: what is above may still change.`);
|
|
2010
|
+
hint(`Wait longer with --wait <seconds>; its external id is ${externalId}.`);
|
|
2011
|
+
process.exit(TIMED_OUT_EXIT_CODE);
|
|
2012
|
+
}
|
|
1934
2013
|
warn(`No result within ${seconds}s. The request was accepted and may still complete.`);
|
|
1935
2014
|
hint(`Wait longer with --wait <seconds>, or read the result later; its external id is ${externalId}.`);
|
|
1936
2015
|
process.exit(TIMED_OUT_EXIT_CODE);
|
|
@@ -1941,10 +2020,10 @@ function buildCommand(schema, fieldName, kind, description, service, resultSubsc
|
|
|
1941
2020
|
const { query, fieldName: fName } = build2(kind, fieldName, variables);
|
|
1942
2021
|
const data = await graphqlRaw(query, variables, requestOptions);
|
|
1943
2022
|
printResult(fieldName, data[fName], opts);
|
|
1944
|
-
if (generatedExternalId &&
|
|
1945
|
-
hint(
|
|
1946
|
-
|
|
1947
|
-
);
|
|
2023
|
+
if (generatedExternalId && resultCommand) {
|
|
2024
|
+
hint(`Its result arrives on sl ${resultCommand} --external-id ${String(opts.externalId)}, or pass --wait.`);
|
|
2025
|
+
} else if (generatedExternalId && resultSubscription) {
|
|
2026
|
+
hint(`Its external id is ${String(opts.externalId)}. Pass --wait to receive its result.`);
|
|
1948
2027
|
}
|
|
1949
2028
|
});
|
|
1950
2029
|
return cmd;
|
|
@@ -1982,17 +2061,43 @@ function deriveServiceMap(schema, fieldServices) {
|
|
|
1982
2061
|
}
|
|
1983
2062
|
return map;
|
|
1984
2063
|
}
|
|
2064
|
+
var TOP_LEVEL_SERVICE = "hermes";
|
|
2065
|
+
function invocation(service, commandName) {
|
|
2066
|
+
return service === TOP_LEVEL_SERVICE ? commandName : `${service} ${commandName}`;
|
|
2067
|
+
}
|
|
2068
|
+
function invocationOf(operation) {
|
|
2069
|
+
return invocation(operation.service, operation.command.name());
|
|
2070
|
+
}
|
|
2071
|
+
function groupOperationCommands(operations) {
|
|
2072
|
+
const topLevel = [];
|
|
2073
|
+
const services = /* @__PURE__ */ new Map();
|
|
2074
|
+
for (const operation of operations) {
|
|
2075
|
+
if (operation.service === TOP_LEVEL_SERVICE) {
|
|
2076
|
+
topLevel.push(operation.command);
|
|
2077
|
+
continue;
|
|
2078
|
+
}
|
|
2079
|
+
let group = services.get(operation.service);
|
|
2080
|
+
if (!group) {
|
|
2081
|
+
group = new Command2(operation.service).description(`Operations served by ${operation.service}`);
|
|
2082
|
+
services.set(operation.service, group);
|
|
2083
|
+
}
|
|
2084
|
+
group.addCommand(operation.command);
|
|
2085
|
+
}
|
|
2086
|
+
return {
|
|
2087
|
+
topLevel,
|
|
2088
|
+
services: [...services.values()].sort((a, b) => a.name().localeCompare(b.name()))
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
1985
2091
|
function buildOperationCommands(schema, fieldServices) {
|
|
1986
2092
|
const serviceMap = deriveServiceMap(schema, fieldServices);
|
|
1987
2093
|
const pairs = resultSubscriptions(schema);
|
|
1988
2094
|
const operations = [];
|
|
1989
|
-
const
|
|
1990
|
-
|
|
2095
|
+
for (const [service, entry] of serviceMap) {
|
|
2096
|
+
const nameCounts = /* @__PURE__ */ new Map();
|
|
1991
2097
|
for (const op of [...entry.queries, ...entry.mutations, ...entry.subscriptions]) {
|
|
1992
2098
|
nameCounts.set(op.fieldName, (nameCounts.get(op.fieldName) ?? 0) + 1);
|
|
1993
2099
|
}
|
|
1994
|
-
|
|
1995
|
-
for (const [service, entry] of serviceMap) {
|
|
2100
|
+
const exposedSubscriptions = new Set(entry.subscriptions.map((op) => op.fieldName));
|
|
1996
2101
|
const kinds = [
|
|
1997
2102
|
{ kind: "query", ops: entry.queries },
|
|
1998
2103
|
{ kind: "mutation", ops: entry.mutations },
|
|
@@ -2002,7 +2107,8 @@ function buildOperationCommands(schema, fieldServices) {
|
|
|
2002
2107
|
for (const op of ops) {
|
|
2003
2108
|
try {
|
|
2004
2109
|
const paired = kind === "mutation" ? pairs.get(op.fieldName) : void 0;
|
|
2005
|
-
const
|
|
2110
|
+
const resultCommand = paired && exposedSubscriptions.has(paired) ? invocation(service, kebab(paired)) : void 0;
|
|
2111
|
+
const command = buildCommand(schema, op.fieldName, kind, op.description, service, paired, resultCommand);
|
|
2006
2112
|
if ((nameCounts.get(op.fieldName) ?? 0) > 1) {
|
|
2007
2113
|
command.name(`${kebab(op.fieldName)}-${kind}`);
|
|
2008
2114
|
}
|
|
@@ -2016,9 +2122,9 @@ function buildOperationCommands(schema, fieldServices) {
|
|
|
2016
2122
|
}
|
|
2017
2123
|
function formatOperationList(operations, search) {
|
|
2018
2124
|
const needle = search?.toLowerCase();
|
|
2019
|
-
const matching = needle ? operations.filter((op) => op
|
|
2125
|
+
const matching = needle ? operations.filter((op) => invocationOf(op).includes(needle) || op.service.toLowerCase().includes(needle)) : operations;
|
|
2020
2126
|
if (matching.length === 0) {
|
|
2021
|
-
return search ? `No operation matching "${search}".` : "No
|
|
2127
|
+
return search ? `No operation matching "${search}".` : "No operation on this endpoint is exposed to the CLI.";
|
|
2022
2128
|
}
|
|
2023
2129
|
const lines = [];
|
|
2024
2130
|
const headings = {
|
|
@@ -2029,10 +2135,12 @@ function formatOperationList(operations, search) {
|
|
|
2029
2135
|
for (const kind of ["query", "mutation", "subscription"]) {
|
|
2030
2136
|
const group = matching.filter((op) => op.kind === kind);
|
|
2031
2137
|
if (group.length === 0) continue;
|
|
2032
|
-
const
|
|
2138
|
+
const rows = group.map((op) => ({ invocation: invocationOf(op), service: op.service }));
|
|
2139
|
+
rows.sort((a, b) => a.invocation.localeCompare(b.invocation));
|
|
2140
|
+
const width = Math.max(...rows.map((row) => row.invocation.length));
|
|
2033
2141
|
lines.push(`${headings[kind]}:`);
|
|
2034
|
-
for (const
|
|
2035
|
-
lines.push(` ${
|
|
2142
|
+
for (const row of rows) {
|
|
2143
|
+
lines.push(` ${row.invocation.padEnd(width)} ${row.service}`);
|
|
2036
2144
|
}
|
|
2037
2145
|
lines.push("");
|
|
2038
2146
|
}
|
|
@@ -2541,6 +2649,12 @@ async function fetchIntrospection(endpoint, token) {
|
|
|
2541
2649
|
}
|
|
2542
2650
|
return { introspection: json.data, raw: json.data };
|
|
2543
2651
|
}
|
|
2652
|
+
var CLI_TAG = "cli";
|
|
2653
|
+
function isTaggedForCli(field) {
|
|
2654
|
+
return field.appliedDirectives?.some(
|
|
2655
|
+
(d) => d.name === "tag" && d.args.some((a) => a.name === "name" && a.value === CLI_TAG)
|
|
2656
|
+
) ?? false;
|
|
2657
|
+
}
|
|
2544
2658
|
function parseIntrospection(raw) {
|
|
2545
2659
|
const fieldServices = /* @__PURE__ */ new Map();
|
|
2546
2660
|
const services = /* @__PURE__ */ new Set();
|
|
@@ -2553,7 +2667,8 @@ function parseIntrospection(raw) {
|
|
|
2553
2667
|
const graphArg = directive.args.find((a) => a.name === "graph");
|
|
2554
2668
|
if (!graphArg || typeof graphArg.value !== "string") continue;
|
|
2555
2669
|
services.add(graphArg.value);
|
|
2556
|
-
if (!
|
|
2670
|
+
if (!isTaggedForCli(field)) continue;
|
|
2671
|
+
fieldMap ??= /* @__PURE__ */ new Map();
|
|
2557
2672
|
fieldMap.set(field.name, graphArg.value);
|
|
2558
2673
|
}
|
|
2559
2674
|
if (fieldMap) fieldServices.set(type.name, fieldMap);
|
|
@@ -2718,15 +2833,13 @@ function buildRootDescription(operationCount) {
|
|
|
2718
2833
|
const parts = [BASE_DESCRIPTION];
|
|
2719
2834
|
if (operationCount > 0) {
|
|
2720
2835
|
parts.push(
|
|
2721
|
-
`Every federation operation is a command (${operationCount} available)
|
|
2722
|
-
|
|
2723
|
-
sl operations
|
|
2724
|
-
sl operations --search
|
|
2725
|
-
sl <operation> --help
|
|
2726
|
-
);
|
|
2727
|
-
parts.push(
|
|
2728
|
-
"Examples:\n sl organizations --limit 5\n sl create-application --name continuous-integration\n sl config show"
|
|
2836
|
+
`Every federation operation exposed to the CLI is a command (${operationCount} available),
|
|
2837
|
+
grouped under the service that serves it. Account and company operations stay at the top level:
|
|
2838
|
+
sl operations List them all
|
|
2839
|
+
sl operations --search organization
|
|
2840
|
+
sl <service> <operation> --help Flags for one operation`
|
|
2729
2841
|
);
|
|
2842
|
+
parts.push("Examples:\n sl companies\n sl atlas find-organizations --help\n sl config show");
|
|
2730
2843
|
}
|
|
2731
2844
|
return parts.join("\n\n");
|
|
2732
2845
|
}
|
|
@@ -2776,8 +2889,12 @@ var endpointOverride = endpointIdx !== -1 ? process.argv[endpointIdx + 1] : void
|
|
|
2776
2889
|
try {
|
|
2777
2890
|
const { schema, fieldServices } = await getIntrospectedSchema(endpointOverride);
|
|
2778
2891
|
const operations = buildOperationCommands(schema, fieldServices);
|
|
2779
|
-
|
|
2780
|
-
|
|
2892
|
+
const { topLevel, services } = groupOperationCommands(operations);
|
|
2893
|
+
for (const command of topLevel) {
|
|
2894
|
+
program.addCommand(command, { hidden: true });
|
|
2895
|
+
}
|
|
2896
|
+
for (const command of services) {
|
|
2897
|
+
program.addCommand(command);
|
|
2781
2898
|
}
|
|
2782
2899
|
const operationsCommand = new Command8("operations").summary("List every federation operation available as a command").option("--search <text>", "Filter by operation or subgraph name").action(function() {
|
|
2783
2900
|
info(formatOperationList(operations, this.opts().search));
|