@zap-studio/permit 0.3.1 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
+ ## @zap-studio/permit@0.3.3
2
+
3
+ ### Migrate to ultracite lint/format
4
+
5
+ Internal formatting and lint cleanup only. No public API or behavior change.
6
+
1
7
  # @zap-studio/permit
2
8
 
9
+ ## 0.3.2
10
+
11
+ ### Dependencies
12
+
13
+ - Updated dependency `@zap-studio/validation` to `0.3.4`.
14
+
3
15
  ## 0.3.1
4
16
 
5
17
  ### Fixed
@@ -23,11 +35,9 @@
23
35
 
24
36
  - fe60f55: Change `policy.can()` to use a single permission string plus the resource object.
25
37
 
26
- `policy.can(ctx, "read", "post", post)` is replaced by
27
- `policy.can(ctx, "post:read", post)`.
38
+ `policy.can(ctx, "read", "post", post)` is replaced by `policy.can(ctx, "post:read", post)`.
28
39
 
29
- This is a breaking API change in the `0.x` line. Docs and examples now use the
30
- new permission-string format consistently.
40
+ This is a breaking API change in the `0.x` line. Docs and examples now use the new permission-string format consistently.
31
41
 
32
42
  ## 0.2.2
33
43
 
package/README.md CHANGED
@@ -126,7 +126,7 @@ Returns a condition that is true only if all conditions are true.
126
126
  ```ts
127
127
  const isOwnerAndPublished = and(
128
128
  (ctx, action, resource) => ctx.user.id === resource.authorId,
129
- (ctx, action, resource) => resource.status === "published",
129
+ (ctx, action, resource) => resource.status === "published"
130
130
  );
131
131
  ```
132
132
 
@@ -137,7 +137,7 @@ Returns a condition that is true if any condition is true.
137
137
  ```ts
138
138
  const isOwnerOrAdmin = or(
139
139
  (ctx, action, resource) => ctx.user.id === resource.authorId,
140
- (ctx, action, resource) => ctx.user.role === "admin",
140
+ (ctx, action, resource) => ctx.user.role === "admin"
141
141
  );
142
142
  ```
143
143
 
