@clivly/sdk 0.3.0-next.4 → 0.3.0-next.6

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.
@@ -0,0 +1,84 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/chat-session.ts
3
+ const DEFAULT_API_URL = "https://api.clivly.com";
4
+ const JSON_HEADERS = { "content-type": "application/json" };
5
+ const TRAILING_SLASH = /\/$/;
6
+ function jsonResponse(body, status) {
7
+ return new Response(JSON.stringify(body), {
8
+ status,
9
+ headers: JSON_HEADERS
10
+ });
11
+ }
12
+ function normalizeApiUrl(apiUrl) {
13
+ return apiUrl.replace(TRAILING_SLASH, "");
14
+ }
15
+ function resolveOrigin(req) {
16
+ const headerOrigin = req.headers.get("origin");
17
+ if (headerOrigin) return headerOrigin;
18
+ try {
19
+ return new URL(req.url).origin;
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+ function isChatSessionRequestBody(value) {
25
+ if (typeof value !== "object" || value === null) return false;
26
+ const body = value;
27
+ if (typeof body.widgetId !== "string" || body.widgetId.trim().length === 0) return false;
28
+ if (typeof body.visitor !== "object" || body.visitor === null || Array.isArray(body.visitor)) return false;
29
+ const visitor = body.visitor;
30
+ if (typeof visitor.name !== "string" || visitor.name.trim().length === 0) return false;
31
+ if (typeof visitor.email !== "string" || visitor.email.trim().length === 0) return false;
32
+ return body.visitorToken === void 0 || body.visitorToken === null || typeof body.visitorToken === "string";
33
+ }
34
+ function originAllowed(origin, allowedOrigins) {
35
+ if (!allowedOrigins || allowedOrigins.length === 0) return true;
36
+ if (!origin) return false;
37
+ return allowedOrigins.includes(origin);
38
+ }
39
+ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL, fetchImpl = fetch }) {
40
+ const sessionUrl = `${normalizeApiUrl(apiUrl)}/clivly/widget/session`;
41
+ return async (request) => {
42
+ if (request.method !== "POST") return new Response(JSON.stringify({ error: "method_not_allowed" }), {
43
+ status: 405,
44
+ headers: {
45
+ ...JSON_HEADERS,
46
+ allow: "POST"
47
+ }
48
+ });
49
+ const origin = resolveOrigin(request);
50
+ if (!originAllowed(origin, allowedOrigins)) return jsonResponse({ error: "origin_not_allowed" }, 403);
51
+ let body;
52
+ try {
53
+ body = await request.json();
54
+ } catch {
55
+ return jsonResponse({ error: "invalid_json" }, 400);
56
+ }
57
+ if (!isChatSessionRequestBody(body)) return jsonResponse({ error: "invalid_request" }, 400);
58
+ try {
59
+ const upstream = await fetchImpl(sessionUrl, {
60
+ method: "POST",
61
+ headers: {
62
+ authorization: `Bearer ${apiKey}`,
63
+ "content-type": "application/json",
64
+ ...origin ? { origin } : {}
65
+ },
66
+ body: JSON.stringify({
67
+ widgetId: body.widgetId,
68
+ visitor: body.visitor,
69
+ visitorToken: body.visitorToken,
70
+ origin
71
+ })
72
+ });
73
+ const responseBody = await upstream.text();
74
+ return new Response(responseBody, {
75
+ status: upstream.status,
76
+ headers: { "content-type": upstream.headers.get("content-type") ?? "application/json" }
77
+ });
78
+ } catch {
79
+ return jsonResponse({ error: "upstream_unreachable" }, 502);
80
+ }
81
+ };
82
+ }
83
+ //#endregion
84
+ exports.createChatSessionHandler = createChatSessionHandler;
@@ -0,0 +1,11 @@
1
+ import { c as CreateChatSessionHandlerOptions } from "./types-jMafEyTv.cjs";
2
+
3
+ //#region src/chat-session.d.ts
4
+ declare function createChatSessionHandler({
5
+ allowedOrigins,
6
+ apiKey,
7
+ apiUrl,
8
+ fetchImpl
9
+ }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
10
+ //#endregion
11
+ export { createChatSessionHandler };
@@ -0,0 +1,11 @@
1
+ import { c as CreateChatSessionHandlerOptions } from "./types-B7wBCHRT.mjs";
2
+
3
+ //#region src/chat-session.d.ts
4
+ declare function createChatSessionHandler({
5
+ allowedOrigins,
6
+ apiKey,
7
+ apiUrl,
8
+ fetchImpl
9
+ }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
10
+ //#endregion
11
+ export { createChatSessionHandler };
@@ -0,0 +1,83 @@
1
+ //#region src/chat-session.ts
2
+ const DEFAULT_API_URL = "https://api.clivly.com";
3
+ const JSON_HEADERS = { "content-type": "application/json" };
4
+ const TRAILING_SLASH = /\/$/;
5
+ function jsonResponse(body, status) {
6
+ return new Response(JSON.stringify(body), {
7
+ status,
8
+ headers: JSON_HEADERS
9
+ });
10
+ }
11
+ function normalizeApiUrl(apiUrl) {
12
+ return apiUrl.replace(TRAILING_SLASH, "");
13
+ }
14
+ function resolveOrigin(req) {
15
+ const headerOrigin = req.headers.get("origin");
16
+ if (headerOrigin) return headerOrigin;
17
+ try {
18
+ return new URL(req.url).origin;
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+ function isChatSessionRequestBody(value) {
24
+ if (typeof value !== "object" || value === null) return false;
25
+ const body = value;
26
+ if (typeof body.widgetId !== "string" || body.widgetId.trim().length === 0) return false;
27
+ if (typeof body.visitor !== "object" || body.visitor === null || Array.isArray(body.visitor)) return false;
28
+ const visitor = body.visitor;
29
+ if (typeof visitor.name !== "string" || visitor.name.trim().length === 0) return false;
30
+ if (typeof visitor.email !== "string" || visitor.email.trim().length === 0) return false;
31
+ return body.visitorToken === void 0 || body.visitorToken === null || typeof body.visitorToken === "string";
32
+ }
33
+ function originAllowed(origin, allowedOrigins) {
34
+ if (!allowedOrigins || allowedOrigins.length === 0) return true;
35
+ if (!origin) return false;
36
+ return allowedOrigins.includes(origin);
37
+ }
38
+ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL, fetchImpl = fetch }) {
39
+ const sessionUrl = `${normalizeApiUrl(apiUrl)}/clivly/widget/session`;
40
+ return async (request) => {
41
+ if (request.method !== "POST") return new Response(JSON.stringify({ error: "method_not_allowed" }), {
42
+ status: 405,
43
+ headers: {
44
+ ...JSON_HEADERS,
45
+ allow: "POST"
46
+ }
47
+ });
48
+ const origin = resolveOrigin(request);
49
+ if (!originAllowed(origin, allowedOrigins)) return jsonResponse({ error: "origin_not_allowed" }, 403);
50
+ let body;
51
+ try {
52
+ body = await request.json();
53
+ } catch {
54
+ return jsonResponse({ error: "invalid_json" }, 400);
55
+ }
56
+ if (!isChatSessionRequestBody(body)) return jsonResponse({ error: "invalid_request" }, 400);
57
+ try {
58
+ const upstream = await fetchImpl(sessionUrl, {
59
+ method: "POST",
60
+ headers: {
61
+ authorization: `Bearer ${apiKey}`,
62
+ "content-type": "application/json",
63
+ ...origin ? { origin } : {}
64
+ },
65
+ body: JSON.stringify({
66
+ widgetId: body.widgetId,
67
+ visitor: body.visitor,
68
+ visitorToken: body.visitorToken,
69
+ origin
70
+ })
71
+ });
72
+ const responseBody = await upstream.text();
73
+ return new Response(responseBody, {
74
+ status: upstream.status,
75
+ headers: { "content-type": upstream.headers.get("content-type") ?? "application/json" }
76
+ });
77
+ } catch {
78
+ return jsonResponse({ error: "upstream_unreachable" }, 502);
79
+ }
80
+ };
81
+ }
82
+ //#endregion
83
+ export { createChatSessionHandler };
@@ -1,4 +1,4 @@
1
- import { d as SyncSource, t as NamespaceIntrospector } from "./namespace-probe-9wTakLJu.cjs";
1
+ import { m as NamespaceIntrospector, p as SyncSource } from "./types-jMafEyTv.cjs";
2
2
  import { Table } from "drizzle-orm";
3
3
 
4
4
  //#region src/drizzle.d.ts
@@ -1,4 +1,4 @@
1
- import { d as SyncSource, t as NamespaceIntrospector } from "./namespace-probe-BD1-lqlp.mjs";
1
+ import { m as NamespaceIntrospector, p as SyncSource } from "./types-B7wBCHRT.mjs";
2
2
  import { Table } from "drizzle-orm";
3
3
 
4
4
  //#region src/drizzle.d.ts
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_drizzle_meta = require("./drizzle-meta-iAu8w1hj.cjs");
3
+ const require_chat_session = require("./chat-session.cjs");
3
4
  //#region src/custom-slug.ts
4
5
  const NON_ALNUM = /[^a-z0-9]+/g;
5
6
  const EDGE_HYPHENS = /(^-|-$)/g;
@@ -12,7 +13,7 @@ function checkCustomObjectSlugs(config) {
12
13
  name: "Custom object slugs",
13
14
  ok: false,
14
15
  skipped: true,
15
- detail: "No custom objects configured."
16
+ detail: "No custom objects in clivly.config. Objects added in the dashboard need a matching source.custom entry here to sync."
16
17
  };
17
18
  const problems = [];
18
19
  const seen = /* @__PURE__ */ new Map();
@@ -37,6 +38,49 @@ function checkCustomObjectSlugs(config) {
37
38
  };
38
39
  }
39
40
  //#endregion
41
+ //#region src/fetch-error.ts
42
+ /** Deepest `Error` reachable through the `.cause` chain (the original error if none). */
43
+ function rootError(error) {
44
+ let current = error;
45
+ const seen = /* @__PURE__ */ new Set();
46
+ while (current instanceof Error && current.cause !== void 0 && !seen.has(current)) {
47
+ seen.add(current);
48
+ current = current.cause;
49
+ }
50
+ return current;
51
+ }
52
+ function codeOf(error) {
53
+ const code = error?.code;
54
+ return typeof code === "string" ? code : void 0;
55
+ }
56
+ const CODE_HINTS = {
57
+ ECONNREFUSED: "the database refused the connection — is Postgres running and is your database URL (e.g. DATABASE_URL) pointing at it?",
58
+ ENOTFOUND: "the database host couldn't be resolved — check the host in your connection string.",
59
+ ETIMEDOUT: "the database connection timed out — check the host, port, and firewall.",
60
+ "28P01": "password authentication failed — check the credentials in your connection string.",
61
+ "28000": "the database rejected the connection role — check the user in your connection string.",
62
+ "3D000": "that database does not exist — check the database name in your connection string.",
63
+ "08006": "the database connection was lost — check that Postgres is reachable."
64
+ };
65
+ const NEWLINE = /\r?\n/;
66
+ /** One-line, single-spaced version of an error message (drops the SQL/params blob). */
67
+ function firstLine(message) {
68
+ const line = message.split(NEWLINE)[0]?.trim() ?? "";
69
+ return line === "" ? message.trim() : line;
70
+ }
71
+ /**
72
+ * Build the `detail` string for a failed sample fetch of `entity`.
73
+ * Recognised connection errors get a plain-English hint; everything else
74
+ * surfaces the root cause's first line rather than the wrapper's SQL dump.
75
+ */
76
+ function describeFetchError(entity, error) {
77
+ const root = rootError(error);
78
+ const code = codeOf(root) ?? codeOf(error);
79
+ const hint = code ? CODE_HINTS[code] : void 0;
80
+ if (hint) return `Couldn't read "${entity}": ${hint}`;
81
+ return `Couldn't read "${entity}": ${firstLine(root instanceof Error ? root.message : String(root?.message ?? root ?? "unknown error"))}`;
82
+ }
83
+ //#endregion
40
84
  //#region src/namespace-probe.ts
41
85
  /**
42
86
  * Verify the tables the integration depends on are genuinely reachable:
@@ -188,7 +232,7 @@ async function runDoctor(args) {
188
232
  checks.push({
189
233
  name: `Sample fetch (${source.entity})`,
190
234
  ok: false,
191
- detail: `"${source.entity}" fetchPage threw: ${error.message}`
235
+ detail: describeFetchError(source.entity, error)
192
236
  });
193
237
  }
194
238
  const result = await connect();
@@ -893,4 +937,5 @@ exports.ClivlyAuthError = ClivlyAuthError;
893
937
  exports.ClivlyError = ClivlyError;
894
938
  exports.ClivlyNetworkError = ClivlyNetworkError;
895
939
  exports.ClivlyRateLimitError = ClivlyRateLimitError;
940
+ exports.createChatSessionHandler = require_chat_session.createChatSessionHandler;
896
941
  exports.createClivlySDK = createClivlySDK;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { a as ClivlySDKConfig, c as DiscoveredTable, i as ClivlySDK, l as DoctorCheck, n as ClivlyConnectReason, o as ClivlyUser, r as ClivlyConnectResult, s as CursorStore, u as DoctorReport } from "./namespace-probe-9wTakLJu.cjs";
1
+ import { a as ClivlySDK, c as CreateChatSessionHandlerOptions, d as DoctorCheck, f as DoctorReport, i as ClivlyConnectResult, l as CursorStore, n as ChatWidgetVisitor, o as ClivlySDKConfig, r as ClivlyConnectReason, s as ClivlyUser, t as ChatSessionRequestBody, u as DiscoveredTable } from "./types-jMafEyTv.cjs";
2
+ import { createChatSessionHandler } from "./chat-session.cjs";
2
3
 
3
4
  //#region src/errors.d.ts
4
5
  declare class ClivlyError extends Error {
@@ -30,4 +31,4 @@ declare class ClivlyNetworkError extends ClivlyError {}
30
31
  */
31
32
  declare function createClivlySDK(config: ClivlySDKConfig): ClivlySDK;
32
33
  //#endregion
33
- export { ClivlyAuthError, type ClivlyConnectReason, type ClivlyConnectResult, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type CursorStore, type DiscoveredTable, type DoctorCheck, type DoctorReport, createClivlySDK };
34
+ export { type ChatSessionRequestBody, type ChatWidgetVisitor, ClivlyAuthError, type ClivlyConnectReason, type ClivlyConnectResult, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type CreateChatSessionHandlerOptions, type CursorStore, type DiscoveredTable, type DoctorCheck, type DoctorReport, createChatSessionHandler, createClivlySDK };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { a as ClivlySDKConfig, c as DiscoveredTable, i as ClivlySDK, l as DoctorCheck, n as ClivlyConnectReason, o as ClivlyUser, r as ClivlyConnectResult, s as CursorStore, u as DoctorReport } from "./namespace-probe-BD1-lqlp.mjs";
1
+ import { a as ClivlySDK, c as CreateChatSessionHandlerOptions, d as DoctorCheck, f as DoctorReport, i as ClivlyConnectResult, l as CursorStore, n as ChatWidgetVisitor, o as ClivlySDKConfig, r as ClivlyConnectReason, s as ClivlyUser, t as ChatSessionRequestBody, u as DiscoveredTable } from "./types-B7wBCHRT.mjs";
2
+ import { createChatSessionHandler } from "./chat-session.mjs";
2
3
 
3
4
  //#region src/errors.d.ts
4
5
  declare class ClivlyError extends Error {
@@ -30,4 +31,4 @@ declare class ClivlyNetworkError extends ClivlyError {}
30
31
  */
31
32
  declare function createClivlySDK(config: ClivlySDKConfig): ClivlySDK;
32
33
  //#endregion
33
- export { ClivlyAuthError, type ClivlyConnectReason, type ClivlyConnectResult, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type CursorStore, type DiscoveredTable, type DoctorCheck, type DoctorReport, createClivlySDK };
34
+ export { type ChatSessionRequestBody, type ChatWidgetVisitor, ClivlyAuthError, type ClivlyConnectReason, type ClivlyConnectResult, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type CreateChatSessionHandlerOptions, type CursorStore, type DiscoveredTable, type DoctorCheck, type DoctorReport, createChatSessionHandler, createClivlySDK };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { t as DRIZZLE_META } from "./drizzle-meta-DMx_9nlj.mjs";
2
+ import { createChatSessionHandler } from "./chat-session.mjs";
2
3
  //#region src/custom-slug.ts
3
4
  const NON_ALNUM = /[^a-z0-9]+/g;
4
5
  const EDGE_HYPHENS = /(^-|-$)/g;
@@ -11,7 +12,7 @@ function checkCustomObjectSlugs(config) {
11
12
  name: "Custom object slugs",
12
13
  ok: false,
13
14
  skipped: true,
14
- detail: "No custom objects configured."
15
+ detail: "No custom objects in clivly.config. Objects added in the dashboard need a matching source.custom entry here to sync."
15
16
  };
16
17
  const problems = [];
17
18
  const seen = /* @__PURE__ */ new Map();
@@ -36,6 +37,49 @@ function checkCustomObjectSlugs(config) {
36
37
  };
37
38
  }
38
39
  //#endregion
40
+ //#region src/fetch-error.ts
41
+ /** Deepest `Error` reachable through the `.cause` chain (the original error if none). */
42
+ function rootError(error) {
43
+ let current = error;
44
+ const seen = /* @__PURE__ */ new Set();
45
+ while (current instanceof Error && current.cause !== void 0 && !seen.has(current)) {
46
+ seen.add(current);
47
+ current = current.cause;
48
+ }
49
+ return current;
50
+ }
51
+ function codeOf(error) {
52
+ const code = error?.code;
53
+ return typeof code === "string" ? code : void 0;
54
+ }
55
+ const CODE_HINTS = {
56
+ ECONNREFUSED: "the database refused the connection — is Postgres running and is your database URL (e.g. DATABASE_URL) pointing at it?",
57
+ ENOTFOUND: "the database host couldn't be resolved — check the host in your connection string.",
58
+ ETIMEDOUT: "the database connection timed out — check the host, port, and firewall.",
59
+ "28P01": "password authentication failed — check the credentials in your connection string.",
60
+ "28000": "the database rejected the connection role — check the user in your connection string.",
61
+ "3D000": "that database does not exist — check the database name in your connection string.",
62
+ "08006": "the database connection was lost — check that Postgres is reachable."
63
+ };
64
+ const NEWLINE = /\r?\n/;
65
+ /** One-line, single-spaced version of an error message (drops the SQL/params blob). */
66
+ function firstLine(message) {
67
+ const line = message.split(NEWLINE)[0]?.trim() ?? "";
68
+ return line === "" ? message.trim() : line;
69
+ }
70
+ /**
71
+ * Build the `detail` string for a failed sample fetch of `entity`.
72
+ * Recognised connection errors get a plain-English hint; everything else
73
+ * surfaces the root cause's first line rather than the wrapper's SQL dump.
74
+ */
75
+ function describeFetchError(entity, error) {
76
+ const root = rootError(error);
77
+ const code = codeOf(root) ?? codeOf(error);
78
+ const hint = code ? CODE_HINTS[code] : void 0;
79
+ if (hint) return `Couldn't read "${entity}": ${hint}`;
80
+ return `Couldn't read "${entity}": ${firstLine(root instanceof Error ? root.message : String(root?.message ?? root ?? "unknown error"))}`;
81
+ }
82
+ //#endregion
39
83
  //#region src/namespace-probe.ts
40
84
  /**
41
85
  * Verify the tables the integration depends on are genuinely reachable:
@@ -187,7 +231,7 @@ async function runDoctor(args) {
187
231
  checks.push({
188
232
  name: `Sample fetch (${source.entity})`,
189
233
  ok: false,
190
- detail: `"${source.entity}" fetchPage threw: ${error.message}`
234
+ detail: describeFetchError(source.entity, error)
191
235
  });
192
236
  }
193
237
  const result = await connect();
@@ -888,4 +932,4 @@ function createClivlySDK(config) {
888
932
  };
889
933
  }
890
934
  //#endregion
891
- export { ClivlyAuthError, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, createClivlySDK };
935
+ export { ClivlyAuthError, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, createChatSessionHandler, createClivlySDK };
@@ -13,6 +13,14 @@ interface DrizzleSourceMeta {
13
13
  tableName?: string;
14
14
  }
15
15
  //#endregion
16
+ //#region src/namespace-probe.d.ts
17
+ interface NamespaceIntrospector {
18
+ /** All base table names in the reachable schema. */
19
+ listTables(): Promise<string[]>;
20
+ /** Prove a table is genuinely selectable (SELECT ... LIMIT 1). Throws if unreachable/denied. */
21
+ sampleSelect(table: string): Promise<void>;
22
+ }
23
+ //#endregion
16
24
  //#region src/types.d.ts
