@clivly/sdk 0.7.4 → 0.9.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/dist/chat-session.d.cts +1 -1
- package/dist/chat-session.d.mts +1 -1
- package/dist/drizzle.cjs +10 -37
- package/dist/drizzle.d.cts +3 -3
- package/dist/drizzle.d.mts +3 -3
- package/dist/drizzle.mjs +5 -38
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/{types-DPSn54S6.d.cts → types-QPbki8ur.d.cts} +9 -0
- package/dist/{types-DPSn54S6.d.mts → types-QPbki8ur.d.mts} +9 -0
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.mts +1 -1
- package/package.json +2 -2
package/dist/chat-session.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as CreateChatSessionHandlerOptions } from "./types-
|
|
1
|
+
import { c as CreateChatSessionHandlerOptions } from "./types-QPbki8ur.cjs";
|
|
2
2
|
//#region src/chat-session.d.ts
|
|
3
3
|
declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
4
4
|
//#endregion
|
package/dist/chat-session.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as CreateChatSessionHandlerOptions } from "./types-
|
|
1
|
+
import { c as CreateChatSessionHandlerOptions } from "./types-QPbki8ur.mjs";
|
|
2
2
|
//#region src/chat-session.d.ts
|
|
3
3
|
declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
4
4
|
//#endregion
|
package/dist/drizzle.cjs
CHANGED
|
@@ -1,43 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_drizzle_meta = require("./drizzle-meta-CdCs30q3.cjs");
|
|
3
|
-
let drizzle_orm = require("drizzle-orm");
|
|
4
|
-
let drizzle_orm_pg_core = require("drizzle-orm/pg-core");
|
|
5
3
|
let _clivly_core_drizzle = require("@clivly/core/drizzle");
|
|
4
|
+
let drizzle_orm = require("drizzle-orm");
|
|
6
5
|
//#region src/drizzle.ts
|
|
7
|
-
function buildColumnsMeta(table) {
|
|
8
|
-
const columns = (0, drizzle_orm.getTableColumns)(table);
|
|
9
|
-
const fkByColumn = /* @__PURE__ */ new Map();
|
|
10
|
-
try {
|
|
11
|
-
for (const fk of (0, drizzle_orm_pg_core.getTableConfig)(table).foreignKeys) {
|
|
12
|
-
const ref = fk.reference();
|
|
13
|
-
const foreignTable = (0, drizzle_orm.getTableName)(ref.foreignTable);
|
|
14
|
-
ref.columns.forEach((col, i) => {
|
|
15
|
-
const foreignCol = ref.foreignColumns[i];
|
|
16
|
-
if (foreignCol) fkByColumn.set(col.name, {
|
|
17
|
-
table: foreignTable,
|
|
18
|
-
column: foreignCol.name
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
} catch {}
|
|
23
|
-
return Object.values(columns).map((col) => {
|
|
24
|
-
const references = fkByColumn.get(col.name);
|
|
25
|
-
let type;
|
|
26
|
-
try {
|
|
27
|
-
type = col.getSQLType();
|
|
28
|
-
} catch {
|
|
29
|
-
type = void 0;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
name: col.name,
|
|
33
|
-
type,
|
|
34
|
-
nullable: !col.notNull,
|
|
35
|
-
isPrimaryKey: Boolean(col.primary),
|
|
36
|
-
isForeignKey: references !== void 0,
|
|
37
|
-
...references ? { references } : {}
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
6
|
function inferIdField(table) {
|
|
42
7
|
const columns = (0, drizzle_orm.getTableColumns)(table);
|
|
43
8
|
const primaryKeys = Object.entries(columns).filter(([, column]) => column.primary);
|
|
@@ -75,12 +40,14 @@ function fromDrizzle(db, table, opts) {
|
|
|
75
40
|
idField: idColumnName,
|
|
76
41
|
fetchPage: ({ since, limit }) => drizzleDb.select(projection).from(table).where(since ? drizzle_orm.sql`(${cursorColumn}, ${idColumn}) > (${since.time}, ${since.id})` : void 0).orderBy((0, drizzle_orm.asc)(cursorColumn), (0, drizzle_orm.asc)(idColumn)).limit(limit)
|
|
77
42
|
};
|
|
43
|
+
const uniqueConstraints = (0, _clivly_core_drizzle.buildUniqueConstraints)(table);
|
|
78
44
|
const meta = {
|
|
79
45
|
columnKeys: Object.keys(columns),
|
|
80
46
|
cursorField: opts.cursorField,
|
|
81
47
|
idField,
|
|
82
48
|
tableName: (0, drizzle_orm.getTableName)(table),
|
|
83
|
-
columnsMeta: buildColumnsMeta(table)
|
|
49
|
+
columnsMeta: (0, _clivly_core_drizzle.buildColumnsMeta)(table),
|
|
50
|
+
...uniqueConstraints === void 0 ? {} : { uniqueConstraints }
|
|
84
51
|
};
|
|
85
52
|
Object.defineProperty(source, require_drizzle_meta.DRIZZLE_META, {
|
|
86
53
|
value: meta,
|
|
@@ -108,6 +75,12 @@ function drizzleIntrospector(db) {
|
|
|
108
75
|
};
|
|
109
76
|
}
|
|
110
77
|
//#endregion
|
|
78
|
+
Object.defineProperty(exports, "buildUniqueConstraints", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function() {
|
|
81
|
+
return _clivly_core_drizzle.buildUniqueConstraints;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
111
84
|
Object.defineProperty(exports, "discoverFromDrizzle", {
|
|
112
85
|
enumerable: true,
|
|
113
86
|
get: function() {
|
package/dist/drizzle.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as NamespaceIntrospector, p as SyncSource } from "./types-
|
|
1
|
+
import { m as NamespaceIntrospector, p as SyncSource } from "./types-QPbki8ur.cjs";
|
|
2
2
|
import { Table } from "drizzle-orm";
|
|
3
|
-
import { discoverFromDrizzle } from "@clivly/core/drizzle";
|
|
3
|
+
import { buildUniqueConstraints, discoverFromDrizzle } from "@clivly/core/drizzle";
|
|
4
4
|
//#region src/drizzle.d.ts
|
|
5
5
|
interface DrizzleDb {
|
|
6
6
|
select: (...args: any[]) => any;
|
|
@@ -25,4 +25,4 @@ declare function fromDrizzle(db: DrizzleDb, table: Table, opts: {
|
|
|
25
25
|
*/
|
|
26
26
|
declare function drizzleIntrospector(db: unknown): NamespaceIntrospector;
|
|
27
27
|
//#endregion
|
|
28
|
-
export { discoverFromDrizzle, drizzleIntrospector, fromDrizzle };
|
|
28
|
+
export { buildUniqueConstraints, discoverFromDrizzle, drizzleIntrospector, fromDrizzle };
|
package/dist/drizzle.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as NamespaceIntrospector, p as SyncSource } from "./types-
|
|
1
|
+
import { m as NamespaceIntrospector, p as SyncSource } from "./types-QPbki8ur.mjs";
|
|
2
|
+
import { buildUniqueConstraints, discoverFromDrizzle } from "@clivly/core/drizzle";
|
|
2
3
|
import { Table } from "drizzle-orm";
|
|
3
|
-
import { discoverFromDrizzle } from "@clivly/core/drizzle";
|
|
4
4
|
//#region src/drizzle.d.ts
|
|
5
5
|
interface DrizzleDb {
|
|
6
6
|
select: (...args: any[]) => any;
|
|
@@ -25,4 +25,4 @@ declare function fromDrizzle(db: DrizzleDb, table: Table, opts: {
|
|
|
25
25
|
*/
|
|
26
26
|
declare function drizzleIntrospector(db: unknown): NamespaceIntrospector;
|
|
27
27
|
//#endregion
|
|
28
|
-
export { discoverFromDrizzle, drizzleIntrospector, fromDrizzle };
|
|
28
|
+
export { buildUniqueConstraints, discoverFromDrizzle, drizzleIntrospector, fromDrizzle };
|
package/dist/drizzle.mjs
CHANGED
|
@@ -1,42 +1,7 @@
|
|
|
1
1
|
import { t as DRIZZLE_META } from "./drizzle-meta-DNqzkREf.mjs";
|
|
2
|
+
import { buildColumnsMeta, buildUniqueConstraints, buildUniqueConstraints as buildUniqueConstraints$1, discoverFromDrizzle } from "@clivly/core/drizzle";
|
|
2
3
|
import { asc, getTableColumns, getTableName, sql } from "drizzle-orm";
|
|
3
|
-
import { getTableConfig } from "drizzle-orm/pg-core";
|
|
4
|
-
import { discoverFromDrizzle } from "@clivly/core/drizzle";
|
|
5
4
|
//#region src/drizzle.ts
|
|
6
|
-
function buildColumnsMeta(table) {
|
|
7
|
-
const columns = getTableColumns(table);
|
|
8
|
-
const fkByColumn = /* @__PURE__ */ new Map();
|
|
9
|
-
try {
|
|
10
|
-
for (const fk of getTableConfig(table).foreignKeys) {
|
|
11
|
-
const ref = fk.reference();
|
|
12
|
-
const foreignTable = getTableName(ref.foreignTable);
|
|
13
|
-
ref.columns.forEach((col, i) => {
|
|
14
|
-
const foreignCol = ref.foreignColumns[i];
|
|
15
|
-
if (foreignCol) fkByColumn.set(col.name, {
|
|
16
|
-
table: foreignTable,
|
|
17
|
-
column: foreignCol.name
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
} catch {}
|
|
22
|
-
return Object.values(columns).map((col) => {
|
|
23
|
-
const references = fkByColumn.get(col.name);
|
|
24
|
-
let type;
|
|
25
|
-
try {
|
|
26
|
-
type = col.getSQLType();
|
|
27
|
-
} catch {
|
|
28
|
-
type = void 0;
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
name: col.name,
|
|
32
|
-
type,
|
|
33
|
-
nullable: !col.notNull,
|
|
34
|
-
isPrimaryKey: Boolean(col.primary),
|
|
35
|
-
isForeignKey: references !== void 0,
|
|
36
|
-
...references ? { references } : {}
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
5
|
function inferIdField(table) {
|
|
41
6
|
const columns = getTableColumns(table);
|
|
42
7
|
const primaryKeys = Object.entries(columns).filter(([, column]) => column.primary);
|
|
@@ -74,12 +39,14 @@ function fromDrizzle(db, table, opts) {
|
|
|
74
39
|
idField: idColumnName,
|
|
75
40
|
fetchPage: ({ since, limit }) => drizzleDb.select(projection).from(table).where(since ? sql`(${cursorColumn}, ${idColumn}) > (${since.time}, ${since.id})` : void 0).orderBy(asc(cursorColumn), asc(idColumn)).limit(limit)
|
|
76
41
|
};
|
|
42
|
+
const uniqueConstraints = buildUniqueConstraints$1(table);
|
|
77
43
|
const meta = {
|
|
78
44
|
columnKeys: Object.keys(columns),
|
|
79
45
|
cursorField: opts.cursorField,
|
|
80
46
|
idField,
|
|
81
47
|
tableName: getTableName(table),
|
|
82
|
-
columnsMeta: buildColumnsMeta(table)
|
|
48
|
+
columnsMeta: buildColumnsMeta(table),
|
|
49
|
+
...uniqueConstraints === void 0 ? {} : { uniqueConstraints }
|
|
83
50
|
};
|
|
84
51
|
Object.defineProperty(source, DRIZZLE_META, {
|
|
85
52
|
value: meta,
|
|
@@ -107,4 +74,4 @@ function drizzleIntrospector(db) {
|
|
|
107
74
|
};
|
|
108
75
|
}
|
|
109
76
|
//#endregion
|
|
110
|
-
export { discoverFromDrizzle, drizzleIntrospector, fromDrizzle };
|
|
77
|
+
export { buildUniqueConstraints, discoverFromDrizzle, drizzleIntrospector, fromDrizzle };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-QPbki8ur.cjs";
|
|
2
2
|
import { createChatSessionHandler } from "./chat-session.cjs";
|
|
3
3
|
import { ClivlyEntitiesConfig, defineClivlyConfig } from "@clivly/core/entity-config";
|
|
4
4
|
//#region src/errors.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-QPbki8ur.mjs";
|
|
2
2
|
import { createChatSessionHandler } from "./chat-session.mjs";
|
|
3
3
|
import { ClivlyEntitiesConfig, defineClivlyConfig } from "@clivly/core/entity-config";
|
|
4
4
|
//#region src/errors.d.ts
|
|
@@ -10,6 +10,8 @@ interface DrizzleSourceMeta {
|
|
|
10
10
|
idField: string;
|
|
11
11
|
/** The backing table's real name, so discovery can key metadata by table. */
|
|
12
12
|
tableName?: string;
|
|
13
|
+
/** Every unique key on the table, each as its DB column names. */
|
|
14
|
+
uniqueConstraints?: string[][];
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
17
|
//#region src/namespace-probe.d.ts
|
|
@@ -41,6 +43,13 @@ interface DiscoveredTable {
|
|
|
41
43
|
name: string;
|
|
42
44
|
/** Approximate source row count, when cheaply derivable. */
|
|
43
45
|
rowCount?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Every unique key on the table, each as its DB column names. Primary keys
|
|
48
|
+
* are included (a PK is a unique key). Absent on v1 hosts and for
|
|
49
|
+
* hand-declared tables — consumers must treat absence as "unknown", never
|
|
50
|
+
* as "no unique keys".
|
|
51
|
+
*/
|
|
52
|
+
uniqueConstraints?: string[][];
|
|
44
53
|
}
|
|
45
54
|
interface ClivlySDKConfig {
|
|
46
55
|
/** Org-scoped API token (sk_live_…) from Settings → API keys. */
|
|
@@ -10,6 +10,8 @@ interface DrizzleSourceMeta {
|
|
|
10
10
|
idField: string;
|
|
11
11
|
/** The backing table's real name, so discovery can key metadata by table. */
|
|
12
12
|
tableName?: string;
|
|
13
|
+
/** Every unique key on the table, each as its DB column names. */
|
|
14
|
+
uniqueConstraints?: string[][];
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
17
|
//#region src/namespace-probe.d.ts
|
|
@@ -41,6 +43,13 @@ interface DiscoveredTable {
|
|
|
41
43
|
name: string;
|
|
42
44
|
/** Approximate source row count, when cheaply derivable. */
|
|
43
45
|
rowCount?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Every unique key on the table, each as its DB column names. Primary keys
|
|
48
|
+
* are included (a PK is a unique key). Absent on v1 hosts and for
|
|
49
|
+
* hand-declared tables — consumers must treat absence as "unknown", never
|
|
50
|
+
* as "no unique keys".
|
|
51
|
+
*/
|
|
52
|
+
uniqueConstraints?: string[][];
|
|
44
53
|
}
|
|
45
54
|
interface ClivlySDKConfig {
|
|
46
55
|
/** Org-scoped API token (sk_live_…) from Settings → API keys. */
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clivly/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clivly SDK — connect your app to Clivly Cloud (heartbeat, discovery, auth bridge).",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@clivly/core": "0.
|
|
58
|
+
"@clivly/core": "0.9.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"drizzle-orm": ">=0.30 || >=1.0.0-rc.0",
|