@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,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Formatter
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error formatting across all PRIVATE.ME packages.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create a detailed ACI error.
|
|
8
|
+
*
|
|
9
|
+
* @param code Machine-readable error code (e.g., 'INVALID_DID')
|
|
10
|
+
* @param message Human-readable error message
|
|
11
|
+
* @param options Optional error details (hint, field, docs)
|
|
12
|
+
* @returns Detailed error object
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const error = createDetailedError(
|
|
17
|
+
* 'INVALID_DID',
|
|
18
|
+
* 'DID format is invalid',
|
|
19
|
+
* {
|
|
20
|
+
* hint: 'DIDs must start with "did:" followed by method (e.g., did:key:z6Mk...)',
|
|
21
|
+
* field: 'recipientDID',
|
|
22
|
+
* docs: 'https://private.me/docs/did-format'
|
|
23
|
+
* }
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function createDetailedError(code, message, options) {
|
|
28
|
+
return {
|
|
29
|
+
code,
|
|
30
|
+
message,
|
|
31
|
+
hint: options?.hint,
|
|
32
|
+
suggested_action: options?.suggested_action,
|
|
33
|
+
field: options?.field,
|
|
34
|
+
docs: options?.docs,
|
|
35
|
+
severity: options?.severity,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Format an error for display to the user.
|
|
40
|
+
*
|
|
41
|
+
* Creates a human-friendly error message with hints and documentation links.
|
|
42
|
+
*
|
|
43
|
+
* @param error Detailed error object
|
|
44
|
+
* @returns Formatted error string
|
|
45
|
+
*
|
|
46
|
+
* @deprecated Use formatErrorStructured() for new code. This function remains for backward compatibility.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const error = createDetailedError('INVALID_DID', 'DID format is invalid', {
|
|
51
|
+
* hint: 'DIDs must start with "did:"',
|
|
52
|
+
* docs: 'https://private.me/docs/did-format'
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* const formatted = formatErrorForUser(error);
|
|
56
|
+
* // "DID format is invalid
|
|
57
|
+
* // Hint: DIDs must start with "did:"
|
|
58
|
+
* // Docs: https://private.me/docs/did-format"
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function formatErrorForUser(error) {
|
|
62
|
+
const parts = [error.message];
|
|
63
|
+
if (error.field) {
|
|
64
|
+
parts.push(`Field: ${error.field}`);
|
|
65
|
+
}
|
|
66
|
+
if (error.hint) {
|
|
67
|
+
parts.push(`Hint: ${error.hint}`);
|
|
68
|
+
}
|
|
69
|
+
if (error.docs) {
|
|
70
|
+
parts.push(`Docs: ${error.docs}`);
|
|
71
|
+
}
|
|
72
|
+
return parts.join('\n');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Format an error for logging (includes error code).
|
|
76
|
+
*
|
|
77
|
+
* @param error Detailed error object
|
|
78
|
+
* @returns Formatted log string
|
|
79
|
+
*/
|
|
80
|
+
export function formatErrorForLog(error) {
|
|
81
|
+
const parts = [`[${error.code}] ${error.message}`];
|
|
82
|
+
if (error.field) {
|
|
83
|
+
parts.push(`field=${error.field}`);
|
|
84
|
+
}
|
|
85
|
+
if (error.hint) {
|
|
86
|
+
parts.push(`hint="${error.hint}"`);
|
|
87
|
+
}
|
|
88
|
+
if (error.docs) {
|
|
89
|
+
parts.push(`docs=${error.docs}`);
|
|
90
|
+
}
|
|
91
|
+
return parts.join(' | ');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if an error is an ACIErrorDetail.
|
|
95
|
+
*
|
|
96
|
+
* @param error Unknown error object
|
|
97
|
+
* @returns True if error is an ACIErrorDetail
|
|
98
|
+
*/
|
|
99
|
+
export function isACIError(error) {
|
|
100
|
+
if (typeof error !== 'object' || error === null)
|
|
101
|
+
return false;
|
|
102
|
+
const e = error;
|
|
103
|
+
return (typeof e.code === 'string' &&
|
|
104
|
+
typeof e.message === 'string' &&
|
|
105
|
+
(e.hint === undefined || typeof e.hint === 'string') &&
|
|
106
|
+
(e.field === undefined || typeof e.field === 'string') &&
|
|
107
|
+
(e.docs === undefined || typeof e.docs === 'string'));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Convert any error to an ACIErrorDetail.
|
|
111
|
+
*
|
|
112
|
+
* @param error Error object (Error, ACIErrorDetail, or unknown)
|
|
113
|
+
* @returns ACIErrorDetail
|
|
114
|
+
*/
|
|
115
|
+
export function toACIError(error) {
|
|
116
|
+
// Already an ACI error
|
|
117
|
+
if (isACIError(error)) {
|
|
118
|
+
return error;
|
|
119
|
+
}
|
|
120
|
+
// Standard Error object
|
|
121
|
+
if (error instanceof Error) {
|
|
122
|
+
return {
|
|
123
|
+
code: 'INTERNAL_ERROR',
|
|
124
|
+
message: error.message,
|
|
125
|
+
hint: 'An unexpected error occurred',
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Unknown error type
|
|
129
|
+
return {
|
|
130
|
+
code: 'UNKNOWN_ERROR',
|
|
131
|
+
message: String(error),
|
|
132
|
+
hint: 'An unexpected error occurred',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Format an error with multiple structured representations.
|
|
137
|
+
*
|
|
138
|
+
* Returns an object with the original error details plus formatted versions
|
|
139
|
+
* optimized for different use cases (display, logging, APIs, docs).
|
|
140
|
+
*
|
|
141
|
+
* @param error Detailed error object
|
|
142
|
+
* @returns Error with formats
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const error = createDetailedError('INVALID_DID', 'DID format is invalid', {
|
|
147
|
+
* hint: 'DIDs must start with "did:"',
|
|
148
|
+
* field: 'recipientDID',
|
|
149
|
+
* docs: 'https://private.me/docs/did-format'
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* const formatted = formatErrorStructured(error);
|
|
153
|
+
* console.log(formatted.formats.singleline);
|
|
154
|
+
* // "error | INVALID_DID | DID format is invalid | field=recipientDID"
|
|
155
|
+
*
|
|
156
|
+
* console.log(formatted.formats.multiline);
|
|
157
|
+
* // "Error: DID format is invalid
|
|
158
|
+
* // Code: INVALID_DID
|
|
159
|
+
* // Field: recipientDID
|
|
160
|
+
* // Hint: DIDs must start with "did:"
|
|
161
|
+
* // Docs: https://private.me/docs/did-format"
|
|
162
|
+
*
|
|
163
|
+
* console.log(formatted.formats.json);
|
|
164
|
+
* // '{"code":"INVALID_DID","message":"DID format is invalid",...}'
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export function formatErrorStructured(error) {
|
|
168
|
+
// Build multiline format (human display)
|
|
169
|
+
const multilineParts = [`Error: ${error.message}`, `Code: ${error.code}`];
|
|
170
|
+
if (error.severity)
|
|
171
|
+
multilineParts.push(`Severity: ${error.severity}`);
|
|
172
|
+
if (error.field)
|
|
173
|
+
multilineParts.push(`Field: ${error.field}`);
|
|
174
|
+
if (error.hint)
|
|
175
|
+
multilineParts.push(`Hint: ${error.hint}`);
|
|
176
|
+
if (error.suggested_action)
|
|
177
|
+
multilineParts.push(`Action: ${error.suggested_action}`);
|
|
178
|
+
if (error.docs)
|
|
179
|
+
multilineParts.push(`Docs: ${error.docs}`);
|
|
180
|
+
const multiline = multilineParts.join('\n');
|
|
181
|
+
// Build singleline format (logs)
|
|
182
|
+
const singlelineParts = ['error', error.code, error.message];
|
|
183
|
+
if (error.severity)
|
|
184
|
+
singlelineParts.push(`severity=${error.severity}`);
|
|
185
|
+
if (error.field)
|
|
186
|
+
singlelineParts.push(`field=${error.field}`);
|
|
187
|
+
if (error.hint) {
|
|
188
|
+
// Escape quotes in hint for proper log formatting
|
|
189
|
+
const escapedHint = error.hint.replace(/"/g, '\\"');
|
|
190
|
+
singlelineParts.push(`hint="${escapedHint}"`);
|
|
191
|
+
}
|
|
192
|
+
if (error.suggested_action) {
|
|
193
|
+
const escapedAction = error.suggested_action.replace(/"/g, '\\"');
|
|
194
|
+
singlelineParts.push(`action="${escapedAction}"`);
|
|
195
|
+
}
|
|
196
|
+
if (error.docs)
|
|
197
|
+
singlelineParts.push(`docs=${error.docs}`);
|
|
198
|
+
const singleline = singlelineParts.join(' | ');
|
|
199
|
+
// Build JSON format (APIs)
|
|
200
|
+
const jsonObj = {
|
|
201
|
+
code: error.code,
|
|
202
|
+
message: error.message,
|
|
203
|
+
};
|
|
204
|
+
if (error.severity)
|
|
205
|
+
jsonObj.severity = error.severity;
|
|
206
|
+
if (error.field)
|
|
207
|
+
jsonObj.field = error.field;
|
|
208
|
+
if (error.hint)
|
|
209
|
+
jsonObj.hint = error.hint;
|
|
210
|
+
if (error.suggested_action)
|
|
211
|
+
jsonObj.suggested_action = error.suggested_action;
|
|
212
|
+
if (error.docs)
|
|
213
|
+
jsonObj.docs = error.docs;
|
|
214
|
+
const json = JSON.stringify(jsonObj);
|
|
215
|
+
// Build markdown format (documentation)
|
|
216
|
+
const markdownParts = [
|
|
217
|
+
`**Error:** ${error.message}`,
|
|
218
|
+
`**Code:** \`${error.code}\``,
|
|
219
|
+
];
|
|
220
|
+
if (error.severity)
|
|
221
|
+
markdownParts.push(`**Severity:** ${error.severity}`);
|
|
222
|
+
if (error.field)
|
|
223
|
+
markdownParts.push(`**Field:** \`${error.field}\``);
|
|
224
|
+
if (error.hint)
|
|
225
|
+
markdownParts.push(`**Hint:** ${error.hint}`);
|
|
226
|
+
if (error.suggested_action)
|
|
227
|
+
markdownParts.push(`**Action:** ${error.suggested_action}`);
|
|
228
|
+
if (error.docs)
|
|
229
|
+
markdownParts.push(`**Docs:** [${error.docs}](${error.docs})`);
|
|
230
|
+
const markdown = markdownParts.join('\n\n');
|
|
231
|
+
return {
|
|
232
|
+
...error,
|
|
233
|
+
formats: {
|
|
234
|
+
multiline,
|
|
235
|
+
singleline,
|
|
236
|
+
json,
|
|
237
|
+
markdown,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Detailed error information for debugging and user-facing messages.
|
|
243
|
+
* Maps error codes to human-readable descriptions and recovery suggestions.
|
|
244
|
+
*/
|
|
245
|
+
export const ERROR_DETAILS = {
|
|
246
|
+
// Add error details here as needed
|
|
247
|
+
// Example:
|
|
248
|
+
// 'INVALID_CONFIG:TOO_FEW_NODES': {
|
|
249
|
+
// description: 'Configuration specifies fewer than 2 storage nodes',
|
|
250
|
+
// recovery: 'Add more storage nodes. At least 2 required, 3+ recommended.'
|
|
251
|
+
// }
|
|
252
|
+
};
|
|
253
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,OAAe,EACf,OAAyB;IAEzB,OAAO;QACL,IAAI;QACJ,OAAO;QACP,IAAI,EAAE,OAAO,EAAE,IAAI;QACnB,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,IAAI,EAAE,OAAO,EAAE,IAAI;QACnB,QAAQ,EAAE,OAAO,EAAE,QAAQ;KAC5B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,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,EAAE,CAAC,CAAC;IAC9D,IAAI,KAAK,CAAC,gBAAgB;QAAE,aAAa,CAAC,IAAI,CAAC,eAAe,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACxF,IAAI,KAAK,CAAC,IAAI;QAAE,aAAa,CAAC,IAAI,CAAC,cAAc,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE5C,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;YACP,SAAS;YACT,UAAU;YACV,IAAI;YACJ,QAAQ;SACT;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAA8D;AACtF,mCAAmC;AACnC,WAAW;AACX,oCAAoC;AACpC,uEAAuE;AACvE,6EAA6E;AAC7E,IAAI;CACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UX Helpers
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for consistent UX across all PRIVATE.ME packages.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export type { PaginationOptions, PaginatedResult, SearchOptions, ProgressCallback, ACIErrorDetail, ACIErrorOptions, FormattedOutput, FormattedError, } from './types.js';
|
|
9
|
+
export { paginate, createPaginationMetadata } from './pagination.js';
|
|
10
|
+
export { search } from './search.js';
|
|
11
|
+
export { ProgressReporter, createStagedProgress } from './progress.js';
|
|
12
|
+
export { createDetailedError, formatErrorForUser, formatErrorForLog, isACIError, toACIError, formatErrorStructured, } from './errors.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UX Helpers
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for consistent UX across all PRIVATE.ME packages.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
// Re-export pagination utilities
|
|
9
|
+
export { paginate, createPaginationMetadata } from './pagination.js';
|
|
10
|
+
// Re-export search utilities
|
|
11
|
+
export { search } from './search.js';
|
|
12
|
+
// Re-export progress utilities
|
|
13
|
+
export { ProgressReporter, createStagedProgress } from './progress.js';
|
|
14
|
+
// Re-export error utilities
|
|
15
|
+
export { createDetailedError, formatErrorForUser, formatErrorForLog, isACIError, toACIError, formatErrorStructured, } from './errors.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAcH,iCAAiC;AACjC,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAErE,6BAA6B;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,+BAA+B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEvE,4BAA4B;AAC5B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination Helper
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent pagination behavior across all PRIVATE.ME packages.
|
|
5
|
+
*/
|
|
6
|
+
import type { PaginationOptions, PaginatedResult } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Paginate a collection of items.
|
|
9
|
+
*
|
|
10
|
+
* Returns a subset of items for the requested page along with pagination metadata.
|
|
11
|
+
*
|
|
12
|
+
* @param items Full collection to paginate
|
|
13
|
+
* @param options Pagination options (page number, limit)
|
|
14
|
+
* @returns Paginated result with data and metadata
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const allItems = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
19
|
+
* const result = paginate(allItems, { page: 2, limit: 3 });
|
|
20
|
+
* // result.data = [4, 5, 6]
|
|
21
|
+
* // result.pagination.page = 2
|
|
22
|
+
* // result.pagination.total = 10
|
|
23
|
+
* // result.pagination.totalPages = 4
|
|
24
|
+
* // result.pagination.hasNext = true
|
|
25
|
+
* // result.pagination.hasPrev = true
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function paginate<T>(items: readonly T[], options?: PaginationOptions): PaginatedResult<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Create pagination metadata without slicing data.
|
|
31
|
+
*
|
|
32
|
+
* Useful when you already have the page data and just need the metadata.
|
|
33
|
+
*
|
|
34
|
+
* @param total Total number of items in the full collection
|
|
35
|
+
* @param options Pagination options
|
|
36
|
+
* @returns Pagination metadata only
|
|
37
|
+
*/
|
|
38
|
+
export declare function createPaginationMetadata(total: number, options?: PaginationOptions): PaginatedResult<never>['pagination'];
|
|
39
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQrE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,eAAe,CAAC,CAAC,CAAC,CAgCpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,iBAAiB,GAC1B,eAAe,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAkBtC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination Helper
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent pagination behavior across all PRIVATE.ME packages.
|
|
5
|
+
*/
|
|
6
|
+
/** Default items per page. */
|
|
7
|
+
const DEFAULT_LIMIT = 50;
|
|
8
|
+
/** Maximum items per page. */
|
|
9
|
+
const MAX_LIMIT = 100;
|
|
10
|
+
/**
|
|
11
|
+
* Paginate a collection of items.
|
|
12
|
+
*
|
|
13
|
+
* Returns a subset of items for the requested page along with pagination metadata.
|
|
14
|
+
*
|
|
15
|
+
* @param items Full collection to paginate
|
|
16
|
+
* @param options Pagination options (page number, limit)
|
|
17
|
+
* @returns Paginated result with data and metadata
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const allItems = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
22
|
+
* const result = paginate(allItems, { page: 2, limit: 3 });
|
|
23
|
+
* // result.data = [4, 5, 6]
|
|
24
|
+
* // result.pagination.page = 2
|
|
25
|
+
* // result.pagination.total = 10
|
|
26
|
+
* // result.pagination.totalPages = 4
|
|
27
|
+
* // result.pagination.hasNext = true
|
|
28
|
+
* // result.pagination.hasPrev = true
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function paginate(items, options) {
|
|
32
|
+
// Normalize pagination parameters
|
|
33
|
+
const page = Math.max(1, options?.page ?? 1);
|
|
34
|
+
const limit = Math.min(Math.max(1, options?.limit ?? DEFAULT_LIMIT), MAX_LIMIT);
|
|
35
|
+
const total = items.length;
|
|
36
|
+
const totalPages = Math.max(1, Math.ceil(total / limit));
|
|
37
|
+
// Clamp page to valid range
|
|
38
|
+
const safePage = Math.min(page, totalPages);
|
|
39
|
+
// Calculate slice indices
|
|
40
|
+
const startIndex = (safePage - 1) * limit;
|
|
41
|
+
const endIndex = Math.min(startIndex + limit, total);
|
|
42
|
+
// Extract page data
|
|
43
|
+
const data = items.slice(startIndex, endIndex);
|
|
44
|
+
return {
|
|
45
|
+
data,
|
|
46
|
+
pagination: {
|
|
47
|
+
page: safePage,
|
|
48
|
+
limit,
|
|
49
|
+
total,
|
|
50
|
+
totalPages,
|
|
51
|
+
hasNext: safePage < totalPages,
|
|
52
|
+
hasPrev: safePage > 1,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create pagination metadata without slicing data.
|
|
58
|
+
*
|
|
59
|
+
* Useful when you already have the page data and just need the metadata.
|
|
60
|
+
*
|
|
61
|
+
* @param total Total number of items in the full collection
|
|
62
|
+
* @param options Pagination options
|
|
63
|
+
* @returns Pagination metadata only
|
|
64
|
+
*/
|
|
65
|
+
export function createPaginationMetadata(total, options) {
|
|
66
|
+
const page = Math.max(1, options?.page ?? 1);
|
|
67
|
+
const limit = Math.min(Math.max(1, options?.limit ?? DEFAULT_LIMIT), MAX_LIMIT);
|
|
68
|
+
const totalPages = Math.max(1, Math.ceil(total / limit));
|
|
69
|
+
const safePage = Math.min(page, totalPages);
|
|
70
|
+
return {
|
|
71
|
+
page: safePage,
|
|
72
|
+
limit,
|
|
73
|
+
total,
|
|
74
|
+
totalPages,
|
|
75
|
+
hasNext: safePage < totalPages,
|
|
76
|
+
hasPrev: safePage > 1,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,8BAA8B;AAC9B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,8BAA8B;AAC9B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAmB,EACnB,OAA2B;IAE3B,kCAAkC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACpB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,aAAa,CAAC,EAC5C,SAAS,CACV,CAAC;IAEF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IAEzD,4BAA4B;IAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAE5C,0BAA0B;IAC1B,MAAM,UAAU,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,KAAK,EAAE,KAAK,CAAC,CAAC;IAErD,oBAAoB;IACpB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE/C,OAAO;QACL,IAAI;QACJ,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,KAAK;YACL,UAAU;YACV,OAAO,EAAE,QAAQ,GAAG,UAAU;YAC9B,OAAO,EAAE,QAAQ,GAAG,CAAC;SACtB;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAa,EACb,OAA2B;IAE3B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACpB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,aAAa,CAAC,EAC5C,SAAS,CACV,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAE5C,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,KAAK;QACL,KAAK;QACL,UAAU;QACV,OAAO,EAAE,QAAQ,GAAG,UAAU;QAC9B,OAAO,EAAE,QAAQ,GAAG,CAAC;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress Reporter
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent progress reporting for long-running operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { ProgressCallback } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Progress reporter for long-running operations.
|
|
9
|
+
*
|
|
10
|
+
* Wraps a progress callback with convenient methods for reporting status updates.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* async function processLargeFile(
|
|
15
|
+
* data: Uint8Array,
|
|
16
|
+
* onProgress?: ProgressCallback
|
|
17
|
+
* ): Promise<void> {
|
|
18
|
+
* const progress = new ProgressReporter(onProgress);
|
|
19
|
+
*
|
|
20
|
+
* progress.start('Initializing...');
|
|
21
|
+
* // ... initialization work
|
|
22
|
+
*
|
|
23
|
+
* progress.update('Processing...', 50);
|
|
24
|
+
* // ... processing work
|
|
25
|
+
*
|
|
26
|
+
* progress.complete();
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class ProgressReporter {
|
|
31
|
+
private readonly callback;
|
|
32
|
+
private lastPercent;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new progress reporter.
|
|
35
|
+
*
|
|
36
|
+
* @param callback Optional callback to invoke on progress updates
|
|
37
|
+
*/
|
|
38
|
+
constructor(callback?: ProgressCallback);
|
|
39
|
+
/**
|
|
40
|
+
* Report progress with status and optional percentage.
|
|
41
|
+
*
|
|
42
|
+
* @param status Human-readable status message
|
|
43
|
+
* @param percent Progress percentage (0-100), optional
|
|
44
|
+
*/
|
|
45
|
+
report(status: string, percent?: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Report the start of an operation (0% progress).
|
|
48
|
+
*
|
|
49
|
+
* @param status Status message
|
|
50
|
+
*/
|
|
51
|
+
start(status: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Update progress with status and percentage.
|
|
54
|
+
*
|
|
55
|
+
* @param status Status message
|
|
56
|
+
* @param percent Progress percentage (0-100)
|
|
57
|
+
*/
|
|
58
|
+
update(status: string, percent: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Report completion (100% progress).
|
|
61
|
+
*/
|
|
62
|
+
complete(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Get the last reported percentage.
|
|
65
|
+
*
|
|
66
|
+
* @returns Last reported percentage (0-100)
|
|
67
|
+
*/
|
|
68
|
+
getLastPercent(): number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a progress reporter that tracks multiple stages.
|
|
72
|
+
*
|
|
73
|
+
* Divides the 0-100% range into equal segments for each stage.
|
|
74
|
+
*
|
|
75
|
+
* @param stages Array of stage names
|
|
76
|
+
* @param callback Progress callback
|
|
77
|
+
* @returns Object with methods for advancing through stages
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const progress = createStagedProgress(
|
|
82
|
+
* ['Initializing', 'Processing', 'Finalizing'],
|
|
83
|
+
* (status, percent) => console.log(`${status}: ${percent}%`)
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* progress.start(); // "Initializing: 0%"
|
|
87
|
+
* progress.nextStage(); // "Processing: 33%"
|
|
88
|
+
* progress.nextStage(); // "Finalizing: 67%"
|
|
89
|
+
* progress.complete(); // "Complete: 100%"
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function createStagedProgress(stages: readonly string[], callback?: ProgressCallback): {
|
|
93
|
+
start: () => void;
|
|
94
|
+
nextStage: () => void;
|
|
95
|
+
complete: () => void;
|
|
96
|
+
getCurrentStage: () => string;
|
|
97
|
+
getProgress: () => number;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+B;IACxD,OAAO,CAAC,WAAW,CAAa;IAEhC;;;;OAIG;gBACS,QAAQ,CAAC,EAAE,gBAAgB;IAIvC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAgB9C;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI3B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAI7C;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;;;OAIG;IACH,cAAc,IAAI,MAAM;CAGzB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B;IACD,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,MAAM,CAAC;IAC9B,WAAW,EAAE,MAAM,MAAM,CAAC;CAC3B,CA+BA"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress Reporter
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent progress reporting for long-running operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Progress reporter for long-running operations.
|
|
8
|
+
*
|
|
9
|
+
* Wraps a progress callback with convenient methods for reporting status updates.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* async function processLargeFile(
|
|
14
|
+
* data: Uint8Array,
|
|
15
|
+
* onProgress?: ProgressCallback
|
|
16
|
+
* ): Promise<void> {
|
|
17
|
+
* const progress = new ProgressReporter(onProgress);
|
|
18
|
+
*
|
|
19
|
+
* progress.start('Initializing...');
|
|
20
|
+
* // ... initialization work
|
|
21
|
+
*
|
|
22
|
+
* progress.update('Processing...', 50);
|
|
23
|
+
* // ... processing work
|
|
24
|
+
*
|
|
25
|
+
* progress.complete();
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export class ProgressReporter {
|
|
30
|
+
callback;
|
|
31
|
+
lastPercent = 0;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new progress reporter.
|
|
34
|
+
*
|
|
35
|
+
* @param callback Optional callback to invoke on progress updates
|
|
36
|
+
*/
|
|
37
|
+
constructor(callback) {
|
|
38
|
+
this.callback = callback;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Report progress with status and optional percentage.
|
|
42
|
+
*
|
|
43
|
+
* @param status Human-readable status message
|
|
44
|
+
* @param percent Progress percentage (0-100), optional
|
|
45
|
+
*/
|
|
46
|
+
report(status, percent) {
|
|
47
|
+
// Clamp percent to valid range if provided
|
|
48
|
+
const normalizedPercent = percent !== undefined ? Math.max(0, Math.min(100, percent)) : undefined;
|
|
49
|
+
// Update last known percent
|
|
50
|
+
if (normalizedPercent !== undefined) {
|
|
51
|
+
this.lastPercent = normalizedPercent;
|
|
52
|
+
}
|
|
53
|
+
// Call callback if provided
|
|
54
|
+
if (this.callback) {
|
|
55
|
+
this.callback(status, normalizedPercent);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Report the start of an operation (0% progress).
|
|
60
|
+
*
|
|
61
|
+
* @param status Status message
|
|
62
|
+
*/
|
|
63
|
+
start(status) {
|
|
64
|
+
this.report(status, 0);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Update progress with status and percentage.
|
|
68
|
+
*
|
|
69
|
+
* @param status Status message
|
|
70
|
+
* @param percent Progress percentage (0-100)
|
|
71
|
+
*/
|
|
72
|
+
update(status, percent) {
|
|
73
|
+
this.report(status, percent);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Report completion (100% progress).
|
|
77
|
+
*/
|
|
78
|
+
complete() {
|
|
79
|
+
this.report('Complete', 100);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the last reported percentage.
|
|
83
|
+
*
|
|
84
|
+
* @returns Last reported percentage (0-100)
|
|
85
|
+
*/
|
|
86
|
+
getLastPercent() {
|
|
87
|
+
return this.lastPercent;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a progress reporter that tracks multiple stages.
|
|
92
|
+
*
|
|
93
|
+
* Divides the 0-100% range into equal segments for each stage.
|
|
94
|
+
*
|
|
95
|
+
* @param stages Array of stage names
|
|
96
|
+
* @param callback Progress callback
|
|
97
|
+
* @returns Object with methods for advancing through stages
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const progress = createStagedProgress(
|
|
102
|
+
* ['Initializing', 'Processing', 'Finalizing'],
|
|
103
|
+
* (status, percent) => console.log(`${status}: ${percent}%`)
|
|
104
|
+
* );
|
|
105
|
+
*
|
|
106
|
+
* progress.start(); // "Initializing: 0%"
|
|
107
|
+
* progress.nextStage(); // "Processing: 33%"
|
|
108
|
+
* progress.nextStage(); // "Finalizing: 67%"
|
|
109
|
+
* progress.complete(); // "Complete: 100%"
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export function createStagedProgress(stages, callback) {
|
|
113
|
+
const reporter = new ProgressReporter(callback);
|
|
114
|
+
let currentStageIndex = 0;
|
|
115
|
+
const percentPerStage = stages.length > 0 ? 100 / stages.length : 100;
|
|
116
|
+
return {
|
|
117
|
+
start: () => {
|
|
118
|
+
currentStageIndex = 0;
|
|
119
|
+
reporter.start(stages[0] ?? 'Starting...');
|
|
120
|
+
},
|
|
121
|
+
nextStage: () => {
|
|
122
|
+
currentStageIndex = Math.min(currentStageIndex + 1, stages.length - 1);
|
|
123
|
+
const percent = Math.round(currentStageIndex * percentPerStage);
|
|
124
|
+
reporter.update(stages[currentStageIndex] ?? 'Processing...', percent);
|
|
125
|
+
},
|
|
126
|
+
complete: () => {
|
|
127
|
+
currentStageIndex = stages.length;
|
|
128
|
+
reporter.complete();
|
|
129
|
+
},
|
|
130
|
+
getCurrentStage: () => {
|
|
131
|
+
return stages[currentStageIndex] ?? '';
|
|
132
|
+
},
|
|
133
|
+
getProgress: () => {
|
|
134
|
+
return Math.round(currentStageIndex * percentPerStage);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,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,M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