@@ -146,7 +146,9 @@ const isOwnerOrAdmin = or(
146
146
  Returns a condition that negates another condition.
147
147
 
148
148
  ```ts
149
- const isNotOwner = not((ctx, action, resource) => ctx.user.id === resource.authorId);
149
+ const isNotOwner = not(
150
+ (ctx, action, resource) => ctx.user.id === resource.authorId
151
+ );
150
152
  ```
151
153
 
152
154
  ### Context Helpers
package/dist/errors.d.mts CHANGED
@@ -1,9 +1,19 @@
1
1
  //#region src/errors.d.ts
2
2
  /**
3
- * Represents an error that occurs during policy evaluation or enforcement.
4
- * Use this error to indicate issues related to policy logic, configuration, or execution.
5
- */
3
+ * Error primitives for policy evaluation and configuration failures.
4
+ *
5
+ * @module @zap-studio/permit/errors
6
+ */
7
+ /**
8
+ * Represents an error that occurs during policy evaluation or enforcement.
9
+ * Use this error to indicate issues related to policy logic, configuration, or execution.
10
+ */
6
11
  declare class PolicyError extends Error {
12
+ /**
13
+ * Creates a policy error with a human-readable message.
14
+ *
15
+ * @param message - Error message describing the policy failure.
16
+ */
7
17
  constructor(message: string);
8
18
  }
9
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;AAIA;;;cAAa,WAAA,SAAoB,KAAA;EAC/B,WAAA,CAAY,OAAA;AAAA"}
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;cAUa,oBAAoB;;;;;;EAM/B,YAAY"}
package/dist/errors.mjs CHANGED
@@ -1,9 +1,19 @@
1
1
  //#region src/errors.ts
2
2
  /**
3
+ * Error primitives for policy evaluation and configuration failures.
4
+ *
5
+ * @module @zap-studio/permit/errors
6
+ */
7
+ /**
3
8
  * Represents an error that occurs during policy evaluation or enforcement.
4
9
  * Use this error to indicate issues related to policy logic, configuration, or execution.
5
10
  */
6
11
  var PolicyError = class extends Error {
12
+ /**
13
+ * Creates a policy error with a human-readable message.
14
+ *
15
+ * @param message - Error message describing the policy failure.
16
+ */
7
17
  constructor(message) {
8
18
  super(message);
9
19
  this.name = "PolicyError";
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Represents an error that occurs during policy evaluation or enforcement.\n * Use this error to indicate issues related to policy logic, configuration, or execution.\n */\nexport class PolicyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PolicyError\";\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Error primitives for policy evaluation and configuration failures.\n *\n * @module @zap-studio/permit/errors\n */\n\n/**\n * Represents an error that occurs during policy evaluation or enforcement.\n * Use this error to indicate issues related to policy logic, configuration, or execution.\n */\nexport class PolicyError extends Error {\n /**\n * Creates a policy error with a human-readable message.\n *\n * @param message - Error message describing the policy failure.\n */\n constructor(message: string) {\n super(message);\n this.name = \"PolicyError\";\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,cAAb,cAAiC,MAAM;;;;;;CAMrC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
@@ -1,27 +1,32 @@
1
1
  //#region src/helpers.d.ts
2
2
  /**
3
- * Ensures that a value of type `never` is actually never encountered at runtime.
4
- * This is useful for exhaustive checks on discriminated unions.
5
- *
6
- * @example
7
- * ```ts
8
- * type Action = 'read' | 'write'
9
- *
10
- * function performAction(action: Action) {
11
- * switch (action) {
12
- * case 'read':
13
- * console.log('Reading...')
14
- * break
15
- * case 'write':
16
- * console.log('Writing...')
17
- * break
18
- * default:
19
- * assertNever(action) // TypeScript will error if a new Action is added but not handled
20
- * }
21
- * }
22
- * ```
23
- */
24
- declare function assertNever(value: never): never;
3
+ * Helper utilities for permit consumers.
4
+ *
5
+ * @module @zap-studio/permit/helpers
6
+ */
7
+ /**
8
+ * Ensures that a value of type `never` is actually never encountered at runtime.
9
+ * This is useful for exhaustive checks on discriminated unions.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * type Action = 'read' | 'write'
14
+ *
15
+ * function performAction(action: Action) {
16
+ * switch (action) {
17
+ * case 'read':
18
+ * console.log('Reading...')
19
+ * break
20
+ * case 'write':
21
+ * console.log('Writing...')
22
+ * break
23
+ * default:
24
+ * assertNever(action) // TypeScript will error if a new Action is added but not handled
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ declare const assertNever: (value: never) => never;
25
30
  //#endregion
26
31
  export { assertNever };
27
32
  //# sourceMappingURL=helpers.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/helpers.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;;;;;iBAAgB,WAAA,CAAY,KAAA"}
1
+ {"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/helpers.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4Ba,cAAe"}
package/dist/helpers.mjs CHANGED
@@ -1,5 +1,10 @@
1
1
  //#region src/helpers.ts
2
2
  /**
3
+ * Helper utilities for permit consumers.
4
+ *
5
+ * @module @zap-studio/permit/helpers
6
+ */
7
+ /**
3
8
  * Ensures that a value of type `never` is actually never encountered at runtime.
4
9
  * This is useful for exhaustive checks on discriminated unions.
5
10
  *
@@ -21,9 +26,9 @@
21
26
  * }
22
27
  * ```
23
28
  */
24
- function assertNever(value) {
29
+ const assertNever = (value) => {
25
30
  throw new Error(`Unexpected value: ${String(value)}`);
26
- }
31
+ };
27
32
  //#endregion
28
33
  export { assertNever };
29
34
 
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Ensures that a value of type `never` is actually never encountered at runtime.\n * This is useful for exhaustive checks on discriminated unions.\n *\n * @example\n * ```ts\n * type Action = 'read' | 'write'\n *\n * function performAction(action: Action) {\n * switch (action) {\n * case 'read':\n * console.log('Reading...')\n * break\n * case 'write':\n * console.log('Writing...')\n * break\n * default:\n * assertNever(action) // TypeScript will error if a new Action is added but not handled\n * }\n * }\n * ```\n */\nexport function assertNever(value: never): never {\n throw new Error(`Unexpected value: ${String(value)}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,YAAY,OAAqB;AAC/C,OAAM,IAAI,MAAM,qBAAqB,OAAO,MAAM,GAAG"}
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Helper utilities for permit consumers.\n *\n * @module @zap-studio/permit/helpers\n */\n\n/**\n * Ensures that a value of type `never` is actually never encountered at runtime.\n * This is useful for exhaustive checks on discriminated unions.\n *\n * @example\n * ```ts\n * type Action = 'read' | 'write'\n *\n * function performAction(action: Action) {\n * switch (action) {\n * case 'read':\n * console.log('Reading...')\n * break\n * case 'write':\n * console.log('Writing...')\n * break\n * default:\n * assertNever(action) // TypeScript will error if a new Action is added but not handled\n * }\n * }\n * ```\n */\nexport const assertNever = (value: never): never => {\n throw new Error(`Unexpected value: ${String(value)}`);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,eAAe,UAAwB;CAClD,MAAM,IAAI,MAAM,qBAAqB,OAAO,KAAK,GAAG;AACtD"}