@xata.io/client 0.0.0-beta.4e4e7fc → 0.0.0-beta.518ec9b
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/schema/query.d.ts +10 -4
- package/dist/schema/query.js +5 -15
- package/dist/schema/repository.d.ts +7 -3
- package/dist/schema/repository.js +2 -2
- package/package.json +2 -2
- package/tsconfig.json +21 -0
package/dist/schema/query.d.ts
CHANGED
@@ -25,14 +25,20 @@ export declare class Query<T extends XataRecord, R extends XataRecord = T> imple
|
|
25
25
|
not(...queries: Query<T, R>[]): Query<T, R>;
|
26
26
|
none(...queries: Query<T, R>[]): Query<T, R>;
|
27
27
|
filter(constraints: FilterConstraints<T>): Query<T, R>;
|
28
|
-
filter<F extends keyof T
|
28
|
+
filter<F extends keyof Selectable<T>>(column: F, value: FilterConstraints<T[F]> | DeepConstraint<T[F]>): Query<T, R>;
|
29
29
|
sort<F extends keyof T>(column: F, direction: SortDirection): Query<T, R>;
|
30
30
|
select<K extends SelectableColumn<T>>(columns: K[]): Query<T, Select<T, K>>;
|
31
|
-
getPaginated<Options extends QueryOptions<T>>(options?: Options): Promise<Page<T, typeof options
|
31
|
+
getPaginated<Options extends QueryOptions<T>>(options?: Options): Promise<Page<T, typeof options extends {
|
32
|
+
columns: SelectableColumn<T>[];
|
33
|
+
} ? Select<T, typeof options['columns'][number]> : R>>;
|
32
34
|
[Symbol.asyncIterator](): AsyncIterableIterator<R>;
|
33
35
|
getIterator(chunk: number, options?: Omit<QueryOptions<T>, 'page'>): AsyncGenerator<R[]>;
|
34
|
-
getMany<Options extends QueryOptions<T>>(options?: Options): Promise<(typeof options
|
35
|
-
|
36
|
+
getMany<Options extends QueryOptions<T>>(options?: Options): Promise<(typeof options extends {
|
37
|
+
columns: SelectableColumn<T>[];
|
38
|
+
} ? Select<T, typeof options['columns'][number]> : R)[]>;
|
39
|
+
getOne<Options extends Omit<QueryOptions<T>, 'page'>>(options?: Options): Promise<(typeof options extends {
|
40
|
+
columns: SelectableColumn<T>[];
|
41
|
+
} ? Select<T, typeof options['columns'][number]> : R) | null>;
|
36
42
|
/**async deleteAll(): Promise<number> {
|
37
43
|
// TODO: Return number of affected rows
|
38
44
|
return 0;
|
package/dist/schema/query.js
CHANGED
@@ -113,9 +113,7 @@ class Query {
|
|
113
113
|
return new Query(__classPrivateFieldGet(this, _Query_repository, "f"), __classPrivateFieldGet(this, _Query_table, "f"), { columns }, __classPrivateFieldGet(this, _Query_data, "f"));
|
114
114
|
}
|
115
115
|
getPaginated(options = {}) {
|
116
|
-
return
|
117
|
-
return __classPrivateFieldGet(this, _Query_repository, "f").query(this, options);
|
118
|
-
});
|
116
|
+
return __classPrivateFieldGet(this, _Query_repository, "f").query(this, options);
|
119
117
|
}
|
120
118
|
[(_Query_table = new WeakMap(), _Query_repository = new WeakMap(), _Query_data = new WeakMap(), Symbol.asyncIterator)]() {
|
121
119
|
return __asyncGenerator(this, arguments, function* _a() {
|
@@ -164,24 +162,16 @@ class Query {
|
|
164
162
|
return 0;
|
165
163
|
}**/
|
166
164
|
nextPage(size, offset) {
|
167
|
-
return
|
168
|
-
return this.firstPage(size, offset);
|
169
|
-
});
|
165
|
+
return this.firstPage(size, offset);
|
170
166
|
}
|
171
167
|
previousPage(size, offset) {
|
172
|
-
return
|
173
|
-
return this.firstPage(size, offset);
|
174
|
-
});
|
168
|
+
return this.firstPage(size, offset);
|
175
169
|
}
|
176
170
|
firstPage(size, offset) {
|
177
|
-
return
|
178
|
-
return this.getPaginated({ page: { size, offset } });
|
179
|
-
});
|
171
|
+
return this.getPaginated({ page: { size, offset } });
|
180
172
|
}
|
181
173
|
lastPage(size, offset) {
|
182
|
-
return
|
183
|
-
return this.getPaginated({ page: { size, offset, before: 'end' } });
|
184
|
-
});
|
174
|
+
return this.getPaginated({ page: { size, offset, before: 'end' } });
|
185
175
|
}
|
186
176
|
hasNextPage() {
|
187
177
|
return this.meta.page.more;
|
@@ -11,7 +11,9 @@ export declare abstract class Repository<T extends XataRecord> extends Query<T>
|
|
11
11
|
abstract update(id: string, object: Partial<Selectable<T>>): Promise<T>;
|
12
12
|
abstract upsert(id: string, object: Selectable<T>): Promise<T>;
|
13
13
|
abstract delete(id: string): void;
|
14
|
-
abstract query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options: Options): Promise<Page<T, typeof options
|
14
|
+
abstract query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options: Options): Promise<Page<T, typeof options extends {
|
15
|
+
columns: SelectableColumn<T>[];
|
16
|
+
} ? Select<T, typeof options['columns'][number]> : R>>;
|
15
17
|
}
|
16
18
|
export declare class RestRepository<T extends XataRecord> extends Repository<T> {
|
17
19
|
#private;
|
@@ -22,7 +24,9 @@ export declare class RestRepository<T extends XataRecord> extends Repository<T>
|
|
22
24
|
update(recordId: string, object: Partial<Selectable<T>>): Promise<T>;
|
23
25
|
upsert(recordId: string, object: Selectable<T>): Promise<T>;
|
24
26
|
delete(recordId: string): Promise<void>;
|
25
|
-
query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options
|
27
|
+
query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options?: Options): Promise<Page<T, typeof options extends {
|
28
|
+
columns: SelectableColumn<T>[];
|
29
|
+
} ? Select<T, typeof options['columns'][number]> : R>>;
|
26
30
|
}
|
27
31
|
interface RepositoryFactory {
|
28
32
|
createRepository<T extends XataRecord>(client: BaseClient<any>, table: string): Repository<T>;
|
@@ -45,7 +49,7 @@ export declare class BaseClient<D extends Record<string, Repository<any>>> {
|
|
45
49
|
#private;
|
46
50
|
options: XataClientOptions;
|
47
51
|
db: D;
|
48
|
-
constructor(options: XataClientOptions, links
|
52
|
+
constructor(options: XataClientOptions, links?: Links);
|
49
53
|
initObject<T>(table: string, object: object): T;
|
50
54
|
getBranch(): Promise<string>;
|
51
55
|
}
|
@@ -121,7 +121,7 @@ class RestRepository extends Repository {
|
|
121
121
|
yield (0, api_1.deleteRecord)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}', tableName: __classPrivateFieldGet(this, _RestRepository_table, "f"), recordId } }, fetchProps));
|
122
122
|
});
|
123
123
|
}
|
124
|
-
query(query, options) {
|
124
|
+
query(query, options = {}) {
|
125
125
|
var _a, _b, _c;
|
126
126
|
return __awaiter(this, void 0, void 0, function* () {
|
127
127
|
const data = query.getQueryOptions();
|
@@ -165,7 +165,7 @@ class RestRespositoryFactory {
|
|
165
165
|
}
|
166
166
|
exports.RestRespositoryFactory = RestRespositoryFactory;
|
167
167
|
class BaseClient {
|
168
|
-
constructor(options, links) {
|
168
|
+
constructor(options, links = {}) {
|
169
169
|
_BaseClient_links.set(this, void 0);
|
170
170
|
_BaseClient_branch.set(this, void 0);
|
171
171
|
if (!options.databaseURL || !options.apiKey || !options.branch) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xata.io/client",
|
3
|
-
"version": "0.0.0-beta.
|
3
|
+
"version": "0.0.0-beta.518ec9b",
|
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": "518ec9b02b676c3f01cb30e12beb7df315275eff"
|
24
24
|
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES6",
|
4
|
+
"lib": ["dom", "esnext"],
|
5
|
+
"allowJs": true,
|
6
|
+
"skipLibCheck": true,
|
7
|
+
"esModuleInterop": true,
|
8
|
+
"allowSyntheticDefaultImports": true,
|
9
|
+
"strict": true,
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
12
|
+
"module": "CommonJS",
|
13
|
+
"moduleResolution": "node",
|
14
|
+
"resolveJsonModule": true,
|
15
|
+
"isolatedModules": true,
|
16
|
+
"noEmit": false,
|
17
|
+
"outDir": "dist",
|
18
|
+
"declaration": true
|
19
|
+
},
|
20
|
+
"include": ["src"]
|
21
|
+
}
|