@fluid-app/fluid-cli 0.1.65 → 0.1.66
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 +26 -7
- package/dist/bin/fluid.mjs +373 -20
- package/dist/bin/fluid.mjs.map +1 -1
- package/dist/index.d.mts +56 -15
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +29 -281
- package/dist/index.mjs.map +1 -1
- package/dist/token-BUGqpr-U.mjs +2975 -0
- package/dist/token-BUGqpr-U.mjs.map +1 -0
- package/package.json +3 -1
- package/dist/token-DnFYT9pe.mjs +0 -624
- package/dist/token-DnFYT9pe.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,30 @@ import { Command, Option } from "commander";
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration types for the Fluid CLI
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* How an identity-mode profile finds its session. Nothing here is a secret:
|
|
9
|
+
* the refresh token lives in the operating system's credential store under
|
|
10
|
+
* `storageKey`, and the access token only in the CLI process's memory.
|
|
11
|
+
*/
|
|
12
|
+
interface IdentityProfileAuth {
|
|
13
|
+
readonly mode: "identity";
|
|
14
|
+
/** Identity service origin the session was signed in with. */
|
|
15
|
+
readonly identityUrl: string;
|
|
16
|
+
/** Credential store account holding this session's refresh token. */
|
|
17
|
+
readonly storageKey: string;
|
|
18
|
+
/**
|
|
19
|
+
* Company `uuid_v7` this profile moved to with `fluid switch`, by token
|
|
20
|
+
* exchange. Absent while the profile uses the company it signed in to.
|
|
21
|
+
*/
|
|
22
|
+
readonly org?: string;
|
|
23
|
+
}
|
|
7
24
|
interface FluidProfile {
|
|
8
25
|
readonly name: string;
|
|
9
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The legacy Rails token. Absent on an identity-mode profile, whose tokens
|
|
28
|
+
* never touch this file (see `auth`).
|
|
29
|
+
*/
|
|
30
|
+
readonly token?: string;
|
|
10
31
|
readonly companyName: string;
|
|
11
32
|
readonly storedAt: string;
|
|
12
33
|
readonly baseUrl?: string;
|
|
@@ -23,7 +44,14 @@ interface FluidProfile {
|
|
|
23
44
|
readonly publicId: string | null; /** ISO-8601. */
|
|
24
45
|
readonly cachedAt: string;
|
|
25
46
|
};
|
|
47
|
+
/** Present when the profile signs in through the Fluid identity service. */
|
|
48
|
+
readonly auth?: IdentityProfileAuth;
|
|
26
49
|
}
|
|
50
|
+
type IdentityProfile = FluidProfile & {
|
|
51
|
+
readonly auth: IdentityProfileAuth;
|
|
52
|
+
};
|
|
53
|
+
/** Whether a profile signs in through the identity service. */
|
|
54
|
+
declare function isIdentityProfile(profile: FluidProfile | null | undefined): profile is IdentityProfile;
|
|
27
55
|
interface FluidConfig {
|
|
28
56
|
activeProfile: string | null;
|
|
29
57
|
profiles: Record<string, FluidProfile>;
|
|
@@ -145,6 +173,8 @@ interface CompanyInfo {
|
|
|
145
173
|
interface UserCompany {
|
|
146
174
|
readonly id: number;
|
|
147
175
|
readonly name: string;
|
|
176
|
+
/** The company's `uuid_v7`, which an identity token exchange names. */
|
|
177
|
+
readonly uuidV7?: string;
|
|
148
178
|
}
|
|
149
179
|
interface SwitchCompanyResult {
|
|
150
180
|
readonly companyId: number;
|
|
@@ -167,11 +197,19 @@ interface CompanyChoice {
|
|
|
167
197
|
interface ConfirmMfaResponse {
|
|
168
198
|
readonly authType: string;
|
|
169
199
|
readonly companies: CompanyChoice[];
|
|
200
|
+
/**
|
|
201
|
+
* `identity` when every company the code covered signs in through the
|
|
202
|
+
* identity service, so Rails handed out no token for them.
|
|
203
|
+
*/
|
|
204
|
+
readonly signInPath: "identity" | "legacy";
|
|
170
205
|
}
|
|
171
206
|
/**
|
|
172
|
-
* Validate a token against the Fluid API and return company info
|
|
207
|
+
* Validate a token against the Fluid API and return company info.
|
|
208
|
+
* `baseUrl` is the API the token belongs to; it defaults to the CLI's.
|
|
173
209
|
*/
|
|
174
|
-
declare function validateToken(token: string
|
|
210
|
+
declare function validateToken(token: string, options?: {
|
|
211
|
+
readonly baseUrl?: string;
|
|
212
|
+
}): Promise<Result<CompanyInfo, FluidApiError>>;
|
|
175
213
|
/**
|
|
176
214
|
* Send a multi-factor authentication code to the given email address.
|
|
177
215
|
* The API answers 201 whether or not the address can sign in
|
|
@@ -208,19 +246,22 @@ declare function switchCompany(token: string, companyId: number, baseUrl?: strin
|
|
|
208
246
|
//#endregion
|
|
209
247
|
//#region src/auth/token.d.ts
|
|
210
248
|
/**
|
|
211
|
-
* Get the auth token for a named profile, or the active profile when omitted
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* in
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* When `profileName` is provided explicitly (e.g. via `--profile` flag),
|
|
220
|
-
* it takes precedence over the environment variables, `.fluidrc`, and the
|
|
221
|
-
* active profile.
|
|
249
|
+
* Get the auth token for a named profile, or the active profile when omitted,
|
|
250
|
+
* in the order {@link resolveCredentialSource} describes.
|
|
251
|
+
*
|
|
252
|
+
* An identity-mode profile keeps no token in the config file. Its access
|
|
253
|
+
* token lives in this process's memory once the session has been restored,
|
|
254
|
+
* which the CLI does before running a command; until then, and after its
|
|
255
|
+
* session ends, this returns null. Prefer {@link getAuthTokenAsync}, which
|
|
256
|
+
* restores and refreshes the session itself.
|
|
222
257
|
*/
|
|
223
258
|
declare function getAuthToken(profileName?: string): string | null;
|
|
259
|
+
/**
|
|
260
|
+
* Like {@link getAuthToken}, but restores, refreshes, or exchanges an
|
|
261
|
+
* identity-mode profile's session as needed. Resolves with null when there
|
|
262
|
+
* is no credential; rejects when an identity session has ended.
|
|
263
|
+
*/
|
|
264
|
+
declare function getAuthTokenAsync(profileName?: string): Promise<string | null>;
|
|
224
265
|
/**
|
|
225
266
|
* Get the active profile, or null if not logged in
|
|
226
267
|
*/
|
|
@@ -632,5 +673,5 @@ interface CatalogEntry {
|
|
|
632
673
|
}
|
|
633
674
|
declare function walkCommands(root: Command): CatalogEntry[];
|
|
634
675
|
//#endregion
|
|
635
|
-
export { ACTOR_CACHE_TTL_MS, type CachedGitSyncActor, type CatalogArgument, type CatalogEntry, type CatalogOption, type ChangeEntry, type ChangeStatus, type Choice, type CliError, type CommandAnnotation, type CommandContext, type CommandEndpoint, type CommitMessage, type CompanyChoice, type CompanyInfo, type ConfirmMfaResponse, type Failure, type FetchClient, type FluidApiError, type FluidConfig, type FluidPlugin, type FluidProfile, type GitSyncActor, type MenuItem, type MfaResponse, NAV_HELP, type Nav, type OutputOptions, type ParsedGitSyncSubject, type PluginContext, type ProjectRcConfig, type Prompter, type Question, type Reply, type Result, SYSTEM_ACTOR_NAME, type Success, type SwitchCompanyResult, type UserCompany, assertInteractive, changeStatusFromCode, confirmMfa, createCommandContext, createDefaultConfig, createDomainCommand, describeCommand, failure, fetchUserCompanies, findProjectConfig, formatCommitTimestamp, formatOutput, getActiveProfile, getAuthToken, getConfigDir, getConfigFilePath, getErrorMessage, getFluidApiBase, gitSyncActorFromMe, gitSyncCommitSubject, gitSyncSubjectAuthor, isError, isFailure, isNodeError, isSuccess, listProfileNames, mapError, mapResult, parseGitSyncSubject, parseNameStatusZ, parseTyped, readCachedActor, readConfig, resolveGitSyncActor, sendMfa, subjectFragment, success, summarizeChanges, switchCompany, terminalPrompter, tryCatch, tryCatchAsync, unwrap, unwrapOr, updateConfig, validateToken, walkCommands, writeCachedActor, writeConfig };
|
|
676
|
+
export { ACTOR_CACHE_TTL_MS, type CachedGitSyncActor, type CatalogArgument, type CatalogEntry, type CatalogOption, type ChangeEntry, type ChangeStatus, type Choice, type CliError, type CommandAnnotation, type CommandContext, type CommandEndpoint, type CommitMessage, type CompanyChoice, type CompanyInfo, type ConfirmMfaResponse, type Failure, type FetchClient, type FluidApiError, type FluidConfig, type FluidPlugin, type FluidProfile, type GitSyncActor, type IdentityProfile, type IdentityProfileAuth, type MenuItem, type MfaResponse, NAV_HELP, type Nav, type OutputOptions, type ParsedGitSyncSubject, type PluginContext, type ProjectRcConfig, type Prompter, type Question, type Reply, type Result, SYSTEM_ACTOR_NAME, type Success, type SwitchCompanyResult, type UserCompany, assertInteractive, changeStatusFromCode, confirmMfa, createCommandContext, createDefaultConfig, createDomainCommand, describeCommand, failure, fetchUserCompanies, findProjectConfig, formatCommitTimestamp, formatOutput, getActiveProfile, getAuthToken, getAuthTokenAsync, getConfigDir, getConfigFilePath, getErrorMessage, getFluidApiBase, gitSyncActorFromMe, gitSyncCommitSubject, gitSyncSubjectAuthor, isError, isFailure, isIdentityProfile, isNodeError, isSuccess, listProfileNames, mapError, mapResult, parseGitSyncSubject, parseNameStatusZ, parseTyped, readCachedActor, readConfig, resolveGitSyncActor, sendMfa, subjectFragment, success, summarizeChanges, switchCompany, terminalPrompter, tryCatch, tryCatchAsync, unwrap, unwrapOr, updateConfig, validateToken, walkCommands, writeCachedActor, writeConfig };
|
|
636
677
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config/types.ts","../src/config/paths.ts","../src/config/config.ts","../src/config/project-config.ts","../src/utils/errors.ts","../src/utils/result.ts","../src/auth/fluid-api.ts","../src/auth/token.ts","../src/plugins/types.ts","../../../platform/api-client-core/src/fetch-client.ts","../src/domain/types.ts","../src/domain/command.ts","../src/domain/context.ts","../src/domain/output.ts","../src/walk/prompter.ts","../src/git-sync/commit-subject.ts","../src/git-sync/change-summary.ts","../src/git-sync/actor-cache.ts","../src/catalog/annotations.ts","../src/catalog/walk.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config/types.ts","../src/config/paths.ts","../src/config/config.ts","../src/config/project-config.ts","../src/utils/errors.ts","../src/utils/result.ts","../src/auth/fluid-api.ts","../src/auth/token.ts","../src/plugins/types.ts","../../../platform/api-client-core/src/fetch-client.ts","../src/domain/types.ts","../src/domain/command.ts","../src/domain/context.ts","../src/domain/output.ts","../src/walk/prompter.ts","../src/git-sync/commit-subject.ts","../src/git-sync/change-summary.ts","../src/git-sync/actor-cache.ts","../src/catalog/annotations.ts","../src/catalog/walk.ts"],"mappings":";;;;;;AASA;;;;;AAAA,UAAiB,mBAAA;EAAA,SACN,IAAA;EASA;EAAA,SAPA,WAAA;EAOG;EAAA,SALH,UAAA;EAQkB;;;;EAAA,SAHlB,GAAA;AAAA;AAAA,UAGM,YAAA;EAAA,SACN,IAAA;EAUA;;;;EAAA,SALA,KAAA;EAAA,SACA,WAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAgB0B;EAAA,SAd1B,SAAA;EAiBgB;;;;;;EAAA,SAVhB,YAAA;IAAA,SACE,IAAA;IAAA,SACA,QAAA,iBAaoB;IAAA,SAXpB,QAAA;EAAA;EAYF;EAAA,SATA,IAAA,GAAO,mBAAA;AAAA;AAAA,KAGN,eAAA,GAAkB,YAAA;EAAA,SACnB,IAAA,EAAM,mBAAA;AAAA;AAUjB;AAAA,iBANgB,iBAAA,CACd,OAAA,EAAS,YAAA,sBACR,OAAA,IAAW,eAAA;AAAA,UAIG,WAAA;EACf,aAAA;EACA,QAAA,EAAU,MAAA,SAAe,YAAA;EACzB,OAAA,EAAS,MAAA;EAeqB;;;;;;;;;;EAJ9B,cAAA;EAI8B;;;EAA9B,2BAAA,GAA8B,MAAA;AAAA;AAAA,iBAGhB,mBAAA,CAAA,GAAuB,WAAA;;;;;;AAzEvC;;;;;;;iBCKgB,YAAA,CAAA;AAAA,iBAoBA,iBAAA,CAAA;;;iBCjBA,UAAA,CAAA,GAAc,WAAA;AAAA,iBAwBd,WAAA,CAAY,MAAA,EAAQ,WAAA;AAAA,iBA6FpB,YAAA,CACd,OAAA,GAAU,MAAA,EAAQ,WAAA,KAAgB,WAAA,GACjC,WAAA;;;;;;AF/HH;;;;;;;;UGMiB,eAAA;EAAA,SACN,OAAA;AAAA;;;;;;;;;;iBAiBK,iBAAA,CAAkB,QAAA,WA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,WAAoB,eAAA;EAAA,SACpB,OAAA,WAAkB,aAAA;EnBYC;EAAA,SmBVnB,mBAAA;EAAA,SACA,WAAA;EnBUyB;EAAA,SmBRzB,QAAA;EnBYK;EAAA,SmBVL,MAAA;;WAEA,SAAA,WAAoB,eAAA;AAAA;AAAA,iBAoDf,YAAA,CAAa,IAAA,EAAM,OAAA,GAAU,YAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,269 +1,6 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as validateToken, B as tryCatch, E as getFluidApiBase, F as isNodeError, H as unwrap, I as isSuccess, J as walkCommands, L as mapError, M as getErrorMessage, N as isError, O as sendMfa, P as isFailure, R as mapResult, S as isIdentityProfile, T as fetchUserCompanies, U as unwrapOr, V as tryCatchAsync, Y as describeCommand, a as resolveCredentialSource, b as createFetchClient, c as updateConfig, d as getConfigFilePath, h as profileAccessToken, i as listProfileNames, j as failure, k as switchCompany, l as writeConfig, n as getAuthToken, o as findProjectConfig, r as getAuthTokenAsync, s as readConfig, t as getActiveProfile, u as getConfigDir, w as confirmMfa, x as createDefaultConfig, z as success } from "./token-BUGqpr-U.mjs";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import prompts from "prompts";
|
|
4
|
-
//#region ../../platform/api-client-core/src/api-error-shape.ts
|
|
5
|
-
/**
|
|
6
|
-
* Narrows a parsed JSON error payload to the envelope contract. Arrays and
|
|
7
|
-
* primitives are not envelopes, so they resolve to `null` — their content is
|
|
8
|
-
* still reachable through `ApiError.data`.
|
|
9
|
-
*/
|
|
10
|
-
function toApiErrorBody(value) {
|
|
11
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The single unwrap rule, shared by every producer of `ApiError`.
|
|
16
|
-
*
|
|
17
|
-
* `??` rather than `||` so an explicitly empty `errors` (`""`, `0`, `false`)
|
|
18
|
-
* is preserved instead of silently falling back to the whole envelope.
|
|
19
|
-
*/
|
|
20
|
-
function toApiErrorData(body) {
|
|
21
|
-
if (!body) return null;
|
|
22
|
-
return body.errors ?? body;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region ../../platform/api-client-core/src/fetch-client.ts
|
|
26
|
-
/**
|
|
27
|
-
* API Error class compatible with fluid-admin's ApiError
|
|
28
|
-
*/
|
|
29
|
-
var ApiError = class ApiError extends Error {
|
|
30
|
-
status;
|
|
31
|
-
/**
|
|
32
|
-
* The unwrapped field-error bag. See `ApiErrorData`; the contract is
|
|
33
|
-
* documented in `docs/api-error-data-contract.md`.
|
|
34
|
-
*/
|
|
35
|
-
data;
|
|
36
|
-
/**
|
|
37
|
-
* The full error response envelope. Read `error_message`, `error`, `status`
|
|
38
|
-
* and nested `errors` from here — `data` has already unwrapped one level.
|
|
39
|
-
*/
|
|
40
|
-
body;
|
|
41
|
-
requestId;
|
|
42
|
-
constructor(message, status, data, requestId, body) {
|
|
43
|
-
super(message);
|
|
44
|
-
this.name = "ApiError";
|
|
45
|
-
this.status = status;
|
|
46
|
-
this.data = data ?? null;
|
|
47
|
-
this.body = body ?? null;
|
|
48
|
-
this.requestId = requestId;
|
|
49
|
-
if ("captureStackTrace" in Error) Error.captureStackTrace(this, ApiError);
|
|
50
|
-
}
|
|
51
|
-
toJSON() {
|
|
52
|
-
return {
|
|
53
|
-
name: this.name,
|
|
54
|
-
message: this.message,
|
|
55
|
-
status: this.status,
|
|
56
|
-
data: this.data,
|
|
57
|
-
body: this.body,
|
|
58
|
-
requestId: this.requestId
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
function getStringRequestId(value) {
|
|
63
|
-
if (typeof value !== "string") return;
|
|
64
|
-
const trimmed = value.trim();
|
|
65
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
66
|
-
}
|
|
67
|
-
function getRequestIdFromHeaders(headers) {
|
|
68
|
-
return getStringRequestId(headers.get("x-request-id")) ?? getStringRequestId(headers.get("request-id")) ?? getStringRequestId(headers.get("X-Request-ID"));
|
|
69
|
-
}
|
|
70
|
-
function getRequestIdFromJsonBody(body) {
|
|
71
|
-
if (!body || typeof body !== "object" || Array.isArray(body)) return;
|
|
72
|
-
const record = body;
|
|
73
|
-
const meta = record.meta;
|
|
74
|
-
return getStringRequestId(record.request_id) ?? getStringRequestId(record.requestId) ?? (meta && typeof meta === "object" && !Array.isArray(meta) ? getStringRequestId(meta.request_id) ?? getStringRequestId(meta.requestId) : void 0);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Creates a configured fetch client instance
|
|
78
|
-
*/
|
|
79
|
-
function createFetchClient(config) {
|
|
80
|
-
const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials, cache, networkRetry, throwOnInvalidJson = false } = config;
|
|
81
|
-
const maxNetworkRetries = Math.max(0, networkRetry?.maxRetries ?? 0);
|
|
82
|
-
const baseNetworkRetryDelayMs = Math.max(0, networkRetry?.baseDelayMs ?? 0);
|
|
83
|
-
/**
|
|
84
|
-
* Build headers for a request
|
|
85
|
-
*/
|
|
86
|
-
async function buildHeaders(customHeaders) {
|
|
87
|
-
const headers = {
|
|
88
|
-
Accept: "application/json",
|
|
89
|
-
"Content-Type": "application/json",
|
|
90
|
-
...defaultHeaders,
|
|
91
|
-
...customHeaders
|
|
92
|
-
};
|
|
93
|
-
if (getAuthToken) {
|
|
94
|
-
const token = await getAuthToken();
|
|
95
|
-
if (token) headers.Authorization = `Bearer ${token}`;
|
|
96
|
-
}
|
|
97
|
-
return headers;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Join baseUrl + endpoint via string concatenation (matches fetchApi).
|
|
101
|
-
* Using `new URL(endpoint, baseUrl)` would strip any path prefix from
|
|
102
|
-
* baseUrl (e.g. "/api") when the endpoint starts with "/".
|
|
103
|
-
*/
|
|
104
|
-
function joinUrl(endpoint) {
|
|
105
|
-
return `${baseUrl}${endpoint}`;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Build URL with query parameters for GET requests
|
|
109
|
-
* Compatible with fluid-admin's query param handling
|
|
110
|
-
*/
|
|
111
|
-
function buildUrl(endpoint, params) {
|
|
112
|
-
const fullUrl = joinUrl(endpoint);
|
|
113
|
-
if (!params || Object.keys(params).length === 0) return fullUrl;
|
|
114
|
-
const queryString = new URLSearchParams();
|
|
115
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
116
|
-
if (value === void 0 || value === null) return;
|
|
117
|
-
if (Array.isArray(value)) {
|
|
118
|
-
const arrayKey = key.endsWith("[]") ? key : `${key}[]`;
|
|
119
|
-
value.forEach((item) => queryString.append(arrayKey, String(item)));
|
|
120
|
-
} else if (typeof value === "object") Object.entries(value).forEach(([subKey, subValue]) => {
|
|
121
|
-
if (subValue === void 0 || subValue === null) return;
|
|
122
|
-
if (Array.isArray(subValue)) subValue.forEach((item) => queryString.append(`${key}[${subKey}][]`, String(item)));
|
|
123
|
-
else queryString.append(`${key}[${subKey}]`, String(subValue));
|
|
124
|
-
});
|
|
125
|
-
else queryString.append(key, String(value));
|
|
126
|
-
});
|
|
127
|
-
const qs = queryString.toString();
|
|
128
|
-
return qs ? `${fullUrl}?${qs}` : fullUrl;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Shared response handler for both JSON and FormData requests.
|
|
132
|
-
* Handles auth errors, non-OK responses, 204 No Content, and JSON parsing.
|
|
133
|
-
*/
|
|
134
|
-
async function handleResponse(response, method, _url) {
|
|
135
|
-
const headerRequestId = getRequestIdFromHeaders(response.headers);
|
|
136
|
-
if (response.status === 401 && onAuthError) onAuthError();
|
|
137
|
-
if (!response.ok) {
|
|
138
|
-
const errorText = await response.text().catch(() => "");
|
|
139
|
-
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
140
|
-
let parsed;
|
|
141
|
-
try {
|
|
142
|
-
parsed = JSON.parse(errorText);
|
|
143
|
-
} catch {
|
|
144
|
-
throw new ApiError(errorText.slice(0, 200) || `${method} request failed with status ${response.status}`, response.status, null, headerRequestId);
|
|
145
|
-
}
|
|
146
|
-
const body = toApiErrorBody(parsed);
|
|
147
|
-
throw new ApiError((body ? (() => {
|
|
148
|
-
const nestedError = typeof body.error === "object" && body.error !== null ? body.error.message : void 0;
|
|
149
|
-
const directError = typeof body.error === "string" ? body.error : void 0;
|
|
150
|
-
const message = typeof body.message === "string" ? body.message : void 0;
|
|
151
|
-
const errorMessage = typeof body.error_message === "string" ? body.error_message : void 0;
|
|
152
|
-
return message || errorMessage || directError || (typeof nestedError === "string" ? nestedError : void 0);
|
|
153
|
-
})() : void 0) || `${method} request failed with status ${response.status}`, response.status, body ? toApiErrorData(body) : parsed, headerRequestId ?? getRequestIdFromJsonBody(parsed), body);
|
|
154
|
-
} else throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null, headerRequestId);
|
|
155
|
-
}
|
|
156
|
-
if (response.status === 204 || response.headers.get("content-length") === "0") return null;
|
|
157
|
-
if (response.headers.get("content-type")?.includes("application/json")) {
|
|
158
|
-
const responseText = await response.text();
|
|
159
|
-
try {
|
|
160
|
-
return JSON.parse(responseText);
|
|
161
|
-
} catch {
|
|
162
|
-
if (throwOnInvalidJson) throw new ApiError("Failed to parse response as JSON", response.status, null, headerRequestId);
|
|
163
|
-
return responseText ? responseText : null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
function getNetworkRetryDelayMs(retryAttempt) {
|
|
169
|
-
return baseNetworkRetryDelayMs * 2 ** (retryAttempt - 1);
|
|
170
|
-
}
|
|
171
|
-
async function waitForNetworkRetry(retryAttempt) {
|
|
172
|
-
const delayMs = getNetworkRetryDelayMs(retryAttempt);
|
|
173
|
-
if (delayMs <= 0) return;
|
|
174
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
175
|
-
}
|
|
176
|
-
async function fetchWithNetworkRetry(url, fetchOptions, signal) {
|
|
177
|
-
let retryCount = 0;
|
|
178
|
-
while (true) try {
|
|
179
|
-
return await fetch(url, fetchOptions);
|
|
180
|
-
} catch (networkError) {
|
|
181
|
-
if (signal?.aborted || retryCount >= maxNetworkRetries) throw networkError;
|
|
182
|
-
retryCount += 1;
|
|
183
|
-
await waitForNetworkRetry(retryCount);
|
|
184
|
-
if (signal?.aborted) throw networkError;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Main request function
|
|
189
|
-
*/
|
|
190
|
-
async function request(endpoint, options = {}) {
|
|
191
|
-
const { method = "GET", headers: customHeaders, params, body, signal, priority } = options;
|
|
192
|
-
const url = params ? buildUrl(endpoint, params) : joinUrl(endpoint);
|
|
193
|
-
const headers = await buildHeaders(customHeaders);
|
|
194
|
-
let response;
|
|
195
|
-
try {
|
|
196
|
-
const fetchOptions = {
|
|
197
|
-
method,
|
|
198
|
-
headers
|
|
199
|
-
};
|
|
200
|
-
if (credentials) fetchOptions.credentials = credentials;
|
|
201
|
-
if (cache) fetchOptions.cache = cache;
|
|
202
|
-
if (priority) fetchOptions.priority = priority;
|
|
203
|
-
const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
|
|
204
|
-
if (serializedBody) fetchOptions.body = serializedBody;
|
|
205
|
-
if (signal) fetchOptions.signal = signal;
|
|
206
|
-
response = await fetchWithNetworkRetry(url, fetchOptions, signal);
|
|
207
|
-
} catch (networkError) {
|
|
208
|
-
throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
209
|
-
}
|
|
210
|
-
return handleResponse(response, method, url);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Request with FormData (for file uploads)
|
|
214
|
-
*/
|
|
215
|
-
async function requestWithFormData(endpoint, formData, options = {}) {
|
|
216
|
-
const { method = "POST", headers: customHeaders, signal, priority } = options;
|
|
217
|
-
const url = joinUrl(endpoint);
|
|
218
|
-
const headers = await buildHeaders(customHeaders);
|
|
219
|
-
delete headers["Content-Type"];
|
|
220
|
-
let response;
|
|
221
|
-
try {
|
|
222
|
-
const fetchOptions = {
|
|
223
|
-
method,
|
|
224
|
-
headers,
|
|
225
|
-
body: formData
|
|
226
|
-
};
|
|
227
|
-
if (credentials) fetchOptions.credentials = credentials;
|
|
228
|
-
if (cache) fetchOptions.cache = cache;
|
|
229
|
-
if (priority) fetchOptions.priority = priority;
|
|
230
|
-
if (signal) fetchOptions.signal = signal;
|
|
231
|
-
response = await fetchWithNetworkRetry(url, fetchOptions, signal);
|
|
232
|
-
} catch (networkError) {
|
|
233
|
-
throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
|
|
234
|
-
}
|
|
235
|
-
return handleResponse(response, method, url);
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
request,
|
|
239
|
-
requestWithFormData,
|
|
240
|
-
get: (endpoint, params, options) => request(endpoint, {
|
|
241
|
-
...options,
|
|
242
|
-
method: "GET",
|
|
243
|
-
...params && { params }
|
|
244
|
-
}),
|
|
245
|
-
post: (endpoint, body, options) => request(endpoint, {
|
|
246
|
-
...options,
|
|
247
|
-
method: "POST",
|
|
248
|
-
body
|
|
249
|
-
}),
|
|
250
|
-
put: (endpoint, body, options) => request(endpoint, {
|
|
251
|
-
...options,
|
|
252
|
-
method: "PUT",
|
|
253
|
-
body
|
|
254
|
-
}),
|
|
255
|
-
patch: (endpoint, body, options) => request(endpoint, {
|
|
256
|
-
...options,
|
|
257
|
-
method: "PATCH",
|
|
258
|
-
body
|
|
259
|
-
}),
|
|
260
|
-
delete: (endpoint, options) => request(endpoint, {
|
|
261
|
-
...options,
|
|
262
|
-
method: "DELETE"
|
|
263
|
-
})
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
4
|
//#region src/domain/output.ts
|
|
268
5
|
function formatOutput(data, options) {
|
|
269
6
|
let result = data;
|
|
@@ -311,9 +48,14 @@ function createCommandContext(opts) {
|
|
|
311
48
|
compact: opts.compact,
|
|
312
49
|
jq: opts.jq
|
|
313
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* The token getter for this command. An identity-mode profile's getter
|
|
53
|
+
* restores and refreshes its session on each call, so a long command never
|
|
54
|
+
* sends an expired token.
|
|
55
|
+
*/
|
|
314
56
|
function requireToken() {
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
57
|
+
const getter = tokenGetter(resolveSource(opts));
|
|
58
|
+
if (getter) return getter;
|
|
317
59
|
if (opts.profile) throw new Error(`No API token found for profile "${opts.profile}". Run \`fluid login\` for that profile or provide --token <token>`);
|
|
318
60
|
throw new Error("No API token found. Run `fluid login` or provide --token <token>");
|
|
319
61
|
}
|
|
@@ -321,18 +63,18 @@ function createCommandContext(opts) {
|
|
|
321
63
|
verbose: opts.verbose,
|
|
322
64
|
async getClient() {
|
|
323
65
|
if (clientInstance) return clientInstance;
|
|
324
|
-
const
|
|
66
|
+
const getAuthToken = requireToken();
|
|
325
67
|
clientInstance = createFetchClient({
|
|
326
68
|
baseUrl: opts.baseUrl ?? process.env["FLUID_API_BASE"] ?? "https://api.fluid.app",
|
|
327
|
-
getAuthToken
|
|
69
|
+
getAuthToken
|
|
328
70
|
});
|
|
329
71
|
return clientInstance;
|
|
330
72
|
},
|
|
331
73
|
async getClientFor(serviceBaseUrl) {
|
|
332
|
-
const
|
|
74
|
+
const getAuthToken = requireToken();
|
|
333
75
|
return createFetchClient({
|
|
334
76
|
baseUrl: serviceBaseUrl.replace(/\/$/, ""),
|
|
335
|
-
getAuthToken
|
|
77
|
+
getAuthToken
|
|
336
78
|
});
|
|
337
79
|
},
|
|
338
80
|
output(data) {
|
|
@@ -348,17 +90,23 @@ function createCommandContext(opts) {
|
|
|
348
90
|
}
|
|
349
91
|
};
|
|
350
92
|
}
|
|
351
|
-
function
|
|
352
|
-
if (opts.token) return
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
93
|
+
function resolveSource(opts) {
|
|
94
|
+
if (opts.token) return {
|
|
95
|
+
kind: "token",
|
|
96
|
+
token: opts.token
|
|
97
|
+
};
|
|
98
|
+
return resolveCredentialSource(opts.profile);
|
|
99
|
+
}
|
|
100
|
+
function tokenGetter(source) {
|
|
101
|
+
if (!source) return null;
|
|
102
|
+
if (source.kind === "token") {
|
|
103
|
+
const token = source.token;
|
|
104
|
+
return () => token;
|
|
360
105
|
}
|
|
361
|
-
|
|
106
|
+
const profile = source.profile;
|
|
107
|
+
if (isIdentityProfile(profile)) return () => profileAccessToken(profile);
|
|
108
|
+
const token = profile.token;
|
|
109
|
+
return token ? () => token : null;
|
|
362
110
|
}
|
|
363
111
|
//#endregion
|
|
364
112
|
//#region src/domain/command.ts
|
|
@@ -792,6 +540,6 @@ async function resolveGitSyncActor(fetchActor) {
|
|
|
792
540
|
return fetched;
|
|
793
541
|
}
|
|
794
542
|
//#endregion
|
|
795
|
-
export { ACTOR_CACHE_TTL_MS, NAV_HELP, SYSTEM_ACTOR_NAME, assertInteractive, changeStatusFromCode, confirmMfa, createCommandContext, createDefaultConfig, createDomainCommand, describeCommand, failure, fetchUserCompanies, findProjectConfig, formatCommitTimestamp, formatOutput, getActiveProfile, getAuthToken, getConfigDir, getConfigFilePath, getErrorMessage, getFluidApiBase, gitSyncActorFromMe, gitSyncCommitSubject, gitSyncSubjectAuthor, isError, isFailure, isNodeError, isSuccess, listProfileNames, mapError, mapResult, parseGitSyncSubject, parseNameStatusZ, parseTyped, readCachedActor, readConfig, resolveGitSyncActor, sendMfa, subjectFragment, success, summarizeChanges, switchCompany, terminalPrompter, tryCatch, tryCatchAsync, unwrap, unwrapOr, updateConfig, validateToken, walkCommands, writeCachedActor, writeConfig };
|
|
543
|
+
export { ACTOR_CACHE_TTL_MS, NAV_HELP, SYSTEM_ACTOR_NAME, assertInteractive, changeStatusFromCode, confirmMfa, createCommandContext, createDefaultConfig, createDomainCommand, describeCommand, failure, fetchUserCompanies, findProjectConfig, formatCommitTimestamp, formatOutput, getActiveProfile, getAuthToken, getAuthTokenAsync, getConfigDir, getConfigFilePath, getErrorMessage, getFluidApiBase, gitSyncActorFromMe, gitSyncCommitSubject, gitSyncSubjectAuthor, isError, isFailure, isIdentityProfile, isNodeError, isSuccess, listProfileNames, mapError, mapResult, parseGitSyncSubject, parseNameStatusZ, parseTyped, readCachedActor, readConfig, resolveGitSyncActor, sendMfa, subjectFragment, success, summarizeChanges, switchCompany, terminalPrompter, tryCatch, tryCatchAsync, unwrap, unwrapOr, updateConfig, validateToken, walkCommands, writeCachedActor, writeConfig };
|
|
796
544
|
|
|
797
545
|
//# sourceMappingURL=index.mjs.map
|