@xata.io/client 0.0.0-beta.f4457bf → 0.0.0-beta.fcefb29

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
@@ -1,5 +1,14 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4803b6f: Memoize ApiClient namespaces
8
+ - 1f268d7: Add search in XataClient
9
+ - d58c3d9: Hide private helper utilities
10
+ - f3b731b: Expose branch resolution API
11
+
3
12
  ## 0.7.1
4
13
 
5
14
  ### Patch Changes
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _XataApiClient_extraProps;
13
+ var _XataApiClient_extraProps, _XataApiClient_namespaces;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.XataApiClient = void 0;
16
16
  const config_1 = require("../util/config");
@@ -21,6 +21,7 @@ class XataApiClient {
21
21
  constructor(options) {
22
22
  var _a, _b;
23
23
  _XataApiClient_extraProps.set(this, void 0);
24
+ _XataApiClient_namespaces.set(this, {});
24
25
  const provider = (_a = options.host) !== null && _a !== void 0 ? _a : 'production';
25
26
  const apiKey = (_b = options === null || options === void 0 ? void 0 : options.apiKey) !== null && _b !== void 0 ? _b : (0, config_1.getAPIKey)();
26
27
  if (!apiKey) {
@@ -34,26 +35,38 @@ class XataApiClient {
34
35
  }, "f");
35
36
  }
36
37
  get user() {
37
- return new UserApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
38
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").user)
39
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").user = new UserApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
40
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").user;
38
41
  }
39
42
  get workspaces() {
40
- return new WorkspaceApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
43
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").workspaces)
44
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").workspaces = new WorkspaceApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
45
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").workspaces;
41
46
  }
42
47
  get databases() {
43
- return new DatabaseApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
48
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").databases)
49
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").databases = new DatabaseApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
50
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").databases;
44
51
  }
45
52
  get branches() {
46
- return new BranchApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
53
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").branches)
54
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").branches = new BranchApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
55
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").branches;
47
56
  }
48
57
  get tables() {
49
- return new TableApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
58
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").tables)
59
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").tables = new TableApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
60
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").tables;
50
61
  }
51
62
  get records() {
52
- return new RecordsApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
63
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").records)
64
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").records = new RecordsApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
65
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").records;
53
66
  }
54
67
  }
55
68
  exports.XataApiClient = XataApiClient;
