react-native-nitro-sqlite 9.1.2 → 9.1.3

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 (74) hide show
  1. package/RNNitroSQLite.podspec +1 -1
  2. package/cpp/operations.cpp +4 -8
  3. package/cpp/sqlite/sqlite3.c +112968 -89110
  4. package/cpp/sqlite/sqlite3.h +2462 -1303
  5. package/cpp/types.hpp +4 -4
  6. package/lib/commonjs/index.js +21 -19
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/operations/execute.js +21 -3
  9. package/lib/commonjs/operations/execute.js.map +1 -1
  10. package/lib/commonjs/operations/session.js.map +1 -1
  11. package/lib/commonjs/types.js +1 -1
  12. package/lib/commonjs/types.js.map +1 -1
  13. package/lib/module/index.js +16 -1
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/module/operations/execute.js +21 -3
  16. package/lib/module/operations/execute.js.map +1 -1
  17. package/lib/module/operations/session.js.map +1 -1
  18. package/lib/module/types.js +2 -0
  19. package/lib/module/types.js.map +1 -1
  20. package/lib/typescript/commonjs/index.d.ts +6 -1
  21. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/operations/execute.d.ts +3 -3
  23. package/lib/typescript/commonjs/operations/execute.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/operations/transaction.d.ts.map +1 -1
  25. package/lib/typescript/commonjs/specs/NativeQueryResult.nitro.d.ts +2 -2
  26. package/lib/typescript/commonjs/specs/NativeQueryResult.nitro.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts +3 -3
  28. package/lib/typescript/commonjs/specs/NitroSQLite.nitro.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/typeORM.d.ts +2 -2
  30. package/lib/typescript/commonjs/typeORM.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/types.d.ts +14 -8
  32. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  33. package/lib/typescript/module/index.d.ts +6 -1
  34. package/lib/typescript/module/index.d.ts.map +1 -1
  35. package/lib/typescript/module/operations/execute.d.ts +3 -3
  36. package/lib/typescript/module/operations/execute.d.ts.map +1 -1
  37. package/lib/typescript/module/operations/transaction.d.ts.map +1 -1
  38. package/lib/typescript/module/specs/NativeQueryResult.nitro.d.ts +2 -2
  39. package/lib/typescript/module/specs/NativeQueryResult.nitro.d.ts.map +1 -1
  40. package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts +3 -3
  41. package/lib/typescript/module/specs/NitroSQLite.nitro.d.ts.map +1 -1
  42. package/lib/typescript/module/typeORM.d.ts +2 -2
  43. package/lib/typescript/module/typeORM.d.ts.map +1 -1
  44. package/lib/typescript/module/types.d.ts +14 -8
  45. package/lib/typescript/module/types.d.ts.map +1 -1
  46. package/nitrogen/generated/android/RNNitroSQLite+autolinking.cmake +1 -1
  47. package/nitrogen/generated/android/RNNitroSQLite+autolinking.gradle +1 -1
  48. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.cpp +1 -1
  49. package/nitrogen/generated/android/RNNitroSQLiteOnLoad.hpp +1 -1
  50. package/nitrogen/generated/ios/RNNitroSQLite+autolinking.rb +1 -1
  51. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.cpp +1 -1
  52. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Bridge.hpp +1 -1
  53. package/nitrogen/generated/ios/RNNitroSQLite-Swift-Cxx-Umbrella.hpp +1 -1
  54. package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.mm +1 -1
  55. package/nitrogen/generated/ios/RNNitroSQLiteAutolinking.swift +1 -1
  56. package/nitrogen/generated/shared/c++/BatchQueryCommand.hpp +9 -6
  57. package/nitrogen/generated/shared/c++/BatchQueryResult.hpp +1 -1
  58. package/nitrogen/generated/shared/c++/ColumnType.hpp +1 -1
  59. package/nitrogen/generated/shared/c++/FileLoadResult.hpp +1 -1
  60. package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.cpp +1 -1
  61. package/nitrogen/generated/shared/c++/HybridNativeQueryResultSpec.hpp +5 -2
  62. package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.cpp +1 -1
  63. package/nitrogen/generated/shared/c++/HybridNitroSQLiteSpec.hpp +6 -3
  64. package/nitrogen/generated/shared/c++/SQLiteNullValue.hpp +68 -0
  65. package/nitrogen/generated/shared/c++/SQLiteQueryColumnMetadata.hpp +1 -1
  66. package/package.json +1 -1
  67. package/src/index.ts +20 -2
  68. package/src/operations/execute.ts +54 -12
  69. package/src/operations/session.ts +6 -6
  70. package/src/operations/transaction.ts +4 -4
  71. package/src/specs/NativeQueryResult.nitro.ts +2 -2
  72. package/src/specs/NitroSQLite.nitro.ts +3 -3
  73. package/src/typeORM.ts +4 -4
  74. package/src/types.ts +23 -12
