@dxgjs/generators 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DXG Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
+ DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
- # Temporary Holding Version
1
+ # @dxgjs/generators
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Generator system for DXG.
4
+
5
+ > Internal package of the [DXG](https://github.com/dxgjs/dxg) monorepo. If you want to use DXG, install the CLI instead: `npx @dxgjs/cli`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm i @dxgjs/generators
11
+ # or
12
+ pnpm add @dxgjs/generators
13
+ ```
14
+
15
+ ## Requirements
16
+
17
+ - Node.js >= 22.13
18
+ - ESM only
19
+
20
+ ## Links
21
+
22
+ - Repository: https://github.com/dxgjs/dxg
23
+ - Issues: https://github.com/dxgjs/dxg/issues
24
+
25
+ ## License
26
+
27
+ MIT
@@ -0,0 +1,14 @@
1
+ import "dotenv/config";
2
+ import { {{adapterImport}} } from "{{adapterPackage}}";
3
+ import { PrismaClient } from "{{generatedClientImport}}";
4
+
5
+ const adapter = new {{adapterClass}}({
6
+ host: process.env.DATABASE_HOST,
7
+ user: process.env.DATABASE_USER,
8
+ password: process.env.DATABASE_PASSWORD,
9
+ database: process.env.DATABASE_NAME,
10
+ connectionLimit: 5,
11
+ });
12
+ const prisma = new PrismaClient({ adapter });
13
+
14
+ export { prisma };
@@ -0,0 +1,21 @@
1
+ import "dotenv/config";
2
+ import { {{adapterImport}} } from "{{adapterPackage}}";
3
+ import { PrismaClient } from "{{generatedClientImport}}";
4
+ import { fetch as undiciFetch } from "undici";
5
+
6
+ // Fail loudly at import time: a missing DATABASE_URL must never silently
7
+ // DXG writes an empty placeholder for
8
+ // server providers and adapters are lazy, so the empty string must be
9
+ // accepted to allow out-of-the-box db:seed (live-proven 2026-10-11).
10
+ const connectionString = process.env.DATABASE_URL;
11
+
12
+ if (connectionString === undefined) {
13
+ throw new Error(
14
+ "DATABASE_URL is not set. Add it to your .env file or export it in your environment.",
15
+ );
16
+ }
17
+
18
+ const adapter = new {{adapterClass}}({ url: connectionString, fetch: undiciFetch });
19
+ const prisma = new PrismaClient({ adapter });
20
+
21
+ export { prisma };
@@ -0,0 +1,20 @@
1
+ import "dotenv/config";
2
+ import { {{adapterImport}} } from "{{adapterPackage}}";
3
+ import { PrismaClient } from "{{generatedClientImport}}";
4
+
5
+ // Fail loudly at import time: a missing DATABASE_URL must never silently
6
+ // DXG writes an empty placeholder for
7
+ // server providers and adapters are lazy, so the empty string must be
8
+ // accepted to allow out-of-the-box db:seed (live-proven 2026-10-11).
9
+ const connectionString = process.env.DATABASE_URL;
10
+
11
+ if (connectionString === undefined) {
12
+ throw new Error(
13
+ "DATABASE_URL is not set. Add it to your .env file or export it in your environment.",
14
+ );
15
+ }
16
+
17
+ const adapter = new {{adapterClass}}({ url: connectionString });
18
+ const prisma = new PrismaClient({ adapter });
19
+
20
+ export { prisma };
@@ -0,0 +1,24 @@
1
+ import "dotenv/config";
2
+ import { {{adapterImport}} } from "{{adapterPackage}}";
3
+ import { PrismaClient } from "{{generatedClientImport}}";
4
+
5
+ const sqlConfig = {
6
+ user: process.env.DB_USER,
7
+ password: process.env.DB_PASSWORD,
8
+ database: process.env.DB_NAME,
9
+ server: process.env.HOST ?? "",
10
+ pool: {
11
+ max: 10,
12
+ min: 0,
13
+ idleTimeoutMillis: 30000,
14
+ },
15
+ options: {
16
+ encrypt: true, // for azure
17
+ trustServerCertificate: false, // change to true for local dev / self-signed certs
18
+ },
19
+ };
20
+
21
+ const adapter = new {{adapterClass}}(sqlConfig);
22
+ const prisma = new PrismaClient({ adapter });
23
+
24
+ export { prisma };
@@ -0,0 +1,20 @@
1
+ import "dotenv/config";
2
+ import { {{adapterImport}} } from "{{adapterPackage}}";
3
+ import { PrismaClient } from "{{generatedClientImport}}";
4
+
5
+ // Fail loudly at import time: a missing DATABASE_URL must never silently
6
+ // DXG writes an empty placeholder for
7
+ // server providers and adapters are lazy, so the empty string must be
8
+ // accepted to allow out-of-the-box db:seed (live-proven 2026-10-11).
9
+ const connectionString = process.env.DATABASE_URL;
10
+
11
+ if (connectionString === undefined) {
12
+ throw new Error(
13
+ "DATABASE_URL is not set. Add it to your .env file or export it in your environment.",
14
+ );
15
+ }
16
+
17
+ const adapter = new {{adapterClass}}({ connectionString });
18
+ const prisma = new PrismaClient({ adapter });
19
+
20
+ export { prisma };
@@ -0,0 +1,24 @@
1
+ // Database seed script — run with `npm run db:seed` (or `pnpm db:seed`).
2
+ // The shared Prisma Client (lib/prisma.ts) already loads .env variables.
3
+ import { prisma } from "{{helperImportFromSeed}}";
4
+
5
+ async function main() {
6
+ // Write your seed data here — use upsert so the seed is re-runnable:
7
+ //
8
+ // await prisma.user.upsert({
9
+ // where: { email: "alice@prisma.io" },
10
+ // update: {},
11
+ // create: { email: "alice@prisma.io", name: "Alice" },
12
+ // });
13
+ console.log("Seed script ready — add your seed data in prisma/seed.ts");
14
+ }
15
+
16
+ main()
17
+ .then(async () => {
18
+ await prisma.$disconnect();
19
+ })
20
+ .catch(async (e) => {
21
+ console.error(e);
22
+ await prisma.$disconnect();
23
+ process.exit(1);
24
+ });