@batijs/cli 0.0.633 → 0.0.635
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/dist/{asset-env-Jk0sS-Q2.js → asset-env-DvKtWq7P.js} +6 -3
- package/dist/{asset-package.json-BgXWfTnb.js → asset-package.json-CBsEdGlU.js} +1 -0
- package/dist/{asset-package.json-CJq8QmFk.js → asset-package.json-CXa26JLJ.js} +1 -0
- package/dist/{asset-package.json-DotEkyyW.js → asset-package.json-CpJdnsXW.js} +2 -1
- package/dist/asset-package.json-D5lEjBIT.js +41 -0
- package/dist/{asset-package.json-BfPjhiqX.js → asset-package.json-DcJFVtbo.js} +2 -0
- package/dist/{asset-package.json-CO-Tvf85.js → asset-package.json-WOGFbHRZ.js} +1 -0
- package/dist/{asset-package.json-D5VQND8y.js → asset-package2.json-Cqt3zXsB.js} +1 -0
- package/dist/boilerplates/@batijs/d1-sqlite/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/docker-compose/files/$Dockerfile.js +17 -9
- package/dist/boilerplates/@batijs/docker-compose/files/$docker-compose.yml.js +1 -1
- package/dist/boilerplates/@batijs/docker-compose/files/asset-env.mjs +6 -3
- package/dist/boilerplates/@batijs/docker-compose/files/docker-compose.yml +25 -2
- package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +5 -2
- package/dist/boilerplates/@batijs/drizzle/files/asset-package.json.mjs +2 -1
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/db.ts +11 -1
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/queries/todos.ts +6 -3
- package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/schema/todos.ts +11 -5
- package/dist/boilerplates/@batijs/drizzle/files/drizzle.config.ts +1 -1
- package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/db.d.mts +5 -1
- package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/queries/todos.d.mts +5 -48
- package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/schema/todos.d.mts +43 -1
- package/dist/boilerplates/@batijs/express/files/+server.ts +1 -1
- package/dist/boilerplates/@batijs/fastify/files/+server.ts +1 -1
- package/dist/boilerplates/@batijs/h3/files/+server.ts +1 -1
- package/dist/boilerplates/@batijs/hono/files/server/hono.ts +1 -1
- package/dist/boilerplates/@batijs/kysely/files/$package.json.js +6 -8
- package/dist/boilerplates/@batijs/kysely/files/asset-package.json.mjs +2 -0
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/db.ts +13 -1
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/migrate.ts +2 -2
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/migrations/001_create_todos_table.ts +4 -5
- package/dist/boilerplates/@batijs/kysely/files/database/kysely/queries/todos.ts +3 -1
- package/dist/boilerplates/@batijs/kysely/types/database/kysely/db.d.mts +2 -1
- package/dist/boilerplates/@batijs/kysely/types/database/kysely/queries/todos.d.mts +3 -1
- package/dist/boilerplates/@batijs/postgres/bati.config.mjs +25 -0
- package/dist/boilerplates/@batijs/postgres/files/$TODO.md.js +25 -0
- package/dist/boilerplates/@batijs/postgres/files/$package.json.js +15 -0
- package/dist/boilerplates/@batijs/postgres/files/asset-package.json.mjs +39 -0
- package/dist/boilerplates/@batijs/postgres/files/database/postgres/db.ts +15 -0
- package/dist/boilerplates/@batijs/postgres/files/database/postgres/queries/todos.ts +9 -0
- package/dist/boilerplates/@batijs/postgres/files/database/postgres/schema/all.ts +1 -0
- package/dist/boilerplates/@batijs/postgres/files/database/postgres/schema/todos.ts +16 -0
- package/dist/boilerplates/@batijs/postgres/types/database/postgres/db.d.mts +6 -0
- package/dist/boilerplates/@batijs/postgres/types/database/postgres/queries/todos.d.mts +10 -0
- package/dist/boilerplates/@batijs/postgres/types/database/postgres/schema/all.d.mts +1 -0
- package/dist/boilerplates/@batijs/postgres/types/database/postgres/schema/todos.d.mts +1 -0
- package/dist/boilerplates/@batijs/prisma/bati.config.mjs +6 -12
- package/dist/boilerplates/@batijs/prisma/files/$TODO.md.js +4 -3
- package/dist/boilerplates/@batijs/shared-db/bati.config.mjs +26 -12
- package/dist/boilerplates/@batijs/shared-db/files/server/db-middleware.ts +25 -15
- package/dist/boilerplates/@batijs/shared-db/types/server/db-middleware.d.mts +9 -5
- package/dist/boilerplates/@batijs/shared-server/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/shared-server/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/shared-server/files/server/create-todo-handler.ts +13 -6
- package/dist/boilerplates/@batijs/shared-server/types/server/create-todo-handler.d.mts +15 -5
- package/dist/boilerplates/@batijs/shared-todo/files/global.d.ts +9 -5
- package/dist/boilerplates/@batijs/shared-todo/files/pages/todo/+data.ts +7 -2
- package/dist/boilerplates/@batijs/shared-todo/types/pages/todo/+data.d.mts +1 -3
- package/dist/boilerplates/@batijs/sqlite/bati.config.mjs +1 -1
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/telefunc/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/telefunc/files/global.d.ts +9 -6
- package/dist/boilerplates/@batijs/telefunc/files/pages/todo/TodoList.telefunc.ts +6 -2
- package/dist/boilerplates/@batijs/telefunc/files/server/telefunc-handler.ts +9 -4
- package/dist/boilerplates/@batijs/trpc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/trpc/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/trpc/files/trpc/server.ts +13 -6
- package/dist/boilerplates/@batijs/trpc/types/trpc/client.d.mts +6 -0
- package/dist/boilerplates/@batijs/trpc/types/trpc/server.d.mts +22 -3
- package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/ts-rest/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/ts-rest/files/server/ts-rest-handler.ts +13 -6
- package/dist/boilerplates/boilerplates.json +6 -0
- package/dist/index.js +4 -1
- package/package.json +5 -5
|
@@ -18,6 +18,7 @@ var package_default = {
|
|
|
18
18
|
"@batijs/d1-sqlite": "workspace:*",
|
|
19
19
|
"@batijs/drizzle": "workspace:*",
|
|
20
20
|
"@batijs/kysely": "workspace:*",
|
|
21
|
+
"@batijs/postgres": "workspace:*",
|
|
21
22
|
"@batijs/sqlite": "workspace:*",
|
|
22
23
|
"@types/node": "^20.19.37",
|
|
23
24
|
"@universal-middleware/core": "^0.4.17",
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type { dbD1, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
-
import type { dbKysely, dbKyselyD1 } from "@batijs/kysely/database/kysely/db";
|
|
1
|
+
import type { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
+
import type { dbKysely, dbKyselyD1, dbKyselyPostgres } from "@batijs/kysely/database/kysely/db";
|
|
3
|
+
import type { db as pgDb } from "@batijs/postgres/database/postgres/db";
|
|
3
4
|
import type { db as sqliteDb } from "@batijs/sqlite/database/sqlite/db";
|
|
4
5
|
|
|
5
|
-
//# BATI.
|
|
6
|
+
//# BATI.hasDbDemo
|
|
6
7
|
declare module "telefunc" {
|
|
7
8
|
namespace Telefunc {
|
|
8
9
|
interface Context {
|
|
9
10
|
db: BATI.If<{
|
|
10
|
-
'BATI.has("
|
|
11
|
+
'BATI.has("drizzle") && BATI.has("postgres")': ReturnType<typeof dbPostgres>;
|
|
12
|
+
'BATI.has("kysely") && BATI.has("postgres")': ReturnType<typeof dbKyselyPostgres>;
|
|
13
|
+
'BATI.has("postgres") && !BATI.hasOrm': ReturnType<typeof pgDb>;
|
|
14
|
+
'BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm': ReturnType<typeof sqliteDb>;
|
|
11
15
|
'BATI.has("drizzle") && !BATI.hasD1': ReturnType<typeof dbSqlite>;
|
|
12
16
|
'BATI.has("drizzle")': ReturnType<typeof dbD1>;
|
|
13
17
|
'BATI.has("kysely") && !BATI.hasD1': ReturnType<typeof dbKysely>;
|
|
14
18
|
'BATI.has("kysely")': ReturnType<typeof dbKyselyD1>;
|
|
15
|
-
"BATI.hasD1": D1Database;
|
|
16
|
-
_: object;
|
|
19
|
+
"BATI.hasD1 && !BATI.hasOrm": D1Database;
|
|
17
20
|
}>;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as d1Queries from "@batijs/d1-sqlite/database/d1/queries/todos";
|
|
4
4
|
import * as drizzleQueries from "@batijs/drizzle/database/drizzle/queries/todos";
|
|
5
5
|
import * as kyselyQueries from "@batijs/kysely/database/kysely/queries/todos";
|
|
6
|
+
import * as pgQueries from "@batijs/postgres/database/postgres/queries/todos";
|
|
6
7
|
import * as sqliteQueries from "@batijs/sqlite/database/sqlite/queries/todos";
|
|
7
8
|
import { getContext } from "telefunc";
|
|
8
9
|
|
|
@@ -10,15 +11,18 @@ export async function onNewTodo({ text }: { text: string }) {
|
|
|
10
11
|
if (BATI.has("drizzle")) {
|
|
11
12
|
const context = getContext();
|
|
12
13
|
await drizzleQueries.insertTodo(context.db, text);
|
|
13
|
-
} else if (BATI.has("sqlite") && !BATI.hasD1) {
|
|
14
|
+
} else if (BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm) {
|
|
14
15
|
const context = getContext();
|
|
15
16
|
sqliteQueries.insertTodo(context.db, text);
|
|
16
17
|
} else if (BATI.has("kysely")) {
|
|
17
18
|
const context = getContext();
|
|
18
19
|
await kyselyQueries.insertTodo(context.db, text);
|
|
19
|
-
} else if (BATI.hasD1) {
|
|
20
|
+
} else if (BATI.hasD1 && !BATI.hasOrm) {
|
|
20
21
|
const context = getContext();
|
|
21
22
|
await d1Queries.insertTodo(context.db, text);
|
|
23
|
+
} else if (BATI.has("postgres") && !BATI.hasOrm) {
|
|
24
|
+
const context = getContext();
|
|
25
|
+
await pgQueries.insertTodo(context.db, text);
|
|
22
26
|
} else {
|
|
23
27
|
// NOTE: This telefunction is only for demonstration — it doesn't actually save changes to a database.
|
|
24
28
|
// Go to https://vike.dev/new and select a database to scaffold an app with a persisted to-do list.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { dbD1, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
-
import type { dbKysely, dbKyselyD1 } from "@batijs/kysely/database/kysely/db";
|
|
1
|
+
import type { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
+
import type { dbKysely, dbKyselyD1, dbKyselyPostgres } from "@batijs/kysely/database/kysely/db";
|
|
3
|
+
import type { db as pgDb } from "@batijs/postgres/database/postgres/db";
|
|
3
4
|
import type { db as sqliteDb } from "@batijs/sqlite/database/sqlite/db";
|
|
4
5
|
import { enhance, type UniversalHandler } from "@universal-middleware/core";
|
|
5
6
|
import { telefunc } from "telefunc";
|
|
@@ -11,12 +12,16 @@ export const telefuncHandler: UniversalHandler = enhance(
|
|
|
11
12
|
request,
|
|
12
13
|
context: {
|
|
13
14
|
...(context as BATI.If<{
|
|
14
|
-
'BATI.has("
|
|
15
|
+
'BATI.has("drizzle") && BATI.has("postgres")': { db: ReturnType<typeof dbPostgres> };
|
|
16
|
+
'BATI.has("kysely") && BATI.has("postgres")': { db: ReturnType<typeof dbKyselyPostgres> };
|
|
17
|
+
'BATI.has("postgres") && !BATI.hasOrm': { db: ReturnType<typeof pgDb> };
|
|
18
|
+
'BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm': { db: ReturnType<typeof sqliteDb> };
|
|
15
19
|
'BATI.has("drizzle") && !BATI.hasD1': { db: ReturnType<typeof dbSqlite> };
|
|
16
20
|
'BATI.has("drizzle")': { db: ReturnType<typeof dbD1> };
|
|
17
21
|
'BATI.has("kysely") && !BATI.hasD1': { db: ReturnType<typeof dbKysely> };
|
|
18
22
|
'BATI.has("kysely")': { db: ReturnType<typeof dbKyselyD1> };
|
|
19
|
-
"BATI.hasD1": { db: D1Database };
|
|
23
|
+
"BATI.hasD1 && !BATI.hasOrm": { db: D1Database };
|
|
24
|
+
_: object;
|
|
20
25
|
}>),
|
|
21
26
|
...(runtime as BATI.If<{
|
|
22
27
|
"BATI.hasD1": { runtime: "workerd"; env?: { DB: D1Database } };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/trpc/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-WOGFbHRZ.js").then((x) => x.default))).addDependencies(["@trpc/server", "@trpc/client"]);
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
export { getPackageJson as default };
|
|
@@ -18,6 +18,7 @@ var package_default = {
|
|
|
18
18
|
"@batijs/d1-sqlite": "workspace:*",
|
|
19
19
|
"@batijs/drizzle": "workspace:*",
|
|
20
20
|
"@batijs/kysely": "workspace:*",
|
|
21
|
+
"@batijs/postgres": "workspace:*",
|
|
21
22
|
"@batijs/sqlite": "workspace:*",
|
|
22
23
|
"@trpc/client": "^11.17.0",
|
|
23
24
|
"@trpc/server": "^11.17.0",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as d1Queries from "@batijs/d1-sqlite/database/d1/queries/todos";
|
|
2
|
-
import type { dbD1, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
+
import type { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
3
3
|
import * as drizzleQueries from "@batijs/drizzle/database/drizzle/queries/todos";
|
|
4
|
-
import type { dbKysely, dbKyselyD1 } from "@batijs/kysely/database/kysely/db";
|
|
4
|
+
import type { dbKysely, dbKyselyD1, dbKyselyPostgres } from "@batijs/kysely/database/kysely/db";
|
|
5
5
|
import * as kyselyQueries from "@batijs/kysely/database/kysely/queries/todos";
|
|
6
|
+
import type { db as pgDb } from "@batijs/postgres/database/postgres/db";
|
|
7
|
+
import * as pgQueries from "@batijs/postgres/database/postgres/queries/todos";
|
|
6
8
|
import type { db as sqliteDb } from "@batijs/sqlite/database/sqlite/db";
|
|
7
9
|
import * as sqliteQueries from "@batijs/sqlite/database/sqlite/queries/todos";
|
|
8
10
|
import { initTRPC } from "@trpc/server";
|
|
@@ -14,12 +16,15 @@ import { initTRPC } from "@trpc/server";
|
|
|
14
16
|
const t = initTRPC
|
|
15
17
|
.context<
|
|
16
18
|
BATI.If<{
|
|
17
|
-
'BATI.has("
|
|
19
|
+
'BATI.has("drizzle") && BATI.has("postgres")': { db: ReturnType<typeof dbPostgres> };
|
|
20
|
+
'BATI.has("kysely") && BATI.has("postgres")': { db: ReturnType<typeof dbKyselyPostgres> };
|
|
21
|
+
'BATI.has("postgres") && !BATI.hasOrm': { db: ReturnType<typeof pgDb> };
|
|
22
|
+
'BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm': { db: ReturnType<typeof sqliteDb> };
|
|
18
23
|
'BATI.has("drizzle") && !BATI.hasD1': { db: ReturnType<typeof dbSqlite> };
|
|
19
24
|
'BATI.has("drizzle")': { db: ReturnType<typeof dbD1> };
|
|
20
25
|
'BATI.has("kysely") && !BATI.hasD1': { db: ReturnType<typeof dbKysely> };
|
|
21
26
|
'BATI.has("kysely")': { db: ReturnType<typeof dbKyselyD1> };
|
|
22
|
-
"BATI.hasD1": { db: D1Database };
|
|
27
|
+
"BATI.hasD1 && !BATI.hasOrm": { db: D1Database };
|
|
23
28
|
_: object;
|
|
24
29
|
}>
|
|
25
30
|
>()
|
|
@@ -46,12 +51,14 @@ export const appRouter = router({
|
|
|
46
51
|
.mutation(async (opts) => {
|
|
47
52
|
if (BATI.has("drizzle")) {
|
|
48
53
|
await drizzleQueries.insertTodo(opts.ctx.db, opts.input);
|
|
49
|
-
} else if (BATI.has("sqlite") && !BATI.hasD1) {
|
|
54
|
+
} else if (BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm) {
|
|
50
55
|
sqliteQueries.insertTodo(opts.ctx.db, opts.input);
|
|
51
56
|
} else if (BATI.has("kysely")) {
|
|
52
57
|
await kyselyQueries.insertTodo(opts.ctx.db, opts.input);
|
|
53
|
-
} else if (BATI.hasD1) {
|
|
58
|
+
} else if (BATI.hasD1 && !BATI.hasOrm) {
|
|
54
59
|
await d1Queries.insertTodo(opts.ctx.db, opts.input);
|
|
60
|
+
} else if (BATI.has("postgres") && !BATI.hasOrm) {
|
|
61
|
+
await pgQueries.insertTodo(opts.ctx.db, opts.input);
|
|
55
62
|
} else {
|
|
56
63
|
// This is where you'd persist the data
|
|
57
64
|
console.log("Received new todo", { text: opts.input });
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
//#region files/trpc/client.d.ts
|
|
2
2
|
declare const trpc: import("@trpc/client").TRPCClient<import("@trpc/server").TRPCBuiltRouter<{
|
|
3
3
|
ctx: object & {
|
|
4
|
+
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbPostgres>;
|
|
5
|
+
} & {
|
|
6
|
+
db: ReturnType<typeof import("@batijs/kysely/database/kysely/db").dbKyselyPostgres>;
|
|
7
|
+
} & {
|
|
8
|
+
db: ReturnType<typeof import("@batijs/postgres/database/postgres/db").db>;
|
|
9
|
+
} & {
|
|
4
10
|
db: ReturnType<typeof import("@batijs/sqlite/database/sqlite/db").db>;
|
|
5
11
|
} & {
|
|
6
12
|
db: ReturnType<typeof import("@batijs/drizzle/database/drizzle/db").dbSqlite>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { dbD1, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
-
import { dbKysely, dbKyselyD1 } from "@batijs/kysely/database/kysely/db";
|
|
3
|
-
import { db } from "@batijs/
|
|
1
|
+
import { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
2
|
+
import { dbKysely, dbKyselyD1, dbKyselyPostgres } from "@batijs/kysely/database/kysely/db";
|
|
3
|
+
import { db } from "@batijs/postgres/database/postgres/db";
|
|
4
|
+
import { db as db$1 } from "@batijs/sqlite/database/sqlite/db";
|
|
4
5
|
|
|
5
6
|
//#region files/trpc/server.d.ts
|
|
6
7
|
/**
|
|
@@ -9,7 +10,13 @@ import { db } from "@batijs/sqlite/database/sqlite/db";
|
|
|
9
10
|
*/
|
|
10
11
|
declare const router: import("@trpc/server").TRPCRouterBuilder<{
|
|
11
12
|
ctx: object & {
|
|
13
|
+
db: ReturnType<typeof dbPostgres>;
|
|
14
|
+
} & {
|
|
15
|
+
db: ReturnType<typeof dbKyselyPostgres>;
|
|
16
|
+
} & {
|
|
12
17
|
db: ReturnType<typeof db>;
|
|
18
|
+
} & {
|
|
19
|
+
db: ReturnType<typeof db$1>;
|
|
13
20
|
} & {
|
|
14
21
|
db: ReturnType<typeof dbSqlite>;
|
|
15
22
|
} & {
|
|
@@ -26,7 +33,13 @@ declare const router: import("@trpc/server").TRPCRouterBuilder<{
|
|
|
26
33
|
transformer: false;
|
|
27
34
|
}>;
|
|
28
35
|
declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<object & {
|
|
36
|
+
db: ReturnType<typeof dbPostgres>;
|
|
37
|
+
} & {
|
|
38
|
+
db: ReturnType<typeof dbKyselyPostgres>;
|
|
39
|
+
} & {
|
|
29
40
|
db: ReturnType<typeof db>;
|
|
41
|
+
} & {
|
|
42
|
+
db: ReturnType<typeof db$1>;
|
|
30
43
|
} & {
|
|
31
44
|
db: ReturnType<typeof dbSqlite>;
|
|
32
45
|
} & {
|
|
@@ -40,7 +53,13 @@ declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<objec
|
|
|
40
53
|
}, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
|
|
41
54
|
declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
42
55
|
ctx: object & {
|
|
56
|
+
db: ReturnType<typeof dbPostgres>;
|
|
57
|
+
} & {
|
|
58
|
+
db: ReturnType<typeof dbKyselyPostgres>;
|
|
59
|
+
} & {
|
|
43
60
|
db: ReturnType<typeof db>;
|
|
61
|
+
} & {
|
|
62
|
+
db: ReturnType<typeof db$1>;
|
|
44
63
|
} & {
|
|
45
64
|
db: ReturnType<typeof dbSqlite>;
|
|
46
65
|
} & {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/ts-rest/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package2.json-Cqt3zXsB.js").then((x) => x.default))).addDevDependencies(["zod"]).addDependencies([
|
|
7
7
|
"@ts-rest/core",
|
|
8
8
|
"@ts-rest/serverless",
|
|
9
9
|
"@universal-middleware/core"
|
|
@@ -18,6 +18,7 @@ var package_default = {
|
|
|
18
18
|
"@batijs/d1-sqlite": "workspace:*",
|
|
19
19
|
"@batijs/drizzle": "workspace:*",
|
|
20
20
|
"@batijs/kysely": "workspace:*",
|
|
21
|
+
"@batijs/postgres": "workspace:*",
|
|
21
22
|
"@batijs/sqlite": "workspace:*",
|
|
22
23
|
"@ts-rest/core": "^3.52.1",
|
|
23
24
|
"@ts-rest/serverless": "^3.52.1",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/** biome-ignore-all lint/suspicious/noExplicitAny: avoid platformContext type inference */
|
|
2
2
|
import * as d1Queries from "@batijs/d1-sqlite/database/d1/queries/todos";
|
|
3
|
-
import type { dbD1, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
3
|
+
import type { dbD1, dbPostgres, dbSqlite } from "@batijs/drizzle/database/drizzle/db";
|
|
4
4
|
import * as drizzleQueries from "@batijs/drizzle/database/drizzle/queries/todos";
|
|
5
|
-
import type { dbKysely, dbKyselyD1 } from "@batijs/kysely/database/kysely/db";
|
|
5
|
+
import type { dbKysely, dbKyselyD1, dbKyselyPostgres } from "@batijs/kysely/database/kysely/db";
|
|
6
6
|
import * as kyselyQueries from "@batijs/kysely/database/kysely/queries/todos";
|
|
7
|
+
import type { db as pgDb } from "@batijs/postgres/database/postgres/db";
|
|
8
|
+
import * as pgQueries from "@batijs/postgres/database/postgres/queries/todos";
|
|
7
9
|
import type { db as sqliteDb } from "@batijs/sqlite/database/sqlite/db";
|
|
8
10
|
import * as sqliteQueries from "@batijs/sqlite/database/sqlite/queries/todos";
|
|
9
11
|
import { fetchRequestHandler, tsr } from "@ts-rest/serverless/fetch";
|
|
@@ -18,12 +20,15 @@ import { contract } from "../ts-rest/contract";
|
|
|
18
20
|
const router = tsr
|
|
19
21
|
.platformContext<
|
|
20
22
|
BATI.If<{
|
|
21
|
-
'BATI.has("
|
|
23
|
+
'BATI.has("drizzle") && BATI.has("postgres")': { db: ReturnType<typeof dbPostgres> };
|
|
24
|
+
'BATI.has("kysely") && BATI.has("postgres")': { db: ReturnType<typeof dbKyselyPostgres> };
|
|
25
|
+
'BATI.has("postgres") && !BATI.hasOrm': { db: ReturnType<typeof pgDb> };
|
|
26
|
+
'BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm': { db: ReturnType<typeof sqliteDb> };
|
|
22
27
|
'BATI.has("drizzle") && !BATI.hasD1': { db: ReturnType<typeof dbSqlite> };
|
|
23
28
|
'BATI.has("drizzle")': { db: ReturnType<typeof dbD1> };
|
|
24
29
|
'BATI.has("kysely") && !BATI.hasD1': { db: ReturnType<typeof dbKysely> };
|
|
25
30
|
'BATI.has("kysely")': { db: ReturnType<typeof dbKyselyD1> };
|
|
26
|
-
"BATI.hasD1": { db: D1Database };
|
|
31
|
+
"BATI.hasD1 && !BATI.hasOrm": { db: D1Database };
|
|
27
32
|
_: object;
|
|
28
33
|
}>
|
|
29
34
|
>()
|
|
@@ -39,12 +44,14 @@ const router = tsr
|
|
|
39
44
|
createTodo: async ({ body }, _ctx) => {
|
|
40
45
|
if (BATI.has("drizzle")) {
|
|
41
46
|
await drizzleQueries.insertTodo(_ctx.db, body.text);
|
|
42
|
-
} else if (BATI.has("sqlite") && !BATI.hasD1) {
|
|
47
|
+
} else if (BATI.has("sqlite") && !BATI.hasD1 && !BATI.hasOrm) {
|
|
43
48
|
sqliteQueries.insertTodo(_ctx.db, body.text);
|
|
44
49
|
} else if (BATI.has("kysely")) {
|
|
45
50
|
await kyselyQueries.insertTodo(_ctx.db, body.text);
|
|
46
|
-
} else if (BATI.hasD1) {
|
|
51
|
+
} else if (BATI.hasD1 && !BATI.hasOrm) {
|
|
47
52
|
await d1Queries.insertTodo(_ctx.db, body.text);
|
|
53
|
+
} else if (BATI.has("postgres") && !BATI.hasOrm) {
|
|
54
|
+
await pgQueries.insertTodo(_ctx.db, body.text);
|
|
48
55
|
} else {
|
|
49
56
|
// This is where you'd persist the data
|
|
50
57
|
console.log("Received new todo", { text: body.text });
|
package/dist/index.js
CHANGED
|
@@ -2637,7 +2637,7 @@ function kebabCase(str, joiner) {
|
|
|
2637
2637
|
//#endregion
|
|
2638
2638
|
//#region package.json
|
|
2639
2639
|
var name = "@batijs/cli";
|
|
2640
|
-
var version = "0.0.
|
|
2640
|
+
var version = "0.0.635";
|
|
2641
2641
|
var description = "Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want";
|
|
2642
2642
|
//#endregion
|
|
2643
2643
|
//#region rules.ts
|
|
@@ -2660,6 +2660,9 @@ const rulesMessages = {
|
|
|
2660
2660
|
[RulesMessage.ERROR_DRIZZLE_R_SERVER]: error(`A ${inverse(bold("Server"))} is required when using ${inverse(bold("Drizzle"))}`),
|
|
2661
2661
|
[RulesMessage.ERROR_SQLITE_R_SERVER]: error(`A ${inverse(bold("Server"))} is required when using ${inverse(bold("SQLite"))}`),
|
|
2662
2662
|
[RulesMessage.ERROR_KYSELY_R_SERVER]: error(`A ${inverse(bold("Server"))} is required when using ${inverse(bold("Kysely"))}`),
|
|
2663
|
+
[RulesMessage.ERROR_POSTGRES_R_SERVER]: error(`A ${inverse(bold("Server"))} is required when using ${inverse(bold("PostgreSQL"))}`),
|
|
2664
|
+
[RulesMessage.ERROR_POSTGRES_X_SQLITE]: error(`${inverse(bold("PostgreSQL"))} and ${inverse(bold("SQLite"))} are mutually exclusive database engines. Pick only one`),
|
|
2665
|
+
[RulesMessage.ERROR_ORM_R_DATABASE]: error(`An ${inverse(bold("ORM / Query builder"))} requires a ${inverse(bold("Database"))} (SQLite or PostgreSQL)`),
|
|
2663
2666
|
[RulesMessage.ERROR_DATA_R_SERVER]: error(`A ${inverse(bold("Server"))} is required when using ${inverse(bold("Data fetching"))}`),
|
|
2664
2667
|
[RulesMessage.ERROR_CLOUDFLARE_R_COMPAT_SERVER]: error(`${inverse(bold("Cloudflare"))} is only compatible with ${inverse(bold("Hono"))} or ${inverse(bold("H3"))}.
|
|
2665
2668
|
Choose one of them or remove selected Server`),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.635",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"check-types": "tsc --noEmit",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"repository": "https://github.com/vikejs/bati",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@batijs/build": "0.0.
|
|
17
|
-
"@batijs/compile": "0.0.
|
|
16
|
+
"@batijs/build": "0.0.635",
|
|
17
|
+
"@batijs/compile": "0.0.635",
|
|
18
18
|
"@inquirer/prompts": "^8.4.3",
|
|
19
19
|
"@types/node": "^20.19.37",
|
|
20
20
|
"@types/which": "^3.0.4",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"vite": "^8.0.14"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@batijs/core": "0.0.
|
|
34
|
-
"@batijs/features": "0.0.
|
|
33
|
+
"@batijs/core": "0.0.635",
|
|
34
|
+
"@batijs/features": "0.0.635"
|
|
35
35
|
},
|
|
36
36
|
"bin": "./cli.js",
|
|
37
37
|
"exports": {
|