@databricks/appkit 0.36.0 → 0.38.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/CLAUDE.md +3 -2
- package/NOTICE.md +1 -0
- package/dist/appkit/package.js +1 -1
- package/dist/cache/index.js +1 -2
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/storage/persistent.js +1 -2
- package/dist/cache/storage/persistent.js.map +1 -1
- package/dist/cli/commands/plugin/add-resource/add-resource.js.map +1 -1
- package/dist/cli/commands/plugin/create/resource-defaults.js +2 -1
- package/dist/cli/commands/plugin/create/resource-defaults.js.map +1 -1
- package/dist/cli/commands/plugin/schema-resources.js +34 -51
- package/dist/cli/commands/plugin/schema-resources.js.map +1 -1
- package/dist/cli/commands/plugin/sync/sync.js +20 -6
- package/dist/cli/commands/plugin/sync/sync.js.map +1 -1
- package/dist/cli/commands/plugin/validate/validate-manifest.js +71 -157
- package/dist/cli/commands/plugin/validate/validate-manifest.js.map +1 -1
- package/dist/cli/commands/plugin/validate/validate.js +2 -2
- package/dist/cli/commands/plugin/validate/validate.js.map +1 -1
- package/dist/cli/commands/setup.js +2 -2
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/connectors/index.js +0 -1
- package/dist/connectors/jobs/client.js +1 -2
- package/dist/connectors/jobs/client.js.map +1 -1
- package/dist/connectors/lakebase/routing-pool.js +1 -2
- package/dist/connectors/lakebase/routing-pool.js.map +1 -1
- package/dist/connectors/sql-warehouse/client.js +1 -2
- package/dist/connectors/sql-warehouse/client.js.map +1 -1
- package/dist/context/execution-context.js +9 -13
- package/dist/context/execution-context.js.map +1 -1
- package/dist/context/index.js +3 -13
- package/dist/context/service-context.js +137 -136
- package/dist/context/service-context.js.map +1 -1
- package/dist/context/user-context.js +1 -5
- package/dist/context/user-context.js.map +1 -1
- package/dist/core/agent/create-agent.js +1 -2
- package/dist/core/agent/create-agent.js.map +1 -1
- package/dist/core/appkit.d.ts.map +1 -1
- package/dist/core/appkit.js +9 -37
- package/dist/core/appkit.js.map +1 -1
- package/dist/errors/authentication.js +44 -40
- package/dist/errors/authentication.js.map +1 -1
- package/dist/errors/base.js +86 -70
- package/dist/errors/base.js.map +1 -1
- package/dist/errors/configuration.js +70 -66
- package/dist/errors/configuration.js.map +1 -1
- package/dist/errors/connection.js +50 -46
- package/dist/errors/connection.js.map +1 -1
- package/dist/errors/execution.js +47 -43
- package/dist/errors/execution.js.map +1 -1
- package/dist/errors/index.js +10 -27
- package/dist/errors/initialization.js +38 -34
- package/dist/errors/initialization.js.map +1 -1
- package/dist/errors/server.js +34 -31
- package/dist/errors/server.js.map +1 -1
- package/dist/errors/tunnel.js +47 -43
- package/dist/errors/tunnel.js.map +1 -1
- package/dist/errors/validation.js +41 -37
- package/dist/errors/validation.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -9
- package/dist/plugin/dev-reader.js +1 -2
- package/dist/plugin/dev-reader.js.map +1 -1
- package/dist/plugin/interceptors/retry.js +1 -2
- package/dist/plugin/interceptors/retry.js.map +1 -1
- package/dist/plugin/interceptors/telemetry.js +1 -2
- package/dist/plugin/interceptors/telemetry.js.map +1 -1
- package/dist/plugin/plugin.d.ts +12 -4
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +59 -28
- package/dist/plugin/plugin.js.map +1 -1
- package/dist/plugins/agents/agents.d.ts +56 -3
- package/dist/plugins/agents/agents.d.ts.map +1 -1
- package/dist/plugins/agents/agents.js +160 -8
- package/dist/plugins/agents/agents.js.map +1 -1
- package/dist/plugins/agents/schemas.js +0 -1
- package/dist/plugins/agents/schemas.js.map +1 -1
- package/dist/plugins/analytics/analytics.js +1 -2
- package/dist/plugins/analytics/analytics.js.map +1 -1
- package/dist/plugins/analytics/manifest.js +9 -1
- package/dist/plugins/analytics/query.js +2 -4
- package/dist/plugins/analytics/query.js.map +1 -1
- package/dist/plugins/files/manifest.js +7 -1
- package/dist/plugins/files/plugin.js +3 -6
- package/dist/plugins/files/plugin.js.map +1 -1
- package/dist/plugins/genie/genie.js +1 -2
- package/dist/plugins/genie/genie.js.map +1 -1
- package/dist/plugins/genie/manifest.js +7 -1
- package/dist/plugins/jobs/plugin.js +2 -4
- package/dist/plugins/jobs/plugin.js.map +1 -1
- package/dist/plugins/lakebase/lakebase.js +1 -2
- package/dist/plugins/lakebase/lakebase.js.map +1 -1
- package/dist/plugins/lakebase/manifest.js +26 -4
- package/dist/plugins/server/index.js +1 -2
- package/dist/plugins/server/index.js.map +1 -1
- package/dist/plugins/server/vite-dev-server.js +1 -2
- package/dist/plugins/server/vite-dev-server.js.map +1 -1
- package/dist/plugins/serving/serving.js +1 -2
- package/dist/plugins/serving/serving.js.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/manifest-loader.d.ts +4 -4
- package/dist/registry/manifest-loader.d.ts.map +1 -1
- package/dist/registry/manifest-loader.js +1 -2
- package/dist/registry/manifest-loader.js.map +1 -1
- package/dist/registry/resource-registry.js +1 -2
- package/dist/registry/resource-registry.js.map +1 -1
- package/dist/registry/types.d.ts +21 -7
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/types.generated.d.ts +1 -1
- package/dist/registry/types.generated.js +1 -1
- package/dist/registry/types.generated.js.map +1 -1
- package/dist/registry/types.js +3 -3
- package/dist/registry/types.js.map +1 -1
- package/dist/schemas/manifest.d.ts +1139 -0
- package/dist/schemas/manifest.d.ts.map +1 -0
- package/dist/schemas/manifest.js +524 -0
- package/dist/schemas/manifest.js.map +1 -0
- package/dist/shared/src/index.d.ts +1 -1
- package/dist/shared/src/plugin.d.ts +38 -7
- package/dist/shared/src/plugin.d.ts.map +1 -1
- package/dist/shared/src/schemas/manifest.d.ts +1110 -0
- package/dist/shared/src/schemas/manifest.d.ts.map +1 -0
- package/dist/stream/arrow-stream-processor.js +1 -2
- package/dist/stream/arrow-stream-processor.js.map +1 -1
- package/dist/stream/buffers.js +1 -2
- package/dist/stream/buffers.js.map +1 -1
- package/docs/api/appkit/Enumeration.ResourceType.md +1 -1
- package/docs/api/appkit/Interface.PluginManifest.md +57 -3
- package/docs/api/appkit/Interface.ResourceEntry.md +6 -4
- package/docs/api/appkit/Interface.ResourceRequirement.md +7 -61
- package/docs/api/appkit/TypeAlias.ResourceFieldEntry.md +6 -0
- package/docs/api/appkit/Variable.agents.md +1 -1
- package/docs/api/appkit.md +12 -12
- package/docs/app-management.md +1 -1
- package/docs/development/ai-assisted-development.md +2 -2
- package/docs/development/local-development.md +1 -1
- package/docs/development/remote-bridge.md +1 -1
- package/docs/development/templates.md +118 -12
- package/docs/development.md +1 -1
- package/docs/plugins/agents.md +8 -4
- package/docs/plugins/custom-plugins.md +33 -23
- package/docs/plugins/lakebase.md +1 -1
- package/docs/plugins/manifest.md +293 -0
- package/docs.md +2 -2
- package/llms.txt +3 -2
- package/package.json +3 -3
- package/sbom.cdx.json +1 -1
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/connectors/lakebase-v1/client.js +0 -15
- package/dist/connectors/lakebase-v1/client.js.map +0 -1
- package/dist/connectors/lakebase-v1/index.js +0 -3
- package/dist/context/index.js.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/schemas/plugin-manifest.generated.d.ts +0 -182
- package/dist/schemas/plugin-manifest.generated.d.ts.map +0 -1
- package/dist/schemas/plugin-manifest.schema.json +0 -489
- package/dist/schemas/template-plugins.schema.json +0 -113
- package/dist/shared/src/schemas/plugin-manifest.generated.d.ts +0 -182
- package/dist/shared/src/schemas/plugin-manifest.generated.d.ts.map +0 -1
- package/docs/api/appkit/Interface.ResourceFieldEntry.md +0 -82
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppKitError, init_base } from "./base.js";
|
|
1
|
+
import { AppKitError } from "./base.js";
|
|
3
2
|
|
|
4
3
|
//#region src/errors/authentication.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when authentication fails.
|
|
6
|
+
* Use for missing tokens, invalid credentials, or authorization failures.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new AuthenticationError("User token is required");
|
|
11
|
+
* throw new AuthenticationError("Failed to generate credentials", { cause: originalError });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
var AuthenticationError = class AuthenticationError extends AppKitError {
|
|
15
|
+
code = "AUTHENTICATION_ERROR";
|
|
16
|
+
statusCode = 401;
|
|
17
|
+
isRetryable = false;
|
|
18
|
+
/**
|
|
19
|
+
* Create an authentication error for missing token
|
|
20
|
+
*/
|
|
21
|
+
static missingToken(tokenType = "access token") {
|
|
22
|
+
return new AuthenticationError(`Missing ${tokenType} in request headers`, { context: { tokenType } });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create an authentication error for missing user identity
|
|
26
|
+
*/
|
|
27
|
+
static missingUserId() {
|
|
28
|
+
return new AuthenticationError("User ID not available in request headers. Ensure the request has the x-forwarded-user header.");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an authentication error for credential generation failure
|
|
32
|
+
*/
|
|
33
|
+
static credentialsFailed(instance, cause) {
|
|
34
|
+
return new AuthenticationError(`Failed to generate credentials for instance: ${instance}`, {
|
|
35
|
+
cause,
|
|
36
|
+
context: { instance }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create an authentication error for failed user lookup
|
|
41
|
+
*/
|
|
42
|
+
static userLookupFailed(cause) {
|
|
43
|
+
return new AuthenticationError("Failed to get current user from Databricks workspace", { cause });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
41
46
|
|
|
42
47
|
//#endregion
|
|
43
|
-
|
|
44
|
-
export { AuthenticationError, init_authentication };
|
|
48
|
+
export { AuthenticationError };
|
|
45
49
|
//# sourceMappingURL=authentication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.js","names":[],"sources":["../../src/errors/authentication.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when authentication fails.\n * Use for missing tokens, invalid credentials, or authorization failures.\n *\n * @example\n * ```typescript\n * throw new AuthenticationError(\"User token is required\");\n * throw new AuthenticationError(\"Failed to generate credentials\", { cause: originalError });\n * ```\n */\nexport class AuthenticationError extends AppKitError {\n readonly code = \"AUTHENTICATION_ERROR\";\n readonly statusCode = 401;\n readonly isRetryable = false;\n\n /**\n * Create an authentication error for missing token\n */\n static missingToken(tokenType = \"access token\"): AuthenticationError {\n return new AuthenticationError(`Missing ${tokenType} in request headers`, {\n context: { tokenType },\n });\n }\n\n /**\n * Create an authentication error for missing user identity\n */\n static missingUserId(): AuthenticationError {\n return new AuthenticationError(\n \"User ID not available in request headers. \" +\n \"Ensure the request has the x-forwarded-user header.\",\n );\n }\n\n /**\n * Create an authentication error for credential generation failure\n */\n static credentialsFailed(\n instance: string,\n cause?: Error,\n ): AuthenticationError {\n return new AuthenticationError(\n `Failed to generate credentials for instance: ${instance}`,\n { cause, context: { instance } },\n );\n }\n\n /**\n * Create an authentication error for failed user lookup\n */\n static userLookupFailed(cause?: Error): AuthenticationError {\n return new AuthenticationError(\n \"Failed to get current user from Databricks workspace\",\n { cause },\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"authentication.js","names":[],"sources":["../../src/errors/authentication.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when authentication fails.\n * Use for missing tokens, invalid credentials, or authorization failures.\n *\n * @example\n * ```typescript\n * throw new AuthenticationError(\"User token is required\");\n * throw new AuthenticationError(\"Failed to generate credentials\", { cause: originalError });\n * ```\n */\nexport class AuthenticationError extends AppKitError {\n readonly code = \"AUTHENTICATION_ERROR\";\n readonly statusCode = 401;\n readonly isRetryable = false;\n\n /**\n * Create an authentication error for missing token\n */\n static missingToken(tokenType = \"access token\"): AuthenticationError {\n return new AuthenticationError(`Missing ${tokenType} in request headers`, {\n context: { tokenType },\n });\n }\n\n /**\n * Create an authentication error for missing user identity\n */\n static missingUserId(): AuthenticationError {\n return new AuthenticationError(\n \"User ID not available in request headers. \" +\n \"Ensure the request has the x-forwarded-user header.\",\n );\n }\n\n /**\n * Create an authentication error for credential generation failure\n */\n static credentialsFailed(\n instance: string,\n cause?: Error,\n ): AuthenticationError {\n return new AuthenticationError(\n `Failed to generate credentials for instance: ${instance}`,\n { cause, context: { instance } },\n );\n }\n\n /**\n * Create an authentication error for failed user lookup\n */\n static userLookupFailed(cause?: Error): AuthenticationError {\n return new AuthenticationError(\n \"Failed to get current user from Databricks workspace\",\n { cause },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAa,sBAAb,MAAa,4BAA4B,YAAY;CACnD,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,aAAa,YAAY,gBAAqC;AACnE,SAAO,IAAI,oBAAoB,WAAW,UAAU,sBAAsB,EACxE,SAAS,EAAE,WAAW,EACvB,CAAC;;;;;CAMJ,OAAO,gBAAqC;AAC1C,SAAO,IAAI,oBACT,gGAED;;;;;CAMH,OAAO,kBACL,UACA,OACqB;AACrB,SAAO,IAAI,oBACT,gDAAgD,YAChD;GAAE;GAAO,SAAS,EAAE,UAAU;GAAE,CACjC;;;;;CAMH,OAAO,iBAAiB,OAAoC;AAC1D,SAAO,IAAI,oBACT,wDACA,EAAE,OAAO,CACV"}
|
package/dist/errors/base.js
CHANGED
|
@@ -1,74 +1,90 @@
|
|
|
1
|
-
import { __esmMin } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
|
|
3
1
|
//#region src/errors/base.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
/** Fields that should be redacted in logs/serialization for security */
|
|
3
|
+
const SENSITIVE_FIELD_PATTERNS = [
|
|
4
|
+
/token/i,
|
|
5
|
+
/password/i,
|
|
6
|
+
/secret/i,
|
|
7
|
+
/credential/i,
|
|
8
|
+
/auth/i,
|
|
9
|
+
/key$/i,
|
|
10
|
+
/apikey/i
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Base error class for all AppKit errors.
|
|
14
|
+
* Provides a consistent structure for error handling across the framework.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Catching errors by type
|
|
19
|
+
* try {
|
|
20
|
+
* await lakebase.query("...");
|
|
21
|
+
* } catch (e) {
|
|
22
|
+
* if (e instanceof AuthenticationError) {
|
|
23
|
+
* // Re-authenticate
|
|
24
|
+
* } else if (e instanceof ConnectionError && e.isRetryable) {
|
|
25
|
+
* // Retry with backoff
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* // Logging errors
|
|
30
|
+
* console.error(error.toJSON()); // Safe for logging, sensitive values redacted
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
var AppKitError = class extends Error {
|
|
34
|
+
/** Optional cause of the error */
|
|
35
|
+
cause;
|
|
36
|
+
/** Additional context for the error */
|
|
37
|
+
context;
|
|
38
|
+
constructor(message, options) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = this.constructor.name;
|
|
41
|
+
this.cause = options?.cause;
|
|
42
|
+
this.context = options?.context;
|
|
43
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Convert error to JSON for logging/serialization.
|
|
47
|
+
* Sensitive values in context are automatically redacted.
|
|
48
|
+
*/
|
|
49
|
+
toJSON() {
|
|
50
|
+
return {
|
|
51
|
+
name: this.name,
|
|
52
|
+
code: this.code,
|
|
53
|
+
message: this.message,
|
|
54
|
+
statusCode: this.statusCode,
|
|
55
|
+
isRetryable: this.isRetryable,
|
|
56
|
+
context: this.sanitizeContext(this.context),
|
|
57
|
+
cause: this.cause?.message,
|
|
58
|
+
stack: this.stack
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a human-readable string representation
|
|
63
|
+
*/
|
|
64
|
+
toString() {
|
|
65
|
+
let str = `${this.name} [${this.code}]: ${this.message}`;
|
|
66
|
+
if (this.cause) str += ` (caused by: ${this.cause.message})`;
|
|
67
|
+
return str;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sanitize context by redacting sensitive field values
|
|
71
|
+
*/
|
|
72
|
+
sanitizeContext(context) {
|
|
73
|
+
if (!context) return void 0;
|
|
74
|
+
const sanitized = {};
|
|
75
|
+
for (const [key, value] of Object.entries(context)) if (this.isSensitiveField(key)) sanitized[key] = "[REDACTED]";
|
|
76
|
+
else if (typeof value === "object" && value !== null) sanitized[key] = Array.isArray(value) ? `[Array(${value.length})]` : "[Object]";
|
|
77
|
+
else sanitized[key] = value;
|
|
78
|
+
return sanitized;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check if a field name matches sensitive patterns
|
|
82
|
+
*/
|
|
83
|
+
isSensitiveField(fieldName) {
|
|
84
|
+
return SENSITIVE_FIELD_PATTERNS.some((pattern) => pattern.test(fieldName));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
70
87
|
|
|
71
88
|
//#endregion
|
|
72
|
-
|
|
73
|
-
export { AppKitError, init_base };
|
|
89
|
+
export { AppKitError };
|
|
74
90
|
//# sourceMappingURL=base.js.map
|
package/dist/errors/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../../src/errors/base.ts"],"sourcesContent":["/** Fields that should be redacted in logs/serialization for security */\nconst SENSITIVE_FIELD_PATTERNS = [\n /token/i,\n /password/i,\n /secret/i,\n /credential/i,\n /auth/i,\n /key$/i,\n /apikey/i,\n];\n\n/**\n * Base error class for all AppKit errors.\n * Provides a consistent structure for error handling across the framework.\n *\n * @example\n * ```typescript\n * // Catching errors by type\n * try {\n * await lakebase.query(\"...\");\n * } catch (e) {\n * if (e instanceof AuthenticationError) {\n * // Re-authenticate\n * } else if (e instanceof ConnectionError && e.isRetryable) {\n * // Retry with backoff\n * }\n * }\n *\n * // Logging errors\n * console.error(error.toJSON()); // Safe for logging, sensitive values redacted\n * ```\n */\nexport abstract class AppKitError extends Error {\n /** Error code for programmatic error handling */\n abstract readonly code: string;\n\n /** HTTP status code suggestion (can be overridden) */\n abstract readonly statusCode: number;\n\n /** Whether this error type is generally safe to retry */\n abstract readonly isRetryable: boolean;\n\n /** Optional cause of the error */\n readonly cause?: Error;\n\n /** Additional context for the error */\n readonly context?: Record<string, unknown>;\n\n constructor(\n message: string,\n options?: { cause?: Error; context?: Record<string, unknown> },\n ) {\n super(message);\n this.name = this.constructor.name;\n this.cause = options?.cause;\n this.context = options?.context;\n\n // Maintains proper stack trace for where the error was thrown\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n /**\n * Convert error to JSON for logging/serialization.\n * Sensitive values in context are automatically redacted.\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n statusCode: this.statusCode,\n isRetryable: this.isRetryable,\n context: this.sanitizeContext(this.context),\n cause: this.cause?.message,\n stack: this.stack,\n };\n }\n\n /**\n * Create a human-readable string representation\n */\n toString(): string {\n let str = `${this.name} [${this.code}]: ${this.message}`;\n if (this.cause) {\n str += ` (caused by: ${this.cause.message})`;\n }\n return str;\n }\n\n /**\n * Sanitize context by redacting sensitive field values\n */\n private sanitizeContext(\n context?: Record<string, unknown>,\n ): Record<string, unknown> | undefined {\n if (!context) return undefined;\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(context)) {\n if (this.isSensitiveField(key)) {\n sanitized[key] = \"[REDACTED]\";\n } else if (typeof value === \"object\" && value !== null) {\n // Don't deep-sanitize nested objects, just indicate their type\n sanitized[key] = Array.isArray(value)\n ? `[Array(${value.length})]`\n : \"[Object]\";\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n }\n\n /**\n * Check if a field name matches sensitive patterns\n */\n private isSensitiveField(fieldName: string): boolean {\n return SENSITIVE_FIELD_PATTERNS.some((pattern) => pattern.test(fieldName));\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../src/errors/base.ts"],"sourcesContent":["/** Fields that should be redacted in logs/serialization for security */\nconst SENSITIVE_FIELD_PATTERNS = [\n /token/i,\n /password/i,\n /secret/i,\n /credential/i,\n /auth/i,\n /key$/i,\n /apikey/i,\n];\n\n/**\n * Base error class for all AppKit errors.\n * Provides a consistent structure for error handling across the framework.\n *\n * @example\n * ```typescript\n * // Catching errors by type\n * try {\n * await lakebase.query(\"...\");\n * } catch (e) {\n * if (e instanceof AuthenticationError) {\n * // Re-authenticate\n * } else if (e instanceof ConnectionError && e.isRetryable) {\n * // Retry with backoff\n * }\n * }\n *\n * // Logging errors\n * console.error(error.toJSON()); // Safe for logging, sensitive values redacted\n * ```\n */\nexport abstract class AppKitError extends Error {\n /** Error code for programmatic error handling */\n abstract readonly code: string;\n\n /** HTTP status code suggestion (can be overridden) */\n abstract readonly statusCode: number;\n\n /** Whether this error type is generally safe to retry */\n abstract readonly isRetryable: boolean;\n\n /** Optional cause of the error */\n readonly cause?: Error;\n\n /** Additional context for the error */\n readonly context?: Record<string, unknown>;\n\n constructor(\n message: string,\n options?: { cause?: Error; context?: Record<string, unknown> },\n ) {\n super(message);\n this.name = this.constructor.name;\n this.cause = options?.cause;\n this.context = options?.context;\n\n // Maintains proper stack trace for where the error was thrown\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n /**\n * Convert error to JSON for logging/serialization.\n * Sensitive values in context are automatically redacted.\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n statusCode: this.statusCode,\n isRetryable: this.isRetryable,\n context: this.sanitizeContext(this.context),\n cause: this.cause?.message,\n stack: this.stack,\n };\n }\n\n /**\n * Create a human-readable string representation\n */\n toString(): string {\n let str = `${this.name} [${this.code}]: ${this.message}`;\n if (this.cause) {\n str += ` (caused by: ${this.cause.message})`;\n }\n return str;\n }\n\n /**\n * Sanitize context by redacting sensitive field values\n */\n private sanitizeContext(\n context?: Record<string, unknown>,\n ): Record<string, unknown> | undefined {\n if (!context) return undefined;\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(context)) {\n if (this.isSensitiveField(key)) {\n sanitized[key] = \"[REDACTED]\";\n } else if (typeof value === \"object\" && value !== null) {\n // Don't deep-sanitize nested objects, just indicate their type\n sanitized[key] = Array.isArray(value)\n ? `[Array(${value.length})]`\n : \"[Object]\";\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n }\n\n /**\n * Check if a field name matches sensitive patterns\n */\n private isSensitiveField(fieldName: string): boolean {\n return SENSITIVE_FIELD_PATTERNS.some((pattern) => pattern.test(fieldName));\n }\n}\n"],"mappings":";;AACA,MAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;;;;;;;;;;;AAuBD,IAAsB,cAAtB,cAA0C,MAAM;;CAW9C,AAAS;;CAGT,AAAS;CAET,YACE,SACA,SACA;AACA,QAAM,QAAQ;AACd,OAAK,OAAO,KAAK,YAAY;AAC7B,OAAK,QAAQ,SAAS;AACtB,OAAK,UAAU,SAAS;AAGxB,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;CAQnD,SAAkC;AAChC,SAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,aAAa,KAAK;GAClB,SAAS,KAAK,gBAAgB,KAAK,QAAQ;GAC3C,OAAO,KAAK,OAAO;GACnB,OAAO,KAAK;GACb;;;;;CAMH,WAAmB;EACjB,IAAI,MAAM,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,KAAK;AAC/C,MAAI,KAAK,MACP,QAAO,gBAAgB,KAAK,MAAM,QAAQ;AAE5C,SAAO;;;;;CAMT,AAAQ,gBACN,SACqC;AACrC,MAAI,CAAC,QAAS,QAAO;EAErB,MAAM,YAAqC,EAAE;AAC7C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,CAChD,KAAI,KAAK,iBAAiB,IAAI,CAC5B,WAAU,OAAO;WACR,OAAO,UAAU,YAAY,UAAU,KAEhD,WAAU,OAAO,MAAM,QAAQ,MAAM,GACjC,UAAU,MAAM,OAAO,MACvB;MAEJ,WAAU,OAAO;AAGrB,SAAO;;;;;CAMT,AAAQ,iBAAiB,WAA4B;AACnD,SAAO,yBAAyB,MAAM,YAAY,QAAQ,KAAK,UAAU,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppKitError, init_base } from "./base.js";
|
|
1
|
+
import { AppKitError } from "./base.js";
|
|
3
2
|
import pc from "picocolors";
|
|
4
3
|
|
|
5
4
|
//#region src/errors/configuration.ts
|
|
@@ -26,70 +25,75 @@ function pinUserFacingAuthError(err) {
|
|
|
26
25
|
configurable: true
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when configuration is missing or invalid.
|
|
30
|
+
* Use for missing environment variables, invalid settings, or setup issues.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* throw new ConfigurationError("DATABRICKS_HOST environment variable is required");
|
|
35
|
+
* throw new ConfigurationError("Warehouse ID not found", { context: { env: "production" } });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
var ConfigurationError = class ConfigurationError extends AppKitError {
|
|
39
|
+
code = "CONFIGURATION_ERROR";
|
|
40
|
+
statusCode = 500;
|
|
41
|
+
isRetryable = false;
|
|
42
|
+
/**
|
|
43
|
+
* Create a configuration error for missing environment variable
|
|
44
|
+
*/
|
|
45
|
+
static missingEnvVar(varName) {
|
|
46
|
+
return new ConfigurationError(`${varName} environment variable is required`, { context: { envVar: varName } });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a configuration error for missing resource
|
|
50
|
+
*/
|
|
51
|
+
static resourceNotFound(resource, hint) {
|
|
52
|
+
return new ConfigurationError(hint ? `${resource} not found. ${hint}` : `${resource} not found`, { context: { resource } });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a configuration error for invalid connection config
|
|
56
|
+
*/
|
|
57
|
+
static invalidConnection(service, details) {
|
|
58
|
+
return new ConfigurationError(details ? `${service} connection not configured. ${details}` : `${service} connection not configured`, { context: { service } });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a configuration error for missing connection string parameter
|
|
62
|
+
*/
|
|
63
|
+
static missingConnectionParam(param) {
|
|
64
|
+
return new ConfigurationError(`Connection string must include ${param} parameter`, { context: { parameter: param } });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Databricks CLI / token auth failed while creating the workspace client.
|
|
68
|
+
*
|
|
69
|
+
* By default the message is short; key lines use **picocolors** when the
|
|
70
|
+
* terminal supports it (also respects `NO_COLOR`). `console.error` won’t show
|
|
71
|
+
* stacks or `{ code, context, … }`. Set `APPKIT_VERBOSE_AUTH_ERRORS=1` for full
|
|
72
|
+
* `cause`, stack, and the raw SDK message (verbose appendix is unstyled).
|
|
73
|
+
*/
|
|
74
|
+
static databricksAuthenticationSetupFailed(detail, options) {
|
|
75
|
+
const verbose = authSetupVerbose();
|
|
76
|
+
const host = process.env.DATABRICKS_HOST ?? "(not set)";
|
|
77
|
+
const warehouseId = process.env.DATABRICKS_WAREHOUSE_ID;
|
|
78
|
+
const d = detail.trim();
|
|
79
|
+
const cli = suggestedDatabricksCliCommand(d);
|
|
80
|
+
const lines = [
|
|
81
|
+
pc.bold(pc.red("Databricks authentication failed.")),
|
|
82
|
+
"",
|
|
83
|
+
cli ? `${pc.bold("Run this, then try again:")}\n ${pc.cyan(cli)}` : pc.yellow("Log in with the Databricks CLI (for example, databricks auth login for this workspace), then try again."),
|
|
84
|
+
"",
|
|
85
|
+
pc.dim("Or set DATABRICKS_TOKEN and DATABRICKS_HOST instead of CLI-based auth."),
|
|
86
|
+
"",
|
|
87
|
+
`${pc.green("DATABRICKS_HOST")}: ${host}`
|
|
88
|
+
];
|
|
89
|
+
if (warehouseId) lines.push(`${pc.green("DATABRICKS_WAREHOUSE_ID")}: ${warehouseId}`);
|
|
90
|
+
if (verbose) lines.push("", d);
|
|
91
|
+
const err = new ConfigurationError(lines.join("\n"), { cause: verbose ? options?.cause : void 0 });
|
|
92
|
+
if (!verbose) pinUserFacingAuthError(err);
|
|
93
|
+
return err;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
91
96
|
|
|
92
97
|
//#endregion
|
|
93
|
-
|
|
94
|
-
export { ConfigurationError, init_configuration };
|
|
98
|
+
export { ConfigurationError };
|
|
95
99
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","names":[],"sources":["../../src/errors/configuration.ts"],"sourcesContent":["import pc from \"picocolors\";\nimport { AppKitError } from \"./base\";\n\nfunction authSetupVerbose(): boolean {\n return (\n process.env.APPKIT_VERBOSE_AUTH_ERRORS === \"1\" ||\n process.env.APPKIT_VERBOSE_AUTH_ERRORS === \"true\"\n );\n}\n\n/** Pulls ` $ databricks ...` from SDK text when present. */\nfunction suggestedDatabricksCliCommand(detail: string): string | undefined {\n const m = detail.match(/\\$\\s*(databricks[^\\n]+)/);\n return m?.[1]?.trim();\n}\n\n/** Makes `console.error` show only the message (no stack, no extra fields). */\nfunction pinUserFacingAuthError(err: ConfigurationError): void {\n Object.defineProperty(err, \"stack\", {\n value: \"\",\n configurable: true,\n enumerable: false,\n writable: true,\n });\n Object.defineProperty(err, Symbol.for(\"nodejs.util.inspect.custom\"), {\n value: function (this: ConfigurationError): string {\n return this.message;\n },\n enumerable: false,\n configurable: true,\n });\n}\n\n/**\n * Error thrown when configuration is missing or invalid.\n * Use for missing environment variables, invalid settings, or setup issues.\n *\n * @example\n * ```typescript\n * throw new ConfigurationError(\"DATABRICKS_HOST environment variable is required\");\n * throw new ConfigurationError(\"Warehouse ID not found\", { context: { env: \"production\" } });\n * ```\n */\nexport class ConfigurationError extends AppKitError {\n readonly code = \"CONFIGURATION_ERROR\";\n readonly statusCode = 500;\n readonly isRetryable = false;\n\n /**\n * Create a configuration error for missing environment variable\n */\n static missingEnvVar(varName: string): ConfigurationError {\n return new ConfigurationError(\n `${varName} environment variable is required`,\n { context: { envVar: varName } },\n );\n }\n\n /**\n * Create a configuration error for missing resource\n */\n static resourceNotFound(resource: string, hint?: string): ConfigurationError {\n const message = hint\n ? `${resource} not found. ${hint}`\n : `${resource} not found`;\n return new ConfigurationError(message, { context: { resource } });\n }\n\n /**\n * Create a configuration error for invalid connection config\n */\n static invalidConnection(\n service: string,\n details?: string,\n ): ConfigurationError {\n const message = details\n ? `${service} connection not configured. ${details}`\n : `${service} connection not configured`;\n return new ConfigurationError(message, { context: { service } });\n }\n\n /**\n * Create a configuration error for missing connection string parameter\n */\n static missingConnectionParam(param: string): ConfigurationError {\n return new ConfigurationError(\n `Connection string must include ${param} parameter`,\n { context: { parameter: param } },\n );\n }\n\n /**\n * Databricks CLI / token auth failed while creating the workspace client.\n *\n * By default the message is short; key lines use **picocolors** when the\n * terminal supports it (also respects `NO_COLOR`). `console.error` won’t show\n * stacks or `{ code, context, … }`. Set `APPKIT_VERBOSE_AUTH_ERRORS=1` for full\n * `cause`, stack, and the raw SDK message (verbose appendix is unstyled).\n */\n static databricksAuthenticationSetupFailed(\n detail: string,\n options?: { cause?: Error },\n ): ConfigurationError {\n const verbose = authSetupVerbose();\n const host = process.env.DATABRICKS_HOST ?? \"(not set)\";\n const warehouseId = process.env.DATABRICKS_WAREHOUSE_ID;\n const d = detail.trim();\n const cli = suggestedDatabricksCliCommand(d);\n\n const title = pc.bold(pc.red(\"Databricks authentication failed.\"));\n const action = cli\n ? `${pc.bold(\"Run this, then try again:\")}\\n ${pc.cyan(cli)}`\n : pc.yellow(\n \"Log in with the Databricks CLI (for example, databricks auth login for this workspace), then try again.\",\n );\n const tokenHint = pc.dim(\n \"Or set DATABRICKS_TOKEN and DATABRICKS_HOST instead of CLI-based auth.\",\n );\n\n const lines: string[] = [\n title,\n \"\",\n action,\n \"\",\n tokenHint,\n \"\",\n `${pc.green(\"DATABRICKS_HOST\")}: ${host}`,\n ];\n if (warehouseId) {\n lines.push(`${pc.green(\"DATABRICKS_WAREHOUSE_ID\")}: ${warehouseId}`);\n }\n if (verbose) {\n lines.push(\"\", d);\n }\n\n const err = new ConfigurationError(lines.join(\"\\n\"), {\n cause: verbose ? options?.cause : undefined,\n });\n\n if (!verbose) {\n pinUserFacingAuthError(err);\n }\n return err;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.js","names":[],"sources":["../../src/errors/configuration.ts"],"sourcesContent":["import pc from \"picocolors\";\nimport { AppKitError } from \"./base\";\n\nfunction authSetupVerbose(): boolean {\n return (\n process.env.APPKIT_VERBOSE_AUTH_ERRORS === \"1\" ||\n process.env.APPKIT_VERBOSE_AUTH_ERRORS === \"true\"\n );\n}\n\n/** Pulls ` $ databricks ...` from SDK text when present. */\nfunction suggestedDatabricksCliCommand(detail: string): string | undefined {\n const m = detail.match(/\\$\\s*(databricks[^\\n]+)/);\n return m?.[1]?.trim();\n}\n\n/** Makes `console.error` show only the message (no stack, no extra fields). */\nfunction pinUserFacingAuthError(err: ConfigurationError): void {\n Object.defineProperty(err, \"stack\", {\n value: \"\",\n configurable: true,\n enumerable: false,\n writable: true,\n });\n Object.defineProperty(err, Symbol.for(\"nodejs.util.inspect.custom\"), {\n value: function (this: ConfigurationError): string {\n return this.message;\n },\n enumerable: false,\n configurable: true,\n });\n}\n\n/**\n * Error thrown when configuration is missing or invalid.\n * Use for missing environment variables, invalid settings, or setup issues.\n *\n * @example\n * ```typescript\n * throw new ConfigurationError(\"DATABRICKS_HOST environment variable is required\");\n * throw new ConfigurationError(\"Warehouse ID not found\", { context: { env: \"production\" } });\n * ```\n */\nexport class ConfigurationError extends AppKitError {\n readonly code = \"CONFIGURATION_ERROR\";\n readonly statusCode = 500;\n readonly isRetryable = false;\n\n /**\n * Create a configuration error for missing environment variable\n */\n static missingEnvVar(varName: string): ConfigurationError {\n return new ConfigurationError(\n `${varName} environment variable is required`,\n { context: { envVar: varName } },\n );\n }\n\n /**\n * Create a configuration error for missing resource\n */\n static resourceNotFound(resource: string, hint?: string): ConfigurationError {\n const message = hint\n ? `${resource} not found. ${hint}`\n : `${resource} not found`;\n return new ConfigurationError(message, { context: { resource } });\n }\n\n /**\n * Create a configuration error for invalid connection config\n */\n static invalidConnection(\n service: string,\n details?: string,\n ): ConfigurationError {\n const message = details\n ? `${service} connection not configured. ${details}`\n : `${service} connection not configured`;\n return new ConfigurationError(message, { context: { service } });\n }\n\n /**\n * Create a configuration error for missing connection string parameter\n */\n static missingConnectionParam(param: string): ConfigurationError {\n return new ConfigurationError(\n `Connection string must include ${param} parameter`,\n { context: { parameter: param } },\n );\n }\n\n /**\n * Databricks CLI / token auth failed while creating the workspace client.\n *\n * By default the message is short; key lines use **picocolors** when the\n * terminal supports it (also respects `NO_COLOR`). `console.error` won’t show\n * stacks or `{ code, context, … }`. Set `APPKIT_VERBOSE_AUTH_ERRORS=1` for full\n * `cause`, stack, and the raw SDK message (verbose appendix is unstyled).\n */\n static databricksAuthenticationSetupFailed(\n detail: string,\n options?: { cause?: Error },\n ): ConfigurationError {\n const verbose = authSetupVerbose();\n const host = process.env.DATABRICKS_HOST ?? \"(not set)\";\n const warehouseId = process.env.DATABRICKS_WAREHOUSE_ID;\n const d = detail.trim();\n const cli = suggestedDatabricksCliCommand(d);\n\n const title = pc.bold(pc.red(\"Databricks authentication failed.\"));\n const action = cli\n ? `${pc.bold(\"Run this, then try again:\")}\\n ${pc.cyan(cli)}`\n : pc.yellow(\n \"Log in with the Databricks CLI (for example, databricks auth login for this workspace), then try again.\",\n );\n const tokenHint = pc.dim(\n \"Or set DATABRICKS_TOKEN and DATABRICKS_HOST instead of CLI-based auth.\",\n );\n\n const lines: string[] = [\n title,\n \"\",\n action,\n \"\",\n tokenHint,\n \"\",\n `${pc.green(\"DATABRICKS_HOST\")}: ${host}`,\n ];\n if (warehouseId) {\n lines.push(`${pc.green(\"DATABRICKS_WAREHOUSE_ID\")}: ${warehouseId}`);\n }\n if (verbose) {\n lines.push(\"\", d);\n }\n\n const err = new ConfigurationError(lines.join(\"\\n\"), {\n cause: verbose ? options?.cause : undefined,\n });\n\n if (!verbose) {\n pinUserFacingAuthError(err);\n }\n return err;\n }\n}\n"],"mappings":";;;;AAGA,SAAS,mBAA4B;AACnC,QACE,QAAQ,IAAI,+BAA+B,OAC3C,QAAQ,IAAI,+BAA+B;;;AAK/C,SAAS,8BAA8B,QAAoC;AAEzE,QADU,OAAO,MAAM,0BAA0B,GACtC,IAAI,MAAM;;;AAIvB,SAAS,uBAAuB,KAA+B;AAC7D,QAAO,eAAe,KAAK,SAAS;EAClC,OAAO;EACP,cAAc;EACd,YAAY;EACZ,UAAU;EACX,CAAC;AACF,QAAO,eAAe,KAAK,OAAO,IAAI,6BAA6B,EAAE;EACnE,OAAO,WAA4C;AACjD,UAAO,KAAK;;EAEd,YAAY;EACZ,cAAc;EACf,CAAC;;;;;;;;;;;;AAaJ,IAAa,qBAAb,MAAa,2BAA2B,YAAY;CAClD,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,cAAc,SAAqC;AACxD,SAAO,IAAI,mBACT,GAAG,QAAQ,oCACX,EAAE,SAAS,EAAE,QAAQ,SAAS,EAAE,CACjC;;;;;CAMH,OAAO,iBAAiB,UAAkB,MAAmC;AAI3E,SAAO,IAAI,mBAHK,OACZ,GAAG,SAAS,cAAc,SAC1B,GAAG,SAAS,aACuB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;;;;;CAMnE,OAAO,kBACL,SACA,SACoB;AAIpB,SAAO,IAAI,mBAHK,UACZ,GAAG,QAAQ,8BAA8B,YACzC,GAAG,QAAQ,6BACwB,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;;;;;CAMlE,OAAO,uBAAuB,OAAmC;AAC/D,SAAO,IAAI,mBACT,kCAAkC,MAAM,aACxC,EAAE,SAAS,EAAE,WAAW,OAAO,EAAE,CAClC;;;;;;;;;;CAWH,OAAO,oCACL,QACA,SACoB;EACpB,MAAM,UAAU,kBAAkB;EAClC,MAAM,OAAO,QAAQ,IAAI,mBAAmB;EAC5C,MAAM,cAAc,QAAQ,IAAI;EAChC,MAAM,IAAI,OAAO,MAAM;EACvB,MAAM,MAAM,8BAA8B,EAAE;EAY5C,MAAM,QAAkB;GAVV,GAAG,KAAK,GAAG,IAAI,oCAAoC,CAAC;GAYhE;GAXa,MACX,GAAG,GAAG,KAAK,4BAA4B,CAAC,MAAM,GAAG,KAAK,IAAI,KAC1D,GAAG,OACD,0GACD;GASH;GARgB,GAAG,IACnB,yEACD;GAQC;GACA,GAAG,GAAG,MAAM,kBAAkB,CAAC,IAAI;GACpC;AACD,MAAI,YACF,OAAM,KAAK,GAAG,GAAG,MAAM,0BAA0B,CAAC,IAAI,cAAc;AAEtE,MAAI,QACF,OAAM,KAAK,IAAI,EAAE;EAGnB,MAAM,MAAM,IAAI,mBAAmB,MAAM,KAAK,KAAK,EAAE,EACnD,OAAO,UAAU,SAAS,QAAQ,QACnC,CAAC;AAEF,MAAI,CAAC,QACH,wBAAuB,IAAI;AAE7B,SAAO"}
|
|
@@ -1,51 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppKitError, init_base } from "./base.js";
|
|
1
|
+
import { AppKitError } from "./base.js";
|
|
3
2
|
|
|
4
3
|
//#region src/errors/connection.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a connection or network operation fails.
|
|
6
|
+
* Use for database pool errors, API failures, timeouts, etc.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* throw new ConnectionError("Query failed", { cause: pgError });
|
|
11
|
+
* throw new ConnectionError("No response received from SQL Warehouse API");
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
var ConnectionError = class ConnectionError extends AppKitError {
|
|
15
|
+
code = "CONNECTION_ERROR";
|
|
16
|
+
statusCode = 503;
|
|
17
|
+
isRetryable = true;
|
|
18
|
+
/**
|
|
19
|
+
* Create a connection error for query failure
|
|
20
|
+
*/
|
|
21
|
+
static queryFailed(cause) {
|
|
22
|
+
return new ConnectionError("Query failed", { cause });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a connection error for transaction failure
|
|
26
|
+
*/
|
|
27
|
+
static transactionFailed(cause) {
|
|
28
|
+
return new ConnectionError("Transaction failed", { cause });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a connection error for pool errors
|
|
32
|
+
*/
|
|
33
|
+
static poolError(operation, cause) {
|
|
34
|
+
return new ConnectionError(`Connection pool error: ${operation}`, { cause });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a connection error for API failures
|
|
38
|
+
*/
|
|
39
|
+
static apiFailure(service, cause) {
|
|
40
|
+
return new ConnectionError(`No response received from ${service} API`, {
|
|
41
|
+
cause,
|
|
42
|
+
context: { service }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a connection error for client unavailable
|
|
47
|
+
*/
|
|
48
|
+
static clientUnavailable(clientType, hint) {
|
|
49
|
+
return new ConnectionError(hint ? `${clientType} not available. ${hint}` : `${clientType} not available`, { context: { clientType } });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
47
52
|
|
|
48
53
|
//#endregion
|
|
49
|
-
|
|
50
|
-
export { ConnectionError, init_connection };
|
|
54
|
+
export { ConnectionError };
|
|
51
55
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","names":[],"sources":["../../src/errors/connection.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when a connection or network operation fails.\n * Use for database pool errors, API failures, timeouts, etc.\n *\n * @example\n * ```typescript\n * throw new ConnectionError(\"Query failed\", { cause: pgError });\n * throw new ConnectionError(\"No response received from SQL Warehouse API\");\n * ```\n */\nexport class ConnectionError extends AppKitError {\n readonly code = \"CONNECTION_ERROR\";\n readonly statusCode = 503;\n readonly isRetryable = true;\n\n /**\n * Create a connection error for query failure\n */\n static queryFailed(cause?: Error): ConnectionError {\n return new ConnectionError(\"Query failed\", { cause });\n }\n\n /**\n * Create a connection error for transaction failure\n */\n static transactionFailed(cause?: Error): ConnectionError {\n return new ConnectionError(\"Transaction failed\", { cause });\n }\n\n /**\n * Create a connection error for pool errors\n */\n static poolError(operation: string, cause?: Error): ConnectionError {\n return new ConnectionError(`Connection pool error: ${operation}`, {\n cause,\n });\n }\n\n /**\n * Create a connection error for API failures\n */\n static apiFailure(service: string, cause?: Error): ConnectionError {\n return new ConnectionError(`No response received from ${service} API`, {\n cause,\n context: { service },\n });\n }\n\n /**\n * Create a connection error for client unavailable\n */\n static clientUnavailable(clientType: string, hint?: string): ConnectionError {\n const message = hint\n ? `${clientType} not available. ${hint}`\n : `${clientType} not available`;\n return new ConnectionError(message, { context: { clientType } });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","names":[],"sources":["../../src/errors/connection.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when a connection or network operation fails.\n * Use for database pool errors, API failures, timeouts, etc.\n *\n * @example\n * ```typescript\n * throw new ConnectionError(\"Query failed\", { cause: pgError });\n * throw new ConnectionError(\"No response received from SQL Warehouse API\");\n * ```\n */\nexport class ConnectionError extends AppKitError {\n readonly code = \"CONNECTION_ERROR\";\n readonly statusCode = 503;\n readonly isRetryable = true;\n\n /**\n * Create a connection error for query failure\n */\n static queryFailed(cause?: Error): ConnectionError {\n return new ConnectionError(\"Query failed\", { cause });\n }\n\n /**\n * Create a connection error for transaction failure\n */\n static transactionFailed(cause?: Error): ConnectionError {\n return new ConnectionError(\"Transaction failed\", { cause });\n }\n\n /**\n * Create a connection error for pool errors\n */\n static poolError(operation: string, cause?: Error): ConnectionError {\n return new ConnectionError(`Connection pool error: ${operation}`, {\n cause,\n });\n }\n\n /**\n * Create a connection error for API failures\n */\n static apiFailure(service: string, cause?: Error): ConnectionError {\n return new ConnectionError(`No response received from ${service} API`, {\n cause,\n context: { service },\n });\n }\n\n /**\n * Create a connection error for client unavailable\n */\n static clientUnavailable(clientType: string, hint?: string): ConnectionError {\n const message = hint\n ? `${clientType} not available. ${hint}`\n : `${clientType} not available`;\n return new ConnectionError(message, { context: { clientType } });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAC/C,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,YAAY,OAAgC;AACjD,SAAO,IAAI,gBAAgB,gBAAgB,EAAE,OAAO,CAAC;;;;;CAMvD,OAAO,kBAAkB,OAAgC;AACvD,SAAO,IAAI,gBAAgB,sBAAsB,EAAE,OAAO,CAAC;;;;;CAM7D,OAAO,UAAU,WAAmB,OAAgC;AAClE,SAAO,IAAI,gBAAgB,0BAA0B,aAAa,EAChE,OACD,CAAC;;;;;CAMJ,OAAO,WAAW,SAAiB,OAAgC;AACjE,SAAO,IAAI,gBAAgB,6BAA6B,QAAQ,OAAO;GACrE;GACA,SAAS,EAAE,SAAS;GACrB,CAAC;;;;;CAMJ,OAAO,kBAAkB,YAAoB,MAAgC;AAI3E,SAAO,IAAI,gBAHK,OACZ,GAAG,WAAW,kBAAkB,SAChC,GAAG,WAAW,iBACkB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
|