@centia-io/sdk 0.2.15 → 0.2.16
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 +48 -0
- package/dist/centia-io-sdk.cjs +125 -9
- package/dist/centia-io-sdk.d.cts +155 -6
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +155 -6
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +125 -10
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +125 -9
- package/package.json +1 -1
|
@@ -3463,12 +3463,6 @@
|
|
|
3463
3463
|
relationPath(schema, relation, rest = "") {
|
|
3464
3464
|
return `api/v4/schemas/${encodeURIComponent(schema)}/relations/${encodeURIComponent(relation)}/snapshots${rest}`;
|
|
3465
3465
|
}
|
|
3466
|
-
/**
|
|
3467
|
-
* Queue a Parquet snapshot of a table or view. Returns 202 with the job id.
|
|
3468
|
-
* Throws `CentiaApiError`: 403 (super-user only), 404 (relation not found),
|
|
3469
|
-
* 409 (a snapshot of the relation is already pending or running),
|
|
3470
|
-
* 501 (snapshot storage not configured).
|
|
3471
|
-
*/
|
|
3472
3466
|
async postSnapshot(body) {
|
|
3473
3467
|
return this.client.request({
|
|
3474
3468
|
path: "api/v4/snapshots",
|
|
@@ -3477,10 +3471,11 @@
|
|
|
3477
3471
|
expectedStatus: 202
|
|
3478
3472
|
});
|
|
3479
3473
|
}
|
|
3480
|
-
/** Get a snapshot job by id. Super-user only. */
|
|
3481
3474
|
async getSnapshot(id) {
|
|
3482
|
-
|
|
3483
|
-
|
|
3475
|
+
var _this2 = this;
|
|
3476
|
+
const keys = Array.isArray(id) ? id : [id];
|
|
3477
|
+
return _this2.client.request({
|
|
3478
|
+
path: `api/v4/snapshots/${keys.map((k) => encodeURIComponent(k)).join(",")}`,
|
|
3484
3479
|
method: "GET"
|
|
3485
3480
|
});
|
|
3486
3481
|
}
|
|
@@ -3581,6 +3576,126 @@
|
|
|
3581
3576
|
}
|
|
3582
3577
|
};
|
|
3583
3578
|
|
|
3579
|
+
//#endregion
|
|
3580
|
+
//#region src/scheduler/Scheduler.ts
|
|
3581
|
+
function idsPath(id) {
|
|
3582
|
+
return (Array.isArray(id) ? id : [id]).map((k) => encodeURIComponent(String(k))).join(",");
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Client for the scheduler API (`/api/v4/scheduler`). Super-user only.
|
|
3586
|
+
*
|
|
3587
|
+
* Jobs describe recurring data imports (cron-scheduled); runs are their
|
|
3588
|
+
* executions. Starting a run is asynchronous — poll `getSchedulerRuns`
|
|
3589
|
+
* (the `_links.runs` of the 202) until the run finishes.
|
|
3590
|
+
*
|
|
3591
|
+
* ```ts
|
|
3592
|
+
* const scheduler = new Scheduler(createCentiaClient({ baseUrl, auth }));
|
|
3593
|
+
* const { ids } = await scheduler.postSchedulerJob({ name, schema, url, schedule: '0 3 * * *' });
|
|
3594
|
+
* await scheduler.postSchedulerRun({ job: ids[0] });
|
|
3595
|
+
* ```
|
|
3596
|
+
*/
|
|
3597
|
+
var Scheduler = class {
|
|
3598
|
+
constructor(client) {
|
|
3599
|
+
this.client = client;
|
|
3600
|
+
}
|
|
3601
|
+
/** List all scheduler jobs. */
|
|
3602
|
+
async getSchedulerJobs() {
|
|
3603
|
+
return this.client.request({
|
|
3604
|
+
path: "api/v4/scheduler/jobs",
|
|
3605
|
+
method: "GET"
|
|
3606
|
+
});
|
|
3607
|
+
}
|
|
3608
|
+
async getSchedulerJob(id) {
|
|
3609
|
+
return this.client.request({
|
|
3610
|
+
path: `api/v4/scheduler/jobs/${idsPath(id)}`,
|
|
3611
|
+
method: "GET"
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
/**
|
|
3615
|
+
* Create one or more jobs (201; all-or-nothing for arrays). Returns the
|
|
3616
|
+
* Location header and the new ids parsed from it, in request order.
|
|
3617
|
+
*/
|
|
3618
|
+
async postSchedulerJob(body) {
|
|
3619
|
+
var _this3 = this;
|
|
3620
|
+
var _res$getHeader, _location$split$pop;
|
|
3621
|
+
const location = (_res$getHeader = (await _this3.client.requestFull({
|
|
3622
|
+
path: "api/v4/scheduler/jobs",
|
|
3623
|
+
method: "POST",
|
|
3624
|
+
body,
|
|
3625
|
+
expectedStatus: 201
|
|
3626
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "";
|
|
3627
|
+
return {
|
|
3628
|
+
location,
|
|
3629
|
+
ids: ((_location$split$pop = location.split("/").pop()) !== null && _location$split$pop !== void 0 ? _location$split$pop : "").split(",").map((s) => Number(s)).filter((n) => Number.isFinite(n))
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3632
|
+
/** Partially update a job (303 + Location). */
|
|
3633
|
+
async patchSchedulerJob(id, body) {
|
|
3634
|
+
var _this4 = this;
|
|
3635
|
+
var _res$getHeader2;
|
|
3636
|
+
return { location: (_res$getHeader2 = (await _this4.client.requestFull({
|
|
3637
|
+
path: `api/v4/scheduler/jobs/${idsPath(id)}`,
|
|
3638
|
+
method: "PATCH",
|
|
3639
|
+
body,
|
|
3640
|
+
expectedStatus: 303
|
|
3641
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
3642
|
+
}
|
|
3643
|
+
/**
|
|
3644
|
+
* Delete one or more jobs (204). Nothing is deleted if any id fails:
|
|
3645
|
+
* throws 404 (unknown id) or 409 (a run is in progress).
|
|
3646
|
+
*/
|
|
3647
|
+
async deleteSchedulerJob(id) {
|
|
3648
|
+
await this.client.request({
|
|
3649
|
+
path: `api/v4/scheduler/jobs/${idsPath(id)}`,
|
|
3650
|
+
method: "DELETE",
|
|
3651
|
+
expectedStatus: 204
|
|
3652
|
+
});
|
|
3653
|
+
}
|
|
3654
|
+
/** List runs (running plus the newest 50 finished), optionally filtered by job and status. */
|
|
3655
|
+
async getSchedulerRuns(options) {
|
|
3656
|
+
var _this6 = this;
|
|
3657
|
+
const query = {};
|
|
3658
|
+
if ((options === null || options === void 0 ? void 0 : options.job) !== void 0) query.job = String(options.job);
|
|
3659
|
+
if ((options === null || options === void 0 ? void 0 : options.status) !== void 0) query.status = options.status;
|
|
3660
|
+
return _this6.client.request({
|
|
3661
|
+
path: "api/v4/scheduler/runs",
|
|
3662
|
+
method: "GET",
|
|
3663
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
3664
|
+
});
|
|
3665
|
+
}
|
|
3666
|
+
/** Get one run by uuid. */
|
|
3667
|
+
async getSchedulerRun(uuid) {
|
|
3668
|
+
return this.client.request({
|
|
3669
|
+
path: `api/v4/scheduler/runs/${encodeURIComponent(uuid)}`,
|
|
3670
|
+
method: "GET"
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
/**
|
|
3674
|
+
* Start a run of a job (202). Throws 404 (unknown job) or 409 (a run of
|
|
3675
|
+
* the job is already running).
|
|
3676
|
+
*/
|
|
3677
|
+
async postSchedulerRun(body) {
|
|
3678
|
+
return this.client.request({
|
|
3679
|
+
path: "api/v4/scheduler/runs",
|
|
3680
|
+
method: "POST",
|
|
3681
|
+
body,
|
|
3682
|
+
expectedStatus: 202
|
|
3683
|
+
});
|
|
3684
|
+
}
|
|
3685
|
+
/**
|
|
3686
|
+
* Stop a running run: sends SIGINT, which the server escalates to SIGKILL
|
|
3687
|
+
* after 30 s — the request itself can take up to ~30 s, so do not use a
|
|
3688
|
+
* short timeout. Throws 404 (no running run with that uuid) or 409 (the
|
|
3689
|
+
* run is on another host).
|
|
3690
|
+
*/
|
|
3691
|
+
async deleteSchedulerRun(uuid) {
|
|
3692
|
+
return this.client.request({
|
|
3693
|
+
path: `api/v4/scheduler/runs/${encodeURIComponent(uuid)}`,
|
|
3694
|
+
method: "DELETE"
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3698
|
+
|
|
3584
3699
|
//#endregion
|
|
3585
3700
|
//#region src/auth/errors.ts
|
|
3586
3701
|
/**
|
|
@@ -3718,6 +3833,7 @@ exports.Ogc = Ogc;
|
|
|
3718
3833
|
exports.Ows = Ows;
|
|
3719
3834
|
exports.PasswordFlow = PasswordFlow;
|
|
3720
3835
|
exports.Rpc = Rpc;
|
|
3836
|
+
exports.Scheduler = Scheduler;
|
|
3721
3837
|
exports.SessionExpiredError = SessionExpiredError;
|
|
3722
3838
|
exports.SignUp = SignUp;
|
|
3723
3839
|
exports.Snapshots = Snapshots;
|