@xata.io/client 0.0.0-alpha.vfb4479d → 0.0.0-alpha.vfbac5b5

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
@@ -6,6 +6,9 @@ declare type FetchImpl = (url: string, init?: {
6
6
  ok: boolean;
7
7
  status: number;
8
8
  json(): Promise<any>;
9
+ headers?: {
10
+ get(name: string): string | null;
11
+ };
9
12
  }>;
10
13
  declare type WorkspaceApiUrlBuilder = (path: string, pathParams: Record<string, string>) => string;
11
14
  declare type FetcherExtraProps = {
@@ -279,6 +282,10 @@ declare type SortOrder = 'asc' | 'desc';
279
282
  * @minimum 0
280
283
  */
281
284
  declare type FuzzinessExpression = number;
285
+ /**
286
+ * If the prefix type is set to "disabled" (the default), the search only matches full words. If the prefix type is set to "phrase", the search will return results that match prefixes of the search phrase.
287
+ */
288
+ declare type PrefixExpression = 'phrase' | 'disabled';
282
289
  /**
283
290
  * @minProperties 1
284
291
  */
@@ -430,6 +437,7 @@ type schemas_ColumnMigration = ColumnMigration;
430
437
  type schemas_SortExpression = SortExpression;
431
438
  type schemas_SortOrder = SortOrder;
432
439
  type schemas_FuzzinessExpression = FuzzinessExpression;
440
+ type schemas_PrefixExpression = PrefixExpression;
433
441
  type schemas_FilterExpression = FilterExpression;
434
442
  type schemas_HighlightExpression = HighlightExpression;
435
443
  type schemas_FilterList = FilterList;
@@ -485,6 +493,7 @@ declare namespace schemas {
485
493
  schemas_SortExpression as SortExpression,
486
494
  schemas_SortOrder as SortOrder,
487
495
  schemas_FuzzinessExpression as FuzzinessExpression,
496
+ schemas_PrefixExpression as PrefixExpression,
488
497
  schemas_FilterExpression as FilterExpression,
489
498
  schemas_HighlightExpression as HighlightExpression,
490
499
  schemas_FilterList as FilterList,
@@ -2622,6 +2631,7 @@ declare type SearchTableError = ErrorWrapper<{
2622
2631
  declare type SearchTableRequestBody = {
2623
2632
  query: string;
2624
2633
  fuzziness?: FuzzinessExpression;
2634
+ prefix?: PrefixExpression;
2625
2635
  filter?: FilterExpression;
2626
2636
  highlight?: HighlightExpression;
2627
2637
  };
@@ -2798,7 +2808,7 @@ declare class DatabaseApi {
2798
2808
  getGitBranchesMapping(workspace: WorkspaceID, dbName: DBName): Promise<ListGitBranchesResponse>;
2799
2809
  addGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, body: AddGitBranchesEntryRequestBody): Promise<AddGitBranchesEntryResponse>;
2800
2810
  removeGitBranchesEntry(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<void>;
2801
- resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch: string): Promise<ResolveBranchResponse>;
2811
+ resolveBranch(workspace: WorkspaceID, dbName: DBName, gitBranch?: string, fallbackBranch?: string): Promise<ResolveBranchResponse>;
2802
2812
  }
2803
2813
  declare class BranchApi {
2804
2814
  private extraProps;
@@ -2867,25 +2877,24 @@ declare type SelectableColumn<O, RecursivePath extends any[] = []> = '*' | 'id'
2867
2877
  declare type SelectedPick<O extends XataRecord, Key extends SelectableColumn<O>[]> = XataRecord & UnionToIntersection<Values<{
2868
2878
  [K in Key[number]]: NestedValueAtColumn<O, K> & XataRecord;
2869
2879
  }>>;
2870
- declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<RemoveNullable<O[K]> extends Record<string, any> ? V extends SelectableColumn<RemoveNullable<O[K]>> ? {
2871
- V: ValueAtColumn<RemoveNullable<O[K]>, V>;
2872
- } : never : O[K]> : never : never;
2880
+ declare type ValueAtColumn<O, P extends SelectableColumn<O>> = P extends '*' ? Values<O> : P extends 'id' ? string : P extends keyof O ? O[P] : P extends `${infer K}.${infer V}` ? K extends keyof O ? Values<NonNullable<O[K]> extends infer Item ? Item extends Record<string, any> ? V extends SelectableColumn<Item> ? {
2881
+ V: ValueAtColumn<Item, V>;
2882
+ } : never : O[K] : never> : never : never;
2873
2883
  declare type MAX_RECURSION = 5;
2874
2884
  declare type NestedColumns<O, RecursivePath extends any[]> = RecursivePath['length'] extends MAX_RECURSION ? never : If<IsObject<O>, Values<{
2875
- [K in DataProps<O>]: If<IsArray<RemoveNullable<O[K]>>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
2876
- If<IsObject<RemoveNullable<O[K]>>, RemoveNullable<O[K]> extends XataRecord ? SelectableColumn<RemoveNullable<O[K]>, [...RecursivePath, O[K]]> extends string ? K | `${K}.${SelectableColumn<RemoveNullable<O[K]>, [...RecursivePath, O[K]]>}` : never : `${K}.${StringKeys<RemoveNullable<O[K]>> | '*'}`, // This allows usage of objects that are not links
2877
- K>>;
2885
+ [K in DataProps<O>]: NonNullable<O[K]> extends infer Item ? If<IsArray<Item>, K, // If the property is an array, we stop recursion. We don't support object arrays yet
2886
+ If<IsObject<Item>, Item extends XataRecord ? SelectableColumn<Item, [...RecursivePath, Item]> extends infer Column ? Column extends string ? K | `${K}.${Column}` : never : never : Item extends Date ? K : `${K}.${StringKeys<Item> | '*'}`, // This allows usage of objects that are not links
2887
+ K>> : never;
2878
2888
  }>, never>;
2879
2889
  declare type DataProps<O> = Exclude<StringKeys<O>, StringKeys<XataRecord>>;
2880
2890
  declare type NestedValueAtColumn<O, Key extends SelectableColumn<O>> = Key extends `${infer N}.${infer M}` ? N extends DataProps<O> ? {
2881
- [K in N]: M extends SelectableColumn<RemoveNullable<O[K]>> ? RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<RemoveNullable<O[K]>, M>> : unknown;
2891
+ [K in N]: M extends SelectableColumn<NonNullable<O[K]>> ? NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], NestedValueAtColumn<NonNullable<O[K]>, M> & XataRecord> : ForwardNullable<O[K], NestedValueAtColumn<NonNullable<O[K]>, M>> : unknown;
2882
2892
  } : unknown : Key extends DataProps<O> ? {
2883
- [K in Key]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<RemoveNullable<O[K]>, ['*']>> : O[K];
2893
+ [K in Key]: NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], SelectedPick<NonNullable<O[K]>, ['*']>> : O[K];
2884
2894
  } : Key extends '*' ? {
2885
- [K in StringKeys<O>]: RemoveNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<RemoveNullable<O[K]>>> : O[K];
2895
+ [K in StringKeys<O>]: NonNullable<O[K]> extends XataRecord ? ForwardNullable<O[K], Link<NonNullable<O[K]>>> : O[K];
2886
2896
  } : unknown;
2887
- declare type RemoveNullable<T> = T extends null | undefined ? never : T;
2888
- declare type ForwardNullable<T, R> = T extends RemoveNullable<T> ? R : R | null;
2897
+ declare type ForwardNullable<T, R> = T extends NonNullable<T> ? R : R | null;
2889
2898
 
2890
2899
  /**
2891
2900
  * Represents an identifiable record from the database.
@@ -2902,16 +2911,11 @@ interface BaseData {
2902
2911
  /**
2903
2912
  * Represents a persisted record from the database.
2904
2913
  */
2905
- interface XataRecord extends Identifiable {
2914
+ interface XataRecord<ExtraMetadata extends Record<string, unknown> = Record<string, unknown>> extends Identifiable {
2906
2915
  /**
2907
- * Metadata of this record.
2916
+ * Get metadata of this record.
2908
2917
  */
2909
- xata: {
2910
- /**
2911
- * Number that is increased every time the record is updated.
2912
- */
2913
- version: number;
2914
- };
2918
+ getMetadata(): XataRecordMetadata & ExtraMetadata;
2915
2919
  /**
2916
2920
  * Retrieves a refreshed copy of the current record from the database.
2917
2921
  */
@@ -2919,7 +2923,7 @@ interface XataRecord extends Identifiable {
2919
2923
  /**
2920
2924
  * Performs a partial update of the current record. On success a new object is
2921
2925
  * returned and the current object is not mutated.
2922
- * @param data The columns and their values that have to be updated.
2926
+ * @param partialUpdate The columns and their values that have to be updated.
2923
2927
  * @returns A new record containing the latest values for all the columns of the current record.
2924
2928
  */
2925
2929
  update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
@@ -2938,19 +2942,26 @@ declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' | 'update
2938
2942
  /**
2939
2943
  * Performs a partial update of the current record. On success a new object is
2940
2944
  * returned and the current object is not mutated.
2941
- * @param data The columns and their values that have to be updated.
2945
+ * @param partialUpdate The columns and their values that have to be updated.
2942
2946
  * @returns A new record containing the latest values for all the columns of the current record.
2943
2947
  */
2944
2948
  update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
2945
2949
  };
2950
+ declare type XataRecordMetadata = {
2951
+ /**
2952
+ * Number that is increased every time the record is updated.
2953
+ */
2954
+ version: number;
2955
+ warnings?: string[];
2956
+ };
2946
2957
  declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
2947
2958
  declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
2948
2959
  declare type EditableData<O extends BaseData> = {
2949
2960
  [K in keyof O]: O[K] extends XataRecord ? {
2950
2961
  id: string;
2951
- } : NonNullable<O[K]> extends XataRecord ? {
2962
+ } | string : NonNullable<O[K]> extends XataRecord ? {
2952
2963
  id: string;
2953
- } | null | undefined : O[K];
2964
+ } | string | null | undefined : O[K];
2954
2965
  };
2955
2966
 
2956
2967
  /**
@@ -3081,7 +3092,7 @@ declare type QueryOptions<T extends XataRecord> = BaseOptions<T> & (CursorQueryO
3081
3092
  declare class Query<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
3082
3093
  #private;
3083
3094
  readonly meta: PaginationQueryMeta;
3084
- readonly records: Result[];
3095
+ readonly records: RecordArray<Result>;
3085
3096
  constructor(repository: Repository<Record> | null, table: string, data: Partial<QueryOptions<Record>>, rawParent?: Partial<QueryOptions<Record>>);
3086
3097
  getQueryOptions(): QueryOptions<Record>;
3087
3098
  key(): string;
@@ -3204,19 +3215,19 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
3204
3215
  * Performs the query in the database and returns a set of results.
3205
3216
  * @returns An array of records from the database.
3206
3217
  */
3207
- getMany(): Promise<Result[]>;
3218
+ getMany(): Promise<RecordArray<Result>>;
3208
3219
  /**
3209
3220
  * Performs the query in the database and returns a set of results.
3210
3221
  * @param options Additional options to be used when performing the query.
3211
3222
  * @returns An array of records from the database.
3212
3223
  */
3213
- getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<Result[]>;
3224
+ getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<RecordArray<SelectedPick<Record, typeof options['columns']>>>;
3214
3225
  /**
3215
3226
  * Performs the query in the database and returns a set of results.
3216
3227
  * @param options Additional options to be used when performing the query.
3217
3228
  * @returns An array of records from the database.
3218
3229
  */
3219
- getMany<Options extends RequiredBy<QueryOptions<Record>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3230
+ getMany(options: OmitBy<QueryOptions<Record>, 'columns'>): Promise<RecordArray<Result>>;
3220
3231
  /**
3221
3232
  * Performs the query in the database and returns all the results.
3222
3233
  * Warning: If there are a large number of results, this method can have performance implications.
@@ -3229,18 +3240,18 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
3229
3240
  * @param options Additional options to be used when performing the query.
3230
3241
  * @returns An array of records from the database.
3231
3242
  */
3232
- getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3243
+ getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3233
3244
  batchSize?: number;
3234
- }): Promise<Result[]>;
3245
+ }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3235
3246
  /**
3236
3247
  * Performs the query in the database and returns all the results.
3237
3248
  * Warning: If there are a large number of results, this method can have performance implications.
3238
3249
  * @param options Additional options to be used when performing the query.
3239
3250
  * @returns An array of records from the database.
3240
3251
  */
