@centia-io/sdk 0.2.11 → 0.2.13
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 +32 -1
- package/dist/centia-io-sdk.cjs +160 -2
- package/dist/centia-io-sdk.d.cts +224 -52
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +224 -52
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +157 -2
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +159 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -474,6 +474,36 @@ const job = await mapcache.deleteMapcacheTileset('my_database', 'my_schema.roads
|
|
|
474
474
|
|
|
475
475
|
The endpoint accepts anonymous, HTTP Basic and Bearer token requests; tile requests are authorized against the tileset's layer. Authorization travels in the `Authorization` header — it cannot be embedded in the URL — so for protected tilesets, inject the header per tile request via the map library's request hook (e.g. MapLibre's `transformRequest` or OpenLayers' `tileLoadFunction`).
|
|
476
476
|
|
|
477
|
+
## OGC API (Features / Maps)
|
|
478
|
+
|
|
479
|
+
`Ogc` wraps the RESTful OGC API under `/api/v4/ogc/database/{database}` — OGC API Features (Part 1 Core, Part 2 CRS) for reading features as GeoJSON and OGC API Maps (Part 1 Core) for rendered images. Like `Ows`/`Wfs` it takes a `CentiaHttpClient`; Bearer token, HTTP Basic and anonymous requests are all accepted:
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
import { createCentiaClient, Ogc, OGC_CRS84, ogcEpsgCrs } from '@centia-io/sdk'
|
|
483
|
+
|
|
484
|
+
const ogc = new Ogc(http)
|
|
485
|
+
|
|
486
|
+
const { collections } = await ogc.getCollections('my_database')
|
|
487
|
+
const collection = await ogc.getCollection('my_database', 'my_schema.roads') // extent, crs list, links
|
|
488
|
+
|
|
489
|
+
// GeoJSON items — default page size is 10; follow the `next` link or pass offset
|
|
490
|
+
const page = await ogc.getItems<{ gid: number; name: string }>('my_database', 'my_schema.roads', {
|
|
491
|
+
bbox: [9, 55, 10, 56], // lon/lat in CRS84 (the default bbox-crs)
|
|
492
|
+
crs: ogcEpsgCrs(25832), // output CRS from the collection's crs list
|
|
493
|
+
limit: 100,
|
|
494
|
+
datetime: '2024-01-01T00:00:00Z', // versioned layers: the version valid at that time
|
|
495
|
+
})
|
|
496
|
+
page.numberMatched // total; page.numberReturned; page.links (next/prev)
|
|
497
|
+
|
|
498
|
+
const feature = await ogc.getItem('my_database', 'my_schema.roads', 42)
|
|
499
|
+
|
|
500
|
+
// Map images are fetched by URL (e.g. an <img> or a map library)
|
|
501
|
+
const url = ogc.mapUrl('my_database', 'my_schema.roads', { bbox: [9, 55, 10, 56], width: 512, format: 'png' })
|
|
502
|
+
const multi = ogc.datasetMapUrl('my_database', ['my_schema.roads', 'my_schema.buildings'], { width: 512 })
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
CRS values are URIs: `OGC_CRS84` (lon/lat, default) or `ogcEpsgCrs(code)`; note `ogcEpsgCrs(4326)` is lat/lon order per OGC API Features Part 2. A collection that exists but is not readable answers `401` (anonymous) or `403` (no privilege); unknown collections and features are `404` — all thrown as `CentiaApiError`. Geofence rules, versioning and workflow are applied server-side.
|
|
506
|
+
|
|
477
507
|
## Key/value store
|
|
478
508
|
|
|
479
509
|
`Keyvalue` wraps the `/api/v4/keyvalue` endpoints for storing arbitrary JSON under globally unique keys. It takes a `CentiaHttpClient` and requires a Bearer token:
|
|
@@ -538,8 +568,9 @@ await features.patchFeature('my_schema', 'my_table', {
|
|
|
538
568
|
properties: { name: 'Moved point' },
|
|
539
569
|
}, { feature: 1 })
|
|
540
570
|
|
|
541
|
-
// Delete
|
|
571
|
+
// Delete one or more features (204; 404 only when no key matches)
|
|
542
572
|
await features.deleteFeature('my_schema', 'my_table', 1)
|
|
573
|
+
await features.deleteFeature('my_schema', 'my_table', [1, 2, 3])
|
|
543
574
|
```
|
|
544
575
|
|
|
545
576
|
`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.
|
package/dist/centia-io-sdk.cjs
CHANGED
|
@@ -3041,6 +3041,157 @@ var Mapcache = class {
|
|
|
3041
3041
|
}
|
|
3042
3042
|
};
|
|
3043
3043
|
|
|
3044
|
+
//#endregion
|
|
3045
|
+
//#region src/ogc/Ogc.ts
|
|
3046
|
+
/** Default CRS of the OGC API: WGS 84 in longitude/latitude order. */
|
|
3047
|
+
const OGC_CRS84 = "http://www.opengis.net/def/crs/OGC/1.3/CRS84";
|
|
3048
|
+
/**
|
|
3049
|
+
* CRS URI for an EPSG code, e.g. `ogcEpsgCrs(25832)`. Note that
|
|
3050
|
+
* `ogcEpsgCrs(4326)` is latitude/longitude order; use `OGC_CRS84` for lon/lat.
|
|
3051
|
+
*/
|
|
3052
|
+
function ogcEpsgCrs(epsg) {
|
|
3053
|
+
return `http://www.opengis.net/def/crs/EPSG/0/${epsg}`;
|
|
3054
|
+
}
|
|
3055
|
+
function bboxToString(bbox) {
|
|
3056
|
+
return typeof bbox === "string" ? bbox : bbox.join(",");
|
|
3057
|
+
}
|
|
3058
|
+
function spatialQuery(options) {
|
|
3059
|
+
const query = {};
|
|
3060
|
+
if ((options === null || options === void 0 ? void 0 : options.bbox) !== void 0) query.bbox = bboxToString(options.bbox);
|
|
3061
|
+
if ((options === null || options === void 0 ? void 0 : options.bboxCrs) !== void 0) query["bbox-crs"] = options.bboxCrs;
|
|
3062
|
+
if ((options === null || options === void 0 ? void 0 : options.crs) !== void 0) query.crs = options.crs;
|
|
3063
|
+
if ((options === null || options === void 0 ? void 0 : options.datetime) !== void 0) query.datetime = options.datetime;
|
|
3064
|
+
return query;
|
|
3065
|
+
}
|
|
3066
|
+
function nonEmpty(query) {
|
|
3067
|
+
return Object.keys(query).length > 0 ? query : void 0;
|
|
3068
|
+
}
|
|
3069
|
+
/**
|
|
3070
|
+
* OGC API Features (Part 1 Core, Part 2 CRS) and OGC API Maps (Part 1 Core)
|
|
3071
|
+
* wrapper for `/api/v4/ogc/database/{database}`.
|
|
3072
|
+
*
|
|
3073
|
+
* The endpoints accept Bearer token, HTTP Basic and anonymous requests. A
|
|
3074
|
+
* Bearer token must match the `database` in the path. Anonymous callers read
|
|
3075
|
+
* layers below `Read/write`; a `Read/write` collection answers 401 (Basic
|
|
3076
|
+
* challenge) for anonymous callers and 403 for identities without privilege.
|
|
3077
|
+
* Geofence rules, versioning and workflow are applied server-side.
|
|
3078
|
+
*
|
|
3079
|
+
* Map images cannot be fetched through this client; use `mapUrl` /
|
|
3080
|
+
* `datasetMapUrl` to build image URLs for `<img>` tags or map libraries.
|
|
3081
|
+
*
|
|
3082
|
+
* ```ts
|
|
3083
|
+
* const ogc = new Ogc(createCentiaClient({ baseUrl, auth }));
|
|
3084
|
+
* const page = await ogc.getItems('my_database', 'my_schema.roads', { bbox: [9, 55, 10, 56], limit: 100 });
|
|
3085
|
+
* ```
|
|
3086
|
+
*/
|
|
3087
|
+
var Ogc = class {
|
|
3088
|
+
constructor(client) {
|
|
3089
|
+
this.client = client;
|
|
3090
|
+
}
|
|
3091
|
+
basePath(database) {
|
|
3092
|
+
return `api/v4/ogc/database/${encodeURIComponent(database)}`;
|
|
3093
|
+
}
|
|
3094
|
+
collectionPath(database, collectionId) {
|
|
3095
|
+
return `${this.basePath(database)}/collections/${encodeURIComponent(collectionId)}`;
|
|
3096
|
+
}
|
|
3097
|
+
/** The landing page with links to conformance, collections and the OpenAPI document. */
|
|
3098
|
+
async getLandingPage(database) {
|
|
3099
|
+
var _this = this;
|
|
3100
|
+
return _this.client.request({
|
|
3101
|
+
path: _this.basePath(database),
|
|
3102
|
+
method: "GET"
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
/** Conformance classes implemented by the server. */
|
|
3106
|
+
async getConformance(database) {
|
|
3107
|
+
var _this2 = this;
|
|
3108
|
+
return _this2.client.request({
|
|
3109
|
+
path: `${_this2.basePath(database)}/conformance`,
|
|
3110
|
+
method: "GET"
|
|
3111
|
+
});
|
|
3112
|
+
}
|
|
3113
|
+
/** The collections (OWS-enabled layers) the caller may read, paged. */
|
|
3114
|
+
async getCollections(database, options) {
|
|
3115
|
+
var _this3 = this;
|
|
3116
|
+
const query = {};
|
|
3117
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) !== void 0) query.limit = String(options.limit);
|
|
3118
|
+
if ((options === null || options === void 0 ? void 0 : options.offset) !== void 0) query.offset = String(options.offset);
|
|
3119
|
+
return _this3.client.request({
|
|
3120
|
+
path: `${_this3.basePath(database)}/collections`,
|
|
3121
|
+
method: "GET",
|
|
3122
|
+
query: nonEmpty(query)
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
/**
|
|
3126
|
+
* One collection. Throws a `CentiaApiError` with status 404 (unknown),
|
|
3127
|
+
* 401 (anonymous caller, credentials required) or 403 (no privilege).
|
|
3128
|
+
*/
|
|
3129
|
+
async getCollection(database, collectionId) {
|
|
3130
|
+
var _this4 = this;
|
|
3131
|
+
return _this4.client.request({
|
|
3132
|
+
path: _this4.collectionPath(database, collectionId),
|
|
3133
|
+
method: "GET"
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3136
|
+
/**
|
|
3137
|
+
* Features of a collection as a GeoJSON FeatureCollection page. The default
|
|
3138
|
+
* page size is 10; follow `links` with `rel: 'next'` or pass `offset`.
|
|
3139
|
+
*/
|
|
3140
|
+
async getItems(database, collectionId, options) {
|
|
3141
|
+
var _this5 = this;
|
|
3142
|
+
const query = {};
|
|
3143
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) !== void 0) query.limit = String(options.limit);
|
|
3144
|
+
if ((options === null || options === void 0 ? void 0 : options.offset) !== void 0) query.offset = String(options.offset);
|
|
3145
|
+
Object.assign(query, spatialQuery(options));
|
|
3146
|
+
return _this5.client.request({
|
|
3147
|
+
path: `${_this5.collectionPath(database, collectionId)}/items`,
|
|
3148
|
+
method: "GET",
|
|
3149
|
+
query: nonEmpty(query),
|
|
3150
|
+
accept: "application/geo+json"
|
|
3151
|
+
});
|
|
3152
|
+
}
|
|
3153
|
+
/** One feature by primary key. Throws a 404 `CentiaApiError` when it does not exist. */
|
|
3154
|
+
async getItem(database, collectionId, featureId, options) {
|
|
3155
|
+
var _this6 = this;
|
|
3156
|
+
const query = {};
|
|
3157
|
+
if ((options === null || options === void 0 ? void 0 : options.crs) !== void 0) query.crs = options.crs;
|
|
3158
|
+
if ((options === null || options === void 0 ? void 0 : options.datetime) !== void 0) query.datetime = options.datetime;
|
|
3159
|
+
return _this6.client.request({
|
|
3160
|
+
path: `${_this6.collectionPath(database, collectionId)}/items/${encodeURIComponent(String(featureId))}`,
|
|
3161
|
+
method: "GET",
|
|
3162
|
+
query: nonEmpty(query),
|
|
3163
|
+
accept: "application/geo+json"
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
/**
|
|
3167
|
+
* URL of a rendered map of one collection (PNG/JPEG), without fetching it.
|
|
3168
|
+
* Authorization travels in the `Authorization` header, so for protected
|
|
3169
|
+
* collections fetch the image with the header set (or use Basic auth).
|
|
3170
|
+
*/
|
|
3171
|
+
mapUrl(database, collectionId, options) {
|
|
3172
|
+
return this.buildUrl(`${this.collectionPath(database, collectionId)}/map`, this.mapQuery(options));
|
|
3173
|
+
}
|
|
3174
|
+
/** URL of a rendered map of several collections of the same schema. */
|
|
3175
|
+
datasetMapUrl(database, collections, options) {
|
|
3176
|
+
const query = _objectSpread2({ collections: collections.join(",") }, this.mapQuery(options));
|
|
3177
|
+
return this.buildUrl(`${this.basePath(database)}/map`, query);
|
|
3178
|
+
}
|
|
3179
|
+
mapQuery(options) {
|
|
3180
|
+
const query = spatialQuery(options);
|
|
3181
|
+
if ((options === null || options === void 0 ? void 0 : options.width) !== void 0) query.width = String(options.width);
|
|
3182
|
+
if ((options === null || options === void 0 ? void 0 : options.height) !== void 0) query.height = String(options.height);
|
|
3183
|
+
if ((options === null || options === void 0 ? void 0 : options.format) !== void 0) query.f = options.format;
|
|
3184
|
+
if ((options === null || options === void 0 ? void 0 : options.transparent) !== void 0) query.transparent = String(options.transparent);
|
|
3185
|
+
if ((options === null || options === void 0 ? void 0 : options.bgcolor) !== void 0) query.bgcolor = options.bgcolor;
|
|
3186
|
+
return query;
|
|
3187
|
+
}
|
|
3188
|
+
buildUrl(path, query) {
|
|
3189
|
+
let url = `${this.client.baseUrl}/${path}`;
|
|
3190
|
+
if (Object.keys(query).length > 0) url += `?${new URLSearchParams(query).toString()}`;
|
|
3191
|
+
return url;
|
|
3192
|
+
}
|
|
3193
|
+
};
|
|
3194
|
+
|
|
3044
3195
|
//#endregion
|
|
3045
3196
|
//#region src/keyvalue/Keyvalue.ts
|
|
3046
3197
|
/**
|
|
@@ -3164,7 +3315,11 @@ var Features = class {
|
|
|
3164
3315
|
expectedStatus: 303
|
|
3165
3316
|
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
3166
3317
|
}
|
|
3167
|
-
/**
|
|
3318
|
+
/**
|
|
3319
|
+
* Delete one or more features by primary key. Keys that match are deleted
|
|
3320
|
+
* in one WFS-T transaction; a 404 `CentiaApiError` is thrown only when
|
|
3321
|
+
* none of the keys match.
|
|
3322
|
+
*/
|
|
3168
3323
|
async deleteFeature(schema, table, feature) {
|
|
3169
3324
|
await this.client.request({
|
|
3170
3325
|
path: featurePath(schema, table, feature),
|
|
@@ -3305,6 +3460,8 @@ exports.Keyvalue = Keyvalue;
|
|
|
3305
3460
|
exports.Mapcache = Mapcache;
|
|
3306
3461
|
exports.Meta = Meta;
|
|
3307
3462
|
exports.NotLoggedInError = NotLoggedInError;
|
|
3463
|
+
exports.OGC_CRS84 = OGC_CRS84;
|
|
3464
|
+
exports.Ogc = Ogc;
|
|
3308
3465
|
exports.Ows = Ows;
|
|
3309
3466
|
exports.PasswordFlow = PasswordFlow;
|
|
3310
3467
|
exports.Rpc = Rpc;
|
|
@@ -3323,4 +3480,5 @@ exports.createCentiaAdminClient = createCentiaAdminClient;
|
|
|
3323
3480
|
exports.createCentiaClient = createCentiaClient;
|
|
3324
3481
|
exports.createSqlBuilder = createSqlBuilder;
|
|
3325
3482
|
exports.createTokenProvider = createTokenProvider;
|
|
3326
|
-
exports.isCentiaApiError = isCentiaApiError;
|
|
3483
|
+
exports.isCentiaApiError = isCentiaApiError;
|
|
3484
|
+
exports.ogcEpsgCrs = ogcEpsgCrs;
|
package/dist/centia-io-sdk.d.cts
CHANGED
|
@@ -1655,55 +1655,6 @@ declare class Mapcache {
|
|
|
1655
1655
|
mapcacheUrl(database: string, path?: string, params?: MapcacheParams): string;
|
|
1656
1656
|
}
|
|
1657
1657
|
//#endregion
|
|
1658
|
-
//#region src/keyvalue/Keyvalue.d.ts
|
|
1659
|
-
/** A stored key/value entry. */
|
|
1660
|
-
interface KeyvalueEntry<T = unknown> {
|
|
1661
|
-
id: number;
|
|
1662
|
-
key: string;
|
|
1663
|
-
/** The stored JSON value, returned decoded. */
|
|
1664
|
-
value: T;
|
|
1665
|
-
/** Screen name of the owning user; null for legacy keys created without an owner. */
|
|
1666
|
-
owner: string | null;
|
|
1667
|
-
/** When true the key is readable by any user in the database. */
|
|
1668
|
-
public: boolean;
|
|
1669
|
-
}
|
|
1670
|
-
/** Body for creating a key. `owner` is always set server-side from the JWT and cannot be sent. */
|
|
1671
|
-
interface CreateKeyvalueRequest<T = unknown> {
|
|
1672
|
-
value: T;
|
|
1673
|
-
public?: boolean;
|
|
1674
|
-
}
|
|
1675
|
-
/** Partial update of a key's value and/or public flag. */
|
|
1676
|
-
interface PatchKeyvalueRequest<T = unknown> {
|
|
1677
|
-
value?: T;
|
|
1678
|
-
public?: boolean;
|
|
1679
|
-
}
|
|
1680
|
-
/** Result of a paths-projected GET: only the requested sub-trees, keyed by each path string. */
|
|
1681
|
-
interface KeyvalueProjection {
|
|
1682
|
-
value: Record<string, unknown>;
|
|
1683
|
-
}
|
|
1684
|
-
/**
|
|
1685
|
-
* Client for the key/value store (`/api/v4/keyvalue`).
|
|
1686
|
-
*
|
|
1687
|
-
* Keys are globally unique. Super users have full CRUD on all keys; sub-users
|
|
1688
|
-
* can read their own keys plus all public keys, and can only modify their own.
|
|
1689
|
-
*
|
|
1690
|
-
* ```ts
|
|
1691
|
-
* const kv = new Keyvalue(createCentiaClient({ baseUrl, auth }));
|
|
1692
|
-
* await kv.postKeyvalue('settings', { value: { theme: 'dark' } });
|
|
1693
|
-
* const entry = await kv.getKeyvalue('settings');
|
|
1694
|
-
* ```
|
|
1695
|
-
*/
|
|
1696
|
-
declare class Keyvalue {
|
|
1697
|
-
private readonly client;
|
|
1698
|
-
constructor(client: CentiaHttpClient);
|
|
1699
|
-
getKeyvalue(): Promise<KeyvalueEntry[]>;
|
|
1700
|
-
getKeyvalue<T = unknown>(key: string): Promise<KeyvalueEntry<T>>;
|
|
1701
|
-
getKeyvalue(key: string, paths: string | string[]): Promise<KeyvalueProjection>;
|
|
1702
|
-
postKeyvalue<T = unknown>(key: string, body: CreateKeyvalueRequest<T>): Promise<LocationResponse>;
|
|
1703
|
-
patchKeyvalue<T = unknown>(key: string, body: PatchKeyvalueRequest<T>): Promise<LocationResponse>;
|
|
1704
|
-
deleteKeyvalue(key: string): Promise<void>;
|
|
1705
|
-
}
|
|
1706
|
-
//#endregion
|
|
1707
1658
|
//#region src/features/Features.d.ts
|
|
1708
1659
|
/** A GeoJSON geometry object. Coordinates are lon/lat for EPSG:4326. */
|
|
1709
1660
|
interface GeoJsonGeometry {
|
|
@@ -1770,8 +1721,229 @@ declare class Features {
|
|
|
1770
1721
|
* feature must carry its primary-key value in `properties`.
|
|
1771
1722
|
*/
|
|
1772
1723
|
patchFeature(schema: string, table: string, body: GeoJsonFeature | GeoJsonFeatureCollection, options?: PatchFeatureOptions): Promise<LocationResponse>;
|
|
1773
|
-
/**
|
|
1774
|
-
|
|
1724
|
+
/**
|
|
1725
|
+
* Delete one or more features by primary key. Keys that match are deleted
|
|
1726
|
+
* in one WFS-T transaction; a 404 `CentiaApiError` is thrown only when
|
|
1727
|
+
* none of the keys match.
|
|
1728
|
+
*/
|
|
1729
|
+
deleteFeature(schema: string, table: string, feature: FeatureKey): Promise<void>;
|
|
1730
|
+
}
|
|
1731
|
+
//#endregion
|
|
1732
|
+
//#region src/ogc/Ogc.d.ts
|
|
1733
|
+
/** Default CRS of the OGC API: WGS 84 in longitude/latitude order. */
|
|
1734
|
+
declare const OGC_CRS84 = "http://www.opengis.net/def/crs/OGC/1.3/CRS84";
|
|
1735
|
+
/**
|
|
1736
|
+
* CRS URI for an EPSG code, e.g. `ogcEpsgCrs(25832)`. Note that
|
|
1737
|
+
* `ogcEpsgCrs(4326)` is latitude/longitude order; use `OGC_CRS84` for lon/lat.
|
|
1738
|
+
*/
|
|
1739
|
+
declare function ogcEpsgCrs(epsg: number): string;
|
|
1740
|
+
/** A link object as used throughout the OGC API. */
|
|
1741
|
+
interface OgcLink {
|
|
1742
|
+
rel: string;
|
|
1743
|
+
href: string;
|
|
1744
|
+
type?: string;
|
|
1745
|
+
title?: string;
|
|
1746
|
+
}
|
|
1747
|
+
/** The landing page of a database's OGC API. */
|
|
1748
|
+
interface OgcLandingPage {
|
|
1749
|
+
title: string;
|
|
1750
|
+
description?: string;
|
|
1751
|
+
links: OgcLink[];
|
|
1752
|
+
}
|
|
1753
|
+
/** Conformance classes implemented by the server. */
|
|
1754
|
+
interface OgcConformance {
|
|
1755
|
+
conformsTo: string[];
|
|
1756
|
+
}
|
|
1757
|
+
/** Spatial and temporal extent of a collection. */
|
|
1758
|
+
interface OgcExtent {
|
|
1759
|
+
spatial?: {
|
|
1760
|
+
bbox: number[][];
|
|
1761
|
+
crs?: string;
|
|
1762
|
+
};
|
|
1763
|
+
temporal?: {
|
|
1764
|
+
interval: Array<Array<string | null>>;
|
|
1765
|
+
trs?: string;
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
/** One collection (an OWS-enabled layer, id = `schema.table`). */
|
|
1769
|
+
interface OgcCollection {
|
|
1770
|
+
id: string;
|
|
1771
|
+
title?: string;
|
|
1772
|
+
description?: string;
|
|
1773
|
+
/** `feature` for vector layers; absent for raster layers (map only). */
|
|
1774
|
+
itemType?: string;
|
|
1775
|
+
extent?: OgcExtent;
|
|
1776
|
+
/** CRS URIs accepted by `crs`/`bbox-crs`. */
|
|
1777
|
+
crs?: string[];
|
|
1778
|
+
storageCrs?: string;
|
|
1779
|
+
links: OgcLink[];
|
|
1780
|
+
}
|
|
1781
|
+
/** A page of collections. */
|
|
1782
|
+
interface OgcCollections {
|
|
1783
|
+
links: OgcLink[];
|
|
1784
|
+
numberMatched: number;
|
|
1785
|
+
numberReturned: number;
|
|
1786
|
+
collections: OgcCollection[];
|
|
1787
|
+
}
|
|
1788
|
+
/** A GeoJSON Feature as returned by the OGC API (with links on single items). */
|
|
1789
|
+
interface OgcFeature<P$1 = Record<string, unknown>> extends GeoJsonFeature<P$1> {
|
|
1790
|
+
links?: OgcLink[];
|
|
1791
|
+
}
|
|
1792
|
+
/** A GeoJSON FeatureCollection page as returned by `/items`. */
|
|
1793
|
+
interface OgcFeatureCollection<P$1 = Record<string, unknown>> extends GeoJsonFeatureCollection<P$1> {
|
|
1794
|
+
features: OgcFeature<P$1>[];
|
|
1795
|
+
numberMatched?: number;
|
|
1796
|
+
numberReturned: number;
|
|
1797
|
+
timeStamp?: string;
|
|
1798
|
+
links: OgcLink[];
|
|
1799
|
+
}
|
|
1800
|
+
/** Options for `getCollections`. */
|
|
1801
|
+
interface OgcCollectionsOptions {
|
|
1802
|
+
/** Page size (default 100, max 1000). */
|
|
1803
|
+
limit?: number;
|
|
1804
|
+
/** Collections to skip. */
|
|
1805
|
+
offset?: number;
|
|
1806
|
+
}
|
|
1807
|
+
/** A bounding box: `[minx, miny, maxx, maxy]` in the axis order of its CRS, or the same as a comma-separated string. */
|
|
1808
|
+
type OgcBbox = [number, number, number, number] | number[] | string;
|
|
1809
|
+
/** Options shared by items and map requests. */
|
|
1810
|
+
interface OgcSpatialOptions {
|
|
1811
|
+
/** Bounding box in the axis order of `bboxCrs` (default CRS84 = lon/lat). */
|
|
1812
|
+
bbox?: OgcBbox;
|
|
1813
|
+
/** CRS URI of `bbox`. Defaults to CRS84. */
|
|
1814
|
+
bboxCrs?: string;
|
|
1815
|
+
/** Output CRS URI from the collection's `crs` list. Defaults to CRS84. */
|
|
1816
|
+
crs?: string;
|
|
1817
|
+
/**
|
|
1818
|
+
* ISO 8601 instant. On a versioned layer, the version valid at that time;
|
|
1819
|
+
* ignored on other layers. Intervals are not supported.
|
|
1820
|
+
*/
|
|
1821
|
+
datetime?: string;
|
|
1822
|
+
}
|
|
1823
|
+
/** Options for `getItems`. */
|
|
1824
|
+
interface OgcItemsOptions extends OgcSpatialOptions {
|
|
1825
|
+
/** Page size (default 10, max 10000). */
|
|
1826
|
+
limit?: number;
|
|
1827
|
+
/** Features to skip. */
|
|
1828
|
+
offset?: number;
|
|
1829
|
+
}
|
|
1830
|
+
/** Options for `getItem`. */
|
|
1831
|
+
interface OgcItemOptions {
|
|
1832
|
+
crs?: string;
|
|
1833
|
+
datetime?: string;
|
|
1834
|
+
}
|
|
1835
|
+
/** Options for map URLs. */
|
|
1836
|
+
interface OgcMapOptions extends OgcSpatialOptions {
|
|
1837
|
+
/** Image width in pixels (max 16384). */
|
|
1838
|
+
width?: number;
|
|
1839
|
+
/** Image height in pixels (max 16384). Missing dimensions follow the bbox aspect ratio. */
|
|
1840
|
+
height?: number;
|
|
1841
|
+
/** `png` (default, transparent) or `jpeg` (opaque). */
|
|
1842
|
+
format?: 'png' | 'jpeg';
|
|
1843
|
+
transparent?: boolean;
|
|
1844
|
+
/** Background colour as `0xRRGGBB`. */
|
|
1845
|
+
bgcolor?: string;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* OGC API Features (Part 1 Core, Part 2 CRS) and OGC API Maps (Part 1 Core)
|
|
1849
|
+
* wrapper for `/api/v4/ogc/database/{database}`.
|
|
1850
|
+
*
|
|
1851
|
+
* The endpoints accept Bearer token, HTTP Basic and anonymous requests. A
|
|
1852
|
+
* Bearer token must match the `database` in the path. Anonymous callers read
|
|
1853
|
+
* layers below `Read/write`; a `Read/write` collection answers 401 (Basic
|
|
1854
|
+
* challenge) for anonymous callers and 403 for identities without privilege.
|
|
1855
|
+
* Geofence rules, versioning and workflow are applied server-side.
|
|
1856
|
+
*
|
|
1857
|
+
* Map images cannot be fetched through this client; use `mapUrl` /
|
|
1858
|
+
* `datasetMapUrl` to build image URLs for `<img>` tags or map libraries.
|
|
1859
|
+
*
|
|
1860
|
+
* ```ts
|
|
1861
|
+
* const ogc = new Ogc(createCentiaClient({ baseUrl, auth }));
|
|
1862
|
+
* const page = await ogc.getItems('my_database', 'my_schema.roads', { bbox: [9, 55, 10, 56], limit: 100 });
|
|
1863
|
+
* ```
|
|
1864
|
+
*/
|
|
1865
|
+
declare class Ogc {
|
|
1866
|
+
private readonly client;
|
|
1867
|
+
constructor(client: CentiaHttpClient);
|
|
1868
|
+
private basePath;
|
|
1869
|
+
private collectionPath;
|
|
1870
|
+
/** The landing page with links to conformance, collections and the OpenAPI document. */
|
|
1871
|
+
getLandingPage(database: string): Promise<OgcLandingPage>;
|
|
1872
|
+
/** Conformance classes implemented by the server. */
|
|
1873
|
+
getConformance(database: string): Promise<OgcConformance>;
|
|
1874
|
+
/** The collections (OWS-enabled layers) the caller may read, paged. */
|
|
1875
|
+
getCollections(database: string, options?: OgcCollectionsOptions): Promise<OgcCollections>;
|
|
1876
|
+
/**
|
|
1877
|
+
* One collection. Throws a `CentiaApiError` with status 404 (unknown),
|
|
1878
|
+
* 401 (anonymous caller, credentials required) or 403 (no privilege).
|
|
1879
|
+
*/
|
|
1880
|
+
getCollection(database: string, collectionId: string): Promise<OgcCollection>;
|
|
1881
|
+
/**
|
|
1882
|
+
* Features of a collection as a GeoJSON FeatureCollection page. The default
|
|
1883
|
+
* page size is 10; follow `links` with `rel: 'next'` or pass `offset`.
|
|
1884
|
+
*/
|
|
1885
|
+
getItems<P$1 = Record<string, unknown>>(database: string, collectionId: string, options?: OgcItemsOptions): Promise<OgcFeatureCollection<P$1>>;
|
|
1886
|
+
/** One feature by primary key. Throws a 404 `CentiaApiError` when it does not exist. */
|
|
1887
|
+
getItem<P$1 = Record<string, unknown>>(database: string, collectionId: string, featureId: string | number, options?: OgcItemOptions): Promise<OgcFeature<P$1>>;
|
|
1888
|
+
/**
|
|
1889
|
+
* URL of a rendered map of one collection (PNG/JPEG), without fetching it.
|
|
1890
|
+
* Authorization travels in the `Authorization` header, so for protected
|
|
1891
|
+
* collections fetch the image with the header set (or use Basic auth).
|
|
1892
|
+
*/
|
|
1893
|
+
mapUrl(database: string, collectionId: string, options?: OgcMapOptions): string;
|
|
1894
|
+
/** URL of a rendered map of several collections of the same schema. */
|
|
1895
|
+
datasetMapUrl(database: string, collections: string[], options?: OgcMapOptions): string;
|
|
1896
|
+
private mapQuery;
|
|
1897
|
+
private buildUrl;
|
|
1898
|
+
}
|
|
1899
|
+
//#endregion
|
|
1900
|
+
//#region src/keyvalue/Keyvalue.d.ts
|
|
1901
|
+
/** A stored key/value entry. */
|
|
1902
|
+
interface KeyvalueEntry<T = unknown> {
|
|
1903
|
+
id: number;
|
|
1904
|
+
key: string;
|
|
1905
|
+
/** The stored JSON value, returned decoded. */
|
|
1906
|
+
value: T;
|
|
1907
|
+
/** Screen name of the owning user; null for legacy keys created without an owner. */
|
|
1908
|
+
owner: string | null;
|
|
1909
|
+
/** When true the key is readable by any user in the database. */
|
|
1910
|
+
public: boolean;
|
|
1911
|
+
}
|
|
1912
|
+
/** Body for creating a key. `owner` is always set server-side from the JWT and cannot be sent. */
|
|
1913
|
+
interface CreateKeyvalueRequest<T = unknown> {
|
|
1914
|
+
value: T;
|
|
1915
|
+
public?: boolean;
|
|
1916
|
+
}
|
|
1917
|
+
/** Partial update of a key's value and/or public flag. */
|
|
1918
|
+
interface PatchKeyvalueRequest<T = unknown> {
|
|
1919
|
+
value?: T;
|
|
1920
|
+
public?: boolean;
|
|
1921
|
+
}
|
|
1922
|
+
/** Result of a paths-projected GET: only the requested sub-trees, keyed by each path string. */
|
|
1923
|
+
interface KeyvalueProjection {
|
|
1924
|
+
value: Record<string, unknown>;
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Client for the key/value store (`/api/v4/keyvalue`).
|
|
1928
|
+
*
|
|
1929
|
+
* Keys are globally unique. Super users have full CRUD on all keys; sub-users
|
|
1930
|
+
* can read their own keys plus all public keys, and can only modify their own.
|
|
1931
|
+
*
|
|
1932
|
+
* ```ts
|
|
1933
|
+
* const kv = new Keyvalue(createCentiaClient({ baseUrl, auth }));
|
|
1934
|
+
* await kv.postKeyvalue('settings', { value: { theme: 'dark' } });
|
|
1935
|
+
* const entry = await kv.getKeyvalue('settings');
|
|
1936
|
+
* ```
|
|
1937
|
+
*/
|
|
1938
|
+
declare class Keyvalue {
|
|
1939
|
+
private readonly client;
|
|
1940
|
+
constructor(client: CentiaHttpClient);
|
|
1941
|
+
getKeyvalue(): Promise<KeyvalueEntry[]>;
|
|
1942
|
+
getKeyvalue<T = unknown>(key: string): Promise<KeyvalueEntry<T>>;
|
|
1943
|
+
getKeyvalue(key: string, paths: string | string[]): Promise<KeyvalueProjection>;
|
|
1944
|
+
postKeyvalue<T = unknown>(key: string, body: CreateKeyvalueRequest<T>): Promise<LocationResponse>;
|
|
1945
|
+
patchKeyvalue<T = unknown>(key: string, body: PatchKeyvalueRequest<T>): Promise<LocationResponse>;
|
|
1946
|
+
deleteKeyvalue(key: string): Promise<void>;
|
|
1775
1947
|
}
|
|
1776
1948
|
//#endregion
|
|
1777
1949
|
//#region src/auth/types.d.ts
|
|
@@ -1883,5 +2055,5 @@ declare class SessionExpiredError extends Error {
|
|
|
1883
2055
|
*/
|
|
1884
2056
|
|
|
1885
2057
|
//#endregion
|
|
1886
|
-
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, 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, 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 };
|
|
2058
|
+
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, 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 };
|
|
1887
2059
|
//# sourceMappingURL=centia-io-sdk.d.cts.map
|