@xata.io/client 0.0.0-alpha.vfb85b8b → 0.0.0-beta.0362c79
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/search/index.d.ts +23 -9
- package/dist/search/index.js +36 -11
- package/package.json +2 -2
package/dist/search/index.d.ts
CHANGED
@@ -1,16 +1,30 @@
|
|
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 } from '../util/types';
|
4
|
+
import { GetArrayInnerType, Values } from '../util/types';
|
5
5
|
export declare class SearchNamespace<Schemas extends Record<string, BaseData>> extends Namespace {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
+
};
|
14
28
|
}
|
15
29
|
declare type SearchXataRecord = XataRecord & {
|
16
30
|
xata: {
|
package/dist/search/index.js
CHANGED
@@ -8,23 +8,48 @@ 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;
|
11
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
18
|
exports.SearchNamespace = void 0;
|
13
19
|
const api_1 = require("../api");
|
14
20
|
const namespace_1 = require("../namespace");
|
15
21
|
class SearchNamespace extends namespace_1.Namespace {
|
22
|
+
constructor() {
|
23
|
+
super(...arguments);
|
24
|
+
_SearchNamespace_instances.add(this);
|
25
|
+
}
|
16
26
|
build({ getFetchProps }) {
|
17
|
-
return
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
+
};
|
28
45
|
}
|
29
46
|
}
|
30
47
|
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-
|
3
|
+
"version": "0.0.0-beta.0362c79",
|
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": "
|
26
|
+
"gitHead": "0362c792d5bb8f816f020448fab7a79ba6bba071"
|
27
27
|
}
|