@salesforce/capg-client 0.1.0-beta.1

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.
Files changed (68) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +122 -0
  3. package/dist/client.d.ts +86 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +167 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/connect-api-client.d.ts +82 -0
  8. package/dist/connect-api-client.d.ts.map +1 -0
  9. package/dist/connect-api-client.js +106 -0
  10. package/dist/connect-api-client.js.map +1 -0
  11. package/dist/constants.d.ts +64 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +68 -0
  14. package/dist/constants.js.map +1 -0
  15. package/dist/errors/api.d.ts +79 -0
  16. package/dist/errors/api.d.ts.map +1 -0
  17. package/dist/errors/api.js +128 -0
  18. package/dist/errors/api.js.map +1 -0
  19. package/dist/errors/auth.d.ts +35 -0
  20. package/dist/errors/auth.d.ts.map +1 -0
  21. package/dist/errors/auth.js +50 -0
  22. package/dist/errors/auth.js.map +1 -0
  23. package/dist/errors/base.d.ts +103 -0
  24. package/dist/errors/base.d.ts.map +1 -0
  25. package/dist/errors/base.js +162 -0
  26. package/dist/errors/base.js.map +1 -0
  27. package/dist/errors/hub-org.d.ts +108 -0
  28. package/dist/errors/hub-org.d.ts.map +1 -0
  29. package/dist/errors/hub-org.js +144 -0
  30. package/dist/errors/hub-org.js.map +1 -0
  31. package/dist/errors/index.d.ts +33 -0
  32. package/dist/errors/index.d.ts.map +1 -0
  33. package/dist/errors/index.js +42 -0
  34. package/dist/errors/index.js.map +1 -0
  35. package/dist/errors/network.d.ts +53 -0
  36. package/dist/errors/network.d.ts.map +1 -0
  37. package/dist/errors/network.js +77 -0
  38. package/dist/errors/network.js.map +1 -0
  39. package/dist/errors/validation.d.ts +69 -0
  40. package/dist/errors/validation.d.ts.map +1 -0
  41. package/dist/errors/validation.js +96 -0
  42. package/dist/errors/validation.js.map +1 -0
  43. package/dist/index.d.ts +16 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +28 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/org-pref-checker.d.ts +129 -0
  48. package/dist/org-pref-checker.d.ts.map +1 -0
  49. package/dist/org-pref-checker.js +193 -0
  50. package/dist/org-pref-checker.js.map +1 -0
  51. package/dist/policy-fetcher.d.ts +144 -0
  52. package/dist/policy-fetcher.d.ts.map +1 -0
  53. package/dist/policy-fetcher.js +241 -0
  54. package/dist/policy-fetcher.js.map +1 -0
  55. package/dist/tsconfig.tsbuildinfo +1 -0
  56. package/dist/types/index.d.ts +532 -0
  57. package/dist/types/index.d.ts.map +1 -0
  58. package/dist/types/index.js +6 -0
  59. package/dist/types/index.js.map +1 -0
  60. package/dist/types/result.d.ts +282 -0
  61. package/dist/types/result.d.ts.map +1 -0
  62. package/dist/types/result.js +351 -0
  63. package/dist/types/result.js.map +1 -0
  64. package/dist/utils/error-classifier.d.ts +55 -0
  65. package/dist/utils/error-classifier.d.ts.map +1 -0
  66. package/dist/utils/error-classifier.js +90 -0
  67. package/dist/utils/error-classifier.js.map +1 -0
  68. package/package.json +143 -0
