@autional/shared 0.1.0-rc.43 → 0.1.0-rc.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autional/shared",
3
- "version": "0.1.0-rc.43",
3
+ "version": "0.1.0-rc.44",
4
4
  "description": "Autional shared layer — API client, auth, types, hooks, utils",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.ts",
@@ -1,7 +1,7 @@
1
1
  // GENERATED FILE — DO NOT EDIT.
2
2
  // Source: contracts/errors.semantics.json(@autional/shared 仓内镜像,源 = service-core base/error/testdata/errors.semantics.json)
3
3
  // Regenerate: pnpm gen:errors · Verify: pnpm gen:errors:check
4
- // rows: 787 · source sha256: f846240c034effe8725e853eb67ab31bf8bcad2595e4ff815ab132c85dfb08aa
4
+ // rows: 792 · source sha256: 962af7ad9e1f41b957fa8cacb6f1bdbf0f0a56cb8cbdf144107e1329df80c0cd
5
5
  //
6
6
  // 单一真源链:service-core/base/error/semantics.go(Go)→ errors.semantics.json → 本文件。
7
7
  // ⚠️ 禁止在本文件或页面里手抄错误码分支:请消费 ERROR_SEMANTICS / UNPROVISIONED_CODES。
@@ -42,6 +42,7 @@ export interface ErrorSemantics {
42
42
  class: ErrorClass;
43
43
  absence: Absence;
44
44
  uiObservation: UIObservation;
45
+ name?: string;
45
46
  retryable: boolean;
46
47
  docsPath: string;
47
48
  }
@@ -364,11 +365,15 @@ export const ERROR_SEMANTICS: Readonly<Record<number, ErrorSemantics>> = {
364
365
  61000301: { code: 61000301, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61000301' },
365
366
  61000302: { code: 61000302, httpStatus: 409, class: 'conflict', absence: '', uiObservation: 'conflict', retryable: false, docsPath: '/errors/61000302' },
366
367
  61000401: { code: 61000401, httpStatus: 401, class: 'unauthorized', absence: '', uiObservation: 'session_expired', retryable: false, docsPath: '/errors/61000401' },
367
- 61000402: { code: 61000402, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', retryable: false, docsPath: '/errors/61000402' },
368
- 61000403: { code: 61000403, httpStatus: 403, class: 'forbidden', absence: '', uiObservation: 'reauth_required', retryable: false, docsPath: '/errors/61000403' },
368
+ 61000402: { code: 61000402, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', name: 'MFA_INVALID_CODE', retryable: false, docsPath: '/errors/61000402' },
369
+ 61000403: { code: 61000403, httpStatus: 403, class: 'forbidden', absence: '', uiObservation: 'reauth_required', name: 'MFA_CHALLENGE_REQUIRED', retryable: false, docsPath: '/errors/61000403' },
370
+ 61000404: { code: 61000404, httpStatus: 403, class: 'forbidden', absence: '', uiObservation: 'reauth_required', name: 'MFA_CHALLENGE_USED', retryable: false, docsPath: '/errors/61000404' },
371
+ 61000405: { code: 61000405, httpStatus: 403, class: 'forbidden', absence: '', uiObservation: 'reauth_required', name: 'MFA_CHALLENGE_ATTEMPTS_EXCEEDED', retryable: false, docsPath: '/errors/61000405' },
369
372
  61000406: { code: 61000406, httpStatus: 403, class: 'forbidden', absence: '', uiObservation: 'forbidden', retryable: false, docsPath: '/errors/61000406' },
370
373
  61000407: { code: 61000407, httpStatus: 410, class: 'gone', absence: '', uiObservation: 'expired', retryable: false, docsPath: '/errors/61000407' },
371
374
  61000408: { code: 61000408, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61000408' },
375
+ 61000409: { code: 61000409, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', name: 'MFA_CODE_ALREADY_USED', retryable: false, docsPath: '/errors/61000409' },
376
+ 61000410: { code: 61000410, httpStatus: 429, class: 'limit', absence: '', uiObservation: 'rate_limited', name: 'MFA_ATTEMPTS_THROTTLED', retryable: true, docsPath: '/errors/61000410' },
372
377
  61000501: { code: 61000501, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61000501' },
373
378
  61000502: { code: 61000502, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', retryable: false, docsPath: '/errors/61000502' },
374
379
  61000601: { code: 61000601, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61000601' },
@@ -554,6 +559,7 @@ export const ERROR_SEMANTICS: Readonly<Record<number, ErrorSemantics>> = {
554
559
  61050012: { code: 61050012, httpStatus: 409, class: 'conflict', absence: '', uiObservation: 'conflict', retryable: false, docsPath: '/errors/61050012' },
555
560
  61050013: { code: 61050013, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61050013' },
556
561
  61050014: { code: 61050014, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61050014' },
562
+ 61050015: { code: 61050015, httpStatus: 403, class: 'forbidden', absence: '', uiObservation: 'forbidden', retryable: false, docsPath: '/errors/61050015' },
557
563
  61050020: { code: 61050020, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/61050020' },
558
564
  61050021: { code: 61050021, httpStatus: 429, class: 'limit', absence: '', uiObservation: 'rate_limited', retryable: true, docsPath: '/errors/61050021' },
559
565
  61050022: { code: 61050022, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', retryable: false, docsPath: '/errors/61050022' },
@@ -847,6 +853,18 @@ export const UNPROVISIONED_CODES: ReadonlySet<number> = new Set([]);
847
853
  export const EMPTY_STATE_CODES: ReadonlySet<number> = new Set([]);
848
854
 
849
855
  export const ERROR_SEMANTICS_META = {
850
- rowCount: 787,
851
- sourceSha256: 'f846240c034effe8725e853eb67ab31bf8bcad2595e4ff815ab132c85dfb08aa',
856
+ rowCount: 792,
857
+ sourceSha256: '962af7ad9e1f41b957fa8cacb6f1bdbf0f0a56cb8cbdf144107e1329df80c0cd',
852
858
  } as const;
859
+
860
+ /** 具名错误码常量(契约 name → code)。页面只消费常量,不写数字字面量。 */
861
+ export const ERROR_CODES = {
862
+ MFA_INVALID_CODE: 61000402,
863
+ MFA_CHALLENGE_REQUIRED: 61000403,
864
+ MFA_CHALLENGE_USED: 61000404,
865
+ MFA_CHALLENGE_ATTEMPTS_EXCEEDED: 61000405,
866
+ MFA_CODE_ALREADY_USED: 61000409,
867
+ MFA_ATTEMPTS_THROTTLED: 61000410,
868
+ } as const;
869
+
870
+ export type ErrorCodeName = keyof typeof ERROR_CODES;
package/src/index.ts CHANGED
@@ -248,6 +248,7 @@ export type { PaginationInfo, ListResult } from './utils/response';
248
248
 
249
249
  export {
250
250
  EMPTY_STATE_CODES,
251
+ ERROR_CODES,
251
252
  ERROR_SEMANTICS,
252
253
  ERROR_SEMANTICS_META,
253
254
  MAX_RETRIES,
@@ -262,4 +263,4 @@ export {
262
263
  semanticsOfError,
263
264
  shouldRetry,
264
265
  } from './utils/error-semantics';
265
- export type { Absence, ErrorClass, ErrorSemantics, UIObservation } from './utils/error-semantics';
266
+ export type { Absence, ErrorClass, ErrorCodeName, ErrorSemantics, UIObservation } from './utils/error-semantics';
@@ -16,14 +16,21 @@
16
16
  import { getHttpStatus, isForbiddenError, isRetryableError } from './query-state';
17
17
  import {
18
18
  EMPTY_STATE_CODES,
19
+ ERROR_CODES,
19
20
  ERROR_SEMANTICS,
20
21
  ERROR_SEMANTICS_META,
21
22
  UNPROVISIONED_CODES,
22
23
  } from '../generated/error-semantics';
23
- import type { Absence, ErrorClass, ErrorSemantics, UIObservation } from '../generated/error-semantics';
24
+ import type {
25
+ Absence,
26
+ ErrorClass,
27
+ ErrorCodeName,
28
+ ErrorSemantics,
29
+ UIObservation,
30
+ } from '../generated/error-semantics';
24
31
 
25
- export { EMPTY_STATE_CODES, ERROR_SEMANTICS, ERROR_SEMANTICS_META, UNPROVISIONED_CODES };
26
- export type { Absence, ErrorClass, ErrorSemantics, UIObservation };
32
+ export { EMPTY_STATE_CODES, ERROR_CODES, ERROR_SEMANTICS, ERROR_SEMANTICS_META, UNPROVISIONED_CODES };
33
+ export type { Absence, ErrorClass, ErrorCodeName, ErrorSemantics, UIObservation };
27
34
  export { getHttpStatus, isForbiddenError, isRetryableError };
28
35
 
29
36
  /** 单次查询最多重试次数(策略参数,唯一出处)。 */