@fragment-dev/cli 2026.6.30 → 2026.7.1-10
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 +42 -2
- package/dist/{chunk-I5JFFWZM.js → chunk-2VYJABNZ.js} +2 -2
- package/dist/{chunk-BBZDU3B4.js → chunk-34NLRFFT.js} +1 -1
- package/dist/chunk-3SJL7FRS.js +186 -0
- package/dist/chunk-45CYJ3K6.js +108 -0
- package/dist/{chunk-UMAUSCLS.js → chunk-5A52AXRT.js} +3 -3
- package/dist/{chunk-LNYDUY5F.js → chunk-5HH4NNSE.js} +2 -2
- package/dist/{chunk-ECSXGVPP.js → chunk-C7ROAUIM.js} +1 -1
- package/dist/{chunk-Q25QYAZ7.js → chunk-FELYEHSZ.js} +1 -1
- package/dist/{chunk-PFGF27Z7.js → chunk-GO2D2LDM.js} +2 -2
- package/dist/{chunk-6BF2IGEK.js → chunk-HCTAYKGL.js} +2 -2
- package/dist/{chunk-VKFC45KB.js → chunk-J6GQWO4E.js} +2 -2
- package/dist/{chunk-T5GGVB7Q.js → chunk-JE5UVURV.js} +32 -28
- package/dist/{chunk-A43XU7QS.js → chunk-LB3C4WTL.js} +1 -1
- package/dist/{chunk-CMB5L4GJ.js → chunk-MMEBN7SR.js} +5 -5
- package/dist/{chunk-BPA2ZDP4.js → chunk-MOZRABR6.js} +2 -2
- package/dist/{chunk-ESEZRPTU.js → chunk-NAJ7S3OV.js} +73 -10
- package/dist/{chunk-PCAB73GF.js → chunk-NWPJRN3W.js} +1 -1
- package/dist/{chunk-2BXFOBDR.js → chunk-NYTFP5AV.js} +1 -1
- package/dist/{chunk-L3XNEX33.js → chunk-OZQUYOQH.js} +2 -2
- package/dist/{chunk-TRYLEOKB.js → chunk-PILLZB3E.js} +8 -8
- package/dist/{chunk-QI5VSJMP.js → chunk-PT6HAWJK.js} +4 -4
- package/dist/{chunk-NM7ENVG2.js → chunk-QDA5BIHP.js} +2 -2
- package/dist/{chunk-IJBNTQ7H.js → chunk-QJOWCJUB.js} +1 -1
- package/dist/{chunk-7X2QSWZ4.js → chunk-QPR6OBXW.js} +4 -4
- package/dist/{chunk-IO6HR226.js → chunk-QRP56DLY.js} +2 -2
- package/dist/{chunk-XKTOP23Z.js → chunk-SQL643PS.js} +1 -1
- package/dist/{chunk-WS2PJBP6.js → chunk-TLM4VKIC.js} +2 -0
- package/dist/{chunk-G5N2UVKQ.js → chunk-UMIUGX6O.js} +2 -2
- package/dist/{chunk-3QZ3TI7I.js → chunk-UOXPSGVC.js} +1 -1
- package/dist/{chunk-7O5S6DOP.js → chunk-V23ZVPPI.js} +3 -3
- package/dist/{chunk-F4X6QF3A.js → chunk-V32GIUJT.js} +1 -1
- package/dist/{chunk-JN7B4RNC.js → chunk-VFXM2XYO.js} +6 -0
- package/dist/{chunk-OVTTESEV.js → chunk-VGBDSE7K.js} +2 -2
- package/dist/{chunk-GT4DQ3S5.js → chunk-VIVSBPCD.js} +2 -2
- package/dist/{chunk-YKRLZ565.js → chunk-WMBVWK2M.js} +1 -1
- package/dist/{chunk-DTKNXMNB.js → chunk-XDGKUJ32.js} +2 -2
- package/dist/{chunk-UGKG4UKY.js → chunk-Y665FSTC.js} +3 -3
- package/dist/{chunk-NTVQKBTC.js → chunk-ZMSR4Z3E.js} +2 -2
- package/dist/commands/add-ledger-entry.js +7 -7
- package/dist/commands/api-client/create.js +18 -0
- package/dist/commands/create-custom-link.js +7 -7
- package/dist/commands/create-ledger.js +7 -7
- package/dist/commands/delete-custom-txs.js +7 -7
- package/dist/commands/delete-ledger.js +7 -7
- package/dist/commands/delete-schema.js +7 -7
- package/dist/commands/gen-graphql.js +11 -11
- package/dist/commands/get-schema.js +8 -8
- package/dist/commands/init.js +6 -6
- package/dist/commands/login.js +8 -7
- package/dist/commands/migrate-ledger-entry.js +7 -7
- package/dist/commands/query/ledgerAccounts.js +7 -7
- package/dist/commands/query/ledgers.js +7 -7
- package/dist/commands/query/schema.js +7 -7
- package/dist/commands/query/schemas.js +7 -7
- package/dist/commands/reverse-ledger-entry.js +7 -7
- package/dist/commands/start.js +6 -6
- package/dist/commands/store-schema.js +7 -7
- package/dist/commands/token.js +7 -7
- package/dist/commands/update-ledger-account.js +7 -7
- package/dist/commands/update.js +7 -7
- package/dist/commands/verify-schema.js +11 -11
- package/dist/commands/workspace.js +7 -7
- package/dist/commands.js +40 -38
- package/dist/graphql.js +4 -4
- package/dist/index.js +40 -38
- package/dist/lib/auth.js +2 -2
- package/dist/lib/authenticatedCommand.js +6 -6
- package/dist/lib/baseCommand.js +5 -5
- package/dist/lib/browserAuth.js +13 -0
- package/dist/lib/constants.js +5 -3
- package/dist/open-SJMVVA3H.js +551 -0
- package/dist/utils/formatValidationErrors.js +3 -3
- package/dist/utils/schemaValidation.js +6 -6
- package/dist/version.js +2 -2
- package/oclif.manifest.json +101 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<!-- commands -->
|
|
8
8
|
* [`fragment add-ledger-entry`](#fragment-add-ledger-entry)
|
|
9
|
+
* [`fragment api-client create`](#fragment-api-client-create)
|
|
9
10
|
* [`fragment autocomplete [SHELL]`](#fragment-autocomplete-shell)
|
|
10
11
|
* [`fragment commands`](#fragment-commands)
|
|
11
12
|
* [`fragment create-custom-link`](#fragment-create-custom-link)
|
|
@@ -65,6 +66,39 @@ FLAG DESCRIPTIONS
|
|
|
65
66
|
You may specify multiple parameters by repeating the flag.
|
|
66
67
|
```
|
|
67
68
|
|
|
69
|
+
## `fragment api-client create`
|
|
70
|
+
|
|
71
|
+
Create an API client for an integration.
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
USAGE
|
|
75
|
+
$ fragment api-client create --workspace <value> --name <value> [--role admin|reader] [--mcp-url <value>] [--output
|
|
76
|
+
<value>] [--format json|env]
|
|
77
|
+
|
|
78
|
+
FLAGS
|
|
79
|
+
--format=<option> [default: json] Output format (applies to both stdout and --output).
|
|
80
|
+
<options: json|env>
|
|
81
|
+
--mcp-url=<value> The Workspace MCP server origin (ex: https://mcp.us-west-2.fragment.dev). Falls back to
|
|
82
|
+
FRAGMENT_MCP_URL.
|
|
83
|
+
--name=<value> (required) A display name for the API client.
|
|
84
|
+
--output=<value> Write the credentials to this file instead of stdout.
|
|
85
|
+
--role=<option> Role to assign the API client (defaults to your own role, capped at it).
|
|
86
|
+
<options: admin|reader>
|
|
87
|
+
--workspace=<value> (required) The Workspace id to create the API client in.
|
|
88
|
+
|
|
89
|
+
DESCRIPTION
|
|
90
|
+
Create an API client for an integration.
|
|
91
|
+
|
|
92
|
+
Authenticates in the browser and provisions a new API client for the
|
|
93
|
+
given Workspace, then writes the credentials to a file or stdout. The
|
|
94
|
+
authorizing user must have permission to create API clients.
|
|
95
|
+
|
|
96
|
+
EXAMPLES
|
|
97
|
+
$ fragment api-client create --workspace <workspace-id> --name "Billing service" --role reader
|
|
98
|
+
|
|
99
|
+
$ fragment api-client create --workspace <workspace-id> --name CI --output ./fragment-client.json
|
|
100
|
+
```
|
|
101
|
+
|
|
68
102
|
## `fragment autocomplete [SHELL]`
|
|
69
103
|
|
|
70
104
|
Display autocomplete installation instructions.
|
|
@@ -342,17 +376,21 @@ Authenticate with FRAGMENT.
|
|
|
342
376
|
|
|
343
377
|
```
|
|
344
378
|
USAGE
|
|
345
|
-
$ fragment login [--
|
|
346
|
-
<value>] [--oauth-scope <value>] [--test]
|
|
379
|
+
$ fragment login [--browser] [--workspace <value>] [--mcp-url <value>] [--client-id <value>]
|
|
380
|
+
[--client-secret <value>] [--api-url <value>] [--oauth-url <value>] [--oauth-scope <value>] [--test]
|
|
347
381
|
|
|
348
382
|
FLAGS
|
|
349
383
|
--api-url=<value> The API URL for your FRAGMENT Workspace (ex: https://api.us-west-2.fragment.dev/graphql)
|
|
384
|
+
--browser Authenticate in the browser and provision an API client automatically.
|
|
350
385
|
--client-id=<value> The API Client ID for your FRAGMENT Workspace.
|
|
351
386
|
--client-secret=<value> The API Client Secret for your FRAGMENT Workspace
|
|
387
|
+
--mcp-url=<value> The Workspace MCP server origin (ex: https://mcp.us-west-2.fragment.dev). Used with
|
|
388
|
+
--browser.
|
|
352
389
|
--oauth-scope=<value> The OAuth Scope for your auth token (ex: https://api.us-west-2.fragment.dev/*)
|
|
353
390
|
--oauth-url=<value> The OAuth URL from which to retrieve your auth token (ex:
|
|
354
391
|
https://auth.fragment.dev/oauth2/token)
|
|
355
392
|
--test If set, tests stored credentials only
|
|
393
|
+
--workspace=<value> The Workspace id to authenticate against (required with --browser).
|
|
356
394
|
|
|
357
395
|
DESCRIPTION
|
|
358
396
|
Authenticate with FRAGMENT.
|
|
@@ -365,6 +403,8 @@ DESCRIPTION
|
|
|
365
403
|
EXAMPLES
|
|
366
404
|
$ fragment login
|
|
367
405
|
|
|
406
|
+
$ fragment login --browser --workspace <workspace-id>
|
|
407
|
+
|
|
368
408
|
$ fragment login --client-id <client-id> --client-secret <client-secret> --api-url <api-url> --oauth-url <oauth-url>
|
|
369
409
|
```
|
|
370
410
|
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_cjs_shims
|
|
3
|
+
} from "./chunk-7GH3YGSC.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/browserAuth.ts
|
|
6
|
+
init_cjs_shims();
|
|
7
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
8
|
+
import { createServer } from "node:http";
|
|
9
|
+
var AUTH_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
10
|
+
var CLI_BOOTSTRAP_CLIENT_NAME = "Fragment CLI";
|
|
11
|
+
var defaultBrowserAuthDeps = (log) => ({
|
|
12
|
+
fetchFn: fetch,
|
|
13
|
+
openBrowser: async (url) => {
|
|
14
|
+
const open = (await import("./open-SJMVVA3H.js")).default;
|
|
15
|
+
return open(url);
|
|
16
|
+
},
|
|
17
|
+
startLoopback: startLoopbackServer,
|
|
18
|
+
log
|
|
19
|
+
});
|
|
20
|
+
var pkcePair = () => {
|
|
21
|
+
const verifier = randomBytes(32).toString("base64url");
|
|
22
|
+
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
|
23
|
+
return { verifier, challenge };
|
|
24
|
+
};
|
|
25
|
+
var trimSlash = (url) => url.replace(/\/$/, "");
|
|
26
|
+
var mcpResourceUrl = (mcpBaseUrl, workspaceId) => `${trimSlash(mcpBaseUrl)}/mcp/w/${encodeURIComponent(workspaceId)}`;
|
|
27
|
+
var protectedResourceMetadataUrl = (mcpBaseUrl, workspaceId) => `${trimSlash(
|
|
28
|
+
mcpBaseUrl
|
|
29
|
+
)}/.well-known/oauth-protected-resource/mcp/w/${encodeURIComponent(
|
|
30
|
+
workspaceId
|
|
31
|
+
)}`;
|
|
32
|
+
var jsonOk = async (response, what) => {
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const body = await response.text().catch(() => "");
|
|
35
|
+
throw new Error(`${what} failed (${response.status}): ${body}`);
|
|
36
|
+
}
|
|
37
|
+
return response.json();
|
|
38
|
+
};
|
|
39
|
+
var errorPage = (message) => `<html><body>${message} You can close this window and return to the CLI.</body></html>`;
|
|
40
|
+
var startLoopbackServer = (expectedState) => new Promise((resolveServer) => {
|
|
41
|
+
let resolveCode;
|
|
42
|
+
let rejectCode;
|
|
43
|
+
const codePromise = new Promise((res, rej) => {
|
|
44
|
+
resolveCode = res;
|
|
45
|
+
rejectCode = rej;
|
|
46
|
+
});
|
|
47
|
+
const server = createServer((req, res) => {
|
|
48
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
49
|
+
if (url.pathname !== "/callback") {
|
|
50
|
+
res.writeHead(404).end("Not found");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const state = url.searchParams.get("state") ?? "";
|
|
54
|
+
if (state !== expectedState) {
|
|
55
|
+
res.writeHead(400, { "Content-Type": "text/html" }).end(errorPage("Invalid authorization state."));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const error = url.searchParams.get("error");
|
|
59
|
+
const code = url.searchParams.get("code");
|
|
60
|
+
if (error) {
|
|
61
|
+
res.writeHead(400, { "Content-Type": "text/html" }).end(errorPage("Authorization was denied."));
|
|
62
|
+
rejectCode(new Error(`authorization denied: ${error}`));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!code) {
|
|
66
|
+
res.writeHead(400, { "Content-Type": "text/html" }).end(errorPage("Authorization response was missing a code."));
|
|
67
|
+
rejectCode(new Error("callback missing code"));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
res.writeHead(200, { "Content-Type": "text/html" }).end(errorPage("Authorized."));
|
|
71
|
+
resolveCode(code);
|
|
72
|
+
});
|
|
73
|
+
server.listen(0, "127.0.0.1", () => {
|
|
74
|
+
const { port } = server.address();
|
|
75
|
+
resolveServer({
|
|
76
|
+
redirectUri: `http://127.0.0.1:${port}/callback`,
|
|
77
|
+
waitForCode: () => new Promise((resolve, reject) => {
|
|
78
|
+
const timer = setTimeout(() => {
|
|
79
|
+
server.close();
|
|
80
|
+
reject(new Error("timed out waiting for browser authorization"));
|
|
81
|
+
}, AUTH_TIMEOUT_MS);
|
|
82
|
+
codePromise.then(
|
|
83
|
+
(code) => {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
resolve(code);
|
|
86
|
+
},
|
|
87
|
+
(err) => {
|
|
88
|
+
clearTimeout(timer);
|
|
89
|
+
reject(err);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}),
|
|
93
|
+
close: () => server.close()
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
var provisionApiClient = async ({ mcpBaseUrl, workspaceId, clientName, role }, deps) => {
|
|
98
|
+
const { fetchFn, openBrowser, startLoopback, log } = deps;
|
|
99
|
+
const resourceMetadata = await jsonOk(
|
|
100
|
+
await fetchFn(protectedResourceMetadataUrl(mcpBaseUrl, workspaceId)),
|
|
101
|
+
"discovering authorization server"
|
|
102
|
+
);
|
|
103
|
+
const issuer = resourceMetadata.authorization_servers?.[0];
|
|
104
|
+
if (!issuer) {
|
|
105
|
+
throw new Error("no authorization server advertised for this workspace");
|
|
106
|
+
}
|
|
107
|
+
const metadata = await jsonOk(
|
|
108
|
+
await fetchFn(
|
|
109
|
+
`${trimSlash(issuer)}/.well-known/oauth-authorization-server`
|
|
110
|
+
),
|
|
111
|
+
"fetching issuer metadata"
|
|
112
|
+
);
|
|
113
|
+
if (!metadata.registration_endpoint) {
|
|
114
|
+
throw new Error("issuer does not support dynamic client registration");
|
|
115
|
+
}
|
|
116
|
+
const { verifier, challenge } = pkcePair();
|
|
117
|
+
const state = randomBytes(16).toString("base64url");
|
|
118
|
+
const loopback = await startLoopback(state);
|
|
119
|
+
try {
|
|
120
|
+
const registration = await jsonOk(
|
|
121
|
+
await fetchFn(metadata.registration_endpoint, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: { "Content-Type": "application/json" },
|
|
124
|
+
body: JSON.stringify({
|
|
125
|
+
redirect_uris: [loopback.redirectUri],
|
|
126
|
+
client_name: CLI_BOOTSTRAP_CLIENT_NAME
|
|
127
|
+
})
|
|
128
|
+
}),
|
|
129
|
+
"registering client"
|
|
130
|
+
);
|
|
131
|
+
const authorizeUrl = new URL(`${trimSlash(issuer)}/authorize`);
|
|
132
|
+
authorizeUrl.search = new URLSearchParams({
|
|
133
|
+
response_type: "code",
|
|
134
|
+
client_id: registration.client_id,
|
|
135
|
+
redirect_uri: loopback.redirectUri,
|
|
136
|
+
state,
|
|
137
|
+
code_challenge: challenge,
|
|
138
|
+
code_challenge_method: "S256",
|
|
139
|
+
resource: mcpResourceUrl(mcpBaseUrl, workspaceId),
|
|
140
|
+
intent: "api_client"
|
|
141
|
+
}).toString();
|
|
142
|
+
log(
|
|
143
|
+
`Opening your browser to authorize. If it doesn't open, visit:
|
|
144
|
+
${authorizeUrl.toString()}`
|
|
145
|
+
);
|
|
146
|
+
await openBrowser(authorizeUrl.toString());
|
|
147
|
+
const code = await loopback.waitForCode();
|
|
148
|
+
const token = await jsonOk(
|
|
149
|
+
await fetchFn(metadata.token_endpoint, {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
152
|
+
body: new URLSearchParams({
|
|
153
|
+
grant_type: "authorization_code",
|
|
154
|
+
code,
|
|
155
|
+
redirect_uri: loopback.redirectUri,
|
|
156
|
+
client_id: registration.client_id,
|
|
157
|
+
code_verifier: verifier
|
|
158
|
+
})
|
|
159
|
+
}),
|
|
160
|
+
"exchanging authorization code"
|
|
161
|
+
);
|
|
162
|
+
const authHeader = { Authorization: `Bearer ${token.access_token}` };
|
|
163
|
+
const credentials = await jsonOk(
|
|
164
|
+
await fetchFn(`${trimSlash(mcpBaseUrl)}/api-clients`, {
|
|
165
|
+
method: "POST",
|
|
166
|
+
headers: { ...authHeader, "Content-Type": "application/json" },
|
|
167
|
+
body: JSON.stringify({ name: clientName, ...role ? { role } : {} })
|
|
168
|
+
}),
|
|
169
|
+
"creating API client"
|
|
170
|
+
);
|
|
171
|
+
await fetchFn(`${trimSlash(mcpBaseUrl)}/mcp-clients/self`, {
|
|
172
|
+
method: "DELETE",
|
|
173
|
+
headers: authHeader
|
|
174
|
+
}).catch(() => void 0);
|
|
175
|
+
return credentials;
|
|
176
|
+
} finally {
|
|
177
|
+
loopback.close();
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export {
|
|
182
|
+
AUTH_TIMEOUT_MS,
|
|
183
|
+
defaultBrowserAuthDeps,
|
|
184
|
+
startLoopbackServer,
|
|
185
|
+
provisionApiClient
|
|
186
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultBrowserAuthDeps,
|
|
3
|
+
provisionApiClient
|
|
4
|
+
} from "./chunk-3SJL7FRS.js";
|
|
5
|
+
import {
|
|
6
|
+
FragmentCommand,
|
|
7
|
+
require_lib
|
|
8
|
+
} from "./chunk-PILLZB3E.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveMcpBaseUrl
|
|
11
|
+
} from "./chunk-TLM4VKIC.js";
|
|
12
|
+
import {
|
|
13
|
+
__toESM,
|
|
14
|
+
init_cjs_shims
|
|
15
|
+
} from "./chunk-7GH3YGSC.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/api-client/create.ts
|
|
18
|
+
init_cjs_shims();
|
|
19
|
+
var import_core = __toESM(require_lib(), 1);
|
|
20
|
+
import { writeFile } from "node:fs/promises";
|
|
21
|
+
var ROLE_KEYS = {
|
|
22
|
+
admin: "workspace_admin",
|
|
23
|
+
reader: "workspace_reader"
|
|
24
|
+
};
|
|
25
|
+
var ApiClientCreate = class _ApiClientCreate extends FragmentCommand {
|
|
26
|
+
static {
|
|
27
|
+
this.summary = "Create an API client for an integration.";
|
|
28
|
+
}
|
|
29
|
+
static {
|
|
30
|
+
this.description = `Authenticates in the browser and provisions a new API client for the
|
|
31
|
+
given Workspace, then writes the credentials to a file or stdout. The
|
|
32
|
+
authorizing user must have permission to create API clients.`;
|
|
33
|
+
}
|
|
34
|
+
static {
|
|
35
|
+
this.examples = [
|
|
36
|
+
'<%= config.bin %> <%= command.id %> --workspace <workspace-id> --name "Billing service" --role reader',
|
|
37
|
+
"<%= config.bin %> <%= command.id %> --workspace <workspace-id> --name CI --output ./fragment-client.json"
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
static {
|
|
41
|
+
this.flags = {
|
|
42
|
+
workspace: import_core.Flags.string({
|
|
43
|
+
required: true,
|
|
44
|
+
description: "The Workspace id to create the API client in."
|
|
45
|
+
}),
|
|
46
|
+
name: import_core.Flags.string({
|
|
47
|
+
required: true,
|
|
48
|
+
description: "A display name for the API client."
|
|
49
|
+
}),
|
|
50
|
+
role: import_core.Flags.string({
|
|
51
|
+
required: false,
|
|
52
|
+
options: ["admin", "reader"],
|
|
53
|
+
description: "Role to assign the API client (defaults to your own role, capped at it)."
|
|
54
|
+
}),
|
|
55
|
+
"mcp-url": import_core.Flags.string({
|
|
56
|
+
required: false,
|
|
57
|
+
description: "The Workspace MCP server origin (ex: https://mcp.us-west-2.fragment.dev). Falls back to FRAGMENT_MCP_URL."
|
|
58
|
+
}),
|
|
59
|
+
output: import_core.Flags.string({
|
|
60
|
+
required: false,
|
|
61
|
+
description: "Write the credentials to this file instead of stdout."
|
|
62
|
+
}),
|
|
63
|
+
format: import_core.Flags.string({
|
|
64
|
+
required: false,
|
|
65
|
+
options: ["json", "env"],
|
|
66
|
+
default: "json",
|
|
67
|
+
description: "Output format (applies to both stdout and --output)."
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
render(result, format) {
|
|
72
|
+
return format === "env" ? [
|
|
73
|
+
`FRAGMENT_CLIENT_ID=${result.clientId}`,
|
|
74
|
+
`FRAGMENT_CLIENT_SECRET=${result.clientSecret}`,
|
|
75
|
+
`FRAGMENT_API_URL=${result.apiUrl}`,
|
|
76
|
+
`FRAGMENT_OAUTH_URL=${result.oauthUrl}`,
|
|
77
|
+
`FRAGMENT_OAUTH_SCOPE=${result.oauthScope}`
|
|
78
|
+
].join("\n") : JSON.stringify(result, null, 2);
|
|
79
|
+
}
|
|
80
|
+
async run() {
|
|
81
|
+
const { flags } = await this.parse(_ApiClientCreate);
|
|
82
|
+
const mcpBaseUrl = resolveMcpBaseUrl(flags["mcp-url"]);
|
|
83
|
+
this.assert(mcpBaseUrl, {
|
|
84
|
+
message: "Must provide --mcp-url (or set FRAGMENT_MCP_URL), e.g. https://mcp.us-west-2.fragment.dev"
|
|
85
|
+
});
|
|
86
|
+
const result = await provisionApiClient(
|
|
87
|
+
{
|
|
88
|
+
mcpBaseUrl,
|
|
89
|
+
workspaceId: flags.workspace,
|
|
90
|
+
clientName: flags.name,
|
|
91
|
+
role: flags.role ? ROLE_KEYS[flags.role] : void 0
|
|
92
|
+
},
|
|
93
|
+
defaultBrowserAuthDeps((msg) => this.log(msg))
|
|
94
|
+
);
|
|
95
|
+
const rendered = this.render(result, flags.format);
|
|
96
|
+
if (flags.output) {
|
|
97
|
+
await writeFile(flags.output, `${rendered}
|
|
98
|
+
`, { mode: 384 });
|
|
99
|
+
this.log(`API client credentials written to ${flags.output}`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.log(rendered);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
ApiClientCreate
|
|
108
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
inquirer_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QJOWCJUB.js";
|
|
4
4
|
import {
|
|
5
5
|
AuthenticatedCommand
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FELYEHSZ.js";
|
|
7
7
|
import {
|
|
8
8
|
require_lib
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PILLZB3E.js";
|
|
10
10
|
import {
|
|
11
11
|
require_source
|
|
12
12
|
} from "./chunk-XK2D2Z44.js";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getStructuralPath,
|
|
6
6
|
getStructuralSubpaths,
|
|
7
7
|
getSubpaths
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-V32GIUJT.js";
|
|
9
9
|
import {
|
|
10
10
|
BadRequestError,
|
|
11
11
|
CurrencyMatchInputSchema,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
currencyCodes,
|
|
22
22
|
safe,
|
|
23
23
|
z
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-VFXM2XYO.js";
|
|
25
25
|
import {
|
|
26
26
|
__commonJS,
|
|
27
27
|
__toESM,
|
|
@@ -1,72 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Workspace
|
|
3
|
+
} from "./chunk-NWPJRN3W.js";
|
|
4
|
+
import {
|
|
5
|
+
QuerySchemas
|
|
6
|
+
} from "./chunk-UOXPSGVC.js";
|
|
1
7
|
import {
|
|
2
8
|
ReverseLedgerEntry
|
|
3
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZMSR4Z3E.js";
|
|
4
10
|
import {
|
|
5
11
|
Start
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LB3C4WTL.js";
|
|
7
13
|
import {
|
|
8
14
|
StoreSchema
|
|
9
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-OZQUYOQH.js";
|
|
10
16
|
import {
|
|
11
17
|
Token
|
|
12
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-C7ROAUIM.js";
|
|
13
19
|
import {
|
|
14
20
|
UpdateLedgerAccount
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2VYJABNZ.js";
|
|
16
22
|
import {
|
|
17
23
|
Update
|
|
18
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-UMIUGX6O.js";
|
|
19
25
|
import {
|
|
20
26
|
VerifySchema
|
|
21
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-Y665FSTC.js";
|
|
22
28
|
import {
|
|
23
|
-
|
|
24
|
-
} from "./chunk-
|
|
29
|
+
GenGraphQL
|
|
30
|
+
} from "./chunk-MMEBN7SR.js";
|
|
25
31
|
import {
|
|
26
32
|
GetSchema
|
|
27
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-5A52AXRT.js";
|
|
28
34
|
import {
|
|
29
35
|
Init
|
|
30
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-SQL643PS.js";
|
|
31
37
|
import {
|
|
32
38
|
Login
|
|
33
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-NAJ7S3OV.js";
|
|
34
40
|
import {
|
|
35
41
|
MigrateLedgerEntry
|
|
36
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-XDGKUJ32.js";
|
|
37
43
|
import {
|
|
38
44
|
QueryLedgerAccounts
|
|
39
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-MOZRABR6.js";
|
|
40
46
|
import {
|
|
41
47
|
QueryLedgers
|
|
42
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-WMBVWK2M.js";
|
|
43
49
|
import {
|
|
44
50
|
GetSchema as GetSchema2
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import {
|
|
47
|
-
QuerySchemas
|
|
48
|
-
} from "./chunk-3QZ3TI7I.js";
|
|
51
|
+
} from "./chunk-VGBDSE7K.js";
|
|
49
52
|
import {
|
|
50
53
|
AddLedgerEntry
|
|
51
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-J6GQWO4E.js";
|
|
55
|
+
import {
|
|
56
|
+
ApiClientCreate
|
|
57
|
+
} from "./chunk-45CYJ3K6.js";
|
|
52
58
|
import {
|
|
53
59
|
CreateCustomLink
|
|
54
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-QDA5BIHP.js";
|
|
55
61
|
import {
|
|
56
62
|
CreateLedger
|
|
57
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-QRP56DLY.js";
|
|
58
64
|
import {
|
|
59
65
|
DeleteCustomTxs
|
|
60
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-VIVSBPCD.js";
|
|
61
67
|
import {
|
|
62
68
|
DeleteLedger
|
|
63
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-HCTAYKGL.js";
|
|
64
70
|
import {
|
|
65
71
|
DeleteSchema
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import {
|
|
68
|
-
GenGraphQL
|
|
69
|
-
} from "./chunk-CMB5L4GJ.js";
|
|
72
|
+
} from "./chunk-5HH4NNSE.js";
|
|
70
73
|
import {
|
|
71
74
|
init_cjs_shims
|
|
72
75
|
} from "./chunk-7GH3YGSC.js";
|
|
@@ -81,6 +84,7 @@ var COMMANDS = {
|
|
|
81
84
|
// Auth commands
|
|
82
85
|
login: Login,
|
|
83
86
|
token: Token,
|
|
87
|
+
"api-client:create": ApiClientCreate,
|
|
84
88
|
// Workspace commands
|
|
85
89
|
workspace: Workspace,
|
|
86
90
|
// Schema commands
|
|
@@ -3,22 +3,22 @@ import {
|
|
|
3
3
|
generateQueryFiles,
|
|
4
4
|
schemaToEntryDefinitions,
|
|
5
5
|
validateOutputName
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QPR6OBXW.js";
|
|
7
7
|
import {
|
|
8
8
|
Schema,
|
|
9
9
|
parseWithError
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GO2D2LDM.js";
|
|
11
11
|
import {
|
|
12
12
|
formatValidationErrors,
|
|
13
13
|
logValidationErrors
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-PT6HAWJK.js";
|
|
15
15
|
import {
|
|
16
16
|
BadRequestError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VFXM2XYO.js";
|
|
18
18
|
import {
|
|
19
19
|
FragmentCommand,
|
|
20
20
|
require_lib
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PILLZB3E.js";
|
|
22
22
|
import {
|
|
23
23
|
getParsedSchema
|
|
24
24
|
} from "./chunk-O7AE4SQS.js";
|