npm package diff
Package: @forge/kvs
Versions: 1.0.9-next.0 - 1.1.0-next.1
File: package/out/storage-api.js
Index: package/out/storage-api.js
===================================================================
--- package/out/storage-api.js
+++ package/out/storage-api.js
@@ -1,7 +1,8 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.StorageApi = void 0;
+const types_1 = require("./interfaces/types");
 const error_handling_1 = require("./utils/error-handling");
 const errors_1 = require("./errors");
 class StorageApi {
     apiClient;
@@ -11,21 +12,21 @@
     async get(body) {
         const rs = await this.handleKeyNotFound(async () => {
             return this.request('/api/v1/get', body, true);
         });
-        return rs?.value;
+        return this.processGetResponse(rs, body.options?.metadataFields);
     }
     async getSecret(body) {
         const rs = await this.handleKeyNotFound(async () => {
             return this.request('/api/v1/secret/get', body, true);
         });
-        return rs?.value;
+        return this.processGetResponse(rs, body.options?.metadataFields);
     }
     async getEntity(body) {
         const rs = await this.handleKeyNotFound(async () => {
             return this.request('/api/v1/entity/get', body, true);
         });
-        return rs?.value;
+        return this.processGetResponse(rs, body.options?.metadataFields);
     }
     async set(body) {
         await this.request('/api/v1/set', body, false);
     }
@@ -98,6 +99,23 @@
         catch (error) {
             throw new errors_1.ForgeKvsError(`Unexpected error. Response was not valid JSON: ${responseText}`);
         }
     }
+    processGetResponse(response, requestedMetadataFields) {
+        if (response && requestedMetadataFields?.length) {
+            const maybeCreatedAt = requestedMetadataFields.includes(types_1.MetadataField.CREATED_AT)
+                ? { createdAt: response.createdAt }
+                : {};
+            const maybeUpdatedAt = requestedMetadataFields.includes(types_1.MetadataField.UPDATED_AT)
+                ? { updatedAt: response.updatedAt }
+                : {};
+            return {
+                key: response.key,
+                value: response.value,
+                ...maybeCreatedAt,
+                ...maybeUpdatedAt
+            };
+        }
+        return response?.value;
+    }
 }
 exports.StorageApi = StorageApi;