@private.me/xbind 1.2.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/AGENTS.md +778 -0
- package/LICENSE.md +27 -0
- package/README.md +400 -0
- package/dist-standalone/_deps/crypto/base64.d.ts +29 -0
- package/dist-standalone/_deps/crypto/base64.js +97 -0
- package/dist-standalone/_deps/crypto/cjs/base64.js +103 -0
- package/dist-standalone/_deps/crypto/cjs/errors.js +119 -0
- package/dist-standalone/_deps/crypto/cjs/hmac.js +71 -0
- package/dist-standalone/_deps/crypto/cjs/index.js +86 -0
- package/dist-standalone/_deps/crypto/cjs/padding.js +57 -0
- package/dist-standalone/_deps/crypto/cjs/share-header.js +68 -0
- package/dist-standalone/_deps/crypto/cjs/shares.js +152 -0
- package/dist-standalone/_deps/crypto/cjs/tlv.js +199 -0
- package/dist-standalone/_deps/crypto/cjs/uuid.js +61 -0
- package/dist-standalone/_deps/crypto/cjs/verify.js +24 -0
- package/dist-standalone/_deps/crypto/cjs/xorida.js +221 -0
- package/dist-standalone/_deps/crypto/errors.d.ts +51 -0
- package/dist-standalone/_deps/crypto/errors.js +109 -0
- package/dist-standalone/_deps/crypto/hmac.d.ts +39 -0
- package/dist-standalone/_deps/crypto/hmac.js +66 -0
- package/dist-standalone/_deps/crypto/index.d.ts +20 -0
- package/dist-standalone/_deps/crypto/index.js +45 -0
- package/dist-standalone/_deps/crypto/padding.d.ts +19 -0
- package/dist-standalone/_deps/crypto/padding.js +53 -0
- package/dist-standalone/_deps/crypto/share-header.d.ts +44 -0
- package/dist-standalone/_deps/crypto/share-header.js +63 -0
- package/dist-standalone/_deps/crypto/shares.d.ts +27 -0
- package/dist-standalone/_deps/crypto/shares.js +148 -0
- package/dist-standalone/_deps/crypto/tlv.d.ts +26 -0
- package/dist-standalone/_deps/crypto/tlv.js +195 -0
- package/dist-standalone/_deps/crypto/uuid.d.ts +22 -0
- package/dist-standalone/_deps/crypto/uuid.js +56 -0
- package/dist-standalone/_deps/crypto/verify.d.ts +15 -0
- package/dist-standalone/_deps/crypto/verify.js +15 -0
- package/dist-standalone/_deps/crypto/xorida.d.ts +44 -0
- package/dist-standalone/_deps/crypto/xorida.js +215 -0
- package/dist-standalone/_deps/mldsa-wasm/LICENSE +24 -0
- package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1920 -0
- package/dist-standalone/_deps/mldsa-wasm/package.json +46 -0
- package/dist-standalone/_deps/mldsa-wasm/types/mldsa.d.ts +30 -0
- package/dist-standalone/_deps/shared/cjs/errors.js +582 -0
- package/dist-standalone/_deps/shared/cjs/index.js +492 -0
- package/dist-standalone/_deps/shared/cjs/package.json +1 -0
- package/dist-standalone/_deps/shared/cjs/types.js +403 -0
- package/dist-standalone/_deps/shared/errors.d.ts +48 -0
- package/dist-standalone/_deps/shared/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/shared/errors.js +192 -0
- package/dist-standalone/_deps/shared/errors.js.map +1 -0
- package/dist-standalone/_deps/shared/index.d.ts +4 -0
- package/dist-standalone/_deps/shared/index.d.ts.map +1 -0
- package/dist-standalone/_deps/shared/index.js +78 -0
- package/dist-standalone/_deps/shared/index.js.map +1 -0
- package/dist-standalone/_deps/shared/types.d.ts +1097 -0
- package/dist-standalone/_deps/shared/types.d.ts.map +1 -0
- package/dist-standalone/_deps/shared/types.js +89 -0
- package/dist-standalone/_deps/shared/types.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts +115 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts +13 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/package.json +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts +39 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +83 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts +99 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js +143 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts +32 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.js +119 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts +109 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.js +8 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/errors.d.ts +115 -0
- package/dist-standalone/_deps/ux-helpers/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/errors.js +253 -0
- package/dist-standalone/_deps/ux-helpers/errors.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/index.d.ts +13 -0
- package/dist-standalone/_deps/ux-helpers/index.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/index.js +16 -0
- package/dist-standalone/_deps/ux-helpers/index.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/pagination.d.ts +39 -0
- package/dist-standalone/_deps/ux-helpers/pagination.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/pagination.js +79 -0
- package/dist-standalone/_deps/ux-helpers/pagination.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/progress.d.ts +99 -0
- package/dist-standalone/_deps/ux-helpers/progress.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/progress.js +138 -0
- package/dist-standalone/_deps/ux-helpers/progress.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/search.d.ts +32 -0
- package/dist-standalone/_deps/ux-helpers/search.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/search.js +116 -0
- package/dist-standalone/_deps/ux-helpers/search.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/types.d.ts +109 -0
- package/dist-standalone/_deps/ux-helpers/types.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/types.js +7 -0
- package/dist-standalone/_deps/ux-helpers/types.js.map +1 -0
- package/dist-standalone/_deps/xchange/auto-accept.d.ts +127 -0
- package/dist-standalone/_deps/xchange/auto-accept.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/errors.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/index.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/package.json +1 -0
- package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -0
- package/dist-standalone/_deps/xchange/errors.d.ts +69 -0
- package/dist-standalone/_deps/xchange/errors.js +1 -0
- package/dist-standalone/_deps/xchange/index.d.ts +15 -0
- package/dist-standalone/_deps/xchange/index.js +1 -0
- package/dist-standalone/_deps/xchange/invite-client.d.ts +178 -0
- package/dist-standalone/_deps/xchange/invite-client.js +1 -0
- package/dist-standalone/_deps/xchange/lazy-init.d.ts +176 -0
- package/dist-standalone/_deps/xchange/lazy-init.js +1 -0
- package/dist-standalone/_deps/xchange/trust-integration.d.ts +102 -0
- package/dist-standalone/_deps/xchange/trust-integration.js +1 -0
- package/dist-standalone/_deps/xchange/xchange.d.ts +60 -0
- package/dist-standalone/_deps/xchange/xchange.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/index.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/package.json +1 -0
- package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/types.js +1 -0
- package/dist-standalone/_deps/xregistry/discovery.d.ts +126 -0
- package/dist-standalone/_deps/xregistry/discovery.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/discovery.js +1 -0
- package/dist-standalone/_deps/xregistry/discovery.js.map +1 -0
- package/dist-standalone/_deps/xregistry/errors.d.ts +41 -0
- package/dist-standalone/_deps/xregistry/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/errors.js +1 -0
- package/dist-standalone/_deps/xregistry/errors.js.map +1 -0
- package/dist-standalone/_deps/xregistry/index.d.ts +8 -0
- package/dist-standalone/_deps/xregistry/index.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/index.js +1 -0
- package/dist-standalone/_deps/xregistry/index.js.map +1 -0
- package/dist-standalone/_deps/xregistry/registry.d.ts +85 -0
- package/dist-standalone/_deps/xregistry/registry.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/registry.js +1 -0
- package/dist-standalone/_deps/xregistry/registry.js.map +1 -0
- package/dist-standalone/_deps/xregistry/schema.d.ts +81 -0
- package/dist-standalone/_deps/xregistry/schema.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/schema.js +1 -0
- package/dist-standalone/_deps/xregistry/schema.js.map +1 -0
- package/dist-standalone/_deps/xregistry/types.d.ts +95 -0
- package/dist-standalone/_deps/xregistry/types.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/types.js +1 -0
- package/dist-standalone/_deps/xregistry/types.js.map +1 -0
- package/dist-standalone/agent-call.d.ts +286 -0
- package/dist-standalone/agent-call.js +642 -0
- package/dist-standalone/agent-sdk.d.ts +207 -0
- package/dist-standalone/agent-sdk.js +328 -0
- package/dist-standalone/agent.d.ts +670 -0
- package/dist-standalone/agent.js +1529 -0
- package/dist-standalone/approval.d.ts +145 -0
- package/dist-standalone/approval.js +193 -0
- package/dist-standalone/auth.d.ts +75 -0
- package/dist-standalone/auth.js +219 -0
- package/dist-standalone/auto-accept.d.ts +102 -0
- package/dist-standalone/auto-accept.js +229 -0
- package/dist-standalone/backup-config.d.ts +150 -0
- package/dist-standalone/backup-config.js +201 -0
- package/dist-standalone/checkpoint.d.ts +125 -0
- package/dist-standalone/checkpoint.js +186 -0
- package/dist-standalone/cjs/agent-call.js +651 -0
- package/dist-standalone/cjs/agent-sdk.js +332 -0
- package/dist-standalone/cjs/agent.js +1566 -0
- package/dist-standalone/cjs/approval.js +199 -0
- package/dist-standalone/cjs/auth.js +225 -0
- package/dist-standalone/cjs/auto-accept.js +233 -0
- package/dist-standalone/cjs/backup-config.js +207 -0
- package/dist-standalone/cjs/checkpoint.js +193 -0
- package/dist-standalone/cjs/cli/init.js +487 -0
- package/dist-standalone/cjs/connect.js +312 -0
- package/dist-standalone/cjs/did-document.js +101 -0
- package/dist-standalone/cjs/did-privateme.js +130 -0
- package/dist-standalone/cjs/did-web.js +201 -0
- package/dist-standalone/cjs/discovery.js +462 -0
- package/dist-standalone/cjs/dual-mode.js +251 -0
- package/dist-standalone/cjs/email-templates.js +313 -0
- package/dist-standalone/cjs/email-transport.js +239 -0
- package/dist-standalone/cjs/envelope.js +510 -0
- package/dist-standalone/cjs/errors.js +562 -0
- package/dist-standalone/cjs/gateway-state.js +55 -0
- package/dist-standalone/cjs/gateway-transport.js +120 -0
- package/dist-standalone/cjs/guardrails.js +223 -0
- package/dist-standalone/cjs/http-compat.js +272 -0
- package/dist-standalone/cjs/identity.js +541 -0
- package/dist-standalone/cjs/index.js +224 -0
- package/dist-standalone/cjs/invitation.js +421 -0
- package/dist-standalone/cjs/invite.js +328 -0
- package/dist-standalone/cjs/key-agreement.js +246 -0
- package/dist-standalone/cjs/lazy-init.js +300 -0
- package/dist-standalone/cjs/mdns-discovery.js +202 -0
- package/dist-standalone/cjs/nonce-store.js +66 -0
- package/dist-standalone/cjs/package.json +3 -0
- package/dist-standalone/cjs/pairing-manager.js +223 -0
- package/dist-standalone/cjs/policy.js +320 -0
- package/dist-standalone/cjs/redis-nonce-store.js +76 -0
- package/dist-standalone/cjs/registry-middleware.js +50 -0
- package/dist-standalone/cjs/retry-transport.js +102 -0
- package/dist-standalone/cjs/security-policy.js +204 -0
- package/dist-standalone/cjs/split-channel.js +177 -0
- package/dist-standalone/cjs/subscription-proof.js +230 -0
- package/dist-standalone/cjs/succession.js +148 -0
- package/dist-standalone/cjs/transport.js +63 -0
- package/dist-standalone/cjs/trust-registry.js +742 -0
- package/dist-standalone/cjs/verify.js +25 -0
- package/dist-standalone/cjs/xfetch.js +252 -0
- package/dist-standalone/cli/init.d.ts +63 -0
- package/dist-standalone/cli/init.js +450 -0
- package/dist-standalone/connect.d.ts +143 -0
- package/dist-standalone/connect.js +274 -0
- package/dist-standalone/did-document.d.ts +65 -0
- package/dist-standalone/did-document.js +96 -0
- package/dist-standalone/did-privateme.d.ts +70 -0
- package/dist-standalone/did-privateme.js +121 -0
- package/dist-standalone/did-web.d.ts +73 -0
- package/dist-standalone/did-web.js +196 -0
- package/dist-standalone/discovery.d.ts +176 -0
- package/dist-standalone/discovery.js +458 -0
- package/dist-standalone/dual-mode.d.ts +145 -0
- package/dist-standalone/dual-mode.js +247 -0
- package/dist-standalone/email-templates.d.ts +41 -0
- package/dist-standalone/email-templates.js +309 -0
- package/dist-standalone/email-transport.d.ts +139 -0
- package/dist-standalone/email-transport.js +232 -0
- package/dist-standalone/envelope.d.ts +288 -0
- package/dist-standalone/envelope.js +497 -0
- package/dist-standalone/errors.d.ts +74 -0
- package/dist-standalone/errors.js +548 -0
- package/dist-standalone/gateway-state.d.ts +32 -0
- package/dist-standalone/gateway-state.js +51 -0
- package/dist-standalone/gateway-transport.d.ts +59 -0
- package/dist-standalone/gateway-transport.js +116 -0
- package/dist-standalone/guardrails.d.ts +136 -0
- package/dist-standalone/guardrails.js +216 -0
- package/dist-standalone/http-compat.d.ts +150 -0
- package/dist-standalone/http-compat.js +267 -0
- package/dist-standalone/identity.d.ts +176 -0
- package/dist-standalone/identity.js +516 -0
- package/dist-standalone/index.d.ts +83 -0
- package/dist-standalone/index.js +51 -0
- package/dist-standalone/invitation.d.ts +211 -0
- package/dist-standalone/invitation.js +415 -0
- package/dist-standalone/invite.d.ts +192 -0
- package/dist-standalone/invite.js +324 -0
- package/dist-standalone/key-agreement.d.ts +122 -0
- package/dist-standalone/key-agreement.js +236 -0
- package/dist-standalone/lazy-init.d.ts +167 -0
- package/dist-standalone/lazy-init.js +295 -0
- package/dist-standalone/mdns-discovery.d.ts +117 -0
- package/dist-standalone/mdns-discovery.js +195 -0
- package/dist-standalone/nonce-store.d.ts +39 -0
- package/dist-standalone/nonce-store.js +62 -0
- package/dist-standalone/package.json +11 -0
- package/dist-standalone/pairing-manager.d.ts +147 -0
- package/dist-standalone/pairing-manager.js +219 -0
- package/dist-standalone/policy.d.ts +150 -0
- package/dist-standalone/policy.js +315 -0
- package/dist-standalone/redis-nonce-store.d.ts +93 -0
- package/dist-standalone/redis-nonce-store.js +72 -0
- package/dist-standalone/registry-middleware.d.ts +38 -0
- package/dist-standalone/registry-middleware.js +47 -0
- package/dist-standalone/retry-transport.d.ts +76 -0
- package/dist-standalone/retry-transport.js +98 -0
- package/dist-standalone/security-policy.d.ts +146 -0
- package/dist-standalone/security-policy.js +198 -0
- package/dist-standalone/split-channel.d.ts +69 -0
- package/dist-standalone/split-channel.js +171 -0
- package/dist-standalone/subscription-proof.d.ts +103 -0
- package/dist-standalone/subscription-proof.js +224 -0
- package/dist-standalone/succession.d.ts +57 -0
- package/dist-standalone/succession.js +142 -0
- package/dist-standalone/transport.d.ts +50 -0
- package/dist-standalone/transport.js +59 -0
- package/dist-standalone/trust-registry.d.ts +286 -0
- package/dist-standalone/trust-registry.js +702 -0
- package/dist-standalone/verify.d.ts +16 -0
- package/dist-standalone/verify.js +16 -0
- package/dist-standalone/xfetch.d.ts +129 -0
- package/dist-standalone/xfetch.js +247 -0
- package/llms.txt +800 -0
- package/package.json +79 -0
- package/share1.dat +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Progress Reporter
|
|
4
|
+
*
|
|
5
|
+
* Provides consistent progress reporting for long-running operations.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ProgressReporter = void 0;
|
|
9
|
+
exports.createStagedProgress = createStagedProgress;
|
|
10
|
+
/**
|
|
11
|
+
* Progress reporter for long-running operations.
|
|
12
|
+
*
|
|
13
|
+
* Wraps a progress callback with convenient methods for reporting status updates.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* async function processLargeFile(
|
|
18
|
+
* data: Uint8Array,
|
|
19
|
+
* onProgress?: ProgressCallback
|
|
20
|
+
* ): Promise<void> {
|
|
21
|
+
* const progress = new ProgressReporter(onProgress);
|
|
22
|
+
*
|
|
23
|
+
* progress.start('Initializing...');
|
|
24
|
+
* // ... initialization work
|
|
25
|
+
*
|
|
26
|
+
* progress.update('Processing...', 50);
|
|
27
|
+
* // ... processing work
|
|
28
|
+
*
|
|
29
|
+
* progress.complete();
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
class ProgressReporter {
|
|
34
|
+
callback;
|
|
35
|
+
lastPercent = 0;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new progress reporter.
|
|
38
|
+
*
|
|
39
|
+
* @param callback Optional callback to invoke on progress updates
|
|
40
|
+
*/
|
|
41
|
+
constructor(callback) {
|
|
42
|
+
this.callback = callback;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Report progress with status and optional percentage.
|
|
46
|
+
*
|
|
47
|
+
* @param status Human-readable status message
|
|
48
|
+
* @param percent Progress percentage (0-100), optional
|
|
49
|
+
*/
|
|
50
|
+
report(status, percent) {
|
|
51
|
+
// Clamp percent to valid range if provided
|
|
52
|
+
const normalizedPercent = percent !== undefined ? Math.max(0, Math.min(100, percent)) : undefined;
|
|
53
|
+
// Update last known percent
|
|
54
|
+
if (normalizedPercent !== undefined) {
|
|
55
|
+
this.lastPercent = normalizedPercent;
|
|
56
|
+
}
|
|
57
|
+
// Call callback if provided
|
|
58
|
+
if (this.callback) {
|
|
59
|
+
this.callback(status, normalizedPercent);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Report the start of an operation (0% progress).
|
|
64
|
+
*
|
|
65
|
+
* @param status Status message
|
|
66
|
+
*/
|
|
67
|
+
start(status) {
|
|
68
|
+
this.report(status, 0);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Update progress with status and percentage.
|
|
72
|
+
*
|
|
73
|
+
* @param status Status message
|
|
74
|
+
* @param percent Progress percentage (0-100)
|
|
75
|
+
*/
|
|
76
|
+
update(status, percent) {
|
|
77
|
+
this.report(status, percent);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Report completion (100% progress).
|
|
81
|
+
*/
|
|
82
|
+
complete() {
|
|
83
|
+
this.report('Complete', 100);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the last reported percentage.
|
|
87
|
+
*
|
|
88
|
+
* @returns Last reported percentage (0-100)
|
|
89
|
+
*/
|
|
90
|
+
getLastPercent() {
|
|
91
|
+
return this.lastPercent;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.ProgressReporter = ProgressReporter;
|
|
95
|
+
/**
|
|
96
|
+
* Create a progress reporter that tracks multiple stages.
|
|
97
|
+
*
|
|
98
|
+
* Divides the 0-100% range into equal segments for each stage.
|
|
99
|
+
*
|
|
100
|
+
* @param stages Array of stage names
|
|
101
|
+
* @param callback Progress callback
|
|
102
|
+
* @returns Object with methods for advancing through stages
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const progress = createStagedProgress(
|
|
107
|
+
* ['Initializing', 'Processing', 'Finalizing'],
|
|
108
|
+
* (status, percent) => console.log(`${status}: ${percent}%`)
|
|
109
|
+
* );
|
|
110
|
+
*
|
|
111
|
+
* progress.start(); // "Initializing: 0%"
|
|
112
|
+
* progress.nextStage(); // "Processing: 33%"
|
|
113
|
+
* progress.nextStage(); // "Finalizing: 67%"
|
|
114
|
+
* progress.complete(); // "Complete: 100%"
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
function createStagedProgress(stages, callback) {
|
|
118
|
+
const reporter = new ProgressReporter(callback);
|
|
119
|
+
let currentStageIndex = 0;
|
|
120
|
+
const percentPerStage = stages.length > 0 ? 100 / stages.length : 100;
|
|
121
|
+
return {
|
|
122
|
+
start: () => {
|
|
123
|
+
currentStageIndex = 0;
|
|
124
|
+
reporter.start(stages[0] ?? 'Starting...');
|
|
125
|
+
},
|
|
126
|
+
nextStage: () => {
|
|
127
|
+
currentStageIndex = Math.min(currentStageIndex + 1, stages.length - 1);
|
|
128
|
+
const percent = Math.round(currentStageIndex * percentPerStage);
|
|
129
|
+
reporter.update(stages[currentStageIndex] ?? 'Processing...', percent);
|
|
130
|
+
},
|
|
131
|
+
complete: () => {
|
|
132
|
+
currentStageIndex = stages.length;
|
|
133
|
+
reporter.complete();
|
|
134
|
+
},
|
|
135
|
+
getCurrentStage: () => {
|
|
136
|
+
return stages[currentStageIndex] ?? '';
|
|
137
|
+
},
|
|
138
|
+
getProgress: () => {
|
|
139
|
+
return Math.round(currentStageIndex * percentPerStage);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAwHH,oDAwCC;AA5JD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,gBAAgB;IACV,QAAQ,CAA+B;IAChD,WAAW,GAAW,CAAC,CAAC;IAEhC;;;;OAIG;IACH,YAAY,QAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAc,EAAE,OAAgB;QACrC,2CAA2C;QAC3C,MAAM,iBAAiB,GACrB,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1E,4BAA4B;QAC5B,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC;QACvC,CAAC;QAED,4BAA4B;QAC5B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAc;QAClB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAc,EAAE,OAAe;QACpC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC/B,CA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ACzD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Helper
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent search behavior across all PRIVATE.ME packages.
|
|
5
|
+
*/
|
|
6
|
+
import type { SearchOptions } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Search a collection of items.
|
|
9
|
+
*
|
|
10
|
+
* Performs case-insensitive substring matching across specified fields.
|
|
11
|
+
*
|
|
12
|
+
* @param items Collection to search
|
|
13
|
+
* @param options Search options (query, fields, fuzzy, limit)
|
|
14
|
+
* @returns Filtered items matching the search query
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const items = [
|
|
19
|
+
* { name: 'Alice', email: 'alice@example.com' },
|
|
20
|
+
* { name: 'Bob', email: 'bob@example.com' },
|
|
21
|
+
* { name: 'Charlie', email: 'charlie@example.com' },
|
|
22
|
+
* ];
|
|
23
|
+
*
|
|
24
|
+
* const results = search(items, {
|
|
25
|
+
* query: 'alice',
|
|
26
|
+
* fields: ['name', 'email'],
|
|
27
|
+
* });
|
|
28
|
+
* // results = [{ name: 'Alice', email: 'alice@example.com' }]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function search<T>(items: readonly T[], options: SearchOptions): readonly T[];
|
|
32
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,EAAE,aAAa,GACrB,SAAS,CAAC,EAAE,CA4Bd"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Search Helper
|
|
4
|
+
*
|
|
5
|
+
* Provides consistent search behavior across all PRIVATE.ME packages.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.search = search;
|
|
9
|
+
/**
|
|
10
|
+
* Search a collection of items.
|
|
11
|
+
*
|
|
12
|
+
* Performs case-insensitive substring matching across specified fields.
|
|
13
|
+
*
|
|
14
|
+
* @param items Collection to search
|
|
15
|
+
* @param options Search options (query, fields, fuzzy, limit)
|
|
16
|
+
* @returns Filtered items matching the search query
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const items = [
|
|
21
|
+
* { name: 'Alice', email: 'alice@example.com' },
|
|
22
|
+
* { name: 'Bob', email: 'bob@example.com' },
|
|
23
|
+
* { name: 'Charlie', email: 'charlie@example.com' },
|
|
24
|
+
* ];
|
|
25
|
+
*
|
|
26
|
+
* const results = search(items, {
|
|
27
|
+
* query: 'alice',
|
|
28
|
+
* fields: ['name', 'email'],
|
|
29
|
+
* });
|
|
30
|
+
* // results = [{ name: 'Alice', email: 'alice@example.com' }]
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function search(items, options) {
|
|
34
|
+
const { query, fields, fuzzy = true, limit } = options;
|
|
35
|
+
// Empty query returns all items
|
|
36
|
+
if (!query.trim()) {
|
|
37
|
+
return limit !== undefined ? items.slice(0, limit) : items;
|
|
38
|
+
}
|
|
39
|
+
// Normalize query for comparison
|
|
40
|
+
const normalizedQuery = fuzzy ? query.toLowerCase() : query;
|
|
41
|
+
// Filter items that match the query
|
|
42
|
+
const results = items.filter((item) => {
|
|
43
|
+
// If fields are specified, search only those fields
|
|
44
|
+
if (fields && fields.length > 0) {
|
|
45
|
+
return fields.some((field) => {
|
|
46
|
+
const value = getNestedValue(item, field);
|
|
47
|
+
if (value === null || value === undefined)
|
|
48
|
+
return false;
|
|
49
|
+
return matchesQuery(String(value), normalizedQuery, fuzzy);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Otherwise, search all string fields
|
|
53
|
+
return searchAllFields(item, normalizedQuery, fuzzy);
|
|
54
|
+
});
|
|
55
|
+
// Apply limit if specified
|
|
56
|
+
return limit !== undefined ? results.slice(0, limit) : results;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get nested property value using dot notation.
|
|
60
|
+
*
|
|
61
|
+
* @param obj Object to query
|
|
62
|
+
* @param path Dot-separated path (e.g., 'user.profile.name')
|
|
63
|
+
* @returns Value at the path, or null if not found
|
|
64
|
+
*/
|
|
65
|
+
function getNestedValue(obj, path) {
|
|
66
|
+
const parts = path.split('.');
|
|
67
|
+
let current = obj;
|
|
68
|
+
for (const part of parts) {
|
|
69
|
+
if (current === null || current === undefined)
|
|
70
|
+
return null;
|
|
71
|
+
if (typeof current !== 'object')
|
|
72
|
+
return null;
|
|
73
|
+
current = current[part];
|
|
74
|
+
}
|
|
75
|
+
return current;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if a value matches the query.
|
|
79
|
+
*
|
|
80
|
+
* @param value Value to check
|
|
81
|
+
* @param query Query string (already normalized)
|
|
82
|
+
* @param fuzzy Whether to use fuzzy (case-insensitive) matching
|
|
83
|
+
* @returns True if value matches query
|
|
84
|
+
*/
|
|
85
|
+
function matchesQuery(value, query, fuzzy) {
|
|
86
|
+
if (fuzzy) {
|
|
87
|
+
return value.toLowerCase().includes(query);
|
|
88
|
+
}
|
|
89
|
+
return value.includes(query);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Search all string fields in an object recursively.
|
|
93
|
+
*
|
|
94
|
+
* @param obj Object to search
|
|
95
|
+
* @param query Normalized query string
|
|
96
|
+
* @param fuzzy Whether to use fuzzy matching
|
|
97
|
+
* @returns True if any field matches the query
|
|
98
|
+
*/
|
|
99
|
+
function searchAllFields(obj, query, fuzzy) {
|
|
100
|
+
if (obj === null || obj === undefined)
|
|
101
|
+
return false;
|
|
102
|
+
// Check primitive types
|
|
103
|
+
if (typeof obj === 'string') {
|
|
104
|
+
return matchesQuery(obj, query, fuzzy);
|
|
105
|
+
}
|
|
106
|
+
if (typeof obj === 'number' || typeof obj === 'boolean') {
|
|
107
|
+
return matchesQuery(String(obj), query, fuzzy);
|
|
108
|
+
}
|
|
109
|
+
// Recurse into arrays
|
|
110
|
+
if (Array.isArray(obj)) {
|
|
111
|
+
return obj.some((item) => searchAllFields(item, query, fuzzy));
|
|
112
|
+
}
|
|
113
|
+
// Recurse into objects
|
|
114
|
+
if (typeof obj === 'object') {
|
|
115
|
+
return Object.values(obj).some((value) => searchAllFields(value, query, fuzzy));
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA4BH,wBA+BC;AAvDD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,MAAM,CACpB,KAAmB,EACnB,OAAsB;IAEtB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEvD,gCAAgC;IAChC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7D,CAAC;IAED,iCAAiC;IACjC,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAE5D,oCAAoC;IACpC,MAAM,OAAO,GAAG,K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+
* Shared types for UX utilities across all PRIVATE.ME packages.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for paginating a collection.
|
|
8
|
+
*/
|
|
9
|
+
export interface PaginationOptions {
|
|
10
|
+
/** Page number (1-based). Defaults to 1. */
|
|
11
|
+
readonly page?: number;
|
|
12
|
+
/** Items per page. Defaults to 50, max 100. */
|
|
13
|
+
readonly limit?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Paginated result with metadata.
|
|
17
|
+
*/
|
|
18
|
+
export interface PaginatedResult<T> {
|
|
19
|
+
/** Items for the current page. */
|
|
20
|
+
readonly data: readonly T[];
|
|
21
|
+
/** Pagination metadata. */
|
|
22
|
+
readonly pagination: {
|
|
23
|
+
readonly page: number;
|
|
24
|
+
readonly limit: number;
|
|
25
|
+
readonly total: number;
|
|
26
|
+
readonly totalPages: number;
|
|
27
|
+
readonly hasNext: boolean;
|
|
28
|
+
readonly hasPrev: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for searching a collection.
|
|
33
|
+
*/
|
|
34
|
+
export interface SearchOptions {
|
|
35
|
+
/** Search query string. */
|
|
36
|
+
readonly query: string;
|
|
37
|
+
/** Fields to search in. If not specified, searches all string fields. */
|
|
38
|
+
readonly fields?: readonly string[];
|
|
39
|
+
/** Enable fuzzy matching (case-insensitive substring). Defaults to true. */
|
|
40
|
+
readonly fuzzy?: boolean;
|
|
41
|
+
/** Maximum number of results to return. Defaults to unlimited. */
|
|
42
|
+
readonly limit?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Callback for progress updates.
|
|
46
|
+
*
|
|
47
|
+
* @param status Human-readable status message
|
|
48
|
+
* @param percent Progress percentage (0-100), optional
|
|
49
|
+
*/
|
|
50
|
+
export type ProgressCallback = (status: string, percent?: number) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Detailed error information for ACI-level operations.
|
|
53
|
+
*/
|
|
54
|
+
export interface ACIErrorDetail {
|
|
55
|
+
/** Machine-readable error code (e.g., 'INVALID_DID'). */
|
|
56
|
+
readonly code: string;
|
|
57
|
+
/** Human-readable error message. */
|
|
58
|
+
readonly message: string;
|
|
59
|
+
/** Optional hint for resolving the error. */
|
|
60
|
+
readonly hint?: string;
|
|
61
|
+
/** Actionable step to resolve the error (imperative verb form). */
|
|
62
|
+
readonly suggested_action?: string;
|
|
63
|
+
/** Field name that caused the error, if applicable. */
|
|
64
|
+
readonly field?: string;
|
|
65
|
+
/** Documentation URL for more information. */
|
|
66
|
+
readonly docs?: string;
|
|
67
|
+
/** Error severity level. */
|
|
68
|
+
readonly severity?: 'info' | 'warning' | 'error' | 'critical';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Multiple format representations for structured data.
|
|
72
|
+
*
|
|
73
|
+
* Used for operations that return rich information (not primitives like IDs or hashes).
|
|
74
|
+
* Each format is optimized for a different use case:
|
|
75
|
+
* - multiline: Human display (terminal, UI)
|
|
76
|
+
* - singleline: Logs (one line per event)
|
|
77
|
+
* - json: APIs (machine-readable)
|
|
78
|
+
* - markdown: Documentation (rendered output)
|
|
79
|
+
*/
|
|
80
|
+
export interface FormattedOutput {
|
|
81
|
+
/** Multi-line format for human display. */
|
|
82
|
+
readonly multiline: string;
|
|
83
|
+
/** Single-line format for logs. */
|
|
84
|
+
readonly singleline: string;
|
|
85
|
+
/** JSON string for APIs. */
|
|
86
|
+
readonly json: string;
|
|
87
|
+
/** Markdown format for documentation. */
|
|
88
|
+
readonly markdown: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Error with multiple format representations.
|
|
92
|
+
*
|
|
93
|
+
* Extends ACIErrorDetail with structured formats for different use cases.
|
|
94
|
+
*/
|
|
95
|
+
export interface FormattedError extends ACIErrorDetail {
|
|
96
|
+
/** Multiple format representations. */
|
|
97
|
+
readonly formats: FormattedOutput;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Options for creating a detailed error.
|
|
101
|
+
*/
|
|
102
|
+
export interface ACIErrorOptions {
|
|
103
|
+
readonly hint?: string;
|
|
104
|
+
readonly suggested_action?: string;
|
|
105
|
+
readonly field?: string;
|
|
106
|
+
readonly docs?: string;
|
|
107
|
+
readonly severity?: 'info' | 'warning' | 'error' | 'critical';
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;KAC3B,CAAC;CACH;AAID;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,kEA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AM,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Formatter
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error formatting across all PRIVATE.ME packages.
|
|
5
|
+
*/
|
|
6
|
+
import type { ACIErrorDetail, ACIErrorOptions } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create a detailed ACI error.
|
|
9
|
+
*
|
|
10
|
+
* @param code Machine-readable error code (e.g., 'INVALID_DID')
|
|
11
|
+
* @param message Human-readable error message
|
|
12
|
+
* @param options Optional error details (hint, field, docs)
|
|
13
|
+
* @returns Detailed error object
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const error = createDetailedError(
|
|
18
|
+
* 'INVALID_DID',
|
|
19
|
+
* 'DID format is invalid',
|
|
20
|
+
* {
|
|
21
|
+
* hint: 'DIDs must start with "did:" followed by method (e.g., did:key:z6Mk...)',
|
|
22
|
+
* field: 'recipientDID',
|
|
23
|
+
* docs: 'https://private.me/docs/did-format'
|
|
24
|
+
* }
|
|
25
|
+
* );
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDetailedError(code: string, message: string, options?: ACIErrorOptions): ACIErrorDetail;
|
|
29
|
+
/**
|
|
30
|
+
* Format an error for display to the user.
|
|
31
|
+
*
|
|
32
|
+
* Creates a human-friendly error message with hints and documentation links.
|
|
33
|
+
*
|
|
34
|
+
* @param error Detailed error object
|
|
35
|
+
* @returns Formatted error string
|
|
36
|
+
*
|
|
37
|
+
* @deprecated Use formatErrorStructured() for new code. This function remains for backward compatibility.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const error = createDetailedError('INVALID_DID', 'DID format is invalid', {
|
|
42
|
+
* hint: 'DIDs must start with "did:"',
|
|
43
|
+
* docs: 'https://private.me/docs/did-format'
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* const formatted = formatErrorForUser(error);
|
|
47
|
+
* // "DID format is invalid
|
|
48
|
+
* // Hint: DIDs must start with "did:"
|
|
49
|
+
* // Docs: https://private.me/docs/did-format"
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatErrorForUser(error: ACIErrorDetail): string;
|
|
53
|
+
/**
|
|
54
|
+
* Format an error for logging (includes error code).
|
|
55
|
+
*
|
|
56
|
+
* @param error Detailed error object
|
|
57
|
+
* @returns Formatted log string
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatErrorForLog(error: ACIErrorDetail): string;
|
|
60
|
+
/**
|
|
61
|
+
* Check if an error is an ACIErrorDetail.
|
|
62
|
+
*
|
|
63
|
+
* @param error Unknown error object
|
|
64
|
+
* @returns True if error is an ACIErrorDetail
|
|
65
|
+
*/
|
|
66
|
+
export declare function isACIError(error: unknown): error is ACIErrorDetail;
|
|
67
|
+
/**
|
|
68
|
+
* Convert any error to an ACIErrorDetail.
|
|
69
|
+
*
|
|
70
|
+
* @param error Error object (Error, ACIErrorDetail, or unknown)
|
|
71
|
+
* @returns ACIErrorDetail
|
|
72
|
+
*/
|
|
73
|
+
export declare function toACIError(error: unknown): ACIErrorDetail;
|
|
74
|
+
/**
|
|
75
|
+
* Format an error with multiple structured representations.
|
|
76
|
+
*
|
|
77
|
+
* Returns an object with the original error details plus formatted versions
|
|
78
|
+
* optimized for different use cases (display, logging, APIs, docs).
|
|
79
|
+
*
|
|
80
|
+
* @param error Detailed error object
|
|
81
|
+
* @returns Error with formats
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const error = createDetailedError('INVALID_DID', 'DID format is invalid', {
|
|
86
|
+
* hint: 'DIDs must start with "did:"',
|
|
87
|
+
* field: 'recipientDID',
|
|
88
|
+
* docs: 'https://private.me/docs/did-format'
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* const formatted = formatErrorStructured(error);
|
|
92
|
+
* console.log(formatted.formats.singleline);
|
|
93
|
+
* // "error | INVALID_DID | DID format is invalid | field=recipientDID"
|
|
94
|
+
*
|
|
95
|
+
* console.log(formatted.formats.multiline);
|
|
96
|
+
* // "Error: DID format is invalid
|
|
97
|
+
* // Code: INVALID_DID
|
|
98
|
+
* // Field: recipientDID
|
|
99
|
+
* // Hint: DIDs must start with "did:"
|
|
100
|
+
* // Docs: https://private.me/docs/did-format"
|
|
101
|
+
*
|
|
102
|
+
* console.log(formatted.formats.json);
|
|
103
|
+
* // '{"code":"INVALID_DID","message":"DID format is invalid",...}'
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function formatErrorStructured(error: ACIErrorDetail): import('./types.js').FormattedError;
|
|
107
|
+
/**
|
|
108
|
+
* Detailed error information for debugging and user-facing messages.
|
|
109
|
+
* Maps error codes to human-readable descriptions and recovery suggestions.
|
|
110
|
+
*/
|
|
111
|
+
export declare const ERROR_DETAILS: Record<string, {
|
|
112
|
+
description: string;
|
|
113
|
+
recovery: string;
|
|
114
|
+
}>;
|
|
115
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,cAAc,CAUhB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAgBhE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAgB/D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAWlE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAqBzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,YAAY,EAAE,cAAc,CA2DhG;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAOnF,CAAC"}
|