postgresdk 0.6.3 → 0.6.4
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/cli.js +9 -8
- package/dist/emit-tests.d.ts +2 -2
- package/dist/index.js +9 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
@@ -741,7 +741,7 @@ var init_cli_pull = () => {};
|
|
741
741
|
|
742
742
|
// src/index.ts
|
743
743
|
var import_config = __toESM(require_config(), 1);
|
744
|
-
import { join } from "node:path";
|
744
|
+
import { join, relative } from "node:path";
|
745
745
|
import { pathToFileURL } from "node:url";
|
746
746
|
|
747
747
|
// src/introspect.ts
|
@@ -2340,15 +2340,15 @@ export async function deleteRecord(
|
|
2340
2340
|
}
|
2341
2341
|
|
2342
2342
|
// src/emit-tests.ts
|
2343
|
-
function emitTableTest(table, framework = "vitest") {
|
2343
|
+
function emitTableTest(table, clientPath, framework = "vitest") {
|
2344
2344
|
const Type = pascal(table.name);
|
2345
2345
|
const tableName = table.name;
|
2346
2346
|
const imports = getFrameworkImports(framework);
|
2347
2347
|
const sampleData = generateSampleData(table);
|
2348
2348
|
const updateData = generateUpdateData(table);
|
2349
2349
|
return `${imports}
|
2350
|
-
import { SDK } from '
|
2351
|
-
import type { Insert${Type}, Update${Type}, Select${Type} } from '
|
2350
|
+
import { SDK } from '${clientPath}';
|
2351
|
+
import type { Insert${Type}, Update${Type}, Select${Type} } from '${clientPath}/types/${tableName}';
|
2352
2352
|
|
2353
2353
|
/**
|
2354
2354
|
* Basic tests for ${tableName} table operations
|
@@ -2371,7 +2371,7 @@ describe('${Type} SDK Operations', () => {
|
|
2371
2371
|
});
|
2372
2372
|
`;
|
2373
2373
|
}
|
2374
|
-
function emitTestSetup(framework = "vitest") {
|
2374
|
+
function emitTestSetup(clientPath, framework = "vitest") {
|
2375
2375
|
return `/**
|
2376
2376
|
* Test Setup and Utilities
|
2377
2377
|
*
|
@@ -2390,7 +2390,7 @@ export const TEST_API_KEY = process.env.TEST_API_KEY;
|
|
2390
2390
|
|
2391
2391
|
// Utility to create SDK instance
|
2392
2392
|
export function createTestSDK() {
|
2393
|
-
const { SDK } = require('
|
2393
|
+
const { SDK } = require('${clientPath}');
|
2394
2394
|
return new SDK({
|
2395
2395
|
baseUrl: TEST_API_URL,
|
2396
2396
|
auth: TEST_API_KEY ? { apiKey: TEST_API_KEY } : undefined
|
@@ -2810,9 +2810,10 @@ async function generate(configPath) {
|
|
2810
2810
|
});
|
2811
2811
|
if (generateTests) {
|
2812
2812
|
console.log("\uD83E\uDDEA Generating tests...");
|
2813
|
+
const relativeClientPath = relative(testDir, clientDir);
|
2813
2814
|
files.push({
|
2814
2815
|
path: join(testDir, "setup.ts"),
|
2815
|
-
content: emitTestSetup(testFramework)
|
2816
|
+
content: emitTestSetup(relativeClientPath, testFramework)
|
2816
2817
|
});
|
2817
2818
|
files.push({
|
2818
2819
|
path: join(testDir, "docker-compose.yml"),
|
@@ -2825,7 +2826,7 @@ async function generate(configPath) {
|
|
2825
2826
|
for (const table of Object.values(model.tables)) {
|
2826
2827
|
files.push({
|
2827
2828
|
path: join(testDir, `${table.name}.test.ts`),
|
2828
|
-
content: emitTableTest(table, testFramework)
|
2829
|
+
content: emitTableTest(table, relativeClientPath, testFramework)
|
2829
2830
|
});
|
2830
2831
|
}
|
2831
2832
|
}
|
package/dist/emit-tests.d.ts
CHANGED
@@ -2,11 +2,11 @@ import type { Table } from "./introspect";
|
|
2
2
|
/**
|
3
3
|
* Generate basic SDK tests for a table
|
4
4
|
*/
|
5
|
-
export declare function emitTableTest(table: Table, framework?: "vitest" | "jest" | "bun"): string;
|
5
|
+
export declare function emitTableTest(table: Table, clientPath: string, framework?: "vitest" | "jest" | "bun"): string;
|
6
6
|
/**
|
7
7
|
* Generate a test setup file
|
8
8
|
*/
|
9
|
-
export declare function emitTestSetup(framework?: "vitest" | "jest" | "bun"): string;
|
9
|
+
export declare function emitTestSetup(clientPath: string, framework?: "vitest" | "jest" | "bun"): string;
|
10
10
|
/**
|
11
11
|
* Generate docker-compose.yml for test database
|
12
12
|
*/
|
package/dist/index.js
CHANGED
@@ -471,7 +471,7 @@ var require_config = __commonJS(() => {
|
|
471
471
|
|
472
472
|
// src/index.ts
|
473
473
|
var import_config = __toESM(require_config(), 1);
|
474
|
-
import { join } from "node:path";
|
474
|
+
import { join, relative } from "node:path";
|
475
475
|
import { pathToFileURL } from "node:url";
|
476
476
|
|
477
477
|
// src/introspect.ts
|
@@ -2070,15 +2070,15 @@ export async function deleteRecord(
|
|
2070
2070
|
}
|
2071
2071
|
|
2072
2072
|
// src/emit-tests.ts
|
2073
|
-
function emitTableTest(table, framework = "vitest") {
|
2073
|
+
function emitTableTest(table, clientPath, framework = "vitest") {
|
2074
2074
|
const Type = pascal(table.name);
|
2075
2075
|
const tableName = table.name;
|
2076
2076
|
const imports = getFrameworkImports(framework);
|
2077
2077
|
const sampleData = generateSampleData(table);
|
2078
2078
|
const updateData = generateUpdateData(table);
|
2079
2079
|
return `${imports}
|
2080
|
-
import { SDK } from '
|
2081
|
-
import type { Insert${Type}, Update${Type}, Select${Type} } from '
|
2080
|
+
import { SDK } from '${clientPath}';
|
2081
|
+
import type { Insert${Type}, Update${Type}, Select${Type} } from '${clientPath}/types/${tableName}';
|
2082
2082
|
|
2083
2083
|
/**
|
2084
2084
|
* Basic tests for ${tableName} table operations
|
@@ -2101,7 +2101,7 @@ describe('${Type} SDK Operations', () => {
|
|
2101
2101
|
});
|
2102
2102
|
`;
|
2103
2103
|
}
|
2104
|
-
function emitTestSetup(framework = "vitest") {
|
2104
|
+
function emitTestSetup(clientPath, framework = "vitest") {
|
2105
2105
|
return `/**
|
2106
2106
|
* Test Setup and Utilities
|
2107
2107
|
*
|
@@ -2120,7 +2120,7 @@ export const TEST_API_KEY = process.env.TEST_API_KEY;
|
|
2120
2120
|
|
2121
2121
|
// Utility to create SDK instance
|
2122
2122
|
export function createTestSDK() {
|
2123
|
-
const { SDK } = require('
|
2123
|
+
const { SDK } = require('${clientPath}');
|
2124
2124
|
return new SDK({
|
2125
2125
|
baseUrl: TEST_API_URL,
|
2126
2126
|
auth: TEST_API_KEY ? { apiKey: TEST_API_KEY } : undefined
|
@@ -2540,9 +2540,10 @@ async function generate(configPath) {
|
|
2540
2540
|
});
|
2541
2541
|
if (generateTests) {
|
2542
2542
|
console.log("\uD83E\uDDEA Generating tests...");
|
2543
|
+
const relativeClientPath = relative(testDir, clientDir);
|
2543
2544
|
files.push({
|
2544
2545
|
path: join(testDir, "setup.ts"),
|
2545
|
-
content: emitTestSetup(testFramework)
|
2546
|
+
content: emitTestSetup(relativeClientPath, testFramework)
|
2546
2547
|
});
|
2547
2548
|
files.push({
|
2548
2549
|
path: join(testDir, "docker-compose.yml"),
|
@@ -2555,7 +2556,7 @@ async function generate(configPath) {
|
|
2555
2556
|
for (const table of Object.values(model.tables)) {
|
2556
2557
|
files.push({
|
2557
2558
|
path: join(testDir, `${table.name}.test.ts`),
|
2558
|
-
content: emitTableTest(table, testFramework)
|
2559
|
+
content: emitTableTest(table, relativeClientPath, testFramework)
|
2559
2560
|
});
|
2560
2561
|
}
|
2561
2562
|
}
|