@xata.io/client 0.0.0-alpha.vc4283f6 → 0.0.0-alpha.vfb85b8b

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.
@@ -1,5 +1,3 @@
1
- import { XataPlugin, XataPluginOptions } from '../plugins';
2
- import { XataApiClient } from './client';
3
1
  import { operationsByTag } from './components';
4
2
  import type * as Responses from './responses';
5
3
  import type * as Schemas from './schemas';
@@ -7,6 +5,3 @@ export * from './client';
7
5
  export * from './components';
8
6
  export { operationsByTag as Operations };
9
7
  export type { Responses, Schemas };
10
- export declare class XataApiPlugin implements XataPlugin {
11
- build(options: XataPluginOptions): Promise<XataApiClient>;
12
- }
package/dist/api/index.js CHANGED
@@ -13,28 +13,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
16
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.XataApiPlugin = exports.Operations = void 0;
27
- const client_1 = require("./client");
17
+ exports.Operations = void 0;
28
18
  const components_1 = require("./components");
29
19
  Object.defineProperty(exports, "Operations", { enumerable: true, get: function () { return components_1.operationsByTag; } });
30
20
  __exportStar(require("./client"), exports);
31
21
  __exportStar(require("./components"), exports);
32
- class XataApiPlugin {
33
- build(options) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const { fetchImpl, apiKey } = yield options.getFetchProps();
36
- return new client_1.XataApiClient({ fetch: fetchImpl, apiKey });
37
- });
38
- }
39
- }
40
- exports.XataApiPlugin = XataApiPlugin;
package/dist/client.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { FetchImpl } from './api/fetcher';
2
- import { XataPlugin } from './plugins';
3
- import { SchemaPlugin } from './schema';
2
+ import { Namespace } from './namespace';
3
+ import { SchemaNamespace } from './schema';
4
4
  import { BaseData } from './schema/record';
5
5
  import { LinkDictionary } from './schema/repository';
6
- import { SearchPlugin } from './search';
6
+ import { SearchNamespace } from './search';
7
7
  import { BranchStrategyOption } from './util/branches';
8
8
  import { StringKeys } from './util/types';