56
- _XataApiClient_extraProps = new WeakMap();
69
+ _XataApiClient_extraProps = new WeakMap(), _XataApiClient_namespaces = new WeakMap();
57
70
  class UserApi {
58
71
  constructor(extraProps) {
59
72
  this.extraProps = extraProps;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
+ const vitest_1 = require("vitest");
3
5
  // Single column with implicit is
4
6
  const singleColumnWithImplicitIs = { name: 'r2' };
5
7
  // Single column with explicit is
@@ -170,6 +172,6 @@ const filterWithInvalidNestedObjectPropertyType = { settings: { plan: 42 } };
170
172
  // Filter with invalid property $is type
171
173
  // @ts-expect-error
172
174
  const filterWithInvalidOperator = { name: { $is: 42 } };
173
- test('fake test', () => {
175
+ (0, vitest_1.test)('fake test', () => {
174
176
  // This is a fake test to make sure that the type definitions in this file are working
175
177
  });
@@ -1,9 +1,11 @@
1
1
  import { FetchImpl } from '../api/fetcher';
2
+ import { Dictionary, GetArrayInnerType, StringKeys } from '../util/types';
2
3
  import { Page } from './pagination';
3
4
  import { Query } from './query';
4
5
  import { BaseData, EditableData, Identifiable, XataRecord } from './record';
5
6
  import { SelectedPick } from './selection';
6
- export declare type Links = Record<string, Array<string[]>>;
7
+ declare type TableLink = string[];
8
+ export declare type LinkDictionary = Dictionary<TableLink[]>;
7
9
  /**
8
10
  * Common interface for performing operations on a table.
9
11
  */
@@ -93,11 +95,20 @@ export declare abstract class Repository<Data extends BaseData, Record extends X
93
95
  * @throws If the record could not be found or there was an error while performing the deletion.
94
96
  */
95
97
  abstract delete(ids: Identifiable[]): Promise<void>;
98
+ /**
99
+ * Search for records in the table.
100
+ * @param query The query to search for.
101
+ * @param options The options to search with (like: fuzziness)
102
+ * @returns The found records.
103
+ */
104
+ abstract search(query: string, options?: {
105
+ fuzziness?: number;
106
+ }): Promise<SelectedPick<Record, ['*']>[]>;
96
107
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
97
108
  }
98
109
  export declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> {
99
110
  #private;
100
- constructor(client: BaseClient<any>, table: string);
111
+ constructor(client: BaseClient<any>, table: string, links?: LinkDictionary);
101
112
  create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
102
113
  create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
103
114
  create(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
@@ -109,13 +120,16 @@ export declare class RestRepository<Data extends BaseData, Record extends XataRe
109
120
  createOrUpdate(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
110
121
  createOrUpdate(objects: EditableData<Data>[]): Promise<SelectedPick<Record, ['*']>[]>;
111
122
  delete(recordId: string | Identifiable | Array<string | Identifiable>): Promise<void>;
123
+ search(query: string, options?: {
124
+ fuzziness?: number;
125
+ }): Promise<SelectedPick<Record, ['*']>[]>;
112
126
  query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
113
127
  }
114
128
  interface RepositoryFactory {
115
- createRepository<Data extends BaseData>(client: BaseClient<any>, table: string): Repository<Data & XataRecord>;
129
+ createRepository<Data extends BaseData>(client: BaseClient<any>, table: string, links?: LinkDictionary): Repository<Data & XataRecord>;
116
130
  }
117
131
  export declare class RestRespositoryFactory implements RepositoryFactory {
118
- createRepository<Data extends BaseData>(client: BaseClient<any>, table: string): Repository<Data & XataRecord>;
132
+ createRepository<Data extends BaseData>(client: BaseClient<any>, table: string, links?: LinkDictionary): Repository<Data & XataRecord>;
119
133
  }
120
134
  declare type BranchStrategyValue = string | undefined | null;
121
135
  declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
@@ -138,11 +152,14 @@ export declare type XataClientOptions = {
138
152
  repositoryFactory?: RepositoryFactory;
139
153
  };
140
154
  export declare class BaseClient<D extends Record<string, Repository<any>> = Record<string, Repository<any>>> {
141
- #private;
142
155
  options: XataClientOptions;
143
156
  db: D;
144
- constructor(options?: XataClientOptions, links?: Links);
145
- initObject<T>(table: string, object: object): T;
146
- getBranch(): Promise<string>;
157
+ constructor(options?: XataClientOptions, links?: LinkDictionary);
158
+ search<Tables extends StringKeys<D>>(query: string, options?: {
159
+ fuzziness?: number;
160
+ tables?: Tables[];
161
+ }): Promise<{
162
+ [Model in GetArrayInnerType<NonNullable<NonNullable<typeof options>['tables']>>]: Awaited<ReturnType<D[Model]['search']>>;
163
+ }>;
147
164
  }
148
165
  export {};
@@ -26,7 +26,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
26
26
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
27
27
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
28
28
  };
29
- var _RestRepository_instances, _RestRepository_client, _RestRepository_fetch, _RestRepository_table, _RestRepository_getFetchProps, _RestRepository_insertRecordWithoutId, _RestRepository_insertRecordWithId, _RestRepository_bulkInsertTableRecords, _RestRepository_updateRecordWithID, _RestRepository_upsertRecordWithID, _RestRepository_deleteRecord, _BaseClient_links, _BaseClient_branch;
29
+ var _RestRepository_instances, _RestRepository_client, _RestRepository_fetch, _RestRepository_table, _RestRepository_links, _RestRepository_branch, _RestRepository_getFetchProps, _RestRepository_getBranch, _RestRepository_insertRecordWithoutId, _RestRepository_insertRecordWithId, _RestRepository_bulkInsertTableRecords, _RestRepository_updateRecordWithID, _RestRepository_upsertRecordWithID, _RestRepository_deleteRecord, _RestRepository_initObject;
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.BaseClient = exports.RestRespositoryFactory = exports.RestRepository = exports.Repository = void 0;
32
32
  const api_1 = require("../api");
@@ -44,15 +44,18 @@ class Repository extends query_1.Query {
44
44
  }
45
45
  exports.Repository = Repository;
46
46
  class RestRepository extends query_1.Query {
47
- constructor(client, table) {
47
+ constructor(client, table, links) {
48
48
  super(null, table, {});
49
49
  _RestRepository_instances.add(this);
50
50
  _RestRepository_client.set(this, void 0);
51
51
  _RestRepository_fetch.set(this, void 0);
52
52
  _RestRepository_table.set(this, void 0);
53
+ _RestRepository_links.set(this, void 0);
54
+ _RestRepository_branch.set(this, void 0);
53
55
  __classPrivateFieldSet(this, _RestRepository_client, client, "f");
54
56
  __classPrivateFieldSet(this, _RestRepository_table, table, "f");
55
57
  __classPrivateFieldSet(this, _RestRepository_fetch, (0, fetch_1.getFetchImplementation)(__classPrivateFieldGet(this, _RestRepository_client, "f").options.fetch), "f");
58
+ __classPrivateFieldSet(this, _RestRepository_links, links !== null && links !== void 0 ? links : {}, "f");
56
59
  }
57
60
  create(a, b) {
58
61
  return __awaiter(this, void 0, void 0, function* () {
@@ -85,7 +88,7 @@ class RestRepository extends query_1.Query {
85
88
  const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
86
89
  try {
87
90
  const response = yield (0, api_1.getRecord)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}', tableName: __classPrivateFieldGet(this, _RestRepository_table, "f"), recordId } }, fetchProps));
88
- return __classPrivateFieldGet(this, _RestRepository_client, "f").initObject(__classPrivateFieldGet(this, _RestRepository_table, "f"), response);
91
+ return __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_initObject).call(this, __classPrivateFieldGet(this, _RestRepository_table, "f"), response);
89
92
  }
90
93
  catch (e) {
91
94
  if ((0, lang_1.isObject)(e) && e.status === 404) {
@@ -161,6 +164,13 @@ class RestRepository extends query_1.Query {
161
164
  throw new Error('Invalid arguments for delete method');
162
165
  });
163
166
  }
167
+ search(query, options = {}) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
170
+ const { records } = yield (0, api_1.searchBranch)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}' }, body: { tables: [__classPrivateFieldGet(this, _RestRepository_table, "f")], query, fuzziness: options.fuzziness } }, fetchProps));
171
+ return records.map((item) => __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_initObject).call(this, __classPrivateFieldGet(this, _RestRepository_table, "f"), item));
172
+ });
173
+ }
164
174
  query(query) {
165
175
  var _a;
166
176
  return __awaiter(this, void 0, void 0, function* () {
@@ -173,16 +183,16 @@ class RestRepository extends query_1.Query {
173
183
  };
174
184
  const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
175
185
  const { meta, records: objects } = yield (0, api_1.queryTable)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}', tableName: __classPrivateFieldGet(this, _RestRepository_table, "f") }, body }, fetchProps));
176
- const records = objects.map((record) => __classPrivateFieldGet(this, _RestRepository_client, "f").initObject(__classPrivateFieldGet(this, _RestRepository_table, "f"), record));
186
+ const records = objects.map((record) => __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_initObject).call(this, __classPrivateFieldGet(this, _RestRepository_table, "f"), record));
177
187
  return new pagination_1.Page(query, meta, records);
178
188
  });
179
189
  }
180
190
  }
