@centia-io/sdk 0.2.9 → 0.2.11
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 +70 -0
- package/dist/centia-io-sdk.cjs +135 -0
- package/dist/centia-io-sdk.d.cts +120 -1
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +120 -1
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +134 -1
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +135 -0
- package/package.json +9 -3
|
@@ -3046,6 +3046,139 @@
|
|
|
3046
3046
|
}
|
|
3047
3047
|
};
|
|
3048
3048
|
|
|
3049
|
+
//#endregion
|
|
3050
|
+
//#region src/keyvalue/Keyvalue.ts
|
|
3051
|
+
/**
|
|
3052
|
+
* Client for the key/value store (`/api/v4/keyvalue`).
|
|
3053
|
+
*
|
|
3054
|
+
* Keys are globally unique. Super users have full CRUD on all keys; sub-users
|
|
3055
|
+
* can read their own keys plus all public keys, and can only modify their own.
|
|
3056
|
+
*
|
|
3057
|
+
* ```ts
|
|
3058
|
+
* const kv = new Keyvalue(createCentiaClient({ baseUrl, auth }));
|
|
3059
|
+
* await kv.postKeyvalue('settings', { value: { theme: 'dark' } });
|
|
3060
|
+
* const entry = await kv.getKeyvalue('settings');
|
|
3061
|
+
* ```
|
|
3062
|
+
*/
|
|
3063
|
+
var Keyvalue = class {
|
|
3064
|
+
constructor(client) {
|
|
3065
|
+
this.client = client;
|
|
3066
|
+
}
|
|
3067
|
+
async getKeyvalue(key, paths) {
|
|
3068
|
+
var _this = this;
|
|
3069
|
+
const path = key != null ? `api/v4/keyvalue/${encodeURIComponent(key)}` : "api/v4/keyvalue";
|
|
3070
|
+
const pathsParam = Array.isArray(paths) ? paths.join(",") : paths;
|
|
3071
|
+
return _this.client.request({
|
|
3072
|
+
path,
|
|
3073
|
+
method: "GET",
|
|
3074
|
+
query: pathsParam ? { paths: pathsParam } : void 0
|
|
3075
|
+
});
|
|
3076
|
+
}
|
|
3077
|
+
async postKeyvalue(key, body) {
|
|
3078
|
+
var _this2 = this;
|
|
3079
|
+
var _res$getHeader;
|
|
3080
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
3081
|
+
path: `api/v4/keyvalue/${encodeURIComponent(key)}`,
|
|
3082
|
+
method: "POST",
|
|
3083
|
+
body,
|
|
3084
|
+
expectedStatus: 201
|
|
3085
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
3086
|
+
}
|
|
3087
|
+
async patchKeyvalue(key, body) {
|
|
3088
|
+
var _this3 = this;
|
|
3089
|
+
var _res$getHeader2;
|
|
3090
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
3091
|
+
path: `api/v4/keyvalue/${encodeURIComponent(key)}`,
|
|
3092
|
+
method: "PATCH",
|
|
3093
|
+
body,
|
|
3094
|
+
expectedStatus: 303
|
|
3095
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
3096
|
+
}
|
|
3097
|
+
async deleteKeyvalue(key) {
|
|
3098
|
+
await this.client.request({
|
|
3099
|
+
path: `api/v4/keyvalue/${encodeURIComponent(key)}`,
|
|
3100
|
+
method: "DELETE",
|
|
3101
|
+
expectedStatus: 204
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
|
|
3106
|
+
//#endregion
|
|
3107
|
+
//#region src/features/Features.ts
|
|
3108
|
+
function featurePath(schema, table, feature) {
|
|
3109
|
+
const base = `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/features`;
|
|
3110
|
+
if (feature === void 0) return base;
|
|
3111
|
+
return `${base}/${(Array.isArray(feature) ? feature : [feature]).map((k) => encodeURIComponent(String(k))).join(",")}`;
|
|
3112
|
+
}
|
|
3113
|
+
/**
|
|
3114
|
+
* Client for the Feature API (`/api/v4/schemas/{schema}/tables/{table}/features`).
|
|
3115
|
+
*
|
|
3116
|
+
* Reads and writes table rows as GeoJSON through WFS-T transactions. Read auth,
|
|
3117
|
+
* geofence rules and versioning filters are applied by the WFS engine.
|
|
3118
|
+
*
|
|
3119
|
+
* ```ts
|
|
3120
|
+
* const features = new Features(createCentiaClient({ baseUrl, auth }));
|
|
3121
|
+
* const feature = await features.getFeature('my_schema', 'my_table', 1);
|
|
3122
|
+
* ```
|
|
3123
|
+
*/
|
|
3124
|
+
var Features = class {
|
|
3125
|
+
constructor(client) {
|
|
3126
|
+
this.client = client;
|
|
3127
|
+
}
|
|
3128
|
+
/**
|
|
3129
|
+
* Get one or more features by primary key. A single match returns a bare
|
|
3130
|
+
* GeoJSON `Feature`; several matches return a `FeatureCollection`.
|
|
3131
|
+
* Throws a 404 `CentiaApiError` when no keys match.
|
|
3132
|
+
*/
|
|
3133
|
+
async getFeature(schema, table, feature, options) {
|
|
3134
|
+
return this.client.request({
|
|
3135
|
+
path: featurePath(schema, table, feature),
|
|
3136
|
+
method: "GET",
|
|
3137
|
+
query: (options === null || options === void 0 ? void 0 : options.srs) !== void 0 ? { srs: String(options.srs) } : void 0
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Insert features from a GeoJSON `Feature` or `FeatureCollection`.
|
|
3142
|
+
* A primary-key value in `properties` is used as the new key; otherwise one
|
|
3143
|
+
* is generated. The returned location points at the new feature(s).
|
|
3144
|
+
*/
|
|
3145
|
+
async postFeature(schema, table, body, options) {
|
|
3146
|
+
var _this2 = this;
|
|
3147
|
+
var _res$getHeader;
|
|
3148
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
3149
|
+
path: featurePath(schema, table),
|
|
3150
|
+
method: "POST",
|
|
3151
|
+
body,
|
|
3152
|
+
query: (options === null || options === void 0 ? void 0 : options.srs) !== void 0 ? { srs: String(options.srs) } : void 0,
|
|
3153
|
+
expectedStatus: 201
|
|
3154
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
3155
|
+
}
|
|
3156
|
+
/**
|
|
3157
|
+
* Update features from a GeoJSON `Feature` or `FeatureCollection`. Pass
|
|
3158
|
+
* `options.feature` to address a single feature by path; otherwise each
|
|
3159
|
+
* feature must carry its primary-key value in `properties`.
|
|
3160
|
+
*/
|
|
3161
|
+
async patchFeature(schema, table, body, options) {
|
|
3162
|
+
var _this3 = this;
|
|
3163
|
+
var _res$getHeader2;
|
|
3164
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
3165
|
+
path: featurePath(schema, table, options === null || options === void 0 ? void 0 : options.feature),
|
|
3166
|
+
method: "PATCH",
|
|
3167
|
+
body,
|
|
3168
|
+
query: (options === null || options === void 0 ? void 0 : options.srs) !== void 0 ? { srs: String(options.srs) } : void 0,
|
|
3169
|
+
expectedStatus: 303
|
|
3170
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
3171
|
+
}
|
|
3172
|
+
/** Delete a single feature by primary key. */
|
|
3173
|
+
async deleteFeature(schema, table, feature) {
|
|
3174
|
+
await this.client.request({
|
|
3175
|
+
path: featurePath(schema, table, feature),
|
|
3176
|
+
method: "DELETE",
|
|
3177
|
+
expectedStatus: 204
|
|
3178
|
+
});
|
|
3179
|
+
}
|
|
3180
|
+
};
|
|
3181
|
+
|
|
3049
3182
|
//#endregion
|
|
3050
3183
|
//#region src/auth/errors.ts
|
|
3051
3184
|
/**
|
|
@@ -3171,7 +3304,9 @@
|
|
|
3171
3304
|
exports.CentiaApiError = CentiaApiError;
|
|
3172
3305
|
exports.Claims = Claims;
|
|
3173
3306
|
exports.CodeFlow = CodeFlow;
|
|
3307
|
+
exports.Features = Features;
|
|
3174
3308
|
exports.Gql = Gql;
|
|
3309
|
+
exports.Keyvalue = Keyvalue;
|
|
3175
3310
|
exports.Mapcache = Mapcache;
|
|
3176
3311
|
exports.Meta = Meta;
|
|
3177
3312
|
exports.NotLoggedInError = NotLoggedInError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centia-io/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Centia-io TypeScript SDK",
|
|
5
5
|
"author": "Martin Høgh",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,8 +14,14 @@
|
|
|
14
14
|
"import": "./dist/centia-io-sdk.js"
|
|
15
15
|
},
|
|
16
16
|
"./node": {
|
|
17
|
-
"import": {
|
|
18
|
-
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/centia-io-sdk-node.d.ts",
|
|
19
|
+
"default": "./dist/centia-io-sdk-node.js"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/centia-io-sdk-node.d.cts",
|
|
23
|
+
"default": "./dist/centia-io-sdk-node.cjs"
|
|
24
|
+
}
|
|
19
25
|
},
|
|
20
26
|
"./package.json": "./package.json"
|
|
21
27
|
},
|