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.
Files changed (125) hide show
  1. package/RNNitroSQLite.podspec +59 -0
  2. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  4. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  5. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/8.9/gc.properties +0 -0
  7. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  9. package/android/.gradle/vcs-1/gc.properties +0 -0
  10. package/android/CMakeLists.txt +38 -0
  11. package/android/build.gradle +119 -0
  12. package/android/src/main/AndroidManifest.xml +4 -0
  13. package/android/src/main/cpp/cpp-adapter.cpp +21 -0
  14. package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLiteOnLoadModule.java +57 -0
  15. package/android/src/main/java/com/margelo/rnnitrosqlite/RNNitroSQLitePackage.java +48 -0
  16. package/cpp/NitroSQLiteException.hpp +63 -0
  17. package/cpp/ThreadPool.cpp +91 -0
  18. package/cpp/ThreadPool.hpp +50 -0
  19. package/cpp/importSqlFile.cpp +48 -0
  20. package/cpp/importSqlFile.hpp +15 -0
  21. package/cpp/logs.hpp +38 -0
  22. package/cpp/macros.hpp +13 -0
  23. package/cpp/operations.cpp +296 -0
  24. package/cpp/operations.hpp +24 -0
  25. package/cpp/specs/HybridNativeQueryResult.cpp +20 -0
  26. package/cpp/specs/HybridNativeQueryResult.hpp +35 -0
  27. package/cpp/specs/HybridNitroSQLite.cpp +132 -0
  28. package/cpp/specs/HybridNitroSQLite.hpp +36 -0
  29. package/cpp/sqlite/sqlite3.c +237594 -0
  30. package/cpp/sqlite/sqlite3.h +12556 -0
  31. package/cpp/sqliteExecuteBatch.cpp +70 -0
  32. package/cpp/sqliteExecuteBatch.hpp +30 -0
  33. package/cpp/types.hpp +53 -0
  34. package/cpp/utils.hpp +61 -0
  35. package/ios/NitroSQLite.xcodeproj/project.pbxproj +447 -0
  36. package/ios/OnLoad.mm +41 -0
  37. package/ios/RNNitroSQLite-Swift.h +1 -0
  38. package/lib/commonjs/index.js +58 -0
  39. package/lib/commonjs/index.js.map +1 -0
  40. package/lib/commonjs/nitro.js +10 -0
  41. package/lib/commonjs/nitro.js.map +1 -0
  42. package/lib/commonjs/operations/execute.js +35 -0
  43. package/lib/commonjs/operations/execute.js.map +1 -0
  44. package/lib/commonjs/operations/session.js +39 -0
  45. package/lib/commonjs/operations/session.js.map +1 -0
  46. package/lib/commonjs/operations/transaction.js +95 -0
  47. package/lib/commonjs/operations/transaction.js.map +1 -0
  48. package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.ios.js +11 -0
  49. package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.ios.js.map +1 -0
  50. package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.js +9 -0
  51. package/lib/commonjs/specs/NativeNitroSQLiteOnLoad.js.map +1 -0
  52. package/lib/commonjs/specs/NativeQueryResult.nitro.js +6 -0
  53. package/lib/commonjs/specs/NativeQueryResult.nitro.js.map +1 -0
  54. package/lib/commonjs/specs/NitroSQLite.nitro.js +6 -0
  55. package/lib/commonjs/specs/NitroSQLite.nitro.js.map +1 -0
  56. package/lib/commonjs/typeORM.js +62 -0
  57. package/lib/commonjs/typeORM.js.map +1 -0
  58. package/lib/commonjs/types.js +35 -0
  59. package/lib/commonjs/types.js.map +1 -0
  60. package/lib/module/index.js +23 -0
  61. package/lib/module/index.js.map +1 -0
  62. package/lib/module/nitro.js +4 -0
  63. package/lib/module/nitro.js.map +1 -0
  64. package/lib/module/operations/execute.js +28 -0
  65. package/lib/module/operations/execute.js.map +1 -0
  66. package/lib/module/operations/session.js +31 -0
  67. package/lib/module/operations/session.js.map +1 -0
  68. package/lib/module/operations/transaction.js +88 -0
  69. package/lib/module/operations/transaction.js.map +1 -0
  70. package/lib/module/specs/NativeNitroSQLiteOnLoad.ios.js +5 -0
  71. package/lib/module/specs/NativeNitroSQLiteOnLoad.ios.js.map +1 -0
  72. package/lib/module/specs/NativeNitroSQLiteOnLoad.js +3 -0
  73. package/lib/module/specs/NativeNitroSQLiteOnLoad.js.map +1 -0
  74. package/lib/module/specs/NativeQueryResult.nitro.js +2 -0
  75. package/lib/module/specs/NativeQueryResult.nitro.js.map +1 -0
  76. package/lib/module/specs/NitroSQLite.nitro.js +2 -0
  77. package/lib/module/specs/NitroSQLite.nitro.js.map +1 -0
  78. package/lib/module/typeORM.js +54 -0
  79. package/lib/module/typeORM.js.map +1 -0
  80. package/lib/module/types.js +33 -0
  81. package/lib/module/types.js.map +1 -0
  82. package/lib/tsconfig.tsbuildinfo +1 -0
  83. package/lib/typescript/index.d.ts +30 -0
  84. package/lib/typescript/nitro.d.ts +7 -0
  85. package/lib/typescript/operations/execute.d.ts +3 -0
  86. package/lib/typescript/operations/session.d.ts +4 -0
  87. package/lib/typescript/operations/transaction.d.ts +5 -0
  88. package/lib/typescript/specs/NativeNitroSQLiteOnLoad.d.ts +6 -0
  89. package/lib/typescript/specs/NativeNitroSQLiteOnLoad.ios.d.ts +3 -0
  90. package/lib/typescript/specs/NativeQueryResult.nitro.d.ts +37 -0
  91. package/lib/typescript/specs/NitroSQLite.nitro.d.ts +19 -0
  92. package/lib/typescript/typeORM.d.ts +19 -0
  93. package/lib/typescript/types.d.ts +79 -0
  94. package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +48 -0
  95. package/nitrogen/generated/android/RNNitroSQLite+autolinking.gradle +25 -0
  96. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.cpp +40 -0
  97. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.hpp +25 -0
  98. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.kt +1 -0
  99. package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +56 -0
  100. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.cpp +8 -0
  101. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.hpp +303 -0
  102. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Umbrella.hpp +67 -0
  103. package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.mm +35 -0
  104. package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.swift +10 -0
  105. package/nitrogen/generated/shared/c++/BatchQueryCommand.hpp +77 -0
  106. package/nitrogen/generated/shared/c++/BatchQueryResult.hpp +68 -0
  107. package/nitrogen/generated/shared/c++/ColumnType.hpp +68 -0
  108. package/nitrogen/generated/shared/c++/FileLoadResult.hpp +72 -0
  109. package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.cpp +24 -0
  110. package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.hpp +74 -0
  111. package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.cpp +31 -0
  112. package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +91 -0
  113. package/nitrogen/generated/shared/c++/SQLiteQueryColumnMetadata.hpp +78 -0
  114. package/package.json +98 -0
  115. package/src/index.ts +26 -0
  116. package/src/nitro.ts +11 -0
  117. package/src/operations/execute.ts +45 -0
  118. package/src/operations/session.ts +58 -0
  119. package/src/operations/transaction.ts +137 -0
  120. package/src/specs/NativeNitroSQLiteOnLoad.ios.ts +7 -0
  121. package/src/specs/NativeNitroSQLiteOnLoad.ts +7 -0
  122. package/src/specs/NativeQueryResult.nitro.ts +44 -0
  123. package/src/specs/NitroSQLite.nitro.ts +39 -0
  124. package/src/typeORM.ts +101 -0
  125. package/src/types.ts +105 -0
