@xata.io/client 0.4.0 → 0.5.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/CHANGELOG.md
CHANGED
package/dist/schema/query.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { Repository, XataRecord } from '..';
|
2
1
|
import { ColumnsFilter, FilterExpression, PageConfig, SortExpression } from '../api/schemas';
|
3
2
|
import { DeepConstraint, FilterConstraints, SortDirection, SortFilter } from './filters';
|
4
3
|
import { Page, Paginable, PaginationOptions, PaginationQueryMeta } from './pagination';
|
4
|
+
import { XataRecord } from './record';
|
5
|
+
import { Repository } from './repository';
|
5
6
|
import { Select, Selectable, SelectableColumn } from './selection';
|
6
7
|
export declare type QueryOptions<T extends XataRecord> = {
|
7
8
|
page?: PaginationOptions;
|
package/dist/schema/record.d.ts
CHANGED
@@ -1,45 +1,40 @@
|
|
1
1
|
import { FetchImpl } from '../api/fetcher';
|
2
2
|
import { Page } from './pagination';
|
3
3
|
import { Query, QueryOptions } from './query';
|
4
|
-
import { XataRecord } from './record';
|
5
|
-
import { Select,
|
4
|
+
import { BaseData, XataRecord } from './record';
|
5
|
+
import { Select, SelectableColumn } from './selection';
|
6
6
|
export declare type Links = Record<string, Array<string[]>>;
|
7
7
|
/**
|
8
8
|
* Common interface for performing operations on a table.
|
9
9
|
*/
|
10
|
-
export declare abstract class Repository<
|
11
|
-
|
12
|
-
* Creates a record in the table.
|
13
|
-
* @param object Object containing the column names with their values to be stored in the table.
|
14
|
-
* @returns The full persisted record.
|
15
|
-
*/
|
16
|
-
abstract create(object: Selectable<T>): Promise<T>;
|
10
|
+
export declare abstract class Repository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record> {
|
11
|
+
abstract create(object: Data): Promise<Record>;
|
17
12
|
/**
|
18
13
|
* Creates multiple records in the table.
|
19
14
|
* @param objects Array of objects with the column names and the values to be stored in the table.
|
20
15
|
* @returns Array of the persisted records.
|
21
16
|
*/
|
22
|
-
abstract createMany(objects:
|
17
|
+
abstract createMany(objects: Data[]): Promise<Record[]>;
|
23
18
|
/**
|
24
19
|
* Queries a single record from the table given its unique id.
|
25
20
|
* @param id The unique id.
|
26
21
|
* @returns The persisted record for the given id or null if the record could not be found.
|
27
22
|
*/
|
28
|
-
abstract read(id: string): Promise<
|
23
|
+
abstract read(id: string): Promise<Record | null>;
|
29
24
|
/**
|
30
25
|
* Insert a single record with a unique id.
|
31
26
|
* @param id The unique id.
|
32
27
|
* @param object Object containing the column names with their values to be stored in the table.
|
33
28
|
* @returns The full persisted record.
|
34
29
|
*/
|
35
|
-
abstract insert(id: string, object:
|
30
|
+
abstract insert(id: string, object: Data): Promise<Record>;
|
36
31
|
/**
|
37
32
|
* Partially update a single record given its unique id.
|
38
33
|
* @param id The unique id.
|
39
34
|
* @param object The column names and their values that have to be updatd.
|
40
35
|
* @returns The full persisted record.
|
41
36
|
*/
|
42
|
-
abstract update(id: string, object: Partial<
|
37
|
+
abstract update(id: string, object: Partial<Data>): Promise<Record>;
|
43
38
|
/**
|
44
39
|
* Updates or inserts a single record. If a record exists with the given id,
|
45
40
|
* it will be update, otherwise a new record will be created.
|
@@ -47,36 +42,36 @@ export declare abstract class Repository<T extends XataRecord> extends Query<T>
|
|
47
42
|
* @param object The column names and the values to be persisted.
|
48
43
|
* @returns The full persisted record.
|
49
44
|
*/
|
50
|
-
abstract updateOrInsert(id: string, object:
|
45
|
+
abstract updateOrInsert(id: string, object: Data): Promise<Record>;
|
51
46
|
/**
|
52
47
|
* Deletes a record given its unique id.
|
53
48
|
* @param id The unique id.
|
54
49
|
* @throws If the record could not be found or there was an error while performing the deletion.
|
55
50
|
*/
|
56
51
|
abstract delete(id: string): void;
|
57
|
-
abstract query<
|
58
|
-
columns: SelectableColumn<
|
59
|
-
} ? Select<
|
52
|
+
abstract query<Result extends XataRecord, Options extends QueryOptions<Record>>(query: Query<Record, Result>, options: Options): Promise<Page<Record, typeof options extends {
|
53
|
+
columns: SelectableColumn<Data>[];
|
54
|
+
} ? Select<Data, typeof options['columns'][number]> : Result>>;
|
60
55
|
}
|
61
|
-
export declare class RestRepository<
|
56
|
+
export declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Repository<Data, Record> {
|
62
57
|
#private;
|
63
58
|
constructor(client: BaseClient<any>, table: string);
|
64
|
-
create(object:
|
65
|
-
createMany(objects:
|
66
|
-
read(recordId: string): Promise<
|
67
|
-
update(recordId: string, object: Partial<
|
68
|
-
insert(recordId: string, object:
|
69
|
-
updateOrInsert(recordId: string, object:
|
59
|
+
create(object: Data): Promise<Record>;
|
60
|
+
createMany(objects: Data[]): Promise<Record[]>;
|
61
|
+
read(recordId: string): Promise<Record | null>;
|
62
|
+
update(recordId: string, object: Partial<Data>): Promise<Record>;
|
63
|
+
insert(recordId: string, object: Data): Promise<Record>;
|
64
|
+
updateOrInsert(recordId: string, object: Data): Promise<Record>;
|
70
65
|
delete(recordId: string): Promise<void>;
|
71
|
-
query<
|
72
|
-
columns: SelectableColumn<
|
73
|
-
} ? Select<
|
66
|
+
query<Result extends XataRecord, Options extends QueryOptions<Record>>(query: Query<Record, Result>, options?: Options): Promise<Page<Record, typeof options extends {
|
67
|
+
columns: SelectableColumn<Data>[];
|
68
|
+
} ? Select<Data, typeof options['columns'][number]> : Result>>;
|
74
69
|
}
|
75
70
|
interface RepositoryFactory {
|
76
|
-
createRepository<
|
71
|
+
createRepository<Data extends BaseData>(client: BaseClient<any>, table: string): Repository<Data>;
|
77
72
|
}
|
78
73
|
export declare class RestRespositoryFactory implements RepositoryFactory {
|
79
|
-
createRepository<
|
74
|
+
createRepository<Data extends BaseData>(client: BaseClient<any>, table: string): Repository<Data>;
|
80
75
|
}
|
81
76
|
declare type BranchStrategyValue = string | undefined | null;
|
82
77
|
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
@@ -1,12 +1,10 @@
|
|
1
|
-
import { XataRecord } from '..';
|
2
1
|
import { StringKeys, UnionToIntersection, Values } from '../util/types';
|
3
2
|
import { Query } from './query';
|
4
|
-
import { Identifiable } from './record';
|
3
|
+
import { BaseData, Identifiable, XataRecord } from './record';
|
5
4
|
declare type Queries<T> = {
|
6
|
-
[key in keyof T as T[key] extends Query<any> ? key : never]: T[key];
|
5
|
+
[key in keyof T as T[key] extends Query<any, any> ? key : never]: T[key];
|
7
6
|
};
|
8
|
-
declare type
|
9
|
-
export declare type Selectable<T extends XataRecord> = Omit<T, InternalProperties> & Identifiable;
|
7
|
+
export declare type Selectable<T extends BaseData> = T & Partial<Identifiable>;
|
10
8
|
export declare type SelectableColumn<O> = '*' | (O extends Array<unknown> ? never : O extends Record<string, any> ? '*' | Values<{
|
11
9
|
[K in StringKeys<O>]: O[K] extends Record<string, any> ? `${K}.${SelectableColumn<O[K]>}` : K;
|
12
10
|
}> : '');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xata.io/client",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.0",
|
4
4
|
"description": "Xata.io SDK for TypeScript and JavaScript",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -20,5 +20,5 @@
|
|
20
20
|
"url": "https://github.com/xataio/client-ts/issues"
|
21
21
|
},
|
22
22
|
"homepage": "https://github.com/xataio/client-ts/blob/main/client/README.md",
|
23
|
-
"gitHead": "
|
23
|
+
"gitHead": "fddf861eb22287d5cf8e23761d5ae0d10c23d664"
|
24
24
|
}
|