@@ -1,9 +1,9 @@
1
1
  import { locks, HybridNitroSQLite } from '../nitro'
2
2
  import type {
3
3
  QueryResult,
4
- SQLiteItem,
5
- SQLiteQueryParams,
6
4
  Transaction,
5
+ SQLiteQueryParams,
6
+ QueryResultRow,
7
7
  } from '../types'
8
8
  import { execute, executeAsync } from './execute'
9
9
 
@@ -30,7 +30,7 @@ export const transaction = (
30
30
  let isFinalized = false
31
31
 
32
32
  // Local transaction context object implementation
33
- const executeOnTransaction = <Data extends SQLiteItem = never>(
33
+ const executeOnTransaction = <Data extends QueryResultRow = never>(
34
34
  query: string,
35
35
  params?: SQLiteQueryParams
36
36
  ): QueryResult<Data> => {
@@ -42,7 +42,7 @@ export const transaction = (
42
42
  return execute(dbName, query, params)
43
43
  }
44
44
 
45
- const executeAsyncOnTransaction = <Data extends SQLiteItem = never>(
45
+ const executeAsyncOnTransaction = <Data extends QueryResultRow = never>(
46
46
  query: string,
47
47
  params?: SQLiteQueryParams
48
48
  ): Promise<QueryResult<Data>> => {
@@ -17,7 +17,7 @@ export interface NativeQueryResult
17
17
  readonly insertId?: number
18
18
 
19
19
  /** Query results */
20
- readonly results: SQLiteQueryResults
20
+ readonly results: NativeSQLiteQueryResults
21
21
  /** Table metadata */
22
22
  readonly metadata?: Record<string, SQLiteQueryColumnMetadata>
23
23
  }
@@ -30,7 +30,7 @@ export interface NativeQueryResult
30
30
  // TODO: Investigate why this doesn't work with nitrogen
31
31
  // export type SQLiteQueryResultRow = Record<string, SQLiteValue>
32
32
  // export type SQLiteQueryResults = SQLiteQueryResultRow[]
33
- export type SQLiteQueryResults = Record<string, SQLiteValue>[]
33
+ export type NativeSQLiteQueryResults = Record<string, SQLiteValue>[]
34
34
 
35
35
  // TODO: Investigate why this doesn't work with nitrogen
36
36
  // export type SQLiteQueryTableMetadata = Record<string, SQLiteQueryColumnMetadata>
@@ -3,7 +3,7 @@ import type {
3
3
  BatchQueryResult,
4
4
  FileLoadResult,
5
5
  BatchQueryCommand,
6
- SQLiteQueryParams,
6
+ NativeSQLiteQueryParams,
7
7
  } from '../types'
8
8
  import type { NativeQueryResult } from './NativeQueryResult.nitro'
9
9
 
@@ -22,12 +22,12 @@ export interface NitroSQLite
22
22
  execute(
23
23
  dbName: string,
24
24
  query: string,
25
- params?: SQLiteQueryParams
25
+ params?: NativeSQLiteQueryParams
26
26
  ): NativeQueryResult
27
27
  executeAsync(
28
28
  dbName: string,
29
29
  query: string,
30
- params?: SQLiteQueryParams
30
+ params?: NativeSQLiteQueryParams
31
31
  ): Promise<NativeQueryResult>
32
32
  executeBatch(dbName: string, commands: BatchQueryCommand[]): BatchQueryResult
33
33
  executeBatchAsync(
package/src/typeORM.ts CHANGED
@@ -7,14 +7,14 @@
7
7
 
8
8
  import type {
9
9
  QueryResult,
10
- SQLiteItem,
11
- SQLiteQueryParams,
12
10
  Transaction,
11
+ SQLiteQueryParams,
12
+ QueryResultRow,
13
13
  } from './types'
14
14
  import * as Operations from './operations/session'
15
15
 
16
16
  interface TypeOrmNitroSQLiteConnection {
17
- executeSql: <RowData extends SQLiteItem = never>(
17
+ executeSql: <RowData extends QueryResultRow = never>(
18
18
  sql: string,
19
19
  params: SQLiteQueryParams | undefined,
20
20
  okExecute: (res: QueryResult<RowData>) => void,
@@ -48,7 +48,7 @@ export const typeORMDriver = {
48
48
  const db = Operations.open(options)
49
49
 
50
50
  const connection: TypeOrmNitroSQLiteConnection = {
51
- executeSql: async <RowData extends SQLiteItem = never>(
51
+ executeSql: async <RowData extends QueryResultRow = never>(
52
52
  sql: string,
53
53
  params: SQLiteQueryParams | undefined,
54
54
  okExecute: (res: QueryResult<RowData>) => void,
package/src/types.ts CHANGED
@@ -26,41 +26,52 @@ export enum ColumnType {
26
26
  NULL_VALUE,
27
27
  }
28
28
 
29
+ // Passing null/undefined in array types is not possible, so we us a special struct as a workaround.
30
+ export type SQLiteNullValue = {
31
+ isNitroSQLiteNull: true
32
+ }
33
+ export type SQLiteValue =
34
+ | boolean
35
+ | number
36
+ | string
37
+ | ArrayBuffer
38
+ | SQLiteNullValue
39
+ export type NativeSQLiteQueryParams = SQLiteValue[]
40
+
29
41
  /**
30
42
  * Represents a value that can be stored in a SQLite database
31
43
  */
32
- export type SQLiteValue = boolean | number | string | ArrayBuffer | undefined
44
+ export type SQLiteQueryParamItem = SQLiteValue | null | undefined
45
+ export type SQLiteQueryParams = SQLiteQueryParamItem[]
33
46
 
34
- export type SQLiteItem = Record<string, SQLiteValue>
35
-
36
- export interface QueryResult<RowData extends SQLiteItem = SQLiteItem> {
47
+ export type QueryResultRowItem = SQLiteValue | undefined
48
+ export type QueryResultRow = Record<string, QueryResultRowItem>
49
+ export interface QueryResult<Row extends QueryResultRow = QueryResultRow> {
37
50
  readonly insertId?: number
38
51
  readonly rowsAffected: number
39
52
 
40
53
  readonly rows?: {
41
54
  /** Raw array with all dataset */
42
- _array: RowData[]
55
+ _array: Row[]
43
56
  /** The lengh of the dataset */
44
57
  length: number
45
58
  /** A convenience function to acess the index based the row object
46
59
  * @param idx the row index
47
60
  * @returns the row structure identified by column names
48
61
  */
49
- item: (idx: number) => RowData | undefined
62
+ item: (idx: number) => Row | undefined
50
63
  }
51
64
  }
52
65
 
53
- export type SQLiteQueryParams = SQLiteValue[]
54
-
55
- export type ExecuteQuery = <RowData extends SQLiteItem = SQLiteItem>(
66
+ export type ExecuteQuery = <Row extends QueryResultRow = QueryResultRow>(
56
67
  query: string,
57
68
  params?: SQLiteQueryParams
58
- ) => QueryResult<RowData>
69
+ ) => QueryResult<Row>
59
70
 
60
- export type ExecuteAsyncQuery = <RowData extends SQLiteItem = SQLiteItem>(
71
+ export type ExecuteAsyncQuery = <Row extends QueryResultRow = QueryResultRow>(
61
72
  query: string,
62
73
  params?: SQLiteQueryParams
63
- ) => Promise<QueryResult<RowData>>
74
+ ) => Promise<QueryResult<Row>>
64
75
 
65
76
  export interface Transaction {
66
77
  commit(): QueryResult