package/ios/OnLoad.mm ADDED
@@ -0,0 +1,41 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "RNNitroSQLite-Swift-Cxx-Umbrella.hpp"
3
+ #import "HybridNitroSQLite.hpp"
4
+
5
+ @interface OnLoad : NSObject
6
+ @end
7
+
8
+ @implementation OnLoad
9
+
10
+ using namespace margelo::nitro;
11
+ using namespace margelo::nitro::rnnitrosqlite;
12
+
13
+ + (void)load {
14
+ // Get appGroupID value from Info.plist using key "AppGroup"
15
+ NSString *appGroupID = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RNNitroSQLite_AppGroup"];
16
+ NSString *documentPath;
17
+
18
+ if (appGroupID != nil) {
19
+ // Get the app groups container storage url
20
+ NSFileManager *fileManager = [NSFileManager defaultManager];
21
+ NSURL *storeUrl = [fileManager containerURLForSecurityApplicationGroupIdentifier:appGroupID];
22
+
23
+ if (storeUrl == nil) {
24
+ NSLog(@"Invalid AppGroup ID provided (%@). Check the value of \"AppGroup\" in your Info.plist file", appGroupID);
25
+ @throw [NSException exceptionWithName:@"SQLiteInitializationException"
26
+ reason:@"Error while initializing SQLite database (AppGroup)"
27
+ userInfo:nil];
28
+ }
29
+ NSLog(@"Configured with AppGroup ID: %@", appGroupID);
30
+
31
+ documentPath = [storeUrl path];
32
+ } else {
33
+ // Get iOS app's document directory (to safely store database .sqlite3 file)
34
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
35
+ documentPath = [paths objectAtIndex:0];
36
+ }
37
+
38
+ HybridNitroSQLite::docPath = [documentPath UTF8String];
39
+ }
40
+
41
+ @end
@@ -0,0 +1 @@
1
+ #pragma once
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ onInitialized: true,
8
+ NitroSQLite: true,
9
+ open: true,
10
+ typeORMDriver: true
11
+ };
12
+ exports.onInitialized = exports.NitroSQLite = void 0;
13
+ Object.defineProperty(exports, "open", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _session.open;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "typeORMDriver", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _typeORM.typeORMDriver;
23
+ }
24
+ });
25
+ var _transaction = require("./operations/transaction");
26
+ var _nitro = require("./nitro");
27
+ var _session = require("./operations/session");
28
+ var _NativeNitroSQLiteOnLoad = _interopRequireDefault(require("./specs/NativeNitroSQLiteOnLoad"));
29
+ var _execute = require("./operations/execute");
30
+ var _types = require("./types");
31
+ Object.keys(_types).forEach(function (key) {
32
+ if (key === "default" || key === "__esModule") return;
33
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
34
+ if (key in exports && exports[key] === _types[key]) return;
35
+ Object.defineProperty(exports, key, {
36
+ enumerable: true,
37
+ get: function () {
38
+ return _types[key];
39
+ }
40
+ });
41
+ });
42
+ var _typeORM = require("./typeORM");
43
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
44
+ const onInitialized = exports.onInitialized = new Promise(resolve => {
45
+ _NativeNitroSQLiteOnLoad.default.onReactApplicationContextReady(resolve);
46
+ });
47
+ const NitroSQLite = exports.NitroSQLite = {
48
+ ..._nitro.HybridNitroSQLite,
49
+ native: _nitro.HybridNitroSQLite,
50
+ onInitialized,
51
+ // Overwrite native functions with session-based JS implementations,
52
+ // where the database name can be ommited once opened
53
+ open: _session.open,
54
+ transaction: _transaction.transaction,
55
+ execute: _execute.execute,
56
+ executeAsync: _execute.executeAsync
57
+ };
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_transaction","require","_nitro","_session","_NativeNitroSQLiteOnLoad","_interopRequireDefault","_execute","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_typeORM","e","__esModule","default","onInitialized","Promise","resolve","NitroSQLiteOnLoad","onReactApplicationContextReady","NitroSQLite","HybridNitroSQLite","native","open","transaction","execute","executeAsync"],"sources":["index.ts"],"sourcesContent":["import { transaction } from './operations/transaction'\nimport { HybridNitroSQLite } from './nitro'\nimport { open } from './operations/session'\nimport NitroSQLiteOnLoad from './specs/NativeNitroSQLiteOnLoad'\nimport { execute, executeAsync } from './operations/execute'\n\nexport * from './types'\nexport { typeORMDriver } from './typeORM'\n\nexport const onInitialized = new Promise<void>((resolve) => {\n NitroSQLiteOnLoad.onReactApplicationContextReady(resolve)\n})\n\nexport const NitroSQLite = {\n ...HybridNitroSQLite,\n native: HybridNitroSQLite,\n onInitialized,\n // Overwrite native functions with session-based JS implementations,\n // where the database name can be ommited once opened\n open,\n transaction,\n execute,\n executeAsync,\n}\n\nexport { open } from './operations/session'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,wBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAAAO,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,QAAA,GAAAnB,OAAA;AAAyC,SAAAI,uBAAAgB,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElC,MAAMG,aAAa,GAAAR,OAAA,CAAAQ,aAAA,GAAG,IAAIC,OAAO,CAAQC,OAAO,IAAK;EAC1DC,gCAAiB,CAACC,8BAA8B,CAACF,OAAO,CAAC;AAC3D,CAAC,CAAC;AAEK,MAAMG,WAAW,GAAAb,OAAA,CAAAa,WAAA,GAAG;EACzB,GAAGC,wBAAiB;EACpBC,MAAM,EAAED,wBAAiB;EACzBN,aAAa;EACb;EACA;EACAQ,IAAI,EAAJA,aAAI;EACJC,WAAW,EAAXA,wBAAW;EACXC,OAAO,EAAPA,gBAAO;EACPC,YAAY,EAAZA;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.locks = exports.HybridNitroSQLite = void 0;
7
+ var _reactNativeNitroModules = require("react-native-nitro-modules");
8
+ const HybridNitroSQLite = exports.HybridNitroSQLite = _reactNativeNitroModules.NitroModules.createHybridObject('NitroSQLite');
9
+ const locks = exports.locks = {};
10
+ //# sourceMappingURL=nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeNitroModules","require","HybridNitroSQLite","exports","NitroModules","createHybridObject","locks"],"sources":["nitro.ts"],"sourcesContent":["import { NitroModules } from 'react-native-nitro-modules'\nimport type { NitroSQLite as NitroSQLiteSpec } from './specs/NitroSQLite.nitro'\nimport type { PendingTransaction } from './operations/transaction'\n\nexport const HybridNitroSQLite =\n NitroModules.createHybridObject<NitroSQLiteSpec>('NitroSQLite')\n\nexport const locks: Record<\n string,\n { queue: PendingTransaction[]; inProgress: boolean }\n> = {}\n"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAIO,MAAMC,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAC5BE,qCAAY,CAACC,kBAAkB,CAAkB,aAAa,CAAC;AAE1D,MAAMC,KAGZ,GAAAH,OAAA,CAAAG,KAAA,GAAG,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.execute = execute;
7
+ exports.executeAsync = executeAsync;
8
+ var _nitro = require("../nitro");
9
+ function execute(dbName, query, params) {
10
+ const nativeResult = _nitro.HybridNitroSQLite.execute(dbName, query, params);
11
+ const result = buildJsQueryResult(nativeResult);
12
+ return result;
13
+ }
14
+ async function executeAsync(dbName, query, params) {
15
+ const nativeResult = await _nitro.HybridNitroSQLite.executeAsync(dbName, query, params);
16
+ const result = buildJsQueryResult(nativeResult);
17
+ return result;
18
+ }
19
+ function buildJsQueryResult({
20
+ insertId,
21
+ rowsAffected,
22
+ results
23
+ }) {
24
+ const data = results;
25
+ return {
26
+ insertId,
27
+ rowsAffected,
28
+ rows: {
29
+ _array: data,
30
+ length: data.length,
31
+ item: idx => data[idx]
32
+ }
33
+ };
34
+ }
35
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_nitro","require","execute","dbName","query","params","nativeResult","HybridNitroSQLite","result","buildJsQueryResult","executeAsync","insertId","rowsAffected","results","data","rows","_array","length","item","idx"],"sources":["execute.ts"],"sourcesContent":["import { HybridNitroSQLite } from '../nitro'\nimport type { NativeQueryResult } from '../specs/NativeQueryResult.nitro'\nimport type { QueryResult, SQLiteItem, SQLiteQueryParams } from '../types'\n\nexport function execute<Data extends SQLiteItem = never>(\n dbName: string,\n query: string,\n params?: SQLiteQueryParams\n): QueryResult<Data> {\n const nativeResult = HybridNitroSQLite.execute(dbName, query, params)\n const result = buildJsQueryResult<Data>(nativeResult)\n return result\n}\n\nexport async function executeAsync<Data extends SQLiteItem = never>(\n dbName: string,\n query: string,\n params?: SQLiteQueryParams\n): Promise<QueryResult<Data>> {\n const nativeResult = await HybridNitroSQLite.executeAsync(\n dbName,\n query,\n params\n )\n const result = buildJsQueryResult<Data>(nativeResult)\n return result\n}\n\nfunction buildJsQueryResult<Data extends SQLiteItem = never>({\n insertId,\n rowsAffected,\n results,\n}: NativeQueryResult): QueryResult<Data> {\n const data = results as Data[]\n\n return {\n insertId,\n rowsAffected,\n rows: {\n _array: data,\n length: data.length,\n item: (idx: number) => data[idx],\n },\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIO,SAASC,OAAOA,CACrBC,MAAc,EACdC,KAAa,EACbC,MAA0B,EACP;EACnB,MAAMC,YAAY,GAAGC,wBAAiB,CAACL,OAAO,CAACC,MAAM,EAAEC,KAAK,EAAEC,MAAM,CAAC;EACrE,MAAMG,MAAM,GAAGC,kBAAkB,CAAOH,YAAY,CAAC;EACrD,OAAOE,MAAM;AACf;AAEO,eAAeE,YAAYA,CAChCP,MAAc,EACdC,KAAa,EACbC,MAA0B,EACE;EAC5B,MAAMC,YAAY,GAAG,MAAMC,wBAAiB,CAACG,YAAY,CACvDP,MAAM,EACNC,KAAK,EACLC,MACF,CAAC;EACD,MAAMG,MAAM,GAAGC,kBAAkB,CAAOH,YAAY,CAAC;EACrD,OAAOE,MAAM;AACf;AAEA,SAASC,kBAAkBA,CAAkC;EAC3DE,QAAQ;EACRC,YAAY;EACZC;AACiB,CAAC,EAAqB;EACvC,MAAMC,IAAI,GAAGD,OAAiB;EAE9B,OAAO;IACLF,QAAQ;IACRC,YAAY;IACZG,IAAI,EAAE;MACJC,MAAM,EAAEF,IAAI;MACZG,MAAM,EAAEH,IAAI,CAACG,MAAM;MACnBC,IAAI,EAAGC,GAAW,IAAKL,IAAI,CAACK,GAAG;IACjC;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.close = close;
7
+ exports.open = open;
8
+ exports.openDb = openDb;
9
+ var _nitro = require("../nitro");
10
+ var _transaction = require("./transaction");
11
+ var _execute = require("./execute");
12
+ function open(options) {
13
+ openDb(options.name, options.location);
14
+ return {
15
+ close: () => close(options.name),
16
+ delete: () => _nitro.HybridNitroSQLite.drop(options.name, options.location),
17
+ attach: (dbNameToAttach, alias, location) => _nitro.HybridNitroSQLite.attach(options.name, dbNameToAttach, alias, location),
18
+ detach: alias => _nitro.HybridNitroSQLite.detach(options.name, alias),
19
+ transaction: fn => (0, _transaction.transaction)(options.name, fn),
20
+ execute: (query, params) => (0, _execute.execute)(options.name, query, params),
21
+ executeAsync: (query, params) => (0, _execute.executeAsync)(options.name, query, params),
22
+ executeBatch: commands => _nitro.HybridNitroSQLite.executeBatch(options.name, commands),
23
+ executeBatchAsync: commands => _nitro.HybridNitroSQLite.executeBatchAsync(options.name, commands),
24
+ loadFile: location => _nitro.HybridNitroSQLite.loadFile(options.name, location),
25
+ loadFileAsync: location => _nitro.HybridNitroSQLite.loadFileAsync(options.name, location)
26
+ };
27
+ }
28
+ function openDb(dbName, location) {
29
+ _nitro.HybridNitroSQLite.open(dbName, location);
30
+ _nitro.locks[dbName] = {
31
+ queue: [],
32
+ inProgress: false
33
+ };
34
+ }
35
+ function close(dbName) {
36
+ _nitro.HybridNitroSQLite.close(dbName);
37
+ delete _nitro.locks[dbName];
38
+ }
39
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_nitro","require","_transaction","_execute","open","options","openDb","name","location","close","delete","HybridNitroSQLite","drop","attach","dbNameToAttach","alias","detach","transaction","fn","execute","query","params","executeAsync","executeBatch","commands","executeBatchAsync","loadFile","loadFileAsync","dbName","locks","queue","inProgress"],"sources":["session.ts"],"sourcesContent":["import { locks, HybridNitroSQLite } from '../nitro'\nimport { transaction } from './transaction'\nimport type {\n BatchQueryCommand,\n NitroSQLiteConnection,\n NitroSQLiteConnectionOptions,\n QueryResult,\n SQLiteItem,\n SQLiteQueryParams,\n Transaction,\n} from '../types'\nimport { execute, executeAsync } from './execute'\n\nexport function open(\n options: NitroSQLiteConnectionOptions\n): NitroSQLiteConnection {\n openDb(options.name, options.location)\n\n return {\n close: () => close(options.name),\n delete: () => HybridNitroSQLite.drop(options.name, options.location),\n attach: (dbNameToAttach: string, alias: string, location?: string) =>\n HybridNitroSQLite.attach(options.name, dbNameToAttach, alias, location),\n detach: (alias: string) => HybridNitroSQLite.detach(options.name, alias),\n transaction: (fn: (tx: Transaction) => Promise<void> | void) =>\n transaction(options.name, fn),\n execute: <Data extends SQLiteItem = never>(\n query: string,\n params?: SQLiteQueryParams\n ): QueryResult<Data> => execute(options.name, query, params),\n executeAsync: <Data extends SQLiteItem = never>(\n query: string,\n params?: SQLiteQueryParams\n ): Promise<QueryResult<Data>> => executeAsync(options.name, query, params),\n executeBatch: (commands: BatchQueryCommand[]) =>\n HybridNitroSQLite.executeBatch(options.name, commands),\n executeBatchAsync: (commands: BatchQueryCommand[]) =>\n HybridNitroSQLite.executeBatchAsync(options.name, commands),\n loadFile: (location: string) =>\n HybridNitroSQLite.loadFile(options.name, location),\n loadFileAsync: (location: string) =>\n HybridNitroSQLite.loadFileAsync(options.name, location),\n }\n}\n\nexport function openDb(dbName: string, location?: string) {\n HybridNitroSQLite.open(dbName, location)\n\n locks[dbName] = {\n queue: [],\n inProgress: false,\n }\n}\n\nexport function close(dbName: string) {\n HybridNitroSQLite.close(dbName)\n delete locks[dbName]\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,QAAA,GAAAF,OAAA;AAEO,SAASG,IAAIA,CAClBC,OAAqC,EACd;EACvBC,MAAM,CAACD,OAAO,CAACE,IAAI,EAAEF,OAAO,CAACG,QAAQ,CAAC;EAEtC,OAAO;IACLC,KAAK,EAAEA,CAAA,KAAMA,KAAK,CAACJ,OAAO,CAACE,IAAI,CAAC;IAChCG,MAAM,EAAEA,CAAA,KAAMC,wBAAiB,CAACC,IAAI,CAACP,OAAO,CAACE,IAAI,EAAEF,OAAO,CAACG,QAAQ,CAAC;IACpEK,MAAM,EAAEA,CAACC,cAAsB,EAAEC,KAAa,EAAEP,QAAiB,KAC/DG,wBAAiB,CAACE,MAAM,CAACR,OAAO,CAACE,IAAI,EAAEO,cAAc,EAAEC,KAAK,EAAEP,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;AACtB","ignoreList":[]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.transaction = void 0;
7
+ var _nitro = require("../nitro");
8
+ var _execute = require("./execute");
9
+ const transaction = async (dbName, fn) => {
10
+ if (_nitro.locks[dbName] == null) throw Error(`Nitro SQLite Error: No lock found on db: ${dbName}`);
11
+ let isFinalized = false;
12
+
13
+ // Local transaction context object implementation
14
+ const executeOnTransaction = (query, params) => {
15
+ if (isFinalized) {
16
+ throw Error(`Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}`);
17
+ }
18
+ return (0, _execute.execute)(dbName, query, params);
19
+ };
20
+ const executeAsyncOnTransaction = (query, params) => {
21
+ if (isFinalized) {
22
+ throw Error(`Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}`);
23
+ }
24
+ return (0, _execute.executeAsync)(dbName, query, params);
25
+ };
26
+ const commit = () => {
27
+ if (isFinalized) {
28
+ throw Error(`Nitro SQLite Error: Cannot execute commit on finalized transaction: ${dbName}`);
29
+ }
30
+ const result = _nitro.HybridNitroSQLite.execute(dbName, 'COMMIT');
31
+ isFinalized = true;
32
+ return result;
33
+ };
34
+ const rollback = () => {
35
+ if (isFinalized) {
36
+ throw Error(`Nitro SQLite Error: Cannot execute rollback on finalized transaction: ${dbName}`);
37
+ }
38
+ const result = _nitro.HybridNitroSQLite.execute(dbName, 'ROLLBACK');
39
+ isFinalized = true;
40
+ return result;
41
+ };
42
+ async function run() {
43
+ try {
44
+ await _nitro.HybridNitroSQLite.executeAsync(dbName, 'BEGIN TRANSACTION');
45
+ await fn({
46
+ commit,
47
+ execute: executeOnTransaction,
48
+ executeAsync: executeAsyncOnTransaction,
49
+ rollback
50
+ });
51
+ if (!isFinalized) commit();
52
+ } catch (executionError) {
53
+ if (!isFinalized) {
54
+ try {
55
+ rollback();
56
+ } catch (rollbackError) {
57
+ throw rollbackError;
58
+ }
59
+ }
60
+ throw executionError;
61
+ } finally {
62
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
63
+ _nitro.locks[dbName].inProgress = false;
64
+ isFinalized = false;
65
+ startNextTransaction(dbName);
66
+ }
67
+ }
68
+ return new Promise((resolve, reject) => {
69
+ var _locks$dbName;
70
+ const tx = {
71
+ start: () => {
72
+ run().then(resolve).catch(reject);
73
+ }
74
+ };
75
+ (_locks$dbName = _nitro.locks[dbName]) === null || _locks$dbName === void 0 || _locks$dbName.queue.push(tx);
76
+ startNextTransaction(dbName);
77
+ });
78
+ };
79
+ exports.transaction = transaction;
80
+ function startNextTransaction(dbName) {
81
+ if (_nitro.locks[dbName] == null) throw Error(`Lock not found for db: ${dbName}`);
82
+ if (_nitro.locks[dbName].inProgress) {
83
+ // Transaction is already in process bail out
84
+ return;
85
+ }
86
+ if (_nitro.locks[dbName].queue.length > 0) {
87
+ _nitro.locks[dbName].inProgress = true;
88
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
89
+ const tx = _nitro.locks[dbName].queue.shift();
90
+ setImmediate(() => {
91
+ tx.start();
92
+ });
93
+ }
94
+ }
95
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_nitro","require","_execute","transaction","dbName","fn","locks","Error","isFinalized","executeOnTransaction","query","params","execute","executeAsyncOnTransaction","executeAsync","commit","result","HybridNitroSQLite","rollback","run","executionError","rollbackError","inProgress","startNextTransaction","Promise","resolve","reject","_locks$dbName","tx","start","then","catch","queue","push","exports","length","shift","setImmediate"],"sources":["transaction.ts"],"sourcesContent":["import { locks, HybridNitroSQLite } from '../nitro'\nimport type {\n QueryResult,\n SQLiteItem,\n SQLiteQueryParams,\n Transaction,\n} from '../types'\nimport { execute, executeAsync } from './execute'\n\nexport interface PendingTransaction {\n /*\n * The start function should not throw or return a promise because the\n * queue just calls it and does not monitor for failures or completions.\n *\n * It should catch any errors and call the resolve or reject of the wrapping\n * promise when complete.\n *\n * It should also automatically commit or rollback the transaction if needed\n */\n start: () => void\n}\n\nexport const transaction = async (\n dbName: string,\n fn: (tx: Transaction) => Promise<void> | void\n): Promise<void> => {\n if (locks[dbName] == null)\n throw Error(`Nitro SQLite Error: No lock found on db: ${dbName}`)\n\n let isFinalized = false\n\n // Local transaction context object implementation\n const executeOnTransaction = <Data extends SQLiteItem = never>(\n query: string,\n params?: SQLiteQueryParams\n ): QueryResult<Data> => {\n if (isFinalized) {\n throw Error(\n `Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}`\n )\n }\n return execute(dbName, query, params)\n }\n\n const executeAsyncOnTransaction = <Data extends SQLiteItem = never>(\n query: string,\n params?: SQLiteQueryParams\n ): Promise<QueryResult<Data>> => {\n if (isFinalized) {\n throw Error(\n `Nitro SQLite Error: Cannot execute query on finalized transaction: ${dbName}`\n )\n }\n return executeAsync(dbName, query, params)\n }\n\n const commit = () => {\n if (isFinalized) {\n throw Error(\n `Nitro SQLite Error: Cannot execute commit on finalized transaction: ${dbName}`\n )\n }\n const result = HybridNitroSQLite.execute(dbName, 'COMMIT')\n isFinalized = true\n return result\n }\n\n const rollback = () => {\n if (isFinalized) {\n throw Error(\n `Nitro SQLite Error: Cannot execute rollback on finalized transaction: ${dbName}`\n )\n }\n const result = HybridNitroSQLite.execute(dbName, 'ROLLBACK')\n isFinalized = true\n return result\n }\n\n async function run() {\n try {\n await HybridNitroSQLite.executeAsync(dbName, 'BEGIN TRANSACTION')\n\n await fn({\n commit,\n execute: executeOnTransaction,\n executeAsync: executeAsyncOnTransaction,\n rollback,\n })\n\n if (!isFinalized) commit()\n } catch (executionError) {\n if (!isFinalized) {\n try {\n rollback()\n } catch (rollbackError) {\n throw rollbackError\n }\n }\n\n throw executionError\n } finally {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n locks[dbName]!.inProgress = false\n isFinalized = false\n startNextTransaction(dbName)\n }\n }\n\n return new Promise((resolve, reject) => {\n const tx: PendingTransaction = {\n start: () => {\n run().then(resolve).catch(reject)\n },\n }\n\n locks[dbName]?.queue.push(tx)\n startNextTransaction(dbName)\n })\n}\n\nfunction startNextTransaction(dbName: string) {\n if (locks[dbName] == null) throw Error(`Lock not found for db: ${dbName}`)\n\n if (locks[dbName].inProgress) {\n // Transaction is already in process bail out\n return\n }\n\n if (locks[dbName].queue.length > 0) {\n locks[dbName].inProgress = true\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const tx = locks[dbName].queue.shift()!\n setImmediate(() => {\n tx.start()\n })\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AAeO,MAAME,WAAW,GAAG,MAAAA,CACzBC,MAAc,EACdC,EAA6C,KAC3B;EAClB,IAAIC,YAAK,CAACF,MAAM,CAAC,IAAI,IAAI,EACvB,MAAMG,KAAK,CAAC,4CAA4CH,MAAM,EAAE,CAAC;EAEnE,IAAII,WAAW,GAAG,KAAK;;EAEvB;EACA,MAAMC,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,MAA0B,KACJ;IACtB,IAAIH,WAAW,EAAE;MACf,MAAMD,KAAK,CACT,sEAAsEH,MAAM,EAC9E,CAAC;IACH;IACA,OAAO,IAAAQ,gBAAO,EAACR,MAAM,EAAEM,KAAK,EAAEC,MAAM,CAAC;EACvC,CAAC;EAED,MAAME,yBAAyB,GAAGA,CAChCH,KAAa,EACbC,MAA0B,KACK;IAC/B,IAAIH,WAAW,EAAE;MACf,MAAMD,KAAK,CACT,sEAAsEH,MAAM,EAC9E,CAAC;IACH;IACA,OAAO,IAAAU,qBAAY,EAACV,MAAM,EAAEM,KAAK,EAAEC,MAAM,CAAC;EAC5C,CAAC;EAED,MAAMI,MAAM,GAAGA,CAAA,KAAM;IACnB,IAAIP,WAAW,EAAE;MACf,MAAMD,KAAK,CACT,uEAAuEH,MAAM,EAC/E,CAAC;IACH;IACA,MAAMY,MAAM,GAAGC,wBAAiB,CAACL,OAAO,CAACR,MAAM,EAAE,QAAQ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,cAAAuB,aAAA,eAAbA,aAAA,CAAeK,KAAK,CAACC,IAAI,CAACL,EAAE,CAAC;IAC7BL,oBAAoB,CAACnB,MAAM,CAAC;EAC9B,CAAC,CAAC;AACJ,CAAC;AAAA8B,OAAA,CAAA/B,WAAA,GAAAA,WAAA;AAED,SAASoB,oBAAoBA,CAACnB,MAAc,EAAE;EAC5C,IAAIE,YAAK,CAACF,MAAM,CAAC,IAAI,IAAI,EAAE,MAAMG,KAAK,CAAC,0BAA0BH,MAAM,EAAE,CAAC;EAE1E,IAAIE,YAAK,CAACF,MAAM,CAAC,CAACkB,UAAU,EAAE;IAC5B;IACA;EACF;EAEA,IAAIhB,YAAK,CAACF,MAAM,CAAC,CAAC4B,KAAK,CAACG,MAAM,GAAG,CAAC,EAAE;IAClC7B,YAAK,CAACF,MAAM,CAAC,CAACkB,UAAU,GAAG,IAAI;IAC/B;IACA,MAAMM,EAAE,GAAGtB,YAAK,CAACF,MAAM,CAAC,CAAC4B,KAAK,CAACI,KAAK,CAAC,CAAE;IACvCC,YAAY,CAAC,MAAM;MACjBT,EAAE,CAACC,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.noop = exports.default = void 0;
7
+ const noop = exports.noop = {
8
+ onReactApplicationContextReady: () => undefined
9
+ };
10
+ var _default = exports.default = noop;
11
+ //# sourceMappingURL=NativeNitroSQLiteOnLoad.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["noop","exports","onReactApplicationContextReady","undefined","_default","default"],"sources":["NativeNitroSQLiteOnLoad.ios.ts"],"sourcesContent":["import type { Spec as AndroidOnLoadTurboModuleSpec } from './NativeNitroSQLiteOnLoad'\n\nexport const noop: AndroidOnLoadTurboModuleSpec = {\n onReactApplicationContextReady: () => undefined,\n}\n\nexport default noop\n"],"mappings":";;;;;;AAEO,MAAMA,IAAkC,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAChDE,8BAA8B,EAAEA,CAAA,KAAMC;AACxC,CAAC;AAAA,IAAAC,QAAA,GAAAH,OAAA,CAAAI,OAAA,GAEcL,IAAI","ignoreList":[]}
@@ -0,0 +1,9 @@
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('RNNitroSQLiteOnLoad');
9
+ //# sourceMappingURL=NativeNitroSQLiteOnLoad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sources":["NativeNitroSQLiteOnLoad.ts"],"sourcesContent":["import { TurboModuleRegistry, type TurboModule } from 'react-native'\n\nexport interface Spec extends TurboModule {\n onReactApplicationContextReady(callback: () => void): void\n}\n\nexport default TurboModuleRegistry.getEnforcing<Spec>('RNNitroSQLiteOnLoad')\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAoE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAMrDC,gCAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=NativeQueryResult.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["NativeQueryResult.nitro.ts"],"sourcesContent":["import type { HybridObject } from 'react-native-nitro-modules'\nimport type { ColumnType, SQLiteValue } from '../types'\n\n/**\n * Object returned by SQL Query executions {\n * insertId: Represent the auto-generated row id if applicable\n * rowsAffected: Number of affected rows if result of a update query\n * message: if status === 1, here you will find error description\n * rows: if status is undefined or 0 this object will contain the query results\n * }\n *\n * @interface NativeQueryResult\n */\nexport interface NativeQueryResult\n extends HybridObject<{ ios: 'c++'; android: 'c++' }> {\n readonly rowsAffected: number\n readonly insertId?: number\n\n /** Query results */\n readonly results: SQLiteQueryResults\n /** Table metadata */\n readonly metadata?: Record<string, SQLiteQueryColumnMetadata>\n}\n\n/**\n * Table metadata\n * Describes some information about the table and it's columns fetched by the query\n * The index is the name of the column\n */\n// TODO: Investigate why this doesn't work with nitrogen\n// export type SQLiteQueryResultRow = Record<string, SQLiteValue>\n// export type SQLiteQueryResults = SQLiteQueryResultRow[]\nexport type SQLiteQueryResults = Record<string, SQLiteValue>[]\n\n// TODO: Investigate why this doesn't work with nitrogen\n// export type SQLiteQueryTableMetadata = Record<string, SQLiteQueryColumnMetadata>\nexport interface SQLiteQueryColumnMetadata {\n /** The name used for this column for this result set */\n name: string\n /** The declared column type for this column, when fetched directly from a table or a View resulting from a table column. \"UNKNOWN\" for dynamic values, like function returned ones. */\n type: ColumnType\n /** The index for this column for this result set */\n index: number\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=NitroSQLite.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["NitroSQLite.nitro.ts"],"sourcesContent":["import type { HybridObject } from 'react-native-nitro-modules'\nimport type {\n BatchQueryResult,\n FileLoadResult,\n BatchQueryCommand,\n SQLiteQueryParams,\n} from '../types'\nimport type { NativeQueryResult } from './NativeQueryResult.nitro'\n\nexport interface NitroSQLite\n extends HybridObject<{ ios: 'c++'; android: 'c++' }> {\n open(dbName: string, location?: string): void\n close(dbName: string): void\n drop(dbName: string, location?: string): void\n attach(\n mainDbName: string,\n dbNameToAttach: string,\n alias: string,\n location?: string\n ): void\n detach(mainDbName: string, alias: string): void\n execute(\n dbName: string,\n query: string,\n params?: SQLiteQueryParams\n ): NativeQueryResult\n executeAsync(\n dbName: string,\n query: string,\n params?: SQLiteQueryParams\n ): Promise<NativeQueryResult>\n executeBatch(dbName: string, commands: BatchQueryCommand[]): BatchQueryResult\n executeBatchAsync(\n dbName: string,\n commands: BatchQueryCommand[]\n ): Promise<BatchQueryResult>\n loadFile(dbName: string, location: string): FileLoadResult\n loadFileAsync(dbName: string, location: string): Promise<FileLoadResult>\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.typeORMDriver = void 0;
7
+ var Operations = _interopRequireWildcard(require("./operations/session"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ // _________ _______ ______ ____ _____ __ __ _____ _____
11
+ // |__ __\ \ / / __ \| ____/ __ \| __ \| \/ | /\ | __ \_ _|
12
+ // | | \ \_/ /| |__) | |__ | | | | |__) | \ / | / \ | |__) || |
13
+ // | | \ / | ___/| __|| | | | _ /| |\/| | / /\ \ | ___/ | |
14
+ // | | | | | | | |___| |__| | | \ \| | | | / ____ \| | _| |_
15
+ // |_| |_| |_| |______\____/|_| \_\_| |_| /_/ \_\_| |_____|
16
+
17
+ /**
18
+ * DO NOT USE THIS! THIS IS MEANT FOR TYPEORM
19
+ * If you are looking for a convenience wrapper use `connect`
20
+ */
21
+ const typeORMDriver = exports.typeORMDriver = {
22
+ openDatabase: (options, ok, fail) => {
23
+ try {
24
+ const db = Operations.open(options);
25
+ const connection = {
26
+ executeSql: async (sql, params, okExecute, failExecute) => {
27
+ try {
28
+ const result = await db.executeAsync(sql, params);
29
+ okExecute(result);
30
+ } catch (e) {
31
+ failExecute(e);
32
+ }
33
+ },
34
+ transaction: fn => {
35
+ return db.transaction(fn);
36
+ },
37
+ close: (okClose, failClose) => {
38
+ try {
39
+ db.close();
40
+ okClose();
41
+ } catch (e) {
42
+ failClose(e);
43
+ }
44
+ },
45
+ attach: (dbNameToAttach, alias, location, callback) => {
46
+ db.attach(dbNameToAttach, alias, location);
47
+ callback();
48
+ },
49
+ detach: (alias, callback) => {
50
+ db.detach(alias);
51
+ callback();
52
+ }
53
+ };
54
+ ok(connection);
55
+ return connection;
56
+ } catch (e) {
57
+ fail(e);
58
+ return null;
59
+ }
60
+ }
61
+ };
62
+ //# sourceMappingURL=typeORM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Operations","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","typeORMDriver","exports","openDatabase","options","ok","fail","db","open","connection","executeSql","sql","params","okExecute","failExecute","result","executeAsync","transaction","fn","close","okClose","failClose","attach","dbNameToAttach","alias","location","callback","detach"],"sources":["typeORM.ts"],"sourcesContent":["// _________ _______ ______ ____ _____ __ __ _____ _____\n// |__ __\\ \\ / / __ \\| ____/ __ \\| __ \\| \\/ | /\\ | __ \\_ _|\n// | | \\ \\_/ /| |__) | |__ | | | | |__) | \\ / | / \\ | |__) || |\n// | | \\ / | ___/| __|| | | | _ /| |\\/| | / /\\ \\ | ___/ | |\n// | | | | | | | |___| |__| | | \\ \\| | | | / ____ \\| | _| |_\n// |_| |_| |_| |______\\____/|_| \\_\\_| |_| /_/ \\_\\_| |_____|\n\nimport type {\n QueryResult,\n SQLiteItem,\n SQLiteQueryParams,\n Transaction,\n} from './types'\nimport * as Operations from './operations/session'\n\ninterface TypeOrmNitroSQLiteConnection {\n executeSql: <RowData extends SQLiteItem = never>(\n sql: string,\n params: SQLiteQueryParams | undefined,\n okExecute: (res: QueryResult<RowData>) => void,\n failExecute: (msg: string) => void\n ) => Promise<void>\n transaction: (fn: (tx: Transaction) => Promise<void>) => Promise<void>\n close: (okClose: () => void, failClose: (e: unknown) => void) => void\n attach: (\n dbNameToAttach: string,\n alias: string,\n location: string | undefined,\n callback: () => void\n ) => void\n detach: (alias: string, callback: () => void) => void\n}\n\n/**\n * DO NOT USE THIS! THIS IS MEANT FOR TYPEORM\n * If you are looking for a convenience wrapper use `connect`\n */\nexport const typeORMDriver = {\n openDatabase: (\n options: {\n name: string\n location?: string\n },\n ok: (db: TypeOrmNitroSQLiteConnection) => void,\n fail: (msg: string) => void\n ): TypeOrmNitroSQLiteConnection | null => {\n try {\n const db = Operations.open(options)\n\n const connection: TypeOrmNitroSQLiteConnection = {\n executeSql: async <RowData extends SQLiteItem = never>(\n sql: string,\n params: SQLiteQueryParams | undefined,\n okExecute: (res: QueryResult<RowData>) => void,\n failExecute: (msg: string) => void\n ) => {\n try {\n const result = await db.executeAsync<RowData>(sql, params)\n okExecute(result)\n } catch (e: unknown) {\n failExecute(e as string)\n }\n },\n transaction: (\n fn: (tx: Transaction) => Promise<void>\n ): Promise<void> => {\n return db.transaction(fn)\n },\n close: (okClose: () => void, failClose: (e: unknown) => void) => {\n try {\n db.close()\n okClose()\n } catch (e) {\n failClose(e)\n }\n },\n attach: (\n dbNameToAttach: string,\n alias: string,\n location: string | undefined,\n callback: () => void\n ) => {\n db.attach(dbNameToAttach, alias, location)\n callback()\n },\n detach: (alias: string, callback: () => void) => {\n db.detach(alias)\n callback()\n },\n }\n\n ok(connection)\n\n return connection\n } catch (e: unknown) {\n fail(e as string)\n\n return null\n }\n },\n}\n"],"mappings":";;;;;;AAaA,IAAAA,UAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAkD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[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ColumnType = void 0;
7
+ // eslint-disable-next-line no-restricted-syntax
8
+ let ColumnType = exports.ColumnType = /*#__PURE__*/function (ColumnType) {
9
+ ColumnType[ColumnType["BOOLEAN"] = 0] = "BOOLEAN";
10
+ ColumnType[ColumnType["NUMBER"] = 1] = "NUMBER";
11
+ ColumnType[ColumnType["INT64"] = 2] = "INT64";
12
+ ColumnType[ColumnType["TEXT"] = 3] = "TEXT";
13
+ ColumnType[ColumnType["ARRAY_BUFFER"] = 4] = "ARRAY_BUFFER";
14
+ ColumnType[ColumnType["NULL_VALUE"] = 5] = "NULL_VALUE";
15
+ return ColumnType;
16
+ }({});
17
+ /**
18
+ * Represents a value that can be stored in a SQLite database
19
+ */
20
+ /**
21
+ * Allows the execution of bulk of sql commands
22
+ * inside a transaction
23
+ * If a single query must be executed many times with different arguments, its preferred
24
+ * to declare it a single time, and use an array of array parameters.
25
+ */
26
+ /**
27
+ * status: 0 or undefined for correct execution, 1 for error
28
+ * message: if status === 1, here you will find error description
29
+ * rowsAffected: Number of affected rows if status == 0
30
+ */
31
+ /**
32
+ * Result of loading a file and executing every line as a SQL command
33
+ * Similar to BatchQueryResult
34
+ */
35
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ColumnType","exports"],"sources":["types.ts"],"sourcesContent":["export interface NitroSQLiteConnectionOptions {\n name: string\n location?: string\n}\n\nexport interface NitroSQLiteConnection {\n close(): void\n delete(): void\n attach(dbNameToAttach: string, alias: string, location?: string): void\n detach(alias: string): void\n transaction(fn: (tx: Transaction) => Promise<void> | void): Promise<void>\n execute: ExecuteQuery\n executeAsync: ExecuteAsyncQuery\n executeBatch(commands: BatchQueryCommand[]): BatchQueryResult\n executeBatchAsync(commands: BatchQueryCommand[]): Promise<BatchQueryResult>\n loadFile(location: string): FileLoadResult\n loadFileAsync(location: string): Promise<FileLoadResult>\n}\n\n// eslint-disable-next-line no-restricted-syntax\nexport enum ColumnType {\n BOOLEAN,\n NUMBER,\n INT64,\n TEXT,\n ARRAY_BUFFER,\n NULL_VALUE,\n}\n\n/**\n * Represents a value that can be stored in a SQLite database\n */\nexport type SQLiteValue =\n | boolean\n | number\n | bigint\n | string\n | ArrayBuffer\n | undefined\n\nexport type SQLiteItem = Record<string, SQLiteValue>\n\nexport interface QueryResult<RowData extends SQLiteItem = SQLiteItem> {\n readonly insertId?: number\n readonly rowsAffected: number\n\n readonly rows?: {\n /** Raw array with all dataset */\n _array: RowData[]\n /** The lengh of the dataset */\n length: number\n /** A convenience function to acess the index based the row object\n * @param idx the row index\n * @returns the row structure identified by column names\n */\n item: (idx: number) => RowData | undefined\n }\n}\n\nexport type SQLiteQueryParams = SQLiteValue[]\n\nexport type ExecuteQuery = <RowData extends SQLiteItem = SQLiteItem>(\n query: string,\n params?: SQLiteQueryParams\n) => QueryResult<RowData>\n\nexport type ExecuteAsyncQuery = <RowData extends SQLiteItem = SQLiteItem>(\n query: string,\n params?: SQLiteQueryParams\n) => Promise<QueryResult<RowData>>\n\nexport interface Transaction {\n commit(): QueryResult\n rollback(): QueryResult\n execute: ExecuteQuery\n executeAsync: ExecuteAsyncQuery\n}\n\n/**\n * Allows the execution of bulk of sql commands\n * inside a transaction\n * If a single query must be executed many times with different arguments, its preferred\n * to declare it a single time, and use an array of array parameters.\n */\nexport interface BatchQueryCommand {\n query: string\n params?: SQLiteQueryParams | SQLiteQueryParams[]\n}\n\n/**\n * status: 0 or undefined for correct execution, 1 for error\n * message: if status === 1, here you will find error description\n * rowsAffected: Number of affected rows if status == 0\n */\nexport interface BatchQueryResult {\n rowsAffected?: number\n}\n\n/**\n * Result of loading a file and executing every line as a SQL command\n * Similar to BatchQueryResult\n */\nexport interface FileLoadResult extends BatchQueryResult {\n commands?: number\n}\n"],"mappings":";;;;;;AAmBA;AAAA,IACYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAStB;AACA;AACA;AA+CA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ import { transaction } from './operations/transaction';
2
+ import { HybridNitroSQLite } from './nitro';
3
+ import { open } from './operations/session';
4
+ import NitroSQLiteOnLoad from './specs/NativeNitroSQLiteOnLoad';
5
+ import { execute, executeAsync } from './operations/execute';
6
+ export * from './types';
7
+ export { typeORMDriver } from './typeORM';
8
+ export const onInitialized = new Promise(resolve => {
9
+ NitroSQLiteOnLoad.onReactApplicationContextReady(resolve);
10
+ });
11
+ export const NitroSQLite = {
12
+ ...HybridNitroSQLite,
13
+ native: HybridNitroSQLite,
14
+ onInitialized,
15
+ // Overwrite native functions with session-based JS implementations,
16
+ // where the database name can be ommited once opened
17
+ open,
18
+ transaction,
19
+ execute,
20
+ executeAsync
21
+ };
22
+ export { open } from './operations/session';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["transaction","HybridNitroSQLite","open","NitroSQLiteOnLoad","execute","executeAsync","typeORMDriver","onInitialized","Promise","resolve","onReactApplicationContextReady","NitroSQLite","native"],"sources":["index.ts"],"sourcesContent":["import { transaction } from './operations/transaction'\nimport { HybridNitroSQLite } from './nitro'\nimport { open } from './operations/session'\nimport NitroSQLiteOnLoad from './specs/NativeNitroSQLiteOnLoad'\nimport { execute, executeAsync } from './operations/execute'\n\nexport * from './types'\nexport { typeORMDriver } from './typeORM'\n\nexport const onInitialized = new Promise<void>((resolve) => {\n NitroSQLiteOnLoad.onReactApplicationContextReady(resolve)\n})\n\nexport const NitroSQLite = {\n ...HybridNitroSQLite,\n native: HybridNitroSQLite,\n onInitialized,\n // Overwrite native functions with session-based JS implementations,\n // where the database name can be ommited once opened\n open,\n transaction,\n execute,\n executeAsync,\n}\n\nexport { open } from './operations/session'\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAQ,SAAS;AAC3C,SAASC,IAAI,QAAQ,sBAAsB;AAC3C,OAAOC,iBAAiB,MAAM,iCAAiC;AAC/D,SAASC,OAAO,EAAEC,YAAY,QAAQ,sBAAsB;AAE5D,cAAc,SAAS;AACvB,SAASC,aAAa,QAAQ,WAAW;AAEzC,OAAO,MAAMC,aAAa,GAAG,IAAIC,OAAO,CAAQC,OAAO,IAAK;EAC1DN,iBAAiB,CAACO,8BAA8B,CAACD,OAAO,CAAC;AAC3D,CAAC,CAAC;AAEF,OAAO,MAAME,WAAW,GAAG;EACzB,GAAGV,iBAAiB;EACpBW,MAAM,EAAEX,iBAAiB;EACzBM,aAAa;EACb;EACA;EACAL,IAAI;EACJF,WAAW;EACXI,OAAO;EACPC;AACF,CAAC;AAED,SAASH,IAAI,QAAQ,sBAAsB","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ export const HybridNitroSQLite = NitroModules.createHybridObject('NitroSQLite');
3
+ export const locks = {};
4
+ //# sourceMappingURL=nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroModules","HybridNitroSQLite","createHybridObject","locks"],"sources":["nitro.ts"],"sourcesContent":["import { NitroModules } from 'react-native-nitro-modules'\nimport type { NitroSQLite as NitroSQLiteSpec } from './specs/NitroSQLite.nitro'\nimport type { PendingTransaction } from './operations/transaction'\n\nexport const HybridNitroSQLite =\n NitroModules.createHybridObject<NitroSQLiteSpec>('NitroSQLite')\n\nexport const locks: Record<\n string,\n { queue: PendingTransaction[]; inProgress: boolean }\n> = {}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAIzD,OAAO,MAAMC,iBAAiB,GAC5BD,YAAY,CAACE,kBAAkB,CAAkB,aAAa,CAAC;AAEjE,OAAO,MAAMC,KAGZ,GAAG,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ import { HybridNitroSQLite } from '../nitro';
2
+ export function execute(dbName, query, params) {
3
+ const nativeResult = HybridNitroSQLite.execute(dbName, query, params);
4
+ const result = buildJsQueryResult(nativeResult);
5
+ return result;
6
+ }
7
+ export async function executeAsync(dbName, query, params) {
8
+ const nativeResult = await HybridNitroSQLite.executeAsync(dbName, query, params);
9
+ const result = buildJsQueryResult(nativeResult);
10
+ return result;
11
+ }
12
+ function buildJsQueryResult({
13
+ insertId,
14
+ rowsAffected,
15
+ results
16
+ }) {
17
+ const data = results;
18
+ return {
19
+ insertId,
20
+ rowsAffected,
21
+ rows: {
22
+ _array: data,
23
+ length: data.length,
24
+ item: idx => data[idx]
25
+ }
26
+ };
27
+ }
28
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HybridNitroSQLite","execute","dbName","query","params","nativeResult","result","buildJsQueryResult","executeAsync","insertId","rowsAffected","results","data","rows","_array","length","item","idx"],"sources":["execute.ts"],"sourcesContent":["import { HybridNitroSQLite } from '../nitro'\nimport type { NativeQueryResult } from '../specs/NativeQueryResult.nitro'\nimport type { QueryResult, SQLiteItem, SQLiteQueryParams } from '../types'\n\nexport function execute<Data extends SQLiteItem = never>(\n dbName: string,\n query: string,\n params?: SQLiteQueryParams\n): QueryResult<Data> {\n const nativeResult = HybridNitroSQLite.execute(dbName, query, params)\n const result = buildJsQueryResult<Data>(nativeResult)\n return result\n}\n\nexport async function executeAsync<Data extends SQLiteItem = never>(\n dbName: string,\n query: string,\n params?: SQLiteQueryParams\n): Promise<QueryResult<Data>> {\n const nativeResult = await HybridNitroSQLite.executeAsync(\n dbName,\n query,\n params\n )\n const result = buildJsQueryResult<Data>(nativeResult)\n return result\n}\n\nfunction buildJsQueryResult<Data extends SQLiteItem = never>({\n insertId,\n rowsAffected,\n results,\n}: NativeQueryResult): QueryResult<Data> {\n const data = results as Data[]\n\n return {\n insertId,\n rowsAffected,\n rows: {\n _array: data,\n length: data.length,\n item: (idx: number) => data[idx],\n },\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,UAAU;AAI5C,OAAO,SAASC,OAAOA,CACrBC,MAAc,EACdC,KAAa,EACbC,MAA0B,EACP;EACnB,MAAMC,YAAY,GAAGL,iBAAiB,CAACC,OAAO,CAACC,MAAM,EAAEC,KAAK,EAAEC,MAAM,CAAC;EACrE,MAAME,MAAM,GAAGC,kBAAkB,CAAOF,YAAY,CAAC;EACrD,OAAOC,MAAM;AACf;AAEA,OAAO,eAAeE,YAAYA,CAChCN,MAAc,EACdC,KAAa,EACbC,MAA0B,EACE;EAC5B,MAAMC,YAAY,GAAG,MAAML,iBAAiB,CAACQ,YAAY,CACvDN,MAAM,EACNC,KAAK,EACLC,MACF,CAAC;EACD,MAAME,MAAM,GAAGC,kBAAkB,CAAOF,YAAY,CAAC;EACrD,OAAOC,MAAM;AACf;AAEA,SAASC,kBAAkBA,CAAkC;EAC3DE,QAAQ;EACRC,YAAY;EACZC;AACiB,CAAC,EAAqB;EACvC,MAAMC,IAAI,GAAGD,OAAiB;EAE9B,OAAO;IACLF,QAAQ;IACRC,YAAY;IACZG,IAAI,EAAE;MACJC,MAAM,EAAEF,IAAI;MACZG,MAAM,EAAEH,IAAI,CAACG,MAAM;MACnBC,IAAI,EAAGC,GAAW,IAAKL,IAAI,CAACK,GAAG;IACjC;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ import { locks, HybridNitroSQLite } from '../nitro';
2
+ import { transaction } from './transaction';
3
+ import { execute, executeAsync } from './execute';
4
+ export function open(options) {
5
+ openDb(options.name, options.location);
6
+ return {
7
+ close: () => close(options.name),
8
+ delete: () => HybridNitroSQLite.drop(options.name, options.location),
9
+ attach: (dbNameToAttach, alias, location) => HybridNitroSQLite.attach(options.name, dbNameToAttach, alias, location),
10
+ detach: alias => HybridNitroSQLite.detach(options.name, alias),
11
+ transaction: fn => transaction(options.name, fn),
12
+ execute: (query, params) => execute(options.name, query, params),
13
+ executeAsync: (query, params) => executeAsync(options.name, query, params),
14
+ executeBatch: commands => HybridNitroSQLite.executeBatch(options.name, commands),
15
+ executeBatchAsync: commands => HybridNitroSQLite.executeBatchAsync(options.name, commands),
16
+ loadFile: location => HybridNitroSQLite.loadFile(options.name, location),
17
+ loadFileAsync: location => HybridNitroSQLite.loadFileAsync(options.name, location)
18
+ };
19
+ }
20
+ export function openDb(dbName, location) {
21
+ HybridNitroSQLite.open(dbName, location);
22
+ locks[dbName] = {
23
+ queue: [],
24
+ inProgress: false
25
+ };
26
+ }
27
+ export function close(dbName) {
28
+ HybridNitroSQLite.close(dbName);
29
+ delete locks[dbName];
30
+ }
31
+ //# sourceMappingURL=session.js.map