@acosmi/sdk-ts 1.4.2 → 1.5.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.
@@ -3466,6 +3466,115 @@ function normalizeRawMessages(rm) {
3466
3466
  // src/shared/index.ts
3467
3467
  init_errors();
3468
3468
 
3469
+ // src/shared/operation.ts
3470
+ var IdempotencyKeyHeader = "Idempotency-Key";
3471
+
3472
+ // src/shared/retry-advice.ts
3473
+ var RETRY_ADVICE_REASONS = [
3474
+ "unknown",
3475
+ "retrying",
3476
+ "failed",
3477
+ "gate_closed",
3478
+ "step_up_required",
3479
+ "tenant_mismatch",
3480
+ "insufficient_scope",
3481
+ "quota_exceeded",
3482
+ "provider_timeout",
3483
+ "local_verify_failed",
3484
+ "billing_preflight_failed"
3485
+ ];
3486
+ var COMPLIANCE_KEY_TO_RETRY_REASON = {
3487
+ // 通用 / token / scope
3488
+ COMPLIANCE_UNAUTHORIZED: "failed",
3489
+ COMPLIANCE_INSUFFICIENT_SCOPE: "insufficient_scope",
3490
+ COMPLIANCE_STEP_UP_REQUIRED: "step_up_required",
3491
+ COMPLIANCE_TOKEN_INVALID: "failed",
3492
+ // 主体快照
3493
+ SUBJECT_SNAPSHOT_REQUIRED: "failed",
3494
+ SUBJECT_SNAPSHOT_NOT_FOUND: "failed",
3495
+ SUBJECT_SNAPSHOT_TENANT_MISMATCH: "tenant_mismatch",
3496
+ // Evidence / Timestamp / Package / Report
3497
+ EVIDENCE_ASSET_NOT_FOUND: "failed",
3498
+ EVIDENCE_ASSET_HASH_MISMATCH: "local_verify_failed",
3499
+ EVIDENCE_ASSET_PAYLOAD_REQUIRED: "failed",
3500
+ TIMESTAMP_TOKEN_NOT_FOUND: "failed",
3501
+ TIMESTAMP_PROVIDER_FAILED: "failed",
3502
+ TIMESTAMP_PROVIDER_UNKNOWN: "unknown",
3503
+ TIMESTAMP_LOCAL_VERIFY_FAILED: "local_verify_failed",
3504
+ TIMESTAMP_PROVIDER_NOT_AVAILABLE: "provider_timeout",
3505
+ EVIDENCE_PACKAGE_NOT_FOUND: "failed",
3506
+ EVIDENCE_PACKAGE_TIMESTAMP_REQUIRED: "failed",
3507
+ EVIDENCE_PACKAGE_MANIFEST_HASH_MISMATCH: "local_verify_failed",
3508
+ REPORT_NOT_FOUND: "failed",
3509
+ REPORT_ALREADY_PUBLISHED: "failed",
3510
+ REPORT_DRAFT_REQUIRED: "failed",
3511
+ EVIDENCE_VERIFY_TARGET_REQUIRED: "failed",
3512
+ EVIDENCE_VERIFY_TARGET_NOT_FOUND: "failed",
3513
+ // Provider request
3514
+ PROVIDER_REQUEST_UNKNOWN_NO_RETRY: "unknown",
3515
+ PROVIDER_CALLBACK_SOURCE_INVALID: "failed",
3516
+ PROVIDER_NOT_CONFIGURED: "gate_closed",
3517
+ PROVIDER_REQUEST_NOT_FOUND: "failed",
3518
+ PROVIDER_REQUEST_IDEMPOTENCY_REQUIRED: "failed",
3519
+ PROVIDER_REQUEST_STATUS_NOT_TERMINAL: "retrying",
3520
+ // Envelope
3521
+ ENVELOPE_NOT_FOUND: "failed",
3522
+ ENVELOPE_TENANT_MISMATCH: "tenant_mismatch",
3523
+ ENVELOPE_STATE_NOT_ALLOWED: "failed",
3524
+ ENVELOPE_GATE_CLOSED: "gate_closed",
3525
+ CONTRACT_NOT_FOUND: "failed",
3526
+ CONTRACT_HASH_MISMATCH: "local_verify_failed",
3527
+ PROVIDER_AUTHORIZATION_NOT_CONFIRMED: "failed",
3528
+ ENVELOPE_EVIDENCE_NOT_READY: "retrying",
3529
+ // Seal approval / use
3530
+ SEAL_ASSET_NOT_FOUND: "failed",
3531
+ SEAL_APPROVAL_NOT_FOUND: "failed",
3532
+ SEAL_APPROVAL_STATE_NOT_APPROVED: "failed",
3533
+ SEAL_APPROVAL_EXPIRED: "failed",
3534
+ SEAL_APPROVAL_ALREADY_USED: "failed",
3535
+ SEAL_APPROVAL_NONCE_USED: "failed",
3536
+ SEAL_APPROVAL_SEAL_MISMATCH: "failed",
3537
+ SEAL_APPROVAL_LOCATION_MISMATCH: "failed",
3538
+ SEAL_APPROVAL_TRANSACTOR_MISMATCH: "failed",
3539
+ SEAL_APPROVAL_CONTRACT_HASH_MISMATCH: "local_verify_failed",
3540
+ SEAL_APPROVAL_INVALID_TRANSITION: "failed",
3541
+ SEAL_USE_ALREADY_CONSUMED: "failed",
3542
+ // Audit chain
3543
+ AUDIT_CHAIN_TAMPER_DETECTED: "local_verify_failed",
3544
+ // Billing
3545
+ BILLING_COMMIT_REQUIRES_LOCAL_VERIFY: "local_verify_failed",
3546
+ BILLING_COMMIT_REQUIRES_PROVIDER_SUCCESS: "billing_preflight_failed",
3547
+ BILLING_CALLBACK_CANNOT_COMMIT: "billing_preflight_failed",
3548
+ BILLING_PROVIDER_UNKNOWN_NOT_COMMITTABLE: "billing_preflight_failed",
3549
+ BILLING_S2S_FORBIDDEN: "failed",
3550
+ // SDK fallback
3551
+ UNKNOWN_COMPLIANCE_ERROR: "unknown"
3552
+ };
3553
+ function retryReasonForComplianceKey(key) {
3554
+ return COMPLIANCE_KEY_TO_RETRY_REASON[key] ?? "unknown";
3555
+ }
3556
+ var OAUTH_ERROR_TO_RETRY_REASON = {
3557
+ insufficient_scope: "insufficient_scope",
3558
+ invalid_token: "failed",
3559
+ invalid_grant: "failed",
3560
+ invalid_request: "failed",
3561
+ access_denied: "failed",
3562
+ unsupported_grant_type: "failed"
3563
+ };
3564
+ function retryReasonForOAuthError(oauthError) {
3565
+ return OAUTH_ERROR_TO_RETRY_REASON[oauthError] ?? "unknown";
3566
+ }
3567
+ function complianceErrorToRetryAdvice(info) {
3568
+ return {
3569
+ retryable: info.retryable,
3570
+ sameIdempotencyKeyRequired: !info.terminal,
3571
+ manualActionRequired: info.terminal || info.stepUpRequired,
3572
+ reason: retryReasonForComplianceKey(info.key),
3573
+ developerMessage: info.message,
3574
+ supportCode: `compliance:${info.code}`
3575
+ };
3576
+ }
3577
+
3469
3578
  // src/auth/scopes.ts
3470
3579
  var ScopeAI = "ai";
3471
3580
  var ScopeSkills = "skills";
@@ -4829,6 +4938,8 @@ var ScopeComplianceSealUseExecute = "compliance:seal_use:execute";
4829
4938
  var ScopeComplianceReportsRead = "compliance:reports:read";
4830
4939
  var ScopeComplianceReportsWrite = "compliance:reports:write";
4831
4940
  var ScopeComplianceReportsPublish = "compliance:reports:publish";
4941
+ var ScopeComplianceContractTemplateRead = "compliance:contract_template:read";
4942
+ var ScopeComplianceContractTemplateWrite = "compliance:contract_template:write";
4832
4943
  function complianceScopes() {
4833
4944
  return [
4834
4945
  ScopeComplianceEvidenceRead,
@@ -4843,7 +4954,9 @@ function complianceScopes() {
4843
4954
  ScopeComplianceSealUseExecute,
4844
4955
  ScopeComplianceReportsRead,
4845
4956
  ScopeComplianceReportsWrite,
4846
- ScopeComplianceReportsPublish
4957
+ ScopeComplianceReportsPublish,
4958
+ ScopeComplianceContractTemplateRead,
4959
+ ScopeComplianceContractTemplateWrite
4847
4960
  ];
4848
4961
  }
4849
4962
 
@@ -5065,6 +5178,21 @@ var ComplianceClient = class {
5065
5178
  signal
5066
5179
  );
5067
5180
  }
5181
+ /**
5182
+ * 读 — 证据资产分页列表(compliance gateway S1)。
5183
+ *
5184
+ * 走 GET 读路径(允许 401 单次刷新重放)。返回 yudao `PageResult<T>`
5185
+ * (`{ total, list }`)。所有过滤项可选;`createTimeStart` / `createTimeEnd`
5186
+ * 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。
5187
+ */
5188
+ listEvidenceAssets(req = {}, signal) {
5189
+ return this.read(
5190
+ "GET",
5191
+ `/compliance/evidence/assets/page${pageQuery(req, ["assetType", "status", "createTimeStart", "createTimeEnd"])}`,
5192
+ null,
5193
+ signal
5194
+ );
5195
+ }
5068
5196
  /**
5069
5197
  * 公开 verify。隐私边界:返回字段不含 PII / 合同原文 / storage / provider raw。
5070
5198
  *
@@ -5109,6 +5237,20 @@ var ComplianceClient = class {
5109
5237
  signal
5110
5238
  );
5111
5239
  }
5240
+ /**
5241
+ * 读 — 时间章分页列表(compliance gateway S1)。
5242
+ *
5243
+ * 走 GET 读路径。返回 yudao `PageResult<T>`。所有过滤项可选;`createTimeStart` /
5244
+ * `createTimeEnd` 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。
5245
+ */
5246
+ listTimestamps(req = {}, signal) {
5247
+ return this.read(
5248
+ "GET",
5249
+ `/compliance/timestamps/page${pageQuery(req, ["provider", "verificationStatus", "createTimeStart", "createTimeEnd"])}`,
5250
+ null,
5251
+ signal
5252
+ );
5253
+ }
5112
5254
  /** verify — 本地离线校验已申请的时间章。 */
5113
5255
  verifyTimestamp(req, opts = {}) {
5114
5256
  return this.write(
@@ -5133,6 +5275,38 @@ var ComplianceClient = class {
5133
5275
  );
5134
5276
  }
5135
5277
  // =========================================================================
5278
+ // TSA readonly views (read-only — compliance gateway S3 / gap-register U-7)
5279
+ // =========================================================================
5280
+ /**
5281
+ * 读 — 时间章授权机构(TSA)provider 列表(compliance gateway S3)。
5282
+ *
5283
+ * 走 GET 读路径(允许 401 单次刷新重放)。后端 G3 为每个 TSA provider 返回
5284
+ * 一条 {@link TsaProvider}:名称、所处环境、当前是否可用。只读视图,不含
5285
+ * provider 端点 / 凭证 / 证书等内部接入材料。
5286
+ */
5287
+ listTsaProviders(signal) {
5288
+ return this.read(
5289
+ "GET",
5290
+ "/compliance/timestamps/providers",
5291
+ null,
5292
+ signal
5293
+ );
5294
+ }
5295
+ /**
5296
+ * 读 — 时间章统计视图(compliance gateway S3)。
5297
+ *
5298
+ * 走 GET 读路径(允许 401 单次刷新重放)。返回 {@link TsaStats}:时间章总数
5299
+ * + 按校验状态分桶的计数。只读聚合视图。
5300
+ */
5301
+ getTsaStats(signal) {
5302
+ return this.read(
5303
+ "GET",
5304
+ "/compliance/timestamps/stats",
5305
+ null,
5306
+ signal
5307
+ );
5308
+ }
5309
+ // =========================================================================
5136
5310
  // Evidence Package
5137
5311
  // =========================================================================
5138
5312
  /** 构建证据包(写)。 */
@@ -5145,6 +5319,20 @@ var ComplianceClient = class {
5145
5319
  writeCtx(opts)
5146
5320
  );
5147
5321
  }
5322
+ /**
5323
+ * 读 — 证据包分页列表(compliance gateway S1)。
5324
+ *
5325
+ * 走 GET 读路径。返回 yudao `PageResult<T>`。所有过滤项可选;`createTimeStart` /
5326
+ * `createTimeEnd` 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。
5327
+ */
5328
+ listEvidencePackages(req = {}, signal) {
5329
+ return this.read(
5330
+ "GET",
5331
+ `/compliance/evidence/packages/page${pageQuery(req, ["status", "createTimeStart", "createTimeEnd"])}`,
5332
+ null,
5333
+ signal
5334
+ );
5335
+ }
5148
5336
  // =========================================================================
5149
5337
  // Report
5150
5338
  // =========================================================================
@@ -5161,6 +5349,20 @@ var ComplianceClient = class {
5161
5349
  signal
5162
5350
  );
5163
5351
  }
