@pmate/cli 0.16.2 → 0.16.4
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 +592 -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,243 @@ 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
|
+
profiles: item.profiles.map((profile) => ({
|
|
20032
|
+
id: profile.id,
|
|
20033
|
+
app: profile.app,
|
|
20034
|
+
nickName: profile.nickName,
|
|
20035
|
+
userName: profile.userName,
|
|
20036
|
+
role: profile.role
|
|
20037
|
+
})),
|
|
20038
|
+
nickNames: item.nickNames,
|
|
20039
|
+
roles: item.roles.map((role) => `${role.namespace}/${role.role}`)
|
|
20040
|
+
});
|
|
20041
|
+
}
|
|
20042
|
+
}
|
|
20043
|
+
renderJson(value, asJson) {
|
|
20044
|
+
if (!asJson) {
|
|
20045
|
+
return;
|
|
20046
|
+
}
|
|
20047
|
+
ui.plain(JSON.stringify(value, null, 2));
|
|
20048
|
+
}
|
|
20049
|
+
};
|
|
20050
|
+
|
|
19814
20051
|
// src/agentCommandParser.ts
|
|
19815
20052
|
var DEFAULT_AGENT_NAMESPACE = "pmate";
|
|
19816
20053
|
function parseAgentArgs(tokens) {
|
|
@@ -19821,7 +20058,7 @@ function parseAgentArgs(tokens) {
|
|
|
19821
20058
|
}
|
|
19822
20059
|
let baseUrl;
|
|
19823
20060
|
let json = false;
|
|
19824
|
-
const
|
|
20061
|
+
const takeSharedOptions4 = () => {
|
|
19825
20062
|
while (rest.length > 0) {
|
|
19826
20063
|
const token = rest[0];
|
|
19827
20064
|
if (token === "--base-url") {
|
|
@@ -19838,7 +20075,7 @@ function parseAgentArgs(tokens) {
|
|
|
19838
20075
|
}
|
|
19839
20076
|
};
|
|
19840
20077
|
if (action === "namespaces") {
|
|
19841
|
-
|
|
20078
|
+
takeSharedOptions4();
|
|
19842
20079
|
if (rest.length > 0) {
|
|
19843
20080
|
throw new Error(`Unknown agent namespaces option: ${rest[0]}`);
|
|
19844
20081
|
}
|
|
@@ -19880,7 +20117,7 @@ function parseAgentArgs(tokens) {
|
|
|
19880
20117
|
`Usage: agent ${action} [<namespace>] <name> [--base-url <url>] [--json]`
|
|
19881
20118
|
);
|
|
19882
20119
|
}
|
|
19883
|
-
|
|
20120
|
+
takeSharedOptions4();
|
|
19884
20121
|
if (rest.length > 0) {
|
|
19885
20122
|
throw new Error(`Unknown agent ${action} option: ${rest[0]}`);
|
|
19886
20123
|
}
|
|
@@ -20248,7 +20485,7 @@ function parseAppArgs(tokens) {
|
|
|
20248
20485
|
}
|
|
20249
20486
|
let baseUrl;
|
|
20250
20487
|
let json = false;
|
|
20251
|
-
const
|
|
20488
|
+
const takeSharedOptions4 = () => {
|
|
20252
20489
|
while (rest.length > 0) {
|
|
20253
20490
|
const token = rest[0];
|
|
20254
20491
|
if (token === "--base-url") {
|
|
@@ -20265,7 +20502,7 @@ function parseAppArgs(tokens) {
|
|
|
20265
20502
|
}
|
|
20266
20503
|
};
|
|
20267
20504
|
if (action === "list") {
|
|
20268
|
-
|
|
20505
|
+
takeSharedOptions4();
|
|
20269
20506
|
if (rest.length > 0) {
|
|
20270
20507
|
throw new Error(`Unknown app list option: ${rest[0]}`);
|
|
20271
20508
|
}
|
|
@@ -20278,7 +20515,7 @@ function parseAppArgs(tokens) {
|
|
|
20278
20515
|
`Usage: app ${action} <id> [--base-url <url>] [--json]`
|
|
20279
20516
|
);
|
|
20280
20517
|
}
|
|
20281
|
-
|
|
20518
|
+
takeSharedOptions4();
|
|
20282
20519
|
if (rest.length > 0) {
|
|
20283
20520
|
throw new Error(`Unknown app ${action} option: ${rest[0]}`);
|
|
20284
20521
|
}
|
|
@@ -20346,6 +20583,233 @@ function requireValue4(tokens, optionName) {
|
|
|
20346
20583
|
return value;
|
|
20347
20584
|
}
|
|
20348
20585
|
|
|
20586
|
+
// src/roleCommandParser.ts
|
|
20587
|
+
function parseRoleArgs(tokens) {
|
|
20588
|
+
const rest = [...tokens];
|
|
20589
|
+
const resource = rest.shift();
|
|
20590
|
+
if (resource !== "definition") {
|
|
20591
|
+
throw new Error("Missing role resource. Use: role definition list|create");
|
|
20592
|
+
}
|
|
20593
|
+
const action = rest.shift();
|
|
20594
|
+
if (!action) {
|
|
20595
|
+
throw new Error("Missing role action. Use: role definition list|create");
|
|
20596
|
+
}
|
|
20597
|
+
let baseUrl;
|
|
20598
|
+
let json = false;
|
|
20599
|
+
if (action === "list") {
|
|
20600
|
+
takeSharedOptions3(rest, {
|
|
20601
|
+
onBaseUrl: (value) => {
|
|
20602
|
+
baseUrl = value;
|
|
20603
|
+
},
|
|
20604
|
+
onJson: () => {
|
|
20605
|
+
json = true;
|
|
20606
|
+
}
|
|
20607
|
+
});
|
|
20608
|
+
return {
|
|
20609
|
+
type: "role" /* Role */,
|
|
20610
|
+
resource,
|
|
20611
|
+
action,
|
|
20612
|
+
baseUrl,
|
|
20613
|
+
json
|
|
20614
|
+
};
|
|
20615
|
+
}
|
|
20616
|
+
if (action === "create") {
|
|
20617
|
+
const role = rest.shift();
|
|
20618
|
+
if (!role || role.startsWith("-")) {
|
|
20619
|
+
throw new Error(
|
|
20620
|
+
"Usage: role definition create <role> [--display-name <name>] [--description <text>] [--base-url <url>] [--json]"
|
|
20621
|
+
);
|
|
20622
|
+
}
|
|
20623
|
+
let displayName;
|
|
20624
|
+
let description;
|
|
20625
|
+
while (rest.length > 0) {
|
|
20626
|
+
const token = rest.shift();
|
|
20627
|
+
switch (token) {
|
|
20628
|
+
case "--display-name":
|
|
20629
|
+
displayName = requireValue5(rest, token);
|
|
20630
|
+
break;
|
|
20631
|
+
case "--description":
|
|
20632
|
+
description = requireValue5(rest, token);
|
|
20633
|
+
break;
|
|
20634
|
+
case "--base-url":
|
|
20635
|
+
baseUrl = requireValue5(rest, token);
|
|
20636
|
+
break;
|
|
20637
|
+
case "--json":
|
|
20638
|
+
json = true;
|
|
20639
|
+
break;
|
|
20640
|
+
default:
|
|
20641
|
+
throw new Error(`Unknown role create option: ${token}`);
|
|
20642
|
+
}
|
|
20643
|
+
}
|
|
20644
|
+
return {
|
|
20645
|
+
type: "role" /* Role */,
|
|
20646
|
+
resource,
|
|
20647
|
+
action,
|
|
20648
|
+
role,
|
|
20649
|
+
displayName,
|
|
20650
|
+
description,
|
|
20651
|
+
baseUrl,
|
|
20652
|
+
json
|
|
20653
|
+
};
|
|
20654
|
+
}
|
|
20655
|
+
throw new Error(`Unknown role action: ${action}`);
|
|
20656
|
+
}
|
|
20657
|
+
function takeSharedOptions3(rest, handlers) {
|
|
20658
|
+
while (rest.length > 0) {
|
|
20659
|
+
const token = rest.shift();
|
|
20660
|
+
switch (token) {
|
|
20661
|
+
case "--base-url":
|
|
20662
|
+
handlers.onBaseUrl(requireValue5(rest, token));
|
|
20663
|
+
break;
|
|
20664
|
+
case "--json":
|
|
20665
|
+
handlers.onJson();
|
|
20666
|
+
break;
|
|
20667
|
+
default:
|
|
20668
|
+
throw new Error(`Unknown role option: ${token}`);
|
|
20669
|
+
}
|
|
20670
|
+
}
|
|
20671
|
+
}
|
|
20672
|
+
function requireValue5(tokens, optionName) {
|
|
20673
|
+
const value = tokens.shift();
|
|
20674
|
+
if (!value || value.startsWith("-")) {
|
|
20675
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
20676
|
+
}
|
|
20677
|
+
return value;
|
|
20678
|
+
}
|
|
20679
|
+
|
|
20680
|
+
// src/accountCommandParser.ts
|
|
20681
|
+
function parseAccountArgs(tokens) {
|
|
20682
|
+
const rest = [...tokens];
|
|
20683
|
+
const action = rest.shift();
|
|
20684
|
+
if (!action) {
|
|
20685
|
+
throw new Error("Missing account action. Use: account view|role");
|
|
20686
|
+
}
|
|
20687
|
+
if (action === "view") {
|
|
20688
|
+
let account2;
|
|
20689
|
+
let mobile;
|
|
20690
|
+
let nickName;
|
|
20691
|
+
let baseUrl2;
|
|
20692
|
+
let json2 = false;
|
|
20693
|
+
while (rest.length > 0) {
|
|
20694
|
+
const token = rest.shift();
|
|
20695
|
+
switch (token) {
|
|
20696
|
+
case void 0:
|
|
20697
|
+
break;
|
|
20698
|
+
case "--account":
|
|
20699
|
+
account2 = requireValue6(rest, token);
|
|
20700
|
+
break;
|
|
20701
|
+
case "--mobile":
|
|
20702
|
+
mobile = requireValue6(rest, token);
|
|
20703
|
+
break;
|
|
20704
|
+
case "--nickname":
|
|
20705
|
+
case "--nickName":
|
|
20706
|
+
nickName = requireValue6(rest, token);
|
|
20707
|
+
break;
|
|
20708
|
+
case "--base-url":
|
|
20709
|
+
baseUrl2 = requireValue6(rest, token);
|
|
20710
|
+
break;
|
|
20711
|
+
case "--json":
|
|
20712
|
+
json2 = true;
|
|
20713
|
+
break;
|
|
20714
|
+
default:
|
|
20715
|
+
if (!token.startsWith("-") && !account2 && !mobile && !nickName) {
|
|
20716
|
+
account2 = token;
|
|
20717
|
+
break;
|
|
20718
|
+
}
|
|
20719
|
+
throw new Error(`Unknown account view option: ${token}`);
|
|
20720
|
+
}
|
|
20721
|
+
}
|
|
20722
|
+
const provided = [account2, mobile, nickName].filter(Boolean).length;
|
|
20723
|
+
if (provided !== 1) {
|
|
20724
|
+
throw new Error(
|
|
20725
|
+
"Usage: account view (--account <id> | --mobile <mobile> | --nickname <nickname>) [--base-url <url>] [--json]"
|
|
20726
|
+
);
|
|
20727
|
+
}
|
|
20728
|
+
return {
|
|
20729
|
+
type: "account" /* Account */,
|
|
20730
|
+
action,
|
|
20731
|
+
account: account2,
|
|
20732
|
+
mobile,
|
|
20733
|
+
nickName,
|
|
20734
|
+
baseUrl: baseUrl2,
|
|
20735
|
+
json: json2
|
|
20736
|
+
};
|
|
20737
|
+
}
|
|
20738
|
+
if (action !== "role") {
|
|
20739
|
+
throw new Error(`Unknown account action: ${action}`);
|
|
20740
|
+
}
|
|
20741
|
+
const roleAction = rest.shift();
|
|
20742
|
+
if (!roleAction) {
|
|
20743
|
+
throw new Error("Missing account role action. Use: account role list|add|remove");
|
|
20744
|
+
}
|
|
20745
|
+
let account;
|
|
20746
|
+
let namespace;
|
|
20747
|
+
let role;
|
|
20748
|
+
let baseUrl;
|
|
20749
|
+
let json = false;
|
|
20750
|
+
while (rest.length > 0) {
|
|
20751
|
+
const token = rest.shift();
|
|
20752
|
+
switch (token) {
|
|
20753
|
+
case "--account":
|
|
20754
|
+
account = requireValue6(rest, token);
|
|
20755
|
+
break;
|
|
20756
|
+
case "--namespace":
|
|
20757
|
+
namespace = requireValue6(rest, token);
|
|
20758
|
+
break;
|
|
20759
|
+
case "--role":
|
|
20760
|
+
role = requireValue6(rest, token);
|
|
20761
|
+
break;
|
|
20762
|
+
case "--base-url":
|
|
20763
|
+
baseUrl = requireValue6(rest, token);
|
|
20764
|
+
break;
|
|
20765
|
+
case "--json":
|
|
20766
|
+
json = true;
|
|
20767
|
+
break;
|
|
20768
|
+
default:
|
|
20769
|
+
throw new Error(`Unknown account role option: ${token}`);
|
|
20770
|
+
}
|
|
20771
|
+
}
|
|
20772
|
+
if (roleAction === "list") {
|
|
20773
|
+
if (!account) {
|
|
20774
|
+
throw new Error(
|
|
20775
|
+
"Usage: account role list --account <id> [--namespace <ns>] [--base-url <url>] [--json]"
|
|
20776
|
+
);
|
|
20777
|
+
}
|
|
20778
|
+
return {
|
|
20779
|
+
type: "account" /* Account */,
|
|
20780
|
+
action: "role-list",
|
|
20781
|
+
account,
|
|
20782
|
+
namespace,
|
|
20783
|
+
baseUrl,
|
|
20784
|
+
json
|
|
20785
|
+
};
|
|
20786
|
+
}
|
|
20787
|
+
if (roleAction === "add" || roleAction === "remove") {
|
|
20788
|
+
if (!account || !namespace || !role) {
|
|
20789
|
+
throw new Error(
|
|
20790
|
+
`Usage: account role ${roleAction} --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]`
|
|
20791
|
+
);
|
|
20792
|
+
}
|
|
20793
|
+
return {
|
|
20794
|
+
type: "account" /* Account */,
|
|
20795
|
+
action: roleAction === "add" ? "role-add" : "role-remove",
|
|
20796
|
+
account,
|
|
20797
|
+
namespace,
|
|
20798
|
+
role,
|
|
20799
|
+
baseUrl,
|
|
20800
|
+
json
|
|
20801
|
+
};
|
|
20802
|
+
}
|
|
20803
|
+
throw new Error(`Unknown account role action: ${roleAction}`);
|
|
20804
|
+
}
|
|
20805
|
+
function requireValue6(tokens, optionName) {
|
|
20806
|
+
const value = tokens.shift();
|
|
20807
|
+
if (!value || value.startsWith("-")) {
|
|
20808
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
20809
|
+
}
|
|
20810
|
+
return value;
|
|
20811
|
+
}
|
|
20812
|
+
|
|
20349
20813
|
// src/index.ts
|
|
20350
20814
|
var pkg = JSON.parse(
|
|
20351
20815
|
(0, import_node_fs15.readFileSync)(import_node_path20.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
@@ -20436,6 +20900,16 @@ var HELP_TEXT = [
|
|
|
20436
20900
|
` ${import_chalk3.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20437
20901
|
` ${import_chalk3.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20438
20902
|
` ${import_chalk3.default.gray(" create <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20903
|
+
` ${import_chalk3.default.cyan("role")} Manage role definitions via auth-api`,
|
|
20904
|
+
` ${import_chalk3.default.gray(" definition list [--base-url <url>] [--json]")}`,
|
|
20905
|
+
` ${import_chalk3.default.gray(" definition create <role> [--display-name <name>] [--description <text>] [--base-url <url>] [--json]")}`,
|
|
20906
|
+
` ${import_chalk3.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
20907
|
+
` ${import_chalk3.default.cyan("account")} View accounts and manage account role bindings`,
|
|
20908
|
+
` ${import_chalk3.default.gray(" view (--account <id> | --mobile <mobile> | --nickname <nickname>) [--base-url <url>] [--json]")}`,
|
|
20909
|
+
` ${import_chalk3.default.gray(" role list --account <id> [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
20910
|
+
` ${import_chalk3.default.gray(" role add --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]")}`,
|
|
20911
|
+
` ${import_chalk3.default.gray(" role remove --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]")}`,
|
|
20912
|
+
` ${import_chalk3.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
20439
20913
|
` ${import_chalk3.default.cyan("store")} Manage @pmate/store namespaces, tables, and kv stores`,
|
|
20440
20914
|
` ${import_chalk3.default.gray(" namespace list [--chain <chain>] [--indexer-base-url <url>] [--json]")}`,
|
|
20441
20915
|
` ${import_chalk3.default.gray(" table list|get|exists|create|update|delete <name> [options]")}`,
|
|
@@ -20508,7 +20982,7 @@ function parseCommandArgs(args) {
|
|
|
20508
20982
|
const token = rest.shift();
|
|
20509
20983
|
switch (token) {
|
|
20510
20984
|
case "--app":
|
|
20511
|
-
app =
|
|
20985
|
+
app = requireValue7(rest, token);
|
|
20512
20986
|
break;
|
|
20513
20987
|
default:
|
|
20514
20988
|
throw new Error(`Unknown login option: ${token}`);
|
|
@@ -20576,6 +21050,12 @@ function parseCommandArgs(args) {
|
|
|
20576
21050
|
if (args.rest[0] === "ns" || args.rest[0] === "namespace") {
|
|
20577
21051
|
return parseNsArgs(args.rest.slice(1));
|
|
20578
21052
|
}
|
|
21053
|
+
if (args.rest[0] === "role") {
|
|
21054
|
+
return parseRoleArgs(args.rest.slice(1));
|
|
21055
|
+
}
|
|
21056
|
+
if (args.rest[0] === "account") {
|
|
21057
|
+
return parseAccountArgs(args.rest.slice(1));
|
|
21058
|
+
}
|
|
20579
21059
|
if (args.rest[0] === "store") {
|
|
20580
21060
|
return parseStoreArgs(args.rest.slice(1));
|
|
20581
21061
|
}
|
|
@@ -20599,7 +21079,7 @@ function parseVercelArgs(tokens) {
|
|
|
20599
21079
|
const token = rest.shift();
|
|
20600
21080
|
switch (token) {
|
|
20601
21081
|
case "--scope":
|
|
20602
|
-
scope =
|
|
21082
|
+
scope = requireValue7(rest, token);
|
|
20603
21083
|
break;
|
|
20604
21084
|
default:
|
|
20605
21085
|
throw new Error(`Unknown vercel option: ${token}`);
|
|
@@ -20619,10 +21099,10 @@ function parseVercelArgs(tokens) {
|
|
|
20619
21099
|
const token = rest.shift();
|
|
20620
21100
|
switch (token) {
|
|
20621
21101
|
case "--scope":
|
|
20622
|
-
scope =
|
|
21102
|
+
scope = requireValue7(rest, token);
|
|
20623
21103
|
break;
|
|
20624
21104
|
case "--project":
|
|
20625
|
-
project =
|
|
21105
|
+
project = requireValue7(rest, token);
|
|
20626
21106
|
break;
|
|
20627
21107
|
case "--last-week":
|
|
20628
21108
|
lastWeek = true;
|
|
@@ -20653,16 +21133,16 @@ function parseAddDnsArgs(tokens) {
|
|
|
20653
21133
|
const token = rest.shift();
|
|
20654
21134
|
switch (token) {
|
|
20655
21135
|
case "--type":
|
|
20656
|
-
options.dnsType =
|
|
21136
|
+
options.dnsType = requireValue7(rest, token);
|
|
20657
21137
|
break;
|
|
20658
21138
|
case "--value":
|
|
20659
|
-
options.dnsValue =
|
|
21139
|
+
options.dnsValue = requireValue7(rest, token);
|
|
20660
21140
|
break;
|
|
20661
21141
|
case "--rr":
|
|
20662
|
-
options.dnsRr =
|
|
21142
|
+
options.dnsRr = requireValue7(rest, token);
|
|
20663
21143
|
break;
|
|
20664
21144
|
case "--ttl": {
|
|
20665
|
-
const ttlValue =
|
|
21145
|
+
const ttlValue = requireValue7(rest, token);
|
|
20666
21146
|
const ttl = Number.parseInt(ttlValue, 10);
|
|
20667
21147
|
if (!Number.isFinite(ttl) || ttl <= 0) {
|
|
20668
21148
|
throw new Error(`Invalid --ttl value: ${ttlValue}`);
|
|
@@ -20671,7 +21151,7 @@ function parseAddDnsArgs(tokens) {
|
|
|
20671
21151
|
break;
|
|
20672
21152
|
}
|
|
20673
21153
|
case "--domain":
|
|
20674
|
-
options.dnsDomain =
|
|
21154
|
+
options.dnsDomain = requireValue7(rest, token);
|
|
20675
21155
|
break;
|
|
20676
21156
|
default:
|
|
20677
21157
|
throw new Error(`Unknown add-dns option: ${token}`);
|
|
@@ -20704,13 +21184,13 @@ function parseBucketArgs(tokens) {
|
|
|
20704
21184
|
options.bucketCreate = true;
|
|
20705
21185
|
break;
|
|
20706
21186
|
case "--name":
|
|
20707
|
-
options.bucketName =
|
|
21187
|
+
options.bucketName = requireValue7(rest, token);
|
|
20708
21188
|
break;
|
|
20709
21189
|
case "--subdomain":
|
|
20710
|
-
options.bucketSubdomain =
|
|
21190
|
+
options.bucketSubdomain = requireValue7(rest, token);
|
|
20711
21191
|
break;
|
|
20712
21192
|
case "--domain":
|
|
20713
|
-
options.bucketDomain =
|
|
21193
|
+
options.bucketDomain = requireValue7(rest, token);
|
|
20714
21194
|
break;
|
|
20715
21195
|
default:
|
|
20716
21196
|
throw new Error(`Unknown bucket option: ${token}`);
|
|
@@ -20749,7 +21229,7 @@ function parseDeployArgs(tokens) {
|
|
|
20749
21229
|
options.deployAction = "logs";
|
|
20750
21230
|
break;
|
|
20751
21231
|
case "--cwd":
|
|
20752
|
-
options.deployCwd =
|
|
21232
|
+
options.deployCwd = requireValue7(rest, token);
|
|
20753
21233
|
break;
|
|
20754
21234
|
default:
|
|
20755
21235
|
throw new Error(`Unknown deploy option: ${token}`);
|
|
@@ -20774,13 +21254,13 @@ function parseLogArgs(tokens) {
|
|
|
20774
21254
|
const token = rest.shift();
|
|
20775
21255
|
switch (token) {
|
|
20776
21256
|
case "--cwd":
|
|
20777
|
-
options.logCwd =
|
|
21257
|
+
options.logCwd = requireValue7(rest, token);
|
|
20778
21258
|
break;
|
|
20779
21259
|
case "--ns":
|
|
20780
|
-
options.logNamespace =
|
|
21260
|
+
options.logNamespace = requireValue7(rest, token);
|
|
20781
21261
|
break;
|
|
20782
21262
|
case "--page": {
|
|
20783
|
-
const value =
|
|
21263
|
+
const value = requireValue7(rest, token);
|
|
20784
21264
|
const page = Number.parseInt(value, 10);
|
|
20785
21265
|
if (!Number.isFinite(page) || page < 0) {
|
|
20786
21266
|
throw new Error(`Invalid log page: ${value}`);
|
|
@@ -20792,7 +21272,7 @@ function parseLogArgs(tokens) {
|
|
|
20792
21272
|
options.logHistory = true;
|
|
20793
21273
|
break;
|
|
20794
21274
|
case "--search":
|
|
20795
|
-
options.logSearch =
|
|
21275
|
+
options.logSearch = requireValue7(rest, token);
|
|
20796
21276
|
break;
|
|
20797
21277
|
default:
|
|
20798
21278
|
throw new Error(`Unknown log option: ${token}`);
|
|
@@ -20815,7 +21295,7 @@ function parseInitArgs(tokens) {
|
|
|
20815
21295
|
const token = rest.shift();
|
|
20816
21296
|
switch (token) {
|
|
20817
21297
|
case "--cwd":
|
|
20818
|
-
options.initCwd =
|
|
21298
|
+
options.initCwd = requireValue7(rest, token);
|
|
20819
21299
|
break;
|
|
20820
21300
|
default:
|
|
20821
21301
|
throw new Error(`Unknown init option: ${token}`);
|
|
@@ -20838,7 +21318,7 @@ function parseDevArgs(tokens) {
|
|
|
20838
21318
|
const token = rest.shift();
|
|
20839
21319
|
switch (token) {
|
|
20840
21320
|
case "--cwd":
|
|
20841
|
-
options.devCwd =
|
|
21321
|
+
options.devCwd = requireValue7(rest, token);
|
|
20842
21322
|
break;
|
|
20843
21323
|
default:
|
|
20844
21324
|
throw new Error(`Unknown dev option: ${token}`);
|
|
@@ -20868,13 +21348,13 @@ function parseOssArgs(tokens) {
|
|
|
20868
21348
|
const token = rest.shift();
|
|
20869
21349
|
switch (token) {
|
|
20870
21350
|
case "--bucket":
|
|
20871
|
-
bucket =
|
|
21351
|
+
bucket = requireValue7(rest, token);
|
|
20872
21352
|
break;
|
|
20873
21353
|
case "--file":
|
|
20874
|
-
filePath =
|
|
21354
|
+
filePath = requireValue7(rest, token);
|
|
20875
21355
|
break;
|
|
20876
21356
|
case "--key":
|
|
20877
|
-
objectKey =
|
|
21357
|
+
objectKey = requireValue7(rest, token);
|
|
20878
21358
|
break;
|
|
20879
21359
|
default:
|
|
20880
21360
|
throw new Error(`Unknown oss option: ${token}`);
|
|
@@ -20907,7 +21387,7 @@ function parseEnvArgs(tokens) {
|
|
|
20907
21387
|
throw new Error("Only one env action is allowed.");
|
|
20908
21388
|
}
|
|
20909
21389
|
action = "set";
|
|
20910
|
-
key =
|
|
21390
|
+
key = requireValue7(rest, token);
|
|
20911
21391
|
break;
|
|
20912
21392
|
case "--list":
|
|
20913
21393
|
if (action) {
|
|
@@ -20920,17 +21400,17 @@ function parseEnvArgs(tokens) {
|
|
|
20920
21400
|
throw new Error("Only one env action is allowed.");
|
|
20921
21401
|
}
|
|
20922
21402
|
action = "delete";
|
|
20923
|
-
key =
|
|
21403
|
+
key = requireValue7(rest, token);
|
|
20924
21404
|
break;
|
|
20925
21405
|
case "--value":
|
|
20926
|
-
value =
|
|
21406
|
+
value = requireValue7(rest, token);
|
|
20927
21407
|
break;
|
|
20928
21408
|
case "--verbose":
|
|
20929
21409
|
case "-v":
|
|
20930
21410
|
verbose = true;
|
|
20931
21411
|
break;
|
|
20932
21412
|
case "--cwd":
|
|
20933
|
-
cwd =
|
|
21413
|
+
cwd = requireValue7(rest, token);
|
|
20934
21414
|
break;
|
|
20935
21415
|
default:
|
|
20936
21416
|
throw new Error(`Unknown env option: ${token}`);
|
|
@@ -20988,7 +21468,7 @@ function parseCommitArgs(tokens) {
|
|
|
20988
21468
|
push = true;
|
|
20989
21469
|
break;
|
|
20990
21470
|
case "--cwd":
|
|
20991
|
-
cwd =
|
|
21471
|
+
cwd = requireValue7(rest, token);
|
|
20992
21472
|
break;
|
|
20993
21473
|
default:
|
|
20994
21474
|
throw new Error(`Unknown commit option: ${token}`);
|
|
@@ -21004,10 +21484,10 @@ function parseSummaryArgs(tokens) {
|
|
|
21004
21484
|
const token = rest.shift();
|
|
21005
21485
|
switch (token) {
|
|
21006
21486
|
case "--pr":
|
|
21007
|
-
prRef =
|
|
21487
|
+
prRef = requireValue7(rest, token);
|
|
21008
21488
|
break;
|
|
21009
21489
|
case "--cwd":
|
|
21010
|
-
cwd =
|
|
21490
|
+
cwd = requireValue7(rest, token);
|
|
21011
21491
|
break;
|
|
21012
21492
|
default:
|
|
21013
21493
|
throw new Error(`Unknown summary option: ${token}`);
|
|
@@ -21076,10 +21556,10 @@ function parseLinearPrArgs(tokens) {
|
|
|
21076
21556
|
const token = rest.shift();
|
|
21077
21557
|
switch (token) {
|
|
21078
21558
|
case "--account":
|
|
21079
|
-
account =
|
|
21559
|
+
account = requireValue7(rest, token);
|
|
21080
21560
|
break;
|
|
21081
21561
|
case "--cwd":
|
|
21082
|
-
cwd =
|
|
21562
|
+
cwd = requireValue7(rest, token);
|
|
21083
21563
|
break;
|
|
21084
21564
|
default:
|
|
21085
21565
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21108,35 +21588,35 @@ function parseLinearCreateArgs(tokens) {
|
|
|
21108
21588
|
const token = rest.shift();
|
|
21109
21589
|
switch (token) {
|
|
21110
21590
|
case "--account":
|
|
21111
|
-
account =
|
|
21591
|
+
account = requireValue7(rest, token);
|
|
21112
21592
|
break;
|
|
21113
21593
|
case "--repl":
|
|
21114
21594
|
useRepl = true;
|
|
21115
21595
|
break;
|
|
21116
21596
|
case "--title":
|
|
21117
|
-
title =
|
|
21597
|
+
title = requireValue7(rest, token);
|
|
21118
21598
|
break;
|
|
21119
21599
|
case "--desc":
|
|
21120
21600
|
case "--description":
|
|
21121
|
-
description = decodeEscapedNewlines(
|
|
21601
|
+
description = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21122
21602
|
break;
|
|
21123
21603
|
case "--team-id":
|
|
21124
|
-
teamId =
|
|
21604
|
+
teamId = requireValue7(rest, token);
|
|
21125
21605
|
break;
|
|
21126
21606
|
case "--team-key":
|
|
21127
|
-
teamKey =
|
|
21607
|
+
teamKey = requireValue7(rest, token);
|
|
21128
21608
|
break;
|
|
21129
21609
|
case "--priority":
|
|
21130
|
-
priority = parseLinearPriority(
|
|
21610
|
+
priority = parseLinearPriority(requireValue7(rest, token));
|
|
21131
21611
|
break;
|
|
21132
21612
|
case "--parent-id":
|
|
21133
|
-
parentId =
|
|
21613
|
+
parentId = requireValue7(rest, token);
|
|
21134
21614
|
break;
|
|
21135
21615
|
case "--state-id":
|
|
21136
|
-
stateId =
|
|
21616
|
+
stateId = requireValue7(rest, token);
|
|
21137
21617
|
break;
|
|
21138
21618
|
case "--cwd":
|
|
21139
|
-
cwd =
|
|
21619
|
+
cwd = requireValue7(rest, token);
|
|
21140
21620
|
break;
|
|
21141
21621
|
default:
|
|
21142
21622
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21171,10 +21651,10 @@ function parseLinearWhoamiArgs(tokens) {
|
|
|
21171
21651
|
const token = rest.shift();
|
|
21172
21652
|
switch (token) {
|
|
21173
21653
|
case "--account":
|
|
21174
|
-
account =
|
|
21654
|
+
account = requireValue7(rest, token);
|
|
21175
21655
|
break;
|
|
21176
21656
|
case "--cwd":
|
|
21177
|
-
cwd =
|
|
21657
|
+
cwd = requireValue7(rest, token);
|
|
21178
21658
|
break;
|
|
21179
21659
|
default:
|
|
21180
21660
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21199,10 +21679,10 @@ function parseLinearViewArgs(tokens) {
|
|
|
21199
21679
|
const token = rest.shift();
|
|
21200
21680
|
switch (token) {
|
|
21201
21681
|
case "--account":
|
|
21202
|
-
account =
|
|
21682
|
+
account = requireValue7(rest, token);
|
|
21203
21683
|
break;
|
|
21204
21684
|
case "--cwd":
|
|
21205
|
-
cwd =
|
|
21685
|
+
cwd = requireValue7(rest, token);
|
|
21206
21686
|
break;
|
|
21207
21687
|
default:
|
|
21208
21688
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21237,32 +21717,32 @@ function parseLinearUpdateArgs(tokens) {
|
|
|
21237
21717
|
const token = rest.shift();
|
|
21238
21718
|
switch (token) {
|
|
21239
21719
|
case "--account":
|
|
21240
|
-
account =
|
|
21720
|
+
account = requireValue7(rest, token);
|
|
21241
21721
|
break;
|
|
21242
21722
|
case "--title":
|
|
21243
|
-
title =
|
|
21723
|
+
title = requireValue7(rest, token);
|
|
21244
21724
|
break;
|
|
21245
21725
|
case "--desc":
|
|
21246
21726
|
case "--description":
|
|
21247
|
-
description = decodeEscapedNewlines(
|
|
21727
|
+
description = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21248
21728
|
break;
|
|
21249
21729
|
case "--team-id":
|
|
21250
|
-
teamId =
|
|
21730
|
+
teamId = requireValue7(rest, token);
|
|
21251
21731
|
break;
|
|
21252
21732
|
case "--team-key":
|
|
21253
|
-
teamKey =
|
|
21733
|
+
teamKey = requireValue7(rest, token);
|
|
21254
21734
|
break;
|
|
21255
21735
|
case "--priority":
|
|
21256
|
-
priority = parseLinearPriority(
|
|
21736
|
+
priority = parseLinearPriority(requireValue7(rest, token));
|
|
21257
21737
|
break;
|
|
21258
21738
|
case "--parent-id":
|
|
21259
|
-
parentId =
|
|
21739
|
+
parentId = requireValue7(rest, token);
|
|
21260
21740
|
break;
|
|
21261
21741
|
case "--state-id":
|
|
21262
|
-
stateId =
|
|
21742
|
+
stateId = requireValue7(rest, token);
|
|
21263
21743
|
break;
|
|
21264
21744
|
case "--cwd":
|
|
21265
|
-
cwd =
|
|
21745
|
+
cwd = requireValue7(rest, token);
|
|
21266
21746
|
break;
|
|
21267
21747
|
default:
|
|
21268
21748
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21300,10 +21780,10 @@ function parseLinearSubIssuesArgs(tokens) {
|
|
|
21300
21780
|
const token = rest.shift();
|
|
21301
21781
|
switch (token) {
|
|
21302
21782
|
case "--account":
|
|
21303
|
-
account =
|
|
21783
|
+
account = requireValue7(rest, token);
|
|
21304
21784
|
break;
|
|
21305
21785
|
case "--cwd":
|
|
21306
|
-
cwd =
|
|
21786
|
+
cwd = requireValue7(rest, token);
|
|
21307
21787
|
break;
|
|
21308
21788
|
default:
|
|
21309
21789
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21330,15 +21810,15 @@ function parseLinearCommentArgs(tokens) {
|
|
|
21330
21810
|
const token = rest.shift();
|
|
21331
21811
|
switch (token) {
|
|
21332
21812
|
case "--account":
|
|
21333
|
-
account =
|
|
21813
|
+
account = requireValue7(rest, token);
|
|
21334
21814
|
break;
|
|
21335
21815
|
case "--body":
|
|
21336
21816
|
case "--desc":
|
|
21337
21817
|
case "--description":
|
|
21338
|
-
body = decodeEscapedNewlines(
|
|
21818
|
+
body = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21339
21819
|
break;
|
|
21340
21820
|
case "--cwd":
|
|
21341
|
-
cwd =
|
|
21821
|
+
cwd = requireValue7(rest, token);
|
|
21342
21822
|
break;
|
|
21343
21823
|
default:
|
|
21344
21824
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21368,10 +21848,10 @@ function parseLinearCommentsArgs(tokens) {
|
|
|
21368
21848
|
const token = rest.shift();
|
|
21369
21849
|
switch (token) {
|
|
21370
21850
|
case "--account":
|
|
21371
|
-
account =
|
|
21851
|
+
account = requireValue7(rest, token);
|
|
21372
21852
|
break;
|
|
21373
21853
|
case "--cwd":
|
|
21374
|
-
cwd =
|
|
21854
|
+
cwd = requireValue7(rest, token);
|
|
21375
21855
|
break;
|
|
21376
21856
|
default:
|
|
21377
21857
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21395,16 +21875,16 @@ function parseLinearCycleArgs(tokens) {
|
|
|
21395
21875
|
const token = rest.shift();
|
|
21396
21876
|
switch (token) {
|
|
21397
21877
|
case "--account":
|
|
21398
|
-
account =
|
|
21878
|
+
account = requireValue7(rest, token);
|
|
21399
21879
|
break;
|
|
21400
21880
|
case "--team-id":
|
|
21401
|
-
teamId =
|
|
21881
|
+
teamId = requireValue7(rest, token);
|
|
21402
21882
|
break;
|
|
21403
21883
|
case "--team-key":
|
|
21404
|
-
teamKey =
|
|
21884
|
+
teamKey = requireValue7(rest, token);
|
|
21405
21885
|
break;
|
|
21406
21886
|
case "--cwd":
|
|
21407
|
-
cwd =
|
|
21887
|
+
cwd = requireValue7(rest, token);
|
|
21408
21888
|
break;
|
|
21409
21889
|
default:
|
|
21410
21890
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21427,10 +21907,10 @@ function parseLinearTeamsArgs(tokens) {
|
|
|
21427
21907
|
const token = rest.shift();
|
|
21428
21908
|
switch (token) {
|
|
21429
21909
|
case "--account":
|
|
21430
|
-
account =
|
|
21910
|
+
account = requireValue7(rest, token);
|
|
21431
21911
|
break;
|
|
21432
21912
|
case "--cwd":
|
|
21433
|
-
cwd =
|
|
21913
|
+
cwd = requireValue7(rest, token);
|
|
21434
21914
|
break;
|
|
21435
21915
|
default:
|
|
21436
21916
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21457,16 +21937,16 @@ function parseLinearUserIssuesArgs(tokens) {
|
|
|
21457
21937
|
const token = rest.shift();
|
|
21458
21938
|
switch (token) {
|
|
21459
21939
|
case "--account":
|
|
21460
|
-
account =
|
|
21940
|
+
account = requireValue7(rest, token);
|
|
21461
21941
|
break;
|
|
21462
21942
|
case "--cycle":
|
|
21463
|
-
cycle = parseLinearCycle(
|
|
21943
|
+
cycle = parseLinearCycle(requireValue7(rest, token));
|
|
21464
21944
|
break;
|
|
21465
21945
|
case "--status":
|
|
21466
|
-
status = parseLinearStatus(
|
|
21946
|
+
status = parseLinearStatus(requireValue7(rest, token));
|
|
21467
21947
|
break;
|
|
21468
21948
|
case "--cwd":
|
|
21469
|
-
cwd =
|
|
21949
|
+
cwd = requireValue7(rest, token);
|
|
21470
21950
|
break;
|
|
21471
21951
|
default:
|
|
21472
21952
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21500,28 +21980,28 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21500
21980
|
const token = rest.shift();
|
|
21501
21981
|
switch (token) {
|
|
21502
21982
|
case "--account":
|
|
21503
|
-
account =
|
|
21983
|
+
account = requireValue7(rest, token);
|
|
21504
21984
|
break;
|
|
21505
21985
|
case "--team-id":
|
|
21506
|
-
teamId =
|
|
21986
|
+
teamId = requireValue7(rest, token);
|
|
21507
21987
|
break;
|
|
21508
21988
|
case "--team-key":
|
|
21509
|
-
teamKey =
|
|
21989
|
+
teamKey = requireValue7(rest, token);
|
|
21510
21990
|
break;
|
|
21511
21991
|
case "--user":
|
|
21512
|
-
user =
|
|
21992
|
+
user = requireValue7(rest, token);
|
|
21513
21993
|
break;
|
|
21514
21994
|
case "--cycle":
|
|
21515
|
-
cycle = parseLinearCycle(
|
|
21995
|
+
cycle = parseLinearCycle(requireValue7(rest, token));
|
|
21516
21996
|
break;
|
|
21517
21997
|
case "--status":
|
|
21518
|
-
status = parseLinearStatus(
|
|
21998
|
+
status = parseLinearStatus(requireValue7(rest, token));
|
|
21519
21999
|
break;
|
|
21520
22000
|
case "--query":
|
|
21521
|
-
query =
|
|
22001
|
+
query = requireValue7(rest, token).trim();
|
|
21522
22002
|
break;
|
|
21523
22003
|
case "--limit": {
|
|
21524
|
-
const value = Number.parseInt(
|
|
22004
|
+
const value = Number.parseInt(requireValue7(rest, token), 10);
|
|
21525
22005
|
if (!Number.isInteger(value) || value < 1 || value > 250) {
|
|
21526
22006
|
throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
|
|
21527
22007
|
}
|
|
@@ -21529,7 +22009,7 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21529
22009
|
break;
|
|
21530
22010
|
}
|
|
21531
22011
|
case "--cwd":
|
|
21532
|
-
cwd =
|
|
22012
|
+
cwd = requireValue7(rest, token);
|
|
21533
22013
|
break;
|
|
21534
22014
|
default:
|
|
21535
22015
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21570,10 +22050,10 @@ function parseLinearLegacyArgs(tokens) {
|
|
|
21570
22050
|
useScreenshot = true;
|
|
21571
22051
|
break;
|
|
21572
22052
|
case "--account":
|
|
21573
|
-
account =
|
|
22053
|
+
account = requireValue7(rest, token);
|
|
21574
22054
|
break;
|
|
21575
22055
|
case "--cwd":
|
|
21576
|
-
cwd =
|
|
22056
|
+
cwd = requireValue7(rest, token);
|
|
21577
22057
|
break;
|
|
21578
22058
|
default:
|
|
21579
22059
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21667,19 +22147,19 @@ function parseNotionArgs(tokens) {
|
|
|
21667
22147
|
const token = rest.shift();
|
|
21668
22148
|
switch (token) {
|
|
21669
22149
|
case "--parent":
|
|
21670
|
-
parentPageId =
|
|
22150
|
+
parentPageId = requireValue7(rest, token);
|
|
21671
22151
|
break;
|
|
21672
22152
|
case "--title":
|
|
21673
|
-
title =
|
|
22153
|
+
title = requireValue7(rest, token);
|
|
21674
22154
|
break;
|
|
21675
22155
|
case "--private":
|
|
21676
22156
|
isPrivate = true;
|
|
21677
22157
|
break;
|
|
21678
22158
|
case "--content":
|
|
21679
|
-
content2 =
|
|
22159
|
+
content2 = requireValue7(rest, token);
|
|
21680
22160
|
break;
|
|
21681
22161
|
case "--file":
|
|
21682
|
-
filePath2 =
|
|
22162
|
+
filePath2 = requireValue7(rest, token);
|
|
21683
22163
|
break;
|
|
21684
22164
|
default:
|
|
21685
22165
|
throw new Error(`Unknown notion option: ${token}`);
|
|
@@ -21723,10 +22203,10 @@ function parseNotionArgs(tokens) {
|
|
|
21723
22203
|
const token = rest.shift();
|
|
21724
22204
|
switch (token) {
|
|
21725
22205
|
case "--content":
|
|
21726
|
-
content =
|
|
22206
|
+
content = requireValue7(rest, token);
|
|
21727
22207
|
break;
|
|
21728
22208
|
case "--file":
|
|
21729
|
-
filePath =
|
|
22209
|
+
filePath = requireValue7(rest, token);
|
|
21730
22210
|
break;
|
|
21731
22211
|
case "--append":
|
|
21732
22212
|
append = true;
|
|
@@ -21771,11 +22251,11 @@ function parseRandomArgs(tokens) {
|
|
|
21771
22251
|
mode = "easy";
|
|
21772
22252
|
break;
|
|
21773
22253
|
case "--length":
|
|
21774
|
-
length = parsePositiveInt(
|
|
22254
|
+
length = parsePositiveInt(requireValue7(rest, token), token);
|
|
21775
22255
|
seenLength = true;
|
|
21776
22256
|
break;
|
|
21777
22257
|
case "--charset": {
|
|
21778
|
-
const value =
|
|
22258
|
+
const value = requireValue7(rest, token);
|
|
21779
22259
|
if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
|
|
21780
22260
|
throw new Error(
|
|
21781
22261
|
`Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
|
|
@@ -21786,18 +22266,18 @@ function parseRandomArgs(tokens) {
|
|
|
21786
22266
|
break;
|
|
21787
22267
|
}
|
|
21788
22268
|
case "--count":
|
|
21789
|
-
count = parsePositiveInt(
|
|
22269
|
+
count = parsePositiveInt(requireValue7(rest, token), token);
|
|
21790
22270
|
break;
|
|
21791
22271
|
case "--words":
|
|
21792
|
-
words = parsePositiveInt(
|
|
22272
|
+
words = parsePositiveInt(requireValue7(rest, token), token);
|
|
21793
22273
|
seenWords = true;
|
|
21794
22274
|
break;
|
|
21795
22275
|
case "--digits":
|
|
21796
|
-
digits = parseNonNegativeInt(
|
|
22276
|
+
digits = parseNonNegativeInt(requireValue7(rest, token), token);
|
|
21797
22277
|
seenDigits = true;
|
|
21798
22278
|
break;
|
|
21799
22279
|
case "--separator":
|
|
21800
|
-
separator =
|
|
22280
|
+
separator = requireValue7(rest, token);
|
|
21801
22281
|
seenSeparator = true;
|
|
21802
22282
|
break;
|
|
21803
22283
|
default:
|
|
@@ -21840,7 +22320,7 @@ function parseCollectArgs(tokens) {
|
|
|
21840
22320
|
const token = rest.shift();
|
|
21841
22321
|
switch (token) {
|
|
21842
22322
|
case "--endpoint":
|
|
21843
|
-
options.endpoint =
|
|
22323
|
+
options.endpoint = requireValue7(rest, token);
|
|
21844
22324
|
break;
|
|
21845
22325
|
case "--json":
|
|
21846
22326
|
options.json = true;
|
|
@@ -21850,7 +22330,7 @@ function parseCollectArgs(tokens) {
|
|
|
21850
22330
|
break;
|
|
21851
22331
|
case "--thread":
|
|
21852
22332
|
options.mode = "thread";
|
|
21853
|
-
options.threadName =
|
|
22333
|
+
options.threadName = requireValue7(rest, token);
|
|
21854
22334
|
break;
|
|
21855
22335
|
default:
|
|
21856
22336
|
throw new Error(`Unknown collect option: ${token}`);
|
|
@@ -21861,7 +22341,7 @@ function parseCollectArgs(tokens) {
|
|
|
21861
22341
|
}
|
|
21862
22342
|
return { type: "collect" /* Collect */, ...options };
|
|
21863
22343
|
}
|
|
21864
|
-
function
|
|
22344
|
+
function requireValue7(tokens, optionName) {
|
|
21865
22345
|
const value = tokens.shift();
|
|
21866
22346
|
if (!value) {
|
|
21867
22347
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22007,6 +22487,16 @@ async function main() {
|
|
|
22007
22487
|
await handler.handle(commandArgs);
|
|
22008
22488
|
return;
|
|
22009
22489
|
}
|
|
22490
|
+
case "role" /* Role */: {
|
|
22491
|
+
const handler = new RoleCommandHandler();
|
|
22492
|
+
await handler.handle(commandArgs);
|
|
22493
|
+
return;
|
|
22494
|
+
}
|
|
22495
|
+
case "account" /* Account */: {
|
|
22496
|
+
const handler = new AccountCommandHandler();
|
|
22497
|
+
await handler.handle(commandArgs);
|
|
22498
|
+
return;
|
|
22499
|
+
}
|
|
22010
22500
|
case "store" /* Store */: {
|
|
22011
22501
|
const handler = new StoreCommandHandler();
|
|
22012
22502
|
await handler.handle(commandArgs);
|