brex-cli 2026.2.1 → 2026.2.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.
- package/dist/main.js +194 -476
- package/package.json +3 -5
package/dist/main.js
CHANGED
|
@@ -2,334 +2,9 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// sources/config.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var homedir = function() {
|
|
9
|
-
return "/";
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// node:path
|
|
13
|
-
function assertPath(path) {
|
|
14
|
-
if (typeof path !== "string")
|
|
15
|
-
throw TypeError("Path must be a string. Received " + JSON.stringify(path));
|
|
16
|
-
}
|
|
17
|
-
function normalizeStringPosix(path, allowAboveRoot) {
|
|
18
|
-
var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
|
|
19
|
-
for (var i = 0;i <= path.length; ++i) {
|
|
20
|
-
if (i < path.length)
|
|
21
|
-
code = path.charCodeAt(i);
|
|
22
|
-
else if (code === 47)
|
|
23
|
-
break;
|
|
24
|
-
else
|
|
25
|
-
code = 47;
|
|
26
|
-
if (code === 47) {
|
|
27
|
-
if (lastSlash === i - 1 || dots === 1)
|
|
28
|
-
;
|
|
29
|
-
else if (lastSlash !== i - 1 && dots === 2) {
|
|
30
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
|
31
|
-
if (res.length > 2) {
|
|
32
|
-
var lastSlashIndex = res.lastIndexOf("/");
|
|
33
|
-
if (lastSlashIndex !== res.length - 1) {
|
|
34
|
-
if (lastSlashIndex === -1)
|
|
35
|
-
res = "", lastSegmentLength = 0;
|
|
36
|
-
else
|
|
37
|
-
res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
38
|
-
lastSlash = i, dots = 0;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
} else if (res.length === 2 || res.length === 1) {
|
|
42
|
-
res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (allowAboveRoot) {
|
|
47
|
-
if (res.length > 0)
|
|
48
|
-
res += "/..";
|
|
49
|
-
else
|
|
50
|
-
res = "..";
|
|
51
|
-
lastSegmentLength = 2;
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
if (res.length > 0)
|
|
55
|
-
res += "/" + path.slice(lastSlash + 1, i);
|
|
56
|
-
else
|
|
57
|
-
res = path.slice(lastSlash + 1, i);
|
|
58
|
-
lastSegmentLength = i - lastSlash - 1;
|
|
59
|
-
}
|
|
60
|
-
lastSlash = i, dots = 0;
|
|
61
|
-
} else if (code === 46 && dots !== -1)
|
|
62
|
-
++dots;
|
|
63
|
-
else
|
|
64
|
-
dots = -1;
|
|
65
|
-
}
|
|
66
|
-
return res;
|
|
67
|
-
}
|
|
68
|
-
function _format(sep, pathObject) {
|
|
69
|
-
var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
70
|
-
if (!dir)
|
|
71
|
-
return base;
|
|
72
|
-
if (dir === pathObject.root)
|
|
73
|
-
return dir + base;
|
|
74
|
-
return dir + sep + base;
|
|
75
|
-
}
|
|
76
|
-
function resolve() {
|
|
77
|
-
var resolvedPath = "", resolvedAbsolute = false, cwd;
|
|
78
|
-
for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
|
|
79
|
-
var path;
|
|
80
|
-
if (i >= 0)
|
|
81
|
-
path = arguments[i];
|
|
82
|
-
else {
|
|
83
|
-
if (cwd === undefined)
|
|
84
|
-
cwd = process.cwd();
|
|
85
|
-
path = cwd;
|
|
86
|
-
}
|
|
87
|
-
if (assertPath(path), path.length === 0)
|
|
88
|
-
continue;
|
|
89
|
-
resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
|
|
90
|
-
}
|
|
91
|
-
if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
|
|
92
|
-
if (resolvedPath.length > 0)
|
|
93
|
-
return "/" + resolvedPath;
|
|
94
|
-
else
|
|
95
|
-
return "/";
|
|
96
|
-
else if (resolvedPath.length > 0)
|
|
97
|
-
return resolvedPath;
|
|
98
|
-
else
|
|
99
|
-
return ".";
|
|
100
|
-
}
|
|
101
|
-
function normalize(path) {
|
|
102
|
-
if (assertPath(path), path.length === 0)
|
|
103
|
-
return ".";
|
|
104
|
-
var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
|
105
|
-
if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
|
|
106
|
-
path = ".";
|
|
107
|
-
if (path.length > 0 && trailingSeparator)
|
|
108
|
-
path += "/";
|
|
109
|
-
if (isAbsolute)
|
|
110
|
-
return "/" + path;
|
|
111
|
-
return path;
|
|
112
|
-
}
|
|
113
|
-
function isAbsolute(path) {
|
|
114
|
-
return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
|
|
115
|
-
}
|
|
116
|
-
function join() {
|
|
117
|
-
if (arguments.length === 0)
|
|
118
|
-
return ".";
|
|
119
|
-
var joined;
|
|
120
|
-
for (var i = 0;i < arguments.length; ++i) {
|
|
121
|
-
var arg = arguments[i];
|
|
122
|
-
if (assertPath(arg), arg.length > 0)
|
|
123
|
-
if (joined === undefined)
|
|
124
|
-
joined = arg;
|
|
125
|
-
else
|
|
126
|
-
joined += "/" + arg;
|
|
127
|
-
}
|
|
128
|
-
if (joined === undefined)
|
|
129
|
-
return ".";
|
|
130
|
-
return normalize(joined);
|
|
131
|
-
}
|
|
132
|
-
function relative(from, to) {
|
|
133
|
-
if (assertPath(from), assertPath(to), from === to)
|
|
134
|
-
return "";
|
|
135
|
-
if (from = resolve(from), to = resolve(to), from === to)
|
|
136
|
-
return "";
|
|
137
|
-
var fromStart = 1;
|
|
138
|
-
for (;fromStart < from.length; ++fromStart)
|
|
139
|
-
if (from.charCodeAt(fromStart) !== 47)
|
|
140
|
-
break;
|
|
141
|
-
var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
|
|
142
|
-
for (;toStart < to.length; ++toStart)
|
|
143
|
-
if (to.charCodeAt(toStart) !== 47)
|
|
144
|
-
break;
|
|
145
|
-
var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
|
|
146
|
-
for (;i <= length; ++i) {
|
|
147
|
-
if (i === length) {
|
|
148
|
-
if (toLen > length) {
|
|
149
|
-
if (to.charCodeAt(toStart + i) === 47)
|
|
150
|
-
return to.slice(toStart + i + 1);
|
|
151
|
-
else if (i === 0)
|
|
152
|
-
return to.slice(toStart + i);
|
|
153
|
-
} else if (fromLen > length) {
|
|
154
|
-
if (from.charCodeAt(fromStart + i) === 47)
|
|
155
|
-
lastCommonSep = i;
|
|
156
|
-
else if (i === 0)
|
|
157
|
-
lastCommonSep = 0;
|
|
158
|
-
}
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
|
|
162
|
-
if (fromCode !== toCode)
|
|
163
|
-
break;
|
|
164
|
-
else if (fromCode === 47)
|
|
165
|
-
lastCommonSep = i;
|
|
166
|
-
}
|
|
167
|
-
var out = "";
|
|
168
|
-
for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
|
|
169
|
-
if (i === fromEnd || from.charCodeAt(i) === 47)
|
|
170
|
-
if (out.length === 0)
|
|
171
|
-
out += "..";
|
|
172
|
-
else
|
|
173
|
-
out += "/..";
|
|
174
|
-
if (out.length > 0)
|
|
175
|
-
return out + to.slice(toStart + lastCommonSep);
|
|
176
|
-
else {
|
|
177
|
-
if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
|
|
178
|
-
++toStart;
|
|
179
|
-
return to.slice(toStart);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function _makeLong(path) {
|
|
183
|
-
return path;
|
|
184
|
-
}
|
|
185
|
-
function dirname(path) {
|
|
186
|
-
if (assertPath(path), path.length === 0)
|
|
187
|
-
return ".";
|
|
188
|
-
var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
|
|
189
|
-
for (var i = path.length - 1;i >= 1; --i)
|
|
190
|
-
if (code = path.charCodeAt(i), code === 47) {
|
|
191
|
-
if (!matchedSlash) {
|
|
192
|
-
end = i;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
} else
|
|
196
|
-
matchedSlash = false;
|
|
197
|
-
if (end === -1)
|
|
198
|
-
return hasRoot ? "/" : ".";
|
|
199
|
-
if (hasRoot && end === 1)
|
|
200
|
-
return "//";
|
|
201
|
-
return path.slice(0, end);
|
|
202
|
-
}
|
|
203
|
-
function basename(path, ext) {
|
|
204
|
-
if (ext !== undefined && typeof ext !== "string")
|
|
205
|
-
throw TypeError('"ext" argument must be a string');
|
|
206
|
-
assertPath(path);
|
|
207
|
-
var start = 0, end = -1, matchedSlash = true, i;
|
|
208
|
-
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
209
|
-
if (ext.length === path.length && ext === path)
|
|
210
|
-
return "";
|
|
211
|
-
var extIdx = ext.length - 1, firstNonSlashEnd = -1;
|
|
212
|
-
for (i = path.length - 1;i >= 0; --i) {
|
|
213
|
-
var code = path.charCodeAt(i);
|
|
214
|
-
if (code === 47) {
|
|
215
|
-
if (!matchedSlash) {
|
|
216
|
-
start = i + 1;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
} else {
|
|
220
|
-
if (firstNonSlashEnd === -1)
|
|
221
|
-
matchedSlash = false, firstNonSlashEnd = i + 1;
|
|
222
|
-
if (extIdx >= 0)
|
|
223
|
-
if (code === ext.charCodeAt(extIdx)) {
|
|
224
|
-
if (--extIdx === -1)
|
|
225
|
-
end = i;
|
|
226
|
-
} else
|
|
227
|
-
extIdx = -1, end = firstNonSlashEnd;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (start === end)
|
|
231
|
-
end = firstNonSlashEnd;
|
|
232
|
-
else if (end === -1)
|
|
233
|
-
end = path.length;
|
|
234
|
-
return path.slice(start, end);
|
|
235
|
-
} else {
|
|
236
|
-
for (i = path.length - 1;i >= 0; --i)
|
|
237
|
-
if (path.charCodeAt(i) === 47) {
|
|
238
|
-
if (!matchedSlash) {
|
|
239
|
-
start = i + 1;
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
} else if (end === -1)
|
|
243
|
-
matchedSlash = false, end = i + 1;
|
|
244
|
-
if (end === -1)
|
|
245
|
-
return "";
|
|
246
|
-
return path.slice(start, end);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
function extname(path) {
|
|
250
|
-
assertPath(path);
|
|
251
|
-
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
|
|
252
|
-
for (var i = path.length - 1;i >= 0; --i) {
|
|
253
|
-
var code = path.charCodeAt(i);
|
|
254
|
-
if (code === 47) {
|
|
255
|
-
if (!matchedSlash) {
|
|
256
|
-
startPart = i + 1;
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (end === -1)
|
|
262
|
-
matchedSlash = false, end = i + 1;
|
|
263
|
-
if (code === 46) {
|
|
264
|
-
if (startDot === -1)
|
|
265
|
-
startDot = i;
|
|
266
|
-
else if (preDotState !== 1)
|
|
267
|
-
preDotState = 1;
|
|
268
|
-
} else if (startDot !== -1)
|
|
269
|
-
preDotState = -1;
|
|
270
|
-
}
|
|
271
|
-
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
|
|
272
|
-
return "";
|
|
273
|
-
return path.slice(startDot, end);
|
|
274
|
-
}
|
|
275
|
-
function format(pathObject) {
|
|
276
|
-
if (pathObject === null || typeof pathObject !== "object")
|
|
277
|
-
throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
278
|
-
return _format("/", pathObject);
|
|
279
|
-
}
|
|
280
|
-
function parse(path) {
|
|
281
|
-
assertPath(path);
|
|
282
|
-
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
283
|
-
if (path.length === 0)
|
|
284
|
-
return ret;
|
|
285
|
-
var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
|
|
286
|
-
if (isAbsolute2)
|
|
287
|
-
ret.root = "/", start = 1;
|
|
288
|
-
else
|
|
289
|
-
start = 0;
|
|
290
|
-
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
|
|
291
|
-
for (;i >= start; --i) {
|
|
292
|
-
if (code = path.charCodeAt(i), code === 47) {
|
|
293
|
-
if (!matchedSlash) {
|
|
294
|
-
startPart = i + 1;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
if (end === -1)
|
|
300
|
-
matchedSlash = false, end = i + 1;
|
|
301
|
-
if (code === 46) {
|
|
302
|
-
if (startDot === -1)
|
|
303
|
-
startDot = i;
|
|
304
|
-
else if (preDotState !== 1)
|
|
305
|
-
preDotState = 1;
|
|
306
|
-
} else if (startDot !== -1)
|
|
307
|
-
preDotState = -1;
|
|
308
|
-
}
|
|
309
|
-
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
310
|
-
if (end !== -1)
|
|
311
|
-
if (startPart === 0 && isAbsolute2)
|
|
312
|
-
ret.base = ret.name = path.slice(1, end);
|
|
313
|
-
else
|
|
314
|
-
ret.base = ret.name = path.slice(startPart, end);
|
|
315
|
-
} else {
|
|
316
|
-
if (startPart === 0 && isAbsolute2)
|
|
317
|
-
ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
|
|
318
|
-
else
|
|
319
|
-
ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
|
|
320
|
-
ret.ext = path.slice(startDot, end);
|
|
321
|
-
}
|
|
322
|
-
if (startPart > 0)
|
|
323
|
-
ret.dir = path.slice(0, startPart - 1);
|
|
324
|
-
else if (isAbsolute2)
|
|
325
|
-
ret.dir = "/";
|
|
326
|
-
return ret;
|
|
327
|
-
}
|
|
328
|
-
var sep = "/";
|
|
329
|
-
var delimiter = ":";
|
|
330
|
-
var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
|
|
331
|
-
|
|
332
|
-
// sources/config.ts
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
333
8
|
var CONFIG_DIR = join(homedir(), ".brex");
|
|
334
9
|
var TOKEN_PATH = join(CONFIG_DIR, "token");
|
|
335
10
|
var CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
@@ -339,6 +14,10 @@ function ensureConfigDir() {
|
|
|
339
14
|
}
|
|
340
15
|
}
|
|
341
16
|
function loadToken() {
|
|
17
|
+
const envToken = process.env.BREX_API_TOKEN?.trim();
|
|
18
|
+
if (envToken && envToken.length > 0) {
|
|
19
|
+
return envToken;
|
|
20
|
+
}
|
|
342
21
|
if (!existsSync(TOKEN_PATH)) {
|
|
343
22
|
return null;
|
|
344
23
|
}
|
|
@@ -421,7 +100,10 @@ function createBrexClient() {
|
|
|
421
100
|
if (response.status === 204) {
|
|
422
101
|
return;
|
|
423
102
|
}
|
|
424
|
-
|
|
103
|
+
const text = (await response.text()).trim();
|
|
104
|
+
if (!text)
|
|
105
|
+
return;
|
|
106
|
+
return JSON.parse(text);
|
|
425
107
|
}
|
|
426
108
|
};
|
|
427
109
|
}
|
|
@@ -552,16 +234,16 @@ class BrexApiError2 extends Error {
|
|
|
552
234
|
|
|
553
235
|
// sources/output.ts
|
|
554
236
|
function parseOutputFlag(args) {
|
|
555
|
-
let
|
|
237
|
+
let format = "table";
|
|
556
238
|
const remaining = [];
|
|
557
239
|
for (const arg of args) {
|
|
558
240
|
if (arg === "--json") {
|
|
559
|
-
|
|
241
|
+
format = "json";
|
|
560
242
|
continue;
|
|
561
243
|
}
|
|
562
244
|
remaining.push(arg);
|
|
563
245
|
}
|
|
564
|
-
return { format
|
|
246
|
+
return { format, args: remaining };
|
|
565
247
|
}
|
|
566
248
|
function printJson(data) {
|
|
567
249
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -641,18 +323,18 @@ var accountsCommand = {
|
|
|
641
323
|
usage: USAGE4,
|
|
642
324
|
aliases: ["account", "acc"],
|
|
643
325
|
run: async (args, context) => {
|
|
644
|
-
const { format
|
|
326
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
645
327
|
const subcommand = remaining[0] ?? "list";
|
|
646
328
|
switch (subcommand) {
|
|
647
329
|
case "list":
|
|
648
|
-
await listAccounts(context, parseListOptions(remaining.slice(1)),
|
|
330
|
+
await listAccounts(context, parseListOptions(remaining.slice(1)), format);
|
|
649
331
|
return;
|
|
650
332
|
case "get": {
|
|
651
333
|
const accountId = remaining[1];
|
|
652
334
|
if (!accountId) {
|
|
653
335
|
throw new Error("Missing account ID. Usage: brex accounts get <account-id> [--type cash|card]");
|
|
654
336
|
}
|
|
655
|
-
await getAccount(context, accountId, parseGetOptions(remaining.slice(2)),
|
|
337
|
+
await getAccount(context, accountId, parseGetOptions(remaining.slice(2)), format);
|
|
656
338
|
return;
|
|
657
339
|
}
|
|
658
340
|
default:
|
|
@@ -711,13 +393,13 @@ function parseGetOptions(args) {
|
|
|
711
393
|
}
|
|
712
394
|
return { type };
|
|
713
395
|
}
|
|
714
|
-
async function listAccounts(context, options,
|
|
396
|
+
async function listAccounts(context, options, format) {
|
|
715
397
|
const cashPath = withCursor("/v2/accounts/cash", options.cursor);
|
|
716
398
|
const cardPath = withCursor("/v2/accounts/card", options.cursor);
|
|
717
399
|
if (options.type === "cash") {
|
|
718
400
|
const cashResponse2 = await context.client.fetch(cashPath);
|
|
719
401
|
const cashAccounts2 = extractItems(cashResponse2, ["items", "cash_accounts", "accounts"]);
|
|
720
|
-
if (
|
|
402
|
+
if (format === "json") {
|
|
721
403
|
printJson({ items: cashAccounts2, nextCursor: cashResponse2.next_cursor ?? null });
|
|
722
404
|
return;
|
|
723
405
|
}
|
|
@@ -731,7 +413,7 @@ Next cursor: ${cashResponse2.next_cursor}`);
|
|
|
731
413
|
if (options.type === "card") {
|
|
732
414
|
const cardResponse2 = await context.client.fetch(cardPath);
|
|
733
415
|
const cardAccounts2 = extractItems(cardResponse2, ["items", "card_accounts", "accounts"]);
|
|
734
|
-
if (
|
|
416
|
+
if (format === "json") {
|
|
735
417
|
printJson({ items: cardAccounts2, nextCursor: cardResponse2.next_cursor ?? null });
|
|
736
418
|
return;
|
|
737
419
|
}
|
|
@@ -748,7 +430,7 @@ Next cursor: ${cardResponse2.next_cursor}`);
|
|
|
748
430
|
]);
|
|
749
431
|
const cashAccounts = extractItems(cashResponse, ["items", "cash_accounts", "accounts"]);
|
|
750
432
|
const cardAccounts = extractItems(cardResponse, ["items", "card_accounts", "accounts"]);
|
|
751
|
-
if (
|
|
433
|
+
if (format === "json") {
|
|
752
434
|
printJson({
|
|
753
435
|
cash: { items: cashAccounts, nextCursor: cashResponse.next_cursor ?? null },
|
|
754
436
|
card: { items: cardAccounts, nextCursor: cardResponse.next_cursor ?? null }
|
|
@@ -761,22 +443,22 @@ Next cursor: ${cardResponse2.next_cursor}`);
|
|
|
761
443
|
];
|
|
762
444
|
printAccountsTable(rows);
|
|
763
445
|
}
|
|
764
|
-
async function getAccount(context, accountId, options,
|
|
446
|
+
async function getAccount(context, accountId, options, format) {
|
|
765
447
|
const fetchCash = async () => context.client.fetch(`/v2/accounts/cash/${accountId}`);
|
|
766
448
|
const fetchCard = async () => context.client.fetch(`/v2/accounts/card/${accountId}`);
|
|
767
449
|
if (options.type === "cash") {
|
|
768
450
|
const account = await fetchCash();
|
|
769
|
-
renderAccount(account, "cash",
|
|
451
|
+
renderAccount(account, "cash", format);
|
|
770
452
|
return;
|
|
771
453
|
}
|
|
772
454
|
if (options.type === "card") {
|
|
773
455
|
const account = await fetchCard();
|
|
774
|
-
renderAccount(account, "card",
|
|
456
|
+
renderAccount(account, "card", format);
|
|
775
457
|
return;
|
|
776
458
|
}
|
|
777
459
|
try {
|
|
778
460
|
const account = await fetchCash();
|
|
779
|
-
renderAccount(account, "cash",
|
|
461
|
+
renderAccount(account, "cash", format);
|
|
780
462
|
return;
|
|
781
463
|
} catch (error) {
|
|
782
464
|
if (!(error instanceof BrexApiError2) || error.status !== 404) {
|
|
@@ -784,10 +466,10 @@ async function getAccount(context, accountId, options, format2) {
|
|
|
784
466
|
}
|
|
785
467
|
}
|
|
786
468
|
const cardAccount = await fetchCard();
|
|
787
|
-
renderAccount(cardAccount, "card",
|
|
469
|
+
renderAccount(cardAccount, "card", format);
|
|
788
470
|
}
|
|
789
|
-
function renderAccount(account, type,
|
|
790
|
-
if (
|
|
471
|
+
function renderAccount(account, type, format) {
|
|
472
|
+
if (format === "json") {
|
|
791
473
|
printJson(account);
|
|
792
474
|
return;
|
|
793
475
|
}
|
|
@@ -866,7 +548,7 @@ var transactionsCommand = {
|
|
|
866
548
|
usage: USAGE5,
|
|
867
549
|
aliases: ["tx", "txn"],
|
|
868
550
|
run: async (args, context) => {
|
|
869
|
-
const { format
|
|
551
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
870
552
|
if (remaining.length === 0) {
|
|
871
553
|
throw new Error("Missing account ID. Usage: brex transactions <account-id>");
|
|
872
554
|
}
|
|
@@ -877,7 +559,7 @@ var transactionsCommand = {
|
|
|
877
559
|
if (!accountId2 || !transactionId) {
|
|
878
560
|
throw new Error("Usage: brex transactions get <account-id> <transaction-id> [--type cash|card]");
|
|
879
561
|
}
|
|
880
|
-
await getTransaction(context, accountId2, transactionId, parseGetOptions2(remaining.slice(3)),
|
|
562
|
+
await getTransaction(context, accountId2, transactionId, parseGetOptions2(remaining.slice(3)), format);
|
|
881
563
|
return;
|
|
882
564
|
}
|
|
883
565
|
if (firstArg === "send") {
|
|
@@ -885,7 +567,7 @@ var transactionsCommand = {
|
|
|
885
567
|
}
|
|
886
568
|
const accountId = firstArg;
|
|
887
569
|
const options = parseListOptions2(remaining.slice(1));
|
|
888
|
-
await listTransactions(context, accountId, options,
|
|
570
|
+
await listTransactions(context, accountId, options, format);
|
|
889
571
|
}
|
|
890
572
|
};
|
|
891
573
|
function parseListOptions2(args) {
|
|
@@ -960,12 +642,12 @@ function parseGetOptions2(args) {
|
|
|
960
642
|
}
|
|
961
643
|
return { type };
|
|
962
644
|
}
|
|
963
|
-
async function listTransactions(context, accountId, options,
|
|
645
|
+
async function listTransactions(context, accountId, options, format) {
|
|
964
646
|
const pathBase = options.type === "cash" ? `/v2/transactions/cash/${accountId}` : `/v2/transactions/card/${accountId}`;
|
|
965
647
|
const path = withQuery(pathBase, options);
|
|
966
648
|
const response = await context.client.fetch(path);
|
|
967
649
|
const transactions = response.items ?? response.transactions ?? [];
|
|
968
|
-
if (
|
|
650
|
+
if (format === "json") {
|
|
969
651
|
printJson({ items: transactions, nextCursor: response.next_cursor ?? null });
|
|
970
652
|
return;
|
|
971
653
|
}
|
|
@@ -986,14 +668,14 @@ async function listTransactions(context, accountId, options, format2) {
|
|
|
986
668
|
Next cursor: ${response.next_cursor}`);
|
|
987
669
|
}
|
|
988
670
|
}
|
|
989
|
-
async function getTransaction(context, accountId, transactionId, options,
|
|
671
|
+
async function getTransaction(context, accountId, transactionId, options, format) {
|
|
990
672
|
const path = options.type === "cash" ? `/v2/transactions/cash/${accountId}/${transactionId}` : `/v2/transactions/card/${accountId}/${transactionId}`;
|
|
991
673
|
const response = await context.client.fetch(path);
|
|
992
674
|
const transaction = response.cash_transaction ?? response.card_transaction ?? response.transaction ?? response.item;
|
|
993
675
|
if (!transaction) {
|
|
994
676
|
throw new Error("Brex API returned an empty transaction payload.");
|
|
995
677
|
}
|
|
996
|
-
if (
|
|
678
|
+
if (format === "json") {
|
|
997
679
|
printJson(transaction);
|
|
998
680
|
return;
|
|
999
681
|
}
|
|
@@ -1045,21 +727,21 @@ var transferCommand = {
|
|
|
1045
727
|
description: "Create and inspect transfers.",
|
|
1046
728
|
usage: USAGE6,
|
|
1047
729
|
run: async (args, context) => {
|
|
1048
|
-
const { format
|
|
730
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
1049
731
|
const subcommand = remaining[0];
|
|
1050
732
|
if (subcommand === "get") {
|
|
1051
733
|
const transferId = remaining[1];
|
|
1052
734
|
if (!transferId)
|
|
1053
735
|
throw new Error("Usage: brex transfer get <transfer-id>");
|
|
1054
|
-
await getTransfer(context, transferId,
|
|
736
|
+
await getTransfer(context, transferId, format);
|
|
1055
737
|
return;
|
|
1056
738
|
}
|
|
1057
739
|
if (subcommand === "list") {
|
|
1058
|
-
await listTransfers(context, parseListTransferOptions(remaining.slice(1)),
|
|
740
|
+
await listTransfers(context, parseListTransferOptions(remaining.slice(1)), format);
|
|
1059
741
|
return;
|
|
1060
742
|
}
|
|
1061
743
|
const options = parseCreateTransferOptions(remaining);
|
|
1062
|
-
await createTransfer(context, options,
|
|
744
|
+
await createTransfer(context, options, format);
|
|
1063
745
|
}
|
|
1064
746
|
};
|
|
1065
747
|
function parseCreateTransferOptions(args) {
|
|
@@ -1176,7 +858,7 @@ function parseListTransferOptions(args) {
|
|
|
1176
858
|
}
|
|
1177
859
|
return options;
|
|
1178
860
|
}
|
|
1179
|
-
async function createTransfer(context, options,
|
|
861
|
+
async function createTransfer(context, options, format) {
|
|
1180
862
|
const body = {
|
|
1181
863
|
from_account: {
|
|
1182
864
|
cash_account: {
|
|
@@ -1191,8 +873,7 @@ async function createTransfer(context, options, format2) {
|
|
|
1191
873
|
amount: {
|
|
1192
874
|
amount: options.amount,
|
|
1193
875
|
currency: options.currency
|
|
1194
|
-
}
|
|
1195
|
-
idempotency_key: options.idempotencyKey
|
|
876
|
+
}
|
|
1196
877
|
};
|
|
1197
878
|
const response = await context.client.fetch("/v1/transfers", {
|
|
1198
879
|
method: "POST",
|
|
@@ -1202,22 +883,22 @@ async function createTransfer(context, options, format2) {
|
|
|
1202
883
|
body: JSON.stringify(body)
|
|
1203
884
|
});
|
|
1204
885
|
const transfer = response.transfer ?? response.item ?? response;
|
|
1205
|
-
if (
|
|
886
|
+
if (format === "json") {
|
|
1206
887
|
printJson(transfer);
|
|
1207
888
|
return;
|
|
1208
889
|
}
|
|
1209
890
|
printTransferDetails(transfer, "Transfer Created");
|
|
1210
891
|
}
|
|
1211
|
-
async function getTransfer(context, transferId,
|
|
892
|
+
async function getTransfer(context, transferId, format) {
|
|
1212
893
|
const response = await context.client.fetch(`/v1/transfers/${transferId}`);
|
|
1213
894
|
const transfer = response.transfer ?? response.item ?? response;
|
|
1214
|
-
if (
|
|
895
|
+
if (format === "json") {
|
|
1215
896
|
printJson(transfer);
|
|
1216
897
|
return;
|
|
1217
898
|
}
|
|
1218
899
|
printTransferDetails(transfer, "Transfer Details");
|
|
1219
900
|
}
|
|
1220
|
-
async function listTransfers(context, options,
|
|
901
|
+
async function listTransfers(context, options, format) {
|
|
1221
902
|
const params = new URLSearchParams;
|
|
1222
903
|
if (options.cursor)
|
|
1223
904
|
params.set("cursor", options.cursor);
|
|
@@ -1233,7 +914,7 @@ async function listTransfers(context, options, format2) {
|
|
|
1233
914
|
const path = query ? `/v1/transfers?${query}` : "/v1/transfers";
|
|
1234
915
|
const response = await context.client.fetch(path);
|
|
1235
916
|
const transfers = response.items ?? response.transfers ?? [];
|
|
1236
|
-
if (
|
|
917
|
+
if (format === "json") {
|
|
1237
918
|
printJson({ items: transfers, nextCursor: response.next_cursor ?? null });
|
|
1238
919
|
return;
|
|
1239
920
|
}
|
|
@@ -1243,16 +924,18 @@ async function listTransfers(context, options, format2) {
|
|
|
1243
924
|
}
|
|
1244
925
|
printTable(transfers.map((transfer) => ({
|
|
1245
926
|
id: transfer.id,
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
amount: transfer.amount ? formatAmount(transfer.amount.amount, transfer.amount.currency) : "-",
|
|
1249
|
-
status: transfer.status ?? "-"
|
|
927
|
+
name: transfer.display_name ?? transfer.counterparty?.description ?? "-",
|
|
928
|
+
from: transfer.originating_account?.id ?? transfer.from_account?.cash_account?.id ?? "-",
|
|
929
|
+
amount: transfer.amount ? formatAmount(centsToDecimal(transfer.amount.amount), transfer.amount.currency) : "-",
|
|
930
|
+
status: transfer.status ?? "-",
|
|
931
|
+
date: formatDate(transfer.process_date ?? transfer.created_at)
|
|
1250
932
|
})), [
|
|
1251
933
|
{ key: "id", header: "Transfer ID", width: 36 },
|
|
934
|
+
{ key: "name", header: "Name", width: 20 },
|
|
1252
935
|
{ key: "from", header: "From Account", width: 36 },
|
|
1253
|
-
{ key: "to", header: "To Counterparty", width: 36 },
|
|
1254
936
|
{ key: "amount", header: "Amount", width: 14 },
|
|
1255
|
-
{ key: "status", header: "Status", width:
|
|
937
|
+
{ key: "status", header: "Status", width: 12 },
|
|
938
|
+
{ key: "date", header: "Date", width: 12 }
|
|
1256
939
|
]);
|
|
1257
940
|
if (response.next_cursor) {
|
|
1258
941
|
console.log(`
|
|
@@ -1262,14 +945,25 @@ Next cursor: ${response.next_cursor}`);
|
|
|
1262
945
|
function printTransferDetails(transfer, title) {
|
|
1263
946
|
console.log(title);
|
|
1264
947
|
console.log("──────────────────");
|
|
1265
|
-
console.log(`ID:
|
|
1266
|
-
console.log(`
|
|
1267
|
-
console.log(`
|
|
1268
|
-
console.log(`
|
|
1269
|
-
console.log(`
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
948
|
+
console.log(`ID: ${transfer.id}`);
|
|
949
|
+
console.log(`Name: ${transfer.display_name ?? transfer.counterparty?.description ?? "-"}`);
|
|
950
|
+
console.log(`From Account: ${transfer.originating_account?.id ?? transfer.from_account?.cash_account?.id ?? "-"}`);
|
|
951
|
+
console.log(`To: ${transfer.counterparty?.description ?? transfer.recipient?.payment_counterparty?.id ?? "-"}`);
|
|
952
|
+
console.log(`Amount: ${transfer.amount ? formatAmount(centsToDecimal(transfer.amount.amount), transfer.amount.currency) : "-"}`);
|
|
953
|
+
console.log(`Status: ${transfer.status ?? "-"}`);
|
|
954
|
+
console.log(`Type: ${transfer.payment_type ?? "-"}`);
|
|
955
|
+
if (transfer.process_date)
|
|
956
|
+
console.log(`Process Date: ${formatDate(transfer.process_date)}`);
|
|
957
|
+
if (transfer.estimated_delivery_date)
|
|
958
|
+
console.log(`Est Delivery: ${formatDate(transfer.estimated_delivery_date)}`);
|
|
959
|
+
if (transfer.external_memo)
|
|
960
|
+
console.log(`Memo: ${transfer.external_memo}`);
|
|
961
|
+
if (transfer.idempotency_key)
|
|
962
|
+
console.log(`Idempotency: ${transfer.idempotency_key}`);
|
|
963
|
+
}
|
|
964
|
+
function centsToDecimal(amount) {
|
|
965
|
+
const numeric = typeof amount === "string" ? Number(amount) : amount;
|
|
966
|
+
return numeric / 100;
|
|
1273
967
|
}
|
|
1274
968
|
|
|
1275
969
|
// sources/commands/recipients/index.ts
|
|
@@ -1285,21 +979,21 @@ var recipientsCommand = {
|
|
|
1285
979
|
usage: USAGE7,
|
|
1286
980
|
aliases: ["recipient", "recip"],
|
|
1287
981
|
run: async (args, context) => {
|
|
1288
|
-
const { format
|
|
982
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
1289
983
|
const subcommand = remaining[0] ?? "list";
|
|
1290
984
|
switch (subcommand) {
|
|
1291
985
|
case "list":
|
|
1292
|
-
await listRecipients(context, parseListOptions3(remaining.slice(1)),
|
|
986
|
+
await listRecipients(context, parseListOptions3(remaining.slice(1)), format);
|
|
1293
987
|
return;
|
|
1294
988
|
case "get": {
|
|
1295
989
|
const recipientId = remaining[1];
|
|
1296
990
|
if (!recipientId)
|
|
1297
991
|
throw new Error("Missing recipient ID. Usage: brex recipients get <counterparty-id>");
|
|
1298
|
-
await getRecipient(context, recipientId,
|
|
992
|
+
await getRecipient(context, recipientId, format);
|
|
1299
993
|
return;
|
|
1300
994
|
}
|
|
1301
995
|
case "add":
|
|
1302
|
-
await addRecipient(context, parseAddOptions(remaining.slice(1)),
|
|
996
|
+
await addRecipient(context, parseAddOptions(remaining.slice(1)), format);
|
|
1303
997
|
return;
|
|
1304
998
|
case "delete": {
|
|
1305
999
|
const recipientId = remaining[1];
|
|
@@ -1416,7 +1110,7 @@ function parseAddOptions(args) {
|
|
|
1416
1110
|
throw new Error("Missing required --routing");
|
|
1417
1111
|
return { name, accountNumber, routingNumber, accountType, country, currency };
|
|
1418
1112
|
}
|
|
1419
|
-
async function listRecipients(context, options,
|
|
1113
|
+
async function listRecipients(context, options, format) {
|
|
1420
1114
|
const params = new URLSearchParams;
|
|
1421
1115
|
if (options.limit)
|
|
1422
1116
|
params.set("limit", String(options.limit));
|
|
@@ -1428,7 +1122,7 @@ async function listRecipients(context, options, format2) {
|
|
|
1428
1122
|
const path = query ? `/v1/payment_counterparties?${query}` : "/v1/payment_counterparties";
|
|
1429
1123
|
const response = await context.client.fetch(path);
|
|
1430
1124
|
const recipients = response.items ?? response.payment_counterparties ?? [];
|
|
1431
|
-
if (
|
|
1125
|
+
if (format === "json") {
|
|
1432
1126
|
printJson({ items: recipients, nextCursor: response.next_cursor ?? null });
|
|
1433
1127
|
return;
|
|
1434
1128
|
}
|
|
@@ -1457,10 +1151,10 @@ async function listRecipients(context, options, format2) {
|
|
|
1457
1151
|
Next cursor: ${response.next_cursor}`);
|
|
1458
1152
|
}
|
|
1459
1153
|
}
|
|
1460
|
-
async function getRecipient(context, recipientId,
|
|
1154
|
+
async function getRecipient(context, recipientId, format) {
|
|
1461
1155
|
const response = await context.client.fetch(`/v1/payment_counterparties/${recipientId}`);
|
|
1462
1156
|
const recipient = response.payment_counterparty ?? response.item ?? response;
|
|
1463
|
-
if (
|
|
1157
|
+
if (format === "json") {
|
|
1464
1158
|
printJson(recipient);
|
|
1465
1159
|
return;
|
|
1466
1160
|
}
|
|
@@ -1480,7 +1174,7 @@ async function getRecipient(context, recipientId, format2) {
|
|
|
1480
1174
|
if (bank?.currency)
|
|
1481
1175
|
console.log(`Currency: ${bank.currency}`);
|
|
1482
1176
|
}
|
|
1483
|
-
async function addRecipient(context, options,
|
|
1177
|
+
async function addRecipient(context, options, format) {
|
|
1484
1178
|
const body = {
|
|
1485
1179
|
name: options.name,
|
|
1486
1180
|
payment_instrument: {
|
|
@@ -1495,10 +1189,11 @@ async function addRecipient(context, options, format2) {
|
|
|
1495
1189
|
};
|
|
1496
1190
|
const response = await context.client.fetch("/v1/payment_counterparties", {
|
|
1497
1191
|
method: "POST",
|
|
1192
|
+
headers: { "Idempotency-Key": crypto.randomUUID() },
|
|
1498
1193
|
body: JSON.stringify(body)
|
|
1499
1194
|
});
|
|
1500
1195
|
const recipient = response.payment_counterparty ?? response.item ?? response;
|
|
1501
|
-
if (
|
|
1196
|
+
if (format === "json") {
|
|
1502
1197
|
printJson(recipient);
|
|
1503
1198
|
return;
|
|
1504
1199
|
}
|
|
@@ -1524,22 +1219,22 @@ var cardsCommand = {
|
|
|
1524
1219
|
usage: USAGE8,
|
|
1525
1220
|
aliases: ["card"],
|
|
1526
1221
|
run: async (args, context) => {
|
|
1527
|
-
const { format
|
|
1222
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
1528
1223
|
const subcommand = remaining[0] ?? "list";
|
|
1529
1224
|
if (subcommand === "get") {
|
|
1530
1225
|
const cardId = remaining[1];
|
|
1531
1226
|
if (!cardId) {
|
|
1532
1227
|
throw new Error("Usage: brex cards get <card-id>");
|
|
1533
1228
|
}
|
|
1534
|
-
await getCard(context, cardId,
|
|
1229
|
+
await getCard(context, cardId, format);
|
|
1535
1230
|
return;
|
|
1536
1231
|
}
|
|
1537
1232
|
if (subcommand !== "list" && !subcommand.startsWith("-")) {
|
|
1538
|
-
await getCard(context, subcommand,
|
|
1233
|
+
await getCard(context, subcommand, format);
|
|
1539
1234
|
return;
|
|
1540
1235
|
}
|
|
1541
1236
|
const listArgs = subcommand === "list" ? remaining.slice(1) : remaining;
|
|
1542
|
-
await listCards(context, parseListOptions4(listArgs),
|
|
1237
|
+
await listCards(context, parseListOptions4(listArgs), format);
|
|
1543
1238
|
}
|
|
1544
1239
|
};
|
|
1545
1240
|
function parseListOptions4(args) {
|
|
@@ -1581,7 +1276,7 @@ function parseListOptions4(args) {
|
|
|
1581
1276
|
}
|
|
1582
1277
|
return { userId, cursor, limit };
|
|
1583
1278
|
}
|
|
1584
|
-
async function listCards(context, options,
|
|
1279
|
+
async function listCards(context, options, format) {
|
|
1585
1280
|
const params = new URLSearchParams;
|
|
1586
1281
|
if (options.userId)
|
|
1587
1282
|
params.set("user_id", options.userId);
|
|
@@ -1593,7 +1288,7 @@ async function listCards(context, options, format2) {
|
|
|
1593
1288
|
const path = query ? `/v2/cards?${query}` : "/v2/cards";
|
|
1594
1289
|
const response = await context.client.fetch(path);
|
|
1595
1290
|
const cards = response.items ?? response.cards ?? [];
|
|
1596
|
-
if (
|
|
1291
|
+
if (format === "json") {
|
|
1597
1292
|
printJson({ items: cards, nextCursor: response.next_cursor ?? null });
|
|
1598
1293
|
return;
|
|
1599
1294
|
}
|
|
@@ -1603,11 +1298,11 @@ async function listCards(context, options, format2) {
|
|
|
1603
1298
|
}
|
|
1604
1299
|
printTable(cards.map((card) => ({
|
|
1605
1300
|
id: card.id,
|
|
1606
|
-
name: card.card_name ?? "-",
|
|
1301
|
+
name: card.card_name ?? card.card_type ?? "-",
|
|
1607
1302
|
last4: card.last_four ?? card.last_4 ?? "-",
|
|
1608
1303
|
status: card.status ?? "-",
|
|
1609
|
-
expires: formatExpiration(card.expiration_month, card.expiration_year),
|
|
1610
|
-
userId: card.cardholder?.user_id ?? "-"
|
|
1304
|
+
expires: formatExpiration(card.expiration_month ?? card.expiration_date?.month, card.expiration_year ?? card.expiration_date?.year),
|
|
1305
|
+
userId: card.owner?.user_id ?? card.cardholder?.user_id ?? "-"
|
|
1611
1306
|
})), [
|
|
1612
1307
|
{ key: "id", header: "Card ID", width: 36 },
|
|
1613
1308
|
{ key: "name", header: "Name", width: 22 },
|
|
@@ -1621,21 +1316,21 @@ async function listCards(context, options, format2) {
|
|
|
1621
1316
|
Next cursor: ${response.next_cursor}`);
|
|
1622
1317
|
}
|
|
1623
1318
|
}
|
|
1624
|
-
async function getCard(context, cardId,
|
|
1319
|
+
async function getCard(context, cardId, format) {
|
|
1625
1320
|
const response = await context.client.fetch(`/v2/cards/${cardId}`);
|
|
1626
1321
|
const card = response.card ?? response.item ?? response;
|
|
1627
|
-
if (
|
|
1322
|
+
if (format === "json") {
|
|
1628
1323
|
printJson(card);
|
|
1629
1324
|
return;
|
|
1630
1325
|
}
|
|
1631
1326
|
console.log("Card Details");
|
|
1632
1327
|
console.log("────────────");
|
|
1633
1328
|
console.log(`ID: ${card.id}`);
|
|
1634
|
-
console.log(`Name: ${card.card_name ?? "-"}`);
|
|
1329
|
+
console.log(`Name: ${card.card_name ?? card.card_type ?? "-"}`);
|
|
1635
1330
|
console.log(`Status: ${card.status ?? "-"}`);
|
|
1636
1331
|
console.log(`Last 4: ${card.last_four ?? card.last_4 ?? "-"}`);
|
|
1637
|
-
console.log(`Expires: ${formatExpiration(card.expiration_month, card.expiration_year)}`);
|
|
1638
|
-
console.log(`User ID: ${card.cardholder?.user_id ?? "-"}`);
|
|
1332
|
+
console.log(`Expires: ${formatExpiration(card.expiration_month ?? card.expiration_date?.month, card.expiration_year ?? card.expiration_date?.year)}`);
|
|
1333
|
+
console.log(`User ID: ${card.owner?.user_id ?? card.cardholder?.user_id ?? "-"}`);
|
|
1639
1334
|
}
|
|
1640
1335
|
function formatExpiration(month, year) {
|
|
1641
1336
|
if (!month || !year)
|
|
@@ -1655,7 +1350,7 @@ var statementsCommand = {
|
|
|
1655
1350
|
usage: USAGE9,
|
|
1656
1351
|
aliases: ["statement"],
|
|
1657
1352
|
run: async (args, context) => {
|
|
1658
|
-
const { format
|
|
1353
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
1659
1354
|
const firstArg = remaining[0] ?? "list";
|
|
1660
1355
|
if (firstArg === "get") {
|
|
1661
1356
|
const statementId = remaining[1];
|
|
@@ -1663,11 +1358,11 @@ var statementsCommand = {
|
|
|
1663
1358
|
throw new Error("Usage: brex statements get <statement-id> [--scope primary|additional] [--account-id <id>]");
|
|
1664
1359
|
}
|
|
1665
1360
|
const options2 = parseSharedOptions(remaining.slice(2));
|
|
1666
|
-
await getStatement(context, statementId, options2,
|
|
1361
|
+
await getStatement(context, statementId, options2, format);
|
|
1667
1362
|
return;
|
|
1668
1363
|
}
|
|
1669
1364
|
const options = parseListOptions5(remaining.slice(firstArg === "list" ? 1 : 0));
|
|
1670
|
-
await listStatements(context, options,
|
|
1365
|
+
await listStatements(context, options, format);
|
|
1671
1366
|
}
|
|
1672
1367
|
};
|
|
1673
1368
|
function parseListOptions5(args) {
|
|
@@ -1724,11 +1419,11 @@ function parseSharedOptions(args) {
|
|
|
1724
1419
|
}
|
|
1725
1420
|
return { scope, accountId };
|
|
1726
1421
|
}
|
|
1727
|
-
async function listStatements(context, options,
|
|
1422
|
+
async function listStatements(context, options, format) {
|
|
1728
1423
|
const path = options.scope === "primary" ? withCursor2("/v2/accounts/card/primary/statements", options.cursor) : withCursor2(`/v2/accounts/card/additional/${options.accountId}/statements`, options.cursor);
|
|
1729
1424
|
const response = await context.client.fetch(path);
|
|
1730
1425
|
const statements = response.items ?? response.statements ?? [];
|
|
1731
|
-
if (
|
|
1426
|
+
if (format === "json") {
|
|
1732
1427
|
printJson({ items: statements, nextCursor: response.next_cursor ?? null });
|
|
1733
1428
|
return;
|
|
1734
1429
|
}
|
|
@@ -1738,43 +1433,53 @@ async function listStatements(context, options, format2) {
|
|
|
1738
1433
|
}
|
|
1739
1434
|
printTable(statements.map((statement) => ({
|
|
1740
1435
|
id: statement.id,
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
downloadUrl: statement.download_url ?? "-"
|
|
1436
|
+
start: formatDate(statement.period_start_date ?? statement.period?.start_date),
|
|
1437
|
+
end: formatDate(statement.period_end_date ?? statement.period?.end_date),
|
|
1438
|
+
startBal: statement.start_balance ? formatAmount(centsToDecimal2(statement.start_balance.amount), statement.start_balance.currency) : "-",
|
|
1439
|
+
endBal: statement.end_balance ? formatAmount(centsToDecimal2(statement.end_balance.amount), statement.end_balance.currency) : "-"
|
|
1746
1440
|
})), [
|
|
1747
1441
|
{ key: "id", header: "Statement ID", width: 36 },
|
|
1748
|
-
{ key: "status", header: "Status", width: 12 },
|
|
1749
1442
|
{ key: "start", header: "Start", width: 12 },
|
|
1750
1443
|
{ key: "end", header: "End", width: 12 },
|
|
1751
|
-
{ key: "
|
|
1752
|
-
{ key: "
|
|
1444
|
+
{ key: "startBal", header: "Start Bal", width: 14 },
|
|
1445
|
+
{ key: "endBal", header: "End Bal", width: 14 }
|
|
1753
1446
|
]);
|
|
1754
1447
|
if (response.next_cursor) {
|
|
1755
1448
|
console.log(`
|
|
1756
1449
|
Next cursor: ${response.next_cursor}`);
|
|
1757
1450
|
}
|
|
1758
1451
|
}
|
|
1759
|
-
async function getStatement(context, statementId, options,
|
|
1452
|
+
async function getStatement(context, statementId, options, format) {
|
|
1760
1453
|
const path = options.scope === "primary" ? `/v2/accounts/card/primary/statements/${statementId}` : `/v2/accounts/card/additional/${options.accountId}/statements/${statementId}`;
|
|
1761
1454
|
const response = await context.client.fetch(path);
|
|
1762
1455
|
const statement = response.account_statement ?? response.statement ?? response.item;
|
|
1763
1456
|
if (!statement) {
|
|
1764
1457
|
throw new Error("Brex API returned an empty statement payload.");
|
|
1765
1458
|
}
|
|
1766
|
-
if (
|
|
1459
|
+
if (format === "json") {
|
|
1767
1460
|
printJson(statement);
|
|
1768
1461
|
return;
|
|
1769
1462
|
}
|
|
1770
1463
|
console.log("Statement Details");
|
|
1771
1464
|
console.log("─────────────────");
|
|
1772
1465
|
console.log(`ID: ${statement.id}`);
|
|
1773
|
-
console.log(`
|
|
1774
|
-
console.log(`Period
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1466
|
+
console.log(`Period Start:${" "}${formatDate(statement.period_start_date ?? statement.period?.start_date)}`);
|
|
1467
|
+
console.log(`Period End: ${formatDate(statement.period_end_date ?? statement.period?.end_date)}`);
|
|
1468
|
+
if (statement.start_balance) {
|
|
1469
|
+
console.log(`Start Bal: ${formatAmount(centsToDecimal2(statement.start_balance.amount), statement.start_balance.currency)}`);
|
|
1470
|
+
}
|
|
1471
|
+
if (statement.end_balance) {
|
|
1472
|
+
console.log(`End Bal: ${formatAmount(centsToDecimal2(statement.end_balance.amount), statement.end_balance.currency)}`);
|
|
1473
|
+
}
|
|
1474
|
+
if (statement.due_date)
|
|
1475
|
+
console.log(`Due Date: ${formatDate(statement.due_date)}`);
|
|
1476
|
+
if (statement.download_url)
|
|
1477
|
+
console.log(`Download: ${statement.download_url}`);
|
|
1478
|
+
}
|
|
1479
|
+
function centsToDecimal2(amount) {
|
|
1480
|
+
if (amount === undefined)
|
|
1481
|
+
return;
|
|
1482
|
+
return amount / 100;
|
|
1778
1483
|
}
|
|
1779
1484
|
function withCursor2(path, cursor) {
|
|
1780
1485
|
if (!cursor)
|
|
@@ -1786,8 +1491,8 @@ function withCursor2(path, cursor) {
|
|
|
1786
1491
|
var USAGE10 = `brex webhooks
|
|
1787
1492
|
brex webhooks list [--cursor <cursor>] [--limit <N>]
|
|
1788
1493
|
brex webhooks get <webhook-id>
|
|
1789
|
-
brex webhooks create --url <url> [--
|
|
1790
|
-
brex webhooks update <webhook-id> [--url <url>] [--
|
|
1494
|
+
brex webhooks create --url <url> [--events <event1,event2>]
|
|
1495
|
+
brex webhooks update <webhook-id> [--url <url>] [--events <event1,event2>]
|
|
1791
1496
|
brex webhooks delete <webhook-id>
|
|
1792
1497
|
brex webhooks --json`;
|
|
1793
1498
|
var webhooksCommand = {
|
|
@@ -1796,27 +1501,27 @@ var webhooksCommand = {
|
|
|
1796
1501
|
usage: USAGE10,
|
|
1797
1502
|
aliases: ["webhook", "wh"],
|
|
1798
1503
|
run: async (args, context) => {
|
|
1799
|
-
const { format
|
|
1504
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
1800
1505
|
const subcommand = remaining[0] ?? "list";
|
|
1801
1506
|
switch (subcommand) {
|
|
1802
1507
|
case "list":
|
|
1803
|
-
await listWebhooks(context, parseListOptions6(remaining.slice(1)),
|
|
1508
|
+
await listWebhooks(context, parseListOptions6(remaining.slice(1)), format);
|
|
1804
1509
|
return;
|
|
1805
1510
|
case "get": {
|
|
1806
1511
|
const webhookId = remaining[1];
|
|
1807
1512
|
if (!webhookId)
|
|
1808
1513
|
throw new Error("Missing webhook ID. Usage: brex webhooks get <webhook-id>");
|
|
1809
|
-
await getWebhook(context, webhookId,
|
|
1514
|
+
await getWebhook(context, webhookId, format);
|
|
1810
1515
|
return;
|
|
1811
1516
|
}
|
|
1812
1517
|
case "create":
|
|
1813
|
-
await createWebhook(context, parseCreateOptions(remaining.slice(1)),
|
|
1518
|
+
await createWebhook(context, parseCreateOptions(remaining.slice(1)), format);
|
|
1814
1519
|
return;
|
|
1815
1520
|
case "update": {
|
|
1816
1521
|
const webhookId = remaining[1];
|
|
1817
1522
|
if (!webhookId)
|
|
1818
1523
|
throw new Error("Missing webhook ID. Usage: brex webhooks update <webhook-id> ...");
|
|
1819
|
-
await updateWebhook(context, webhookId, parseUpdateOptions(remaining.slice(2)),
|
|
1524
|
+
await updateWebhook(context, webhookId, parseUpdateOptions(remaining.slice(2)), format);
|
|
1820
1525
|
return;
|
|
1821
1526
|
}
|
|
1822
1527
|
case "delete": {
|
|
@@ -1933,7 +1638,7 @@ function parseUpdateOptions(args) {
|
|
|
1933
1638
|
}
|
|
1934
1639
|
return options;
|
|
1935
1640
|
}
|
|
1936
|
-
async function listWebhooks(context, options,
|
|
1641
|
+
async function listWebhooks(context, options, format) {
|
|
1937
1642
|
const params = new URLSearchParams;
|
|
1938
1643
|
if (options.cursor)
|
|
1939
1644
|
params.set("cursor", options.cursor);
|
|
@@ -1943,7 +1648,7 @@ async function listWebhooks(context, options, format2) {
|
|
|
1943
1648
|
const path = query ? `/v1/webhooks?${query}` : "/v1/webhooks";
|
|
1944
1649
|
const response = await context.client.fetch(path);
|
|
1945
1650
|
const webhooks = response.items ?? response.webhooks ?? [];
|
|
1946
|
-
if (
|
|
1651
|
+
if (format === "json") {
|
|
1947
1652
|
printJson({ items: webhooks, nextCursor: response.next_cursor ?? null });
|
|
1948
1653
|
return;
|
|
1949
1654
|
}
|
|
@@ -1955,7 +1660,7 @@ async function listWebhooks(context, options, format2) {
|
|
|
1955
1660
|
id: webhook.id,
|
|
1956
1661
|
url: truncate(webhook.url ?? "-", 40),
|
|
1957
1662
|
status: webhook.status ?? "-",
|
|
1958
|
-
events: truncate((webhook.
|
|
1663
|
+
events: truncate((webhook.event_types ?? []).join(", ") || "-", 35)
|
|
1959
1664
|
})), [
|
|
1960
1665
|
{ key: "id", header: "ID", width: 36 },
|
|
1961
1666
|
{ key: "url", header: "URL", width: 40 },
|
|
@@ -1967,14 +1672,14 @@ async function listWebhooks(context, options, format2) {
|
|
|
1967
1672
|
Next cursor: ${response.next_cursor}`);
|
|
1968
1673
|
}
|
|
1969
1674
|
}
|
|
1970
|
-
async function getWebhook(context, webhookId,
|
|
1675
|
+
async function getWebhook(context, webhookId, format) {
|
|
1971
1676
|
const response = await context.client.fetch(`/v1/webhooks/${webhookId}`);
|
|
1972
1677
|
const webhook = response.webhook ?? response.item ?? response;
|
|
1973
|
-
if (
|
|
1678
|
+
if (format === "json") {
|
|
1974
1679
|
printJson(webhook);
|
|
1975
1680
|
return;
|
|
1976
1681
|
}
|
|
1977
|
-
const events =
|
|
1682
|
+
const events = webhook.event_types ?? [];
|
|
1978
1683
|
console.log("Webhook Details");
|
|
1979
1684
|
console.log("───────────────");
|
|
1980
1685
|
console.log(`ID: ${webhook.id}`);
|
|
@@ -1982,24 +1687,20 @@ async function getWebhook(context, webhookId, format2) {
|
|
|
1982
1687
|
console.log(`Status: ${webhook.status ?? "-"}`);
|
|
1983
1688
|
console.log(`Events: ${events.length > 0 ? events.join(", ") : "-"}`);
|
|
1984
1689
|
}
|
|
1985
|
-
async function createWebhook(context, options,
|
|
1690
|
+
async function createWebhook(context, options, format) {
|
|
1986
1691
|
const body = {
|
|
1987
1692
|
url: options.url
|
|
1988
1693
|
};
|
|
1989
|
-
if (options.status)
|
|
1990
|
-
body.status = options.status;
|
|
1991
1694
|
if (options.events && options.events.length > 0) {
|
|
1992
|
-
body.
|
|
1993
|
-
event_type: eventType,
|
|
1994
|
-
status: "ACTIVE"
|
|
1995
|
-
}));
|
|
1695
|
+
body.event_types = options.events;
|
|
1996
1696
|
}
|
|
1997
1697
|
const response = await context.client.fetch("/v1/webhooks", {
|
|
1998
1698
|
method: "POST",
|
|
1699
|
+
headers: { "Idempotency-Key": crypto.randomUUID() },
|
|
1999
1700
|
body: JSON.stringify(body)
|
|
2000
1701
|
});
|
|
2001
1702
|
const webhook = response.webhook ?? response.item ?? response;
|
|
2002
|
-
if (
|
|
1703
|
+
if (format === "json") {
|
|
2003
1704
|
printJson(webhook);
|
|
2004
1705
|
return;
|
|
2005
1706
|
}
|
|
@@ -2009,24 +1710,22 @@ async function createWebhook(context, options, format2) {
|
|
|
2009
1710
|
console.log(`URL: ${webhook.url ?? "-"}`);
|
|
2010
1711
|
console.log(`Status: ${webhook.status ?? "-"}`);
|
|
2011
1712
|
}
|
|
2012
|
-
async function updateWebhook(context, webhookId, options,
|
|
2013
|
-
const
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
body.status = options.status;
|
|
2018
|
-
if (options.events && options.events.length > 0) {
|
|
2019
|
-
body.subscriptions = options.events.map((eventType) => ({
|
|
2020
|
-
event_type: eventType,
|
|
2021
|
-
status: "ACTIVE"
|
|
2022
|
-
}));
|
|
1713
|
+
async function updateWebhook(context, webhookId, options, format) {
|
|
1714
|
+
const existing = await context.client.fetch(`/v1/webhooks/${webhookId}`);
|
|
1715
|
+
const current = existing.webhook ?? existing.item ?? existing;
|
|
1716
|
+
if (!current.url && !current.id) {
|
|
1717
|
+
throw new Error(`Could not retrieve existing webhook ${webhookId} — unexpected API response`);
|
|
2023
1718
|
}
|
|
1719
|
+
const body = {
|
|
1720
|
+
url: options.url ?? current.url,
|
|
1721
|
+
event_types: options.events && options.events.length > 0 ? options.events : current.event_types ?? []
|
|
1722
|
+
};
|
|
2024
1723
|
const response = await context.client.fetch(`/v1/webhooks/${webhookId}`, {
|
|
2025
1724
|
method: "PUT",
|
|
2026
1725
|
body: JSON.stringify(body)
|
|
2027
1726
|
});
|
|
2028
1727
|
const webhook = response.webhook ?? response.item ?? response;
|
|
2029
|
-
if (
|
|
1728
|
+
if (format === "json") {
|
|
2030
1729
|
printJson(webhook);
|
|
2031
1730
|
return;
|
|
2032
1731
|
}
|
|
@@ -2052,21 +1751,21 @@ var eventsCommand = {
|
|
|
2052
1751
|
usage: USAGE11,
|
|
2053
1752
|
aliases: ["event"],
|
|
2054
1753
|
run: async (args, context) => {
|
|
2055
|
-
const { format
|
|
1754
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
2056
1755
|
const subcommand = remaining[0] ?? "list";
|
|
2057
1756
|
if (subcommand === "list") {
|
|
2058
|
-
await listEvents(context, parseListOptions7(remaining.slice(1)),
|
|
1757
|
+
await listEvents(context, parseListOptions7(remaining.slice(1)), format);
|
|
2059
1758
|
return;
|
|
2060
1759
|
}
|
|
2061
1760
|
if (subcommand === "get") {
|
|
2062
1761
|
const eventId = remaining[1];
|
|
2063
1762
|
if (!eventId)
|
|
2064
1763
|
throw new Error("Missing event ID. Usage: brex events get <event-id>");
|
|
2065
|
-
await getEvent(context, eventId,
|
|
1764
|
+
await getEvent(context, eventId, format);
|
|
2066
1765
|
return;
|
|
2067
1766
|
}
|
|
2068
1767
|
if (!subcommand.startsWith("-")) {
|
|
2069
|
-
await getEvent(context, subcommand,
|
|
1768
|
+
await getEvent(context, subcommand, format);
|
|
2070
1769
|
return;
|
|
2071
1770
|
}
|
|
2072
1771
|
throw new Error(`Unknown subcommand: ${subcommand}`);
|
|
@@ -2123,7 +1822,7 @@ function parseListOptions7(args) {
|
|
|
2123
1822
|
}
|
|
2124
1823
|
return options;
|
|
2125
1824
|
}
|
|
2126
|
-
async function listEvents(context, options,
|
|
1825
|
+
async function listEvents(context, options, format) {
|
|
2127
1826
|
const params = new URLSearchParams;
|
|
2128
1827
|
if (options.eventType)
|
|
2129
1828
|
params.set("event_type", options.eventType);
|
|
@@ -2139,7 +1838,7 @@ async function listEvents(context, options, format2) {
|
|
|
2139
1838
|
const path = query ? `/v1/events?${query}` : "/v1/events";
|
|
2140
1839
|
const response = await context.client.fetch(path);
|
|
2141
1840
|
const events = response.items ?? response.events ?? [];
|
|
2142
|
-
if (
|
|
1841
|
+
if (format === "json") {
|
|
2143
1842
|
printJson({ items: events, nextCursor: response.next_cursor ?? null });
|
|
2144
1843
|
return;
|
|
2145
1844
|
}
|
|
@@ -2163,10 +1862,10 @@ async function listEvents(context, options, format2) {
|
|
|
2163
1862
|
Next cursor: ${response.next_cursor}`);
|
|
2164
1863
|
}
|
|
2165
1864
|
}
|
|
2166
|
-
async function getEvent(context, eventId,
|
|
1865
|
+
async function getEvent(context, eventId, format) {
|
|
2167
1866
|
const response = await context.client.fetch(`/v1/events/${eventId}`);
|
|
2168
1867
|
const event = response.event ?? response.item ?? response;
|
|
2169
|
-
if (
|
|
1868
|
+
if (format === "json") {
|
|
2170
1869
|
printJson(event);
|
|
2171
1870
|
return;
|
|
2172
1871
|
}
|
|
@@ -2190,10 +1889,10 @@ var organizationCommand = {
|
|
|
2190
1889
|
usage: USAGE12,
|
|
2191
1890
|
aliases: ["org"],
|
|
2192
1891
|
run: async (args, context) => {
|
|
2193
|
-
const { format
|
|
1892
|
+
const { format } = parseOutputFlag(args);
|
|
2194
1893
|
const response = await context.client.fetch("/v2/company");
|
|
2195
1894
|
const company = response.company ?? response.item ?? response;
|
|
2196
|
-
if (
|
|
1895
|
+
if (format === "json") {
|
|
2197
1896
|
printJson(company);
|
|
2198
1897
|
return;
|
|
2199
1898
|
}
|
|
@@ -2234,22 +1933,22 @@ var usersCommand = {
|
|
|
2234
1933
|
usage: USAGE13,
|
|
2235
1934
|
aliases: ["user"],
|
|
2236
1935
|
run: async (args, context) => {
|
|
2237
|
-
const { format
|
|
1936
|
+
const { format, args: remaining } = parseOutputFlag(args);
|
|
2238
1937
|
const subcommand = remaining[0] ?? "list";
|
|
2239
1938
|
switch (subcommand) {
|
|
2240
1939
|
case "list":
|
|
2241
|
-
await listUsers(context, parseListOptions8(remaining.slice(1)),
|
|
1940
|
+
await listUsers(context, parseListOptions8(remaining.slice(1)), format);
|
|
2242
1941
|
return;
|
|
2243
1942
|
case "get": {
|
|
2244
1943
|
const userId = remaining[1];
|
|
2245
1944
|
if (!userId)
|
|
2246
1945
|
throw new Error("Missing user ID. Usage: brex users get <user-id>");
|
|
2247
|
-
await getUser(context, userId,
|
|
1946
|
+
await getUser(context, userId, format);
|
|
2248
1947
|
return;
|
|
2249
1948
|
}
|
|
2250
1949
|
default:
|
|
2251
1950
|
if (!subcommand.startsWith("-")) {
|
|
2252
|
-
await getUser(context, subcommand,
|
|
1951
|
+
await getUser(context, subcommand, format);
|
|
2253
1952
|
return;
|
|
2254
1953
|
}
|
|
2255
1954
|
throw new Error(`Unknown subcommand: ${subcommand}`);
|
|
@@ -2283,7 +1982,7 @@ function parseListOptions8(args) {
|
|
|
2283
1982
|
}
|
|
2284
1983
|
return { cursor, email };
|
|
2285
1984
|
}
|
|
2286
|
-
async function listUsers(context, options,
|
|
1985
|
+
async function listUsers(context, options, format) {
|
|
2287
1986
|
const params = new URLSearchParams;
|
|
2288
1987
|
if (options.cursor)
|
|
2289
1988
|
params.set("cursor", options.cursor);
|
|
@@ -2293,7 +1992,7 @@ async function listUsers(context, options, format2) {
|
|
|
2293
1992
|
const path = query ? `/v2/users?${query}` : "/v2/users";
|
|
2294
1993
|
const response = await context.client.fetch(path);
|
|
2295
1994
|
const users = response.items ?? response.users ?? [];
|
|
2296
|
-
if (
|
|
1995
|
+
if (format === "json") {
|
|
2297
1996
|
printJson({ items: users, nextCursor: response.next_cursor ?? null });
|
|
2298
1997
|
return;
|
|
2299
1998
|
}
|
|
@@ -2321,10 +2020,10 @@ async function listUsers(context, options, format2) {
|
|
|
2321
2020
|
Next cursor: ${response.next_cursor}`);
|
|
2322
2021
|
}
|
|
2323
2022
|
}
|
|
2324
|
-
async function getUser(context, userId,
|
|
2023
|
+
async function getUser(context, userId, format) {
|
|
2325
2024
|
const response = await context.client.fetch(`/v2/users/${userId}`);
|
|
2326
2025
|
const user = response.user ?? response.item ?? response;
|
|
2327
|
-
if (
|
|
2026
|
+
if (format === "json") {
|
|
2328
2027
|
printJson(user);
|
|
2329
2028
|
return;
|
|
2330
2029
|
}
|
|
@@ -2353,14 +2052,33 @@ var categoriesCommand = {
|
|
|
2353
2052
|
};
|
|
2354
2053
|
|
|
2355
2054
|
// sources/commands/version/index.ts
|
|
2356
|
-
|
|
2055
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2056
|
+
import { join as join2, dirname } from "node:path";
|
|
2057
|
+
import { fileURLToPath } from "node:url";
|
|
2058
|
+
function getVersion() {
|
|
2059
|
+
try {
|
|
2060
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
2061
|
+
for (let i = 0;i < 5; i++) {
|
|
2062
|
+
const candidate = join2(dir, "package.json");
|
|
2063
|
+
try {
|
|
2064
|
+
const pkg = JSON.parse(readFileSync2(candidate, "utf-8"));
|
|
2065
|
+
if (pkg.name === "brex-cli" && pkg.version)
|
|
2066
|
+
return pkg.version;
|
|
2067
|
+
} catch {}
|
|
2068
|
+
dir = dirname(dir);
|
|
2069
|
+
}
|
|
2070
|
+
return process.env.npm_package_version ?? "unknown";
|
|
2071
|
+
} catch {
|
|
2072
|
+
return "unknown";
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2357
2075
|
var versionCommand = {
|
|
2358
2076
|
name: "version",
|
|
2359
2077
|
description: "Show brex-cli version.",
|
|
2360
2078
|
usage: "brex version",
|
|
2361
2079
|
aliases: ["v"],
|
|
2362
2080
|
run: async () => {
|
|
2363
|
-
console.log(`brex-cli v${
|
|
2081
|
+
console.log(`brex-cli v${getVersion()}`);
|
|
2364
2082
|
}
|
|
2365
2083
|
};
|
|
2366
2084
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brex-cli",
|
|
3
|
-
"version": "2026.2.
|
|
3
|
+
"version": "2026.2.2",
|
|
4
4
|
"description": "CLI for Brex Banking API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "mkdir -p dist && bun build ./sources/main.ts --outfile ./dist/main.js",
|
|
20
|
+
"build": "mkdir -p dist && bun build ./sources/main.ts --outfile ./dist/main.js --target node",
|
|
21
21
|
"build:binary": "bun build ./sources/main.ts --compile --outfile ./dist/brex",
|
|
22
22
|
"dev": "bun ./sources/main.ts",
|
|
23
23
|
"typecheck": "tsc --noEmit"
|
|
24
24
|
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"date-fns": "^4.1.0"
|
|
27
|
-
},
|
|
25
|
+
"dependencies": {},
|
|
28
26
|
"devDependencies": {
|
|
29
27
|
"bun-types": "^1.3.8",
|
|
30
28
|
"typescript": "^5.7.3"
|