5352
+ /**
5353
+ * 读 — 证据报告分页列表(compliance gateway S1)。
5354
+ *
5355
+ * 走 GET 读路径。返回 yudao `PageResult<T>`。所有过滤项可选;`createTimeStart` /
5356
+ * `createTimeEnd` 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。
5357
+ */
5358
+ listReports(req = {}, signal) {
5359
+ return this.read(
5360
+ "GET",
5361
+ `/compliance/reports/page${pageQuery(req, ["status", "createTimeStart", "createTimeEnd"])}`,
5362
+ null,
5363
+ signal
5364
+ );
5365
+ }
5164
5366
  /**
5165
5367
  * 发布报告(写,step-up 必须)。
5166
5368
  *
@@ -5211,6 +5413,20 @@ var ComplianceClient = class {
5211
5413
  signal
5212
5414
  );
5213
5415
  }
5416
+ /**
5417
+ * 读 — 签署 envelope 分页列表(compliance gateway S1)。
5418
+ *
5419
+ * 走 GET 读路径。返回 yudao `PageResult<T>`。所有过滤项可选;`createTimeStart` /
5420
+ * `createTimeEnd` 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。
5421
+ */
5422
+ listSigningEnvelopes(req = {}, signal) {
5423
+ return this.read(
5424
+ "GET",
5425
+ `/compliance/signing-envelopes/page${pageQuery(req, ["status", "createTimeStart", "createTimeEnd"])}`,
5426
+ null,
5427
+ signal
5428
+ );
5429
+ }
5214
5430
  /**
5215
5431
  * 正式签署(写,step-up 必须)。
5216
5432
  *
@@ -5247,6 +5463,52 @@ var ComplianceClient = class {
5247
5463
  writeCtx(opts)
5248
5464
  );
5249
5465
  }
5466
+ /**
5467
+ * 读 — envelope 下挂的合同列表(compliance gateway S4)。
5468
+ *
5469
+ * 走 GET 读路径(允许 401 单次刷新重放)。后端 G4 为每份挂在该 envelope 上的
5470
+ * 合同返回一条 {@link EnvelopeContractItem}:编号 / 标题 / MIME / 大小 / 哈希
5471
+ * 指纹 / 状态。返回普通数组(非 `PageResult`)。SDK-safe 视图——不含合同原文 /
5472
+ * storage key / provider raw payload。
5473
+ */
5474
+ listEnvelopeContracts(envelopeId, signal) {
5475
+ return this.read(
5476
+ "GET",
5477
+ `/compliance/signing-envelopes/${encodeURIComponent(envelopeId)}/contracts`,
5478
+ null,
5479
+ signal
5480
+ );
5481
+ }
5482
+ /**
5483
+ * 读 — envelope 关联的 provider 请求列表(compliance gateway S4)。
5484
+ *
5485
+ * 走 GET 读路径(允许 401 单次刷新重放)。后端 G4 复用操作投影
5486
+ * {@link OperationPageItem}:描述每次 provider 请求本身的执行进度,与 envelope
5487
+ * 领域状态正交。返回普通数组(非 `PageResult`)。
5488
+ */
5489
+ listEnvelopeProviderRequests(envelopeId, signal) {
5490
+ return this.read(
5491
+ "GET",
5492
+ `/compliance/signing-envelopes/${encodeURIComponent(envelopeId)}/provider-requests`,
5493
+ null,
5494
+ signal
5495
+ );
5496
+ }
5497
+ /**
5498
+ * 作废 envelope(写,compliance gateway S4)。
5499
+ *
5500
+ * 走 compliance 写路径——发送前 `ensureToken` 一次、不自动重试、`401` 不刷新
5501
+ * 重放;支持 `Idempotency-Key` header(强烈建议调用方持久化幂等键,重试 / 恢复
5502
+ * 时复用,避免重复作废)。`req.reason` 为必填的作废原因,随 JSON body 提交。
5503
+ */
5504
+ voidEnvelope(envelopeId, req, opts = {}) {
5505
+ return this.write(
5506
+ "POST",
5507
+ `/compliance/signing-envelopes/${encodeURIComponent(envelopeId)}/void`,
5508
+ req,
5509
+ writeCtx(opts)
5510
+ );
5511
+ }
5250
5512
  // =========================================================================