17
25
  interface DiscoveredColumn {
18
26
  isForeignKey?: boolean;
@@ -179,6 +187,21 @@ interface ClivlyUser {
179
187
  id: string;
180
188
  name?: string;
181
189
  }
190
+ interface ChatWidgetVisitor {
191
+ email: string;
192
+ name: string;
193
+ }
194
+ interface ChatSessionRequestBody {
195
+ visitor: ChatWidgetVisitor;
196
+ visitorToken?: string | null;
197
+ widgetId: string;
198
+ }
199
+ interface CreateChatSessionHandlerOptions {
200
+ allowedOrigins?: string[];
201
+ apiKey: string;
202
+ apiUrl?: string;
203
+ fetchImpl?: typeof fetch;
204
+ }
182
205
  interface DoctorCheck {
183
206
  /** Human-readable outcome — what passed, or why it failed. */
184
207
  detail: string;
@@ -305,12 +328,4 @@ interface ClivlySDK {
305
328
  }): Promise<void>;
306
329
  }
307
330
  //#endregion
308
- //#region src/namespace-probe.d.ts
309
- interface NamespaceIntrospector {
310
- /** All base table names in the reachable schema. */
311
- listTables(): Promise<string[]>;
312
- /** Prove a table is genuinely selectable (SELECT ... LIMIT 1). Throws if unreachable/denied. */
313
- sampleSelect(table: string): Promise<void>;
314
- }
315
- //#endregion
316
- export { ClivlySDKConfig as a, DiscoveredTable as c, SyncSource as d, ClivlySDK as i, DoctorCheck as l, ClivlyConnectReason as n, ClivlyUser as o, ClivlyConnectResult as r, CursorStore as s, NamespaceIntrospector as t, DoctorReport as u };
331
+ export { ClivlySDK as a, CreateChatSessionHandlerOptions as c, DoctorCheck as d, DoctorReport as f, ClivlyConnectResult as i, CursorStore as l, NamespaceIntrospector as m, ChatWidgetVisitor as n, ClivlySDKConfig as o, SyncSource as p, ClivlyConnectReason as r, ClivlyUser as s, ChatSessionRequestBody as t, DiscoveredTable as u };
@@ -13,6 +13,14 @@ interface DrizzleSourceMeta {
13
13
  tableName?: string;
14
14
  }
