@kadoa/node-sdk 0.18.1 → 0.19.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/browser/index.global.js +15 -15
- package/dist/browser/index.global.js.map +1 -1
- package/dist/index.d.mts +9 -12
- package/dist/index.d.ts +9 -12
- package/dist/index.js +110 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -377,19 +377,10 @@ interface MonitoringConfig {
|
|
|
377
377
|
*/
|
|
378
378
|
'channels'?: Array<any | null>;
|
|
379
379
|
/**
|
|
380
|
-
*
|
|
380
|
+
* Condition group with logical operator and conditions
|
|
381
381
|
*/
|
|
382
|
-
'conditions'?:
|
|
383
|
-
/**
|
|
384
|
-
* Logical operator for conditions
|
|
385
|
-
*/
|
|
386
|
-
'logicalOperator'?: MonitoringConfigLogicalOperatorEnum;
|
|
382
|
+
'conditions'?: any;
|
|
387
383
|
}
|
|
388
|
-
declare const MonitoringConfigLogicalOperatorEnum: {
|
|
389
|
-
readonly And: "AND";
|
|
390
|
-
readonly Or: "OR";
|
|
391
|
-
};
|
|
392
|
-
type MonitoringConfigLogicalOperatorEnum = typeof MonitoringConfigLogicalOperatorEnum[keyof typeof MonitoringConfigLogicalOperatorEnum];
|
|
393
384
|
|
|
394
385
|
/**
|
|
395
386
|
* Kadoa API
|
|
@@ -6020,6 +6011,7 @@ interface CreateWorkflowInput {
|
|
|
6020
6011
|
autoStart?: boolean;
|
|
6021
6012
|
schedules?: string[];
|
|
6022
6013
|
additionalData?: Record<string, unknown>;
|
|
6014
|
+
userPrompt?: string;
|
|
6023
6015
|
}
|
|
6024
6016
|
declare const TERMINAL_JOB_STATES: Set<JobStateEnum>;
|
|
6025
6017
|
declare const TERMINAL_RUN_STATES: Set<string>;
|
|
@@ -6075,6 +6067,7 @@ interface ExtractionOptionsInternal {
|
|
|
6075
6067
|
notifications?: NotificationOptions;
|
|
6076
6068
|
autoStart?: boolean;
|
|
6077
6069
|
additionalData?: Record<string, unknown>;
|
|
6070
|
+
userPrompt?: string;
|
|
6078
6071
|
}
|
|
6079
6072
|
type ExtractionOptions = {
|
|
6080
6073
|
urls: string[];
|
|
@@ -6250,7 +6243,7 @@ declare class SchemaBuilder {
|
|
|
6250
6243
|
|
|
6251
6244
|
interface ExtractOptionsInternal {
|
|
6252
6245
|
urls: string[];
|
|
6253
|
-
name
|
|
6246
|
+
name?: string;
|
|
6254
6247
|
description?: string;
|
|
6255
6248
|
navigationMode: NavigationMode;
|
|
6256
6249
|
entity: EntityConfig;
|
|
@@ -6259,6 +6252,7 @@ interface ExtractOptionsInternal {
|
|
|
6259
6252
|
schedules?: string[];
|
|
6260
6253
|
location?: LocationConfig;
|
|
6261
6254
|
additionalData?: Record<string, unknown>;
|
|
6255
|
+
userPrompt?: string;
|
|
6262
6256
|
}
|
|
6263
6257
|
interface ExtractOptions extends Omit<ExtractOptionsInternal, "navigationMode" | "entity"> {
|
|
6264
6258
|
navigationMode?: NavigationMode;
|
|
@@ -6277,6 +6271,7 @@ interface PreparedExtraction {
|
|
|
6277
6271
|
}) => PreparedExtraction;
|
|
6278
6272
|
bypassPreview: () => PreparedExtraction;
|
|
6279
6273
|
setLocation: (options: LocationConfig) => PreparedExtraction;
|
|
6274
|
+
withPrompt: (prompt: string) => PreparedExtraction;
|
|
6280
6275
|
create: () => Promise<CreatedExtraction>;
|
|
6281
6276
|
}
|
|
6282
6277
|
interface RunWorkflowOptions {
|
|
@@ -6314,6 +6309,7 @@ declare class ExtractionBuilderService {
|
|
|
6314
6309
|
private _jobId;
|
|
6315
6310
|
private _notificationOptions;
|
|
6316
6311
|
private _monitoringOptions;
|
|
6312
|
+
private _userPrompt;
|
|
6317
6313
|
get options(): ExtractOptionsInternal;
|
|
6318
6314
|
get notificationOptions(): NotificationOptions | undefined;
|
|
6319
6315
|
get monitoringOptions(): WorkflowMonitoringConfig | undefined;
|
|
@@ -6330,6 +6326,7 @@ declare class ExtractionBuilderService {
|
|
|
6330
6326
|
schedules: string[];
|
|
6331
6327
|
}): PreparedExtraction;
|
|
6332
6328
|
setLocation(options: LocationConfig): PreparedExtraction;
|
|
6329
|
+
withPrompt(prompt: string): PreparedExtraction;
|
|
6333
6330
|
create(): Promise<CreatedExtraction>;
|
|
6334
6331
|
waitForReady(options?: WaitForReadyOptions): Promise<GetWorkflowResponse>;
|
|
6335
6332
|
run(options?: RunWorkflowOptions): Promise<FinishedExtraction>;
|
package/dist/index.d.ts
CHANGED
|
@@ -377,19 +377,10 @@ interface MonitoringConfig {
|
|
|
377
377
|
*/
|
|
378
378
|
'channels'?: Array<any | null>;
|
|
379
379
|
/**
|
|
380
|
-
*
|
|
380
|
+
* Condition group with logical operator and conditions
|
|
381
381
|
*/
|
|
382
|
-
'conditions'?:
|
|
383
|
-
/**
|
|
384
|
-
* Logical operator for conditions
|
|
385
|
-
*/
|
|
386
|
-
'logicalOperator'?: MonitoringConfigLogicalOperatorEnum;
|
|
382
|
+
'conditions'?: any;
|
|
387
383
|
}
|
|
388
|
-
declare const MonitoringConfigLogicalOperatorEnum: {
|
|
389
|
-
readonly And: "AND";
|
|
390
|
-
readonly Or: "OR";
|
|
391
|
-
};
|
|
392
|
-
type MonitoringConfigLogicalOperatorEnum = typeof MonitoringConfigLogicalOperatorEnum[keyof typeof MonitoringConfigLogicalOperatorEnum];
|
|
393
384
|
|
|
394
385
|
/**
|
|
395
386
|
* Kadoa API
|
|
@@ -6020,6 +6011,7 @@ interface CreateWorkflowInput {
|
|
|
6020
6011
|
autoStart?: boolean;
|
|
6021
6012
|
schedules?: string[];
|
|
6022
6013
|
additionalData?: Record<string, unknown>;
|
|
6014
|
+
userPrompt?: string;
|
|
6023
6015
|
}
|
|
6024
6016
|
declare const TERMINAL_JOB_STATES: Set<JobStateEnum>;
|
|
6025
6017
|
declare const TERMINAL_RUN_STATES: Set<string>;
|
|
@@ -6075,6 +6067,7 @@ interface ExtractionOptionsInternal {
|
|
|
6075
6067
|
notifications?: NotificationOptions;
|
|
6076
6068
|
autoStart?: boolean;
|
|
6077
6069
|
additionalData?: Record<string, unknown>;
|
|
6070
|
+
userPrompt?: string;
|
|
6078
6071
|
}
|
|
6079
6072
|
type ExtractionOptions = {
|
|
6080
6073
|
urls: string[];
|
|
@@ -6250,7 +6243,7 @@ declare class SchemaBuilder {
|
|
|
6250
6243
|
|
|
6251
6244
|
interface ExtractOptionsInternal {
|
|
6252
6245
|
urls: string[];
|
|
6253
|
-
name
|
|
6246
|
+
name?: string;
|
|
6254
6247
|
description?: string;
|
|
6255
6248
|
navigationMode: NavigationMode;
|
|
6256
6249
|
entity: EntityConfig;
|
|
@@ -6259,6 +6252,7 @@ interface ExtractOptionsInternal {
|
|
|
6259
6252
|
schedules?: string[];
|
|
6260
6253
|
location?: LocationConfig;
|
|
6261
6254
|
additionalData?: Record<string, unknown>;
|
|
6255
|
+
userPrompt?: string;
|
|
6262
6256
|
}
|
|
6263
6257
|
interface ExtractOptions extends Omit<ExtractOptionsInternal, "navigationMode" | "entity"> {
|
|
6264
6258
|
navigationMode?: NavigationMode;
|
|
@@ -6277,6 +6271,7 @@ interface PreparedExtraction {
|
|
|
6277
6271
|
}) => PreparedExtraction;
|
|
6278
6272
|
bypassPreview: () => PreparedExtraction;
|
|
6279
6273
|
setLocation: (options: LocationConfig) => PreparedExtraction;
|
|
6274
|
+
withPrompt: (prompt: string) => PreparedExtraction;
|
|
6280
6275
|
create: () => Promise<CreatedExtraction>;
|
|
6281
6276
|
}
|
|
6282
6277
|
interface RunWorkflowOptions {
|
|
@@ -6314,6 +6309,7 @@ declare class ExtractionBuilderService {
|
|
|
6314
6309
|
private _jobId;
|
|
6315
6310
|
private _notificationOptions;
|
|
6316
6311
|
private _monitoringOptions;
|
|
6312
|
+
private _userPrompt;
|
|
6317
6313
|
get options(): ExtractOptionsInternal;
|
|
6318
6314
|
get notificationOptions(): NotificationOptions | undefined;
|
|
6319
6315
|
get monitoringOptions(): WorkflowMonitoringConfig | undefined;
|
|
@@ -6330,6 +6326,7 @@ declare class ExtractionBuilderService {
|
|
|
6330
6326
|
schedules: string[];
|
|
6331
6327
|
}): PreparedExtraction;
|
|
6332
6328
|
setLocation(options: LocationConfig): PreparedExtraction;
|
|
6329
|
+
withPrompt(prompt: string): PreparedExtraction;
|
|
6333
6330
|
create(): Promise<CreatedExtraction>;
|
|
6334
6331
|
waitForReady(options?: WaitForReadyOptions): Promise<GetWorkflowResponse>;
|
|
6335
6332
|
run(options?: RunWorkflowOptions): Promise<FinishedExtraction>;
|
package/dist/index.js
CHANGED
|
@@ -4427,19 +4427,41 @@ var ExtractionService = class {
|
|
|
4427
4427
|
);
|
|
4428
4428
|
}
|
|
4429
4429
|
let workflowId;
|
|
4430
|
-
const
|
|
4431
|
-
|
|
4432
|
-
{
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4430
|
+
const isAgenticNavigation = config.navigationMode === "agentic-navigation";
|
|
4431
|
+
if (isAgenticNavigation) {
|
|
4432
|
+
if (!config.userPrompt) {
|
|
4433
|
+
throw new KadoaSdkException(
|
|
4434
|
+
"userPrompt is required when navigationMode is 'agentic-navigation'",
|
|
4435
|
+
{
|
|
4436
|
+
code: "VALIDATION_ERROR",
|
|
4437
|
+
details: { navigationMode: config.navigationMode }
|
|
4438
|
+
}
|
|
4439
|
+
);
|
|
4436
4440
|
}
|
|
4437
|
-
|
|
4441
|
+
}
|
|
4442
|
+
let resolvedEntity;
|
|
4443
|
+
if (isAgenticNavigation) {
|
|
4444
|
+
const entityConfig = options.entity || "ai-detection";
|
|
4445
|
+
resolvedEntity = {
|
|
4446
|
+
entity: typeof entityConfig === "object" && "name" in entityConfig ? entityConfig.name : void 0,
|
|
4447
|
+
fields: typeof entityConfig === "object" && "fields" in entityConfig ? entityConfig.fields : []
|
|
4448
|
+
};
|
|
4449
|
+
} else {
|
|
4450
|
+
resolvedEntity = await this.entityResolverService.resolveEntity(
|
|
4451
|
+
options.entity || "ai-detection",
|
|
4452
|
+
{
|
|
4453
|
+
link: config.urls[0],
|
|
4454
|
+
location: config.location,
|
|
4455
|
+
navigationMode: config.navigationMode
|
|
4456
|
+
}
|
|
4457
|
+
);
|
|
4458
|
+
}
|
|
4438
4459
|
const hasNotifications = !!config.notifications;
|
|
4439
4460
|
const workflowRequest = {
|
|
4440
4461
|
...config,
|
|
4441
4462
|
fields: resolvedEntity.fields,
|
|
4442
|
-
...resolvedEntity.entity !== void 0 ? { entity: resolvedEntity.entity } : {}
|
|
4463
|
+
...resolvedEntity.entity !== void 0 ? { entity: resolvedEntity.entity } : {},
|
|
4464
|
+
...config.userPrompt ? { userPrompt: config.userPrompt } : {}
|
|
4443
4465
|
};
|
|
4444
4466
|
const result = await this.workflowsCoreService.create(workflowRequest);
|
|
4445
4467
|
workflowId = result.id;
|
|
@@ -4627,20 +4649,46 @@ var ExtractionBuilderService = class {
|
|
|
4627
4649
|
this._options.location = options;
|
|
4628
4650
|
return this;
|
|
4629
4651
|
}
|
|
4652
|
+
withPrompt(prompt) {
|
|
4653
|
+
assert__default.default(this._options, "Options are not set");
|
|
4654
|
+
this._userPrompt = prompt;
|
|
4655
|
+
this._options.userPrompt = prompt;
|
|
4656
|
+
return this;
|
|
4657
|
+
}
|
|
4630
4658
|
async create() {
|
|
4631
4659
|
assert__default.default(this._options, "Options are not set");
|
|
4632
4660
|
const { urls, name, description, navigationMode, entity } = this.options;
|
|
4661
|
+
const isAgenticNavigation = navigationMode === "agentic-navigation";
|
|
4662
|
+
if (isAgenticNavigation) {
|
|
4663
|
+
if (!this._userPrompt) {
|
|
4664
|
+
throw new KadoaSdkException(
|
|
4665
|
+
"userPrompt is required when navigationMode is 'agentic-navigation'",
|
|
4666
|
+
{
|
|
4667
|
+
code: "VALIDATION_ERROR",
|
|
4668
|
+
details: { navigationMode }
|
|
4669
|
+
}
|
|
4670
|
+
);
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4633
4673
|
const isRealTime = this._options.interval === "REAL_TIME";
|
|
4634
4674
|
const useSelectorMode = isRealTime && entity === "ai-detection";
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
{
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4675
|
+
let resolvedEntity;
|
|
4676
|
+
if (isAgenticNavigation) {
|
|
4677
|
+
resolvedEntity = {
|
|
4678
|
+
entity: typeof entity === "object" && "name" in entity ? entity.name : void 0,
|
|
4679
|
+
fields: typeof entity === "object" && "fields" in entity ? entity.fields : []
|
|
4680
|
+
};
|
|
4681
|
+
} else {
|
|
4682
|
+
resolvedEntity = await this.entityResolverService.resolveEntity(
|
|
4683
|
+
entity,
|
|
4684
|
+
{
|
|
4685
|
+
link: urls[0],
|
|
4686
|
+
location: this._options.location,
|
|
4687
|
+
navigationMode,
|
|
4688
|
+
selectorMode: useSelectorMode
|
|
4689
|
+
}
|
|
4690
|
+
);
|
|
4691
|
+
}
|
|
4644
4692
|
const workflow = await this.workflowsCoreService.create({
|
|
4645
4693
|
urls,
|
|
4646
4694
|
name,
|
|
@@ -4654,7 +4702,8 @@ var ExtractionBuilderService = class {
|
|
|
4654
4702
|
interval: this._options.interval,
|
|
4655
4703
|
schedules: this._options.schedules,
|
|
4656
4704
|
additionalData: this._options.additionalData,
|
|
4657
|
-
bypassPreview: this._options.bypassPreview
|
|
4705
|
+
bypassPreview: this._options.bypassPreview,
|
|
4706
|
+
userPrompt: this._userPrompt
|
|
4658
4707
|
});
|
|
4659
4708
|
if (this._notificationOptions) {
|
|
4660
4709
|
await this.notificationSetupService.setup({
|
|
@@ -5178,7 +5227,7 @@ var WSS_API_URI = process.env.KADOA_WSS_API_URI ?? "wss://realtime.kadoa.com";
|
|
|
5178
5227
|
var REALTIME_API_URI = process.env.KADOA_REALTIME_API_URI ?? "https://realtime.kadoa.com";
|
|
5179
5228
|
|
|
5180
5229
|
// src/version.ts
|
|
5181
|
-
var SDK_VERSION = "0.
|
|
5230
|
+
var SDK_VERSION = "0.19.0";
|
|
5182
5231
|
var SDK_NAME = "kadoa-node-sdk";
|
|
5183
5232
|
var SDK_LANGUAGE = "node";
|
|
5184
5233
|
|
|
@@ -5783,6 +5832,48 @@ var WorkflowsCoreService = class {
|
|
|
5783
5832
|
async create(input) {
|
|
5784
5833
|
validateAdditionalData(input.additionalData);
|
|
5785
5834
|
const domainName = new URL(input.urls[0]).hostname;
|
|
5835
|
+
if (input.navigationMode === "agentic-navigation") {
|
|
5836
|
+
if (!input.userPrompt) {
|
|
5837
|
+
throw new KadoaSdkException(
|
|
5838
|
+
"userPrompt is required when navigationMode is 'agentic-navigation'",
|
|
5839
|
+
{
|
|
5840
|
+
code: "VALIDATION_ERROR",
|
|
5841
|
+
details: { navigationMode: input.navigationMode }
|
|
5842
|
+
}
|
|
5843
|
+
);
|
|
5844
|
+
}
|
|
5845
|
+
const agenticRequest = {
|
|
5846
|
+
urls: input.urls,
|
|
5847
|
+
navigationMode: "agentic-navigation",
|
|
5848
|
+
name: input.name ?? domainName,
|
|
5849
|
+
description: input.description,
|
|
5850
|
+
userPrompt: input.userPrompt,
|
|
5851
|
+
schemaId: input.schemaId,
|
|
5852
|
+
entity: input.entity,
|
|
5853
|
+
fields: input.fields,
|
|
5854
|
+
bypassPreview: input.bypassPreview ?? true,
|
|
5855
|
+
tags: input.tags,
|
|
5856
|
+
interval: input.interval,
|
|
5857
|
+
monitoring: input.monitoring,
|
|
5858
|
+
location: input.location,
|
|
5859
|
+
autoStart: input.autoStart,
|
|
5860
|
+
schedules: input.schedules,
|
|
5861
|
+
additionalData: input.additionalData
|
|
5862
|
+
};
|
|
5863
|
+
const response2 = await this.workflowsApi.v4WorkflowsPost({
|
|
5864
|
+
createWorkflowBody: agenticRequest
|
|
5865
|
+
});
|
|
5866
|
+
const workflowId2 = response2.data?.workflowId;
|
|
5867
|
+
if (!workflowId2) {
|
|
5868
|
+
throw new KadoaSdkException(ERROR_MESSAGES.NO_WORKFLOW_ID, {
|
|
5869
|
+
code: "INTERNAL_ERROR",
|
|
5870
|
+
details: {
|
|
5871
|
+
response: response2.data
|
|
5872
|
+
}
|
|
5873
|
+
});
|
|
5874
|
+
}
|
|
5875
|
+
return { id: workflowId2 };
|
|
5876
|
+
}
|
|
5786
5877
|
const request = {
|
|
5787
5878
|
urls: input.urls,
|
|
5788
5879
|
name: input.name ?? domainName,
|