postgresdk 0.18.2 → 0.18.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/cache.d.ts +1 -0
- package/dist/cli.js +134 -22
- package/dist/index.js +129 -17
- package/package.json +1 -1
package/dist/cache.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface CacheData {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Compute a deterministic hash of the schema and config
|
|
17
|
+
* Includes postgresdk version to trigger regeneration on upgrades
|
|
17
18
|
*/
|
|
18
19
|
export declare function computeSchemaHash(model: Model, config: Config): string;
|
|
19
20
|
/**
|
package/dist/cli.js
CHANGED
|
@@ -1689,10 +1689,11 @@ var init_emit_sdk_contract = __esm(() => {
|
|
|
1689
1689
|
// src/cache.ts
|
|
1690
1690
|
import { createHash } from "crypto";
|
|
1691
1691
|
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, appendFile } from "fs/promises";
|
|
1692
|
-
import { existsSync } from "fs";
|
|
1692
|
+
import { existsSync, readFileSync } from "fs";
|
|
1693
1693
|
import { join } from "path";
|
|
1694
1694
|
function computeSchemaHash(model, config) {
|
|
1695
1695
|
const payload = {
|
|
1696
|
+
version: POSTGRESDK_VERSION,
|
|
1696
1697
|
schema: model.schema,
|
|
1697
1698
|
tables: model.tables,
|
|
1698
1699
|
enums: model.enums,
|
|
@@ -1780,7 +1781,11 @@ async function appendToHistory(entry, baseDir) {
|
|
|
1780
1781
|
${formattedEntry}`, "utf-8");
|
|
1781
1782
|
}
|
|
1782
1783
|
}
|
|
1783
|
-
var
|
|
1784
|
+
var __dirname = "/workspace/src", packageJson, POSTGRESDK_VERSION;
|
|
1785
|
+
var init_cache = __esm(() => {
|
|
1786
|
+
packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
1787
|
+
POSTGRESDK_VERSION = packageJson.version;
|
|
1788
|
+
});
|
|
1784
1789
|
|
|
1785
1790
|
// src/cli-config-utils.ts
|
|
1786
1791
|
function extractConfigFields(configContent) {
|
|
@@ -2201,7 +2206,7 @@ var exports_cli_init = {};
|
|
|
2201
2206
|
__export(exports_cli_init, {
|
|
2202
2207
|
initCommand: () => initCommand
|
|
2203
2208
|
});
|
|
2204
|
-
import { existsSync as existsSync3, writeFileSync, readFileSync, copyFileSync } from "fs";
|
|
2209
|
+
import { existsSync as existsSync3, writeFileSync, readFileSync as readFileSync2, copyFileSync } from "fs";
|
|
2205
2210
|
import { resolve } from "path";
|
|
2206
2211
|
import prompts from "prompts";
|
|
2207
2212
|
async function initCommand(args) {
|
|
@@ -2219,7 +2224,7 @@ async function initCommand(args) {
|
|
|
2219
2224
|
}
|
|
2220
2225
|
console.log(`⚠️ Found existing postgresdk.config.ts
|
|
2221
2226
|
`);
|
|
2222
|
-
const existingContent =
|
|
2227
|
+
const existingContent = readFileSync2(configPath, "utf-8");
|
|
2223
2228
|
const existingFields = extractConfigFields(existingContent);
|
|
2224
2229
|
console.log("\uD83D\uDCCB Existing configuration detected:");
|
|
2225
2230
|
existingFields.forEach((field) => {
|
|
@@ -3780,11 +3785,25 @@ ${hasJsonbColumns ? ` /**
|
|
|
3780
3785
|
const url = query ? \`\${this.resource}?\${query}\` : this.resource;
|
|
3781
3786
|
return this.post<Select${Type}<TJsonb>>(url, data);
|
|
3782
3787
|
}` : ` /**
|
|
3788
|
+
* Create a new ${table.name} record with field selection
|
|
3789
|
+
* @param data - The data to insert
|
|
3790
|
+
* @param options - Select specific fields to return
|
|
3791
|
+
* @returns The created record with only selected fields
|
|
3792
|
+
*/
|
|
3793
|
+
async create(data: Insert${Type}, options: { select: string[] }): Promise<Partial<Select${Type}>>;
|
|
3794
|
+
/**
|
|
3795
|
+
* Create a new ${table.name} record with field exclusion
|
|
3796
|
+
* @param data - The data to insert
|
|
3797
|
+
* @param options - Exclude specific fields from return
|
|
3798
|
+
* @returns The created record without excluded fields
|
|
3799
|
+
*/
|
|
3800
|
+
async create(data: Insert${Type}, options: { exclude: string[] }): Promise<Partial<Select${Type}>>;
|
|
3801
|
+
/**
|
|
3783
3802
|
* Create a new ${table.name} record
|
|
3784
3803
|
* @param data - The data to insert
|
|
3785
|
-
* @
|
|
3786
|
-
* @returns The created record
|
|
3804
|
+
* @returns The created record with all fields
|
|
3787
3805
|
*/
|
|
3806
|
+
async create(data: Insert${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type}>;
|
|
3788
3807
|
async create(
|
|
3789
3808
|
data: Insert${Type},
|
|
3790
3809
|
options?: { select?: string[]; exclude?: string[] }
|
|
@@ -3818,11 +3837,25 @@ ${hasJsonbColumns ? ` /**
|
|
|
3818
3837
|
const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
|
|
3819
3838
|
return this.get<Select${Type}<TJsonb> | null>(url);
|
|
3820
3839
|
}` : ` /**
|
|
3840
|
+
* Get a ${table.name} record by primary key with field selection
|
|
3841
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3842
|
+
* @param options - Select specific fields to return
|
|
3843
|
+
* @returns The record with only selected fields if found, null otherwise
|
|
3844
|
+
*/
|
|
3845
|
+
async getByPk(pk: ${pkType}, options: { select: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
3846
|
+
/**
|
|
3847
|
+
* Get a ${table.name} record by primary key with field exclusion
|
|
3848
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3849
|
+
* @param options - Exclude specific fields from return
|
|
3850
|
+
* @returns The record without excluded fields if found, null otherwise
|
|
3851
|
+
*/
|
|
3852
|
+
async getByPk(pk: ${pkType}, options: { exclude: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
3853
|
+
/**
|
|
3821
3854
|
* Get a ${table.name} record by primary key
|
|
3822
3855
|
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3823
|
-
* @
|
|
3824
|
-
* @returns The record if found, null otherwise
|
|
3856
|
+
* @returns The record with all fields if found, null otherwise
|
|
3825
3857
|
*/
|
|
3858
|
+
async getByPk(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
|
|
3826
3859
|
async getByPk(
|
|
3827
3860
|
pk: ${pkType},
|
|
3828
3861
|
options?: { select?: string[]; exclude?: string[] }
|
|
@@ -3873,21 +3906,70 @@ ${hasJsonbColumns ? ` /**
|
|
|
3873
3906
|
}): Promise<PaginatedResponse<(Select${Type}<TJsonb> | Partial<Select${Type}<TJsonb>>)${hasVectorColumns ? " & { _distance?: number }" : ""}>> {
|
|
3874
3907
|
return this.post<PaginatedResponse<Select${Type}<TJsonb>${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
|
|
3875
3908
|
}` : ` /**
|
|
3909
|
+
* List ${table.name} records with field selection
|
|
3910
|
+
* @param params - Query parameters with select
|
|
3911
|
+
* @returns Paginated results with only selected fields
|
|
3912
|
+
*/
|
|
3913
|
+
async list(params: {
|
|
3914
|
+
select: string[];
|
|
3915
|
+
include?: any;
|
|
3916
|
+
limit?: number;
|
|
3917
|
+
offset?: number;
|
|
3918
|
+
where?: Where<Select${Type}>;${hasVectorColumns ? `
|
|
3919
|
+
vector?: {
|
|
3920
|
+
field: string;
|
|
3921
|
+
query: number[];
|
|
3922
|
+
metric?: "cosine" | "l2" | "inner";
|
|
3923
|
+
maxDistance?: number;
|
|
3924
|
+
};` : ""}
|
|
3925
|
+
orderBy?: string | string[];
|
|
3926
|
+
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
3927
|
+
}): Promise<PaginatedResponse<Partial<Select${Type}>${hasVectorColumns ? " & { _distance?: number }" : ""}>>;
|
|
3928
|
+
/**
|
|
3929
|
+
* List ${table.name} records with field exclusion
|
|
3930
|
+
* @param params - Query parameters with exclude
|
|
3931
|
+
* @returns Paginated results without excluded fields
|
|
3932
|
+
*/
|
|
3933
|
+
async list(params: {
|
|
3934
|
+
exclude: string[];
|
|
3935
|
+
include?: any;
|
|
3936
|
+
limit?: number;
|
|
3937
|
+
offset?: number;
|
|
3938
|
+
where?: Where<Select${Type}>;${hasVectorColumns ? `
|
|
3939
|
+
vector?: {
|
|
3940
|
+
field: string;
|
|
3941
|
+
query: number[];
|
|
3942
|
+
metric?: "cosine" | "l2" | "inner";
|
|
3943
|
+
maxDistance?: number;
|
|
3944
|
+
};` : ""}
|
|
3945
|
+
orderBy?: string | string[];
|
|
3946
|
+
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
3947
|
+
}): Promise<PaginatedResponse<Partial<Select${Type}>${hasVectorColumns ? " & { _distance?: number }" : ""}>>;
|
|
3948
|
+
/**
|
|
3876
3949
|
* List ${table.name} records with pagination and filtering
|
|
3877
3950
|
* @param params - Query parameters
|
|
3878
3951
|
* @param params.where - Filter conditions using operators like $eq, $gt, $in, $like, etc.
|
|
3879
|
-
* @param params.select - Array of field names to include in response
|
|
3880
|
-
* @param params.exclude - Array of field names to exclude from response (mutually exclusive with select)
|
|
3881
3952
|
* @param params.orderBy - Column(s) to sort by
|
|
3882
3953
|
* @param params.order - Sort direction(s): "asc" or "desc"
|
|
3883
3954
|
* @param params.limit - Maximum number of records to return (default: 50, max: 1000)
|
|
3884
3955
|
* @param params.offset - Number of records to skip for pagination
|
|
3885
3956
|
* @param params.include - Related records to include (see listWith* methods for typed includes)
|
|
3886
|
-
* @returns Paginated results with
|
|
3887
|
-
* @example
|
|
3888
|
-
* // With select:
|
|
3889
|
-
* const users = await client.list({ select: ['id', 'email'] });
|
|
3957
|
+
* @returns Paginated results with all fields
|
|
3890
3958
|
*/
|
|
3959
|
+
async list(params?: {
|
|
3960
|
+
include?: any;
|
|
3961
|
+
limit?: number;
|
|
3962
|
+
offset?: number;
|
|
3963
|
+
where?: Where<Select${Type}>;${hasVectorColumns ? `
|
|
3964
|
+
vector?: {
|
|
3965
|
+
field: string;
|
|
3966
|
+
query: number[];
|
|
3967
|
+
metric?: "cosine" | "l2" | "inner";
|
|
3968
|
+
maxDistance?: number;
|
|
3969
|
+
};` : ""}
|
|
3970
|
+
orderBy?: string | string[];
|
|
3971
|
+
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
3972
|
+
}): Promise<PaginatedResponse<Select${Type}${hasVectorColumns ? " & { _distance?: number }" : ""}>>;
|
|
3891
3973
|
async list(params?: {
|
|
3892
3974
|
include?: any;
|
|
3893
3975
|
select?: string[];
|
|
@@ -3903,7 +3985,7 @@ ${hasJsonbColumns ? ` /**
|
|
|
3903
3985
|
};` : ""}
|
|
3904
3986
|
orderBy?: string | string[];
|
|
3905
3987
|
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
3906
|
-
}): Promise<PaginatedResponse<
|
|
3988
|
+
}): Promise<PaginatedResponse<Select${Type} | Partial<Select${Type}>>> {
|
|
3907
3989
|
return this.post<PaginatedResponse<Select${Type}${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
|
|
3908
3990
|
}`}
|
|
3909
3991
|
|
|
@@ -3930,12 +4012,28 @@ ${hasJsonbColumns ? ` /**
|
|
|
3930
4012
|
const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
|
|
3931
4013
|
return this.patch<Select${Type}<TJsonb> | null>(url, patch);
|
|
3932
4014
|
}` : ` /**
|
|
4015
|
+
* Update a ${table.name} record by primary key with field selection
|
|
4016
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
4017
|
+
* @param patch - Partial data to update
|
|
4018
|
+
* @param options - Select specific fields to return
|
|
4019
|
+
* @returns The updated record with only selected fields if found, null otherwise
|
|
4020
|
+
*/
|
|
4021
|
+
async update(pk: ${pkType}, patch: Update${Type}, options: { select: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
4022
|
+
/**
|
|
4023
|
+
* Update a ${table.name} record by primary key with field exclusion
|
|
4024
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
4025
|
+
* @param patch - Partial data to update
|
|
4026
|
+
* @param options - Exclude specific fields from return
|
|
4027
|
+
* @returns The updated record without excluded fields if found, null otherwise
|
|
4028
|
+
*/
|
|
4029
|
+
async update(pk: ${pkType}, patch: Update${Type}, options: { exclude: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
4030
|
+
/**
|
|
3933
4031
|
* Update a ${table.name} record by primary key
|
|
3934
4032
|
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3935
4033
|
* @param patch - Partial data to update
|
|
3936
|
-
* @
|
|
3937
|
-
* @returns The updated record if found, null otherwise
|
|
4034
|
+
* @returns The updated record with all fields if found, null otherwise
|
|
3938
4035
|
*/
|
|
4036
|
+
async update(pk: ${pkType}, patch: Update${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
|
|
3939
4037
|
async update(
|
|
3940
4038
|
pk: ${pkType},
|
|
3941
4039
|
patch: Update${Type},
|
|
@@ -3971,11 +4069,25 @@ ${hasJsonbColumns ? ` /**
|
|
|
3971
4069
|
const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
|
|
3972
4070
|
return this.del<Select${Type}<TJsonb> | null>(url);
|
|
3973
4071
|
}` : ` /**
|
|
4072
|
+
* Delete a ${table.name} record by primary key with field selection
|
|
4073
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
4074
|
+
* @param options - Select specific fields to return
|
|
4075
|
+
* @returns The deleted record with only selected fields if found, null otherwise
|
|
4076
|
+
*/
|
|
4077
|
+
async delete(pk: ${pkType}, options: { select: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
4078
|
+
/**
|
|
4079
|
+
* Delete a ${table.name} record by primary key with field exclusion
|
|
4080
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
4081
|
+
* @param options - Exclude specific fields from return
|
|
4082
|
+
* @returns The deleted record without excluded fields if found, null otherwise
|
|
4083
|
+
*/
|
|
4084
|
+
async delete(pk: ${pkType}, options: { exclude: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
4085
|
+
/**
|
|
3974
4086
|
* Delete a ${table.name} record by primary key
|
|
3975
4087
|
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3976
|
-
* @
|
|
3977
|
-
* @returns The deleted record if found, null otherwise
|
|
4088
|
+
* @returns The deleted record with all fields if found, null otherwise
|
|
3978
4089
|
*/
|
|
4090
|
+
async delete(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
|
|
3979
4091
|
async delete(
|
|
3980
4092
|
pk: ${pkType},
|
|
3981
4093
|
options?: { select?: string[]; exclude?: string[] }
|
|
@@ -7192,13 +7304,13 @@ async function generate(configPath) {
|
|
|
7192
7304
|
// src/cli.ts
|
|
7193
7305
|
var import_config2 = __toESM(require_config(), 1);
|
|
7194
7306
|
import { resolve as resolve3 } from "node:path";
|
|
7195
|
-
import { readFileSync as
|
|
7307
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
7196
7308
|
import { fileURLToPath } from "node:url";
|
|
7197
7309
|
import { dirname as dirname4, join as join4 } from "node:path";
|
|
7198
7310
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
7199
7311
|
var __dirname2 = dirname4(__filename2);
|
|
7200
|
-
var
|
|
7201
|
-
var VERSION =
|
|
7312
|
+
var packageJson2 = JSON.parse(readFileSync3(join4(__dirname2, "../package.json"), "utf-8"));
|
|
7313
|
+
var VERSION = packageJson2.version;
|
|
7202
7314
|
var args = process.argv.slice(2);
|
|
7203
7315
|
var command = args[0];
|
|
7204
7316
|
if (args.includes("--version") || args.includes("-v") || command === "version") {
|
package/dist/index.js
CHANGED
|
@@ -1688,10 +1688,11 @@ var init_emit_sdk_contract = __esm(() => {
|
|
|
1688
1688
|
// src/cache.ts
|
|
1689
1689
|
import { createHash } from "crypto";
|
|
1690
1690
|
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, appendFile } from "fs/promises";
|
|
1691
|
-
import { existsSync } from "fs";
|
|
1691
|
+
import { existsSync, readFileSync } from "fs";
|
|
1692
1692
|
import { join } from "path";
|
|
1693
1693
|
function computeSchemaHash(model, config) {
|
|
1694
1694
|
const payload = {
|
|
1695
|
+
version: POSTGRESDK_VERSION,
|
|
1695
1696
|
schema: model.schema,
|
|
1696
1697
|
tables: model.tables,
|
|
1697
1698
|
enums: model.enums,
|
|
@@ -1779,7 +1780,11 @@ async function appendToHistory(entry, baseDir) {
|
|
|
1779
1780
|
${formattedEntry}`, "utf-8");
|
|
1780
1781
|
}
|
|
1781
1782
|
}
|
|
1782
|
-
var
|
|
1783
|
+
var __dirname = "/workspace/src", packageJson, POSTGRESDK_VERSION;
|
|
1784
|
+
var init_cache = __esm(() => {
|
|
1785
|
+
packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
1786
|
+
POSTGRESDK_VERSION = packageJson.version;
|
|
1787
|
+
});
|
|
1783
1788
|
|
|
1784
1789
|
// src/index.ts
|
|
1785
1790
|
var import_config = __toESM(require_config(), 1);
|
|
@@ -2801,11 +2806,25 @@ ${hasJsonbColumns ? ` /**
|
|
|
2801
2806
|
const url = query ? \`\${this.resource}?\${query}\` : this.resource;
|
|
2802
2807
|
return this.post<Select${Type}<TJsonb>>(url, data);
|
|
2803
2808
|
}` : ` /**
|
|
2809
|
+
* Create a new ${table.name} record with field selection
|
|
2810
|
+
* @param data - The data to insert
|
|
2811
|
+
* @param options - Select specific fields to return
|
|
2812
|
+
* @returns The created record with only selected fields
|
|
2813
|
+
*/
|
|
2814
|
+
async create(data: Insert${Type}, options: { select: string[] }): Promise<Partial<Select${Type}>>;
|
|
2815
|
+
/**
|
|
2816
|
+
* Create a new ${table.name} record with field exclusion
|
|
2817
|
+
* @param data - The data to insert
|
|
2818
|
+
* @param options - Exclude specific fields from return
|
|
2819
|
+
* @returns The created record without excluded fields
|
|
2820
|
+
*/
|
|
2821
|
+
async create(data: Insert${Type}, options: { exclude: string[] }): Promise<Partial<Select${Type}>>;
|
|
2822
|
+
/**
|
|
2804
2823
|
* Create a new ${table.name} record
|
|
2805
2824
|
* @param data - The data to insert
|
|
2806
|
-
* @
|
|
2807
|
-
* @returns The created record
|
|
2825
|
+
* @returns The created record with all fields
|
|
2808
2826
|
*/
|
|
2827
|
+
async create(data: Insert${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type}>;
|
|
2809
2828
|
async create(
|
|
2810
2829
|
data: Insert${Type},
|
|
2811
2830
|
options?: { select?: string[]; exclude?: string[] }
|
|
@@ -2839,11 +2858,25 @@ ${hasJsonbColumns ? ` /**
|
|
|
2839
2858
|
const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
|
|
2840
2859
|
return this.get<Select${Type}<TJsonb> | null>(url);
|
|
2841
2860
|
}` : ` /**
|
|
2861
|
+
* Get a ${table.name} record by primary key with field selection
|
|
2862
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
2863
|
+
* @param options - Select specific fields to return
|
|
2864
|
+
* @returns The record with only selected fields if found, null otherwise
|
|
2865
|
+
*/
|
|
2866
|
+
async getByPk(pk: ${pkType}, options: { select: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
2867
|
+
/**
|
|
2868
|
+
* Get a ${table.name} record by primary key with field exclusion
|
|
2869
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
2870
|
+
* @param options - Exclude specific fields from return
|
|
2871
|
+
* @returns The record without excluded fields if found, null otherwise
|
|
2872
|
+
*/
|
|
2873
|
+
async getByPk(pk: ${pkType}, options: { exclude: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
2874
|
+
/**
|
|
2842
2875
|
* Get a ${table.name} record by primary key
|
|
2843
2876
|
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
2844
|
-
* @
|
|
2845
|
-
* @returns The record if found, null otherwise
|
|
2877
|
+
* @returns The record with all fields if found, null otherwise
|
|
2846
2878
|
*/
|
|
2879
|
+
async getByPk(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
|
|
2847
2880
|
async getByPk(
|
|
2848
2881
|
pk: ${pkType},
|
|
2849
2882
|
options?: { select?: string[]; exclude?: string[] }
|
|
@@ -2894,21 +2927,70 @@ ${hasJsonbColumns ? ` /**
|
|
|
2894
2927
|
}): Promise<PaginatedResponse<(Select${Type}<TJsonb> | Partial<Select${Type}<TJsonb>>)${hasVectorColumns ? " & { _distance?: number }" : ""}>> {
|
|
2895
2928
|
return this.post<PaginatedResponse<Select${Type}<TJsonb>${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
|
|
2896
2929
|
}` : ` /**
|
|
2930
|
+
* List ${table.name} records with field selection
|
|
2931
|
+
* @param params - Query parameters with select
|
|
2932
|
+
* @returns Paginated results with only selected fields
|
|
2933
|
+
*/
|
|
2934
|
+
async list(params: {
|
|
2935
|
+
select: string[];
|
|
2936
|
+
include?: any;
|
|
2937
|
+
limit?: number;
|
|
2938
|
+
offset?: number;
|
|
2939
|
+
where?: Where<Select${Type}>;${hasVectorColumns ? `
|
|
2940
|
+
vector?: {
|
|
2941
|
+
field: string;
|
|
2942
|
+
query: number[];
|
|
2943
|
+
metric?: "cosine" | "l2" | "inner";
|
|
2944
|
+
maxDistance?: number;
|
|
2945
|
+
};` : ""}
|
|
2946
|
+
orderBy?: string | string[];
|
|
2947
|
+
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
2948
|
+
}): Promise<PaginatedResponse<Partial<Select${Type}>${hasVectorColumns ? " & { _distance?: number }" : ""}>>;
|
|
2949
|
+
/**
|
|
2950
|
+
* List ${table.name} records with field exclusion
|
|
2951
|
+
* @param params - Query parameters with exclude
|
|
2952
|
+
* @returns Paginated results without excluded fields
|
|
2953
|
+
*/
|
|
2954
|
+
async list(params: {
|
|
2955
|
+
exclude: string[];
|
|
2956
|
+
include?: any;
|
|
2957
|
+
limit?: number;
|
|
2958
|
+
offset?: number;
|
|
2959
|
+
where?: Where<Select${Type}>;${hasVectorColumns ? `
|
|
2960
|
+
vector?: {
|
|
2961
|
+
field: string;
|
|
2962
|
+
query: number[];
|
|
2963
|
+
metric?: "cosine" | "l2" | "inner";
|
|
2964
|
+
maxDistance?: number;
|
|
2965
|
+
};` : ""}
|
|
2966
|
+
orderBy?: string | string[];
|
|
2967
|
+
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
2968
|
+
}): Promise<PaginatedResponse<Partial<Select${Type}>${hasVectorColumns ? " & { _distance?: number }" : ""}>>;
|
|
2969
|
+
/**
|
|
2897
2970
|
* List ${table.name} records with pagination and filtering
|
|
2898
2971
|
* @param params - Query parameters
|
|
2899
2972
|
* @param params.where - Filter conditions using operators like $eq, $gt, $in, $like, etc.
|
|
2900
|
-
* @param params.select - Array of field names to include in response
|
|
2901
|
-
* @param params.exclude - Array of field names to exclude from response (mutually exclusive with select)
|
|
2902
2973
|
* @param params.orderBy - Column(s) to sort by
|
|
2903
2974
|
* @param params.order - Sort direction(s): "asc" or "desc"
|
|
2904
2975
|
* @param params.limit - Maximum number of records to return (default: 50, max: 1000)
|
|
2905
2976
|
* @param params.offset - Number of records to skip for pagination
|
|
2906
2977
|
* @param params.include - Related records to include (see listWith* methods for typed includes)
|
|
2907
|
-
* @returns Paginated results with
|
|
2908
|
-
* @example
|
|
2909
|
-
* // With select:
|
|
2910
|
-
* const users = await client.list({ select: ['id', 'email'] });
|
|
2978
|
+
* @returns Paginated results with all fields
|
|
2911
2979
|
*/
|
|
2980
|
+
async list(params?: {
|
|
2981
|
+
include?: any;
|
|
2982
|
+
limit?: number;
|
|
2983
|
+
offset?: number;
|
|
2984
|
+
where?: Where<Select${Type}>;${hasVectorColumns ? `
|
|
2985
|
+
vector?: {
|
|
2986
|
+
field: string;
|
|
2987
|
+
query: number[];
|
|
2988
|
+
metric?: "cosine" | "l2" | "inner";
|
|
2989
|
+
maxDistance?: number;
|
|
2990
|
+
};` : ""}
|
|
2991
|
+
orderBy?: string | string[];
|
|
2992
|
+
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
2993
|
+
}): Promise<PaginatedResponse<Select${Type}${hasVectorColumns ? " & { _distance?: number }" : ""}>>;
|
|
2912
2994
|
async list(params?: {
|
|
2913
2995
|
include?: any;
|
|
2914
2996
|
select?: string[];
|
|
@@ -2924,7 +3006,7 @@ ${hasJsonbColumns ? ` /**
|
|
|
2924
3006
|
};` : ""}
|
|
2925
3007
|
orderBy?: string | string[];
|
|
2926
3008
|
order?: "asc" | "desc" | ("asc" | "desc")[];
|
|
2927
|
-
}): Promise<PaginatedResponse<
|
|
3009
|
+
}): Promise<PaginatedResponse<Select${Type} | Partial<Select${Type}>>> {
|
|
2928
3010
|
return this.post<PaginatedResponse<Select${Type}${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
|
|
2929
3011
|
}`}
|
|
2930
3012
|
|
|
@@ -2951,12 +3033,28 @@ ${hasJsonbColumns ? ` /**
|
|
|
2951
3033
|
const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
|
|
2952
3034
|
return this.patch<Select${Type}<TJsonb> | null>(url, patch);
|
|
2953
3035
|
}` : ` /**
|
|
3036
|
+
* Update a ${table.name} record by primary key with field selection
|
|
3037
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3038
|
+
* @param patch - Partial data to update
|
|
3039
|
+
* @param options - Select specific fields to return
|
|
3040
|
+
* @returns The updated record with only selected fields if found, null otherwise
|
|
3041
|
+
*/
|
|
3042
|
+
async update(pk: ${pkType}, patch: Update${Type}, options: { select: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
3043
|
+
/**
|
|
3044
|
+
* Update a ${table.name} record by primary key with field exclusion
|
|
3045
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3046
|
+
* @param patch - Partial data to update
|
|
3047
|
+
* @param options - Exclude specific fields from return
|
|
3048
|
+
* @returns The updated record without excluded fields if found, null otherwise
|
|
3049
|
+
*/
|
|
3050
|
+
async update(pk: ${pkType}, patch: Update${Type}, options: { exclude: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
3051
|
+
/**
|
|
2954
3052
|
* Update a ${table.name} record by primary key
|
|
2955
3053
|
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
2956
3054
|
* @param patch - Partial data to update
|
|
2957
|
-
* @
|
|
2958
|
-
* @returns The updated record if found, null otherwise
|
|
3055
|
+
* @returns The updated record with all fields if found, null otherwise
|
|
2959
3056
|
*/
|
|
3057
|
+
async update(pk: ${pkType}, patch: Update${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
|
|
2960
3058
|
async update(
|
|
2961
3059
|
pk: ${pkType},
|
|
2962
3060
|
patch: Update${Type},
|
|
@@ -2992,11 +3090,25 @@ ${hasJsonbColumns ? ` /**
|
|
|
2992
3090
|
const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
|
|
2993
3091
|
return this.del<Select${Type}<TJsonb> | null>(url);
|
|
2994
3092
|
}` : ` /**
|
|
3093
|
+
* Delete a ${table.name} record by primary key with field selection
|
|
3094
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3095
|
+
* @param options - Select specific fields to return
|
|
3096
|
+
* @returns The deleted record with only selected fields if found, null otherwise
|
|
3097
|
+
*/
|
|
3098
|
+
async delete(pk: ${pkType}, options: { select: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
3099
|
+
/**
|
|
3100
|
+
* Delete a ${table.name} record by primary key with field exclusion
|
|
3101
|
+
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
3102
|
+
* @param options - Exclude specific fields from return
|
|
3103
|
+
* @returns The deleted record without excluded fields if found, null otherwise
|
|
3104
|
+
*/
|
|
3105
|
+
async delete(pk: ${pkType}, options: { exclude: string[] }): Promise<Partial<Select${Type}> | null>;
|
|
3106
|
+
/**
|
|
2995
3107
|
* Delete a ${table.name} record by primary key
|
|
2996
3108
|
* @param pk - The primary key value${hasCompositePk ? "s" : ""}
|
|
2997
|
-
* @
|
|
2998
|
-
* @returns The deleted record if found, null otherwise
|
|
3109
|
+
* @returns The deleted record with all fields if found, null otherwise
|
|
2999
3110
|
*/
|
|
3111
|
+
async delete(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
|
|
3000
3112
|
async delete(
|
|
3001
3113
|
pk: ${pkType},
|
|
3002
3114
|
options?: { select?: string[]; exclude?: string[] }
|