9
9
  export declare type BaseClientOptions = {
@@ -12,16 +12,28 @@ export declare type BaseClientOptions = {
12
12
  databaseURL?: string;
13
13
  branch?: BranchStrategyOption;
14
14
  };
15
- export declare const buildClient: <Plugins extends Record<string, XataPlugin> = {}>(plugins?: Plugins | undefined) => ClientConstructor<Plugins>;
16
- export interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
17
- new <Schemas extends Record<string, BaseData>>(options?: Partial<BaseClientOptions>, links?: LinkDictionary): Omit<{
18
- db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
19
- search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
20
- }, keyof Plugins> & {
21
- [Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
15
+ export declare const buildClientWithNamespaces: <ExternalNamespaces extends Record<string, Namespace>>(namespaces: ExternalNamespaces) => <Schemas extends Record<string, BaseData>>() => WrapperConstructor<Schemas, {
16
+ db: SchemaNamespace<Schemas>;
17
+ search: SearchNamespace<Schemas>;
18
+ }, ExternalNamespaces>;
19
+ export declare const buildClient: <Schemas extends Record<string, BaseData>, ExternalNamespaces extends Record<string, Namespace> = {}, Namespaces extends Record<string, Namespace> = {
20
+ db: SchemaNamespace<Schemas>;
21
+ search: SearchNamespace<Schemas>;
22
+ }>(external?: ExternalNamespaces | undefined) => WrapperConstructor<Schemas, Namespaces, ExternalNamespaces>;
23
+ export interface WrapperConstructor<Schemas extends Record<string, BaseData> = Record<string, any>, Namespaces extends Record<string, Namespace> = {
24
+ db: SchemaNamespace<Schemas>;
25
+ search: SearchNamespace<Schemas>;
26
+ }, ExternalNamespaces extends Record<string, Namespace> = Record<string, Namespace>> {
27
+ new (options?: Partial<BaseClientOptions>, links?: LinkDictionary): {
28
+ [Key in StringKeys<Namespaces>]: ReturnType<Namespaces[Key]['build']>;
29
+ } & {
30
+ [Key in StringKeys<NonNullable<ExternalNamespaces>>]: ReturnType<NonNullable<ExternalNamespaces>[Key]['build']>;
22
31
  };
23
32
  }
24
- declare const BaseClient_base: ClientConstructor<{}>;
25
- export declare class BaseClient extends BaseClient_base<Record<string, any>> {
33
+ declare const BaseClient_base: WrapperConstructor<Record<string, any>, {
34
+ db: SchemaNamespace<Record<string, any>>;
35
+ search: SearchNamespace<Record<string, any>>;
36
+ }, {}>;
37
+ export declare class BaseClient extends BaseClient_base {
26
38
  }
27
39
  export {};
package/dist/client.js CHANGED
@@ -27,34 +27,27 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
27
27
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.BaseClient = exports.buildClient = void 0;
30
+ exports.BaseClient = exports.buildClient = exports.buildClientWithNamespaces = void 0;
31
31
  const schema_1 = require("./schema");
32
32
  const search_1 = require("./search");
33
33
  const branches_1 = require("./util/branches");
34
34
  const config_1 = require("./util/config");
35
35
  const fetch_1 = require("./util/fetch");
36
- const buildClient = (plugins) => {
36
+ const buildClientWithNamespaces = (namespaces) => () => (0, exports.buildClient)(namespaces);
37
+ exports.buildClientWithNamespaces = buildClientWithNamespaces;
38
+ const buildClient = (external) => {
37
39
  var _instances, _branch, _parseOptions, _getFetchProps, _evaluateBranch, _a;
38
40
  return _a = class {
39
41
  constructor(options = {}, links) {
40
42
  _instances.add(this);
41
43
  _branch.set(this, void 0);
42
44
  const safeOptions = __classPrivateFieldGet(this, _instances, "m", _parseOptions).call(this, options);
43
- const namespaces = Object.assign({ db: new schema_1.SchemaPlugin(links), search: new search_1.SearchPlugin() }, plugins);
45
+ const namespaces = Object.assign({ db: new schema_1.SchemaNamespace(links), search: new search_1.SearchNamespace() }, external);
44
46
  for (const [key, namespace] of Object.entries(namespaces)) {
45
47
  if (!namespace)
46
48
  continue;
47
- const result = namespace.build({ getFetchProps: () => __classPrivateFieldGet(this, _instances, "m", _getFetchProps).call(this, safeOptions) });
48
- if (result instanceof Promise) {
49
- void result.then((namespace) => {
50
- // @ts-ignore
51
- this[key] = namespace;
52
- });
53
- }
54
- else {
55
- // @ts-ignore
56
- this[key] = result;
57
- }
49
+ // @ts-ignore
50
+ this[key] = namespace.build({ getFetchProps: () => __classPrivateFieldGet(this, _instances, "m", _getFetchProps).call(this, safeOptions) });
58
51
  }
59
52
  }
60
53
  },
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export declare class XataError extends Error {
3
3
  constructor(message: string, status: number);
4
4
  }
5
5
  export * from './api';
6
- export * from './plugins';
7
6
  export * from './client';
8
7
  export * from './schema';
9
8
  export * from './search';
package/dist/index.js CHANGED
@@ -23,7 +23,6 @@ class XataError extends Error {
23
23
  }
24
24
  exports.XataError = XataError;
25
25
  __exportStar(require("./api"), exports);
26
- __exportStar(require("./plugins"), exports);
27
26
  __exportStar(require("./client"), exports);
28
27
  __exportStar(require("./schema"), exports);
29
28
  __exportStar(require("./search"), exports);
@@ -0,0 +1,7 @@
1
+ import { FetcherExtraProps } from './api/fetcher';
2
+ export declare abstract class Namespace {
3
+ abstract build(options: NamespaceBuildOptions): unknown;
4
+ }
5
+ export declare type NamespaceBuildOptions = {
6
+ getFetchProps: () => Promise<FetcherExtraProps>;
7
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Namespace = void 0;
4
+ class Namespace {
5
+ }
6
+ exports.Namespace = Namespace;
@@ -1,23 +1,21 @@
1
- import { XataPlugin, XataPluginOptions } from '../plugins';
1
+ import { Namespace, NamespaceBuildOptions } from '../namespace';
2
2
  import { BaseData } from './record';
3
3
  import { LinkDictionary, Repository } from './repository';
4
4
  export * from './operators';
5
5
  export * from './pagination';
6
6
  export { Query } from './query';
7
7
  export { isIdentifiable, isXataRecord } from './record';
8
- export type { BaseData, EditableData, Identifiable, XataRecord } from './record';
8
+ export type { Identifiable, XataRecord } from './record';
9
9
  export { Repository, RestRepository } from './repository';
10
- export type { LinkDictionary } from './repository';
11
- export * from './selection';
12
10
  export declare type SchemaDefinition = {
13
11
  table: string;
14
12
  links?: LinkDictionary;
15
13
  };
16
- export declare type SchemaPluginResult<Schemas extends Record<string, BaseData>> = {
14
+ export declare type SchemaNamespaceResult<Schemas extends Record<string, BaseData>> = {
17
15
  [Key in keyof Schemas]: Repository<Schemas[Key]>;
18
16
  };
19
- export declare class SchemaPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
17
+ export declare class SchemaNamespace<Schemas extends Record<string, BaseData>> extends Namespace {
20
18
  private links?;
21
19
  constructor(links?: LinkDictionary | undefined);
22
- build(options: XataPluginOptions): SchemaPluginResult<Schemas>;
20
+ build(options: NamespaceBuildOptions): SchemaNamespaceResult<Schemas>;
23
21
  }
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.SchemaPlugin = exports.RestRepository = exports.Repository = exports.isXataRecord = exports.isIdentifiable = exports.Query = void 0;
18
- const plugins_1 = require("../plugins");
17
+ exports.SchemaNamespace = exports.RestRepository = exports.Repository = exports.isXataRecord = exports.isIdentifiable = exports.Query = void 0;
18
+ const namespace_1 = require("../namespace");
19
19
  const lang_1 = require("../util/lang");
20
20
  const repository_1 = require("./repository");
21
21
  __exportStar(require("./operators"), exports);
@@ -28,8 +28,7 @@ Object.defineProperty(exports, "isXataRecord", { enumerable: true, get: function
28
28
  var repository_2 = require("./repository");
29
29
  Object.defineProperty(exports, "Repository", { enumerable: true, get: function () { return repository_2.Repository; } });
30
30
  Object.defineProperty(exports, "RestRepository", { enumerable: true, get: function () { return repository_2.RestRepository; } });
31
- __exportStar(require("./selection"), exports);
32
- class SchemaPlugin extends plugins_1.XataPlugin {
31
+ class SchemaNamespace extends namespace_1.Namespace {
33
32
  constructor(links) {
34
33
  super();
35
34
  this.links = links;
@@ -37,14 +36,14 @@ class SchemaPlugin extends plugins_1.XataPlugin {
37
36
  build(options) {
38
37
  const { getFetchProps } = options;
39
38
  const links = this.links;
40
- const db = new Proxy({}, {
39
+ const schemaNamespace = new Proxy({}, {
41
40
  get: (_target, table) => {
42
41
  if (!(0, lang_1.isString)(table))
43
42
  throw new Error('Invalid table name');
44
- return new repository_1.RestRepository({ db, getFetchProps, table, links });
43
+ return new repository_1.RestRepository({ schemaNamespace, getFetchProps, table, links });
45
44
  }
46
45
  });
47
- return db;
46
+ return schemaNamespace;
48
47
  }
49
48
  }
50
- exports.SchemaPlugin = SchemaPlugin;
49
+ exports.SchemaNamespace = SchemaNamespace;
@@ -1,4 +1,4 @@
1
- import { SchemaPluginResult } from '.';
1
+ import { SchemaNamespaceResult } from '.';
2
2
  import { FetcherExtraProps } from '../api/fetcher';
3
3
  import { Dictionary } from '../util/types';
4
4
  import { Page } from './pagination';
@@ -107,14 +107,13 @@ export declare abstract class Repository<Data extends BaseData, Record extends X
107
107
  }): Promise<SelectedPick<Record, ['*']>[]>;
108
108
  abstract query<Result extends XataRecord>(query: Query<Record, Result>): Promise<Page<Record, Result>>;
109
109
  }
110
- export declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
110
+ export declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> {
111
111
  #private;
112
- db: SchemaPluginResult<any>;
113
112
  constructor(options: {
114
113
  table: string;
115
114
  links?: LinkDictionary;
116
115
  getFetchProps: () => Promise<FetcherExtraProps>;
117
- db: SchemaPluginResult<any>;
116
+ schemaNamespace: SchemaNamespaceResult<any>;
118
117
  });
119
118
  create(object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
120
119
  create(recordId: string, object: EditableData<Data>): Promise<SelectedPick<Record, ['*']>>;
@@ -19,7 +19,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
19
19
  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");
20
20
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
21
  };
22
- var _RestRepository_instances, _RestRepository_table, _RestRepository_links, _RestRepository_getFetchProps, _RestRepository_insertRecordWithoutId, _RestRepository_insertRecordWithId, _RestRepository_bulkInsertTableRecords, _RestRepository_updateRecordWithID, _RestRepository_upsertRecordWithID, _RestRepository_deleteRecord, _RestRepository_initObject;
22
+ var _RestRepository_instances, _RestRepository_table, _RestRepository_links, _RestRepository_getFetchProps, _RestRepository_schemaNamespace, _RestRepository_insertRecordWithoutId, _RestRepository_insertRecordWithId, _RestRepository_bulkInsertTableRecords, _RestRepository_updateRecordWithID, _RestRepository_upsertRecordWithID, _RestRepository_deleteRecord, _RestRepository_initObject;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.RestRepository = exports.Repository = void 0;
25
25
  const api_1 = require("../api");
@@ -42,10 +42,11 @@ class RestRepository extends query_1.Query {
42
42
  _RestRepository_table.set(this, void 0);
43
43
  _RestRepository_links.set(this, void 0);
44
44
  _RestRepository_getFetchProps.set(this, void 0);
45
+ _RestRepository_schemaNamespace.set(this, void 0);
45
46
  __classPrivateFieldSet(this, _RestRepository_table, options.table, "f");
46
47
  __classPrivateFieldSet(this, _RestRepository_links, (_a = options.links) !== null && _a !== void 0 ? _a : {}, "f");
47
48
  __classPrivateFieldSet(this, _RestRepository_getFetchProps, options.getFetchProps, "f");
48
- this.db = options.db;
49
+ __classPrivateFieldSet(this, _RestRepository_schemaNamespace, options.schemaNamespace, "f");
49
50
  }
50
51
  create(a, b) {
51
52
  return __awaiter(this, void 0, void 0, function* () {
@@ -179,7 +180,7 @@ class RestRepository extends query_1.Query {
179
180
  }
180
181
  }
181
182
  exports.RestRepository = RestRepository;
182
- _RestRepository_table = new WeakMap(), _RestRepository_links = new WeakMap(), _RestRepository_getFetchProps = new WeakMap(), _RestRepository_instances = new WeakSet(), _RestRepository_insertRecordWithoutId = function _RestRepository_insertRecordWithoutId(object) {
183
+ _RestRepository_table = new WeakMap(), _RestRepository_links = new WeakMap(), _RestRepository_getFetchProps = new WeakMap(), _RestRepository_schemaNamespace = new WeakMap(), _RestRepository_instances = new WeakSet(), _RestRepository_insertRecordWithoutId = function _RestRepository_insertRecordWithoutId(object) {
183
184
  return __awaiter(this, void 0, void 0, function* () {
184
185
  const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_getFetchProps, "f").call(this);
185
186
  const record = transformObjectLinks(object);
@@ -256,7 +257,7 @@ _RestRepository_table = new WeakMap(), _RestRepository_links = new WeakMap(), _R
256
257
  result[field] = __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_initObject).call(this, linkTable, value);
257
258
  }
258
259
  }
259
- const db = this.db;
260
+ const db = __classPrivateFieldGet(this, _RestRepository_schemaNamespace, "f");
260
261
  result.read = function () {
261
262
  return db[table].read(result['id']);
262
263
  };
@@ -1,4 +1,4 @@
1
- import { SingleOrArray, StringKeys, Values } from '../util/types';
1
+ import { SingleOrArray, Values } from '../util/types';
2
2
  import { XataRecord } from './record';
3
3
  import { SelectableColumn } from './selection';
4
4
  export declare type SortDirection = 'asc' | 'desc';
@@ -6,17 +6,12 @@ export declare type SortFilterExtended<T extends XataRecord> = {
6
6
  column: SelectableColumn<T>;
7
7
  direction?: SortDirection;
8
8
  };
9
- export declare type SortFilter<T extends XataRecord> = SelectableColumn<T> | SortFilterExtended<T> | SortFilterBase<T>;
10
- declare type SortFilterBase<T extends XataRecord> = {
11
- [Key in StringKeys<T>]: SortDirection;
12
- };
9
+ export declare type SortFilter<T extends XataRecord> = SelectableColumn<T> | SortFilterExtended<T>;
13
10
  export declare type ApiSortFilter<T extends XataRecord> = SingleOrArray<Values<{
14
- [Key in SelectableColumn<T>]: {
15
- [K in Key]: SortDirection;
11
+ [key in SelectableColumn<T>]: {
12
+ [K in key]: SortDirection;
16
13
  };
17
14
  }>>;
18
15
  export declare function isSortFilterString<T extends XataRecord>(value: any): value is SelectableColumn<T>;
19
- export declare function isSortFilterBase<T extends XataRecord>(filter: SortFilter<T>): filter is SortFilterBase<T>;
20
16
  export declare function isSortFilterObject<T extends XataRecord>(filter: SortFilter<T>): filter is SortFilterExtended<T>;
21
17
  export declare function buildSortFilter<T extends XataRecord>(filter: SingleOrArray<SortFilter<T>>): ApiSortFilter<T>;
22
- export {};
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSortFilter = exports.isSortFilterObject = exports.isSortFilterBase = exports.isSortFilterString = void 0;
3
+ exports.buildSortFilter = exports.isSortFilterObject = exports.isSortFilterString = void 0;
4
4
  const lang_1 = require("../util/lang");
5
5
  function isSortFilterString(value) {
6
6
  return (0, lang_1.isString)(value);
7
7
  }
8
8
  exports.isSortFilterString = isSortFilterString;
9
- function isSortFilterBase(filter) {
10
- return (0, lang_1.isObject)(filter) && Object.values(filter).every((value) => value === 'asc' || value === 'desc');
11
- }
12
- exports.isSortFilterBase = isSortFilterBase;
13
9
  function isSortFilterObject(filter) {
14
- return (0, lang_1.isObject)(filter) && !isSortFilterBase(filter) && filter.column !== undefined;
10
+ return (0, lang_1.isObject)(filter) && filter.column !== undefined;
15
11
  }
16
12
  exports.isSortFilterObject = isSortFilterObject;
17
13
  function buildSortFilter(filter) {
@@ -22,9 +18,6 @@ function buildSortFilter(filter) {
22
18
  else if (Array.isArray(filter)) {
23
19
  return filter.map((item) => buildSortFilter(item));
24
20
  }
25
- else if (isSortFilterBase(filter)) {
26
- return filter;
27
- }
28
21
  else if (isSortFilterObject(filter)) {
29
22
  return { [filter.column]: (_a = filter.direction) !== null && _a !== void 0 ? _a : 'asc' };
30
23
  }
@@ -1,30 +1,16 @@
1
- import { XataPlugin, XataPluginOptions } from '../plugins';
1
+ import { Namespace, NamespaceBuildOptions } from '../namespace';
2
2
  import { BaseData, XataRecord } from '../schema/record';
3
3
  import { SelectedPick } from '../schema/selection';
4
- import { GetArrayInnerType, Values } from '../util/types';
5
- export declare class SearchPlugin<Schemas extends Record<string, BaseData>> extends XataPlugin {
6
- #private;
7
- build({ getFetchProps }: XataPluginOptions): {
8
- all: <Tables extends Extract<keyof Schemas, string>>(query: string, options?: {
9
- fuzziness?: number | undefined;
10
- tables?: Tables[] | undefined;
11
- }) => Promise<Values<{ [Model in Tables]: {
12
- table: Model;
13
- record: Awaited<SelectedPick<Schemas[Model] & XataRecord & {
14
- xata: {
15
- table: string;
16
- };
17
- }, ["*"]>>;
18
- }; }>[]>;
19
- byTable: <Tables_1 extends Extract<keyof Schemas, string>>(query: string, options?: {
20
- fuzziness?: number | undefined;
21
- tables?: Tables_1[] | undefined;
22
- }) => Promise<{ [Model_1 in Tables_1]: SelectedPick<Schemas[Model_1] & XataRecord & {
23
- xata: {
24
- table: string;
25
- };
26
- }, ["*"]>[]; }>;
27
- };
4
+ import { GetArrayInnerType } from '../util/types';
5
+ export declare class SearchNamespace<Schemas extends Record<string, BaseData>> extends Namespace {
6
+ build({ getFetchProps }: NamespaceBuildOptions): <Tables extends Extract<keyof Schemas, string>>(query: string, options?: {
7
+ fuzziness?: number | undefined;
8
+ tables?: Tables[] | undefined;
9
+ } | undefined) => Promise<{ [Model in Tables]: SelectedPick<Schemas[Model] & XataRecord & {
10
+ xata: {
11
+ table: string;
12
+ };
13
+ }, ["*"]>[]; }>;
28
14
  }
29
15
  declare type SearchXataRecord = XataRecord & {
30
16
  xata: {
@@ -8,48 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
- 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");
14
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
- };
16
- var _SearchPlugin_instances, _SearchPlugin_search;
17
11
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.SearchPlugin = void 0;
12
+ exports.SearchNamespace = void 0;
19
13
  const api_1 = require("../api");
20
- const plugins_1 = require("../plugins");
21
- class SearchPlugin extends plugins_1.XataPlugin {
22
- constructor() {
23
- super(...arguments);
24
- _SearchPlugin_instances.add(this);
25
- }
14
+ const namespace_1 = require("../namespace");
15
+ class SearchNamespace extends namespace_1.Namespace {
26
16
  build({ getFetchProps }) {
27
- return {
28
- all: (query, options = {}) => __awaiter(this, void 0, void 0, function* () {
29
- const records = yield __classPrivateFieldGet(this, _SearchPlugin_instances, "m", _SearchPlugin_search).call(this, query, options, getFetchProps);
30
- return records.map((record) => {
31
- const { table = 'orphan' } = record.xata;
32
- return { table, record };
33
- });
34
- }),
35
- byTable: (query, options = {}) => __awaiter(this, void 0, void 0, function* () {
36
- const records = yield __classPrivateFieldGet(this, _SearchPlugin_instances, "m", _SearchPlugin_search).call(this, query, options, getFetchProps);
37
- return records.reduce((acc, record) => {
38
- var _a;
39
- const { table = 'orphan' } = record.xata;
40
- const items = (_a = acc[table]) !== null && _a !== void 0 ? _a : [];
41
- return Object.assign(Object.assign({}, acc), { [table]: [...items, record] });
42
- }, {});
43
- })
44
- };
17
+ return (query, options) => __awaiter(this, void 0, void 0, function* () {
18
+ const fetchProps = yield getFetchProps();
19
+ const { tables, fuzziness } = options !== null && options !== void 0 ? options : {};
20
+ const { records } = yield (0, api_1.searchBranch)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}' }, body: { tables, query, fuzziness } }, fetchProps));
21
+ return records.reduce((acc, record) => {
22
+ var _a;
23
+ const { table = 'orphan' } = record.xata;
24
+ const items = (_a = acc[table]) !== null && _a !== void 0 ? _a : [];
25
+ return Object.assign(Object.assign({}, acc), { [table]: [...items, record] });
26
+ }, {});
27
+ });
45
28
  }
46
29
  }
47
- exports.SearchPlugin = SearchPlugin;
48
- _SearchPlugin_instances = new WeakSet(), _SearchPlugin_search = function _SearchPlugin_search(query, options, getFetchProps) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const fetchProps = yield getFetchProps();
51
- const { tables, fuzziness } = options !== null && options !== void 0 ? options : {};
52
- const { records } = yield (0, api_1.searchBranch)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}' }, body: { tables, query, fuzziness } }, fetchProps));
53
- return records;
54
- });
55
- };
30
+ exports.SearchNamespace = SearchNamespace;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xata.io/client",
3
- "version": "0.0.0-alpha.vc4283f6",
3
+ "version": "0.0.0-alpha.vfb85b8b",
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": "c4283f68fb3760f0771661e6b38158947e1b056f"
26
+ "gitHead": "fb85b8b847299a3fa60b6f347255484ffdc1752c"
27
27
  }
package/dist/plugins.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { FetcherExtraProps } from './api/fetcher';
2
- export declare abstract class XataPlugin {
3
- abstract build(options: XataPluginOptions): unknown | Promise<unknown>;
4
- }
5
- export declare type XataPluginOptions = {
6
- getFetchProps: () => Promise<FetcherExtraProps>;
7
- };
package/dist/plugins.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XataPlugin = void 0;
4
- class XataPlugin {
5
- }
6
- exports.XataPlugin = XataPlugin;