@pmate/cli 0.18.0 → 0.20.0

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 CHANGED
@@ -139,6 +139,16 @@ type QuizCommandArgs = {
139
139
  paperId: string;
140
140
  apiBaseUrl?: string;
141
141
  linkBaseUrl?: string;
142
+ } | {
143
+ type: Command.Quiz;
144
+ action: "edit-step";
145
+ paperId: string;
146
+ stepId: string;
147
+ filePath: string;
148
+ newPaperId?: string;
149
+ apiBaseUrl?: string;
150
+ linkBaseUrl?: string;
151
+ activate: boolean;
142
152
  };
143
153
  type LinearPrCommandArgs = {
144
154
  type: Command.Linear;
package/dist/index.js CHANGED
@@ -34,24 +34,94 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  ));
35
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
36
 
37
+ // src/namespacedRef.ts
38
+ function parseNamespacedRef(value, options = {}) {
39
+ const raw = value.trim();
40
+ const entityLabel = options.entityLabel || "ref";
41
+ if (!raw) {
42
+ throw new Error(`Invalid ${entityLabel}.`);
43
+ }
44
+ const colonIndex = raw.indexOf(":");
45
+ if (colonIndex > 0) {
46
+ const namespace2 = raw.slice(0, colonIndex).trim();
47
+ const objectId = raw.slice(colonIndex + 1).trim();
48
+ if (!namespace2 || !objectId) {
49
+ throw new Error(`Invalid ${entityLabel} "${value}". Use <ns:objectId>.`);
50
+ }
51
+ return {
52
+ namespace: namespace2,
53
+ objectId,
54
+ fullId: `${namespace2}:${objectId}`
55
+ };
56
+ }
57
+ const namespace = options.defaultNamespace?.trim();
58
+ if (namespace) {
59
+ return {
60
+ namespace,
61
+ objectId: raw,
62
+ fullId: `${namespace}:${raw}`
63
+ };
64
+ }
65
+ throw new Error(`Invalid ${entityLabel} "${value}". Use <ns:objectId>.`);
66
+ }
67
+ function composeNamespacedRef(namespace, objectId) {
68
+ const normalizedNamespace = namespace.trim();
69
+ const normalizedObjectId = objectId.trim();
70
+ return `${normalizedNamespace}:${normalizedObjectId}`;
71
+ }
72
+ function formatNamespacedDisplayId(namespace, objectIdOrFullId) {
73
+ const raw = objectIdOrFullId.trim();
74
+ if (raw.includes(":")) {
75
+ return raw;
76
+ }
77
+ const ns = namespace?.trim();
78
+ if (!ns) {
79
+ return raw;
80
+ }
81
+ return composeNamespacedRef(ns, raw);
82
+ }
83
+ var init_namespacedRef = __esm({
84
+ "src/namespacedRef.ts"() {
85
+ "use strict";
86
+ }
87
+ });
88
+
37
89
  // src/sessionStore.ts
38
90
  function buildSessionStorePath() {
39
91
  return import_node_path3.default.join(import_node_os2.default.homedir(), ".pmate", "session.json");
40
92
  }
