@centia-io/sdk 0.2.8 → 0.2.10

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.
@@ -2872,8 +2872,9 @@
2872
2872
  /**
2873
2873
  * OWS (WMS/WFS/UTFGRID) endpoint wrapper.
2874
2874
  *
2875
- * Token-authenticated clients use `getOws`/`postOws`; anonymous and HTTP-Basic
2876
- * clients use the `...NoToken` variants, which include the database in the path.
2875
+ * The endpoint accepts Bearer token, HTTP Basic and anonymous requests. A
2876
+ * Bearer token must match the `database` in the path; protected layers
2877
+ * challenge token-less requests with HTTP Basic auth.
2877
2878
  *
2878
2879
  * Responses are streamed from the backend and returned as text (XML) or, for
2879
2880
  * JSON responses such as UTFGRID, as parsed JSON. Binary responses (e.g. WMS
@@ -2883,38 +2884,24 @@
2883
2884
  constructor(client) {
2884
2885
  this.client = client;
2885
2886
  }
2886
- /** Token-authenticated OWS GET (WMS/WFS/UTFGRID). */
2887
- async getOws(schema, params) {
2888
- return this.client.request({
2889
- path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2890
- method: "GET",
2891
- query: toQuery$2(params),
2892
- accept: "*/*"
2893
- });
2887
+ basePath(schema, database) {
2888
+ return `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2894
2889
  }
2895
- /** Token-authenticated OWS POST (WFS XML). */
2896
- async postOws(schema, xml) {
2897
- return this.client.request({
2898
- path: `api/v4/ows/schema/${encodeURIComponent(schema)}`,
2899
- method: "POST",
2900
- body: xml,
2901
- contentType: "text/xml",
2902
- accept: "*/*"
2903
- });
2904
- }
2905
- /** Anonymous/HTTP-Basic OWS GET (WMS/WFS/UTFGRID). */
2906
- async getOwsNoToken(schema, database, params) {
2907
- return this.client.request({
2908
- path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2890
+ /** OWS GET (WMS/WFS/UTFGRID). */
2891
+ async getOws(schema, database, params) {
2892
+ var _this = this;
2893
+ return _this.client.request({
2894
+ path: _this.basePath(schema, database),
2909
2895
  method: "GET",
2910
2896
  query: toQuery$2(params),
2911
2897
  accept: "*/*"
2912
2898
  });
2913
2899
  }
2914
- /** Anonymous/HTTP-Basic OWS POST (WFS XML). */
2915
- async postOwsNoToken(schema, database, xml) {
2916
- return this.client.request({
2917
- path: `api/v4/ows/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`,
2900
+ /** OWS POST (WFS XML). */
2901
+ async postOws(schema, database, xml) {
2902
+ var _this2 = this;
2903
+ return _this2.client.request({
2904
+ path: _this2.basePath(schema, database),
2918
2905
  method: "POST",
2919
2906
  body: xml,
2920
2907
  contentType: "text/xml",
@@ -2930,7 +2917,7 @@
2930
2917
  if ((options === null || options === void 0 ? void 0 : options.timeSlice) != null && options.srs == null) throw new Error("timeSlice requires srs to be set");
2931
2918
  if ((options === null || options === void 0 ? void 0 : options.srs) != null) {
2932
2919
  path += `/srs/${encodeURIComponent(options.srs)}`;
2933
- if (options.timeSlice != null) path += `/${encodeURIComponent(options.timeSlice)}`;
2920
+ if (options.timeSlice != null) path += `/ts/${encodeURIComponent(options.timeSlice)}`;
2934
2921
  }
2935
2922
  return path;
2936
2923
  }
@@ -2943,50 +2930,33 @@
2943
2930
  * WFS endpoint wrapper (GetCapabilities, DescribeFeatureType, GetFeature and
2944
2931
  * WFS-T transactions).
2945
2932
  *
2946
- * Token-authenticated clients use `getWfs`/`postWfs`; anonymous and HTTP-Basic
2947
- * clients (e.g. QGIS) use the `...NoToken` variants, which include the
2948
- * database in the path. Responses are returned as XML text.
2933
+ * The endpoint accepts Bearer token, HTTP Basic and anonymous requests. A
2934
+ * Bearer token must match the `database` in the path; protected layers
2935
+ * challenge token-less requests with HTTP Basic auth, and transactions on a
2936
+ * protected layer require credentials. Responses are returned as XML text.
2949
2937
  */
2950
2938
  var Wfs = class {
2951
2939
  constructor(client) {
2952
2940
  this.client = client;
2953
2941
  }
2954
- /** Token-authenticated WFS GET. */
2955
- async getWfs(schema, params, options) {
2956
- return this.client.request({
2957
- path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2958
- method: "GET",
2959
- query: toQuery$1(params),
2960
- accept: "text/xml"
2961
- });
2962
- }
2963
- /** Token-authenticated WFS POST (XML-encoded GetFeature or Transaction). */
2964
- async postWfs(schema, xml, options) {
2965
- return this.client.request({
2966
- path: wfsPath(`api/v4/wfs/schema/${encodeURIComponent(schema)}`, options),
2967
- method: "POST",
2968
- body: xml,
2969
- contentType: "text/xml",
2970
- accept: "text/xml"
2971
- });
2942
+ basePath(schema, database) {
2943
+ return `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2972
2944
  }
2973
- /** Anonymous/HTTP-Basic WFS GET. */
2974
- async getWfsNoToken(schema, database, params, options) {
2975
- var _this3 = this;
2976
- const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2977
- return _this3.client.request({
2978
- path: wfsPath(base, options),
2945
+ /** WFS GET. */
2946
+ async getWfs(schema, database, params, options) {
2947
+ var _this = this;
2948
+ return _this.client.request({
2949
+ path: wfsPath(_this.basePath(schema, database), options),
2979
2950
  method: "GET",
2980
2951
  query: toQuery$1(params),
2981
2952
  accept: "text/xml"
2982
2953
  });
2983
2954
  }
2984
- /** Anonymous/HTTP-Basic WFS POST (XML-encoded GetFeature or Transaction). */
2985
- async postWfsNoToken(schema, database, xml, options) {
2986
- var _this4 = this;
2987
- const base = `api/v4/wfs/schema/${encodeURIComponent(schema)}/database/${encodeURIComponent(database)}`;
2988
- return _this4.client.request({
2989
- path: wfsPath(base, options),
2955
+ /** WFS POST (XML-encoded GetFeature or Transaction). */
2956
+ async postWfs(schema, database, xml, options) {
2957
+ var _this2 = this;
2958
+ return _this2.client.request({
2959
+ path: wfsPath(_this2.basePath(schema, database), options),
2990
2960
  method: "POST",
2991
2961
  body: xml,
2992
2962
  contentType: "text/xml",
@@ -3076,6 +3046,63 @@
3076
3046
  }
3077
3047
  };
3078
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
+
3079
3106
  //#endregion
3080
3107
  //#region src/auth/errors.ts
3081
3108
  /**
@@ -3202,6 +3229,7 @@ exports.CentiaApiError = CentiaApiError;
3202
3229
  exports.Claims = Claims;
3203
3230
  exports.CodeFlow = CodeFlow;
3204
3231
  exports.Gql = Gql;
3232
+ exports.Keyvalue = Keyvalue;
3205
3233
  exports.Mapcache = Mapcache;
3206
3234
  exports.Meta = Meta;
3207
3235
  exports.NotLoggedInError = NotLoggedInError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centia-io/sdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
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": { "types": "./dist/centia-io-sdk-node.d.ts", "default": "./dist/centia-io-sdk-node.js" },
18
- "require": { "types": "./dist/centia-io-sdk-node.d.cts", "default": "./dist/centia-io-sdk-node.cjs" }
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
  },