181
191
  exports.RestRepository = RestRepository;
182
- _RestRepository_client = new WeakMap(), _RestRepository_fetch = new WeakMap(), _RestRepository_table = new WeakMap(), _RestRepository_instances = new WeakSet(), _RestRepository_getFetchProps = function _RestRepository_getFetchProps() {
192
+ _RestRepository_client = new WeakMap(), _RestRepository_fetch = new WeakMap(), _RestRepository_table = new WeakMap(), _RestRepository_links = new WeakMap(), _RestRepository_branch = new WeakMap(), _RestRepository_instances = new WeakSet(), _RestRepository_getFetchProps = function _RestRepository_getFetchProps() {
183
193
  var _a;
184
194
  return __awaiter(this, void 0, void 0, function* () {
185
- const branch = yield __classPrivateFieldGet(this, _RestRepository_client, "f").getBranch();
195
+ const branch = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getBranch).call(this);
186
196
  const apiKey = (_a = __classPrivateFieldGet(this, _RestRepository_client, "f").options.apiKey) !== null && _a !== void 0 ? _a : (0, config_1.getAPIKey)();
187
197
  if (!apiKey) {
188
198
  throw new Error('Could not resolve a valid apiKey');
@@ -201,6 +211,35 @@ _RestRepository_client = new WeakMap(), _RestRepository_fetch = new WeakMap(), _
201
211
  }
202
212
  };
203
213
  });
