react-native-nitro-sqlite 8.2.1-nitro.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNNitroSQLite.podspec +59 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/CMakeLists.txt +38 -0
- package/android/build.gradle +119 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/cpp/cpp-adapter.cpp +21 -0
- package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLiteOnLoadModule.java +57 -0
- package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLitePackage.java +48 -0
- package/cpp/NitroSQLiteException.hpp +63 -0
- package/cpp/ThreadPool.cpp +91 -0
- package/cpp/ThreadPool.hpp +50 -0
- package/cpp/importSqlFile.cpp +48 -0
- package/cpp/importSqlFile.hpp +15 -0
- package/cpp/logs.hpp +38 -0
- package/cpp/macros.hpp +13 -0
- package/cpp/operations.cpp +296 -0
- package/cpp/operations.hpp +24 -0
- package/cpp/specs/HybridNativeQueryResult.cpp +20 -0
- package/cpp/specs/HybridNativeQueryResult.hpp +35 -0
- package/cpp/specs/HybridNitroSQLite.cpp +132 -0
- package/cpp/specs/HybridNitroSQLite.hpp +36 -0
- package/cpp/sqlite/sqlite3.c +237594 -0
- package/cpp/sqlite/sqlite3.h +12556 -0
- package/cpp/sqliteExecuteBatch.cpp +70 -0
- package/cpp/sqliteExecuteBatch.hpp +30 -0
- package/cpp/types.hpp +53 -0
- package/cpp/utils.hpp +61 -0
- package/ios/NitroSQLite.xcodeproj/project.pbxproj +447 -0
- package/ios/OnLoad.mm +41 -0
- package/ios/RNNitroSQLite-Swift.h +1 -0
- package/lib/commonjs/index.js +58 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/nitro.js +10 -0
- package/lib/commonjs/nitro.js.map +1 -0
- package/lib/commonjs/operations/execute.js +35 -0
- package/lib/commonjs/operations/execute.js.map +1 -0
- package/lib/commonjs/operations/session.js +39 -0
- package/lib/commonjs/operations/session.js.map +1 -0
- package/lib/commonjs/operations/transaction.js +95 -0
- package/lib/commonjs/operations/transaction.js.map +1 -0
- package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.ios.js +11 -0
- package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.ios.js.map +1 -0
- package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.js +9 -0
- package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.js.map +1 -0
- package/lib/commonjs/specs/NativeQueryResult.nitro.js +6 -0
- package/lib/commonjs/specs/NativeQueryResult.nitro.js.map +1 -0
- package/lib/commonjs/specs/NitroSQLite.nitro.js +6 -0
- package/lib/commonjs/specs/NitroSQLite.nitro.js.map +1 -0
- package/lib/commonjs/typeORM.js +62 -0
- package/lib/commonjs/typeORM.js.map +1 -0
- package/lib/commonjs/types.js +35 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/nitro.js +4 -0
- package/lib/module/nitro.js.map +1 -0
- package/lib/module/operations/execute.js +28 -0
- package/lib/module/operations/execute.js.map +1 -0
- package/lib/module/operations/session.js +31 -0
- package/lib/module/operations/session.js.map +1 -0
- package/lib/module/operations/transaction.js +88 -0
- package/lib/module/operations/transaction.js.map +1 -0
- package/lib/module/specs/NativeNitroSQLiteOnLoad.ios.js +5 -0
- package/lib/module/specs/NativeNitroSQLiteOnLoad.ios.js.map +1 -0
- package/lib/module/specs/NativeNitroSQLiteOnLoad.js +3 -0
- package/lib/module/specs/NativeNitroSQLiteOnLoad.js.map +1 -0
- package/lib/module/specs/NativeQueryResult.nitro.js +2 -0
- package/lib/module/specs/NativeQueryResult.nitro.js.map +1 -0
- package/lib/module/specs/NitroSQLite.nitro.js +2 -0
- package/lib/module/specs/NitroSQLite.nitro.js.map +1 -0
- package/lib/module/typeORM.js +54 -0
- package/lib/module/typeORM.js.map +1 -0
- package/lib/module/types.js +33 -0
- package/lib/module/types.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/typescript/index.d.ts +30 -0
- package/lib/typescript/nitro.d.ts +7 -0
- package/lib/typescript/operations/execute.d.ts +3 -0
- package/lib/typescript/operations/session.d.ts +4 -0
- package/lib/typescript/operations/transaction.d.ts +5 -0
- package/lib/typescript/specs/NativeNitroSQLiteOnLoad.d.ts +6 -0
- package/lib/typescript/specs/NativeNitroSQLiteOnLoad.ios.d.ts +3 -0
- package/lib/typescript/specs/NativeQueryResult.nitro.d.ts +37 -0
- package/lib/typescript/specs/NitroSQLite.nitro.d.ts +19 -0
- package/lib/typescript/typeORM.d.ts +19 -0
- package/lib/typescript/types.d.ts +79 -0
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +48 -0
- package/nitrogen/generated/android/RNNitroSQLite+autolinking.gradle +25 -0
- package/nitrogen/generated/android/RNNitroSQLiteOnLoad.cpp +40 -0
- package/nitrogen/generated/android/RNNitroSQLiteOnLoad.hpp +25 -0
- package/nitrogen/generated/android/RNNitroSQLiteOnLoad.kt +1 -0
- package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +56 -0
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.hpp +303 -0
- package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Umbrella.hpp +67 -0
- package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.mm +35 -0
- package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.swift +10 -0
- package/nitrogen/generated/shared/c++/BatchQueryCommand.hpp +77 -0
- package/nitrogen/generated/shared/c++/BatchQueryResult.hpp +68 -0
- package/nitrogen/generated/shared/c++/ColumnType.hpp +68 -0
- package/nitrogen/generated/shared/c++/FileLoadResult.hpp +72 -0
- package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.cpp +31 -0
- package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +91 -0
- package/nitrogen/generated/shared/c++/SQLiteQueryColumnMetadata.hpp +78 -0
- package/package.json +98 -0
- package/src/index.ts +26 -0
- package/src/nitro.ts +11 -0
- package/src/operations/execute.ts +45 -0
- package/src/operations/session.ts +58 -0
- package/src/operations/transaction.ts +137 -0
- package/src/specs/NativeNitroSQLiteOnLoad.ios.ts +7 -0
- package/src/specs/NativeNitroSQLiteOnLoad.ts +7 -0
- package/src/specs/NativeQueryResult.nitro.ts +44 -0
- package/src/specs/NitroSQLite.nitro.ts +39 -0
- package/src/typeORM.ts +101 -0
- package/src/types.ts +105 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RNNitroSQLiteAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridNitroSQLite.hpp"
|
|
14
|
+
|
|
15
|
+
@interface RNNitroSQLiteAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation RNNitroSQLiteAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::rnnitrosqlite;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"NitroSQLite",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
static_assert(std::is_default_constructible_v<HybridNitroSQLite>,
|
|
28
|
+
"The HybridObject \"HybridNitroSQLite\" is not default-constructible! "
|
|
29
|
+
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
30
|
+
return std::make_shared<HybridNitroSQLite>();
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BatchQueryCommand.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
22
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
23
|
+
|
|
24
|
+
#include <string>
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include <variant>
|
|
27
|
+
#include <vector>
|
|
28
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (BatchQueryCommand).
|
|
34
|
+
*/
|
|
35
|
+
struct BatchQueryCommand {
|
|
36
|
+
public:
|
|
37
|
+
std::string query SWIFT_PRIVATE;
|
|
38
|
+
std::optional<std::variant<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>, std::vector<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>>> params SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
explicit BatchQueryCommand(std::string query, std::optional<std::variant<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>, std::vector<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>>> params): query(query), params(params) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
using namespace margelo::nitro::rnnitrosqlite;
|
|
49
|
+
|
|
50
|
+
// C++ BatchQueryCommand <> JS BatchQueryCommand (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<BatchQueryCommand> {
|
|
53
|
+
static inline BatchQueryCommand fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return BatchQueryCommand(
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "query")),
|
|
57
|
+
JSIConverter<std::optional<std::variant<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>, std::vector<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>>>>::fromJSI(runtime, obj.getProperty(runtime, "params"))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const BatchQueryCommand& arg) {
|
|
61
|
+
jsi::Object obj(runtime);
|
|
62
|
+
obj.setProperty(runtime, "query", JSIConverter<std::string>::toJSI(runtime, arg.query));
|
|
63
|
+
obj.setProperty(runtime, "params", JSIConverter<std::optional<std::variant<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>, std::vector<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>>>>::toJSI(runtime, arg.params));
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isObject()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
jsi::Object obj = value.getObject(runtime);
|
|
71
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "query"))) return false;
|
|
72
|
+
if (!JSIConverter<std::optional<std::variant<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>, std::vector<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>>>>::canConvert(runtime, obj.getProperty(runtime, "params"))) return false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BatchQueryResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#include <optional>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A struct which can be represented as a JavaScript object (BatchQueryResult).
|
|
29
|
+
*/
|
|
30
|
+
struct BatchQueryResult {
|
|
31
|
+
public:
|
|
32
|
+
std::optional<double> rowsAffected SWIFT_PRIVATE;
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
explicit BatchQueryResult(std::optional<double> rowsAffected): rowsAffected(rowsAffected) {}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
using namespace margelo::nitro::rnnitrosqlite;
|
|
43
|
+
|
|
44
|
+
// C++ BatchQueryResult <> JS BatchQueryResult (object)
|
|
45
|
+
template <>
|
|
46
|
+
struct JSIConverter<BatchQueryResult> {
|
|
47
|
+
static inline BatchQueryResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
48
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
49
|
+
return BatchQueryResult(
|
|
50
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "rowsAffected"))
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const BatchQueryResult& arg) {
|
|
54
|
+
jsi::Object obj(runtime);
|
|
55
|
+
obj.setProperty(runtime, "rowsAffected", JSIConverter<std::optional<double>>::toJSI(runtime, arg.rowsAffected));
|
|
56
|
+
return obj;
|
|
57
|
+
}
|
|
58
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
59
|
+
if (!value.isObject()) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
jsi::Object obj = value.getObject(runtime);
|
|
63
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "rowsAffected"))) return false;
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ColumnType.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <cmath>
|
|
11
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
13
|
+
#else
|
|
14
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
15
|
+
#endif
|
|
16
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
17
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
18
|
+
#else
|
|
19
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* An enum which can be represented as a JavaScript enum (ColumnType).
|
|
26
|
+
*/
|
|
27
|
+
enum class ColumnType {
|
|
28
|
+
BOOLEAN SWIFT_NAME(boolean) = 0,
|
|
29
|
+
NUMBER SWIFT_NAME(number) = 1,
|
|
30
|
+
INT64 SWIFT_NAME(int64) = 2,
|
|
31
|
+
TEXT SWIFT_NAME(text) = 3,
|
|
32
|
+
ARRAY_BUFFER SWIFT_NAME(arrayBuffer) = 4,
|
|
33
|
+
NULL_VALUE SWIFT_NAME(nullValue) = 5,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
using namespace margelo::nitro::rnnitrosqlite;
|
|
41
|
+
|
|
42
|
+
// C++ ColumnType <> JS ColumnType (enum)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<ColumnType> {
|
|
45
|
+
static inline ColumnType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
47
|
+
return static_cast<ColumnType>(enumValue);
|
|
48
|
+
}
|
|
49
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, ColumnType arg) {
|
|
50
|
+
int enumValue = static_cast<int>(arg);
|
|
51
|
+
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
52
|
+
}
|
|
53
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
54
|
+
if (!value.isNumber()) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
double integer;
|
|
58
|
+
double fraction = modf(value.getNumber(), &integer);
|
|
59
|
+
if (fraction != 0.0) {
|
|
60
|
+
// It is some kind of floating point number - our enums are ints.
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Check if we are within the bounds of the enum.
|
|
64
|
+
return integer >= 0 && integer <= 5;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// FileLoadResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#include <optional>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A struct which can be represented as a JavaScript object (FileLoadResult).
|
|
29
|
+
*/
|
|
30
|
+
struct FileLoadResult {
|
|
31
|
+
public:
|
|
32
|
+
std::optional<double> commands SWIFT_PRIVATE;
|
|
33
|
+
std::optional<double> rowsAffected SWIFT_PRIVATE;
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
explicit FileLoadResult(std::optional<double> commands, std::optional<double> rowsAffected): commands(commands), rowsAffected(rowsAffected) {}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro {
|
|
42
|
+
|
|
43
|
+
using namespace margelo::nitro::rnnitrosqlite;
|
|
44
|
+
|
|
45
|
+
// C++ FileLoadResult <> JS FileLoadResult (object)
|
|
46
|
+
template <>
|
|
47
|
+
struct JSIConverter<FileLoadResult> {
|
|
48
|
+
static inline FileLoadResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
49
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
50
|
+
return FileLoadResult(
|
|
51
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "commands")),
|
|
52
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "rowsAffected"))
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const FileLoadResult& arg) {
|
|
56
|
+
jsi::Object obj(runtime);
|
|
57
|
+
obj.setProperty(runtime, "commands", JSIConverter<std::optional<double>>::toJSI(runtime, arg.commands));
|
|
58
|
+
obj.setProperty(runtime, "rowsAffected", JSIConverter<std::optional<double>>::toJSI(runtime, arg.rowsAffected));
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isObject()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
jsi::Object obj = value.getObject(runtime);
|
|
66
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "commands"))) return false;
|
|
67
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "rowsAffected"))) return false;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNativeQueryResultSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNativeQueryResultSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
11
|
+
|
|
12
|
+
void HybridNativeQueryResultSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("rowsAffected", &HybridNativeQueryResultSpec::getRowsAffected);
|
|
18
|
+
prototype.registerHybridGetter("insertId", &HybridNativeQueryResultSpec::getInsertId);
|
|
19
|
+
prototype.registerHybridGetter("results", &HybridNativeQueryResultSpec::getResults);
|
|
20
|
+
prototype.registerHybridGetter("metadata", &HybridNativeQueryResultSpec::getMetadata);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNativeQueryResultSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
17
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
18
|
+
// Forward declaration of `SQLiteQueryColumnMetadata` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::rnnitrosqlite { struct SQLiteQueryColumnMetadata; }
|
|
20
|
+
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <vector>
|
|
23
|
+
#include <unordered_map>
|
|
24
|
+
#include <string>
|
|
25
|
+
#include <variant>
|
|
26
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
27
|
+
#include "SQLiteQueryColumnMetadata.hpp"
|
|
28
|
+
|
|
29
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
30
|
+
|
|
31
|
+
using namespace margelo::nitro;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An abstract base class for `NativeQueryResult`
|
|
35
|
+
* Inherit this class to create instances of `HybridNativeQueryResultSpec` in C++.
|
|
36
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
37
|
+
* @example
|
|
38
|
+
* ```cpp
|
|
39
|
+
* class HybridNativeQueryResult: public HybridNativeQueryResultSpec {
|
|
40
|
+
* public:
|
|
41
|
+
* HybridNativeQueryResult(...): HybridObject(TAG) { ... }
|
|
42
|
+
* // ...
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
class HybridNativeQueryResultSpec: public virtual HybridObject {
|
|
47
|
+
public:
|
|
48
|
+
// Constructor
|
|
49
|
+
explicit HybridNativeQueryResultSpec(): HybridObject(TAG) { }
|
|
50
|
+
|
|
51
|
+
// Destructor
|
|
52
|
+
virtual ~HybridNativeQueryResultSpec() { }
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Properties
|
|
56
|
+
virtual double getRowsAffected() = 0;
|
|
57
|
+
virtual std::optional<double> getInsertId() = 0;
|
|
58
|
+
virtual std::vector<std::unordered_map<std::string, std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>> getResults() = 0;
|
|
59
|
+
virtual std::optional<std::unordered_map<std::string, SQLiteQueryColumnMetadata>> getMetadata() = 0;
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
// Methods
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
protected:
|
|
66
|
+
// Hybrid Setup
|
|
67
|
+
void loadHybridMethods() override;
|
|
68
|
+
|
|
69
|
+
protected:
|
|
70
|
+
// Tag for logging
|
|
71
|
+
static constexpr auto TAG = "NativeQueryResult";
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSQLiteSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroSQLiteSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
11
|
+
|
|
12
|
+
void HybridNitroSQLiteSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("open", &HybridNitroSQLiteSpec::open);
|
|
18
|
+
prototype.registerHybridMethod("close", &HybridNitroSQLiteSpec::close);
|
|
19
|
+
prototype.registerHybridMethod("drop", &HybridNitroSQLiteSpec::drop);
|
|
20
|
+
prototype.registerHybridMethod("attach", &HybridNitroSQLiteSpec::attach);
|
|
21
|
+
prototype.registerHybridMethod("detach", &HybridNitroSQLiteSpec::detach);
|
|
22
|
+
prototype.registerHybridMethod("execute", &HybridNitroSQLiteSpec::execute);
|
|
23
|
+
prototype.registerHybridMethod("executeAsync", &HybridNitroSQLiteSpec::executeAsync);
|
|
24
|
+
prototype.registerHybridMethod("executeBatch", &HybridNitroSQLiteSpec::executeBatch);
|
|
25
|
+
prototype.registerHybridMethod("executeBatchAsync", &HybridNitroSQLiteSpec::executeBatchAsync);
|
|
26
|
+
prototype.registerHybridMethod("loadFile", &HybridNitroSQLiteSpec::loadFile);
|
|
27
|
+
prototype.registerHybridMethod("loadFileAsync", &HybridNitroSQLiteSpec::loadFileAsync);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSQLiteSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `HybridNativeQueryResultSpec` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::rnnitrosqlite { class HybridNativeQueryResultSpec; }
|
|
18
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
19
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
20
|
+
// Forward declaration of `BatchQueryResult` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::rnnitrosqlite { struct BatchQueryResult; }
|
|
22
|
+
// Forward declaration of `BatchQueryCommand` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::rnnitrosqlite { struct BatchQueryCommand; }
|
|
24
|
+
// Forward declaration of `FileLoadResult` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::rnnitrosqlite { struct FileLoadResult; }
|
|
26
|
+
|
|
27
|
+
#include <string>
|
|
28
|
+
#include <optional>
|
|
29
|
+
#include <memory>
|
|
30
|
+
#include "HybridNativeQueryResultSpec.hpp"
|
|
31
|
+
#include <vector>
|
|
32
|
+
#include <variant>
|
|
33
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
34
|
+
#include <future>
|
|
35
|
+
#include "BatchQueryResult.hpp"
|
|
36
|
+
#include "BatchQueryCommand.hpp"
|
|
37
|
+
#include "FileLoadResult.hpp"
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
40
|
+
|
|
41
|
+
using namespace margelo::nitro;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* An abstract base class for `NitroSQLite`
|
|
45
|
+
* Inherit this class to create instances of `HybridNitroSQLiteSpec` in C++.
|
|
46
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
47
|
+
* @example
|
|
48
|
+
* ```cpp
|
|
49
|
+
* class HybridNitroSQLite: public HybridNitroSQLiteSpec {
|
|
50
|
+
* public:
|
|
51
|
+
* HybridNitroSQLite(...): HybridObject(TAG) { ... }
|
|
52
|
+
* // ...
|
|
53
|
+
* };
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
class HybridNitroSQLiteSpec: public virtual HybridObject {
|
|
57
|
+
public:
|
|
58
|
+
// Constructor
|
|
59
|
+
explicit HybridNitroSQLiteSpec(): HybridObject(TAG) { }
|
|
60
|
+
|
|
61
|
+
// Destructor
|
|
62
|
+
virtual ~HybridNitroSQLiteSpec() { }
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
// Properties
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
// Methods
|
|
70
|
+
virtual void open(const std::string& dbName, const std::optional<std::string>& location) = 0;
|
|
71
|
+
virtual void close(const std::string& dbName) = 0;
|
|
72
|
+
virtual void drop(const std::string& dbName, const std::optional<std::string>& location) = 0;
|
|
73
|
+
virtual void attach(const std::string& mainDbName, const std::string& dbNameToAttach, const std::string& alias, const std::optional<std::string>& location) = 0;
|
|
74
|
+
virtual void detach(const std::string& mainDbName, const std::string& alias) = 0;
|
|
75
|
+
virtual std::shared_ptr<margelo::nitro::rnnitrosqlite::HybridNativeQueryResultSpec> execute(const std::string& dbName, const std::string& query, const std::optional<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>& params) = 0;
|
|
76
|
+
virtual std::future<std::shared_ptr<margelo::nitro::rnnitrosqlite::HybridNativeQueryResultSpec>> executeAsync(const std::string& dbName, const std::string& query, const std::optional<std::vector<std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>>>& params) = 0;
|
|
77
|
+
virtual BatchQueryResult executeBatch(const std::string& dbName, const std::vector<BatchQueryCommand>& commands) = 0;
|
|
78
|
+
virtual std::future<BatchQueryResult> executeBatchAsync(const std::string& dbName, const std::vector<BatchQueryCommand>& commands) = 0;
|
|
79
|
+
virtual FileLoadResult loadFile(const std::string& dbName, const std::string& location) = 0;
|
|
80
|
+
virtual std::future<FileLoadResult> loadFileAsync(const std::string& dbName, const std::string& location) = 0;
|
|
81
|
+
|
|
82
|
+
protected:
|
|
83
|
+
// Hybrid Setup
|
|
84
|
+
void loadHybridMethods() override;
|
|
85
|
+
|
|
86
|
+
protected:
|
|
87
|
+
// Tag for logging
|
|
88
|
+
static constexpr auto TAG = "NitroSQLite";
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SQLiteQueryColumnMetadata.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2024 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Forward declaration of `ColumnType` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rnnitrosqlite { enum class ColumnType; }
|
|
23
|
+
|
|
24
|
+
#include <string>
|
|
25
|
+
#include "ColumnType.hpp"
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::rnnitrosqlite {
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A struct which can be represented as a JavaScript object (SQLiteQueryColumnMetadata).
|
|
31
|
+
*/
|
|
32
|
+
struct SQLiteQueryColumnMetadata {
|
|
33
|
+
public:
|
|
34
|
+
std::string name SWIFT_PRIVATE;
|
|
35
|
+
ColumnType type SWIFT_PRIVATE;
|
|
36
|
+
double index SWIFT_PRIVATE;
|
|
37
|
+
|
|
38
|
+
public:
|
|
39
|
+
explicit SQLiteQueryColumnMetadata(std::string name, ColumnType type, double index): name(name), type(type), index(index) {}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
} // namespace margelo::nitro::rnnitrosqlite
|
|
43
|
+
|
|
44
|
+
namespace margelo::nitro {
|
|
45
|
+
|
|
46
|
+
using namespace margelo::nitro::rnnitrosqlite;
|
|
47
|
+
|
|
48
|
+
// C++ SQLiteQueryColumnMetadata <> JS SQLiteQueryColumnMetadata (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<SQLiteQueryColumnMetadata> {
|
|
51
|
+
static inline SQLiteQueryColumnMetadata fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return SQLiteQueryColumnMetadata(
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "name")),
|
|
55
|
+
JSIConverter<ColumnType>::fromJSI(runtime, obj.getProperty(runtime, "type")),
|
|
56
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "index"))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const SQLiteQueryColumnMetadata& arg) {
|
|
60
|
+
jsi::Object obj(runtime);
|
|
61
|
+
obj.setProperty(runtime, "name", JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
62
|
+
obj.setProperty(runtime, "type", JSIConverter<ColumnType>::toJSI(runtime, arg.type));
|
|
63
|
+
obj.setProperty(runtime, "index", JSIConverter<double>::toJSI(runtime, arg.index));
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isObject()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
jsi::Object obj = value.getObject(runtime);
|
|
71
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
|
|
72
|
+
if (!JSIConverter<ColumnType>::canConvert(runtime, obj.getProperty(runtime, "type"))) return false;
|
|
73
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "index"))) return false;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro
|