weave-typescript 0.50.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/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,
|
|
@@ -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[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clearThreadClusterAssignmentsByDocumentQuery = exports.clearThreadClusterAssignmentsByOrganizationQuery = exports.assignThreadsToClusterQuery = exports.listApprovedThreadsForConsolidationQuery = exports.
|
|
3
|
+
exports.clearThreadClusterAssignmentsByDocumentQuery = exports.clearThreadClusterAssignmentsByOrganizationQuery = exports.assignThreadsToClusterQuery = exports.listApprovedThreadsForConsolidationQuery = exports.listConceptClustersByParentAndScopeQuery = exports.listConceptClustersByScopeQuery = exports.getConceptClusterByOrganizationScopeAndIDQuery = exports.upsertConceptClusterQuery = exports.listConsolidationRunsByOrganizationQuery = exports.updateConsolidationRunStateQuery = exports.getConsolidationRunByOrganizationAndIDQuery = exports.createConsolidationRunQuery = void 0;
|
|
4
4
|
exports.createConsolidationRun = createConsolidationRun;
|
|
5
5
|
exports.getConsolidationRunByOrganizationAndID = getConsolidationRunByOrganizationAndID;
|
|
6
6
|
exports.updateConsolidationRunState = updateConsolidationRunState;
|
|
7
7
|
exports.listConsolidationRunsByOrganization = listConsolidationRunsByOrganization;
|
|
8
8
|
exports.upsertConceptCluster = upsertConceptCluster;
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
9
|
+
exports.getConceptClusterByOrganizationScopeAndID = getConceptClusterByOrganizationScopeAndID;
|
|
10
|
+
exports.listConceptClustersByScope = listConceptClustersByScope;
|
|
11
|
+
exports.listConceptClustersByParentAndScope = listConceptClustersByParentAndScope;
|
|
12
12
|
exports.listApprovedThreadsForConsolidation = listApprovedThreadsForConsolidation;
|
|
13
13
|
exports.createConsolidationRunQuery = `-- name: CreateConsolidationRun :one
|
|
14
14
|
INSERT INTO weave.consolidation_runs (
|
|
@@ -170,8 +170,8 @@ exports.upsertConceptClusterQuery = `-- name: UpsertConceptCluster :one
|
|
|
170
170
|
INSERT INTO weave.concept_clusters (
|
|
171
171
|
id,
|
|
172
172
|
organization_id,
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
scope_kind,
|
|
174
|
+
scope_key,
|
|
175
175
|
name,
|
|
176
176
|
description,
|
|
177
177
|
knowledge_type,
|
|
@@ -200,8 +200,8 @@ ON CONFLICT (id) DO UPDATE
|
|
|
200
200
|
SET
|
|
201
201
|
name = EXCLUDED.name,
|
|
202
202
|
description = EXCLUDED.description,
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
scope_kind = EXCLUDED.scope_kind,
|
|
204
|
+
scope_key = EXCLUDED.scope_key,
|
|
205
205
|
knowledge_type = EXCLUDED.knowledge_type,
|
|
206
206
|
level = EXCLUDED.level,
|
|
207
207
|
parent_id = EXCLUDED.parent_id,
|
|
@@ -213,8 +213,8 @@ SET
|
|
|
213
213
|
RETURNING
|
|
214
214
|
id,
|
|
215
215
|
organization_id,
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
scope_kind,
|
|
217
|
+
scope_key,
|
|
218
218
|
name,
|
|
219
219
|
description,
|
|
220
220
|
knowledge_type,
|
|
@@ -227,7 +227,7 @@ RETURNING
|
|
|
227
227
|
async function upsertConceptCluster(client, args) {
|
|
228
228
|
const result = await client.query({
|
|
229
229
|
text: exports.upsertConceptClusterQuery,
|
|
230
|
-
values: [args.id, args.organizationId, args.
|
|
230
|
+
values: [args.id, args.organizationId, args.scopeKind, args.scopeKey, args.name, args.description, args.knowledgeType, args.level, args.parentId, args.embedding, args.centroid, args.threadCount, args.consolidationRunId],
|
|
231
231
|
rowMode: "array"
|
|
232
232
|
});
|
|
233
233
|
if (result.rows.length !== 1) {
|
|
@@ -237,8 +237,8 @@ async function upsertConceptCluster(client, args) {
|
|
|
237
237
|
return {
|
|
238
238
|
id: row[0],
|
|
239
239
|
organizationId: row[1],
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
scopeKind: row[2],
|
|
241
|
+
scopeKey: row[3],
|
|
242
242
|
name: row[4],
|
|
243
243
|
description: row[5],
|
|
244
244
|
knowledgeType: row[6],
|
|
@@ -250,12 +250,12 @@ async function upsertConceptCluster(client, args) {
|
|
|
250
250
|
updatedAt: row[12]
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
|
-
exports.
|
|
253
|
+
exports.getConceptClusterByOrganizationScopeAndIDQuery = `-- name: GetConceptClusterByOrganizationScopeAndID :one
|
|
254
254
|
SELECT
|
|
255
255
|
id,
|
|
256
256
|
organization_id,
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
scope_kind,
|
|
258
|
+
scope_key,
|
|
259
259
|
name,
|
|
260
260
|
description,
|
|
261
261
|
knowledge_type,
|
|
@@ -267,13 +267,13 @@ SELECT
|
|
|
267
267
|
updated_at
|
|
268
268
|
FROM weave.concept_clusters
|
|
269
269
|
WHERE organization_id = $1
|
|
270
|
-
AND
|
|
271
|
-
AND
|
|
270
|
+
AND scope_kind = $2
|
|
271
|
+
AND scope_key = $3
|
|
272
272
|
AND id = $4`;
|
|
273
|
-
async function
|
|
273
|
+
async function getConceptClusterByOrganizationScopeAndID(client, args) {
|
|
274
274
|
const result = await client.query({
|
|
275
|
-
text: exports.
|
|
276
|
-
values: [args.organizationId, args.
|
|
275
|
+
text: exports.getConceptClusterByOrganizationScopeAndIDQuery,
|
|
276
|
+
values: [args.organizationId, args.scopeKind, args.scopeKey, args.id],
|
|
277
277
|
rowMode: "array"
|
|
278
278
|
});
|
|
279
279
|
if (result.rows.length !== 1) {
|
|
@@ -283,8 +283,8 @@ async function getConceptClusterByOrganizationRealmAndID(client, args) {
|
|
|
283
283
|
return {
|
|
284
284
|
id: row[0],
|
|
285
285
|
organizationId: row[1],
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
scopeKind: row[2],
|
|
287
|
+
scopeKey: row[3],
|
|
288
288
|
name: row[4],
|
|
289
289
|
description: row[5],
|
|
290
290
|
knowledgeType: row[6],
|
|
@@ -296,12 +296,12 @@ async function getConceptClusterByOrganizationRealmAndID(client, args) {
|
|
|
296
296
|
updatedAt: row[12]
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
|
-
exports.
|
|
299
|
+
exports.listConceptClustersByScopeQuery = `-- name: ListConceptClustersByScope :many
|
|
300
300
|
SELECT
|
|
301
301
|
id,
|
|
302
302
|
organization_id,
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
scope_kind,
|
|
304
|
+
scope_key,
|
|
305
305
|
name,
|
|
306
306
|
description,
|
|
307
307
|
knowledge_type,
|
|
@@ -313,23 +313,23 @@ SELECT
|
|
|
313
313
|
updated_at
|
|
314
314
|
FROM weave.concept_clusters
|
|
315
315
|
WHERE organization_id = $1
|
|
316
|
-
AND
|
|
317
|
-
AND
|
|
316
|
+
AND scope_kind = $2
|
|
317
|
+
AND scope_key = $3
|
|
318
318
|
AND ($4 = '' OR knowledge_type = $4)
|
|
319
319
|
AND ($5 <= 0 OR level <= $5)
|
|
320
320
|
ORDER BY level ASC, updated_at DESC, id ASC`;
|
|
321
|
-
async function
|
|
321
|
+
async function listConceptClustersByScope(client, args) {
|
|
322
322
|
const result = await client.query({
|
|
323
|
-
text: exports.
|
|
324
|
-
values: [args.organizationId, args.
|
|
323
|
+
text: exports.listConceptClustersByScopeQuery,
|
|
324
|
+
values: [args.organizationId, args.scopeKind, args.scopeKey, args.knowledgeType, args.maxDepth],
|
|
325
325
|
rowMode: "array"
|
|
326
326
|
});
|
|
327
327
|
return result.rows.map(row => {
|
|
328
328
|
return {
|
|
329
329
|
id: row[0],
|
|
330
330
|
organizationId: row[1],
|
|
331
|
-
|
|
332
|
-
|
|
331
|
+
scopeKind: row[2],
|
|
332
|
+
scopeKey: row[3],
|
|
333
333
|
name: row[4],
|
|
334
334
|
description: row[5],
|
|
335
335
|
knowledgeType: row[6],
|
|
@@ -342,12 +342,12 @@ async function listConceptClustersByRealm(client, args) {
|
|
|
342
342
|
};
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
-
exports.
|
|
345
|
+
exports.listConceptClustersByParentAndScopeQuery = `-- name: ListConceptClustersByParentAndScope :many
|
|
346
346
|
SELECT
|
|
347
347
|
id,
|
|
348
348
|
organization_id,
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
scope_kind,
|
|
350
|
+
scope_key,
|
|
351
351
|
name,
|
|
352
352
|
description,
|
|
353
353
|
knowledge_type,
|
|
@@ -359,22 +359,22 @@ SELECT
|
|
|
359
359
|
updated_at
|
|
360
360
|
FROM weave.concept_clusters
|
|
361
361
|
WHERE organization_id = $1
|
|
362
|
-
AND
|
|
363
|
-
AND
|
|
362
|
+
AND scope_kind = $2
|
|
363
|
+
AND scope_key = $3
|
|
364
364
|
AND parent_id = $4
|
|
365
365
|
ORDER BY updated_at DESC, id ASC`;
|
|
366
|
-
async function
|
|
366
|
+
async function listConceptClustersByParentAndScope(client, args) {
|
|
367
367
|
const result = await client.query({
|
|
368
|
-
text: exports.
|
|
369
|
-
values: [args.organizationId, args.
|
|
368
|
+
text: exports.listConceptClustersByParentAndScopeQuery,
|
|
369
|
+
values: [args.organizationId, args.scopeKind, args.scopeKey, args.parentId],
|
|
370
370
|
rowMode: "array"
|
|
371
371
|
});
|
|
372
372
|
return result.rows.map(row => {
|
|
373
373
|
return {
|
|
374
374
|
id: row[0],
|
|
375
375
|
organizationId: row[1],
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
scopeKind: row[2],
|
|
377
|
+
scopeKey: row[3],
|
|
378
378
|
name: row[4],
|
|
379
379
|
description: row[5],
|
|
380
380
|
knowledgeType: row[6],
|
|
@@ -399,12 +399,12 @@ SELECT
|
|
|
399
399
|
t.approved_at,
|
|
400
400
|
CASE
|
|
401
401
|
WHEN d.scope = 'DOCUMENT_SCOPE_ORG'
|
|
402
|
-
THEN '
|
|
402
|
+
THEN 'SCOPE_KIND_ORG'::text
|
|
403
403
|
WHEN d.scope = 'DOCUMENT_SCOPE_RESTRICTED'
|
|
404
|
-
THEN '
|
|
404
|
+
THEN 'SCOPE_KIND_RESTRICTED_GROUP'::text
|
|
405
405
|
WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'
|
|
406
|
-
THEN '
|
|
407
|
-
END AS
|
|
406
|
+
THEN 'SCOPE_KIND_USER'::text
|
|
407
|
+
END AS scope_kind,
|
|
408
408
|
CASE
|
|
409
409
|
WHEN d.scope = 'DOCUMENT_SCOPE_ORG'
|
|
410
410
|
THEN ''::text
|
|
@@ -412,7 +412,7 @@ SELECT
|
|
|
412
412
|
THEN drg.restricted_group_id::text
|
|
413
413
|
WHEN d.scope = 'DOCUMENT_SCOPE_PRIVATE'
|
|
414
414
|
THEN d.uploaded_by_user_id::text
|
|
415
|
-
END AS
|
|
415
|
+
END AS scope_key
|
|
416
416
|
FROM weave.threads t
|
|
417
417
|
JOIN weave.documents d ON d.id = t.document_id
|
|
418
418
|
LEFT JOIN weave.document_restricted_groups drg
|
|
@@ -441,8 +441,8 @@ async function listApprovedThreadsForConsolidation(client, args) {
|
|
|
441
441
|
knowledgeType: row[5],
|
|
442
442
|
embeddingText: row[6],
|
|
443
443
|
approvedAt: row[7],
|
|
444
|
-
|
|
445
|
-
|
|
444
|
+
scopeKind: row[8],
|
|
445
|
+
scopeKey: row[9]
|
|
446
446
|
};
|
|
447
447
|
});
|
|
448
448
|
}
|
|
@@ -457,21 +457,21 @@ WHERE t.organization_id = $1
|
|
|
457
457
|
AND cc.id = $3
|
|
458
458
|
AND d.id = t.document_id
|
|
459
459
|
AND (
|
|
460
|
-
(cc.
|
|
461
|
-
AND cc.
|
|
460
|
+
(cc.scope_kind = 'SCOPE_KIND_ORG'
|
|
461
|
+
AND cc.scope_key = ''
|
|
462
462
|
AND d.scope = 'DOCUMENT_SCOPE_ORG')
|
|
463
|
-
OR (cc.
|
|
463
|
+
OR (cc.scope_kind = 'SCOPE_KIND_RESTRICTED_GROUP'
|
|
464
464
|
AND d.scope = 'DOCUMENT_SCOPE_RESTRICTED'
|
|
465
465
|
AND EXISTS (
|
|
466
466
|
SELECT 1
|
|
467
467
|
FROM weave.document_restricted_groups drg
|
|
468
468
|
WHERE drg.organization_id = d.organization_id
|
|
469
469
|
AND drg.document_id = d.id
|
|
470
|
-
AND drg.restricted_group_id::text = cc.
|
|
470
|
+
AND drg.restricted_group_id::text = cc.scope_key
|
|
471
471
|
))
|
|
472
|
-
OR (cc.
|
|
472
|
+
OR (cc.scope_kind = 'SCOPE_KIND_USER'
|
|
473
473
|
AND d.scope = 'DOCUMENT_SCOPE_PRIVATE'
|
|
474
|
-
AND cc.
|
|
474
|
+
AND cc.scope_key = d.uploaded_by_user_id::text)
|
|
475
475
|
)`;
|
|
476
476
|
exports.clearThreadClusterAssignmentsByOrganizationQuery = `-- name: ClearThreadClusterAssignmentsByOrganization :execrows
|
|
477
477
|
UPDATE weave.threads
|