15
15
  //#endregion
16
+ //#region src/namespace-probe.d.ts
17
+ interface NamespaceIntrospector {
18
+ /** All base table names in the reachable schema. */
19
+ listTables(): Promise<string[]>;
20
+ /** Prove a table is genuinely selectable (SELECT ... LIMIT 1). Throws if unreachable/denied. */
21
+ sampleSelect(table: string): Promise<void>;
22
+ }
23
+ //#endregion
16
24
  //#region src/types.d.ts
17
25
  interface DiscoveredColumn {
18
26
  isForeignKey?: boolean;
@@ -179,6 +187,21 @@ interface ClivlyUser {
179
187
  id: string;
180
188
  name?: string;
181
189
  }
190
+ interface ChatWidgetVisitor {
191
+ email: string;
192
+ name: string;
193
+ }
194
+ interface ChatSessionRequestBody {
195
+ visitor: ChatWidgetVisitor;
196
+ visitorToken?: string | null;
197
+ widgetId: string;
198
+ }
199
+ interface CreateChatSessionHandlerOptions {
200
+ allowedOrigins?: string[];
201
+ apiKey: string;
202
+ apiUrl?: string;
203
+ fetchImpl?: typeof fetch;
204
+ }
182
205
  interface DoctorCheck {
183
206
  /** Human-readable outcome — what passed, or why it failed. */
184
207
  detail: string;
@@ -305,12 +328,4 @@ interface ClivlySDK {
305
328
  }): Promise<void>;
306
329
  }