3241
- getAll<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'> & {
3252
+ getAll(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'> & {
3242
3253
  batchSize?: number;
3243
- }>(options: Options): Promise<SelectedPick<Record, typeof options['columns']>[]>;
3254
+ }): Promise<Result[]>;
3244
3255
  /**
3245
3256
  * Performs the query in the database and returns the first result.
3246
3257
  * @returns The first record that matches the query, or null if no record matched the query.
@@ -3251,13 +3262,13 @@ declare class Query<Record extends XataRecord, Result extends XataRecord = Recor
3251
3262
  * @param options Additional options to be used when performing the query.
3252
3263
  * @returns The first record that matches the query, or null if no record matched the query.
3253
3264
  */
3254
- getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3265
+ getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3255
3266
  /**
3256
3267
  * Performs the query in the database and returns the first result.
3257
3268
  * @param options Additional options to be used when performing the query.
3258
3269
  * @returns The first record that matches the query, or null if no record matched the query.
3259
3270
  */
3260
- getFirst<Options extends RequiredBy<OmitBy<QueryOptions<Record>, 'pagination'>, 'columns'>>(options: Options): Promise<SelectedPick<Record, typeof options['columns']> | null>;
3271
+ getFirst(options: OmitBy<QueryOptions<Record>, 'columns' | 'pagination'>): Promise<Result | null>;
3261
3272
  /**
3262
3273
  * Builds a new query object adding a cache TTL in milliseconds.
3263
3274
  * @param ttl The cache TTL in milliseconds.
@@ -3302,7 +3313,7 @@ declare type PaginationQueryMeta = {
3302
3313
  };
3303
3314
  interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
3304
3315
  meta: PaginationQueryMeta;
3305
- records: Result[];
3316
+ records: RecordArray<Result>;
3306
3317
  nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3307
3318
  previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
3308
3319
  firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
@@ -3322,7 +3333,7 @@ declare class Page<Record extends XataRecord, Result extends XataRecord = Record
3322
3333
  /**
3323
3334
  * The set of results for this page.
3324
3335
  */
