@xata.io/client 0.0.0-alpha.ve276c32 → 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,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
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';
4
+ import { GetArrayInnerType } from '../util/types';
5
5
  export declare class SearchNamespace<Schemas extends Record<string, BaseData>> extends Namespace {
6
- #private;
7
- build({ getFetchProps }: NamespaceBuildOptions): {
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
- };
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 _SearchNamespace_instances, _SearchNamespace_search;
17
11
  Object.defineProperty(exports, "__esModule", { value: true });
18
12
  exports.SearchNamespace = void 0;
19
13
  const api_1 = require("../api");
20
14
  const namespace_1 = require("../namespace");
21
15
  class SearchNamespace extends namespace_1.Namespace {
22
- constructor() {
23
- super(...arguments);
24
- _SearchNamespace_instances.add(this);
25
- }
26
16
  build({ getFetchProps }) {
27
- return {
28
- all: (query, options = {}) => __awaiter(this, void 0, void 0, function* () {
29
- const records = yield __classPrivateFieldGet(this, _SearchNamespace_instances, "m", _SearchNamespace_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, _SearchNamespace_instances, "m", _SearchNamespace_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
30
  exports.SearchNamespace = SearchNamespace;
48
- _SearchNamespace_instances = new WeakSet(), _SearchNamespace_search = function _SearchNamespace_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
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xata.io/client",
3
- "version": "0.0.0-alpha.ve276c32",
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": "e276c32d9a0946b08d4eda5a9d2aa308b76ecac7"
26
+ "gitHead": "fb85b8b847299a3fa60b6f347255484ffdc1752c"
27
27
  }