@centia-io/sdk 0.2.15 → 0.2.17
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 +57 -1
- package/dist/centia-io-sdk.cjs +153 -15
- package/dist/centia-io-sdk.d.cts +204 -7
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +204 -7
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +153 -16
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +153 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -612,7 +612,18 @@ import { createCentiaClient, Snapshots } from '@centia-io/sdk'
|
|
|
612
612
|
const snapshots = new Snapshots(http)
|
|
613
613
|
|
|
614
614
|
// Queue an export (202; super-user only). The export runs asynchronously.
|
|
615
|
-
|
|
615
|
+
// formats picks the output format(s) — 'parquet' (default) and/or 'flatgeobuf'.
|
|
616
|
+
const { id } = await snapshots.postSnapshot({
|
|
617
|
+
schema: 'geodanmark', relation: 'bygning', srs: 25832, formats: ['parquet', 'flatgeobuf'],
|
|
618
|
+
})
|
|
619
|
+
|
|
620
|
+
// Or queue several at once (all-or-nothing; accepted jobs come back in request order).
|
|
621
|
+
// getSnapshot also accepts an array of ids.
|
|
622
|
+
const accepted = await snapshots.postSnapshot([
|
|
623
|
+
{ schema: 'geodanmark', relation: 'bygning' },
|
|
624
|
+
{ schema: 'geodanmark', relation: 'vej' },
|
|
625
|
+
])
|
|
626
|
+
const both = await snapshots.getSnapshot(accepted.map((a) => a.id))
|
|
616
627
|
|
|
617
628
|
// Poll until it finishes (succeeded/failed/superseded) — or use getSnapshot(id) yourself
|
|
618
629
|
const job = await snapshots.waitForSnapshot(id, { intervalMs: 2000, timeoutMs: 300_000 })
|
|
@@ -632,10 +643,55 @@ const url = snapshots.getRelationSnapshotDataUrl('geodanmark', 'bygning', '2026-
|
|
|
632
643
|
const head = await snapshots.headRelationSnapshotData('geodanmark', 'bygning', '2026-09-16') // Content-Length/ETag
|
|
633
644
|
const part = await snapshots.getRelationSnapshotData('geodanmark', 'bygning', '2026-09-16', { range: [0, 1023] })
|
|
634
645
|
const file = await snapshots.getRelationSnapshotFile('geodanmark', 'bygning', '2026-09-16', 'metadata-<id>.json')
|
|
646
|
+
|
|
647
|
+
// One specific output format ('parquet' | 'flatgeobuf'). The snapshot's
|
|
648
|
+
// `formats` array says what was produced (status/size/media_type/href).
|
|
649
|
+
const fgbUrl = snapshots.getRelationSnapshotDataFormatUrl('geodanmark', 'bygning', '2026-09-16', 'flatgeobuf')
|
|
650
|
+
const fgb = await snapshots.getRelationSnapshotDataFormat('geodanmark', 'bygning', '2026-09-16', 'flatgeobuf', { range: [0, 1023] })
|
|
635
651
|
```
|
|
636
652
|
|
|
637
653
|
The job API is super-user only (403 `SUPER_USER_ONLY`); creating throws 404 (relation not found), 409 (a snapshot of the relation is already pending or running) or 501 (snapshot storage not configured). The read API needs read access to the relation — sub-users with a deny/limit geofence rule get 403 `GEOFENCE_RULES_APPLY`. A snapshot with several data files answers 409 `MULTI_FILE_SNAPSHOT` on `/data`; list `files` in the metadata and fetch them with `getRelationSnapshotFile`.
|
|
638
654
|
|
|
655
|
+
## Scheduler (recurring imports)
|
|
656
|
+
|
|
657
|
+
`Scheduler` wraps the scheduler API: cron-scheduled data-import jobs and their runs. Super-user only. It takes a `CentiaHttpClient` and requires a Bearer token:
|
|
658
|
+
|
|
659
|
+
```ts
|
|
660
|
+
import { createCentiaClient, Scheduler } from '@centia-io/sdk'
|
|
661
|
+
|
|
662
|
+
const scheduler = new Scheduler(http)
|
|
663
|
+
|
|
664
|
+
// Create one or more jobs (201; arrays are all-or-nothing). The new ids are
|
|
665
|
+
// parsed from the Location header, in request order.
|
|
666
|
+
const { ids } = await scheduler.postSchedulerJob({
|
|
667
|
+
name: 'import buildings',
|
|
668
|
+
schema: 'geodanmark',
|
|
669
|
+
url: 'https://example.com/data.zip',
|
|
670
|
+
schedule: '0 3 * * *', // 5-field cron
|
|
671
|
+
epsg: 25832, // defaults: epsg 4326, type "AUTO", encoding "UTF8",
|
|
672
|
+
}) // delete_append false, download_schema true, active true, snapshot false
|
|
673
|
+
|
|
674
|
+
// Read jobs — a single id returns one job, an array returns an array
|
|
675
|
+
const jobs = await scheduler.getSchedulerJobs()
|
|
676
|
+
const job = await scheduler.getSchedulerJob(ids[0])
|
|
677
|
+
const some = await scheduler.getSchedulerJob([5497, 5498])
|
|
678
|
+
|
|
679
|
+
// Update / delete (delete is all-or-nothing; 409 if a run is in progress)
|
|
680
|
+
await scheduler.patchSchedulerJob(ids[0], { active: false })
|
|
681
|
+
await scheduler.deleteSchedulerJob([5497, 5498])
|
|
682
|
+
|
|
683
|
+
// Runs. Starting is asynchronous (202) — poll getSchedulerRuns until it finishes.
|
|
684
|
+
await scheduler.postSchedulerRun({ job: ids[0], force: true }) // force ignores delete_append and overwrites
|
|
685
|
+
const runs = await scheduler.getSchedulerRuns({ job: ids[0], status: 'running' })
|
|
686
|
+
const run = await scheduler.getSchedulerRun(runs[0].uuid)
|
|
687
|
+
|
|
688
|
+
// Stop a running run: SIGINT, escalated to SIGKILL by the server after 30 s.
|
|
689
|
+
// The request itself can take up to ~30 s — do not use a short timeout.
|
|
690
|
+
const { signal } = await scheduler.deleteSchedulerRun(runs[0].uuid)
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
Errors throw `CentiaApiError` with status/code: 400 `INVALID_CRON_FIELD`/`INPUT_VALIDATION_ERROR`, 404 `JOB_NOT_FOUND`/`RUN_NOT_FOUND`, 409 `JOB_RUNNING`.
|
|
694
|
+
|
|
639
695
|
## Error handling
|
|
640
696
|
|
|
641
697
|
- Network/HTTP errors: thrown as `Error` with the status/body text when available.
|
package/dist/centia-io-sdk.cjs
CHANGED
|
@@ -3458,12 +3458,6 @@ var Snapshots = class {
|
|
|
3458
3458
|
relationPath(schema, relation, rest = "") {
|
|
3459
3459
|
return `api/v4/schemas/${encodeURIComponent(schema)}/relations/${encodeURIComponent(relation)}/snapshots${rest}`;
|
|
3460
3460
|
}
|
|
3461
|
-
/**
|
|
3462
|
-
* Queue a Parquet snapshot of a table or view. Returns 202 with the job id.
|
|
3463
|
-
* Throws `CentiaApiError`: 403 (super-user only), 404 (relation not found),
|
|
3464
|
-
* 409 (a snapshot of the relation is already pending or running),
|
|
3465
|
-
* 501 (snapshot storage not configured).
|
|
3466
|
-
*/
|
|
3467
3461
|
async postSnapshot(body) {
|
|
3468
3462
|
return this.client.request({
|
|
3469
3463
|
path: "api/v4/snapshots",
|
|
@@ -3472,10 +3466,11 @@ var Snapshots = class {
|
|
|
3472
3466
|
expectedStatus: 202
|
|
3473
3467
|
});
|
|
3474
3468
|
}
|
|
3475
|
-
/** Get a snapshot job by id. Super-user only. */
|
|
3476
3469
|
async getSnapshot(id) {
|
|
3477
|
-
|
|
3478
|
-
|
|
3470
|
+
var _this2 = this;
|
|
3471
|
+
const keys = Array.isArray(id) ? id : [id];
|
|
3472
|
+
return _this2.client.request({
|
|
3473
|
+
path: `api/v4/snapshots/${keys.map((k) => encodeURIComponent(k)).join(",")}`,
|
|
3479
3474
|
method: "GET"
|
|
3480
3475
|
});
|
|
3481
3476
|
}
|
|
@@ -3550,24 +3545,46 @@ var Snapshots = class {
|
|
|
3550
3545
|
return _this8.rawGet(_this8.relationPath(schema, relation, `/${encodeURIComponent(date)}/data`), "HEAD");
|
|
3551
3546
|
}
|
|
3552
3547
|
/**
|
|
3548
|
+
* Absolute URL of one output format of the snapshot, without fetching it —
|
|
3549
|
+
* for DuckDB/GDAL or a plain fetch.
|
|
3550
|
+
*/
|
|
3551
|
+
getRelationSnapshotDataFormatUrl(schema, relation, date, format) {
|
|
3552
|
+
return `${this.client.baseUrl}/${this.relationPath(schema, relation, `/${encodeURIComponent(date)}/data/${encodeURIComponent(format)}`)}`;
|
|
3553
|
+
}
|
|
3554
|
+
/**
|
|
3555
|
+
* Fetch one output format of the snapshot (Content-Type is the format's
|
|
3556
|
+
* media type). Same redirect/range semantics as getRelationSnapshotData.
|
|
3557
|
+
* Throws `CentiaApiError`: 400 (unknown format id), 404 (no snapshot for
|
|
3558
|
+
* that date, or the format was skipped/not requested), 403, 416, 502.
|
|
3559
|
+
*/
|
|
3560
|
+
async getRelationSnapshotDataFormat(schema, relation, date, format, options) {
|
|
3561
|
+
var _this9 = this;
|
|
3562
|
+
return _this9.rawGet(_this9.relationPath(schema, relation, `/${encodeURIComponent(date)}/data/${encodeURIComponent(format)}`), "GET", options);
|
|
3563
|
+
}
|
|
3564
|
+
/** HEAD request for one output format of the snapshot. */
|
|
3565
|
+
async headRelationSnapshotDataFormat(schema, relation, date, format) {
|
|
3566
|
+
var _this10 = this;
|
|
3567
|
+
return _this10.rawGet(_this10.relationPath(schema, relation, `/${encodeURIComponent(date)}/data/${encodeURIComponent(format)}`), "HEAD");
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3553
3570
|
* Fetch one file of the snapshot by catalog name (`data-<id>.parquet`,
|
|
3554
3571
|
* `metadata-<id>.json`). Same redirect/range semantics as
|
|
3555
3572
|
* getRelationSnapshotData.
|
|
3556
3573
|
*/
|
|
3557
3574
|
async getRelationSnapshotFile(schema, relation, date, file, options) {
|
|
3558
|
-
var
|
|
3559
|
-
return
|
|
3575
|
+
var _this11 = this;
|
|
3576
|
+
return _this11.rawGet(_this11.relationPath(schema, relation, `/${encodeURIComponent(date)}/files/${encodeURIComponent(file)}`), "GET", options);
|
|
3560
3577
|
}
|
|
3561
3578
|
/** HEAD request for one file of the snapshot. */
|
|
3562
3579
|
async headRelationSnapshotFile(schema, relation, date, file) {
|
|
3563
|
-
var
|
|
3564
|
-
return
|
|
3580
|
+
var _this12 = this;
|
|
3581
|
+
return _this12.rawGet(_this12.relationPath(schema, relation, `/${encodeURIComponent(date)}/files/${encodeURIComponent(file)}`), "HEAD");
|
|
3565
3582
|
}
|
|
3566
3583
|
async rawGet(path, method, options) {
|
|
3567
|
-
var
|
|
3584
|
+
var _this13 = this;
|
|
3568
3585
|
const headers = {};
|
|
3569
3586
|
if (options === null || options === void 0 ? void 0 : options.range) headers["Range"] = `bytes=${options.range[0]}-${options.range[1]}`;
|
|
3570
|
-
return
|
|
3587
|
+
return _this13.client.requestRaw({
|
|
3571
3588
|
path,
|
|
3572
3589
|
method,
|
|
3573
3590
|
headers: Object.keys(headers).length > 0 ? headers : void 0,
|
|
@@ -3576,6 +3593,126 @@ var Snapshots = class {
|
|
|
3576
3593
|
}
|
|
3577
3594
|
};
|
|
3578
3595
|
|
|
3596
|
+
//#endregion
|
|
3597
|
+
//#region src/scheduler/Scheduler.ts
|
|
3598
|
+
function idsPath(id) {
|
|
3599
|
+
return (Array.isArray(id) ? id : [id]).map((k) => encodeURIComponent(String(k))).join(",");
|
|
3600
|
+
}
|
|
3601
|
+
/**
|
|
3602
|
+
* Client for the scheduler API (`/api/v4/scheduler`). Super-user only.
|
|
3603
|
+
*
|
|
3604
|
+
* Jobs describe recurring data imports (cron-scheduled); runs are their
|
|
3605
|
+
* executions. Starting a run is asynchronous — poll `getSchedulerRuns`
|
|
3606
|
+
* (the `_links.runs` of the 202) until the run finishes.
|
|
3607
|
+
*
|
|
3608
|
+
* ```ts
|
|
3609
|
+
* const scheduler = new Scheduler(createCentiaClient({ baseUrl, auth }));
|
|
3610
|
+
* const { ids } = await scheduler.postSchedulerJob({ name, schema, url, schedule: '0 3 * * *' });
|
|
3611
|
+
* await scheduler.postSchedulerRun({ job: ids[0] });
|
|
3612
|
+
* ```
|
|
3613
|
+
*/
|
|
3614
|
+
var Scheduler = class {
|
|
3615
|
+
constructor(client) {
|
|
3616
|
+
this.client = client;
|
|
3617
|
+
}
|
|
3618
|
+
/** List all scheduler jobs. */
|
|
3619
|
+
async getSchedulerJobs() {
|
|
3620
|
+
return this.client.request({
|
|
3621
|
+
path: "api/v4/scheduler/jobs",
|
|
3622
|
+
method: "GET"
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
3625
|
+
async getSchedulerJob(id) {
|
|
3626
|
+
return this.client.request({
|
|
3627
|
+
path: `api/v4/scheduler/jobs/${idsPath(id)}`,
|
|
3628
|
+
method: "GET"
|
|
3629
|
+
});
|
|
3630
|
+
}
|
|
3631
|
+
/**
|
|
3632
|
+
* Create one or more jobs (201; all-or-nothing for arrays). Returns the
|
|
3633
|
+
* Location header and the new ids parsed from it, in request order.
|
|
3634
|
+
*/
|
|
3635
|
+
async postSchedulerJob(body) {
|
|
3636
|
+
var _this3 = this;
|
|
3637
|
+
var _res$getHeader, _location$split$pop;
|
|
3638
|
+
const location = (_res$getHeader = (await _this3.client.requestFull({
|
|
3639
|
+
path: "api/v4/scheduler/jobs",
|
|
3640
|
+
method: "POST",
|
|
3641
|
+
body,
|
|
3642
|
+
expectedStatus: 201
|
|
3643
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "";
|
|
3644
|
+
return {
|
|
3645
|
+
location,
|
|
3646
|
+
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))
|
|
3647
|
+
};
|
|
3648
|
+
}
|
|
3649
|
+
/** Partially update a job (303 + Location). */
|
|
3650
|
+
async patchSchedulerJob(id, body) {
|
|
3651
|
+
var _this4 = this;
|
|
3652
|
+
var _res$getHeader2;
|
|
3653
|
+
return { location: (_res$getHeader2 = (await _this4.client.requestFull({
|
|
3654
|
+
path: `api/v4/scheduler/jobs/${idsPath(id)}`,
|
|
3655
|
+
method: "PATCH",
|
|
3656
|
+
body,
|
|
3657
|
+
expectedStatus: 303
|
|
3658
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
3659
|
+
}
|
|
3660
|
+
/**
|
|
3661
|
+
* Delete one or more jobs (204). Nothing is deleted if any id fails:
|
|
3662
|
+
* throws 404 (unknown id) or 409 (a run is in progress).
|
|
3663
|
+
*/
|
|
3664
|
+
async deleteSchedulerJob(id) {
|
|
3665
|
+
await this.client.request({
|
|
3666
|
+
path: `api/v4/scheduler/jobs/${idsPath(id)}`,
|
|
3667
|
+
method: "DELETE",
|
|
3668
|
+
expectedStatus: 204
|
|
3669
|
+
});
|
|
3670
|
+
}
|
|
3671
|
+
/** List runs (running plus the newest 50 finished), optionally filtered by job and status. */
|
|
3672
|
+
async getSchedulerRuns(options) {
|
|
3673
|
+
var _this6 = this;
|
|
3674
|
+
const query = {};
|
|
3675
|
+
if ((options === null || options === void 0 ? void 0 : options.job) !== void 0) query.job = String(options.job);
|
|
3676
|
+
if ((options === null || options === void 0 ? void 0 : options.status) !== void 0) query.status = options.status;
|
|
3677
|
+
return _this6.client.request({
|
|
3678
|
+
path: "api/v4/scheduler/runs",
|
|
3679
|
+
method: "GET",
|
|
3680
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
3681
|
+
});
|
|
3682
|
+
}
|
|
3683
|
+
/** Get one run by uuid. */
|
|
3684
|
+
async getSchedulerRun(uuid) {
|
|
3685
|
+
return this.client.request({
|
|
3686
|
+
path: `api/v4/scheduler/runs/${encodeURIComponent(uuid)}`,
|
|
3687
|
+
method: "GET"
|
|
3688
|
+
});
|
|
3689
|
+
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Start a run of a job (202). Throws 404 (unknown job) or 409 (a run of
|
|
3692
|
+
* the job is already running).
|
|
3693
|
+
*/
|
|
3694
|
+
async postSchedulerRun(body) {
|
|
3695
|
+
return this.client.request({
|
|
3696
|
+
path: "api/v4/scheduler/runs",
|
|
3697
|
+
method: "POST",
|
|
3698
|
+
body,
|
|
3699
|
+
expectedStatus: 202
|
|
3700
|
+
});
|
|
3701
|
+
}
|
|
3702
|
+
/**
|
|
3703
|
+
* Stop a running run: sends SIGINT, which the server escalates to SIGKILL
|
|
3704
|
+
* after 30 s — the request itself can take up to ~30 s, so do not use a
|
|
3705
|
+
* short timeout. Throws 404 (no running run with that uuid) or 409 (the
|
|
3706
|
+
* run is on another host).
|
|
3707
|
+
*/
|
|
3708
|
+
async deleteSchedulerRun(uuid) {
|
|
3709
|
+
return this.client.request({
|
|
3710
|
+
path: `api/v4/scheduler/runs/${encodeURIComponent(uuid)}`,
|
|
3711
|
+
method: "DELETE"
|
|
3712
|
+
});
|
|
3713
|
+
}
|
|
3714
|
+
};
|
|
3715
|
+
|
|
3579
3716
|
//#endregion
|
|
3580
3717
|
//#region src/auth/errors.ts
|
|
3581
3718
|
/**
|
|
@@ -3713,6 +3850,7 @@ exports.Ogc = Ogc;
|
|
|
3713
3850
|
exports.Ows = Ows;
|
|
3714
3851
|
exports.PasswordFlow = PasswordFlow;
|
|
3715
3852
|
exports.Rpc = Rpc;
|
|
3853
|
+
exports.Scheduler = Scheduler;
|
|
3716
3854
|
exports.SessionExpiredError = SessionExpiredError;
|
|
3717
3855
|
exports.SignUp = SignUp;
|
|
3718
3856
|
exports.Snapshots = Snapshots;
|
package/dist/centia-io-sdk.d.cts
CHANGED
|
@@ -1993,7 +1993,29 @@ declare class Keyvalue {
|
|
|
1993
1993
|
//#region src/snapshots/Snapshots.d.ts
|
|
1994
1994
|
/** Status of a snapshot job. */
|
|
1995
1995
|
type SnapshotStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'superseded';
|
|
1996
|
-
/** A
|
|
1996
|
+
/** A snapshot output format id. Known ids: `parquet`, `flatgeobuf` — extensible server-side. */
|
|
1997
|
+
type SnapshotFormat = 'parquet' | 'flatgeobuf' | (string & {});
|
|
1998
|
+
/**
|
|
1999
|
+
* One output format of a snapshot and what became of it: `requested` before
|
|
2000
|
+
* the worker ran, then `produced` (with file, size and media type) or
|
|
2001
|
+
* `skipped` (with a reason, e.g. a geometry-only format on a relation
|
|
2002
|
+
* without geometry).
|
|
2003
|
+
*/
|
|
2004
|
+
interface SnapshotFormatResult {
|
|
2005
|
+
format: SnapshotFormat;
|
|
2006
|
+
status: 'requested' | 'produced' | 'skipped';
|
|
2007
|
+
/** Produced only: file name in the snapshot directory. */
|
|
2008
|
+
file?: string;
|
|
2009
|
+
/** Produced only. */
|
|
2010
|
+
size_bytes?: number;
|
|
2011
|
+
/** Produced only. */
|
|
2012
|
+
media_type?: string;
|
|
2013
|
+
/** Skipped only: why this format could not be produced. */
|
|
2014
|
+
reason?: string;
|
|
2015
|
+
/** Produced only, and only in the relation snapshot read API: where to download this format. */
|
|
2016
|
+
href?: string;
|
|
2017
|
+
}
|
|
2018
|
+
/** A request to snapshot a table or view to S3. */
|
|
1997
2019
|
interface SnapshotRequest {
|
|
1998
2020
|
/** Schema of the relation. */
|
|
1999
2021
|
schema: string;
|
|
@@ -2001,6 +2023,14 @@ interface SnapshotRequest {
|
|
|
2001
2023
|
relation: string;
|
|
2002
2024
|
/** Optional EPSG code to reproject to. Omit to keep the native SRID. */
|
|
2003
2025
|
srs?: number;
|
|
2026
|
+
/**
|
|
2027
|
+
* Output formats to produce, in order. Omit to use the server default
|
|
2028
|
+
* (usually `['parquet']`). Must be non-empty and free of duplicates; a
|
|
2029
|
+
* geometry-only format (FlatGeobuf) is skipped with a reason for a
|
|
2030
|
+
* relation without geometry — unless every requested format needs one,
|
|
2031
|
+
* which is refused up front (400).
|
|
2032
|
+
*/
|
|
2033
|
+
formats?: SnapshotFormat[];
|
|
2004
2034
|
}
|
|
2005
2035
|
/** 202 response from postSnapshot; poll `_links.self` (or getSnapshot) for status. */
|
|
2006
2036
|
interface SnapshotAccepted {
|
|
@@ -2034,6 +2064,8 @@ interface SnapshotJob {
|
|
|
2034
2064
|
created: string;
|
|
2035
2065
|
started: string | null;
|
|
2036
2066
|
finished: string | null;
|
|
2067
|
+
/** One entry per requested output format and its outcome. */
|
|
2068
|
+
formats: SnapshotFormatResult[];
|
|
2037
2069
|
}
|
|
2038
2070
|
/** One file of a published snapshot. */
|
|
2039
2071
|
interface RelationSnapshotFile {
|
|
@@ -2050,6 +2082,8 @@ interface RelationSnapshot {
|
|
|
2050
2082
|
schema_version: string;
|
|
2051
2083
|
files: RelationSnapshotFile[];
|
|
2052
2084
|
published: string;
|
|
2085
|
+
/** One entry per requested output format; a produced one carries its `href` under `/data/{format}`. */
|
|
2086
|
+
formats: SnapshotFormatResult[];
|
|
2053
2087
|
}
|
|
2054
2088
|
/** One published snapshot with full metadata, as returned by the single-date endpoint. */
|
|
2055
2089
|
interface RelationSnapshotDetails extends RelationSnapshot {
|
|
@@ -2103,14 +2137,20 @@ declare class Snapshots {
|
|
|
2103
2137
|
constructor(client: CentiaHttpClient);
|
|
2104
2138
|
private relationPath;
|
|
2105
2139
|
/**
|
|
2106
|
-
* Queue
|
|
2107
|
-
*
|
|
2108
|
-
*
|
|
2109
|
-
*
|
|
2140
|
+
* Queue Parquet snapshots of one or more tables or views (an array returns
|
|
2141
|
+
* an array, in request order; all-or-nothing). Returns 202 with the job
|
|
2142
|
+
* id(s). Throws `CentiaApiError`: 400 (duplicates or an empty list),
|
|
2143
|
+
* 403 (super-user only), 404 (relation not found), 409 (a snapshot of a
|
|
2144
|
+
* relation is already pending or running), 501 (storage not configured).
|
|
2110
2145
|
*/
|
|
2111
2146
|
postSnapshot(body: SnapshotRequest): Promise<SnapshotAccepted>;
|
|
2112
|
-
|
|
2147
|
+
postSnapshot(body: SnapshotRequest[]): Promise<SnapshotAccepted[]>;
|
|
2148
|
+
/**
|
|
2149
|
+
* Get one snapshot job by id, or several (an array returns an array).
|
|
2150
|
+
* Throws a 404 `CentiaApiError` when any id is unknown. Super-user only.
|
|
2151
|
+
*/
|
|
2113
2152
|
getSnapshot(id: string): Promise<SnapshotJob>;
|
|
2153
|
+
getSnapshot(ids: string[]): Promise<SnapshotJob[]>;
|
|
2114
2154
|
/** List the newest snapshot jobs (50), optionally filtered by schema/relation. Super-user only. */
|
|
2115
2155
|
getSnapshots(options?: GetSnapshotsOptions): Promise<SnapshotJob[]>;
|
|
2116
2156
|
/**
|
|
@@ -2139,6 +2179,20 @@ declare class Snapshots {
|
|
|
2139
2179
|
getRelationSnapshotData(schema: string, relation: string, date: string, options?: SnapshotDataOptions): Promise<Response>;
|
|
2140
2180
|
/** HEAD request for the snapshot's Parquet file — Content-Length, Accept-Ranges and ETag without the body. */
|
|
2141
2181
|
headRelationSnapshotData(schema: string, relation: string, date: string): Promise<Response>;
|
|
2182
|
+
/**
|
|
2183
|
+
* Absolute URL of one output format of the snapshot, without fetching it —
|
|
2184
|
+
* for DuckDB/GDAL or a plain fetch.
|
|
2185
|
+
*/
|
|
2186
|
+
getRelationSnapshotDataFormatUrl(schema: string, relation: string, date: string, format: SnapshotFormat): string;
|
|
2187
|
+
/**
|
|
2188
|
+
* Fetch one output format of the snapshot (Content-Type is the format's
|
|
2189
|
+
* media type). Same redirect/range semantics as getRelationSnapshotData.
|
|
2190
|
+
* Throws `CentiaApiError`: 400 (unknown format id), 404 (no snapshot for
|
|
2191
|
+
* that date, or the format was skipped/not requested), 403, 416, 502.
|
|
2192
|
+
*/
|
|
2193
|
+
getRelationSnapshotDataFormat(schema: string, relation: string, date: string, format: SnapshotFormat, options?: SnapshotDataOptions): Promise<Response>;
|
|
2194
|
+
/** HEAD request for one output format of the snapshot. */
|
|
2195
|
+
headRelationSnapshotDataFormat(schema: string, relation: string, date: string, format: SnapshotFormat): Promise<Response>;
|
|
2142
2196
|
/**
|
|
2143
2197
|
* Fetch one file of the snapshot by catalog name (`data-<id>.parquet`,
|
|
2144
2198
|
* `metadata-<id>.json`). Same redirect/range semantics as
|
|
@@ -2150,6 +2204,149 @@ declare class Snapshots {
|
|
|
2150
2204
|
private rawGet;
|
|
2151
2205
|
}
|
|
2152
2206
|
//#endregion
|
|
2207
|
+
//#region src/scheduler/Scheduler.d.ts
|
|
2208
|
+
/** Status of a scheduler run. */
|
|
2209
|
+
type SchedulerRunStatus = 'running' | 'succeeded' | 'failed' | 'skipped' | 'lost';
|
|
2210
|
+
/** Body for creating a scheduler job. Server defaults: epsg 4326, type "AUTO", encoding "UTF8", delete_append false, download_schema true, active true, snapshot false. */
|
|
2211
|
+
interface SchedulerJobInput {
|
|
2212
|
+
name: string;
|
|
2213
|
+
schema: string;
|
|
2214
|
+
url: string;
|
|
2215
|
+
/** 5-field cron expression, e.g. "0 3 * * *". */
|
|
2216
|
+
schedule: string;
|
|
2217
|
+
epsg?: number;
|
|
2218
|
+
type?: string;
|
|
2219
|
+
encoding?: string;
|
|
2220
|
+
extra?: string | null;
|
|
2221
|
+
delete_append?: boolean;
|
|
2222
|
+
download_schema?: boolean;
|
|
2223
|
+
presql?: string | null;
|
|
2224
|
+
postsql?: string | null;
|
|
2225
|
+
active?: boolean;
|
|
2226
|
+
snapshot?: boolean;
|
|
2227
|
+
}
|
|
2228
|
+
/** Partial update of a scheduler job. */
|
|
2229
|
+
type PatchSchedulerJobRequest = Partial<SchedulerJobInput>;
|
|
2230
|
+
/** A scheduler job as returned by the API. */
|
|
2231
|
+
interface SchedulerJob {
|
|
2232
|
+
id: number;
|
|
2233
|
+
name: string;
|
|
2234
|
+
schema: string;
|
|
2235
|
+
url: string;
|
|
2236
|
+
/** 5-field cron expression. */
|
|
2237
|
+
schedule: string;
|
|
2238
|
+
epsg: number | null;
|
|
2239
|
+
type: string;
|
|
2240
|
+
encoding: string;
|
|
2241
|
+
extra: string | null;
|
|
2242
|
+
delete_append: boolean;
|
|
2243
|
+
download_schema: boolean;
|
|
2244
|
+
presql: string | null;
|
|
2245
|
+
postsql: string | null;
|
|
2246
|
+
active: boolean;
|
|
2247
|
+
snapshot: boolean;
|
|
2248
|
+
lastcheck: boolean | null;
|
|
2249
|
+
lasttimestamp: string | null;
|
|
2250
|
+
lastrun: string | null;
|
|
2251
|
+
report: Record<string, unknown> | null;
|
|
2252
|
+
}
|
|
2253
|
+
/** 201 response info from postSchedulerJob: the Location header and the ids parsed from it. */
|
|
2254
|
+
interface SchedulerJobsCreated extends LocationResponse {
|
|
2255
|
+
ids: number[];
|
|
2256
|
+
}
|
|
2257
|
+
/** One run of a scheduler job. */
|
|
2258
|
+
interface SchedulerRun {
|
|
2259
|
+
uuid: string;
|
|
2260
|
+
job: number;
|
|
2261
|
+
name: string | null;
|
|
2262
|
+
pid: number;
|
|
2263
|
+
host: string | null;
|
|
2264
|
+
slot: number | null;
|
|
2265
|
+
status: SchedulerRunStatus;
|
|
2266
|
+
stale: boolean;
|
|
2267
|
+
started_at: string;
|
|
2268
|
+
heartbeat: string | null;
|
|
2269
|
+
finished_at: string | null;
|
|
2270
|
+
exit_reason: string | null;
|
|
2271
|
+
}
|
|
2272
|
+
/** Body for starting a run. */
|
|
2273
|
+
interface PostSchedulerRunRequest {
|
|
2274
|
+
job: number;
|
|
2275
|
+
/** Ignore delete_append and overwrite. */
|
|
2276
|
+
force?: boolean;
|
|
2277
|
+
}
|
|
2278
|
+
/** 202 response from postSchedulerRun. */
|
|
2279
|
+
interface SchedulerRunAccepted {
|
|
2280
|
+
job: number;
|
|
2281
|
+
status: 'starting';
|
|
2282
|
+
_links: {
|
|
2283
|
+
runs: string;
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
/** 200 response from deleteSchedulerRun. The server escalates SIGINT to SIGKILL after 30 s. */
|
|
2287
|
+
interface SchedulerRunStopped {
|
|
2288
|
+
uuid: string;
|
|
2289
|
+
signal: string;
|
|
2290
|
+
}
|
|
2291
|
+
/** Filters for getSchedulerRuns. */
|
|
2292
|
+
interface GetSchedulerRunsOptions {
|
|
2293
|
+
job?: number;
|
|
2294
|
+
status?: SchedulerRunStatus;
|
|
2295
|
+
}
|
|
2296
|
+
/**
|
|
2297
|
+
* Client for the scheduler API (`/api/v4/scheduler`). Super-user only.
|
|
2298
|
+
*
|
|
2299
|
+
* Jobs describe recurring data imports (cron-scheduled); runs are their
|
|
2300
|
+
* executions. Starting a run is asynchronous — poll `getSchedulerRuns`
|
|
2301
|
+
* (the `_links.runs` of the 202) until the run finishes.
|
|
2302
|
+
*
|
|
2303
|
+
* ```ts
|
|
2304
|
+
* const scheduler = new Scheduler(createCentiaClient({ baseUrl, auth }));
|
|
2305
|
+
* const { ids } = await scheduler.postSchedulerJob({ name, schema, url, schedule: '0 3 * * *' });
|
|
2306
|
+
* await scheduler.postSchedulerRun({ job: ids[0] });
|
|
2307
|
+
* ```
|
|
2308
|
+
*/
|
|
2309
|
+
declare class Scheduler {
|
|
2310
|
+
private readonly client;
|
|
2311
|
+
constructor(client: CentiaHttpClient);
|
|
2312
|
+
/** List all scheduler jobs. */
|
|
2313
|
+
getSchedulerJobs(): Promise<SchedulerJob[]>;
|
|
2314
|
+
/**
|
|
2315
|
+
* Get one job by id, or several (an array returns an array). Throws a 404
|
|
2316
|
+
* `CentiaApiError` when any id is unknown.
|
|
2317
|
+
*/
|
|
2318
|
+
getSchedulerJob(id: number): Promise<SchedulerJob>;
|
|
2319
|
+
getSchedulerJob(ids: number[]): Promise<SchedulerJob[]>;
|
|
2320
|
+
/**
|
|
2321
|
+
* Create one or more jobs (201; all-or-nothing for arrays). Returns the
|
|
2322
|
+
* Location header and the new ids parsed from it, in request order.
|
|
2323
|
+
*/
|
|
2324
|
+
postSchedulerJob(body: SchedulerJobInput | SchedulerJobInput[]): Promise<SchedulerJobsCreated>;
|
|
2325
|
+
/** Partially update a job (303 + Location). */
|
|
2326
|
+
patchSchedulerJob(id: number, body: PatchSchedulerJobRequest): Promise<LocationResponse>;
|
|
2327
|
+
/**
|
|
2328
|
+
* Delete one or more jobs (204). Nothing is deleted if any id fails:
|
|
2329
|
+
* throws 404 (unknown id) or 409 (a run is in progress).
|
|
2330
|
+
*/
|
|
2331
|
+
deleteSchedulerJob(id: number | number[]): Promise<void>;
|
|
2332
|
+
/** List runs (running plus the newest 50 finished), optionally filtered by job and status. */
|
|
2333
|
+
getSchedulerRuns(options?: GetSchedulerRunsOptions): Promise<SchedulerRun[]>;
|
|
2334
|
+
/** Get one run by uuid. */
|
|
2335
|
+
getSchedulerRun(uuid: string): Promise<SchedulerRun>;
|
|
2336
|
+
/**
|
|
2337
|
+
* Start a run of a job (202). Throws 404 (unknown job) or 409 (a run of
|
|
2338
|
+
* the job is already running).
|
|
2339
|
+
*/
|
|
2340
|
+
postSchedulerRun(body: PostSchedulerRunRequest): Promise<SchedulerRunAccepted>;
|
|
2341
|
+
/**
|
|
2342
|
+
* Stop a running run: sends SIGINT, which the server escalates to SIGKILL
|
|
2343
|
+
* after 30 s — the request itself can take up to ~30 s, so do not use a
|
|
2344
|
+
* short timeout. Throws 404 (no running run with that uuid) or 409 (the
|
|
2345
|
+
* run is on another host).
|
|
2346
|
+
*/
|
|
2347
|
+
deleteSchedulerRun(uuid: string): Promise<SchedulerRunStopped>;
|
|
2348
|
+
}
|
|
2349
|
+
//#endregion
|
|
2153
2350
|
//#region src/auth/types.d.ts
|
|
2154
2351
|
interface StoredCredentials {
|
|
2155
2352
|
token?: string;
|
|
@@ -2259,5 +2456,5 @@ declare class SessionExpiredError extends Error {
|
|
|
2259
2456
|
*/
|
|
2260
2457
|
|
|
2261
2458
|
//#endregion
|
|
2262
|
-
export { type AsyncInvocationAccepted, type AuthService, type BatchMessage, type CentiaAdminClient, CentiaApiError, type CentiaApiErrorOptions, type CentiaAuth, type CentiaClientConfig, type CentiaHttpClient, Claims, type ClientInfo, CodeFlow, type CodeFlowOptions, type ColumnDef, type ColumnInfo, type CommitRequest, type CommitResult, type ConstraintInfo, type CreateClientRequest, type CreateClientResponse, type CreateColumnRequest, type CreateConstraintRequest, type CreateFunctionRequest, type CreateIndexRequest, type CreateKeyvalueRequest, type CreateRpcMethodRequest, type CreateRuleRequest, type CreateSchemaRequest, type CreateSequenceRequest, type CreateTokenProviderOptions, type CreateUserRequest, type DBSchema, type DeleteMapcacheTilesetOptions, type DryRunResult, type FeatureKey, type FeatureSrsOptions, Features, type FileProcessRequest, type FileProcessResponse, type FileUploadOptions, type FontWeight, type FullResponse, type FunctionEventOp, type FunctionInfo, type FunctionInvocationRecord, type FunctionInvocationResult, type FunctionPackage, type FunctionRuntime, type FunctionStatus, type FunctionTriggers, type GeoJsonFeature, type GeoJsonFeatureCollection, type GeoJsonGeometry, type GeomTransform, type GetLayerOptions, type GetSchemaOptions, type GetSnapshotsOptions, Gql, type GqlRequest, type GqlResponse, GuestFlow, type GuestFlowOptions, type IndexInfo, Keyvalue, type KeyvalueEntry, type KeyvalueProjection, type Label, type LabelPosition, type Layer, type LayerCacheType, type LayerClass, type LayerGeotype, type LayerProperties, type LayerTileFormat, type LineCap, type LocationResponse, type MapConfig, Mapcache, type MapcacheParams, type MapcacheTilesetDeleteResult, Meta, type MetadataFieldInfo, type MetadataRelationInfo, NotLoggedInError, OGC_CRS84, Ogc, type OgcBbox, type OgcCollection, type OgcCollections, type OgcCollectionsOptions, type OgcConformance, type OgcExtent, type OgcFeature, type OgcFeatureCollection, type OgcItemOptions, type OgcItemsOptions, type OgcLandingPage, type OgcLink, type OgcMapOptions, type OgcSpatialOptions, type Options, Ows, type OwsParams, type ParamsOfApiMethod, PasswordFlow, type PasswordFlowOptions, type PatchClientRequest, type PatchColumnRequest, type PatchFeatureOptions, type PatchFunctionRequest, type PatchKeyvalueRequest, type PatchMetadataRequest, type PatchPrivilegeRequest, type PatchRpcMethodRequest, type PatchRuleRequest, type PatchSequenceRequest, type PatchUserRequest, type pgTypes_d_exports as PgTypes, type PickRow, type PrivilegeInfo, type PrivilegeLevel, type RawRequestOptions, type RelationSnapshot, type RelationSnapshotDetails, type RelationSnapshotFile, type RenameSchemaRequest, type RequestOptions, type RowForTable, type RowOfApiCall, type RowOfApiMethod, type RowOfRequest, type RowOfSelect, type RowsOfApiCall, type RowsOfApiMethod, type RowsOfRequest, type RowsOfSelect, Rpc, type RpcMethodInfo, type RpcRequest, type RpcResponse, type RuleAccess, type RuleInfo, type RuleRequest, type RuleService, type SchemaInfo, type SequenceInfo, SessionExpiredError, SignUp, type SnapshotAccepted, type SnapshotColumn, type SnapshotDataOptions, type SnapshotJob, type SnapshotRequest, type SnapshotStatus, Snapshots, Sql, SqlNoToken, type SqlNoTokenRequest, type SqlRequest, type SqlResponse, Stats, Status, type StoredCredentials, type Style, type SubscriptionAckMessage, type SubscriptionRequest, type TableBatch, type TableDef, type TableInfo, Tables, type TokenProvider, type TokenStore, type UserInfo, Users, type WaitForSnapshotOptions, Wfs, type WfsGetParams, type WfsPathOptions, Ws, type WsErrorMessage, type WsMessage, type WsOptions, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, createTokenProvider, isCentiaApiError, ogcEpsgCrs };
|
|
2459
|
+
export { type AsyncInvocationAccepted, type AuthService, type BatchMessage, type CentiaAdminClient, CentiaApiError, type CentiaApiErrorOptions, type CentiaAuth, type CentiaClientConfig, type CentiaHttpClient, Claims, type ClientInfo, CodeFlow, type CodeFlowOptions, type ColumnDef, type ColumnInfo, type CommitRequest, type CommitResult, type ConstraintInfo, type CreateClientRequest, type CreateClientResponse, type CreateColumnRequest, type CreateConstraintRequest, type CreateFunctionRequest, type CreateIndexRequest, type CreateKeyvalueRequest, type CreateRpcMethodRequest, type CreateRuleRequest, type CreateSchemaRequest, type CreateSequenceRequest, type CreateTokenProviderOptions, type CreateUserRequest, type DBSchema, type DeleteMapcacheTilesetOptions, type DryRunResult, type FeatureKey, type FeatureSrsOptions, Features, type FileProcessRequest, type FileProcessResponse, type FileUploadOptions, type FontWeight, type FullResponse, type FunctionEventOp, type FunctionInfo, type FunctionInvocationRecord, type FunctionInvocationResult, type FunctionPackage, type FunctionRuntime, type FunctionStatus, type FunctionTriggers, type GeoJsonFeature, type GeoJsonFeatureCollection, type GeoJsonGeometry, type GeomTransform, type GetLayerOptions, type GetSchedulerRunsOptions, type GetSchemaOptions, type GetSnapshotsOptions, Gql, type GqlRequest, type GqlResponse, GuestFlow, type GuestFlowOptions, type IndexInfo, Keyvalue, type KeyvalueEntry, type KeyvalueProjection, type Label, type LabelPosition, type Layer, type LayerCacheType, type LayerClass, type LayerGeotype, type LayerProperties, type LayerTileFormat, type LineCap, type LocationResponse, type MapConfig, Mapcache, type MapcacheParams, type MapcacheTilesetDeleteResult, Meta, type MetadataFieldInfo, type MetadataRelationInfo, NotLoggedInError, OGC_CRS84, Ogc, type OgcBbox, type OgcCollection, type OgcCollections, type OgcCollectionsOptions, type OgcConformance, type OgcExtent, type OgcFeature, type OgcFeatureCollection, type OgcItemOptions, type OgcItemsOptions, type OgcLandingPage, type OgcLink, type OgcMapOptions, type OgcSpatialOptions, type Options, Ows, type OwsParams, type ParamsOfApiMethod, PasswordFlow, type PasswordFlowOptions, type PatchClientRequest, type PatchColumnRequest, type PatchFeatureOptions, type PatchFunctionRequest, type PatchKeyvalueRequest, type PatchMetadataRequest, type PatchPrivilegeRequest, type PatchRpcMethodRequest, type PatchRuleRequest, type PatchSchedulerJobRequest, type PatchSequenceRequest, type PatchUserRequest, type pgTypes_d_exports as PgTypes, type PickRow, type PostSchedulerRunRequest, type PrivilegeInfo, type PrivilegeLevel, type RawRequestOptions, type RelationSnapshot, type RelationSnapshotDetails, type RelationSnapshotFile, type RenameSchemaRequest, type RequestOptions, type RowForTable, type RowOfApiCall, type RowOfApiMethod, type RowOfRequest, type RowOfSelect, type RowsOfApiCall, type RowsOfApiMethod, type RowsOfRequest, type RowsOfSelect, Rpc, type RpcMethodInfo, type RpcRequest, type RpcResponse, type RuleAccess, type RuleInfo, type RuleRequest, type RuleService, Scheduler, type SchedulerJob, type SchedulerJobInput, type SchedulerJobsCreated, type SchedulerRun, type SchedulerRunAccepted, type SchedulerRunStatus, type SchedulerRunStopped, type SchemaInfo, type SequenceInfo, SessionExpiredError, SignUp, type SnapshotAccepted, type SnapshotColumn, type SnapshotDataOptions, type SnapshotFormat, type SnapshotFormatResult, type SnapshotJob, type SnapshotRequest, type SnapshotStatus, Snapshots, Sql, SqlNoToken, type SqlNoTokenRequest, type SqlRequest, type SqlResponse, Stats, Status, type StoredCredentials, type Style, type SubscriptionAckMessage, type SubscriptionRequest, type TableBatch, type TableDef, type TableInfo, Tables, type TokenProvider, type TokenStore, type UserInfo, Users, type WaitForSnapshotOptions, Wfs, type WfsGetParams, type WfsPathOptions, Ws, type WsErrorMessage, type WsMessage, type WsOptions, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, createTokenProvider, isCentiaApiError, ogcEpsgCrs };
|
|
2263
2460
|
//# sourceMappingURL=centia-io-sdk.d.cts.map
|