Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 195 additions & 3 deletions extensions/salesforce/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions extensions/salesforce/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "salesforce",
"version": "4.4.0",
"version": "4.5.1",
"description": "This Extension integrates with all Salesforce Clouds",
"authors": "Matt Muller <https://github.com/Mattallmighty>",
"main": "build/module.js",
"scripts": {
"transpile": "tsc -p .",
Expand All @@ -23,13 +24,15 @@
"author": "Cognigy GmbH",
"license": "MIT",
"devDependencies": {
"@types/node": "^10.12.5",
"@types/node": "^10.17.60",
"@types/qs": "^6.9.17",
"dotenv": "^17.3.1",
"ts-node": "^10.9.2",
"tslint": "^6.1.2",
"typescript": "^4.9.5"
},
"dependencies": {
"@cognigy/extension-tools": "^0.16.1",
"axios": "^1.13.5"
}
}
}
2 changes: 1 addition & 1 deletion extensions/salesforce/src/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ export const authenticate = async (oauthConnection: IConnection["oauthConnection
query,
sobject
};
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Thin wrapper around the Cognigy Management REST API.
*
* Provides listing and deletion of knowledge sources — operations not
* exposed by the @cognigy/extension-tools SDK — for incremental sync.
*
* Auth: X-API-Key header (from Profile → API Keys in Cognigy.AI UI).
*/

import axios from "axios";

export interface ManagedSource {
_id: string;
name: string;
description?: string;
}

const REQUEST_TIMEOUT = 30_000;

/**
* List all knowledge sources in a store, paginating automatically.
*
* GET {apiUrl}/v2.0/knowledgestores/{storeId}/knowledgesources?limit=100&skip=0
*/
export async function listKnowledgeSources(
apiUrl: string,
apiKey: string,
storeId: string,
): Promise<ManagedSource[]> {
const baseUrl = apiUrl.replace(/\/+$/, "");
const all: ManagedSource[] = [];
const limit = 100;
let skip = 0;

while (true) {
const res = await axios.get<{ data: ManagedSource[] }>(
`${baseUrl}/v2.0/knowledgestores/${storeId}/knowledgesources`,
{
params: { limit, skip },
headers: { "X-API-Key": apiKey },
timeout: REQUEST_TIMEOUT,
validateStatus: (s) => s >= 200 && s < 300,
},
Comment thread
Mattallmighty marked this conversation as resolved.
);

const page = res.data?.data ?? [];
all.push(...page);

if (page.length < limit) break;
skip += limit;
}

return all;
}

/**
* Delete a single knowledge source by its ID.
*
* DELETE {apiUrl}/v2.0/knowledgestores/{storeId}/knowledgesources/{sourceId}
*/
export async function deleteKnowledgeSourceById(
apiUrl: string,
apiKey: string,
storeId: string,
sourceId: string,
): Promise<void> {
const baseUrl = apiUrl.replace(/\/+$/, "");
await axios.delete(
`${baseUrl}/v2.0/knowledgestores/${storeId}/knowledgesources/${sourceId}`,
{
headers: { "X-API-Key": apiKey },
timeout: REQUEST_TIMEOUT,
validateStatus: (s) => s >= 200 && s < 300,
},
);
}
Loading
Loading