@xata.io/client 0.16.2 → 0.17.0

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/index.d.ts CHANGED
@@ -3065,12 +3065,12 @@ interface XataRecord<OriginalRecord extends XataRecord<any> = XataRecord<any>> e
3065
3065
  /**
3066
3066
  * Retrieves a refreshed copy of the current record from the database.
3067
3067
  * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3068
- * @returns The persisted record with the selected columns.
3068
+ * @returns The persisted record with the selected columns, null if not found.
3069
3069
  */
3070
3070
  read<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
3071
3071
  /**
3072
3072
  * Retrieves a refreshed copy of the current record from the database.
3073
- * @returns The persisted record with all first level properties.
3073
+ * @returns The persisted record with all first level properties, null if not found.
3074
3074
  */
3075
3075
  read(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
3076
3076
  /**
@@ -3078,22 +3078,28 @@ interface XataRecord<OriginalRecord extends XataRecord<any> = XataRecord<any>> e
3078
3078
  * returned and the current object is not mutated.
3079
3079
  * @param partialUpdate The columns and their values that have to be updated.
3080
3080
  * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3081
- * @returns The persisted record with the selected columns.
3081
+ * @returns The persisted record with the selected columns, null if not found.
3082
3082
  */
3083
- update<K extends SelectableColumn<OriginalRecord>>(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>, columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>>>;
3083
+ update<K extends SelectableColumn<OriginalRecord>>(partialUpdate: Partial<EditableData<OriginalRecord>>, columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
3084
3084
  /**
3085
3085
  * Performs a partial update of the current record. On success a new object is
3086
3086
  * returned and the current object is not mutated.
3087
3087
  * @param partialUpdate The columns and their values that have to be updated.
3088
- * @returns The persisted record with all first level properties.
3088
+ * @returns The persisted record with all first level properties, null if not found.
3089
3089
  */
3090
- update(partialUpdate: Partial<EditableData<Omit<OriginalRecord, keyof XataRecord>>>): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>>>;
3090
+ update(partialUpdate: Partial<EditableData<OriginalRecord>>): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
3091
3091
  /**
3092
3092
  * Performs a deletion of the current record in the database.
3093
- *
3094
- * @throws If the record was already deleted or if an error happened while performing the deletion.
3093
+ * @param columns The columns to retrieve. If not specified, all first level properties are retrieved.
3094
+ * @returns The deleted record, null if not found.
3095
3095
  */
3096
- delete(): Promise<void>;
3096
+ delete<K extends SelectableColumn<OriginalRecord>>(columns: K[]): Promise<Readonly<SelectedPick<OriginalRecord, typeof columns>> | null>;
3097
+ /**
3098
+ * Performs a deletion of the current record in the database.
3099
+ * @returns The deleted record, null if not found.
3100
+
3101
+ */
3102
+ delete(): Promise<Readonly<SelectedPick<OriginalRecord, ['*']>> | null>;
3097
3103
  }
3098
3104
  declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update'> & {
3099
3105
  /**
@@ -3106,7 +3112,7 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
3106
3112
  * @param partialUpdate The columns and their values that have to be updated.
3107
3113
  * @returns A new record containing the latest values for all the columns of the current record.
3108
3114
  */
3109
- update<K extends SelectableColumn<Record>>(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>, columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>>>;
3115
+ update<K extends SelectableColumn<Record>>(partialUpdate: Partial<EditableData<Record>>, columns?: K[]): Promise<Readonly<SelectedPick<Record, typeof columns extends SelectableColumn<Record>[] ? typeof columns : ['*']>>>;
3110
3116
  /**
3111
3117
  * Performs a deletion of the current record in the database.
3112
3118
  *
@@ -3123,13 +3129,13 @@ declare type XataRecordMetadata = {
3123
3129
  };
3124
3130
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
3125
3131
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
3126
- declare type EditableData<O extends BaseData> = {
3132
+ declare type EditableData<O extends XataRecord> = Identifiable & Omit<{
3127
3133
  [K in keyof O]: O[K] extends XataRecord ? {
3128
3134
  id: string;
3129
3135
  } | string : NonNullable<O[K]> extends XataRecord ? {
3130
3136
  id: string;
3131
3137
  } | string | null | undefined : O[K];
3132
- };
3138
+ }, keyof XataRecord>;
3133
3139
 
3134
3140
  /**
3135
3141
  * PropertyMatchFilter
@@ -3280,7 +3286,7 @@ declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3280
3286
  [Model in ExtractTables<Schemas, Tables, GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>>]?: Awaited<SearchXataRecord<SelectedPick<Schemas[Model] & XataRecord, ['*']>>[]>;
3281
3287
  }>;
3282
3288
  };
3283
- declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3289
+ declare class SearchPlugin<Schemas extends Record<string, XataRecord>> extends XataPlugin {
3284
3290
  #private;
3285
3291
  private db;
3286
3292
  constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
@@ -3670,9 +3676,9 @@ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3670
3676
  /**
3671
3677
  * Common interface for performing operations on a table.
3672
3678
  */
3673
- declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
3674
- abstract create<K extends SelectableColumn<Record>>(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3675
- abstract create(object: Omit<EditableData<Data>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3679
+ declare abstract class Repository<Record extends XataRecord> extends Query<Record, Readonly<SelectedPick<Record, ['*']>>> {
3680
+ abstract create<K extends SelectableColumn<Record>>(object: Omit<EditableData<Record>, 'id'> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3681
+ abstract create(object: Omit<EditableData<Record>, 'id'> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3676
3682
  /**
3677
3683
  * Creates a single record in the table with a unique id.
3678
3684
  * @param id The unique id.
@@ -3680,27 +3686,27 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3680
3686
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3681
3687
  * @returns The full persisted record.
3682
3688
  */
3683
- abstract create<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3689
+ abstract create<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Record>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3684
3690
  /**
3685
3691
  * Creates a single record in the table with a unique id.
3686
3692
  * @param id The unique id.
3687
3693
  * @param object Object containing the column names with their values to be stored in the table.
3688
3694
  * @returns The full persisted record.
3689
3695
  */
3690
- abstract create(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3696
+ abstract create(id: string, object: Omit<EditableData<Record>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3691
3697
  /**
3692
3698
  * Creates multiple records in the table.
3693
3699
  * @param objects Array of objects with the column names and the values to be stored in the table.
3694
3700
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3695
3701
  * @returns Array of the persisted records in order.
3696
3702
  */
3697
- abstract create<K extends SelectableColumn<Record>>(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3703
+ abstract create<K extends SelectableColumn<Record>>(objects: Array<Omit<EditableData<Record>, 'id'> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3698
3704
  /**
3699
3705
  * Creates multiple records in the table.
3700
3706
  * @param objects Array of objects with the column names and the values to be stored in the table.
3701
3707
  * @returns Array of the persisted records in order.
3702
3708
  */
3703
- abstract create(objects: Array<Omit<EditableData<Data>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3709
+ abstract create(objects: Array<Omit<EditableData<Record>, 'id'> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3704
3710
  /**
3705
3711
  * Queries a single record from the table given its unique id.
3706
3712
  * @param id The unique id.
@@ -3757,43 +3763,43 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3757
3763
  * Partially update a single record.
3758
3764
  * @param object An object with its id and the columns to be updated.
3759
3765
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3760
- * @returns The full persisted record.
3766
+ * @returns The full persisted record, null if the record could not be found.
3761
3767
  */
3762
- abstract update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3768
+ abstract update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Record>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3763
3769
  /**
3764
3770
  * Partially update a single record.
3765
3771
  * @param object An object with its id and the columns to be updated.
3766
- * @returns The full persisted record.
3772
+ * @returns The full persisted record, null if the record could not be found.
3767
3773
  */
3768
- abstract update(object: Partial<EditableData<Data>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3774
+ abstract update(object: Partial<EditableData<Record>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3769
3775
  /**
3770
3776
  * Partially update a single record given its unique id.
3771
3777
  * @param id The unique id.
3772
3778
  * @param object The column names and their values that have to be updated.
3773
3779
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3774
- * @returns The full persisted record.
3780
+ * @returns The full persisted record, null if the record could not be found.
3775
3781
  */
3776
- abstract update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3782
+ abstract update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Record>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3777
3783
  /**
3778
3784
  * Partially update a single record given its unique id.
3779
3785
  * @param id The unique id.
3780
3786
  * @param object The column names and their values that have to be updated.
3781
- * @returns The full persisted record.
3787
+ * @returns The full persisted record, null if the record could not be found.
3782
3788
  */
3783
- abstract update(id: string, object: Partial<EditableData<Data>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3789
+ abstract update(id: string, object: Partial<EditableData<Record>>): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3784
3790
  /**
3785
3791
  * Partially updates multiple records.
3786
3792
  * @param objects An array of objects with their ids and columns to be updated.
3787
3793
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3788
- * @returns Array of the persisted records in order.
3794
+ * @returns Array of the persisted records in order (if a record could not be found null is returned).
3789
3795
  */
3790
- abstract update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3796
+ abstract update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3791
3797
  /**
3792
3798
  * Partially updates multiple records.
3793
3799
  * @param objects An array of objects with their ids and columns to be updated.
3794
- * @returns Array of the persisted records in order.
3800
+ * @returns Array of the persisted records in order (if a record could not be found null is returned).
3795
3801
  */
3796
- abstract update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3802
+ abstract update(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3797
3803
  /**
3798
3804
  * Creates or updates a single record. If a record exists with the given id,
3799
3805
  * it will be update, otherwise a new record will be created.
@@ -3801,14 +3807,14 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3801
3807
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3802
3808
  * @returns The full persisted record.
3803
3809
  */
3804
- abstract createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3810
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Record> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3805
3811
  /**
3806
3812
  * Creates or updates a single record. If a record exists with the given id,
3807
3813
  * it will be update, otherwise a new record will be created.
3808
3814
  * @param object Object containing the column names with their values to be persisted in the table.
3809
3815
  * @returns The full persisted record.
3810
3816
  */
3811
- abstract createOrUpdate(object: EditableData<Data> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3817
+ abstract createOrUpdate(object: EditableData<Record> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3812
3818
  /**
3813
3819
  * Creates or updates a single record. If a record exists with the given id,
3814
3820
  * it will be update, otherwise a new record will be created.
@@ -3817,7 +3823,7 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3817
3823
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3818
3824
  * @returns The full persisted record.
3819
3825
  */
3820
- abstract createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Data>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3826
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Record>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3821
3827
  /**
3822
3828
  * Creates or updates a single record. If a record exists with the given id,
3823
3829
  * it will be update, otherwise a new record will be created.
@@ -3825,7 +3831,7 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3825
3831
  * @param object The column names and the values to be persisted.
3826
3832
  * @returns The full persisted record.
3827
3833
  */
3828
- abstract createOrUpdate(id: string, object: Omit<EditableData<Data>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3834
+ abstract createOrUpdate(id: string, object: Omit<EditableData<Record>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3829
3835
  /**
3830
3836
  * Creates or updates a single record. If a record exists with the given id,
3831
3837
  * it will be update, otherwise a new record will be created.
@@ -3833,38 +3839,66 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3833
3839
  * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3834
3840
  * @returns Array of the persisted records.
3835
3841
  */
3836
- abstract createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Data> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3842
+ abstract createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Record> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3837
3843
  /**
3838
3844
  * Creates or updates a single record. If a record exists with the given id,
3839
3845
  * it will be update, otherwise a new record will be created.
3840
3846
  * @param objects Array of objects with the column names and the values to be stored in the table.
3841
3847
  * @returns Array of the persisted records.
3842
3848
  */
3843
- abstract createOrUpdate(objects: Array<EditableData<Data> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3849
+ abstract createOrUpdate(objects: Array<EditableData<Record> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3844
3850
  /**
3845
3851
  * Deletes a record given its unique id.
3846
- * @param id The unique id.
3847
- * @throws If the record could not be found or there was an error while performing the deletion.
3852
+ * @param object An object with a unique id.
3853
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3854
+ * @returns The deleted record, null if the record could not be found.
3848
3855
  */
3849
- abstract delete(id: string): Promise<void>;
3856
+ abstract delete<K extends SelectableColumn<Record>>(object: Identifiable & Partial<EditableData<Record>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3850
3857
  /**
3851
3858
  * Deletes a record given its unique id.
3852
- * @param id An object with a unique id.
3853
- * @throws If the record could not be found or there was an error while performing the deletion.
3859
+ * @param object An object with a unique id.
3860
+ * @returns The deleted record, null if the record could not be found.
3861
+ */
3862
+ abstract delete(object: Identifiable & Partial<EditableData<Record>>): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3863
+ /**
3864
+ * Deletes a record given a unique id.
3865
+ * @param id The unique id.
3866
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3867
+ * @returns The deleted record, null if the record could not be found.
3868
+ */
3869
+ abstract delete<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3870
+ /**
3871
+ * Deletes a record given a unique id.
3872
+ * @param id The unique id.
3873
+ * @returns The deleted record, null if the record could not be found.
3874
+ */
3875
+ abstract delete(id: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3876
+ /**
3877
+ * Deletes multiple records given an array of objects with ids.
3878
+ * @param objects An array of objects with unique ids.
3879
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3880
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3854
3881
  */
3855
- abstract delete(id: Identifiable): Promise<void>;
3882
+ abstract delete<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3856
3883
  /**
3857
- * Deletes a record given a list of unique ids.
3858
- * @param ids The array of unique ids.
3859
- * @throws If the record could not be found or there was an error while performing the deletion.
3884
+ * Deletes multiple records given an array of objects with ids.
3885
+ * @param objects An array of objects with unique ids.
3886
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3887
+ */
3888
+ abstract delete(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3889
+ /**
3890
+ * Deletes multiple records given an array of unique ids.
3891
+ * @param objects An array of ids.
3892
+ * @param columns Array of columns to be returned. If not specified, first level columns will be returned.
3893
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3860
3894
  */
3861
- abstract delete(ids: string[]): Promise<void>;
3895
+ abstract delete<K extends SelectableColumn<Record>>(objects: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3862
3896
  /**
3863
- * Deletes a record given a list of unique ids.
3864
- * @param ids An array of objects with unique ids.
3865
- * @throws If the record could not be found or there was an error while performing the deletion.
3897
+ * Deletes multiple records given an array of unique ids.
3898
+ * @param objects An array of ids.
3899
+ * @returns Array of the deleted records in order (if a record could not be found null is returned).
3866
3900
  */
3867
- abstract delete(ids: Identifiable[]): Promise<void>;
3901
+ abstract delete(objects: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3868
3902
  /**
3869
3903
  * Search for records in the table.
3870
3904
  * @param query The query to search for.
@@ -3880,7 +3914,7 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3880
3914
  }): Promise<SearchXataRecord<SelectedPick<Record, ['*']>>[]>;
3881
3915
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3882
3916
  }
3883
- declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
3917
+ declare class RestRepository<Record extends XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Record> {
3884
3918
  #private;
3885
3919
  constructor(options: {
3886
3920
  table: string;
@@ -3888,33 +3922,40 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3888
3922
  pluginOptions: XataPluginOptions;
3889
3923
  schemaTables?: Table[];
3890
3924
  });
3891
- create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3892
- create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3893
- create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3894
- create<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3895
- create<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3896
- create<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3897
- read(recordId: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3898
- read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3899
- read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3900
- read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3901
- read<K extends SelectableColumn<Record>>(recordId: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3902
- read<K extends SelectableColumn<Record>>(recordIds: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
3903
- read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3904
- read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>>>>;
3905
- update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3906
- update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3907
- update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
3908
- update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Data>> & Identifiable, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3909
- update<K extends SelectableColumn<Record>>(recordId: string, object: Partial<EditableData<Data>>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3910
- update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Data>> & Identifiable>, columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
3911
- createOrUpdate(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3912
- createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3913
- createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3914
- createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3915
- createOrUpdate<K extends SelectableColumn<Record>>(recordId: string, object: EditableData<Data>, columns: K[]): Promise<SelectedPick<Record, typeof columns>>;
3916
- createOrUpdate<K extends SelectableColumn<Record>>(objects: EditableData<Data>[], columns: K[]): Promise<SelectedPick<Record, typeof columns>[]>;
3917
- delete(a: string | Identifiable | Array<string | Identifiable>): Promise<void>;
3925
+ create<K extends SelectableColumn<Record>>(object: EditableData<Record> & Partial<Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3926
+ create(object: EditableData<Record> & Partial<Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3927
+ create<K extends SelectableColumn<Record>>(id: string, object: EditableData<Record>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3928
+ create(id: string, object: EditableData<Record>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3929
+ create<K extends SelectableColumn<Record>>(objects: Array<EditableData<Record> & Partial<Identifiable>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3930
+ create(objects: Array<EditableData<Record> & Partial<Identifiable>>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3931
+ read<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3932
+ read(id: string): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3933
+ read<K extends SelectableColumn<Record>>(ids: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3934
+ read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3935
+ read<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns> | null>>;
3936
+ read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3937
+ read<K extends SelectableColumn<Record>>(objects: Identifiable[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3938
+ read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3939
+ update<K extends SelectableColumn<Record>>(object: Partial<EditableData<Record>> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3940
+ update(object: Partial<EditableData<Record>> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3941
+ update<K extends SelectableColumn<Record>>(id: string, object: Partial<EditableData<Record>>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3942
+ update(id: string, object: Partial<EditableData<Record>>): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3943
+ update<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3944
+ update(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3945
+ createOrUpdate<K extends SelectableColumn<Record>>(object: EditableData<Record> & Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3946
+ createOrUpdate(object: EditableData<Record> & Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3947
+ createOrUpdate<K extends SelectableColumn<Record>>(id: string, object: Omit<EditableData<Record>, 'id'>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>>;
3948
+ createOrUpdate(id: string, object: Omit<EditableData<Record>, 'id'>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3949
+ createOrUpdate<K extends SelectableColumn<Record>>(objects: Array<EditableData<Record> & Identifiable>, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>>[]>;
3950
+ createOrUpdate(objects: Array<EditableData<Record> & Identifiable>): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3951
+ delete<K extends SelectableColumn<Record>>(object: Identifiable, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3952
+ delete(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3953
+ delete<K extends SelectableColumn<Record>>(id: string, columns: K[]): Promise<Readonly<SelectedPick<Record, typeof columns>> | null>;
3954
+ delete(id: string): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
3955
+ delete<K extends SelectableColumn<Record>>(objects: Array<Partial<EditableData<Record>> & Identifiable>, columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3956
+ delete(objects: Array<Partial<EditableData<Record>> & Identifiable>): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3957
+ delete<K extends SelectableColumn<Record>>(objects: string[], columns: K[]): Promise<Array<Readonly<SelectedPick<Record, typeof columns>> | null>>;
3958
+ delete(objects: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>> | null>>;
3918
3959
  search(query: string, options?: {
3919
3960
  fuzziness?: FuzzinessExpression;
3920
3961
  prefix?: PrefixExpression;
@@ -4082,12 +4123,12 @@ declare const includesAny: <T>(value: T) => ArrayFilter<T>;
4082
4123
  declare type SchemaDefinition = {
4083
4124
  table: string;
4084
4125
  };
4085
- declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
4126
+ declare type SchemaPluginResult<Schemas extends Record<string, XataRecord>> = {
4086
4127
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
4087
4128
  } & {
4088
- [key: string]: Repository<XataRecord$1>;
4129
+ [key: string]: Repository<XataRecord>;
4089
4130
  };
4090
- declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
4131
+ declare class SchemaPlugin<Schemas extends Record<string, XataRecord>> extends XataPlugin {
4091
4132
  #private;
4092
4133
  constructor(schemaTables?: Schemas.Table[]);
4093
4134
  build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
@@ -4108,9 +4149,9 @@ declare type BaseClientOptions = {
4108
4149
  };
4109
4150
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
4110
4151
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
4111
- new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
4112
- db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
4113
- search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
4152
+ new <Schemas extends Record<string, XataRecord> = {}>(options?: Partial<BaseClientOptions>, schemaTables?: readonly BaseSchema[]): Omit<{
4153
+ db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
4154
+ search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
4114
4155
  }, keyof Plugins> & {
4115
4156
  [Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
4116
4157
  } & {
@@ -4121,7 +4162,7 @@ interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
4121
4162
  };
4122
4163
  }
4123
4164
  declare const BaseClient_base: ClientConstructor<{}>;
4124
- declare class BaseClient extends BaseClient_base<[]> {
4165
+ declare class BaseClient extends BaseClient_base<Record<string, any>> {
4125
4166
  }
4126
4167
 
4127
4168
  declare class Serializer {
package/dist/index.mjs CHANGED
@@ -152,7 +152,7 @@ function getFetchImplementation(userFetch) {
152
152
  return fetchImpl;
153
153
  }
154
154
 
155
- const VERSION = "0.16.2";
155
+ const VERSION = "0.17.0";
156
156
 
157
157
  class ErrorWithCause extends Error {
158
158
  constructor(message, options) {
@@ -1448,16 +1448,16 @@ class RestRepository extends Query {
1448
1448
  if (Array.isArray(a)) {
1449
1449
  if (a.length === 0)
1450
1450
  return [];
1451
- const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1452
- const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1451
+ const ids = a.map((item) => extractId(item));
1452
+ const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
1453
1453
  const dictionary = finalObjects.reduce((acc, object) => {
1454
1454
  acc[object.id] = object;
1455
1455
  return acc;
1456
1456
  }, {});
1457
- return ids.map((id2) => dictionary[id2] ?? null);
1457
+ return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
1458
1458
  }
1459
- const id = isString(a) ? a : a.id;
1460
- if (isString(id)) {
1459
+ const id = extractId(a);
1460
+ if (id) {
1461
1461
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1462
1462
  try {
1463
1463
  const response = await getRecord({
@@ -1526,24 +1526,21 @@ class RestRepository extends Query {
1526
1526
  throw new Error("Invalid arguments for createOrUpdate method");
1527
1527
  });
1528
1528
  }
1529
- async delete(a) {
1529
+ async delete(a, b) {
1530
1530
  return __privateGet$4(this, _trace).call(this, "delete", async () => {
1531
1531
  if (Array.isArray(a)) {
1532
1532
  if (a.length === 0)
1533
- return;
1533
+ return [];
1534
1534
  if (a.length > 100) {
1535
1535
  console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1536
1536
  }
1537
- await Promise.all(a.map((id) => this.delete(id)));
1538
- return;
1537
+ return Promise.all(a.map((id) => this.delete(id, b)));
1539
1538
  }
1540
1539
  if (isString(a)) {
1541
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1542
- return;
1540
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
1543
1541
  }
1544
1542
  if (isObject(a) && isString(a.id)) {
1545
- await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1546
- return;
1543
+ return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
1547
1544
  }
1548
1545
  throw new Error("Invalid arguments for delete method");
1549
1546
  });
@@ -1653,14 +1650,21 @@ _updateRecordWithID = new WeakSet();
1653
1650
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1654
1651
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1655
1652
  const record = transformObjectLinks(object);
1656
- const response = await updateRecordWithID({
1657
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1658
- queryParams: { columns },
1659
- body: record,
1660
- ...fetchProps
1661
- });
1662
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1663
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1653
+ try {
1654
+ const response = await updateRecordWithID({
1655
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1656
+ queryParams: { columns },
1657
+ body: record,
1658
+ ...fetchProps
1659
+ });
1660
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1661
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1662
+ } catch (e) {
1663
+ if (isObject(e) && e.status === 404) {
1664
+ return null;
1665
+ }
1666
+ throw e;
1667
+ }
1664
1668
  };
1665
1669
  _upsertRecordWithID = new WeakSet();
1666
1670
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1675,12 +1679,22 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1675
1679
  return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1676
1680
  };
1677
1681
  _deleteRecord = new WeakSet();
1678
- deleteRecord_fn = async function(recordId) {
1682
+ deleteRecord_fn = async function(recordId, columns = ["*"]) {
1679
1683
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1680
- await deleteRecord({
1681
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1682
- ...fetchProps
1683
- });
1684
+ try {
1685
+ const response = await deleteRecord({
1686
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1687
+ queryParams: { columns },
1688
+ ...fetchProps
1689
+ });
1690
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1691
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1692
+ } catch (e) {
1693
+ if (isObject(e) && e.status === 404) {
1694
+ return null;
1695
+ }
1696
+ throw e;
1697
+ }
1684
1698
  };
1685
1699
  _setCacheQuery = new WeakSet();
1686
1700
  setCacheQuery_fn = async function(query, meta, records) {
@@ -1768,6 +1782,13 @@ const initObject = (db, schemaTables, table, object) => {
1768
1782
  function isResponseWithRecords(value) {
1769
1783
  return isObject(value) && Array.isArray(value.records);
1770
1784
  }
1785
+ function extractId(value) {
1786
+ if (isString(value))
1787
+ return value;
1788
+ if (isObject(value) && isString(value.id))
1789
+ return value.id;
1790
+ return void 0;
1791
+ }
1771
1792
 
1772
1793
  var __accessCheck$3 = (obj, member, msg) => {
1773
1794
  if (!member.has(obj))