Skip to content

Commit 868613f

Browse files
authored
Support for systems (#106)
1 parent a639737 commit 868613f

6 files changed

Lines changed: 92 additions & 8 deletions

File tree

Sources/StitchSchemaKit/SchemaVersions.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public typealias CurrentComponentEntity = ComponentEntity_V25
104104
public typealias CurrentGraphEntity = GraphEntity_V25
105105
public typealias CurrentGraphSaveLocation = GraphSaveLocation_V25
106106
public typealias CurrentGraphDocumentPath = GraphDocumentPath_V25
107+
public typealias CurrentStitchSystemType = StitchSystemType_V25
108+
public typealias CurrentStitchSystem = StitchSystem_V25
107109

108110
// MARK: - end
109111

Sources/StitchSchemaKit/V25/Document/StitchComponent_V25.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ public enum StitchComponent_V25: StitchSchemaVersionable {
2020
public struct StitchComponent: StitchVersionedCodable, Equatable, Sendable {
2121
// Share location, saved here due to static helpers for sharing
2222
public var saveLocation: GraphSaveLocation
23-
public var isPublished: Bool
2423
public var graph: GraphEntity
2524

2625
public init(saveLocation: GraphSaveLocation,
27-
isPublished: Bool,
2826
graph: GraphEntity) {
2927
self.saveLocation = saveLocation
30-
self.isPublished = isPublished
3128
self.graph = graph
3229
}
3330
}

Sources/StitchSchemaKit/V25/Graph/GraphDocumentPath_V25.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ public enum GraphDocumentPath_V25: StitchSchemaVersionable {
1616

1717
public struct GraphDocumentPath: Codable, Equatable, Sendable {
1818
public let docId: UUID
19+
public let componentId: UUID
1920
public let componentsPath: [UUID]
2021

2122
public init(docId: UUID,
23+
componentId: UUID,
2224
componentsPath: [UUID]) {
2325
self.docId = docId
26+
self.componentId = componentId
2427
self.componentsPath = componentsPath
2528
}
2629
}

Sources/StitchSchemaKit/V25/Graph/GraphSaveLocation_V25.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ public enum GraphSaveLocation_V25: StitchSchemaVersionable {
1313
public static let version = StitchSchemaVersion._V25
1414
public typealias PreviousInstance = Self.GraphSaveLocation
1515
public typealias GraphDocumentPath = GraphDocumentPath_V25.GraphDocumentPath
16+
public typealias StitchSystemType = StitchSystemType_V25.StitchSystemType
1617
// MARK: - end
17-
18+
1819
public enum GraphSaveLocation: Codable, Equatable, Sendable {
19-
case document(GraphDocumentPath)
20-
case userLibrary
21-
// TODO: system
22-
//case system(UUID)
20+
case document(UUID)
21+
case localComponent(GraphDocumentPath)
22+
case systemComponent(StitchSystemType, UUID)
23+
case system(StitchSystemType)
2324
}
2425
}
2526

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// StitchSystem_V25.swift
3+
// StitchSchemaKit
4+
//
5+
// Created by Elliot Boschwitz on 10/7/24.
6+
//
7+
8+
import Foundation
9+
10+
public enum StitchSystem_V25: StitchSchemaVersionable {
11+
12+
// MARK: - ensure versions are correct
13+
public static let version = StitchSchemaVersion._V25
14+
public typealias PreviousInstance = Self.StitchSystem
15+
public typealias StitchSystemType = StitchSystemType_V25.StitchSystemType
16+
// MARK: - end
17+
18+
public struct StitchSystem: StitchVersionedCodable, Equatable, Sendable {
19+
public var id: StitchSystemType
20+
public var name: String
21+
22+
public init(id: StitchSystemType,
23+
name: String) {
24+
self.id = id
25+
self.name = name
26+
}
27+
}
28+
}
29+
30+
extension StitchSystem_V25.StitchSystem {
31+
public init(previousInstance: StitchSystem_V25.PreviousInstance) {
32+
// TODO: fix after version 25 (wasn't encoded ever in version 24)
33+
fatalError()
34+
}
35+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// SystemType_V25.swift
3+
// StitchSchemaKit
4+
//
5+
// Created by Elliot Boschwitz on 10/7/24.
6+
//
7+
8+
import Foundation
9+
10+
public enum StitchSystemType_V25: StitchSchemaVersionable {
11+
12+
// MARK: - ensure versions are correct
13+
public static let version = StitchSchemaVersion._V25
14+
public typealias PreviousInstance = Self.StitchSystemType
15+
// MARK: - end
16+
17+
public enum StitchSystemType: Codable, Hashable, Identifiable, CustomStringConvertible, Sendable {
18+
case userLibrary
19+
case system(UUID)
20+
21+
public var id: Int {
22+
switch self {
23+
case .userLibrary:
24+
return Self.userLibraryName.hashValue
25+
26+
case .system(let id):
27+
return id.hashValue
28+
}
29+
}
30+
31+
public var description: String {
32+
"\(self.hashValue)"
33+
}
34+
}
35+
}
36+
37+
extension StitchSystemType_V25.StitchSystemType {
38+
public static let userLibraryName = "User Library"
39+
}
40+
41+
extension StitchSystemType_V25.StitchSystemType {
42+
public init(previousInstance: StitchSystemType_V25.PreviousInstance) {
43+
// TODO: fix after version 25 (wasn't encoded ever in version 24)
44+
fatalError()
45+
}
46+
}

0 commit comments

Comments
 (0)