5251
5513
  // Seal Approval
5252
5514
  // =========================================================================
@@ -5321,6 +5583,45 @@ var ComplianceClient = class {
5321
5583
  signal
5322
5584
  );
5323
5585
  }
5586
+ /**
5587
+ * 读 — 用印审批分页列表(compliance gateway S1)。
5588
+ *
5589
+ * 与 {@link listPendingSealApprovals}(仅 pending、不分页)不同,本方法支持分页与
5590
+ * 状态 / 时间过滤。走 GET 读路径。返回 yudao `PageResult<T>`。所有过滤项可选;
5591
+ * `createTimeStart` / `createTimeEnd` 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,
5592
+ * SDK 原样透传。
5593
+ */
5594
+ listSealApprovals(req = {}, signal) {
5595
+ return this.read(
5596
+ "GET",
5597
+ `/compliance/seal-approvals/page${pageQuery(req, ["status", "createTimeStart", "createTimeEnd"])}`,
5598
+ null,
5599
+ signal
5600
+ );
5601
+ }
5602
+ // =========================================================================
5603
+ // Seal Use (read-only — compliance gateway S6 / gap-register U-4)
5604
+ // =========================================================================
5605
+ /**
5606
+ * 读 — 用印执行记录分页列表(compliance gateway S6)。
5607
+ *
5608
+ * 走 GET 读路径(允许 401 单次刷新重放)。返回 yudao `PageResult<T>`
5609
+ * (`{ total, list }`)。一次用印执行(seal use)描述 envelope / contract /
5610
+ * seal / 审批联动后【真正调用 provider 落章】的那一笔记录,与 envelope
5611
+ * 领域状态正交。所有过滤项可选;`createTimeStart` / `createTimeEnd` 由调用方
5612
+ * 按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。
5613
+ *
5614
+ * 与后端复用同一只读 scope `CONTRACT_SIGNING_READ`
5615
+ *({@link ScopeComplianceContractSigningRead})——不引入新 scope。
5616
+ */
5617
+ listSealUses(req = {}, signal) {
5618
+ return this.read(
5619
+ "GET",
5620
+ `/compliance/seal-uses/page${pageQuery(req, ["sealId", "envelopeId", "usageStatus", "createTimeStart", "createTimeEnd"])}`,
5621
+ null,
5622
+ signal
5623
+ );
5624
+ }
5324
5625
  // =========================================================================
