postgresdk 0.18.25 → 0.18.26
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 +10 -8
- package/dist/index.js +10 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3107,7 +3107,8 @@ ${hasAuth ? `
|
|
|
3107
3107
|
result.data,
|
|
3108
3108
|
result.includeSpec,
|
|
3109
3109
|
deps.pg,
|
|
3110
|
-
${opts.includeMethodsDepth}
|
|
3110
|
+
${opts.includeMethodsDepth},
|
|
3111
|
+
body.data.includeSoftDeleted ?? false
|
|
3111
3112
|
);
|
|
3112
3113
|
return c.json({
|
|
3113
3114
|
data: stitched,
|
|
@@ -4430,7 +4431,8 @@ export async function loadIncludes(
|
|
|
4430
4431
|
parents: any[],
|
|
4431
4432
|
spec: IncludeSpec | undefined,
|
|
4432
4433
|
pg: { query: (text: string, params?: any[]) => Promise<{ rows: any[] }> },
|
|
4433
|
-
maxDepth: number = ${maxDepth}
|
|
4434
|
+
maxDepth: number = ${maxDepth},
|
|
4435
|
+
includeSoftDeleted: boolean = false
|
|
4434
4436
|
) {
|
|
4435
4437
|
try {
|
|
4436
4438
|
if (!spec || !parents.length) return parents;
|
|
@@ -4550,7 +4552,7 @@ export async function loadIncludes(
|
|
|
4550
4552
|
const pkCols = pkOf(target);
|
|
4551
4553
|
const where = buildOrAndPredicate(pkCols, tuples.length, 1);
|
|
4552
4554
|
const params = tuples.flat();
|
|
4553
|
-
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${softDeleteFilter(target)}\`;
|
|
4555
|
+
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
4554
4556
|
log.debug("belongsTo SQL", { curr, target, key, sql, paramsCount: params.length });
|
|
4555
4557
|
const { rows: targets } = await pg.query(sql, params);
|
|
4556
4558
|
|
|
@@ -4577,7 +4579,7 @@ export async function loadIncludes(
|
|
|
4577
4579
|
// SELECT target WHERE fk IN tuples
|
|
4578
4580
|
const where = buildOrAndPredicate(fk.from, tuples.length, 1);
|
|
4579
4581
|
const params = tuples.flat();
|
|
4580
|
-
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${softDeleteFilter(target)}\`;
|
|
4582
|
+
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
4581
4583
|
log.debug("hasOne SQL", { curr, target, key, sql, paramsCount: params.length });
|
|
4582
4584
|
const { rows: targets } = await pg.query(sql, params);
|
|
4583
4585
|
|
|
@@ -4604,7 +4606,7 @@ export async function loadIncludes(
|
|
|
4604
4606
|
const params = tuples.flat();
|
|
4605
4607
|
|
|
4606
4608
|
// Build SQL with optional ORDER BY, LIMIT, OFFSET
|
|
4607
|
-
let sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${softDeleteFilter(target)}\`;
|
|
4609
|
+
let sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
4608
4610
|
|
|
4609
4611
|
// If limit/offset are needed, use window functions to limit per parent
|
|
4610
4612
|
if (options.limit !== undefined || options.offset !== undefined) {
|
|
@@ -4620,7 +4622,7 @@ export async function loadIncludes(
|
|
|
4620
4622
|
SELECT * FROM (
|
|
4621
4623
|
SELECT *, ROW_NUMBER() OVER (PARTITION BY \${partitionCols} \${orderByClause}) as __rn
|
|
4622
4624
|
FROM "\${target}"
|
|
4623
|
-
WHERE (\${where})\${softDeleteFilter(target)}
|
|
4625
|
+
WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}
|
|
4624
4626
|
) __sub
|
|
4625
4627
|
WHERE __rn > \${offset} AND __rn <= \${offset + limit}
|
|
4626
4628
|
\`;
|
|
@@ -4684,7 +4686,7 @@ export async function loadIncludes(
|
|
|
4684
4686
|
\${toCurr.from.map((c: string) => \`j."\${c}"\`).join(' || \\',\\' || ')} as __parent_fk
|
|
4685
4687
|
FROM "\${via}" j
|
|
4686
4688
|
INNER JOIN "\${target}" t ON \${joinConditions}
|
|
4687
|
-
WHERE (\${whereVia})\${softDeleteFilter(target, "t")}
|
|
4689
|
+
WHERE (\${whereVia})\${includeSoftDeleted ? "" : softDeleteFilter(target, "t")}
|
|
4688
4690
|
) __numbered
|
|
4689
4691
|
WHERE __numbered.__rn > \${offset} AND __numbered.__rn <= \${offset + limit}
|
|
4690
4692
|
\`;
|
|
@@ -4728,7 +4730,7 @@ export async function loadIncludes(
|
|
|
4728
4730
|
// 2) Load targets by distinct target fk tuples in junction
|
|
4729
4731
|
const tTuples = distinctTuples(jrows, toTarget.from);
|
|
4730
4732
|
const whereT = buildOrAndPredicate(pkOf(target), tTuples.length, 1);
|
|
4731
|
-
const sqlT = \`SELECT * FROM "\${target}" WHERE (\${whereT})\${softDeleteFilter(target)}\`;
|
|
4733
|
+
const sqlT = \`SELECT * FROM "\${target}" WHERE (\${whereT})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
4732
4734
|
const paramsT = tTuples.flat();
|
|
4733
4735
|
log.debug("manyToMany target SQL", { curr, target, via, key, sql: sqlT, paramsCount: paramsT.length });
|
|
4734
4736
|
const { rows: targets } = await pg.query(sqlT, paramsT);
|
package/dist/index.js
CHANGED
|
@@ -2146,7 +2146,8 @@ ${hasAuth ? `
|
|
|
2146
2146
|
result.data,
|
|
2147
2147
|
result.includeSpec,
|
|
2148
2148
|
deps.pg,
|
|
2149
|
-
${opts.includeMethodsDepth}
|
|
2149
|
+
${opts.includeMethodsDepth},
|
|
2150
|
+
body.data.includeSoftDeleted ?? false
|
|
2150
2151
|
);
|
|
2151
2152
|
return c.json({
|
|
2152
2153
|
data: stitched,
|
|
@@ -3469,7 +3470,8 @@ export async function loadIncludes(
|
|
|
3469
3470
|
parents: any[],
|
|
3470
3471
|
spec: IncludeSpec | undefined,
|
|
3471
3472
|
pg: { query: (text: string, params?: any[]) => Promise<{ rows: any[] }> },
|
|
3472
|
-
maxDepth: number = ${maxDepth}
|
|
3473
|
+
maxDepth: number = ${maxDepth},
|
|
3474
|
+
includeSoftDeleted: boolean = false
|
|
3473
3475
|
) {
|
|
3474
3476
|
try {
|
|
3475
3477
|
if (!spec || !parents.length) return parents;
|
|
@@ -3589,7 +3591,7 @@ export async function loadIncludes(
|
|
|
3589
3591
|
const pkCols = pkOf(target);
|
|
3590
3592
|
const where = buildOrAndPredicate(pkCols, tuples.length, 1);
|
|
3591
3593
|
const params = tuples.flat();
|
|
3592
|
-
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${softDeleteFilter(target)}\`;
|
|
3594
|
+
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
3593
3595
|
log.debug("belongsTo SQL", { curr, target, key, sql, paramsCount: params.length });
|
|
3594
3596
|
const { rows: targets } = await pg.query(sql, params);
|
|
3595
3597
|
|
|
@@ -3616,7 +3618,7 @@ export async function loadIncludes(
|
|
|
3616
3618
|
// SELECT target WHERE fk IN tuples
|
|
3617
3619
|
const where = buildOrAndPredicate(fk.from, tuples.length, 1);
|
|
3618
3620
|
const params = tuples.flat();
|
|
3619
|
-
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${softDeleteFilter(target)}\`;
|
|
3621
|
+
const sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
3620
3622
|
log.debug("hasOne SQL", { curr, target, key, sql, paramsCount: params.length });
|
|
3621
3623
|
const { rows: targets } = await pg.query(sql, params);
|
|
3622
3624
|
|
|
@@ -3643,7 +3645,7 @@ export async function loadIncludes(
|
|
|
3643
3645
|
const params = tuples.flat();
|
|
3644
3646
|
|
|
3645
3647
|
// Build SQL with optional ORDER BY, LIMIT, OFFSET
|
|
3646
|
-
let sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${softDeleteFilter(target)}\`;
|
|
3648
|
+
let sql = \`SELECT * FROM "\${target}" WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
3647
3649
|
|
|
3648
3650
|
// If limit/offset are needed, use window functions to limit per parent
|
|
3649
3651
|
if (options.limit !== undefined || options.offset !== undefined) {
|
|
@@ -3659,7 +3661,7 @@ export async function loadIncludes(
|
|
|
3659
3661
|
SELECT * FROM (
|
|
3660
3662
|
SELECT *, ROW_NUMBER() OVER (PARTITION BY \${partitionCols} \${orderByClause}) as __rn
|
|
3661
3663
|
FROM "\${target}"
|
|
3662
|
-
WHERE (\${where})\${softDeleteFilter(target)}
|
|
3664
|
+
WHERE (\${where})\${includeSoftDeleted ? "" : softDeleteFilter(target)}
|
|
3663
3665
|
) __sub
|
|
3664
3666
|
WHERE __rn > \${offset} AND __rn <= \${offset + limit}
|
|
3665
3667
|
\`;
|
|
@@ -3723,7 +3725,7 @@ export async function loadIncludes(
|
|
|
3723
3725
|
\${toCurr.from.map((c: string) => \`j."\${c}"\`).join(' || \\',\\' || ')} as __parent_fk
|
|
3724
3726
|
FROM "\${via}" j
|
|
3725
3727
|
INNER JOIN "\${target}" t ON \${joinConditions}
|
|
3726
|
-
WHERE (\${whereVia})\${softDeleteFilter(target, "t")}
|
|
3728
|
+
WHERE (\${whereVia})\${includeSoftDeleted ? "" : softDeleteFilter(target, "t")}
|
|
3727
3729
|
) __numbered
|
|
3728
3730
|
WHERE __numbered.__rn > \${offset} AND __numbered.__rn <= \${offset + limit}
|
|
3729
3731
|
\`;
|
|
@@ -3767,7 +3769,7 @@ export async function loadIncludes(
|
|
|
3767
3769
|
// 2) Load targets by distinct target fk tuples in junction
|
|
3768
3770
|
const tTuples = distinctTuples(jrows, toTarget.from);
|
|
3769
3771
|
const whereT = buildOrAndPredicate(pkOf(target), tTuples.length, 1);
|
|
3770
|
-
const sqlT = \`SELECT * FROM "\${target}" WHERE (\${whereT})\${softDeleteFilter(target)}\`;
|
|
3772
|
+
const sqlT = \`SELECT * FROM "\${target}" WHERE (\${whereT})\${includeSoftDeleted ? "" : softDeleteFilter(target)}\`;
|
|
3771
3773
|
const paramsT = tTuples.flat();
|
|
3772
3774
|
log.debug("manyToMany target SQL", { curr, target, via, key, sql: sqlT, paramsCount: paramsT.length });
|
|
3773
3775
|
const { rows: targets } = await pg.query(sqlT, paramsT);
|