@@ -35,46 +35,46 @@ public struct MetaRelationship<MetaType: JSONAPI.Meta, LinksType: JSONAPI.Links>
3535/// a JSON API "Resource Linkage."
3636/// See https://jsonapi.org/format/#document-resource-object-linkage
3737/// A convenient typealias might make your code much more legible: `One<ResourceObjectDescription>`
38- public struct ToOneRelationship < Identifiable: JSONAPI . Identifiable , MetaType: JSONAPI . Meta , LinksType: JSONAPI . Links > : RelationshipType , Equatable {
38+ public struct ToOneRelationship < Identifiable: JSONAPI . JSONAPIIdentifiable , MetaType: JSONAPI . Meta , LinksType: JSONAPI . Links > : RelationshipType , Equatable {
3939
40- public let id : Identifiable . Identifier
40+ public let id : Identifiable . ID
4141
4242 public let meta : MetaType
4343 public let links : LinksType
4444
45- public init ( id: Identifiable . Identifier , meta: MetaType , links: LinksType ) {
45+ public init ( id: Identifiable . ID , meta: MetaType , links: LinksType ) {
4646 self . id = id
4747 self . meta = meta
4848 self . links = links
4949 }
5050}
5151
5252extension ToOneRelationship where MetaType == NoMetadata , LinksType == NoLinks {
53- public init ( id: Identifiable . Identifier ) {
53+ public init ( id: Identifiable . ID ) {
5454 self . init ( id: id, meta: . none, links: . none)
5555 }
5656}
5757
5858extension ToOneRelationship {
59- public init < T: ResourceObjectType > ( resourceObject: T , meta: MetaType , links: LinksType ) where T. Id == Identifiable . Identifier {
59+ public init < T: ResourceObjectType > ( resourceObject: T , meta: MetaType , links: LinksType ) where T. ID == Identifiable . ID {
6060 self . init ( id: resourceObject. id, meta: meta, links: links)
6161 }
6262}
6363
6464extension ToOneRelationship where MetaType == NoMetadata , LinksType == NoLinks {
65- public init < T: ResourceObjectType > ( resourceObject: T ) where T. Id == Identifiable . Identifier {
65+ public init < T: ResourceObjectType > ( resourceObject: T ) where T. ID == Identifiable . ID {
6666 self . init ( id: resourceObject. id, meta: . none, links: . none)
6767 }
6868}
6969
7070extension ToOneRelationship where Identifiable: OptionalRelatable {
71- public init < T: ResourceObjectType > ( resourceObject: T ? , meta: MetaType , links: LinksType ) where T. Id == Identifiable . Wrapped . Identifier {
71+ public init < T: ResourceObjectType > ( resourceObject: T ? , meta: MetaType , links: LinksType ) where T. ID == Identifiable . Wrapped . ID {
7272 self . init ( id: resourceObject? . id, meta: meta, links: links)
7373 }
7474}
7575
7676extension ToOneRelationship where Identifiable: OptionalRelatable , MetaType == NoMetadata , LinksType == NoLinks {
77- public init < T: ResourceObjectType > ( resourceObject: T ? ) where T. Id == Identifiable . Wrapped . Identifier {
77+ public init < T: ResourceObjectType > ( resourceObject: T ? ) where T. ID == Identifiable . Wrapped . ID {
7878 self . init ( id: resourceObject? . id, meta: . none, links: . none)
7979 }
8080}
@@ -85,24 +85,24 @@ extension ToOneRelationship where Identifiable: OptionalRelatable, MetaType == N
8585/// A convenient typealias might make your code much more legible: `Many<ResourceObjectDescription>`
8686public struct ToManyRelationship < Relatable: JSONAPI . Relatable , MetaType: JSONAPI . Meta , LinksType: JSONAPI . Links > : RelationshipType , Equatable {
8787
88- public let ids : [ Relatable . Identifier ]
88+ public let ids : [ Relatable . ID ]
8989
9090 public let meta : MetaType
9191 public let links : LinksType
9292
93- public init ( ids: [ Relatable . Identifier ] , meta: MetaType , links: LinksType ) {
93+ public init ( ids: [ Relatable . ID ] , meta: MetaType , links: LinksType ) {
9494 self . ids = ids
9595 self . meta = meta
9696 self . links = links
9797 }
9898
99- public init < T: JSONAPI . Identifiable > ( pointers: [ ToOneRelationship < T , NoMetadata , NoLinks > ] , meta: MetaType , links: LinksType ) where T. Identifier == Relatable . Identifier {
99+ public init < T: JSONAPI . JSONAPIIdentifiable > ( pointers: [ ToOneRelationship < T , NoMetadata , NoLinks > ] , meta: MetaType , links: LinksType ) where T. ID == Relatable . ID {
100100 ids = pointers. map ( \. id)
101101 self . meta = meta
102102 self . links = links
103103 }
104104
105- public init < T: ResourceObjectType > ( resourceObjects: [ T ] , meta: MetaType , links: LinksType ) where T. Id == Relatable . Identifier {
105+ public init < T: ResourceObjectType > ( resourceObjects: [ T ] , meta: MetaType , links: LinksType ) where T. ID == Relatable . ID {
106106 self . init ( ids: resourceObjects. map ( \. id) , meta: meta, links: links)
107107 }
108108
@@ -117,40 +117,40 @@ public struct ToManyRelationship<Relatable: JSONAPI.Relatable, MetaType: JSONAPI
117117
118118extension ToManyRelationship where MetaType == NoMetadata , LinksType == NoLinks {
119119
120- public init ( ids: [ Relatable . Identifier ] ) {
120+ public init ( ids: [ Relatable . ID ] ) {
121121 self . init ( ids: ids, meta: . none, links: . none)
122122 }
123123
124- public init < T: JSONAPI . Identifiable > ( pointers: [ ToOneRelationship < T , NoMetadata , NoLinks > ] ) where T. Identifier == Relatable . Identifier {
124+ public init < T: JSONAPI . JSONAPIIdentifiable > ( pointers: [ ToOneRelationship < T , NoMetadata , NoLinks > ] ) where T. ID == Relatable . ID {
125125 self . init ( pointers: pointers, meta: . none, links: . none)
126126 }
127127
128128 public static var none : ToManyRelationship {
129129 return . none( withMeta: . none, links: . none)
130130 }
131131
132- public init < T: ResourceObjectType > ( resourceObjects: [ T ] ) where T. Id == Relatable . Identifier {
132+ public init < T: ResourceObjectType > ( resourceObjects: [ T ] ) where T. ID == Relatable . ID {
133133 self . init ( resourceObjects: resourceObjects, meta: . none, links: . none)
134134 }
135135}
136136
137- public protocol Identifiable : JSONTyped {
138- associatedtype Identifier : Equatable
137+ public protocol JSONAPIIdentifiable : JSONTyped {
138+ associatedtype ID : Equatable
139139}
140140
141141/// The Relatable protocol describes anything that
142142/// has an IdType Identifier
143- public protocol Relatable : Identifiable where Identifier : JSONAPI . IdType {
143+ public protocol Relatable : JSONAPIIdentifiable where ID : JSONAPI . IdType {
144144}
145145
146146/// OptionalRelatable just describes an Optional
147147/// with a Reltable Wrapped type.
148- public protocol OptionalRelatable : Identifiable where Identifier == Wrapped . Identifier ? {
148+ public protocol OptionalRelatable : JSONAPIIdentifiable where ID == Wrapped . ID ? {
149149 associatedtype Wrapped : JSONAPI . Relatable
150150}
151151
152- extension Optional : Identifiable , OptionalRelatable , JSONTyped where Wrapped: JSONAPI . Relatable {
153- public typealias Identifier = Wrapped . Identifier ?
152+ extension Optional : JSONAPIIdentifiable , OptionalRelatable , JSONTyped where Wrapped: JSONAPI . Relatable {
153+ public typealias ID = Wrapped . ID ?
154154
155155 public static var jsonType : String { return Wrapped . jsonType }
156156}
@@ -196,7 +196,7 @@ extension MetaRelationship: Codable {
196196 }
197197}
198198
199- extension ToOneRelationship : Codable where Identifiable. Identifier : OptionalId {
199+ extension ToOneRelationship : Codable where Identifiable. ID : OptionalId {
200200 public init ( from decoder: Decoder ) throws {
201201 let container = try decoder. container ( keyedBy: ResourceLinkageCodingKeys . self)
202202
@@ -219,7 +219,7 @@ extension ToOneRelationship: Codable where Identifiable.Identifier: OptionalId {
219219 // type at which point we can store nil in `id`.
220220 let anyNil : Any ? = nil
221221 if try container. decodeNil ( forKey: . data) {
222- guard let val = anyNil as? Identifiable . Identifier else {
222+ guard let val = anyNil as? Identifiable . ID else {
223223 throw DecodingError . valueNotFound (
224224 Self . self,
225225 DecodingError . Context (
@@ -256,7 +256,7 @@ extension ToOneRelationship: Codable where Identifiable.Identifier: OptionalId {
256256 )
257257 }
258258
259- id = Identifiable . Identifier ( rawValue: try identifier. decode ( Identifiable . Identifier . RawType. self, forKey: . id) )
259+ id = Identifiable . ID ( rawValue: try identifier. decode ( Identifiable . ID . RawType. self, forKey: . id) )
260260 }
261261
262262 public func encode( to encoder: Encoder ) throws {
@@ -273,7 +273,7 @@ extension ToOneRelationship: Codable where Identifiable.Identifier: OptionalId {
273273 // If id is nil, instead of {id: , type: } we will just
274274 // encode `null`
275275 let anyNil : Any ? = nil
276- let nilId = anyNil as? Identifiable . Identifier
276+ let nilId = anyNil as? Identifiable . ID
277277 guard id != nilId else {
278278 try container. encodeNil ( forKey: . data)
279279 return
@@ -314,7 +314,7 @@ extension ToManyRelationship: Codable {
314314 path: context. codingPath)
315315 }
316316
317- var newIds = [ Relatable . Identifier ] ( )
317+ var newIds = [ Relatable . ID ] ( )
318318 while !identifiers. isAtEnd {
319319 let identifier = try identifiers. nestedContainer ( keyedBy: ResourceIdentifierCodingKeys . self)
320320
@@ -324,7 +324,7 @@ extension ToManyRelationship: Codable {
324324 throw JSONAPICodingError . typeMismatch ( expected: Relatable . jsonType, found: type, path: decoder. codingPath)
325325 }
326326
327- newIds. append ( Relatable . Identifier ( rawValue: try identifier. decode ( Relatable . Identifier . RawType. self, forKey: . id) ) )
327+ newIds. append ( Relatable . ID ( rawValue: try identifier. decode ( Relatable . ID . RawType. self, forKey: . id) ) )
328328 }
329329 ids = newIds
330330 }
0 commit comments