93
+ function assertValidAppRef(appRef) {
94
+ return parseNamespacedRef(appRef, { entityLabel: "app ref" }).fullId;
95
+ }
41
96
  function saveLoginSession(session, requestedApp = DEFAULT_APP_ID) {
42
97
  const store = loadExistingSessionStoreOrEmpty();
43
- const app = resolveStoredAppId(session, requestedApp);
98
+ const app = assertValidAppRef(requestedApp);
99
+ const sessionApp = session.session?.app?.trim();
100
+ if (!sessionApp) {
101
+ throw new Error("Missing app in login session payload.");
102
+ }
103
+ const normalizedSessionApp = assertValidAppRef(sessionApp);
104
+ if (normalizedSessionApp !== app) {
105
+ throw new Error(
106
+ `Session app mismatch. requested=${app}, received=${normalizedSessionApp}`
107
+ );
108
+ }
109
+ const accountId = session.session.identity?.accountId?.trim();
110
+ const token = session.token?.trim();
111
+ const issuedAt = session.session.issuedAt?.trim();
112
+ const expiresAt = session.session.expiresAt?.trim();
113
+ if (!accountId || !token || !issuedAt || !expiresAt) {
114
+ throw new Error("Invalid login session payload.");
115
+ }
44
116
  const nextSession = {
45
- ...session,
46
- app,
47
- session: {
48
- ...session.session,
49
- ...session.session.app ? {} : { app }
50
- },
117
+ token,
118
+ accountId,
119
+ issuedAt,
120
+ expiresAt,
51
121
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
52
122
  };
53
123
  store.sessions[app] = nextSession;
54
- store.activeApp = app;
124
+ store.activeAppRef = app;
55
125
  writeSessionStore(store);
56
126
  return {
57
127
  app,
@@ -67,7 +137,9 @@ function readRequiredSession(options) {
67
137
  }
68
138
  const token = session.token?.trim();
69
139
  if (!token) {
70
- throw new Error(`Missing token in ${sessionPath}. Run "pmate login --app ${resolvedApp}" again.`);
140
+ throw new Error(
141
+ `Missing token in ${sessionPath}. Run "pmate login --app ${resolvedApp}" again.`
142
+ );
71
143
  }
72
144
  return {
73
145
  ...session,
@@ -82,7 +154,7 @@ function loadExistingSessionStoreOrEmpty() {
82
154
  if (!(0, import_node_fs2.existsSync)(sessionPath)) {
83
155
  return {
84
156
  version: SESSION_STORE_VERSION,
85
- activeApp: DEFAULT_APP_ID,
157
+ activeAppRef: DEFAULT_APP_ID,
86
158
  sessions: {}
87
159
  };
88
160
  }
@@ -104,31 +176,74 @@ function normalizeStore(value) {
104
176
  `Invalid session store format in ${buildSessionStorePath()}. Run "pmate login" again.`
105
177
  );
106
178
  }
107
- return {
108
- version: SESSION_STORE_VERSION,
109
- activeApp: value.activeApp || DEFAULT_APP_ID,
110
- sessions: value.sessions || {}
111
- };
179
+ return value;
112
180
  }
113
181
  function isSessionStore(value) {
114
- return !!value && typeof value === "object" && "version" in value && "sessions" in value && typeof value.sessions === "object";
182
+ if (!value || typeof value !== "object") {
183
+ return false;
184
+ }
185
+ const candidate = value;
186
+ if (candidate.version !== SESSION_STORE_VERSION) {
187
+ return false;
188
+ }
189
+ if (typeof candidate.activeAppRef !== "string") {
190
+ return false;
191
+ }
192
+ let normalizedActiveApp;
193
+ try {
194
+ normalizedActiveApp = assertValidAppRef(candidate.activeAppRef);
195
+ } catch {
196
+ return false;
197
+ }
198
+ if (normalizedActiveApp !== candidate.activeAppRef) {
199
+ return false;
200
+ }
201
+ if (!candidate.sessions || typeof candidate.sessions !== "object") {
202
+ return false;
203
+ }
204
+ if (!(normalizedActiveApp in candidate.sessions)) {
205
+ return false;
206
+ }
207
+ for (const [appRef, session] of Object.entries(candidate.sessions)) {
208
+ try {
209
+ if (assertValidAppRef(appRef) !== appRef) {
210
+ return false;
211
+ }
212
+ } catch {
213
+ return false;
214
+ }
215
+ if (!isStoredSession(session)) {
216
+ return false;
217
+ }
218
+ }
219
+ return true;
115
220
  }
116
- function resolveStoredAppId(session, fallbackApp) {
117
- return session.session?.app?.trim() || session.app?.trim() || fallbackApp.trim() || DEFAULT_APP_ID;
221
+ function isStoredSession(value) {
222
+ if (!value || typeof value !== "object") {
223
+ return false;
224
+ }
225
+ const session = value;
226
+ return typeof session.token === "string" && !!session.token.trim() && typeof session.accountId === "string" && !!session.accountId.trim() && typeof session.issuedAt === "string" && !!session.issuedAt.trim() && typeof session.expiresAt === "string" && !!session.expiresAt.trim() && typeof session.updatedAt === "string" && !!session.updatedAt.trim();
118
227
  }
119
228
  function resolveReadApp(store, options) {
120
229
  const requestedApp = options?.app?.trim();
121
230
  if (requestedApp) {
122
- return requestedApp;
231
+ return assertValidAppRef(requestedApp);
123
232
  }
124
233
  const preferredApp = options?.preferredApp?.trim();
125
- if (preferredApp && store.sessions[preferredApp]) {
126
- return preferredApp;
234
+ if (preferredApp) {
235
+ const normalizedPreferred = assertValidAppRef(preferredApp);
236
+ if (store.sessions[normalizedPreferred]) {
237
+ return normalizedPreferred;
238
+ }
127
239
  }
128
- if (options?.fallbackToActiveApp && store.activeApp && store.sessions[store.activeApp]) {
129
- return store.activeApp;
240
+ if (options?.fallbackToActiveApp && store.sessions[store.activeAppRef]) {
241
+ return store.activeAppRef;
130
242
  }
131
- return preferredApp || store.activeApp || DEFAULT_APP_ID;
243
+ if (preferredApp) {
244
+ return assertValidAppRef(preferredApp);
245
+ }
246
+ return store.activeAppRef;
132
247
  }
133
248
  function writeSessionStore(store) {
134
249
  const sessionPath = buildSessionStorePath();
@@ -154,8 +269,9 @@ var init_sessionStore = __esm({
154
269
  import_node_fs2 = require("fs");
155
270
  import_node_os2 = __toESM(require("os"));
156
271
  import_node_path3 = __toESM(require("path"));
157
- DEFAULT_APP_ID = "@pmate/cli";
158
- SESSION_STORE_VERSION = 2;
272
+ init_namespacedRef();
273
+ DEFAULT_APP_ID = "pmate:cli";
274
+ SESSION_STORE_VERSION = 3;
159
275
  }
160
276
  });
161
277
 
@@ -13025,23 +13141,24 @@ var ListCommandHandler = class {
13025
13141
  };
13026
13142
 
13027
13143
  // src/commands/LoginCommandHandler.ts
13028
- var import_node_http = require("http");
13029
13144
  var import_node_child_process = require("child_process");
13145
+ var import_node_http = require("http");
13030
13146
  init_sessionStore();
13031
13147
  var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
13032
13148
  var AUTH_API_BASE_URL = "https://auth-api-v2.pmate.chat";
13033
13149
  var CALLBACK_PATH = "/pmate-login-callback";
13034
13150
  var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
13035
13151
  function buildHostedLoginUrl(redirectUrl, appId = DEFAULT_APP_ID) {
13152
+ const resolvedApp = assertValidAppRef(appId);
13036
13153
  const url = new URL(AUTH_UI_BASE_URL);
13037
13154
  url.searchParams.set("redirect", redirectUrl);
13038
- url.searchParams.set("app", appId);
13155
+ url.searchParams.set("app", resolvedApp);
13039
13156
  return url.toString();
13040
13157
  }
13041
13158
  var LoginCommandHandler = class {
13042
13159
  async handle(args) {
13043
13160
  const callback = await this.startCallbackServer();
13044
- const appId = args.app?.trim() || DEFAULT_APP_ID;
13161
+ const appId = assertValidAppRef(args.app?.trim() || DEFAULT_APP_ID);
13045
13162
  const loginUrl = buildHostedLoginUrl(callback.redirectUrl, appId);
13046
13163
  let savedSession = null;
13047
13164
  ui.info("Opening browser for login.", {
@@ -13058,7 +13175,7 @@ var LoginCommandHandler = class {
13058
13175
  });
13059
13176
  try {
13060
13177
  const token = await callback.waitForToken;
13061
- const loginResponse = await this.fetchSession(token, appId);
13178
+ const loginResponse = await this.exchangeSession(token, appId);
13062
13179
  savedSession = saveLoginSession(loginResponse, appId);
13063
13180
  } finally {
13064
13181
  await callback.close();
@@ -13069,26 +13186,26 @@ var LoginCommandHandler = class {
13069
13186
  );
13070
13187
  }
13071
13188
  }
13072
- async fetchSession(token, appId) {
13073
- const url = new URL(`${AUTH_API_BASE_URL}/session`);
13074
- url.searchParams.set("app", appId);
13075
- const response = await fetch(url.toString(), {
13076
- method: "GET",
13189
+ async exchangeSession(token, appId) {
13190
+ const response = await fetch(`${AUTH_API_BASE_URL}/session/exchange`, {
13191
+ method: "POST",
13077
13192
  headers: {
13193
+ "Content-Type": "application/json",
13078
13194
  Authorization: `Bearer ${token}`
13079
- }
13195
+ },
13196
+ body: JSON.stringify({ app: appId })
13080
13197
  });
13081
13198
  if (!response.ok) {
13082
13199
  const detail = await response.text();
13083
13200
  throw new Error(
13084
- `Failed to validate session (${response.status}): ${detail || response.statusText}`
13201
+ `Failed to exchange app session (${response.status}): ${detail || response.statusText}`
13085
13202
  );
13086
13203
  }
13087
13204
  const resp = await response.json();
13088
- return {
13089
- ...resp.data,
13090
- token
13091
- };
13205
+ if (!resp?.data?.session?.app || resp.data.session.app !== appId) {
13206
+ throw new Error("Invalid exchange response: app-scoped session mismatch.");
13207
+ }
13208
+ return resp.data;
13092
13209
  }
13093
13210
  async startCallbackServer() {
13094
13211
  let resolveToken;
@@ -18097,6 +18214,26 @@ async function viewQuizPaper({
18097
18214
  data
18098
18215
  };
18099
18216
  }
18217
+ async function getQuizPaper({
18218
+ fetchImpl = fetch,
18219
+ apiBaseUrl,
18220
+ linkBaseUrl,
18221
+ paperId,
18222
+ token
18223
+ }) {
18224
+ const viewed = await viewQuizPaper({
18225
+ fetchImpl,
18226
+ apiBaseUrl,
18227
+ linkBaseUrl,
18228
+ paperId,
18229
+ token
18230
+ });
18231
+ const paper = viewed.data;
18232
+ if (!paper || !Array.isArray(paper.steps)) {
18233
+ throw new Error("\u67E5\u770B\u8BD5\u5377\u5931\u8D25\uFF1A\u8FD4\u56DE\u6570\u636E\u4E0D\u5305\u542B\u6709\u6548 steps\u3002");
18234
+ }
18235
+ return paper;
18236
+ }
18100
18237
 
18101
18238
  // src/commands/QuizCommandHandler.ts
18102
18239
  var QuizCommandHandler = class {
@@ -18128,6 +18265,51 @@ var QuizCommandHandler = class {
18128
18265
  }
18129
18266
  return;
18130
18267
  }
18268
+ if (args.action === "edit-step") {
18269
+ const basePaper = await getQuizPaper({
18270
+ apiBaseUrl,
18271
+ linkBaseUrl,
18272
+ paperId: args.paperId,
18273
+ token: session.token
18274
+ });
18275
+ const targetIndex = basePaper.steps.findIndex((item) => item.stepId === args.stepId);
18276
+ if (targetIndex < 0) {
18277
+ throw new Error(`\u672A\u627E\u5230 stepId=${args.stepId}\uFF0C\u65E0\u6CD5\u66F4\u65B0\u8BE5\u9898\u76EE\u3002`);
18278
+ }
18279
+ const resolvedFilePath2 = import_node_path14.default.resolve(process.cwd(), args.filePath);
18280
+ const nextStep = JSON.parse((0, import_node_fs9.readFileSync)(resolvedFilePath2, "utf8"));
18281
+ nextStep.stepId = args.stepId;
18282
+ const nextSteps = [...basePaper.steps];
18283
+ nextSteps[targetIndex] = nextStep;
18284
+ const nextPaperId = args.newPaperId || `${args.paperId}-rev-${this.timestampTag()}`;
18285
+ const result2 = await publishQuizPaper({
18286
+ apiBaseUrl,
18287
+ linkBaseUrl,
18288
+ paperId: nextPaperId,
18289
+ payload: {
18290
+ eyebrow: basePaper.eyebrow ?? "",
18291
+ completionTitle: basePaper.completionTitle ?? "",
18292
+ completionSummaryPerfect: basePaper.completionSummaryPerfect ?? "",
18293
+ completionSummaryReview: basePaper.completionSummaryReview ?? "",
18294
+ steps: nextSteps
18295
+ },
18296
+ token: session.token,
18297
+ activate: args.activate
18298
+ });
18299
+ if (result2.status === "draft") {
18300
+ ui.success("Quiz \u5355\u9898\u4FEE\u8BA2\u7A3F\u5DF2\u521B\u5EFA", result2.previewLink);
18301
+ ui.info("\u6765\u6E90\u8BD5\u5377", args.paperId);
18302
+ ui.info("\u4FEE\u8BA2\u9898\u76EE", args.stepId);
18303
+ ui.info("\u65B0\u8BD5\u5377", nextPaperId);
18304
+ ui.info("\u4E0B\u4E00\u6B65", `pmate quiz activate --paper-id ${nextPaperId}`);
18305
+ return;
18306
+ }
18307
+ ui.success("Quiz \u5355\u9898\u4FEE\u8BA2\u7A3F\u5DF2\u53D1\u5E03", result2.link);
18308
+ ui.info("\u6765\u6E90\u8BD5\u5377", args.paperId);
18309
+ ui.info("\u4FEE\u8BA2\u9898\u76EE", args.stepId);
18310
+ ui.info("\u65B0\u8BD5\u5377", nextPaperId);
18311
+ return;
18312
+ }
18131
18313
  const resolvedFilePath = import_node_path14.default.resolve(process.cwd(), args.filePath);
18132
18314
  const payload = JSON.parse((0, import_node_fs9.readFileSync)(resolvedFilePath, "utf8"));
18133
18315
  const result = await publishQuizPaper({
@@ -18146,6 +18328,19 @@ var QuizCommandHandler = class {
18146
18328
  }
18147
18329
  ui.success("Quiz \u5DF2\u53D1\u5E03", result.link);
18148
18330
  }
18331
+ timestampTag() {
18332
+ const now = /* @__PURE__ */ new Date();
18333
+ const pad = (value) => String(value).padStart(2, "0");
18334
+ return [
18335
+ now.getFullYear(),
18336
+ pad(now.getMonth() + 1),
18337
+ pad(now.getDate()),
18338
+ "-",
18339
+ pad(now.getHours()),
18340
+ pad(now.getMinutes()),
18341
+ pad(now.getSeconds())
18342
+ ].join("");
18343
+ }
18149
18344
  };
18150
18345
 
18151
18346
  // src/commands/CollectCommandHandler.ts
@@ -18912,54 +19107,8 @@ var NamespaceRegistry = class {
18912
19107
  }
18913
19108
  };
18914
19109
 
18915
- // src/namespacedRef.ts
18916
- function parseNamespacedRef(value, options = {}) {
18917
- const raw = value.trim();
18918
- const entityLabel = options.entityLabel || "ref";
18919
- if (!raw) {
18920
- throw new Error(`Invalid ${entityLabel}.`);
18921
- }
18922
- const colonIndex = raw.indexOf(":");
18923
- if (colonIndex > 0) {
18924
- const namespace2 = raw.slice(0, colonIndex).trim();
18925
- const objectId = raw.slice(colonIndex + 1).trim();
18926
- if (!namespace2 || !objectId) {
18927
- throw new Error(`Invalid ${entityLabel} "${value}". Use <ns:objectId>.`);
18928
- }
18929
- return {
18930
- namespace: namespace2,
18931
- objectId,
18932
- fullId: `${namespace2}:${objectId}`
18933
- };
18934
- }
18935
- const namespace = options.defaultNamespace?.trim();
18936
- if (namespace) {
18937
- return {
18938
- namespace,
18939
- objectId: raw,
18940
- fullId: `${namespace}:${raw}`
18941
- };
18942
- }
18943
- throw new Error(`Invalid ${entityLabel} "${value}". Use <ns:objectId>.`);
18944
- }
18945
- function composeNamespacedRef(namespace, objectId) {
18946
- const normalizedNamespace = namespace.trim();
18947
- const normalizedObjectId = objectId.trim();
18948
- return `${normalizedNamespace}:${normalizedObjectId}`;
18949
- }
18950
- function formatNamespacedDisplayId(namespace, objectIdOrFullId) {
18951
- const raw = objectIdOrFullId.trim();
18952
- if (raw.includes(":")) {
18953
- return raw;
18954
- }
18955
- const ns = namespace?.trim();
18956
- if (!ns) {
18957
- return raw;
18958
- }
18959
- return composeNamespacedRef(ns, raw);
18960
- }
18961
-
18962
19110
  // src/commands/AgentCommandHandler.ts
19111
+ init_namespacedRef();
18963
19112
  var AgentCommandHandler = class {
18964
19113
  async handle(args) {
18965
19114
  const token = this.readToken();
@@ -19423,6 +19572,7 @@ var StoreCommandHandler = class {
19423
19572
  var import_node_fs13 = require("fs");
19424
19573
  var import_node_path18 = __toESM(require("path"));
19425
19574
  init_sessionStore();
19575
+ init_namespacedRef();
19426
19576
  var AppCommandHandler = class {
19427
19577
  async handle(args) {
19428
19578
  const token = this.readToken();
@@ -20130,6 +20280,7 @@ function normalizeRepository(repository) {
20130
20280
  }
20131
20281
 
20132
20282
  // src/commands/ServiceCommandHandler.ts
20283
+ init_namespacedRef();
20133
20284
  var ServiceCommandHandler = class {
20134
20285
  async handle(args) {
20135
20286
  const baseUrl = this.resolveBaseUrl(args.baseUrl);
@@ -20645,6 +20796,7 @@ var AccountCommandHandler = class {
20645
20796
  };
20646
20797
 
20647
20798
  // src/agentCommandParser.ts
20799
+ init_namespacedRef();
20648
20800
  var DEFAULT_AGENT_NAMESPACE = "pmate";
20649
20801
  function parseAgentArgs(tokens) {
20650
20802
  const rest = [...tokens];
@@ -21153,6 +21305,7 @@ function parsePage(value) {
21153
21305
  }
21154
21306
 
21155
21307
  // src/appCommandParser.ts
21308
+ init_namespacedRef();
21156
21309
  function parseAppArgs(tokens) {
21157
21310
  const rest = [...tokens];
21158
21311
  const rawAction = rest.shift();
@@ -21342,6 +21495,7 @@ function parseBareRenameId2(value, entityName) {
21342
21495
  }
21343
21496
 
21344
21497
  // src/serviceCommandParser.ts
21498
+ init_namespacedRef();
21345
21499
  function parseServiceArgs(tokens) {
21346
21500
  const rest = [...tokens];
21347
21501
  const rawAction = rest.shift();
@@ -21826,6 +21980,7 @@ var HELP_TEXT = [
21826
21980
  ` ${import_chalk3.default.gray(" publish --file <json> --paper-id <id> [--activate]")}`,
21827
21981
  ` ${import_chalk3.default.gray(" activate --paper-id <id>")}`,
21828
21982
  ` ${import_chalk3.default.gray(" view --paper-id <id>")}`,
21983
+ ` ${import_chalk3.default.gray(" edit-step --paper-id <id> --step-id <step-id> --file <step.json> [--new-paper-id <id>] [--activate]")}`,
21829
21984
  ` ${import_chalk3.default.cyan("linear")} Create Linear issues`,
21830
21985
  ` ${import_chalk3.default.gray(" (default) create via REPL")}`,
21831
21986
  ` ${import_chalk3.default.gray(" create --repl [--cwd <dir>]")}`,
@@ -22530,6 +22685,63 @@ function parseQuizArgs(tokens) {
22530
22685
  linkBaseUrl
22531
22686
  };
22532
22687
  }
22688
+ if (action === "edit-step") {
22689
+ let paperId;
22690
+ let stepId;
22691
+ let filePath;
22692
+ let newPaperId;
22693
+ let apiBaseUrl;
22694
+ let linkBaseUrl;
22695
+ let activate = false;
22696
+ while (rest.length > 0) {
22697
+ const token = rest.shift();
22698
+ switch (token) {
22699
+ case "--paper-id":
22700
+ paperId = requireValue8(rest, token);
22701
+ break;
22702
+ case "--step-id":
22703
+ stepId = requireValue8(rest, token);
22704
+ break;
22705
+ case "--file":
22706
+ filePath = requireValue8(rest, token);
22707
+ break;
22708
+ case "--new-paper-id":
22709
+ newPaperId = requireValue8(rest, token);
22710
+ break;
22711
+ case "--base-url":
22712
+ apiBaseUrl = requireValue8(rest, token);
22713
+ break;
22714
+ case "--link-base":
22715
+ linkBaseUrl = requireValue8(rest, token);
22716
+ break;
22717
+ case "--activate":
22718
+ activate = true;
22719
+ break;
22720
+ default:
22721
+ throw new Error(`Unknown quiz edit-step option: ${token}`);
22722
+ }
22723
+ }
22724
+ if (!paperId) {
22725
+ throw new Error("Missing --paper-id. Usage: quiz edit-step --paper-id <id> --step-id <id> --file <step.json>.");
22726
+ }
22727
+ if (!stepId) {
22728
+ throw new Error("Missing --step-id. Usage: quiz edit-step --paper-id <id> --step-id <id> --file <step.json>.");
22729
+ }
22730
+ if (!filePath) {
22731
+ throw new Error("Missing --file. Usage: quiz edit-step --paper-id <id> --step-id <id> --file <step.json>.");
22732
+ }
22733
+ return {
22734
+ type: "quiz" /* Quiz */,
22735
+ action: "edit-step",
22736
+ paperId,
22737
+ stepId,
22738
+ filePath,
22739
+ newPaperId,
22740
+ apiBaseUrl,
22741
+ linkBaseUrl,
22742
+ activate
22743
+ };
22744
+ }
22533
22745
  throw new Error(`Unknown quiz action: ${action}`);
22534
22746
  }
22535
22747
  function parseLinearArgs(tokens) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {