Skip to content

Commit 337478b

Browse files
committed
first commit
1 parent 6335e7c commit 337478b

File tree

564 files changed

+160612
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

564 files changed

+160612
-2
lines changed

.swiftlint.yml

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
disabled_rules: # rule identifiers to exclude from running
2+
- trailing_whitespace
3+
- class_delegate_protocol
4+
opt_in_rules: # some rules are only opt-in
5+
- array_init
6+
- closure_spacing
7+
- closure_body_length
8+
- collection_alignment
9+
- contains_over_range_nil_comparison
10+
- contains_over_filter_count
11+
- contains_over_filter_is_empty
12+
- contains_over_first_not_nil
13+
- discouraged_object_literal
14+
- discouraged_optional_boolean
15+
- empty_collection_literal
16+
- empty_string
17+
- empty_count
18+
- empty_xctest_method
19+
- enum_case_associated_values_count
20+
- explicit_init
21+
- implicit_return
22+
- implicitly_unwrapped_optional
23+
- identical_operands
24+
- force_unwrapping
25+
- first_where
26+
- fatal_error_message
27+
- for_where
28+
- flatmap_over_map_reduce
29+
- generic_type_name
30+
- modifier_order
31+
- joined_default_parameter
32+
- extension_access_modifier
33+
- fallthrough
34+
- closure_end_indentation
35+
- attributes
36+
- let_var_whitespace
37+
- last_where
38+
- legacy_multiple
39+
- legacy_random
40+
- multiline_parameters
41+
- multiline_literal_brackets
42+
- number_separator
43+
- private_action
44+
- prefer_zero_over_explicit_init
45+
- prefer_self_type_over_type_of_self
46+
- overridden_super_call
47+
- prohibited_super_call
48+
- redundant_nil_coalescing
49+
- switch_case_on_newline
50+
- trailing_closure
51+
- vertical_parameter_alignment_on_call
52+
- literal_expression_end_indentation
53+
- lower_acl_than_parent
54+
- operator_usage_whitespace
55+
- operator_whitespace
56+
- quick_discouraged_call
57+
- untyped_error_in_catch
58+
- multiline_function_chains
59+
- file_name
60+
- file_name_no_space
61+
- file_types_order
62+
- convenience_type
63+
- reduce_into
64+
- redundant_type_annotation
65+
- single_test_class
66+
- sorted_first_last
67+
- static_operator
68+
- toggle_bool
69+
- trailing_comma
70+
- unavailable_function
71+
- unneeded_parentheses_in_closure_argument
72+
- unowned_variable_capture
73+
- yoda_condition
74+
- vertical_whitespace
75+
- vertical_whitespace_between_cases
76+
- vertical_whitespace_closing_braces
77+
- vertical_whitespace_opening_braces
78+
79+
included:
80+
- ./Projects/
81+
82+
attributes:
83+
always_on_same_line: ["@State", "@ObservedObject", "@MainActor", "@Binding", "@Published"]
84+
always_on_line_above: []
85+
severity: warning
86+
87+
# configurable rules can be customized from this configuration file
88+
# binary rules can set their severity level
89+
cyclomatic_complexity:
90+
- 15
91+
- 20
92+
93+
force_cast: warning # implicitly
94+
force_try:
95+
severity: warning # explicitly
96+
# rules that have both warning and error levels, can set just the warning level
97+
# implicitly
98+
line_length: 250
99+
# they can set both implicitly with an array
100+
type_body_length:
101+
- 300 # warning
102+
- 400 # error
103+
function_body_length:
104+
- 100
105+
- 200
106+
# or they can set both explicitly
107+
file_length:
108+
warning: 500
109+
error: 1200
110+
ignore_comment_only_lines: true
111+
# naming rules can set warnings/errors for min_length and max_length
112+
# additionally they can set excluded names
113+
type_name:
114+
min_length: 3 # only warning
115+
max_length: # warning and error
116+
warning: 50
117+
error: 60
118+
excluded:
119+
- iPhone # excluded via string
120+
- In
121+
- Out
122+
- Err
123+
- Bit
124+
- Bits
125+
- Geo
126+
- Lan
127+
- Tag
128+
- Box
129+
- Id
130+
131+
identifier_name:
132+
min_length: # only min_length
133+
error: 2 # only error
134+
max_length:
135+
warning: 50
136+
error: 60
137+
excluded: # excluded via string array
138+
- id
139+
- URL
140+
- op
141+
- x
142+
- y
143+
- ex
144+
- pk
145+
- vm
146+
147+
large_tuple:
148+
warning: 3
149+
error: 4
150+
151+
nesting:
152+
type_level: 3
153+
154+
custom_rules:
155+
comments_space: # From https://github.com/brandenr/swiftlintconfig
156+
name: "Space After Comment"
157+
regex: "(^ *//\\w+)"
158+
message: "There should be a space after //"
159+
severity: warning
160+
161+
double_space: # From https://github.com/IBM-Swift/Package-Builder
162+
include: "*.swift"
163+
name: "Double space"
164+
regex: "([a-z,A-Z] \\s+)"
165+
message: "Double space between keywords"
166+
match_kinds: keyword
167+
severity: warning
168+
169+
new_line_between_import:
170+
name: "New line between import"
171+
regex: "import(.*?)\n\n+import"
172+
message: "No new line between import"
173+
severity: warning
174+
175+
# numbers_smell:
176+
# regex: '(return |case |\w\(|: |\?\? |\, |== |<=? |>=? |\+= |\-= |\/= |\*= |%= |\w\.\w+ = )\(*\d{2,}'
177+
# message: "Numbers smell; define a constant instead."
178+
# severity: warning
179+
180+
auto_generated_leftovers:
181+
regex: 'func [^\n]*\{\n(\s*super\.[^\n]*\n(\s*\/\/[^\n]*\n)*|(\s*\/\/[^\n]*\n)+)\s*\}'
182+
message: "Delete auto-generated functions that you don't use"
183+
severity: warning
184+
185+
# empty_line_after_guard:
186+
# regex: '(^ *guard[ a-zA-Z0-9=?.\(\),><!]*\{[ a-zA-Z0-9=?.\(\),><!]*\}\n *(?!(?:return|guard))\S+)'
187+
# message: "There should be an empty line after a guard"
188+
# severity: error
189+
190+
empty_line_after_super:
191+
name: "Empty Line After Super"
192+
regex: '(^ *super\.[ a-zA-Z0-9=?.\(\)\{\}:,><!]*\n *(?!(?:\}|return))\S+)'
193+
message: "There should be an empty line after super"
194+
severity: error
195+
196+
multiple_empty_lines:
197+
name: "Multiple Empty Lines"
198+
regex: '((?:\s*\n){3,})'
199+
message: "There are too many line breaks"
200+
severity: error
201+
202+
protocol_conformance:
203+
included: ".*.swift"
204+
name: "Protocol Conformance"
205+
message: "Protocol conformance should be declared in separate extensions in the same file"
206+
regex: "(class|struct|extension)[[:space:]]+(?i:(?![^d]*delegate:))[^'\"()<>{},!?:]+:([^'\"<>(){},!?:]+,)+[^'\"<>(){},!?:]*\\{"
207+
match_kinds:
208+
- keyword
209+
severity: warning