3325
- readonly records: Result[];
3336
+ readonly records: RecordArray<Result>;
3326
3337
  constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
3327
3338
  /**
3328
3339
  * Retrieves the next page of results.
@@ -3371,10 +3382,45 @@ declare type OffsetNavigationOptions = {
3371
3382
  offset?: number;
3372
3383
  };
3373
3384
  declare const PAGINATION_MAX_SIZE = 200;
3374
- declare const PAGINATION_DEFAULT_SIZE = 200;
3385
+ declare const PAGINATION_DEFAULT_SIZE = 20;
3375
3386
  declare const PAGINATION_MAX_OFFSET = 800;
3376
3387
  declare const PAGINATION_DEFAULT_OFFSET = 0;
3377
3388
  declare function isCursorPaginationOptions(options: Record<string, unknown> | undefined | null): options is CursorNavigationOptions;
3389
+ declare class RecordArray<Result extends XataRecord> extends Array<Result> {
3390
+ #private;
3391
+ constructor(page: Paginable<any, Result>, overrideRecords?: Result[]);
3392
+ static parseConstructorParams(...args: any[]): any[];
3393
+ toArray(): Result[];
3394
+ map<U>(callbackfn: (value: Result, index: number, array: Result[]) => U, thisArg?: any): U[];
3395
+ /**
3396
+ * Retrieve next page of records
3397
+ *
3398
+ * @returns A new array of objects
3399
+ */
3400
+ nextPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3401
+ /**
3402
+ * Retrieve previous page of records
3403
+ *
3404
+ * @returns A new array of objects
3405
+ */
3406
+ previousPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3407
+ /**
3408
+ * Retrieve first page of records
3409
+ *
3410
+ * @returns A new array of objects
3411
+ */
3412
+ firstPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3413
+ /**
3414
+ * Retrieve last page of records
3415
+ *
3416
+ * @returns A new array of objects
3417
+ */
3418
+ lastPage(size?: number, offset?: number): Promise<RecordArray<Result>>;
3419
+ /**
3420
+ * @returns Boolean indicating if there is a next page
3421
+ */
3422
+ hasNextPage(): boolean;
3423
+ }
3378
3424
 
