@hcmai/sdk 0.21.4 → 0.21.5

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
@@ -236,6 +236,11 @@ interface FieldMeta {
236
236
  required?: boolean;
237
237
  label?: string;
238
238
  description?: string;
239
+ /** 字段写入与值形态约束,保留服务端声明。 */
240
+ readOnly?: boolean;
241
+ systemManaged?: boolean;
242
+ jsonObject?: boolean;
243
+ decimalNumber?: boolean;
239
244
  /**
240
245
  * 该字段的枚举取值域(服务端 `ModelFieldMeta.enums`)。
241
246
  *
@@ -350,7 +355,7 @@ interface DescribeOpts {
350
355
  * interface 加了键忘了登记、或清单里有 interface 没有的键,都在**编译期**红。
351
356
  * 不这样做,它就是又一张「漏登永远不红」的手工登记表。
352
357
  */
353
- declare const HCM_FIELD_RAW_KEYS: readonly ["key", "name", "type", "isRequired", "description", "enums", "object", "objectLabel", "isI18n"];
358
+ declare const HCM_FIELD_RAW_KEYS: readonly ["key", "name", "type", "isRequired", "description", "isReadonly", "systemManaged", "jsonObject", "decimalNumber", "enums", "object", "objectLabel", "isI18n"];
354
359
 
355
360
  interface CreateResult {
356
361
  id: string;
@@ -395,6 +400,12 @@ interface RowResult {
395
400
  status: RowStatus;
396
401
  id?: string;
397
402
  error?: string;
403
+ /** 后端校验原值;缺失时不推断错误码、字段或 HTTP 状态。 */
404
+ errorCode?: string;
405
+ httpStatus?: number;
406
+ field?: string;
407
+ details?: unknown;
408
+ nextStep?: string;
398
409
  traceId?: string;
399
410
  /**
400
411
  * 这一行里**目标模型两种写法都不认**的键(原名)。只在非空时出现。
package/dist/index.js CHANGED
@@ -351,6 +351,10 @@ var HCM_FIELD_RAW_KEYS = [
351
351
  "type",
352
352
  "isRequired",
353
353
  "description",
354
+ "isReadonly",
355
+ "systemManaged",
356
+ "jsonObject",
357
+ "decimalNumber",
354
358
  "enums",
355
359
  "object",
356
360
  "objectLabel",
@@ -383,6 +387,10 @@ async function describe(http, model, _opts = {}) {
383
387
  type: f.type ?? "unknown",
384
388
  required: f.isRequired,
385
389
  description: f.description,
390
+ ...typeof f.isReadonly === "boolean" ? { readOnly: f.isReadonly } : {},
391
+ ...typeof f.systemManaged === "boolean" ? { systemManaged: f.systemManaged } : {},
392
+ ...typeof f.jsonObject === "boolean" ? { jsonObject: f.jsonObject } : {},
393
+ ...typeof f.decimalNumber === "boolean" ? { decimalNumber: f.decimalNumber } : {},
386
394
  // 只在真有值时出这一位,口径同下面的 object / i18n:绝大多数字段没有值域,
387
395
  // 无条件出一个 `enums: undefined` 会让 --output json 每个字段都多一行噪声。
388
396
  ...f.enums?.length ? { enums: f.enums } : {},
@@ -2098,13 +2106,20 @@ async function runImport(client, fixtures, opts = {}) {
2098
2106
  tally.created++;
2099
2107
  }
2100
2108
  } catch (e) {
2101
- const err = e;
2109
+ const err = e instanceof CliError ? e : fromAxiosError(e);
2110
+ const context = err.context;
2102
2111
  rows.push({
2103
2112
  model: fx.model,
2104
2113
  key,
2105
2114
  status: "failed",
2106
- error: err.response?.data?.message ?? err.message ?? "write failed",
2107
- traceId: err.response?.headers?.["x-trace-id"]
2115
+ error: err.message,
2116
+ ...typeof context?.responseCode === "string" ? { errorCode: context.responseCode } : {},
2117
+ ...typeof context?.status === "number" ? { httpStatus: context.status } : {},
2118
+ ...typeof context?.field === "string" ? { field: context.field } : {},
2119
+ ...context?.details !== void 0 ? { details: context.details } : {},
2120
+ ...typeof context?.nextStep === "string" ? { nextStep: context.nextStep } : {},
2121
+ traceId: err.traceId,
2122
+ ...unmappedNote
2108
2123
  });
2109
2124
  tally.failed++;
2110
2125
  if (opts.onError === "stop") return result();