@lessly/sdk-app 63.2.3 → 63.2.4

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.js CHANGED
@@ -11261,8 +11261,30 @@ function createLesslyApp(opts) {
11261
11261
  }
11262
11262
 
11263
11263
  // src/runtime/access-reason.ts
11264
+ var LEVELS2 = ["read", "write", "admin"];
11265
+ var isNonEmptyString = (value) => typeof value === "string" && value.trim() !== "";
11266
+ var isLevel = (value) => typeof value === "string" && LEVELS2.includes(value);
11267
+ function warnDegenerate(input) {
11268
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
11269
+ console.warn("accessReason: degenerate input", input);
11270
+ }
11271
+ }
11264
11272
  function accessReason(op) {
11265
- return typeof op === "string" ? `Requires access to ${op}. Ask an admin of this product.` : `Requires level:${op.level} (${op.operationKey}). Ask an admin of this product.`;
11273
+ if (isNonEmptyString(op)) {
11274
+ return `Requires access to ${op}. Ask an admin of this product.`;
11275
+ }
11276
+ if (op !== null && (typeof op === "object" || typeof op === "function")) {
11277
+ const { operationKey, level } = op;
11278
+ if (isNonEmptyString(operationKey)) {
11279
+ if (isLevel(level)) {
11280
+ return `Requires level:${level} (${operationKey}). Ask an admin of this product.`;
11281
+ }
11282
+ warnDegenerate(op);
11283
+ return `Requires access to ${operationKey}. Ask an admin of this product.`;
11284
+ }
11285
+ }
11286
+ warnDegenerate(op);
11287
+ return "Not available for your role. Ask an admin of this product.";
11266
11288
  }
11267
11289
 
11268
11290
  // src/runtime/operations.ts