307
330
  //#endregion
308
- //#region src/namespace-probe.d.ts
309
- interface NamespaceIntrospector {
310
- /** All base table names in the reachable schema. */
311
- listTables(): Promise<string[]>;
312
- /** Prove a table is genuinely selectable (SELECT ... LIMIT 1). Throws if unreachable/denied. */
313
- sampleSelect(table: string): Promise<void>;
314
- }
315
- //#endregion
316
- export { ClivlySDKConfig as a, DiscoveredTable as c, SyncSource as d, ClivlySDK as i, DoctorCheck as l, ClivlyConnectReason as n, ClivlyUser as o, ClivlyConnectResult as r, CursorStore as s, NamespaceIntrospector as t, DoctorReport as u };
331
+ export { ClivlySDK as a, CreateChatSessionHandlerOptions as c, DoctorCheck as d, DoctorReport as f, ClivlyConnectResult as i, CursorStore as l, NamespaceIntrospector as m, ChatWidgetVisitor as n, ClivlySDKConfig as o, SyncSource as p, ClivlyConnectReason as r, ClivlyUser as s, ChatSessionRequestBody as t, DiscoveredTable as u };
package/dist/vite.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as ClivlySDK } from "./namespace-probe-9wTakLJu.cjs";
1
+ import { a as ClivlySDK } from "./types-jMafEyTv.cjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as ClivlySDK } from "./namespace-probe-BD1-lqlp.mjs";
1
+ import { a as ClivlySDK } from "./types-B7wBCHRT.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clivly/sdk",
3
- "version": "0.3.0-next.4",
3
+ "version": "0.3.0-next.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Clivly SDK — connect your app to Clivly Cloud (heartbeat, discovery, auth bridge).",
@@ -17,6 +17,16 @@
17
17
  "default": "./dist/index.cjs"
18
18
  }
19
19
  },
20
+ "./chat-session": {
21
+ "import": {
22
+ "types": "./dist/chat-session.d.mts",
23
+ "default": "./dist/chat-session.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/chat-session.d.cts",
27
+ "default": "./dist/chat-session.cjs"
28
+ }
29
+ },
20
30
  "./drizzle": {
21
31
  "import": {
22
32
  "types": "./dist/drizzle.d.mts",
@@ -45,7 +55,7 @@
45
55
  "access": "public"
46
56
  },
47
57
  "dependencies": {
48
- "@clivly/core": "0.3.0-next.4"
58
+ "@clivly/core": "0.3.0-next.6"
49
59
  },
50
60
  "peerDependencies": {
51
61
  "drizzle-orm": ">=0.30",