postgresdk 0.18.3 → 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.
Files changed (3) hide show
  1. package/dist/cli.js +122 -15
  2. package/dist/index.js +122 -15
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3785,11 +3785,25 @@ ${hasJsonbColumns ? ` /**
3785
3785
  const url = query ? \`\${this.resource}?\${query}\` : this.resource;
3786
3786
  return this.post<Select${Type}<TJsonb>>(url, data);
3787
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
+ /**
3788
3802
  * Create a new ${table.name} record
3789
3803
  * @param data - The data to insert
3790
- * @param options - Optional select/exclude for returned fields
3791
- * @returns The created record
3804
+ * @returns The created record with all fields
3792
3805
  */
3806
+ async create(data: Insert${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type}>;
3793
3807
  async create(
3794
3808
  data: Insert${Type},
3795
3809
  options?: { select?: string[]; exclude?: string[] }
@@ -3823,11 +3837,25 @@ ${hasJsonbColumns ? ` /**
3823
3837
  const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
3824
3838
  return this.get<Select${Type}<TJsonb> | null>(url);
3825
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
+ /**
3826
3854
  * Get a ${table.name} record by primary key
3827
3855
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
3828
- * @param options - Optional select/exclude for returned fields
3829
- * @returns The record if found, null otherwise
3856
+ * @returns The record with all fields if found, null otherwise
3830
3857
  */
3858
+ async getByPk(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
3831
3859
  async getByPk(
3832
3860
  pk: ${pkType},
3833
3861
  options?: { select?: string[]; exclude?: string[] }
@@ -3878,21 +3906,70 @@ ${hasJsonbColumns ? ` /**
3878
3906
  }): Promise<PaginatedResponse<(Select${Type}<TJsonb> | Partial<Select${Type}<TJsonb>>)${hasVectorColumns ? " & { _distance?: number }" : ""}>> {
3879
3907
  return this.post<PaginatedResponse<Select${Type}<TJsonb>${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
3880
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
+ /**
3881
3949
  * List ${table.name} records with pagination and filtering
3882
3950
  * @param params - Query parameters
3883
3951
  * @param params.where - Filter conditions using operators like $eq, $gt, $in, $like, etc.
3884
- * @param params.select - Array of field names to include in response
3885
- * @param params.exclude - Array of field names to exclude from response (mutually exclusive with select)
3886
3952
  * @param params.orderBy - Column(s) to sort by
3887
3953
  * @param params.order - Sort direction(s): "asc" or "desc"
3888
3954
  * @param params.limit - Maximum number of records to return (default: 50, max: 1000)
3889
3955
  * @param params.offset - Number of records to skip for pagination
3890
3956
  * @param params.include - Related records to include (see listWith* methods for typed includes)
3891
- * @returns Paginated results with data, total count, and hasMore flag
3892
- * @example
3893
- * // With select:
3894
- * const users = await client.list({ select: ['id', 'email'] });
3957
+ * @returns Paginated results with all fields
3895
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 }" : ""}>>;
3896
3973
  async list(params?: {
3897
3974
  include?: any;
3898
3975
  select?: string[];
@@ -3908,7 +3985,7 @@ ${hasJsonbColumns ? ` /**
3908
3985
  };` : ""}
3909
3986
  orderBy?: string | string[];
3910
3987
  order?: "asc" | "desc" | ("asc" | "desc")[];
3911
- }): Promise<PaginatedResponse<(Select${Type} | Partial<Select${Type}>)${hasVectorColumns ? " & { _distance?: number }" : ""}>> {
3988
+ }): Promise<PaginatedResponse<Select${Type} | Partial<Select${Type}>>> {
3912
3989
  return this.post<PaginatedResponse<Select${Type}${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
3913
3990
  }`}
3914
3991
 
@@ -3935,12 +4012,28 @@ ${hasJsonbColumns ? ` /**
3935
4012
  const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
3936
4013
  return this.patch<Select${Type}<TJsonb> | null>(url, patch);
3937
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
+ /**
3938
4031
  * Update a ${table.name} record by primary key
3939
4032
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
3940
4033
  * @param patch - Partial data to update
3941
- * @param options - Optional select/exclude for returned fields
3942
- * @returns The updated record if found, null otherwise
4034
+ * @returns The updated record with all fields if found, null otherwise
3943
4035
  */
4036
+ async update(pk: ${pkType}, patch: Update${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
3944
4037
  async update(
3945
4038
  pk: ${pkType},
3946
4039
  patch: Update${Type},
@@ -3976,11 +4069,25 @@ ${hasJsonbColumns ? ` /**
3976
4069
  const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
3977
4070
  return this.del<Select${Type}<TJsonb> | null>(url);
3978
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
+ /**
3979
4086
  * Delete a ${table.name} record by primary key
3980
4087
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
3981
- * @param options - Optional select/exclude for returned fields
3982
- * @returns The deleted record if found, null otherwise
4088
+ * @returns The deleted record with all fields if found, null otherwise
3983
4089
  */
4090
+ async delete(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
3984
4091
  async delete(
3985
4092
  pk: ${pkType},
3986
4093
  options?: { select?: string[]; exclude?: string[] }
package/dist/index.js CHANGED
@@ -2806,11 +2806,25 @@ ${hasJsonbColumns ? ` /**
2806
2806
  const url = query ? \`\${this.resource}?\${query}\` : this.resource;
2807
2807
  return this.post<Select${Type}<TJsonb>>(url, data);
2808
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
+ /**
2809
2823
  * Create a new ${table.name} record
2810
2824
  * @param data - The data to insert
2811
- * @param options - Optional select/exclude for returned fields
2812
- * @returns The created record
2825
+ * @returns The created record with all fields
2813
2826
  */
2827
+ async create(data: Insert${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type}>;
2814
2828
  async create(
2815
2829
  data: Insert${Type},
2816
2830
  options?: { select?: string[]; exclude?: string[] }
@@ -2844,11 +2858,25 @@ ${hasJsonbColumns ? ` /**
2844
2858
  const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
2845
2859
  return this.get<Select${Type}<TJsonb> | null>(url);
2846
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
+ /**
2847
2875
  * Get a ${table.name} record by primary key
2848
2876
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
2849
- * @param options - Optional select/exclude for returned fields
2850
- * @returns The record if found, null otherwise
2877
+ * @returns The record with all fields if found, null otherwise
2851
2878
  */
2879
+ async getByPk(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
2852
2880
  async getByPk(
2853
2881
  pk: ${pkType},
2854
2882
  options?: { select?: string[]; exclude?: string[] }
@@ -2899,21 +2927,70 @@ ${hasJsonbColumns ? ` /**
2899
2927
  }): Promise<PaginatedResponse<(Select${Type}<TJsonb> | Partial<Select${Type}<TJsonb>>)${hasVectorColumns ? " & { _distance?: number }" : ""}>> {
2900
2928
  return this.post<PaginatedResponse<Select${Type}<TJsonb>${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
2901
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
+ /**
2902
2970
  * List ${table.name} records with pagination and filtering
2903
2971
  * @param params - Query parameters
2904
2972
  * @param params.where - Filter conditions using operators like $eq, $gt, $in, $like, etc.
2905
- * @param params.select - Array of field names to include in response
2906
- * @param params.exclude - Array of field names to exclude from response (mutually exclusive with select)
2907
2973
  * @param params.orderBy - Column(s) to sort by
2908
2974
  * @param params.order - Sort direction(s): "asc" or "desc"
2909
2975
  * @param params.limit - Maximum number of records to return (default: 50, max: 1000)
2910
2976
  * @param params.offset - Number of records to skip for pagination
2911
2977
  * @param params.include - Related records to include (see listWith* methods for typed includes)
2912
- * @returns Paginated results with data, total count, and hasMore flag
2913
- * @example
2914
- * // With select:
2915
- * const users = await client.list({ select: ['id', 'email'] });
2978
+ * @returns Paginated results with all fields
2916
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 }" : ""}>>;
2917
2994
  async list(params?: {
2918
2995
  include?: any;
2919
2996
  select?: string[];
@@ -2929,7 +3006,7 @@ ${hasJsonbColumns ? ` /**
2929
3006
  };` : ""}
2930
3007
  orderBy?: string | string[];
2931
3008
  order?: "asc" | "desc" | ("asc" | "desc")[];
2932
- }): Promise<PaginatedResponse<(Select${Type} | Partial<Select${Type}>)${hasVectorColumns ? " & { _distance?: number }" : ""}>> {
3009
+ }): Promise<PaginatedResponse<Select${Type} | Partial<Select${Type}>>> {
2933
3010
  return this.post<PaginatedResponse<Select${Type}${hasVectorColumns ? " & { _distance?: number }" : ""}>>(\`\${this.resource}/list\`, params ?? {});
2934
3011
  }`}
2935
3012
 
@@ -2956,12 +3033,28 @@ ${hasJsonbColumns ? ` /**
2956
3033
  const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
2957
3034
  return this.patch<Select${Type}<TJsonb> | null>(url, patch);
2958
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
+ /**
2959
3052
  * Update a ${table.name} record by primary key
2960
3053
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
2961
3054
  * @param patch - Partial data to update
2962
- * @param options - Optional select/exclude for returned fields
2963
- * @returns The updated record if found, null otherwise
3055
+ * @returns The updated record with all fields if found, null otherwise
2964
3056
  */
3057
+ async update(pk: ${pkType}, patch: Update${Type}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
2965
3058
  async update(
2966
3059
  pk: ${pkType},
2967
3060
  patch: Update${Type},
@@ -2997,11 +3090,25 @@ ${hasJsonbColumns ? ` /**
2997
3090
  const url = query ? \`\${this.resource}/\${path}?\${query}\` : \`\${this.resource}/\${path}\`;
2998
3091
  return this.del<Select${Type}<TJsonb> | null>(url);
2999
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
+ /**
3000
3107
  * Delete a ${table.name} record by primary key
3001
3108
  * @param pk - The primary key value${hasCompositePk ? "s" : ""}
3002
- * @param options - Optional select/exclude for returned fields
3003
- * @returns The deleted record if found, null otherwise
3109
+ * @returns The deleted record with all fields if found, null otherwise
3004
3110
  */
3111
+ async delete(pk: ${pkType}, options?: Omit<{ select?: string[]; exclude?: string[] }, 'select' | 'exclude'>): Promise<Select${Type} | null>;
3005
3112
  async delete(
3006
3113
  pk: ${pkType},
3007
3114
  options?: { select?: string[]; exclude?: string[] }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.18.3",
3
+ "version": "0.18.4",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {