@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.
@@ -4,7 +4,7 @@
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-baichuan",
7
- "version": "0.1.0"
7
+ "version": "0.1.1"
8
8
  },
9
9
  "factories": [
10
10
  {
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 document;
108
+ let wire;
109
109
  try {
110
- document = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
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
- if (!isRecord(document) || document.object !== "list" || !Array.isArray(document.data) || document.data.length > 1e4) return branch("invalidResponse", "PROTOCOL", "Baichuan returned an invalid knowledge-base list");
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 item of document.data) {
118
- if (!isRecord(item) || 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");
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 ? null : item.file_ids;
122
- if (fileIds !== null && (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
+ 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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-baichuan",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "Baichuan knowledge base list connector for Dex TypeScript applications",
6
6
  "repository": {