postgresdk 0.9.5 → 0.9.7
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/README.md +1 -1
- package/dist/cli.js +23 -13
- package/dist/core/operations.d.ts +1 -1
- package/dist/emit-routes-hono.d.ts +1 -1
- package/dist/emit-routes.d.ts +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ export default {
|
|
|
88
88
|
outServer: "./api/server", // Server code output directory
|
|
89
89
|
outClient: "./api/client", // Client SDK output directory
|
|
90
90
|
softDeleteColumn: null, // Column name for soft deletes (e.g., "deleted_at")
|
|
91
|
-
|
|
91
|
+
includeMethodsDepth: 2, // Max depth for nested includes
|
|
92
92
|
dateType: "date", // "date" | "string" - How to handle timestamps
|
|
93
93
|
serverFramework: "hono", // Currently only hono is supported
|
|
94
94
|
useJsExtensions: false, // Add .js to imports (for Vercel Edge, Deno)
|
package/dist/cli.js
CHANGED
|
@@ -1355,11 +1355,11 @@ function extractConfigFields(configContent) {
|
|
|
1355
1355
|
isCommented: !!softDeleteMatch[1]
|
|
1356
1356
|
});
|
|
1357
1357
|
}
|
|
1358
|
-
const depthMatch = configContent.match(/^\s*(\/\/)?\s*includeDepthLimit:\s*(\d+)/m);
|
|
1358
|
+
const depthMatch = configContent.match(/^\s*(\/\/)?\s*(includeMethodsDepth|includeDepthLimit):\s*(\d+)/m);
|
|
1359
1359
|
if (depthMatch) {
|
|
1360
1360
|
fields.push({
|
|
1361
|
-
key: "
|
|
1362
|
-
value: parseInt(depthMatch[
|
|
1361
|
+
key: "includeMethodsDepth",
|
|
1362
|
+
value: parseInt(depthMatch[3]),
|
|
1363
1363
|
description: "Maximum depth for nested relationship includes",
|
|
1364
1364
|
isCommented: !!depthMatch[1]
|
|
1365
1365
|
});
|
|
@@ -1469,9 +1469,9 @@ export default {
|
|
|
1469
1469
|
|
|
1470
1470
|
/**
|
|
1471
1471
|
* Maximum depth for nested relationship includes to prevent infinite loops
|
|
1472
|
-
* @default
|
|
1472
|
+
* @default 2
|
|
1473
1473
|
*/
|
|
1474
|
-
${getFieldLine("
|
|
1474
|
+
${getFieldLine("includeMethodsDepth", existingFields, mergeStrategy, "2", userChoices)}
|
|
1475
1475
|
|
|
1476
1476
|
|
|
1477
1477
|
/**
|
|
@@ -1562,13 +1562,23 @@ function getFieldValue(key, existingFields, mergeStrategy, userChoices) {
|
|
|
1562
1562
|
return value;
|
|
1563
1563
|
}
|
|
1564
1564
|
if (mergeStrategy === "interactive" && userChoices?.has(key)) {
|
|
1565
|
-
|
|
1565
|
+
const choice = userChoices.get(key);
|
|
1566
|
+
if (choice === "keep") {
|
|
1567
|
+
if (existing && !existing.isCommented) {
|
|
1568
|
+
const value = existing.value.toString().replace(/,\s*$/, "");
|
|
1569
|
+
return value;
|
|
1570
|
+
} else {
|
|
1571
|
+
return 'process.env.DATABASE_URL || "postgres://user:password@localhost:5432/mydb"';
|
|
1572
|
+
}
|
|
1573
|
+
} else if (choice === "new") {
|
|
1574
|
+
return 'process.env.DATABASE_URL || "postgres://user:password@localhost:5432/mydb"';
|
|
1575
|
+
}
|
|
1566
1576
|
}
|
|
1567
1577
|
return 'process.env.DATABASE_URL || "postgres://user:password@localhost:5432/mydb"';
|
|
1568
1578
|
}
|
|
1569
1579
|
function getFieldLine(key, existingFields, mergeStrategy, defaultValue, userChoices) {
|
|
1570
1580
|
const existing = existingFields.find((f) => f.key === key);
|
|
1571
|
-
const shouldUseExisting = mergeStrategy === "keep-existing" && existing && !existing.isCommented || mergeStrategy === "interactive" && userChoices?.get(key) === "keep";
|
|
1581
|
+
const shouldUseExisting = mergeStrategy === "keep-existing" && existing && !existing.isCommented || mergeStrategy === "interactive" && userChoices?.get(key) === "keep" && existing && !existing.isCommented;
|
|
1572
1582
|
const shouldUseNew = mergeStrategy === "use-defaults" || mergeStrategy === "interactive" && userChoices?.get(key) === "new";
|
|
1573
1583
|
if (shouldUseExisting && existing) {
|
|
1574
1584
|
const value = typeof existing.value === "string" && !existing.value.startsWith('"') ? `"${existing.value}"` : existing.value;
|
|
@@ -1783,9 +1793,9 @@ export default {
|
|
|
1783
1793
|
|
|
1784
1794
|
/**
|
|
1785
1795
|
* Maximum depth for nested relationship includes to prevent infinite loops
|
|
1786
|
-
* @default
|
|
1796
|
+
* @default 2
|
|
1787
1797
|
*/
|
|
1788
|
-
//
|
|
1798
|
+
// includeMethodsDepth: 2,
|
|
1789
1799
|
|
|
1790
1800
|
|
|
1791
1801
|
/**
|
|
@@ -2349,7 +2359,7 @@ export function register${Type}Routes(app: Hono, deps: { pg: { query: (text: str
|
|
|
2349
2359
|
table: "${fileTableName}",
|
|
2350
2360
|
pkColumns: ${JSON.stringify(safePkCols)},
|
|
2351
2361
|
softDeleteColumn: ${softDel ? `"${softDel}"` : "null"},
|
|
2352
|
-
|
|
2362
|
+
includeMethodsDepth: ${opts.includeMethodsDepth}
|
|
2353
2363
|
};
|
|
2354
2364
|
${hasAuth ? `
|
|
2355
2365
|
// \uD83D\uDD10 Auth: protect all routes for this table
|
|
@@ -2410,7 +2420,7 @@ ${hasAuth ? `
|
|
|
2410
2420
|
result.data,
|
|
2411
2421
|
result.includeSpec,
|
|
2412
2422
|
deps.pg,
|
|
2413
|
-
${opts.
|
|
2423
|
+
${opts.includeMethodsDepth}
|
|
2414
2424
|
);
|
|
2415
2425
|
return c.json(stitched);
|
|
2416
2426
|
} catch (e: any) {
|
|
@@ -3482,7 +3492,7 @@ export interface OperationContext {
|
|
|
3482
3492
|
table: string;
|
|
3483
3493
|
pkColumns: string[];
|
|
3484
3494
|
softDeleteColumn?: string | null;
|
|
3485
|
-
|
|
3495
|
+
includeMethodsDepth: number;
|
|
3486
3496
|
}
|
|
3487
3497
|
|
|
3488
3498
|
const DEBUG = process.env.SDK_DEBUG === "1" || process.env.SDK_DEBUG === "true";
|
|
@@ -4525,7 +4535,7 @@ async function generate(configPath) {
|
|
|
4525
4535
|
if (serverFramework === "hono") {
|
|
4526
4536
|
routeContent = emitHonoRoutes(table, graph, {
|
|
4527
4537
|
softDeleteColumn: cfg.softDeleteColumn || null,
|
|
4528
|
-
|
|
4538
|
+
includeMethodsDepth: cfg.includeMethodsDepth || 2,
|
|
4529
4539
|
authStrategy: normalizedAuth?.strategy,
|
|
4530
4540
|
useJsExtensions: cfg.useJsExtensions
|
|
4531
4541
|
});
|
|
@@ -5,7 +5,7 @@ import type { Table } from "./introspect";
|
|
|
5
5
|
import type { Graph } from "./rel-classify";
|
|
6
6
|
export declare function emitHonoRoutes(table: Table, _graph: Graph, opts: {
|
|
7
7
|
softDeleteColumn: string | null;
|
|
8
|
-
|
|
8
|
+
includeMethodsDepth: number;
|
|
9
9
|
authStrategy?: string;
|
|
10
10
|
useJsExtensions?: boolean;
|
|
11
11
|
}): string;
|
package/dist/emit-routes.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ import type { Graph } from "./rel-classify";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function emitRoutes(table: Table, _graph: Graph, opts: {
|
|
18
18
|
softDeleteColumn: string | null;
|
|
19
|
-
|
|
19
|
+
includeMethodsDepth: number;
|
|
20
20
|
authStrategy?: string;
|
|
21
21
|
}): string;
|
package/dist/index.js
CHANGED
|
@@ -1694,7 +1694,7 @@ export function register${Type}Routes(app: Hono, deps: { pg: { query: (text: str
|
|
|
1694
1694
|
table: "${fileTableName}",
|
|
1695
1695
|
pkColumns: ${JSON.stringify(safePkCols)},
|
|
1696
1696
|
softDeleteColumn: ${softDel ? `"${softDel}"` : "null"},
|
|
1697
|
-
|
|
1697
|
+
includeMethodsDepth: ${opts.includeMethodsDepth}
|
|
1698
1698
|
};
|
|
1699
1699
|
${hasAuth ? `
|
|
1700
1700
|
// \uD83D\uDD10 Auth: protect all routes for this table
|
|
@@ -1755,7 +1755,7 @@ ${hasAuth ? `
|
|
|
1755
1755
|
result.data,
|
|
1756
1756
|
result.includeSpec,
|
|
1757
1757
|
deps.pg,
|
|
1758
|
-
${opts.
|
|
1758
|
+
${opts.includeMethodsDepth}
|
|
1759
1759
|
);
|
|
1760
1760
|
return c.json(stitched);
|
|
1761
1761
|
} catch (e: any) {
|
|
@@ -2827,7 +2827,7 @@ export interface OperationContext {
|
|
|
2827
2827
|
table: string;
|
|
2828
2828
|
pkColumns: string[];
|
|
2829
2829
|
softDeleteColumn?: string | null;
|
|
2830
|
-
|
|
2830
|
+
includeMethodsDepth: number;
|
|
2831
2831
|
}
|
|
2832
2832
|
|
|
2833
2833
|
const DEBUG = process.env.SDK_DEBUG === "1" || process.env.SDK_DEBUG === "true";
|
|
@@ -3870,7 +3870,7 @@ async function generate(configPath) {
|
|
|
3870
3870
|
if (serverFramework === "hono") {
|
|
3871
3871
|
routeContent = emitHonoRoutes(table, graph, {
|
|
3872
3872
|
softDeleteColumn: cfg.softDeleteColumn || null,
|
|
3873
|
-
|
|
3873
|
+
includeMethodsDepth: cfg.includeMethodsDepth || 2,
|
|
3874
3874
|
authStrategy: normalizedAuth?.strategy,
|
|
3875
3875
|
useJsExtensions: cfg.useJsExtensions
|
|
3876
3876
|
});
|