@palbase/backend 10.1.0 → 10.2.0

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.
package/dist/index.cjs CHANGED
@@ -977,6 +977,8 @@ function valueMatchesType(type, value) {
977
977
  return typeof value === "number" && Number.isFinite(value);
978
978
  case "string":
979
979
  return typeof value === "string";
980
+ case "json":
981
+ return typeof value === "object" && value !== null && !Array.isArray(value);
980
982
  }
981
983
  }
982
984
  function flag(opts) {
@@ -984,8 +986,8 @@ function flag(opts) {
984
986
  throw new Error("flag() expects { type, default, variants?, description? }");
985
987
  }
986
988
  const { type } = opts;
987
- if (type !== "boolean" && type !== "number" && type !== "string") {
988
- throw new Error(`flag type must be "boolean", "number", or "string", got ${JSON.stringify(type)}`);
989
+ if (type !== "boolean" && type !== "number" && type !== "string" && type !== "json") {
990
+ throw new Error(`flag type must be "boolean", "number", "string", or "json", got ${JSON.stringify(type)}`);
989
991
  }
990
992
  if (!valueMatchesType(type, opts.default)) {
991
993
  throw new Error(
@@ -994,7 +996,7 @@ function flag(opts) {
994
996
  }
995
997
  let variants = null;
996
998
  if (opts.variants !== void 0) {
997
- if (type !== "string") {
999
+ if (opts.type !== "string") {
998
1000
  throw new Error(`flag variants are only valid for type "string" (got type "${type}")`);
999
1001
  }
1000
1002
  if (!Array.isArray(opts.variants)) {