pg-seed-kit 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kulcsár Rudolf
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 FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # pg-seed-kit
2
+
3
+ [![npm version](https://img.shields.io/npm/v/pg-seed-kit)](https://www.npmjs.com/package/pg-seed-kit)
4
+ [![license](https://badgen.net/npm/license/pg-seed-kit)](https://github.com/kulcsarrudolf/pg-seed-kit/blob/main/LICENSE)
5
+ [![downloads](https://img.shields.io/npm/dt/pg-seed-kit)](https://www.npmjs.com/package/pg-seed-kit)
6
+ [![GitHub Stars](https://badgen.net/github/stars/kulcsarrudolf/pg-seed-kit)](https://github.com/kulcsarrudolf/pg-seed-kit)
7
+
8
+ A lightweight, zero-dependency seeder toolkit for Postgres that works with **Prisma**, **Drizzle**, **TypeORM**, and **Sequelize**. Run one-time seed scripts on startup, track execution status, and manage seeders via a small CLI.
9
+
10
+ The package ships **no runtime dependencies**: instead of opening its own connection, it runs its tracking SQL through a tiny adapter built on the connection your ORM already owns.
11
+
12
+ > Docs with copy-paste examples for every ORM: **https://kulcsarrudolf.github.io/pg-seed-kit/**
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install pg-seed-kit
18
+ ```
19
+
20
+ Your ORM is an optional peer dependency: install whichever one you already use (`@prisma/client`, `drizzle-orm`, `typeorm`, or `sequelize`).
21
+
22
+ ## Quick Start (Drizzle)
23
+
24
+ Point pg-seed-kit at your seeders and tell it how to connect. Create `pg-seed-kit.config.js`:
25
+
26
+ ```javascript
27
+ import { drizzleAdapter } from "pg-seed-kit/drizzle";
28
+ import { db, pool } from "./db.js"; // your drizzle db + pg Pool
29
+
30
+ export default {
31
+ seedersPath: "./src/db/seeders",
32
+ connect: async () => drizzleAdapter(db, { close: () => pool.end() }),
33
+ };
34
+ ```
35
+
36
+ Scaffold a seeder:
37
+
38
+ ```bash
39
+ npx pg-seed-kit create add-admin
40
+ ```
41
+
42
+ Implement the generated `src/db/seeders/20260320120000-add-admin.seeder.ts`:
43
+
44
+ ```typescript
45
+ import { db } from "../../db.js";
46
+ import { users } from "../schema.js";
47
+
48
+ const seed = async (): Promise<void> => {
49
+ await db
50
+ .insert(users)
51
+ .values({ email: "admin@example.com", role: "admin" })
52
+ .onConflictDoNothing();
53
+ };
54
+
55
+ export default seed;
56
+ ```
57
+
58
+ Run pending seeders, either from your app (after the ORM is connected) or via the CLI:
59
+
60
+ ```typescript
61
+ import { runPendingSeeders } from "pg-seed-kit";
62
+ import { drizzleAdapter } from "pg-seed-kit/drizzle";
63
+ import { db } from "./db.js";
64
+
65
+ await runPendingSeeders({ adapter: drizzleAdapter(db) });
66
+ ```
67
+
68
+ ```bash
69
+ npx pg-seed-kit run
70
+ ```
71
+
72
+ Using **Prisma**, **TypeORM**, or **Sequelize**? The same three steps, with that ORM's adapter and idiom: see the [website](https://kulcsarrudolf.github.io/pg-seed-kit/).
73
+
74
+ ## How It Works
75
+
76
+ 1. Seeder files are sorted alphabetically; the timestamp prefix (`20260320120000-`) keeps them in chronological order.
77
+ 2. On each run, only seeders without a `success` record in the tracking table are executed. The table (`seeders` by default) is auto-created on first run.
78
+ 3. If a seeder fails it is recorded as `failed` and retried on the next run; execution continues with the remaining seeders.
79
+
80
+ ## API
81
+
82
+ All functions take an options object with a live `adapter` and assume your ORM is already connected.
83
+
84
+ | Function | Description | Returns |
85
+ | -------------------------------- | -------------------------------------------------- | ------------------- |
86
+ | `runPendingSeeders(options?)` | Runs seeders without a successful tracking record | `SeederRunResult[]` |
87
+ | `runSeederByName(name, options?)`| Force-runs one seeder, even if already executed | `SeederRunResult[]` |
88
+ | `getSeederStatuses(options?)` | Lists `pending`, `success`, and `failed` seeders | `SeederStatus[]` |
89
+ | `resetSeeder(name, options?)` | Deletes the tracking record so a seeder can rerun | `Promise<void>` |
90
+
91
+ ## Adapters
92
+
93
+ Import an adapter from its subpath and build it from your ORM's connection.
94
+
95
+ | ORM | Import | Factory |
96
+ | --------- | ------------------------ | ---------------------------------------- |
97
+ | Prisma | `pg-seed-kit/prisma` | `prismaAdapter(prisma)` |
98
+ | Drizzle | `pg-seed-kit/drizzle` | `drizzleAdapter(db, { close? })` |
99
+ | TypeORM | `pg-seed-kit/typeorm` | `typeormAdapter(dataSource)` |
100
+ | Sequelize | `pg-seed-kit/sequelize` | `sequelizeAdapter(sequelize)` |
101
+
102
+ ## Config
103
+
104
+ Config is loaded from `pg-seed-kit.config.js` (or `.cjs`/`.mjs`), the `"pg-seed-kit"` key in `package.json`, or inline options.
105
+
106
+ | Option | Type | Default | Description |
107
+ | ------------- | -------------------------- | -------------- | ---------------------------------------------------- |
108
+ | `seedersPath` | `string \| () => string` | (required) | Directory containing seeder files |
109
+ | `tableName` | `string` | `"seeders"` | Table used to track execution |
110
+ | `filePattern` | `RegExp` | `/^\d{14}-.+\.seeder\.(ts\|js\|mjs\|cjs)$/` | Pattern that matches seeder files |
111
+ | `adapter` | `Adapter` | (none) | A live adapter, for calling the API from your app |
112
+ | `connect` | `() => Promise<Adapter>` | (none) | Used by the CLI to open a connection and adapter |
113
+
114
+ ## CLI
115
+
116
+ ```bash
117
+ npx pg-seed-kit create <name> # Scaffold a new seeder file
118
+ npx pg-seed-kit status # List seeders and statuses
119
+ npx pg-seed-kit run # Run all pending seeders
120
+ npx pg-seed-kit run <name> # Force-run one seeder by name
121
+ npx pg-seed-kit reset <name> # Mark a seeder as pending
122
+ ```
123
+
124
+ `status`, `run`, and `reset` use your config's async `connect()` to open a connection, then close it when done. `run` exits non-zero if any seeder fails.
125
+
126
+ ## Contributing
127
+
128
+ Submit a pull request or open an issue on GitHub.
129
+
130
+ ## License
131
+
132
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli/index.js';
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/drizzle.ts
21
+ var drizzle_exports = {};
22
+ __export(drizzle_exports, {
23
+ drizzleAdapter: () => drizzleAdapter
24
+ });
25
+ module.exports = __toCommonJS(drizzle_exports);
26
+ var import_drizzle_orm = require("drizzle-orm");
27
+ function toDrizzleSql(text, params) {
28
+ const chunks = [];
29
+ const placeholder = /\$(\d+)/g;
30
+ let lastIndex = 0;
31
+ let match;
32
+ while ((match = placeholder.exec(text)) !== null) {
33
+ chunks.push(import_drizzle_orm.sql.raw(text.slice(lastIndex, match.index)));
34
+ chunks.push(import_drizzle_orm.sql`${params[Number(match[1]) - 1]}`);
35
+ lastIndex = placeholder.lastIndex;
36
+ }
37
+ chunks.push(import_drizzle_orm.sql.raw(text.slice(lastIndex)));
38
+ return import_drizzle_orm.sql.join(chunks);
39
+ }
40
+ function drizzleAdapter(db, options) {
41
+ return {
42
+ async query(sqlText, params) {
43
+ const result = await db.execute(toDrizzleSql(sqlText, params ?? []));
44
+ const rows = Array.isArray(result) ? result : result.rows;
45
+ return rows ?? [];
46
+ },
47
+ close: options?.close
48
+ };
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ drizzleAdapter
53
+ });
@@ -0,0 +1,25 @@
1
+ import { SQL } from 'drizzle-orm';
2
+ import { A as Adapter } from '../types-CCBHgrLA.cjs';
3
+
4
+ /** The subset of a Drizzle database this adapter relies on. */
5
+ interface DrizzleLike {
6
+ execute(query: SQL): Promise<unknown>;
7
+ }
8
+ /**
9
+ * Build an {@link Adapter} from a Drizzle database. Tracking SQL is bound through
10
+ * Drizzle's `sql` template and run with `db.execute`. Because closing the
11
+ * connection is driver-specific (the pool lives outside the Drizzle instance),
12
+ * pass `close` to end it from the CLI.
13
+ *
14
+ * Targets the `drizzle-orm/node-postgres` driver (result exposes `rows`);
15
+ * postgres-js returns the rows array directly, which is handled too.
16
+ *
17
+ * @example
18
+ * import { drizzleAdapter } from 'pg-seed-kit/drizzle';
19
+ * const adapter = drizzleAdapter(db, { close: () => pool.end() });
20
+ */
21
+ declare function drizzleAdapter(db: DrizzleLike, options?: {
22
+ close?: () => Promise<void>;
23
+ }): Adapter;
24
+
25
+ export { type DrizzleLike, drizzleAdapter };
@@ -0,0 +1,25 @@
1
+ import { SQL } from 'drizzle-orm';
2
+ import { A as Adapter } from '../types-CCBHgrLA.js';
3
+
4
+ /** The subset of a Drizzle database this adapter relies on. */
5
+ interface DrizzleLike {
6
+ execute(query: SQL): Promise<unknown>;
7
+ }
8
+ /**
9
+ * Build an {@link Adapter} from a Drizzle database. Tracking SQL is bound through
10
+ * Drizzle's `sql` template and run with `db.execute`. Because closing the
11
+ * connection is driver-specific (the pool lives outside the Drizzle instance),
12
+ * pass `close` to end it from the CLI.
13
+ *
14
+ * Targets the `drizzle-orm/node-postgres` driver (result exposes `rows`);
15
+ * postgres-js returns the rows array directly, which is handled too.
16
+ *
17
+ * @example
18
+ * import { drizzleAdapter } from 'pg-seed-kit/drizzle';
19
+ * const adapter = drizzleAdapter(db, { close: () => pool.end() });
20
+ */
21
+ declare function drizzleAdapter(db: DrizzleLike, options?: {
22
+ close?: () => Promise<void>;
23
+ }): Adapter;
24
+
25
+ export { type DrizzleLike, drizzleAdapter };
@@ -0,0 +1,28 @@
1
+ // src/adapters/drizzle.ts
2
+ import { sql } from "drizzle-orm";
3
+ function toDrizzleSql(text, params) {
4
+ const chunks = [];
5
+ const placeholder = /\$(\d+)/g;
6
+ let lastIndex = 0;
7
+ let match;
8
+ while ((match = placeholder.exec(text)) !== null) {
9
+ chunks.push(sql.raw(text.slice(lastIndex, match.index)));
10
+ chunks.push(sql`${params[Number(match[1]) - 1]}`);
11
+ lastIndex = placeholder.lastIndex;
12
+ }
13
+ chunks.push(sql.raw(text.slice(lastIndex)));
14
+ return sql.join(chunks);
15
+ }
16
+ function drizzleAdapter(db, options) {
17
+ return {
18
+ async query(sqlText, params) {
19
+ const result = await db.execute(toDrizzleSql(sqlText, params ?? []));
20
+ const rows = Array.isArray(result) ? result : result.rows;
21
+ return rows ?? [];
22
+ },
23
+ close: options?.close
24
+ };
25
+ }
26
+ export {
27
+ drizzleAdapter
28
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/prisma.ts
21
+ var prisma_exports = {};
22
+ __export(prisma_exports, {
23
+ prismaAdapter: () => prismaAdapter
24
+ });
25
+ module.exports = __toCommonJS(prisma_exports);
26
+ function prismaAdapter(prisma) {
27
+ return {
28
+ async query(sql, params) {
29
+ const values = params ?? [];
30
+ if (/^\s*(select|with)\b/i.test(sql)) {
31
+ const rows = await prisma.$queryRawUnsafe(sql, ...values);
32
+ return rows ?? [];
33
+ }
34
+ await prisma.$executeRawUnsafe(sql, ...values);
35
+ return [];
36
+ },
37
+ async close() {
38
+ await prisma.$disconnect();
39
+ }
40
+ };
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ prismaAdapter
45
+ });
@@ -0,0 +1,22 @@
1
+ import { A as Adapter } from '../types-CCBHgrLA.cjs';
2
+
3
+ /** The subset of a Prisma client this adapter relies on. */
4
+ interface PrismaClientLike {
5
+ $queryRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;
6
+ $executeRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;
7
+ $disconnect(): Promise<unknown>;
8
+ }
9
+ /**
10
+ * Build an {@link Adapter} from a Prisma client. Prisma splits raw access into
11
+ * two methods: `$queryRawUnsafe` returns rows (for `SELECT`), `$executeRawUnsafe`
12
+ * returns an affected-row count (for `INSERT`/`DELETE`/DDL). We route by the
13
+ * leading keyword so both read and write tracking statements work. Both use
14
+ * Postgres `$1` positional parameters.
15
+ *
16
+ * @example
17
+ * import { prismaAdapter } from 'pg-seed-kit/prisma';
18
+ * const adapter = prismaAdapter(prisma);
19
+ */
20
+ declare function prismaAdapter(prisma: PrismaClientLike): Adapter;
21
+
22
+ export { type PrismaClientLike, prismaAdapter };
@@ -0,0 +1,22 @@
1
+ import { A as Adapter } from '../types-CCBHgrLA.js';
2
+
3
+ /** The subset of a Prisma client this adapter relies on. */
4
+ interface PrismaClientLike {
5
+ $queryRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;
6
+ $executeRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;
7
+ $disconnect(): Promise<unknown>;
8
+ }
9
+ /**
10
+ * Build an {@link Adapter} from a Prisma client. Prisma splits raw access into
11
+ * two methods: `$queryRawUnsafe` returns rows (for `SELECT`), `$executeRawUnsafe`
12
+ * returns an affected-row count (for `INSERT`/`DELETE`/DDL). We route by the
13
+ * leading keyword so both read and write tracking statements work. Both use
14
+ * Postgres `$1` positional parameters.
15
+ *
16
+ * @example
17
+ * import { prismaAdapter } from 'pg-seed-kit/prisma';
18
+ * const adapter = prismaAdapter(prisma);
19
+ */
20
+ declare function prismaAdapter(prisma: PrismaClientLike): Adapter;
21
+
22
+ export { type PrismaClientLike, prismaAdapter };
@@ -0,0 +1,20 @@
1
+ // src/adapters/prisma.ts
2
+ function prismaAdapter(prisma) {
3
+ return {
4
+ async query(sql, params) {
5
+ const values = params ?? [];
6
+ if (/^\s*(select|with)\b/i.test(sql)) {
7
+ const rows = await prisma.$queryRawUnsafe(sql, ...values);
8
+ return rows ?? [];
9
+ }
10
+ await prisma.$executeRawUnsafe(sql, ...values);
11
+ return [];
12
+ },
13
+ async close() {
14
+ await prisma.$disconnect();
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ prismaAdapter
20
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/sequelize.ts
21
+ var sequelize_exports = {};
22
+ __export(sequelize_exports, {
23
+ sequelizeAdapter: () => sequelizeAdapter
24
+ });
25
+ module.exports = __toCommonJS(sequelize_exports);
26
+ function sequelizeAdapter(sequelize) {
27
+ return {
28
+ async query(sql, params) {
29
+ const result = await sequelize.query(sql, { bind: params });
30
+ const rows = Array.isArray(result) ? result[0] : result;
31
+ return rows ?? [];
32
+ },
33
+ async close() {
34
+ await sequelize.close();
35
+ }
36
+ };
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ sequelizeAdapter
41
+ });
@@ -0,0 +1,21 @@
1
+ import { A as Adapter } from '../types-CCBHgrLA.cjs';
2
+
3
+ /** The subset of a Sequelize instance this adapter relies on. */
4
+ interface SequelizeLike {
5
+ query(sql: string, options: {
6
+ bind?: unknown[];
7
+ }): Promise<unknown>;
8
+ close(): Promise<unknown>;
9
+ }
10
+ /**
11
+ * Build an {@link Adapter} from a Sequelize instance. Tracking SQL runs through
12
+ * `sequelize.query` with `bind`, which uses Postgres `$1` positional parameters.
13
+ * Sequelize resolves to a `[rows, metadata]` tuple; we return the rows.
14
+ *
15
+ * @example
16
+ * import { sequelizeAdapter } from 'pg-seed-kit/sequelize';
17
+ * const adapter = sequelizeAdapter(sequelize);
18
+ */
19
+ declare function sequelizeAdapter(sequelize: SequelizeLike): Adapter;
20
+
21
+ export { type SequelizeLike, sequelizeAdapter };
@@ -0,0 +1,21 @@
1
+ import { A as Adapter } from '../types-CCBHgrLA.js';
2
+
3
+ /** The subset of a Sequelize instance this adapter relies on. */
4
+ interface SequelizeLike {
5
+ query(sql: string, options: {
6
+ bind?: unknown[];
7
+ }): Promise<unknown>;
8
+ close(): Promise<unknown>;
9
+ }
10
+ /**
11
+ * Build an {@link Adapter} from a Sequelize instance. Tracking SQL runs through
12
+ * `sequelize.query` with `bind`, which uses Postgres `$1` positional parameters.
13
+ * Sequelize resolves to a `[rows, metadata]` tuple; we return the rows.
14
+ *
15
+ * @example
16
+ * import { sequelizeAdapter } from 'pg-seed-kit/sequelize';
17
+ * const adapter = sequelizeAdapter(sequelize);
18
+ */
19
+ declare function sequelizeAdapter(sequelize: SequelizeLike): Adapter;
20
+
21
+ export { type SequelizeLike, sequelizeAdapter };
@@ -0,0 +1,16 @@
1
+ // src/adapters/sequelize.ts
2
+ function sequelizeAdapter(sequelize) {
3
+ return {
4
+ async query(sql, params) {
5
+ const result = await sequelize.query(sql, { bind: params });
6
+ const rows = Array.isArray(result) ? result[0] : result;
7
+ return rows ?? [];
8
+ },
9
+ async close() {
10
+ await sequelize.close();
11
+ }
12
+ };
13
+ }
14
+ export {
15
+ sequelizeAdapter
16
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/typeorm.ts
21
+ var typeorm_exports = {};
22
+ __export(typeorm_exports, {
23
+ typeormAdapter: () => typeormAdapter
24
+ });
25
+ module.exports = __toCommonJS(typeorm_exports);
26
+ function typeormAdapter(dataSource) {
27
+ return {
28
+ async query(sql, params) {
29
+ const rows = await dataSource.query(sql, params);
30
+ return rows ?? [];
31
+ },
32
+ async close() {
33
+ await dataSource.destroy();
34
+ }
35
+ };
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ typeormAdapter
40
+ });
@@ -0,0 +1,18 @@
1
+ import { A as Adapter } from '../types-CCBHgrLA.cjs';
2
+
3
+ /** The subset of a TypeORM `DataSource` this adapter relies on. */
4
+ interface TypeOrmDataSourceLike {
5
+ query(query: string, parameters?: unknown[]): Promise<unknown>;
6
+ destroy(): Promise<unknown>;
7
+ }
8
+ /**
9
+ * Build an {@link Adapter} from a TypeORM `DataSource`. Tracking SQL runs through
10
+ * `dataSource.query`, which uses Postgres `$1` positional parameters.
11
+ *
12
+ * @example
13
+ * import { typeormAdapter } from 'pg-seed-kit/typeorm';
14
+ * const adapter = typeormAdapter(dataSource);
15
+ */
16
+ declare function typeormAdapter(dataSource: TypeOrmDataSourceLike): Adapter;
17
+
18
+ export { type TypeOrmDataSourceLike, typeormAdapter };
@@ -0,0 +1,18 @@
1
+ import { A as Adapter } from '../types-CCBHgrLA.js';
2
+
3
+ /** The subset of a TypeORM `DataSource` this adapter relies on. */
4
+ interface TypeOrmDataSourceLike {
5
+ query(query: string, parameters?: unknown[]): Promise<unknown>;
6
+ destroy(): Promise<unknown>;
7
+ }
8
+ /**
9
+ * Build an {@link Adapter} from a TypeORM `DataSource`. Tracking SQL runs through
10
+ * `dataSource.query`, which uses Postgres `$1` positional parameters.
11
+ *
12
+ * @example
13
+ * import { typeormAdapter } from 'pg-seed-kit/typeorm';
14
+ * const adapter = typeormAdapter(dataSource);
15
+ */
16
+ declare function typeormAdapter(dataSource: TypeOrmDataSourceLike): Adapter;
17
+
18
+ export { type TypeOrmDataSourceLike, typeormAdapter };
@@ -0,0 +1,15 @@
1
+ // src/adapters/typeorm.ts
2
+ function typeormAdapter(dataSource) {
3
+ return {
4
+ async query(sql, params) {
5
+ const rows = await dataSource.query(sql, params);
6
+ return rows ?? [];
7
+ },
8
+ async close() {
9
+ await dataSource.destroy();
10
+ }
11
+ };
12
+ }
13
+ export {
14
+ typeormAdapter
15
+ };