@miaixz/sdk 0.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.
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +412 -0
- package/dist/api/client.d.ts +223 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +1069 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/endpoint.d.ts +10 -0
- package/dist/api/endpoint.d.ts.map +1 -0
- package/dist/api/endpoint.js +51 -0
- package/dist/api/endpoint.js.map +1 -0
- package/dist/api/errors.d.ts +180 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +173 -0
- package/dist/api/errors.js.map +1 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +5 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/request.d.ts +135 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +2 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/response.d.ts +69 -0
- package/dist/api/response.d.ts.map +1 -0
- package/dist/api/response.js +43 -0
- package/dist/api/response.js.map +1 -0
- package/dist/api/telemetry.d.ts +139 -0
- package/dist/api/telemetry.d.ts.map +1 -0
- package/dist/api/telemetry.js +2 -0
- package/dist/api/telemetry.js.map +1 -0
- package/dist/appearance/appearance.d.ts +161 -0
- package/dist/appearance/appearance.d.ts.map +1 -0
- package/dist/appearance/appearance.js +614 -0
- package/dist/appearance/appearance.js.map +1 -0
- package/dist/appearance/index.d.ts +3 -0
- package/dist/appearance/index.d.ts.map +1 -0
- package/dist/appearance/index.js +3 -0
- package/dist/appearance/index.js.map +1 -0
- package/dist/auth/auth.d.ts +197 -0
- package/dist/auth/auth.d.ts.map +1 -0
- package/dist/auth/auth.js +314 -0
- package/dist/auth/auth.js.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/config/config.d.ts +117 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +241 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -0
- package/dist/consts/index.d.ts +35 -0
- package/dist/consts/index.d.ts.map +1 -0
- package/dist/consts/index.js +35 -0
- package/dist/consts/index.js.map +1 -0
- package/dist/context/context.d.ts +123 -0
- package/dist/context/context.d.ts.map +1 -0
- package/dist/context/context.js +252 -0
- package/dist/context/context.js.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -0
- package/dist/contracts/host-context.d.ts +132 -0
- package/dist/contracts/host-context.d.ts.map +1 -0
- package/dist/contracts/host-context.js +2 -0
- package/dist/contracts/host-context.js.map +1 -0
- package/dist/contracts/index.d.ts +8 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/lifecycle.d.ts +49 -0
- package/dist/contracts/lifecycle.d.ts.map +1 -0
- package/dist/contracts/lifecycle.js +2 -0
- package/dist/contracts/lifecycle.js.map +1 -0
- package/dist/contracts/module-manifest.d.ts +110 -0
- package/dist/contracts/module-manifest.d.ts.map +1 -0
- package/dist/contracts/module-manifest.js +317 -0
- package/dist/contracts/module-manifest.js.map +1 -0
- package/dist/contracts/navigation.d.ts +36 -0
- package/dist/contracts/navigation.d.ts.map +1 -0
- package/dist/contracts/navigation.js +11 -0
- package/dist/contracts/navigation.js.map +1 -0
- package/dist/contracts/permission.d.ts +8 -0
- package/dist/contracts/permission.d.ts.map +1 -0
- package/dist/contracts/permission.js +14 -0
- package/dist/contracts/permission.js.map +1 -0
- package/dist/contracts/post-message.d.ts +124 -0
- package/dist/contracts/post-message.d.ts.map +1 -0
- package/dist/contracts/post-message.js +2 -0
- package/dist/contracts/post-message.js.map +1 -0
- package/dist/contracts/route.d.ts +45 -0
- package/dist/contracts/route.d.ts.map +1 -0
- package/dist/contracts/route.js +35 -0
- package/dist/contracts/route.js.map +1 -0
- package/dist/events/events.d.ts +191 -0
- package/dist/events/events.d.ts.map +1 -0
- package/dist/events/events.js +486 -0
- package/dist/events/events.js.map +1 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +2 -0
- package/dist/events/index.js.map +1 -0
- package/dist/files/files.d.ts +138 -0
- package/dist/files/files.d.ts.map +1 -0
- package/dist/files/files.js +144 -0
- package/dist/files/files.js.map +1 -0
- package/dist/files/index.d.ts +2 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +2 -0
- package/dist/files/index.js.map +1 -0
- package/dist/formatters/index.d.ts +44 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +50 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/i18n/default-translator.d.ts +17 -0
- package/dist/i18n/default-translator.d.ts.map +1 -0
- package/dist/i18n/default-translator.js +19 -0
- package/dist/i18n/default-translator.js.map +1 -0
- package/dist/i18n/i18n.d.ts +248 -0
- package/dist/i18n/i18n.d.ts.map +1 -0
- package/dist/i18n/i18n.js +617 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +2 -0
- package/dist/models/index.js.map +1 -0
- package/dist/permissions/index.d.ts +2 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +2 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/permissions/permissions.d.ts +67 -0
- package/dist/permissions/permissions.d.ts.map +1 -0
- package/dist/permissions/permissions.js +123 -0
- package/dist/permissions/permissions.js.map +1 -0
- package/dist/runtime/direct-host-bridge.d.ts +11 -0
- package/dist/runtime/direct-host-bridge.d.ts.map +1 -0
- package/dist/runtime/direct-host-bridge.js +299 -0
- package/dist/runtime/direct-host-bridge.js.map +1 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/post-message-bridge.d.ts +20 -0
- package/dist/runtime/post-message-bridge.d.ts.map +1 -0
- package/dist/runtime/post-message-bridge.js +1115 -0
- package/dist/runtime/post-message-bridge.js.map +1 -0
- package/dist/sdk.d.ts +177 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +214 -0
- package/dist/sdk.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.d.ts +246 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +358 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/types/api.d.ts +82 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +2 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/appearance.d.ts +85 -0
- package/dist/types/appearance.d.ts.map +1 -0
- package/dist/types/appearance.js +48 -0
- package/dist/types/appearance.js.map +1 -0
- package/dist/types/config.d.ts +49 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/context.d.ts +41 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/file.d.ts +48 -0
- package/dist/types/file.d.ts.map +1 -0
- package/dist/types/file.js +2 -0
- package/dist/types/file.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/organization.d.ts +56 -0
- package/dist/types/organization.d.ts.map +1 -0
- package/dist/types/organization.js +2 -0
- package/dist/types/organization.js.map +1 -0
- package/dist/types/pagination.d.ts +55 -0
- package/dist/types/pagination.d.ts.map +1 -0
- package/dist/types/pagination.js +13 -0
- package/dist/types/pagination.js.map +1 -0
- package/dist/types/permissions.d.ts +26 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/permissions.js +2 -0
- package/dist/types/permissions.js.map +1 -0
- package/dist/types/space.d.ts +43 -0
- package/dist/types/space.d.ts.map +1 -0
- package/dist/types/space.js +2 -0
- package/dist/types/space.js.map +1 -0
- package/dist/types/tenant.d.ts +31 -0
- package/dist/types/tenant.d.ts.map +1 -0
- package/dist/types/tenant.js +2 -0
- package/dist/types/tenant.js.map +1 -0
- package/dist/types/user.d.ts +48 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +2 -0
- package/dist/types/user.js.map +1 -0
- package/dist/utils/date.d.ts +9 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +11 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/number.d.ts +11 -0
- package/dist/utils/number.d.ts.map +1 -0
- package/dist/utils/number.js +13 -0
- package/dist/utils/number.js.map +1 -0
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +11 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils/string.d.ts +9 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +11 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/validators/index.d.ts +8 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +8 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +156 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAyB9E;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAMvC;;OAEG;IACM,IAAI,CAAS;IAEtB;;OAEG;IACM,OAAO,CAAW;IAE3B;;;;;OAKG;IACH,YAAY,OAAe,EAAE,OAAO,GAA0B,EAAE;QAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,KAAK,CAAC,OAAO,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC;QACxC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;aAC7D,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAChE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF;AAkCD;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,cAAc;IAChD;;OAEG;IACM,MAAM,CAAS;IAExB;;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AAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAClD;;;;;OAKG;IACH,YAAY,KAAe,EAAE,SAAS,GAAqB,6BAA6B;QACtF,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,YAAY,cAAc,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,YAAY,cAAc,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,SAAS,GAAqB,6BAA6B;IAE3D,IAAI,KAAK,YAAY,cAAc;QAAE,OAAO,KAAK,CAAC;IAClD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE;YACxD,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import { translateMiaixzDefaultMessage } from \"../i18n/default-translator.js\";\nimport type { MiaixzTranslator } from \"../i18n/index.js\";\n\n/**\n * Configures metadata attached to a Miaixz SDK error.\n *\n * @public\n */\nexport interface MiaixzSdkErrorOptions {\n /**\n * Optional stable machine-readable error code.\n */\n readonly code?: string;\n\n /**\n * Optional diagnostic details associated with the error.\n */\n readonly details?: unknown;\n\n /**\n * Optional original value that caused the error.\n */\n readonly cause?: unknown;\n}\n\n/**\n * Base class for errors created by the Miaixz SDK.\n *\n * @public\n */\nexport class MiaixzSdkError extends Error {\n /**\n * Original Error preserved for local diagnostics when one was supplied.\n */\n declare readonly cause?: Error;\n\n /**\n * Stable machine-readable error code.\n */\n readonly code: string;\n\n /**\n * Optional diagnostic details associated with the error.\n */\n readonly details?: unknown;\n\n /**\n * Creates an SDK error.\n *\n * @param message - Localized human-readable error message.\n * @param options - Stable code, diagnostic details, and original cause.\n */\n constructor(message: string, options: MiaixzSdkErrorOptions = {}) {\n const safeCause = options.cause instanceof Error ? options.cause : undefined;\n super(message, safeCause === undefined ? undefined : { cause: safeCause });\n this.name = \"MiaixzSdkError\";\n this.code = options.code ?? \"SDK_ERROR\";\n if (options.details !== undefined) this.details = options.details;\n else if (options.cause !== undefined && safeCause === undefined) {\n this.details = Object.freeze({ type: typeof options.cause });\n }\n }\n}\n\n/**\n * Configures request and response metadata attached to an API error.\n *\n * @public\n */\nexport interface MiaixzApiErrorOptions extends MiaixzSdkErrorOptions {\n /**\n * HTTP status code, or zero when no HTTP response exists.\n */\n readonly status: number;\n\n /**\n * HTTP method or request operation name.\n */\n readonly method: string;\n\n /**\n * URL associated with the failed request.\n */\n readonly url: string;\n\n /**\n * Optional request identifier returned by the server.\n */\n readonly requestId?: string;\n\n /**\n * Indicates whether retrying the request may succeed.\n */\n readonly retryable?: boolean;\n}\n\n/**\n * Error returned for HTTP failures, invalid envelopes, or non-zero business codes.\n *\n * @public\n */\nexport class MiaixzApiError extends MiaixzSdkError {\n /**\n * HTTP status code, or zero when no HTTP response exists.\n */\n readonly status: number;\n\n /**\n * HTTP method or request operation name.\n */\n readonly method: string;\n\n /**\n * URL associated with the failed request.\n */\n readonly url: string;\n\n /**\n * Optional request identifier returned by the server.\n */\n readonly requestId?: string;\n\n /**\n * Indicates whether retrying the request may succeed.\n */\n readonly retryable?: boolean;\n\n /**\n * Creates a structured API error.\n *\n * @param message - Backend or localized fallback message.\n * @param options - Request, response, and retry metadata.\n */\n constructor(message: string, options: MiaixzApiErrorOptions) {\n super(message, options);\n this.name = \"MiaixzApiError\";\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n if (options.retryable !== undefined) this.retryable = options.retryable;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n }\n}\n\n/**\n * Represents a transport failure before a valid HTTP response was received.\n *\n * @public\n */\nexport class MiaixzNetworkError extends MiaixzSdkError {\n /**\n * Creates a transport error.\n *\n * @param cause - Original transport error.\n * @param translate - Message translator.\n */\n constructor(cause?: unknown, translate: MiaixzTranslator = translateMiaixzDefaultMessage) {\n super(translate(\"sdk.error.network\"), { code: \"NETWORK_ERROR\", cause });\n this.name = \"MiaixzNetworkError\";\n }\n}\n\n/**\n * Represents a request cancelled after exceeding its configured timeout.\n *\n * @public\n */\nexport class MiaixzTimeoutError extends MiaixzSdkError {\n /**\n * Timeout threshold in milliseconds that cancelled the request.\n */\n readonly timeoutMs: number;\n\n /**\n * Creates a timeout error.\n *\n * @param timeoutMs - Timeout threshold in milliseconds.\n * @param cause - Original abort or transport error.\n * @param translate - Message translator.\n */\n constructor(\n timeoutMs: number,\n cause?: unknown,\n translate: MiaixzTranslator = translateMiaixzDefaultMessage,\n ) {\n super(translate(\"sdk.error.timeout\", { timeoutMs }), { code: \"TIMEOUT\", cause });\n this.name = \"MiaixzTimeoutError\";\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Represents cancellation requested by the caller.\n *\n * @public\n */\nexport class MiaixzAbortError extends MiaixzSdkError {\n /**\n * Creates a caller-requested cancellation error.\n *\n * @param cause - Original cancellation reason.\n * @param translate - Message translator.\n */\n constructor(cause?: unknown, translate: MiaixzTranslator = translateMiaixzDefaultMessage) {\n super(translate(\"sdk.error.aborted\"), { code: \"ABORTED\", cause });\n this.name = \"MiaixzAbortError\";\n }\n}\n\n/**\n * Determines whether a value is an error created by the Miaixz SDK.\n *\n * @param value - Value to inspect.\n * @returns Whether `value` is an SDK-created error.\n * @public\n */\nexport function isMiaixzSdkError(value: unknown): value is MiaixzSdkError {\n return value instanceof MiaixzSdkError;\n}\n\n/**\n * Determines whether a value contains Miaixz API request metadata.\n *\n * @param value - Value to inspect.\n * @returns Whether `value` contains Miaixz API request metadata.\n * @public\n */\nexport function isMiaixzApiError(value: unknown): value is MiaixzApiError {\n return value instanceof MiaixzApiError;\n}\n\n/**\n * Converts an arbitrary thrown value into a stable SDK error.\n *\n * @param value - Unknown caught value.\n * @param translate - Translator used for non-Error values.\n * @returns The original SDK error or a normalized wrapper.\n * @public\n */\nexport function normalizeMiaixzError(\n value: unknown,\n translate: MiaixzTranslator = translateMiaixzDefaultMessage,\n): MiaixzSdkError {\n if (value instanceof MiaixzSdkError) return value;\n if (value instanceof Error) {\n return new MiaixzSdkError(translate(\"sdk.error.unknown\"), {\n cause: value,\n });\n }\n return new MiaixzSdkError(translate(\"sdk.error.unknown\"), { cause: value });\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./client.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./request.js";
|
|
4
|
+
export * from "./response.js";
|
|
5
|
+
export type { MiaixzApiTelemetryHooks, MiaixzErrorEvent, MiaixzRequestEvent, MiaixzResponseEvent, } from "./telemetry.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,YAAY,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC","sourcesContent":["export * from \"./client.js\";\nexport * from \"./errors.js\";\nexport * from \"./request.js\";\nexport * from \"./response.js\";\nexport type {\n MiaixzApiTelemetryHooks,\n MiaixzErrorEvent,\n MiaixzRequestEvent,\n MiaixzResponseEvent,\n} from \"./telemetry.js\";\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP method supported by the Miaixz API client.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type MiaixzHttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
7
|
+
/**
|
|
8
|
+
* Selects how the API client parses an HTTP response body.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type MiaixzResponseType = "auto" | "json" | "text" | "blob" | "arrayBuffer" | "void";
|
|
13
|
+
/**
|
|
14
|
+
* Selects how the API client handles a Miaixz response envelope.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export type MiaixzEnvelopeMode = "required" | "optional" | "none";
|
|
19
|
+
/**
|
|
20
|
+
* Converts an untrusted API response value into a verified application value.
|
|
21
|
+
*
|
|
22
|
+
* @typeParam T - Verified value returned by the parser.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export type MiaixzResponseParser<T> = (value: unknown) => T;
|
|
26
|
+
/**
|
|
27
|
+
* Represents a scalar value accepted in a URL query parameter.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export type MiaixzQueryPrimitive = string | number | boolean | Date | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Represents a scalar or repeated URL query parameter value.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export type MiaixzQueryValue = MiaixzQueryPrimitive | readonly MiaixzQueryPrimitive[];
|
|
38
|
+
/**
|
|
39
|
+
* Maps URL query parameter names to supported values.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export type MiaixzQuery = Readonly<Record<string, MiaixzQueryValue>>;
|
|
44
|
+
/**
|
|
45
|
+
* Represents a body accepted by the Miaixz API client.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export type MiaixzRequestBody = BodyInit | Readonly<Record<string, unknown>> | readonly unknown[];
|
|
50
|
+
/**
|
|
51
|
+
* Describes a request after URL, headers, and options are prepared.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export interface MiaixzPreparedRequest {
|
|
56
|
+
/**
|
|
57
|
+
* Fully resolved request URL.
|
|
58
|
+
*/
|
|
59
|
+
readonly url: string;
|
|
60
|
+
/**
|
|
61
|
+
* Fetch initialization options for the request.
|
|
62
|
+
*/
|
|
63
|
+
readonly init: RequestInit;
|
|
64
|
+
/**
|
|
65
|
+
* Zero-based request attempt number.
|
|
66
|
+
*/
|
|
67
|
+
readonly attempt: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Transforms a prepared request before it is sent.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export type MiaixzRequestInterceptor = (request: MiaixzPreparedRequest) => MiaixzPreparedRequest | Promise<MiaixzPreparedRequest>;
|
|
75
|
+
/**
|
|
76
|
+
* Configures an individual request made by the Miaixz API client.
|
|
77
|
+
*
|
|
78
|
+
* @typeParam TBody - Type of the request body.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export interface MiaixzRequestOptions<TResponse = unknown, TBody extends MiaixzRequestBody = MiaixzRequestBody> {
|
|
82
|
+
/**
|
|
83
|
+
* Optional HTTP method used for the request.
|
|
84
|
+
*/
|
|
85
|
+
readonly method?: MiaixzHttpMethod;
|
|
86
|
+
/**
|
|
87
|
+
* Optional URL query parameters appended to the request path.
|
|
88
|
+
*/
|
|
89
|
+
readonly query?: MiaixzQuery;
|
|
90
|
+
/**
|
|
91
|
+
* Optional request-specific HTTP headers.
|
|
92
|
+
*/
|
|
93
|
+
readonly headers?: HeadersInit;
|
|
94
|
+
/**
|
|
95
|
+
* Optional request body.
|
|
96
|
+
*/
|
|
97
|
+
readonly body?: TBody;
|
|
98
|
+
/**
|
|
99
|
+
* Optional signal used to cancel the request.
|
|
100
|
+
*/
|
|
101
|
+
readonly signal?: AbortSignal;
|
|
102
|
+
/**
|
|
103
|
+
* Optional request timeout in milliseconds.
|
|
104
|
+
*/
|
|
105
|
+
readonly timeoutMs?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Optional Fetch credentials mode.
|
|
108
|
+
*/
|
|
109
|
+
readonly credentials?: RequestCredentials;
|
|
110
|
+
/**
|
|
111
|
+
* Optional response parsing mode.
|
|
112
|
+
*/
|
|
113
|
+
readonly responseType?: MiaixzResponseType;
|
|
114
|
+
/**
|
|
115
|
+
* JSON responses use the Miaixz errcode/errmsg/data envelope by default.
|
|
116
|
+
*/
|
|
117
|
+
readonly envelope?: MiaixzEnvelopeMode;
|
|
118
|
+
/**
|
|
119
|
+
* Indicates whether authentication headers should be attached.
|
|
120
|
+
*/
|
|
121
|
+
readonly authenticate?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Indicates whether active runtime-context headers should be attached.
|
|
124
|
+
*/
|
|
125
|
+
readonly includeContext?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Optional number of retry attempts for eligible requests.
|
|
128
|
+
*/
|
|
129
|
+
readonly retry?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Optional runtime parser applied after envelope handling and response interceptors.
|
|
132
|
+
*/
|
|
133
|
+
readonly parse?: MiaixzResponseParser<TResponse>;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=request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;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,OAAO,EAAE,qBAAqB,KAC3B,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CACnC,SAAS,GAAG,OAAO,EACnB,KAAK,SAAS,iBAAiB,GAAG,iBAAiB;IAEnD;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents an HTTP method supported by the Miaixz API client.\n *\n * @public\n */\nexport type MiaixzHttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\" | \"HEAD\" | \"OPTIONS\";\n\n/**\n * Selects how the API client parses an HTTP response body.\n *\n * @public\n */\nexport type MiaixzResponseType = \"auto\" | \"json\" | \"text\" | \"blob\" | \"arrayBuffer\" | \"void\";\n\n/**\n * Selects how the API client handles a Miaixz response envelope.\n *\n * @public\n */\nexport type MiaixzEnvelopeMode = \"required\" | \"optional\" | \"none\";\n\n/**\n * Converts an untrusted API response value into a verified application value.\n *\n * @typeParam T - Verified value returned by the parser.\n * @public\n */\nexport type MiaixzResponseParser<T> = (value: unknown) => T;\n\n/**\n * Represents a scalar value accepted in a URL query parameter.\n *\n * @public\n */\nexport type MiaixzQueryPrimitive = string | number | boolean | Date | null | undefined;\n\n/**\n * Represents a scalar or repeated URL query parameter value.\n *\n * @public\n */\nexport type MiaixzQueryValue = MiaixzQueryPrimitive | readonly MiaixzQueryPrimitive[];\n\n/**\n * Maps URL query parameter names to supported values.\n *\n * @public\n */\nexport type MiaixzQuery = Readonly<Record<string, MiaixzQueryValue>>;\n\n/**\n * Represents a body accepted by the Miaixz API client.\n *\n * @public\n */\nexport type MiaixzRequestBody = BodyInit | Readonly<Record<string, unknown>> | readonly unknown[];\n\n/**\n * Describes a request after URL, headers, and options are prepared.\n *\n * @public\n */\nexport interface MiaixzPreparedRequest {\n /**\n * Fully resolved request URL.\n */\n readonly url: string;\n\n /**\n * Fetch initialization options for the request.\n */\n readonly init: RequestInit;\n\n /**\n * Zero-based request attempt number.\n */\n readonly attempt: number;\n}\n\n/**\n * Transforms a prepared request before it is sent.\n *\n * @public\n */\nexport type MiaixzRequestInterceptor = (\n request: MiaixzPreparedRequest,\n) => MiaixzPreparedRequest | Promise<MiaixzPreparedRequest>;\n\n/**\n * Configures an individual request made by the Miaixz API client.\n *\n * @typeParam TBody - Type of the request body.\n * @public\n */\nexport interface MiaixzRequestOptions<\n TResponse = unknown,\n TBody extends MiaixzRequestBody = MiaixzRequestBody,\n> {\n /**\n * Optional HTTP method used for the request.\n */\n readonly method?: MiaixzHttpMethod;\n\n /**\n * Optional URL query parameters appended to the request path.\n */\n readonly query?: MiaixzQuery;\n\n /**\n * Optional request-specific HTTP headers.\n */\n readonly headers?: HeadersInit;\n\n /**\n * Optional request body.\n */\n readonly body?: TBody;\n\n /**\n * Optional signal used to cancel the request.\n */\n readonly signal?: AbortSignal;\n\n /**\n * Optional request timeout in milliseconds.\n */\n readonly timeoutMs?: number;\n\n /**\n * Optional Fetch credentials mode.\n */\n readonly credentials?: RequestCredentials;\n\n /**\n * Optional response parsing mode.\n */\n readonly responseType?: MiaixzResponseType;\n\n /**\n * JSON responses use the Miaixz errcode/errmsg/data envelope by default.\n */\n readonly envelope?: MiaixzEnvelopeMode;\n\n /**\n * Indicates whether authentication headers should be attached.\n */\n readonly authenticate?: boolean;\n\n /**\n * Indicates whether active runtime-context headers should be attached.\n */\n readonly includeContext?: boolean;\n\n /**\n * Optional number of retry attempts for eligible requests.\n */\n readonly retry?: number;\n\n /**\n * Optional runtime parser applied after envelope handling and response interceptors.\n */\n readonly parse?: MiaixzResponseParser<TResponse>;\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { MiaixzApiEnvelope } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Describes a successful HTTP response returned by the Miaixz API client.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - Type of the normalized response payload.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface MiaixzHttpResponse<T> {
|
|
9
|
+
/**
|
|
10
|
+
* Normalized response payload.
|
|
11
|
+
*/
|
|
12
|
+
readonly data: T;
|
|
13
|
+
/**
|
|
14
|
+
* HTTP status code.
|
|
15
|
+
*/
|
|
16
|
+
readonly status: number;
|
|
17
|
+
/**
|
|
18
|
+
* HTTP status text.
|
|
19
|
+
*/
|
|
20
|
+
readonly statusText: string;
|
|
21
|
+
/**
|
|
22
|
+
* Response headers returned by the server.
|
|
23
|
+
*/
|
|
24
|
+
readonly headers: Headers;
|
|
25
|
+
/**
|
|
26
|
+
* Optional request identifier returned by the server.
|
|
27
|
+
*/
|
|
28
|
+
readonly requestId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Final response URL after redirects.
|
|
31
|
+
*/
|
|
32
|
+
readonly url: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Transforms a normalized response before it reaches the caller.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export type MiaixzResponseInterceptor = (response: MiaixzHttpResponse<unknown>) => MiaixzHttpResponse<unknown> | Promise<MiaixzHttpResponse<unknown>>;
|
|
40
|
+
/**
|
|
41
|
+
* Validates the standard `{ errcode, errmsg, data }` response shape.
|
|
42
|
+
*
|
|
43
|
+
* @param value - Parsed response body.
|
|
44
|
+
* @returns Whether the body is a Miaixz API envelope.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare function isMiaixzApiEnvelope<T = unknown>(value: unknown): value is MiaixzApiEnvelope<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Determines whether an API result code represents success.
|
|
50
|
+
*
|
|
51
|
+
* @param value - API result code to inspect.
|
|
52
|
+
* @returns Whether an API envelope has the success code `0`.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare function isMiaixzApiSuccess(value: {
|
|
56
|
+
/**
|
|
57
|
+
* Business result code returned by the API.
|
|
58
|
+
*/
|
|
59
|
+
errcode: string | number;
|
|
60
|
+
}): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Returns an envelope's `data` value and leaves non-envelope values unchanged.
|
|
63
|
+
*
|
|
64
|
+
* @param value - Envelope or already-unwrapped value.
|
|
65
|
+
* @returns Unwrapped envelope data or the original non-envelope value.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function unwrapMiaixzData<T>(value: T | MiaixzApiEnvelope<T>):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|
|
2
|
+
* Validates the standard `{ errcode, errmsg, data }` response shape.
|
|
3
|
+
*
|
|
4
|
+
* @param value - Parsed response body.
|
|
5
|
+
* @returns Whether the body is a Miaixz API envelope.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export function isMiaixzApiEnvelope(value) {
|
|
9
|
+
const record = value;
|
|
10
|
+
return (typeof value === "object" &&
|
|
11
|
+
value !== null &&
|
|
12
|
+
"errcode" in value &&
|
|
13
|
+
(typeof record.errcode === "string" || typeof record.errcode === "number") &&
|
|
14
|
+
"errmsg" in value &&
|
|
15
|
+
typeof record.errmsg === "string" &&
|
|
16
|
+
"data" in value);
|
|
17
|
+
}
|
|
18
|
+
/* eslint-disable jsdoc/check-param-names, jsdoc/require-param -- TSDoc documents the inline field on its TypeScript property. */
|
|
19
|
+
/**
|
|
20
|
+
* Determines whether an API result code represents success.
|
|
21
|
+
*
|
|
22
|
+
* @param value - API result code to inspect.
|
|
23
|
+
* @returns Whether an API envelope has the success code `0`.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export function isMiaixzApiSuccess(value) {
|
|
27
|
+
return String(value.errcode) === "0";
|
|
28
|
+
}
|
|
29
|
+
/* eslint-enable jsdoc/check-param-names, jsdoc/require-param */
|
|
30
|
+
/**
|
|
31
|
+
* Returns an envelope's `data` value and leaves non-envelope values unchanged.
|
|
32
|
+
*
|
|
33
|
+
* @param value - Envelope or already-unwrapped value.
|
|
34
|
+
* @returns Unwrapped envelope data or the original non-envelope value.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export function unwrapMiaixzData(value) {
|
|
38
|
+
if (isMiaixzApiEnvelope(value)) {
|
|
39
|
+
return value.data;
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":"AAiDA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAc,KAAc;IAC7D,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,CAAC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC;QAC1E,QAAQ,IAAI,KAAK;QACjB,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QACjC,MAAM,IAAI,KAAK,CAChB,CAAC;AACJ,CAAC;AAED,iIAAiI;AACjI;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAKlC;IACC,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;AACvC,CAAC;AACD,gEAAgE;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAI,KAA+B;IACjE,IAAI,mBAAmB,CAAI,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { MiaixzApiEnvelope } from \"../types/index.js\";\n\n/**\n * Describes a successful HTTP response returned by the Miaixz API client.\n *\n * @typeParam T - Type of the normalized response payload.\n * @public\n */\nexport interface MiaixzHttpResponse<T> {\n /**\n * Normalized response payload.\n */\n readonly data: T;\n\n /**\n * HTTP status code.\n */\n readonly status: number;\n\n /**\n * HTTP status text.\n */\n readonly statusText: string;\n\n /**\n * Response headers returned by the server.\n */\n readonly headers: Headers;\n\n /**\n * Optional request identifier returned by the server.\n */\n readonly requestId?: string;\n\n /**\n * Final response URL after redirects.\n */\n readonly url: string;\n}\n\n/**\n * Transforms a normalized response before it reaches the caller.\n *\n * @public\n */\nexport type MiaixzResponseInterceptor = (\n response: MiaixzHttpResponse<unknown>,\n) => MiaixzHttpResponse<unknown> | Promise<MiaixzHttpResponse<unknown>>;\n\n/**\n * Validates the standard `{ errcode, errmsg, data }` response shape.\n *\n * @param value - Parsed response body.\n * @returns Whether the body is a Miaixz API envelope.\n * @public\n */\nexport function isMiaixzApiEnvelope<T = unknown>(value: unknown): value is MiaixzApiEnvelope<T> {\n const record = value as Record<string, unknown>;\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"errcode\" in value &&\n (typeof record.errcode === \"string\" || typeof record.errcode === \"number\") &&\n \"errmsg\" in value &&\n typeof record.errmsg === \"string\" &&\n \"data\" in value\n );\n}\n\n/* eslint-disable jsdoc/check-param-names, jsdoc/require-param -- TSDoc documents the inline field on its TypeScript property. */\n/**\n * Determines whether an API result code represents success.\n *\n * @param value - API result code to inspect.\n * @returns Whether an API envelope has the success code `0`.\n * @public\n */\nexport function isMiaixzApiSuccess(value: {\n /**\n * Business result code returned by the API.\n */\n errcode: string | number;\n}): boolean {\n return String(value.errcode) === \"0\";\n}\n/* eslint-enable jsdoc/check-param-names, jsdoc/require-param */\n\n/**\n * Returns an envelope's `data` value and leaves non-envelope values unchanged.\n *\n * @param value - Envelope or already-unwrapped value.\n * @returns Unwrapped envelope data or the original non-envelope value.\n * @public\n */\nexport function unwrapMiaixzData<T>(value: T | MiaixzApiEnvelope<T>): T {\n if (isMiaixzApiEnvelope<T>(value)) {\n return value.data;\n }\n return value;\n}\n"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { MiaixzHttpMethod } from "./request.js";
|
|
2
|
+
/**
|
|
3
|
+
* Receives immutable, redacted API lifecycle events without changing request behavior.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface MiaixzApiTelemetryHooks {
|
|
8
|
+
/**
|
|
9
|
+
* Observes a request immediately before Fetch is invoked.
|
|
10
|
+
*/
|
|
11
|
+
readonly onRequest?: (event: Readonly<MiaixzRequestEvent>) => void | Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Observes an HTTP response immediately after Fetch resolves.
|
|
14
|
+
*/
|
|
15
|
+
readonly onResponse?: (event: Readonly<MiaixzResponseEvent>) => void | Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Observes a normalized request failure.
|
|
18
|
+
*/
|
|
19
|
+
readonly onError?: (event: Readonly<MiaixzErrorEvent>) => void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Receives an exception thrown by a primary telemetry hook.
|
|
22
|
+
*/
|
|
23
|
+
readonly onHookError?: (error: unknown, hook: "request" | "response" | "error") => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Describes a safe request attempt for host-provided telemetry.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export interface MiaixzRequestEvent {
|
|
31
|
+
/**
|
|
32
|
+
* Correlates every attempt belonging to one logical request.
|
|
33
|
+
*/
|
|
34
|
+
readonly requestId: string;
|
|
35
|
+
/**
|
|
36
|
+
* Contains the request HTTP method.
|
|
37
|
+
*/
|
|
38
|
+
readonly method: MiaixzHttpMethod;
|
|
39
|
+
/**
|
|
40
|
+
* Contains the URL with credentials, fragments, and query values removed.
|
|
41
|
+
*/
|
|
42
|
+
readonly url: string;
|
|
43
|
+
/**
|
|
44
|
+
* Contains the zero-based request attempt number.
|
|
45
|
+
*/
|
|
46
|
+
readonly attempt: number;
|
|
47
|
+
/**
|
|
48
|
+
* Contains a frozen header snapshot with sensitive values redacted.
|
|
49
|
+
*/
|
|
50
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
51
|
+
/**
|
|
52
|
+
* Contains a frozen redacted JSON value or safe non-JSON body summary.
|
|
53
|
+
*/
|
|
54
|
+
readonly body?: unknown;
|
|
55
|
+
/**
|
|
56
|
+
* Contains the attempt start time as Unix epoch milliseconds.
|
|
57
|
+
*/
|
|
58
|
+
readonly startedAt: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Describes a safe HTTP response attempt for host-provided telemetry.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export interface MiaixzResponseEvent {
|
|
66
|
+
/**
|
|
67
|
+
* Correlates the response with its logical request.
|
|
68
|
+
*/
|
|
69
|
+
readonly requestId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Contains the request HTTP method.
|
|
72
|
+
*/
|
|
73
|
+
readonly method: MiaixzHttpMethod;
|
|
74
|
+
/**
|
|
75
|
+
* Contains the URL with credentials, fragments, and query values removed.
|
|
76
|
+
*/
|
|
77
|
+
readonly url: string;
|
|
78
|
+
/**
|
|
79
|
+
* Contains the zero-based request attempt number.
|
|
80
|
+
*/
|
|
81
|
+
readonly attempt: number;
|
|
82
|
+
/**
|
|
83
|
+
* Contains the HTTP response status.
|
|
84
|
+
*/
|
|
85
|
+
readonly status: number;
|
|
86
|
+
/**
|
|
87
|
+
* Contains elapsed time from attempt start through response receipt.
|
|
88
|
+
*/
|
|
89
|
+
readonly durationMs: number;
|
|
90
|
+
/**
|
|
91
|
+
* Contains a frozen header snapshot with sensitive values redacted.
|
|
92
|
+
*/
|
|
93
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Describes a safe normalized failure for host-provided telemetry.
|
|
97
|
+
*
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export interface MiaixzErrorEvent {
|
|
101
|
+
/**
|
|
102
|
+
* Correlates the failure with its logical request.
|
|
103
|
+
*/
|
|
104
|
+
readonly requestId: string;
|
|
105
|
+
/**
|
|
106
|
+
* Contains the request HTTP method.
|
|
107
|
+
*/
|
|
108
|
+
readonly method: MiaixzHttpMethod;
|
|
109
|
+
/**
|
|
110
|
+
* Contains the URL with credentials, fragments, and query values removed.
|
|
111
|
+
*/
|
|
112
|
+
readonly url: string;
|
|
113
|
+
/**
|
|
114
|
+
* Contains the zero-based request attempt number.
|
|
115
|
+
*/
|
|
116
|
+
readonly attempt: number;
|
|
117
|
+
/**
|
|
118
|
+
* Contains elapsed time from attempt start through failure normalization.
|
|
119
|
+
*/
|
|
120
|
+
readonly durationMs: number;
|
|
121
|
+
/**
|
|
122
|
+
* Contains a frozen error summary without causes or diagnostic payloads.
|
|
123
|
+
*/
|
|
124
|
+
readonly error: Readonly<{
|
|
125
|
+
/**
|
|
126
|
+
* Contains the stable JavaScript error class name.
|
|
127
|
+
*/
|
|
128
|
+
name: string;
|
|
129
|
+
/**
|
|
130
|
+
* Contains the stable machine-readable SDK error code.
|
|
131
|
+
*/
|
|
132
|
+
code: string;
|
|
133
|
+
/**
|
|
134
|
+
* Contains the localized, content-safe error message.
|
|
135
|
+
*/
|
|
136
|
+
message: string;
|
|
137
|
+
}>;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/api/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnF;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErF;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,I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AC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;QACvB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/api/telemetry.ts"],"names":[],"mappings":"","sourcesContent":["import type { MiaixzHttpMethod } from \"./request.js\";\n\n/**\n * Receives immutable, redacted API lifecycle events without changing request behavior.\n *\n * @public\n */\nexport interface MiaixzApiTelemetryHooks {\n /**\n * Observes a request immediately before Fetch is invoked.\n */\n readonly onRequest?: (event: Readonly<MiaixzRequestEvent>) => void | Promise<void>;\n\n /**\n * Observes an HTTP response immediately after Fetch resolves.\n */\n readonly onResponse?: (event: Readonly<MiaixzResponseEvent>) => void | Promise<void>;\n\n /**\n * Observes a normalized request failure.\n */\n readonly onError?: (event: Readonly<MiaixzErrorEvent>) => void | Promise<void>;\n\n /**\n * Receives an exception thrown by a primary telemetry hook.\n */\n readonly onHookError?: (error: unknown, hook: \"request\" | \"response\" | \"error\") => void;\n}\n\n/**\n * Describes a safe request attempt for host-provided telemetry.\n *\n * @public\n */\nexport interface MiaixzRequestEvent {\n /**\n * Correlates every attempt belonging to one logical request.\n */\n readonly requestId: string;\n\n /**\n * Contains the request HTTP method.\n */\n readonly method: MiaixzHttpMethod;\n\n /**\n * Contains the URL with credentials, fragments, and query values removed.\n */\n readonly url: string;\n\n /**\n * Contains the zero-based request attempt number.\n */\n readonly attempt: number;\n\n /**\n * Contains a frozen header snapshot with sensitive values redacted.\n */\n readonly headers: Readonly<Record<string, string>>;\n\n /**\n * Contains a frozen redacted JSON value or safe non-JSON body summary.\n */\n readonly body?: unknown;\n\n /**\n * Contains the attempt start time as Unix epoch milliseconds.\n */\n readonly startedAt: number;\n}\n\n/**\n * Describes a safe HTTP response attempt for host-provided telemetry.\n *\n * @public\n */\nexport interface MiaixzResponseEvent {\n /**\n * Correlates the response with its logical request.\n */\n readonly requestId: string;\n\n /**\n * Contains the request HTTP method.\n */\n readonly method: MiaixzHttpMethod;\n\n /**\n * Contains the URL with credentials, fragments, and query values removed.\n */\n readonly url: string;\n\n /**\n * Contains the zero-based request attempt number.\n */\n readonly attempt: number;\n\n /**\n * Contains the HTTP response status.\n */\n readonly status: number;\n\n /**\n * Contains elapsed time from attempt start through response receipt.\n */\n readonly durationMs: number;\n\n /**\n * Contains a frozen header snapshot with sensitive values redacted.\n */\n readonly headers: Readonly<Record<string, string>>;\n}\n\n/**\n * Describes a safe normalized failure for host-provided telemetry.\n *\n * @public\n */\nexport interface MiaixzErrorEvent {\n /**\n * Correlates the failure with its logical request.\n */\n readonly requestId: string;\n\n /**\n * Contains the request HTTP method.\n */\n readonly method: MiaixzHttpMethod;\n\n /**\n * Contains the URL with credentials, fragments, and query values removed.\n */\n readonly url: string;\n\n /**\n * Contains the zero-based request attempt number.\n */\n readonly attempt: number;\n\n /**\n * Contains elapsed time from attempt start through failure normalization.\n */\n readonly durationMs: number;\n\n /**\n * Contains a frozen error summary without causes or diagnostic payloads.\n */\n readonly error: Readonly<{\n /**\n * Contains the stable JavaScript error class name.\n */\n name: string;\n\n /**\n * Contains the stable machine-readable SDK error code.\n */\n code: string;\n\n /**\n * Contains the localized, content-safe error message.\n */\n message: string;\n }>;\n}\n"]}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { MiaixzEventBus, MiaixzSdkEventMap } from "../events/index.js";
|
|
2
|
+
import type { MiaixzTranslator } from "../i18n/index.js";
|
|
3
|
+
import { type MiaixzKeyValueStorage, type MiaixzStorageMigration } from "../storage/index.js";
|
|
4
|
+
import { type MiaixzAppearanceSettings, type MiaixzColorMode, type MiaixzDensity, type MiaixzThemeColorToken } from "../types/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Defines the complete built-in light theme used for validation and CSS mirroring.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare const miaixzLightThemeColors: Readonly<Record<MiaixzThemeColorToken, string>>;
|
|
11
|
+
/**
|
|
12
|
+
* Defines the complete built-in dark theme used for validation and CSS mirroring.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare const miaixzDarkThemeColors: Readonly<Record<MiaixzThemeColorToken, string>>;
|
|
17
|
+
/**
|
|
18
|
+
* Defines the default Miaixz appearance settings.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const miaixzDefaultAppearance: Readonly<MiaixzAppearanceSettings>;
|
|
23
|
+
/**
|
|
24
|
+
* Configures a Miaixz appearance manager.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export interface MiaixzAppearanceManagerOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Identifies the consuming frontend application.
|
|
31
|
+
*/
|
|
32
|
+
readonly appId: string;
|
|
33
|
+
/**
|
|
34
|
+
* Identifies the optional initial tenant persistence boundary.
|
|
35
|
+
*/
|
|
36
|
+
readonly tenantId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Supplies complete settings merged over persisted settings at construction.
|
|
39
|
+
*/
|
|
40
|
+
readonly initialAppearance?: MiaixzAppearanceSettings;
|
|
41
|
+
/**
|
|
42
|
+
* Supplies an optional versioned persistence adapter.
|
|
43
|
+
*/
|
|
44
|
+
readonly storage?: MiaixzKeyValueStorage;
|
|
45
|
+
/**
|
|
46
|
+
* Supplies an optional continuous appearance migration chain.
|
|
47
|
+
*/
|
|
48
|
+
readonly migrations?: readonly MiaixzStorageMigration[];
|
|
49
|
+
/**
|
|
50
|
+
* Supplies an optional event bus for local or cross-service synchronization.
|
|
51
|
+
*/
|
|
52
|
+
readonly events?: MiaixzEventBus<MiaixzSdkEventMap>;
|
|
53
|
+
/**
|
|
54
|
+
* Supplies the translator used for appearance validation errors.
|
|
55
|
+
*/
|
|
56
|
+
readonly translate?: MiaixzTranslator;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Determines whether a value is a supported Miaixz color mode.
|
|
60
|
+
*
|
|
61
|
+
* @param value - Value to inspect.
|
|
62
|
+
* @returns Whether the value is a supported color mode.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare function isMiaixzColorMode(value: unknown): value is MiaixzColorMode;
|
|
66
|
+
/**
|
|
67
|
+
* Determines whether a value is a supported Miaixz density.
|
|
68
|
+
*
|
|
69
|
+
* @param value - Value to inspect.
|
|
70
|
+
* @returns Whether the value is a supported density.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare function isMiaixzDensity(value: unknown): value is MiaixzDensity;
|
|
74
|
+
/**
|
|
75
|
+
* Parses, normalizes, validates, and freezes appearance settings.
|
|
76
|
+
*
|
|
77
|
+
* @param value - Untrusted appearance settings to parse.
|
|
78
|
+
* @returns A deeply frozen settings snapshot with uppercase custom colors.
|
|
79
|
+
* @throws MiaixzSdkError When object shape, values, colors, or contrast are invalid.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export declare function parseMiaixzAppearanceSettings(value: unknown): MiaixzAppearanceSettings;
|
|
83
|
+
/**
|
|
84
|
+
* Determines whether a value satisfies the complete appearance contract.
|
|
85
|
+
*
|
|
86
|
+
* @param value - Untrusted appearance settings to inspect.
|
|
87
|
+
* @returns Whether parsing and contrast validation both succeed.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export declare function isMiaixzAppearanceSettings(value: unknown): value is MiaixzAppearanceSettings;
|
|
91
|
+
/**
|
|
92
|
+
* Validates all frozen WCAG contrast pairs for an appearance.
|
|
93
|
+
*
|
|
94
|
+
* @param appearance - Appearance settings whose merged themes are validated.
|
|
95
|
+
* @throws MiaixzSdkError When a custom color is invalid or a pair misses its threshold.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export declare function validateMiaixzThemeContrast(appearance: Readonly<MiaixzAppearanceSettings>): void;
|
|
99
|
+
/**
|
|
100
|
+
* Manages versioned, tenant-scoped appearance state without accessing the DOM.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare class MiaixzAppearanceManager {
|
|
105
|
+
#private;
|
|
106
|
+
/**
|
|
107
|
+
* Creates a validated appearance manager for one application and tenant scope.
|
|
108
|
+
*
|
|
109
|
+
* @param options - Required application identity and optional runtime adapters.
|
|
110
|
+
* @throws MiaixzSdkError When scope, migrations, initial settings, or contrast are invalid.
|
|
111
|
+
*/
|
|
112
|
+
constructor(options: Readonly<MiaixzAppearanceManagerOptions>);
|
|
113
|
+
/**
|
|
114
|
+
* Returns the current deeply frozen appearance snapshot.
|
|
115
|
+
*
|
|
116
|
+
* @returns Current normalized appearance settings.
|
|
117
|
+
*/
|
|
118
|
+
getSnapshot(): Readonly<MiaixzAppearanceSettings>;
|
|
119
|
+
/**
|
|
120
|
+
* Replaces the complete appearance after atomic validation.
|
|
121
|
+
*
|
|
122
|
+
* @param appearance - Complete appearance settings to commit.
|
|
123
|
+
* @throws MiaixzSdkError When settings, colors, or contrast are invalid.
|
|
124
|
+
*/
|
|
125
|
+
set(appearance: MiaixzAppearanceSettings): void;
|
|
126
|
+
/**
|
|
127
|
+
* Shallowly merges and commits a partial appearance update.
|
|
128
|
+
*
|
|
129
|
+
* @param appearance - Top-level settings fields to replace.
|
|
130
|
+
* @throws MiaixzSdkError When merged settings, colors, or contrast are invalid.
|
|
131
|
+
*/
|
|
132
|
+
patch(appearance: Partial<MiaixzAppearanceSettings>): void;
|
|
133
|
+
/**
|
|
134
|
+
* Reloads appearance state from a new validated tenant scope.
|
|
135
|
+
*
|
|
136
|
+
* @param tenantId - Optional tenant identifier, or undefined for global scope.
|
|
137
|
+
* @throws MiaixzSdkError When the new scope or migration configuration is invalid.
|
|
138
|
+
*/
|
|
139
|
+
setScope(tenantId?: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Registers a listener for committed appearance snapshots.
|
|
142
|
+
*
|
|
143
|
+
* @param listener - Callback invoked synchronously after each committed change.
|
|
144
|
+
* @returns An idempotent function that removes the listener.
|
|
145
|
+
*/
|
|
146
|
+
subscribe(listener: (appearance: Readonly<MiaixzAppearanceSettings>) => void): () => void;
|
|
147
|
+
/**
|
|
148
|
+
* Releases the event subscription and all local appearance listeners.
|
|
149
|
+
*/
|
|
150
|
+
destroy(): void;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Creates a tenant-aware appearance manager without DOM side effects.
|
|
154
|
+
*
|
|
155
|
+
* @param options - Required application identity and optional runtime adapters.
|
|
156
|
+
* @returns Configured appearance manager.
|
|
157
|
+
* @throws MiaixzSdkError When scope, migrations, initial settings, or contrast are invalid.
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare function createMiaixzAppearanceManager(options: Readonly<MiaixzAppearanceManagerOptions>): MiaixzAppearanceManager;
|
|
161
|
+
//# sourceMappingURL=appearance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../src/appearance/appearance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KA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