| | | 1 | | namespace Elsa.Authorization; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// The recommended core verbs. Modules SHOULD reuse these wherever the meaning fits, so that a role |
| | | 5 | | /// editor reads consistently across resources. They are a convention, not a closed set: a module that |
| | | 6 | | /// needs a verb outside this list declares it, and the catalog marks it as non-core so a reviewer can |
| | | 7 | | /// spot a needless synonym. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <remarks> |
| | | 10 | | /// A resource declares either <see cref="Create"/> + <see cref="Update"/>, or <see cref="Write"/> — |
| | | 11 | | /// never both. Which one depends on whether the module's API separates the operations. Never-both is |
| | | 12 | | /// what stops <see cref="Write"/> acting as an aggregate: within any one resource there is no ambiguity |
| | | 13 | | /// about which verb an endpoint requires, so no verb needs to imply another. |
| | | 14 | | /// </remarks> |
| | | 15 | | public static class CoreVerbs |
| | | 16 | | { |
| | | 17 | | /// <summary>Read, list, query, inspect, export.</summary> |
| | | 18 | | public const string View = "view"; |
| | | 19 | | |
| | | 20 | | /// <summary>Bring a new record into existence.</summary> |
| | | 21 | | public const string Create = "create"; |
| | | 22 | | |
| | | 23 | | /// <summary>Modify an existing record.</summary> |
| | | 24 | | public const string Update = "update"; |
| | | 25 | | |
| | | 26 | | /// <summary>Create or modify, where the API does not separate the two.</summary> |
| | | 27 | | public const string Write = "write"; |
| | | 28 | | |
| | | 29 | | /// <summary>Remove a record.</summary> |
| | | 30 | | public const string Delete = "delete"; |
| | | 31 | | |
| | | 32 | | /// <summary>Run, dispatch, or invoke against a live system.</summary> |
| | | 33 | | public const string Execute = "execute"; |
| | | 34 | | |
| | | 35 | | /// <summary>The recommended core set, in declaration order.</summary> |
| | 175 | 36 | | public static IReadOnlyList<string> All { get; } = [View, Create, Update, Write, Delete, Execute]; |
| | | 37 | | |
| | | 38 | | /// <summary>Whether <paramref name="verb"/> belongs to the recommended core set.</summary> |
| | 173 | 39 | | public static bool IsCore(string verb) => All.Contains(verb, StringComparer.Ordinal); |
| | | 40 | | } |