3379
3425
  /**
3380
3426
  * Common interface for performing operations on a table.
@@ -3406,6 +3452,18 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
3406
3452
  * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3407
3453
  */
3408
3454
  abstract read(ids: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3455
+ /**
3456
+ * Queries a single record from the table by the id in the object.
3457
+ * @param object Object containing the id of the record.
3458
+ * @returns The persisted record for the given id or null if the record could not be found.
3459
+ */
3460
+ abstract read(object: Identifiable): Promise<Readonly<SelectedPick<Record, ['*']> | null>>;
3461
+ /**
3462
+ * Queries multiple records from the table by the ids in the objects.
3463
+ * @param objects Array of objects containing the ids of the records.
3464
+ * @returns The persisted records for the given ids (if a record could not be found it is not returned).
3465
+ */
3466
+ abstract read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3409
3467
  /**
3410
3468
  * Partially update a single record.
3411
3469
  * @param object An object with its id and the columns to be updated.
@@ -3491,12 +3549,15 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3491
3549
  table: string;
3492
3550
  db: SchemaPluginResult<any>;
3493
3551
  pluginOptions: XataPluginOptions;
3552
+ schemaTables?: Table[];
3494
3553
  });
3495
- create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3496
- create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
3497
- create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
3554
+ create(object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3555
+ create(recordId: string, object: EditableData<Data>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
3556
+ create(objects: EditableData<Data>[]): Promise<Readonly<SelectedPick<Record, ['*']>>[]>;
3498
3557
  read(recordId: string): Promise<SelectedPick<Record, ['*']> | null>;
3499
3558
  read(recordIds: string[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3559
+ read(object: Identifiable): Promise<SelectedPick<Record, ['*']> | null>;
3560
+ read(objects: Identifiable[]): Promise<Array<Readonly<SelectedPick<Record, ['*']>>>>;
3500
3561
  update(object: Partial<EditableData<Data>> & Identifiable): Promise<SelectedPick<Record, ['*']>>;
3501
3562
  update(recordId: string, object: Partial<EditableData<Data>>): Promise<SelectedPick<Record, ['*']>>;
3502
3563
  update(objects: Array<Partial<EditableData<Data>> & Identifiable>): Promise<SelectedPick<Record, ['*']>[]>;
@@ -3512,6 +3573,59 @@ declare class RestRepository<Data extends BaseData, Record extends XataRecord =
3512
3573
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
3513
3574
  }
3514
3575
 
3576
+ declare type BaseSchema = {
3577
+ name: string;
3578
+ columns: readonly ({
3579
+ name: string;
3580
+ type: Column['type'];
3581
+ } | {
3582
+ name: string;
3583
+ type: 'link';
3584
+ link: {
3585
+ table: string;
3586
+ };
3587
+ } | {
3588
+ name: string;
3589
+ type: 'object';
3590
+ columns: {
3591
+ name: string;
3592
+ type: string;
3593
+ }[];
3594
+ })[];
3595
+ };
3596
+ declare type SchemaInference<T extends readonly BaseSchema[]> = T extends never[] ? Record<string, Record<string, any>> : T extends readonly unknown[] ? T[number] extends {
3597
+ name: string;
3598
+ columns: readonly unknown[];
3599
+ } ? {
3600
+ [K in T[number]['name']]: TableType<T[number], K>;
3601
+ } : never : never;
3602
+ declare type TableType<Tables, TableName> = Tables & {
3603
+ name: TableName;
3604
+ } extends infer Table ? Table extends {
3605
+ name: string;
3606
+ columns: infer Columns;
3607
+ } ? Columns extends readonly unknown[] ? Columns[number] extends {
3608
+ name: string;
3609
+ type: string;
3610
+ } ? Identifiable & {
3611
+ [K in Columns[number]['name']]?: PropertyType<Tables, Columns[number], K>;
3612
+ } : never : never : never : never;
3613
+ declare type PropertyType<Tables, Properties, PropertyName> = Properties & {
3614
+ name: PropertyName;
3615
+ } extends infer Property ? Property extends {
3616
+ name: string;
3617
+ type: infer Type;
3618
+ link?: {
3619
+ table: infer LinkedTable;
3620
+ };
3621
+ columns?: infer ObjectColumns;
3622
+ } ? (Type extends 'string' | 'text' | 'email' ? string : Type extends 'int' | 'float' ? number : Type extends 'bool' ? boolean : Type extends 'datetime' ? Date : Type extends 'multiple' ? string[] : Type extends 'object' ? ObjectColumns extends readonly unknown[] ? ObjectColumns[number] extends {
3623
+ name: string;
3624
+ type: string;
3625
+ } ? {
3626
+ [K in ObjectColumns[number]['name']]?: PropertyType<Tables, ObjectColumns[number], K>;
3627
+ } : never : never : Type extends 'link' ? TableType<Tables, LinkedTable> & XataRecord : never) | null : never : never;
3628
+
3515
3629
  /**
3516
3630
  * Operator to restrict results to only values that are greater than the given value.
3517
3631
  */
@@ -3595,8 +3709,7 @@ declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
3595
3709
  };
