@evolu/react-native 7.1.1 → 8.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteLive.d.ts","sourceRoot":"","sources":["../src/SqliteLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EAMP,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,eAAO,MAAM,UAAU,oCA6BtB,CAAC"}
1
+ {"version":3,"file":"SqliteLive.d.ts","sourceRoot":"","sources":["../src/SqliteLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EAOP,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,eAAO,MAAM,UAAU,oCA2BtB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Config, Sqlite, ensureSqliteQuery, isSqlMutation, maybeParseJson, valuesToSqliteValues, } from "@evolu/common";
1
+ import { Config, Sqlite, isSqlMutation, maybeLogSql, maybeLogSqliteQueryExecutionTime, maybeParseJson, valuesToSqliteValues, } from "@evolu/common";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import * as ExpoSQLite from "expo-sqlite/next";
@@ -6,18 +6,14 @@ export const SqliteLive = Layer.effect(Sqlite, Effect.gen(function* (_) {
6
6
  const config = yield* _(Config);
7
7
  const db = ExpoSQLite.openDatabaseSync(`evolu1-${config.name}.db`);
8
8
  return Sqlite.of({
9
- exec: (arg) => Effect.gen(function* (_) {
10
- const sqliteQuery = ensureSqliteQuery(arg);
11
- const query = {
12
- sql: sqliteQuery.sql,
13
- args: valuesToSqliteValues(sqliteQuery.parameters),
14
- };
9
+ exec: (query) => Effect.gen(function* (_) {
10
+ const parameters = valuesToSqliteValues(query.parameters || []);
15
11
  if (!isSqlMutation(query.sql)) {
16
- const rows = (yield* _(Effect.promise(() => db.getAllAsync(query.sql, query.args))));
12
+ const rows = (yield* _(Effect.promise(() => db.getAllAsync(query.sql, parameters)), maybeLogSql(query, config.logSql), maybeLogSqliteQueryExecutionTime(query)));
17
13
  maybeParseJson(rows);
18
14
  return { rows, changes: 0 };
19
15
  }
20
- const { changes } = yield* _(Effect.promise(() => db.runAsync(query.sql, query.args)));
16
+ const { changes } = yield* _(Effect.promise(() => db.runAsync(query.sql, parameters)));
21
17
  return { rows: [], changes };
22
18
  }),
23
19
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/react-native",
3
- "version": "7.1.1",
3
+ "version": "8.0.1",
4
4
  "description": "Evolu for React Native",
5
5
  "keywords": [
6
6
  "evolu",
@@ -35,21 +35,21 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "eslint": "^8.57.0",
38
- "expo": "^50.0.11",
39
- "expo-sqlite": "~13.3.0",
40
- "react-native": "0.73.4",
41
- "typescript": "^5.4.2",
38
+ "expo": "^50.0.14",
39
+ "expo-sqlite": "~13.4.0",
40
+ "react-native": "0.73.6",
41
+ "typescript": "^5.4.3",
42
42
  "vitest": "^1.4.0",
43
- "@evolu/common": "4.0.5",
44
- "@evolu/common-react": "6.0.3",
45
- "eslint-config-evolu": "1.0.0",
46
- "@evolu/tsconfig": "0.0.2"
43
+ "@evolu/common": "4.1.1",
44
+ "@evolu/common-react": "7.0.0",
45
+ "@evolu/tsconfig": "0.0.2",
46
+ "eslint-config-evolu": "1.0.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@evolu/common-react": "^6.0.3",
50
- "expo": "^50.0.11",
51
- "expo-sqlite": "~13.3.0",
52
- "react-native": "0.73.4"
49
+ "@evolu/common-react": "^7.0.0",
50
+ "expo": "^50.0.14",
51
+ "expo-sqlite": "~13.4.0",
52
+ "react-native": "0.73.6"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
package/src/SqliteLive.ts CHANGED
@@ -2,8 +2,9 @@ import {
2
2
  Config,
3
3
  Sqlite,
4
4
  SqliteRow,
5
- ensureSqliteQuery,
6
5
  isSqlMutation,
6
+ maybeLogSql,
7
+ maybeLogSqliteQueryExecutionTime,
7
8
  maybeParseJson,
8
9
  valuesToSqliteValues,
9
10
  } from "@evolu/common";
@@ -18,23 +19,21 @@ export const SqliteLive = Layer.effect(
18
19
  const db = ExpoSQLite.openDatabaseSync(`evolu1-${config.name}.db`);
19
20
 
20
21
  return Sqlite.of({
21
- exec: (arg) =>
22
+ exec: (query) =>
22
23
  Effect.gen(function* (_) {
23
- const sqliteQuery = ensureSqliteQuery(arg);
24
- const query = {
25
- sql: sqliteQuery.sql,
26
- args: valuesToSqliteValues(sqliteQuery.parameters),
27
- };
24
+ const parameters = valuesToSqliteValues(query.parameters || []);
28
25
 
29
26
  if (!isSqlMutation(query.sql)) {
30
27
  const rows = (yield* _(
31
- Effect.promise(() => db.getAllAsync(query.sql, query.args)),
28
+ Effect.promise(() => db.getAllAsync(query.sql, parameters)),
29
+ maybeLogSql(query, config.logSql),
30
+ maybeLogSqliteQueryExecutionTime(query),
32
31
  )) as SqliteRow[];
33
32
  maybeParseJson(rows);
34
33
  return { rows, changes: 0 };
35
34
  }
36
35
  const { changes } = yield* _(
37
- Effect.promise(() => db.runAsync(query.sql, query.args)),
36
+ Effect.promise(() => db.runAsync(query.sql, parameters)),
38
37
  );
39
38
  return { rows: [], changes };
40
39
  }),