@powersync/op-sqlite 0.0.0-dev-20241107150304 → 0.0.0-dev-20250121114305
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/README.md +36 -0
- package/lib/{typescript/commonjs/src → src}/db/OPSQLiteConnection.d.ts +11 -2
- package/lib/src/db/OPSQLiteConnection.js +118 -0
- package/lib/{typescript/commonjs/src → src}/db/OPSqliteAdapter.d.ts +3 -2
- package/lib/src/db/OPSqliteAdapter.js +267 -0
- package/lib/{typescript/commonjs/src → src}/db/OPSqliteDBOpenFactory.d.ts +0 -1
- package/lib/src/db/OPSqliteDBOpenFactory.js +15 -0
- package/lib/{typescript/module/src → src}/db/SqliteOptions.d.ts +9 -2
- package/lib/src/db/SqliteOptions.js +29 -0
- package/lib/{typescript/commonjs/src → src}/index.d.ts +0 -2
- package/lib/src/index.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +11 -80
- package/android/build.gradle +0 -124
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/powersync/opsqlite/PowerSyncOpSqliteModule.kt +0 -25
- package/android/src/main/java/com/powersync/opsqlite/PowerSyncOpSqlitePackage.kt +0 -35
- package/android/src/newarch/PowerSyncOpSqliteSpec.kt +0 -7
- package/android/src/oldarch/PowerSyncOpSqliteSpec.kt +0 -11
- package/ios/PowerSyncOpSqlite.h +0 -5
- package/ios/PowerSyncOpSqlite.mm +0 -11
- package/lib/commonjs/NativePowerSyncOpSqlite.js +0 -9
- package/lib/commonjs/NativePowerSyncOpSqlite.js.map +0 -1
- package/lib/commonjs/db/OPSQLiteConnection.js +0 -77
- package/lib/commonjs/db/OPSQLiteConnection.js.map +0 -1
- package/lib/commonjs/db/OPSqliteAdapter.js +0 -234
- package/lib/commonjs/db/OPSqliteAdapter.js.map +0 -1
- package/lib/commonjs/db/OPSqliteDBOpenFactory.js +0 -26
- package/lib/commonjs/db/OPSqliteDBOpenFactory.js.map +0 -1
- package/lib/commonjs/db/SqliteOptions.js +0 -32
- package/lib/commonjs/db/SqliteOptions.js.map +0 -1
- package/lib/commonjs/index.js +0 -35
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/NativePowerSyncOpSqlite.js +0 -5
- package/lib/module/NativePowerSyncOpSqlite.js.map +0 -1
- package/lib/module/db/OPSQLiteConnection.js +0 -72
- package/lib/module/db/OPSQLiteConnection.js.map +0 -1
- package/lib/module/db/OPSqliteAdapter.js +0 -229
- package/lib/module/db/OPSqliteAdapter.js.map +0 -1
- package/lib/module/db/OPSqliteDBOpenFactory.js +0 -21
- package/lib/module/db/OPSqliteDBOpenFactory.js.map +0 -1
- package/lib/module/db/SqliteOptions.js +0 -28
- package/lib/module/db/SqliteOptions.js.map +0 -1
- package/lib/module/index.js +0 -19
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/NativePowerSyncOpSqlite.d.ts +0 -7
- package/lib/typescript/commonjs/src/NativePowerSyncOpSqlite.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/OPSQLiteConnection.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/OPSqliteAdapter.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/OPSqliteDBOpenFactory.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/db/SqliteOptions.d.ts +0 -44
- package/lib/typescript/commonjs/src/db/SqliteOptions.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +0 -1
- package/lib/typescript/module/package.json +0 -1
- package/lib/typescript/module/src/NativePowerSyncOpSqlite.d.ts +0 -7
- package/lib/typescript/module/src/NativePowerSyncOpSqlite.d.ts.map +0 -1
- package/lib/typescript/module/src/db/OPSQLiteConnection.d.ts +0 -17
- package/lib/typescript/module/src/db/OPSQLiteConnection.d.ts.map +0 -1
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts +0 -43
- package/lib/typescript/module/src/db/OPSqliteAdapter.d.ts.map +0 -1
- package/lib/typescript/module/src/db/OPSqliteDBOpenFactory.d.ts +0 -12
- package/lib/typescript/module/src/db/OPSqliteDBOpenFactory.d.ts.map +0 -1
- package/lib/typescript/module/src/db/SqliteOptions.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -3
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +0 -1
- package/powersync-op-sqlite.podspec +0 -26
- package/src/NativePowerSyncOpSqlite.ts +0 -8
- package/src/db/OPSQLiteConnection.ts +0 -82
- package/src/db/OPSqliteAdapter.ts +0 -274
- package/src/db/OPSqliteDBOpenFactory.ts +0 -25
- package/src/db/SqliteOptions.ts +0 -61
- package/src/index.ts +0 -30
package/package.json
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/op-sqlite",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20250121114305",
|
|
4
4
|
"description": "PowerSync - sync Postgres or MongoDB with SQLite in your React Native app for offline-first and real-time data",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
|
-
"main": "
|
|
7
|
-
"
|
|
8
|
-
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./lib/typescript/module/src/index.d.ts",
|
|
13
|
-
"default": "./lib/module/index.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
17
|
-
"default": "./lib/commonjs/index.js"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
6
|
+
"main": "lib/src/index.js",
|
|
7
|
+
"types": "lib/src/index.d.ts",
|
|
21
8
|
"files": [
|
|
22
|
-
"
|
|
23
|
-
"lib",
|
|
24
|
-
"android",
|
|
25
|
-
"ios",
|
|
26
|
-
"cpp",
|
|
27
|
-
"*.podspec",
|
|
28
|
-
"!ios/build",
|
|
29
|
-
"!android/build",
|
|
30
|
-
"!android/gradle",
|
|
31
|
-
"!android/gradlew",
|
|
32
|
-
"!android/gradlew.bat",
|
|
33
|
-
"!android/local.properties",
|
|
34
|
-
"!**/__tests__",
|
|
35
|
-
"!**/__fixtures__",
|
|
36
|
-
"!**/__mocks__",
|
|
37
|
-
"!**/.*"
|
|
9
|
+
"lib"
|
|
38
10
|
],
|
|
39
11
|
"keywords": [
|
|
40
12
|
"data sync",
|
|
@@ -58,17 +30,17 @@
|
|
|
58
30
|
"access": "public"
|
|
59
31
|
},
|
|
60
32
|
"peerDependencies": {
|
|
61
|
-
"@op-engineering/op-sqlite": "^
|
|
62
|
-
"@powersync/common": "
|
|
33
|
+
"@op-engineering/op-sqlite": "^11.2.13",
|
|
34
|
+
"@powersync/common": "^1.22.2",
|
|
63
35
|
"react": "*",
|
|
64
36
|
"react-native": "*"
|
|
65
37
|
},
|
|
66
38
|
"dependencies": {
|
|
67
39
|
"async-lock": "^1.4.0",
|
|
68
|
-
"@powersync/common": "
|
|
40
|
+
"@powersync/common": "1.22.2"
|
|
69
41
|
},
|
|
70
42
|
"devDependencies": {
|
|
71
|
-
"@op-engineering/op-sqlite": "^
|
|
43
|
+
"@op-engineering/op-sqlite": "^11.2.13",
|
|
72
44
|
"@react-native/eslint-config": "^0.73.1",
|
|
73
45
|
"@types/async-lock": "^1.4.0",
|
|
74
46
|
"@types/react": "^18.2.44",
|
|
@@ -79,58 +51,17 @@
|
|
|
79
51
|
"prettier": "^3.0.3",
|
|
80
52
|
"react": "18.3.1",
|
|
81
53
|
"react-native": "0.75.3",
|
|
82
|
-
"react-native-builder-bob": "^0.30.2",
|
|
83
|
-
"turbo": "^1.10.7",
|
|
84
54
|
"typescript": "^5.2.2"
|
|
85
55
|
},
|
|
86
56
|
"eslintIgnore": [
|
|
87
57
|
"node_modules/",
|
|
88
58
|
"lib/"
|
|
89
59
|
],
|
|
90
|
-
"react-native-builder-bob": {
|
|
91
|
-
"source": "src",
|
|
92
|
-
"output": "lib",
|
|
93
|
-
"targets": [
|
|
94
|
-
"codegen",
|
|
95
|
-
[
|
|
96
|
-
"commonjs",
|
|
97
|
-
{
|
|
98
|
-
"esm": true
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
[
|
|
102
|
-
"module",
|
|
103
|
-
{
|
|
104
|
-
"esm": true
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
[
|
|
108
|
-
"typescript",
|
|
109
|
-
{
|
|
110
|
-
"project": "tsconfig.build.json",
|
|
111
|
-
"esm": true,
|
|
112
|
-
"tsc": "../../node_modules/.bin/tsc"
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
]
|
|
116
|
-
},
|
|
117
|
-
"codegenConfig": {
|
|
118
|
-
"name": "RNPowerSyncOpSqliteSpec",
|
|
119
|
-
"type": "modules",
|
|
120
|
-
"jsSrcsDir": "src",
|
|
121
|
-
"outputDir": {
|
|
122
|
-
"ios": "codegen",
|
|
123
|
-
"android": "codegen"
|
|
124
|
-
},
|
|
125
|
-
"android": {
|
|
126
|
-
"javaPackageName": "com.powersync.opsqlite"
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
60
|
"scripts": {
|
|
130
|
-
"build": "
|
|
131
|
-
"build:prod": "
|
|
61
|
+
"build": "tsc --build",
|
|
62
|
+
"build:prod": "tsc --build --sourceMap false",
|
|
132
63
|
"typecheck": "tsc",
|
|
133
64
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
134
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib"
|
|
65
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib node_modules"
|
|
135
66
|
}
|
|
136
67
|
}
|
package/android/build.gradle
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
buildscript {
|
|
2
|
-
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["OpSqlite_kotlinVersion"]
|
|
4
|
-
|
|
5
|
-
repositories {
|
|
6
|
-
google()
|
|
7
|
-
mavenCentral()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
-
// noinspection DifferentKotlinGradleVersion
|
|
13
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
def reactNativeArchitectures() {
|
|
18
|
-
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
def isNewArchitectureEnabled() {
|
|
23
|
-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
apply plugin: "com.android.library"
|
|
27
|
-
apply plugin: "kotlin-android"
|
|
28
|
-
|
|
29
|
-
if (isNewArchitectureEnabled()) {
|
|
30
|
-
apply plugin: "com.facebook.react"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
def getExtOrDefault(name) {
|
|
34
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["PowerSyncOpSqlite_" + name]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
def getExtOrIntegerDefault(name) {
|
|
38
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PowerSyncOpSqlite_" + name]).toInteger()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
def supportsNamespace() {
|
|
42
|
-
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
43
|
-
def major = parsed[0].toInteger()
|
|
44
|
-
def minor = parsed[1].toInteger()
|
|
45
|
-
|
|
46
|
-
// Namespace support was added in 7.3.0
|
|
47
|
-
return (major == 7 && minor >= 3) || major >= 8
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
android {
|
|
51
|
-
if (supportsNamespace()) {
|
|
52
|
-
namespace "com.powersync.opsqlite"
|
|
53
|
-
|
|
54
|
-
sourceSets {
|
|
55
|
-
main {
|
|
56
|
-
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
62
|
-
|
|
63
|
-
defaultConfig {
|
|
64
|
-
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
65
|
-
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
66
|
-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
buildFeatures {
|
|
71
|
-
buildConfig true
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
buildTypes {
|
|
75
|
-
release {
|
|
76
|
-
minifyEnabled false
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
lintOptions {
|
|
81
|
-
disable "GradleCompatible"
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
compileOptions {
|
|
85
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
86
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
sourceSets {
|
|
90
|
-
main {
|
|
91
|
-
if (isNewArchitectureEnabled()) {
|
|
92
|
-
java.srcDirs += [
|
|
93
|
-
"src/newarch"
|
|
94
|
-
]
|
|
95
|
-
} else {
|
|
96
|
-
java.srcDirs += ["src/oldarch"]
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
repositories {
|
|
103
|
-
mavenCentral()
|
|
104
|
-
google()
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
108
|
-
|
|
109
|
-
dependencies {
|
|
110
|
-
implementation 'co.powersync:powersync-sqlite-core:0.3.0'
|
|
111
|
-
// For < 0.71, this will be from the local maven repo
|
|
112
|
-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
113
|
-
//noinspection GradleDynamicVersion
|
|
114
|
-
implementation "com.facebook.react:react-native:+"
|
|
115
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (isNewArchitectureEnabled()) {
|
|
119
|
-
react {
|
|
120
|
-
jsRootDir = file("../src/")
|
|
121
|
-
libraryName = "PowerSyncOpSqlite"
|
|
122
|
-
codegenJavaPackageName = "com.powersync.opsqlite"
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.powersync.opsqlite
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
import com.facebook.react.bridge.ReactMethod
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
|
-
|
|
7
|
-
class PowerSyncOpSqliteModule internal constructor(context: ReactApplicationContext) :
|
|
8
|
-
PowerSyncOpSqliteSpec(context) {
|
|
9
|
-
|
|
10
|
-
@ReactMethod
|
|
11
|
-
override fun getBundlePath(): String {
|
|
12
|
-
//This method should only be used for iOS platforms
|
|
13
|
-
//Ensure you wrap its usage with a (Platform.OS === 'ios') check
|
|
14
|
-
//Returns an empty string for android
|
|
15
|
-
return ""
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override fun getName(): String {
|
|
19
|
-
return NAME
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
companion object {
|
|
23
|
-
const val NAME = "PowerSyncOpSqlite"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
package com.powersync.opsqlite
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.TurboReactPackage
|
|
4
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
-
import com.facebook.react.bridge.NativeModule
|
|
6
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
-
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
-
import java.util.HashMap
|
|
9
|
-
|
|
10
|
-
class PowerSyncOpSqlitePackage : TurboReactPackage() {
|
|
11
|
-
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
-
return if (name == PowerSyncOpSqliteModule.NAME) {
|
|
13
|
-
PowerSyncOpSqliteModule(reactContext)
|
|
14
|
-
} else {
|
|
15
|
-
null
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
-
return ReactModuleInfoProvider {
|
|
21
|
-
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
-
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
23
|
-
moduleInfos[PowerSyncOpSqliteModule.NAME] = ReactModuleInfo(
|
|
24
|
-
PowerSyncOpSqliteModule.NAME,
|
|
25
|
-
PowerSyncOpSqliteModule.NAME,
|
|
26
|
-
false, // canOverrideExistingModule
|
|
27
|
-
false, // needsEagerInit
|
|
28
|
-
true, // hasConstants
|
|
29
|
-
false, // isCxxModule
|
|
30
|
-
isTurboModule // isTurboModule
|
|
31
|
-
)
|
|
32
|
-
moduleInfos
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
package com.powersync.opsqlite
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
|
-
|
|
7
|
-
abstract class PowerSyncOpSqliteSpec internal constructor(context: ReactApplicationContext) :
|
|
8
|
-
ReactContextBaseJavaModule(context) {
|
|
9
|
-
|
|
10
|
-
abstract fun getBundlePath(): String
|
|
11
|
-
}
|
package/ios/PowerSyncOpSqlite.h
DELETED
package/ios/PowerSyncOpSqlite.mm
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('PowerSyncOpSqlite');
|
|
9
|
-
//# sourceMappingURL=NativePowerSyncOpSqlite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativePowerSyncOpSqlite.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAMpCC,gCAAmB,CAACC,YAAY,CAAO,mBAAmB,CAAC","ignoreList":[]}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.OPSQLiteConnection = void 0;
|
|
7
|
-
var _common = require("@powersync/common");
|
|
8
|
-
class OPSQLiteConnection extends _common.BaseObserver {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
super();
|
|
11
|
-
this.options = options;
|
|
12
|
-
this.DB = options.baseDB;
|
|
13
|
-
|
|
14
|
-
// link table update commands
|
|
15
|
-
this.DB.updateHook(update => {
|
|
16
|
-
this.iterateListeners(cb => {
|
|
17
|
-
let opType;
|
|
18
|
-
switch (update.operation) {
|
|
19
|
-
case 'INSERT':
|
|
20
|
-
opType = _common.RowUpdateType.SQLITE_INSERT;
|
|
21
|
-
break;
|
|
22
|
-
case 'DELETE':
|
|
23
|
-
opType = _common.RowUpdateType.SQLITE_DELETE;
|
|
24
|
-
break;
|
|
25
|
-
case 'UPDATE':
|
|
26
|
-
opType = _common.RowUpdateType.SQLITE_UPDATE;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
cb.tablesUpdated?.({
|
|
30
|
-
table: update.table,
|
|
31
|
-
opType,
|
|
32
|
-
rowId: update.rowId
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
close() {
|
|
38
|
-
return this.DB.close();
|
|
39
|
-
}
|
|
40
|
-
async execute(query, params) {
|
|
41
|
-
const res = await this.DB.execute(query, params);
|
|
42
|
-
return {
|
|
43
|
-
insertId: res.insertId,
|
|
44
|
-
rowsAffected: res.rowsAffected,
|
|
45
|
-
rows: {
|
|
46
|
-
_array: res.rows ?? [],
|
|
47
|
-
length: res.rows?.length ?? 0,
|
|
48
|
-
item: index => res.rows?.[index]
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async executeBatch(query, params = []) {
|
|
53
|
-
const tuple = [[query, params[0]]];
|
|
54
|
-
params.slice(1).forEach(p => tuple.push([query, p]));
|
|
55
|
-
const result = await this.DB.executeBatch(tuple);
|
|
56
|
-
return {
|
|
57
|
-
rowsAffected: result.rowsAffected ?? 0
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
async getAll(sql, parameters) {
|
|
61
|
-
const result = await this.DB.execute(sql, parameters);
|
|
62
|
-
return result.rows ?? [];
|
|
63
|
-
}
|
|
64
|
-
async getOptional(sql, parameters) {
|
|
65
|
-
const result = await this.DB.execute(sql, parameters);
|
|
66
|
-
return result.rows?.[0] ?? null;
|
|
67
|
-
}
|
|
68
|
-
async get(sql, parameters) {
|
|
69
|
-
const result = await this.getOptional(sql, parameters);
|
|
70
|
-
if (!result) {
|
|
71
|
-
throw new Error('Result set is empty');
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.OPSQLiteConnection = OPSQLiteConnection;
|
|
77
|
-
//# sourceMappingURL=OPSQLiteConnection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_common","require","OPSQLiteConnection","BaseObserver","constructor","options","DB","baseDB","updateHook","update","iterateListeners","cb","opType","operation","RowUpdateType","SQLITE_INSERT","SQLITE_DELETE","SQLITE_UPDATE","tablesUpdated","table","rowId","close","execute","query","params","res","insertId","rowsAffected","rows","_array","length","item","index","executeBatch","tuple","slice","forEach","p","push","result","getAll","sql","parameters","getOptional","get","Error","exports"],"sourceRoot":"../../../src","sources":["db/OPSQLiteConnection.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAMO,MAAMC,kBAAkB,SAASC,oBAAY,CAAoB;EAEtEC,WAAWA,CAAWC,OAAkC,EAAE;IACxD,KAAK,CAAC,CAAC;IAAC,KADYA,OAAkC,GAAlCA,OAAkC;IAEtD,IAAI,CAACC,EAAE,GAAGD,OAAO,CAACE,MAAM;;IAExB;IACA,IAAI,CAACD,EAAE,CAACE,UAAU,CAAEC,MAAM,IAAK;MAC7B,IAAI,CAACC,gBAAgB,CAAEC,EAAE,IAAK;QAC5B,IAAIC,MAAqB;QACzB,QAAQH,MAAM,CAACI,SAAS;UACtB,KAAK,QAAQ;YACXD,MAAM,GAAGE,qBAAa,CAACC,aAAa;YACpC;UACF,KAAK,QAAQ;YACXH,MAAM,GAAG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