@superdurable/connector-baichuan 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dex-connector.json +1 -1
- package/dist/index.js +12 -7
- package/package.json +1 -1
package/dex-connector.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -105,21 +105,23 @@ var ListKnowledgeBasesOperation = class {
|
|
|
105
105
|
}
|
|
106
106
|
const status = classifyStatus(response.status, response.headers);
|
|
107
107
|
if (status) return status;
|
|
108
|
-
let
|
|
108
|
+
let wire;
|
|
109
109
|
try {
|
|
110
|
-
|
|
110
|
+
wire = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
|
|
111
111
|
} catch {
|
|
112
112
|
return branch("invalidResponse", "PROTOCOL", "Baichuan returned an invalid knowledge-base list");
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
const document = isRecord(wire) ? providerFields(wire) : {};
|
|
115
|
+
if (document.object !== "list" || !Array.isArray(document.data) || document.data.length > 1e4) return branch("invalidResponse", "PROTOCOL", "Baichuan returned an invalid knowledge-base list");
|
|
115
116
|
const knowledgeBases = [];
|
|
116
117
|
const seen = /* @__PURE__ */ new Set();
|
|
117
|
-
for (const
|
|
118
|
-
|
|
118
|
+
for (const row of document.data) {
|
|
119
|
+
const item = isRecord(row) ? providerFields(row) : {};
|
|
120
|
+
if (typeof item.id !== "string" || !item.id || byteLength(item.id) > 256 || item.object !== "knowledge-base" || !isOptionalString(item.name) || byteLength(optionalString(item.name)) > 256 || !isOptionalString(item.description) || byteLength(optionalString(item.description)) > 4096 || !isOptionalString(item.status) || !isOptionalInteger(item.created_at) || !isOptionalInteger(item.updated_at) || optionalInteger(item.created_at) < 0 || optionalInteger(item.updated_at) < 0 || !(item.file_ids === void 0 || item.file_ids === null || Array.isArray(item.file_ids))) return branch("invalidResponse", "PROTOCOL", "Baichuan returned an invalid knowledge-base list");
|
|
119
121
|
if (seen.has(item.id)) return branch("invalidResponse", "PROTOCOL", "Baichuan returned an invalid knowledge-base list");
|
|
120
122
|
seen.add(item.id);
|
|
121
|
-
const fileIds = item.file_ids === void 0 || item.file_ids === null ?
|
|
122
|
-
if (fileIds
|
|
123
|
+
const fileIds = item.file_ids === void 0 || item.file_ids === null ? [] : item.file_ids;
|
|
124
|
+
if (fileIds.length > 1e4 || fileIds.some((fileId) => typeof fileId !== "string" || !fileId || byteLength(fileId) > 256)) return branch("invalidResponse", "PROTOCOL", "Baichuan returned an invalid knowledge-base list");
|
|
123
125
|
knowledgeBases.push({ id: item.id, name: optionalString(item.name), description: optionalString(item.description), status: optionalString(item.status), fileIds, createdAt: optionalInteger(item.created_at), updatedAt: optionalInteger(item.updated_at) });
|
|
124
126
|
}
|
|
125
127
|
return newQueryBranch("listed", { knowledgeBases });
|
|
@@ -163,6 +165,9 @@ function branch(id, kind, message) {
|
|
|
163
165
|
function retry(kind, message, delayMs = 0) {
|
|
164
166
|
return newQueryRetry(failure(kind, message), delayMs);
|
|
165
167
|
}
|
|
168
|
+
function providerFields(record) {
|
|
169
|
+
return Object.fromEntries(Object.entries(record).map(([name, value]) => [name.toLowerCase(), value]));
|
|
170
|
+
}
|
|
166
171
|
|
|
167
172
|
// src/project.ts
|
|
168
173
|
function newProjectConnection2(project, connectionName) {
|