3596
3710
  declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3597
3711
  #private;
3598
- private tableNames?;
3599
- constructor(tableNames?: string[] | undefined);
3712
+ constructor(schemaTables?: Schemas.Table[]);
3600
3713
  build(pluginOptions: XataPluginOptions): SchemaPluginResult<Schemas>;
3601
3714
  }
3602
3715
 
@@ -3624,16 +3737,15 @@ declare type SearchPluginResult<Schemas extends Record<string, BaseData>> = {
3624
3737
  declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
3625
3738
  #private;
3626
3739
  private db;
3627
- constructor(db: SchemaPluginResult<Schemas>);
3740
+ constructor(db: SchemaPluginResult<Schemas>, schemaTables?: Schemas.Table[]);
3628
3741
  build({ getFetchProps }: XataPluginOptions): SearchPluginResult<Schemas>;
3629
3742
  }
3630
- declare type SearchXataRecord = XataRecord & {
3631
- xata: {
3632
- table?: string;
3633
- highlight?: {
3634
- [key: string]: string[] | {
3635
- [key: string]: any;
3636
- };
3743
+ declare type SearchXataRecord = XataRecord<SearchExtraProperties>;
3744
+ declare type SearchExtraProperties = {
3745
+ table: string;
3746
+ highlight?: {
3747
+ [key: string]: string[] | {
3748
+ [key: string]: any;
3637
3749
  };
3638
3750
  };
3639
3751
  };
@@ -3656,15 +3768,15 @@ declare type BaseClientOptions = {
3656
3768
  };
3657
3769
  declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
3658
3770
  interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
3659
- new <Schemas extends Record<string, BaseData> = {}>(options?: Partial<BaseClientOptions>, tables?: string[]): Omit<{
3660
- db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
3661
- search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
3771
+ new <T extends readonly BaseSchema[]>(options?: Partial<BaseClientOptions>, schemaTables?: T): Omit<{
3772
+ db: Awaited<ReturnType<SchemaPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
3773
+ search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
3662
3774
  }, keyof Plugins> & {
3663
3775
  [Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
3664
3776
  };
3665
3777
  }
3666
3778
  declare const BaseClient_base: ClientConstructor<{}>;
3667
- declare class BaseClient extends BaseClient_base<Record<string, any>> {
3779
+ declare class BaseClient extends BaseClient_base<[]> {
3668
3780
  }
3669
3781
 
3670
3782
  declare type BranchResolutionOptions = {
@@ -3683,4 +3795,4 @@ declare class XataError extends Error {
3683
3795
  constructor(message: string, status: number);
3684
3796
  }
3685
3797
 
3686
- export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SearchTableError, SearchTablePathParams, SearchTableRequestBody, SearchTableVariables, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
3798
+ export { AcceptWorkspaceMemberInviteError, AcceptWorkspaceMemberInvitePathParams, AcceptWorkspaceMemberInviteVariables, AddGitBranchesEntryError, AddGitBranchesEntryPathParams, AddGitBranchesEntryRequestBody, AddGitBranchesEntryResponse, AddGitBranchesEntryVariables, AddTableColumnError, AddTableColumnPathParams, AddTableColumnVariables, BaseClient, BaseClientOptions, BaseData, BaseSchema, BulkInsertTableRecordsError, BulkInsertTableRecordsPathParams, BulkInsertTableRecordsRequestBody, BulkInsertTableRecordsResponse, BulkInsertTableRecordsVariables, CacheImpl, CancelWorkspaceMemberInviteError, CancelWorkspaceMemberInvitePathParams, CancelWorkspaceMemberInviteVariables, ClientConstructor, CreateBranchError, CreateBranchPathParams, CreateBranchQueryParams, CreateBranchRequestBody, CreateBranchVariables, CreateDatabaseError, CreateDatabasePathParams, CreateDatabaseRequestBody, CreateDatabaseResponse, CreateDatabaseVariables, CreateTableError, CreateTablePathParams, CreateTableVariables, CreateUserAPIKeyError, CreateUserAPIKeyPathParams, CreateUserAPIKeyResponse, CreateUserAPIKeyVariables, CreateWorkspaceError, CreateWorkspaceVariables, CursorNavigationOptions, DeleteBranchError, DeleteBranchPathParams, DeleteBranchVariables, DeleteColumnError, DeleteColumnPathParams, DeleteColumnVariables, DeleteDatabaseError, DeleteDatabasePathParams, DeleteDatabaseVariables, DeleteRecordError, DeleteRecordPathParams, DeleteRecordVariables, DeleteTableError, DeleteTablePathParams, DeleteTableVariables, DeleteUserAPIKeyError, DeleteUserAPIKeyPathParams, DeleteUserAPIKeyVariables, DeleteUserError, DeleteUserVariables, DeleteWorkspaceError, DeleteWorkspacePathParams, DeleteWorkspaceVariables, EditableData, ExecuteBranchMigrationPlanError, ExecuteBranchMigrationPlanPathParams, ExecuteBranchMigrationPlanRequestBody, ExecuteBranchMigrationPlanVariables, FetchImpl, FetcherExtraProps, GetBranchDetailsError, GetBranchDetailsPathParams, GetBranchDetailsVariables, GetBranchListError, GetBranchListPathParams, GetBranchListVariables, GetBranchMetadataError, GetBranchMetadataPathParams, GetBranchMetadataVariables, GetBranchMigrationHistoryError, GetBranchMigrationHistoryPathParams, GetBranchMigrationHistoryRequestBody, GetBranchMigrationHistoryResponse, GetBranchMigrationHistoryVariables, GetBranchMigrationPlanError, GetBranchMigrationPlanPathParams, GetBranchMigrationPlanVariables, GetBranchStatsError, GetBranchStatsPathParams, GetBranchStatsResponse, GetBranchStatsVariables, GetColumnError, GetColumnPathParams, GetColumnVariables, GetDatabaseListError, GetDatabaseListPathParams, GetDatabaseListVariables, GetGitBranchesMappingError, GetGitBranchesMappingPathParams, GetGitBranchesMappingVariables, GetRecordError, GetRecordPathParams, GetRecordRequestBody, GetRecordVariables, GetTableColumnsError, GetTableColumnsPathParams, GetTableColumnsResponse, GetTableColumnsVariables, GetTableSchemaError, GetTableSchemaPathParams, GetTableSchemaResponse, GetTableSchemaVariables, GetUserAPIKeysError, GetUserAPIKeysResponse, GetUserAPIKeysVariables, GetUserError, GetUserVariables, GetWorkspaceError, GetWorkspaceMembersListError, GetWorkspaceMembersListPathParams, GetWorkspaceMembersListVariables, GetWorkspacePathParams, GetWorkspaceVariables, GetWorkspacesListError, GetWorkspacesListResponse, GetWorkspacesListVariables, Identifiable, InsertRecordError, InsertRecordPathParams, InsertRecordResponse, InsertRecordVariables, InsertRecordWithIDError, InsertRecordWithIDPathParams, InsertRecordWithIDQueryParams, InsertRecordWithIDVariables, InviteWorkspaceMemberError, InviteWorkspaceMemberPathParams, InviteWorkspaceMemberRequestBody, InviteWorkspaceMemberVariables, Link, OffsetNavigationOptions, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Paginable, PaginationQueryMeta, Query, QueryTableError, QueryTablePathParams, QueryTableRequestBody, QueryTableVariables, RecordArray, RemoveGitBranchesEntryError, RemoveGitBranchesEntryPathParams, RemoveGitBranchesEntryQueryParams, RemoveGitBranchesEntryVariables, RemoveWorkspaceMemberError, RemoveWorkspaceMemberPathParams, RemoveWorkspaceMemberVariables, Repository, ResendWorkspaceMemberInviteError, ResendWorkspaceMemberInvitePathParams, ResendWorkspaceMemberInviteVariables, ResolveBranchError, ResolveBranchPathParams, ResolveBranchQueryParams, ResolveBranchResponse, ResolveBranchVariables, responses as Responses, RestRepository, SchemaDefinition, SchemaInference, SchemaPlugin, SchemaPluginResult, schemas as Schemas, SearchBranchError, SearchBranchPathParams, SearchBranchRequestBody, SearchBranchVariables, SearchOptions, SearchPlugin, SearchPluginResult, SearchTableError, SearchTablePathParams, SearchTableRequestBody, SearchTableVariables, SelectableColumn, SelectedPick, SetTableSchemaError, SetTableSchemaPathParams, SetTableSchemaRequestBody, SetTableSchemaVariables, SimpleCache, SimpleCacheOptions, UpdateBranchMetadataError, UpdateBranchMetadataPathParams, UpdateBranchMetadataVariables, UpdateColumnError, UpdateColumnPathParams, UpdateColumnRequestBody, UpdateColumnVariables, UpdateRecordWithIDError, UpdateRecordWithIDPathParams, UpdateRecordWithIDQueryParams, UpdateRecordWithIDVariables, UpdateTableError, UpdateTablePathParams, UpdateTableRequestBody, UpdateTableVariables, UpdateUserError, UpdateUserVariables, UpdateWorkspaceError, UpdateWorkspaceMemberRoleError, UpdateWorkspaceMemberRolePathParams, UpdateWorkspaceMemberRoleRequestBody, UpdateWorkspaceMemberRoleVariables, UpdateWorkspacePathParams, UpdateWorkspaceVariables, UpsertRecordWithIDError, UpsertRecordWithIDPathParams, UpsertRecordWithIDQueryParams, UpsertRecordWithIDVariables, ValueAtColumn, XataApiClient, XataApiClientOptions, XataApiPlugin, XataError, XataPlugin, XataPluginOptions, XataRecord, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };