Skip to content

Commit a0de55b

Browse files
committed
Remove LogEntry and divide Device
1 parent 045ace8 commit a0de55b

File tree

13 files changed

+114
-156
lines changed

13 files changed

+114
-156
lines changed

Package.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ let package = Package(
2222
],
2323
swiftSettings: swiftSettings
2424
),
25-
.testTarget(
26-
name: "FluentWalletTests",
27-
dependencies: [
28-
.target(name: "FluentWallet"),
29-
.product(name: "XCTFluent", package: "fluent-kit"),
30-
],
31-
swiftSettings: swiftSettings
32-
),
3325
.target(
3426
name: "FluentWalletPasses",
3527
dependencies: [

Sources/FluentWallet/FluentWallet.docc/FluentWallet.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,3 @@ This package provides a collection of Fluent protocol and concrete models, usefu
1313
}
1414
@Column(size: 2) { }
1515
}
16-
17-
## Topics
18-
19-
### Models
20-
21-
- ``DeviceModel``
22-
- ``LogEntryModel``
23-
24-
### Concrete Models
25-
26-
- ``Device``
27-
- ``LogEntry``
28-
29-
### Migrations
30-
31-
- ``CreateDevice``
32-
- ``CreateLogEntry``

Sources/FluentWallet/Models/Concrete Models/LogEntry.swift

Lines changed: 0 additions & 43 deletions
This file was deleted.

Sources/FluentWallet/Models/LogEntryModel.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

Sources/FluentWalletOrders/FluentWalletOrders.docc/FluentWalletOrders.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ For information on Apple Wallet orders, see the [Apple Developer Documentation](
1919
### Concrete Models
2020

2121
- ``Order``
22+
- ``OrdersDevice``
2223
- ``OrdersRegistration``
2324

2425
### Migrations
2526

2627
- ``CreateOrder``
28+
- ``CreateOrdersDevice``
2729
- ``CreateOrdersRegistration``

Sources/FluentWallet/Models/Concrete Models/Device.swift renamed to Sources/FluentWalletOrders/Models/Concrete Models/OrdersDevice.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import FluentKit
22

3-
/// The `Model` that stores Apple Wallet devices.
4-
final public class Device: DeviceModel, @unchecked Sendable {
3+
/// The `Model` that stores Apple Wallet passes devices.
4+
final public class OrdersDevice: DeviceModel, @unchecked Sendable {
55
/// The schema name of the device model.
6-
public static let schema = Device.FieldKeys.schemaName
6+
public static let schema = OrdersDevice.FieldKeys.schemaName
77

88
@ID(custom: .id)
99
public var id: Int?
1010

1111
/// The push token used for sending updates to the device.
12-
@Field(key: Device.FieldKeys.pushToken)
12+
@Field(key: OrdersDevice.FieldKeys.pushToken)
1313
public var pushToken: String
1414

1515
/// The identifier Apple Wallet provides for the device.
16-
@Field(key: Device.FieldKeys.libraryIdentifier)
16+
@Field(key: OrdersDevice.FieldKeys.libraryIdentifier)
1717
public var libraryIdentifier: String
1818

1919
public init(libraryIdentifier: String, pushToken: String) {
@@ -24,25 +24,25 @@ final public class Device: DeviceModel, @unchecked Sendable {
2424
public init() {}
2525
}
2626

27-
/// The migration that creates the ``Device`` table.
28-
public struct CreateDevice: AsyncMigration {
27+
/// The migration that creates the ``OrdersDevice`` table.
28+
public struct CreateOrdersDevice: AsyncMigration {
2929
public func prepare(on database: any Database) async throws {
30-
try await database.schema(Device.FieldKeys.schemaName)
30+
try await database.schema(OrdersDevice.FieldKeys.schemaName)
3131
.field(.id, .int, .identifier(auto: true))
32-
.field(Device.FieldKeys.pushToken, .string, .required)
33-
.field(Device.FieldKeys.libraryIdentifier, .string, .required)
34-
.unique(on: Device.FieldKeys.pushToken, Device.FieldKeys.libraryIdentifier)
32+
.field(OrdersDevice.FieldKeys.pushToken, .string, .required)
33+
.field(OrdersDevice.FieldKeys.libraryIdentifier, .string, .required)
34+
.unique(on: OrdersDevice.FieldKeys.pushToken, OrdersDevice.FieldKeys.libraryIdentifier)
3535
.create()
3636
}
3737

3838
public func revert(on database: any Database) async throws {
39-
try await database.schema(Device.FieldKeys.schemaName).delete()
39+
try await database.schema(OrdersDevice.FieldKeys.schemaName).delete()
4040
}
4141

4242
public init() {}
4343
}
4444

45-
extension Device {
45+
extension OrdersDevice {
4646
package enum FieldKeys {
4747
package static let schemaName = "devices"
4848
static let pushToken = FieldKey(stringLiteral: "push_token")

Sources/FluentWalletOrders/Models/Concrete Models/OrdersRegistration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final public class OrdersRegistration: OrdersRegistrationModel, @unchecked Senda
1111

1212
/// The device for this registration.
1313
@Parent(key: OrdersRegistration.FieldKeys.deviceID)
14-
public var device: Device
14+
public var device: OrdersDevice
1515

1616
/// The order for this registration.
1717
@Parent(key: OrdersRegistration.FieldKeys.orderID)
@@ -27,7 +27,7 @@ public struct CreateOrdersRegistration: AsyncMigration {
2727
.field(.id, .int, .identifier(auto: true))
2828
.field(
2929
OrdersRegistration.FieldKeys.deviceID, .int, .required,
30-
.references(Device.FieldKeys.schemaName, .id, onDelete: .cascade)
30+
.references(OrdersDevice.FieldKeys.schemaName, .id, onDelete: .cascade)
3131
)
3232
.field(
3333
OrdersRegistration.FieldKeys.orderID, .uuid, .required,

Sources/FluentWalletPasses/FluentWalletPasses.docc/FluentWalletPasses.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ For information on Apple Wallet passes, see the [Apple Developer Documentation](
2727
### Concrete Models
2828

2929
- ``Pass``
30+
- ``PassesDevice``
3031
- ``PassesRegistration``
3132

3233
### Migrations
3334

3435
- ``CreatePass``
36+
- ``CreatePassesDevice``
3537
- ``CreatePassesRegistration``
3638

3739
### Personalized Passes
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import FluentKit
2+
3+
/// The `Model` that stores Apple Wallet passes devices.
4+
final public class PassesDevice: DeviceModel, @unchecked Sendable {
5+
/// The schema name of the device model.
6+
public static let schema = PassesDevice.FieldKeys.schemaName
7+
8+
@ID(custom: .id)
9+
public var id: Int?
10+
11+
/// The push token used for sending updates to the device.
12+
@Field(key: PassesDevice.FieldKeys.pushToken)
13+
public var pushToken: String
14+
15+
/// The identifier Apple Wallet provides for the device.
16+
@Field(key: PassesDevice.FieldKeys.libraryIdentifier)
17+
public var libraryIdentifier: String
18+
19+
public init(libraryIdentifier: String, pushToken: String) {
20+
self.libraryIdentifier = libraryIdentifier
21+
self.pushToken = pushToken
22+
}
23+
24+
public init() {}
25+
}
26+
27+
/// The migration that creates the ``PassesDevice`` table.
28+
public struct CreatePassesDevice: AsyncMigration {
29+
public func prepare(on database: any Database) async throws {
30+
try await database.schema(PassesDevice.FieldKeys.schemaName)
31+
.field(.id, .int, .identifier(auto: true))
32+
.field(PassesDevice.FieldKeys.pushToken, .string, .required)
33+
.field(PassesDevice.FieldKeys.libraryIdentifier, .string, .required)
34+
.unique(on: PassesDevice.FieldKeys.pushToken, PassesDevice.FieldKeys.libraryIdentifier)
35+
.create()
36+
}
37+
38+
public func revert(on database: any Database) async throws {
39+
try await database.schema(PassesDevice.FieldKeys.schemaName).delete()
40+
}
41+
42+
public init() {}
43+
}
44+
45+
extension PassesDevice {
46+
package enum FieldKeys {
47+
package static let schemaName = "devices"
48+
static let pushToken = FieldKey(stringLiteral: "push_token")
49+
static let libraryIdentifier = FieldKey(stringLiteral: "library_identifier")
50+
}
51+
}

Sources/FluentWalletPasses/Models/Concrete Models/PassesRegistration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final public class PassesRegistration: PassesRegistrationModel, @unchecked Senda
1111

1212
/// The device for this registration.
1313
@Parent(key: PassesRegistration.FieldKeys.deviceID)
14-
public var device: Device
14+
public var device: PassesDevice
1515

1616
/// The pass for this registration.
1717
@Parent(key: PassesRegistration.FieldKeys.passID)
@@ -27,7 +27,7 @@ public struct CreatePassesRegistration: AsyncMigration {
2727
.field(.id, .int, .identifier(auto: true))
2828
.field(
2929
PassesRegistration.FieldKeys.deviceID, .int, .required,
30-
.references(Device.FieldKeys.schemaName, .id, onDelete: .cascade)
30+
.references(PassesDevice.FieldKeys.schemaName, .id, onDelete: .cascade)
3131
)
3232
.field(
3333
PassesRegistration.FieldKeys.passID, .uuid, .required,

0 commit comments

Comments
 (0)