Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorials and dependencies updates #20

Merged
merged 79 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b63f1cd
swift-docc-plugin 1.3.0
makoni Aug 22, 2023
aa93653
async-http-client 1.19.0
makoni Aug 22, 2023
4788d8a
replaced deprecated .createNew with the new .singleton
makoni Aug 22, 2023
fcb6c8d
Merge branch 'master' into develop
makoni Sep 15, 2023
37c4bf6
Adding _find capability. (#13)
gevartosky Jan 16, 2024
7db38dd
docs
makoni Jan 16, 2024
4e37384
tabs
makoni Jan 16, 2024
a70250c
renames
makoni Jan 16, 2024
e2f2b50
added test for find method with body
makoni Jan 16, 2024
f9aa3ab
docs added
makoni Jan 16, 2024
e5602ae
findError added
makoni Jan 16, 2024
0e06ef6
tests renamed
makoni Jan 16, 2024
c941657
added test for find method with generic type
makoni Jan 16, 2024
e6b6566
docs
makoni Jan 16, 2024
d4f520f
README updated
makoni Jan 16, 2024
78e7d10
updated dependencies
makoni Jan 16, 2024
51966c3
docs updated
makoni Jan 16, 2024
1118bb3
try Swift 5.7.1
makoni Jan 16, 2024
dfdc610
Update build-ubuntu.yml
makoni Jan 16, 2024
842bc38
Merge branch 'develop' of github.com:makoni/couchdb-vapor into develop
makoni Jan 16, 2024
ab8f67a
Swift 5.7.3
makoni Jan 16, 2024
896eef9
Revert "Swift 5.7.3"
makoni Jan 16, 2024
4798e40
Merge branch 'master' into develop
makoni Jan 17, 2024
04f3bdd
updated dependencies
makoni Feb 24, 2024
bdeedda
Docs updated
makoni Feb 24, 2024
2dd69f6
Delete .github/workflows/CodeQL.yml
makoni Feb 24, 2024
1c34ed3
Merge branch 'master' into develop
makoni Feb 24, 2024
33cb174
dependencies updated
makoni Mar 26, 2024
abce15f
fixed when update method didn’t use passed dateEncodingStrategy
makoni Mar 26, 2024
0cac14d
Merge branch 'master' into develop
makoni Mar 26, 2024
1a522e0
noData error added
makoni Apr 2, 2024
a1dcfaf
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
0bb6982
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
ad36014
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
73ffa10
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
c60fead
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
dd00301
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
febe7b3
makoni Apr 2, 2024
5260938
migrating to new HTTPClientRequest from HTTPClient.Request wip
makoni Apr 2, 2024
c1cd49a
rename
makoni Apr 2, 2024
d9e4ec8
tests updated
makoni Apr 5, 2024
20497eb
auth fixed
makoni Apr 5, 2024
d8eab77
collect body bytes before returning response
makoni Apr 5, 2024
8520826
param renamed to make keep backward compatibility with old methods
makoni Apr 5, 2024
7af5c33
marking old find as deprecated
makoni Apr 5, 2024
ca0caa2
private
makoni Apr 5, 2024
78f5666
deprecated message
makoni Apr 5, 2024
a54dfcf
renames
makoni Apr 5, 2024
d6c9c9c
moved deprecations
makoni Apr 5, 2024
eecb20f
docs
makoni Apr 5, 2024
469247f
docs
makoni Apr 6, 2024
31187b5
added Codable to CouchDBRepresentable protocol
makoni Apr 7, 2024
f337240
added RowsResponse model
makoni Apr 7, 2024
6cd2d09
docs
makoni Apr 7, 2024
8d47cd2
Vapor tutorial updated
makoni Apr 7, 2024
dba25fe
docs
makoni Apr 7, 2024
ebab497
docs and refactoring
makoni Apr 7, 2024
cc290e1
docs and refactoring
makoni Apr 7, 2024
d8343b1
Tutorials updated
makoni Apr 7, 2024
952f8e2
docs
makoni Apr 7, 2024
093c7c3
platforms list updated
makoni Apr 7, 2024
79bd657
minimum swift version 5.8
makoni Apr 7, 2024
e1737a7
workflow updated
makoni Apr 7, 2024
2a6c964
Update build-ubuntu.yml
makoni Apr 7, 2024
04bcd15
Update build-macos.yml
makoni Apr 7, 2024
a70d23e
import NIOFoundationCompat to fix building on Ubuntu
makoni Apr 7, 2024
804e23f
Merge branch 'master' into develop
makoni Apr 7, 2024
22e006e
Merge branch 'master' into develop
makoni Apr 8, 2024
7acc1b6
using async-http-client from 1.21.0. Not calling http
makoni Apr 8, 2024
c9ec8c1
Using HTTPClient.shared if eventLoopGroup not provided. No more calls…
makoni Apr 8, 2024
aef587b
Merge branch 'master' into develop
makoni Apr 8, 2024
5de558e
Merge branch 'master' into develop
makoni Apr 11, 2024
8604500
docs updated
makoni Apr 11, 2024
49637d2
docs updated
makoni Apr 11, 2024
ef10c9c
Merge branch 'master' into develop
makoni Apr 15, 2024
a57f6ad
Vapor tutorial updated
makoni Apr 15, 2024
8190603
A SwiftUI tutorial
makoni Apr 15, 2024
8b6e347
tutorial fixed
makoni Apr 15, 2024
6e734f4
updated dependencies
makoni May 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"location" : "https://github.com/swift-server/async-http-client",
"state" : {
"revision" : "fb308ee72f3d4c082a507033f94afa7395963ef3",
"version" : "1.21.0"
"revision" : "a22083713ee90808d527d0baa290c2fb13ca3096",
"version" : "1.21.1"
}
},
{
Expand Down Expand Up @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982",
"version" : "2.64.0"
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
"version" : "2.65.0"
}
},
{
Expand All @@ -95,8 +95,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "0904bf0feb5122b7e5c3f15db7df0eabe623dd87",
"version" : "1.30.0"
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ let package = Package(
.library(name: "CouchDBClient", targets: ["CouchDBClient"]),
],
dependencies: [
.package(url: "https://github.com/swift-server/async-http-client", from: "1.21.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0")
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.21.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.3.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions Sources/CouchDBClient/CouchDBClient.docc/Resources/swift.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import SwiftUI
import CouchDBClient

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import SwiftUI
import CouchDBClient

let couchDBClient = CouchDBClient(
couchProtocol: .http,
couchHost: "127.0.0.1",
couchPort: 5984,
userName: "admin",
userPassword: "yourPassword"
)

let dbName = "fortests"

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import SwiftUI
import CouchDBClient

let couchDBClient = CouchDBClient(
couchProtocol: .http,
couchHost: "127.0.0.1",
couchPort: 5984,
userName: "admin",
userPassword: "yourPassword"
)

let dbName = "fortests"

class MyDoc: Identifiable, CouchDBRepresentable {
var _id: String?
var _rev: String?
var title: String
}

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import SwiftUI
import CouchDBClient

let couchDBClient = CouchDBClient(
couchProtocol: .http,
couchHost: "127.0.0.1",
couchPort: 5984,
userName: "admin",
userPassword: "yourPassword"
)

let dbName = "fortests"

class MyDoc: Identifiable, CouchDBRepresentable {
var _id: String?
var _rev: String?
var title: String
}

@Observable class DocsStore {
var docs = [MyDoc]()

func getDocs() async throws {
let response = try await couchDBClient.get(
fromDB: dbName,
uri: "_design/all/_view/list"
)

let expectedBytes = response.headers
.first(name: "content-length")
.flatMap(Int.init) ?? 1024 * 1024 * 10
var bytes = try await response.body.collect(upTo: expectedBytes)

guard let data = bytes.readData(length: bytes.readableBytes) else { return }

let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .secondsSince1970

let decodeResponse = try decoder.decode(RowsResponse<MyDoc>.self, from: data)

await MainActor.run { [self] in
docs = decodeResponse.rows.map({ $0.value })
}
}
}

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import SwiftUI
import CouchDBClient

let couchDBClient = CouchDBClient(
couchProtocol: .http,
couchHost: "127.0.0.1",
couchPort: 5984,
userName: "admin",
userPassword: "yourPassword"
)

let dbName = "fortests"

class MyDoc: Identifiable, CouchDBRepresentable {
var _id: String?
var _rev: String?
var title: String
}

@Observable class DocsStore {
var docs = [MyDoc]()

func getDocs() async throws {
let response = try await couchDBClient.get(
fromDB: dbName,
uri: "_design/all/_view/list"
)

let expectedBytes = response.headers
.first(name: "content-length")
.flatMap(Int.init) ?? 1024 * 1024 * 10
var bytes = try await response.body.collect(upTo: expectedBytes)

guard let data = bytes.readData(length: bytes.readableBytes) else { return }

let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .secondsSince1970

let decodeResponse = try decoder.decode(RowsResponse<MyDoc>.self, from: data)

await MainActor.run { [self] in
docs = decodeResponse.rows.map({ $0.value })
}
}
}

struct ContentView: View {
@State var docsStore = DocsStore()
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")

List(docsStore.docs) { doc in
Text(doc.title)
}
}
.padding()
.task {
do {
try await docsStore.getDocs()
} catch {
print(error.localizedDescription)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@Tutorial(time: 10) {
@Intro(title: "Using with a SwiftUI app") {
A SwiftUI app example

@Image(source: curlybraces.square.fill.svg, alt: "Application icon")
}

@Section(title: "Initialization") {
@ContentAndMedia {
Adding CouchDBClient to your project.

@Image(source: swift.svg, alt: "Swift icon")
}

@Steps {
@Step {
Open the "Package Dependencies" tab in Xcode.

@Image(source: swiftui-example-1.png, alt: "Xcode")
}

@Step {
Add `CouchDBClient` as a Swift Package dependency.

@Image(source: swiftui-example-2.png, alt: "Add CouchDBClient as a Swift Package dependency.")
}

@Step {
Open your View file.

@Code(name: "ContentView.swift", file: SwiftUITutorial-1.swift)
}

@Step {
Import `CouchDBClient`.

@Code(name: "ContentView.swift", file: SwiftUITutorial-2.swift)
}

@Step {
Create a CouchDBClient object, define connection settings and database name.

@Code(name: "ContentView.swift", file: SwiftUITutorial-3.swift)
}

@Step {
Define a model for your CouchDB document. It should conform to the `CouchDBRepresentable` and `Identifiable` protocols.

@Code(name: "ContentView.swift", file: SwiftUITutorial-4.swift)
}

@Step {
Add a data source for your View.

@Code(name: "ContentView.swift", file: SwiftUITutorial-5.swift)
}

@Step {
Add getting the data and displaying it in the UI.

@Code(name: "ContentView.swift", file: SwiftUITutorial-6.swift)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@Image(source: curlybraces.square.fill.svg, alt: "CouchDBClient logo")

@TutorialReference(tutorial: "doc:macOSTutorial")
@TutorialReference(tutorial: "doc:SwiftUITutorial")
@TutorialReference(tutorial: "doc:VaporTutorial")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Tutorial(time: 10) {
@Intro(title: "Using in macOS app") {
Learn how to use CouchDBClient in your macOS app
@Intro(title: "macOS app example") {
Learn how to use `CouchDBClient` in a macOS app

@Image(source: curlybraces.square.fill.svg, alt: "Application icon")
}
Expand Down Expand Up @@ -32,7 +32,7 @@
}

@Step {
Create a CouchDBClient object, define database name and create a worker to perform requests.
Create a CouchDBClient object, define connection settings and database name.

@Code(name: "main.swift", file: macOSTutorial-3.swift)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.10
import PackageDescription

let package = Package(
name: "spaceinbox.me",
platforms: [
.macOS(.v13)
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor", from: "4.0.0"),
.package(url: "https://github.com/vapor/leaf", from: "4.0.0"),
],
targets: [
.target(
name: "App",
dependencies: [
.product(name: "Leaf", package: "leaf"),
.product(name: "Vapor", package: "vapor"),
]
),
.executableTarget(name: "Run", dependencies: [.target(name: "App")]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
]
)
Loading