@pmate/cli 0.16.1 → 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 +594 -109
- 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
|
@@ -18908,9 +18908,16 @@ var BlockLogAppender = class {
|
|
|
18908
18908
|
var Namespace = class {
|
|
18909
18909
|
constructor(options) {
|
|
18910
18910
|
this.options = options;
|
|
18911
|
-
this.appender = new BlockLogAppender(options.chain, options.baseUrl.replace(/\/+$/, ""));
|
|
18912
18911
|
this.indexerClient = new IndexerClient(options.indexerBaseUrl.replace(/\/+$/, ""));
|
|
18913
18912
|
}
|
|
18913
|
+
getAppender() {
|
|
18914
|
+
if (!this.options.baseUrl) {
|
|
18915
|
+
throw new Error(
|
|
18916
|
+
"Missing store base URL. Provide --base-url or set PMATE_STORE_BASE_URL / BLOCKCHAIN_BASE_URL."
|
|
18917
|
+
);
|
|
18918
|
+
}
|
|
18919
|
+
return new BlockLogAppender(this.options.chain, this.options.baseUrl.replace(/\/+$/, ""));
|
|
18920
|
+
}
|
|
18914
18921
|
table(name) {
|
|
18915
18922
|
const descriptor = createDescriptor({
|
|
18916
18923
|
chain: this.options.chain,
|
|
@@ -18951,7 +18958,7 @@ var Namespace = class {
|
|
|
18951
18958
|
v: STORE_LOG_VERSION,
|
|
18952
18959
|
data: { type: "create", after: data }
|
|
18953
18960
|
};
|
|
18954
|
-
await this.
|
|
18961
|
+
await this.getAppender().append([log]);
|
|
18955
18962
|
},
|
|
18956
18963
|
updateRow: async (data) => {
|
|
18957
18964
|
const { id, ...value } = data;
|
|
@@ -18963,7 +18970,7 @@ var Namespace = class {
|
|
|
18963
18970
|
v: STORE_LOG_VERSION,
|
|
18964
18971
|
data: { type: "update", id, value }
|
|
18965
18972
|
};
|
|
18966
|
-
await this.
|
|
18973
|
+
await this.getAppender().append([log]);
|
|
18967
18974
|
},
|
|
18968
18975
|
deleteRow: async (id) => {
|
|
18969
18976
|
const log = {
|
|
@@ -18974,7 +18981,7 @@ var Namespace = class {
|
|
|
18974
18981
|
v: STORE_LOG_VERSION,
|
|
18975
18982
|
data: { type: "delete", id }
|
|
18976
18983
|
};
|
|
18977
|
-
await this.
|
|
18984
|
+
await this.getAppender().append([log]);
|
|
18978
18985
|
}
|
|
18979
18986
|
};
|
|
18980
18987
|
}
|
|
@@ -19017,7 +19024,7 @@ var Namespace = class {
|
|
|
19017
19024
|
v: STORE_LOG_VERSION,
|
|
19018
19025
|
data: { key, value }
|
|
19019
19026
|
};
|
|
19020
|
-
await this.
|
|
19027
|
+
await this.getAppender().append([log]);
|
|
19021
19028
|
},
|
|
19022
19029
|
delete: async (key) => {
|
|
19023
19030
|
const log = {
|
|
@@ -19028,7 +19035,7 @@ var Namespace = class {
|
|
|
19028
19035
|
v: STORE_LOG_VERSION,
|
|
19029
19036
|
data: { key, value: null }
|
|
19030
19037
|
};
|
|
19031
|
-
await this.
|
|
19038
|
+
await this.getAppender().append([log]);
|
|
19032
19039
|
}
|
|
19033
19040
|
};
|
|
19034
19041
|
}
|
|
@@ -19436,10 +19443,11 @@ var StoreCommandHandler = class {
|
|
|
19436
19443
|
}
|
|
19437
19444
|
}
|
|
19438
19445
|
createNamespace(args) {
|
|
19446
|
+
const needsWriteBaseUrl = args.scope === "table" && (args.action === "create" || args.action === "update" || args.action === "delete") || args.scope === "kv" && (args.action === "set" || args.action === "delete");
|
|
19439
19447
|
return new Namespace({
|
|
19440
19448
|
chain: args.chain,
|
|
19441
19449
|
ns: args.namespace,
|
|
19442
|
-
baseUrl: this.resolveBaseUrl(args.baseUrl),
|
|
19450
|
+
baseUrl: needsWriteBaseUrl ? this.resolveBaseUrl(args.baseUrl) : args.baseUrl,
|
|
19443
19451
|
indexerBaseUrl: this.resolveIndexerBaseUrl(args.indexerBaseUrl)
|
|
19444
19452
|
});
|
|
19445
19453
|
}
|
|
@@ -19803,6 +19811,236 @@ var VercelCommandHandler = class {
|
|
|
19803
19811
|
}
|
|
19804
19812
|
};
|
|
19805
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
|
+
|
|
19806
20044
|
// src/agentCommandParser.ts
|
|
19807
20045
|
var DEFAULT_AGENT_NAMESPACE = "pmate";
|
|
19808
20046
|
function parseAgentArgs(tokens) {
|
|
@@ -19813,7 +20051,7 @@ function parseAgentArgs(tokens) {
|
|
|
19813
20051
|
}
|
|
19814
20052
|
let baseUrl;
|
|
19815
20053
|
let json = false;
|
|
19816
|
-
const
|
|
20054
|
+
const takeSharedOptions4 = () => {
|
|
19817
20055
|
while (rest.length > 0) {
|
|
19818
20056
|
const token = rest[0];
|
|
19819
20057
|
if (token === "--base-url") {
|
|
@@ -19830,7 +20068,7 @@ function parseAgentArgs(tokens) {
|
|
|
19830
20068
|
}
|
|
19831
20069
|
};
|
|
19832
20070
|
if (action === "namespaces") {
|
|
19833
|
-
|
|
20071
|
+
takeSharedOptions4();
|
|
19834
20072
|
if (rest.length > 0) {
|
|
19835
20073
|
throw new Error(`Unknown agent namespaces option: ${rest[0]}`);
|
|
19836
20074
|
}
|
|
@@ -19872,7 +20110,7 @@ function parseAgentArgs(tokens) {
|
|
|
19872
20110
|
`Usage: agent ${action} [<namespace>] <name> [--base-url <url>] [--json]`
|
|
19873
20111
|
);
|
|
19874
20112
|
}
|
|
19875
|
-
|
|
20113
|
+
takeSharedOptions4();
|
|
19876
20114
|
if (rest.length > 0) {
|
|
19877
20115
|
throw new Error(`Unknown agent ${action} option: ${rest[0]}`);
|
|
19878
20116
|
}
|
|
@@ -20240,7 +20478,7 @@ function parseAppArgs(tokens) {
|
|
|
20240
20478
|
}
|
|
20241
20479
|
let baseUrl;
|
|
20242
20480
|
let json = false;
|
|
20243
|
-
const
|
|
20481
|
+
const takeSharedOptions4 = () => {
|
|
20244
20482
|
while (rest.length > 0) {
|
|
20245
20483
|
const token = rest[0];
|
|
20246
20484
|
if (token === "--base-url") {
|
|
@@ -20257,7 +20495,7 @@ function parseAppArgs(tokens) {
|
|
|
20257
20495
|
}
|
|
20258
20496
|
};
|
|
20259
20497
|
if (action === "list") {
|
|
20260
|
-
|
|
20498
|
+
takeSharedOptions4();
|
|
20261
20499
|
if (rest.length > 0) {
|
|
20262
20500
|
throw new Error(`Unknown app list option: ${rest[0]}`);
|
|
20263
20501
|
}
|
|
@@ -20270,7 +20508,7 @@ function parseAppArgs(tokens) {
|
|
|
20270
20508
|
`Usage: app ${action} <id> [--base-url <url>] [--json]`
|
|
20271
20509
|
);
|
|
20272
20510
|
}
|
|
20273
|
-
|
|
20511
|
+
takeSharedOptions4();
|
|
20274
20512
|
if (rest.length > 0) {
|
|
20275
20513
|
throw new Error(`Unknown app ${action} option: ${rest[0]}`);
|
|
20276
20514
|
}
|
|
@@ -20338,6 +20576,227 @@ function requireValue4(tokens, optionName) {
|
|
|
20338
20576
|
return value;
|
|
20339
20577
|
}
|
|
20340
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
|
+
|
|
20341
20800
|
// src/index.ts
|
|
20342
20801
|
var pkg = JSON.parse(
|
|
20343
20802
|
(0, import_node_fs15.readFileSync)(import_node_path20.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
@@ -20428,6 +20887,16 @@ var HELP_TEXT = [
|
|
|
20428
20887
|
` ${import_chalk3.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20429
20888
|
` ${import_chalk3.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
20430
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")}`,
|
|
20431
20900
|
` ${import_chalk3.default.cyan("store")} Manage @pmate/store namespaces, tables, and kv stores`,
|
|
20432
20901
|
` ${import_chalk3.default.gray(" namespace list [--chain <chain>] [--indexer-base-url <url>] [--json]")}`,
|
|
20433
20902
|
` ${import_chalk3.default.gray(" table list|get|exists|create|update|delete <name> [options]")}`,
|
|
@@ -20500,7 +20969,7 @@ function parseCommandArgs(args) {
|
|
|
20500
20969
|
const token = rest.shift();
|
|
20501
20970
|
switch (token) {
|
|
20502
20971
|
case "--app":
|
|
20503
|
-
app =
|
|
20972
|
+
app = requireValue7(rest, token);
|
|
20504
20973
|
break;
|
|
20505
20974
|
default:
|
|
20506
20975
|
throw new Error(`Unknown login option: ${token}`);
|
|
@@ -20568,6 +21037,12 @@ function parseCommandArgs(args) {
|
|
|
20568
21037
|
if (args.rest[0] === "ns" || args.rest[0] === "namespace") {
|
|
20569
21038
|
return parseNsArgs(args.rest.slice(1));
|
|
20570
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
|
+
}
|
|
20571
21046
|
if (args.rest[0] === "store") {
|
|
20572
21047
|
return parseStoreArgs(args.rest.slice(1));
|
|
20573
21048
|
}
|
|
@@ -20591,7 +21066,7 @@ function parseVercelArgs(tokens) {
|
|
|
20591
21066
|
const token = rest.shift();
|
|
20592
21067
|
switch (token) {
|
|
20593
21068
|
case "--scope":
|
|
20594
|
-
scope =
|
|
21069
|
+
scope = requireValue7(rest, token);
|
|
20595
21070
|
break;
|
|
20596
21071
|
default:
|
|
20597
21072
|
throw new Error(`Unknown vercel option: ${token}`);
|
|
@@ -20611,10 +21086,10 @@ function parseVercelArgs(tokens) {
|
|
|
20611
21086
|
const token = rest.shift();
|
|
20612
21087
|
switch (token) {
|
|
20613
21088
|
case "--scope":
|
|
20614
|
-
scope =
|
|
21089
|
+
scope = requireValue7(rest, token);
|
|
20615
21090
|
break;
|
|
20616
21091
|
case "--project":
|
|
20617
|
-
project =
|
|
21092
|
+
project = requireValue7(rest, token);
|
|
20618
21093
|
break;
|
|
20619
21094
|
case "--last-week":
|
|
20620
21095
|
lastWeek = true;
|
|
@@ -20645,16 +21120,16 @@ function parseAddDnsArgs(tokens) {
|
|
|
20645
21120
|
const token = rest.shift();
|
|
20646
21121
|
switch (token) {
|
|
20647
21122
|
case "--type":
|
|
20648
|
-
options.dnsType =
|
|
21123
|
+
options.dnsType = requireValue7(rest, token);
|
|
20649
21124
|
break;
|
|
20650
21125
|
case "--value":
|
|
20651
|
-
options.dnsValue =
|
|
21126
|
+
options.dnsValue = requireValue7(rest, token);
|
|
20652
21127
|
break;
|
|
20653
21128
|
case "--rr":
|
|
20654
|
-
options.dnsRr =
|
|
21129
|
+
options.dnsRr = requireValue7(rest, token);
|
|
20655
21130
|
break;
|
|
20656
21131
|
case "--ttl": {
|
|
20657
|
-
const ttlValue =
|
|
21132
|
+
const ttlValue = requireValue7(rest, token);
|
|
20658
21133
|
const ttl = Number.parseInt(ttlValue, 10);
|
|
20659
21134
|
if (!Number.isFinite(ttl) || ttl <= 0) {
|
|
20660
21135
|
throw new Error(`Invalid --ttl value: ${ttlValue}`);
|
|
@@ -20663,7 +21138,7 @@ function parseAddDnsArgs(tokens) {
|
|
|
20663
21138
|
break;
|
|
20664
21139
|
}
|
|
20665
21140
|
case "--domain":
|
|
20666
|
-
options.dnsDomain =
|
|
21141
|
+
options.dnsDomain = requireValue7(rest, token);
|
|
20667
21142
|
break;
|
|
20668
21143
|
default:
|
|
20669
21144
|
throw new Error(`Unknown add-dns option: ${token}`);
|
|
@@ -20696,13 +21171,13 @@ function parseBucketArgs(tokens) {
|
|
|
20696
21171
|
options.bucketCreate = true;
|
|
20697
21172
|
break;
|
|
20698
21173
|
case "--name":
|
|
20699
|
-
options.bucketName =
|
|
21174
|
+
options.bucketName = requireValue7(rest, token);
|
|
20700
21175
|
break;
|
|
20701
21176
|
case "--subdomain":
|
|
20702
|
-
options.bucketSubdomain =
|
|
21177
|
+
options.bucketSubdomain = requireValue7(rest, token);
|
|
20703
21178
|
break;
|
|
20704
21179
|
case "--domain":
|
|
20705
|
-
options.bucketDomain =
|
|
21180
|
+
options.bucketDomain = requireValue7(rest, token);
|
|
20706
21181
|
break;
|
|
20707
21182
|
default:
|
|
20708
21183
|
throw new Error(`Unknown bucket option: ${token}`);
|
|
@@ -20741,7 +21216,7 @@ function parseDeployArgs(tokens) {
|
|
|
20741
21216
|
options.deployAction = "logs";
|
|
20742
21217
|
break;
|
|
20743
21218
|
case "--cwd":
|
|
20744
|
-
options.deployCwd =
|
|
21219
|
+
options.deployCwd = requireValue7(rest, token);
|
|
20745
21220
|
break;
|
|
20746
21221
|
default:
|
|
20747
21222
|
throw new Error(`Unknown deploy option: ${token}`);
|
|
@@ -20766,13 +21241,13 @@ function parseLogArgs(tokens) {
|
|
|
20766
21241
|
const token = rest.shift();
|
|
20767
21242
|
switch (token) {
|
|
20768
21243
|
case "--cwd":
|
|
20769
|
-
options.logCwd =
|
|
21244
|
+
options.logCwd = requireValue7(rest, token);
|
|
20770
21245
|
break;
|
|
20771
21246
|
case "--ns":
|
|
20772
|
-
options.logNamespace =
|
|
21247
|
+
options.logNamespace = requireValue7(rest, token);
|
|
20773
21248
|
break;
|
|
20774
21249
|
case "--page": {
|
|
20775
|
-
const value =
|
|
21250
|
+
const value = requireValue7(rest, token);
|
|
20776
21251
|
const page = Number.parseInt(value, 10);
|
|
20777
21252
|
if (!Number.isFinite(page) || page < 0) {
|
|
20778
21253
|
throw new Error(`Invalid log page: ${value}`);
|
|
@@ -20784,7 +21259,7 @@ function parseLogArgs(tokens) {
|
|
|
20784
21259
|
options.logHistory = true;
|
|
20785
21260
|
break;
|
|
20786
21261
|
case "--search":
|
|
20787
|
-
options.logSearch =
|
|
21262
|
+
options.logSearch = requireValue7(rest, token);
|
|
20788
21263
|
break;
|
|
20789
21264
|
default:
|
|
20790
21265
|
throw new Error(`Unknown log option: ${token}`);
|
|
@@ -20807,7 +21282,7 @@ function parseInitArgs(tokens) {
|
|
|
20807
21282
|
const token = rest.shift();
|
|
20808
21283
|
switch (token) {
|
|
20809
21284
|
case "--cwd":
|
|
20810
|
-
options.initCwd =
|
|
21285
|
+
options.initCwd = requireValue7(rest, token);
|
|
20811
21286
|
break;
|
|
20812
21287
|
default:
|
|
20813
21288
|
throw new Error(`Unknown init option: ${token}`);
|
|
@@ -20830,7 +21305,7 @@ function parseDevArgs(tokens) {
|
|
|
20830
21305
|
const token = rest.shift();
|
|
20831
21306
|
switch (token) {
|
|
20832
21307
|
case "--cwd":
|
|
20833
|
-
options.devCwd =
|
|
21308
|
+
options.devCwd = requireValue7(rest, token);
|
|
20834
21309
|
break;
|
|
20835
21310
|
default:
|
|
20836
21311
|
throw new Error(`Unknown dev option: ${token}`);
|
|
@@ -20860,13 +21335,13 @@ function parseOssArgs(tokens) {
|
|
|
20860
21335
|
const token = rest.shift();
|
|
20861
21336
|
switch (token) {
|
|
20862
21337
|
case "--bucket":
|
|
20863
|
-
bucket =
|
|
21338
|
+
bucket = requireValue7(rest, token);
|
|
20864
21339
|
break;
|
|
20865
21340
|
case "--file":
|
|
20866
|
-
filePath =
|
|
21341
|
+
filePath = requireValue7(rest, token);
|
|
20867
21342
|
break;
|
|
20868
21343
|
case "--key":
|
|
20869
|
-
objectKey =
|
|
21344
|
+
objectKey = requireValue7(rest, token);
|
|
20870
21345
|
break;
|
|
20871
21346
|
default:
|
|
20872
21347
|
throw new Error(`Unknown oss option: ${token}`);
|
|
@@ -20899,7 +21374,7 @@ function parseEnvArgs(tokens) {
|
|
|
20899
21374
|
throw new Error("Only one env action is allowed.");
|
|
20900
21375
|
}
|
|
20901
21376
|
action = "set";
|
|
20902
|
-
key =
|
|
21377
|
+
key = requireValue7(rest, token);
|
|
20903
21378
|
break;
|
|
20904
21379
|
case "--list":
|
|
20905
21380
|
if (action) {
|
|
@@ -20912,17 +21387,17 @@ function parseEnvArgs(tokens) {
|
|
|
20912
21387
|
throw new Error("Only one env action is allowed.");
|
|
20913
21388
|
}
|
|
20914
21389
|
action = "delete";
|
|
20915
|
-
key =
|
|
21390
|
+
key = requireValue7(rest, token);
|
|
20916
21391
|
break;
|
|
20917
21392
|
case "--value":
|
|
20918
|
-
value =
|
|
21393
|
+
value = requireValue7(rest, token);
|
|
20919
21394
|
break;
|
|
20920
21395
|
case "--verbose":
|
|
20921
21396
|
case "-v":
|
|
20922
21397
|
verbose = true;
|
|
20923
21398
|
break;
|
|
20924
21399
|
case "--cwd":
|
|
20925
|
-
cwd =
|
|
21400
|
+
cwd = requireValue7(rest, token);
|
|
20926
21401
|
break;
|
|
20927
21402
|
default:
|
|
20928
21403
|
throw new Error(`Unknown env option: ${token}`);
|
|
@@ -20980,7 +21455,7 @@ function parseCommitArgs(tokens) {
|
|
|
20980
21455
|
push = true;
|
|
20981
21456
|
break;
|
|
20982
21457
|
case "--cwd":
|
|
20983
|
-
cwd =
|
|
21458
|
+
cwd = requireValue7(rest, token);
|
|
20984
21459
|
break;
|
|
20985
21460
|
default:
|
|
20986
21461
|
throw new Error(`Unknown commit option: ${token}`);
|
|
@@ -20996,10 +21471,10 @@ function parseSummaryArgs(tokens) {
|
|
|
20996
21471
|
const token = rest.shift();
|
|
20997
21472
|
switch (token) {
|
|
20998
21473
|
case "--pr":
|
|
20999
|
-
prRef =
|
|
21474
|
+
prRef = requireValue7(rest, token);
|
|
21000
21475
|
break;
|
|
21001
21476
|
case "--cwd":
|
|
21002
|
-
cwd =
|
|
21477
|
+
cwd = requireValue7(rest, token);
|
|
21003
21478
|
break;
|
|
21004
21479
|
default:
|
|
21005
21480
|
throw new Error(`Unknown summary option: ${token}`);
|
|
@@ -21068,10 +21543,10 @@ function parseLinearPrArgs(tokens) {
|
|
|
21068
21543
|
const token = rest.shift();
|
|
21069
21544
|
switch (token) {
|
|
21070
21545
|
case "--account":
|
|
21071
|
-
account =
|
|
21546
|
+
account = requireValue7(rest, token);
|
|
21072
21547
|
break;
|
|
21073
21548
|
case "--cwd":
|
|
21074
|
-
cwd =
|
|
21549
|
+
cwd = requireValue7(rest, token);
|
|
21075
21550
|
break;
|
|
21076
21551
|
default:
|
|
21077
21552
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21100,35 +21575,35 @@ function parseLinearCreateArgs(tokens) {
|
|
|
21100
21575
|
const token = rest.shift();
|
|
21101
21576
|
switch (token) {
|
|
21102
21577
|
case "--account":
|
|
21103
|
-
account =
|
|
21578
|
+
account = requireValue7(rest, token);
|
|
21104
21579
|
break;
|
|
21105
21580
|
case "--repl":
|
|
21106
21581
|
useRepl = true;
|
|
21107
21582
|
break;
|
|
21108
21583
|
case "--title":
|
|
21109
|
-
title =
|
|
21584
|
+
title = requireValue7(rest, token);
|
|
21110
21585
|
break;
|
|
21111
21586
|
case "--desc":
|
|
21112
21587
|
case "--description":
|
|
21113
|
-
description = decodeEscapedNewlines(
|
|
21588
|
+
description = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21114
21589
|
break;
|
|
21115
21590
|
case "--team-id":
|
|
21116
|
-
teamId =
|
|
21591
|
+
teamId = requireValue7(rest, token);
|
|
21117
21592
|
break;
|
|
21118
21593
|
case "--team-key":
|
|
21119
|
-
teamKey =
|
|
21594
|
+
teamKey = requireValue7(rest, token);
|
|
21120
21595
|
break;
|
|
21121
21596
|
case "--priority":
|
|
21122
|
-
priority = parseLinearPriority(
|
|
21597
|
+
priority = parseLinearPriority(requireValue7(rest, token));
|
|
21123
21598
|
break;
|
|
21124
21599
|
case "--parent-id":
|
|
21125
|
-
parentId =
|
|
21600
|
+
parentId = requireValue7(rest, token);
|
|
21126
21601
|
break;
|
|
21127
21602
|
case "--state-id":
|
|
21128
|
-
stateId =
|
|
21603
|
+
stateId = requireValue7(rest, token);
|
|
21129
21604
|
break;
|
|
21130
21605
|
case "--cwd":
|
|
21131
|
-
cwd =
|
|
21606
|
+
cwd = requireValue7(rest, token);
|
|
21132
21607
|
break;
|
|
21133
21608
|
default:
|
|
21134
21609
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21163,10 +21638,10 @@ function parseLinearWhoamiArgs(tokens) {
|
|
|
21163
21638
|
const token = rest.shift();
|
|
21164
21639
|
switch (token) {
|
|
21165
21640
|
case "--account":
|
|
21166
|
-
account =
|
|
21641
|
+
account = requireValue7(rest, token);
|
|
21167
21642
|
break;
|
|
21168
21643
|
case "--cwd":
|
|
21169
|
-
cwd =
|
|
21644
|
+
cwd = requireValue7(rest, token);
|
|
21170
21645
|
break;
|
|
21171
21646
|
default:
|
|
21172
21647
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21191,10 +21666,10 @@ function parseLinearViewArgs(tokens) {
|
|
|
21191
21666
|
const token = rest.shift();
|
|
21192
21667
|
switch (token) {
|
|
21193
21668
|
case "--account":
|
|
21194
|
-
account =
|
|
21669
|
+
account = requireValue7(rest, token);
|
|
21195
21670
|
break;
|
|
21196
21671
|
case "--cwd":
|
|
21197
|
-
cwd =
|
|
21672
|
+
cwd = requireValue7(rest, token);
|
|
21198
21673
|
break;
|
|
21199
21674
|
default:
|
|
21200
21675
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21229,32 +21704,32 @@ function parseLinearUpdateArgs(tokens) {
|
|
|
21229
21704
|
const token = rest.shift();
|
|
21230
21705
|
switch (token) {
|
|
21231
21706
|
case "--account":
|
|
21232
|
-
account =
|
|
21707
|
+
account = requireValue7(rest, token);
|
|
21233
21708
|
break;
|
|
21234
21709
|
case "--title":
|
|
21235
|
-
title =
|
|
21710
|
+
title = requireValue7(rest, token);
|
|
21236
21711
|
break;
|
|
21237
21712
|
case "--desc":
|
|
21238
21713
|
case "--description":
|
|
21239
|
-
description = decodeEscapedNewlines(
|
|
21714
|
+
description = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21240
21715
|
break;
|
|
21241
21716
|
case "--team-id":
|
|
21242
|
-
teamId =
|
|
21717
|
+
teamId = requireValue7(rest, token);
|
|
21243
21718
|
break;
|
|
21244
21719
|
case "--team-key":
|
|
21245
|
-
teamKey =
|
|
21720
|
+
teamKey = requireValue7(rest, token);
|
|
21246
21721
|
break;
|
|
21247
21722
|
case "--priority":
|
|
21248
|
-
priority = parseLinearPriority(
|
|
21723
|
+
priority = parseLinearPriority(requireValue7(rest, token));
|
|
21249
21724
|
break;
|
|
21250
21725
|
case "--parent-id":
|
|
21251
|
-
parentId =
|
|
21726
|
+
parentId = requireValue7(rest, token);
|
|
21252
21727
|
break;
|
|
21253
21728
|
case "--state-id":
|
|
21254
|
-
stateId =
|
|
21729
|
+
stateId = requireValue7(rest, token);
|
|
21255
21730
|
break;
|
|
21256
21731
|
case "--cwd":
|
|
21257
|
-
cwd =
|
|
21732
|
+
cwd = requireValue7(rest, token);
|
|
21258
21733
|
break;
|
|
21259
21734
|
default:
|
|
21260
21735
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21292,10 +21767,10 @@ function parseLinearSubIssuesArgs(tokens) {
|
|
|
21292
21767
|
const token = rest.shift();
|
|
21293
21768
|
switch (token) {
|
|
21294
21769
|
case "--account":
|
|
21295
|
-
account =
|
|
21770
|
+
account = requireValue7(rest, token);
|
|
21296
21771
|
break;
|
|
21297
21772
|
case "--cwd":
|
|
21298
|
-
cwd =
|
|
21773
|
+
cwd = requireValue7(rest, token);
|
|
21299
21774
|
break;
|
|
21300
21775
|
default:
|
|
21301
21776
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21322,15 +21797,15 @@ function parseLinearCommentArgs(tokens) {
|
|
|
21322
21797
|
const token = rest.shift();
|
|
21323
21798
|
switch (token) {
|
|
21324
21799
|
case "--account":
|
|
21325
|
-
account =
|
|
21800
|
+
account = requireValue7(rest, token);
|
|
21326
21801
|
break;
|
|
21327
21802
|
case "--body":
|
|
21328
21803
|
case "--desc":
|
|
21329
21804
|
case "--description":
|
|
21330
|
-
body = decodeEscapedNewlines(
|
|
21805
|
+
body = decodeEscapedNewlines(requireValue7(rest, token));
|
|
21331
21806
|
break;
|
|
21332
21807
|
case "--cwd":
|
|
21333
|
-
cwd =
|
|
21808
|
+
cwd = requireValue7(rest, token);
|
|
21334
21809
|
break;
|
|
21335
21810
|
default:
|
|
21336
21811
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21360,10 +21835,10 @@ function parseLinearCommentsArgs(tokens) {
|
|
|
21360
21835
|
const token = rest.shift();
|
|
21361
21836
|
switch (token) {
|
|
21362
21837
|
case "--account":
|
|
21363
|
-
account =
|
|
21838
|
+
account = requireValue7(rest, token);
|
|
21364
21839
|
break;
|
|
21365
21840
|
case "--cwd":
|
|
21366
|
-
cwd =
|
|
21841
|
+
cwd = requireValue7(rest, token);
|
|
21367
21842
|
break;
|
|
21368
21843
|
default:
|
|
21369
21844
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21387,16 +21862,16 @@ function parseLinearCycleArgs(tokens) {
|
|
|
21387
21862
|
const token = rest.shift();
|
|
21388
21863
|
switch (token) {
|
|
21389
21864
|
case "--account":
|
|
21390
|
-
account =
|
|
21865
|
+
account = requireValue7(rest, token);
|
|
21391
21866
|
break;
|
|
21392
21867
|
case "--team-id":
|
|
21393
|
-
teamId =
|
|
21868
|
+
teamId = requireValue7(rest, token);
|
|
21394
21869
|
break;
|
|
21395
21870
|
case "--team-key":
|
|
21396
|
-
teamKey =
|
|
21871
|
+
teamKey = requireValue7(rest, token);
|
|
21397
21872
|
break;
|
|
21398
21873
|
case "--cwd":
|
|
21399
|
-
cwd =
|
|
21874
|
+
cwd = requireValue7(rest, token);
|
|
21400
21875
|
break;
|
|
21401
21876
|
default:
|
|
21402
21877
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21419,10 +21894,10 @@ function parseLinearTeamsArgs(tokens) {
|
|
|
21419
21894
|
const token = rest.shift();
|
|
21420
21895
|
switch (token) {
|
|
21421
21896
|
case "--account":
|
|
21422
|
-
account =
|
|
21897
|
+
account = requireValue7(rest, token);
|
|
21423
21898
|
break;
|
|
21424
21899
|
case "--cwd":
|
|
21425
|
-
cwd =
|
|
21900
|
+
cwd = requireValue7(rest, token);
|
|
21426
21901
|
break;
|
|
21427
21902
|
default:
|
|
21428
21903
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21449,16 +21924,16 @@ function parseLinearUserIssuesArgs(tokens) {
|
|
|
21449
21924
|
const token = rest.shift();
|
|
21450
21925
|
switch (token) {
|
|
21451
21926
|
case "--account":
|
|
21452
|
-
account =
|
|
21927
|
+
account = requireValue7(rest, token);
|
|
21453
21928
|
break;
|
|
21454
21929
|
case "--cycle":
|
|
21455
|
-
cycle = parseLinearCycle(
|
|
21930
|
+
cycle = parseLinearCycle(requireValue7(rest, token));
|
|
21456
21931
|
break;
|
|
21457
21932
|
case "--status":
|
|
21458
|
-
status = parseLinearStatus(
|
|
21933
|
+
status = parseLinearStatus(requireValue7(rest, token));
|
|
21459
21934
|
break;
|
|
21460
21935
|
case "--cwd":
|
|
21461
|
-
cwd =
|
|
21936
|
+
cwd = requireValue7(rest, token);
|
|
21462
21937
|
break;
|
|
21463
21938
|
default:
|
|
21464
21939
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21492,28 +21967,28 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21492
21967
|
const token = rest.shift();
|
|
21493
21968
|
switch (token) {
|
|
21494
21969
|
case "--account":
|
|
21495
|
-
account =
|
|
21970
|
+
account = requireValue7(rest, token);
|
|
21496
21971
|
break;
|
|
21497
21972
|
case "--team-id":
|
|
21498
|
-
teamId =
|
|
21973
|
+
teamId = requireValue7(rest, token);
|
|
21499
21974
|
break;
|
|
21500
21975
|
case "--team-key":
|
|
21501
|
-
teamKey =
|
|
21976
|
+
teamKey = requireValue7(rest, token);
|
|
21502
21977
|
break;
|
|
21503
21978
|
case "--user":
|
|
21504
|
-
user =
|
|
21979
|
+
user = requireValue7(rest, token);
|
|
21505
21980
|
break;
|
|
21506
21981
|
case "--cycle":
|
|
21507
|
-
cycle = parseLinearCycle(
|
|
21982
|
+
cycle = parseLinearCycle(requireValue7(rest, token));
|
|
21508
21983
|
break;
|
|
21509
21984
|
case "--status":
|
|
21510
|
-
status = parseLinearStatus(
|
|
21985
|
+
status = parseLinearStatus(requireValue7(rest, token));
|
|
21511
21986
|
break;
|
|
21512
21987
|
case "--query":
|
|
21513
|
-
query =
|
|
21988
|
+
query = requireValue7(rest, token).trim();
|
|
21514
21989
|
break;
|
|
21515
21990
|
case "--limit": {
|
|
21516
|
-
const value = Number.parseInt(
|
|
21991
|
+
const value = Number.parseInt(requireValue7(rest, token), 10);
|
|
21517
21992
|
if (!Number.isInteger(value) || value < 1 || value > 250) {
|
|
21518
21993
|
throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
|
|
21519
21994
|
}
|
|
@@ -21521,7 +21996,7 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
21521
21996
|
break;
|
|
21522
21997
|
}
|
|
21523
21998
|
case "--cwd":
|
|
21524
|
-
cwd =
|
|
21999
|
+
cwd = requireValue7(rest, token);
|
|
21525
22000
|
break;
|
|
21526
22001
|
default:
|
|
21527
22002
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21562,10 +22037,10 @@ function parseLinearLegacyArgs(tokens) {
|
|
|
21562
22037
|
useScreenshot = true;
|
|
21563
22038
|
break;
|
|
21564
22039
|
case "--account":
|
|
21565
|
-
account =
|
|
22040
|
+
account = requireValue7(rest, token);
|
|
21566
22041
|
break;
|
|
21567
22042
|
case "--cwd":
|
|
21568
|
-
cwd =
|
|
22043
|
+
cwd = requireValue7(rest, token);
|
|
21569
22044
|
break;
|
|
21570
22045
|
default:
|
|
21571
22046
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -21659,19 +22134,19 @@ function parseNotionArgs(tokens) {
|
|
|
21659
22134
|
const token = rest.shift();
|
|
21660
22135
|
switch (token) {
|
|
21661
22136
|
case "--parent":
|
|
21662
|
-
parentPageId =
|
|
22137
|
+
parentPageId = requireValue7(rest, token);
|
|
21663
22138
|
break;
|
|
21664
22139
|
case "--title":
|
|
21665
|
-
title =
|
|
22140
|
+
title = requireValue7(rest, token);
|
|
21666
22141
|
break;
|
|
21667
22142
|
case "--private":
|
|
21668
22143
|
isPrivate = true;
|
|
21669
22144
|
break;
|
|
21670
22145
|
case "--content":
|
|
21671
|
-
content2 =
|
|
22146
|
+
content2 = requireValue7(rest, token);
|
|
21672
22147
|
break;
|
|
21673
22148
|
case "--file":
|
|
21674
|
-
filePath2 =
|
|
22149
|
+
filePath2 = requireValue7(rest, token);
|
|
21675
22150
|
break;
|
|
21676
22151
|
default:
|
|
21677
22152
|
throw new Error(`Unknown notion option: ${token}`);
|
|
@@ -21715,10 +22190,10 @@ function parseNotionArgs(tokens) {
|
|
|
21715
22190
|
const token = rest.shift();
|
|
21716
22191
|
switch (token) {
|
|
21717
22192
|
case "--content":
|
|
21718
|
-
content =
|
|
22193
|
+
content = requireValue7(rest, token);
|
|
21719
22194
|
break;
|
|
21720
22195
|
case "--file":
|
|
21721
|
-
filePath =
|
|
22196
|
+
filePath = requireValue7(rest, token);
|
|
21722
22197
|
break;
|
|
21723
22198
|
case "--append":
|
|
21724
22199
|
append = true;
|
|
@@ -21763,11 +22238,11 @@ function parseRandomArgs(tokens) {
|
|
|
21763
22238
|
mode = "easy";
|
|
21764
22239
|
break;
|
|
21765
22240
|
case "--length":
|
|
21766
|
-
length = parsePositiveInt(
|
|
22241
|
+
length = parsePositiveInt(requireValue7(rest, token), token);
|
|
21767
22242
|
seenLength = true;
|
|
21768
22243
|
break;
|
|
21769
22244
|
case "--charset": {
|
|
21770
|
-
const value =
|
|
22245
|
+
const value = requireValue7(rest, token);
|
|
21771
22246
|
if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
|
|
21772
22247
|
throw new Error(
|
|
21773
22248
|
`Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
|
|
@@ -21778,18 +22253,18 @@ function parseRandomArgs(tokens) {
|
|
|
21778
22253
|
break;
|
|
21779
22254
|
}
|
|
21780
22255
|
case "--count":
|
|
21781
|
-
count = parsePositiveInt(
|
|
22256
|
+
count = parsePositiveInt(requireValue7(rest, token), token);
|
|
21782
22257
|
break;
|
|
21783
22258
|
case "--words":
|
|
21784
|
-
words = parsePositiveInt(
|
|
22259
|
+
words = parsePositiveInt(requireValue7(rest, token), token);
|
|
21785
22260
|
seenWords = true;
|
|
21786
22261
|
break;
|
|
21787
22262
|
case "--digits":
|
|
21788
|
-
digits = parseNonNegativeInt(
|
|
22263
|
+
digits = parseNonNegativeInt(requireValue7(rest, token), token);
|
|
21789
22264
|
seenDigits = true;
|
|
21790
22265
|
break;
|
|
21791
22266
|
case "--separator":
|
|
21792
|
-
separator =
|
|
22267
|
+
separator = requireValue7(rest, token);
|
|
21793
22268
|
seenSeparator = true;
|
|
21794
22269
|
break;
|
|
21795
22270
|
default:
|
|
@@ -21832,7 +22307,7 @@ function parseCollectArgs(tokens) {
|
|
|
21832
22307
|
const token = rest.shift();
|
|
21833
22308
|
switch (token) {
|
|
21834
22309
|
case "--endpoint":
|
|
21835
|
-
options.endpoint =
|
|
22310
|
+
options.endpoint = requireValue7(rest, token);
|
|
21836
22311
|
break;
|
|
21837
22312
|
case "--json":
|
|
21838
22313
|
options.json = true;
|
|
@@ -21842,7 +22317,7 @@ function parseCollectArgs(tokens) {
|
|
|
21842
22317
|
break;
|
|
21843
22318
|
case "--thread":
|
|
21844
22319
|
options.mode = "thread";
|
|
21845
|
-
options.threadName =
|
|
22320
|
+
options.threadName = requireValue7(rest, token);
|
|
21846
22321
|
break;
|
|
21847
22322
|
default:
|
|
21848
22323
|
throw new Error(`Unknown collect option: ${token}`);
|
|
@@ -21853,7 +22328,7 @@ function parseCollectArgs(tokens) {
|
|
|
21853
22328
|
}
|
|
21854
22329
|
return { type: "collect" /* Collect */, ...options };
|
|
21855
22330
|
}
|
|
21856
|
-
function
|
|
22331
|
+
function requireValue7(tokens, optionName) {
|
|
21857
22332
|
const value = tokens.shift();
|
|
21858
22333
|
if (!value) {
|
|
21859
22334
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -21999,6 +22474,16 @@ async function main() {
|
|
|
21999
22474
|
await handler.handle(commandArgs);
|
|
22000
22475
|
return;
|
|
22001
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
|
+
}
|
|
22002
22487
|
case "store" /* Store */: {
|
|
22003
22488
|
const handler = new StoreCommandHandler();
|
|
22004
22489
|
await handler.handle(commandArgs);
|