weave-typescript 0.49.0 → 0.51.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/weaveapi/consolidation/v1/consolidation.pb.d.ts +13 -14
- package/dist/weaveapi/consolidation/v1/consolidation.pb.js +62 -74
- package/dist/weaveapi/ingestion/v1/ingestion.pb.d.ts +82 -50
- package/dist/weaveapi/ingestion/v1/ingestion.pb.js +708 -216
- package/dist/weaveapi/ingestion/v1/service.pb.d.ts +50 -7
- package/dist/weaveapi/ingestion/v1/service.pb.js +279 -16
- package/dist/weaveapi/ingestion/v1/table.pb.d.ts +121 -0
- package/dist/weaveapi/ingestion/v1/table.pb.js +1478 -0
- package/dist/weaveapi/model/v1/model.pb.d.ts +3 -3
- package/dist/weaveapi/model/v1/model.pb.js +33 -33
- package/dist/weaveapi/model/v1/service.pb.d.ts +3 -3
- package/dist/weaveapi/model/v1/service.pb.js +33 -33
- package/dist/weaveapi/retrieval/v1/retrieval.pb.d.ts +123 -0
- package/dist/weaveapi/retrieval/v1/retrieval.pb.js +2096 -113
- package/dist/weaveapi/retrieval/v1/service.pb.d.ts +29 -1
- package/dist/weaveapi/retrieval/v1/service.pb.js +142 -0
- package/dist/weavesql/weavedb/agent_sql.d.ts +27 -0
- package/dist/weavesql/weavedb/agent_sql.js +43 -1
- package/dist/weavesql/weavedb/consolidation_sql.d.ts +33 -33
- package/dist/weavesql/weavedb/consolidation_sql.js +56 -56
- package/dist/weavesql/weavedb/document_table_sql.d.ts +533 -0
- package/dist/weavesql/weavedb/document_table_sql.js +1352 -0
- package/dist/weavesql/weavedb/ingestion_sql.d.ts +67 -34
- package/dist/weavesql/weavedb/ingestion_sql.js +169 -73
- package/dist/weavesql/weavedb/retrieval_sql.d.ts +11 -11
- package/dist/weavesql/weavedb/retrieval_sql.js +13 -13
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ExplainRetrievalRequest, ExplainRetrievalResponse, RetrieveRequest, RetrieveResponse, SearchDocumentsRequest, SearchDocumentsResponse } from "./retrieval.pb";
|
|
1
|
+
import { ExplainRetrievalRequest, ExplainRetrievalResponse, RetrieveDataRequest, RetrieveDataResponse, RetrieveRequest, RetrieveResponse, RetrieveTabularDataRequest, RetrieveTabularDataResponse, SearchDocumentsRequest, SearchDocumentsResponse } from "./retrieval.pb";
|
|
2
2
|
export declare const protobufPackage = "weaveapi.retrieval.v1";
|
|
3
3
|
export interface RetrievalService {
|
|
4
4
|
Retrieve(request: RetrieveRequest): Promise<RetrieveResponse>;
|
|
5
5
|
SearchDocuments(request: SearchDocumentsRequest): Promise<SearchDocumentsResponse>;
|
|
6
|
+
RetrieveData(request: RetrieveDataRequest): Promise<RetrieveDataResponse>;
|
|
7
|
+
RetrieveTabularData(request: RetrieveTabularDataRequest): Promise<RetrieveTabularDataResponse>;
|
|
6
8
|
ExplainRetrieval(request: ExplainRetrievalRequest): Promise<ExplainRetrievalResponse>;
|
|
7
9
|
}
|
|
8
10
|
export declare const RetrievalServiceServiceName = "weaveapi.retrieval.v1.RetrievalService";
|
|
@@ -14,6 +16,8 @@ export declare class RetrievalServiceClientImpl implements RetrievalService {
|
|
|
14
16
|
});
|
|
15
17
|
Retrieve(request: RetrieveRequest): Promise<RetrieveResponse>;
|
|
16
18
|
SearchDocuments(request: SearchDocumentsRequest): Promise<SearchDocumentsResponse>;
|
|
19
|
+
RetrieveData(request: RetrieveDataRequest): Promise<RetrieveDataResponse>;
|
|
20
|
+
RetrieveTabularData(request: RetrieveTabularDataRequest): Promise<RetrieveTabularDataResponse>;
|
|
17
21
|
ExplainRetrieval(request: ExplainRetrievalRequest): Promise<ExplainRetrievalResponse>;
|
|
18
22
|
}
|
|
19
23
|
export type RetrievalServiceDefinition = typeof RetrievalServiceDefinition;
|
|
@@ -45,6 +49,30 @@ export declare const RetrievalServiceDefinition: {
|
|
|
45
49
|
};
|
|
46
50
|
};
|
|
47
51
|
};
|
|
52
|
+
readonly retrieveData: {
|
|
53
|
+
readonly name: "RetrieveData";
|
|
54
|
+
readonly requestType: typeof RetrieveDataRequest;
|
|
55
|
+
readonly requestStream: false;
|
|
56
|
+
readonly responseType: typeof RetrieveDataResponse;
|
|
57
|
+
readonly responseStream: false;
|
|
58
|
+
readonly options: {
|
|
59
|
+
readonly _unknownFields: {
|
|
60
|
+
readonly 578365826: readonly [Uint8Array];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
readonly retrieveTabularData: {
|
|
65
|
+
readonly name: "RetrieveTabularData";
|
|
66
|
+
readonly requestType: typeof RetrieveTabularDataRequest;
|
|
67
|
+
readonly requestStream: false;
|
|
68
|
+
readonly responseType: typeof RetrieveTabularDataResponse;
|
|
69
|
+
readonly responseStream: false;
|
|
70
|
+
readonly options: {
|
|
71
|
+
readonly _unknownFields: {
|
|
72
|
+
readonly 578365826: readonly [Uint8Array];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
48
76
|
readonly explainRetrieval: {
|
|
49
77
|
readonly name: "ExplainRetrieval";
|
|
50
78
|
readonly requestType: typeof ExplainRetrievalRequest;
|
|
@@ -17,6 +17,8 @@ class RetrievalServiceClientImpl {
|
|
|
17
17
|
this.rpc = rpc;
|
|
18
18
|
this.Retrieve = this.Retrieve.bind(this);
|
|
19
19
|
this.SearchDocuments = this.SearchDocuments.bind(this);
|
|
20
|
+
this.RetrieveData = this.RetrieveData.bind(this);
|
|
21
|
+
this.RetrieveTabularData = this.RetrieveTabularData.bind(this);
|
|
20
22
|
this.ExplainRetrieval = this.ExplainRetrieval.bind(this);
|
|
21
23
|
}
|
|
22
24
|
Retrieve(request) {
|
|
@@ -29,6 +31,16 @@ class RetrievalServiceClientImpl {
|
|
|
29
31
|
const promise = this.rpc.request(this.service, "SearchDocuments", data);
|
|
30
32
|
return promise.then((data) => retrieval_pb_1.SearchDocumentsResponse.decode(new wire_1.BinaryReader(data)));
|
|
31
33
|
}
|
|
34
|
+
RetrieveData(request) {
|
|
35
|
+
const data = retrieval_pb_1.RetrieveDataRequest.encode(request).finish();
|
|
36
|
+
const promise = this.rpc.request(this.service, "RetrieveData", data);
|
|
37
|
+
return promise.then((data) => retrieval_pb_1.RetrieveDataResponse.decode(new wire_1.BinaryReader(data)));
|
|
38
|
+
}
|
|
39
|
+
RetrieveTabularData(request) {
|
|
40
|
+
const data = retrieval_pb_1.RetrieveTabularDataRequest.encode(request).finish();
|
|
41
|
+
const promise = this.rpc.request(this.service, "RetrieveTabularData", data);
|
|
42
|
+
return promise.then((data) => retrieval_pb_1.RetrieveTabularDataResponse.decode(new wire_1.BinaryReader(data)));
|
|
43
|
+
}
|
|
32
44
|
ExplainRetrieval(request) {
|
|
33
45
|
const data = retrieval_pb_1.ExplainRetrievalRequest.encode(request).finish();
|
|
34
46
|
const promise = this.rpc.request(this.service, "ExplainRetrieval", data);
|
|
@@ -175,6 +187,136 @@ exports.RetrievalServiceDefinition = {
|
|
|
175
187
|
},
|
|
176
188
|
},
|
|
177
189
|
},
|
|
190
|
+
retrieveData: {
|
|
191
|
+
name: "RetrieveData",
|
|
192
|
+
requestType: retrieval_pb_1.RetrieveDataRequest,
|
|
193
|
+
requestStream: false,
|
|
194
|
+
responseType: retrieval_pb_1.RetrieveDataResponse,
|
|
195
|
+
responseStream: false,
|
|
196
|
+
options: {
|
|
197
|
+
_unknownFields: {
|
|
198
|
+
578365826: [
|
|
199
|
+
new Uint8Array([
|
|
200
|
+
45,
|
|
201
|
+
58,
|
|
202
|
+
1,
|
|
203
|
+
42,
|
|
204
|
+
34,
|
|
205
|
+
40,
|
|
206
|
+
47,
|
|
207
|
+
118,
|
|
208
|
+
49,
|
|
209
|
+
47,
|
|
210
|
+
111,
|
|
211
|
+
114,
|
|
212
|
+
103,
|
|
213
|
+
47,
|
|
214
|
+
123,
|
|
215
|
+
111,
|
|
216
|
+
114,
|
|
217
|
+
103,
|
|
218
|
+
97,
|
|
219
|
+
110,
|
|
220
|
+
105,
|
|
221
|
+
122,
|
|
222
|
+
97,
|
|
223
|
+
116,
|
|
224
|
+
105,
|
|
225
|
+
111,
|
|
226
|
+
110,
|
|
227
|
+
95,
|
|
228
|
+
105,
|
|
229
|
+
100,
|
|
230
|
+
125,
|
|
231
|
+
47,
|
|
232
|
+
114,
|
|
233
|
+
101,
|
|
234
|
+
116,
|
|
235
|
+
114,
|
|
236
|
+
105,
|
|
237
|
+
101,
|
|
238
|
+
118,
|
|
239
|
+
97,
|
|
240
|
+
108,
|
|
241
|
+
47,
|
|
242
|
+
100,
|
|
243
|
+
97,
|
|
244
|
+
116,
|
|
245
|
+
97,
|
|
246
|
+
]),
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
retrieveTabularData: {
|
|
252
|
+
name: "RetrieveTabularData",
|
|
253
|
+
requestType: retrieval_pb_1.RetrieveTabularDataRequest,
|
|
254
|
+
requestStream: false,
|
|
255
|
+
responseType: retrieval_pb_1.RetrieveTabularDataResponse,
|
|
256
|
+
responseStream: false,
|
|
257
|
+
options: {
|
|
258
|
+
_unknownFields: {
|
|
259
|
+
578365826: [
|
|
260
|
+
new Uint8Array([
|
|
261
|
+
53,
|
|
262
|
+
58,
|
|
263
|
+
1,
|
|
264
|
+
42,
|
|
265
|
+
34,
|
|
266
|
+
48,
|
|
267
|
+
47,
|
|
268
|
+
118,
|
|
269
|
+
49,
|
|
270
|
+
47,
|
|
271
|
+
111,
|
|
272
|
+
114,
|
|
273
|
+
103,
|
|
274
|
+
47,
|
|
275
|
+
123,
|
|
276
|
+
111,
|
|
277
|
+
114,
|
|
278
|
+
103,
|
|
279
|
+
97,
|
|
280
|
+
110,
|
|
281
|
+
105,
|
|
282
|
+
122,
|
|
283
|
+
97,
|
|
284
|
+
116,
|
|
285
|
+
105,
|
|
286
|
+
111,
|
|
287
|
+
110,
|
|
288
|
+
95,
|
|
289
|
+
105,
|
|
290
|
+
100,
|
|
291
|
+
125,
|
|
292
|
+
47,
|
|
293
|
+
114,
|
|
294
|
+
101,
|
|
295
|
+
116,
|
|
296
|
+
114,
|
|
297
|
+
105,
|
|
298
|
+
101,
|
|
299
|
+
118,
|
|
300
|
+
97,
|
|
301
|
+
108,
|
|
302
|
+
47,
|
|
303
|
+
116,
|
|
304
|
+
97,
|
|
305
|
+
98,
|
|
306
|
+
108,
|
|
307
|
+
101,
|
|
308
|
+
115,
|
|
309
|
+
47,
|
|
310
|
+
113,
|
|
311
|
+
117,
|
|
312
|
+
101,
|
|
313
|
+
114,
|
|
314
|
+
121,
|
|
315
|
+
]),
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
178
320
|
explainRetrieval: {
|
|
179
321
|
name: "ExplainRetrieval",
|
|
180
322
|
requestType: retrieval_pb_1.ExplainRetrievalRequest,
|
|
@@ -498,6 +498,33 @@ export interface GetAgentRunRow {
|
|
|
498
498
|
finishedAt: Date | null;
|
|
499
499
|
}
|
|
500
500
|
export declare function getAgentRun(client: Client, args: GetAgentRunArgs): Promise<GetAgentRunRow | null>;
|
|
501
|
+
export declare const claimAgentRunQuery = "-- name: ClaimAgentRun :one\nUPDATE weave.agent_runs\nSET\n status = $1,\n error_code = '',\n safe_error_message = '',\n started_at = COALESCE(started_at, $2::timestamptz),\n finished_at = NULL\nWHERE organization_id = $3\n AND id = $4\n AND status = $5\nRETURNING id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at";
|
|
502
|
+
export interface ClaimAgentRunArgs {
|
|
503
|
+
status: string;
|
|
504
|
+
startedAt: Date;
|
|
505
|
+
organizationId: string;
|
|
506
|
+
agentRunId: string;
|
|
507
|
+
expectedStatus: string;
|
|
508
|
+
}
|
|
509
|
+
export interface ClaimAgentRunRow {
|
|
510
|
+
id: string;
|
|
511
|
+
organizationId: string;
|
|
512
|
+
agentDefinitionId: string;
|
|
513
|
+
agentVersionId: string;
|
|
514
|
+
status: string;
|
|
515
|
+
createdByUserId: string;
|
|
516
|
+
chatSessionId: string | null;
|
|
517
|
+
workflowRunId: string | null;
|
|
518
|
+
workflowStepRunId: string | null;
|
|
519
|
+
input: any;
|
|
520
|
+
output: any;
|
|
521
|
+
errorCode: string;
|
|
522
|
+
safeErrorMessage: string;
|
|
523
|
+
createdAt: Date;
|
|
524
|
+
startedAt: Date | null;
|
|
525
|
+
finishedAt: Date | null;
|
|
526
|
+
}
|
|
527
|
+
export declare function claimAgentRun(client: Client, args: ClaimAgentRunArgs): Promise<ClaimAgentRunRow | null>;
|
|
501
528
|
export declare const listAgentRunsQuery = "-- name: ListAgentRuns :many\nSELECT id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at FROM weave.agent_runs\nWHERE organization_id = $1\n AND (\n $2::uuid IS NULL\n OR agent_definition_id = $2::uuid\n )\n AND (\n $3::text IS NULL\n OR status = $3::text\n )\nORDER BY created_at DESC\nLIMIT $5 OFFSET $4";
|
|
502
529
|
export interface ListAgentRunsArgs {
|
|
503
530
|
organizationId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.listAgentDraftEventsQuery = exports.insertAgentDraftEventQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
|
|
3
|
+
exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.claimAgentRunQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.listAgentDraftEventsQuery = exports.insertAgentDraftEventQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
|
|
4
4
|
exports.createAgentDefinition = createAgentDefinition;
|
|
5
5
|
exports.createAgentDefinitionDraft = createAgentDefinitionDraft;
|
|
6
6
|
exports.getAgentDefinitionByID = getAgentDefinitionByID;
|
|
@@ -20,6 +20,7 @@ exports.getAgentDefinitionVersionByID = getAgentDefinitionVersionByID;
|
|
|
20
20
|
exports.listAgentDefinitionVersions = listAgentDefinitionVersions;
|
|
21
21
|
exports.createAgentRun = createAgentRun;
|
|
22
22
|
exports.getAgentRun = getAgentRun;
|
|
23
|
+
exports.claimAgentRun = claimAgentRun;
|
|
23
24
|
exports.listAgentRuns = listAgentRuns;
|
|
24
25
|
exports.updateAgentRunStatus = updateAgentRunStatus;
|
|
25
26
|
exports.insertAgentRunEvent = insertAgentRunEvent;
|
|
@@ -794,6 +795,47 @@ async function getAgentRun(client, args) {
|
|
|
794
795
|
finishedAt: row[15]
|
|
795
796
|
};
|
|
796
797
|
}
|
|
798
|
+
exports.claimAgentRunQuery = `-- name: ClaimAgentRun :one
|
|
799
|
+
UPDATE weave.agent_runs
|
|
800
|
+
SET
|
|
801
|
+
status = $1,
|
|
802
|
+
error_code = '',
|
|
803
|
+
safe_error_message = '',
|
|
804
|
+
started_at = COALESCE(started_at, $2::timestamptz),
|
|
805
|
+
finished_at = NULL
|
|
806
|
+
WHERE organization_id = $3
|
|
807
|
+
AND id = $4
|
|
808
|
+
AND status = $5
|
|
809
|
+
RETURNING id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at`;
|
|
810
|
+
async function claimAgentRun(client, args) {
|
|
811
|
+
const result = await client.query({
|
|
812
|
+
text: exports.claimAgentRunQuery,
|
|
813
|
+
values: [args.status, args.startedAt, args.organizationId, args.agentRunId, args.expectedStatus],
|
|
814
|
+
rowMode: "array"
|
|
815
|
+
});
|
|
816
|
+
if (result.rows.length !== 1) {
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
const row = result.rows[0];
|
|
820
|
+
return {
|
|
821
|
+
id: row[0],
|
|
822
|
+
organizationId: row[1],
|
|
823
|
+
agentDefinitionId: row[2],
|
|
824
|
+
agentVersionId: row[3],
|
|
825
|
+
status: row[4],
|
|
826
|
+
createdByUserId: row[5],
|
|
827
|
+
chatSessionId: row[6],
|
|
828
|
+
workflowRunId: row[7],
|
|
829
|
+
workflowStepRunId: row[8],
|
|
830
|
+
input: row[9],
|
|
831
|
+
output: row[10],
|
|
832
|
+
errorCode: row[11],
|
|
833
|
+
safeErrorMessage: row[12],
|
|
834
|
+
createdAt: row[13],
|
|
835
|
+
startedAt: row[14],
|
|
836
|
+
finishedAt: row[15]
|
|
837
|
+
};
|
|
838
|
+
}
|
|
797
839
|
exports.listAgentRunsQuery = `-- name: ListAgentRuns :many
|
|
798
840
|
SELECT id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at FROM weave.agent_runs
|
|
799
841
|
WHERE organization_id = $1
|
|
@@ -78,12 +78,12 @@ export interface ListConsolidationRunsByOrganizationRow {
|
|
|
78
78
|
completedAt: Date | null;
|
|
79
79
|
}
|
|
80
80
|
export declare function listConsolidationRunsByOrganization(client: Client, args: ListConsolidationRunsByOrganizationArgs): Promise<ListConsolidationRunsByOrganizationRow[]>;
|
|
81
|
-
export declare const upsertConceptClusterQuery = "-- name: UpsertConceptCluster :one\nINSERT INTO weave.concept_clusters (\n id,\n organization_id,\n
|
|
81
|
+
export declare const upsertConceptClusterQuery = "-- name: UpsertConceptCluster :one\nINSERT INTO weave.concept_clusters (\n id,\n organization_id,\n scope_kind,\n scope_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n embedding,\n centroid,\n thread_count,\n consolidation_run_id\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10::vector,\n $11::vector,\n $12,\n $13\n)\nON CONFLICT (id) DO UPDATE\nSET\n name = EXCLUDED.name,\n description = EXCLUDED.description,\n scope_kind = EXCLUDED.scope_kind,\n scope_key = EXCLUDED.scope_key,\n knowledge_type = EXCLUDED.knowledge_type,\n level = EXCLUDED.level,\n parent_id = EXCLUDED.parent_id,\n embedding = EXCLUDED.embedding,\n centroid = EXCLUDED.centroid,\n thread_count = EXCLUDED.thread_count,\n consolidation_run_id = EXCLUDED.consolidation_run_id,\n updated_at = now()\nRETURNING\n id,\n organization_id,\n scope_kind,\n scope_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at";
|
|
82
82
|
export interface UpsertConceptClusterArgs {
|
|
83
83
|
id: string;
|
|
84
84
|
organizationId: string;
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
scopeKind: string;
|
|
86
|
+
scopeKey: string;
|
|
87
87
|
name: string;
|
|
88
88
|
description: string;
|
|
89
89
|
knowledgeType: string;
|
|
@@ -97,8 +97,8 @@ export interface UpsertConceptClusterArgs {
|
|
|
97
97
|
export interface UpsertConceptClusterRow {
|
|
98
98
|
id: string;
|
|
99
99
|
organizationId: string;
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
scopeKind: string;
|
|
101
|
+
scopeKey: string;
|
|
102
102
|
name: string;
|
|
103
103
|
description: string;
|
|
104
104
|
knowledgeType: string;
|
|
@@ -110,18 +110,18 @@ export interface UpsertConceptClusterRow {
|
|
|
110
110
|
updatedAt: Date;
|
|
111
111
|
}
|
|
112
112
|
export declare function upsertConceptCluster(client: Client, args: UpsertConceptClusterArgs): Promise<UpsertConceptClusterRow | null>;
|
|
113
|
-
export declare const
|
|
114
|
-
export interface
|
|
113
|
+
export declare const getConceptClusterByOrganizationScopeAndIDQuery = "-- name: GetConceptClusterByOrganizationScopeAndID :one\nSELECT\n id,\n organization_id,\n scope_kind,\n scope_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at\nFROM weave.concept_clusters\nWHERE organization_id = $1\n AND scope_kind = $2\n AND scope_key = $3\n AND id = $4";
|
|
114
|
+
export interface GetConceptClusterByOrganizationScopeAndIDArgs {
|
|
115
115
|
organizationId: string;
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
scopeKind: string;
|
|
117
|
+
scopeKey: string;
|
|
118
118
|
id: string;
|
|
119
119
|
}
|
|
120
|
-
export interface
|
|
120
|
+
export interface GetConceptClusterByOrganizationScopeAndIDRow {
|
|
121
121
|
id: string;
|
|
122
122
|
organizationId: string;
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
scopeKind: string;
|
|
124
|
+
scopeKey: string;
|
|
125
125
|
name: string;
|
|
126
126
|
description: string;
|
|
127
127
|
knowledgeType: string;
|
|
@@ -132,20 +132,20 @@ export interface GetConceptClusterByOrganizationRealmAndIDRow {
|
|
|
132
132
|
createdAt: Date;
|
|
133
133
|
updatedAt: Date;
|
|
134
134
|
}
|
|
135
|
-
export declare function
|
|
136
|
-
export declare const
|
|
137
|
-
export interface
|
|
135
|
+
export declare function getConceptClusterByOrganizationScopeAndID(client: Client, args: GetConceptClusterByOrganizationScopeAndIDArgs): Promise<GetConceptClusterByOrganizationScopeAndIDRow | null>;
|
|
136
|
+
export declare const listConceptClustersByScopeQuery = "-- name: ListConceptClustersByScope :many\nSELECT\n id,\n organization_id,\n scope_kind,\n scope_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at\nFROM weave.concept_clusters\nWHERE organization_id = $1\n AND scope_kind = $2\n AND scope_key = $3\n AND ($4 = '' OR knowledge_type = $4)\n AND ($5 <= 0 OR level <= $5)\nORDER BY level ASC, updated_at DESC, id ASC";
|
|
137
|
+
export interface ListConceptClustersByScopeArgs {
|
|
138
138
|
organizationId: string;
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
scopeKind: string;
|
|
140
|
+
scopeKey: string;
|
|
141
141
|
knowledgeType: string | null;
|
|
142
142
|
maxDepth: string | null;
|
|
143
143
|
}
|
|
144
|
-
export interface
|
|
144
|
+
export interface ListConceptClustersByScopeRow {
|
|
145
145
|
id: string;
|
|
146
146
|
organizationId: string;
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
scopeKind: string;
|
|
148
|
+
scopeKey: string;
|
|
149
149
|
name: string;
|
|
150
150
|
description: string;
|
|
151
151
|
knowledgeType: string;
|
|
@@ -156,19 +156,19 @@ export interface ListConceptClustersByRealmRow {
|
|
|
156
156
|
createdAt: Date;
|
|
157
157
|
updatedAt: Date;
|
|
158
158
|
}
|
|
159
|
-
export declare function
|
|
160
|
-
export declare const
|
|
161
|
-
export interface
|
|
159
|
+
export declare function listConceptClustersByScope(client: Client, args: ListConceptClustersByScopeArgs): Promise<ListConceptClustersByScopeRow[]>;
|
|
160
|
+
export declare const listConceptClustersByParentAndScopeQuery = "-- name: ListConceptClustersByParentAndScope :many\nSELECT\n id,\n organization_id,\n scope_kind,\n scope_key,\n name,\n description,\n knowledge_type,\n level,\n parent_id,\n thread_count,\n consolidation_run_id,\n created_at,\n updated_at\nFROM weave.concept_clusters\nWHERE organization_id = $1\n AND scope_kind = $2\n AND scope_key = $3\n AND parent_id = $4\nORDER BY updated_at DESC, id ASC";
|
|
161
|
+
export interface ListConceptClustersByParentAndScopeArgs {
|
|
162
162
|
organizationId: string;
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
scopeKind: string;
|
|
164
|
+
scopeKey: string;
|
|
165
165
|
parentId: string | null;
|
|
166
166
|
}
|
|
167
|
-
export interface
|
|
167
|
+
export interface ListConceptClustersByParentAndScopeRow {
|
|
168
168
|
id: string;
|
|
169
169
|
organizationId: string;
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
scopeKind: string;
|
|
171
|
+
scopeKey: string;
|
|
172
172
|
name: string;
|
|
173
173
|
description: string;
|
|
174
174
|
knowledgeType: string;
|
|
@@ -179,8 +179,8 @@ export interface ListConceptClustersByParentAndRealmRow {
|
|
|
179
179
|
createdAt: Date;
|
|
180
180
|
updatedAt: Date;
|
|
181
181
|
}
|
|
182
|
-
export declare function
|
|
183
|
-
export declare const listApprovedThreadsForConsolidationQuery = "-- name: ListApprovedThreadsForConsolidation :many\nSELECT\n t.id,\n t.organization_id,\n t.document_id,\n t.ingestion_run_id,\n t.text,\n t.knowledge_type,\n t.embedding::text AS embedding_text,\n t.approved_at,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN '
|
|
182
|
+
export declare function listConceptClustersByParentAndScope(client: Client, args: ListConceptClustersByParentAndScopeArgs): Promise<ListConceptClustersByParentAndScopeRow[]>;
|
|
183
|
+
export declare const listApprovedThreadsForConsolidationQuery = "-- name: ListApprovedThreadsForConsolidation :many\nSELECT\n t.id,\n t.organization_id,\n t.document_id,\n t.ingestion_run_id,\n t.text,\n t.knowledge_type,\n t.embedding::text AS embedding_text,\n t.approved_at,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN 'SCOPE_KIND_ORG'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN 'SCOPE_KIND_RESTRICTED_GROUP'::text\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN 'SCOPE_KIND_USER'::text\n END AS scope_kind,\n CASE\n WHEN d.scope = 'DOCUMENT_SCOPE_ORG'\n THEN ''::text\n WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n THEN drg.restricted_group_id::text\n WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n THEN d.uploaded_by_user_id::text\n END AS scope_key\nFROM weave.threads t\nJOIN weave.documents d ON d.id = t.document_id\nLEFT JOIN weave.document_restricted_groups drg\n ON drg.organization_id = d.organization_id\n AND drg.document_id = d.id\n AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\nWHERE t.organization_id = $1\n AND t.retrieval_status = 'THREAD_RETRIEVAL_STATUS_APPROVED'\n AND t.embedding IS NOT NULL\n AND (d.scope <> 'DOCUMENT_SCOPE_RESTRICTED' OR drg.restricted_group_id IS NOT NULL)\nORDER BY t.approved_at DESC, t.id ASC\nLIMIT $3 OFFSET $2";
|
|
184
184
|
export interface ListApprovedThreadsForConsolidationArgs {
|
|
185
185
|
organizationId: string;
|
|
186
186
|
pageOffset: string;
|
|
@@ -195,11 +195,11 @@ export interface ListApprovedThreadsForConsolidationRow {
|
|
|
195
195
|
knowledgeType: string;
|
|
196
196
|
embeddingText: string;
|
|
197
197
|
approvedAt: Date | null;
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
scopeKind: string | null;
|
|
199
|
+
scopeKey: string | null;
|
|
200
200
|
}
|
|
201
201
|
export declare function listApprovedThreadsForConsolidation(client: Client, args: ListApprovedThreadsForConsolidationArgs): Promise<ListApprovedThreadsForConsolidationRow[]>;
|
|
202
|
-
export declare const assignThreadsToClusterQuery = "-- name: AssignThreadsToCluster :execrows\nUPDATE weave.threads AS t\nSET cluster_id = cc.id\nFROM weave.concept_clusters cc,\n weave.documents d\nWHERE t.organization_id = $1\n AND t.id = ANY($2::uuid[])\n AND cc.organization_id = t.organization_id\n AND cc.id = $3\n AND d.id = t.document_id\n AND (\n (cc.
|
|
202
|
+
export declare const assignThreadsToClusterQuery = "-- name: AssignThreadsToCluster :execrows\nUPDATE weave.threads AS t\nSET cluster_id = cc.id\nFROM weave.concept_clusters cc,\n weave.documents d\nWHERE t.organization_id = $1\n AND t.id = ANY($2::uuid[])\n AND cc.organization_id = t.organization_id\n AND cc.id = $3\n AND d.id = t.document_id\n AND (\n (cc.scope_kind = 'SCOPE_KIND_ORG'\n AND cc.scope_key = ''\n AND d.scope = 'DOCUMENT_SCOPE_ORG')\n OR (cc.scope_kind = 'SCOPE_KIND_RESTRICTED_GROUP'\n AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'\n AND EXISTS (\n SELECT 1\n FROM weave.document_restricted_groups drg\n WHERE drg.organization_id = d.organization_id\n AND drg.document_id = d.id\n AND drg.restricted_group_id::text = cc.scope_key\n ))\n OR (cc.scope_kind = 'SCOPE_KIND_USER'\n AND d.scope = 'DOCUMENT_SCOPE_PRIVATE'\n AND cc.scope_key = d.uploaded_by_user_id::text)\n )";
|
|
203
203
|
export interface AssignThreadsToClusterArgs {
|
|
204
204
|
organizationId: string;
|
|
205
205
|
threadIds: string[];
|