@nmnmcc/ability 0.3.0 → 1.0.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.
Files changed (63) hide show
  1. package/README.md +169 -14
  2. package/dist/Authorizer.d.ts +64 -39
  3. package/dist/Authorizer.d.ts.map +1 -1
  4. package/dist/Authorizer.js +291 -6
  5. package/dist/Authorizer.js.map +1 -1
  6. package/dist/Condition.d.ts +444 -65
  7. package/dist/Condition.d.ts.map +1 -1
  8. package/dist/Condition.js +1007 -25
  9. package/dist/Condition.js.map +1 -1
  10. package/dist/Domain.d.ts +27 -17
  11. package/dist/Domain.d.ts.map +1 -1
  12. package/dist/Domain.js +52 -10
  13. package/dist/Domain.js.map +1 -1
  14. package/dist/HttpApi.d.ts +84 -40
  15. package/dist/HttpApi.d.ts.map +1 -1
  16. package/dist/HttpApi.js +101 -11
  17. package/dist/HttpApi.js.map +1 -1
  18. package/dist/Policy.d.ts +311 -53
  19. package/dist/Policy.d.ts.map +1 -1
  20. package/dist/Policy.js +1212 -35
  21. package/dist/Policy.js.map +1 -1
  22. package/dist/Resource.d.ts +167 -16
  23. package/dist/Resource.d.ts.map +1 -1
  24. package/dist/Resource.js +784 -11
  25. package/dist/Resource.js.map +1 -1
  26. package/dist/Rule.d.ts +113 -27
  27. package/dist/Rule.d.ts.map +1 -1
  28. package/dist/Rule.js +217 -10
  29. package/dist/Rule.js.map +1 -1
  30. package/dist/index.js +4 -4
  31. package/package.json +1 -1
  32. package/src/Authorizer.ts +623 -59
  33. package/src/Condition.ts +2403 -112
  34. package/src/Domain.ts +79 -22
  35. package/src/HttpApi.ts +223 -23
  36. package/src/Policy.ts +2833 -93
  37. package/src/Resource.ts +1537 -22
  38. package/src/Rule.ts +461 -43
  39. package/dist/internal/authorizer.d.ts +0 -28
  40. package/dist/internal/authorizer.d.ts.map +0 -1
  41. package/dist/internal/authorizer.js +0 -153
  42. package/dist/internal/authorizer.js.map +0 -1
  43. package/dist/internal/condition.d.ts +0 -11
  44. package/dist/internal/condition.d.ts.map +0 -1
  45. package/dist/internal/condition.js +0 -393
  46. package/dist/internal/condition.js.map +0 -1
  47. package/dist/internal/domain.js +0 -34
  48. package/dist/internal/domain.js.map +0 -1
  49. package/dist/internal/httpApi.js +0 -41
  50. package/dist/internal/httpApi.js.map +0 -1
  51. package/dist/internal/policy.js +0 -524
  52. package/dist/internal/policy.js.map +0 -1
  53. package/dist/internal/resource.js +0 -66
  54. package/dist/internal/resource.js.map +0 -1
  55. package/dist/internal/rule.js +0 -131
  56. package/dist/internal/rule.js.map +0 -1
  57. package/src/internal/authorizer.ts +0 -271
  58. package/src/internal/condition.ts +0 -607
  59. package/src/internal/domain.ts +0 -56
  60. package/src/internal/httpApi.ts +0 -84
  61. package/src/internal/policy.ts +0 -815
  62. package/src/internal/resource.ts +0 -98
  63. package/src/internal/rule.ts +0 -203
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.js","names":["internal.TypeId","internal.Class","internal.make","internal.isResource","internal.descriptor"],"sources":["../src/Resource.ts"],"sourcesContent":["/**\n * A resource is a kind of thing that a person may act on, such as a Bot or a\n * document. Each resource has a kind name, a list of actions, a Schema for its\n * data, and an optional path.\n *\n * Make a resource in one of two ways:\n * - {@link Class} makes a Schema class, in the same way as\n * `Schema.TaggedClass`. The class is a Schema, a constructor, and a resource\n * at the same time.\n * - {@link make} makes a resource from plain fields. Its values are plain\n * objects with a `_tag` field.\n *\n * Every value of a resource has a `_tag` field with the kind name. The library\n * uses this field to find the resource of a value. It does not guess from the\n * constructor name.\n *\n * A path puts a resource inside a tree, such as\n * `[\"org\", organizationId, \"user\", ownerUserId, \"bot\", id]`. A condition can\n * then ask if a value is under a part of the tree. See `Condition.under`.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport * as Schema from \"effect/Schema\"\nimport * as internal from \"./internal/resource.ts\"\n\n/**\n * @stability stable\n * @category type IDs\n * @since 0.3.0\n */\nexport const TypeId: \"~@nmnmcc/ability/Resource\" = internal.TypeId\n\n/**\n * @stability stable\n * @category type IDs\n * @since 0.3.0\n */\nexport type TypeId = typeof TypeId\n\n/**\n * One part of a resource path. A string is a fixed part. A field reference\n * takes the part from a field of the value.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type PathSegment = string | FieldRef<string>\n\n/**\n * A reference to a top-level field of a resource, used in a path.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface FieldRef<Name extends string> {\n\treadonly _tag: \"Field\"\n\treadonly field: Name\n}\n\n/**\n * The runtime data of a resource.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Descriptor {\n\treadonly kind: string\n\treadonly actions: ReadonlyArray<string>\n\treadonly path: ReadonlyArray<PathSegment> | undefined\n\t/** The paths of the data fields, with dots for nested fields. */\n\treadonly fieldPaths: ReadonlyArray<string>\n\t/** The Schema of the values, with the `_tag` field. */\n\treadonly schema: Schema.Top\n}\n\n/**\n * A resource. `Kind` is its name, `Action` is the union of its actions, `Data`\n * is the type of its Schema fields, and `Value` is the type of its values.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Resource<\n\tKind extends string,\n\tAction extends string,\n\tData extends object,\n\tValue extends { readonly _tag: Kind },\n> {\n\treadonly [TypeId]: Descriptor\n\treadonly \"~Resource\"?: {\n\t\treadonly Kind: Kind\n\t\treadonly Action: Action\n\t\treadonly Data: Data\n\t\treadonly Value: Value\n\t}\n}\n\n/**\n * Any resource.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Any = Resource<string, string, object, { readonly _tag: string }>\n\n/**\n * The kind name of a resource.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Kind<R> = R extends Resource<infer K, any, any, any> ? K : never\n\n/**\n * The actions of a resource.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Action<R> = R extends Resource<any, infer A, any, any> ? A : never\n\n/**\n * The type of the Schema fields of a resource, without `_tag`.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Data<R> = R extends Resource<any, any, infer D, any> ? D : never\n\n/**\n * The type of the values of a resource.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Value<R> = R extends Resource<any, any, any, infer V> ? V : never\n\n/**\n * The options of a resource.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Options<\n\tActions extends ReadonlyArray<string>,\n\tFields extends Schema.Struct.Fields,\n> {\n\treadonly actions: Actions\n\treadonly fields: Fields\n\t/**\n\t * Gives the path of the resource. The function gets one reference for each\n\t * top-level field.\n\t */\n\treadonly path?: (fields: {\n\t\treadonly [K in keyof Fields & string]: FieldRef<K>\n\t}) => ReadonlyArray<PathSegment>\n}\n\n/**\n * The type of a class made by {@link Class}.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Class<\n\tSelf,\n\tKind extends string,\n\tActions extends ReadonlyArray<string>,\n\tFields extends Schema.Struct.Fields,\n> = Schema.Class<Self, Schema.TaggedStruct<Kind, Fields>, {}> &\n\tResource<\n\t\tKind,\n\t\tActions[number],\n\t\tSchema.Struct.Type<Fields>,\n\t\tSelf & { readonly _tag: Kind }\n\t> & {\n\t\treadonly kind: Kind\n\t\treadonly actions: Actions\n\t}\n\n/**\n * Makes a resource as a Schema class. Use it in the same way as\n * `Schema.TaggedClass`.\n *\n * @example\n * ```ts\n * import { Schema } from \"effect\"\n * import { Resource } from \"@nmnmcc/ability\"\n *\n * class Bot extends Resource.Class<Bot>()(\"Bot\", {\n * actions: [\"read\", \"update\"],\n * fields: {\n * id: Schema.String,\n * ownerUserId: Schema.NullOr(Schema.String),\n * },\n * path: (f) => [\"user\", f.ownerUserId, \"bot\", f.id],\n * }) {}\n *\n * const bot = new Bot({ id: \"b1\", ownerUserId: \"u1\" })\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const Class: <Self = never>(\n\tidentifier?: string,\n) => <\n\tconst Kind extends string,\n\tconst Actions extends ReadonlyArray<string>,\n\tconst Fields extends Schema.Struct.Fields,\n>(\n\tkind: Kind,\n\toptions: Options<Actions, Fields>,\n) => [Self] extends [never]\n\t? \"Missing `Self` type: use Resource.Class<Self>()(...)\"\n\t: Class<Self, Kind, Actions, Fields> = internal.Class as never\n\n/**\n * A resource made by {@link make}. Its values are plain objects.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Struct<\n\tKind extends string,\n\tActions extends ReadonlyArray<string>,\n\tFields extends Schema.Struct.Fields,\n> extends Resource<\n\tKind,\n\tActions[number],\n\tSchema.Struct.Type<Fields>,\n\tSchema.Struct.Type<Fields> & { readonly _tag: Kind }\n> {\n\treadonly kind: Kind\n\treadonly actions: Actions\n\treadonly schema: Schema.TaggedStruct<Kind, Fields>\n\t/** Makes a value. It puts the `_tag` field on the value for you. */\n\treadonly make: (\n\t\tinput: Schema.Struct.Type<Fields>,\n\t) => Schema.Struct.Type<Fields> & { readonly _tag: Kind }\n}\n\n/**\n * Makes a resource from plain fields. Its values are plain objects with a\n * `_tag` field.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const make: <\n\tconst Kind extends string,\n\tconst Actions extends ReadonlyArray<string>,\n\tconst Fields extends Schema.Struct.Fields,\n>(\n\tkind: Kind,\n\toptions: Options<Actions, Fields>,\n) => Struct<Kind, Actions, Fields> = internal.make as never\n\n/**\n * Tests if a value is a resource.\n *\n * @stability stable\n * @category guards\n * @since 0.3.0\n */\nexport const isResource: (u: unknown) => u is Any = internal.isResource\n\n/**\n * Gets the runtime data of a resource.\n *\n * @stability stable\n * @category getters\n * @since 0.3.0\n */\nexport const descriptor: (resource: Any) => Descriptor = internal.descriptor\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAa,SAAsCA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0LnD,MAAa,QAW2BC;;;;;;;;;AAoCxC,MAAa,OAOwBC;;;;;;;;AASrC,MAAa,aAAuCC;;;;;;;;AASpD,MAAa,aAA4CC"}
1
+ {"version":3,"file":"Resource.js","names":["DataClass"],"sources":["../src/Resource.ts"],"sourcesContent":["/**\n * A resource is a kind of thing that a person may act on, such as a Bot or a\n * document. Each resource has a kind name, a list of actions, a Schema for its\n * data, and an optional path.\n *\n * Make a resource in one of two ways:\n * - {@link Class} makes a Schema class, in the same way as\n * `Schema.TaggedClass`. The class is a Schema, a constructor, and a resource\n * at the same time.\n * - {@link make} makes a resource from plain fields. Its values are plain\n * objects with a `_tag` field.\n *\n * Every value of a resource has a `_tag` field with the kind name. The library\n * uses this field to find the resource of a value. It does not guess from the\n * constructor name.\n *\n * A path puts a resource inside a tree, such as\n * `[\"org\", organizationId, \"user\", ownerUserId, \"bot\", id]`. A condition can\n * then ask if a value is under a part of the tree. See `Condition.under`.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport * as Arr from \"effect/Array\"\nimport { Class as DataClass } from \"effect/Data\"\nimport * as HashMap from \"effect/HashMap\"\nimport * as HashSet from \"effect/HashSet\"\nimport * as Option from \"effect/Option\"\nimport { hasProperty, isObject } from \"effect/Predicate\"\nimport * as Schema from \"effect/Schema\"\nimport * as SchemaAST from \"effect/SchemaAST\"\n\n/**\n * One part of a resource path. A string is a fixed part. A field reference\n * takes the part from a field of the value.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type PathSegment = string | FieldRef<string>\n\n/**\n * A reference to a top-level field of a resource, used in a path.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface FieldRef<Name extends string> {\n\treadonly _tag: \"Field\"\n\treadonly field: Name\n}\n\n/**\n * The runtime data of a resource.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Descriptor {\n\treadonly kind: string\n\treadonly actions: ReadonlyArray<string>\n\treadonly path: ReadonlyArray<PathSegment> | undefined\n\t/** The paths of the data fields, with dots for nested fields. */\n\treadonly fieldPaths: ReadonlyArray<string>\n\t/**\n\t * The paths in {@link fieldPaths} of fields that hold more than one value,\n\t * such as a record, a map or an array. The parts of such a field are not\n\t * in `fieldPaths`, but a rule may name them.\n\t */\n\treadonly openPaths: ReadonlyArray<string>\n\t/**\n\t * A struct Schema of the data of the values, with the `_tag` field. It is a\n\t * struct also for a `Resource.Class`. The class Schema must not be read\n\t * before the class is made, because Effect then binds the class Schema to\n\t * the base class, and the values lose the getters of the class.\n\t */\n\treadonly schema: Schema.Top\n}\n\n/**\n * A resource. `Kind` is its name, `Action` is the union of its actions, `Data`\n * is the type of its Schema fields, and `Value` is the type of its values.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Resource<\n\tKind extends string,\n\tAction extends string,\n\tData extends object,\n\tValue extends { readonly _tag: Kind },\n> {\n\treadonly descriptor: Descriptor\n\treadonly \"~Resource\"?: {\n\t\treadonly Kind: Kind\n\t\treadonly Action: Action\n\t\treadonly Data: Data\n\t\treadonly Value: Value\n\t}\n}\n\n/**\n * Any resource.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Any = Resource<string, string, object, { readonly _tag: string }>\n\n/**\n * The kind name of a resource.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Kind<R> = R extends Resource<infer K, any, any, any> ? K : never\n\n/**\n * The actions of a resource.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Action<R> = R extends Resource<any, infer A, any, any> ? A : never\n\n/**\n * The type of the Schema fields of a resource, without `_tag`.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Data<R> = R extends Resource<any, any, infer D, any> ? D : never\n\n/**\n * The type of the values of a resource.\n *\n * @stability stable\n * @category utility types\n * @since 0.3.0\n */\nexport type Value<R> = R extends Resource<any, any, any, infer V> ? V : never\n\n/**\n * The options of a resource.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Options<\n\tActions extends ReadonlyArray<string>,\n\tFields extends Schema.Struct.Fields,\n> {\n\treadonly actions: Actions\n\treadonly fields: Fields\n\t/**\n\t * Gives the path of the resource. The function gets one reference for each\n\t * top-level field.\n\t */\n\treadonly path?: (fields: {\n\t\treadonly [K in keyof Fields & string]: FieldRef<K>\n\t}) => ReadonlyArray<string | FieldRef<keyof Fields & string>>\n}\n\n/**\n * The class of the runtime data of a resource. {@link isResource} uses it to\n * know a resource.\n */\nclass ResourceDescriptor extends DataClass<Descriptor> {}\n\n/** The prototypes from `prototype` up, below `Object.prototype`. */\nconst prototypesFrom = (prototype: unknown): ReadonlyArray<object> =>\n\tArr.unfold(prototype, (current) =>\n\t\ttypeof current === \"object\" &&\n\t\tcurrent !== null &&\n\t\tcurrent !== Object.prototype\n\t\t\t? Option.some([current, Object.getPrototypeOf(current)] as const)\n\t\t\t: Option.none(),\n\t)\n\n/**\n * Gives the prototype of the class of a class node, or `undefined`. The node\n * does not keep the class: a class Schema with an annotation or a check, or\n * one inside `Schema.suspend`, is a new Schema with the same node. So the\n * walk asks the node to make a value with no check, and reads its prototype.\n *\n * This uses the `\"~constructor\"` annotation of Effect, which is not a public\n * API: it gives a link whose decode makes a value of the class from its\n * fields without a check. When that is not so, the walk gives `undefined`,\n * and the check of a policy says no to the getter.\n */\nconst classPrototype = (ast: SchemaAST.Declaration): object | undefined => {\n\tconst make: unknown = ast.annotations?.[\"~constructor\"]\n\tif (typeof make !== \"function\") {\n\t\treturn undefined\n\t}\n\ttry {\n\t\tconst made: unknown = make(ast.typeParameters)\n\t\tconst decode: unknown =\n\t\t\thasProperty(made, \"link\") &&\n\t\t\thasProperty(made.link, \"transformation\") &&\n\t\t\thasProperty(made.link.transformation, \"decode\")\n\t\t\t\t? made.link.transformation.decode\n\t\t\t\t: undefined\n\t\tconst value: unknown =\n\t\t\thasProperty(decode, \"transform\") && typeof decode.transform === \"function\"\n\t\t\t\t? decode.transform({})\n\t\t\t\t: undefined\n\t\treturn isObject(value) ? Object.getPrototypeOf(value) : undefined\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Tests if a path names a getter of a class Schema, such as a getter of a\n * `Schema.Class` or a `Principal.Class`, at its root or in a nested field. A\n * condition reads such a field, and the types of a condition take it, so the\n * check of a policy takes it too. It goes into the fields of a struct, the\n * values of a record, the members of a union, `Schema.suspend`, and a class\n * with an annotation or a check.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const hasGetter = (schema: unknown, path: string): boolean =>\n\t!isTooLong(path) &&\n\tSchema.isSchema(schema) &&\n\tgetterAt(\n\t\tschema.ast,\n\t\tpath.split(\".\"),\n\t\t0,\n\t\t(part, name) => part === name,\n\t\tnew Map(),\n\t)\n\n/**\n * The most parts that a field path may have. The walks below call themselves\n * for each part, and a path comes from the input of a policy. So a very long\n * path, as in a recursive Schema, could fill the stack.\n */\nconst maxPathParts = 256\n\n/** Tests if a field path has more than {@link maxPathParts} parts. */\nconst isTooLong = (path: string): boolean =>\n\tpath.split(\".\", maxPathParts + 1).length > maxPathParts\n\n/**\n * Tests if a Schema has a getter of a class at a path whose parts fit\n * `parts`, as `hasGetter` does for one path. A part fits a name when `fits`\n * says so, as a part with `*` fits many names. A part `**` stands for any\n * number of parts, also none.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const hasMatchingGetter = (\n\tschema: unknown,\n\tparts: ReadonlyArray<string>,\n\tfits: (part: string, name: string) => boolean,\n): boolean =>\n\tparts.length <= maxPathParts &&\n\tSchema.isSchema(schema) &&\n\tgetterAt(schema.ast, parts, 0, fits, new Map())\n\n/** The names of the getters of a prototype and the prototypes above it. */\nconst getterNames = (prototype: object | undefined): ReadonlyArray<string> =>\n\tArr.flatMap(prototypesFrom(prototype), (current) =>\n\t\tArr.filter(\n\t\t\tObject.getOwnPropertyNames(current),\n\t\t\t(name) =>\n\t\t\t\tObject.getOwnPropertyDescriptor(current, name)?.get !== undefined,\n\t\t),\n\t)\n\nconst getterAt = (\n\tast: SchemaAST.AST,\n\tnames: ReadonlyArray<string>,\n\tindex: number,\n\tfits: (part: string, name: string) => boolean,\n\tmemo: PathMemo<boolean>,\n): boolean =>\n\trememberAt(memo, ast, index, false, () => {\n\t\tconst name = names[index]\n\t\tif (name === undefined) {\n\t\t\treturn false\n\t\t}\n\t\tconst last = index === names.length - 1\n\t\tconst next = (type: SchemaAST.AST, at: number) =>\n\t\t\tgetterAt(type, names, at, fits, memo)\n\t\t// A `**` may stand for no parts.\n\t\tif (name === \"**\" && !last && next(ast, index + 1)) {\n\t\t\treturn true\n\t\t}\n\t\tswitch (ast._tag) {\n\t\t\tcase \"Union\":\n\t\t\t\treturn Arr.some(ast.types, (type) => next(type, index))\n\t\t\tcase \"Suspend\":\n\t\t\t\treturn next(ast.thunk(), index)\n\t\t\tcase \"Declaration\": {\n\t\t\t\tconst inner = classStruct(ast)\n\t\t\t\tif (inner === undefined) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\t// A path ends at a getter. The library can not see the type of\n\t\t\t\t// the value of a getter, so it can not check a path that goes\n\t\t\t\t// past it.\n\t\t\t\treturn last\n\t\t\t\t\t? Arr.some(getterNames(classPrototype(ast)), (getter) =>\n\t\t\t\t\t\t\tfits(name, getter),\n\t\t\t\t\t\t)\n\t\t\t\t\t: next(inner, index)\n\t\t\t}\n\t\t\tcase \"Objects\":\n\t\t\t\treturn (\n\t\t\t\t\t!last &&\n\t\t\t\t\t(Arr.some(\n\t\t\t\t\t\tast.propertySignatures,\n\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\ttypeof property.name === \"string\" &&\n\t\t\t\t\t\t\t// A `**` may stand for this part and more.\n\t\t\t\t\t\t\t((name === \"**\" && next(property.type, index)) ||\n\t\t\t\t\t\t\t\t(fits(name, property.name) && next(property.type, index + 1))),\n\t\t\t\t\t) ||\n\t\t\t\t\t\t// A record keeps the Schema of its keys and of its values.\n\t\t\t\t\t\tArr.some(ast.indexSignatures, (signature) =>\n\t\t\t\t\t\t\tname === \"**\"\n\t\t\t\t\t\t\t\t? hasSomeKey(signature.parameter) &&\n\t\t\t\t\t\t\t\t\t(next(signature.type, index) ||\n\t\t\t\t\t\t\t\t\t\tnext(signature.type, index + 1))\n\t\t\t\t\t\t\t\t: Arr.some(\n\t\t\t\t\t\t\t\t\t\t[name.replaceAll(\"*\", \"\"), name.replaceAll(\"*\", \"a\")],\n\t\t\t\t\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t\t\t\t\t\tfits(name, key) && keyFits(signature.parameter, key),\n\t\t\t\t\t\t\t\t\t) && next(signature.type, index + 1),\n\t\t\t\t\t\t))\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\treturn false\n\t\t}\n\t})\n\n/**\n * Tests if a record takes a key. A key of an object is a string, also a key\n * that a number Schema takes: `{ 1: \"a\" }` has the key `\"1\"`. So a key that\n * is the text of a number is tried as that number too.\n */\nconst keyFits = (parameter: SchemaAST.AST, key: string): boolean => {\n\tconst is = Schema.is(Schema.make(parameter))\n\treturn (\n\t\tis(key) || (key !== \"\" && String(Number(key)) === key && is(Number(key)))\n\t)\n}\n\n/**\n * Gives the struct of a `Schema.Class`. A class is a declaration with one\n * struct as its type parameter, and Effect marks it with a `\"~constructor\"`\n * annotation, also through more codec steps, as in\n * `Schema.fromJsonString(User)`. Other declarations, such as\n * `Schema.OptionFromNullOr` or `Schema.ReadonlyMap`, have no such mark, and\n * the fields of their type parameter are not fields of the value.\n */\nconst classStruct = (\n\tast: SchemaAST.Declaration,\n): SchemaAST.Objects | undefined => {\n\tconst [inner] = ast.typeParameters\n\treturn ast.annotations?.[\"~constructor\"] !== undefined &&\n\t\tast.typeParameters.length === 1 &&\n\t\tinner?._tag === \"Objects\"\n\t\t? inner\n\t\t: undefined\n}\n\n/**\n * Gives the structs inside a Schema, with the `Schema.suspend` nodes that are\n * open on the way to each one. The open nodes are in a native `Set`, because\n * it must find a node by the node itself: `Equal` compares Schema nodes by\n * structure, and a recursive Schema has no end. It looks through optional keys, unions such as\n * `Schema.NullOr`, `Schema.suspend`, and `Schema.Class`. A suspend node that\n * is already open is not opened again, so a recursive Schema has an end.\n */\nconst structsOf = (\n\tast: SchemaAST.AST,\n\topen: ReadonlySet<SchemaAST.AST>,\n): ReadonlyArray<readonly [SchemaAST.Objects, ReadonlySet<SchemaAST.AST>]> => {\n\tswitch (ast._tag) {\n\t\tcase \"Objects\":\n\t\t\treturn ast.propertySignatures.length === 0 ? [] : [[ast, open]]\n\t\tcase \"Union\":\n\t\t\treturn ast.types.flatMap((type) => structsOf(type, open))\n\t\tcase \"Suspend\":\n\t\t\treturn open.has(ast)\n\t\t\t\t? []\n\t\t\t\t: structsOf(ast.thunk(), new Set([...open, ast]))\n\t\tcase \"Declaration\": {\n\t\t\tconst inner = classStruct(ast)\n\t\t\treturn inner === undefined ? [] : structsOf(inner, open)\n\t\t}\n\t\tdefault:\n\t\t\treturn []\n\t}\n}\n\n/** Tests if a Schema holds one plain value, with no parts. */\n/**\n * The kind of value that a field holds: one plain value, a record with keys\n * that the Schema does not name, or another value with parts, such as an\n * array or a map.\n */\ntype FieldShape = \"scalar\" | \"record\" | \"other\"\n\n/** Gives the kind of value that a field holds. See {@link FieldShape}. */\nconst shapeOf = (\n\tast: SchemaAST.AST,\n\topen: ReadonlySet<SchemaAST.AST> = new Set(),\n): FieldShape => {\n\tswitch (ast._tag) {\n\t\tcase \"Objects\":\n\t\t\treturn ast.indexSignatures.length > 0 ? \"record\" : \"other\"\n\t\tcase \"Union\": {\n\t\t\tconst shapes = ast.types.map((type) => shapeOf(type, open))\n\t\t\treturn shapes.every((shape) => shape === \"scalar\")\n\t\t\t\t? \"scalar\"\n\t\t\t\t: shapes.includes(\"record\")\n\t\t\t\t\t? \"record\"\n\t\t\t\t\t: \"other\"\n\t\t}\n\t\tcase \"Suspend\":\n\t\t\treturn open.has(ast)\n\t\t\t\t? \"other\"\n\t\t\t\t: shapeOf(ast.thunk(), new Set([...open, ast]))\n\t\tdefault:\n\t\t\treturn isScalar(ast) ? \"scalar\" : \"other\"\n\t}\n}\n\nconst isScalar = (ast: SchemaAST.AST): boolean => {\n\tswitch (ast._tag) {\n\t\tcase \"String\":\n\t\tcase \"Number\":\n\t\tcase \"Boolean\":\n\t\tcase \"BigInt\":\n\t\tcase \"Symbol\":\n\t\tcase \"UniqueSymbol\":\n\t\tcase \"Literal\":\n\t\tcase \"Enum\":\n\t\tcase \"TemplateLiteral\":\n\t\tcase \"Null\":\n\t\tcase \"Undefined\":\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\n/**\n * Tests if a Schema holds, in some branch, a value that is not a struct: a\n * scalar, or a value such as a record or an array.\n */\nconst holdsValue = (\n\tast: SchemaAST.AST,\n\topen: ReadonlySet<SchemaAST.AST>,\n): boolean => {\n\tswitch (ast._tag) {\n\t\tcase \"Objects\":\n\t\t\t// A struct with a record part, as from `Schema.StructWithRest`, holds\n\t\t\t// keys that are not named, so it holds more than one value.\n\t\t\treturn (\n\t\t\t\tast.propertySignatures.length === 0 || ast.indexSignatures.length > 0\n\t\t\t)\n\t\tcase \"Union\":\n\t\t\treturn ast.types.some((type) => holdsValue(type, open))\n\t\tcase \"Suspend\":\n\t\t\treturn !open.has(ast) && holdsValue(ast.thunk(), new Set([...open, ast]))\n\t\tcase \"Declaration\":\n\t\t\treturn classStruct(ast) === undefined\n\t\tdefault:\n\t\t\treturn true\n\t}\n}\n\n/** One field that {@link walkFields} finds. */\ninterface FieldVisit {\n\treadonly path: string\n\t/**\n\t * `true` for a field that holds a value that is not a struct, and `false`\n\t * for a field that holds a struct.\n\t */\n\treadonly leaf: boolean\n\treadonly type: SchemaAST.AST\n}\n\n/**\n * Gives the path of every field of a Schema, with a dot between the names of\n * nested fields. A field of a union may come two times: one time as a field\n * that holds a value, and one time as a field that holds a struct.\n */\nconst walkFields = (\n\tast: SchemaAST.AST,\n\tprefix = \"\",\n\topen: ReadonlySet<SchemaAST.AST> = new Set(),\n): ReadonlyArray<FieldVisit> =>\n\tArr.flatMap(structsOf(ast, open), ([struct, inner]) =>\n\t\tArr.flatMap(struct.propertySignatures, (property): Array<FieldVisit> => {\n\t\t\tconst name = property.name\n\t\t\tif (typeof name !== \"string\") {\n\t\t\t\treturn []\n\t\t\t}\n\t\t\t// A dot in a path is the step into a nested field. A field name with a\n\t\t\t// dot would make two fields have one path, so it is a defect.\n\t\t\tif (name.includes(\".\")) {\n\t\t\t\tthrow new Error(`A field name may not have a dot: \"${name}\"`)\n\t\t\t}\n\t\t\t// An empty name would make an empty part in a path, such as `.secret`.\n\t\t\tif (name === \"\") {\n\t\t\t\tthrow new Error(\"A field name may not be empty\")\n\t\t\t}\n\t\t\tconst path = prefix === \"\" ? name : `${prefix}.${name}`\n\t\t\tconst type = property.type\n\t\t\treturn [\n\t\t\t\t...(holdsValue(type, inner) ? [{ path, leaf: true, type }] : []),\n\t\t\t\t...(structsOf(type, inner).length > 0\n\t\t\t\t\t? [{ path, leaf: false, type }, ...walkFields(type, path, inner)]\n\t\t\t\t\t: []),\n\t\t\t]\n\t\t}),\n\t)\n\n/**\n * Gives the paths of all the fields of a Schema, with dots for nested fields.\n * A nested struct gives its own path and the paths of its fields. Arrays are\n * left out. It throws when a field name has a dot or is empty, because such a\n * name would give two fields one path, or a path with an empty part.\n *\n * @stability stable\n * @category getters\n * @since 1.0.0\n */\nexport const fieldPaths = (schema: Schema.Top): ReadonlyArray<string> =>\n\tArr.dedupe(Arr.map(walkFields(schema.ast), (visit) => visit.path))\n\n/** Tests if a Schema holds only plain scalars: see {@link isPlainField}. */\n/**\n * The ids of the checks that the search knows. `domainOf` reads them, so a\n * field with only these checks has an exact domain.\n */\nconst knownChecks = HashSet.make(\n\t\"effect/schema/isInt\",\n\t\"effect/schema/isFinite\",\n)\n\n/**\n * Tests if each check of a Schema node is a check that the search knows. A\n * check such as `isGreaterThan(0)` stops some values, and the search does not\n * see it, so it could find a value that the Schema does not take.\n */\nconst hasOnlyKnownChecks = (\n\tchecks: ReadonlyArray<SchemaAST.Check<never>> | undefined,\n): boolean =>\n\tArr.every(checks ?? [], (check) =>\n\t\tcheck._tag === \"FilterGroup\"\n\t\t\t? hasOnlyKnownChecks(check.checks)\n\t\t\t: HashSet.has(knownChecks, check.annotations?.representation?.id),\n\t)\n\nconst isPlainScalar = (ast: SchemaAST.AST): boolean => {\n\t// `domainOf` reads the known checks only on a number node. A check on\n\t// another node, such as on a union of literals, is a check it can not see.\n\tif (\n\t\tast._tag === \"Number\"\n\t\t\t? !hasOnlyKnownChecks(ast.checks)\n\t\t\t: (ast.checks ?? []).length > 0\n\t) {\n\t\treturn false\n\t}\n\tswitch (ast._tag) {\n\t\tcase \"String\":\n\t\tcase \"Number\":\n\t\tcase \"Boolean\":\n\t\tcase \"Literal\":\n\t\tcase \"Null\":\n\t\tcase \"Undefined\":\n\t\t\treturn true\n\t\tcase \"Union\":\n\t\t\t// A union in the mode \"oneOf\" stops a value that fits two members.\n\t\t\t// The search does not see that, so such a field is not plain.\n\t\t\treturn (\n\t\t\t\tast.options?.mode !== \"oneOf\" && Arr.every(ast.types, isPlainScalar)\n\t\t\t)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\n/**\n * Tests if a path names a plain scalar field of a Schema: a string, a number,\n * a boolean, a literal, `null`, or an optional field or a union of these. Its\n * only checks may be integer and finite checks: another check, such as\n * `isGreaterThan(0)`, stops values that the search does not know about. On\n * the way, each part must be a required field of a plain struct with no\n * checks, with a name that is not a name of `Object.prototype`.\n *\n * `Policy.coverage` and `Condition.satisfiable` answer `All`, `None` or\n * `Some` only when each field of the condition is such a field. Their model of\n * the values of a field is exact for these Schemas. For other Schemas, such as\n * classes, records, unions of structs or declarations, a value may have data\n * that the Schema does not show, and the answer is `Unknown`.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const isPlainField = (schema: Schema.Top, path: string): boolean =>\n\t!isTooLong(path) && plainAt(schema.ast, path.split(\".\"))\n\nconst plainAt = (ast: SchemaAST.AST, names: ReadonlyArray<string>): boolean => {\n\tconst [name, ...rest] = names\n\tif (\n\t\tname === undefined ||\n\t\tast._tag !== \"Objects\" ||\n\t\tast.indexSignatures.length > 0 ||\n\t\t(ast.checks ?? []).length > 0 ||\n\t\tname in Object.prototype\n\t) {\n\t\treturn false\n\t}\n\tconst property = ast.propertySignatures.find(\n\t\t(signature) => signature.name === name,\n\t)\n\tif (property === undefined) {\n\t\treturn false\n\t}\n\treturn rest.length === 0\n\t\t? isPlainScalar(property.type)\n\t\t: !SchemaAST.isOptional(property.type) && plainAt(property.type, rest)\n}\n\n/**\n * Tests if a path names a field of a Schema that holds a value with no named\n * fields: a scalar, or a value such as a record or an array. It goes into\n * records by their keys, and into recursive Schemas as far as the path goes.\n * So it finds paths that {@link fieldPaths} does not list.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const hasPath = (schema: Schema.Top, path: string): boolean =>\n\t!isTooLong(path) && resolves(schema.ast, path.split(\".\"), 0, new Map())\n\n/**\n * The answers of a walk along a path, by Schema node and by place in the path.\n * Two branches of a union may come to one node at one place, as in a recursive\n * union, and the memo does that work one time. It is a native `Map`, because\n * it must find a Schema node by the node itself.\n */\ntype PathMemo<A> = Map<SchemaAST.AST, Map<number, A>>\n\n/**\n * Gives the answer for a node at a place from the memo, or works it out and\n * keeps it. While the work runs, the memo holds `pending`, so a walk that\n * comes back to the node at the same place, with no step on the path, gets\n * `pending` and stops.\n */\nconst rememberAt = <A>(\n\tmemo: PathMemo<A>,\n\tast: SchemaAST.AST,\n\tindex: number,\n\tpending: A,\n\twork: () => A,\n): A => {\n\tconst places = memo.get(ast) ?? new Map<number, A>()\n\tmemo.set(ast, places)\n\tif (places.has(index)) {\n\t\treturn places.get(index) as A\n\t}\n\tplaces.set(index, pending)\n\tconst result = work()\n\tplaces.set(index, result)\n\treturn result\n}\n\nconst resolves = (\n\tast: SchemaAST.AST,\n\tnames: ReadonlyArray<string>,\n\tindex: number,\n\tmemo: PathMemo<boolean>,\n): boolean =>\n\trememberAt(memo, ast, index, false, () => {\n\t\tif (index === names.length) {\n\t\t\treturn index > 0 && holdsValue(ast, new Set())\n\t\t}\n\t\tconst name = names[index]!\n\t\tswitch (ast._tag) {\n\t\t\tcase \"Objects\": {\n\t\t\t\tconst property = ast.propertySignatures.find(\n\t\t\t\t\t(signature) => signature.name === name,\n\t\t\t\t)\n\t\t\t\tif (property !== undefined) {\n\t\t\t\t\treturn resolves(property.type, names, index + 1, memo)\n\t\t\t\t}\n\t\t\t\t// A key of a record must fit the Schema of the keys.\n\t\t\t\treturn ast.indexSignatures.some(\n\t\t\t\t\t(signature) =>\n\t\t\t\t\t\tkeyFits(signature.parameter, name) &&\n\t\t\t\t\t\tresolves(signature.type, names, index + 1, memo),\n\t\t\t\t)\n\t\t\t}\n\t\t\tcase \"Union\":\n\t\t\t\treturn ast.types.some((type) => resolves(type, names, index, memo))\n\t\t\tcase \"Suspend\":\n\t\t\t\treturn resolves(ast.thunk(), names, index, memo)\n\t\t\tcase \"Declaration\": {\n\t\t\t\tconst inner = classStruct(ast)\n\t\t\t\treturn inner !== undefined && resolves(inner, names, index, memo)\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn false\n\t\t}\n\t})\n\n/**\n * Tests if a Schema has a field whose path fits a pattern. `parts` are the\n * parts of the pattern, split at the dots. A part `**` stands for any number\n * of parts, also none. Another part fits a name when `fits` says so, as a\n * part with `*` fits many names. For a record, the walk asks if the key\n * Schema takes a key that fits the part. For a template literal key Schema,\n * 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\n * key, and then the answer is `false`.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const hasMatchingPath = (\n\tschema: Schema.Top,\n\tparts: ReadonlyArray<string>,\n\tfits: (part: string, name: string) => boolean,\n): boolean =>\n\tparts.length <= maxPathParts &&\n\tmatchesFrom(schema.ast, parts, 0, false, fits, new Map())\n\nconst matchesFrom = (\n\tast: SchemaAST.AST,\n\tparts: ReadonlyArray<string>,\n\tindex: number,\n\tstepped: boolean,\n\tfits: (part: string, name: string) => boolean,\n\tmemo: PathMemo<boolean>,\n): boolean =>\n\t// The memo keeps two answers for each place: before the first step, and\n\t// after it.\n\trememberAt(memo, ast, index * 2 + (stepped ? 1 : 0), false, () => {\n\t\tconst next = (type: SchemaAST.AST, at: number, step: boolean): boolean =>\n\t\t\tmatchesFrom(type, parts, at, step, fits, memo)\n\t\tswitch (ast._tag) {\n\t\t\tcase \"Union\":\n\t\t\t\treturn Arr.some(ast.types, (type) => next(type, index, stepped))\n\t\t\tcase \"Suspend\":\n\t\t\t\treturn next(ast.thunk(), index, stepped)\n\t\t\tcase \"Declaration\": {\n\t\t\t\tconst inner = classStruct(ast)\n\t\t\t\tif (inner !== undefined) {\n\t\t\t\t\treturn next(inner, index, stepped)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t\t// The path ends at a field that holds a value, as a field that a rule\n\t\t// may name does.\n\t\tif (index === parts.length) {\n\t\t\treturn stepped && holdsValue(ast, new Set())\n\t\t}\n\t\tconst part = parts[index]!\n\t\tif (part === \"**\" && next(ast, index + 1, stepped)) {\n\t\t\treturn true\n\t\t}\n\t\tif (ast._tag !== \"Objects\") {\n\t\t\treturn false\n\t\t}\n\t\t// Keys made from the part, and keys made from the key Schema. A key\n\t\t// Schema such as `TemplateLiteral([\"x\", String])` takes neither \"\" nor\n\t\t// \"a\", but it takes \"x\" and \"xa\".\n\t\tconst fromPart = [part.replaceAll(\"*\", \"\"), part.replaceAll(\"*\", \"a\")]\n\t\treturn (\n\t\t\tArr.some(\n\t\t\t\tast.propertySignatures,\n\t\t\t\t(property) =>\n\t\t\t\t\ttypeof property.name === \"string\" &&\n\t\t\t\t\t(part === \"**\"\n\t\t\t\t\t\t? next(property.type, index, true)\n\t\t\t\t\t\t: fits(part, property.name) &&\n\t\t\t\t\t\t\tnext(property.type, index + 1, true)),\n\t\t\t) ||\n\t\t\tArr.some(ast.indexSignatures, (signature) =>\n\t\t\t\tpart === \"**\"\n\t\t\t\t\t? // A step into a record needs a key that its key Schema takes.\n\t\t\t\t\t\thasSomeKey(signature.parameter) && next(signature.type, index, true)\n\t\t\t\t\t: // A template literal key Schema gives an exact answer. Another\n\t\t\t\t\t\t// key Schema is tried with sample keys.\n\t\t\t\t\t\t(globMeetsKeys(part, signature.parameter) ??\n\t\t\t\t\t\t\tArr.some(\n\t\t\t\t\t\t\t\tArr.dedupe([...fromPart, ...sampleKeys(signature.parameter)]),\n\t\t\t\t\t\t\t\t(key) => keyFits(signature.parameter, key) && fits(part, key),\n\t\t\t\t\t\t\t)) &&\n\t\t\t\t\t\tnext(signature.type, index + 1, true),\n\t\t\t)\n\t\t)\n\t})\n\n/**\n * Tests if a key Schema takes some key: the exact search for a template\n * literal, or a sample key.\n */\nconst hasSomeKey = (parameter: SchemaAST.AST): boolean =>\n\tglobMeetsKeys(\"*\", parameter) ??\n\tArr.some(Arr.dedupe([\"\", \"a\", ...sampleKeys(parameter)]), (key) =>\n\t\tkeyFits(parameter, key),\n\t)\n\n/** The longest key pattern that the exact search of keys takes. */\nconst maxExactKeyLength = 256\n\n/** A part of a key pattern: one character, or `*` for any characters. */\ntype GlobToken =\n\t{ readonly _tag: \"Char\"; readonly char: string } | { readonly _tag: \"Star\" }\n\n/** A part of a template literal: one character, or any characters. */\ntype TemplateToken =\n\t{ readonly _tag: \"Char\"; readonly char: string } | { readonly _tag: \"Any\" }\n\nconst charsOf = (text: string): ReadonlyArray<TemplateToken> =>\n\tArr.map(Array.from(text), (char) => ({ _tag: \"Char\", char }) as const)\n\n/**\n * Gives the token lists of a template literal, one for each choice of its\n * unions of literals, or `undefined` when the lists can not be exact: a part\n * that this walk does not know, such as a number, a part with checks, or\n * more than 64 lists.\n */\nconst templateTokens = (\n\tast: SchemaAST.TemplateLiteral,\n): ReadonlyArray<ReadonlyArray<TemplateToken>> | undefined => {\n\tconst partTokens = (\n\t\tpart: SchemaAST.AST,\n\t): ReadonlyArray<ReadonlyArray<TemplateToken>> | undefined => {\n\t\tif ((part.checks ?? []).length > 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tswitch (part._tag) {\n\t\t\tcase \"Literal\": {\n\t\t\t\tconst text = String(part.literal)\n\t\t\t\t// A half of a pair of UTF-16 code units may join a half in the\n\t\t\t\t// next part, and the tokens of each part can not show that.\n\t\t\t\treturn /[\\uD800-\\uDFFF]/.test(text) ? undefined : [charsOf(text)]\n\t\t\t}\n\t\t\tcase \"String\":\n\t\t\t\treturn [[{ _tag: \"Any\" }]]\n\t\t\tcase \"Number\":\n\t\t\t\t// The tokens can not hold all numbers, such as `-1.5`, so the\n\t\t\t\t// search is not exact.\n\t\t\t\treturn undefined\n\t\t\tcase \"Union\": {\n\t\t\t\t// A union in the mode \"oneOf\" stops a key that fits two members,\n\t\t\t\t// and token lists can not show that.\n\t\t\t\tif (part.options?.mode === \"oneOf\") {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst choices = Arr.map(part.types, partTokens)\n\t\t\t\treturn Arr.every(choices, (choice) => choice !== undefined)\n\t\t\t\t\t? Arr.flatten(\n\t\t\t\t\t\t\tchoices as ReadonlyArray<\n\t\t\t\t\t\t\t\tReadonlyArray<ReadonlyArray<TemplateToken>>\n\t\t\t\t\t\t\t>,\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn undefined\n\t\t}\n\t}\n\treturn Arr.reduce(\n\t\tast.parts,\n\t\t[[]] as ReadonlyArray<ReadonlyArray<TemplateToken>> | undefined,\n\t\t(lists, part) => {\n\t\t\tconst choices = partTokens(part)\n\t\t\tif (lists === undefined || choices === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\t// Each list so far, with each choice of this part. Past 64 lists the\n\t\t\t// search would not be exact, so it gives no answer.\n\t\t\tconst all = Arr.flatMap(lists, (list) =>\n\t\t\t\tArr.map(choices, (choice) => [...list, ...choice]),\n\t\t\t)\n\t\t\t// The search calls itself for each character, so a long list of\n\t\t\t// tokens gives no answer too.\n\t\t\treturn all.length > 64 ||\n\t\t\t\tArr.some(all, (list) => list.length > maxExactKeyLength)\n\t\t\t\t? undefined\n\t\t\t\t: all\n\t\t},\n\t)\n}\n\n/**\n * Tests if a key pattern and a list of template tokens share a key. It walks\n * the pairs of places in the two lists, with a few characters that stand for\n * all others, so the answer is exact for these tokens.\n */\nconst tokensMeet = (\n\tglob: ReadonlyArray<GlobToken>,\n\ttemplate: ReadonlyArray<TemplateToken>,\n): boolean => {\n\tconst key = (t: number, g: number) => t * (glob.length + 1) + g\n\t// The places that a pair can reach with no character.\n\tconst closeOf = (\n\t\tt: number,\n\t\tg: number,\n\t): ReadonlyArray<readonly [number, number]> => [\n\t\t[t, g],\n\t\t...(template[t]?._tag === \"Any\" ? closeOf(t + 1, g) : []),\n\t\t...(glob[g]?._tag === \"Star\" ? closeOf(t, g + 1) : []),\n\t]\n\tconst alphabet = Arr.dedupe([\n\t\t\"a\",\n\t\t\"0\",\n\t\t...Arr.flatMap(glob, (token) =>\n\t\t\ttoken._tag === \"Char\" ? [token.char] : [],\n\t\t),\n\t\t...Arr.flatMap(template, (token) =>\n\t\t\ttoken._tag === \"Char\" ? [token.char] : [],\n\t\t),\n\t])\n\tconst stepTemplate = (t: number, char: string): ReadonlyArray<number> => {\n\t\tconst token = template[t]\n\t\treturn token === undefined\n\t\t\t? []\n\t\t\t: token._tag === \"Any\"\n\t\t\t\t? [t]\n\t\t\t\t: token.char === char\n\t\t\t\t\t? [t + 1]\n\t\t\t\t\t: []\n\t}\n\tconst stepGlob = (g: number, char: string): ReadonlyArray<number> => {\n\t\tconst token = glob[g]\n\t\treturn token === undefined\n\t\t\t? []\n\t\t\t: token._tag === \"Char\"\n\t\t\t\t? token.char === char\n\t\t\t\t\t? [g + 1]\n\t\t\t\t\t: []\n\t\t\t\t: char === \".\"\n\t\t\t\t\t? []\n\t\t\t\t\t: [g]\n\t}\n\t// A search over the pairs: each pair is seen one time.\n\tconst search = (\n\t\tfrontier: ReadonlyArray<readonly [number, number]>,\n\t\tseen: HashSet.HashSet<number>,\n\t): boolean => {\n\t\t// Each pair comes one time, also when many paths reach it, so the work\n\t\t// is at most the number of pairs.\n\t\tconst fresh = Array.from(\n\t\t\tHashMap.values(\n\t\t\t\tHashMap.fromIterable(\n\t\t\t\t\tArr.map(\n\t\t\t\t\t\tArr.filter(\n\t\t\t\t\t\t\tArr.flatMap(frontier, ([t, g]) => closeOf(t, g)),\n\t\t\t\t\t\t\t([t, g]) => !HashSet.has(seen, key(t, g)),\n\t\t\t\t\t\t),\n\t\t\t\t\t\t(pair) => [key(pair[0], pair[1]), pair] as const,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\t\tif (fresh.length === 0) {\n\t\t\treturn false\n\t\t}\n\t\tif (\n\t\t\tArr.some(fresh, ([t, g]) => t === template.length && g === glob.length)\n\t\t) {\n\t\t\treturn true\n\t\t}\n\t\tconst next = HashSet.union(\n\t\t\tseen,\n\t\t\tHashSet.fromIterable(Arr.map(fresh, ([t, g]) => key(t, g))),\n\t\t)\n\t\treturn search(\n\t\t\tArr.flatMap(fresh, ([t, g]) =>\n\t\t\t\tArr.flatMap(alphabet, (char) =>\n\t\t\t\t\tArr.flatMap(stepTemplate(t, char), (t2) =>\n\t\t\t\t\t\tArr.map(stepGlob(g, char), (g2) => [t2, g2] as const),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t\tnext,\n\t\t)\n\t}\n\treturn search([[0, 0]], HashSet.empty())\n}\n\n/**\n * Tests if a key pattern fits a key of a template literal key Schema, or\n * `undefined` when the search is not exact for the Schema. The search calls\n * itself one time for each character of a key, so a very long part gives\n * `undefined` too.\n */\nconst globMeetsKeys = (\n\tpart: string,\n\tast: SchemaAST.AST,\n): boolean | undefined => {\n\tif (\n\t\tast._tag !== \"TemplateLiteral\" ||\n\t\t(ast.checks ?? []).length > 0 ||\n\t\tpart.length > maxExactKeyLength\n\t) {\n\t\treturn undefined\n\t}\n\tconst lists = templateTokens(ast)\n\tif (lists === undefined) {\n\t\treturn undefined\n\t}\n\tconst glob = Arr.map(\n\t\t(part.match(/\\*+|[^*]/gu) ?? []) as ReadonlyArray<string>,\n\t\t(token): GlobToken =>\n\t\t\ttoken.startsWith(\"*\") ? { _tag: \"Star\" } : { _tag: \"Char\", char: token },\n\t)\n\treturn Arr.some(lists, (list) => tokensMeet(glob, list))\n}\n\n/**\n * A few keys that a key Schema of a record takes: each part of a template\n * literal gives its literal, or a short text for a string or a number. These\n * are samples. A key that is not a sample may fit too, so a \"no\" from a test\n * with them is only \"not found\".\n */\nconst sampleKeys = (ast: SchemaAST.AST): ReadonlyArray<string> => {\n\tswitch (ast._tag) {\n\t\tcase \"String\":\n\t\t\treturn [\"\", \"a\"]\n\t\tcase \"Number\":\n\t\t\treturn [\"0\", \"1\"]\n\t\tcase \"Literal\":\n\t\t\treturn [String(ast.literal)]\n\t\tcase \"Union\":\n\t\t\treturn Arr.flatMap(ast.types, sampleKeys)\n\t\tcase \"TemplateLiteral\":\n\t\t\t// Each key of the parts before, with each key of this part. Two\n\t\t\t// samples for each part keep the list short.\n\t\t\treturn Arr.reduce(ast.parts, [\"\"], (keys: ReadonlyArray<string>, part) =>\n\t\t\t\tArr.take(\n\t\t\t\t\tArr.flatMap(keys, (key) =>\n\t\t\t\t\t\tArr.map(Arr.take(sampleKeys(part), 2), (end) => key + end),\n\t\t\t\t\t),\n\t\t\t\t\t64,\n\t\t\t\t),\n\t\t\t)\n\t\tdefault:\n\t\t\treturn []\n\t}\n}\n\n/**\n * Tests if a Schema surely has a value: each required field, at each depth,\n * has a type that has values, with no checks other than integer and finite\n * checks on numbers. A check such as a minimum length may stop every value,\n * and the library can not see that, so such a Schema gives `false`. So does a\n * required field that holds the struct itself again.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const hasValue = (schema: Schema.Top): boolean =>\n\tisSurelyInhabited(schema.ast, new Set())\n\nconst isSurelyInhabited = (\n\tast: SchemaAST.AST,\n\topen: ReadonlySet<SchemaAST.AST>,\n): boolean => {\n\tif (\n\t\tast._tag === \"Number\"\n\t\t\t? !hasOnlyKnownChecks(ast.checks)\n\t\t\t: (ast.checks ?? []).length > 0\n\t) {\n\t\treturn false\n\t}\n\tswitch (ast._tag) {\n\t\tcase \"Never\":\n\t\t\treturn false\n\t\tcase \"Objects\":\n\t\t\t// A named field must fit the record part too, as in\n\t\t\t// `Schema.StructWithRest`, and the two types may share no value. That\n\t\t\t// is not easy to know, so such a struct is not sure.\n\t\t\treturn (\n\t\t\t\t(ast.propertySignatures.length === 0 ||\n\t\t\t\t\tast.indexSignatures.length === 0) &&\n\t\t\t\tArr.every(\n\t\t\t\t\tast.propertySignatures,\n\t\t\t\t\t(property) =>\n\t\t\t\t\t\tSchemaAST.isOptional(property.type) ||\n\t\t\t\t\t\tisSurelyInhabited(property.type, open),\n\t\t\t\t)\n\t\t\t)\n\t\tcase \"Union\":\n\t\t\t// A union in the mode \"oneOf\" may stop every value of its members.\n\t\t\treturn (\n\t\t\t\tast.options?.mode !== \"oneOf\" &&\n\t\t\t\tArr.some(ast.types, (type) => isSurelyInhabited(type, open))\n\t\t\t)\n\t\tcase \"Suspend\":\n\t\t\treturn (\n\t\t\t\t!open.has(ast) &&\n\t\t\t\tisSurelyInhabited(ast.thunk(), new Set([...open, ast]))\n\t\t\t)\n\t\tcase \"Arrays\":\n\t\t\t// The elements that a tuple needs, and the elements after its rest.\n\t\t\t// The rest itself may be empty.\n\t\t\treturn Arr.every(\n\t\t\t\t[\n\t\t\t\t\t...Arr.filter(\n\t\t\t\t\t\tast.elements,\n\t\t\t\t\t\t(element) => !SchemaAST.isOptional(element),\n\t\t\t\t\t),\n\t\t\t\t\t...ast.rest.slice(1),\n\t\t\t\t],\n\t\t\t\t(element) => isSurelyInhabited(element, open),\n\t\t\t)\n\t\tcase \"Declaration\": {\n\t\t\tconst inner = classStruct(ast)\n\t\t\tif (inner !== undefined) {\n\t\t\t\treturn isSurelyInhabited(inner, open)\n\t\t\t}\n\t\t\tconst id = declarationId(ast)\n\t\t\t// A value of these holds a value of one of its type parameters.\n\t\t\tif (HashSet.has(wrapperDeclarations, id)) {\n\t\t\t\treturn Arr.some(ast.typeParameters, (type) =>\n\t\t\t\t\tisSurelyInhabited(type, open),\n\t\t\t\t)\n\t\t\t}\n\t\t\t// These have a value for any type parameters, such as an empty map\n\t\t\t// or `Option.none()`. Another declaration may take no value.\n\t\t\treturn HashSet.has(inhabitedDeclarations, id)\n\t\t}\n\t\tcase \"Enum\":\n\t\t\treturn ast.enums.length > 0\n\t\tcase \"TemplateLiteral\":\n\t\t\treturn Arr.every(ast.parts, (part) => isSurelyInhabited(part, open))\n\t\tcase \"String\":\n\t\tcase \"Number\":\n\t\tcase \"Boolean\":\n\t\tcase \"BigInt\":\n\t\tcase \"Symbol\":\n\t\tcase \"UniqueSymbol\":\n\t\tcase \"Literal\":\n\t\tcase \"Null\":\n\t\tcase \"Undefined\":\n\t\tcase \"Void\":\n\t\tcase \"Unknown\":\n\t\tcase \"Any\":\n\t\tcase \"ObjectKeyword\":\n\t\t\treturn true\n\t\tdefault:\n\t\t\t// A node that this walk does not know may take no value.\n\t\t\treturn false\n\t}\n}\n\n/** Declarations of Effect that hold a value of a type parameter. */\nconst wrapperDeclarations = HashSet.make(\n\t\"effect/schema/Redacted\",\n\t\"effect/schema/Result\",\n)\n\n/** Declarations of Effect that have a value for any type parameters. */\nconst inhabitedDeclarations = HashSet.make(\n\t\"effect/schema/Date\",\n\t\"effect/schema/URL\",\n\t\"effect/schema/Uint8Array\",\n\t\"effect/schema/Duration\",\n\t\"effect/schema/DateTimeUtc\",\n\t\"effect/schema/BigDecimal\",\n\t\"effect/schema/Cause\",\n\t\"effect/schema/Chunk\",\n\t\"effect/schema/HashMap\",\n\t\"effect/schema/HashSet\",\n\t\"effect/schema/ReadonlyMap\",\n\t\"effect/schema/ReadonlySet\",\n\t\"effect/schema/Option\",\n\t\"effect/schema/File\",\n\t\"effect/schema/FormData\",\n\t\"effect/schema/RegExp\",\n\t\"effect/schema/Json\",\n\t\"effect/schema/ByteSize\",\n\t\"effect/schema/DateTimeZoned\",\n\t\"effect/schema/Error\",\n\t\"effect/schema/Exit\",\n\t\"effect/schema/CauseReason\",\n\t\"effect/schema/Graph\",\n\t\"effect/schema/SemVer\",\n\t\"effect/schema/SemVerRange\",\n\t\"effect/schema/TimeZone\",\n\t\"effect/schema/TimeZoneNamed\",\n\t\"effect/schema/TimeZoneOffset\",\n\t\"effect/schema/URLSearchParams\",\n)\n\n/**\n * Tests if a Schema has no value at all: a required field of it, at some\n * depth, has no value, as `Schema.Never` has none. A required field that\n * holds the struct itself again, with no way to stop, has no finite value\n * either. Other checks, such as a minimum and a maximum that do not meet, are\n * not seen, so a \"no\" does not prove that the Schema has a value.\n *\n * @stability stable\n * @category predicates\n * @since 1.0.0\n */\nexport const hasNoValue = (schema: Schema.Top): boolean =>\n\tisEmptyType(schema.ast, new Set())\n\nconst isEmptyType = (\n\tast: SchemaAST.AST,\n\topen: ReadonlySet<SchemaAST.AST>,\n): boolean => {\n\tswitch (ast._tag) {\n\t\tcase \"Never\":\n\t\t\treturn true\n\t\tcase \"Objects\":\n\t\t\treturn Arr.some(\n\t\t\t\tast.propertySignatures,\n\t\t\t\t(property) =>\n\t\t\t\t\t!SchemaAST.isOptional(property.type) &&\n\t\t\t\t\tisEmptyType(property.type, open),\n\t\t\t)\n\t\tcase \"Union\":\n\t\t\treturn Arr.every(ast.types, (type) => isEmptyType(type, open))\n\t\tcase \"Suspend\":\n\t\t\t// A walk that comes back to a suspend node on required fields only\n\t\t\t// never stops, so such a value can not be made.\n\t\t\treturn open.has(ast) || isEmptyType(ast.thunk(), new Set([...open, ast]))\n\t\tcase \"Declaration\": {\n\t\t\tconst inner = classStruct(ast)\n\t\t\treturn inner !== undefined && isEmptyType(inner, open)\n\t\t}\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\n/**\n * The values that one field of a resource may hold, as a condition sees them.\n * A missing field and `undefined` are `null`. The domain may be larger than\n * the real set of values: Schema checks other than finite and integer checks\n * are left out. A larger domain only makes a check say \"no\" more often.\n *\n * @stability stable\n * @category models\n * @since 1.0.0\n */\nexport interface FieldDomain {\n\t/** The field may be `null` or missing. */\n\treadonly null: boolean\n\t/** The field may hold a value with parts, or a value that is not a scalar. */\n\treadonly object: boolean\n\t/** The field may hold `true` and `false`. */\n\treadonly boolean: boolean\n\t/** The field may hold any string. */\n\treadonly string: boolean\n\t/** The numbers that the field may hold. */\n\treadonly number: \"none\" | \"integer\" | \"finite\" | \"any\"\n\t/** Single values that the field may hold, other than the ones above. */\n\treadonly literals: ReadonlyArray<string | number | boolean>\n}\n\nconst numberOrder = [\"none\", \"integer\", \"finite\", \"any\"] as const\n\nconst emptyDomain: FieldDomain = {\n\tnull: false,\n\tobject: false,\n\tboolean: false,\n\tstring: false,\n\tnumber: \"none\",\n\tliterals: [],\n}\n\nconst nullDomain: FieldDomain = { ...emptyDomain, null: true }\n\nconst objectDomain: FieldDomain = { ...emptyDomain, object: true }\n\n/**\n * The domain of a field with no Schema: any value.\n *\n * @stability stable\n * @category constants\n * @since 1.0.0\n */\nexport const anyDomain: FieldDomain = {\n\tnull: true,\n\tobject: true,\n\tboolean: true,\n\tstring: true,\n\tnumber: \"any\",\n\tliterals: [],\n}\n\nconst joinDomains = (domains: ReadonlyArray<FieldDomain>): FieldDomain =>\n\tdomains.reduce(\n\t\t(left, right) => ({\n\t\t\tnull: left.null || right.null,\n\t\t\tobject: left.object || right.object,\n\t\t\tboolean: left.boolean || right.boolean,\n\t\t\tstring: left.string || right.string,\n\t\t\tnumber:\n\t\t\t\tnumberOrder.indexOf(left.number) >= numberOrder.indexOf(right.number)\n\t\t\t\t\t? left.number\n\t\t\t\t\t: right.number,\n\t\t\tliterals: [...left.literals, ...right.literals],\n\t\t}),\n\t\temptyDomain,\n\t)\n\nconst hasCheck = (\n\tchecks: ReadonlyArray<SchemaAST.Check<never>>,\n\tid: string,\n): boolean =>\n\tchecks.some(\n\t\t(check) =>\n\t\t\tcheck.annotations?.representation?.id === id ||\n\t\t\t(check._tag === \"FilterGroup\" && hasCheck(check.checks, id)),\n\t)\n\n/**\n * The ids of the declarations of Effect that hold only values with parts.\n * Effect puts the id in the `representation` annotation. A declaration that\n * is not in this list may hold a scalar, as `Schema.Json` may.\n */\nconst objectDeclarations = HashSet.make(\n\t\"effect/schema/Date\",\n\t\"effect/schema/URL\",\n\t\"effect/schema/Uint8Array\",\n\t\"effect/schema/Duration\",\n\t\"effect/schema/DateTimeUtc\",\n\t\"effect/schema/BigDecimal\",\n\t\"effect/schema/Redacted\",\n\t\"effect/schema/Cause\",\n\t\"effect/schema/Chunk\",\n\t\"effect/schema/HashMap\",\n\t\"effect/schema/HashSet\",\n\t\"effect/schema/ReadonlyMap\",\n\t\"effect/schema/ReadonlySet\",\n\t\"effect/schema/Option\",\n\t\"effect/schema/Result\",\n\t\"effect/schema/File\",\n\t\"effect/schema/FormData\",\n\t\"effect/schema/RegExp\",\n)\n\nconst declarationId = (ast: SchemaAST.Declaration): string | undefined => {\n\tconst representation: unknown = ast.annotations?.[\"representation\"]\n\treturn hasProperty(representation, \"id\") &&\n\t\ttypeof representation.id === \"string\"\n\t\t? representation.id\n\t\t: undefined\n}\n\n/** The domain of the values of a Schema node. */\nconst domainOfType = (\n\tast: SchemaAST.AST,\n\topen: ReadonlySet<SchemaAST.AST>,\n): FieldDomain => {\n\tswitch (ast._tag) {\n\t\tcase \"Null\":\n\t\tcase \"Undefined\":\n\t\t\treturn nullDomain\n\t\tcase \"Never\":\n\t\t\treturn emptyDomain\n\t\t// `Schema.Void` takes any value, as `Schema.Unknown` does.\n\t\tcase \"Void\":\n\t\tcase \"Unknown\":\n\t\tcase \"Any\":\n\t\t\treturn anyDomain\n\t\tcase \"String\":\n\t\tcase \"TemplateLiteral\":\n\t\t\treturn { ...emptyDomain, string: true }\n\t\tcase \"Number\": {\n\t\t\tconst checks = ast.checks ?? []\n\t\t\treturn {\n\t\t\t\t...emptyDomain,\n\t\t\t\tnumber: hasCheck(checks, \"effect/schema/isInt\")\n\t\t\t\t\t? \"integer\"\n\t\t\t\t\t: hasCheck(checks, \"effect/schema/isFinite\")\n\t\t\t\t\t\t? \"finite\"\n\t\t\t\t\t\t: \"any\",\n\t\t\t}\n\t\t}\n\t\tcase \"Boolean\":\n\t\t\treturn { ...emptyDomain, boolean: true }\n\t\tcase \"Literal\":\n\t\t\treturn typeof ast.literal === \"bigint\"\n\t\t\t\t? objectDomain\n\t\t\t\t: { ...emptyDomain, literals: [ast.literal] }\n\t\tcase \"Enum\":\n\t\t\treturn { ...emptyDomain, literals: ast.enums.map(([, value]) => value) }\n\t\tcase \"Union\":\n\t\t\treturn joinDomains(ast.types.map((type) => domainOfType(type, open)))\n\t\tcase \"Suspend\":\n\t\t\treturn open.has(ast)\n\t\t\t\t? anyDomain\n\t\t\t\t: domainOfType(ast.thunk(), new Set([...open, ast]))\n\t\tcase \"Objects\":\n\t\t\t// A struct with no fields holds any value: Effect's\n\t\t\t// `Schema.Struct({})` takes a string too.\n\t\t\treturn ast.propertySignatures.length === 0 &&\n\t\t\t\tast.indexSignatures.length === 0\n\t\t\t\t? anyDomain\n\t\t\t\t: objectDomain\n\t\tcase \"Declaration\":\n\t\t\t// A class, and a declaration of Effect in `objectDeclarations`, holds\n\t\t\t// a value with parts. Another declaration may hold any value, as\n\t\t\t// `Schema.Json` or one from `Schema.declare` may, so its domain is all\n\t\t\t// values: a smaller domain could hide a value that a deny rule names.\n\t\t\treturn classStruct(ast) !== undefined ||\n\t\t\t\tHashSet.has(objectDeclarations, declarationId(ast))\n\t\t\t\t? objectDomain\n\t\t\t\t: anyDomain\n\t\tdefault:\n\t\t\treturn objectDomain\n\t}\n}\n\nconst domainAt = (\n\tast: SchemaAST.AST,\n\tnames: ReadonlyArray<string>,\n\tindex: number,\n\tmemo: PathMemo<FieldDomain>,\n): FieldDomain =>\n\t// A walk that comes back to a node at the same place may hold any value.\n\trememberAt(memo, ast, index, anyDomain, () => {\n\t\tif (index === names.length) {\n\t\t\treturn domainOfType(ast, new Set())\n\t\t}\n\t\tconst name = names[index]!\n\t\tswitch (ast._tag) {\n\t\t\tcase \"Objects\": {\n\t\t\t\tconst property = ast.propertySignatures.find(\n\t\t\t\t\t(signature) => signature.name === name,\n\t\t\t\t)\n\t\t\t\tif (property !== undefined) {\n\t\t\t\t\tconst inner = domainAt(property.type, names, index + 1, memo)\n\t\t\t\t\t// A field that may be missing may be `null`. So may a field with\n\t\t\t\t\t// a name of `Object.prototype`: a condition reads it only when a\n\t\t\t\t\t// value gives it another value.\n\t\t\t\t\treturn SchemaAST.isOptional(property.type) || name in Object.prototype\n\t\t\t\t\t\t? joinDomains([nullDomain, inner])\n\t\t\t\t\t\t: inner\n\t\t\t\t}\n\t\t\t\t// A name that the struct does not have may still be a field of a\n\t\t\t\t// value: a condition reads a field that a value has from its\n\t\t\t\t// class, such as a getter, and the Schema does not stop such a\n\t\t\t\t// field. A key of a record is not safe either: the Schema of a\n\t\t\t\t// record checks only the keys that a loop over the keys sees, and\n\t\t\t\t// a condition reads the others too. So such a field may hold any\n\t\t\t\t// value.\n\t\t\t\treturn anyDomain\n\t\t\t}\n\t\t\tcase \"Union\":\n\t\t\t\treturn joinDomains(\n\t\t\t\t\tast.types.map((type) => domainAt(type, names, index, memo)),\n\t\t\t\t)\n\t\t\tcase \"Suspend\":\n\t\t\t\treturn domainAt(ast.thunk(), names, index, memo)\n\t\t\tcase \"Declaration\": {\n\t\t\t\tconst inner = classStruct(ast)\n\t\t\t\treturn inner === undefined\n\t\t\t\t\t? anyDomain\n\t\t\t\t\t: domainAt(inner, names, index, memo)\n\t\t\t}\n\t\t\tcase \"Arrays\":\n\t\t\tcase \"ObjectKeyword\":\n\t\t\tcase \"Unknown\":\n\t\t\tcase \"Any\":\n\t\t\t\t// A path may go into these values, and the Schema does not say\n\t\t\t\t// what is there.\n\t\t\t\treturn anyDomain\n\t\t\tdefault:\n\t\t\t\t// A path does not go into a scalar, so the field is `null`.\n\t\t\t\treturn nullDomain\n\t\t}\n\t})\n\n/**\n * Gives the domain of a field of a Schema, by its path with dots. A path that\n * the Schema does not name gives `null`, as a condition reads such a field.\n *\n * @stability stable\n * @category getters\n * @since 1.0.0\n */\nexport const domainOf = (schema: Schema.Top, path: string): FieldDomain =>\n\t// No cache here: a search keeps the cells of each field for itself. A path\n\t// that is too long to walk may hold any value.\n\tisTooLong(path)\n\t\t? anyDomain\n\t\t: domainAt(schema.ast, path.split(\".\"), 0, new Map())\n\n/**\n * Checks the names of the top fields of a resource at once, when it is made.\n * The names of nested fields are checked when the descriptor is made.\n */\nconst checkFields = (\n\tkind: string,\n\toptions: Options<ReadonlyArray<string>, Schema.Struct.Fields>,\n): void => {\n\t// The kind of a value comes from its `_tag`. A field with this name could\n\t// give a value another kind, so it is a defect.\n\tif (Object.hasOwn(options.fields, \"_tag\")) {\n\t\tthrow new Error(`The resource \"${kind}\" may not have a field \"_tag\"`)\n\t}\n\tArr.map(Object.keys(options.fields), (name) => {\n\t\tif (name.includes(\".\")) {\n\t\t\tthrow new Error(`A field name may not have a dot: \"${name}\"`)\n\t\t}\n\t\tif (name === \"\") {\n\t\t\tthrow new Error(\"A field name may not be empty\")\n\t\t}\n\t})\n}\n\n/**\n * Gives a value that is made on first use, and then kept. The descriptor of a\n * resource reads its Schema, and a recursive Schema refers to the resource\n * class, so it can not be read while the class is made. The cell belongs to\n * one resource.\n */\nconst lazy = <A>(make: () => A): (() => A) => {\n\tconst cell: { value?: A } = {}\n\treturn () => {\n\t\tif (!(\"value\" in cell)) {\n\t\t\tcell.value = make()\n\t\t}\n\t\treturn cell.value as A\n\t}\n}\n\n/**\n * Checks each part of the path of a resource: a string, or a reference to a\n * top-level field of the resource. A reference to another field would read\n * nothing, and a rule on the path could then match a value by mistake.\n */\nconst checkPath = (\n\tkind: string,\n\tfields: Schema.Struct.Fields,\n\tpath: ReadonlyArray<unknown>,\n): ReadonlyArray<PathSegment> =>\n\t// `Array.from` gives `undefined` for a hole of a sparse array, so the check\n\t// sees each place.\n\tArr.map(Array.from(path), (segment): PathSegment => {\n\t\tif (typeof segment === \"string\") {\n\t\t\treturn segment\n\t\t}\n\t\tif (\n\t\t\thasProperty(segment, \"_tag\") &&\n\t\t\tsegment._tag === \"Field\" &&\n\t\t\thasProperty(segment, \"field\") &&\n\t\t\ttypeof segment.field === \"string\" &&\n\t\t\tObject.hasOwn(fields, segment.field)\n\t\t) {\n\t\t\treturn { _tag: \"Field\", field: segment.field }\n\t\t}\n\t\tthrow new globalThis.Error(\n\t\t\t`A part of the path of \"${kind}\" is not a string or a field of the resource`,\n\t\t)\n\t})\n\n/**\n * Copies the options of a resource. The descriptor is made later, when it is\n * first read, so a change to the objects of the caller before then must not\n * change it: the Schema of the values and the descriptor must agree.\n */\nconst snapshot = (\n\toptions: Options<ReadonlyArray<string>, Schema.Struct.Fields>,\n): Options<ReadonlyArray<string>, Schema.Struct.Fields> => ({\n\t...options,\n\tactions: [...options.actions],\n\tfields: { ...options.fields },\n})\n\nconst makeDescriptor = (\n\tkind: string,\n\toptions: Options<ReadonlyArray<string>, Schema.Struct.Fields>,\n): Descriptor => {\n\tconst refs: Record<string, FieldRef<string>> = Object.fromEntries(\n\t\tArr.map(Object.keys(options.fields), (key) => [\n\t\t\tkey,\n\t\t\t{ _tag: \"Field\", field: key },\n\t\t]),\n\t)\n\tconst visits = walkFields(Schema.Struct(options.fields).ast)\n\tconst leaves = Arr.filter(visits, (visit) => visit.leaf)\n\t// In a union, one path may hold a scalar in one branch and a struct in\n\t// another. Such a path holds more than one value, so it is open too.\n\tconst structs = HashSet.fromIterable(\n\t\tArr.map(\n\t\t\tArr.filter(visits, (visit) => !visit.leaf),\n\t\t\t(visit) => visit.path,\n\t\t),\n\t)\n\tconst open = Arr.filter(\n\t\tleaves,\n\t\t(visit) =>\n\t\t\tshapeOf(visit.type) !== \"scalar\" || HashSet.has(structs, visit.path),\n\t)\n\treturn new ResourceDescriptor({\n\t\tkind,\n\t\tactions: [...options.actions],\n\t\tpath:\n\t\t\toptions.path === undefined\n\t\t\t\t? undefined\n\t\t\t\t: checkPath(kind, options.fields, options.path(refs)),\n\t\tfieldPaths: Arr.dedupe(Arr.map(leaves, (visit) => visit.path)),\n\t\topenPaths: Arr.dedupe(Arr.map(open, (visit) => visit.path)),\n\t\tschema: Schema.TaggedStruct(kind, options.fields),\n\t})\n}\n\n/**\n * The type of a class made by {@link Class}.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Class<\n\tSelf,\n\tKind extends string,\n\tActions extends ReadonlyArray<string>,\n\tFields extends Schema.Struct.Fields,\n> = Schema.Class<Self, Schema.TaggedStruct<Kind, Fields>, {}> &\n\tResource<\n\t\tKind,\n\t\tActions[number],\n\t\tSchema.Struct.Type<Fields>,\n\t\tSelf & { readonly _tag: Kind }\n\t> & {\n\t\treadonly kind: Kind\n\t\treadonly actions: Actions\n\t}\n\n/**\n * Makes a resource as a Schema class. Use it in the same way as\n * `Schema.TaggedClass`.\n *\n * @example\n * ```ts\n * import { Schema } from \"effect\"\n * import { Resource } from \"@nmnmcc/ability\"\n *\n * class Bot extends Resource.Class<Bot>()(\"Bot\", {\n * actions: [\"read\", \"update\"],\n * fields: {\n * id: Schema.String,\n * ownerUserId: Schema.NullOr(Schema.String),\n * },\n * path: (f) => [\"user\", f.ownerUserId, \"bot\", f.id],\n * }) {}\n *\n * const bot = new Bot({ id: \"b1\", ownerUserId: \"u1\" })\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const Class: <Self = never>(\n\tidentifier?: string,\n) => <\n\tconst Kind extends string,\n\tconst Actions extends ReadonlyArray<string>,\n\tconst Fields extends Schema.Struct.Fields,\n>(\n\tkind: Kind,\n\toptions: Options<Actions, Fields>,\n) => [Self] extends [never]\n\t? \"Missing `Self` type: use Resource.Class<Self>()(...)\"\n\t: Class<Self, Kind, Actions, Fields> = ((identifier?: string) =>\n\t(\n\t\tkind: string,\n\t\tinput: Options<ReadonlyArray<string>, Schema.Struct.Fields>,\n\t) => {\n\t\tconst options = snapshot(input)\n\t\tcheckFields(kind, options)\n\t\tconst Base = Schema.TaggedClass<any>(identifier)(kind, options.fields)\n\t\tconst descriptor = lazy(() => makeDescriptor(kind, options))\n\t\treturn class extends Base {\n\t\t\tstatic get descriptor() {\n\t\t\t\treturn descriptor()\n\t\t\t}\n\t\t\tstatic readonly kind = kind\n\t\t\tstatic readonly actions = [...options.actions]\n\t\t}\n\t}) as never\n\n/**\n * A resource made by {@link make}. Its values are plain objects.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Struct<\n\tKind extends string,\n\tActions extends ReadonlyArray<string>,\n\tFields extends Schema.Struct.Fields,\n> extends Resource<\n\tKind,\n\tActions[number],\n\tSchema.Struct.Type<Fields>,\n\tSchema.Struct.Type<Fields> & { readonly _tag: Kind }\n> {\n\treadonly kind: Kind\n\treadonly actions: Actions\n\treadonly schema: Schema.TaggedStruct<Kind, Fields>\n\t/** Makes a value. It puts the `_tag` field on the value for you. */\n\treadonly make: (\n\t\tinput: Schema.Struct.Type<Fields>,\n\t) => Schema.Struct.Type<Fields> & { readonly _tag: Kind }\n}\n\n/**\n * Makes a resource from plain fields. Its values are plain objects with a\n * `_tag` field.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const make: <\n\tconst Kind extends string,\n\tconst Actions extends ReadonlyArray<string>,\n\tconst Fields extends Schema.Struct.Fields,\n>(\n\tkind: Kind,\n\toptions: Options<Actions, Fields>,\n) => Struct<Kind, Actions, Fields> = ((\n\tkind: string,\n\tinput: Options<ReadonlyArray<string>, Schema.Struct.Fields>,\n) => {\n\tconst options = snapshot(input)\n\tcheckFields(kind, options)\n\tconst schema = Schema.TaggedStruct(kind, options.fields)\n\tconst descriptor = lazy(() => makeDescriptor(kind, options))\n\treturn {\n\t\tget descriptor() {\n\t\t\treturn descriptor()\n\t\t},\n\t\tkind,\n\t\tactions: [...options.actions],\n\t\tschema,\n\t\tmake: (input: object) => schema.make(input as never),\n\t}\n}) as never\n\n/**\n * Tests if a value is a resource.\n *\n * @stability stable\n * @category guards\n * @since 0.3.0\n */\nexport const isResource = (u: unknown): u is Any =>\n\thasProperty(u, \"descriptor\") && u.descriptor instanceof ResourceDescriptor\n\n/**\n * Gets the runtime data of a resource.\n *\n * @stability stable\n * @category getters\n * @since 0.3.0\n */\nexport const descriptor = (resource: Any): Descriptor => resource.descriptor\n\n/**\n * Gives the kind name of a resource value, from its `_tag` field.\n *\n * @stability stable\n * @category getters\n * @since 1.0.0\n */\nexport const kindOf = (value: unknown): string | undefined =>\n\thasProperty(value, \"_tag\") && typeof value._tag === \"string\"\n\t\t? value._tag\n\t\t: undefined\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgLA,IAAM,qBAAN,cAAiCA,QAAsB,CAAC;;AAGxD,MAAM,kBAAkB,cACvB,IAAI,OAAO,YAAY,YACtB,OAAO,YAAY,YACnB,YAAY,QACZ,YAAY,OAAO,YAChB,OAAO,KAAK,CAAC,SAAS,OAAO,eAAe,OAAO,CAAC,CAAU,IAC9D,OAAO,KAAK,CAChB;;;;;;;;;;;;AAaD,MAAM,kBAAkB,QAAmD;CAC1E,MAAM,OAAgB,IAAI,cAAc;CACxC,IAAI,OAAO,SAAS,YACnB;CAED,IAAI;EACH,MAAM,OAAgB,KAAK,IAAI,cAAc;EAC7C,MAAM,SACL,YAAY,MAAM,MAAM,KACxB,YAAY,KAAK,MAAM,gBAAgB,KACvC,YAAY,KAAK,KAAK,gBAAgB,QAAQ,IAC3C,KAAK,KAAK,eAAe,SACzB,KAAA;EACJ,MAAM,QACL,YAAY,QAAQ,WAAW,KAAK,OAAO,OAAO,cAAc,aAC7D,OAAO,UAAU,CAAC,CAAC,IACnB,KAAA;EACJ,OAAO,SAAS,KAAK,IAAI,OAAO,eAAe,KAAK,IAAI,KAAA;CACzD,QAAQ;EACP;CACD;AACD;;;;;;;;;;;;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K;CAC9B,YAAY,MAAM,OAAO;CACzB,MAAM,OAAO,OAAO,YAAiB,UAAU,CAAC,CAAC,MAAM,QAAQ,MAAM;CACrE,MAAM,aAAa,WAAW,eAAe,MAAM,OAAO,CAAC;CAC3D,OAAO,cAAc,KAAK;EACzB,WAAW,aAAa;GACvB,OAAO,WAAW;EACnB;EACA,OAAgB,OAAO;EACvB,OAAgB,UAAU,CAAC,GAAG,QAAQ,OAAO;CAC9C;AACD;;;;;;;;;AAoCD,MAAa,SAQZ,MACA,UACI;CACJ,MAAM,UAAU,SAAS,KAAK;CAC9B,YAAY,MAAM,OAAO;CACzB,MAAM,SAAS,OAAO,aAAa,MAAM,QAAQ,MAAM;CACvD,MAAM,aAAa,WAAW,eAAe,MAAM,OAAO,CAAC;CAC3D,OAAO;EACN,IAAI,aAAa;GAChB,OAAO,WAAW;EACnB;EACA;EACA,SAAS,CAAC,GAAG,QAAQ,OAAO;EAC5B;EACA,OAAO,UAAkB,OAAO,KAAK,KAAc;CACpD;AACD;;;;;;;;AASA,MAAa,cAAc,MAC1B,YAAY,GAAG,YAAY,KAAK,EAAE,sBAAsB;;;;;;;;AASzD,MAAa,cAAc,aAA8B,SAAS;;;;;;;;AASlE,MAAa,UAAU,UACtB,YAAY,OAAO,MAAM,KAAK,OAAO,MAAM,SAAS,WACjD,MAAM,OACN,KAAA"}
package/dist/Rule.d.ts CHANGED
@@ -1,44 +1,48 @@
1
- import { Kind } from "./Resource.js";
2
- import { Any as Any$1, Ast, Builder as Builder$1, Condition, Error as Error$1, FieldPath, OpaqueOf as OpaqueOf$1, Services as Services$1, Variance } from "./Condition.js";
3
- import { ActionOf, Any as Any$2, AnyAction, AnyValue, DataOf, Kind as Kind$1, Meta, Principal, Resources, ValueOf } from "./Domain.js";
4
- import * as Equal from "effect/Equal";
5
- import * as Inspectable from "effect/Inspectable";
1
+ import { Descriptor, Kind } from "./Resource.js";
2
+ import { Any as Any$1, Builder as Builder$1, Checked, Condition, Error as Error$1, FieldSelector, OpaqueOf as OpaqueOf$1, Reads, ReadsOf, Services as Services$1, Variance } from "./Condition.js";
3
+ import { ActionOf, Any as Any$2, AnyAction, AnyValue, CommonAction, DataOf, Kind as Kind$1, Meta, Principal, Resources, ValueOf } from "./Domain.js";
6
4
  import * as Pipeable from "effect/Pipeable";
7
5
  declare namespace Rule_d_exports {
8
- export { ActionFor, Any, Builder, DataFor, Error, FieldFor, KindOf, OpaqueOf, Options, Rule, Services, Target, TypeId, ValueFor, builder, isRule, matchesField };
6
+ export { ActionFor, ActionForTargets, Any, Builder, ConditionFor, DataFor, Error, FieldFor, KindOf, OpaqueOf, Options, Rule, Services, Shape, Target, TargetOf, ValueFor, builder, domainOf, isRule, make, matchesField, matchesInside, matchesTarget };
9
7
  }
10
8
  /**
9
+ * A rule. `E`, `R` and `O` come from its condition. See
10
+ * `Condition.Condition`. `D` is the domain of the rule. A predicate reads the
11
+ * values and the principal of its domain, so a rule may go only into a policy
12
+ * of its own domain. A rule from {@link make} has the domain `any`. `I` is
13
+ * what the predicates of its condition read. See `Condition.Reads`.
14
+ *
11
15
  * @stability stable
12
- * @category type IDs
13
- * @since 0.3.0
14
- */
15
- export declare const TypeId: "~@nmnmcc/ability/Rule";
16
- /**
17
- * @stability stable
18
- * @category type IDs
16
+ * @category models
19
17
  * @since 0.3.0
20
18
  */
21
- export type TypeId = typeof TypeId;
19
+ export interface Rule<E = never, R = never, O = never, D = any, I = unknown> extends Shape<E, R, O, I>, Pipeable.Pipeable {
20
+ readonly "~Rule": Variance<E, R, O>;
21
+ readonly "~Domain": (domain: D) => D;
22
+ [Symbol.iterator](): Generator<Rule<E, R, O, D, I>, Rule<E, R, O, D, I>, unknown>;
23
+ }
22
24
  /**
23
- * A rule. `E`, `R` and `O` come from its condition. See
24
- * `Condition.Condition`.
25
+ * The data of a rule.
25
26
  *
26
27
  * @stability stable
27
28
  * @category models
28
- * @since 0.3.0
29
+ * @since 1.0.0
29
30
  */
30
- export interface Rule<E = never, R = never, O = never> extends Equal.Equal, Inspectable.Inspectable, Pipeable.Pipeable {
31
- readonly [TypeId]: TypeId;
31
+ export interface Shape<E = never, R = never, O = never, I = unknown> {
32
32
  readonly _tag: "Allow" | "Deny";
33
33
  readonly actions: ReadonlyArray<string>;
34
34
  readonly resources: ReadonlyArray<string>;
35
- readonly when?: Ast;
35
+ readonly when?: Condition<E, R, O, I>;
36
36
  readonly fields?: ReadonlyArray<string>;
37
37
  readonly reason?: string;
38
38
  readonly id?: string;
39
39
  readonly meta?: unknown;
40
- readonly "~Rule"?: Variance<E, R, O>;
41
- [Symbol.iterator](): Generator<Rule<E, R, O>, Rule<E, R, O>, unknown>;
40
+ /**
41
+ * The domain of the builder that made the rule. Two domains may have the
42
+ * same types but other paths, so the types can not tell them apart. It is
43
+ * not in the JSON form of a rule.
44
+ */
45
+ readonly domain?: Any$2;
42
46
  }
43
47
  /**
44
48
  * Any rule.
@@ -47,7 +51,7 @@ export interface Rule<E = never, R = never, O = never> extends Equal.Equal, Insp
47
51
  * @category models
48
52
  * @since 0.3.0
49
53
  */
50
- export type Any = Rule<any, any, any>;
54
+ export type Any = Rule<any, any, any, any, never>;
51
55
  /**
52
56
  * The error type of a rule.
53
57
  *
@@ -102,6 +106,29 @@ export type KindOf<T> = T extends string ? T : Kind<T>;
102
106
  * @since 0.3.0
103
107
  */
104
108
  export type ActionFor<D, K> = "*" | ("*" extends K ? AnyAction<D> : ActionOf<D, Extract<K, string>>);
109
+ /**
110
+ * The targets in the resource argument of a rule: the one target, or the
111
+ * targets of a list.
112
+ *
113
+ * @stability stable
114
+ * @category utility types
115
+ * @since 1.0.0
116
+ */
117
+ export type TargetOf<Res> = Res extends ReadonlyArray<infer X> ? X : Res;
118
+ /**
119
+ * The actions that a rule may use for its resource argument. A list of
120
+ * resources may use an action of any of them. One target with a union type
121
+ * may use only an action of every kind in the union, because its value may be
122
+ * any one of them. When the argument may be a list or one target, the rule
123
+ * may use only an action that each of these shapes allows.
124
+ *
125
+ * @stability stable
126
+ * @category utility types
127
+ * @since 1.0.0
128
+ */
129
+ export type ActionForTargets<D, Res> = (Res extends ReadonlyArray<infer X> ? (action: ActionFor<D, KindOf<X>>) => void : (action: ActionForTarget<D, Res>) => void) extends ((action: infer A) => void) ? A : never;
130
+ /** The actions for one target that is not a list. */
131
+ type ActionForTarget<D, Res> = "*" | ("*" extends KindOf<Res> ? AnyAction<D> : CommonAction<D, Extract<KindOf<Res>, string>>);
105
132
  /**
106
133
  * The data type of the kinds `K`. For `"*"` it has no fields.
107
134
  *
@@ -125,7 +152,16 @@ export type ValueFor<D, K> = "*" extends K ? AnyValue<D> : ValueOf<D, Extract<K,
125
152
  * @category models
126
153
  * @since 0.3.0
127
154
  */
128
- export type FieldFor<D, K> = FieldPath<DataFor<D, K>> | `${string}*${string}`;
155
+ export type FieldFor<D, K> = FieldSelector<DataFor<D, K>> | `${string}*${string}`;
156
+ /**
157
+ * A condition that a rule for the kinds `K` may have. Its predicates may read
158
+ * only the values of these kinds and the principal of the domain.
159
+ *
160
+ * @stability stable
161
+ * @category models
162
+ * @since 1.0.0
163
+ */
164
+ export type ConditionFor<D, K> = Condition<any, any, any, Reads<ValueFor<D, K>, Principal<D>>>;
129
165
  /**
130
166
  * The options of a rule.
131
167
  *
@@ -135,7 +171,7 @@ export type FieldFor<D, K> = FieldPath<DataFor<D, K>> | `${string}*${string}`;
135
171
  */
136
172
  export interface Options<D, K, C extends Any$1> {
137
173
  /** The condition. It gets a builder with the types of the resource. */
138
- readonly when?: (builder: Builder$1<DataFor<D, K>, ValueFor<D, K>, Principal<D>>) => C;
174
+ readonly when?: (builder: Builder$1<DataFor<D, K>, ValueFor<D, K>, Principal<D>>) => C & Checked<C>;
139
175
  readonly fields?: ReadonlyArray<FieldFor<D, K>>;
140
176
  readonly reason?: string;
141
177
  readonly id?: string;
@@ -150,9 +186,28 @@ type SingleOrArray<A> = A | ReadonlyArray<A>;
150
186
  * @since 0.3.0
151
187
  */
152
188
  export interface Builder<D> {
153
- readonly allow: <const T extends Target<D>, const A extends ActionFor<D, KindOf<T>>, const C extends Any$1 = Condition>(action: SingleOrArray<A>, resource: SingleOrArray<T>, options?: Options<D, KindOf<T>, C>) => Rule<Error$1<C>, Services$1<C>, OpaqueOf$1<C>>;
154
- readonly deny: <const T extends Target<D>, const A extends ActionFor<D, KindOf<T>>, const C extends Any$1 = Condition>(action: SingleOrArray<A>, resource: SingleOrArray<T>, options?: Options<D, KindOf<T>, C>) => Rule<Error$1<C>, Services$1<C>, OpaqueOf$1<C>>;
189
+ readonly allow: <const Res extends SingleOrArray<Target<D>>, const A extends ActionForTargets<D, Res>, const C extends ConditionFor<D, KindOf<TargetOf<Res>>> = Condition>(action: SingleOrArray<A>, resource: Res, options?: Options<D, KindOf<TargetOf<Res>>, C>) => Rule<Error$1<C>, Services$1<C>, OpaqueOf$1<C>, D, ReadsOf<C>>;
190
+ readonly deny: <const Res extends SingleOrArray<Target<D>>, const A extends ActionForTargets<D, Res>, const C extends ConditionFor<D, KindOf<TargetOf<Res>>> = Condition>(action: SingleOrArray<A>, resource: Res, options?: Options<D, KindOf<TargetOf<Res>>, C>) => Rule<Error$1<C>, Services$1<C>, OpaqueOf$1<C>, D, ReadsOf<C>>;
155
191
  }
192
+ /**
193
+ * Makes a rule from its data. It does not check the data against a domain.
194
+ * Use {@link builder} for rules with types, or `Policy.schema` for rules from
195
+ * JSON.
196
+ *
197
+ * @stability stable
198
+ * @category constructors
199
+ * @since 1.0.0
200
+ */
201
+ export declare const make: <E = never, R = never, O = never, I = unknown>(data: Shape<E, R, O, I>) => Rule<E, R, O, any, I>;
202
+ /**
203
+ * Gives the domain of the builder that made a rule. A rule from {@link make}
204
+ * has none, unless its data gives one.
205
+ *
206
+ * @stability stable
207
+ * @category getters
208
+ * @since 1.0.0
209
+ */
210
+ export declare const domainOf: (rule: Any) => Any$2 | undefined;
156
211
  /**
157
212
  * Makes a rule builder for a domain.
158
213
  *
@@ -185,5 +240,36 @@ export declare const isRule: (u: unknown) => u is Any;
185
240
  * @since 0.3.0
186
241
  */
187
242
  export declare const matchesField: (pattern: string, field: string) => boolean;
243
+ /**
244
+ * Tests if a field pattern may match a field inside `field`, such as
245
+ * `settings.secret` inside `settings`, or `settings.` for the empty key of a
246
+ * record.
247
+ *
248
+ * @stability stable
249
+ * @category predicates
250
+ * @since 1.0.0
251
+ */
252
+ export declare const matchesInside: (pattern: string, field: string) => boolean;
253
+ /**
254
+ * Tests the parts of a rule that do not need the resource value: the action,
255
+ * the kind and the field.
256
+ *
257
+ * A rule with an empty list of fields covers no request. A rule with fields
258
+ * covers a request with no field only when it is an allow rule. So "may update some fields" is a yes. A deny rule for some fields does
259
+ * not stop a request for the whole value. With the `descriptor` of the kind,
260
+ * such an allow rule covers the request only when one of its patterns may
261
+ * match a field of the kind. A grant of fields that the kind does not have is
262
+ * not a grant of some fields.
263
+ *
264
+ * @stability stable
265
+ * @category predicates
266
+ * @since 1.0.0
267
+ */
268
+ export declare const matchesTarget: (rule: Any, target: {
269
+ readonly action: string;
270
+ readonly kind: string;
271
+ readonly field?: string | undefined;
272
+ readonly descriptor?: Descriptor | undefined;
273
+ }) => boolean;
188
274
  export { Rule_d_exports };
189
275
  //# sourceMappingURL=Rule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Rule.d.ts","names":["Condition.Ast","Condition.Variance","Domain.Kind","Domain.Resources","Resource.Kind","Domain.AnyAction","Domain.ActionOf","Domain.DataOf","Domain.AnyValue","Domain.ValueOf","Condition.FieldPath","Condition.Any","Domain.Principal","Condition.Builder","Domain.Meta","Condition.Condition","Condition.Error","Condition.Services","Condition.OpaqueOf","Domain.Any"],"sources":["../src/Rule.ts"],"mappings":";;;;;;;;;;;;;;qBAkCa;;;;;;YAOD,gBAAgB;;;;;;;;;iBAUX,KAAK,WAAW,WAAW,mBACnC,MAAM,OAAO,YAAY,aAAa,SAAS;YAC7C,SAAS;WACV;WACA,SAAS;WACT,WAAW;WACX,OAAOA;WACP,SAAS;WACT;WACA;WACA;WACA,UA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AQ,GAAG,OAAO,IAAI,OAC5B,KAAKC,QAAgB,IAAIC,WAAmB,IAAIC,WAAmB;;;;;;;;;;;;;;;;;qBAkB5D,UAAU,UAAUC,OAAY,QAAQ,MAAM,QAAQ;;;;;;;;qBAUtD,SAAS,eAAe,KAAK;;;;;;;;qBAS7B,eAAe,iBAAiB"}
1
+ {"version":3,"file":"Rule.d.ts","names":["Condition.Variance","Condition.Condition","Domain.Any","Domain.Kind","Domain.Resources","Resource.Kind","Domain.AnyAction","Domain.ActionOf","Domain.CommonAction","Domain.DataOf","Domain.AnyValue","Domain.ValueOf","Condition.FieldSelector","Domain.Principal","Condition.Reads","Condition.Any","Condition.Builder","Condition.Checked","Domain.Meta","Condition.Error","Condition.Services","Condition.OpaqueOf","Condition.ReadsOf","Resource.Descriptor"],"sources":["../src/Rule.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBAwCiB,KAAK,WAAW,WAAW,WAAW,SAAS,qBACvD,MAAM,GAAG,GAAG,GAAG,IAAI,SAAS;WAC3B,SAASA,SAAmB,GAAG,GAAG;WAClC,YAAY,QAAQ,MAAM;GAClC,OAAO,aAAa,UACpB,KAAK,GAAG,GAAG,GAAG,GAAG,IACjB,KAAK,GAAG,GAAG,GAAG,GAAG;;;;;;;;;iBAYF,MAAM,WAAW,WAAW,WAAW;WAC9C;WACA,SAAS;WACT,WAAW;WACX,OAAOC,UAAoB,GAAG,GAAG,GAAG;WACpC,SAAS;WACT;WACA;WACA;;;;;;WAMA,SAASC;;;;;;;;;YAYP,MAAM;;;;;;;;YASN,MAAM,KAAK;WACb,UAAUF,eAAyB,SAAS,UAAU;IAE7D;;;;;;;;YAUS,SAAS,KAAK;WAChB,UAAUA,eAAyB,UAAU,SAAS;IAE7D;;;;;;;;YAUS,SAAS,KAAK;WAChB,UAAUA,eAAyB,UAAU,UAAU;IAE9D;;;;;;;;YAUS,OAAO,KAAKG,OAAY,KAAKC,UAAiB;;;;;;;;YAS9C,OAAO,KAAK,mBAAmB,IAA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