@lessly/sdk-app 62.0.0 → 62.1.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/_types/index.d.ts +1 -0
- package/dist/_types/runtime/access-reason.d.ts +20 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/docs/recipes/access.md +456 -15
- package/docs/rules.md +92 -0
- package/package.json +1 -1
package/dist/_types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { createLesslyApp } from './runtime/createLesslyApp.js';
|
|
|
2
2
|
export type { LesslyClientBase } from './runtime/createLesslyApp.js';
|
|
3
3
|
export { connectStream } from './runtime/connectStream.js';
|
|
4
4
|
export { LesslyApiError, isAccessDenied } from './runtime/errors.js';
|
|
5
|
+
export { accessReason } from './runtime/access-reason.js';
|
|
5
6
|
export type { LesslyAppOptions, HttpMethod, Binding, BindingsMap, ParamSpec, ParamIn, ToolLevel, Operation, } from './runtime/types.js';
|
|
6
7
|
export type { WsBinding, WsBindingsMap, LesslyStream, LesslyStreamOpener, StreamCloseInfo, StreamData, WebSocketCtor, WebSocketLike, } from './runtime/types.js';
|
|
7
8
|
export type { Access, AccessState, AccessApi } from './runtime/access.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Operation } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one reason string every App shows on a gated control (APP-012).
|
|
4
|
+
*
|
|
5
|
+
* Both values come from the generated method, so the sentence cannot drift when the catalog
|
|
6
|
+
* re-levels a tool. It names the operation key as well as the level because a level alone does not
|
|
7
|
+
* identify a grant — a screenful of controls can all require `write` — and an admin grants by
|
|
8
|
+
* level AND by exact key, so the user has to be able to pass on both.
|
|
9
|
+
*
|
|
10
|
+
* It explains ONE operation. Picking which one — the first that `can()` denied, among the several
|
|
11
|
+
* a button performs — is the caller's job: the rule differs between a button that runs every
|
|
12
|
+
* operation and one that dispatches to a single one, so this takes no array.
|
|
13
|
+
*
|
|
14
|
+
* A bare key is the fallback for a control with no generated method to point at (a runtime probe,
|
|
15
|
+
* an operation no method covers). It drops the level rather than inventing one: there is nothing
|
|
16
|
+
* to read it from, and `level:undefined` in front of a user is worse than saying less. It is a
|
|
17
|
+
* DEGRADATION, not an equal input — an App whose every gate holds an `Operation` never reaches for
|
|
18
|
+
* it, and that is the normal shape, not an omission.
|
|
19
|
+
*/
|
|
20
|
+
export declare function accessReason(op: Operation | string): string;
|
package/dist/index.cjs
CHANGED
|
@@ -11402,7 +11402,13 @@ function createLesslyApp(opts) {
|
|
|
11402
11402
|
});
|
|
11403
11403
|
}
|
|
11404
11404
|
|
|
11405
|
+
// src/runtime/access-reason.ts
|
|
11406
|
+
function accessReason(op) {
|
|
11407
|
+
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.`;
|
|
11408
|
+
}
|
|
11409
|
+
|
|
11405
11410
|
exports.LesslyApiError = LesslyApiError;
|
|
11411
|
+
exports.accessReason = accessReason;
|
|
11406
11412
|
exports.connectStream = connectStream;
|
|
11407
11413
|
exports.createLesslyApp = createLesslyApp;
|
|
11408
11414
|
exports.isAccessDenied = isAccessDenied;
|