@centia-io/sdk 0.2.9 → 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.
@@ -3046,6 +3046,63 @@
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
+
3049
3106
  //#endregion
3050
3107
  //#region src/auth/errors.ts
3051
3108
  /**
@@ -3172,6 +3229,7 @@ exports.CentiaApiError = CentiaApiError;
3172
3229
  exports.Claims = Claims;
3173
3230
  exports.CodeFlow = CodeFlow;
3174
3231
  exports.Gql = Gql;
3232
+ exports.Keyvalue = Keyvalue;
3175
3233
  exports.Mapcache = Mapcache;
3176
3234
  exports.Meta = Meta;
3177
3235
  exports.NotLoggedInError = NotLoggedInError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centia-io/sdk",
3
- "version": "0.2.9",
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
  },