@synapcores/sdk 0.1.0 → 0.2.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/README.md +94 -1
- package/dist/index.d.mts +1019 -188
- package/dist/index.d.ts +1019 -188
- package/dist/index.js +1774 -893
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1765 -893
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -35,10 +35,16 @@ __export(index_exports, {
|
|
|
35
35
|
AutoMLModel: () => AutoMLModel,
|
|
36
36
|
BackupClient: () => BackupClient,
|
|
37
37
|
BatchOperationError: () => BatchOperationError,
|
|
38
|
+
ChatClient: () => ChatClient,
|
|
38
39
|
Collection: () => Collection,
|
|
39
40
|
ConnectionError: () => ConnectionError,
|
|
41
|
+
FilesystemCollectionsClient: () => FilesystemCollectionsClient,
|
|
42
|
+
GraphClient: () => GraphClient,
|
|
40
43
|
ImportExportClient: () => ImportExportClient,
|
|
41
44
|
IntegrationClient: () => IntegrationClient,
|
|
45
|
+
McpClient: () => McpClient,
|
|
46
|
+
MultimodalClient: () => MultimodalClient,
|
|
47
|
+
NL2SqlClient: () => NL2SqlClient,
|
|
42
48
|
NLPClient: () => NLPClient,
|
|
43
49
|
NotFoundError: () => NotFoundError,
|
|
44
50
|
RateLimitError: () => RateLimitError,
|
|
@@ -49,8 +55,11 @@ __export(index_exports, {
|
|
|
49
55
|
Subscription: () => Subscription,
|
|
50
56
|
SynapCores: () => SynapCores,
|
|
51
57
|
SynapCoresError: () => SynapCoresError,
|
|
58
|
+
SystemClient: () => SystemClient,
|
|
52
59
|
TimeoutError: () => TimeoutError,
|
|
53
60
|
TransactionError: () => TransactionError,
|
|
61
|
+
TransactionsClient: () => TransactionsClient,
|
|
62
|
+
Tx: () => Tx,
|
|
54
63
|
VERSION: () => VERSION,
|
|
55
64
|
ValidationError: () => ValidationError,
|
|
56
65
|
VectorError: () => VectorError,
|
|
@@ -83,13 +92,14 @@ var Subscription = class extends import_events.EventEmitter {
|
|
|
83
92
|
}
|
|
84
93
|
async createConnection() {
|
|
85
94
|
const client = this.collection.client;
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
95
|
+
const { token } = await client.createWsTicket();
|
|
96
|
+
const wsBase = client._getWsBaseUrl ? client._getWsBaseUrl() : (() => {
|
|
97
|
+
const cfg = client.config ?? client._getConfig();
|
|
98
|
+
const protocol = cfg.useHttps ? "wss" : "ws";
|
|
99
|
+
return `${protocol}://${cfg.host}:${cfg.port}`;
|
|
100
|
+
})();
|
|
101
|
+
const url = `${wsBase}/ws?token=${encodeURIComponent(token)}`;
|
|
102
|
+
this.ws = new import_ws.default(url);
|
|
93
103
|
this.ws.on("open", () => {
|
|
94
104
|
this.reconnectAttempts = 0;
|
|
95
105
|
this.subscribe();
|
|
@@ -400,19 +410,14 @@ var AutoMLModel = class {
|
|
|
400
410
|
const isSingle = !Array.isArray(data);
|
|
401
411
|
const inputs = isSingle ? [data] : data;
|
|
402
412
|
const response = await this.client.synapCores._getHttpClient().post(
|
|
403
|
-
|
|
404
|
-
{
|
|
405
|
-
model_id: this.id,
|
|
406
|
-
inputs
|
|
407
|
-
}
|
|
413
|
+
`/automl/models/${this.id}/predict`,
|
|
414
|
+
{ inputs }
|
|
408
415
|
);
|
|
409
|
-
const predictions = response.data.predictions;
|
|
416
|
+
const predictions = response.data.predictions ?? response.data;
|
|
410
417
|
return isSingle ? predictions[0] : predictions;
|
|
411
418
|
}
|
|
412
419
|
async evaluate(testData, target) {
|
|
413
|
-
const payload = {
|
|
414
|
-
model_id: this.id
|
|
415
|
-
};
|
|
420
|
+
const payload = {};
|
|
416
421
|
if (typeof testData === "string") {
|
|
417
422
|
payload.collection = testData;
|
|
418
423
|
} else {
|
|
@@ -422,14 +427,14 @@ var AutoMLModel = class {
|
|
|
422
427
|
}
|
|
423
428
|
}
|
|
424
429
|
const { data } = await this.client.synapCores._getHttpClient().post(
|
|
425
|
-
|
|
430
|
+
`/automl/models/${this.id}/evaluate`,
|
|
426
431
|
payload
|
|
427
432
|
);
|
|
428
433
|
return data;
|
|
429
434
|
}
|
|
430
435
|
async delete() {
|
|
431
436
|
await this.client.synapCores._getHttpClient().delete(
|
|
432
|
-
`/
|
|
437
|
+
`/automl/models/${this.id}`
|
|
433
438
|
);
|
|
434
439
|
}
|
|
435
440
|
};
|
|
@@ -438,7 +443,7 @@ var AutoMLClient = class {
|
|
|
438
443
|
this.synapCores = synapCores;
|
|
439
444
|
}
|
|
440
445
|
async train(options) {
|
|
441
|
-
const { data } = await this.synapCores._getHttpClient().post("/
|
|
446
|
+
const { data } = await this.synapCores._getHttpClient().post("/automl/train", {
|
|
442
447
|
collection: options.collection,
|
|
443
448
|
target: options.target,
|
|
444
449
|
features: options.features,
|
|
@@ -455,15 +460,15 @@ var AutoMLClient = class {
|
|
|
455
460
|
task: data.task,
|
|
456
461
|
status: data.status,
|
|
457
462
|
accuracy: data.accuracy,
|
|
458
|
-
createdAt: new Date(data.created_at),
|
|
463
|
+
createdAt: new Date(data.created_at ?? Date.now()),
|
|
459
464
|
updatedAt: data.updated_at ? new Date(data.updated_at) : void 0,
|
|
460
|
-
config: data.config
|
|
465
|
+
config: data.config ?? {}
|
|
461
466
|
};
|
|
462
467
|
return new AutoMLModel(this, modelInfo);
|
|
463
468
|
}
|
|
464
469
|
async getModel(modelId) {
|
|
465
470
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
466
|
-
`/
|
|
471
|
+
`/automl/models/${modelId}`
|
|
467
472
|
);
|
|
468
473
|
const modelInfo = {
|
|
469
474
|
id: data.id,
|
|
@@ -471,32 +476,35 @@ var AutoMLClient = class {
|
|
|
471
476
|
task: data.task,
|
|
472
477
|
status: data.status,
|
|
473
478
|
accuracy: data.accuracy,
|
|
474
|
-
createdAt: new Date(data.created_at),
|
|
479
|
+
createdAt: new Date(data.created_at ?? Date.now()),
|
|
475
480
|
updatedAt: data.updated_at ? new Date(data.updated_at) : void 0,
|
|
476
|
-
config: data.config
|
|
481
|
+
config: data.config ?? {}
|
|
477
482
|
};
|
|
478
483
|
return new AutoMLModel(this, modelInfo);
|
|
479
484
|
}
|
|
480
485
|
async listModels(filters) {
|
|
481
|
-
const { data } = await this.synapCores._getHttpClient().get("/
|
|
486
|
+
const { data } = await this.synapCores._getHttpClient().get("/automl/models", {
|
|
482
487
|
params: filters
|
|
483
488
|
});
|
|
484
|
-
return data.models.map((model) => ({
|
|
489
|
+
return (data.models ?? data ?? []).map((model) => ({
|
|
485
490
|
id: model.id,
|
|
486
491
|
name: model.name,
|
|
487
492
|
task: model.task,
|
|
488
493
|
status: model.status,
|
|
489
494
|
accuracy: model.accuracy,
|
|
490
|
-
createdAt: new Date(model.created_at),
|
|
495
|
+
createdAt: new Date(model.created_at ?? Date.now()),
|
|
491
496
|
updatedAt: model.updated_at ? new Date(model.updated_at) : void 0,
|
|
492
|
-
config: model.config
|
|
497
|
+
config: model.config ?? {}
|
|
493
498
|
}));
|
|
494
499
|
}
|
|
495
500
|
/**
|
|
496
|
-
* Start async training job
|
|
501
|
+
* Start async training job.
|
|
502
|
+
*
|
|
503
|
+
* In v1.5.0-ce there is no separate /train/async endpoint — /automl/train
|
|
504
|
+
* itself returns a job descriptor when the training is long-running.
|
|
497
505
|
*/
|
|
498
506
|
async trainAsync(options) {
|
|
499
|
-
const { data } = await this.synapCores._getHttpClient().post("/
|
|
507
|
+
const { data } = await this.synapCores._getHttpClient().post("/automl/train", {
|
|
500
508
|
collection: options.collection,
|
|
501
509
|
target: options.target,
|
|
502
510
|
features: options.features,
|
|
@@ -506,49 +514,20 @@ var AutoMLClient = class {
|
|
|
506
514
|
validation_split: options.validationSplit || 0.2,
|
|
507
515
|
max_trials: options.maxTrials || 10,
|
|
508
516
|
timeout_minutes: options.timeoutMinutes || 60,
|
|
517
|
+
async: true,
|
|
509
518
|
callback_url: options.callback_url,
|
|
510
519
|
webhook_url: options.webhook_url
|
|
511
520
|
});
|
|
512
|
-
return
|
|
513
|
-
id: data.id || data.job_id,
|
|
514
|
-
name: data.name,
|
|
515
|
-
status: data.status,
|
|
516
|
-
progress: data.progress || 0,
|
|
517
|
-
phase: data.phase,
|
|
518
|
-
task: data.task,
|
|
519
|
-
current_trial: data.current_trial,
|
|
520
|
-
total_trials: data.total_trials || options.maxTrials || 10,
|
|
521
|
-
best_accuracy: data.best_accuracy,
|
|
522
|
-
eta_ms: data.eta_ms || data.estimated_time_remaining_ms,
|
|
523
|
-
error: data.error,
|
|
524
|
-
started_at: new Date(data.started_at || Date.now()),
|
|
525
|
-
completed_at: data.completed_at ? new Date(data.completed_at) : void 0,
|
|
526
|
-
model_id: data.model_id
|
|
527
|
-
};
|
|
521
|
+
return this.mapTrainingJob(data, options.maxTrials || 10);
|
|
528
522
|
}
|
|
529
523
|
/**
|
|
530
524
|
* Get training job status
|
|
531
525
|
*/
|
|
532
526
|
async getTrainingJob(jobId) {
|
|
533
527
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
534
|
-
`/
|
|
528
|
+
`/automl/jobs/${jobId}`
|
|
535
529
|
);
|
|
536
|
-
return
|
|
537
|
-
id: data.id || jobId,
|
|
538
|
-
name: data.name,
|
|
539
|
-
status: data.status,
|
|
540
|
-
progress: data.progress || 0,
|
|
541
|
-
phase: data.phase,
|
|
542
|
-
task: data.task,
|
|
543
|
-
current_trial: data.current_trial,
|
|
544
|
-
total_trials: data.total_trials,
|
|
545
|
-
best_accuracy: data.best_accuracy,
|
|
546
|
-
eta_ms: data.eta_ms || data.estimated_time_remaining_ms,
|
|
547
|
-
error: data.error,
|
|
548
|
-
started_at: new Date(data.started_at),
|
|
549
|
-
completed_at: data.completed_at ? new Date(data.completed_at) : void 0,
|
|
550
|
-
model_id: data.model_id
|
|
551
|
-
};
|
|
530
|
+
return this.mapTrainingJob(data);
|
|
552
531
|
}
|
|
553
532
|
/**
|
|
554
533
|
* List training jobs
|
|
@@ -558,45 +537,36 @@ var AutoMLClient = class {
|
|
|
558
537
|
if (options.status) params.append("status", options.status);
|
|
559
538
|
if (options.page) params.append("page", options.page.toString());
|
|
560
539
|
if (options.page_size) params.append("page_size", options.page_size.toString());
|
|
540
|
+
const qs = params.toString();
|
|
561
541
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
562
|
-
`/
|
|
542
|
+
`/automl/jobs${qs ? `?${qs}` : ""}`
|
|
563
543
|
);
|
|
564
|
-
return (data.jobs
|
|
565
|
-
id: job.id,
|
|
566
|
-
name: job.name,
|
|
567
|
-
status: job.status,
|
|
568
|
-
progress: job.progress || 0,
|
|
569
|
-
phase: job.phase,
|
|
570
|
-
task: job.task,
|
|
571
|
-
current_trial: job.current_trial,
|
|
572
|
-
total_trials: job.total_trials,
|
|
573
|
-
best_accuracy: job.best_accuracy,
|
|
574
|
-
eta_ms: job.eta_ms || job.estimated_time_remaining_ms,
|
|
575
|
-
error: job.error,
|
|
576
|
-
started_at: new Date(job.started_at),
|
|
577
|
-
completed_at: job.completed_at ? new Date(job.completed_at) : void 0,
|
|
578
|
-
model_id: job.model_id
|
|
579
|
-
}));
|
|
544
|
+
return (data.jobs ?? data ?? []).map((job) => this.mapTrainingJob(job));
|
|
580
545
|
}
|
|
581
546
|
/**
|
|
582
|
-
* Cancel a training job
|
|
547
|
+
* Cancel/stop a training job
|
|
583
548
|
*/
|
|
584
549
|
async cancelTrainingJob(jobId) {
|
|
585
|
-
await this.synapCores._getHttpClient().post(`/
|
|
550
|
+
await this.synapCores._getHttpClient().post(`/automl/jobs/${jobId}/stop`);
|
|
586
551
|
}
|
|
587
552
|
/**
|
|
588
|
-
* Get training metrics for a job
|
|
553
|
+
* Get training metrics for a job.
|
|
554
|
+
*
|
|
555
|
+
* v1.5.0-ce: gateway no longer has a dedicated /metrics route — metrics
|
|
556
|
+
* (when available) ship inside the /automl/jobs/:id payload as
|
|
557
|
+
* `metrics` or `trial_metrics`. We just unwrap that field here.
|
|
589
558
|
*/
|
|
590
559
|
async getTrainingMetrics(jobId) {
|
|
591
560
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
592
|
-
`/
|
|
561
|
+
`/automl/jobs/${jobId}`
|
|
593
562
|
);
|
|
594
|
-
|
|
563
|
+
const metrics = data.metrics ?? data.trial_metrics ?? [];
|
|
564
|
+
return metrics.map((metric) => ({
|
|
595
565
|
trial: metric.trial,
|
|
596
566
|
accuracy: metric.accuracy,
|
|
597
567
|
loss: metric.loss,
|
|
598
568
|
metrics: metric.metrics,
|
|
599
|
-
timestamp: new Date(metric.timestamp)
|
|
569
|
+
timestamp: new Date(metric.timestamp ?? Date.now())
|
|
600
570
|
}));
|
|
601
571
|
}
|
|
602
572
|
/**
|
|
@@ -629,6 +599,24 @@ var AutoMLClient = class {
|
|
|
629
599
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
630
600
|
}
|
|
631
601
|
}
|
|
602
|
+
mapTrainingJob(data, fallbackMaxTrials) {
|
|
603
|
+
return {
|
|
604
|
+
id: data.id ?? data.job_id,
|
|
605
|
+
name: data.name,
|
|
606
|
+
status: data.status,
|
|
607
|
+
progress: data.progress ?? 0,
|
|
608
|
+
phase: data.phase,
|
|
609
|
+
task: data.task,
|
|
610
|
+
current_trial: data.current_trial,
|
|
611
|
+
total_trials: data.total_trials ?? fallbackMaxTrials,
|
|
612
|
+
best_accuracy: data.best_accuracy,
|
|
613
|
+
eta_ms: data.eta_ms ?? data.estimated_time_remaining_ms,
|
|
614
|
+
error: data.error,
|
|
615
|
+
started_at: new Date(data.started_at ?? Date.now()),
|
|
616
|
+
completed_at: data.completed_at ? new Date(data.completed_at) : void 0,
|
|
617
|
+
model_id: data.model_id
|
|
618
|
+
};
|
|
619
|
+
}
|
|
632
620
|
};
|
|
633
621
|
|
|
634
622
|
// src/nlp.ts
|
|
@@ -636,32 +624,67 @@ var NLPClient = class {
|
|
|
636
624
|
constructor(synapCores) {
|
|
637
625
|
this.synapCores = synapCores;
|
|
638
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Run multiple NLP tasks in parallel and stitch them into a single
|
|
629
|
+
* NLPAnalysis (or array of them, matching the input shape).
|
|
630
|
+
*/
|
|
639
631
|
async analyze(options) {
|
|
640
632
|
const isBatch = Array.isArray(options.text);
|
|
641
633
|
const texts = isBatch ? options.text : [options.text];
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
634
|
+
const tasks = options.tasks || ["sentiment", "entities", "summarize"];
|
|
635
|
+
const http = this.synapCores._getHttpClient();
|
|
636
|
+
const wantSentiment = tasks.includes("sentiment");
|
|
637
|
+
const wantEntities = tasks.includes("entities");
|
|
638
|
+
const wantSummarize = tasks.includes("summarize") || tasks.includes("summary");
|
|
639
|
+
const wantKeywords = tasks.includes("keywords");
|
|
640
|
+
const results = await Promise.all(
|
|
641
|
+
texts.map(async (text) => {
|
|
642
|
+
const out = {};
|
|
643
|
+
const calls = [];
|
|
644
|
+
if (wantSentiment) {
|
|
645
|
+
calls.push(
|
|
646
|
+
http.post("/ai/sentiment", { texts: [text], language: options.language }).then(({ data }) => {
|
|
647
|
+
const s = (data.sentiments ?? [])[0] ?? data.sentiment ?? data;
|
|
648
|
+
if (s) {
|
|
649
|
+
out.sentiment = {
|
|
650
|
+
label: s.label,
|
|
651
|
+
score: s.score,
|
|
652
|
+
confidence: s.confidence
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
}).catch(() => void 0)
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
if (wantEntities) {
|
|
659
|
+
calls.push(
|
|
660
|
+
http.post("/ai/entities", { text, language: options.language }).then(({ data }) => {
|
|
661
|
+
const arr = data.entities ?? [];
|
|
662
|
+
out.entities = arr.map((e) => ({
|
|
663
|
+
text: e.text,
|
|
664
|
+
type: e.type,
|
|
665
|
+
start: e.start,
|
|
666
|
+
end: e.end,
|
|
667
|
+
score: e.score
|
|
668
|
+
}));
|
|
669
|
+
}).catch(() => void 0)
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
if (wantSummarize) {
|
|
673
|
+
calls.push(
|
|
674
|
+
http.post("/ai/summarize", { text }).then(({ data }) => {
|
|
675
|
+
out.summary = data.summary;
|
|
676
|
+
}).catch(() => void 0)
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
if (wantKeywords) {
|
|
680
|
+
out.keywords = void 0;
|
|
681
|
+
}
|
|
682
|
+
await Promise.all(calls);
|
|
683
|
+
return out;
|
|
684
|
+
})
|
|
685
|
+
);
|
|
686
|
+
if (isBatch) return results;
|
|
687
|
+
return results[0] ?? {};
|
|
665
688
|
}
|
|
666
689
|
async summarize(options) {
|
|
667
690
|
const { data } = await this.synapCores._getHttpClient().post("/ai/summarize", {
|
|
@@ -676,7 +699,7 @@ var NLPClient = class {
|
|
|
676
699
|
text,
|
|
677
700
|
entity_types: entityTypes
|
|
678
701
|
});
|
|
679
|
-
return data.entities.map((e) => ({
|
|
702
|
+
return (data.entities ?? []).map((e) => ({
|
|
680
703
|
text: e.text,
|
|
681
704
|
type: e.type,
|
|
682
705
|
start: e.start,
|
|
@@ -690,7 +713,7 @@ var NLPClient = class {
|
|
|
690
713
|
const { data } = await this.synapCores._getHttpClient().post("/ai/sentiment", {
|
|
691
714
|
texts
|
|
692
715
|
});
|
|
693
|
-
const results = data.sentiments.map((s) => ({
|
|
716
|
+
const results = (data.sentiments ?? []).map((s) => ({
|
|
694
717
|
label: s.label,
|
|
695
718
|
score: s.score,
|
|
696
719
|
confidence: s.confidence
|
|
@@ -707,6 +730,22 @@ var NLPClient = class {
|
|
|
707
730
|
});
|
|
708
731
|
return isBatch ? data.classifications : data.classifications[0];
|
|
709
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* Question-answering against an optional context window.
|
|
735
|
+
*/
|
|
736
|
+
async qa(question, context, opts = {}) {
|
|
737
|
+
const { data } = await this.synapCores._getHttpClient().post("/ai/qa", {
|
|
738
|
+
question,
|
|
739
|
+
context,
|
|
740
|
+
max_answer_tokens: opts.maxAnswerTokens
|
|
741
|
+
});
|
|
742
|
+
return {
|
|
743
|
+
answer: data.answer ?? data.text ?? "",
|
|
744
|
+
score: data.score ?? data.confidence,
|
|
745
|
+
start: data.start,
|
|
746
|
+
end: data.end
|
|
747
|
+
};
|
|
748
|
+
}
|
|
710
749
|
};
|
|
711
750
|
|
|
712
751
|
// src/recipes.ts
|
|
@@ -850,11 +889,142 @@ var RecipeClient = class {
|
|
|
850
889
|
};
|
|
851
890
|
}
|
|
852
891
|
/**
|
|
853
|
-
* List available recipe categories
|
|
892
|
+
* List available recipe categories with counts.
|
|
893
|
+
*
|
|
894
|
+
* v0.2.0: gateway path is /recipes/categories/counts.
|
|
895
|
+
* Returns the array of category names; for the {category, count}
|
|
896
|
+
* payload use `listCategoriesWithCounts`.
|
|
854
897
|
*/
|
|
855
898
|
async listCategories() {
|
|
856
|
-
const
|
|
857
|
-
return data.
|
|
899
|
+
const data = await this.listCategoriesWithCounts();
|
|
900
|
+
return data.map((c) => c.category);
|
|
901
|
+
}
|
|
902
|
+
async listCategoriesWithCounts() {
|
|
903
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
904
|
+
"/recipes/categories/counts"
|
|
905
|
+
);
|
|
906
|
+
const arr = data.categories ?? data ?? [];
|
|
907
|
+
return arr.map((c) => ({
|
|
908
|
+
category: c.category ?? c.name ?? c,
|
|
909
|
+
count: c.count ?? c.recipe_count ?? 0
|
|
910
|
+
}));
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Validate a recipe payload before saving/executing.
|
|
914
|
+
*/
|
|
915
|
+
async validate(body) {
|
|
916
|
+
const { data } = await this.synapCores._getHttpClient().post("/recipes/validate", body);
|
|
917
|
+
return {
|
|
918
|
+
is_valid: data.is_valid ?? data.valid ?? false,
|
|
919
|
+
errors: data.errors ?? [],
|
|
920
|
+
warnings: data.warnings ?? []
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Get execution history for a specific recipe.
|
|
925
|
+
*/
|
|
926
|
+
async getHistory(id) {
|
|
927
|
+
const { data } = await this.synapCores._getHttpClient().get(`/recipes/${id}/history`);
|
|
928
|
+
const arr = data.history ?? data.executions ?? data ?? [];
|
|
929
|
+
return arr.map((row) => ({
|
|
930
|
+
id: row.id ?? row.execution_id ?? "",
|
|
931
|
+
success: row.success ?? row.status === "completed",
|
|
932
|
+
results: row.results,
|
|
933
|
+
error: row.error,
|
|
934
|
+
execution_time_ms: row.execution_time_ms ?? row.took_ms ?? 0,
|
|
935
|
+
statements_executed: row.statements_executed ?? 0
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* List built-in / shared recipe templates.
|
|
940
|
+
*/
|
|
941
|
+
async listTemplates() {
|
|
942
|
+
const { data } = await this.synapCores._getHttpClient().get("/recipes/templates");
|
|
943
|
+
return (data.templates ?? data ?? []).map((t) => ({
|
|
944
|
+
id: t.id,
|
|
945
|
+
name: t.name,
|
|
946
|
+
description: t.description ?? "",
|
|
947
|
+
category: t.category ?? "template",
|
|
948
|
+
tags: t.tags ?? [],
|
|
949
|
+
created_at: new Date(t.created_at ?? Date.now()),
|
|
950
|
+
updated_at: new Date(t.updated_at ?? t.created_at ?? Date.now()),
|
|
951
|
+
author: t.author,
|
|
952
|
+
execution_count: t.execution_count
|
|
953
|
+
}));
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Get a specific recipe template.
|
|
957
|
+
*/
|
|
958
|
+
async getTemplate(id) {
|
|
959
|
+
const { data } = await this.synapCores._getHttpClient().get(`/recipes/templates/${id}`);
|
|
960
|
+
return {
|
|
961
|
+
id: data.id,
|
|
962
|
+
name: data.name,
|
|
963
|
+
description: data.description ?? "",
|
|
964
|
+
category: data.category ?? "template",
|
|
965
|
+
content: data.content ?? "",
|
|
966
|
+
tags: data.tags ?? [],
|
|
967
|
+
parameters: data.parameters ?? [],
|
|
968
|
+
created_at: new Date(data.created_at ?? Date.now()),
|
|
969
|
+
updated_at: new Date(data.updated_at ?? data.created_at ?? Date.now()),
|
|
970
|
+
author: data.author,
|
|
971
|
+
execution_count: data.execution_count,
|
|
972
|
+
version: data.version
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Execute a recipe template with a parameter set.
|
|
977
|
+
*/
|
|
978
|
+
async executeTemplate(id, params = {}) {
|
|
979
|
+
const { data } = await this.synapCores._getHttpClient().post(
|
|
980
|
+
`/recipes/templates/${id}/execute`,
|
|
981
|
+
{ parameters: params }
|
|
982
|
+
);
|
|
983
|
+
return {
|
|
984
|
+
id: data.id ?? data.execution_id ?? "",
|
|
985
|
+
success: data.success ?? false,
|
|
986
|
+
results: data.results,
|
|
987
|
+
error: data.error,
|
|
988
|
+
execution_time_ms: data.execution_time_ms ?? data.took_ms ?? 0,
|
|
989
|
+
statements_executed: data.statements_executed ?? 0
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* List all recipe executions across recipes.
|
|
994
|
+
*/
|
|
995
|
+
async listExecutions(options = {}) {
|
|
996
|
+
const params = new URLSearchParams();
|
|
997
|
+
if (options.limit) params.append("limit", options.limit.toString());
|
|
998
|
+
if (options.status) params.append("status", options.status);
|
|
999
|
+
const qs = params.toString();
|
|
1000
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1001
|
+
`/recipes/executions${qs ? `?${qs}` : ""}`
|
|
1002
|
+
);
|
|
1003
|
+
const arr = data.executions ?? data ?? [];
|
|
1004
|
+
return arr.map((row) => ({
|
|
1005
|
+
id: row.id ?? row.execution_id ?? "",
|
|
1006
|
+
success: row.success ?? row.status === "completed",
|
|
1007
|
+
results: row.results,
|
|
1008
|
+
error: row.error,
|
|
1009
|
+
execution_time_ms: row.execution_time_ms ?? row.took_ms ?? 0,
|
|
1010
|
+
statements_executed: row.statements_executed ?? 0
|
|
1011
|
+
}));
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Get a single execution by ID.
|
|
1015
|
+
*/
|
|
1016
|
+
async getExecution(id) {
|
|
1017
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1018
|
+
`/recipes/executions/${id}`
|
|
1019
|
+
);
|
|
1020
|
+
return {
|
|
1021
|
+
id: data.id ?? id,
|
|
1022
|
+
success: data.success ?? data.status === "completed",
|
|
1023
|
+
results: data.results,
|
|
1024
|
+
error: data.error,
|
|
1025
|
+
execution_time_ms: data.execution_time_ms ?? data.took_ms ?? 0,
|
|
1026
|
+
statements_executed: data.statements_executed ?? 0
|
|
1027
|
+
};
|
|
858
1028
|
}
|
|
859
1029
|
};
|
|
860
1030
|
|
|
@@ -864,17 +1034,30 @@ var SchemaClient = class {
|
|
|
864
1034
|
this.synapCores = synapCores;
|
|
865
1035
|
}
|
|
866
1036
|
/**
|
|
867
|
-
* List all
|
|
1037
|
+
* List all databases visible to the current authentication context.
|
|
1038
|
+
*/
|
|
1039
|
+
async listDatabases() {
|
|
1040
|
+
const { data } = await this.synapCores._getHttpClient().get("/schema/databases");
|
|
1041
|
+
return (data.databases ?? data ?? []).map((db) => ({
|
|
1042
|
+
name: db.name,
|
|
1043
|
+
table_count: db.table_count,
|
|
1044
|
+
size_bytes: db.size_bytes,
|
|
1045
|
+
is_default: db.is_default
|
|
1046
|
+
}));
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* List all tables in the current database.
|
|
868
1050
|
*/
|
|
869
1051
|
async listTables(options = {}) {
|
|
870
1052
|
const params = new URLSearchParams();
|
|
871
1053
|
if (options.includeSystem) {
|
|
872
1054
|
params.append("include_system", "true");
|
|
873
1055
|
}
|
|
1056
|
+
const qs = params.toString();
|
|
874
1057
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
875
|
-
`/schema/tables
|
|
1058
|
+
`/schema/tables${qs ? `?${qs}` : ""}`
|
|
876
1059
|
);
|
|
877
|
-
return (data.tables || data).map((table) => ({
|
|
1060
|
+
return (data.tables || data || []).map((table) => ({
|
|
878
1061
|
name: table.name,
|
|
879
1062
|
type: table.type || "table",
|
|
880
1063
|
column_count: table.column_count || 0,
|
|
@@ -886,24 +1069,33 @@ var SchemaClient = class {
|
|
|
886
1069
|
}));
|
|
887
1070
|
}
|
|
888
1071
|
/**
|
|
889
|
-
* Get complete schema for a specific table
|
|
1072
|
+
* Get complete schema for a specific table.
|
|
1073
|
+
*
|
|
1074
|
+
* Combines /schema/tables/:t with /schema/tables/:t/columns and
|
|
1075
|
+
* /schema/tables/:t/indexes side-channels because the table-only payload
|
|
1076
|
+
* does not always include columns and indexes inline.
|
|
890
1077
|
*/
|
|
891
1078
|
async getTable(tableName) {
|
|
892
|
-
const
|
|
893
|
-
`/schema/tables/${tableName}`
|
|
894
|
-
|
|
1079
|
+
const [tableRes, colsRes, idxRes] = await Promise.all([
|
|
1080
|
+
this.synapCores._getHttpClient().get(`/schema/tables/${tableName}`),
|
|
1081
|
+
this.synapCores._getHttpClient().get(`/schema/tables/${tableName}/columns`),
|
|
1082
|
+
this.synapCores._getHttpClient().get(`/schema/tables/${tableName}/indexes`)
|
|
1083
|
+
]);
|
|
1084
|
+
const table = tableRes.data ?? {};
|
|
1085
|
+
const columns = colsRes.data?.columns ?? colsRes.data ?? [];
|
|
1086
|
+
const indexes = idxRes.data?.indexes ?? idxRes.data ?? [];
|
|
895
1087
|
return {
|
|
896
1088
|
table: {
|
|
897
|
-
name:
|
|
898
|
-
type:
|
|
899
|
-
column_count:
|
|
900
|
-
row_count:
|
|
901
|
-
size_bytes:
|
|
902
|
-
created_at:
|
|
903
|
-
updated_at:
|
|
904
|
-
comment:
|
|
1089
|
+
name: table.name ?? tableName,
|
|
1090
|
+
type: table.type || "table",
|
|
1091
|
+
column_count: columns.length,
|
|
1092
|
+
row_count: table.row_count,
|
|
1093
|
+
size_bytes: table.size_bytes,
|
|
1094
|
+
created_at: table.created_at ? new Date(table.created_at) : void 0,
|
|
1095
|
+
updated_at: table.updated_at ? new Date(table.updated_at) : void 0,
|
|
1096
|
+
comment: table.comment
|
|
905
1097
|
},
|
|
906
|
-
columns:
|
|
1098
|
+
columns: columns.map((col) => ({
|
|
907
1099
|
name: col.name,
|
|
908
1100
|
data_type: col.data_type || col.type,
|
|
909
1101
|
nullable: col.nullable !== false,
|
|
@@ -915,7 +1107,7 @@ var SchemaClient = class {
|
|
|
915
1107
|
comment: col.comment,
|
|
916
1108
|
ordinal_position: col.ordinal_position || col.position
|
|
917
1109
|
})),
|
|
918
|
-
indexes:
|
|
1110
|
+
indexes: indexes.map((idx) => ({
|
|
919
1111
|
name: idx.name,
|
|
920
1112
|
table: idx.table || tableName,
|
|
921
1113
|
type: idx.type || "btree",
|
|
@@ -925,8 +1117,8 @@ var SchemaClient = class {
|
|
|
925
1117
|
size_bytes: idx.size_bytes,
|
|
926
1118
|
created_at: idx.created_at ? new Date(idx.created_at) : void 0
|
|
927
1119
|
})),
|
|
928
|
-
constraints:
|
|
929
|
-
relationships: (
|
|
1120
|
+
constraints: table.constraints || [],
|
|
1121
|
+
relationships: (table.relationships || []).map((rel) => ({
|
|
930
1122
|
type: rel.type,
|
|
931
1123
|
from_table: rel.from_table || rel.source_table,
|
|
932
1124
|
from_column: rel.from_column || rel.source_column,
|
|
@@ -937,106 +1129,186 @@ var SchemaClient = class {
|
|
|
937
1129
|
};
|
|
938
1130
|
}
|
|
939
1131
|
/**
|
|
940
|
-
* Get columns for a specific table
|
|
1132
|
+
* Get columns for a specific table.
|
|
941
1133
|
*/
|
|
942
1134
|
async getColumns(tableName) {
|
|
943
|
-
const
|
|
944
|
-
|
|
1135
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1136
|
+
`/schema/tables/${tableName}/columns`
|
|
1137
|
+
);
|
|
1138
|
+
const cols = data.columns ?? data ?? [];
|
|
1139
|
+
return cols.map((col) => ({
|
|
1140
|
+
name: col.name,
|
|
1141
|
+
data_type: col.data_type || col.type,
|
|
1142
|
+
nullable: col.nullable !== false,
|
|
1143
|
+
default_value: col.default_value || col.default,
|
|
1144
|
+
is_primary_key: col.is_primary_key || col.primary_key,
|
|
1145
|
+
is_unique: col.is_unique || col.unique,
|
|
1146
|
+
is_indexed: col.is_indexed || col.indexed,
|
|
1147
|
+
foreign_key: col.foreign_key,
|
|
1148
|
+
comment: col.comment,
|
|
1149
|
+
ordinal_position: col.ordinal_position || col.position
|
|
1150
|
+
}));
|
|
945
1151
|
}
|
|
946
1152
|
/**
|
|
947
|
-
* Get indexes for a specific table
|
|
1153
|
+
* Get indexes for a specific table.
|
|
948
1154
|
*/
|
|
949
1155
|
async getIndexes(tableName) {
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
to_column: rel.to_column || rel.target_column,
|
|
964
|
-
name: rel.name
|
|
1156
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1157
|
+
`/schema/tables/${tableName}/indexes`
|
|
1158
|
+
);
|
|
1159
|
+
const idxs = data.indexes ?? data ?? [];
|
|
1160
|
+
return idxs.map((idx) => ({
|
|
1161
|
+
name: idx.name,
|
|
1162
|
+
table: idx.table || tableName,
|
|
1163
|
+
type: idx.type || "btree",
|
|
1164
|
+
columns: idx.columns || [],
|
|
1165
|
+
is_unique: idx.is_unique || idx.unique || false,
|
|
1166
|
+
is_primary: idx.is_primary || idx.primary || false,
|
|
1167
|
+
size_bytes: idx.size_bytes,
|
|
1168
|
+
created_at: idx.created_at ? new Date(idx.created_at) : void 0
|
|
965
1169
|
}));
|
|
966
1170
|
}
|
|
967
1171
|
/**
|
|
968
|
-
*
|
|
1172
|
+
* Preview rows from a table without writing SQL.
|
|
1173
|
+
*
|
|
1174
|
+
* GET /schema/tables/:t/data?limit=&offset=
|
|
969
1175
|
*/
|
|
970
|
-
async
|
|
971
|
-
const
|
|
1176
|
+
async previewTable(tableName, opts = {}) {
|
|
1177
|
+
const params = new URLSearchParams();
|
|
1178
|
+
if (opts.limit !== void 0) params.append("limit", String(opts.limit));
|
|
1179
|
+
if (opts.offset !== void 0) params.append("offset", String(opts.offset));
|
|
1180
|
+
const qs = params.toString();
|
|
1181
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1182
|
+
`/schema/tables/${tableName}/data${qs ? `?${qs}` : ""}`
|
|
1183
|
+
);
|
|
972
1184
|
return {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
relationship_count: data.relationship_count || 0,
|
|
977
|
-
total_size_bytes: data.total_size_bytes || 0,
|
|
978
|
-
total_rows: data.total_rows || 0,
|
|
979
|
-
version: data.version,
|
|
980
|
-
analyzed_at: data.analyzed_at ? new Date(data.analyzed_at) : void 0
|
|
1185
|
+
columns: data.columns ?? [],
|
|
1186
|
+
rows: data.rows ?? data.data ?? [],
|
|
1187
|
+
total_rows: data.total_rows ?? data.total
|
|
981
1188
|
};
|
|
982
1189
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
}
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// src/errors.ts
|
|
1193
|
+
var SynapCoresError = class _SynapCoresError extends Error {
|
|
1194
|
+
constructor(message, code, details) {
|
|
1195
|
+
super(message);
|
|
1196
|
+
this.name = "SynapCoresError";
|
|
1197
|
+
this.code = code;
|
|
1198
|
+
this.details = details;
|
|
1199
|
+
if (Error.captureStackTrace) {
|
|
1200
|
+
Error.captureStackTrace(this, _SynapCoresError);
|
|
1201
|
+
}
|
|
995
1202
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
schema1,
|
|
1002
|
-
schema2
|
|
1003
|
-
});
|
|
1004
|
-
return {
|
|
1005
|
-
differences: data.differences || [],
|
|
1006
|
-
added: data.added || [],
|
|
1007
|
-
removed: data.removed || [],
|
|
1008
|
-
modified: data.modified || []
|
|
1009
|
-
};
|
|
1203
|
+
};
|
|
1204
|
+
var ConnectionError = class extends SynapCoresError {
|
|
1205
|
+
constructor(message, details) {
|
|
1206
|
+
super(message, "CONNECTION_ERROR", details);
|
|
1207
|
+
this.name = "ConnectionError";
|
|
1010
1208
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
`/schema/tables/${tableName}/ddl`
|
|
1017
|
-
);
|
|
1018
|
-
return data.ddl || data.sql;
|
|
1209
|
+
};
|
|
1210
|
+
var AuthenticationError = class extends SynapCoresError {
|
|
1211
|
+
constructor(message, details) {
|
|
1212
|
+
super(message, "AUTH_ERROR", details);
|
|
1213
|
+
this.name = "AuthenticationError";
|
|
1019
1214
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1215
|
+
};
|
|
1216
|
+
var ValidationError = class extends SynapCoresError {
|
|
1217
|
+
constructor(message, details) {
|
|
1218
|
+
super(message, "VALIDATION_ERROR", details);
|
|
1219
|
+
this.name = "ValidationError";
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
var NotFoundError = class extends SynapCoresError {
|
|
1223
|
+
constructor(message, details) {
|
|
1224
|
+
super(message, "NOT_FOUND", details);
|
|
1225
|
+
this.name = "NotFoundError";
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
var ServerError = class extends SynapCoresError {
|
|
1229
|
+
constructor(message, details) {
|
|
1230
|
+
super(message, "SERVER_ERROR", details);
|
|
1231
|
+
this.name = "ServerError";
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
var TimeoutError = class extends SynapCoresError {
|
|
1235
|
+
constructor(message, details) {
|
|
1236
|
+
super(message, "TIMEOUT_ERROR", details);
|
|
1237
|
+
this.name = "TimeoutError";
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
var RateLimitError = class extends SynapCoresError {
|
|
1241
|
+
constructor(message, retryAfter, details) {
|
|
1242
|
+
super(message, "RATE_LIMIT_ERROR", details);
|
|
1243
|
+
this.name = "RateLimitError";
|
|
1244
|
+
this.retryAfter = retryAfter;
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
var SQLError = class extends SynapCoresError {
|
|
1248
|
+
constructor(message, code, severity = "ERROR", position, hint, detail, details) {
|
|
1249
|
+
super(message, code, details);
|
|
1250
|
+
this.name = "SQLError";
|
|
1251
|
+
this.severity = severity;
|
|
1252
|
+
this.position = position;
|
|
1253
|
+
this.hint = hint;
|
|
1254
|
+
this.detail = detail;
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
var VectorError = class extends SynapCoresError {
|
|
1258
|
+
constructor(message, code, vectorDimensions, expectedDimensions, operation, details) {
|
|
1259
|
+
super(message, code, details);
|
|
1260
|
+
this.name = "VectorError";
|
|
1261
|
+
this.vectorDimensions = vectorDimensions;
|
|
1262
|
+
this.expectedDimensions = expectedDimensions;
|
|
1263
|
+
this.operation = operation;
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
var TransactionError = class extends SynapCoresError {
|
|
1267
|
+
constructor(message, code, transactionId, transactionState, details) {
|
|
1268
|
+
super(message, code, details);
|
|
1269
|
+
this.name = "TransactionError";
|
|
1270
|
+
this.transactionId = transactionId;
|
|
1271
|
+
this.transactionState = transactionState;
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
var BatchOperationError = class extends SynapCoresError {
|
|
1275
|
+
constructor(message, code, failedItems, totalProcessed, successfulCount, details) {
|
|
1276
|
+
super(message, code, details);
|
|
1277
|
+
this.name = "BatchOperationError";
|
|
1278
|
+
this.failedItems = failedItems;
|
|
1279
|
+
this.totalProcessed = totalProcessed;
|
|
1280
|
+
this.successfulCount = successfulCount;
|
|
1025
1281
|
}
|
|
1026
1282
|
};
|
|
1027
1283
|
|
|
1028
1284
|
// src/import.ts
|
|
1285
|
+
var NOT_SUPPORTED_MSG = "not supported in v1.5.0-ce \u2014 use SynapCores.executeQuery with COPY ... or process locally";
|
|
1029
1286
|
var ImportExportClient = class {
|
|
1030
1287
|
constructor(synapCores) {
|
|
1031
1288
|
this.synapCores = synapCores;
|
|
1032
1289
|
}
|
|
1033
1290
|
/**
|
|
1034
|
-
* Import data into a table
|
|
1291
|
+
* Import data into a table.
|
|
1292
|
+
*
|
|
1293
|
+
* Routes to /v1/data/import/csv or /v1/data/import/json based on
|
|
1294
|
+
* `options.format`. NDJSON falls under the JSON endpoint.
|
|
1035
1295
|
*/
|
|
1036
1296
|
async import(options) {
|
|
1037
|
-
const
|
|
1297
|
+
const fmt = options.format;
|
|
1298
|
+
if (fmt !== "csv" && fmt !== "json" && fmt !== "ndjson") {
|
|
1299
|
+
throw new ValidationError(
|
|
1300
|
+
`Unsupported import format '${fmt}' \u2014 gateway v1.5.0-ce only accepts csv or json`
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
const path = fmt === "csv" ? "/data/import/csv" : "/data/import/json";
|
|
1304
|
+
let FormDataClass;
|
|
1305
|
+
try {
|
|
1306
|
+
FormDataClass = require("form-data");
|
|
1307
|
+
} catch {
|
|
1308
|
+
FormDataClass = globalThis.FormData;
|
|
1309
|
+
}
|
|
1310
|
+
const formData = new FormDataClass();
|
|
1038
1311
|
formData.append("table", options.table);
|
|
1039
|
-
formData.append("format", options.format);
|
|
1040
1312
|
if (options.mode) formData.append("mode", options.mode);
|
|
1041
1313
|
if (options.column_mapping) {
|
|
1042
1314
|
formData.append("column_mapping", JSON.stringify(options.column_mapping));
|
|
@@ -1045,7 +1317,9 @@ var ImportExportClient = class {
|
|
|
1045
1317
|
formData.append("skip_header", options.skip_header.toString());
|
|
1046
1318
|
}
|
|
1047
1319
|
if (options.delimiter) formData.append("delimiter", options.delimiter);
|
|
1048
|
-
if (options.batch_size)
|
|
1320
|
+
if (options.batch_size) {
|
|
1321
|
+
formData.append("batch_size", options.batch_size.toString());
|
|
1322
|
+
}
|
|
1049
1323
|
if (options.continue_on_error !== void 0) {
|
|
1050
1324
|
formData.append("continue_on_error", options.continue_on_error.toString());
|
|
1051
1325
|
}
|
|
@@ -1053,228 +1327,88 @@ var ImportExportClient = class {
|
|
|
1053
1327
|
formData.append("primary_keys", JSON.stringify(options.primary_keys));
|
|
1054
1328
|
}
|
|
1055
1329
|
if (Buffer.isBuffer(options.data)) {
|
|
1056
|
-
formData.append("file",
|
|
1330
|
+
formData.append("file", options.data, { filename: `data.${fmt}` });
|
|
1057
1331
|
} else {
|
|
1058
|
-
formData.append("
|
|
1332
|
+
formData.append("file", Buffer.from(String(options.data)), {
|
|
1333
|
+
filename: `data.${fmt}`
|
|
1334
|
+
});
|
|
1059
1335
|
}
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1336
|
+
const headers = {};
|
|
1337
|
+
if (typeof formData.getHeaders === "function") {
|
|
1338
|
+
Object.assign(headers, formData.getHeaders());
|
|
1339
|
+
} else {
|
|
1340
|
+
headers["Content-Type"] = "multipart/form-data";
|
|
1341
|
+
}
|
|
1342
|
+
const { data } = await this.synapCores._getHttpClient().post(path, formData, {
|
|
1343
|
+
headers,
|
|
1344
|
+
maxBodyLength: Infinity,
|
|
1345
|
+
maxContentLength: Infinity
|
|
1064
1346
|
});
|
|
1065
1347
|
return {
|
|
1066
|
-
id: data.id
|
|
1067
|
-
success: data.success,
|
|
1068
|
-
rows_processed: data.rows_processed
|
|
1069
|
-
rows_imported: data.rows_imported
|
|
1070
|
-
rows_failed: data.rows_failed
|
|
1071
|
-
duration_ms: data.duration_ms
|
|
1072
|
-
errors: data.errors
|
|
1073
|
-
warnings: data.warnings
|
|
1348
|
+
id: data.id ?? data.job_id ?? "",
|
|
1349
|
+
success: data.success ?? true,
|
|
1350
|
+
rows_processed: data.rows_processed ?? 0,
|
|
1351
|
+
rows_imported: data.rows_imported ?? data.rows_processed ?? 0,
|
|
1352
|
+
rows_failed: data.rows_failed ?? 0,
|
|
1353
|
+
duration_ms: data.duration_ms ?? data.took_ms ?? 0,
|
|
1354
|
+
errors: data.errors ?? [],
|
|
1355
|
+
warnings: data.warnings ?? []
|
|
1074
1356
|
};
|
|
1075
1357
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
columns: options.columns,
|
|
1085
|
-
filter: options.filter,
|
|
1086
|
-
order_by: options.order_by,
|
|
1087
|
-
limit: options.limit,
|
|
1088
|
-
include_header: options.include_header,
|
|
1089
|
-
delimiter: options.delimiter,
|
|
1090
|
-
compress: options.compress
|
|
1091
|
-
});
|
|
1092
|
-
return {
|
|
1093
|
-
id: data.id || data.job_id,
|
|
1094
|
-
success: data.success,
|
|
1095
|
-
rows_exported: data.rows_exported || 0,
|
|
1096
|
-
duration_ms: data.duration_ms || data.took_ms || 0,
|
|
1097
|
-
file_path: data.file_path,
|
|
1098
|
-
data: data.data,
|
|
1099
|
-
size_bytes: data.size_bytes,
|
|
1100
|
-
download_url: data.download_url,
|
|
1101
|
-
expires_at: data.expires_at ? new Date(data.expires_at) : void 0
|
|
1102
|
-
};
|
|
1358
|
+
// ---------------------------------------------------------------------
|
|
1359
|
+
// Removed methods: every export route, every job-tracking route, bulk
|
|
1360
|
+
// import, validate, template — none of those endpoints exist in the
|
|
1361
|
+
// v1.5.0-ce gateway. We keep the shape so old callers get a clear error
|
|
1362
|
+
// instead of a silent 404.
|
|
1363
|
+
// ---------------------------------------------------------------------
|
|
1364
|
+
async export(_options) {
|
|
1365
|
+
throw new ValidationError(`export() ${NOT_SUPPORTED_MSG}`);
|
|
1103
1366
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
*/
|
|
1107
|
-
async getImportStatus(jobId) {
|
|
1108
|
-
const { data } = await this.synapCores._getHttpClient().get(`/import/${jobId}/status`);
|
|
1109
|
-
return {
|
|
1110
|
-
id: data.id || jobId,
|
|
1111
|
-
status: data.status,
|
|
1112
|
-
progress: data.progress || 0,
|
|
1113
|
-
phase: data.phase,
|
|
1114
|
-
rows_processed: data.rows_processed,
|
|
1115
|
-
eta_ms: data.eta_ms || data.estimated_time_remaining_ms,
|
|
1116
|
-
error: data.error,
|
|
1117
|
-
started_at: data.started_at ? new Date(data.started_at) : void 0,
|
|
1118
|
-
completed_at: data.completed_at ? new Date(data.completed_at) : void 0
|
|
1119
|
-
};
|
|
1367
|
+
async getImportStatus(_jobId) {
|
|
1368
|
+
throw new ValidationError(`getImportStatus() ${NOT_SUPPORTED_MSG}`);
|
|
1120
1369
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
*/
|
|
1124
|
-
async getExportStatus(jobId) {
|
|
1125
|
-
const { data } = await this.synapCores._getHttpClient().get(`/export/${jobId}/status`);
|
|
1126
|
-
return {
|
|
1127
|
-
id: data.id || jobId,
|
|
1128
|
-
status: data.status,
|
|
1129
|
-
progress: data.progress || 0,
|
|
1130
|
-
phase: data.phase,
|
|
1131
|
-
rows_exported: data.rows_exported,
|
|
1132
|
-
eta_ms: data.eta_ms || data.estimated_time_remaining_ms,
|
|
1133
|
-
error: data.error,
|
|
1134
|
-
started_at: data.started_at ? new Date(data.started_at) : void 0,
|
|
1135
|
-
completed_at: data.completed_at ? new Date(data.completed_at) : void 0
|
|
1136
|
-
};
|
|
1370
|
+
async getExportStatus(_jobId) {
|
|
1371
|
+
throw new ValidationError(`getExportStatus() ${NOT_SUPPORTED_MSG}`);
|
|
1137
1372
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
*/
|
|
1141
|
-
async cancelImport(jobId) {
|
|
1142
|
-
await this.synapCores._getHttpClient().post(`/import/${jobId}/cancel`);
|
|
1373
|
+
async cancelImport(_jobId) {
|
|
1374
|
+
throw new ValidationError(`cancelImport() ${NOT_SUPPORTED_MSG}`);
|
|
1143
1375
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
*/
|
|
1147
|
-
async cancelExport(jobId) {
|
|
1148
|
-
await this.synapCores._getHttpClient().post(`/export/${jobId}/cancel`);
|
|
1376
|
+
async cancelExport(_jobId) {
|
|
1377
|
+
throw new ValidationError(`cancelExport() ${NOT_SUPPORTED_MSG}`);
|
|
1149
1378
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
*/
|
|
1153
|
-
async bulkImport(options) {
|
|
1154
|
-
const { data } = await this.synapCores._getHttpClient().post("/import/bulk", {
|
|
1155
|
-
jobs: options.jobs,
|
|
1156
|
-
parallel: options.parallel || false,
|
|
1157
|
-
stop_on_error: options.stop_on_error || false
|
|
1158
|
-
});
|
|
1159
|
-
return {
|
|
1160
|
-
id: data.id || data.bulk_id,
|
|
1161
|
-
success: data.success,
|
|
1162
|
-
results: data.results || [],
|
|
1163
|
-
total_rows_imported: data.total_rows_imported || 0,
|
|
1164
|
-
total_duration_ms: data.total_duration_ms || data.took_ms || 0
|
|
1165
|
-
};
|
|
1379
|
+
async bulkImport(_options) {
|
|
1380
|
+
throw new ValidationError(`bulkImport() ${NOT_SUPPORTED_MSG}`);
|
|
1166
1381
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
*/
|
|
1170
|
-
async validateData(options) {
|
|
1171
|
-
const { data } = await this.synapCores._getHttpClient().post("/import/validate", {
|
|
1172
|
-
table: options.table,
|
|
1173
|
-
data: options.data,
|
|
1174
|
-
mode: options.mode || "strict",
|
|
1175
|
-
check_foreign_keys: options.check_foreign_keys,
|
|
1176
|
-
check_unique: options.check_unique
|
|
1177
|
-
});
|
|
1178
|
-
return {
|
|
1179
|
-
is_valid: data.is_valid || data.valid,
|
|
1180
|
-
errors: data.errors || [],
|
|
1181
|
-
warnings: data.warnings || [],
|
|
1182
|
-
rows_validated: data.rows_validated || options.data.length
|
|
1183
|
-
};
|
|
1382
|
+
async validateData(_options) {
|
|
1383
|
+
throw new ValidationError(`validateData() ${NOT_SUPPORTED_MSG}`);
|
|
1184
1384
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
*/
|
|
1188
|
-
async getImportTemplate(tableName, format = "csv") {
|
|
1189
|
-
const { data } = await this.synapCores._getHttpClient().get(
|
|
1190
|
-
`/import/template/${tableName}?format=${format}`
|
|
1191
|
-
);
|
|
1192
|
-
return data.template || data.content || data;
|
|
1385
|
+
async getImportTemplate(_tableName, _format = "csv") {
|
|
1386
|
+
throw new ValidationError(`getImportTemplate() ${NOT_SUPPORTED_MSG}`);
|
|
1193
1387
|
}
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
*/
|
|
1197
|
-
async listJobs(options = {}) {
|
|
1198
|
-
const params = new URLSearchParams();
|
|
1199
|
-
if (options.type) params.append("type", options.type);
|
|
1200
|
-
if (options.status) params.append("status", options.status);
|
|
1201
|
-
if (options.limit) params.append("limit", options.limit.toString());
|
|
1202
|
-
const { data } = await this.synapCores._getHttpClient().get(
|
|
1203
|
-
`/import/jobs?${params.toString()}`
|
|
1204
|
-
);
|
|
1205
|
-
return (data.jobs || data).map((job) => ({
|
|
1206
|
-
id: job.id,
|
|
1207
|
-
status: job.status,
|
|
1208
|
-
progress: job.progress || 0,
|
|
1209
|
-
phase: job.phase,
|
|
1210
|
-
rows_processed: job.rows_processed,
|
|
1211
|
-
rows_exported: job.rows_exported,
|
|
1212
|
-
eta_ms: job.eta_ms,
|
|
1213
|
-
error: job.error,
|
|
1214
|
-
started_at: job.started_at ? new Date(job.started_at) : void 0,
|
|
1215
|
-
completed_at: job.completed_at ? new Date(job.completed_at) : void 0
|
|
1216
|
-
}));
|
|
1388
|
+
async listJobs(_options = {}) {
|
|
1389
|
+
throw new ValidationError(`listJobs() ${NOT_SUPPORTED_MSG}`);
|
|
1217
1390
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
*/
|
|
1221
|
-
async downloadExport(jobId) {
|
|
1222
|
-
const { data } = await this.synapCores._getHttpClient().get(`/export/${jobId}/download`, {
|
|
1223
|
-
responseType: "arraybuffer"
|
|
1224
|
-
});
|
|
1225
|
-
return Buffer.from(data);
|
|
1391
|
+
async downloadExport(_jobId) {
|
|
1392
|
+
throw new ValidationError(`downloadExport() ${NOT_SUPPORTED_MSG}`);
|
|
1226
1393
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
*/
|
|
1230
|
-
async streamImport(options, onProgress) {
|
|
1231
|
-
const result = await this.import(options);
|
|
1232
|
-
const jobId = result.id;
|
|
1233
|
-
if (onProgress) {
|
|
1234
|
-
const pollInterval = setInterval(async () => {
|
|
1235
|
-
try {
|
|
1236
|
-
const status = await this.getImportStatus(jobId);
|
|
1237
|
-
onProgress(status);
|
|
1238
|
-
if (status.status === "completed" || status.status === "failed" || status.status === "cancelled") {
|
|
1239
|
-
clearInterval(pollInterval);
|
|
1240
|
-
}
|
|
1241
|
-
} catch (error) {
|
|
1242
|
-
clearInterval(pollInterval);
|
|
1243
|
-
}
|
|
1244
|
-
}, 1e3);
|
|
1245
|
-
}
|
|
1246
|
-
return result;
|
|
1394
|
+
async streamImport(options, _onProgress) {
|
|
1395
|
+
return this.import(options);
|
|
1247
1396
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
*/
|
|
1251
|
-
async streamExport(options, onProgress) {
|
|
1252
|
-
const result = await this.export(options);
|
|
1253
|
-
const jobId = result.id;
|
|
1254
|
-
if (onProgress) {
|
|
1255
|
-
const pollInterval = setInterval(async () => {
|
|
1256
|
-
try {
|
|
1257
|
-
const status = await this.getExportStatus(jobId);
|
|
1258
|
-
onProgress(status);
|
|
1259
|
-
if (status.status === "completed" || status.status === "failed" || status.status === "cancelled") {
|
|
1260
|
-
clearInterval(pollInterval);
|
|
1261
|
-
}
|
|
1262
|
-
} catch (error) {
|
|
1263
|
-
clearInterval(pollInterval);
|
|
1264
|
-
}
|
|
1265
|
-
}, 1e3);
|
|
1266
|
-
}
|
|
1267
|
-
return result;
|
|
1397
|
+
async streamExport(_options, _onProgress) {
|
|
1398
|
+
throw new ValidationError(`streamExport() ${NOT_SUPPORTED_MSG}`);
|
|
1268
1399
|
}
|
|
1269
1400
|
};
|
|
1270
1401
|
|
|
1271
1402
|
// src/integrations.ts
|
|
1403
|
+
var NOT_SUPPORTED = "not supported in v1.5.0-ce \u2014 see SynapCores integrations API";
|
|
1272
1404
|
var IntegrationClient = class {
|
|
1273
1405
|
constructor(synapCores) {
|
|
1274
1406
|
this.synapCores = synapCores;
|
|
1275
1407
|
}
|
|
1276
1408
|
/**
|
|
1277
|
-
* Create a new integration
|
|
1409
|
+
* Create a new integration. Gateway v1.5.0-ce keys integrations by
|
|
1410
|
+
* `type` (slug). The body still carries the type so old call sites
|
|
1411
|
+
* remain backwards compatible.
|
|
1278
1412
|
*/
|
|
1279
1413
|
async create(options) {
|
|
1280
1414
|
const { data } = await this.synapCores._getHttpClient().post("/integrations", {
|
|
@@ -1288,7 +1422,7 @@ var IntegrationClient = class {
|
|
|
1288
1422
|
return this.mapIntegration(data);
|
|
1289
1423
|
}
|
|
1290
1424
|
/**
|
|
1291
|
-
* List integrations
|
|
1425
|
+
* List integrations (optional filters).
|
|
1292
1426
|
*/
|
|
1293
1427
|
async list(options = {}) {
|
|
1294
1428
|
const params = new URLSearchParams();
|
|
@@ -1300,79 +1434,41 @@ var IntegrationClient = class {
|
|
|
1300
1434
|
if (options.tags && options.tags.length > 0) {
|
|
1301
1435
|
params.append("tags", options.tags.join(","));
|
|
1302
1436
|
}
|
|
1437
|
+
const qs = params.toString();
|
|
1303
1438
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
1304
|
-
`/integrations
|
|
1439
|
+
`/integrations${qs ? `?${qs}` : ""}`
|
|
1305
1440
|
);
|
|
1306
|
-
return (data.integrations || data).map(
|
|
1441
|
+
return (data.integrations || data || []).map(
|
|
1307
1442
|
(integration) => this.mapIntegration(integration)
|
|
1308
1443
|
);
|
|
1309
1444
|
}
|
|
1310
1445
|
/**
|
|
1311
|
-
* Get a specific integration by
|
|
1446
|
+
* Get a specific integration by type-slug.
|
|
1312
1447
|
*/
|
|
1313
|
-
async get(
|
|
1314
|
-
const { data } = await this.synapCores._getHttpClient().get(
|
|
1448
|
+
async get(type) {
|
|
1449
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1450
|
+
`/integrations/${type}`
|
|
1451
|
+
);
|
|
1315
1452
|
return this.mapIntegration(data);
|
|
1316
1453
|
}
|
|
1317
1454
|
/**
|
|
1318
|
-
* Update an existing integration
|
|
1455
|
+
* Update an existing integration by type-slug.
|
|
1319
1456
|
*/
|
|
1320
|
-
async update(
|
|
1457
|
+
async update(type, updates) {
|
|
1321
1458
|
const { data } = await this.synapCores._getHttpClient().put(
|
|
1322
|
-
`/integrations/${
|
|
1459
|
+
`/integrations/${type}`,
|
|
1323
1460
|
updates
|
|
1324
1461
|
);
|
|
1325
1462
|
return this.mapIntegration(data);
|
|
1326
1463
|
}
|
|
1327
1464
|
/**
|
|
1328
|
-
* Delete an integration
|
|
1329
|
-
*/
|
|
1330
|
-
async delete(id) {
|
|
1331
|
-
await this.synapCores._getHttpClient().delete(`/integrations/${id}`);
|
|
1332
|
-
}
|
|
1333
|
-
/**
|
|
1334
|
-
* Activate an integration
|
|
1335
|
-
*/
|
|
1336
|
-
async activate(id) {
|
|
1337
|
-
const { data } = await this.synapCores._getHttpClient().post(
|
|
1338
|
-
`/integrations/${id}/activate`
|
|
1339
|
-
);
|
|
1340
|
-
return this.mapIntegration(data);
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Deactivate an integration
|
|
1344
|
-
*/
|
|
1345
|
-
async deactivate(id) {
|
|
1346
|
-
const { data } = await this.synapCores._getHttpClient().post(
|
|
1347
|
-
`/integrations/${id}/deactivate`
|
|
1348
|
-
);
|
|
1349
|
-
return this.mapIntegration(data);
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* Execute an integration
|
|
1465
|
+
* Delete an integration by type-slug.
|
|
1353
1466
|
*/
|
|
1354
|
-
async
|
|
1355
|
-
|
|
1356
|
-
`/integrations/${options.integration}/execute`,
|
|
1357
|
-
{
|
|
1358
|
-
payload: options.payload,
|
|
1359
|
-
config_override: options.config_override,
|
|
1360
|
-
sync: options.sync !== false
|
|
1361
|
-
}
|
|
1362
|
-
);
|
|
1363
|
-
return {
|
|
1364
|
-
id: data.id || data.execution_id,
|
|
1365
|
-
success: data.success,
|
|
1366
|
-
response: data.response,
|
|
1367
|
-
status_code: data.status_code,
|
|
1368
|
-
error: data.error,
|
|
1369
|
-
execution_time_ms: data.execution_time_ms || data.took_ms || 0,
|
|
1370
|
-
retry_count: data.retry_count || 0,
|
|
1371
|
-
executed_at: data.executed_at ? new Date(data.executed_at) : /* @__PURE__ */ new Date()
|
|
1372
|
-
};
|
|
1467
|
+
async delete(type) {
|
|
1468
|
+
await this.synapCores._getHttpClient().delete(`/integrations/${type}`);
|
|
1373
1469
|
}
|
|
1374
1470
|
/**
|
|
1375
|
-
* Test an integration
|
|
1471
|
+
* Test an integration connection.
|
|
1376
1472
|
*/
|
|
1377
1473
|
async test(options) {
|
|
1378
1474
|
const { data } = await this.synapCores._getHttpClient().post(
|
|
@@ -1391,160 +1487,88 @@ var IntegrationClient = class {
|
|
|
1391
1487
|
};
|
|
1392
1488
|
}
|
|
1393
1489
|
/**
|
|
1394
|
-
*
|
|
1490
|
+
* List supported integration types and their config schemas.
|
|
1395
1491
|
*/
|
|
1396
|
-
async
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
return (data.executions || data).map((exec) => ({
|
|
1404
|
-
id: exec.id || exec.execution_id,
|
|
1405
|
-
success: exec.success,
|
|
1406
|
-
response: exec.response,
|
|
1407
|
-
status_code: exec.status_code,
|
|
1408
|
-
error: exec.error,
|
|
1409
|
-
execution_time_ms: exec.execution_time_ms || exec.took_ms || 0,
|
|
1410
|
-
retry_count: exec.retry_count || 0,
|
|
1411
|
-
executed_at: exec.executed_at ? new Date(exec.executed_at) : /* @__PURE__ */ new Date()
|
|
1492
|
+
async listTypes() {
|
|
1493
|
+
const { data } = await this.synapCores._getHttpClient().get("/integrations/types");
|
|
1494
|
+
return (data.types ?? data ?? []).map((t) => ({
|
|
1495
|
+
type: t.type ?? t.name,
|
|
1496
|
+
display_name: t.display_name ?? t.label,
|
|
1497
|
+
description: t.description,
|
|
1498
|
+
config_schema: t.config_schema ?? t.schema
|
|
1412
1499
|
}));
|
|
1413
1500
|
}
|
|
1414
1501
|
/**
|
|
1415
|
-
* Get
|
|
1502
|
+
* Get the integrations audit trail.
|
|
1416
1503
|
*/
|
|
1417
|
-
async
|
|
1504
|
+
async audit(options = {}) {
|
|
1505
|
+
const params = new URLSearchParams();
|
|
1506
|
+
if (options.limit) params.append("limit", options.limit.toString());
|
|
1507
|
+
if (options.type) params.append("type", options.type);
|
|
1508
|
+
const qs = params.toString();
|
|
1418
1509
|
const { data } = await this.synapCores._getHttpClient().get(
|
|
1419
|
-
`/integrations
|
|
1510
|
+
`/integrations/audit${qs ? `?${qs}` : ""}`
|
|
1420
1511
|
);
|
|
1421
|
-
return {
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
last_success_at: data.last_success_at ? new Date(data.last_success_at) : void 0,
|
|
1430
|
-
last_error_at: data.last_error_at ? new Date(data.last_error_at) : void 0
|
|
1431
|
-
};
|
|
1512
|
+
return (data.entries ?? data.audit ?? data ?? []).map((row) => ({
|
|
1513
|
+
id: row.id,
|
|
1514
|
+
type: row.type ?? row.integration_type,
|
|
1515
|
+
action: row.action ?? row.event,
|
|
1516
|
+
user: row.user ?? row.actor,
|
|
1517
|
+
timestamp: new Date(row.timestamp ?? row.created_at ?? Date.now()),
|
|
1518
|
+
details: row.details ?? row.data
|
|
1519
|
+
}));
|
|
1432
1520
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
event: options.event,
|
|
1440
|
-
url: options.url,
|
|
1441
|
-
secret: options.secret,
|
|
1442
|
-
activate: options.activate !== false
|
|
1443
|
-
});
|
|
1444
|
-
return {
|
|
1445
|
-
id: data.id,
|
|
1446
|
-
integration_id: data.integration_id,
|
|
1447
|
-
event: data.event,
|
|
1448
|
-
url: data.url,
|
|
1449
|
-
active: data.active,
|
|
1450
|
-
secret: data.secret,
|
|
1451
|
-
created_at: new Date(data.created_at)
|
|
1452
|
-
};
|
|
1521
|
+
// -------------------------------------------------------------------
|
|
1522
|
+
// Methods removed from v1.5.0-ce (gateway has no matching route).
|
|
1523
|
+
// We keep the names for backwards-compat but throw a clear error.
|
|
1524
|
+
// -------------------------------------------------------------------
|
|
1525
|
+
async activate(_type) {
|
|
1526
|
+
throw new ValidationError(`integrations.activate() ${NOT_SUPPORTED} \u2014 use update() with {activate:true}`);
|
|
1453
1527
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
*/
|
|
1457
|
-
async listWebhooks(integrationId) {
|
|
1458
|
-
const { data } = await this.synapCores._getHttpClient().get(
|
|
1459
|
-
`/integrations/${integrationId}/webhooks`
|
|
1460
|
-
);
|
|
1461
|
-
return (data.webhooks || data).map((webhook) => ({
|
|
1462
|
-
id: webhook.id,
|
|
1463
|
-
integration_id: webhook.integration_id,
|
|
1464
|
-
event: webhook.event,
|
|
1465
|
-
url: webhook.url,
|
|
1466
|
-
active: webhook.active,
|
|
1467
|
-
secret: webhook.secret,
|
|
1468
|
-
created_at: new Date(webhook.created_at)
|
|
1469
|
-
}));
|
|
1528
|
+
async deactivate(_type) {
|
|
1529
|
+
throw new ValidationError(`integrations.deactivate() ${NOT_SUPPORTED} \u2014 use update() with {activate:false}`);
|
|
1470
1530
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
*/
|
|
1474
|
-
async deleteWebhook(webhookId) {
|
|
1475
|
-
await this.synapCores._getHttpClient().delete(`/integrations/webhooks/${webhookId}`);
|
|
1531
|
+
async execute(_options) {
|
|
1532
|
+
throw new ValidationError(`integrations.execute() ${NOT_SUPPORTED}`);
|
|
1476
1533
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
*/
|
|
1480
|
-
async getEvents(integrationId, options = {}) {
|
|
1481
|
-
const params = new URLSearchParams();
|
|
1482
|
-
if (options.limit) params.append("limit", options.limit.toString());
|
|
1483
|
-
if (options.status) params.append("status", options.status);
|
|
1484
|
-
const { data } = await this.synapCores._getHttpClient().get(
|
|
1485
|
-
`/integrations/${integrationId}/events?${params.toString()}`
|
|
1486
|
-
);
|
|
1487
|
-
return (data.events || data).map((event) => ({
|
|
1488
|
-
id: event.id,
|
|
1489
|
-
integration_id: event.integration_id,
|
|
1490
|
-
event: event.event,
|
|
1491
|
-
data: event.data,
|
|
1492
|
-
timestamp: new Date(event.timestamp),
|
|
1493
|
-
status: event.status,
|
|
1494
|
-
error: event.error
|
|
1495
|
-
}));
|
|
1534
|
+
async getExecutionHistory(_type, _options = {}) {
|
|
1535
|
+
throw new ValidationError(`integrations.getExecutionHistory() ${NOT_SUPPORTED}`);
|
|
1496
1536
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
*/
|
|
1500
|
-
async getLogs(integrationId, options = {}) {
|
|
1501
|
-
const params = new URLSearchParams();
|
|
1502
|
-
if (options.limit) params.append("limit", options.limit.toString());
|
|
1503
|
-
if (options.level) params.append("level", options.level);
|
|
1504
|
-
const { data } = await this.synapCores._getHttpClient().get(
|
|
1505
|
-
`/integrations/${integrationId}/logs?${params.toString()}`
|
|
1506
|
-
);
|
|
1507
|
-
return (data.logs || data).map((log) => ({
|
|
1508
|
-
id: log.id,
|
|
1509
|
-
integration_id: log.integration_id,
|
|
1510
|
-
level: log.level,
|
|
1511
|
-
message: log.message,
|
|
1512
|
-
data: log.data,
|
|
1513
|
-
timestamp: new Date(log.timestamp)
|
|
1514
|
-
}));
|
|
1537
|
+
async getStats(_type) {
|
|
1538
|
+
throw new ValidationError(`integrations.getStats() ${NOT_SUPPORTED}`);
|
|
1515
1539
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
async
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
};
|
|
1540
|
+
async createWebhook(_options) {
|
|
1541
|
+
throw new ValidationError(`integrations.createWebhook() ${NOT_SUPPORTED}`);
|
|
1542
|
+
}
|
|
1543
|
+
async listWebhooks(_type) {
|
|
1544
|
+
throw new ValidationError(`integrations.listWebhooks() ${NOT_SUPPORTED}`);
|
|
1545
|
+
}
|
|
1546
|
+
async deleteWebhook(_webhookId) {
|
|
1547
|
+
throw new ValidationError(`integrations.deleteWebhook() ${NOT_SUPPORTED}`);
|
|
1548
|
+
}
|
|
1549
|
+
async getEvents(_type, _options = {}) {
|
|
1550
|
+
throw new ValidationError(`integrations.getEvents() ${NOT_SUPPORTED}`);
|
|
1551
|
+
}
|
|
1552
|
+
async getLogs(_type, _options = {}) {
|
|
1553
|
+
throw new ValidationError(`integrations.getLogs() ${NOT_SUPPORTED}`);
|
|
1554
|
+
}
|
|
1555
|
+
async retryExecution(_executionId) {
|
|
1556
|
+
throw new ValidationError(`integrations.retryExecution() ${NOT_SUPPORTED}`);
|
|
1533
1557
|
}
|
|
1534
1558
|
/**
|
|
1535
|
-
* Map raw integration data to Integration type
|
|
1559
|
+
* Map raw integration data to Integration type.
|
|
1536
1560
|
*/
|
|
1537
1561
|
mapIntegration(data) {
|
|
1538
1562
|
return {
|
|
1539
|
-
id: data.id,
|
|
1540
|
-
name: data.name,
|
|
1563
|
+
id: data.id ?? data.type,
|
|
1564
|
+
name: data.name ?? data.type,
|
|
1541
1565
|
type: data.type,
|
|
1542
|
-
status: data.status,
|
|
1543
|
-
config: data.config,
|
|
1566
|
+
status: data.status ?? (data.active ? "active" : "inactive"),
|
|
1567
|
+
config: data.config ?? {},
|
|
1544
1568
|
description: data.description,
|
|
1545
1569
|
tags: data.tags || [],
|
|
1546
|
-
created_at: new Date(data.created_at),
|
|
1547
|
-
updated_at: new Date(data.updated_at),
|
|
1570
|
+
created_at: new Date(data.created_at ?? Date.now()),
|
|
1571
|
+
updated_at: new Date(data.updated_at ?? data.created_at ?? Date.now()),
|
|
1548
1572
|
last_success_at: data.last_success_at ? new Date(data.last_success_at) : void 0,
|
|
1549
1573
|
last_error: data.last_error,
|
|
1550
1574
|
execution_count: data.execution_count
|
|
@@ -1677,18 +1701,9 @@ var BackupClient = class {
|
|
|
1677
1701
|
completed_at: data.completed_at ? new Date(data.completed_at) : void 0
|
|
1678
1702
|
};
|
|
1679
1703
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
async cancelBackup(backupId) {
|
|
1684
|
-
await this.synapCores._getHttpClient().post(`/backups/${backupId}/cancel`);
|
|
1685
|
-
}
|
|
1686
|
-
/**
|
|
1687
|
-
* Cancel a restore in progress
|
|
1688
|
-
*/
|
|
1689
|
-
async cancelRestore(restoreId) {
|
|
1690
|
-
await this.synapCores._getHttpClient().post(`/backups/restore/${restoreId}/cancel`);
|
|
1691
|
-
}
|
|
1704
|
+
// cancelBackup() / cancelRestore() removed — gateway v1.5.0-ce has no
|
|
1705
|
+
// /backups/:id/cancel or /backups/restore/:id/cancel routes. Use
|
|
1706
|
+
// delete() to clean up an aborted backup record.
|
|
1692
1707
|
/**
|
|
1693
1708
|
* Download a backup file
|
|
1694
1709
|
*/
|
|
@@ -1823,155 +1838,967 @@ var BackupClient = class {
|
|
|
1823
1838
|
};
|
|
1824
1839
|
}
|
|
1825
1840
|
/**
|
|
1826
|
-
* Deactivate a schedule
|
|
1841
|
+
* Deactivate a schedule
|
|
1842
|
+
*/
|
|
1843
|
+
async deactivateSchedule(scheduleId) {
|
|
1844
|
+
const { data } = await this.synapCores._getHttpClient().post(
|
|
1845
|
+
`/backups/schedules/${scheduleId}/deactivate`
|
|
1846
|
+
);
|
|
1847
|
+
return {
|
|
1848
|
+
id: data.id,
|
|
1849
|
+
name: data.name,
|
|
1850
|
+
cron: data.cron,
|
|
1851
|
+
backup_options: data.backup_options,
|
|
1852
|
+
active: data.active,
|
|
1853
|
+
last_run_at: data.last_run_at ? new Date(data.last_run_at) : void 0,
|
|
1854
|
+
next_run_at: data.next_run_at ? new Date(data.next_run_at) : void 0,
|
|
1855
|
+
created_at: new Date(data.created_at),
|
|
1856
|
+
tags: data.tags || []
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
// getMetrics() removed — gateway v1.5.0-ce has no /backups/metrics route.
|
|
1860
|
+
// Aggregate metrics can be derived client-side from list().
|
|
1861
|
+
/**
|
|
1862
|
+
* Map raw backup data to Backup type
|
|
1863
|
+
*/
|
|
1864
|
+
mapBackup(data) {
|
|
1865
|
+
return {
|
|
1866
|
+
id: data.id,
|
|
1867
|
+
name: data.name,
|
|
1868
|
+
description: data.description,
|
|
1869
|
+
type: data.type,
|
|
1870
|
+
status: data.status,
|
|
1871
|
+
size_bytes: data.size_bytes,
|
|
1872
|
+
compressed_size_bytes: data.compressed_size_bytes,
|
|
1873
|
+
table_count: data.table_count,
|
|
1874
|
+
created_at: new Date(data.created_at),
|
|
1875
|
+
completed_at: data.completed_at ? new Date(data.completed_at) : void 0,
|
|
1876
|
+
duration_ms: data.duration_ms || data.took_ms,
|
|
1877
|
+
storage: data.storage,
|
|
1878
|
+
storage_path: data.storage_path,
|
|
1879
|
+
encrypted: data.encrypted || false,
|
|
1880
|
+
tags: data.tags || [],
|
|
1881
|
+
parent_backup_id: data.parent_backup_id,
|
|
1882
|
+
error: data.error
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1887
|
+
// src/graph.ts
|
|
1888
|
+
var GraphNodeApi = class {
|
|
1889
|
+
constructor(synapCores) {
|
|
1890
|
+
this.synapCores = synapCores;
|
|
1891
|
+
}
|
|
1892
|
+
async create(label, props = {}) {
|
|
1893
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/nodes", {
|
|
1894
|
+
label,
|
|
1895
|
+
properties: props
|
|
1896
|
+
});
|
|
1897
|
+
return this.normalize(data);
|
|
1898
|
+
}
|
|
1899
|
+
async get(id) {
|
|
1900
|
+
const { data } = await this.synapCores._getHttpClient().get(`/graph/nodes/${id}`);
|
|
1901
|
+
return this.normalize(data);
|
|
1902
|
+
}
|
|
1903
|
+
async update(id, patch) {
|
|
1904
|
+
const { data } = await this.synapCores._getHttpClient().patch(
|
|
1905
|
+
`/graph/nodes/${id}`,
|
|
1906
|
+
{ properties: patch }
|
|
1907
|
+
);
|
|
1908
|
+
return this.normalize(data);
|
|
1909
|
+
}
|
|
1910
|
+
async delete(id) {
|
|
1911
|
+
await this.synapCores._getHttpClient().delete(`/graph/nodes/${id}`);
|
|
1912
|
+
}
|
|
1913
|
+
async neighbors(id, opts = {}) {
|
|
1914
|
+
const params = new URLSearchParams();
|
|
1915
|
+
if (opts.direction) params.append("direction", opts.direction);
|
|
1916
|
+
if (opts.limit !== void 0) params.append("limit", String(opts.limit));
|
|
1917
|
+
if (opts.type) params.append("type", opts.type);
|
|
1918
|
+
const qs = params.toString();
|
|
1919
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
1920
|
+
`/graph/nodes/${id}/neighbors${qs ? `?${qs}` : ""}`
|
|
1921
|
+
);
|
|
1922
|
+
return {
|
|
1923
|
+
nodes: (data.nodes ?? []).map((n) => this.normalize(n)),
|
|
1924
|
+
edges: (data.edges ?? []).map((e) => this.normalizeEdge(e))
|
|
1925
|
+
};
|
|
1926
|
+
}
|
|
1927
|
+
normalize(data) {
|
|
1928
|
+
return {
|
|
1929
|
+
id: String(data.id ?? data.node_id ?? ""),
|
|
1930
|
+
label: data.label,
|
|
1931
|
+
labels: data.labels,
|
|
1932
|
+
properties: data.properties ?? data.props ?? {}
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
normalizeEdge(data) {
|
|
1936
|
+
return {
|
|
1937
|
+
id: data.id !== void 0 ? String(data.id) : void 0,
|
|
1938
|
+
from: String(data.from ?? data.source ?? ""),
|
|
1939
|
+
to: String(data.to ?? data.target ?? ""),
|
|
1940
|
+
type: data.type ?? data.label ?? "",
|
|
1941
|
+
properties: data.properties ?? data.props ?? {}
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
var GraphEdgeApi = class {
|
|
1946
|
+
constructor(synapCores) {
|
|
1947
|
+
this.synapCores = synapCores;
|
|
1948
|
+
}
|
|
1949
|
+
async create(from, to, type, props = {}) {
|
|
1950
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/edges", {
|
|
1951
|
+
from,
|
|
1952
|
+
to,
|
|
1953
|
+
type,
|
|
1954
|
+
properties: props
|
|
1955
|
+
});
|
|
1956
|
+
return {
|
|
1957
|
+
id: data.id !== void 0 ? String(data.id) : void 0,
|
|
1958
|
+
from: String(data.from ?? from),
|
|
1959
|
+
to: String(data.to ?? to),
|
|
1960
|
+
type: data.type ?? type,
|
|
1961
|
+
properties: data.properties ?? props
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
var GraphIndexesApi = class {
|
|
1966
|
+
constructor(synapCores) {
|
|
1967
|
+
this.synapCores = synapCores;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Create a graph index (label/property index, fulltext, or vector
|
|
1971
|
+
* depending on the gateway's accepted DDL strings).
|
|
1972
|
+
*/
|
|
1973
|
+
async create(stmt) {
|
|
1974
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/indexes", {
|
|
1975
|
+
statement: stmt
|
|
1976
|
+
});
|
|
1977
|
+
return { name: data.name ?? data.index_name, raw: data };
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
var GraphAlgorithmsApi = class {
|
|
1981
|
+
constructor(synapCores) {
|
|
1982
|
+
this.synapCores = synapCores;
|
|
1983
|
+
}
|
|
1984
|
+
async run(name, opts = {}) {
|
|
1985
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/algorithms", {
|
|
1986
|
+
algorithm: name,
|
|
1987
|
+
...opts
|
|
1988
|
+
});
|
|
1989
|
+
return {
|
|
1990
|
+
algorithm: name,
|
|
1991
|
+
results: data.results ?? data.result ?? data,
|
|
1992
|
+
stats: data.stats,
|
|
1993
|
+
execution_time_ms: data.execution_time_ms ?? data.took_ms
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
};
|
|
1997
|
+
var GraphsApi = class {
|
|
1998
|
+
constructor(synapCores) {
|
|
1999
|
+
this.synapCores = synapCores;
|
|
2000
|
+
}
|
|
2001
|
+
async list() {
|
|
2002
|
+
const { data } = await this.synapCores._getHttpClient().get("/graphs");
|
|
2003
|
+
return (data.graphs ?? data ?? []).map((g) => this.normalize(g));
|
|
2004
|
+
}
|
|
2005
|
+
async create(name, opts = {}) {
|
|
2006
|
+
const { data } = await this.synapCores._getHttpClient().post("/graphs", {
|
|
2007
|
+
name,
|
|
2008
|
+
description: opts.description
|
|
2009
|
+
});
|
|
2010
|
+
return this.normalize(data);
|
|
2011
|
+
}
|
|
2012
|
+
async get(name) {
|
|
2013
|
+
const { data } = await this.synapCores._getHttpClient().get(`/graphs/${name}`);
|
|
2014
|
+
return this.normalize(data);
|
|
2015
|
+
}
|
|
2016
|
+
async delete(name) {
|
|
2017
|
+
await this.synapCores._getHttpClient().delete(`/graphs/${name}`);
|
|
2018
|
+
}
|
|
2019
|
+
normalize(data) {
|
|
2020
|
+
return {
|
|
2021
|
+
name: data.name,
|
|
2022
|
+
node_count: data.node_count ?? data.nodes,
|
|
2023
|
+
edge_count: data.edge_count ?? data.edges,
|
|
2024
|
+
created_at: data.created_at ? new Date(data.created_at) : void 0,
|
|
2025
|
+
description: data.description
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
var GraphClient = class {
|
|
2030
|
+
constructor(synapCores) {
|
|
2031
|
+
this.synapCores = synapCores;
|
|
2032
|
+
this.nodes = new GraphNodeApi(synapCores);
|
|
2033
|
+
this.edges = new GraphEdgeApi(synapCores);
|
|
2034
|
+
this.indexes = new GraphIndexesApi(synapCores);
|
|
2035
|
+
this.algorithms = new GraphAlgorithmsApi(synapCores);
|
|
2036
|
+
this.graphs = new GraphsApi(synapCores);
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Run a Cypher / MATCH query.
|
|
2040
|
+
*/
|
|
2041
|
+
async cypher(query, params = {}, graph) {
|
|
2042
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/match", {
|
|
2043
|
+
query,
|
|
2044
|
+
params,
|
|
2045
|
+
graph
|
|
2046
|
+
});
|
|
2047
|
+
return this.normalizeCypher(data);
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Profile a Cypher / MATCH query (returns plan/profile metadata).
|
|
2051
|
+
*/
|
|
2052
|
+
async cypherProfile(query, params = {}, graph) {
|
|
2053
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/match/profile", {
|
|
2054
|
+
query,
|
|
2055
|
+
params,
|
|
2056
|
+
graph
|
|
2057
|
+
});
|
|
2058
|
+
return {
|
|
2059
|
+
...this.normalizeCypher(data),
|
|
2060
|
+
plan: data.plan,
|
|
2061
|
+
profile: data.profile ?? data.profile_data
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Run LLM-based extraction over text into the given graph.
|
|
2066
|
+
*/
|
|
2067
|
+
async extract(req, graphName) {
|
|
2068
|
+
const body = typeof req === "string" ? { text: req, graph: graphName } : req;
|
|
2069
|
+
const { data } = await this.synapCores._getHttpClient().post("/graph/extract", body);
|
|
2070
|
+
return {
|
|
2071
|
+
nodes: (data.nodes ?? []).map((n) => ({
|
|
2072
|
+
id: String(n.id ?? ""),
|
|
2073
|
+
label: n.label,
|
|
2074
|
+
labels: n.labels,
|
|
2075
|
+
properties: n.properties ?? n.props ?? {}
|
|
2076
|
+
})),
|
|
2077
|
+
edges: (data.edges ?? []).map((e) => ({
|
|
2078
|
+
id: e.id !== void 0 ? String(e.id) : void 0,
|
|
2079
|
+
from: String(e.from ?? e.source ?? ""),
|
|
2080
|
+
to: String(e.to ?? e.target ?? ""),
|
|
2081
|
+
type: e.type ?? e.label ?? "",
|
|
2082
|
+
properties: e.properties ?? e.props ?? {}
|
|
2083
|
+
})),
|
|
2084
|
+
spans: data.spans
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
normalizeCypher(data) {
|
|
2088
|
+
return {
|
|
2089
|
+
columns: data.columns ?? data.fields,
|
|
2090
|
+
rows: data.rows ?? data.values ?? [],
|
|
2091
|
+
records: data.records ?? data.results,
|
|
2092
|
+
stats: data.stats,
|
|
2093
|
+
execution_time_ms: data.execution_time_ms ?? data.took_ms
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2096
|
+
};
|
|
2097
|
+
|
|
2098
|
+
// src/nl2sql.ts
|
|
2099
|
+
var NL2SqlClient = class {
|
|
2100
|
+
constructor(synapCores) {
|
|
2101
|
+
this.synapCores = synapCores;
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* Ask a question in natural language. The gateway returns the
|
|
2105
|
+
* generated SQL and optionally the executed result set when
|
|
2106
|
+
* `execute=true`.
|
|
2107
|
+
*/
|
|
2108
|
+
async ask(question, opts = {}) {
|
|
2109
|
+
const { data } = await this.synapCores._getHttpClient().post("/nl2sql/query", {
|
|
2110
|
+
question,
|
|
2111
|
+
...opts
|
|
2112
|
+
});
|
|
2113
|
+
return {
|
|
2114
|
+
sql: data.sql ?? data.generated_sql ?? "",
|
|
2115
|
+
confidence: data.confidence,
|
|
2116
|
+
rows: data.rows ?? data.data,
|
|
2117
|
+
columns: data.columns,
|
|
2118
|
+
execution_time_ms: data.execution_time_ms ?? data.took_ms,
|
|
2119
|
+
trace: data.trace ?? data.plan,
|
|
2120
|
+
question
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Push schema context the model should use for subsequent ask() calls.
|
|
2125
|
+
*/
|
|
2126
|
+
async updateSchemaContext(payload) {
|
|
2127
|
+
const { data } = await this.synapCores._getHttpClient().post(
|
|
2128
|
+
"/nl2sql/schema/context",
|
|
2129
|
+
payload
|
|
2130
|
+
);
|
|
2131
|
+
return { accepted: data.accepted ?? data.success ?? true, raw: data };
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Retrieve recent NL2SQL history for the current authenticated user.
|
|
2135
|
+
*/
|
|
2136
|
+
async history(opts = {}) {
|
|
2137
|
+
const params = new URLSearchParams();
|
|
2138
|
+
if (opts.limit) params.append("limit", String(opts.limit));
|
|
2139
|
+
if (opts.session_id) params.append("session_id", opts.session_id);
|
|
2140
|
+
const qs = params.toString();
|
|
2141
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2142
|
+
`/nl2sql/history${qs ? `?${qs}` : ""}`
|
|
2143
|
+
);
|
|
2144
|
+
return (data.history ?? data.entries ?? data ?? []).map((row) => ({
|
|
2145
|
+
id: String(row.id ?? row.entry_id ?? ""),
|
|
2146
|
+
question: row.question ?? row.prompt ?? "",
|
|
2147
|
+
sql: row.sql ?? row.generated_sql ?? "",
|
|
2148
|
+
created_at: new Date(row.created_at ?? row.timestamp ?? Date.now()),
|
|
2149
|
+
executed: row.executed,
|
|
2150
|
+
success: row.success
|
|
2151
|
+
}));
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Validate a SQL string against the current schema and policies.
|
|
2155
|
+
*/
|
|
2156
|
+
async validate(sql) {
|
|
2157
|
+
const { data } = await this.synapCores._getHttpClient().post("/nl2sql/validate", {
|
|
2158
|
+
sql
|
|
2159
|
+
});
|
|
2160
|
+
return {
|
|
2161
|
+
is_valid: data.is_valid ?? data.valid ?? false,
|
|
2162
|
+
errors: data.errors ?? [],
|
|
2163
|
+
warnings: data.warnings ?? [],
|
|
2164
|
+
rewritten_sql: data.rewritten_sql ?? data.sql
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
|
|
2169
|
+
// src/filesystem.ts
|
|
2170
|
+
var import_ws2 = __toESM(require("ws"));
|
|
2171
|
+
var FsCollectionsApi = class {
|
|
2172
|
+
constructor(synapCores) {
|
|
2173
|
+
this.synapCores = synapCores;
|
|
2174
|
+
}
|
|
2175
|
+
async create(opts) {
|
|
2176
|
+
const { data } = await this.synapCores._getHttpClient().post(
|
|
2177
|
+
"/filesystem-collections",
|
|
2178
|
+
opts
|
|
2179
|
+
);
|
|
2180
|
+
return this.normalize(data);
|
|
2181
|
+
}
|
|
2182
|
+
async list() {
|
|
2183
|
+
const { data } = await this.synapCores._getHttpClient().get("/filesystem-collections");
|
|
2184
|
+
return (data.collections ?? data ?? []).map((c) => this.normalize(c));
|
|
2185
|
+
}
|
|
2186
|
+
async get(id) {
|
|
2187
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2188
|
+
`/filesystem-collections/${id}`
|
|
2189
|
+
);
|
|
2190
|
+
return this.normalize(data);
|
|
2191
|
+
}
|
|
2192
|
+
async patch(id, p) {
|
|
2193
|
+
const { data } = await this.synapCores._getHttpClient().patch(
|
|
2194
|
+
`/filesystem-collections/${id}`,
|
|
2195
|
+
p
|
|
2196
|
+
);
|
|
2197
|
+
return this.normalize(data);
|
|
2198
|
+
}
|
|
2199
|
+
async delete(id) {
|
|
2200
|
+
await this.synapCores._getHttpClient().delete(`/filesystem-collections/${id}`);
|
|
2201
|
+
}
|
|
2202
|
+
async documents(id, opts = {}) {
|
|
2203
|
+
const params = new URLSearchParams();
|
|
2204
|
+
if (opts.page) params.append("page", String(opts.page));
|
|
2205
|
+
if (opts.page_size) params.append("page_size", String(opts.page_size));
|
|
2206
|
+
const qs = params.toString();
|
|
2207
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2208
|
+
`/filesystem-collections/${id}/documents${qs ? `?${qs}` : ""}`
|
|
2209
|
+
);
|
|
2210
|
+
return (data.documents ?? data ?? []).map((d) => ({
|
|
2211
|
+
id: String(d.id ?? d.document_id ?? ""),
|
|
2212
|
+
collection_id: d.collection_id !== void 0 ? String(d.collection_id) : id,
|
|
2213
|
+
filename: d.filename ?? d.name,
|
|
2214
|
+
path: d.path,
|
|
2215
|
+
status: d.status,
|
|
2216
|
+
size_bytes: d.size_bytes,
|
|
2217
|
+
created_at: d.created_at ? new Date(d.created_at) : void 0,
|
|
2218
|
+
updated_at: d.updated_at ? new Date(d.updated_at) : void 0
|
|
2219
|
+
}));
|
|
2220
|
+
}
|
|
2221
|
+
async reprocess(id, fileId) {
|
|
2222
|
+
const body = fileId ? { document_id: fileId } : {};
|
|
2223
|
+
const { data } = await this.synapCores._getHttpClient().post(
|
|
2224
|
+
`/filesystem-collections/${id}/reprocess`,
|
|
2225
|
+
body
|
|
2226
|
+
);
|
|
2227
|
+
return { accepted: data.accepted ?? data.success ?? true, raw: data };
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Stream progress events for an in-flight ingestion. Each tick maps to
|
|
2231
|
+
* a JSON payload broadcast by the gateway over the WS channel. The
|
|
2232
|
+
* iterator ends when the server closes the socket or the consumer
|
|
2233
|
+
* breaks out of the for-await loop.
|
|
2234
|
+
*/
|
|
2235
|
+
async *subscribeProgress(id, opts = {}) {
|
|
2236
|
+
const { token } = await this.synapCores.createWsTicket();
|
|
2237
|
+
const wsBase = this.synapCores._getWsBaseUrl();
|
|
2238
|
+
const url = `${wsBase}/ws/filesystem-collections/${id}/progress?token=${encodeURIComponent(token)}`;
|
|
2239
|
+
const ws = new import_ws2.default(url);
|
|
2240
|
+
const queue = [];
|
|
2241
|
+
let resolver = null;
|
|
2242
|
+
const push = (p) => {
|
|
2243
|
+
if (resolver) {
|
|
2244
|
+
const r = resolver;
|
|
2245
|
+
resolver = null;
|
|
2246
|
+
r(p);
|
|
2247
|
+
} else {
|
|
2248
|
+
queue.push(p);
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
ws.on("message", (raw) => {
|
|
2252
|
+
try {
|
|
2253
|
+
const obj = JSON.parse(raw.toString());
|
|
2254
|
+
push({
|
|
2255
|
+
kind: "value",
|
|
2256
|
+
value: {
|
|
2257
|
+
type: obj.type ?? obj.event ?? "progress",
|
|
2258
|
+
collection_id: obj.collection_id !== void 0 ? String(obj.collection_id) : id,
|
|
2259
|
+
document_id: obj.document_id !== void 0 ? String(obj.document_id) : void 0,
|
|
2260
|
+
filename: obj.filename ?? obj.path,
|
|
2261
|
+
status: obj.status,
|
|
2262
|
+
progress: obj.progress,
|
|
2263
|
+
message: obj.message,
|
|
2264
|
+
error: obj.error,
|
|
2265
|
+
timestamp: obj.timestamp ? new Date(obj.timestamp) : void 0,
|
|
2266
|
+
raw: obj
|
|
2267
|
+
}
|
|
2268
|
+
});
|
|
2269
|
+
} catch (e) {
|
|
2270
|
+
push({ kind: "error", error: e });
|
|
2271
|
+
}
|
|
2272
|
+
});
|
|
2273
|
+
ws.on("error", (err) => push({ kind: "error", error: err }));
|
|
2274
|
+
ws.on("close", () => push({ kind: "done" }));
|
|
2275
|
+
const onAbort = () => {
|
|
2276
|
+
try {
|
|
2277
|
+
ws.close();
|
|
2278
|
+
} catch {
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
if (opts.signal) {
|
|
2282
|
+
if (opts.signal.aborted) onAbort();
|
|
2283
|
+
else opts.signal.addEventListener("abort", onAbort);
|
|
2284
|
+
}
|
|
2285
|
+
try {
|
|
2286
|
+
while (true) {
|
|
2287
|
+
const next = await new Promise((resolve) => {
|
|
2288
|
+
if (queue.length > 0) {
|
|
2289
|
+
resolve(queue.shift());
|
|
2290
|
+
} else {
|
|
2291
|
+
resolver = resolve;
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
if (next.kind === "value") yield next.value;
|
|
2295
|
+
else if (next.kind === "error") throw next.error;
|
|
2296
|
+
else return;
|
|
2297
|
+
}
|
|
2298
|
+
} finally {
|
|
2299
|
+
try {
|
|
2300
|
+
ws.close();
|
|
2301
|
+
} catch {
|
|
2302
|
+
}
|
|
2303
|
+
if (opts.signal) opts.signal.removeEventListener("abort", onAbort);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
normalize(data) {
|
|
2307
|
+
return {
|
|
2308
|
+
id: String(data.id ?? data.collection_id ?? ""),
|
|
2309
|
+
name: data.name,
|
|
2310
|
+
description: data.description,
|
|
2311
|
+
path: data.path,
|
|
2312
|
+
status: data.status,
|
|
2313
|
+
document_count: data.document_count ?? data.documents,
|
|
2314
|
+
created_at: data.created_at ? new Date(data.created_at) : void 0,
|
|
2315
|
+
updated_at: data.updated_at ? new Date(data.updated_at) : void 0,
|
|
2316
|
+
config: data.config
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
var FilesystemCollectionsClient = class {
|
|
2321
|
+
constructor(synapCores) {
|
|
2322
|
+
this.collections = new FsCollectionsApi(synapCores);
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
// src/chat.ts
|
|
2327
|
+
var ChatSessionsApi = class {
|
|
2328
|
+
constructor(synapCores) {
|
|
2329
|
+
this.synapCores = synapCores;
|
|
2330
|
+
}
|
|
2331
|
+
async create(opts = {}) {
|
|
2332
|
+
const { data } = await this.synapCores._getHttpClient().post("/ai/sessions", opts);
|
|
2333
|
+
return this.normalize(data);
|
|
2334
|
+
}
|
|
2335
|
+
async list(opts = {}) {
|
|
2336
|
+
const params = new URLSearchParams();
|
|
2337
|
+
if (opts.limit) params.append("limit", String(opts.limit));
|
|
2338
|
+
if (opts.offset) params.append("offset", String(opts.offset));
|
|
2339
|
+
const qs = params.toString();
|
|
2340
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2341
|
+
`/ai/sessions${qs ? `?${qs}` : ""}`
|
|
2342
|
+
);
|
|
2343
|
+
return (data.sessions ?? data ?? []).map((s) => this.normalize(s));
|
|
2344
|
+
}
|
|
2345
|
+
async get(id) {
|
|
2346
|
+
const { data } = await this.synapCores._getHttpClient().get(`/ai/sessions/${id}`);
|
|
2347
|
+
return this.normalize(data);
|
|
2348
|
+
}
|
|
2349
|
+
async delete(id) {
|
|
2350
|
+
await this.synapCores._getHttpClient().delete(`/ai/sessions/${id}`);
|
|
2351
|
+
}
|
|
2352
|
+
async messages(id, opts = {}) {
|
|
2353
|
+
const params = new URLSearchParams();
|
|
2354
|
+
if (opts.limit) params.append("limit", String(opts.limit));
|
|
2355
|
+
if (opts.offset) params.append("offset", String(opts.offset));
|
|
2356
|
+
const qs = params.toString();
|
|
2357
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2358
|
+
`/ai/sessions/${id}/messages${qs ? `?${qs}` : ""}`
|
|
2359
|
+
);
|
|
2360
|
+
return (data.messages ?? data ?? []).map((m) => this.normalizeMessage(m, id));
|
|
2361
|
+
}
|
|
2362
|
+
normalize(data) {
|
|
2363
|
+
return {
|
|
2364
|
+
id: String(data.id ?? data.session_id ?? ""),
|
|
2365
|
+
title: data.title,
|
|
2366
|
+
model: data.model,
|
|
2367
|
+
system_prompt: data.system_prompt,
|
|
2368
|
+
created_at: new Date(data.created_at ?? Date.now()),
|
|
2369
|
+
updated_at: data.updated_at ? new Date(data.updated_at) : void 0,
|
|
2370
|
+
message_count: data.message_count ?? data.messages,
|
|
2371
|
+
metadata: data.metadata
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
normalizeMessage(m, sessionId) {
|
|
2375
|
+
return {
|
|
2376
|
+
id: String(m.id ?? m.message_id ?? ""),
|
|
2377
|
+
session_id: m.session_id !== void 0 ? String(m.session_id) : sessionId,
|
|
2378
|
+
role: m.role,
|
|
2379
|
+
content: m.content ?? m.text ?? "",
|
|
2380
|
+
created_at: new Date(m.created_at ?? Date.now()),
|
|
2381
|
+
metadata: m.metadata
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
};
|
|
2385
|
+
var ChatToolsApi = class {
|
|
2386
|
+
constructor(synapCores) {
|
|
2387
|
+
this.synapCores = synapCores;
|
|
2388
|
+
}
|
|
2389
|
+
async list() {
|
|
2390
|
+
const { data } = await this.synapCores._getHttpClient().get("/ai/tools");
|
|
2391
|
+
return (data.tools ?? data ?? []).map((t) => ({
|
|
2392
|
+
name: t.name,
|
|
2393
|
+
description: t.description,
|
|
2394
|
+
parameters: t.parameters ?? t.schema
|
|
2395
|
+
}));
|
|
2396
|
+
}
|
|
2397
|
+
async execute(name, args = {}) {
|
|
2398
|
+
const { data } = await this.synapCores._getHttpClient().post("/ai/tools/execute", {
|
|
2399
|
+
tool: name,
|
|
2400
|
+
arguments: args
|
|
2401
|
+
});
|
|
2402
|
+
return data;
|
|
2403
|
+
}
|
|
2404
|
+
async sql(sql, params = []) {
|
|
2405
|
+
const { data } = await this.synapCores._getHttpClient().post("/ai/tools/sql", {
|
|
2406
|
+
sql,
|
|
2407
|
+
parameters: params
|
|
2408
|
+
});
|
|
2409
|
+
return data;
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
var ChatCacheApi = class {
|
|
2413
|
+
constructor(synapCores) {
|
|
2414
|
+
this.synapCores = synapCores;
|
|
2415
|
+
}
|
|
2416
|
+
async stats() {
|
|
2417
|
+
const { data } = await this.synapCores._getHttpClient().get("/ai/cache/stats");
|
|
2418
|
+
return {
|
|
2419
|
+
size_bytes: data.size_bytes ?? data.bytes,
|
|
2420
|
+
hit_count: data.hit_count ?? data.hits,
|
|
2421
|
+
miss_count: data.miss_count ?? data.misses,
|
|
2422
|
+
entries: data.entries ?? data.count,
|
|
2423
|
+
raw: data
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
async clear() {
|
|
2427
|
+
await this.synapCores._getHttpClient().post("/ai/cache/clear", {});
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
var ChatClient = class {
|
|
2431
|
+
constructor(synapCores) {
|
|
2432
|
+
this.synapCores = synapCores;
|
|
2433
|
+
this.sessions = new ChatSessionsApi(synapCores);
|
|
2434
|
+
this.tools = new ChatToolsApi(synapCores);
|
|
2435
|
+
this.cache = new ChatCacheApi(synapCores);
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* Send a one-shot chat message. The gateway accepts both /ai/chat and
|
|
2439
|
+
* the alias /ai/ — we use /ai/chat for clarity.
|
|
2440
|
+
*/
|
|
2441
|
+
async send(sessionId, content, opts = {}) {
|
|
2442
|
+
const { data } = await this.synapCores._getHttpClient().post("/ai/chat", {
|
|
2443
|
+
session_id: sessionId,
|
|
2444
|
+
content,
|
|
2445
|
+
...opts
|
|
2446
|
+
});
|
|
2447
|
+
const messageData = data.message ?? data;
|
|
2448
|
+
return {
|
|
2449
|
+
message: {
|
|
2450
|
+
id: String(messageData.id ?? messageData.message_id ?? ""),
|
|
2451
|
+
session_id: sessionId,
|
|
2452
|
+
role: messageData.role ?? "assistant",
|
|
2453
|
+
content: messageData.content ?? messageData.text ?? "",
|
|
2454
|
+
created_at: new Date(messageData.created_at ?? Date.now()),
|
|
2455
|
+
metadata: messageData.metadata
|
|
2456
|
+
},
|
|
2457
|
+
tool_calls: data.tool_calls,
|
|
2458
|
+
usage: data.usage
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Stream a chat completion. Returns an async iterator over SSE chunks.
|
|
2463
|
+
*/
|
|
2464
|
+
async *stream(sessionId, content, opts = {}) {
|
|
2465
|
+
const http = this.synapCores._getHttpClient();
|
|
2466
|
+
const response = await http.post(
|
|
2467
|
+
"/ai/chat/stream",
|
|
2468
|
+
{
|
|
2469
|
+
session_id: sessionId,
|
|
2470
|
+
content,
|
|
2471
|
+
...opts
|
|
2472
|
+
},
|
|
2473
|
+
{ responseType: "stream" }
|
|
2474
|
+
);
|
|
2475
|
+
const stream = response.data;
|
|
2476
|
+
let buffer = "";
|
|
2477
|
+
for await (const chunk of stream) {
|
|
2478
|
+
buffer += chunk.toString();
|
|
2479
|
+
const frames = buffer.split(/\n\n/);
|
|
2480
|
+
buffer = frames.pop() ?? "";
|
|
2481
|
+
for (const frame of frames) {
|
|
2482
|
+
const trimmed = frame.trim();
|
|
2483
|
+
if (!trimmed) continue;
|
|
2484
|
+
const line = trimmed.startsWith("data:") ? trimmed.slice(5).trim() : trimmed;
|
|
2485
|
+
if (line === "[DONE]") {
|
|
2486
|
+
yield { done: true };
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
try {
|
|
2490
|
+
const obj = JSON.parse(line);
|
|
2491
|
+
yield {
|
|
2492
|
+
delta: obj.delta ?? obj.choices?.[0]?.delta?.content ?? obj.text ?? void 0,
|
|
2493
|
+
content: obj.content ?? obj.message?.content,
|
|
2494
|
+
type: obj.type ?? obj.event,
|
|
2495
|
+
done: obj.done ?? obj.finished,
|
|
2496
|
+
raw: obj
|
|
2497
|
+
};
|
|
2498
|
+
} catch {
|
|
2499
|
+
yield { delta: line, raw: line };
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
if (buffer.trim()) {
|
|
2504
|
+
try {
|
|
2505
|
+
yield { raw: JSON.parse(buffer) };
|
|
2506
|
+
} catch {
|
|
2507
|
+
yield { delta: buffer };
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Get prompt suggestions, e.g. for an empty session UI.
|
|
2513
|
+
*/
|
|
2514
|
+
async suggestions(opts = {}) {
|
|
2515
|
+
const { data } = await this.synapCores._getHttpClient().post("/ai/suggestions", opts);
|
|
2516
|
+
return (data.suggestions ?? data ?? []).map((s) => ({
|
|
2517
|
+
prompt: s.prompt ?? s.text ?? "",
|
|
2518
|
+
category: s.category,
|
|
2519
|
+
meta: s.meta ?? s.metadata
|
|
2520
|
+
}));
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* List configured chat models.
|
|
1827
2524
|
*/
|
|
1828
|
-
async
|
|
1829
|
-
const { data } = await this.synapCores._getHttpClient().
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
active: data.active,
|
|
1838
|
-
last_run_at: data.last_run_at ? new Date(data.last_run_at) : void 0,
|
|
1839
|
-
next_run_at: data.next_run_at ? new Date(data.next_run_at) : void 0,
|
|
1840
|
-
created_at: new Date(data.created_at),
|
|
1841
|
-
tags: data.tags || []
|
|
1842
|
-
};
|
|
2525
|
+
async models() {
|
|
2526
|
+
const { data } = await this.synapCores._getHttpClient().get("/ai/models");
|
|
2527
|
+
return (data.models ?? data ?? []).map((m) => ({
|
|
2528
|
+
id: m.id ?? m.name,
|
|
2529
|
+
name: m.name,
|
|
2530
|
+
provider: m.provider,
|
|
2531
|
+
context_window: m.context_window ?? m.max_context,
|
|
2532
|
+
capabilities: m.capabilities
|
|
2533
|
+
}));
|
|
1843
2534
|
}
|
|
1844
2535
|
/**
|
|
1845
|
-
*
|
|
2536
|
+
* List the available system prompts library.
|
|
1846
2537
|
*/
|
|
1847
|
-
async
|
|
1848
|
-
const { data } = await this.synapCores._getHttpClient().get("/
|
|
2538
|
+
async systemPrompts() {
|
|
2539
|
+
const { data } = await this.synapCores._getHttpClient().get("/ai/system-prompts");
|
|
2540
|
+
return (data.prompts ?? data.system_prompts ?? data ?? []).map((p) => ({
|
|
2541
|
+
id: String(p.id ?? p.name ?? ""),
|
|
2542
|
+
name: p.name,
|
|
2543
|
+
content: p.content ?? p.text ?? "",
|
|
2544
|
+
description: p.description,
|
|
2545
|
+
category: p.category
|
|
2546
|
+
}));
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
|
|
2550
|
+
// src/multimodal.ts
|
|
2551
|
+
var MultimodalClient = class {
|
|
2552
|
+
constructor(synapCores) {
|
|
2553
|
+
this.synapCores = synapCores;
|
|
2554
|
+
}
|
|
2555
|
+
async similarity(a, b, opts = {}) {
|
|
2556
|
+
const { data } = await this.synapCores._getHttpClient().post("/multimodal/similarity", {
|
|
2557
|
+
a: typeof a === "string" ? { type: "text", text: a } : a,
|
|
2558
|
+
b: typeof b === "string" ? { type: "text", text: b } : b,
|
|
2559
|
+
...opts
|
|
2560
|
+
});
|
|
1849
2561
|
return {
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
failed_backups: data.failed_backups || 0,
|
|
1854
|
-
avg_backup_size_bytes: data.avg_backup_size_bytes || 0,
|
|
1855
|
-
avg_duration_ms: data.avg_duration_ms || 0,
|
|
1856
|
-
last_backup_at: data.last_backup_at ? new Date(data.last_backup_at) : void 0,
|
|
1857
|
-
next_scheduled_at: data.next_scheduled_at ? new Date(data.next_scheduled_at) : void 0
|
|
2562
|
+
similarity: data.similarity ?? data.score ?? 0,
|
|
2563
|
+
metric: data.metric ?? opts.metric,
|
|
2564
|
+
raw: data
|
|
1858
2565
|
};
|
|
1859
2566
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
2567
|
+
async search(query, opts = {}) {
|
|
2568
|
+
const { data } = await this.synapCores._getHttpClient().post("/multimodal/search", {
|
|
2569
|
+
query: typeof query === "string" ? { type: "text", text: query } : query,
|
|
2570
|
+
...opts
|
|
2571
|
+
});
|
|
2572
|
+
return (data.results ?? data.hits ?? data ?? []).map((r) => ({
|
|
2573
|
+
id: String(r.id ?? r.document_id ?? ""),
|
|
2574
|
+
score: r.score ?? r.similarity ?? 0,
|
|
2575
|
+
modality: r.modality,
|
|
2576
|
+
metadata: r.metadata
|
|
2577
|
+
}));
|
|
2578
|
+
}
|
|
2579
|
+
async join(left, right, opts = {}) {
|
|
2580
|
+
const normalize = (side) => Array.isArray(side) ? side.map((s) => typeof s === "string" ? { type: "text", text: s } : s) : side;
|
|
2581
|
+
const { data } = await this.synapCores._getHttpClient().post("/multimodal/join", {
|
|
2582
|
+
left: normalize(left),
|
|
2583
|
+
right: normalize(right),
|
|
2584
|
+
...opts
|
|
2585
|
+
});
|
|
1864
2586
|
return {
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
2587
|
+
pairs: (data.pairs ?? data.results ?? []).map((p) => ({
|
|
2588
|
+
left: p.left,
|
|
2589
|
+
right: p.right,
|
|
2590
|
+
score: p.score ?? p.similarity ?? 0
|
|
2591
|
+
}))
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
async embed(input, model) {
|
|
2595
|
+
const { data } = await this.synapCores._getHttpClient().post("/multimodal/embed", {
|
|
2596
|
+
input: typeof input === "string" ? { type: "text", text: input } : input,
|
|
2597
|
+
model
|
|
2598
|
+
});
|
|
2599
|
+
const embedding = data.embedding ?? data.vector ?? [];
|
|
2600
|
+
return {
|
|
2601
|
+
embedding,
|
|
2602
|
+
modality: data.modality,
|
|
2603
|
+
model: data.model ?? model,
|
|
2604
|
+
dimensions: data.dimensions ?? embedding.length
|
|
1882
2605
|
};
|
|
1883
2606
|
}
|
|
1884
2607
|
};
|
|
1885
2608
|
|
|
1886
|
-
// src/
|
|
1887
|
-
var
|
|
1888
|
-
constructor(
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
2609
|
+
// src/system.ts
|
|
2610
|
+
var VisionApi = class {
|
|
2611
|
+
constructor(synapCores) {
|
|
2612
|
+
this.synapCores = synapCores;
|
|
2613
|
+
}
|
|
2614
|
+
async get() {
|
|
2615
|
+
try {
|
|
2616
|
+
const { data } = await this.synapCores._getHttpClient().get("/system/vision");
|
|
2617
|
+
if (!data || Object.keys(data).length === 0) return null;
|
|
2618
|
+
return data;
|
|
2619
|
+
} catch (e) {
|
|
2620
|
+
if (e?.statusCode === 404 || e?.code === "NOT_FOUND") return null;
|
|
2621
|
+
throw e;
|
|
1895
2622
|
}
|
|
1896
2623
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
super(message, "CONNECTION_ERROR", details);
|
|
1901
|
-
this.name = "ConnectionError";
|
|
2624
|
+
async set(cfg) {
|
|
2625
|
+
const { data } = await this.synapCores._getHttpClient().put("/system/vision", cfg);
|
|
2626
|
+
return data;
|
|
1902
2627
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
constructor(message, details) {
|
|
1906
|
-
super(message, "AUTH_ERROR", details);
|
|
1907
|
-
this.name = "AuthenticationError";
|
|
2628
|
+
async delete() {
|
|
2629
|
+
await this.synapCores._getHttpClient().delete("/system/vision");
|
|
1908
2630
|
}
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
2631
|
+
async test(payload = {}) {
|
|
2632
|
+
const { data } = await this.synapCores._getHttpClient().post("/system/vision/test", payload);
|
|
2633
|
+
return {
|
|
2634
|
+
success: data.success ?? false,
|
|
2635
|
+
latency_ms: data.latency_ms,
|
|
2636
|
+
response: data.response,
|
|
2637
|
+
error: data.error
|
|
2638
|
+
};
|
|
1914
2639
|
}
|
|
1915
2640
|
};
|
|
1916
|
-
var
|
|
1917
|
-
constructor(
|
|
1918
|
-
|
|
1919
|
-
this.name = "NotFoundError";
|
|
2641
|
+
var SystemClient = class {
|
|
2642
|
+
constructor(synapCores) {
|
|
2643
|
+
this.vision = new VisionApi(synapCores);
|
|
1920
2644
|
}
|
|
1921
2645
|
};
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2646
|
+
|
|
2647
|
+
// src/transactions.ts
|
|
2648
|
+
var Tx = class {
|
|
2649
|
+
constructor(http, id, options) {
|
|
2650
|
+
this.http = http;
|
|
2651
|
+
this.id = id;
|
|
2652
|
+
this.options = options;
|
|
2653
|
+
this.active = true;
|
|
1926
2654
|
}
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
constructor(message, details) {
|
|
1930
|
-
super(message, "TIMEOUT_ERROR", details);
|
|
1931
|
-
this.name = "TimeoutError";
|
|
2655
|
+
isActive() {
|
|
2656
|
+
return this.active;
|
|
1932
2657
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2658
|
+
async execute(sql, params = []) {
|
|
2659
|
+
this.assertActive();
|
|
2660
|
+
const { data } = await this.http.post(`/transactions/${this.id}/execute`, {
|
|
2661
|
+
sql,
|
|
2662
|
+
parameters: params
|
|
2663
|
+
});
|
|
2664
|
+
return {
|
|
2665
|
+
columns: data.columns ?? [],
|
|
2666
|
+
rows: data.rows ?? [],
|
|
2667
|
+
rows_affected: data.rows_affected,
|
|
2668
|
+
execution_time_ms: data.execution_time_ms ?? data.took_ms
|
|
2669
|
+
};
|
|
1939
2670
|
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
this.
|
|
1947
|
-
this.
|
|
1948
|
-
this.
|
|
2671
|
+
async commit() {
|
|
2672
|
+
this.assertActive();
|
|
2673
|
+
await this.http.post(`/transactions/${this.id}/commit`, {});
|
|
2674
|
+
this.active = false;
|
|
2675
|
+
}
|
|
2676
|
+
async rollback() {
|
|
2677
|
+
this.assertActive();
|
|
2678
|
+
await this.http.post(`/transactions/${this.id}/rollback`, {});
|
|
2679
|
+
this.active = false;
|
|
2680
|
+
}
|
|
2681
|
+
async savepoint(name) {
|
|
2682
|
+
this.assertActive();
|
|
2683
|
+
await this.http.post(`/transactions/${this.id}/savepoint`, { name });
|
|
2684
|
+
}
|
|
2685
|
+
async rollbackTo(name) {
|
|
2686
|
+
this.assertActive();
|
|
2687
|
+
await this.http.post(`/transactions/${this.id}/savepoint/${name}/rollback`, {});
|
|
2688
|
+
}
|
|
2689
|
+
assertActive() {
|
|
2690
|
+
if (!this.active) {
|
|
2691
|
+
throw new Error(`Transaction ${this.id} has already been committed/rolled back`);
|
|
2692
|
+
}
|
|
1949
2693
|
}
|
|
1950
2694
|
};
|
|
1951
|
-
var
|
|
1952
|
-
constructor(
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
2695
|
+
var TxHistoryApi = class {
|
|
2696
|
+
constructor(synapCores) {
|
|
2697
|
+
this.synapCores = synapCores;
|
|
2698
|
+
}
|
|
2699
|
+
async list(opts = {}) {
|
|
2700
|
+
const params = new URLSearchParams();
|
|
2701
|
+
if (opts.limit) params.append("limit", String(opts.limit));
|
|
2702
|
+
if (opts.status) params.append("status", opts.status);
|
|
2703
|
+
const qs = params.toString();
|
|
2704
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2705
|
+
`/transactions/history${qs ? `?${qs}` : ""}`
|
|
2706
|
+
);
|
|
2707
|
+
return (data.transactions ?? data.history ?? data ?? []).map((row) => ({
|
|
2708
|
+
id: String(row.id ?? row.transaction_id ?? ""),
|
|
2709
|
+
status: row.status ?? "unknown",
|
|
2710
|
+
started_at: new Date(row.started_at ?? row.created_at ?? Date.now()),
|
|
2711
|
+
completed_at: row.completed_at ? new Date(row.completed_at) : void 0,
|
|
2712
|
+
isolation_level: row.isolation_level,
|
|
2713
|
+
read_only: row.read_only,
|
|
2714
|
+
statement_count: row.statement_count ?? row.statements,
|
|
2715
|
+
metrics: row.metrics
|
|
2716
|
+
}));
|
|
2717
|
+
}
|
|
2718
|
+
async get(id) {
|
|
2719
|
+
const { data } = await this.synapCores._getHttpClient().get(
|
|
2720
|
+
`/transactions/history/${id}`
|
|
2721
|
+
);
|
|
2722
|
+
return {
|
|
2723
|
+
id: String(data.id ?? id),
|
|
2724
|
+
status: data.status ?? "unknown",
|
|
2725
|
+
started_at: new Date(data.started_at ?? data.created_at ?? Date.now()),
|
|
2726
|
+
completed_at: data.completed_at ? new Date(data.completed_at) : void 0,
|
|
2727
|
+
isolation_level: data.isolation_level,
|
|
2728
|
+
read_only: data.read_only,
|
|
2729
|
+
statement_count: data.statement_count ?? data.statements,
|
|
2730
|
+
metrics: data.metrics
|
|
2731
|
+
};
|
|
1958
2732
|
}
|
|
1959
2733
|
};
|
|
1960
|
-
var
|
|
1961
|
-
constructor(
|
|
1962
|
-
|
|
1963
|
-
this.
|
|
1964
|
-
|
|
1965
|
-
|
|
2734
|
+
var TransactionsClient = class {
|
|
2735
|
+
constructor(synapCores) {
|
|
2736
|
+
this.synapCores = synapCores;
|
|
2737
|
+
this.history = new TxHistoryApi(synapCores);
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Begin a new server-side transaction.
|
|
2741
|
+
*/
|
|
2742
|
+
async begin(opts = {}) {
|
|
2743
|
+
const { data } = await this.synapCores._getHttpClient().post("/transactions", opts);
|
|
2744
|
+
const id = String(data.id ?? data.transaction_id ?? "");
|
|
2745
|
+
if (!id) {
|
|
2746
|
+
throw new Error("begin(): server did not return a transaction id");
|
|
2747
|
+
}
|
|
2748
|
+
return new Tx(this.synapCores._getHttpClient(), id, opts);
|
|
1966
2749
|
}
|
|
1967
2750
|
};
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
2751
|
+
|
|
2752
|
+
// src/mcp.ts
|
|
2753
|
+
var mcpRequestCounter = 0;
|
|
2754
|
+
function withId(req) {
|
|
2755
|
+
if (req.id !== void 0 && req.id !== null) return req;
|
|
2756
|
+
mcpRequestCounter += 1;
|
|
2757
|
+
return { ...req, id: `mcp-${Date.now()}-${mcpRequestCounter}` };
|
|
2758
|
+
}
|
|
2759
|
+
var McpClient = class {
|
|
2760
|
+
constructor(synapCores) {
|
|
2761
|
+
this.synapCores = synapCores;
|
|
2762
|
+
}
|
|
2763
|
+
/**
|
|
2764
|
+
* Invoke a single MCP method.
|
|
2765
|
+
*/
|
|
2766
|
+
async invoke(req) {
|
|
2767
|
+
const body = withId(req);
|
|
2768
|
+
const { data } = await this.synapCores._getHttpClient().post("/mcp", body);
|
|
2769
|
+
return {
|
|
2770
|
+
id: data.id ?? body.id,
|
|
2771
|
+
result: data.result,
|
|
2772
|
+
error: data.error,
|
|
2773
|
+
raw: data
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* Send an array of MCP invocations and resolve to the matching array
|
|
2778
|
+
* of responses (in the order returned by the gateway).
|
|
2779
|
+
*/
|
|
2780
|
+
async batch(reqs) {
|
|
2781
|
+
const body = reqs.map(withId);
|
|
2782
|
+
const { data } = await this.synapCores._getHttpClient().post("/mcp/batch", body);
|
|
2783
|
+
const arr = Array.isArray(data) ? data : data.responses ?? data.results ?? [];
|
|
2784
|
+
return arr.map((r) => ({
|
|
2785
|
+
id: r.id,
|
|
2786
|
+
result: r.result,
|
|
2787
|
+
error: r.error,
|
|
2788
|
+
raw: r
|
|
2789
|
+
}));
|
|
2790
|
+
}
|
|
2791
|
+
/**
|
|
2792
|
+
* Discover the server's MCP capabilities and tools.
|
|
2793
|
+
*/
|
|
2794
|
+
async info() {
|
|
2795
|
+
const { data } = await this.synapCores._getHttpClient().get("/mcp/info");
|
|
2796
|
+
return {
|
|
2797
|
+
version: data.version ?? data.mcp_version ?? "0",
|
|
2798
|
+
capabilities: data.capabilities,
|
|
2799
|
+
tools: data.tools,
|
|
2800
|
+
meta: data.meta ?? data.metadata
|
|
2801
|
+
};
|
|
1975
2802
|
}
|
|
1976
2803
|
};
|
|
1977
2804
|
|
|
@@ -2010,7 +2837,7 @@ var SynapCores = class {
|
|
|
2010
2837
|
timeout: this.config.timeout,
|
|
2011
2838
|
headers: {
|
|
2012
2839
|
"Content-Type": "application/json",
|
|
2013
|
-
"User-Agent": "synapcores-nodejs/0.
|
|
2840
|
+
"User-Agent": "synapcores-nodejs/0.2.0",
|
|
2014
2841
|
...authHeader
|
|
2015
2842
|
},
|
|
2016
2843
|
...httpsAgent && { httpsAgent }
|
|
@@ -2026,6 +2853,44 @@ var SynapCores = class {
|
|
|
2026
2853
|
this.import = new ImportExportClient(this);
|
|
2027
2854
|
this.integrations = new IntegrationClient(this);
|
|
2028
2855
|
this.backup = new BackupClient(this);
|
|
2856
|
+
this.graph = new GraphClient(this);
|
|
2857
|
+
this.nl2sql = new NL2SqlClient(this);
|
|
2858
|
+
this.filesystem = new FilesystemCollectionsClient(this);
|
|
2859
|
+
this.chat = new ChatClient(this);
|
|
2860
|
+
this.multimodal = new MultimodalClient(this);
|
|
2861
|
+
this.system = new SystemClient(this);
|
|
2862
|
+
this.transactions = new TransactionsClient(this);
|
|
2863
|
+
this.mcp = new McpClient(this);
|
|
2864
|
+
}
|
|
2865
|
+
/**
|
|
2866
|
+
* Build the WebSocket base URL (ws:// or wss://).
|
|
2867
|
+
*/
|
|
2868
|
+
_getWsBaseUrl() {
|
|
2869
|
+
const protocol = this.config.useHttps ? "wss" : "ws";
|
|
2870
|
+
return `${protocol}://${this.config.host}:${this.config.port}`;
|
|
2871
|
+
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Read-only access to the configured host/port for WS-clients.
|
|
2874
|
+
*/
|
|
2875
|
+
_getConfig() {
|
|
2876
|
+
return this.config;
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Exchange the current credentials (JWT or API key) for a short-lived
|
|
2880
|
+
* WebSocket ticket. Use the returned token as the `?token=` query
|
|
2881
|
+
* param when opening any /ws endpoint.
|
|
2882
|
+
*/
|
|
2883
|
+
async createWsTicket() {
|
|
2884
|
+
const { data } = await this.httpClient.post("/ws/ticket", {});
|
|
2885
|
+
const token = data.token ?? data.ticket;
|
|
2886
|
+
const expiresAt = typeof data.expiresAt === "number" ? data.expiresAt : data.expires_at ? Date.parse(data.expires_at) : Date.now() + 6e4;
|
|
2887
|
+
return { token, expiresAt };
|
|
2888
|
+
}
|
|
2889
|
+
/**
|
|
2890
|
+
* Revoke a previously-issued ticket (best-effort).
|
|
2891
|
+
*/
|
|
2892
|
+
async revokeWsTicket(token) {
|
|
2893
|
+
await this.httpClient.post("/ws/ticket/revoke", { token });
|
|
2029
2894
|
}
|
|
2030
2895
|
handleError(error) {
|
|
2031
2896
|
if (!error.response) {
|
|
@@ -2214,11 +3079,11 @@ var SynapCores = class {
|
|
|
2214
3079
|
async embed(text, options = {}) {
|
|
2215
3080
|
const isBatch = Array.isArray(text);
|
|
2216
3081
|
const texts = isBatch ? text : [text];
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
return
|
|
3082
|
+
const path = isBatch ? "/ai/embeddings/batch" : "/ai/embeddings";
|
|
3083
|
+
const body = isBatch ? { texts, model: options.model } : { text: texts[0], model: options.model };
|
|
3084
|
+
const { data } = await this.httpClient.post(path, body);
|
|
3085
|
+
if (isBatch) return data.embeddings ?? data;
|
|
3086
|
+
return data.embedding ?? data.embeddings?.[0] ?? data;
|
|
2222
3087
|
}
|
|
2223
3088
|
// Internal method for HTTP client access
|
|
2224
3089
|
_getHttpClient() {
|
|
@@ -2345,8 +3210,16 @@ var SynapCores = class {
|
|
|
2345
3210
|
* @returns Promise resolving to table information
|
|
2346
3211
|
*/
|
|
2347
3212
|
async describeTable(tableName) {
|
|
2348
|
-
const
|
|
2349
|
-
|
|
3213
|
+
const [tableRes, colsRes, idxRes] = await Promise.all([
|
|
3214
|
+
this.httpClient.get(`/schema/tables/${tableName}`),
|
|
3215
|
+
this.httpClient.get(`/schema/tables/${tableName}/columns`),
|
|
3216
|
+
this.httpClient.get(`/schema/tables/${tableName}/indexes`)
|
|
3217
|
+
]);
|
|
3218
|
+
return {
|
|
3219
|
+
...tableRes.data,
|
|
3220
|
+
columns: colsRes.data?.columns ?? colsRes.data ?? [],
|
|
3221
|
+
indexes: idxRes.data?.indexes ?? idxRes.data ?? []
|
|
3222
|
+
};
|
|
2350
3223
|
}
|
|
2351
3224
|
/**
|
|
2352
3225
|
* Lists all tables in the current database
|
|
@@ -2479,19 +3352,26 @@ var SynapCores = class {
|
|
|
2479
3352
|
* @returns Promise resolving to batch operation result
|
|
2480
3353
|
*/
|
|
2481
3354
|
async batchInsert(options) {
|
|
2482
|
-
const
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
3355
|
+
const cols = options.columns ?? [];
|
|
3356
|
+
const queries = options.rows.map((row) => {
|
|
3357
|
+
const values = Array.isArray(row) ? row : cols.map((c) => row[c]);
|
|
3358
|
+
return {
|
|
3359
|
+
sql: `INSERT INTO ${options.tableName} (${cols.join(", ")}) VALUES (${values.map((_, i) => "$" + (i + 1)).join(", ")})`,
|
|
3360
|
+
parameters: values
|
|
3361
|
+
};
|
|
3362
|
+
});
|
|
3363
|
+
const { data } = await this.httpClient.post("/query/execute/batch", {
|
|
3364
|
+
queries,
|
|
3365
|
+
transactional: false
|
|
3366
|
+
});
|
|
3367
|
+
const results = data.results ?? [];
|
|
3368
|
+
const successful = results.filter((r) => !r.error).length;
|
|
3369
|
+
return {
|
|
3370
|
+
totalProcessed: results.length,
|
|
3371
|
+
successful,
|
|
3372
|
+
failed: results.length - successful,
|
|
3373
|
+
errors: results.filter((r) => r.error).map((r) => r.error),
|
|
3374
|
+
tookMs: data.total_execution_time_ms ?? 0
|
|
2495
3375
|
};
|
|
2496
3376
|
}
|
|
2497
3377
|
/**
|
|
@@ -2500,17 +3380,27 @@ var SynapCores = class {
|
|
|
2500
3380
|
* @returns Promise resolving to batch operation result
|
|
2501
3381
|
*/
|
|
2502
3382
|
async batchUpdate(options) {
|
|
2503
|
-
const
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
3383
|
+
const queries = options.updates.map((u) => {
|
|
3384
|
+
const setClause = Object.keys(u.set ?? {}).map((k, i) => `${k} = $${i + 1}`).join(", ");
|
|
3385
|
+
const setVals = Object.values(u.set ?? {});
|
|
3386
|
+
const whereStr = u.where ?? "1=1";
|
|
3387
|
+
return {
|
|
3388
|
+
sql: `UPDATE ${options.tableName} SET ${setClause} WHERE ${whereStr}`,
|
|
3389
|
+
parameters: setVals
|
|
3390
|
+
};
|
|
2507
3391
|
});
|
|
3392
|
+
const { data } = await this.httpClient.post("/query/execute/batch", {
|
|
3393
|
+
queries,
|
|
3394
|
+
transactional: false
|
|
3395
|
+
});
|
|
3396
|
+
const results = data.results ?? [];
|
|
3397
|
+
const successful = results.filter((r) => !r.error).length;
|
|
2508
3398
|
return {
|
|
2509
|
-
totalProcessed:
|
|
2510
|
-
successful
|
|
2511
|
-
failed:
|
|
2512
|
-
errors:
|
|
2513
|
-
tookMs: data.
|
|
3399
|
+
totalProcessed: results.length,
|
|
3400
|
+
successful,
|
|
3401
|
+
failed: results.length - successful,
|
|
3402
|
+
errors: results.filter((r) => r.error).map((r) => r.error),
|
|
3403
|
+
tookMs: data.total_execution_time_ms ?? 0
|
|
2514
3404
|
};
|
|
2515
3405
|
}
|
|
2516
3406
|
/**
|
|
@@ -2519,17 +3409,22 @@ var SynapCores = class {
|
|
|
2519
3409
|
* @returns Promise resolving to batch operation result
|
|
2520
3410
|
*/
|
|
2521
3411
|
async batchDelete(options) {
|
|
2522
|
-
const
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
3412
|
+
const queries = (options.whereConditions ?? []).map((cond) => ({
|
|
3413
|
+
sql: `DELETE FROM ${options.tableName} WHERE ${typeof cond === "string" ? cond : JSON.stringify(cond)}`,
|
|
3414
|
+
parameters: []
|
|
3415
|
+
}));
|
|
3416
|
+
const { data } = await this.httpClient.post("/query/execute/batch", {
|
|
3417
|
+
queries,
|
|
3418
|
+
transactional: false
|
|
2526
3419
|
});
|
|
3420
|
+
const results = data.results ?? [];
|
|
3421
|
+
const successful = results.filter((r) => !r.error).length;
|
|
2527
3422
|
return {
|
|
2528
|
-
totalProcessed:
|
|
2529
|
-
successful
|
|
2530
|
-
failed:
|
|
2531
|
-
errors:
|
|
2532
|
-
tookMs: data.
|
|
3423
|
+
totalProcessed: results.length,
|
|
3424
|
+
successful,
|
|
3425
|
+
failed: results.length - successful,
|
|
3426
|
+
errors: results.filter((r) => r.error).map((r) => r.error),
|
|
3427
|
+
tookMs: data.total_execution_time_ms ?? 0
|
|
2533
3428
|
};
|
|
2534
3429
|
}
|
|
2535
3430
|
// =================================================================
|
|
@@ -2542,15 +3437,15 @@ var SynapCores = class {
|
|
|
2542
3437
|
* @returns Promise resolving to prepared statement
|
|
2543
3438
|
*/
|
|
2544
3439
|
async prepareStatement(sql, options = {}) {
|
|
2545
|
-
const { data } = await this.httpClient.post("/prepare", {
|
|
3440
|
+
const { data } = await this.httpClient.post("/query/prepare", {
|
|
2546
3441
|
sql,
|
|
2547
3442
|
name: options.name,
|
|
2548
3443
|
parameter_types: options.parameterTypes
|
|
2549
3444
|
});
|
|
2550
3445
|
const prepared = {
|
|
2551
|
-
id: data.statement_id,
|
|
3446
|
+
id: data.statement_id ?? data.id,
|
|
2552
3447
|
sql,
|
|
2553
|
-
parameterCount: data.parameter_count
|
|
3448
|
+
parameterCount: data.parameter_count ?? data.parameters_count ?? 0
|
|
2554
3449
|
};
|
|
2555
3450
|
if (options.name) {
|
|
2556
3451
|
this.preparedStatements.set(options.name, prepared);
|
|
@@ -2567,7 +3462,7 @@ var SynapCores = class {
|
|
|
2567
3462
|
if (this.preparedStatements.has(statementId)) {
|
|
2568
3463
|
statementId = this.preparedStatements.get(statementId).id;
|
|
2569
3464
|
}
|
|
2570
|
-
const { data } = await this.httpClient.post("/
|
|
3465
|
+
const { data } = await this.httpClient.post("/query/exec", {
|
|
2571
3466
|
statement_id: statementId,
|
|
2572
3467
|
parameters: params
|
|
2573
3468
|
});
|
|
@@ -2587,10 +3482,10 @@ var SynapCores = class {
|
|
|
2587
3482
|
async deallocatePrepared(statementId) {
|
|
2588
3483
|
if (this.preparedStatements.has(statementId)) {
|
|
2589
3484
|
const prepared = this.preparedStatements.get(statementId);
|
|
2590
|
-
await this.httpClient.
|
|
3485
|
+
await this.httpClient.post("/query/close", { statement_id: prepared.id });
|
|
2591
3486
|
this.preparedStatements.delete(statementId);
|
|
2592
3487
|
} else {
|
|
2593
|
-
await this.httpClient.
|
|
3488
|
+
await this.httpClient.post("/query/close", { statement_id: statementId });
|
|
2594
3489
|
}
|
|
2595
3490
|
}
|
|
2596
3491
|
/**
|
|
@@ -2681,231 +3576,198 @@ var SynapCores = class {
|
|
|
2681
3576
|
if (vector1.length !== vector2.length) {
|
|
2682
3577
|
throw new VectorError("Vector dimensions must match", "DIMENSION_MISMATCH");
|
|
2683
3578
|
}
|
|
2684
|
-
const { data } = await this.httpClient.post("/
|
|
2685
|
-
|
|
2686
|
-
|
|
3579
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3580
|
+
op: "add",
|
|
3581
|
+
a: vector1,
|
|
3582
|
+
b: vector2
|
|
2687
3583
|
});
|
|
3584
|
+
const result = data.result ?? data.vector ?? [];
|
|
2688
3585
|
return {
|
|
2689
|
-
result: { values:
|
|
3586
|
+
result: { values: result, dimensions: result.length },
|
|
2690
3587
|
operation: "addition",
|
|
2691
3588
|
tookMs: data.took_ms
|
|
2692
3589
|
};
|
|
2693
3590
|
}
|
|
2694
3591
|
/**
|
|
2695
3592
|
* Performs vector subtraction
|
|
2696
|
-
* @param vector1 - First vector (minuend)
|
|
2697
|
-
* @param vector2 - Second vector (subtrahend)
|
|
2698
|
-
* @returns Promise resolving to vector subtraction result
|
|
2699
3593
|
*/
|
|
2700
3594
|
async vectorSubtract(vector1, vector2) {
|
|
2701
3595
|
if (vector1.length !== vector2.length) {
|
|
2702
3596
|
throw new VectorError("Vector dimensions must match", "DIMENSION_MISMATCH");
|
|
2703
3597
|
}
|
|
2704
|
-
const { data } = await this.httpClient.post("/
|
|
2705
|
-
|
|
2706
|
-
|
|
3598
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3599
|
+
op: "subtract",
|
|
3600
|
+
a: vector1,
|
|
3601
|
+
b: vector2
|
|
2707
3602
|
});
|
|
3603
|
+
const result = data.result ?? data.vector ?? [];
|
|
2708
3604
|
return {
|
|
2709
|
-
result: { values:
|
|
3605
|
+
result: { values: result, dimensions: result.length },
|
|
2710
3606
|
operation: "subtraction",
|
|
2711
3607
|
tookMs: data.took_ms
|
|
2712
3608
|
};
|
|
2713
3609
|
}
|
|
2714
3610
|
/**
|
|
2715
3611
|
* Performs scalar multiplication on a vector
|
|
2716
|
-
* @param vector - Input vector
|
|
2717
|
-
* @param scalar - Scalar value to multiply by
|
|
2718
|
-
* @returns Promise resolving to scalar multiplication result
|
|
2719
3612
|
*/
|
|
2720
3613
|
async vectorScalarMultiply(vector, scalar) {
|
|
2721
|
-
const { data } = await this.httpClient.post("/
|
|
2722
|
-
|
|
3614
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3615
|
+
op: "scalar_multiply",
|
|
3616
|
+
a: vector,
|
|
2723
3617
|
scalar
|
|
2724
3618
|
});
|
|
3619
|
+
const result = data.result ?? data.vector ?? [];
|
|
2725
3620
|
return {
|
|
2726
|
-
result: { values:
|
|
3621
|
+
result: { values: result, dimensions: result.length },
|
|
2727
3622
|
operation: "scalar_multiplication",
|
|
2728
3623
|
tookMs: data.took_ms
|
|
2729
3624
|
};
|
|
2730
3625
|
}
|
|
2731
3626
|
/**
|
|
2732
3627
|
* Calculates the dot product of two vectors
|
|
2733
|
-
* @param vector1 - First vector
|
|
2734
|
-
* @param vector2 - Second vector
|
|
2735
|
-
* @returns Promise resolving to dot product result
|
|
2736
3628
|
*/
|
|
2737
3629
|
async vectorDotProduct(vector1, vector2) {
|
|
2738
3630
|
if (vector1.length !== vector2.length) {
|
|
2739
3631
|
throw new VectorError("Vector dimensions must match", "DIMENSION_MISMATCH");
|
|
2740
3632
|
}
|
|
2741
|
-
const { data } = await this.httpClient.post("/
|
|
2742
|
-
|
|
2743
|
-
|
|
3633
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3634
|
+
op: "dot_product",
|
|
3635
|
+
a: vector1,
|
|
3636
|
+
b: vector2
|
|
2744
3637
|
});
|
|
2745
|
-
return {
|
|
2746
|
-
dotProduct: data.dot_product,
|
|
2747
|
-
tookMs: data.took_ms
|
|
2748
|
-
};
|
|
3638
|
+
return { dotProduct: data.scalar ?? data.dot_product ?? 0, tookMs: data.took_ms };
|
|
2749
3639
|
}
|
|
2750
3640
|
/**
|
|
2751
3641
|
* Calculates cosine similarity between two vectors
|
|
2752
|
-
* @param vector1 - First vector
|
|
2753
|
-
* @param vector2 - Second vector
|
|
2754
|
-
* @returns Promise resolving to cosine similarity result
|
|
2755
3642
|
*/
|
|
2756
3643
|
async cosineSimilarity(vector1, vector2) {
|
|
2757
3644
|
if (vector1.length !== vector2.length) {
|
|
2758
3645
|
throw new VectorError("Vector dimensions must match", "DIMENSION_MISMATCH");
|
|
2759
3646
|
}
|
|
2760
|
-
const { data } = await this.httpClient.post("/
|
|
2761
|
-
|
|
2762
|
-
|
|
3647
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3648
|
+
op: "cosine_similarity",
|
|
3649
|
+
a: vector1,
|
|
3650
|
+
b: vector2
|
|
2763
3651
|
});
|
|
2764
|
-
return {
|
|
2765
|
-
similarity: data.similarity,
|
|
2766
|
-
function: "cosine",
|
|
2767
|
-
tookMs: data.took_ms
|
|
2768
|
-
};
|
|
3652
|
+
return { similarity: data.scalar ?? data.similarity ?? 0, function: "cosine", tookMs: data.took_ms };
|
|
2769
3653
|
}
|
|
2770
3654
|
/**
|
|
2771
3655
|
* Calculates L2 (Euclidean) distance between two vectors
|
|
2772
|
-
* @param vector1 - First vector
|
|
2773
|
-
* @param vector2 - Second vector
|
|
2774
|
-
* @returns Promise resolving to L2 distance result
|
|
2775
3656
|
*/
|
|
2776
3657
|
async l2Distance(vector1, vector2) {
|
|
2777
3658
|
if (vector1.length !== vector2.length) {
|
|
2778
3659
|
throw new VectorError("Vector dimensions must match", "DIMENSION_MISMATCH");
|
|
2779
3660
|
}
|
|
2780
|
-
const { data } = await this.httpClient.post("/
|
|
2781
|
-
|
|
2782
|
-
|
|
3661
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3662
|
+
op: "l2_distance",
|
|
3663
|
+
a: vector1,
|
|
3664
|
+
b: vector2
|
|
2783
3665
|
});
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
similarity: data.distance,
|
|
2787
|
-
// Include similarity for compatibility
|
|
2788
|
-
function: "l2",
|
|
2789
|
-
tookMs: data.took_ms
|
|
2790
|
-
};
|
|
3666
|
+
const distance = data.scalar ?? data.distance ?? 0;
|
|
3667
|
+
return { distance, similarity: distance, function: "l2", tookMs: data.took_ms };
|
|
2791
3668
|
}
|
|
2792
3669
|
/**
|
|
2793
3670
|
* Calculates inner product between two vectors
|
|
2794
|
-
* @param vector1 - First vector
|
|
2795
|
-
* @param vector2 - Second vector
|
|
2796
|
-
* @returns Promise resolving to inner product result
|
|
2797
3671
|
*/
|
|
2798
3672
|
async innerProduct(vector1, vector2) {
|
|
2799
3673
|
if (vector1.length !== vector2.length) {
|
|
2800
3674
|
throw new VectorError("Vector dimensions must match", "DIMENSION_MISMATCH");
|
|
2801
3675
|
}
|
|
2802
|
-
const { data } = await this.httpClient.post("/
|
|
2803
|
-
|
|
2804
|
-
|
|
3676
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3677
|
+
op: "inner_product",
|
|
3678
|
+
a: vector1,
|
|
3679
|
+
b: vector2
|
|
2805
3680
|
});
|
|
2806
|
-
return {
|
|
2807
|
-
similarity: data.inner_product,
|
|
2808
|
-
function: "inner_product",
|
|
2809
|
-
tookMs: data.took_ms
|
|
2810
|
-
};
|
|
3681
|
+
return { similarity: data.scalar ?? data.inner_product ?? 0, function: "inner_product", tookMs: data.took_ms };
|
|
2811
3682
|
}
|
|
2812
3683
|
/**
|
|
2813
|
-
* Performs K-nearest neighbors vector search
|
|
2814
|
-
*
|
|
2815
|
-
* @returns Promise resolving to KNN search results
|
|
3684
|
+
* Performs K-nearest neighbors vector search.
|
|
3685
|
+
* v0.2.0: routes through /vectors/collections/:c/search with mode discriminator.
|
|
2816
3686
|
*/
|
|
2817
3687
|
async knnSearch(options) {
|
|
2818
|
-
const
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
metadata_columns: options.metadataColumns,
|
|
3688
|
+
const collection = options.collectionName ?? options.tableName;
|
|
3689
|
+
const { data } = await this.httpClient.post(`/vectors/collections/${collection}/search`, {
|
|
3690
|
+
mode: "knn",
|
|
3691
|
+
vector: options.queryVector,
|
|
3692
|
+
limit: options.k,
|
|
2824
3693
|
filter: options.filter
|
|
2825
3694
|
});
|
|
2826
|
-
return data.results.map((
|
|
2827
|
-
id:
|
|
2828
|
-
vector:
|
|
2829
|
-
similarity:
|
|
2830
|
-
distance:
|
|
2831
|
-
metadata:
|
|
3695
|
+
return (data.matches ?? data.results ?? []).map((r) => ({
|
|
3696
|
+
id: r.id,
|
|
3697
|
+
vector: r.vector,
|
|
3698
|
+
similarity: r.similarity,
|
|
3699
|
+
distance: r.distance,
|
|
3700
|
+
metadata: r.metadata
|
|
2832
3701
|
}));
|
|
2833
3702
|
}
|
|
2834
3703
|
/**
|
|
2835
|
-
* Performs range-based vector similarity search
|
|
2836
|
-
* @param options - Range search options
|
|
2837
|
-
* @returns Promise resolving to range search results
|
|
3704
|
+
* Performs range-based vector similarity search.
|
|
2838
3705
|
*/
|
|
2839
3706
|
async rangeSearch(options) {
|
|
2840
|
-
const
|
|
2841
|
-
|
|
3707
|
+
const collection = options.collectionName ?? options.tableName;
|
|
3708
|
+
const { data } = await this.httpClient.post(`/vectors/collections/${collection}/search`, {
|
|
3709
|
+
mode: "range",
|
|
3710
|
+
vector: options.queryVector,
|
|
2842
3711
|
threshold: options.threshold,
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
similarity: result.similarity,
|
|
2853
|
-
distance: result.distance,
|
|
2854
|
-
metadata: result.metadata
|
|
3712
|
+
max_results: options.maxResults,
|
|
3713
|
+
filter: options.filter
|
|
3714
|
+
});
|
|
3715
|
+
return (data.matches ?? data.results ?? []).map((r) => ({
|
|
3716
|
+
id: r.id,
|
|
3717
|
+
vector: r.vector,
|
|
3718
|
+
similarity: r.similarity,
|
|
3719
|
+
distance: r.distance,
|
|
3720
|
+
metadata: r.metadata
|
|
2855
3721
|
}));
|
|
2856
3722
|
}
|
|
2857
3723
|
/**
|
|
2858
|
-
* Performs hybrid search combining vector similarity and SQL filtering
|
|
2859
|
-
* @param options - Hybrid search options
|
|
2860
|
-
* @returns Promise resolving to hybrid search results
|
|
3724
|
+
* Performs hybrid search combining vector similarity and SQL filtering.
|
|
2861
3725
|
*/
|
|
2862
3726
|
async hybridSearch(options) {
|
|
2863
|
-
const
|
|
3727
|
+
const collection = options.collectionName ?? options.tableName;
|
|
3728
|
+
const { data } = await this.httpClient.post(`/vectors/collections/${collection}/search`, {
|
|
3729
|
+
mode: "hybrid",
|
|
2864
3730
|
vector: options.vector,
|
|
2865
3731
|
text_query: options.textQuery,
|
|
2866
3732
|
sql_filter: options.sqlFilter,
|
|
2867
|
-
|
|
3733
|
+
limit: options.k,
|
|
2868
3734
|
threshold: options.threshold,
|
|
2869
3735
|
metric: options.metric,
|
|
2870
3736
|
filter: options.filter,
|
|
2871
3737
|
weights: options.weights
|
|
2872
3738
|
});
|
|
2873
|
-
return data.results.map((
|
|
2874
|
-
id:
|
|
2875
|
-
vector:
|
|
2876
|
-
similarity:
|
|
2877
|
-
distance:
|
|
2878
|
-
metadata:
|
|
3739
|
+
return (data.matches ?? data.results ?? []).map((r) => ({
|
|
3740
|
+
id: r.id,
|
|
3741
|
+
vector: r.vector,
|
|
3742
|
+
similarity: r.similarity,
|
|
3743
|
+
distance: r.distance,
|
|
3744
|
+
metadata: r.metadata
|
|
2879
3745
|
}));
|
|
2880
3746
|
}
|
|
2881
3747
|
/**
|
|
2882
3748
|
* Normalizes a vector to unit length
|
|
2883
|
-
* @param vector - Input vector to normalize
|
|
2884
|
-
* @returns Promise resolving to normalized vector
|
|
2885
3749
|
*/
|
|
2886
3750
|
async normalizeVector(vector) {
|
|
2887
|
-
const { data } = await this.httpClient.post("/
|
|
2888
|
-
|
|
3751
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3752
|
+
op: "normalize",
|
|
3753
|
+
a: vector
|
|
2889
3754
|
});
|
|
3755
|
+
const result = data.result ?? data.vector ?? [];
|
|
2890
3756
|
return {
|
|
2891
|
-
result: { values:
|
|
3757
|
+
result: { values: result, dimensions: result.length },
|
|
2892
3758
|
operation: "normalization",
|
|
2893
3759
|
tookMs: data.took_ms
|
|
2894
3760
|
};
|
|
2895
3761
|
}
|
|
2896
3762
|
/**
|
|
2897
3763
|
* Calculates the magnitude (length) of a vector
|
|
2898
|
-
* @param vector - Input vector
|
|
2899
|
-
* @returns Promise resolving to vector magnitude
|
|
2900
3764
|
*/
|
|
2901
3765
|
async vectorMagnitude(vector) {
|
|
2902
|
-
const { data } = await this.httpClient.post("/
|
|
2903
|
-
|
|
3766
|
+
const { data } = await this.httpClient.post("/vector-algebra/operation", {
|
|
3767
|
+
op: "magnitude",
|
|
3768
|
+
a: vector
|
|
2904
3769
|
});
|
|
2905
|
-
return {
|
|
2906
|
-
magnitude: data.magnitude,
|
|
2907
|
-
tookMs: data.took_ms
|
|
2908
|
-
};
|
|
3770
|
+
return { magnitude: data.scalar ?? data.magnitude ?? 0, tookMs: data.took_ms };
|
|
2909
3771
|
}
|
|
2910
3772
|
// =================================================================
|
|
2911
3773
|
// AUTHENTICATION & USER MANAGEMENT
|
|
@@ -2937,16 +3799,26 @@ var SynapCores = class {
|
|
|
2937
3799
|
return data;
|
|
2938
3800
|
}
|
|
2939
3801
|
/**
|
|
2940
|
-
* Refresh JWT token
|
|
3802
|
+
* Refresh JWT token.
|
|
3803
|
+
*
|
|
3804
|
+
* v0.2.0: the gateway does not currently expose a refresh endpoint —
|
|
3805
|
+
* this method now re-runs login() with the same credentials. Pass
|
|
3806
|
+
* the credentials in the call site (or supply them at SDK construction
|
|
3807
|
+
* time and we'll re-use the cached pair).
|
|
2941
3808
|
*/
|
|
2942
|
-
async refreshToken() {
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3809
|
+
async refreshToken(credentials) {
|
|
3810
|
+
if (credentials?.username && credentials?.password) {
|
|
3811
|
+
const login = await this.login({ username: credentials.username, password: credentials.password });
|
|
3812
|
+
return {
|
|
3813
|
+
access_token: login.access_token,
|
|
3814
|
+
refresh_token: "",
|
|
3815
|
+
token_type: "Bearer",
|
|
3816
|
+
expires_in: login.expires_in
|
|
3817
|
+
};
|
|
2948
3818
|
}
|
|
2949
|
-
|
|
3819
|
+
throw new ValidationError(
|
|
3820
|
+
"refreshToken now requires credentials \u2014 the gateway has no /auth/refresh endpoint in v1.5.0-ce. Pass {username, password} or call login() again."
|
|
3821
|
+
);
|
|
2950
3822
|
}
|
|
2951
3823
|
/**
|
|
2952
3824
|
* Set JWT token manually (useful after login)
|
|
@@ -3077,7 +3949,7 @@ var SynapCores = class {
|
|
|
3077
3949
|
|
|
3078
3950
|
// src/index.ts
|
|
3079
3951
|
var import_zod = require("zod");
|
|
3080
|
-
var VERSION = "0.
|
|
3952
|
+
var VERSION = "0.2.0";
|
|
3081
3953
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3082
3954
|
0 && (module.exports = {
|
|
3083
3955
|
AuthenticationError,
|
|
@@ -3085,10 +3957,16 @@ var VERSION = "0.1.0";
|
|
|
3085
3957
|
AutoMLModel,
|
|
3086
3958
|
BackupClient,
|
|
3087
3959
|
BatchOperationError,
|
|
3960
|
+
ChatClient,
|
|
3088
3961
|
Collection,
|
|
3089
3962
|
ConnectionError,
|
|
3963
|
+
FilesystemCollectionsClient,
|
|
3964
|
+
GraphClient,
|
|
3090
3965
|
ImportExportClient,
|
|
3091
3966
|
IntegrationClient,
|
|
3967
|
+
McpClient,
|
|
3968
|
+
MultimodalClient,
|
|
3969
|
+
NL2SqlClient,
|
|
3092
3970
|
NLPClient,
|
|
3093
3971
|
NotFoundError,
|
|
3094
3972
|
RateLimitError,
|
|
@@ -3099,8 +3977,11 @@ var VERSION = "0.1.0";
|
|
|
3099
3977
|
Subscription,
|
|
3100
3978
|
SynapCores,
|
|
3101
3979
|
SynapCoresError,
|
|
3980
|
+
SystemClient,
|
|
3102
3981
|
TimeoutError,
|
|
3103
3982
|
TransactionError,
|
|
3983
|
+
TransactionsClient,
|
|
3984
|
+
Tx,
|
|
3104
3985
|
VERSION,
|
|
3105
3986
|
ValidationError,
|
|
3106
3987
|
VectorError,
|