diff --git a/deps.js b/deps.js index 9142734..d62af6f 100644 --- a/deps.js +++ b/deps.js @@ -1 +1 @@ -export { makeRpcCall } from "https://dev.zaubrik.com/schicksal@v0.1.2/client/dist/mod.js"; +export { makeRpcCall } from "https://dev.zaubrik.com/schicksal@v0.1.3/client/dist/mod.js"; diff --git a/shadow.js b/shadow.js index 823a41a..8308498 100644 --- a/shadow.js +++ b/shadow.js @@ -3,6 +3,7 @@ import { convertDashToCamel, createTemplate, getJwt, + isArray, isHtmlElement, isNull, isObject, @@ -56,7 +57,7 @@ export class Shadow extends HTMLElement { /** @type{JsonValue} */ jsonData = null; - /** @type{Record} */ + /** @type{JsonObject | JsonArray } */ rpcData = {}; /** @@ -298,7 +299,7 @@ export class Shadow extends HTMLElement { { method, params: /**@type {any}*/ (this)[property] }, isNull(jwt) ? undefined : { jwt }, ); - if (isObject(result)) { + if (isObject(result) || isArray(result)) { this.rpcData[method] = /**@type {JsonObject}*/ (result); } else { throw new Error("The rpc result is not an object."); diff --git a/util.js b/util.js index 80ff3ff..5b5ec63 100644 --- a/util.js +++ b/util.js @@ -85,6 +85,14 @@ export function isObject(obj) { Array.isArray(obj) === false); } +/** + * @param {unknown} obj + * @returns {obj is unknown[]} + */ +export function isArray(obj) { + return Array.isArray(obj); +} + /** * @param {unknown} input * @returns {input is HTMLElement}