Package.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// swift-tools-version: 5.8
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SQLiteCloud",
8+
platforms: [
9+
.macOS(.v12), .iOS(.v13), .watchOS(.v7)
10+
],
11+
products: [
12+
.library(
13+
name: "SQLiteCloud",
14+
targets: ["SQLiteCloud"]),
15+
],
16+
dependencies: [
17+
.package(url: "https://github.com/realm/SwiftLint", from: "0.52.4")
18+
],
19+
targets: [
20+
.target(
21+
name: "SQLiteCloud",
22+
dependencies: [
23+
.target(name: "CSQCloud")
24+
],
25+
swiftSettings: [
26+
.enableExperimentalFeature("StrictConcurrency")
27+
],
28+
plugins: [
29+
.plugin(name: "SwiftLintPlugin", package: "SwiftLint")
30+
]
31+
),
32+
.target(
33+
name: "CSQCloud",
34+
dependencies: ["libsqcloud"]
35+
),
36+
.binaryTarget(
37+
name: "libtls",
38+
path: "./Sources/libtls.xcframework"
39+
),
40+
.binaryTarget(
41+
name: "libsqcloud",
42+
path: "./Sources/libsqcloud.xcframework"
43+
),
44+
.testTarget(
45+
name: "SQLiteCloudTests",
46+
dependencies: ["SQLiteCloud"]
47+
),
48+
]
49+
)

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
# swift
2-
SQLite Cloud Swift
1+
# SQLiteCloud Swift Package
2+
3+
![SQLiteCloud Logo](https://sqlitecloud.io/static/image/c19460c9ed65bc09aea9.png)
4+
5+
SQLiteCloud is a powerful Swift package that allows you to interact with the SQLite Cloud backend server seamlessly. It provides methods for various database operations and real-time notifications. This package is designed to simplify database operations in Swift applications, making it easier than ever to work with SQLite Cloud.
6+
7+
## Features
8+
9+
- **Database Operations**: Easily perform database operations, including queries, updates, inserts, and more.
10+
11+
- **Real-time Notifications**: Get real-time notifications from the SQLite Cloud backend server.
12+
13+
- **Efficient**: SQLiteCloud is designed for efficiency, ensuring that your database operations are fast and reliable.
14+
15+
- **Swift Native:** Written in Swift for a seamless integration experience.
16+
17+
18+
## Installation
19+
20+
You can install SQLiteCloud Swift Package using Swift Package Manager (SPM). Add the following dependency to your `Package.swift` file:
21+
22+
```swift
23+
dependencies: [
24+
.package(url: "https://github.com/sqlitecloud/swift", from: "0.1.0")
25+
]
26+
```
27+
28+
## License
29+
SQLiteCloud is licensed under the MIT License. See the LICENSE file for details.

Sources/CSQCloud/brdige.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Sources/CSQCloud/include/bridge.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Header.h
3+
//
4+
//
5+
// Created by Massimo Oliviero on 13/09/23.
6+
//
7+
8+
#ifndef Bridge_h
9+
#define Bridge_h
10+
11+
#ifdef __OBJC__
12+
13+
// Add all required headers from the binary framework.
14+
#include "sqcloud.h"
15+
16+
#endif
17+
18+
19+
#include <stdio.h>
20+
21+
#endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// SQLiteCloud
3+
//
4+
// Created by Massimo Oliviero.
5+
//
6+
// Copyright (c) 2023 SQLite Cloud, Inc. (https://sqlitecloud.io/)
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in
16+
// all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
// THE SOFTWARE.
25+
26+
import Foundation
27+
28+
public let defaultBlobSizeThreshold = 1_048_576 // 1MB
29+
public let defaultBlobNumOfParts = 20
30+
public let defaultChunkHandler: CalculateChunkHandler = { dataSize in dataSize / defaultBlobNumOfParts }
31+
32+
public typealias Payloadable = Codable & Sendable
33+
public typealias Callback<A> = @Sendable (A) -> Void
34+
public typealias ProgressHandler = @Sendable (Double) -> Void
35+
public typealias CalculateChunkHandler = @Sendable (Int) -> Int
36+
public typealias NotificationHandler = Callback<SQLiteCloudPayload>

0 commit comments

Comments
 (0)