5325
5626
  // Provider Request (read-only)
5326
5627
  // =========================================================================
@@ -5348,6 +5649,206 @@ var ComplianceClient = class {
5348
5649
  );
5349
5650
  }
5350
5651
  // =========================================================================
5652
+ // Capabilities (read-only — compliance gateway S2 / gap-register U-6)
5653
+ // =========================================================================
5654
+ /**
5655
+ * 读 — compliance 能力闸门列表(compliance gateway S2)。
5656
+ *
5657
+ * 走 GET 读路径(允许 401 单次刷新重放)。后端 G2 为每个高风险 / 收费动作
5658
+ * (`signEnvelope` / `createH5SigningUrl` / `publishReport` /
5659
+ * `approveSealApproval` / `executeSealUse` / `createSeal`)返回一条
5660
+ * {@link ComplianceCapability}:是否可执行、所处状态、所需 scope / step-up。
5661
+ *
5662
+ * 调用方在高风险动作执行【前】查询本结果做门控;拿不到能力时必须 fail-closed
5663
+ *(按 `executable=false` 处理)。
5664
+ */
5665
+ getCapabilities(signal) {
5666
+ return this.read(
5667
+ "GET",
5668
+ "/compliance/capabilities",
5669
+ null,
5670
+ signal
5671
+ );
5672
+ }
5673
+ /**
5674
+ * 读 — 单个动作的能力闸门视图(便捷方法)。
5675
+ *
5676
+ * 拉取完整 {@link getCapabilities} 列表并返回 `action` 匹配的那一条,无匹配时
5677
+ * 返回 `undefined`。**每次调用产生一次网络请求**——需要门控多个动作时应改用
5678
+ * {@link getCapabilities} 一次性取回再本地查表,避免重复请求。
5679
+ *
5680
+ * 与 {@link getCapabilities} 一致走 GET 读路径(允许 401 单次刷新重放)。
5681
+ */
5682
+ async getFeatureGate(action, signal) {
5683
+ const caps = await this.getCapabilities(signal);
5684
+ return caps.find((c) => c.action === action);
5685
+ }
5686
+ // =========================================================================
5687
+ // Operation projection (read-only — compliance gateway S2 / gap-register U-5)
5688
+ // =========================================================================
5689
+ /**
5690
+ * 读 — compliance 操作投影分页列表(compliance gateway S2)。
5691
+ *
5692
+ * 走 GET 读路径。返回 yudao `PageResult<T>`(`{ total, list }`)。所有过滤项
5693
+ * 可选;`createTimeStart` / `createTimeEnd` 由调用方按 `yyyy-MM-dd HH:mm:ss`
5694
+ * 提供,SDK 原样透传,不做格式校验或时区转换。
5695
+ *
5696
+ * 操作投影描述【一次操作】本身的执行进度,与履约对象的领域状态正交。
5697
+ */
5698
+ listOperations(req = {}, signal) {
5699
+ return this.read(
5700
+ "GET",
5701
+ `/compliance/operations/page${pageQuery(req, ["status", "createTimeStart", "createTimeEnd"])}`,
5702
+ null,
5703
+ signal
5704
+ );
5705
+ }
5706
+ /**
5707
+ * 读 — compliance 操作投影详情(compliance gateway S2)。
5708
+ *
5709
+ * `id` 为数值行主键(非 `operationId` 幂等键)。走 GET 读路径(允许 401 单次
5710
+ * 刷新重放)。
5711
+ */
5712
+ getOperation(id, signal) {
5713
+ return this.read(
5714
+ "GET",
5715
+ `/compliance/operations/${encodeURIComponent(id)}`,
5716
+ null,
5717
+ signal
5718
+ );
5719
+ }
5720
+ // =========================================================================
5721
+ // Contract Template (compliance gateway S5 — gap-register U-2)
5722
+ // =========================================================================
5723
+ /**
5724
+ * 创建合同模板(写)。
5725
+ *
5726
+ * 走 compliance 写路径——发送前 `ensureToken` 一次、不自动重试、`401` 不刷新
5727
+ * 重放;支持 `Idempotency-Key` header(强烈建议调用方持久化幂等键,重试 / 恢复
5728
+ * 时复用,避免重复创建模板)。模板创建后初始状态为 `DRAFT`。
5729
+ */
5730
+ createContractTemplate(req, opts = {}) {
5731
+ return this.write(
5732
+ "POST",
5733
+ "/compliance/contract-templates",
5734
+ req,
5735
+ writeCtx(opts)
5736
+ );
5737
+ }
5738
+ /**
5739
+ * 更新合同模板(写,仅 DRAFT 状态)。
5740
+ *
5741
+ * 走 compliance 写路径——`Idempotency-Key`、不重试、`401` 不刷新重放。所有字段
5742
+ * 可选,缺省字段视为不修改。服务端在 PUBLISHED / ARCHIVED 状态下会拒绝更新。
5743
+ */
5744
+ updateContractTemplate(id, req, opts = {}) {
5745
+ return this.write(
5746
+ "POST",
5747
+ `/compliance/contract-templates/${encodeURIComponent(id)}`,
5748
+ req,
5749
+ writeCtx(opts)
5750
+ );
5751
+ }
5752
+ /**
5753
+ * 删除合同模板(写,仅 DRAFT 状态)。
5754
+ *
5755
+ * 走 compliance 写路径——`Idempotency-Key`、不重试、`401` 不刷新重放。服务端
5756
+ * 在 PUBLISHED / ARCHIVED 状态下会拒绝删除——已发布的模板应改走 `archive`。
5757
+ */
5758
+ deleteContractTemplate(id, opts = {}) {
5759
+ return this.write(
5760
+ "POST",
5761
+ `/compliance/contract-templates/${encodeURIComponent(id)}/delete`,
5762
+ null,
5763
+ writeCtx(opts)
5764
+ );
5765
+ }
5766
+ /** 读 — 合同模板详情。 */
5767
+ getContractTemplate(id, signal) {
5768
+ return this.read(
5769
+ "GET",
5770
+ `/compliance/contract-templates/${encodeURIComponent(id)}`,
5771
+ null,
5772
+ signal
5773
+ );
5774
+ }
5775
+ /**
5776
+ * 读 — 合同模板分页列表(compliance gateway S5)。
5777
+ *
5778
+ * 走 GET 读路径(允许 401 单次刷新重放)。返回 yudao `PageResult<T>`
5779
+ * (`{ total, list }`)。所有过滤项可选;`createTimeStart` / `createTimeEnd`
5780
+ * 由调用方按 `yyyy-MM-dd HH:mm:ss` 提供,SDK 原样透传。列表项视图
5781
+ * {@link ContractTemplatePageItem} 不含 `fields`——字段叠加只在详情 / 版本
5782
+ * 快照里返回。
5783
+ */
5784
+ listContractTemplates(req = {}, signal) {
5785
+ return this.read(
5786
+ "GET",
5787
+ `/compliance/contract-templates/page${pageQuery(req, ["status", "createTimeStart", "createTimeEnd"])}`,
5788
+ null,
5789
+ signal
5790
+ );
5791
+ }
5792
+ /**
5793
+ * 上传合同模板 PDF(写)。
5794
+ *
5795
+ * 走 compliance 写路径——`Idempotency-Key`、不重试、`401` 不刷新重放。请求体
5796
+ * 为 `{ pdfBase64 }`;SDK 不在客户端做 PDF 解析 / 几何校验,原样透传给后端。
5797
+ * 返回上传后的最新模板视图(含 `pdfHash` / `pdfPageCount`)。
5798
+ */
5799
+ uploadContractTemplatePdf(id, req, opts = {}) {
5800
+ return this.write(
5801
+ "POST",
5802
+ `/compliance/contract-templates/${encodeURIComponent(id)}/pdf`,
5803
+ req,
5804
+ writeCtx(opts)
5805
+ );
5806
+ }
5807
+ /**
5808
+ * 发布合同模板(写)。DRAFT → PUBLISHED,落版本快照。
5809
+ *
5810
+ * 走 compliance 写路径——`Idempotency-Key`、不重试、`401` 不刷新重放。
5811
+ * publish 后 `currentVersion` 递增,`fields` 与 `pdfHash` 同步固化进版本表。
5812
+ */
5813
+ publishContractTemplate(id, opts = {}) {
5814
+ return this.write(
5815
+ "POST",
5816
+ `/compliance/contract-templates/${encodeURIComponent(id)}/publish`,
5817
+ null,
5818
+ writeCtx(opts)
5819
+ );
5820
+ }
5821
+ /**
5822
+ * 归档合同模板(写)。PUBLISHED → ARCHIVED。
5823
+ *
5824
+ * 走 compliance 写路径——`Idempotency-Key`、不重试、`401` 不刷新重放。
5825
+ * 已归档模板只读,不再允许 publish / 编辑 / 删除。
5826
+ */
5827
+ archiveContractTemplate(id, opts = {}) {
5828
+ return this.write(
5829
+ "POST",
5830
+ `/compliance/contract-templates/${encodeURIComponent(id)}/archive`,
5831
+ null,
5832
+ writeCtx(opts)
5833
+ );
5834
+ }
5835
+ /**
5836
+ * 读 — 合同模板版本快照列表。
5837
+ *
5838
+ * 走 GET 读路径(允许 401 单次刷新重放)。返回 {@link ContractTemplateVersion}
5839
+ * 普通数组(非 `PageResult`)——每次 publish 落一个不可变快照,记录当时的
5840
+ * `name` / `pdfHash` / `fields` / `statusAtSnapshot`,是离线复核 / 版本对账
5841
+ * 的依据。
5842
+ */
5843
+ listContractTemplateVersions(id, signal) {
5844
+ return this.read(
5845
+ "GET",
5846
+ `/compliance/contract-templates/${encodeURIComponent(id)}/versions`,
5847
+ null,
5848
+ signal
5849
+ );
5850
+ }
5851
+ // =========================================================================
5351
5852
  // Error classification (re-export for convenience)
