@knowledgesdk/node 0.1.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/LICENSE +21 -0
- package/README.md +495 -0
- package/dist/api/classify.d.ts +24 -0
- package/dist/api/classify.js +19 -0
- package/dist/api/classify.js.map +1 -0
- package/dist/api/extract.d.ts +118 -0
- package/dist/api/extract.js +60 -0
- package/dist/api/extract.js.map +1 -0
- package/dist/api/jobs.d.ts +35 -0
- package/dist/api/jobs.js +43 -0
- package/dist/api/jobs.js.map +1 -0
- package/dist/api/scrape.d.ts +18 -0
- package/dist/api/scrape.js +18 -0
- package/dist/api/scrape.js.map +1 -0
- package/dist/api/screenshot.d.ts +15 -0
- package/dist/api/screenshot.js +18 -0
- package/dist/api/screenshot.js.map +1 -0
- package/dist/api/search.d.ts +29 -0
- package/dist/api/search.js +22 -0
- package/dist/api/search.js.map +1 -0
- package/dist/api/sitemap.d.ts +17 -0
- package/dist/api/sitemap.js +19 -0
- package/dist/api/sitemap.js.map +1 -0
- package/dist/api/webhooks.d.ts +40 -0
- package/dist/api/webhooks.js +39 -0
- package/dist/api/webhooks.js.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/esm/api/classify.d.ts +24 -0
- package/dist/esm/api/classify.js +15 -0
- package/dist/esm/api/classify.js.map +1 -0
- package/dist/esm/api/extract.d.ts +118 -0
- package/dist/esm/api/extract.js +56 -0
- package/dist/esm/api/extract.js.map +1 -0
- package/dist/esm/api/jobs.d.ts +35 -0
- package/dist/esm/api/jobs.js +39 -0
- package/dist/esm/api/jobs.js.map +1 -0
- package/dist/esm/api/scrape.d.ts +18 -0
- package/dist/esm/api/scrape.js +14 -0
- package/dist/esm/api/scrape.js.map +1 -0
- package/dist/esm/api/screenshot.d.ts +15 -0
- package/dist/esm/api/screenshot.js +14 -0
- package/dist/esm/api/screenshot.js.map +1 -0
- package/dist/esm/api/search.d.ts +29 -0
- package/dist/esm/api/search.js +18 -0
- package/dist/esm/api/search.js.map +1 -0
- package/dist/esm/api/sitemap.d.ts +17 -0
- package/dist/esm/api/sitemap.js +15 -0
- package/dist/esm/api/sitemap.js.map +1 -0
- package/dist/esm/api/webhooks.d.ts +40 -0
- package/dist/esm/api/webhooks.js +35 -0
- package/dist/esm/api/webhooks.js.map +1 -0
- package/dist/esm/constants.d.ts +5 -0
- package/dist/esm/constants.js +6 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/errors.d.ts +32 -0
- package/dist/esm/errors.js +43 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.d.ts +100 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/http-client.d.ts +62 -0
- package/dist/esm/utils/http-client.js +354 -0
- package/dist/esm/utils/http-client.js.map +1 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils/http-client.d.ts +62 -0
- package/dist/utils/http-client.js +361 -0
- package/dist/utils/http-client.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Extract = void 0;
|
|
4
|
+
class Extract {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Run a synchronous extraction pipeline against a URL.
|
|
10
|
+
* Scrapes the site, classifies the business, and returns structured knowledge items.
|
|
11
|
+
* @param url The URL to extract knowledge from
|
|
12
|
+
* @param options Optional extraction options
|
|
13
|
+
* @returns The full extraction result including business profile and knowledge items
|
|
14
|
+
*/
|
|
15
|
+
async run(url, options) {
|
|
16
|
+
return this.httpClient.post('/extract', {
|
|
17
|
+
url,
|
|
18
|
+
...options,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Start an asynchronous extraction pipeline and return a job ID.
|
|
23
|
+
* Use jobs.poll() or jobs.get() to retrieve the result when complete.
|
|
24
|
+
* @param url The URL to extract knowledge from
|
|
25
|
+
* @param options Optional async extraction options including a callbackUrl
|
|
26
|
+
* @returns The job ID and initial status
|
|
27
|
+
*/
|
|
28
|
+
async runAsync(url, options) {
|
|
29
|
+
return this.httpClient.post('/extract/async', {
|
|
30
|
+
url,
|
|
31
|
+
...options,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Stream extraction progress as server-sent events.
|
|
36
|
+
* Yields typed events as the pipeline runs: classification, page discovery,
|
|
37
|
+
* per-page scraping, and the final complete result.
|
|
38
|
+
* Requires Node.js 18+ (native fetch).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* for await (const event of client.extract.runStream('https://stripe.com')) {
|
|
43
|
+
* if (event.type === 'page_scraped') {
|
|
44
|
+
* console.log(`Scraped ${event.index + 1}/${event.total}: ${event.url}`);
|
|
45
|
+
* }
|
|
46
|
+
* if (event.type === 'complete') {
|
|
47
|
+
* console.log(event.result.knowledgeItems);
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
async *runStream(url, options) {
|
|
53
|
+
yield* this.httpClient.streamPost('/extract/stream', {
|
|
54
|
+
url,
|
|
55
|
+
...options,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Extract = Extract;
|
|
60
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/api/extract.ts"],"names":[],"mappings":";;;AA0DA,MAAa,OAAO;IAGlB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,OAAwB;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAgB,UAAU,EAAE;YACrD,GAAG;YACH,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,OAA6B;QACvD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAqB,gBAAgB,EAAE;YAChE,GAAG;YACH,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,CAAC,SAAS,CAAC,GAAW,EAAE,OAA8B;QAC1D,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAqB,iBAAiB,EAAE;YACvE,GAAG;YACH,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF;AA3DD,0BA2DC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export type JobStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
3
|
+
export interface JobResult {
|
|
4
|
+
jobId: string;
|
|
5
|
+
status: JobStatus;
|
|
6
|
+
result?: any;
|
|
7
|
+
error?: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
completedAt?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PollOptions {
|
|
13
|
+
/** Interval in milliseconds between status checks. Defaults to 2000ms. */
|
|
14
|
+
intervalMs?: number;
|
|
15
|
+
/** Maximum time in milliseconds to wait before throwing a TimeoutError. Defaults to 120000ms (2 minutes). */
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare class Jobs {
|
|
19
|
+
private httpClient;
|
|
20
|
+
constructor(httpClient: HttpClient);
|
|
21
|
+
/**
|
|
22
|
+
* Get the current status and result of an async job.
|
|
23
|
+
* @param jobId The job ID returned from an async operation (e.g. extract.runAsync)
|
|
24
|
+
* @returns The current job status and result if completed
|
|
25
|
+
*/
|
|
26
|
+
get(jobId: string): Promise<JobResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Poll a job until it completes or fails, then return the result.
|
|
29
|
+
* Throws a TimeoutError if the job does not complete within the timeout window.
|
|
30
|
+
* @param jobId The job ID to poll
|
|
31
|
+
* @param options Optional polling configuration
|
|
32
|
+
* @returns The final job result once status is 'completed' or 'failed'
|
|
33
|
+
*/
|
|
34
|
+
poll(jobId: string, options?: PollOptions): Promise<JobResult>;
|
|
35
|
+
}
|
package/dist/api/jobs.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Jobs = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
class Jobs {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
this.httpClient = httpClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get the current status and result of an async job.
|
|
11
|
+
* @param jobId The job ID returned from an async operation (e.g. extract.runAsync)
|
|
12
|
+
* @returns The current job status and result if completed
|
|
13
|
+
*/
|
|
14
|
+
async get(jobId) {
|
|
15
|
+
return this.httpClient.get(`/jobs/${jobId}`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Poll a job until it completes or fails, then return the result.
|
|
19
|
+
* Throws a TimeoutError if the job does not complete within the timeout window.
|
|
20
|
+
* @param jobId The job ID to poll
|
|
21
|
+
* @param options Optional polling configuration
|
|
22
|
+
* @returns The final job result once status is 'completed' or 'failed'
|
|
23
|
+
*/
|
|
24
|
+
async poll(jobId, options) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
const intervalMs = (_a = options === null || options === void 0 ? void 0 : options.intervalMs) !== null && _a !== void 0 ? _a : 2000;
|
|
27
|
+
const timeoutMs = (_b = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _b !== void 0 ? _b : 120000;
|
|
28
|
+
const startTime = Date.now();
|
|
29
|
+
while (true) {
|
|
30
|
+
const job = await this.get(jobId);
|
|
31
|
+
if (job.status === 'completed' || job.status === 'failed') {
|
|
32
|
+
return job;
|
|
33
|
+
}
|
|
34
|
+
const elapsed = Date.now() - startTime;
|
|
35
|
+
if (elapsed + intervalMs >= timeoutMs) {
|
|
36
|
+
throw new errors_1.TimeoutError(`Job ${jobId} did not complete within ${timeoutMs}ms. Last status: ${job.status}`, { code: 'job_timeout', data: { jobId, status: job.status } });
|
|
37
|
+
}
|
|
38
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Jobs = Jobs;
|
|
43
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/api/jobs.ts"],"names":[],"mappings":";;;AACA,sCAAyC;AAqBzC,MAAa,IAAI;IAGf,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,KAAa;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAY,SAAS,KAAK,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,OAAqB;;QAC7C,MAAM,UAAU,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,mCAAI,IAAI,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,MAAM,CAAC;QAE/C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAElC,IAAI,GAAG,CAAC,MAAM,KAAK,WAAW,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC1D,OAAO,GAAG,CAAC;YACb,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACvC,IAAI,OAAO,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;gBACtC,MAAM,IAAI,qBAAY,CACpB,OAAO,KAAK,4BAA4B,SAAS,oBAAoB,GAAG,CAAC,MAAM,EAAE,EACjF,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAC7D,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF;AA/CD,oBA+CC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export interface ScrapeResult {
|
|
3
|
+
url: string;
|
|
4
|
+
markdown: string;
|
|
5
|
+
title: string | null;
|
|
6
|
+
description: string | null;
|
|
7
|
+
links: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class Scrape {
|
|
10
|
+
private httpClient;
|
|
11
|
+
constructor(httpClient: HttpClient);
|
|
12
|
+
/**
|
|
13
|
+
* Scrape a single URL and return its content as Markdown along with metadata.
|
|
14
|
+
* @param url The URL to scrape
|
|
15
|
+
* @returns The scraped content including markdown, title, description and extracted links
|
|
16
|
+
*/
|
|
17
|
+
run(url: string): Promise<ScrapeResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scrape = void 0;
|
|
4
|
+
class Scrape {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Scrape a single URL and return its content as Markdown along with metadata.
|
|
10
|
+
* @param url The URL to scrape
|
|
11
|
+
* @returns The scraped content including markdown, title, description and extracted links
|
|
12
|
+
*/
|
|
13
|
+
async run(url) {
|
|
14
|
+
return this.httpClient.post('/scrape', { url });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Scrape = Scrape;
|
|
18
|
+
//# sourceMappingURL=scrape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape.js","sourceRoot":"","sources":["../../src/api/scrape.ts"],"names":[],"mappings":";;;AAUA,MAAa,MAAM;IAGjB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAe,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;CACF;AAfD,wBAeC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export interface ScreenshotResult {
|
|
3
|
+
url: string;
|
|
4
|
+
screenshot: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class Screenshot {
|
|
7
|
+
private httpClient;
|
|
8
|
+
constructor(httpClient: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* Capture a full-page screenshot of a URL.
|
|
11
|
+
* @param url The URL to screenshot
|
|
12
|
+
* @returns The original URL and a base64-encoded PNG screenshot
|
|
13
|
+
*/
|
|
14
|
+
run(url: string): Promise<ScreenshotResult>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Screenshot = void 0;
|
|
4
|
+
class Screenshot {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Capture a full-page screenshot of a URL.
|
|
10
|
+
* @param url The URL to screenshot
|
|
11
|
+
* @returns The original URL and a base64-encoded PNG screenshot
|
|
12
|
+
*/
|
|
13
|
+
async run(url) {
|
|
14
|
+
return this.httpClient.post('/screenshot', { url });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Screenshot = Screenshot;
|
|
18
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/api/screenshot.ts"],"names":[],"mappings":";;;AAOA,MAAa,UAAU;IAGrB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAmB,aAAa,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACxE,CAAC;CACF;AAfD,gCAeC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export interface SearchHit {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
content: string;
|
|
6
|
+
category: string;
|
|
7
|
+
source: string;
|
|
8
|
+
score: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SearchResult {
|
|
11
|
+
hits: SearchHit[];
|
|
12
|
+
total: number;
|
|
13
|
+
query: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SearchOptions {
|
|
16
|
+
limit?: number;
|
|
17
|
+
apiKeyId?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class Search {
|
|
20
|
+
private httpClient;
|
|
21
|
+
constructor(httpClient: HttpClient);
|
|
22
|
+
/**
|
|
23
|
+
* Search across indexed knowledge items using a natural language query.
|
|
24
|
+
* @param query The search query string
|
|
25
|
+
* @param options Optional search parameters including result limit and API key ID filter
|
|
26
|
+
* @returns Matching knowledge items ranked by relevance score
|
|
27
|
+
*/
|
|
28
|
+
run(query: string, options?: SearchOptions): Promise<SearchResult>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Search = void 0;
|
|
4
|
+
class Search {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Search across indexed knowledge items using a natural language query.
|
|
10
|
+
* @param query The search query string
|
|
11
|
+
* @param options Optional search parameters including result limit and API key ID filter
|
|
12
|
+
* @returns Matching knowledge items ranked by relevance score
|
|
13
|
+
*/
|
|
14
|
+
async run(query, options) {
|
|
15
|
+
return this.httpClient.post('/search', {
|
|
16
|
+
query,
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Search = Search;
|
|
22
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/api/search.ts"],"names":[],"mappings":";;;AAsBA,MAAa,MAAM;IAGjB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,OAAuB;QAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAe,SAAS,EAAE;YACnD,KAAK;YACL,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,wBAmBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export interface SitemapResult {
|
|
3
|
+
url: string;
|
|
4
|
+
urls: string[];
|
|
5
|
+
count: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class Sitemap {
|
|
8
|
+
private httpClient;
|
|
9
|
+
constructor(httpClient: HttpClient);
|
|
10
|
+
/**
|
|
11
|
+
* Discover all URLs for a given website by crawling its sitemap(s).
|
|
12
|
+
* Falls back to crawling the site if no sitemap.xml is found.
|
|
13
|
+
* @param url The root URL of the website
|
|
14
|
+
* @returns The root URL, a list of discovered URLs, and the total count
|
|
15
|
+
*/
|
|
16
|
+
run(url: string): Promise<SitemapResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Sitemap = void 0;
|
|
4
|
+
class Sitemap {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Discover all URLs for a given website by crawling its sitemap(s).
|
|
10
|
+
* Falls back to crawling the site if no sitemap.xml is found.
|
|
11
|
+
* @param url The root URL of the website
|
|
12
|
+
* @returns The root URL, a list of discovered URLs, and the total count
|
|
13
|
+
*/
|
|
14
|
+
async run(url) {
|
|
15
|
+
return this.httpClient.post('/sitemap', { url });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Sitemap = Sitemap;
|
|
19
|
+
//# sourceMappingURL=sitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/api/sitemap.ts"],"names":[],"mappings":";;;AAQA,MAAa,OAAO;IAGlB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAgB,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAhBD,0BAgBC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export interface WebhookCreateOptions {
|
|
3
|
+
url: string;
|
|
4
|
+
events: string[];
|
|
5
|
+
displayName?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WebhookFull {
|
|
8
|
+
id: string;
|
|
9
|
+
url: string;
|
|
10
|
+
events: string[];
|
|
11
|
+
displayName?: string;
|
|
12
|
+
status: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class Webhooks {
|
|
17
|
+
private httpClient;
|
|
18
|
+
constructor(httpClient: HttpClient);
|
|
19
|
+
/**
|
|
20
|
+
* Create a new webhook endpoint.
|
|
21
|
+
* @param options The webhook creation options including URL, events, and optional display name
|
|
22
|
+
* @returns The created webhook
|
|
23
|
+
*/
|
|
24
|
+
create(options: WebhookCreateOptions): Promise<WebhookFull>;
|
|
25
|
+
/**
|
|
26
|
+
* List all registered webhooks.
|
|
27
|
+
* @returns An array of all webhooks
|
|
28
|
+
*/
|
|
29
|
+
list(): Promise<WebhookFull[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Delete a webhook by ID.
|
|
32
|
+
* @param webhookId The ID of the webhook to delete
|
|
33
|
+
*/
|
|
34
|
+
delete(webhookId: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Send a test event to a webhook to verify it is working.
|
|
37
|
+
* @param webhookId The ID of the webhook to test
|
|
38
|
+
*/
|
|
39
|
+
test(webhookId: string): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Webhooks = void 0;
|
|
4
|
+
class Webhooks {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create a new webhook endpoint.
|
|
10
|
+
* @param options The webhook creation options including URL, events, and optional display name
|
|
11
|
+
* @returns The created webhook
|
|
12
|
+
*/
|
|
13
|
+
async create(options) {
|
|
14
|
+
return this.httpClient.post('/webhooks', options);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* List all registered webhooks.
|
|
18
|
+
* @returns An array of all webhooks
|
|
19
|
+
*/
|
|
20
|
+
async list() {
|
|
21
|
+
return this.httpClient.get('/webhooks');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Delete a webhook by ID.
|
|
25
|
+
* @param webhookId The ID of the webhook to delete
|
|
26
|
+
*/
|
|
27
|
+
async delete(webhookId) {
|
|
28
|
+
return this.httpClient.delete(`/webhooks/${webhookId}`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Send a test event to a webhook to verify it is working.
|
|
32
|
+
* @param webhookId The ID of the webhook to test
|
|
33
|
+
*/
|
|
34
|
+
async test(webhookId) {
|
|
35
|
+
return this.httpClient.post(`/webhooks/${webhookId}/test`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Webhooks = Webhooks;
|
|
39
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/api/webhooks.ts"],"names":[],"mappings":";;;AAkBA,MAAa,QAAQ;IAGnB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAA6B;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAc,WAAW,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAgB,WAAW,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAO,aAAa,SAAS,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAO,aAAa,SAAS,OAAO,CAAC,CAAC;IACnE,CAAC;CACF;AAvCD,4BAuCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_API_VERSION = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_BASE_URL = exports.VERSION = void 0;
|
|
4
|
+
exports.VERSION = '0.1.0';
|
|
5
|
+
exports.DEFAULT_BASE_URL = 'https://api.knowledgesdk.com';
|
|
6
|
+
exports.DEFAULT_MAX_RETRIES = 3;
|
|
7
|
+
exports.DEFAULT_TIMEOUT = 30000;
|
|
8
|
+
exports.DEFAULT_API_VERSION = 'v1';
|
|
9
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC;AAElB,QAAA,gBAAgB,GAAG,8BAA8B,CAAC;AAClD,QAAA,mBAAmB,GAAG,CAAC,CAAC;AACxB,QAAA,eAAe,GAAG,KAAK,CAAC;AACxB,QAAA,mBAAmB,GAAG,IAAI,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ErrorOptions {
|
|
2
|
+
code?: string;
|
|
3
|
+
statusCode?: number;
|
|
4
|
+
requestId?: string;
|
|
5
|
+
cause?: Error;
|
|
6
|
+
data?: any;
|
|
7
|
+
retryAfter?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class KnowledgeSDKError extends Error {
|
|
10
|
+
readonly code?: string;
|
|
11
|
+
readonly statusCode?: number;
|
|
12
|
+
readonly requestId?: string;
|
|
13
|
+
readonly cause?: Error;
|
|
14
|
+
readonly data?: any;
|
|
15
|
+
constructor(message: string, options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
export declare class APIError extends KnowledgeSDKError {
|
|
18
|
+
constructor(message: string, options?: ErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
export declare class AuthenticationError extends KnowledgeSDKError {
|
|
21
|
+
constructor(message: string, options?: ErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
export declare class NetworkError extends KnowledgeSDKError {
|
|
24
|
+
constructor(message: string, options?: ErrorOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare class RateLimitError extends KnowledgeSDKError {
|
|
27
|
+
readonly retryAfter?: number;
|
|
28
|
+
constructor(message: string, options?: ErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
export declare class TimeoutError extends KnowledgeSDKError {
|
|
31
|
+
constructor(message: string, options?: ErrorOptions);
|
|
32
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeoutError = exports.RateLimitError = exports.NetworkError = exports.AuthenticationError = exports.APIError = exports.KnowledgeSDKError = void 0;
|
|
4
|
+
class KnowledgeSDKError extends Error {
|
|
5
|
+
constructor(message, options = {}) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'KnowledgeSDKError';
|
|
8
|
+
this.code = options.code;
|
|
9
|
+
this.statusCode = options.statusCode;
|
|
10
|
+
this.requestId = options.requestId;
|
|
11
|
+
this.cause = options.cause;
|
|
12
|
+
this.data = options.data;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.KnowledgeSDKError = KnowledgeSDKError;
|
|
16
|
+
class APIError extends KnowledgeSDKError {
|
|
17
|
+
constructor(message, options = {}) {
|
|
18
|
+
super(message, options);
|
|
19
|
+
this.name = 'APIError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.APIError = APIError;
|
|
23
|
+
class AuthenticationError extends KnowledgeSDKError {
|
|
24
|
+
constructor(message, options = {}) {
|
|
25
|
+
super(message, options);
|
|
26
|
+
this.name = 'AuthenticationError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.AuthenticationError = AuthenticationError;
|
|
30
|
+
class NetworkError extends KnowledgeSDKError {
|
|
31
|
+
constructor(message, options = {}) {
|
|
32
|
+
super(message, options);
|
|
33
|
+
this.name = 'NetworkError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.NetworkError = NetworkError;
|
|
37
|
+
class RateLimitError extends KnowledgeSDKError {
|
|
38
|
+
constructor(message, options = {}) {
|
|
39
|
+
super(message, options);
|
|
40
|
+
this.name = 'RateLimitError';
|
|
41
|
+
this.retryAfter = typeof options.retryAfter === 'number' ? options.retryAfter : undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.RateLimitError = RateLimitError;
|
|
45
|
+
class TimeoutError extends KnowledgeSDKError {
|
|
46
|
+
constructor(message, options = {}) {
|
|
47
|
+
super(message, options);
|
|
48
|
+
this.name = 'TimeoutError';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.TimeoutError = TimeoutError;
|
|
52
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AASA,MAAa,iBAAkB,SAAQ,KAAK;IAO1C,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AAhBD,8CAgBC;AAED,MAAa,QAAS,SAAQ,iBAAiB;IAC7C,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AALD,4BAKC;AAED,MAAa,mBAAoB,SAAQ,iBAAiB;IACxD,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAED,MAAa,YAAa,SAAQ,iBAAiB;IACjD,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,MAAa,cAAe,SAAQ,iBAAiB;IAGnD,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5F,CAAC;CACF;AARD,wCAQC;AAED,MAAa,YAAa,SAAQ,iBAAiB;IACjD,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
export interface BusinessClassification {
|
|
3
|
+
businessName: string;
|
|
4
|
+
businessType: string;
|
|
5
|
+
industrySector: string;
|
|
6
|
+
targetAudience: string;
|
|
7
|
+
description: string;
|
|
8
|
+
valueProposition: string;
|
|
9
|
+
painPoints: string[];
|
|
10
|
+
uniqueSellingPoints: string[];
|
|
11
|
+
keyInsights: string[];
|
|
12
|
+
confidenceScore: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class Classify {
|
|
15
|
+
private httpClient;
|
|
16
|
+
constructor(httpClient: HttpClient);
|
|
17
|
+
/**
|
|
18
|
+
* Classify a business by analyzing its website URL.
|
|
19
|
+
* Returns a structured business profile with industry, target audience, and key insights.
|
|
20
|
+
* @param url The URL of the business website to classify
|
|
21
|
+
* @returns A structured business classification
|
|
22
|
+
*/
|
|
23
|
+
run(url: string): Promise<BusinessClassification>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class Classify {
|
|
2
|
+
constructor(httpClient) {
|
|
3
|
+
this.httpClient = httpClient;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Classify a business by analyzing its website URL.
|
|
7
|
+
* Returns a structured business profile with industry, target audience, and key insights.
|
|
8
|
+
* @param url The URL of the business website to classify
|
|
9
|
+
* @returns A structured business classification
|
|
10
|
+
*/
|
|
11
|
+
async run(url) {
|
|
12
|
+
return this.httpClient.post('/classify', { url });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=classify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../../../src/api/classify.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,QAAQ;IAGnB,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAyB,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF"}
|