@pmate/cli 0.16.2 → 0.16.3
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/index.d.ts +43 -1
- package/dist/index.js +579 -102
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ declare enum Command {
|
|
|
22
22
|
Collect = "collect",
|
|
23
23
|
Agent = "agent",
|
|
24
24
|
Ns = "ns",
|
|
25
|
+
Role = "role",
|
|
26
|
+
Account = "account",
|
|
25
27
|
Store = "store",
|
|
26
28
|
App = "app",
|
|
27
29
|
Vercel = "vercel"
|
|
@@ -239,6 +241,46 @@ type OssCommandArgs = {
|
|
|
239
241
|
filePath: string;
|
|
240
242
|
objectKey: string;
|
|
241
243
|
};
|
|
244
|
+
type RoleCommandArgs = {
|
|
245
|
+
type: Command.Role;
|
|
246
|
+
resource: "definition";
|
|
247
|
+
action: "list";
|
|
248
|
+
baseUrl?: string;
|
|
249
|
+
json: boolean;
|
|
250
|
+
} | {
|
|
251
|
+
type: Command.Role;
|
|
252
|
+
resource: "definition";
|
|
253
|
+
action: "create";
|
|
254
|
+
role: string;
|
|
255
|
+
displayName?: string;
|
|
256
|
+
description?: string;
|
|
257
|
+
baseUrl?: string;
|
|
258
|
+
json: boolean;
|
|
259
|
+
};
|
|
260
|
+
type AccountCommandArgs = {
|
|
261
|
+
type: Command.Account;
|
|
262
|
+
action: "view";
|
|
263
|
+
account?: string;
|
|
264
|
+
mobile?: string;
|
|
265
|
+
nickName?: string;
|
|
266
|
+
baseUrl?: string;
|
|
267
|
+
json: boolean;
|
|
268
|
+
} | {
|
|
269
|
+
type: Command.Account;
|
|
270
|
+
action: "role-list";
|
|
271
|
+
account: string;
|
|
272
|
+
namespace?: string;
|
|
273
|
+
baseUrl?: string;
|
|
274
|
+
json: boolean;
|
|
275
|
+
} | {
|
|
276
|
+
type: Command.Account;
|
|
277
|
+
action: "role-add" | "role-remove";
|
|
278
|
+
account: string;
|
|
279
|
+
namespace: string;
|
|
280
|
+
role: string;
|
|
281
|
+
baseUrl?: string;
|
|
282
|
+
json: boolean;
|
|
283
|
+
};
|
|
242
284
|
type QrcodeCommandArgs = {
|
|
243
285
|
type: Command.Qrcode;
|
|
244
286
|
};
|
|
@@ -421,7 +463,7 @@ type VercelDeploysCommandArgs = {
|
|
|
421
463
|
lastWeek: boolean;
|
|
422
464
|
};
|
|
423
465
|
type VercelCommandArgs = VercelProjectsCommandArgs | VercelDeploysCommandArgs;
|
|
424
|
-
type CommandArgs = NoneCommandArgs | ListCommandArgs | LoginCommandArgs | AddDnsCommandArgs | StsCommandArgs | BucketCommandArgs | DeployCommandArgs | LogCommandArgs | InitCommandArgs | DevCommandArgs | EnvCommandArgs | PrCommandArgs | CommitCommandArgs | SummaryCommandArgs | LinearCommandArgs | NotionCommandArgs | OssCommandArgs | QrcodeCommandArgs | RandomCommandArgs | CollectCommandArgs | AgentCommandArgs | NsCommandArgs | StoreCommandArgs | AppCommandArgs | VercelCommandArgs;
|
|
466
|
+
type CommandArgs = NoneCommandArgs | ListCommandArgs | LoginCommandArgs | AddDnsCommandArgs | StsCommandArgs | BucketCommandArgs | DeployCommandArgs | LogCommandArgs | InitCommandArgs | DevCommandArgs | EnvCommandArgs | PrCommandArgs | CommitCommandArgs | SummaryCommandArgs | LinearCommandArgs | NotionCommandArgs | OssCommandArgs | QrcodeCommandArgs | RandomCommandArgs | CollectCommandArgs | AgentCommandArgs | NsCommandArgs | RoleCommandArgs | AccountCommandArgs | StoreCommandArgs | AppCommandArgs | VercelCommandArgs;
|
|
425
467
|
|
|
426
468
|
interface ParsedArgs {
|
|
427
469
|
help: boolean;
|
package/dist/index.js
CHANGED
|
@@ -19811,6 +19811,236 @@ var VercelCommandHandler = class {
|
|
|
19811
19811
|
}
|
|
19812
19812
|
};
|
|
19813
19813
|
|
|
19814
|
+
// src/commands/RoleCommandHandler.ts
|
|
19815
|
+
init_sessionStore();
|
|
19816
|
+
var RoleCommandHandler = class {
|
|
19817
|
+
async handle(args) {
|
|
19818
|
+
const token = this.readToken();
|
|
19819
|
+
const baseUrl = this.resolveBaseUrl(args.baseUrl);
|
|
19820
|
+
switch (args.action) {
|
|
19821
|
+
case "list": {
|
|
19822
|
+
const items = await this.request(
|
|
19823
|
+
baseUrl,
|
|
19824
|
+
token,
|
|
19825
|
+
"GET",
|
|
19826
|
+
"/role/definitions"
|
|
19827
|
+
);
|
|
19828
|
+
this.renderList(items, args.json);
|
|
19829
|
+
return;
|
|
19830
|
+
}
|
|
19831
|
+
case "create": {
|
|
19832
|
+
const item = await this.request(
|
|
19833
|
+
baseUrl,
|
|
19834
|
+
token,
|
|
19835
|
+
"POST",
|
|
19836
|
+
"/role/definitions",
|
|
19837
|
+
{
|
|
19838
|
+
role: args.role,
|
|
19839
|
+
displayName: args.displayName ?? args.role,
|
|
19840
|
+
description: args.description ?? ""
|
|
19841
|
+
}
|
|
19842
|
+
);
|
|
19843
|
+
ui.success(`Created role definition ${item.role}`);
|
|
19844
|
+
this.renderJson(item, args.json);
|
|
19845
|
+
return;
|
|
19846
|
+
}
|
|
19847
|
+
}
|
|
19848
|
+
}
|
|
19849
|
+
resolveBaseUrl(baseUrl) {
|
|
19850
|
+
return (baseUrl || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || "https://auth-api-v2.pmate.chat").replace(/\/+$/, "");
|
|
19851
|
+
}
|
|
19852
|
+
readToken() {
|
|
19853
|
+
return readRequiredSession({
|
|
19854
|
+
preferredApp: DEFAULT_APP_ID,
|
|
19855
|
+
fallbackToActiveApp: true
|
|
19856
|
+
}).token;
|
|
19857
|
+
}
|
|
19858
|
+
async request(baseUrl, token, method, pathname, body) {
|
|
19859
|
+
const response = await fetch(`${baseUrl}${pathname}`, {
|
|
19860
|
+
method,
|
|
19861
|
+
headers: {
|
|
19862
|
+
Authorization: `Bearer ${token}`,
|
|
19863
|
+
"Content-Type": "application/json"
|
|
19864
|
+
},
|
|
19865
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
19866
|
+
});
|
|
19867
|
+
let payload = null;
|
|
19868
|
+
try {
|
|
19869
|
+
payload = await response.json();
|
|
19870
|
+
} catch {
|
|
19871
|
+
payload = null;
|
|
19872
|
+
}
|
|
19873
|
+
if (!response.ok || !payload?.success) {
|
|
19874
|
+
throw new Error(payload?.message || `Request failed with status ${response.status}`);
|
|
19875
|
+
}
|
|
19876
|
+
return payload.data;
|
|
19877
|
+
}
|
|
19878
|
+
renderList(items, asJson) {
|
|
19879
|
+
if (asJson) {
|
|
19880
|
+
ui.plain(JSON.stringify(items, null, 2));
|
|
19881
|
+
return;
|
|
19882
|
+
}
|
|
19883
|
+
if (items.length === 0) {
|
|
19884
|
+
ui.warn("No role definitions found.");
|
|
19885
|
+
return;
|
|
19886
|
+
}
|
|
19887
|
+
for (const item of items) {
|
|
19888
|
+
ui.info(item.role, {
|
|
19889
|
+
builtin: item.builtin,
|
|
19890
|
+
status: item.status
|
|
19891
|
+
});
|
|
19892
|
+
}
|
|
19893
|
+
}
|
|
19894
|
+
renderJson(value, asJson) {
|
|
19895
|
+
if (!asJson) {
|
|
19896
|
+
return;
|
|
19897
|
+
}
|
|
19898
|
+
ui.plain(JSON.stringify(value, null, 2));
|
|
19899
|
+
}
|
|
19900
|
+
};
|
|
19901
|
+
|
|
19902
|
+
// src/commands/AccountCommandHandler.ts
|
|
19903
|
+
init_sessionStore();
|
|
19904
|
+
var AccountCommandHandler = class {
|
|
19905
|
+
async handle(args) {
|
|
19906
|
+
const token = this.readToken();
|
|
19907
|
+
const baseUrl = this.resolveBaseUrl(args.baseUrl);
|
|
19908
|
+
switch (args.action) {
|
|
19909
|
+
case "view": {
|
|
19910
|
+
const result = await this.request(
|
|
19911
|
+
baseUrl,
|
|
19912
|
+
token,
|
|
19913
|
+
"GET",
|
|
19914
|
+
`/accounts/view?${this.buildAccountViewQuery(args)}`
|
|
19915
|
+
);
|
|
19916
|
+
this.renderAccountView(result.items, args.json);
|
|
19917
|
+
return;
|
|
19918
|
+
}
|
|
19919
|
+
case "role-list": {
|
|
19920
|
+
const items = await this.request(
|
|
19921
|
+
baseUrl,
|
|
19922
|
+
token,
|
|
19923
|
+
"GET",
|
|
19924
|
+
`/role/bindings?${this.buildRoleBindingsQuery(args)}`
|
|
19925
|
+
);
|
|
19926
|
+
this.renderRoleBindings(items, args.json);
|
|
19927
|
+
return;
|
|
19928
|
+
}
|
|
19929
|
+
case "role-add": {
|
|
19930
|
+
const item = await this.request(
|
|
19931
|
+
baseUrl,
|
|
19932
|
+
token,
|
|
19933
|
+
"POST",
|
|
19934
|
+
"/role/bindings",
|
|
19935
|
+
{
|
|
19936
|
+
account: args.account,
|
|
19937
|
+
namespace: args.namespace,
|
|
19938
|
+
role: args.role
|
|
19939
|
+
}
|
|
19940
|
+
);
|
|
19941
|
+
ui.success(`Added ${item.role} for ${item.account} in ${item.namespace}`);
|
|
19942
|
+
this.renderJson(item, args.json);
|
|
19943
|
+
return;
|
|
19944
|
+
}
|
|
19945
|
+
case "role-remove": {
|
|
19946
|
+
await this.request(
|
|
19947
|
+
baseUrl,
|
|
19948
|
+
token,
|
|
19949
|
+
"DELETE",
|
|
19950
|
+
"/role/bindings",
|
|
19951
|
+
{
|
|
19952
|
+
account: args.account,
|
|
19953
|
+
namespace: args.namespace,
|
|
19954
|
+
role: args.role
|
|
19955
|
+
}
|
|
19956
|
+
);
|
|
19957
|
+
ui.success(`Removed ${args.role} for ${args.account} in ${args.namespace}`);
|
|
19958
|
+
return;
|
|
19959
|
+
}
|
|
19960
|
+
}
|
|
19961
|
+
}
|
|
19962
|
+
resolveBaseUrl(baseUrl) {
|
|
19963
|
+
return (baseUrl || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || "https://auth-api-v2.pmate.chat").replace(/\/+$/, "");
|
|
19964
|
+
}
|
|
19965
|
+
readToken() {
|
|
19966
|
+
return readRequiredSession({
|
|
19967
|
+
preferredApp: DEFAULT_APP_ID,
|
|
19968
|
+
fallbackToActiveApp: true
|
|
19969
|
+
}).token;
|
|
19970
|
+
}
|
|
19971
|
+
buildAccountViewQuery(args) {
|
|
19972
|
+
const params = new URLSearchParams();
|
|
19973
|
+
if (args.account) params.set("account", args.account);
|
|
19974
|
+
if (args.mobile) params.set("mobile", args.mobile);
|
|
19975
|
+
if (args.nickName) params.set("nickName", args.nickName);
|
|
19976
|
+
return params.toString();
|
|
19977
|
+
}
|
|
19978
|
+
buildRoleBindingsQuery(args) {
|
|
19979
|
+
const params = new URLSearchParams();
|
|
19980
|
+
params.set("account", args.account);
|
|
19981
|
+
if (args.namespace) params.set("namespace", args.namespace);
|
|
19982
|
+
return params.toString();
|
|
19983
|
+
}
|
|
19984
|
+
async request(baseUrl, token, method, pathname, body) {
|
|
19985
|
+
const response = await fetch(`${baseUrl}${pathname}`, {
|
|
19986
|
+
method,
|
|
19987
|
+
headers: {
|
|
19988
|
+
Authorization: `Bearer ${token}`,
|
|
19989
|
+
"Content-Type": "application/json"
|
|
19990
|
+
},
|
|
19991
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
19992
|
+
});
|
|
19993
|
+
let payload = null;
|
|
19994
|
+
try {
|
|
19995
|
+
payload = await response.json();
|
|
19996
|
+
} catch {
|
|
19997
|
+
payload = null;
|
|
19998
|
+
}
|
|
19999
|
+
if (!response.ok || !payload?.success) {
|
|
20000
|
+
throw new Error(payload?.message || `Request failed with status ${response.status}`);
|
|
20001
|
+
}
|
|
20002
|
+
return payload.data;
|
|
20003
|
+
}
|
|
20004
|
+
renderRoleBindings(items, asJson) {
|
|
20005
|
+
if (asJson) {
|
|
20006
|
+
ui.plain(JSON.stringify(items, null, 2));
|
|
20007
|
+
return;
|
|
20008
|
+
}
|
|
20009
|
+
if (items.length === 0) {
|
|
20010
|
+
ui.warn("No role bindings found.");
|
|
20011
|
+
return;
|
|
20012
|
+
}
|
|
20013
|
+
for (const item of items) {
|
|
20014
|
+
ui.info(`${item.account} ${item.namespace}/${item.role}`, {
|
|
20015
|
+
source: item.source
|
|
20016
|
+
});
|
|
20017
|
+
}
|
|
20018
|
+
}
|
|
20019
|
+
renderAccountView(items, asJson) {
|
|
20020
|
+
if (asJson) {
|
|
20021
|
+
ui.plain(JSON.stringify(items, null, 2));
|
|
20022
|
+
return;
|
|
20023
|
+
}
|
|
20024
|
+
if (items.length === 0) {
|
|
20025
|
+
ui.warn("No accounts found.");
|
|
20026
|
+
return;
|
|
20027
|
+
}
|
|
20028
|
+
for (const item of items) {
|
|
20029
|
+
ui.info(item.account.id, {
|
|
20030
|
+
mobile: item.account.mobile,
|
|
20031
|
+
nickNames: item.nickNames,
|
|
20032
|
+
roles: item.roles.map((role) => `${role.namespace}/${role.role}`)
|
|
20033
|
+
});
|
|
20034
|
+
}
|
|
20035
|
+
}
|
|
20036
|
+
renderJson(value, asJson) {
|
|
20037
|
+
if (!asJson) {
|
|
20038
|
+
return;
|
|
20039
|
+
}
|
|
20040
|
+
ui.plain(JSON.stringify(value, null, 2));
|
|
20041
|
+
}
|
|
20042
|
+
};
|
|
20043
|
+
|
|
19814
20044
|
// src/agentCommandParser.ts
|
|
19815
20045
|
var DEFAULT_AGENT_NAMESPACE = "pmate";
|
|
19816
20046
|
function parseAgentArgs(tokens) {
|
|
@@ -19821,7 +20051,7 @@ function parseAgentArgs(tokens) {
|
|
|
19821
20051
|
}
|
|
19822
20052
|
let baseUrl;
|
|
19823
20053
|
let json = false;
|
|
19824
|
-
const
|
|
20054
|
+
const takeSharedOptions4 = () => {
|
|
19825
20055
|
while (rest.length > 0) {
|
|
19826
20056
|
const token = rest[0];
|
|
19827
20057
|
if (token === "--base-url") {
|
|
@@ -19838,7 +20068,7 @@ function parseAgentArgs(tokens) {
|
|
|
19838
20068
|
}
|
|
19839
20069
|
};
|
|
19840
20070
|
if (action === "namespaces") {
|
|
19841
|
-
|
|
20071
|
+
takeSharedOptions4();
|
|
19842
20072
|
if (rest.length > 0) {
|
|
19843
20073
|
throw new Error(`Unknown agent namespaces option: ${rest[0]}`);
|
|
19844
20074
|
}
|
|
@@ -19880,7 +20110,7 @@ function parseAgentArgs(tokens) {
|
|
|
19880
20110
|
`Usage: agent ${action} [<namespace>] <name> [--base-url <url>] [--json]`
|
|
19881
20111
|
);
|
|
19882
20112
|
}
|
|
19883
|
-
|
|
20113
|
+
takeSharedOptions4();
|
|
19884
20114
|
if (rest.length > 0) {
|
|
19885
20115
|
throw new Error(`Unknown agent ${action} option: ${rest[0]}`);
|
|
19886
20116
|
}
|
|
@@ -20248,7 +20478,7 @@ function parseAppArgs(tokens) {
|
|
|
20248
20478
|
}
|
|
20249
20479
|
let baseUrl;
|
|
20250
20480
|
let json = false;
|
|
20251
|
-
const
|
|
20481
|
+
const takeSharedOptions4 = () => {
|
|
20252
20482
|
while (rest.length > 0) {
|
|
20253
20483
|
const token = rest[0];
|
|
20254
20484
|
if (token === "--base-url") {
|
|
@@ -20265,7 +20495,7 @@ function parseAppArgs(tokens) {
|
|
|
20265
20495
|
}
|
|
20266
20496
|
};
|
|
20267
20497
|
if (action === "list") {
|
|
20268
|
-
|
|
20498
|
+
takeSharedOptions4();
|
|
20269
20499
|
if (rest.length > 0) {
|
|
20270
20500
|
throw new Error(`Unknown app list option: ${rest[0]}`);
|
|
20271
20501
|
}
|
|
@@ -20278,7 +20508,7 @@ function parseAppArgs(tokens) {
|
|
|
20278
20508
|
`Usage: app ${action} <id> [--base-url <url>] [--json]`
|
|
20279
20509
|
);
|
|
20280
20510
|
}
|
|
20281
|
-
|
|
20511
|
+
takeSharedOptions4();
|
|
20282
20512
|
if (rest.length > 0) {
|
|
20283
20513
|
throw new Error(`Unknown app ${action} option: ${rest[0]}`);
|
|
20284
20514
|
}
|
|
@@ -20346,6 +20576,227 @@ function requireValue4(tokens, optionName) {
|
|
|
20346
20576
|
return value;
|
|
20347
20577
|
}
|
|
20348
20578
|
|
|
20579
|
+
// src/roleCommandParser.ts
|
|
20580
|
+
function parseRoleArgs(tokens) {
|
|
20581
|
+
const rest = [...tokens];
|
|
20582
|
+
const resource = rest.shift();
|
|
20583
|
+
if (resource !== "definition") {
|
|
20584
|
+
throw new Error("Missing role resource. Use: role definition list|create");
|
|
20585
|
+
}
|
|
20586
|
+
const action = rest.shift();
|
|
20587
|
+
if (!action) {
|
|
20588
|
+
throw new Error("Missing role action. Use: role definition list|create");
|
|
20589
|
+
}
|
|
20590
|
+
let baseUrl;
|
|
20591
|
+
let json = false;
|
|
20592
|
+
if (action === "list") {
|
|
20593
|
+
takeSharedOptions3(rest, {
|
|
20594
|
+
onBaseUrl: (value) => {
|
|
20595
|
+
baseUrl = value;
|
|
20596
|
+
},
|
|
20597
|
+
onJson: () => {
|
|
20598
|
+
json = true;
|
|
20599
|
+
}
|
|
20600
|
+
});
|
|
20601
|
+
return {
|
|
20602
|
+
type: "role" /* Role */,
|
|
20603
|
+
resource,
|
|
20604
|
+
action,
|
|
20605
|
+
baseUrl,
|
|
20606
|
+
json
|
|
20607
|
+
};
|
|
20608
|
+
}
|
|
20609
|
+
if (action === "create") {
|
|
20610
|
+
const role = rest.shift();
|
|
20611
|
+
if (!role || role.startsWith("-")) {
|
|
20612
|
+
throw new Error(
|
|
20613
|
+
"Usage: role definition create <role> [--display-name <name>] [--description <text>] [--base-url <url>] [--json]"
|
|
20614
|
+
);
|
|
20615
|
+
}
|
|
20616
|
+
let displayName;
|
|
20617
|
+
let description;
|
|
20618
|
+
while (rest.length > 0) {
|
|
20619
|
+
const token = rest.shift();
|
|
20620
|
+
switch (token) {
|
|
20621
|
+
case "--display-name":
|
|
20622
|
+
displayName = requireValue5(rest, token);
|
|
20623
|
+
break;
|
|
20624
|
+
case "--description":
|
|
20625
|
+
description = requireValue5(rest, token);
|
|
20626
|
+
break;
|
|
20627
|
+
case "--base-url":
|
|
20628
|
+
baseUrl = requireValue5(rest, token);
|
|
20629
|
+
break;
|
|
20630
|
+
case "--json":
|
|
20631
|
+
json = true;
|
|
20632
|
+
break;
|
|
20633
|
+
default:
|
|
20634
|
+
throw new Error(`Unknown role create option: ${token}`);
|
|
20635
|
+
}
|
|
20636
|
+
}
|
|
20637
|
+
return {
|
|
20638
|
+
type: "role" /* Role */,
|
|
20639
|
+
resource,
|
|
20640
|
+
action,
|
|
20641
|
+
role,
|
|
20642
|
+
displayName,
|
|
20643
|
+
description,
|
|
20644
|
+
baseUrl,
|
|
20645
|
+
json
|
|
20646
|
+
};
|
|
20647
|
+
}
|
|
20648
|
+
throw new Error(`Unknown role action: ${action}`);
|
|
20649
|
+
}
|
|
20650
|
+
function takeSharedOptions3(rest, handlers) {
|
|
20651
|
+
while (rest.length > 0) {
|
|
20652
|
+
const token = rest.shift();
|
|
20653
|
+
switch (token) {
|
|
20654
|
+
case "--base-url":
|
|
20655
|
+
handlers.onBaseUrl(requireValue5(rest, token));
|
|
20656
|
+
break;
|
|
20657
|
+
case "--json":
|
|
20658
|
+
handlers.onJson();
|
|
20659
|
+
break;
|
|
20660
|
+
default:
|
|
20661
|
+
throw new Error(`Unknown role option: ${token}`);
|
|
20662
|
+
}
|
|
20663
|
+
}
|
|
20664
|
+
}
|
|
20665
|
+
function requireValue5(tokens, optionName) {
|
|
20666
|
+
const value = tokens.shift();
|
|
20667
|
+
if (!value || value.startsWith("-")) {
|
|
20668
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
20669
|
+
}
|
|
20670
|
+
return value;
|
|
20671
|
+
}
|
|
20672
|
+
|
|
20673
|
+
// src/accountCommandParser.ts
|
|
20674
|
+
function parseAccountArgs(tokens) {
|
|
20675
|
+
const rest = [...tokens];
|
|
20676
|
+
const action = rest.shift();
|
|
20677
|
+
if (!action) {
|
|
20678
|
+
throw new Error("Missing account action. Use: account view|role");
|
|
20679
|
+
}
|
|
20680
|
+
if (action === "view") {
|
|
20681
|
+
let account2;
|
|
20682
|
+
let mobile;
|
|
20683
|
+
let nickName;
|
|
20684
|
+
let baseUrl2;
|
|
20685
|
+
let json2 = false;
|
|
20686
|
+
while (rest.length > 0) {
|
|
20687
|
+
const token = rest.shift();
|
|
20688
|
+
switch (token) {
|
|
20689
|
+
case "--account":
|
|
20690
|
+
account2 = requireValue6(rest, token);
|
|
20691
|
+
break;
|
|
20692
|
+
case "--mobile":
|
|
20693
|
+
mobile = requireValue6(rest, token);
|
|
20694
|
+
break;
|
|
20695
|
+
case "--nickname":
|
|
20696
|
+
case "--nickName":
|
|
20697
|
+
nickName = requireValue6(rest, token);
|
|
20698
|
+
break;
|
|
20699
|
+
case "--base-url":
|
|
20700
|
+
baseUrl2 = requireValue6(rest, token);
|
|
20701
|
+
break;
|
|
20702
|
+
case "--json":
|
|
20703
|
+
json2 = true;
|
|
20704
|
+
break;
|
|
20705
|
+
default:
|
|
20706
|
+
throw new Error(`Unknown account view option: ${token}`);
|
|
20707
|
+
}
|
|
20708
|
+
}
|
|
20709
|
+
const provided = [account2, mobile, nickName].filter(Boolean).length;
|
|
20710
|
+
if (provided !== 1) {
|
|
20711
|
+
throw new Error(
|
|
20712
|
+
"Usage: account view (--account <id> | --mobile <mobile> | --nickname <nickname>) [--base-url <url>] [--json]"
|
|
20713
|
+
);
|
|
20714
|
+
}
|
|
20715
|
+
return {
|
|
20716
|
+
type: "account" /* Account */,
|
|
20717
|
+
action,
|
|
20718
|
+
account: account2,
|
|
20719
|
+
mobile,
|
|
20720
|
+
nickName,
|
|
20721
|
+
baseUrl: baseUrl2,
|
|
20722
|
+
json: json2
|
|
20723
|
+
};
|
|
20724
|
+
}
|
|
20725
|
+
if (action !== "role") {
|
|
20726
|
+
throw new Error(`Unknown account action: ${action}`);
|
|
20727
|
+
}
|
|
20728
|
+
const roleAction = rest.shift();
|
|
20729
|
+
if (!roleAction) {
|
|
20730
|
+
throw new Error("Missing account role action. Use: account role list|add|remove");
|
|
20731
|
+
}
|
|
20732
|
+
let account;
|
|
20733
|
+
let namespace;
|
|
20734
|
+
let role;
|
|
20735
|
+
let baseUrl;
|
|
20736
|
+
let json = false;
|
|
20737
|
+
while (rest.length > 0) {
|
|
20738
|
+
const token = rest.shift();
|
|
20739
|
+
switch (token) {
|
|
20740
|
+
case "--account":
|
|
20741
|
+
account = requireValue6(rest, token);
|
|
20742
|
+
break;
|
|
20743
|
+
case "--namespace":
|
|
20744
|
+
namespace = requireValue6(rest, token);
|
|
20745
|
+
break;
|
|
20746
|
+
case "--role":
|
|
20747
|
+
role = requireValue6(rest, token);
|
|
20748
|
+
break;
|
|
20749
|
+
case "--base-url":
|
|
20750
|
+
baseUrl = requireValue6(rest, token);
|
|
20751
|
+
break;
|
|
20752
|
+
case "--json":
|
|
20753
|
+
json = true;
|
|
20754
|
+
break;
|
|
20755
|
+
default:
|
|
20756
|
+
throw new Error(`Unknown account role option: ${token}`);
|
|
20757
|
+
}
|
|
20758
|
+
}
|
|
20759
|
+
if (roleAction === "list") {
|
|
20760
|
+
if (!account) {
|
|
20761
|
+
throw new Error(
|
|
20762
|
+
"Usage: account role list --account <id> [--namespace <ns>] [--base-url <url>] [--json]"
|
|
20763
|
+
);
|
|
20764
|
+
}
|
|
20765
|
+
return {
|
|
20766
|
+
type: "account" /* Account */,
|
|
20767
|
+
action: "role-list",
|
|
20768
|
+
account,
|
|
20769
|
+
namespace,
|
|
20770
|
+
baseUrl,
|
|
20771
|
+
json
|
|
20772
|
+
};
|
|
20773
|
+
}
|
|
20774
|
+
if (roleAction === "add" || roleAction === "remove") {
|
|
20775
|
+
if (!account || !namespace || !role) {
|
|
20776
|
+
throw new Error(
|
|
20777
|
+
`Usage: account role ${roleAction} --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]`
|
|
20778
|
+
);
|
|
20779
|
+
}
|
|
20780
|
+
return {
|
|
20781
|
+
type: "account" /* Account */,
|
|
20782
|
+
action: roleAction === "add" ? "role-add" : "role-remove",
|
|
20783
|
+
account,
|
|
20784
|
+
namespace,
|
|
20785
|
+
role,
|
|
20786
|
+
baseUrl,
|
|
20787
|
+
json
|
|
20788
|
+
};
|
|
20789
|
+
}
|
|
20790
|
+
throw new Error(`Unknown account role action: ${roleAction}`);
|
|
20791
|
+
}
|
|
20792
|
+
function requireValue6(tokens, optionName) {
|
|
20793
|
+
const value = tokens.shift();
|
|
20794
|
+
if (!value || value.startsWith("-")) {
|
|
20795
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
20796
|
+
}
|
|
20797
|
+
return value;
|
|
20798
|
+
}
|
|
20799
|
+
|
|
20349
20800
|
// src/index.ts
|
|
20350
20801
|
var pkg = JSON.parse(
|
|
20351
20802
|
(0, import_node_fs15.readFileSync)(import_node_path20.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
@@ -20436,6 +20887,16 @@ var HELP_TEXT = [
|
|
|
20436
20887
|
` ${import_chalk3.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20437
20888
|
` ${import_chalk3.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20438
20889
|
` ${import_chalk3.default.gray(" create <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20890
|
+
` ${import_chalk3.default.cyan("role")} Manage role definitions via auth-api`,
|
|
20891
|
+
` ${import_chalk3.default.gray(" definition list [--base-url <url>] [--json]")}`,
|
|
20892
|
+
` ${import_chalk3.default.gray(" definition create <role> [--display-name <name>] [--description <text>] [--base-url <url>] [--json]")}`,
|
|
20893
|
+
` ${import_chalk3.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
20894
|
+
` ${import_chalk3.default.cyan("account")} View accounts and manage account role bindings`,
|
|
20895
|
+
` ${import_chalk3.default.gray(" view (--account <id> | --mobile <mobile> | --nickname <nickname>) [--base-url <url>] [--json]")}`,
|
|
20896
|
+
` ${import_chalk3.default.gray(" role list --account <id> [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
20897
|
+
` ${import_chalk3.default.gray(" role add --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]")}`,
|
|
20898
|
+
` ${import_chalk3.default.gray(" role remove --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]")}`,
|
|
20899
|
+
` ${import_chalk3.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
20439
20900
|
` ${import_chalk3.default.cyan("store")} Manage @pmate/store namespaces, tables, and kv stores`,
|
|
20440
20901
|
` ${import_chalk3.default.gray(" namespace list [--chain <chain>] [--indexer-base-url <url>] [--json]")}`,
|
|
20441
20902
|
` ${import_chalk3.default.gray(" table list|get|exists|create|update|delete <name> [options]")}`,
|
|
@@ -20508,7 +20969,7 @@ function parseCommandArgs(args) {
|
|
|
20508
20969
|
const token = rest.shift();
|
|
20509
20970
|
switch (token) {
|
|
20510
20971
|
case "--app":
|
|
20511
|
-
app =
|
|
20972
|
+
app = requireValue7(rest, token);
|
|
20512
20973
|
break;
|
|
20513
20974
|
default:
|
|
20514
20975
|
throw new Error(`Unknown login option: ${token}`);
|
|
@@ -20576,6 +21037,12 @@ function parseCommandArgs(args) {
|
|
|
20576
21037
|
if (args.rest[0] === "ns" || args.rest[0] === "namespace") {
|
|
20577
21038
|
return parseNsArgs(args.rest.slice(1));
|
|
20578
21039
|
}
|
|
21040
|
+
if (args.rest[0] === "role") {
|
|
21041
|
+
return parseRoleArgs(args.rest.slice(1));
|
|
21042
|
+
}
|
|
21043
|
+
if (args.rest[0] === "account") {
|
|
21044
|
+
return parseAccountArgs(args.rest.slice(1));
|
|
21045
|
+
}
|
|
20579
21046
|
if (args.rest[0] === "store") {
|
|
20580
21047
|
return parseStoreArgs(args.rest.slice(1));
|
|
20581
21048
|
}
|
|
@@ -20599,7 +21066,7 @@ function parseVercelArgs(tokens) {
|
|
|
20599
21066
|
const token = rest.shift();
|
|
20600
21067
|
switch (token) {
|
|
20601
21068
|
case "--scope":
|
|
20602
|
-
scope =
|
|
21069
|
+
scope = requireValue7(rest, token);
|
|
20603
21070
|
break;
|
|
20604
21071
|
default:
|
|
20605
21072
|
throw new Error(`Unknown vercel option: ${token}`);
|
|
@@ -20619,10 +21086,10 @@ function parseVercelArgs(tokens) {
|
|
|
20619
21086
|
const token = rest.shift();
|
|
20620
21087
|
switch (token) {
|
|
20621
21088
|
case "--scope":
|
|
20622
|
-
scope =
|
|
21089
|
+
scope = requireValue7(rest, token);
|
|
20623
21090
|
break;
|
|
20624
21091
|
case "--project":
|
|
20625
|
-
project =
|
|
21092
|
+
project = requireValue7(rest, token);
|
|
20626
21093
|
break;
|
|
20627
21094
|
case "--last-week":
|
|
20628
21095
|
lastWeek = true;
|
|
@@ -20653,16 +21120,16 @@ function parseAddDnsArgs(tokens) {
|
|
|
20653
21120
|
const token = rest.shift();
|
|
20654
21121
|
switch (token) {
|
|
20655
21122
|
case "--type":
|
|
20656
|
-
options.dnsType =
|
|
21123
|
+
options.dnsType = requireValue7(rest, token);
|
|
20657
21124
|
break;
|
|
20658
21125
|
case "--value":
|
|
20659
|
-
options.dnsValue =
|
|
21126
|
+
options.dnsValue = requireValue7(rest, token);
|
|
20660
21127
|
break;
|
|
20661
21128
|
case "--rr":
|
|
20662
|
-
options.dnsRr =
|
|
21129
|
+
options.dnsRr = requireValue7(rest, token);
|
|
20663
21130
|
break;
|
|
20664
21131
|
case "--ttl": {
|
|
20665
|
-
const ttlValue =
|
|
21132
|
+
const ttlValue = requireValue7(rest, token);
|
|
20666
21133
|
const ttl = Number.parseInt(ttlValue, 10);
|
|
20667
21134
|
if (!Number.isFinite(ttl) || ttl <= 0) {
|
|
20668
21135
|
throw new Error(`Invalid --ttl value: ${ttlValue}`);
|
|
@@ -20671,7 +21138,7 @@ function parseAddDnsArgs(tokens) {
|
|
|
20671
21138
|
break;
|
|
20672
21139
|
}
|
|
20673
21140
|
case "--domain":
|
|
20674
|
-
options.dnsDomain =
|
|
21141
|
+
options.dnsDomain = requireValue7(rest, token);
|
|
20675
21142
|
break;
|
|
20676
21143
|
default:
|
|
20677
21144
|
throw new Error(`Unknown add-dns option: ${token}`);
|
|
@@ -20704,13 +21171,13 @@ function parseBucketArgs(tokens) {
|
|
|
20704
21171
|
options.bucketCreate = true;
|
|
20705
21172
|
break;
|
|
20706
21173
|
case "--name":
|
|
20707
|
-
options.bucketName =
|
|
21174
|
+
options.bucketName = requireValue7(rest, token);
|
|
20708
21175
|
break;
|
|
20709
21176
|
case "--subdomain":
|
|
20710
|
-
options.bucketSubdomain =
|
|
21177
|
+
options.bucketSubdomain = requireValue7(rest, token);
|
|
20711
21178
|
break;
|
|
20712
21179
|
case "--domain":
|
|
20713
|
-
options.bucketDomain =
|
|
21180
|
+
options.bucketDomain = requireValue7(rest, token);
|
|
20714
21181
|
break;
|
|
20715
21182
|
default:
|
|
20716
21183
|
throw new Error(`Unknown bucket option: ${token}`);
|
|
@@ -20749,7 +21216,7 @@ function parseDeployArgs(tokens) {
|
|
|
20749
21216
|
options.deployAction = "logs";
|
|
20750
21217
|
break;
|
|
20751
21218
|
case "--cwd":
|
|
20752
|
-
options.deployCwd =
|
|
21219
|
+
options.deployCwd = requireValue7(rest, token);
|
|
20753
21220
|
break;
|
|
20754
21221
|
default:
|
|
20755
21222
|
throw new Error(`Unknown deploy option: ${token}`);
|
|
@@ -20774,13 +21241,13 @@ function parseLogArgs(tokens) {
|
|
|
20774
21241
|
const token = rest.shift();
|
|
20775
21242
|
switch (token) {
|
|
20776
21243
|
case "--cwd":
|
|
20777
|
-
options.logCwd =
|
|
21244
|
+
options.logCwd = requireValue7(rest, token);
|
|
20778
21245
|
break;
|
|
20779
21246
|
case "--ns":
|
|
20780
|
-
options.logNamespace =
|
|
21247
|
+
options.logNamespace = requireValue7(rest, token);
|
|
20781
21248
|
break;
|
|
20782
21249
|
case "--page": {
|
|
20783
|
-
const value =
|
|
21250
|
+
const value = requireValue7(rest, token);
|
|
20784
21251
|
const page = Number.parseInt(value, 10);
|
|
20785
21252
|
if (!Number.isFinite(page) || page < 0) {
|
|
20786
21253
|
throw new Error(`Invalid log page: ${value}`);
|
|
@@ -20792,7 +21259,7 @@ function parseLogArgs(tokens) {
|
|
|
20792
21259
|
options.logHistory = true;
|
|
20793
21260
|
break;
|
|
20794
21261
|
case "--search":
|
|
20795
|
-
options.logSearch =
|
|
21262
|
+
options.logSearch = requireValue7(rest, token);
|
|
20796
21263
|
break;
|
|
20797
21264
|
default:
|
|
20798
21265
|
throw new Error(`Unknown log option: ${token}`);
|
|
@@ -20815,7 +21282,7 @@ function parseInitArgs(tokens) {
|
|
|
20815
21282
|
const token = rest.shift();
|
|
20816
21283
|
switch (token) {
|
|
20817
21284
|
case "--cwd":
|
|
20818
|
-
options.initCwd =
|
|
21285
|
+
options.initCwd = requireValue7(rest, token);
|
|
20819
21286
|
break;
|
|
20820
21287
|
default:
|
|
20821
21288
|
throw new Error(`Unknown init option: ${token}`);
|
|
@@ -20838,7 +21305,7 @@ function parseDevArgs(tokens) {
|
|
|
20838
21305
|
const token = rest.shift();
|
|
20839
21306
|
switch (token) {
|
|
20840
21307
|
case "--cwd":
|
|
20841
|
-
options.devCwd =
|
|
21308
|
+
options.devCwd = requireValue7(rest, token);
|
|
20842
21309
|
break;
|
|
20843
21310
|
default:
|
|
20844
21311
|
throw new Error(`Unknown dev option: ${token}`);
|
|
@@ -20868,13 +21335,13 @@ function parseOssArgs(tokens) {
|
|
|
20868
21335
|
const token = rest.shift();
|
|
20869
21336
|
switch (token) {
|
|
20870
21337
|
case "--bucket":
|
|
20871
|
-
bucket =
|
|
21338
|
+
bucket = requireValue7(rest, token);
|
|
20872
21339
|
break;
|
|
20873
21340
|
case "--file":
|
|
20874
|
-
filePath =
|
|
21341
|
+
filePath = requireValue7(rest, token);
|
|
20875
21342
|
break;
|
|
20876
21343
|
case "--key":
|
|
20877
|
-
objectKey =
|
|
21344
|
+
objectKey = requireValue7(rest, token);
|
|
20878
21345
|
break;
|
|
20879
21346
|
default:
|
|
20880
21347
|
throw new Error(`Unknown oss option: ${token}`);
|
|
@@ -20907,7 +21374,7 @@ function parseEnvArgs(tokens) {
|
|
|
20907
21374
|
throw new Error("Only one env action is allowed.");
|
|
20908
21375
|
}
|
|
20909
21376
|
action = "set";
|
|
20910
|
-
key =
|
|
21377
|
+
key = requireValue7(rest, token);
|
|
20911
21378
|
break;
|
|
20912
21379
|
case "--list":
|
|
20913
21380
|
if (action) {
|
|
@@ -20920,17 +21387,17 @@ function parseEnvArgs(tokens) {
|
|
|
20920
21387
|
throw new Error("Only one env action is allowed.");
|
|
20921
21388
|
}
|
|
20922
21389
|
action = "delete";
|
|
20923
|
-
key =
|
|
21390
|
+
key = requireValue7(rest, token);
|
|
20924
21391
|
break;
|
|
20925
21392
|
case "--value":
|
|
20926
|
-
value =
|
|
21393
|
+
value = requireValue7(rest, token);
|
|
20927
21394
|
break;
|
|
20928
21395
|
case "--verbose":
|
|
20929
21396
|
case "-v":
|
|
20930
21397
|
verbose = true;
|
|
20931
21398
|
break;
|
|
20932
21399
|
case "--cwd":
|
|
20933
|
-
cwd =
|
|
21400
|
+
cwd = requireValue7(rest, token);
|
|
20934
21401
|
break;
|
|
20935
21402
|
default:
|
|
20936
21403
|
throw new Error(`Unknown env option: ${token}`);
|
|
@@ -20988,7 +21455,7 @@ function parseCommitArgs(tokens) {
|
|
|
20988
21455
|
push = true;
|
|
20989
21456
|
break;
|
|
20990
21457
|
case "--cwd":
|
|
20991
|
-
cwd =
|
|
21458
|
+
cwd = requireValue7(rest, token);
|
|
20992
21459
|
break;
|
|
20993
21460
|
default:
|
|
20994
21461
|
throw new Error(`Unknown commit option: ${token}`);
|
|
@@ -21004,10 +21471,10 @@ function parseSummaryArgs(tokens) {
|
|
|
21004
21471
|
const token = rest.shift();
|
|
21005
21472
|
switch (token) {
|
|
21006
21473
|
case "--pr":
|
|
21007
|
-
prRef =
|
|
21474
|
+
prRef = requireValue7(rest, token);
|
|
21008
21475
|
break;
|
|
21009
21476
|
case "--cwd":
|
|
21010
|
-
cwd =
|
|
21477
|
+
cwd = requireValue7(rest, token);
|
|
21011
21478
|
break;
|
|
21012
21479
|
default:
|
|
21013
21480
|
throw new Error(`Unknown summary option: ${token}`);
|
|
@@ -21076,10 +21543,10 @@ function parseLinearPrArgs(tokens) {
|
|
|
21076
21543
|
const token = rest.shift();
|
|
21077
21544
|
switch (token) {
|
|
21078
21545
|
case "--account":
|
|
21079
|
-
account =
|
|
21546
|
+
account = requireValue7(rest, token);
|
|
21080
21547
|
break;
|
|
21081
21548
|
case "--cwd":
|
|
21082
|
-
cwd =
|
|
21549
|
+
cwd = requireValue7(rest, token);
|
|
21083
21550
|
break;
|
|
21084
21551
|
default:
|
|
21085
21552
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21108,35 +21575,35 @@ function parseLinearCreateArgs(tokens) {
|
|
|
21108
21575
|
const token = rest.shift();
|
|
21109
21576
|
switch (token) {
|
|
21110
21577
|
case "--account":
|
|
21111
|
-
account =
|
|
21578
|
+
account = requireValue7(rest, token);
|
|
21112
21579
|
break;
|
|
21113
21580
|
case "--repl":
|
|
21114
21581
|
useRepl = true;
|
|
21115
21582
|
break;
|
|
21116
21583
|
case "--title":
|
|
21117
|
-
title =
|
|
21584
|
+
title = requireValue7(rest, token);
|
|
21118
21585
|
break;
|
|
21119
21586
|
case "--desc":
|
|
21120
21587
|
case "--description":
|
|
21121
|
-
description = decodeEscapedNewlines(
|
|
21588
|
+
description = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21122
21589
|
break;
|
|
21123
21590
|
case "--team-id":
|
|
21124
|
-
teamId =
|
|
21591
|
+
teamId = requireValue7(rest, token);
|
|
21125
21592
|
break;
|
|
21126
21593
|
case "--team-key":
|
|
21127
|
-
teamKey =
|
|
21594
|
+
teamKey = requireValue7(rest, token);
|
|
21128
21595
|
break;
|
|
21129
21596
|
case "--priority":
|
|
21130
|
-
priority = parseLinearPriority(
|
|
21597
|
+
priority = parseLinearPriority(requireValue7(rest, token));
|
|
21131
21598
|
break;
|
|
21132
21599
|
case "--parent-id":
|
|
21133
|
-
parentId =
|
|
21600
|
+
parentId = requireValue7(rest, token);
|
|
21134
21601
|
break;
|
|
21135
21602
|
case "--state-id":
|
|
21136
|
-
stateId =
|
|
21603
|
+
stateId = requireValue7(rest, token);
|
|
21137
21604
|
break;
|
|
21138
21605
|
case "--cwd":
|
|
21139
|
-
cwd =
|
|
21606
|
+
cwd = requireValue7(rest, token);
|
|
21140
21607
|
break;
|
|
21141
21608
|
default:
|
|
21142
21609
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21171,10 +21638,10 @@ function parseLinearWhoamiArgs(tokens) {
|
|
|
21171
21638
|
const token = rest.shift();
|
|
21172
21639
|
switch (token) {
|
|
21173
21640
|
case "--account":
|
|
21174
|
-
account =
|
|
21641
|
+
account = requireValue7(rest, token);
|
|
21175
21642
|
break;
|
|
21176
21643
|
case "--cwd":
|
|
21177
|
-
cwd =
|
|
21644
|
+
cwd = requireValue7(rest, token);
|
|
21178
21645
|
break;
|
|
21179
21646
|
default:
|
|
21180
21647
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21199,10 +21666,10 @@ function parseLinearViewArgs(tokens) {
|
|
|
21199
21666
|
const token = rest.shift();
|
|
21200
21667
|
switch (token) {
|
|
21201
21668
|
case "--account":
|
|
21202
|
-
account =
|
|
21669
|
+
account = requireValue7(rest, token);
|
|
21203
21670
|
break;
|
|
21204
21671
|
case "--cwd":
|
|
21205
|
-
cwd =
|
|
21672
|
+
cwd = requireValue7(rest, token);
|
|
21206
21673
|
break;
|
|
21207
21674
|
default:
|
|
21208
21675
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21237,32 +21704,32 @@ function parseLinearUpdateArgs(tokens) {
|
|
|
21237
21704
|
const token = rest.shift();
|
|
21238
21705
|
switch (token) {
|
|
21239
21706
|
case "--account":
|
|
21240
|
-
account =
|
|
21707
|
+
account = requireValue7(rest, token);
|
|
21241
21708
|
break;
|
|
21242
21709
|
case "--title":
|
|
21243
|
-
title =
|
|
21710
|
+
title = requireValue7(rest, token);
|
|
21244
21711
|
break;
|
|
21245
21712
|
case "--desc":
|
|
21246
21713
|
case "--description":
|
|
21247
|
-
description = decodeEscapedNewlines(
|
|
21714
|
+
description = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21248
21715
|
break;
|
|
21249
21716
|
case "--team-id":
|
|
21250
|
-
teamId =
|
|
21717
|
+
teamId = requireValue7(rest, token);
|
|
21251
21718
|
break;
|
|
21252
21719
|
case "--team-key":
|
|
21253
|
-
teamKey =
|
|
21720
|
+
teamKey = requireValue7(rest, token);
|
|
21254
21721
|
break;
|
|
21255
21722
|
case "--priority":
|
|
21256
|
-
priority = parseLinearPriority(
|
|
21723
|
+
priority = parseLinearPriority(requireValue7(rest, token));
|
|
21257
21724
|
break;
|
|
21258
21725
|
case "--parent-id":
|
|
21259
|
-
parentId =
|
|
21726
|
+
parentId = requireValue7(rest, token);
|
|
21260
21727
|
break;
|
|
21261
21728
|
case "--state-id":
|
|
21262
|
-
stateId =
|
|
21729
|
+
stateId = requireValue7(rest, token);
|
|
21263
21730
|
break;
|
|
21264
21731
|
case "--cwd":
|
|
21265
|
-
cwd =
|
|
21732
|
+
cwd = requireValue7(rest, token);
|
|
21266
21733
|
break;
|
|
21267
21734
|
default:
|
|
21268
21735
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21300,10 +21767,10 @@ function parseLinearSubIssuesArgs(tokens) {
|
|
|
21300
21767
|
const token = rest.shift();
|
|
21301
21768
|
switch (token) {
|
|
21302
21769
|
case "--account":
|
|
21303
|
-
account =
|
|
21770
|
+
account = requireValue7(rest, token);
|
|
21304
21771
|
break;
|
|
21305
21772
|
case "--cwd":
|
|
21306
|
-
cwd =
|
|
21773
|
+
cwd = requireValue7(rest, token);
|
|
21307
21774
|
break;
|
|
21308
21775
|
default:
|
|
21309
21776
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21330,15 +21797,15 @@ function parseLinearCommentArgs(tokens) {
|
|
|
21330
21797
|
const token = rest.shift();
|
|
21331
21798
|
switch (token) {
|
|
21332
21799
|
case "--account":
|
|
21333
|
-
account =
|
|
21800
|
+
account = requireValue7(rest, token);
|
|
21334
21801
|
break;
|
|
21335
21802
|
case "--body":
|
|
21336
21803
|
case "--desc":
|
|
21337
21804
|
case "--description":
|
|
21338
|
-
body = decodeEscapedNewlines(
|
|
21805
|
+
body = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21339
21806
|
break;
|
|
21340
21807
|
case "--cwd":
|
|
21341
|
-
cwd =
|
|
21808
|
+
cwd = requireValue7(rest, token);
|
|
21342
21809
|
break;
|
|
21343
21810
|
default:
|
|
21344
21811
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21368,10 +21835,10 @@ function parseLinearCommentsArgs(tokens) {
|
|
|
21368
21835
|
const token = rest.shift();
|
|
21369
21836
|
switch (token) {
|
|
21370
21837
|
case "--account":
|
|
21371
|
-
account =
|
|
21838
|
+
account = requireValue7(rest, token);
|
|
21372
21839
|
break;
|
|
21373
21840
|
case "--cwd":
|
|
21374
|
-
cwd =
|
|
21841
|
+
cwd = requireValue7(rest, token);
|
|
21375
21842
|
break;
|
|
21376
21843
|
default:
|
|
21377
21844
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21395,16 +21862,16 @@ function parseLinearCycleArgs(tokens) {
|
|
|
21395
21862
|
const token = rest.shift();
|
|
21396
21863
|
switch (token) {
|
|
21397
21864
|
case "--account":
|
|
21398
|
-
account =
|
|
21865
|
+
account = requireValue7(rest, token);
|
|
21399
21866
|
break;
|
|
21400
21867
|
case "--team-id":
|
|
21401
|
-
teamId =
|
|
21868
|
+
teamId = requireValue7(rest, token);
|
|
21402
21869
|
break;
|
|
21403
21870
|
case "--team-key":
|
|
21404
|
-
teamKey =
|
|
21871
|
+
teamKey = requireValue7(rest, token);
|
|
21405
21872
|
break;
|
|
21406
21873
|
case "--cwd":
|
|
21407
|
-
cwd =
|
|
21874
|
+
cwd = requireValue7(rest, token);
|
|
21408
21875
|
break;
|
|
21409
21876
|
default:
|
|
21410
21877
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21427,10 +21894,10 @@ function parseLinearTeamsArgs(tokens) {
|
|
|
21427
21894
|
const token = rest.shift();
|
|
21428
21895
|
switch (token) {
|
|
21429
21896
|
case "--account":
|
|
21430
|
-
account =
|
|
21897
|
+
account = requireValue7(rest, token);
|
|
21431
21898
|
break;
|
|
21432
21899
|
case "--cwd":
|
|
21433
|
-
cwd =
|
|
21900
|
+
cwd = requireValue7(rest, token);
|
|
21434
21901
|
break;
|
|
21435
21902
|
default:
|
|
21436
21903
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21457,16 +21924,16 @@ function parseLinearUserIssuesArgs(tokens) {
|
|
|
21457
21924
|
const token = rest.shift();
|
|
21458
21925
|
switch (token) {
|
|
21459
21926
|
case "--account":
|
|
21460
|
-
account =
|
|
21927
|
+
account = requireValue7(rest, token);
|
|
21461
21928
|
break;
|
|
21462
21929
|
case "--cycle":
|
|
21463
|
-
cycle = parseLinearCycle(
|
|
21930
|
+
cycle = parseLinearCycle(requireValue7(rest, token));
|
|
21464
21931
|
break;
|
|
21465
21932
|
case "--status":
|
|
21466
|
-
status = parseLinearStatus(
|
|
21933
|
+
status = parseLinearStatus(requireValue7(rest, token));
|
|
21467
21934
|
break;
|
|
21468
21935
|
case "--cwd":
|
|
21469
|
-
cwd =
|
|
21936
|
+
cwd = requireValue7(rest, token);
|
|
21470
21937
|
break;
|
|
21471
21938
|
default:
|
|
21472
21939
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21500,28 +21967,28 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21500
21967
|
const token = rest.shift();
|
|
21501
21968
|
switch (token) {
|
|
21502
21969
|
case "--account":
|
|
21503
|
-
account =
|
|
21970
|
+
account = requireValue7(rest, token);
|
|
21504
21971
|
break;
|
|
21505
21972
|
case "--team-id":
|
|
21506
|
-
teamId =
|
|
21973
|
+
teamId = requireValue7(rest, token);
|
|
21507
21974
|
break;
|
|
21508
21975
|
case "--team-key":
|
|
21509
|
-
teamKey =
|
|
21976
|
+
teamKey = requireValue7(rest, token);
|
|
21510
21977
|
break;
|
|
21511
21978
|
case "--user":
|
|
21512
|
-
user =
|
|
21979
|
+
user = requireValue7(rest, token);
|
|
21513
21980
|
break;
|
|
21514
21981
|
case "--cycle":
|
|
21515
|
-
cycle = parseLinearCycle(
|
|
21982
|
+
cycle = parseLinearCycle(requireValue7(rest, token));
|
|
21516
21983
|
break;
|
|
21517
21984
|
case "--status":
|
|
21518
|
-
status = parseLinearStatus(
|
|
21985
|
+
status = parseLinearStatus(requireValue7(rest, token));
|
|
21519
21986
|
break;
|
|
21520
21987
|
case "--query":
|
|
21521
|
-
query =
|
|
21988
|
+
query = requireValue7(rest, token).trim();
|
|
21522
21989
|
break;
|
|
21523
21990
|
case "--limit": {
|
|
21524
|
-
const value = Number.parseInt(
|
|
21991
|
+
const value = Number.parseInt(requireValue7(rest, token), 10);
|
|
21525
21992
|
if (!Number.isInteger(value) || value < 1 || value > 250) {
|
|
21526
21993
|
throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
|
|
21527
21994
|
}
|
|
@@ -21529,7 +21996,7 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21529
21996
|
break;
|
|
21530
21997
|
}
|
|
21531
21998
|
case "--cwd":
|
|
21532
|
-
cwd =
|
|
21999
|
+
cwd = requireValue7(rest, token);
|
|
21533
22000
|
break;
|
|
21534
22001
|
default:
|
|
21535
22002
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21570,10 +22037,10 @@ function parseLinearLegacyArgs(tokens) {
|
|
|
21570
22037
|
useScreenshot = true;
|
|
21571
22038
|
break;
|
|
21572
22039
|
case "--account":
|
|
21573
|
-
account =
|
|
22040
|
+
account = requireValue7(rest, token);
|
|
21574
22041
|
break;
|
|
21575
22042
|
case "--cwd":
|
|
21576
|
-
cwd =
|
|
22043
|
+
cwd = requireValue7(rest, token);
|
|
21577
22044
|
break;
|
|
21578
22045
|
default:
|
|
21579
22046
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21667,19 +22134,19 @@ function parseNotionArgs(tokens) {
|
|
|
21667
22134
|
const token = rest.shift();
|
|
21668
22135
|
switch (token) {
|
|
21669
22136
|
case "--parent":
|
|
21670
|
-
parentPageId =
|
|
22137
|
+
parentPageId = requireValue7(rest, token);
|
|
21671
22138
|
break;
|
|
21672
22139
|
case "--title":
|
|
21673
|
-
title =
|
|
22140
|
+
title = requireValue7(rest, token);
|
|
21674
22141
|
break;
|
|
21675
22142
|
case "--private":
|
|
21676
22143
|
isPrivate = true;
|
|
21677
22144
|
break;
|
|
21678
22145
|
case "--content":
|
|
21679
|
-
content2 =
|
|
22146
|
+
content2 = requireValue7(rest, token);
|
|
21680
22147
|
break;
|
|
21681
22148
|
case "--file":
|
|
21682
|
-
filePath2 =
|
|
22149
|
+
filePath2 = requireValue7(rest, token);
|
|
21683
22150
|
break;
|
|
21684
22151
|
default:
|
|
21685
22152
|
throw new Error(`Unknown notion option: ${token}`);
|
|
@@ -21723,10 +22190,10 @@ function parseNotionArgs(tokens) {
|
|
|
21723
22190
|
const token = rest.shift();
|
|
21724
22191
|
switch (token) {
|
|
21725
22192
|
case "--content":
|
|
21726
|
-
content =
|
|
22193
|
+
content = requireValue7(rest, token);
|
|
21727
22194
|
break;
|
|
21728
22195
|
case "--file":
|
|
21729
|
-
filePath =
|
|
22196
|
+
filePath = requireValue7(rest, token);
|
|
21730
22197
|
break;
|
|
21731
22198
|
case "--append":
|
|
21732
22199
|
append = true;
|
|
@@ -21771,11 +22238,11 @@ function parseRandomArgs(tokens) {
|
|
|
21771
22238
|
mode = "easy";
|
|
21772
22239
|
break;
|
|
21773
22240
|
case "--length":
|
|
21774
|
-
length = parsePositiveInt(
|
|
22241
|
+
length = parsePositiveInt(requireValue7(rest, token), token);
|
|
21775
22242
|
seenLength = true;
|
|
21776
22243
|
break;
|
|
21777
22244
|
case "--charset": {
|
|
21778
|
-
const value =
|
|
22245
|
+
const value = requireValue7(rest, token);
|
|
21779
22246
|
if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
|
|
21780
22247
|
throw new Error(
|
|
21781
22248
|
`Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
|
|
@@ -21786,18 +22253,18 @@ function parseRandomArgs(tokens) {
|
|
|
21786
22253
|
break;
|
|
21787
22254
|
}
|
|
21788
22255
|
case "--count":
|
|
21789
|
-
count = parsePositiveInt(
|
|
22256
|
+
count = parsePositiveInt(requireValue7(rest, token), token);
|
|
21790
22257
|
break;
|
|
21791
22258
|
case "--words":
|
|
21792
|
-
words = parsePositiveInt(
|
|
22259
|
+
words = parsePositiveInt(requireValue7(rest, token), token);
|
|
21793
22260
|
seenWords = true;
|
|
21794
22261
|
break;
|
|
21795
22262
|
case "--digits":
|
|
21796
|
-
digits = parseNonNegativeInt(
|
|
22263
|
+
digits = parseNonNegativeInt(requireValue7(rest, token), token);
|
|
21797
22264
|
seenDigits = true;
|
|
21798
22265
|
break;
|
|
21799
22266
|
case "--separator":
|
|
21800
|
-
separator =
|
|
22267
|
+
separator = requireValue7(rest, token);
|
|
21801
22268
|
seenSeparator = true;
|
|
21802
22269
|
break;
|
|
21803
22270
|
default:
|
|
@@ -21840,7 +22307,7 @@ function parseCollectArgs(tokens) {
|
|
|
21840
22307
|
const token = rest.shift();
|
|
21841
22308
|
switch (token) {
|
|
21842
22309
|
case "--endpoint":
|
|
21843
|
-
options.endpoint =
|
|
22310
|
+
options.endpoint = requireValue7(rest, token);
|
|
21844
22311
|
break;
|
|
21845
22312
|
case "--json":
|
|
21846
22313
|
options.json = true;
|
|
@@ -21850,7 +22317,7 @@ function parseCollectArgs(tokens) {
|
|
|
21850
22317
|
break;
|
|
21851
22318
|
case "--thread":
|
|
21852
22319
|
options.mode = "thread";
|
|
21853
|
-
options.threadName =
|
|
22320
|
+
options.threadName = requireValue7(rest, token);
|
|
21854
22321
|
break;
|
|
21855
22322
|
default:
|
|
21856
22323
|
throw new Error(`Unknown collect option: ${token}`);
|
|
@@ -21861,7 +22328,7 @@ function parseCollectArgs(tokens) {
|
|
|
21861
22328
|
}
|
|
21862
22329
|
return { type: "collect" /* Collect */, ...options };
|
|
21863
22330
|
}
|
|
21864
|
-
function
|
|
22331
|
+
function requireValue7(tokens, optionName) {
|
|
21865
22332
|
const value = tokens.shift();
|
|
21866
22333
|
if (!value) {
|
|
21867
22334
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22007,6 +22474,16 @@ async function main() {
|
|
|
22007
22474
|
await handler.handle(commandArgs);
|
|
22008
22475
|
return;
|
|
22009
22476
|
}
|
|
22477
|
+
case "role" /* Role */: {
|
|
22478
|
+
const handler = new RoleCommandHandler();
|
|
22479
|
+
await handler.handle(commandArgs);
|
|
22480
|
+
return;
|
|
22481
|
+
}
|
|
22482
|
+
case "account" /* Account */: {
|
|
22483
|
+
const handler = new AccountCommandHandler();
|
|
22484
|
+
await handler.handle(commandArgs);
|
|
22485
|
+
return;
|
|
22486
|
+
}
|
|
22010
22487
|
case "store" /* Store */: {
|
|
22011
22488
|
const handler = new StoreCommandHandler();
|
|
22012
22489
|
await handler.handle(commandArgs);
|