|
10 | 10 |
|
11 | 11 | namespace JsonApiDotNetCore.Services
|
12 | 12 | {
|
13 |
| - public interface IJsonApiContext |
| 13 | + public interface IJsonApiApplication |
14 | 14 | {
|
15 | 15 | JsonApiOptions Options { get; set; }
|
16 |
| - IJsonApiContext ApplyContext<T>(object controller); |
17 | 16 | IContextGraph ContextGraph { get; set; }
|
18 |
| - ContextEntity RequestEntity { get; set; } |
19 |
| - string BasePath { get; set; } |
20 |
| - QuerySet QuerySet { get; set; } |
21 |
| - bool IsRelationshipData { get; set; } |
| 17 | + } |
| 18 | + |
| 19 | + public interface IQueryRequest |
| 20 | + { |
22 | 21 | List<string> IncludedRelationships { get; set; }
|
23 |
| - bool IsRelationshipPath { get; } |
| 22 | + QuerySet QuerySet { get; set; } |
24 | 23 | PageManager PageManager { get; set; }
|
25 |
| - IMetaBuilder MetaBuilder { get; set; } |
26 |
| - IGenericProcessorFactory GenericProcessorFactory { get; set; } |
| 24 | + } |
| 25 | + |
| 26 | + public interface IUpdateRequest |
| 27 | + { |
27 | 28 | Dictionary<AttrAttribute, object> AttributesToUpdate { get; set; }
|
28 | 29 | Dictionary<RelationshipAttribute, object> RelationshipsToUpdate { get; set; }
|
| 30 | + } |
| 31 | + |
| 32 | + public interface IJsonApiRequest : IJsonApiApplication, IUpdateRequest, IQueryRequest |
| 33 | + { |
| 34 | + /// <summary> |
| 35 | + /// The request namespace. This may be an absolute or relative path |
| 36 | + /// depending upon the configuration. |
| 37 | + /// </summary> |
| 38 | + /// <example> |
| 39 | + /// Absolute: https://example.com/api/v1 |
| 40 | + /// |
| 41 | + /// Relative: /api/v1 |
| 42 | + /// </example> |
| 43 | + string BasePath { get; set; } |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Stores information to set relationships for the request resource. |
| 47 | + /// These relationships must already exist and should not be re-created. |
| 48 | + /// By default, it is the responsibility of the repository to use the |
| 49 | + /// relationship pointers to persist the relationship. |
| 50 | + /// |
| 51 | + /// The expected use case is POST-ing or PATCH-ing an entity with HasMany |
| 52 | + /// relaitonships: |
| 53 | + /// <code> |
| 54 | + /// { |
| 55 | + /// "data": { |
| 56 | + /// "type": "photos", |
| 57 | + /// "attributes": { |
| 58 | + /// "title": "Ember Hamster", |
| 59 | + /// "src": "http://example.com/images/productivity.png" |
| 60 | + /// }, |
| 61 | + /// "relationships": { |
| 62 | + /// "tags": { |
| 63 | + /// "data": [ |
| 64 | + /// { "type": "tags", "id": "2" }, |
| 65 | + /// { "type": "tags", "id": "3" } |
| 66 | + /// ] |
| 67 | + /// } |
| 68 | + /// } |
| 69 | + /// } |
| 70 | + /// } |
| 71 | + /// </code> |
| 72 | + /// </summary> |
| 73 | + HasManyRelationshipPointers HasManyRelationshipPointers { get; } |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// If the request is a bulk json:api v1.1 operations request. |
| 77 | + /// This is determined by the ` |
| 78 | + /// <see cref="JsonApiDotNetCore.Serialization.JsonApiDeSerializer" />` class. |
| 79 | + /// |
| 80 | + /// See [json-api/1254](https://github.com/json-api/json-api/pull/1254) for details. |
| 81 | + /// </summary> |
| 82 | + bool IsBulkOperationRequest { get; set; } |
| 83 | + |
| 84 | + /// <summary> |
| 85 | + /// The `<see cref="ContextEntity" />`for the target route. |
| 86 | + /// </summary> |
| 87 | + /// |
| 88 | + /// <example> |
| 89 | + /// For a `GET /articles` request, `RequestEntity` will be set |
| 90 | + /// to the `Article` resource representation on the `JsonApiContext`. |
| 91 | + /// </example> |
| 92 | + ContextEntity RequestEntity { get; set; } |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// The concrete type of the controller that was activated by the MVC routing middleware |
| 96 | + /// </summary> |
29 | 97 | Type ControllerType { get; set; }
|
| 98 | + |
| 99 | + /// <summary> |
| 100 | + /// The json:api meta data at the document level |
| 101 | + /// </summary> |
30 | 102 | Dictionary<string, object> DocumentMeta { get; set; }
|
31 |
| - bool IsBulkOperationRequest { get; set; } |
32 |
| - HasManyRelationshipPointers HasManyRelationshipPointers { get; } |
33 | 103 |
|
| 104 | + /// <summary> |
| 105 | + /// If the request is on the `{id}/relationships/{relationshipName}` route |
| 106 | + /// </summary> |
| 107 | + bool IsRelationshipPath { get; } |
| 108 | + |
| 109 | + [Obsolete("Use `IsRelationshipPath` instead.")] |
| 110 | + bool IsRelationshipData { get; set; } |
| 111 | + } |
| 112 | + |
| 113 | + public interface IJsonApiContext : IJsonApiRequest |
| 114 | + { |
| 115 | + IJsonApiContext ApplyContext<T>(object controller); |
| 116 | + IMetaBuilder MetaBuilder { get; set; } |
| 117 | + IGenericProcessorFactory GenericProcessorFactory { get; set; } |
| 118 | + |
| 119 | + [Obsolete("Use the proxied method IControllerContext.GetControllerAttribute instead.")] |
34 | 120 | TAttribute GetControllerAttribute<TAttribute>() where TAttribute : Attribute;
|
35 | 121 | }
|
36 | 122 | }
|
0 commit comments