@centia-io/sdk 0.2.10 → 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.
@@ -3103,6 +3103,82 @@
3103
3103
  }
3104
3104
  };
3105
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
+
3106
3182
  //#endregion
3107
3183
  //#region src/auth/errors.ts
3108
3184
  /**
@@ -3228,6 +3304,7 @@
3228
3304
  exports.CentiaApiError = CentiaApiError;
3229
3305
  exports.Claims = Claims;
3230
3306
  exports.CodeFlow = CodeFlow;
3307
+ exports.Features = Features;
3231
3308
  exports.Gql = Gql;
3232
3309
  exports.Keyvalue = Keyvalue;
3233
3310
  exports.Mapcache = Mapcache;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centia-io/sdk",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Centia-io TypeScript SDK",
5
5
  "author": "Martin Høgh",
6
6
  "license": "MIT",