@shivaedev/effect-prisma 0.6.4 → 0.7.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/CHANGELOG.md +27 -0
- package/dist/bin/normalize-contract.js +2 -1
- package/dist/bin/normalize-contract.js.map +1 -1
- package/dist/database.d.ts +3 -3
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +4 -4
- package/dist/database.js.map +1 -1
- package/dist/error.js +4 -4
- package/dist/error.js.map +1 -1
- package/dist/internal/adapters/transaction-settlement.d.ts.map +1 -1
- package/dist/internal/adapters/transaction-settlement.js +1 -1
- package/dist/internal/adapters/transaction-settlement.js.map +1 -1
- package/dist/internal/client-lifecycle.d.ts +2 -2
- package/dist/internal/client-lifecycle.d.ts.map +1 -1
- package/dist/internal/client-lifecycle.js.map +1 -1
- package/dist/internal/contract-normalization.d.ts +0 -4
- package/dist/internal/contract-normalization.d.ts.map +1 -1
- package/dist/internal/contract-normalization.js +4 -7
- package/dist/internal/contract-normalization.js.map +1 -1
- package/dist/internal/database-facade.d.ts +1 -6
- package/dist/internal/database-facade.d.ts.map +1 -1
- package/dist/internal/database-facade.js +3 -8
- package/dist/internal/database-facade.js.map +1 -1
- package/dist/internal/database-factory.d.ts +1 -5
- package/dist/internal/database-factory.d.ts.map +1 -1
- package/dist/internal/database-factory.js +1 -7
- package/dist/internal/database-factory.js.map +1 -1
- package/dist/internal/database-types.d.ts +4 -8
- package/dist/internal/database-types.d.ts.map +1 -1
- package/dist/internal/dynamic.d.ts +1 -1
- package/dist/internal/dynamic.d.ts.map +1 -1
- package/dist/internal/dynamic.js.map +1 -1
- package/dist/internal/executor.d.ts +3 -7
- package/dist/internal/executor.d.ts.map +1 -1
- package/dist/internal/promise.d.ts +1 -1
- package/dist/internal/promise.d.ts.map +1 -1
- package/dist/internal/promise.js +2 -2
- package/dist/internal/promise.js.map +1 -1
- package/dist/internal/query-execution.d.ts +1 -1
- package/dist/internal/query-execution.d.ts.map +1 -1
- package/dist/internal/query-execution.js +1 -1
- package/dist/internal/query-execution.js.map +1 -1
- package/dist/internal/recipe.d.ts +3 -3
- package/dist/internal/recipe.d.ts.map +1 -1
- package/dist/internal/recipe.js +2 -2
- package/dist/internal/recipe.js.map +1 -1
- package/dist/internal/relation-result.d.ts +1 -1
- package/dist/internal/relation-result.d.ts.map +1 -1
- package/dist/internal/relation-result.js.map +1 -1
- package/dist/internal/relation-runtime.d.ts +2 -2
- package/dist/internal/relation-runtime.d.ts.map +1 -1
- package/dist/internal/relation-runtime.js +3 -3
- package/dist/internal/relation-runtime.js.map +1 -1
- package/dist/internal/relation-stream.d.ts +1 -1
- package/dist/internal/relation-stream.d.ts.map +1 -1
- package/dist/internal/relation-stream.js +13 -15
- package/dist/internal/relation-stream.js.map +1 -1
- package/dist/internal/sqlite-datetime.d.ts +0 -26
- package/dist/internal/sqlite-datetime.d.ts.map +1 -1
- package/dist/internal/sqlite-datetime.js +13 -34
- package/dist/internal/sqlite-datetime.js.map +1 -1
- package/dist/internal/sqlite-pragmas.d.ts +1 -13
- package/dist/internal/sqlite-pragmas.d.ts.map +1 -1
- package/dist/internal/sqlite-pragmas.js +2 -12
- package/dist/internal/sqlite-pragmas.js.map +1 -1
- package/dist/internal/testing.d.ts +1 -1
- package/dist/internal/testing.d.ts.map +1 -1
- package/dist/internal/transaction.d.ts +3 -3
- package/dist/internal/transaction.d.ts.map +1 -1
- package/dist/internal/transaction.js +3 -3
- package/dist/internal/transaction.js.map +1 -1
- package/dist/relation/include-metadata.d.ts +1 -1
- package/dist/relation/include-metadata.d.ts.map +1 -1
- package/dist/relation/include.d.ts +7 -4
- package/dist/relation/include.d.ts.map +1 -1
- package/dist/relation/prisma-methods.d.ts +16 -16
- package/dist/relation/prisma-methods.d.ts.map +1 -1
- package/dist/relation.d.ts +3 -3
- package/dist/relation.d.ts.map +1 -1
- package/dist/sqlite.d.ts +4 -9
- package/dist/sqlite.d.ts.map +1 -1
- package/dist/sqlite.js +6 -6
- package/dist/sqlite.js.map +1 -1
- package/dist/testing/transaction.d.ts +1 -1
- package/dist/testing/transaction.d.ts.map +1 -1
- package/dist/testing/transaction.js +1 -1
- package/dist/testing/transaction.js.map +1 -1
- package/dist/testing/types.d.ts +7 -7
- package/dist/testing/types.d.ts.map +1 -1
- package/dist/testing/vitest.d.ts.map +1 -1
- package/dist/testing/vitest.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/package.json +42 -36
- package/src/bin/normalize-contract.ts +2 -1
- package/src/database.ts +7 -7
- package/src/error.ts +4 -4
- package/src/internal/adapters/transaction-settlement.ts +4 -1
- package/src/internal/client-lifecycle.ts +2 -2
- package/src/internal/contract-normalization.ts +4 -7
- package/src/internal/database-facade.ts +3 -8
- package/src/internal/database-factory.ts +5 -9
- package/src/internal/database-types.ts +5 -9
- package/src/internal/dynamic.ts +1 -1
- package/src/internal/executor.ts +3 -7
- package/src/internal/promise.ts +2 -2
- package/src/internal/query-execution.ts +1 -1
- package/src/internal/recipe.ts +8 -8
- package/src/internal/relation-result.ts +2 -2
- package/src/internal/relation-runtime.ts +6 -6
- package/src/internal/relation-stream.ts +5 -6
- package/src/internal/sqlite-datetime.ts +13 -34
- package/src/internal/sqlite-pragmas.ts +3 -13
- package/src/internal/testing.ts +1 -1
- package/src/internal/transaction.ts +5 -5
- package/src/relation/include-metadata.ts +1 -1
- package/src/relation/include.ts +36 -34
- package/src/relation/prisma-methods.ts +21 -19
- package/src/relation.ts +3 -3
- package/src/sqlite.ts +10 -15
- package/src/testing/transaction.ts +2 -2
- package/src/testing/types.ts +8 -8
- package/src/testing/vitest.ts +1 -1
- package/src/testing.ts +3 -3
package/src/sqlite.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import sqlite, { type SqliteClient, type SqliteOptionsBase } from "@prisma-next/sqlite/runtime";
|
|
2
2
|
import { type Layer, Semaphore } from "effect";
|
|
3
|
+
import { acquireConnectedClient, assertAvailableModelNames } from "#internal/client-lifecycle.ts";
|
|
4
|
+
import { contractModels } from "#internal/database-facade.ts";
|
|
5
|
+
import { makeSqlDatabase } from "#internal/database-factory.ts";
|
|
6
|
+
import type { DatabaseIdentifier, DatabaseIdentifierLiteral, DatabaseServiceHolder, DefaultModels } from "#internal/database-types.ts";
|
|
7
|
+
import type { AnySqlContract } from "#internal/executor.ts";
|
|
8
|
+
import { fromPrismaPromise } from "#internal/promise.ts";
|
|
9
|
+
import { decodeSqliteDatetimesAsUtc } from "#internal/sqlite-datetime.ts";
|
|
10
|
+
import { applySqlitePragmas, assertFileBackedPath } from "#internal/sqlite-pragmas.ts";
|
|
3
11
|
import type { PrismaError } from "./error.ts";
|
|
4
|
-
import { acquireConnectedClient, assertAvailableModelNames } from "./internal/client-lifecycle.ts";
|
|
5
|
-
import { contractModels } from "./internal/database-facade.ts";
|
|
6
|
-
import { makeSqlDatabase } from "./internal/database-factory.ts";
|
|
7
|
-
import type { DatabaseIdentifier, DatabaseIdentifierLiteral, DatabaseServiceHolder, DefaultModels } from "./internal/database-types.ts";
|
|
8
|
-
import type { AnySqlContract } from "./internal/executor.ts";
|
|
9
|
-
import { fromPrismaPromise } from "./internal/promise.ts";
|
|
10
|
-
import { decodeSqliteDatetimesAsUtc } from "./internal/sqlite-datetime.ts";
|
|
11
|
-
import { applySqlitePragmas, assertFileBackedPath } from "./internal/sqlite-pragmas.ts";
|
|
12
12
|
|
|
13
|
-
export const defaultSqlitePragmas:
|
|
13
|
+
export const defaultSqlitePragmas: readonly string[] = ["journal_mode=WAL"];
|
|
14
14
|
|
|
15
15
|
export interface SqliteDatabaseLayerOptions extends SqliteOptionsBase {
|
|
16
|
-
/** Path to the database file. In-memory databases are not supported. */
|
|
17
16
|
readonly path: string;
|
|
18
|
-
|
|
19
|
-
* Pragmas applied once when the Layer connects. Defaults to
|
|
20
|
-
* {@link defaultSqlitePragmas}; pass `[]` to skip them.
|
|
21
|
-
*/
|
|
22
|
-
readonly pragmas?: ReadonlyArray<string>;
|
|
17
|
+
readonly pragmas?: readonly string[];
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
type SqliteFactoryOptions<Contract extends AnySqlContract> =
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Effect } from "effect";
|
|
2
|
-
import type { PrismaError } from "
|
|
3
|
-
import { getDatabaseTesting } from "
|
|
2
|
+
import type { PrismaError } from "#error.ts";
|
|
3
|
+
import { getDatabaseTesting } from "#internal/testing.ts";
|
|
4
4
|
import type { AnyDatabase } from "./types.ts";
|
|
5
5
|
|
|
6
6
|
type TestProgram<Database extends AnyDatabase, A, E, R> = Effect.Effect<A, E, R> & (Effect.Services<Database> extends R ? unknown : never);
|
package/src/testing/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TestContext, Vitest } from "@effect/vitest";
|
|
2
|
-
import type { EffectClock, EffectTestOptions } from "@shivaedev/effect-test";
|
|
3
2
|
import type { Effect, Layer } from "effect";
|
|
4
|
-
import type {
|
|
3
|
+
import type { EffectClock, EffectTestOptions } from "@shivaedev/effect-test";
|
|
4
|
+
import type { AnyDatabase, DatabaseServiceOf } from "#database.ts";
|
|
5
5
|
|
|
6
|
-
export type { AnyDatabase } from "
|
|
6
|
+
export type { AnyDatabase } from "#database.ts";
|
|
7
7
|
export type DatabaseService<Database extends AnyDatabase> = DatabaseServiceOf<Database>;
|
|
8
8
|
|
|
9
9
|
export type DatabaseTest<Database extends AnyDatabase, Provided> = <A, Eff extends Effect.Effect<unknown, unknown, Provided>>(
|
|
@@ -13,18 +13,18 @@ export type DatabaseTest<Database extends AnyDatabase, Provided> = <A, Eff exten
|
|
|
13
13
|
) => void;
|
|
14
14
|
|
|
15
15
|
export interface DatabaseTester<Database extends AnyDatabase, Provided> extends DatabaseTest<Database, Provided> {
|
|
16
|
-
readonly skip: DatabaseTest<Database, Provided>;
|
|
17
|
-
readonly skipIf: (condition: unknown) => DatabaseTest<Database, Provided>;
|
|
18
|
-
readonly runIf: (condition: unknown) => DatabaseTest<Database, Provided>;
|
|
19
|
-
readonly only: DatabaseTest<Database, Provided>;
|
|
20
16
|
readonly each: <Item>(
|
|
21
|
-
cases:
|
|
17
|
+
cases: readonly Item[],
|
|
22
18
|
) => <A, Eff extends Effect.Effect<unknown, unknown, Provided>>(
|
|
23
19
|
name: string,
|
|
24
20
|
body: (item: Item, database: DatabaseService<Database>, context: TestContext) => Generator<Eff, A, never>,
|
|
25
21
|
options?: number | EffectTestOptions,
|
|
26
22
|
) => void;
|
|
27
23
|
readonly fails: DatabaseTest<Database, Provided>;
|
|
24
|
+
readonly only: DatabaseTest<Database, Provided>;
|
|
25
|
+
readonly runIf: (condition: unknown) => DatabaseTest<Database, Provided>;
|
|
26
|
+
readonly skip: DatabaseTest<Database, Provided>;
|
|
27
|
+
readonly skipIf: (condition: unknown) => DatabaseTest<Database, Provided>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export type DatabaseIt<Database extends AnyDatabase, Provided> = Vitest.Methods & {
|
package/src/testing/vitest.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { it as effectIt } from "@effect/vitest";
|
|
2
|
-
import { type EffectClock, makeEffectIt } from "@shivaedev/effect-test";
|
|
3
2
|
import type { Effect, Layer } from "effect";
|
|
3
|
+
import { type EffectClock, makeEffectIt } from "@shivaedev/effect-test";
|
|
4
4
|
import { withTestTransaction } from "./transaction.ts";
|
|
5
5
|
import type { AnyDatabase, DatabaseIt, MakeDatabaseItOptions } from "./types.ts";
|
|
6
6
|
|
package/src/testing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { withTestTransaction } from "
|
|
1
|
+
export { withTestTransaction } from "#testing/transaction.ts";
|
|
2
2
|
export type {
|
|
3
3
|
AnyDatabase,
|
|
4
4
|
DatabaseIt,
|
|
@@ -6,5 +6,5 @@ export type {
|
|
|
6
6
|
DatabaseTest,
|
|
7
7
|
DatabaseTester,
|
|
8
8
|
MakeDatabaseItOptions,
|
|
9
|
-
} from "
|
|
10
|
-
export { makeDatabaseIt } from "
|
|
9
|
+
} from "#testing/types.ts";
|
|
10
|
+
export { makeDatabaseIt } from "#testing/vitest.ts";
|