@@ -0,0 +1,162 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ /**
6
+ * Base Error Class for CAPG Client
7
+ *
8
+ * This is the foundation error class for all CAPG-specific errors.
9
+ * All other error classes should extend this base class.
10
+ *
11
+ * Features:
12
+ * - Error code for programmatic error type identification
13
+ * - Error cause chaining for tracking root causes
14
+ * - Retry flags for automatic retry logic
15
+ * - User actionability flags for UX decisions
16
+ * - Request ID for distributed tracing
17
+ * - Suggested actions for user guidance
18
+ * - Stack trace preservation
19
+ * - JSON serialization support
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const error = new CAPGError(
24
+ * 'OPERATION_FAILED',
25
+ * 'Failed to complete operation',
26
+ * 'Try again later'
27
+ * );
28
+ * console.error(error.toJSON());
29
+ * ```
30
+ */
31
+ export class CAPGError extends Error {
32
+ /**
33
+ * Error code for programmatic identification
34
+ *
35
+ * @readonly
36
+ */
37
+ code;
38
+ /**
39
+ * The underlying error that caused this error (if any)
40
+ *
41
+ * @readonly
42
+ */
43
+ cause;
44
+ /**
45
+ * Whether this error is retryable (transient failure)
46
+ *
47
+ * @readonly
48
+ */
49
+ isRetryable;
50
+ /**
51
+ * Whether user action can resolve this error
52
+ *
53
+ * @readonly
54
+ */
55
+ isUserActionable;
56
+ /**
57
+ * Request ID for distributed tracing (optional)
58
+ */
59
+ requestId;
60
+ /**
61
+ * Suggested action to resolve the error (optional)
62
+ *
63
+ * @readonly
64
+ */
65
+ suggestedAction;
66
+ /**
67
+ * Creates a new CAPGError instance
68
+ *
69
+ * @param code - Error code for programmatic identification
70
+ * @param message - Human-readable error message
71
+ * @param suggestedAction - Optional suggested action to resolve the error
72
+ * @param cause - Optional underlying error that caused this error
73
+ * @param isRetryable - Whether this error is retryable (default: false)
74
+ * @param isUserActionable - Whether user action can resolve this error (default: true)
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const error = new CAPGError(
79
+ * 'CONFIG_ERROR',
80
+ * 'Invalid configuration',
81
+ * 'Check your config file',
82
+ * originalError,
83
+ * false,
84
+ * true
85
+ * );
86
+ * ```
87
+ */
88
+ constructor(code, message, suggestedAction, cause, isRetryable = false, isUserActionable = true) {
89
+ super(message);
90
+ // Set error name to class name for better stack traces
91
+ this.name = 'CAPGError';
92
+ // Set all properties
93
+ this.code = code;
94
+ this.suggestedAction = suggestedAction;
95
+ this.cause = cause;
96
+ this.isRetryable = isRetryable;
97
+ this.isUserActionable = isUserActionable;
98
+ // Maintain proper prototype chain for instanceof checks
99
+ // This is required because TypeScript/JavaScript don't properly
100
+ // handle prototype chains when extending built-in classes like Error
101
+ Object.setPrototypeOf(this, CAPGError.prototype);
102
+ // Capture stack trace for debugging
103
+ // Exclude constructor call from stack trace
104
+ if (Error.captureStackTrace) {
105
+ Error.captureStackTrace(this, this.constructor);
106
+ }
107
+ }
108
+ /**
109
+ * Serializes the error to a JSON object
110
+ *
111
+ * This method is called automatically by JSON.stringify().
112
+ * It includes all error properties and recursively serializes
113
+ * the cause chain.
114
+ *
115
+ * @returns JSON representation of the error
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const error = new CAPGError('TEST_ERROR', 'Test message');
120
+ * const json = error.toJSON();
121
+ * console.log(JSON.stringify(json, null, 2));
122
+ * ```
123
+ */
124
+ toJSON() {
125
+ const json = {
126
+ name: this.name,
127
+ code: this.code,
128
+ message: this.message,
129
+ isRetryable: this.isRetryable,
130
+ isUserActionable: this.isUserActionable,
131
+ stack: this.stack,
132
+ };
133
+ // Include optional properties if they are defined
134
+ if (this.suggestedAction !== undefined) {
135
+ json.suggestedAction = this.suggestedAction;
136
+ }
137
+ if (this.requestId !== undefined) {
138
+ json.requestId = this.requestId;
139
+ }
140
+ // Recursively serialize cause chain
141
+ if (this.cause !== undefined) {
142
+ if (this.cause instanceof CAPGError) {
143
+ // CAPGError has toJSON method
144
+ json.cause = this.cause.toJSON();
145
+ }
146
+ else if (this.cause instanceof Error) {
147
+ // Native Error - serialize basic properties
148
+ json.cause = {
149
+ name: this.cause.name,
150
+ message: this.cause.message,
151
+ stack: this.cause.stack,
152
+ };
153
+ }
154
+ else {
155
+ // Non-Error cause (edge case)
156
+ json.cause = this.cause;
157
+ }
158
+ }
159
+ return json;
160
+ }
161
+ }
162
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/errors/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC;;;;OAIG;IACa,IAAI,CAAS;IAE7B;;;;OAIG;IACa,KAAK,CAAS;IAE9B;;;;OAIG;IACa,WAAW,CAAU;IAErC;;;;OAIG;IACa,gBAAgB,CAAU;IAE1C;;OAEG;IACI,SAAS,CAAU;IAE1B;;;;OAIG;IACa,eAAe,CAAU;IAEzC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YACE,IAAY,EACZ,OAAe,EACf,eAAwB,EACxB,KAAa,EACb,cAAuB,KAAK,EAC5B,mBAA4B,IAAI;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,uDAAuD;QACvD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QAExB,qBAAqB;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,wDAAwD;QACxD,gEAAgE;QAChE,qEAAqE;QACrE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAEjD,oCAAoC;QACpC,4CAA4C;QAC5C,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,MAAM;QACX,MAAM,IAAI,GAA4B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;QAEF,kDAAkD;QAClD,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACvC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC9C,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAClC,CAAC;QAED,oCAAoC;QACpC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,KAAK,YAAY,SAAS,EAAE,CAAC;gBACpC,8BAA8B;gBAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACnC,CAAC;iBAAM,IAAI,IAAI,CAAC,KAAK,YAAY,KAAK,EAAE,CAAC;gBACvC,4CAA4C;gBAC5C,IAAI,CAAC,KAAK,GAAG;oBACX,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;oBACrB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;oBAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;iBACxB,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,8BAA8B;gBAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Hub Org Error Classes
3
+ *
4
+ * Errors related to Hub Org authentication and validation.
5
+ * These errors indicate that the user needs to authenticate or provide a valid Hub Org.
6
+ *
7
+ * @deprecated These error classes are deprecated as of v0.2.0. Hub org auto-detection
8
+ * has been removed in favor of explicit org alias specification. These classes are
9
+ * retained for future Connect API integration work but marked @internal.
10
+ *
11
+ * @internal These classes should not be used by external consumers. They are preserved
12
+ * for future Connect API integration work.
13
+ */
14
+ import { CAPGError } from './base.js';
15
+ /**
16
+ * Hub Org Not Found Error
17
+ *
18
+ * Thrown when no Hub Org is detected in the authenticated orgs.
19
+ * The user needs to authenticate with a Hub Org.
20
+ *
21
+ * Properties:
22
+ * - code: 'HUB_ORG_NOT_FOUND'
23
+ * - isRetryable: false (user must authenticate)
24
+ * - isUserActionable: true (user can fix by logging in)
25
+ * - suggestedAction: CLI command to authenticate with Hub Org
26
+ *
27
+ * @deprecated This error class is deprecated as of v0.2.0. Hub org auto-detection
28
+ * has been removed. Use explicit org alias specification instead.
29
+ *
30
+ * @internal This class should not be used by external consumers. It is preserved
31
+ * for future Connect API integration work.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * throw new HubOrgNotFoundError('No Hub Org found in authenticated orgs');
36
+ * ```
37
+ */
38
+ export declare class HubOrgNotFoundError extends CAPGError {
39
+ /**
40
+ * Creates a new HubOrgNotFoundError instance
41
+ *
42
+ * @param message - Human-readable error message
43
+ * @param context - Optional context object with additional information
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const error = new HubOrgNotFoundError(
48
+ * 'No Hub Org found. Checked aliases: hub1, hub2',
49
+ * { attemptedAliases: ['hub1', 'hub2'], availableOrgs: 3 }
50
+ * );
51
+ * ```
52
+ */
53
+ constructor(message: string);
54
+ }
55
+ /**
56
+ * Invalid Hub Org Error
57
+ *
58
+ * Thrown when an org exists but is not a valid Dev Hub.
59
+ * The user needs to provide a different org that has Dev Hub enabled.
60
+ *
61
+ * Properties:
62
+ * - code: 'INVALID_HUB_ORG'
63
+ * - isRetryable: false (user must provide different org)
64
+ * - isUserActionable: true (user can fix by providing valid Hub Org)
65
+ * - orgAlias: The org alias that was invalid
66
+ * - suggestedAction: Guidance to provide a valid Hub Org
67
+ *
68
+ * @deprecated This error class is deprecated as of v0.2.0. Hub org auto-detection
69
+ * has been removed. Use explicit org alias specification instead.
70
+ *
71
+ * @internal This class should not be used by external consumers. It is preserved
72
+ * for future Connect API integration work.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * throw new InvalidHubOrgError('myOrg', 'Org is not a Dev Hub');
77
+ * ```
78
+ */
79
+ export declare class InvalidHubOrgError extends CAPGError {
80
+ /**
81
+ * The org alias that was invalid
82
+ *
83
+ * @readonly
84
+ */
85
+ readonly orgAlias: string;
86
+ /**
87
+ * Creates a new InvalidHubOrgError instance
88
+ *
89
+ * @param orgAlias - The org alias that was invalid
90
+ * @param message - Human-readable error message
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const error = new InvalidHubOrgError(
95
+ * 'testOrg',
96
+ * 'Org testOrg is not a Dev Hub. Enable Dev Hub in Setup.'
97
+ * );
98
+ * console.error(error.orgAlias); // 'testOrg'
99
+ * ```
100
+ */
101
+ constructor(orgAlias: string, message: string);
102
+ /**
103
+ * Serializes the error to JSON
104
+ * Includes orgAlias property
105
+ */
106
+ toJSON(): Record<string, unknown>;
107
+ }
108
+ //# sourceMappingURL=hub-org.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub-org.d.ts","sourceRoot":"","sources":["../../src/errors/hub-org.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD;;;;;;;;;;;;;OAaG;gBACgB,OAAO,EAAE,MAAM;CAyBnC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C;;;;OAIG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;;;;;;;;;;;;;OAcG;gBACgB,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAyBpD;;;OAGG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQzC"}
@@ -0,0 +1,144 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ /**
6
+ * Hub Org Error Classes
7
+ *
8
+ * Errors related to Hub Org authentication and validation.
9
+ * These errors indicate that the user needs to authenticate or provide a valid Hub Org.
10
+ *
11
+ * @deprecated These error classes are deprecated as of v0.2.0. Hub org auto-detection
12
+ * has been removed in favor of explicit org alias specification. These classes are
13
+ * retained for future Connect API integration work but marked @internal.
14
+ *
15
+ * @internal These classes should not be used by external consumers. They are preserved
16
+ * for future Connect API integration work.
17
+ */
18
+ import { CAPGError } from './base.js';
19
+ /**
20
+ * Hub Org Not Found Error
21
+ *
22
+ * Thrown when no Hub Org is detected in the authenticated orgs.
23
+ * The user needs to authenticate with a Hub Org.
24
+ *
25
+ * Properties:
26
+ * - code: 'HUB_ORG_NOT_FOUND'
27
+ * - isRetryable: false (user must authenticate)
28
+ * - isUserActionable: true (user can fix by logging in)
29
+ * - suggestedAction: CLI command to authenticate with Hub Org
30
+ *
31
+ * @deprecated This error class is deprecated as of v0.2.0. Hub org auto-detection
32
+ * has been removed. Use explicit org alias specification instead.
33
+ *
34
+ * @internal This class should not be used by external consumers. It is preserved
35
+ * for future Connect API integration work.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * throw new HubOrgNotFoundError('No Hub Org found in authenticated orgs');
40
+ * ```
41
+ */
42
+ export class HubOrgNotFoundError extends CAPGError {
43
+ /**
44
+ * Creates a new HubOrgNotFoundError instance
45
+ *
46
+ * @param message - Human-readable error message
47
+ * @param context - Optional context object with additional information
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const error = new HubOrgNotFoundError(
52
+ * 'No Hub Org found. Checked aliases: hub1, hub2',
53
+ * { attemptedAliases: ['hub1', 'hub2'], availableOrgs: 3 }
54
+ * );
55
+ * ```
56
+ */
57
+ constructor(message) {
58
+ super('HUB_ORG_NOT_FOUND', message, 'Login to Hub Org: sf org login web --set-default-dev-hub', undefined, false, // Not retryable - user must authenticate
59
+ true);
60
+ // Set error name to class name for better stack traces
61
+ this.name = 'HubOrgNotFoundError';
62
+ // Maintain proper prototype chain for instanceof checks
63
+ Object.setPrototypeOf(this, HubOrgNotFoundError.prototype);
64
+ // Capture stack trace for debugging
65
+ if (Error.captureStackTrace) {
66
+ Error.captureStackTrace(this, this.constructor);
67
+ }
68
+ // Note: _context is accepted but not stored as a property
69
+ // It's just for flexibility in error construction
70
+ // Prefixed with _ to indicate intentionally unused parameter
71
+ }
72
+ }
73
+ /**
74
+ * Invalid Hub Org Error
75
+ *
76
+ * Thrown when an org exists but is not a valid Dev Hub.
77
+ * The user needs to provide a different org that has Dev Hub enabled.
78
+ *
79
+ * Properties:
80
+ * - code: 'INVALID_HUB_ORG'
81
+ * - isRetryable: false (user must provide different org)
82
+ * - isUserActionable: true (user can fix by providing valid Hub Org)
83
+ * - orgAlias: The org alias that was invalid
84
+ * - suggestedAction: Guidance to provide a valid Hub Org
85
+ *
86
+ * @deprecated This error class is deprecated as of v0.2.0. Hub org auto-detection
87
+ * has been removed. Use explicit org alias specification instead.
88
+ *
89
+ * @internal This class should not be used by external consumers. It is preserved
90
+ * for future Connect API integration work.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * throw new InvalidHubOrgError('myOrg', 'Org is not a Dev Hub');
95
+ * ```
96
+ */
97
+ export class InvalidHubOrgError extends CAPGError {
98
+ /**
99
+ * The org alias that was invalid
100
+ *
101
+ * @readonly
102
+ */
103
+ orgAlias;
104
+ /**
105
+ * Creates a new InvalidHubOrgError instance
106
+ *
107
+ * @param orgAlias - The org alias that was invalid
108
+ * @param message - Human-readable error message
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const error = new InvalidHubOrgError(
113
+ * 'testOrg',
114
+ * 'Org testOrg is not a Dev Hub. Enable Dev Hub in Setup.'
115
+ * );
116
+ * console.error(error.orgAlias); // 'testOrg'
117
+ * ```
118
+ */
119
+ constructor(orgAlias, message) {
120
+ super('INVALID_HUB_ORG', message, 'Provide a valid Hub Org alias or enable Dev Hub in the org', undefined, false, // Not retryable - user must provide different org
121
+ true);
122
+ // Set error name to class name for better stack traces
123
+ this.name = 'InvalidHubOrgError';
124
+ // Store org alias
125
+ this.orgAlias = orgAlias;
126
+ // Maintain proper prototype chain for instanceof checks
127
+ Object.setPrototypeOf(this, InvalidHubOrgError.prototype);
128
+ // Capture stack trace for debugging
129
+ if (Error.captureStackTrace) {
130
+ Error.captureStackTrace(this, this.constructor);
131
+ }
132
+ }
133
+ /**
134
+ * Serializes the error to JSON
135
+ * Includes orgAlias property
136
+ */
137
+ toJSON() {
138
+ const json = super.toJSON();
139
+ // Include orgAlias
140
+ json.orgAlias = this.orgAlias;
141
+ return json;
142
+ }
143
+ }
144
+ //# sourceMappingURL=hub-org.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub-org.js","sourceRoot":"","sources":["../../src/errors/hub-org.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD;;;;;;;;;;;;;OAaG;IACH,YAAmB,OAAe;QAChC,KAAK,CACH,mBAAmB,EACnB,OAAO,EACP,0DAA0D,EAC1D,SAAS,EACT,KAAK,EAAE,yCAAyC;QAChD,IAAI,CACL,CAAC;QAEF,uDAAuD;QACvD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAElC,wDAAwD;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAE3D,oCAAoC;QACpC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,0DAA0D;QAC1D,kDAAkD;QAClD,6DAA6D;IAC/D,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C;;;;OAIG;IACa,QAAQ,CAAS;IAEjC;;;;;;;;;;;;;;OAcG;IACH,YAAmB,QAAgB,EAAE,OAAe;QAClD,KAAK,CACH,iBAAiB,EACjB,OAAO,EACP,4DAA4D,EAC5D,SAAS,EACT,KAAK,EAAE,kDAAkD;QACzD,IAAI,CACL,CAAC;QAEF,uDAAuD;QACvD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QAEjC,kBAAkB;QAClB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,wDAAwD;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAE1D,oCAAoC;QACpC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAE5B,mBAAmB;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * CAPG Client Error Classes
3
+ *
4
+ * Barrel export file for all error classes.
5
+ * Import all error classes from this single entry point.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import {
10
+ * CAPGError,
11
+ * CAPGAuthError,
12
+ * CAPGNetworkError,
13
+ * CAPGAPIError,
14
+ * HubOrgNotFoundError,
15
+ * InvalidHubOrgError,
16
+ * CAPGValidationError
17
+ * } from './errors.js';
18
+ * ```
19
+ */
20
+ export { CAPGError } from './base.js';
21
+ export { CAPGAuthError } from './auth.js';
22
+ /**
23
+ * Hub Org errors
24
+ *
25
+ * @deprecated These error classes are deprecated as of v0.2.0. Hub org auto-detection
26
+ * has been removed in favor of explicit org alias specification. These classes are
27
+ * retained for future Connect API integration work but marked @internal.
28
+ */
29
+ export { HubOrgNotFoundError, InvalidHubOrgError } from './hub-org.js';
30
+ export { CAPGNetworkError } from './network.js';
31
+ export { CAPGAPIError } from './api.js';
32
+ export { CAPGValidationError } from './validation.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ /**
6
+ * CAPG Client Error Classes
7
+ *
8
+ * Barrel export file for all error classes.
9
+ * Import all error classes from this single entry point.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import {
14
+ * CAPGError,
15
+ * CAPGAuthError,
16
+ * CAPGNetworkError,
17
+ * CAPGAPIError,
18
+ * HubOrgNotFoundError,
19
+ * InvalidHubOrgError,
20
+ * CAPGValidationError
21
+ * } from './errors.js';
22
+ * ```
23
+ */
24
+ // Base error class
25
+ export { CAPGError } from './base.js';
26
+ // Authentication error
27
+ export { CAPGAuthError } from './auth.js';
28
+ /**
29
+ * Hub Org errors
30
+ *
31
+ * @deprecated These error classes are deprecated as of v0.2.0. Hub org auto-detection
32
+ * has been removed in favor of explicit org alias specification. These classes are
33
+ * retained for future Connect API integration work but marked @internal.
34
+ */
35
+ export { HubOrgNotFoundError, InvalidHubOrgError } from './hub-org.js';
36
+ // Network error
37
+ export { CAPGNetworkError } from './network.js';
38
+ // API error
39
+ export { CAPGAPIError } from './api.js';
40
+ // Validation error
41
+ export { CAPGValidationError } from './validation.js';
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvE,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,YAAY;AACZ,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,mBAAmB;AACnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Network Error Class
3
+ *
4
+ * Thrown when network failures occur (timeout, DNS failure, connection refused, etc.).
5
+ * These are typically transient failures that can be retried.
6
+ *
7
+ * Properties:
8
+ * - code: 'NETWORK_ERROR'
9
+ * - isRetryable: true (transient network failures)
10
+ * - isUserActionable: false (network issues are usually temporary)
11
+ * - statusCode: Optional HTTP status code (e.g., 408 timeout, 504 gateway timeout)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * throw new CAPGNetworkError('Connection timeout', 504);
16
+ * ```
17
+ */
18
+ import { CAPGError } from './base.js';
19
+ export declare class CAPGNetworkError extends CAPGError {
20
+ /**
21
+ * HTTP status code (if available)
22
+ *
23
+ * @readonly
24
+ */
25
+ readonly statusCode?: number;
26
+ /**
27
+ * Creates a new CAPGNetworkError instance
28
+ *
29
+ * @param message - Human-readable error message
30
+ * @param statusCode - Optional HTTP status code (e.g., 408, 503, 504)
31
+ * @param cause - Optional underlying error that caused this network error
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // DNS failure (no status code)
36
+ * const dnsError = new CAPGNetworkError('DNS resolution failed');
37
+ *
38
+ * // Gateway timeout (with status code)
39
+ * const timeoutError = new CAPGNetworkError('Gateway timeout', 504);
40
+ *
41
+ * // Connection refused (with cause)
42
+ * const socketError = new Error('ECONNREFUSED');
43
+ * const connError = new CAPGNetworkError('Connection refused', undefined, socketError);
44
+ * ```
45
+ */
46
+ constructor(message: string, statusCode?: number, cause?: Error);
47
+ /**
48
+ * Serializes the network error to JSON
49
+ * Includes statusCode if present
50
+ */
51
+ toJSON(): Record<string, unknown>;
52
+ }
53
+ //# sourceMappingURL=network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/errors/network.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C;;;;OAIG;IACH,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;;;;;;;;;;;;;;;;OAmBG;gBACgB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAyBtE;;;OAGG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUzC"}
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ /**
6
+ * Network Error Class
7
+ *
8
+ * Thrown when network failures occur (timeout, DNS failure, connection refused, etc.).
9
+ * These are typically transient failures that can be retried.
10
+ *
11
+ * Properties:
12
+ * - code: 'NETWORK_ERROR'
13
+ * - isRetryable: true (transient network failures)
14
+ * - isUserActionable: false (network issues are usually temporary)
15
+ * - statusCode: Optional HTTP status code (e.g., 408 timeout, 504 gateway timeout)
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * throw new CAPGNetworkError('Connection timeout', 504);
20
+ * ```
21
+ */
22
+ import { CAPGError } from './base.js';
23
+ export class CAPGNetworkError extends CAPGError {
24
+ /**
25
+ * HTTP status code (if available)
26
+ *
27
+ * @readonly
28
+ */
29
+ statusCode;
30
+ /**
31
+ * Creates a new CAPGNetworkError instance
32
+ *
33
+ * @param message - Human-readable error message
34
+ * @param statusCode - Optional HTTP status code (e.g., 408, 503, 504)
35
+ * @param cause - Optional underlying error that caused this network error
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // DNS failure (no status code)
40
+ * const dnsError = new CAPGNetworkError('DNS resolution failed');
41
+ *
42
+ * // Gateway timeout (with status code)
43
+ * const timeoutError = new CAPGNetworkError('Gateway timeout', 504);
44
+ *
45
+ * // Connection refused (with cause)
46
+ * const socketError = new Error('ECONNREFUSED');
47
+ * const connError = new CAPGNetworkError('Connection refused', undefined, socketError);
48
+ * ```
49
+ */
50
+ constructor(message, statusCode, cause) {
51
+ super('NETWORK_ERROR', message, 'Check your network connection and try again', cause, true, // Retryable - network failures are typically transient
52
+ false);
53
+ // Set error name to class name for better stack traces
54
+ this.name = 'CAPGNetworkError';
55
+ // Store status code if provided
56
+ this.statusCode = statusCode;
57
+ // Maintain proper prototype chain for instanceof checks
58
+ Object.setPrototypeOf(this, CAPGNetworkError.prototype);
59
+ // Capture stack trace for debugging
60
+ if (Error.captureStackTrace) {
61
+ Error.captureStackTrace(this, this.constructor);
62
+ }
63
+ }
64
+ /**
65
+ * Serializes the network error to JSON
66
+ * Includes statusCode if present
67
+ */
68
+ toJSON() {
69
+ const json = super.toJSON();
70
+ // Include statusCode if present
71
+ if (this.statusCode !== undefined) {
72
+ json.statusCode = this.statusCode;
73
+ }
74
+ return json;
75
+ }
76
+ }
77
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/errors/network.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C;;;;OAIG;IACa,UAAU,CAAU;IAEpC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAmB,OAAe,EAAE,UAAmB,EAAE,KAAa;QACpE,KAAK,CACH,eAAe,EACf,OAAO,EACP,6CAA6C,EAC7C,KAAK,EACL,IAAI,EAAE,uDAAuD;QAC7D,KAAK,CACN,CAAC;QAEF,uDAAuD;QACvD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAE/B,gCAAgC;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,wDAAwD;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAExD,oCAAoC;QACpC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAE5B,gCAAgC;QAChC,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACpC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}