214
+ }, _RestRepository_getBranch = function _RestRepository_getBranch() {
215
+ var e_1, _a;
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ if (__classPrivateFieldGet(this, _RestRepository_branch, "f"))
218
+ return __classPrivateFieldGet(this, _RestRepository_branch, "f");
219
+ const { branch: param } = __classPrivateFieldGet(this, _RestRepository_client, "f").options;
220
+ const strategies = Array.isArray(param) ? [...param] : [param];
221
+ const evaluateBranch = (strategy) => __awaiter(this, void 0, void 0, function* () {
222
+ return isBranchStrategyBuilder(strategy) ? yield strategy() : strategy;
223
+ });
224
+ try {
225
+ for (var strategies_1 = __asyncValues(strategies), strategies_1_1; strategies_1_1 = yield strategies_1.next(), !strategies_1_1.done;) {
226
+ const strategy = strategies_1_1.value;
227
+ const branch = yield evaluateBranch(strategy);
228
+ if (branch) {
229
+ __classPrivateFieldSet(this, _RestRepository_branch, branch, "f");
230
+ return branch;
231
+ }
232
+ }
233
+ }
234
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
235
+ finally {
236
+ try {
237
+ if (strategies_1_1 && !strategies_1_1.done && (_a = strategies_1.return)) yield _a.call(strategies_1);
238
+ }
239
+ finally { if (e_1) throw e_1.error; }
240
+ }
241
+ throw new Error('Unable to resolve branch value');
242
+ });
204
243
  }, _RestRepository_insertRecordWithoutId = function _RestRepository_insertRecordWithoutId(object) {
205
244
  return __awaiter(this, void 0, void 0, function* () {
206
245
  const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
@@ -267,10 +306,36 @@ _RestRepository_client = new WeakMap(), _RestRepository_fetch = new WeakMap(), _
267
306
  const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
268
307
  yield (0, api_1.deleteRecord)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}', tableName: __classPrivateFieldGet(this, _RestRepository_table, "f"), recordId } }, fetchProps));
269
308
  });
309
+ }, _RestRepository_initObject = function _RestRepository_initObject(table, object) {
310
+ const result = {};
311
+ Object.assign(result, object);
312
+ const tableLinks = __classPrivateFieldGet(this, _RestRepository_links, "f")[table] || [];
313
+ for (const link of tableLinks) {
314
+ const [field, linkTable] = link;
315
+ const value = result[field];
316
+ if (value && (0, lang_1.isObject)(value)) {
317
+ result[field] = __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_initObject).call(this, linkTable, value);
318
+ }
319
+ }
320
+ const db = __classPrivateFieldGet(this, _RestRepository_client, "f").db;
321
+ result.read = function () {
322
+ return db[table].read(result['id']);
323
+ };
324
+ result.update = function (data) {
325
+ return db[table].update(result['id'], data);
326
+ };
327
+ result.delete = function () {
328
+ return db[table].delete(result['id']);
329
+ };
330
+ for (const prop of ['read', 'update', 'delete']) {
331
+ Object.defineProperty(result, prop, { enumerable: false });
332
+ }
333
+ Object.freeze(result);
334
+ return result;
270
335
  };
271
336
  class RestRespositoryFactory {
272
- createRepository(client, table) {
273
- return new RestRepository(client, table);
337
+ createRepository(client, table, links) {
338
+ return new RestRepository(client, table, links);
274
339
  }
275
340
  }
276
341
  exports.RestRespositoryFactory = RestRespositoryFactory;
@@ -286,82 +351,30 @@ function resolveXataClientOptions(options) {
286
351
  branch });
287
352
  }
