@centia-io/sdk 0.2.14 → 0.2.15

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 CHANGED
@@ -602,6 +602,40 @@ await features.deleteFeature('my_schema', 'my_table', [1, 2, 3])
602
602
 
603
603
  `srs` on `postFeature`/`patchFeature` declares the SRID of the *incoming* geometry. Reading requires a key — use the SQL or WFS APIs to query whole collections. PUT is not supported.
604
604
 
605
+ ## Snapshots (GeoParquet exports)
606
+
607
+ `Snapshots` wraps the snapshot API: asynchronous GeoParquet exports of a table or view to S3, and read access to the published snapshot files. It takes a `CentiaHttpClient` and requires a Bearer token:
608
+
609
+ ```ts
610
+ import { createCentiaClient, Snapshots } from '@centia-io/sdk'
611
+
612
+ const snapshots = new Snapshots(http)
613
+
614
+ // Queue an export (202; super-user only). The export runs asynchronously.
615
+ const { id } = await snapshots.postSnapshot({ schema: 'geodanmark', relation: 'bygning', srs: 25832 })
616
+
617
+ // Poll until it finishes (succeeded/failed/superseded) — or use getSnapshot(id) yourself
618
+ const job = await snapshots.waitForSnapshot(id, { intervalMs: 2000, timeoutMs: 300_000 })
619
+ if (job.status === 'failed') throw new Error(job.error ?? 'export failed')
620
+
621
+ // List jobs, optionally filtered (super-user only)
622
+ const jobs = await snapshots.getSnapshots({ schema: 'geodanmark', relation: 'bygning' })
623
+
624
+ // Read API — any user with read access to the relation:
625
+ const published = await snapshots.getRelationSnapshots('geodanmark', 'bygning') // newest first
626
+ const meta = await snapshots.getRelationSnapshot('geodanmark', 'bygning', '2026-09-16')
627
+
628
+ // The Parquet file itself. dataUrl for DuckDB/GDAL/plain fetch; the data
629
+ // methods return the raw Response (stream or buffer it yourself) and follow
630
+ // the 302 redirect to presigned storage URLs.
631
+ const url = snapshots.getRelationSnapshotDataUrl('geodanmark', 'bygning', '2026-09-16')
632
+ const head = await snapshots.headRelationSnapshotData('geodanmark', 'bygning', '2026-09-16') // Content-Length/ETag
633
+ const part = await snapshots.getRelationSnapshotData('geodanmark', 'bygning', '2026-09-16', { range: [0, 1023] })
634
+ const file = await snapshots.getRelationSnapshotFile('geodanmark', 'bygning', '2026-09-16', 'metadata-<id>.json')
635
+ ```
636
+
637
+ 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
+
605
639
  ## Error handling
606
640
 
607
641
  - Network/HTTP errors: thrown as `Error` with the status/body text when available.
@@ -707,6 +707,52 @@ var CentiaHttpClient = class {
707
707
  getHeader: (name) => response.headers.get(name)
708
708
  };
709
709
  }
