@alphalawyer/alpha-classic-cli 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,6 +28,19 @@ npm run build:test
28
28
  npm run build:prod
29
29
  ```
30
30
 
31
+ ## 发布到 npm
32
+
33
+ 正式发布会使用 `build:prod`,避免把 dev 环境固化进 npm 包。
34
+
35
+ ```bash
36
+ npm run release:dry-run
37
+ npm run release:patch
38
+ ```
39
+
40
+ - `release:dry-run`:执行类型检查、测试、生产环境构建和 `npm pack --dry-run`,只检查发包内容,不发布。
41
+ - `release:patch`:先确认 npm 登录用户,再完成发布前检查、自动升级补丁版本、重新生产构建并发布到公开 npm 仓库。
42
+ - 如果 npm 要求 OTP,命令后追加参数即可,例如 `npm run release:patch -- --otp=123456`。
43
+
31
44
  当前 dev 环境:
32
45
 
33
46
  ```text
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ function normalizePreset(name, preset) {
77
77
  };
78
78
  }
79
79
  function resolveBuildEnvironmentName() {
80
- const rawName = "dev".trim() ? "dev" : DEFAULT_ENVIRONMENT_NAME;
80
+ const rawName = "prod".trim() ? "prod" : DEFAULT_ENVIRONMENT_NAME;
81
81
  const normalized = rawName.trim().toLowerCase();
82
82
  if (normalized in PRESETS) {
83
83
  return normalized;
@@ -220,7 +220,7 @@ var ApiClient = class {
220
220
  if (envelope) {
221
221
  const code = envelope.code ?? envelope.resultCode;
222
222
  const success = envelope.success ?? envelope.isSuccess;
223
- if (success !== false && (code === void 0 || Number(code) === RESULT_CODE_SUCCESS)) {
223
+ if (success !== false && (code === void 0 || isSuccessCode(code))) {
224
224
  return envelope.data;
225
225
  }
226
226
  if (Number(code) === RESULT_CODE_AUTH && retry.allowRefresh) {
@@ -307,16 +307,20 @@ function asResultEnvelope(value) {
307
307
  return null;
308
308
  }
309
309
  const record = value;
310
- const hasModernEnvelope = typeof record.success === "boolean" && (record.code === void 0 || typeof record.code === "number") && (record.msg === void 0 || typeof record.msg === "string");
311
- const hasLegacyEnvelope = typeof record.isSuccess === "boolean" && (record.resultCode === void 0 || typeof record.resultCode === "number" || typeof record.resultCode === "string") && (record.resultMsg === void 0 || typeof record.resultMsg === "string");
310
+ const hasModernEnvelope = (typeof record.success === "boolean" || typeof record.code === "number" || typeof record.code === "string") && (record.code === void 0 || typeof record.code === "number" || typeof record.code === "string") && (record.msg === void 0 || typeof record.msg === "string");
311
+ const hasLegacyEnvelope = (typeof record.isSuccess === "boolean" || typeof record.resultCode === "number" || typeof record.resultCode === "string") && (record.resultCode === void 0 || typeof record.resultCode === "number" || typeof record.resultCode === "string") && (record.resultMsg === void 0 || typeof record.resultMsg === "string") && (record.resultMess === void 0 || typeof record.resultMess === "string");
312
312
  if ("data" in record && (hasModernEnvelope || hasLegacyEnvelope)) {
313
313
  return value;
314
314
  }
315
315
  return null;
316
316
  }
317
+ function isSuccessCode(code) {
318
+ const numericCode2 = Number(code);
319
+ return numericCode2 === 0 || numericCode2 === 1 || numericCode2 === RESULT_CODE_SUCCESS;
320
+ }
317
321
  function throwApiEnvelopeError(envelope, status) {
318
322
  const code = envelope.code ?? envelope.resultCode;
319
- const message = envelope.msg ?? envelope.resultMsg ?? envelope.message ?? "API request failed.";
323
+ const message = envelope.msg ?? envelope.resultMsg ?? envelope.resultMess ?? envelope.message ?? "API request failed.";
320
324
  if (Number(code) === RESULT_CODE_AUTH) {
321
325
  throw new AuthError(message, code, status);
322
326
  }
@@ -649,7 +653,7 @@ async function runApiCommand(method, apiPath, options, sessionStore) {
649
653
  params: options.params ? parseJsonObject(options.params, "--params") : void 0,
650
654
  data: options.data ? JSON.parse(options.data) : void 0
651
655
  });
652
- printSuccess(data);
656
+ printSuccess(redactSensitiveData(data));
653
657
  }
654
658
  function parseJsonObject(value, flagName) {
655
659
  const parsed = JSON.parse(value);
@@ -658,6 +662,23 @@ function parseJsonObject(value, flagName) {
658
662
  }
659
663
  return parsed;
660
664
  }
665
+ function redactSensitiveData(value) {
666
+ if (Array.isArray(value)) {
667
+ return value.map(redactSensitiveData);
668
+ }
669
+ if (!value || typeof value !== "object") {
670
+ return value;
671
+ }
672
+ return Object.fromEntries(
673
+ Object.entries(value).map(([key, item]) => [
674
+ key,
675
+ isSensitiveKey(key) ? "[REDACTED]" : redactSensitiveData(item)
676
+ ])
677
+ );
678
+ }
679
+ function isSensitiveKey(key) {
680
+ return key.toLowerCase().includes("token");
681
+ }
661
682
 
662
683
  // src/commands/appro.ts
663
684
  var APPRO_SCOPE_TO_ENUM = {
@@ -2843,18 +2864,21 @@ async function runMatterTaskDetail(options, sessionStore) {
2843
2864
  if (commentResponse.succeed === false) {
2844
2865
  throw new Error(commentResponse.message ?? commentResponse.detail ?? "Matter task comments request failed.");
2845
2866
  }
2846
- const task = detailResponse.data;
2867
+ const task = unwrapEnvelopeData2(detailResponse);
2847
2868
  if (!task) {
2848
2869
  throw new Error("\u4EFB\u52A1\u4E0D\u5B58\u5728\u6216\u5F53\u524D\u7528\u6237\u65E0\u6743\u67E5\u770B\u3002");
2849
2870
  }
2850
- const attachmentPage = attachmentResponse.data ?? {};
2871
+ const checkItems = unwrapEnvelopeData2(checkItemResponse) ?? [];
2872
+ const attachmentPage = unwrapEnvelopeData2(attachmentResponse) ?? {};
2851
2873
  const attachments = attachmentPage.data ?? attachmentPage.items ?? [];
2852
2874
  const attachmentDetails = await fetchDocumentDetailsForAttachments(client, attachments);
2853
- const timingPage = timingResponse.data ?? {};
2854
- const commentPage = commentResponse.result ?? {};
2875
+ const timingPage = unwrapEnvelopeData2(timingResponse) ?? {};
2876
+ const commentPage = commentResponse.result ?? unwrapEnvelopeData2(
2877
+ commentResponse
2878
+ ) ?? {};
2855
2879
  printSuccess({
2856
2880
  "\u4EFB\u52A1\u6982\u89C8": toMatterTaskDetailSummary(task),
2857
- "\u68C0\u67E5\u9879": (checkItemResponse.data ?? []).map(toMatterTaskCheckItemSummary),
2881
+ "\u68C0\u67E5\u9879": checkItems.map(toMatterTaskCheckItemSummary),
2858
2882
  "\u9644\u4EF6": attachments.map(
2859
2883
  (attachment) => toMatterTaskAttachmentSummary(attachment, attachmentDetails.get(getAttachmentDocumentKey(attachment)))
2860
2884
  ),
@@ -3558,7 +3582,7 @@ async function buildJoinedMatterMemberFilter(client, sessionStore) {
3558
3582
  };
3559
3583
  }
3560
3584
  function unwrapEnvelopeData2(response) {
3561
- if (response && typeof response === "object" && "data" in response && ("isSuccess" in response || "resultMsg" in response)) {
3585
+ if (response && typeof response === "object" && "data" in response && ("isSuccess" in response || "resultCode" in response || "resultMsg" in response || "resultMess" in response || "code" in response || "msg" in response)) {
3562
3586
  return response.data;
3563
3587
  }
3564
3588
  return response;