288
353
  class BaseClient {
289
- constructor(options = {}, links = {}) {
290
- _BaseClient_links.set(this, void 0);
291
- _BaseClient_branch.set(this, void 0);
354
+ constructor(options = {}, links) {
292
355
  this.options = resolveXataClientOptions(options);
293
356
  // Make this property not enumerable so it doesn't show up in console.dir, etc.
294
357
  Object.defineProperty(this.options, 'apiKey', { enumerable: false });
295
- __classPrivateFieldSet(this, _BaseClient_links, links, "f");
296
358
  const factory = this.options.repositoryFactory || new RestRespositoryFactory();
297
359
  this.db = new Proxy({}, {
298
360
  get: (_target, prop) => {
299
- if (typeof prop !== 'string')
361
+ if (!(0, lang_1.isString)(prop))
300
362
  throw new Error('Invalid table name');
301
- return factory.createRepository(this, prop);
363
+ return factory.createRepository(this, prop, links);
302
364
  }
303
365
  });
304
366
  }
305
- initObject(table, object) {
306
- const result = {};
307
- Object.assign(result, object);
308
- const tableLinks = __classPrivateFieldGet(this, _BaseClient_links, "f")[table] || [];
309
- for (const link of tableLinks) {
310
- const [field, linkTable] = link;
311
- const value = result[field];
312
- if (value && (0, lang_1.isObject)(value)) {
313
- result[field] = this.initObject(linkTable, value);
314
- }
315
- }
316
- const db = this.db;
317
- result.read = function () {
318
- return db[table].read(result['id']);
319
- };
320
- result.update = function (data) {
321
- return db[table].update(result['id'], data);
322
- };
323
- result.delete = function () {
324
- return db[table].delete(result['id']);
325
- };
326
- for (const prop of ['read', 'update', 'delete']) {
327
- Object.defineProperty(result, prop, { enumerable: false });
328
- }
329
- Object.freeze(result);
330
- return result;
331
- }
332
- getBranch() {
333
- var e_1, _a;
367
+ search(query, options) {
368
+ var _a;
334
369
  return __awaiter(this, void 0, void 0, function* () {
335
- if (__classPrivateFieldGet(this, _BaseClient_branch, "f"))
336
- return __classPrivateFieldGet(this, _BaseClient_branch, "f");
337
- const { branch: param } = this.options;
338
- const strategies = Array.isArray(param) ? [...param] : [param];
339
- const evaluateBranch = (strategy) => __awaiter(this, void 0, void 0, function* () {
340
- return isBranchStrategyBuilder(strategy) ? yield strategy() : strategy;
341
- });
342
- try {
343
- for (var strategies_1 = __asyncValues(strategies), strategies_1_1; strategies_1_1 = yield strategies_1.next(), !strategies_1_1.done;) {
344
- const strategy = strategies_1_1.value;
345
- const branch = yield evaluateBranch(strategy);
346
- if (branch) {
347
- __classPrivateFieldSet(this, _BaseClient_branch, branch, "f");
348
- return branch;
349
- }
350
- }
351
- }
352
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
353
- finally {
354
- try {
355
- if (strategies_1_1 && !strategies_1_1.done && (_a = strategies_1.return)) yield _a.call(strategies_1);
356
- }
357
- finally { if (e_1) throw e_1.error; }
358
- }
359
- throw new Error('Unable to resolve branch value');
370
+ const tables = (_a = options === null || options === void 0 ? void 0 : options.tables) !== null && _a !== void 0 ? _a : Object.keys(this.db);
371
+ // TODO: Implement global search with a single call, REST repository abstraction needed
372
+ const results = yield Promise.all(tables.map((table) => this.db[table].search(query, options).then((results) => [table, results])));
373
+ return Object.fromEntries(results);
360
374
  });
361
375
  }
362
376
  }
363
377
  exports.BaseClient = BaseClient;
364
- _BaseClient_links = new WeakMap(), _BaseClient_branch = new WeakMap();
365
378
  const isBranchStrategyBuilder = (strategy) => {
366
379
  return typeof strategy === 'function';
367
380
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-floating-promises */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ const vitest_1 = require("vitest");
4
5
  // SelectableColumn<O> //
5
6
  // --------------------------------------------------------------------------- //
6
7
  const validTeamColumns = [
@@ -198,6 +199,6 @@ function test8(user) {
198
199
  user.partner = null;
199
200
  user.team = null;
200
201
  }
201
- test('fake test', () => {
202
+ (0, vitest_1.test)('fake test', () => {
202
203
  // This is a fake test to make sure that the type definitions in this file are working
203
204
  });
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
+ const vitest_1 = require("vitest");
3
5
  // Simple sorting
4
6
  const simpleSorting = { name: 'asc' };
5
7
  // Array of simple sorting
6
8
  const arrayOfSimpleSorting = [{ name: 'asc' }, { age: 'desc' }];
7
- test('fake test', () => {
9
+ (0, vitest_1.test)('fake test', () => {
8
10
  // This is a fake test to make sure that the type definitions in this file are working
9
11
  });
@@ -21,4 +21,5 @@ declare type Impossible<K extends keyof any> = {
21
21
  };
22
22
  export declare type Exactly<T, U extends T = T> = U & Impossible<Exclude<keyof U, keyof T>>;
23
23
  export declare type SingleOrArray<T> = T | T[];
24
+ export declare type Dictionary<T> = Record<string, T>;
24
25
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xata.io/client",
3
- "version": "0.0.0-beta.f4457bf",
3
+ "version": "0.0.0-beta.fcefb29",
4
4
  "description": "Xata.io SDK for TypeScript and JavaScript",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,5 +23,5 @@
23
23
  "url": "https://github.com/xataio/client-ts/issues"
24
24
  },
25
25
  "homepage": "https://github.com/xataio/client-ts/blob/main/client/README.md",
26
- "gitHead": "f4457bf4620defacaea6fb30935f27f918aafbeb"
26
+ "gitHead": "fcefb290e92a61d51c170040aa1dfe2eaadf596a"
27
27
  }