710
+ /**
711
+ * Execute a request and return the raw Response without consuming the body.
712
+ * For binary endpoints (file downloads): follows redirects (a presigned
713
+ * storage URL — the fetch spec strips Authorization on cross-origin
714
+ * redirects), sends no Content-Type, and supports extra request headers
715
+ * such as Range. Throws CentiaApiError on a status not in expectedStatus.
716
+ */
717
+ async requestRaw(opts) {
718
+ var _this3 = this;
719
+ var _opts$accept, _opts$expectedStatus2;
720
+ const url = _this3.buildUrl(opts.path, opts.query);
721
+ const headers = { "Accept": (_opts$accept = opts.accept) !== null && _opts$accept !== void 0 ? _opts$accept : "*/*" };
722
+ if (_this3.auth.getAccessToken) {
723
+ const token = await _this3.auth.getAccessToken();
724
+ if (token) headers["Authorization"] = `Bearer ${token}`;
725
+ }
726
+ if (_this3.auth.getHeaders) Object.assign(headers, await _this3.auth.getHeaders());
727
+ if (_this3.userAgent && typeof navigator === "undefined") headers["User-Agent"] = _this3.userAgent;
728
+ Object.assign(headers, opts.headers);
729
+ const response = await _this3.fetchFn(url, {
730
+ method: opts.method,
731
+ headers,
732
+ redirect: "follow"
733
+ });
734
+ if (!((_opts$expectedStatus2 = opts.expectedStatus) !== null && _opts$expectedStatus2 !== void 0 ? _opts$expectedStatus2 : [200]).includes(response.status)) {
735
+ var _ref, _parsed$message, _response$headers$get;
736
+ let bodyText = "";
737
+ try {
738
+ bodyText = await response.text();
739
+ } catch (_unused) {}
740
+ let parsed = null;
741
+ if (bodyText) try {
742
+ parsed = JSON.parse(bodyText);
743
+ } catch (_unused2) {}
744
+ throw new CentiaApiError({
745
+ message: ((_ref = (_parsed$message = parsed === null || parsed === void 0 ? void 0 : parsed.message) !== null && _parsed$message !== void 0 ? _parsed$message : parsed === null || parsed === void 0 ? void 0 : parsed.error) !== null && _ref !== void 0 ? _ref : bodyText) || `Unexpected status ${response.status}`,
746
+ status: response.status,
747
+ code: parsed === null || parsed === void 0 ? void 0 : parsed.code,
748
+ details: parsed,
749
+ requestId: (_response$headers$get = response.headers.get("x-request-id")) !== null && _response$headers$get !== void 0 ? _response$headers$get : void 0,
750
+ method: opts.method,
751
+ url
752
+ });
753
+ }
754
+ return response;
755
+ }
710
756
  buildUrl(path, query) {
711
757
  const cleanPath = path.replace(/^\/+/, "");
712
758
  let url = `${this.baseUrl}/${cleanPath}`;
@@ -717,19 +763,19 @@ var CentiaHttpClient = class {
717
763
  return url;
718
764
  }
719
765
  async buildHeaders(opts) {
720
- var _this3 = this;
721
- var _opts$accept;
722
- const headers = { "Accept": (_opts$accept = opts.accept) !== null && _opts$accept !== void 0 ? _opts$accept : "application/json" };
723
- if (_this3.auth.getAccessToken) {
724
- const token = await _this3.auth.getAccessToken();
766
+ var _this4 = this;
767
+ var _opts$accept2;
768
+ const headers = { "Accept": (_opts$accept2 = opts.accept) !== null && _opts$accept2 !== void 0 ? _opts$accept2 : "application/json" };
769
+ if (_this4.auth.getAccessToken) {
770
+ const token = await _this4.auth.getAccessToken();
725
771
  if (token) headers["Authorization"] = `Bearer ${token}`;
726
772
  }
727
- if (_this3.auth.getHeaders) {
728
- const authHeaders = await _this3.auth.getHeaders();
773
+ if (_this4.auth.getHeaders) {
774
+ const authHeaders = await _this4.auth.getHeaders();
729
775
  Object.assign(headers, authHeaders);
730
776
  }
731
- if (_this3.userAgent && typeof navigator === "undefined") headers["User-Agent"] = _this3.userAgent;
732
- const ct = _this3.resolveContentType(opts.contentType);
777
+ if (_this4.userAgent && typeof navigator === "undefined") headers["User-Agent"] = _this4.userAgent;
778
+ const ct = _this4.resolveContentType(opts.contentType);
733
779
  if (ct) headers["Content-Type"] = ct;
734
780
  return headers;
735
781
  }
@@ -738,24 +784,24 @@ var CentiaHttpClient = class {
738
784
  return contentType !== null && contentType !== void 0 ? contentType : "application/json";
739
785
  }
740
786
  async handleResponse(response, opts, url) {
741
- var _opts$expectedStatus2, _parsed;
742
- const expectedStatus = (_opts$expectedStatus2 = opts.expectedStatus) !== null && _opts$expectedStatus2 !== void 0 ? _opts$expectedStatus2 : 200;
787
+ var _opts$expectedStatus3, _parsed;
788
+ const expectedStatus = (_opts$expectedStatus3 = opts.expectedStatus) !== null && _opts$expectedStatus3 !== void 0 ? _opts$expectedStatus3 : 200;
743
789
  let bodyText = "";
744
790
  try {
745
791
  bodyText = await response.text();
746
- } catch (_unused) {}
792
+ } catch (_unused3) {}
747
793
  let parsed = null;
748
794
  if (bodyText) try {
749
795
  parsed = JSON.parse(bodyText);
750
- } catch (_unused2) {}
796
+ } catch (_unused4) {}
751
797
  if (response.status !== expectedStatus) {
752
- var _ref, _parsed$message, _response$headers$get;
798
+ var _ref2, _parsed$message2, _response$headers$get2;
753
799
  throw new CentiaApiError({
754
- message: ((_ref = (_parsed$message = parsed === null || parsed === void 0 ? void 0 : parsed.message) !== null && _parsed$message !== void 0 ? _parsed$message : parsed === null || parsed === void 0 ? void 0 : parsed.error) !== null && _ref !== void 0 ? _ref : bodyText) || `Unexpected status ${response.status}`,
800
+ message: ((_ref2 = (_parsed$message2 = parsed === null || parsed === void 0 ? void 0 : parsed.message) !== null && _parsed$message2 !== void 0 ? _parsed$message2 : parsed === null || parsed === void 0 ? void 0 : parsed.error) !== null && _ref2 !== void 0 ? _ref2 : bodyText) || `Unexpected status ${response.status}`,
755
801
  status: response.status,
756
802
  code: parsed === null || parsed === void 0 ? void 0 : parsed.code,
757
803
  details: parsed,
758
- requestId: (_response$headers$get = response.headers.get("x-request-id")) !== null && _response$headers$get !== void 0 ? _response$headers$get : void 0,
804
+ requestId: (_response$headers$get2 = response.headers.get("x-request-id")) !== null && _response$headers$get2 !== void 0 ? _response$headers$get2 : void 0,
759
805
  method: opts.method,
760
806
  url
761
807
  });
@@ -3386,6 +3432,150 @@ var Features = class {
3386
3432
  }
3387
3433
  };
3388
3434
 
3435
+ //#endregion
3436
+ //#region src/snapshots/Snapshots.ts
3437
+ /**
3438
+ * Client for the snapshot API: GeoParquet exports of a relation.
3439
+ *
3440
+ * The job API (`/api/v4/snapshots`) queues and inspects exports and is
3441
+ * super-user only; exports run asynchronously — poll with `getSnapshot` or
3442
+ * use `waitForSnapshot`. The read API
3443
+ * (`/api/v4/schemas/{schema}/relations/{relation}/snapshots`) serves the
3444
+ * published snapshots to any user with read access to the relation, with
3445
+ * HEAD + byte-range support so Parquet readers can fetch footers and row
3446
+ * groups selectively.
3447
+ *
3448
+ * ```ts
3449
+ * const snapshots = new Snapshots(createCentiaClient({ baseUrl, auth }));
3450
+ * const { id } = await snapshots.postSnapshot({ schema: 'geodanmark', relation: 'bygning' });
3451
+ * const done = await snapshots.waitForSnapshot(id);
3452
+ * ```
3453
+ */
3454
+ var Snapshots = class {
3455
+ constructor(client) {
3456
+ this.client = client;
3457
+ }
3458
+ relationPath(schema, relation, rest = "") {
3459
+ return `api/v4/schemas/${encodeURIComponent(schema)}/relations/${encodeURIComponent(relation)}/snapshots${rest}`;
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
+ async postSnapshot(body) {
3468
+ return this.client.request({
3469
+ path: "api/v4/snapshots",
3470
+ method: "POST",
3471
+ body,
3472
+ expectedStatus: 202
3473
+ });
3474
+ }
3475
+ /** Get a snapshot job by id. Super-user only. */
3476
+ async getSnapshot(id) {
3477
+ return this.client.request({
3478
+ path: `api/v4/snapshots/${encodeURIComponent(id)}`,
3479
+ method: "GET"
3480
+ });
3481
+ }
3482
+ /** List the newest snapshot jobs (50), optionally filtered by schema/relation. Super-user only. */
3483
+ async getSnapshots(options) {
3484
+ var _this3 = this;
3485
+ const query = {};
3486
+ if ((options === null || options === void 0 ? void 0 : options.schema) !== void 0) query.schema = options.schema;
3487
+ if ((options === null || options === void 0 ? void 0 : options.relation) !== void 0) query.relation = options.relation;
3488
+ return _this3.client.request({
3489
+ path: "api/v4/snapshots",
3490
+ method: "GET",
3491
+ query: Object.keys(query).length > 0 ? query : void 0
3492
+ });
3493
+ }
3494
+ /**
3495
+ * Poll a snapshot job until it reaches a terminal status (succeeded, failed
3496
+ * or superseded) and return it — check `status`/`error` on the result.
3497
+ * Throws an `Error` when `timeoutMs` elapses first.
3498
+ */
3499
+ async waitForSnapshot(id, options) {
3500
+ var _this4 = this;
3501
+ var _options$intervalMs, _options$timeoutMs;
3502
+ const intervalMs = (_options$intervalMs = options === null || options === void 0 ? void 0 : options.intervalMs) !== null && _options$intervalMs !== void 0 ? _options$intervalMs : 2e3;
3503
+ const timeoutMs = (_options$timeoutMs = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _options$timeoutMs !== void 0 ? _options$timeoutMs : 3e5;
3504
+ const deadline = Date.now() + timeoutMs;
3505
+ for (;;) {
3506
+ const job = await _this4.getSnapshot(id);
3507
+ if (job.status === "succeeded" || job.status === "failed" || job.status === "superseded") return job;
3508
+ if (Date.now() + intervalMs > deadline) throw new Error(`Timed out after ${timeoutMs} ms waiting for snapshot ${id} (status: ${job.status})`);
3509
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
3510
+ }
3511
+ }
3512
+ /** List the published snapshots of a relation, newest first. */
3513
+ async getRelationSnapshots(schema, relation) {
3514
+ var _this5 = this;
3515
+ return _this5.client.request({
3516
+ path: _this5.relationPath(schema, relation),
3517
+ method: "GET"
3518
+ });
3519
+ }
3520
+ /** Get one published snapshot (metadata) by date (`YYYY-MM-DD`). */
3521
+ async getRelationSnapshot(schema, relation, date) {
3522
+ var _this6 = this;
3523
+ return _this6.client.request({
3524
+ path: _this6.relationPath(schema, relation, `/${encodeURIComponent(date)}`),
3525
+ method: "GET"
3526
+ });
3527
+ }
3528
+ /**
3529
+ * Absolute URL of the snapshot's Parquet file, without fetching it — for
3530
+ * DuckDB/GDAL or a plain fetch. Authorization travels in the request
3531
+ * header, so protected relations need the caller to attach the token.
3532
+ */
3533
+ getRelationSnapshotDataUrl(schema, relation, date) {
3534
+ return `${this.client.baseUrl}/${this.relationPath(schema, relation, `/${encodeURIComponent(date)}/data`)}`;
3535
+ }
3536
+ /**
3537
+ * Fetch the snapshot's Parquet file and return the raw `Response` (stream
3538
+ * or buffer it yourself). Follows the 302 redirect the server answers in
3539
+ * redirect mode. Pass `range` for a single byte range (206). Throws
3540
+ * `CentiaApiError`: 403, 404, 409 (several files; use
3541
+ * getRelationSnapshotFile), 416, 502.
3542
+ */
3543
+ async getRelationSnapshotData(schema, relation, date, options) {
3544
+ var _this7 = this;
3545
+ return _this7.rawGet(_this7.relationPath(schema, relation, `/${encodeURIComponent(date)}/data`), "GET", options);
3546
+ }
3547
+ /** HEAD request for the snapshot's Parquet file — Content-Length, Accept-Ranges and ETag without the body. */
3548
+ async headRelationSnapshotData(schema, relation, date) {
3549
+ var _this8 = this;
3550
+ return _this8.rawGet(_this8.relationPath(schema, relation, `/${encodeURIComponent(date)}/data`), "HEAD");
3551
+ }
3552
+ /**
3553
+ * Fetch one file of the snapshot by catalog name (`data-<id>.parquet`,
3554
+ * `metadata-<id>.json`). Same redirect/range semantics as
3555
+ * getRelationSnapshotData.
3556
+ */
3557
+ async getRelationSnapshotFile(schema, relation, date, file, options) {
3558
+ var _this9 = this;
3559
+ return _this9.rawGet(_this9.relationPath(schema, relation, `/${encodeURIComponent(date)}/files/${encodeURIComponent(file)}`), "GET", options);
3560
+ }
3561
+ /** HEAD request for one file of the snapshot. */
3562
+ async headRelationSnapshotFile(schema, relation, date, file) {
3563
+ var _this10 = this;
3564
+ return _this10.rawGet(_this10.relationPath(schema, relation, `/${encodeURIComponent(date)}/files/${encodeURIComponent(file)}`), "HEAD");
3565
+ }
3566
+ async rawGet(path, method, options) {
3567
+ var _this11 = this;
3568
+ const headers = {};
3569
+ if (options === null || options === void 0 ? void 0 : options.range) headers["Range"] = `bytes=${options.range[0]}-${options.range[1]}`;
3570
+ return _this11.client.requestRaw({
3571
+ path,
3572
+ method,
3573
+ headers: Object.keys(headers).length > 0 ? headers : void 0,
3574
+ expectedStatus: [200, 206]
3575
+ });
3576
+ }
3577
+ };
3578
+
3389
3579
  //#endregion
3390
3580
  //#region src/auth/errors.ts
3391
3581
  /**
@@ -3525,6 +3715,7 @@ exports.PasswordFlow = PasswordFlow;
3525
3715
  exports.Rpc = Rpc;
3526
3716
  exports.SessionExpiredError = SessionExpiredError;
3527
3717
  exports.SignUp = SignUp;
3718
+ exports.Snapshots = Snapshots;
3528
3719
  exports.Sql = Sql;
3529
3720
  exports.SqlNoToken = SqlNoToken;
3530
3721
  exports.Stats = Stats;
@@ -155,6 +155,21 @@ interface RequestOptions {
155
155
  /** Expected HTTP status code. Defaults to 200. Non-match throws CentiaApiError. */
156
156
  expectedStatus?: number;
157
157
  }
158
+ /** Options for a raw request via CentiaHttpClient.requestRaw(). */
159
+ interface RawRequestOptions {
160
+ /** URL path relative to baseUrl. Leading slash is stripped. */
161
+ path: string;
162
+ /** HTTP method. */
163
+ method: 'GET' | 'HEAD';
164
+ /** Query parameters appended to the URL. */
165
+ query?: Record<string, string>;
166
+ /** Accept header. Defaults to the wildcard media type. */
167
+ accept?: string;
168
+ /** Extra request headers, e.g. Range. */
169
+ headers?: Record<string, string>;
170
+ /** Accepted HTTP status codes. Defaults to [200]. Non-match throws CentiaApiError. */
171
+ expectedStatus?: number[];
172
+ }
158
173
  /** Full HTTP response with metadata, returned by CentiaHttpClient.requestFull(). */
159
174
  interface FullResponse<T> {
160
175
  /** Parsed response body (null for empty responses like 204). */
@@ -187,6 +202,14 @@ declare class CentiaHttpClient {
187
202
  * Useful for operations that return Location headers (POST 201, PATCH 303).
188
203
  */
189
204
  requestFull<T = unknown>(opts: RequestOptions): Promise<FullResponse<T>>;
205
+ /**
206
+ * Execute a request and return the raw Response without consuming the body.
207
+ * For binary endpoints (file downloads): follows redirects (a presigned
208
+ * storage URL — the fetch spec strips Authorization on cross-origin
209
+ * redirects), sends no Content-Type, and supports extra request headers
210
+ * such as Range. Throws CentiaApiError on a status not in expectedStatus.
211
+ */
212
+ requestRaw(opts: RawRequestOptions): Promise<Response>;
190
213
  private buildUrl;
191
214
  private buildHeaders;
192
215
  private resolveContentType;
@@ -1967,6 +1990,166 @@ declare class Keyvalue {
1967
1990
  deleteKeyvalue(key: string): Promise<void>;
1968
1991
  }
1969
1992
  //#endregion
1993
+ //#region src/snapshots/Snapshots.d.ts
1994
+ /** Status of a snapshot job. */
1995
+ type SnapshotStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'superseded';
1996
+ /** A request to snapshot a table or view to Parquet on S3. */
1997
+ interface SnapshotRequest {
1998
+ /** Schema of the relation. */
1999
+ schema: string;
2000
+ /** Table or view name. */
2001
+ relation: string;
2002
+ /** Optional EPSG code to reproject to. Omit to keep the native SRID. */
2003
+ srs?: number;
2004
+ }
2005
+ /** 202 response from postSnapshot; poll `_links.self` (or getSnapshot) for status. */
2006
+ interface SnapshotAccepted {
2007
+ id: string;
2008
+ status: 'pending';
2009
+ _links: {
2010
+ self: string;
2011
+ };
2012
+ }
2013
+ /** One column of the relation at snapshot time. */
2014
+ interface SnapshotColumn {
2015
+ column_name: string;
2016
+ data_type: string;
2017
+ }
2018
+ /** Status of a snapshot job. */
2019
+ interface SnapshotJob {
2020
+ id: string;
2021
+ schema: string;
2022
+ relation: string;
2023
+ srs: number | null;
2024
+ status: SnapshotStatus;
2025
+ /** UTC date the export ran; the {date} segment of the relation snapshot read API. */
2026
+ snapshot_date: string | null;
2027
+ s3_path: string | null;
2028
+ row_count: number | null;
2029
+ /** md5 fingerprint of relation_schema, for drift detection. */
2030
+ schema_version: string | null;
2031
+ relation_schema: SnapshotColumn[] | null;
2032
+ error: string | null;
2033
+ username: string;
2034
+ created: string;
2035
+ started: string | null;
2036
+ finished: string | null;
2037
+ }
2038
+ /** One file of a published snapshot. */
2039
+ interface RelationSnapshotFile {
2040
+ name: string;
2041
+ size_bytes: number;
2042
+ href: string;
2043
+ }
2044
+ /** A published snapshot of a relation, as returned by the list endpoint. */
2045
+ interface RelationSnapshot {
2046
+ snapshot_date: string;
2047
+ snapshot_id: string;
2048
+ row_count: number;
2049
+ size_bytes: number;
2050
+ schema_version: string;
2051
+ files: RelationSnapshotFile[];
2052
+ published: string;
2053
+ }
2054
+ /** One published snapshot with full metadata, as returned by the single-date endpoint. */
2055
+ interface RelationSnapshotDetails extends RelationSnapshot {
2056
+ srs: number | null;
2057
+ relation_schema: SnapshotColumn[] | null;
2058
+ crs: string | null;
2059
+ _links: {
2060
+ data: string;
2061
+ files: {
2062
+ name: string;
2063
+ href: string;
2064
+ }[];
2065
+ };
2066
+ }
2067
+ /** Filters for getSnapshots. */
2068
+ interface GetSnapshotsOptions {
2069
+ schema?: string;
2070
+ relation?: string;
2071
+ }
2072
+ /** Polling options for waitForSnapshot. */
2073
+ interface WaitForSnapshotOptions {
2074
+ /** Milliseconds between polls. Default 2000. */
2075
+ intervalMs?: number;
2076
+ /** Give up after this many milliseconds. Default 300000 (5 minutes). */
2077
+ timeoutMs?: number;
2078
+ }
2079
+ /** Options for the snapshot data/file download methods. */
2080
+ interface SnapshotDataOptions {
2081
+ /** Inclusive byte range to request, e.g. `[0, 1023]` for the first KiB. */
2082
+ range?: [number, number];
2083
+ }
2084
+ /**
2085
+ * Client for the snapshot API: GeoParquet exports of a relation.
2086
+ *
2087
+ * The job API (`/api/v4/snapshots`) queues and inspects exports and is
2088
+ * super-user only; exports run asynchronously — poll with `getSnapshot` or
2089
+ * use `waitForSnapshot`. The read API
2090
+ * (`/api/v4/schemas/{schema}/relations/{relation}/snapshots`) serves the
2091
+ * published snapshots to any user with read access to the relation, with
2092
+ * HEAD + byte-range support so Parquet readers can fetch footers and row
2093
+ * groups selectively.
2094
+ *
2095
+ * ```ts
2096
+ * const snapshots = new Snapshots(createCentiaClient({ baseUrl, auth }));
2097
+ * const { id } = await snapshots.postSnapshot({ schema: 'geodanmark', relation: 'bygning' });
2098
+ * const done = await snapshots.waitForSnapshot(id);
2099
+ * ```
2100
+ */
2101
+ declare class Snapshots {
2102
+ private readonly client;
2103
+ constructor(client: CentiaHttpClient);
2104
+ private relationPath;
2105
+ /**
2106
+ * Queue a Parquet snapshot of a table or view. Returns 202 with the job id.
2107
+ * Throws `CentiaApiError`: 403 (super-user only), 404 (relation not found),
2108
+ * 409 (a snapshot of the relation is already pending or running),
2109
+ * 501 (snapshot storage not configured).
2110
+ */
2111
+ postSnapshot(body: SnapshotRequest): Promise<SnapshotAccepted>;
2112
+ /** Get a snapshot job by id. Super-user only. */
2113
+ getSnapshot(id: string): Promise<SnapshotJob>;
2114
+ /** List the newest snapshot jobs (50), optionally filtered by schema/relation. Super-user only. */
2115
+ getSnapshots(options?: GetSnapshotsOptions): Promise<SnapshotJob[]>;
2116
+ /**
2117
+ * Poll a snapshot job until it reaches a terminal status (succeeded, failed
2118
+ * or superseded) and return it — check `status`/`error` on the result.
2119
+ * Throws an `Error` when `timeoutMs` elapses first.
2120
+ */
2121
+ waitForSnapshot(id: string, options?: WaitForSnapshotOptions): Promise<SnapshotJob>;
2122
+ /** List the published snapshots of a relation, newest first. */
2123
+ getRelationSnapshots(schema: string, relation: string): Promise<RelationSnapshot[]>;
2124
+ /** Get one published snapshot (metadata) by date (`YYYY-MM-DD`). */
2125
+ getRelationSnapshot(schema: string, relation: string, date: string): Promise<RelationSnapshotDetails>;
2126
+ /**
2127
+ * Absolute URL of the snapshot's Parquet file, without fetching it — for
2128
+ * DuckDB/GDAL or a plain fetch. Authorization travels in the request
2129
+ * header, so protected relations need the caller to attach the token.
2130
+ */
2131
+ getRelationSnapshotDataUrl(schema: string, relation: string, date: string): string;
2132
+ /**
2133
+ * Fetch the snapshot's Parquet file and return the raw `Response` (stream
2134
+ * or buffer it yourself). Follows the 302 redirect the server answers in
2135
+ * redirect mode. Pass `range` for a single byte range (206). Throws
2136
+ * `CentiaApiError`: 403, 404, 409 (several files; use
2137
+ * getRelationSnapshotFile), 416, 502.
2138
+ */
2139
+ getRelationSnapshotData(schema: string, relation: string, date: string, options?: SnapshotDataOptions): Promise<Response>;
2140
+ /** HEAD request for the snapshot's Parquet file — Content-Length, Accept-Ranges and ETag without the body. */
2141
+ headRelationSnapshotData(schema: string, relation: string, date: string): Promise<Response>;
2142
+ /**
2143
+ * Fetch one file of the snapshot by catalog name (`data-<id>.parquet`,
2144
+ * `metadata-<id>.json`). Same redirect/range semantics as
2145
+ * getRelationSnapshotData.
2146
+ */
2147
+ getRelationSnapshotFile(schema: string, relation: string, date: string, file: string, options?: SnapshotDataOptions): Promise<Response>;
2148
+ /** HEAD request for one file of the snapshot. */
2149
+ headRelationSnapshotFile(schema: string, relation: string, date: string, file: string): Promise<Response>;
2150
+ private rawGet;
2151
+ }
2152
+ //#endregion
1970
2153
  //#region src/auth/types.d.ts
1971
2154
  interface StoredCredentials {
1972
2155
  token?: string;
@@ -2076,5 +2259,5 @@ declare class SessionExpiredError extends Error {
2076
2259
  */
2077
2260
 
2078
2261
  //#endregion
2079
- 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, 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 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, 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, Wfs, type WfsGetParams, type WfsPathOptions, Ws, type WsErrorMessage, type WsMessage, type WsOptions, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, createTokenProvider, isCentiaApiError, ogcEpsgCrs };
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 };
2080
2263
  //# sourceMappingURL=centia-io-sdk.d.cts.map