@useatlas/types 0.0.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.
- package/dist/action.d.ts +29 -0
- package/dist/action.js +26 -0
- package/dist/auth.d.ts +20 -0
- package/dist/auth.js +7 -0
- package/dist/connection.d.ts +49 -0
- package/dist/connection.js +12 -0
- package/dist/conversation.d.ts +23 -0
- package/dist/conversation.js +0 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.js +82 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +147 -0
- package/dist/scheduled-task.d.ts +62 -0
- package/dist/scheduled-task.js +25 -0
- package/dist/semantic.d.ts +47 -0
- package/dist/semantic.js +0 -0
- package/dist/share.d.ts +5 -0
- package/dist/share.js +0 -0
- package/package.json +77 -0
package/dist/action.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const ACTION_APPROVAL_MODES: readonly ["auto", "manual", "admin-only"];
|
|
2
|
+
export type ActionApprovalMode = (typeof ACTION_APPROVAL_MODES)[number];
|
|
3
|
+
/** Status lifecycle for action tools that require user approval. */
|
|
4
|
+
export type ActionStatus = "pending_approval" | "approved" | "executed" | "auto_approved" | "denied" | "failed" | "rolled_back" | "timed_out";
|
|
5
|
+
/** A status that is terminal (no longer pending). */
|
|
6
|
+
export type ResolvedStatus = Exclude<ActionStatus, "pending_approval">;
|
|
7
|
+
/** Single source of truth for every ActionStatus value. */
|
|
8
|
+
export declare const ALL_STATUSES: readonly ["pending_approval", "approved", "executed", "auto_approved", "denied", "failed", "rolled_back", "timed_out"];
|
|
9
|
+
/** All statuses that are terminal (no longer pending). */
|
|
10
|
+
export declare const RESOLVED_STATUSES: ReadonlySet<ActionStatus>;
|
|
11
|
+
/** Shape returned by action tools in the tool result. */
|
|
12
|
+
export interface ActionToolResultShape {
|
|
13
|
+
status: ActionStatus;
|
|
14
|
+
actionId: string;
|
|
15
|
+
summary?: string;
|
|
16
|
+
details?: Record<string, unknown>;
|
|
17
|
+
result?: unknown;
|
|
18
|
+
reason?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
/** API response when approving or denying an action. */
|
|
22
|
+
export interface ActionApprovalResponse {
|
|
23
|
+
actionId: string;
|
|
24
|
+
status: ActionStatus;
|
|
25
|
+
result?: unknown;
|
|
26
|
+
error?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Type guard: returns true if `result` looks like an action tool result. */
|
|
29
|
+
export declare function isActionToolResult(result: unknown): result is ActionToolResultShape;
|
package/dist/action.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/action.ts
|
|
2
|
+
var ACTION_APPROVAL_MODES = ["auto", "manual", "admin-only"];
|
|
3
|
+
var ALL_STATUSES = [
|
|
4
|
+
"pending_approval",
|
|
5
|
+
"approved",
|
|
6
|
+
"executed",
|
|
7
|
+
"auto_approved",
|
|
8
|
+
"denied",
|
|
9
|
+
"failed",
|
|
10
|
+
"rolled_back",
|
|
11
|
+
"timed_out"
|
|
12
|
+
];
|
|
13
|
+
var RESOLVED_STATUSES = new Set(ALL_STATUSES.filter((s) => s !== "pending_approval"));
|
|
14
|
+
var VALID_STATUSES = new Set(ALL_STATUSES);
|
|
15
|
+
function isActionToolResult(result) {
|
|
16
|
+
if (result == null || typeof result !== "object")
|
|
17
|
+
return false;
|
|
18
|
+
const r = result;
|
|
19
|
+
return typeof r.actionId === "string" && typeof r.status === "string" && VALID_STATUSES.has(r.status);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
isActionToolResult,
|
|
23
|
+
RESOLVED_STATUSES,
|
|
24
|
+
ALL_STATUSES,
|
|
25
|
+
ACTION_APPROVAL_MODES
|
|
26
|
+
};
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth types shared across API, frontend, and SDK.
|
|
3
|
+
*
|
|
4
|
+
* AuthMode determines how requests are authenticated.
|
|
5
|
+
* AtlasRole determines the user's permission level for action approval.
|
|
6
|
+
* AtlasUser represents a verified identity attached to a request.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AUTH_MODES: readonly ["none", "simple-key", "managed", "byot"];
|
|
9
|
+
export type AuthMode = (typeof AUTH_MODES)[number];
|
|
10
|
+
export declare const ATLAS_ROLES: readonly ["viewer", "analyst", "admin"];
|
|
11
|
+
export type AtlasRole = (typeof ATLAS_ROLES)[number];
|
|
12
|
+
export interface AtlasUser {
|
|
13
|
+
id: string;
|
|
14
|
+
mode: Exclude<AuthMode, "none">;
|
|
15
|
+
label: string;
|
|
16
|
+
/** Permission role for action approval. Defaults based on auth mode when not set. */
|
|
17
|
+
role?: AtlasRole;
|
|
18
|
+
/** Auth-source claims for RLS policy evaluation (JWT payload, session user, or env-derived). */
|
|
19
|
+
claims?: Readonly<Record<string, unknown>>;
|
|
20
|
+
}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Known database types for UI dropdowns and wire format validation. Plugins may register additional dbType values not listed here. */
|
|
2
|
+
export declare const DB_TYPES: readonly [{
|
|
3
|
+
readonly value: "postgres";
|
|
4
|
+
readonly label: "PostgreSQL";
|
|
5
|
+
}, {
|
|
6
|
+
readonly value: "mysql";
|
|
7
|
+
readonly label: "MySQL";
|
|
8
|
+
}, {
|
|
9
|
+
readonly value: "clickhouse";
|
|
10
|
+
readonly label: "ClickHouse";
|
|
11
|
+
}, {
|
|
12
|
+
readonly value: "snowflake";
|
|
13
|
+
readonly label: "Snowflake";
|
|
14
|
+
}, {
|
|
15
|
+
readonly value: "duckdb";
|
|
16
|
+
readonly label: "DuckDB";
|
|
17
|
+
}, {
|
|
18
|
+
readonly value: "salesforce";
|
|
19
|
+
readonly label: "Salesforce";
|
|
20
|
+
}];
|
|
21
|
+
/** Database type — closed union derived from DB_TYPES. The backend's internal DBType in @atlas/api/lib/db/connection.ts is wider to accommodate plugin-registered databases. */
|
|
22
|
+
export type DBType = (typeof DB_TYPES)[number]["value"];
|
|
23
|
+
/** Health check status for a connection. */
|
|
24
|
+
export type HealthStatus = "healthy" | "degraded" | "unhealthy";
|
|
25
|
+
/** Wire format for a connection health check result (JSON-serialized). */
|
|
26
|
+
export interface ConnectionHealth {
|
|
27
|
+
status: HealthStatus;
|
|
28
|
+
latencyMs: number;
|
|
29
|
+
message?: string;
|
|
30
|
+
checkedAt: string;
|
|
31
|
+
}
|
|
32
|
+
/** Wire format for a connection in list responses. */
|
|
33
|
+
export interface ConnectionInfo {
|
|
34
|
+
id: string;
|
|
35
|
+
dbType: DBType;
|
|
36
|
+
description?: string | null;
|
|
37
|
+
health?: ConnectionHealth;
|
|
38
|
+
}
|
|
39
|
+
/** Wire format for a single connection detail response. */
|
|
40
|
+
export interface ConnectionDetail {
|
|
41
|
+
id: string;
|
|
42
|
+
/** Broader than DBType — includes fallback "unknown" when metadata is unavailable. */
|
|
43
|
+
dbType: DBType | "unknown";
|
|
44
|
+
description: string | null;
|
|
45
|
+
health: ConnectionHealth | null;
|
|
46
|
+
maskedUrl: string | null;
|
|
47
|
+
schema: string | null;
|
|
48
|
+
managed: boolean;
|
|
49
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/connection.ts
|
|
2
|
+
var DB_TYPES = [
|
|
3
|
+
{ value: "postgres", label: "PostgreSQL" },
|
|
4
|
+
{ value: "mysql", label: "MySQL" },
|
|
5
|
+
{ value: "clickhouse", label: "ClickHouse" },
|
|
6
|
+
{ value: "snowflake", label: "Snowflake" },
|
|
7
|
+
{ value: "duckdb", label: "DuckDB" },
|
|
8
|
+
{ value: "salesforce", label: "Salesforce" }
|
|
9
|
+
];
|
|
10
|
+
export {
|
|
11
|
+
DB_TYPES
|
|
12
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Conversation persistence types — wire format for conversations and messages. */
|
|
2
|
+
export type MessageRole = "user" | "assistant" | "system" | "tool";
|
|
3
|
+
export type Surface = "web" | "api" | "mcp" | "slack";
|
|
4
|
+
export interface Conversation {
|
|
5
|
+
id: string;
|
|
6
|
+
userId: string | null;
|
|
7
|
+
title: string | null;
|
|
8
|
+
surface: Surface;
|
|
9
|
+
connectionId: string | null;
|
|
10
|
+
starred: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export interface Message {
|
|
15
|
+
id: string;
|
|
16
|
+
conversationId: string;
|
|
17
|
+
role: MessageRole;
|
|
18
|
+
content: unknown;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ConversationWithMessages extends Conversation {
|
|
22
|
+
messages: Message[];
|
|
23
|
+
}
|
|
File without changes
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AuthMode } from "./auth";
|
|
2
|
+
export declare const CHAT_ERROR_CODES: readonly ["auth_error", "rate_limited", "configuration_error", "no_datasource", "invalid_request", "provider_model_not_found", "provider_auth_error", "provider_rate_limit", "provider_timeout", "provider_unreachable", "provider_error", "internal_error"];
|
|
3
|
+
/** Union of all error codes the server can return in the `error` field. */
|
|
4
|
+
export type ChatErrorCode = (typeof CHAT_ERROR_CODES)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Structured error info extracted from a chat error response.
|
|
7
|
+
*
|
|
8
|
+
* - `title` — Primary user-facing message (always present).
|
|
9
|
+
* - `detail` — Optional secondary message with extra context.
|
|
10
|
+
* - `retryAfterSeconds` — Seconds to wait before retrying (rate_limited only).
|
|
11
|
+
* Clamped to [0, 300].
|
|
12
|
+
* - `code` — The server error code, if the response was valid JSON with a known code.
|
|
13
|
+
*/
|
|
14
|
+
export interface ChatErrorInfo {
|
|
15
|
+
title: string;
|
|
16
|
+
detail?: string;
|
|
17
|
+
retryAfterSeconds?: number;
|
|
18
|
+
code?: ChatErrorCode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Map an auth mode to a user-friendly error message.
|
|
22
|
+
*
|
|
23
|
+
* Different auth modes require different guidance:
|
|
24
|
+
* - `simple-key`: the user needs to check or re-enter their API key.
|
|
25
|
+
* - `managed`: the session likely expired; a fresh sign-in is needed.
|
|
26
|
+
* - `byot`: the external token may have expired or been revoked.
|
|
27
|
+
* - `none`: auth should not fail in this mode; a generic message is shown.
|
|
28
|
+
*/
|
|
29
|
+
export declare function authErrorMessage(authMode: AuthMode): string;
|
|
30
|
+
/**
|
|
31
|
+
* Parse an AI SDK chat error into a user-friendly `ChatErrorInfo`.
|
|
32
|
+
*
|
|
33
|
+
* Expects `error.message` to contain a JSON string with `{ error, message, retryAfterSeconds? }`.
|
|
34
|
+
* Falls back to a generic message when the body is not valid JSON (e.g. network failures,
|
|
35
|
+
* HTML error pages, or unexpected formats).
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseChatError(error: Error, authMode: AuthMode): ChatErrorInfo;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var CHAT_ERROR_CODES = [
|
|
3
|
+
"auth_error",
|
|
4
|
+
"rate_limited",
|
|
5
|
+
"configuration_error",
|
|
6
|
+
"no_datasource",
|
|
7
|
+
"invalid_request",
|
|
8
|
+
"provider_model_not_found",
|
|
9
|
+
"provider_auth_error",
|
|
10
|
+
"provider_rate_limit",
|
|
11
|
+
"provider_timeout",
|
|
12
|
+
"provider_unreachable",
|
|
13
|
+
"provider_error",
|
|
14
|
+
"internal_error"
|
|
15
|
+
];
|
|
16
|
+
function authErrorMessage(authMode) {
|
|
17
|
+
switch (authMode) {
|
|
18
|
+
case "simple-key":
|
|
19
|
+
return "Invalid or missing API key. Check your key and try again.";
|
|
20
|
+
case "managed":
|
|
21
|
+
return "Your session has expired. Please sign in again.";
|
|
22
|
+
case "byot":
|
|
23
|
+
return "Authentication failed. Your token may have expired.";
|
|
24
|
+
case "none":
|
|
25
|
+
return "An unexpected authentication error occurred. Please refresh the page.";
|
|
26
|
+
default: {
|
|
27
|
+
const _exhaustive = authMode;
|
|
28
|
+
return `Authentication failed (unknown mode: ${_exhaustive}).`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function parseChatError(error, authMode) {
|
|
33
|
+
let parsed;
|
|
34
|
+
try {
|
|
35
|
+
parsed = JSON.parse(error.message);
|
|
36
|
+
} catch {
|
|
37
|
+
return { title: "Something went wrong. Please try again." };
|
|
38
|
+
}
|
|
39
|
+
const code = typeof parsed.error === "string" ? parsed.error : undefined;
|
|
40
|
+
const serverMessage = typeof parsed.message === "string" ? parsed.message : undefined;
|
|
41
|
+
switch (code) {
|
|
42
|
+
case "auth_error":
|
|
43
|
+
return { title: authErrorMessage(authMode), code };
|
|
44
|
+
case "rate_limited": {
|
|
45
|
+
const raw = typeof parsed.retryAfterSeconds === "number" ? parsed.retryAfterSeconds : undefined;
|
|
46
|
+
const clamped = raw !== undefined ? Math.max(0, Math.min(raw, 300)) : undefined;
|
|
47
|
+
return {
|
|
48
|
+
title: "Too many requests.",
|
|
49
|
+
detail: clamped !== undefined ? `Try again in ${clamped} seconds.` : "Please wait before trying again.",
|
|
50
|
+
retryAfterSeconds: clamped,
|
|
51
|
+
code
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
case "configuration_error":
|
|
55
|
+
return { title: "Atlas is not fully configured.", detail: serverMessage, code };
|
|
56
|
+
case "no_datasource":
|
|
57
|
+
return { title: "No data source configured.", detail: serverMessage, code };
|
|
58
|
+
case "invalid_request":
|
|
59
|
+
return { title: "Invalid request.", detail: serverMessage, code };
|
|
60
|
+
case "provider_model_not_found":
|
|
61
|
+
return { title: "The configured AI model was not found.", detail: serverMessage, code };
|
|
62
|
+
case "provider_auth_error":
|
|
63
|
+
return { title: "The AI provider could not authenticate.", detail: serverMessage, code };
|
|
64
|
+
case "provider_rate_limit":
|
|
65
|
+
return { title: "The AI provider is rate limiting requests.", detail: serverMessage, code };
|
|
66
|
+
case "provider_timeout":
|
|
67
|
+
return { title: "The AI provider timed out.", detail: serverMessage, code };
|
|
68
|
+
case "provider_unreachable":
|
|
69
|
+
return { title: "Could not reach the AI provider.", detail: serverMessage, code };
|
|
70
|
+
case "provider_error":
|
|
71
|
+
return { title: "The AI provider returned an error.", detail: serverMessage, code };
|
|
72
|
+
case "internal_error":
|
|
73
|
+
return { title: serverMessage ?? "An unexpected error occurred.", code };
|
|
74
|
+
default:
|
|
75
|
+
return { title: serverMessage ?? "Something went wrong. Please try again." };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
parseChatError,
|
|
80
|
+
authErrorMessage,
|
|
81
|
+
CHAT_ERROR_CODES
|
|
82
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// src/auth.ts
|
|
2
|
+
var AUTH_MODES = ["none", "simple-key", "managed", "byot"];
|
|
3
|
+
var ATLAS_ROLES = ["viewer", "analyst", "admin"];
|
|
4
|
+
// src/connection.ts
|
|
5
|
+
var DB_TYPES = [
|
|
6
|
+
{ value: "postgres", label: "PostgreSQL" },
|
|
7
|
+
{ value: "mysql", label: "MySQL" },
|
|
8
|
+
{ value: "clickhouse", label: "ClickHouse" },
|
|
9
|
+
{ value: "snowflake", label: "Snowflake" },
|
|
10
|
+
{ value: "duckdb", label: "DuckDB" },
|
|
11
|
+
{ value: "salesforce", label: "Salesforce" }
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
// src/action.ts
|
|
15
|
+
var ACTION_APPROVAL_MODES = ["auto", "manual", "admin-only"];
|
|
16
|
+
var ALL_STATUSES = [
|
|
17
|
+
"pending_approval",
|
|
18
|
+
"approved",
|
|
19
|
+
"executed",
|
|
20
|
+
"auto_approved",
|
|
21
|
+
"denied",
|
|
22
|
+
"failed",
|
|
23
|
+
"rolled_back",
|
|
24
|
+
"timed_out"
|
|
25
|
+
];
|
|
26
|
+
var RESOLVED_STATUSES = new Set(ALL_STATUSES.filter((s) => s !== "pending_approval"));
|
|
27
|
+
var VALID_STATUSES = new Set(ALL_STATUSES);
|
|
28
|
+
function isActionToolResult(result) {
|
|
29
|
+
if (result == null || typeof result !== "object")
|
|
30
|
+
return false;
|
|
31
|
+
const r = result;
|
|
32
|
+
return typeof r.actionId === "string" && typeof r.status === "string" && VALID_STATUSES.has(r.status);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/scheduled-task.ts
|
|
36
|
+
var DELIVERY_CHANNELS = ["email", "slack", "webhook"];
|
|
37
|
+
var RUN_STATUSES = ["running", "success", "failed", "skipped"];
|
|
38
|
+
var DELIVERY_STATUSES = ["pending", "sent", "failed"];
|
|
39
|
+
function isRecipient(value) {
|
|
40
|
+
if (typeof value !== "object" || value === null || !("type" in value))
|
|
41
|
+
return false;
|
|
42
|
+
const r = value;
|
|
43
|
+
switch (r.type) {
|
|
44
|
+
case "email":
|
|
45
|
+
return typeof r.address === "string" && r.address.length > 0;
|
|
46
|
+
case "slack":
|
|
47
|
+
return typeof r.channel === "string" && r.channel.length > 0;
|
|
48
|
+
case "webhook":
|
|
49
|
+
return typeof r.url === "string" && r.url.length > 0;
|
|
50
|
+
default:
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/errors.ts
|
|
56
|
+
var CHAT_ERROR_CODES = [
|
|
57
|
+
"auth_error",
|
|
58
|
+
"rate_limited",
|
|
59
|
+
"configuration_error",
|
|
60
|
+
"no_datasource",
|
|
61
|
+
"invalid_request",
|
|
62
|
+
"provider_model_not_found",
|
|
63
|
+
"provider_auth_error",
|
|
64
|
+
"provider_rate_limit",
|
|
65
|
+
"provider_timeout",
|
|
66
|
+
"provider_unreachable",
|
|
67
|
+
"provider_error",
|
|
68
|
+
"internal_error"
|
|
69
|
+
];
|
|
70
|
+
function authErrorMessage(authMode) {
|
|
71
|
+
switch (authMode) {
|
|
72
|
+
case "simple-key":
|
|
73
|
+
return "Invalid or missing API key. Check your key and try again.";
|
|
74
|
+
case "managed":
|
|
75
|
+
return "Your session has expired. Please sign in again.";
|
|
76
|
+
case "byot":
|
|
77
|
+
return "Authentication failed. Your token may have expired.";
|
|
78
|
+
case "none":
|
|
79
|
+
return "An unexpected authentication error occurred. Please refresh the page.";
|
|
80
|
+
default: {
|
|
81
|
+
const _exhaustive = authMode;
|
|
82
|
+
return `Authentication failed (unknown mode: ${_exhaustive}).`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function parseChatError(error, authMode) {
|
|
87
|
+
let parsed;
|
|
88
|
+
try {
|
|
89
|
+
parsed = JSON.parse(error.message);
|
|
90
|
+
} catch {
|
|
91
|
+
return { title: "Something went wrong. Please try again." };
|
|
92
|
+
}
|
|
93
|
+
const code = typeof parsed.error === "string" ? parsed.error : undefined;
|
|
94
|
+
const serverMessage = typeof parsed.message === "string" ? parsed.message : undefined;
|
|
95
|
+
switch (code) {
|
|
96
|
+
case "auth_error":
|
|
97
|
+
return { title: authErrorMessage(authMode), code };
|
|
98
|
+
case "rate_limited": {
|
|
99
|
+
const raw = typeof parsed.retryAfterSeconds === "number" ? parsed.retryAfterSeconds : undefined;
|
|
100
|
+
const clamped = raw !== undefined ? Math.max(0, Math.min(raw, 300)) : undefined;
|
|
101
|
+
return {
|
|
102
|
+
title: "Too many requests.",
|
|
103
|
+
detail: clamped !== undefined ? `Try again in ${clamped} seconds.` : "Please wait before trying again.",
|
|
104
|
+
retryAfterSeconds: clamped,
|
|
105
|
+
code
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
case "configuration_error":
|
|
109
|
+
return { title: "Atlas is not fully configured.", detail: serverMessage, code };
|
|
110
|
+
case "no_datasource":
|
|
111
|
+
return { title: "No data source configured.", detail: serverMessage, code };
|
|
112
|
+
case "invalid_request":
|
|
113
|
+
return { title: "Invalid request.", detail: serverMessage, code };
|
|
114
|
+
case "provider_model_not_found":
|
|
115
|
+
return { title: "The configured AI model was not found.", detail: serverMessage, code };
|
|
116
|
+
case "provider_auth_error":
|
|
117
|
+
return { title: "The AI provider could not authenticate.", detail: serverMessage, code };
|
|
118
|
+
case "provider_rate_limit":
|
|
119
|
+
return { title: "The AI provider is rate limiting requests.", detail: serverMessage, code };
|
|
120
|
+
case "provider_timeout":
|
|
121
|
+
return { title: "The AI provider timed out.", detail: serverMessage, code };
|
|
122
|
+
case "provider_unreachable":
|
|
123
|
+
return { title: "Could not reach the AI provider.", detail: serverMessage, code };
|
|
124
|
+
case "provider_error":
|
|
125
|
+
return { title: "The AI provider returned an error.", detail: serverMessage, code };
|
|
126
|
+
case "internal_error":
|
|
127
|
+
return { title: serverMessage ?? "An unexpected error occurred.", code };
|
|
128
|
+
default:
|
|
129
|
+
return { title: serverMessage ?? "Something went wrong. Please try again." };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
parseChatError,
|
|
134
|
+
isRecipient,
|
|
135
|
+
isActionToolResult,
|
|
136
|
+
authErrorMessage,
|
|
137
|
+
RUN_STATUSES,
|
|
138
|
+
RESOLVED_STATUSES,
|
|
139
|
+
DELIVERY_STATUSES,
|
|
140
|
+
DELIVERY_CHANNELS,
|
|
141
|
+
DB_TYPES,
|
|
142
|
+
CHAT_ERROR_CODES,
|
|
143
|
+
AUTH_MODES,
|
|
144
|
+
ATLAS_ROLES,
|
|
145
|
+
ALL_STATUSES,
|
|
146
|
+
ACTION_APPROVAL_MODES
|
|
147
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ActionApprovalMode } from "./action";
|
|
2
|
+
export declare const DELIVERY_CHANNELS: readonly ["email", "slack", "webhook"];
|
|
3
|
+
export type DeliveryChannel = (typeof DELIVERY_CHANNELS)[number];
|
|
4
|
+
export declare const RUN_STATUSES: readonly ["running", "success", "failed", "skipped"];
|
|
5
|
+
export type RunStatus = (typeof RUN_STATUSES)[number];
|
|
6
|
+
export declare const DELIVERY_STATUSES: readonly ["pending", "sent", "failed"];
|
|
7
|
+
export type DeliveryStatus = (typeof DELIVERY_STATUSES)[number];
|
|
8
|
+
export interface EmailRecipient {
|
|
9
|
+
type: "email";
|
|
10
|
+
address: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SlackRecipient {
|
|
13
|
+
type: "slack";
|
|
14
|
+
channel: string;
|
|
15
|
+
teamId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface WebhookRecipient {
|
|
18
|
+
type: "webhook";
|
|
19
|
+
url: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export type Recipient = EmailRecipient | SlackRecipient | WebhookRecipient;
|
|
23
|
+
export interface ScheduledTask {
|
|
24
|
+
id: string;
|
|
25
|
+
ownerId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
question: string;
|
|
28
|
+
cronExpression: string;
|
|
29
|
+
deliveryChannel: DeliveryChannel;
|
|
30
|
+
/** Recipients should match the deliveryChannel type (email recipients for email channel, etc). */
|
|
31
|
+
recipients: Recipient[];
|
|
32
|
+
connectionId: string | null;
|
|
33
|
+
approvalMode: ActionApprovalMode;
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
lastRunAt: string | null;
|
|
36
|
+
nextRunAt: string | null;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ScheduledTaskWithRuns extends ScheduledTask {
|
|
41
|
+
recentRuns: ScheduledTaskRun[];
|
|
42
|
+
}
|
|
43
|
+
export interface ScheduledTaskRun {
|
|
44
|
+
id: string;
|
|
45
|
+
taskId: string;
|
|
46
|
+
startedAt: string;
|
|
47
|
+
completedAt: string | null;
|
|
48
|
+
status: RunStatus;
|
|
49
|
+
conversationId: string | null;
|
|
50
|
+
actionId: string | null;
|
|
51
|
+
error: string | null;
|
|
52
|
+
tokensUsed: number | null;
|
|
53
|
+
deliveryStatus: DeliveryStatus | null;
|
|
54
|
+
deliveryError: string | null;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
}
|
|
57
|
+
/** Cross-task run with the parent task name joined for display. */
|
|
58
|
+
export interface ScheduledTaskRunWithTaskName extends ScheduledTaskRun {
|
|
59
|
+
taskName: string;
|
|
60
|
+
}
|
|
61
|
+
/** Runtime type guard for Recipient — validates JSONB boundary. */
|
|
62
|
+
export declare function isRecipient(value: unknown): value is Recipient;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/scheduled-task.ts
|
|
2
|
+
var DELIVERY_CHANNELS = ["email", "slack", "webhook"];
|
|
3
|
+
var RUN_STATUSES = ["running", "success", "failed", "skipped"];
|
|
4
|
+
var DELIVERY_STATUSES = ["pending", "sent", "failed"];
|
|
5
|
+
function isRecipient(value) {
|
|
6
|
+
if (typeof value !== "object" || value === null || !("type" in value))
|
|
7
|
+
return false;
|
|
8
|
+
const r = value;
|
|
9
|
+
switch (r.type) {
|
|
10
|
+
case "email":
|
|
11
|
+
return typeof r.address === "string" && r.address.length > 0;
|
|
12
|
+
case "slack":
|
|
13
|
+
return typeof r.channel === "string" && r.channel.length > 0;
|
|
14
|
+
case "webhook":
|
|
15
|
+
return typeof r.url === "string" && r.url.length > 0;
|
|
16
|
+
default:
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
isRecipient,
|
|
22
|
+
RUN_STATUSES,
|
|
23
|
+
DELIVERY_STATUSES,
|
|
24
|
+
DELIVERY_CHANNELS
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Semantic layer entity types — dimensions, joins, measures, query patterns, and entity shapes. */
|
|
2
|
+
/** Valid dimension types per the semantic layer YAML spec. */
|
|
3
|
+
export type DimensionType = "string" | "number" | "date" | "boolean" | "timestamp";
|
|
4
|
+
export interface Dimension {
|
|
5
|
+
name: string;
|
|
6
|
+
type: DimensionType | (string & {});
|
|
7
|
+
description?: string;
|
|
8
|
+
sample_values?: string[];
|
|
9
|
+
primary_key?: boolean;
|
|
10
|
+
foreign_key?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface Join {
|
|
13
|
+
to: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
relationship?: string;
|
|
16
|
+
on?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Measure {
|
|
19
|
+
name: string;
|
|
20
|
+
sql: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface QueryPattern {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
sql: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SemanticEntitySummary {
|
|
30
|
+
table: string;
|
|
31
|
+
description: string;
|
|
32
|
+
columnCount: number;
|
|
33
|
+
joinCount: number;
|
|
34
|
+
type: "table" | "view" | null;
|
|
35
|
+
}
|
|
36
|
+
export interface SemanticEntityDetail {
|
|
37
|
+
table: string;
|
|
38
|
+
description: string;
|
|
39
|
+
type?: "table" | "view" | null;
|
|
40
|
+
dimensions: Record<string, Dimension> | Dimension[];
|
|
41
|
+
joins?: Join[] | Record<string, Join>;
|
|
42
|
+
measures?: Record<string, Measure> | Measure[];
|
|
43
|
+
query_patterns?: Record<string, QueryPattern> | QueryPattern[];
|
|
44
|
+
}
|
|
45
|
+
export interface EntityData extends SemanticEntityDetail {
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
package/dist/semantic.js
ADDED
|
File without changes
|
package/dist/share.d.ts
ADDED
package/dist/share.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@useatlas/types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Shared types for the Atlas text-to-SQL agent",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rm -rf dist && bun build src/index.ts src/auth.ts src/conversation.ts src/connection.ts src/action.ts src/scheduled-task.ts src/errors.ts src/semantic.ts src/share.ts --outdir dist --root src --target node --packages external && npx tsc -p tsconfig.build.json"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./auth": {
|
|
16
|
+
"types": "./dist/auth.d.ts",
|
|
17
|
+
"import": "./dist/auth.js",
|
|
18
|
+
"default": "./dist/auth.js"
|
|
19
|
+
},
|
|
20
|
+
"./conversation": {
|
|
21
|
+
"types": "./dist/conversation.d.ts",
|
|
22
|
+
"import": "./dist/conversation.js",
|
|
23
|
+
"default": "./dist/conversation.js"
|
|
24
|
+
},
|
|
25
|
+
"./connection": {
|
|
26
|
+
"types": "./dist/connection.d.ts",
|
|
27
|
+
"import": "./dist/connection.js",
|
|
28
|
+
"default": "./dist/connection.js"
|
|
29
|
+
},
|
|
30
|
+
"./action": {
|
|
31
|
+
"types": "./dist/action.d.ts",
|
|
32
|
+
"import": "./dist/action.js",
|
|
33
|
+
"default": "./dist/action.js"
|
|
34
|
+
},
|
|
35
|
+
"./scheduled-task": {
|
|
36
|
+
"types": "./dist/scheduled-task.d.ts",
|
|
37
|
+
"import": "./dist/scheduled-task.js",
|
|
38
|
+
"default": "./dist/scheduled-task.js"
|
|
39
|
+
},
|
|
40
|
+
"./errors": {
|
|
41
|
+
"types": "./dist/errors.d.ts",
|
|
42
|
+
"import": "./dist/errors.js",
|
|
43
|
+
"default": "./dist/errors.js"
|
|
44
|
+
},
|
|
45
|
+
"./semantic": {
|
|
46
|
+
"types": "./dist/semantic.d.ts",
|
|
47
|
+
"import": "./dist/semantic.js",
|
|
48
|
+
"default": "./dist/semantic.js"
|
|
49
|
+
},
|
|
50
|
+
"./share": {
|
|
51
|
+
"types": "./dist/share.d.ts",
|
|
52
|
+
"import": "./dist/share.js",
|
|
53
|
+
"default": "./dist/share.js"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"main": "./dist/index.js",
|
|
57
|
+
"types": "./dist/index.d.ts",
|
|
58
|
+
"files": [
|
|
59
|
+
"dist/"
|
|
60
|
+
],
|
|
61
|
+
"keywords": [
|
|
62
|
+
"atlas",
|
|
63
|
+
"text-to-sql",
|
|
64
|
+
"types",
|
|
65
|
+
"typescript"
|
|
66
|
+
],
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "https://github.com/AtlasDevHQ/atlas",
|
|
70
|
+
"directory": "packages/types"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://useatlas.dev",
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/AtlasDevHQ/atlas/issues"
|
|
75
|
+
},
|
|
76
|
+
"license": "MIT"
|
|
77
|
+
}
|