@nmnmcc/ability 1.0.1 → 2.0.1
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/README.md +112 -69
- package/dist/Authorizer.d.ts +43 -47
- package/dist/Authorizer.d.ts.map +1 -1
- package/dist/Authorizer.js +5 -290
- package/dist/Authorizer.js.map +1 -1
- package/dist/Condition.d.ts +164 -332
- package/dist/Condition.d.ts.map +1 -1
- package/dist/Condition.js +75 -890
- package/dist/Condition.js.map +1 -1
- package/dist/Decision.d.ts +13 -13
- package/dist/Decision.d.ts.map +1 -1
- package/dist/Decision.js.map +1 -1
- package/dist/Domain.d.ts +10 -21
- package/dist/Domain.d.ts.map +1 -1
- package/dist/Domain.js +4 -62
- package/dist/Domain.js.map +1 -1
- package/dist/HttpApi.d.ts +31 -7
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +25 -8
- package/dist/HttpApi.js.map +1 -1
- package/dist/Limits.d.ts +114 -0
- package/dist/Limits.d.ts.map +1 -0
- package/dist/Limits.js +132 -0
- package/dist/Limits.js.map +1 -0
- package/dist/Policy.d.ts +276 -269
- package/dist/Policy.d.ts.map +1 -1
- package/dist/Policy.js +73 -1177
- package/dist/Policy.js.map +1 -1
- package/dist/Resource.d.ts +4 -177
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +4 -803
- package/dist/Resource.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +4 -5
- package/dist/internal/algebra.js +267 -0
- package/dist/internal/algebra.js.map +1 -0
- package/dist/internal/analysis.js +245 -0
- package/dist/internal/analysis.js.map +1 -0
- package/dist/internal/authorizer.d.ts +30 -0
- package/dist/internal/authorizer.d.ts.map +1 -0
- package/dist/internal/authorizer.js +221 -0
- package/dist/internal/authorizer.js.map +1 -0
- package/dist/internal/bind.js +311 -0
- package/dist/internal/bind.js.map +1 -0
- package/dist/internal/catalog.d.ts +56 -0
- package/dist/internal/catalog.d.ts.map +1 -0
- package/dist/internal/catalog.js +292 -0
- package/dist/internal/catalog.js.map +1 -0
- package/dist/internal/decide.js +166 -0
- package/dist/internal/decide.js.map +1 -0
- package/dist/internal/domain.js +32 -0
- package/dist/internal/domain.js.map +1 -0
- package/dist/internal/json.js +134 -0
- package/dist/internal/json.js.map +1 -0
- package/dist/internal/limits.d.ts +14 -0
- package/dist/internal/limits.d.ts.map +1 -0
- package/dist/internal/limits.js +43 -0
- package/dist/internal/limits.js.map +1 -0
- package/dist/internal/nodes.d.ts +121 -0
- package/dist/internal/nodes.d.ts.map +1 -0
- package/dist/internal/nodes.js +277 -0
- package/dist/internal/nodes.js.map +1 -0
- package/dist/internal/patterns.js +110 -0
- package/dist/internal/patterns.js.map +1 -0
- package/dist/internal/policy-json.js +265 -0
- package/dist/internal/policy-json.js.map +1 -0
- package/dist/internal/policy-nodes.d.ts +61 -0
- package/dist/internal/policy-nodes.d.ts.map +1 -0
- package/dist/internal/policy-nodes.js +146 -0
- package/dist/internal/policy-nodes.js.map +1 -0
- package/dist/internal/policy.d.ts +42 -0
- package/dist/internal/policy.d.ts.map +1 -0
- package/dist/internal/policy.js +124 -0
- package/dist/internal/policy.js.map +1 -0
- package/dist/internal/read.js +39 -0
- package/dist/internal/read.js.map +1 -0
- package/dist/internal/resource.js +115 -0
- package/dist/internal/resource.js.map +1 -0
- package/dist/internal/rule.d.ts +26 -0
- package/dist/internal/rule.d.ts.map +1 -0
- package/dist/internal/rule.js +103 -0
- package/dist/internal/rule.js.map +1 -0
- package/dist/internal/search.d.ts +22 -0
- package/dist/internal/search.d.ts.map +1 -0
- package/dist/internal/search.js +274 -0
- package/dist/internal/search.js.map +1 -0
- package/dist/internal/suggest.js +46 -0
- package/dist/internal/suggest.js.map +1 -0
- package/package.json +3 -4
- package/src/Authorizer.ts +67 -583
- package/src/Condition.ts +339 -2095
- package/src/Decision.ts +6 -5
- package/src/Domain.ts +12 -69
- package/src/HttpApi.ts +72 -10
- package/src/Limits.ts +132 -0
- package/src/Policy.ts +391 -2772
- package/src/Resource.ts +7 -1548
- package/src/index.ts +3 -9
- package/src/internal/algebra.ts +482 -0
- package/src/internal/analysis.ts +478 -0
- package/src/internal/authorizer.ts +418 -0
- package/src/internal/bind.ts +648 -0
- package/src/internal/catalog.ts +534 -0
- package/src/internal/decide.ts +402 -0
- package/src/internal/domain.ts +66 -0
- package/src/internal/json.ts +260 -0
- package/src/internal/limits.ts +78 -0
- package/src/internal/nodes.ts +404 -0
- package/src/internal/patterns.ts +211 -0
- package/src/internal/policy-json.ts +487 -0
- package/src/internal/policy-nodes.ts +207 -0
- package/src/internal/policy.ts +264 -0
- package/src/internal/read.ts +55 -0
- package/src/internal/resource.ts +180 -0
- package/src/internal/rule.ts +196 -0
- package/src/internal/search.ts +541 -0
- package/src/internal/suggest.ts +104 -0
- package/dist/Principal.d.ts +0 -35
- package/dist/Principal.d.ts.map +0 -1
- package/dist/Principal.js +0 -37
- package/dist/Principal.js.map +0 -1
- package/dist/Rule.d.ts +0 -275
- package/dist/Rule.d.ts.map +0 -1
- package/dist/Rule.js +0 -257
- package/dist/Rule.js.map +0 -1
- package/src/Principal.ts +0 -41
- package/src/Rule.ts +0 -683
package/dist/Resource.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Catalog } from "./internal/catalog.js";
|
|
1
2
|
import * as Schema from "effect/Schema";
|
|
2
3
|
declare namespace Resource_d_exports {
|
|
3
|
-
export { Action, Any, Class, Data, Descriptor,
|
|
4
|
+
export { Action, Any, Class, Data, Descriptor, FieldRef, Kind, Options, PathSegment, Resource, Struct, Value, make };
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* One part of a resource path. A string is a fixed part. A field reference
|
|
@@ -33,14 +34,8 @@ export interface Descriptor {
|
|
|
33
34
|
readonly kind: string;
|
|
34
35
|
readonly actions: ReadonlyArray<string>;
|
|
35
36
|
readonly path: ReadonlyArray<PathSegment> | undefined;
|
|
36
|
-
/** The
|
|
37
|
-
readonly
|
|
38
|
-
/**
|
|
39
|
-
* The paths in {@link fieldPaths} of fields that hold more than one value,
|
|
40
|
-
* such as a record, a map or an array. The parts of such a field are not
|
|
41
|
-
* in `fieldPaths`, but a rule may name them.
|
|
42
|
-
*/
|
|
43
|
-
readonly openPaths: ReadonlyArray<string>;
|
|
37
|
+
/** The catalog of the data fields of the values. */
|
|
38
|
+
readonly catalog: Catalog;
|
|
44
39
|
/**
|
|
45
40
|
* A struct Schema of the data of the values, with the `_tag` field. It is a
|
|
46
41
|
* struct also for a `Resource.Class`. The class Schema must not be read
|
|
@@ -126,150 +121,6 @@ export interface Options<Actions extends ReadonlyArray<string>, Fields extends S
|
|
|
126
121
|
*/
|
|
127
122
|
readonly path?: (fields: { readonly [K in keyof Fields & string]: FieldRef<K>; }) => ReadonlyArray<string | FieldRef<keyof Fields & string>>;
|
|
128
123
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Tests if a path names a getter of a class Schema, such as a getter of a
|
|
131
|
-
* `Schema.Class` or a `Principal.Class`, at its root or in a nested field. A
|
|
132
|
-
* condition reads such a field, and the types of a condition take it, so the
|
|
133
|
-
* check of a policy takes it too. It goes into the fields of a struct, the
|
|
134
|
-
* values of a record, the members of a union, `Schema.suspend`, and a class
|
|
135
|
-
* with an annotation or a check.
|
|
136
|
-
*
|
|
137
|
-
* @stability stable
|
|
138
|
-
* @category predicates
|
|
139
|
-
* @since 1.0.0
|
|
140
|
-
*/
|
|
141
|
-
export declare const hasGetter: (schema: unknown, path: string) => boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Tests if a Schema has a getter of a class at a path whose parts fit
|
|
144
|
-
* `parts`, as `hasGetter` does for one path. A part fits a name when `fits`
|
|
145
|
-
* says so, as a part with `*` fits many names. A part `**` stands for any
|
|
146
|
-
* number of parts, also none.
|
|
147
|
-
*
|
|
148
|
-
* @stability stable
|
|
149
|
-
* @category predicates
|
|
150
|
-
* @since 1.0.0
|
|
151
|
-
*/
|
|
152
|
-
export declare const hasMatchingGetter: (schema: unknown, parts: ReadonlyArray<string>, fits: (part: string, name: string) => boolean) => boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Gives the paths of all the fields of a Schema, with dots for nested fields.
|
|
155
|
-
* A nested struct gives its own path and the paths of its fields. Arrays are
|
|
156
|
-
* left out. It throws when a field name has a dot or is empty, because such a
|
|
157
|
-
* name would give two fields one path, or a path with an empty part.
|
|
158
|
-
*
|
|
159
|
-
* @stability stable
|
|
160
|
-
* @category getters
|
|
161
|
-
* @since 1.0.0
|
|
162
|
-
*/
|
|
163
|
-
export declare const fieldPaths: (schema: Schema.Top) => ReadonlyArray<string>;
|
|
164
|
-
/**
|
|
165
|
-
* Tests if a path names a plain scalar field of a Schema: a string, a number,
|
|
166
|
-
* a boolean, a literal, `null`, or an optional field or a union of these. Its
|
|
167
|
-
* only checks may be integer and finite checks: another check, such as
|
|
168
|
-
* `isGreaterThan(0)`, stops values that the search does not know about. On
|
|
169
|
-
* the way, each part must be a required field of a plain struct with no
|
|
170
|
-
* checks, with a name that is not a name of `Object.prototype`.
|
|
171
|
-
*
|
|
172
|
-
* `Policy.coverage` and `Condition.satisfiable` answer `All`, `None` or
|
|
173
|
-
* `Some` only when each field of the condition is such a field. Their model of
|
|
174
|
-
* the values of a field is exact for these Schemas. For other Schemas, such as
|
|
175
|
-
* classes, records, unions of structs or declarations, a value may have data
|
|
176
|
-
* that the Schema does not show, and the answer is `Unknown`.
|
|
177
|
-
*
|
|
178
|
-
* @stability stable
|
|
179
|
-
* @category predicates
|
|
180
|
-
* @since 1.0.0
|
|
181
|
-
*/
|
|
182
|
-
export declare const isPlainField: (schema: Schema.Top, path: string) => boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Tests if a path names a field of a Schema that holds a value with no named
|
|
185
|
-
* fields: a scalar, or a value such as a record or an array. It goes into
|
|
186
|
-
* records by their keys, and into recursive Schemas as far as the path goes.
|
|
187
|
-
* So it finds paths that {@link fieldPaths} does not list.
|
|
188
|
-
*
|
|
189
|
-
* @stability stable
|
|
190
|
-
* @category predicates
|
|
191
|
-
* @since 1.0.0
|
|
192
|
-
*/
|
|
193
|
-
export declare const hasPath: (schema: Schema.Top, path: string) => boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Tests if a Schema has a field whose path fits a pattern. `parts` are the
|
|
196
|
-
* parts of the pattern, split at the dots. A part `**` stands for any number
|
|
197
|
-
* of parts, also none. Another part fits a name when `fits` says so, as a
|
|
198
|
-
* part with `*` fits many names. For a record, the walk asks if the key
|
|
199
|
-
* Schema takes a key that fits the part. For a template literal key Schema,
|
|
200
|
-
* with parts that are literals and strings, the answer is exact. For another key Schema, the walk tries sample keys, so it may miss a
|
|
201
|
-
* key, and then the answer is `false`.
|
|
202
|
-
*
|
|
203
|
-
* @stability stable
|
|
204
|
-
* @category predicates
|
|
205
|
-
* @since 1.0.0
|
|
206
|
-
*/
|
|
207
|
-
export declare const hasMatchingPath: (schema: Schema.Top, parts: ReadonlyArray<string>, fits: (part: string, name: string) => boolean) => boolean;
|
|
208
|
-
/**
|
|
209
|
-
* Tests if a Schema surely has a value: each required field, at each depth,
|
|
210
|
-
* has a type that has values, with no checks other than integer and finite
|
|
211
|
-
* checks on numbers. A check such as a minimum length may stop every value,
|
|
212
|
-
* and the library can not see that, so such a Schema gives `false`. So does a
|
|
213
|
-
* required field that holds the struct itself again.
|
|
214
|
-
*
|
|
215
|
-
* @stability stable
|
|
216
|
-
* @category predicates
|
|
217
|
-
* @since 1.0.0
|
|
218
|
-
*/
|
|
219
|
-
export declare const hasValue: (schema: Schema.Top) => boolean;
|
|
220
|
-
/**
|
|
221
|
-
* Tests if a Schema has no value at all: a required field of it, at some
|
|
222
|
-
* depth, has no value, as `Schema.Never` has none. A required field that
|
|
223
|
-
* holds the struct itself again, with no way to stop, has no finite value
|
|
224
|
-
* either. Other checks, such as a minimum and a maximum that do not meet, are
|
|
225
|
-
* not seen, so a "no" does not prove that the Schema has a value.
|
|
226
|
-
*
|
|
227
|
-
* @stability stable
|
|
228
|
-
* @category predicates
|
|
229
|
-
* @since 1.0.0
|
|
230
|
-
*/
|
|
231
|
-
export declare const hasNoValue: (schema: Schema.Top) => boolean;
|
|
232
|
-
/**
|
|
233
|
-
* The values that one field of a resource may hold, as a condition sees them.
|
|
234
|
-
* A missing field and `undefined` are `null`. The domain may be larger than
|
|
235
|
-
* the real set of values: Schema checks other than finite and integer checks
|
|
236
|
-
* are left out. A larger domain only makes a check say "no" more often.
|
|
237
|
-
*
|
|
238
|
-
* @stability stable
|
|
239
|
-
* @category models
|
|
240
|
-
* @since 1.0.0
|
|
241
|
-
*/
|
|
242
|
-
export interface FieldDomain {
|
|
243
|
-
/** The field may be `null` or missing. */
|
|
244
|
-
readonly null: boolean;
|
|
245
|
-
/** The field may hold a value with parts, or a value that is not a scalar. */
|
|
246
|
-
readonly object: boolean;
|
|
247
|
-
/** The field may hold `true` and `false`. */
|
|
248
|
-
readonly boolean: boolean;
|
|
249
|
-
/** The field may hold any string. */
|
|
250
|
-
readonly string: boolean;
|
|
251
|
-
/** The numbers that the field may hold. */
|
|
252
|
-
readonly number: "none" | "integer" | "finite" | "any";
|
|
253
|
-
/** Single values that the field may hold, other than the ones above. */
|
|
254
|
-
readonly literals: ReadonlyArray<string | number | boolean>;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* The domain of a field with no Schema: any value.
|
|
258
|
-
*
|
|
259
|
-
* @stability stable
|
|
260
|
-
* @category constants
|
|
261
|
-
* @since 1.0.0
|
|
262
|
-
*/
|
|
263
|
-
export declare const anyDomain: FieldDomain;
|
|
264
|
-
/**
|
|
265
|
-
* Gives the domain of a field of a Schema, by its path with dots. A path that
|
|
266
|
-
* the Schema does not name gives `null`, as a condition reads such a field.
|
|
267
|
-
*
|
|
268
|
-
* @stability stable
|
|
269
|
-
* @category getters
|
|
270
|
-
* @since 1.0.0
|
|
271
|
-
*/
|
|
272
|
-
export declare const domainOf: (schema: Schema.Top, path: string) => FieldDomain;
|
|
273
124
|
/**
|
|
274
125
|
* The type of a class made by {@link Class}.
|
|
275
126
|
*
|
|
@@ -336,29 +187,5 @@ export interface Struct<Kind extends string, Actions extends ReadonlyArray<strin
|
|
|
336
187
|
* @since 0.3.0
|
|
337
188
|
*/
|
|
338
189
|
export declare const make: <const Kind extends string, const Actions extends ReadonlyArray<string>, const Fields extends Schema.Struct.Fields>(kind: Kind, options: Options<Actions, Fields>) => Struct<Kind, Actions, Fields>;
|
|
339
|
-
/**
|
|
340
|
-
* Tests if a value is a resource.
|
|
341
|
-
*
|
|
342
|
-
* @stability stable
|
|
343
|
-
* @category guards
|
|
344
|
-
* @since 0.3.0
|
|
345
|
-
*/
|
|
346
|
-
export declare const isResource: (u: unknown) => u is Any;
|
|
347
|
-
/**
|
|
348
|
-
* Gets the runtime data of a resource.
|
|
349
|
-
*
|
|
350
|
-
* @stability stable
|
|
351
|
-
* @category getters
|
|
352
|
-
* @since 0.3.0
|
|
353
|
-
*/
|
|
354
|
-
export declare const descriptor: (resource: Any) => Descriptor;
|
|
355
|
-
/**
|
|
356
|
-
* Gives the kind name of a resource value, from its `_tag` field.
|
|
357
|
-
*
|
|
358
|
-
* @stability stable
|
|
359
|
-
* @category getters
|
|
360
|
-
* @since 1.0.0
|
|
361
|
-
*/
|
|
362
|
-
export declare const kindOf: (value: unknown) => string | undefined;
|
|
363
190
|
export { Resource_d_exports };
|
|
364
191
|
//# sourceMappingURL=Resource.d.ts.map
|
package/dist/Resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.d.ts","names":[],"sources":["../src/Resource.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Resource.d.ts","names":["Catalog.Catalog"],"sources":["../src/Resource.ts"],"mappings":";;;;;;;;;;;;;YAmCY,uBAAuB;;;;;;;;iBASlB,SAAS;WAChB;WACA,OAAO;;;;;;;;;iBAUA;WACP;WACA,SAAS;WACT,MAAM,cAAc;;WAEpB,SAASA;;;;;;;WAOT,QAAQ,O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