Skip to content

Commit d54cee8

Browse files
committed
Cleanup model creation code
1 parent 7b36d6f commit d54cee8

File tree

3 files changed

+106
-106
lines changed

3 files changed

+106
-106
lines changed

Sources/Pulse/Helpers/CoreData+Extensions.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extension NSEntityDescription {
9797
}
9898

9999
extension NSAttributeDescription {
100-
convenience init(name: String, type: NSAttributeType, _ configure: (NSAttributeDescription) -> Void = { _ in }) {
100+
convenience init(_ name: String, _ type: NSAttributeType, _ configure: (NSAttributeDescription) -> Void = { _ in }) {
101101
self.init()
102102
self.name = name
103103
self.attributeType = type
@@ -111,8 +111,8 @@ enum RelationshipType {
111111
}
112112

113113
extension NSRelationshipDescription {
114-
convenience init(name: String,
115-
type: RelationshipType,
114+
convenience init(_ name: String,
115+
_ type: RelationshipType,
116116
deleteRule: NSDeleteRule = .cascadeDeleteRule,
117117
entity: NSEntityDescription) {
118118
self.init()

Sources/Pulse/Helpers/PulseDocument.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ final class PulseDocument {
3232
let model = NSManagedObjectModel()
3333
let blob = NSEntityDescription(class: PulseBlobEntity.self)
3434
blob.properties = [
35-
NSAttributeDescription(name: "key", type: .stringAttributeType),
36-
NSAttributeDescription(name: "data", type: .binaryDataAttributeType)
35+
NSAttributeDescription("key", .stringAttributeType),
36+
NSAttributeDescription("data", .binaryDataAttributeType)
3737
]
3838
model.entities = [blob]
3939
return model

Sources/Pulse/LoggerStore/LoggerStore+Model.swift

+101-101
Original file line numberDiff line numberDiff line change
@@ -23,128 +23,128 @@ extension LoggerStore {
2323
let blob = Entity(class: LoggerBlobHandleEntity.self)
2424

2525
session.properties = [
26-
Attribute(name: "id", type: .UUIDAttributeType),
27-
Attribute(name: "createdAt", type: .dateAttributeType),
28-
Attribute(name: "version", type: .stringAttributeType) { $0.isOptional = true },
29-
Attribute(name: "build", type: .stringAttributeType) { $0.isOptional = true }
26+
Attribute("id", .UUIDAttributeType),
27+
Attribute("createdAt", .dateAttributeType),
28+
Attribute("version", .stringAttributeType) { $0.isOptional = true },
29+
Attribute("build", .stringAttributeType) { $0.isOptional = true }
3030
]
3131

3232
message.properties = [
33-
Attribute(name: "createdAt", type: .dateAttributeType),
34-
Attribute(name: "isPinned", type: .booleanAttributeType),
35-
Attribute(name: "session", type: .UUIDAttributeType),
36-
Attribute(name: "level", type: .integer16AttributeType),
37-
Attribute(name: "text", type: .stringAttributeType),
38-
Attribute(name: "file", type: .stringAttributeType),
39-
Attribute(name: "function", type: .stringAttributeType),
40-
Attribute(name: "line", type: .integer32AttributeType),
41-
Attribute(name: "rawMetadata", type: .stringAttributeType),
42-
Attribute(name: "label", type: .stringAttributeType),
43-
Relationship(name: "task", type: .oneToOne(isOptional: true), entity: task)
33+
Attribute("createdAt", .dateAttributeType),
34+
Attribute("isPinned", .booleanAttributeType),
35+
Attribute("session", .UUIDAttributeType),
36+
Attribute("level", .integer16AttributeType),
37+
Attribute("text", .stringAttributeType),
38+
Attribute("file", .stringAttributeType),
39+
Attribute("function", .stringAttributeType),
40+
Attribute("line", .integer32AttributeType),
41+
Attribute("rawMetadata", .stringAttributeType),
42+
Attribute("label", .stringAttributeType),
43+
Relationship("task", .oneToOne(isOptional: true), entity: task)
4444
]
4545

4646
task.properties = [
47-
Attribute(name: "createdAt", type: .dateAttributeType),
48-
Attribute(name: "session", type: .UUIDAttributeType),
49-
Attribute(name: "taskId", type: .UUIDAttributeType),
50-
Attribute(name: "taskType", type: .integer16AttributeType),
51-
Attribute(name: "url", type: .stringAttributeType),
52-
Attribute(name: "host", type: .stringAttributeType),
53-
Attribute(name: "httpMethod", type: .stringAttributeType),
54-
Attribute(name: "statusCode", type: .integer32AttributeType),
55-
Attribute(name: "errorCode", type: .integer32AttributeType),
56-
Attribute(name: "errorDomain", type: .stringAttributeType),
57-
Attribute(name: "errorDebugDescription", type: .stringAttributeType),
58-
Attribute(name: "underlyingError", type: .binaryDataAttributeType),
59-
Attribute(name: "startDate", type: .dateAttributeType),
60-
Attribute(name: "duration", type: .doubleAttributeType),
61-
Attribute(name: "redirectCount", type: .integer16AttributeType),
62-
Attribute(name: "responseContentType", type: .stringAttributeType),
63-
Attribute(name: "requestState", type: .integer16AttributeType),
64-
Attribute(name: "requestBodySize", type: .integer64AttributeType),
65-
Attribute(name: "responseBodySize", type: .integer64AttributeType),
66-
Attribute(name: "isFromCache", type: .booleanAttributeType),
67-
Attribute(name: "isMocked", type: .booleanAttributeType),
68-
Attribute(name: "rawMetadata", type: .stringAttributeType),
69-
Attribute(name: "taskDescription", type: .stringAttributeType),
70-
Relationship(name: "originalRequest", type: .oneToOne(), entity: request),
71-
Relationship(name: "currentRequest", type: .oneToOne(isOptional: true), entity: request),
72-
Relationship(name: "response", type: .oneToOne(isOptional: true), entity: response),
73-
Relationship(name: "transactions", type: .oneToMany, entity: transaction),
74-
Relationship(name: "message", type: .oneToOne(), entity: message),
75-
Relationship(name: "requestBody", type: .oneToOne(isOptional: true), deleteRule: .noActionDeleteRule, entity: blob),
76-
Relationship(name: "responseBody", type: .oneToOne(isOptional: true), deleteRule: .noActionDeleteRule, entity: blob),
77-
Relationship(name: "progress", type: .oneToOne(isOptional: true), entity: progress)
47+
Attribute("createdAt", .dateAttributeType),
48+
Attribute("session", .UUIDAttributeType),
49+
Attribute("taskId", .UUIDAttributeType),
50+
Attribute("taskType", .integer16AttributeType),
51+
Attribute("url", .stringAttributeType),
52+
Attribute("host", .stringAttributeType),
53+
Attribute("httpMethod", .stringAttributeType),
54+
Attribute("statusCode", .integer32AttributeType),
55+
Attribute("errorCode", .integer32AttributeType),
56+
Attribute("errorDomain", .stringAttributeType),
57+
Attribute("errorDebugDescription", .stringAttributeType),
58+
Attribute("underlyingError", .binaryDataAttributeType),
59+
Attribute("startDate", .dateAttributeType),
60+
Attribute("duration", .doubleAttributeType),
61+
Attribute("redirectCount", .integer16AttributeType),
62+
Attribute("responseContentType", .stringAttributeType),
63+
Attribute("requestState", .integer16AttributeType),
64+
Attribute("requestBodySize", .integer64AttributeType),
65+
Attribute("responseBodySize", .integer64AttributeType),
66+
Attribute("isFromCache", .booleanAttributeType),
67+
Attribute("isMocked", .booleanAttributeType),
68+
Attribute("rawMetadata", .stringAttributeType),
69+
Attribute("taskDescription", .stringAttributeType),
70+
Relationship("originalRequest", .oneToOne(), entity: request),
71+
Relationship("currentRequest", .oneToOne(isOptional: true), entity: request),
72+
Relationship("response", .oneToOne(isOptional: true), entity: response),
73+
Relationship("transactions", .oneToMany, entity: transaction),
74+
Relationship("message", .oneToOne(), entity: message),
75+
Relationship("requestBody", .oneToOne(isOptional: true), deleteRule: .noActionDeleteRule, entity: blob),
76+
Relationship("responseBody", .oneToOne(isOptional: true), deleteRule: .noActionDeleteRule, entity: blob),
77+
Relationship("progress", .oneToOne(isOptional: true), entity: progress)
7878
]
7979

8080
request.properties = [
81-
Attribute(name: "url", type: .stringAttributeType),
82-
Attribute(name: "httpMethod", type: .stringAttributeType) { $0.isOptional = true },
83-
Attribute(name: "httpHeaders", type: .stringAttributeType),
84-
Attribute(name: "allowsCellularAccess", type: .booleanAttributeType),
85-
Attribute(name: "allowsExpensiveNetworkAccess", type: .booleanAttributeType),
86-
Attribute(name: "allowsConstrainedNetworkAccess", type: .booleanAttributeType),
87-
Attribute(name: "httpShouldHandleCookies", type: .booleanAttributeType),
88-
Attribute(name: "httpShouldUsePipelining", type: .booleanAttributeType),
89-
Attribute(name: "timeoutInterval", type: .integer32AttributeType),
90-
Attribute(name: "rawCachePolicy", type: .integer16AttributeType)
81+
Attribute("url", .stringAttributeType),
82+
Attribute("httpMethod", .stringAttributeType) { $0.isOptional = true },
83+
Attribute("httpHeaders", .stringAttributeType),
84+
Attribute("allowsCellularAccess", .booleanAttributeType),
85+
Attribute("allowsExpensiveNetworkAccess", .booleanAttributeType),
86+
Attribute("allowsConstrainedNetworkAccess", .booleanAttributeType),
87+
Attribute("httpShouldHandleCookies", .booleanAttributeType),
88+
Attribute("httpShouldUsePipelining", .booleanAttributeType),
89+
Attribute("timeoutInterval", .integer32AttributeType),
90+
Attribute("rawCachePolicy", .integer16AttributeType)
9191
]
9292

9393
response.properties = [
94-
Attribute(name: "statusCode", type: .integer16AttributeType),
95-
Attribute(name: "httpHeaders", type: .stringAttributeType)
94+
Attribute("statusCode", .integer16AttributeType),
95+
Attribute("httpHeaders", .stringAttributeType)
9696
]
9797

9898
progress.properties = [
99-
Attribute(name: "completedUnitCount", type: .integer64AttributeType),
100-
Attribute(name: "totalUnitCount", type: .integer64AttributeType)
99+
Attribute("completedUnitCount", .integer64AttributeType),
100+
Attribute("totalUnitCount", .integer64AttributeType)
101101
]
102102

103103
transaction.properties = [
104-
Attribute(name: "index", type: .integer16AttributeType),
105-
Attribute(name: "rawFetchType", type: .integer16AttributeType),
106-
Relationship(name: "request", type: .oneToOne(), entity: request),
107-
Relationship(name: "response", type: .oneToOne(isOptional: true), entity: response),
108-
Attribute(name: "networkProtocol", type: .stringAttributeType),
109-
Attribute(name: "localAddress", type: .stringAttributeType),
110-
Attribute(name: "remoteAddress", type: .stringAttributeType),
111-
Attribute(name: "localPort", type: .integer32AttributeType),
112-
Attribute(name: "remotePort", type: .integer32AttributeType),
113-
Attribute(name: "isProxyConnection", type: .booleanAttributeType),
114-
Attribute(name: "isReusedConnection", type: .booleanAttributeType),
115-
Attribute(name: "isCellular", type: .booleanAttributeType),
116-
Attribute(name: "isExpensive", type: .booleanAttributeType),
117-
Attribute(name: "isConstrained", type: .booleanAttributeType),
118-
Attribute(name: "isMultipath", type: .booleanAttributeType),
119-
Attribute(name: "rawNegotiatedTLSProtocolVersion", type: .integer32AttributeType),
120-
Attribute(name: "rawNegotiatedTLSCipherSuite", type: .integer32AttributeType),
121-
Attribute(name: "fetchStartDate", type: .dateAttributeType),
122-
Attribute(name: "domainLookupStartDate", type: .dateAttributeType),
123-
Attribute(name: "domainLookupEndDate", type: .dateAttributeType),
124-
Attribute(name: "connectStartDate", type: .dateAttributeType),
125-
Attribute(name: "secureConnectionStartDate", type: .dateAttributeType),
126-
Attribute(name: "secureConnectionEndDate", type: .dateAttributeType),
127-
Attribute(name: "connectEndDate", type: .dateAttributeType),
128-
Attribute(name: "requestStartDate", type: .dateAttributeType),
129-
Attribute(name: "requestEndDate", type: .dateAttributeType),
130-
Attribute(name: "responseStartDate", type: .dateAttributeType),
131-
Attribute(name: "responseEndDate", type: .dateAttributeType),
132-
Attribute(name: "requestHeaderBytesSent", type: .integer64AttributeType),
133-
Attribute(name: "requestBodyBytesBeforeEncoding", type: .integer64AttributeType),
134-
Attribute(name: "requestBodyBytesSent", type: .integer64AttributeType),
135-
Attribute(name: "responseHeaderBytesReceived", type: .integer64AttributeType),
136-
Attribute(name: "responseBodyBytesAfterDecoding", type: .integer64AttributeType),
137-
Attribute(name: "responseBodyBytesReceived", type: .integer64AttributeType)
104+
Attribute("index", .integer16AttributeType),
105+
Attribute("rawFetchType", .integer16AttributeType),
106+
Relationship("request", .oneToOne(), entity: request),
107+
Relationship("response", .oneToOne(isOptional: true), entity: response),
108+
Attribute("networkProtocol", .stringAttributeType),
109+
Attribute("localAddress", .stringAttributeType),
110+
Attribute("remoteAddress", .stringAttributeType),
111+
Attribute("localPort", .integer32AttributeType),
112+
Attribute("remotePort", .integer32AttributeType),
113+
Attribute("isProxyConnection", .booleanAttributeType),
114+
Attribute("isReusedConnection", .booleanAttributeType),
115+
Attribute("isCellular", .booleanAttributeType),
116+
Attribute("isExpensive", .booleanAttributeType),
117+
Attribute("isConstrained", .booleanAttributeType),
118+
Attribute("isMultipath", .booleanAttributeType),
119+
Attribute("rawNegotiatedTLSProtocolVersion", .integer32AttributeType),
120+
Attribute("rawNegotiatedTLSCipherSuite", .integer32AttributeType),
121+
Attribute("fetchStartDate", .dateAttributeType),
122+
Attribute("domainLookupStartDate", .dateAttributeType),
123+
Attribute("domainLookupEndDate", .dateAttributeType),
124+
Attribute("connectStartDate", .dateAttributeType),
125+
Attribute("secureConnectionStartDate", .dateAttributeType),
126+
Attribute("secureConnectionEndDate", .dateAttributeType),
127+
Attribute("connectEndDate", .dateAttributeType),
128+
Attribute("requestStartDate", .dateAttributeType),
129+
Attribute("requestEndDate", .dateAttributeType),
130+
Attribute("responseStartDate", .dateAttributeType),
131+
Attribute("responseEndDate", .dateAttributeType),
132+
Attribute("requestHeaderBytesSent", .integer64AttributeType),
133+
Attribute("requestBodyBytesBeforeEncoding", .integer64AttributeType),
134+
Attribute("requestBodyBytesSent", .integer64AttributeType),
135+
Attribute("responseHeaderBytesReceived", .integer64AttributeType),
136+
Attribute("responseBodyBytesAfterDecoding", .integer64AttributeType),
137+
Attribute("responseBodyBytesReceived", .integer64AttributeType)
138138
]
139139

140140
blob.properties = [
141-
Attribute(name: "key", type: .binaryDataAttributeType),
142-
Attribute(name: "size", type: .integer32AttributeType),
143-
Attribute(name: "decompressedSize", type: .integer32AttributeType),
144-
Attribute(name: "linkCount", type: .integer32AttributeType),
145-
Attribute(name: "rawContentType", type: .stringAttributeType),
146-
Attribute(name: "inlineData", type: .binaryDataAttributeType),
147-
Attribute(name: "isUncompressed", type: .booleanAttributeType)
141+
Attribute("key", .binaryDataAttributeType),
142+
Attribute("size", .integer32AttributeType),
143+
Attribute("decompressedSize", .integer32AttributeType),
144+
Attribute("linkCount", .integer32AttributeType),
145+
Attribute("rawContentType", .stringAttributeType),
146+
Attribute("inlineData", .binaryDataAttributeType),
147+
Attribute("isUncompressed", .booleanAttributeType)
148148
]
149149

150150
let model = NSManagedObjectModel()

0 commit comments

Comments
 (0)