|
| 1 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 2 | +import type { Cache } from '../cache.ts'; |
1 | 3 | import type { ResourceKey } from '../identifier.ts'; |
| 4 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 5 | +import type { Operation } from './operations.ts'; |
2 | 6 |
|
3 | 7 | export interface AddToResourceRelationshipMutation { |
4 | 8 | op: 'add'; |
@@ -43,27 +47,51 @@ export interface ReplaceRelatedRecordsMutation { |
43 | 47 | index?: number; |
44 | 48 | } |
45 | 49 |
|
| 50 | +/** |
| 51 | + * Reorders the local (uncommitted) state of a `to-many` relationship. |
| 52 | + */ |
46 | 53 | export interface SortRelatedRecordsMutation { |
| 54 | + /** |
| 55 | + * The name of the mutation |
| 56 | + */ |
47 | 57 | op: 'sortRelatedRecords'; |
| 58 | + /** |
| 59 | + * The cache key for the resource whose relationship is being reordered |
| 60 | + */ |
48 | 61 | record: ResourceKey; |
| 62 | + /** |
| 63 | + * The name of the relationship to reorder |
| 64 | + */ |
49 | 65 | field: string; |
| 66 | + /** |
| 67 | + * The relationship's members in their new order |
| 68 | + */ |
50 | 69 | value: ResourceKey[]; |
51 | 70 | } |
52 | | -// A Mutation is an action that updates |
53 | | -// the local state of the Cache in some |
54 | | -// manner. |
55 | | -// Most Mutations are in theory also |
56 | | -// Operations; with the difference being |
57 | | -// that the change should be applied as |
58 | | -// "local" or "dirty" state instead of |
59 | | -// as "remote" or "clean" state. |
60 | | -// |
61 | | -// Note: this RFC does not publicly surface |
62 | | -// any of the mutations listed here as |
63 | | -// "operations", though the (private) Graph |
64 | | -// already expects and utilizes these. |
65 | | -// and we look forward to an RFC that makes |
66 | | -// the Graph a fully public API. |
| 71 | + |
| 72 | +/** |
| 73 | + * A `Mutation` is an action that updates the local (uncommitted or "dirty") |
| 74 | + * state of the {@link Cache} in some manner. |
| 75 | + * |
| 76 | + * Most Mutations are in theory also {@link Operation | Operations}; the |
| 77 | + * difference is that the change should be applied as local/dirty state |
| 78 | + * instead of as remote/clean state. |
| 79 | + * |
| 80 | + * Mutations are applied via {@link Cache.mutate}. |
| 81 | + * |
| 82 | + * See also: |
| 83 | + * - {@link ReplaceRelatedRecordsMutation} |
| 84 | + * - {@link ReplaceRelatedRecordMutation} |
| 85 | + * - {@link RemoveFromResourceRelationshipMutation} |
| 86 | + * - {@link AddToResourceRelationshipMutation} |
| 87 | + * - {@link SortRelatedRecordsMutation} |
| 88 | + * |
| 89 | + * @privateRemarks |
| 90 | + * Note: this RFC does not publicly surface any of the mutations listed |
| 91 | + * here as "operations", though the (private) Graph already expects and |
| 92 | + * utilizes these, and we look forward to an RFC that makes the Graph a |
| 93 | + * fully public API. |
| 94 | + */ |
67 | 95 | export type Mutation = |
68 | 96 | | ReplaceRelatedRecordsMutation |
69 | 97 | | ReplaceRelatedRecordMutation |
|
0 commit comments