5352
5853
  // =========================================================================
5353
5854
  classifyError(err) {
@@ -5506,6 +6007,24 @@ function classifyProviderStatus(status) {
5506
6007
  return "continue";
5507
6008
  }
5508
6009
  }
6010
+ function pageQuery(req, filterKeys) {
6011
+ const q = new URLSearchParams();
6012
+ const append = (key, value) => {
6013
+ if (value == null) return;
6014
+ const s = typeof value === "string" ? value : String(value);
6015
+ if (s === "") return;
6016
+ q.set(key, s);
6017
+ };
6018
+ append("pageNo", req.pageNo);
6019
+ append("pageSize", req.pageSize);
6020
+ append("sortBy", req.sortBy);
6021
+ append("sortDirection", req.sortDirection);
6022
+ for (const key of filterKeys) {
6023
+ append(String(key), req[key]);
6024
+ }
6025
+ const qs = q.toString();
6026
+ return qs ? "?" + qs : "";
6027
+ }
5509
6028
  function writeCtx(opts, extraHeaders = {}) {
5510
6029
  return {
5511
6030
  idempotencyKey: opts.idempotencyKey,
@@ -5614,12 +6133,16 @@ exports.FilterStatusFallbackTkdistSkew = FilterStatusFallbackTkdistSkew;
5614
6133
  exports.FilterStatusInternalBypass = FilterStatusInternalBypass;
5615
6134
  exports.FilterStatusOK = FilterStatusOK;
5616
6135
  exports.FilterStatusUnknown = FilterStatusUnknown;
6136
+ exports.IdempotencyKeyHeader = IdempotencyKeyHeader;
5617
6137
  exports.InMemoryTokenStore = InMemoryTokenStore;
5618
6138
  exports.LocalStorageTokenStore = LocalStorageTokenStore;
6139
+ exports.RETRY_ADVICE_REASONS = RETRY_ADVICE_REASONS;
5619
6140
  exports.ScopeAI = ScopeAI;
5620
6141
  exports.ScopeAccount = ScopeAccount;
5621
6142
  exports.ScopeComplianceContractSigningRead = ScopeComplianceContractSigningRead;
5622
6143
  exports.ScopeComplianceContractSigningWrite = ScopeComplianceContractSigningWrite;
6144
+ exports.ScopeComplianceContractTemplateRead = ScopeComplianceContractTemplateRead;
6145
+ exports.ScopeComplianceContractTemplateWrite = ScopeComplianceContractTemplateWrite;
5623
6146
  exports.ScopeComplianceEvidenceRead = ScopeComplianceEvidenceRead;
5624
6147
  exports.ScopeComplianceEvidenceWrite = ScopeComplianceEvidenceWrite;
5625
6148
  exports.ScopeComplianceReportsPublish = ScopeComplianceReportsPublish;
@@ -5655,6 +6178,7 @@ exports.buildBetas = buildBetas;
5655
6178
  exports.classifyComplianceError = classifyComplianceError;
5656
6179
  exports.commerceScopes = commerceScopes;
5657
6180
  exports.completeWebAuthorizationRequest = completeWebAuthorizationRequest;
6181
+ exports.complianceErrorToRetryAdvice = complianceErrorToRetryAdvice;
5658
6182
  exports.complianceScopes = complianceScopes;
5659
6183
  exports.computeBackoff = computeBackoff;
5660
6184
  exports.createWebAuthorizationRequest = createWebAuthorizationRequest;
@@ -5689,6 +6213,8 @@ exports.parseSourcesEvent = parseSourcesEvent;
5689
6213
  exports.refreshToken = refreshToken;
5690
6214
  exports.register = register;
5691
6215
  exports.registerWebOAuthClient = registerWebOAuthClient;
6216
+ exports.retryReasonForComplianceKey = retryReasonForComplianceKey;
6217
+ exports.retryReasonForOAuthError = retryReasonForOAuthError;
5692
6218
  exports.revokeToken = revokeToken;
5693
6219
  exports.sanitize = sanitize_exports;
5694
6220
  exports.skillScopes = skillScopes;