@xata.io/client 0.0.0-beta.f46df88 → 0.0.0-beta.f65b504
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 +31 -0
- package/dist/api/client.d.ts +1 -1
- package/dist/api/client.js +32 -17
- package/dist/api/components.d.ts +7 -6
- package/dist/api/components.js +7 -6
- package/dist/api/fetcher.d.ts +15 -0
- package/dist/api/fetcher.js +19 -13
- package/dist/client.d.ts +39 -0
- package/dist/client.js +124 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/namespace.d.ts +7 -0
- package/dist/namespace.js +6 -0
- package/dist/schema/filters.d.ts +93 -19
- package/dist/schema/filters.js +0 -23
- package/dist/schema/filters.spec.d.ts +1 -0
- package/dist/schema/filters.spec.js +177 -0
- package/dist/schema/index.d.ts +16 -2
- package/dist/schema/index.js +26 -6
- package/dist/schema/operators.d.ts +26 -24
- package/dist/schema/operators.js +13 -11
- package/dist/schema/query.d.ts +8 -8
- package/dist/schema/record.d.ts +5 -5
- package/dist/schema/repository.d.ts +82 -48
- package/dist/schema/repository.js +162 -166
- package/dist/schema/selection.d.ts +5 -4
- package/dist/schema/selection.spec.js +154 -59
- package/dist/schema/sorting.d.ts +17 -0
- package/dist/schema/sorting.js +28 -0
- package/dist/schema/sorting.spec.d.ts +1 -0
- package/dist/schema/sorting.spec.js +11 -0
- package/dist/search/index.d.ts +20 -0
- package/dist/search/index.js +30 -0
- package/dist/util/branches.d.ts +5 -0
- package/dist/util/branches.js +7 -0
- package/dist/util/config.d.ts +11 -0
- package/dist/util/config.js +121 -0
- package/dist/util/environment.d.ts +5 -0
- package/dist/util/environment.js +68 -0
- package/dist/util/fetch.d.ts +2 -0
- package/dist/util/fetch.js +13 -0
- package/dist/util/lang.d.ts +1 -1
- package/dist/util/lang.js +1 -1
- package/dist/util/types.d.ts +12 -0
- package/package.json +5 -2
@@ -0,0 +1,177 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
4
|
+
const vitest_1 = require("vitest");
|
5
|
+
// Single column with implicit is
|
6
|
+
const singleColumnWithImplicitIs = { name: 'r2' };
|
7
|
+
// Single column with explicit is
|
8
|
+
const singleColumnWithExplicitIs = { name: { $is: 'r2' } };
|
9
|
+
// Is string
|
10
|
+
const isString = { string: 'string' };
|
11
|
+
// Is true
|
12
|
+
const isTrue = { boolean: true };
|
13
|
+
// Is false
|
14
|
+
const isFalse = { boolean: false };
|
15
|
+
// Is pos int
|
16
|
+
const isPosInt = { number: 1234567 };
|
17
|
+
// Is neg int
|
18
|
+
const isNegInt = { number: -42 };
|
19
|
+
// Is float
|
20
|
+
const isFloat = { number: 3.14 };
|
21
|
+
// with dots
|
22
|
+
const withDots = { 'settings.plan': 'free' };
|
23
|
+
// Nested columns
|
24
|
+
const nestedColumns = { settings: { plan: 'free' } };
|
25
|
+
// Nested columns array
|
26
|
+
const nestedColumnsArray = { settings: [{ dark: false }, { plan: 'free' }] };
|
27
|
+
// Nested columns any
|
28
|
+
const nestedColumnsAny = { settings: { $any: [{ plan: 'free' }, { plan: 'trial' }] } };
|
29
|
+
// Nested columns any value
|
30
|
+
const nestedColumnsAnyValue = { settings: { plan: { $any: ['free', 'trial'] } } };
|
31
|
+
// Or with $any
|
32
|
+
const orWithAny = { 'settings.plan': { $any: ['free', 'paid'] } };
|
33
|
+
// Multiple columns implicit and
|
34
|
+
const multipleColumnsImplicitAnd = { 'settings.dark': true, 'settings.plan': 'free' };
|
35
|
+
// Explicit $all with multi-key filter list
|
36
|
+
const explicitAllWithMultiKeyFilterList = {
|
37
|
+
$all: { 'settings.dark': true, 'settings.plan': 'free' }
|
38
|
+
};
|
39
|
+
// Explicit $all with filter list
|
40
|
+
const explicitAllWithFilterList = {
|
41
|
+
$all: [{ 'settings.dark': true }, { 'settings.plan': 'free' }]
|
42
|
+
};
|
43
|
+
// Explicit $any with multi-key filter list
|
44
|
+
const explicitAnyWithMultiKeyFilterList = {
|
45
|
+
$all: { 'settings.dark': true, 'settings.plan': 'free' }
|
46
|
+
};
|
47
|
+
// Explicit $any with filter list
|
48
|
+
const explicitAnyWithFilterList = {
|
49
|
+
$any: [{ 'settings.dark': true }, { 'settings.plan': 'free' }]
|
50
|
+
};
|
51
|
+
// $any with multiple values
|
52
|
+
const anyWithMultipleValues = { number: { $any: [1, 2, 3] } };
|
53
|
+
// $none with multiple values
|
54
|
+
const noneWithMultipleValues = { number: { $none: [1, 2, 3] } };
|
55
|
+
// Exists filter
|
56
|
+
const existsFilter = { $exists: 'test' };
|
57
|
+
// Not exists filter
|
58
|
+
const notExistsFilter = { $notExists: 'test' };
|
59
|
+
// Exists with all
|
60
|
+
const existsWithAll = { $all: [{ $exists: 'settings' }, { $exists: 'name' }] };
|
61
|
+
// Nest any with not
|
62
|
+
const nestAnyWithNot = { $not: { $any: { 'settings.dark': true, 'settings.plan': 'free' } } };
|
63
|
+
// Mix $all and $any with extra keys
|
64
|
+
const mixAllAndAnyWithExtraKeys = {
|
65
|
+
$all: { $any: { 'settings.dark': false, 'settings.plan': 'free' }, name: 'r1' }
|
66
|
+
};
|
67
|
+
// Range query with less first
|
68
|
+
const rangeQueryWithLessFirst = { age: { $lt: 30, $ge: 20 } };
|
69
|
+
// Range query with greater first
|
70
|
+
const rangeQueryWithGreaterFirst = { age: { $ge: 20, $lt: 30 } };
|
71
|
+
// Ordered op
|
72
|
+
const orderedOp = { age: { $lt: 30 } };
|
73
|
+
// Simple includes
|
74
|
+
const simpleIncludes = { labels: { $includes: 'test' } };
|
75
|
+
// Simple includes with op
|
76
|
+
const simpleIncludesWithOp = { labels: { $includes: { $contains: 'test' } } };
|
77
|
+
// Simple includes multiple
|
78
|
+
const simpleIncludesMultiple = { labels: { $includes: ['a', 'b', 'c'] } };
|
79
|
+
// Simple includes multiple with op
|
80
|
+
const simpleIncludesMultipleWithOp = {
|
81
|
+
labels: { $includes: [{ $is: 'a' }, { $is: 'b' }, { $is: 'c' }] }
|
82
|
+
};
|
83
|
+
// Includes with many comparisons
|
84
|
+
const includesWithManyComparisons = {
|
85
|
+
labels: { $includes: { $all: [{ $contains: 'a' }, { $contains: 'b' }] } }
|
86
|
+
};
|
87
|
+
// Simple includes multiple op and value
|
88
|
+
const simpleIncludesMultipleOpAndValue = { labels: { $includes: [{ $contains: 'a' }, 'b'] } };
|
89
|
+
// Includes with mode and array of filters
|
90
|
+
const includesWithModeAndArrayOfFilters = {
|
91
|
+
labels: { $includesNone: [{ $contains: 'test' }, 'abc', { $endsWith: 'bad' }] }
|
92
|
+
};
|
93
|
+
// Includes with mix of any and all in predicate position
|
94
|
+
const includesWithMixOfAnyAndAllInPredicatePosition = {
|
95
|
+
labels: { $includes: { $any: { $all: [{ $startsWith: 'test' }, { $contains: 'x' }], $any: ['a', 'b'] } } }
|
96
|
+
};
|
97
|
+
// Simple $includesany
|
98
|
+
const simpleIncludesAny = { labels: { $includesAny: 'test' } };
|
99
|
+
// Simple $includesall
|
100
|
+
const simpleIncludesAll = { labels: { $includesAll: 'test' } };
|
101
|
+
// Simple $includesnone
|
102
|
+
const simpleIncludesNone = { labels: { $includesNone: 'test' } };
|
103
|
+
// Exists value must be string not int
|
104
|
+
// @ts-expect-error
|
105
|
+
const existsValueMustBeStringNotInt = { $exists: 42 };
|
106
|
+
// Exists value must be string not objct
|
107
|
+
// @ts-expect-error
|
108
|
+
const existsValueMustBeStringNotObject = { $exists: { field: 'settings.unknown' } };
|
109
|
+
// Filter by one column
|
110
|
+
const filterByOneColumn = { name: 'r1' };
|
111
|
+
// Filter with the $is operator
|
112
|
+
const filterWithTheIsOperator = { name: { $is: 'r1' } };
|
113
|
+
// Filter with dot notation
|
114
|
+
const filterWithDotNotation = { 'settings.plan': 'free' };
|
115
|
+
// Filter with nested object
|
116
|
+
const filterWithNestedObject = { 'settings.plan': { $is: 'free' } };
|
117
|
+
// Filter with $any operation
|
118
|
+
const filterWithAnyOperation = { 'settings.plan': { $any: ['free', 'paid'] } };
|
119
|
+
// Filter with and operations
|
120
|
+
const filterWithAndOperations = { 'settings.dark': true, 'settings.plan': 'free' };
|
121
|
+
// Filter with both and and any operations
|
122
|
+
const filterWithBothAndAndAnyOperations = {
|
123
|
+
$any: { 'settings.dark': true, 'settings.plan': 'free' }
|
124
|
+
};
|
125
|
+
// Filter with both and and any operations in array
|
126
|
+
const filterWithBothAndAndAnyOperationsInArray = { $any: [{ name: 'r1' }, { name: 'r2' }] };
|
127
|
+
// Filter with exists operation
|
128
|
+
const filterWithExistsOperation = { $exists: 'settings' };
|
129
|
+
// Filter with exists, and and any operations
|
130
|
+
const filterWithExistsAndAndAnyOperations = {
|
131
|
+
$all: [{ $exists: 'settings' }, { $exists: 'name' }]
|
132
|
+
};
|
133
|
+
// Filter with not exists operation
|
134
|
+
const filterWithNotExistsOperation = { $notExists: 'settings' };
|
135
|
+
// Filter with partial match
|
136
|
+
const filterWithPartialMatch = { name: { $contains: 'value' } };
|
137
|
+
// Filter with pattern operator
|
138
|
+
const filterWithPatternOperator = { name: { $pattern: 'value' } };
|
139
|
+
// Filter with $startsWith and $endsWith operators
|
140
|
+
const filterWithStartsWithAndEndsWithOperators = {
|
141
|
+
name: { $startsWith: 'value', $endsWith: 'value' }
|
142
|
+
};
|
143
|
+
// Filter with numeric ranges
|
144
|
+
const filterWithNumericRanges = { age: { $lt: 30, $ge: 20 } };
|
145
|
+
// Filter with negations
|
146
|
+
const filterWithNegations = { $not: { name: 'r1' } };
|
147
|
+
// Filter with complex negations
|
148
|
+
const filterWithComplexNegations = { $not: { $any: [{ name: 'r1' }, { name: 'r2' }] } };
|
149
|
+
// Filter with arrays complex negations
|
150
|
+
const filterWithArraysComplexNegations = {
|
151
|
+
labels: {
|
152
|
+
$includes: {
|
153
|
+
$all: [{ $contains: 'label' }, { $not: { $endsWith: '-debug' } }]
|
154
|
+
}
|
155
|
+
}
|
156
|
+
};
|
157
|
+
// Filters with $includesAll
|
158
|
+
const filtersWithIncludesAll = {
|
159
|
+
'settings.labels': {
|
160
|
+
$includesAll: [{ $contains: 'label' }]
|
161
|
+
}
|
162
|
+
};
|
163
|
+
// Filter with invalid property type
|
164
|
+
// @ts-expect-error
|
165
|
+
const filterWithInvalidPropertyType = { name: 42 };
|
166
|
+
// Filter with invalid dot notation property type
|
167
|
+
// @ts-expect-error
|
168
|
+
const filterWithInvalidNestedPropertyType = { 'settings.plan': 42 };
|
169
|
+
// Filter with invalid nested object property type
|
170
|
+
// @ts-expect-error
|
171
|
+
const filterWithInvalidNestedObjectPropertyType = { settings: { plan: 42 } };
|
172
|
+
// Filter with invalid property $is type
|
173
|
+
// @ts-expect-error
|
174
|
+
const filterWithInvalidOperator = { name: { $is: 42 } };
|
175
|
+
(0, vitest_1.test)('fake test', () => {
|
176
|
+
// This is a fake test to make sure that the type definitions in this file are working
|
177
|
+
});
|
package/dist/schema/index.d.ts
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
+
import { Namespace, NamespaceBuildOptions } from '../namespace';
|
2
|
+
import { BaseData } from './record';
|
3
|
+
import { LinkDictionary, Repository } from './repository';
|
1
4
|
export * from './operators';
|
2
5
|
export * from './pagination';
|
3
6
|
export { Query } from './query';
|
4
7
|
export { isIdentifiable, isXataRecord } from './record';
|
5
8
|
export type { Identifiable, XataRecord } from './record';
|
6
|
-
export {
|
7
|
-
export type
|
9
|
+
export { Repository, RestRepository } from './repository';
|
10
|
+
export declare type SchemaDefinition = {
|
11
|
+
table: string;
|
12
|
+
links?: LinkDictionary;
|
13
|
+
};
|
14
|
+
export declare type SchemaNamespaceResult<Schemas extends Record<string, BaseData>> = {
|
15
|
+
[Key in keyof Schemas]: Repository<Schemas[Key]>;
|
16
|
+
};
|
17
|
+
export declare class SchemaNamespace<Schemas extends Record<string, BaseData>> extends Namespace {
|
18
|
+
private links?;
|
19
|
+
constructor(links?: LinkDictionary | undefined);
|
20
|
+
build(options: NamespaceBuildOptions): SchemaNamespaceResult<Schemas>;
|
21
|
+
}
|
package/dist/schema/index.js
CHANGED
@@ -14,7 +14,10 @@ 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.
|
17
|
+
exports.SchemaNamespace = exports.RestRepository = exports.Repository = exports.isXataRecord = exports.isIdentifiable = exports.Query = void 0;
|
18
|
+
const namespace_1 = require("../namespace");
|
19
|
+
const lang_1 = require("../util/lang");
|
20
|
+
const repository_1 = require("./repository");
|
18
21
|
__exportStar(require("./operators"), exports);
|
19
22
|
__exportStar(require("./pagination"), exports);
|
20
23
|
var query_1 = require("./query");
|
@@ -22,8 +25,25 @@ Object.defineProperty(exports, "Query", { enumerable: true, get: function () { r
|
|
22
25
|
var record_1 = require("./record");
|
23
26
|
Object.defineProperty(exports, "isIdentifiable", { enumerable: true, get: function () { return record_1.isIdentifiable; } });
|
24
27
|
Object.defineProperty(exports, "isXataRecord", { enumerable: true, get: function () { return record_1.isXataRecord; } });
|
25
|
-
var
|
26
|
-
Object.defineProperty(exports, "
|
27
|
-
Object.defineProperty(exports, "
|
28
|
-
|
29
|
-
|
28
|
+
var repository_2 = require("./repository");
|
29
|
+
Object.defineProperty(exports, "Repository", { enumerable: true, get: function () { return repository_2.Repository; } });
|
30
|
+
Object.defineProperty(exports, "RestRepository", { enumerable: true, get: function () { return repository_2.RestRepository; } });
|
31
|
+
class SchemaNamespace extends namespace_1.Namespace {
|
32
|
+
constructor(links) {
|
33
|
+
super();
|
34
|
+
this.links = links;
|
35
|
+
}
|
36
|
+
build(options) {
|
37
|
+
const { getFetchProps } = options;
|
38
|
+
const links = this.links;
|
39
|
+
const schemaNamespace = new Proxy({}, {
|
40
|
+
get: (_target, table) => {
|
41
|
+
if (!(0, lang_1.isString)(table))
|
42
|
+
throw new Error('Invalid table name');
|
43
|
+
return new repository_1.RestRepository({ schemaNamespace, getFetchProps, table, links });
|
44
|
+
}
|
45
|
+
});
|
46
|
+
return schemaNamespace;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
exports.SchemaNamespace = SchemaNamespace;
|
@@ -1,72 +1,74 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { ArrayFilter, ComparableType, ComparableTypeFilter, ExistanceFilter, PropertyFilter, StringTypeFilter } from './filters';
|
2
|
+
import { SelectableColumn } from './selection';
|
3
3
|
/**
|
4
4
|
* Operator to restrict results to only values that are greater than the given value.
|
5
5
|
*/
|
6
|
-
export declare const gt: <T extends ComparableType>(value: T) =>
|
6
|
+
export declare const gt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
7
7
|
/**
|
8
8
|
* Operator to restrict results to only values that are greater than or equal to the given value.
|
9
9
|
*/
|
10
|
-
export declare const ge: <T extends ComparableType>(value: T) =>
|
10
|
+
export declare const ge: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
11
11
|
/**
|
12
12
|
* Operator to restrict results to only values that are greater than or equal to the given value.
|
13
13
|
*/
|
14
|
-
export declare const gte: <T extends ComparableType>(value: T) =>
|
14
|
+
export declare const gte: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
15
15
|
/**
|
16
16
|
* Operator to restrict results to only values that are lower than the given value.
|
17
17
|
*/
|
18
|
-
export declare const lt: <T extends ComparableType>(value: T) =>
|
18
|
+
export declare const lt: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
19
19
|
/**
|
20
20
|
* Operator to restrict results to only values that are lower than or equal to the given value.
|
21
21
|
*/
|
22
|
-
export declare const lte: <T extends ComparableType>(value: T) =>
|
22
|
+
export declare const lte: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
23
23
|
/**
|
24
24
|
* Operator to restrict results to only values that are lower than or equal to the given value.
|
25
25
|
*/
|
26
|
-
export declare const le: <T extends ComparableType>(value: T) =>
|
26
|
+
export declare const le: <T extends ComparableType>(value: T) => ComparableTypeFilter<T>;
|
27
27
|
/**
|
28
28
|
* Operator to restrict results to only values that are not null.
|
29
29
|
*/
|
30
|
-
export declare const exists: (column:
|
30
|
+
export declare const exists: <T>(column: SelectableColumn<T, []>) => ExistanceFilter<T>;
|
31
31
|
/**
|
32
32
|
* Operator to restrict results to only values that are null.
|
33
33
|
*/
|
34
|
-
export declare const notExists: (column:
|
34
|
+
export declare const notExists: <T>(column: SelectableColumn<T, []>) => ExistanceFilter<T>;
|
35
35
|
/**
|
36
36
|
* Operator to restrict results to only values that start with the given prefix.
|
37
37
|
*/
|
38
|
-
export declare const startsWith: (value: string) =>
|
38
|
+
export declare const startsWith: (value: string) => StringTypeFilter;
|
39
39
|
/**
|
40
40
|
* Operator to restrict results to only values that end with the given suffix.
|
41
41
|
*/
|
42
|
-
export declare const endsWith: (value: string) =>
|
42
|
+
export declare const endsWith: (value: string) => StringTypeFilter;
|
43
43
|
/**
|
44
44
|
* Operator to restrict results to only values that match the given pattern.
|
45
45
|
*/
|
46
|
-
export declare const pattern: (value: string) =>
|
46
|
+
export declare const pattern: (value: string) => StringTypeFilter;
|
47
47
|
/**
|
48
48
|
* Operator to restrict results to only values that are equal to the given value.
|
49
49
|
*/
|
50
|
-
export declare const is: <T>(value: T) =>
|
50
|
+
export declare const is: <T>(value: T) => PropertyFilter<T>;
|
51
51
|
/**
|
52
52
|
* Operator to restrict results to only values that are not equal to the given value.
|
53
53
|
*/
|
54
|
-
export declare const isNot: <T>(value: T) =>
|
54
|
+
export declare const isNot: <T>(value: T) => PropertyFilter<T>;
|
55
55
|
/**
|
56
56
|
* Operator to restrict results to only values that contain the given value.
|
57
57
|
*/
|
58
|
-
export declare const contains:
|
58
|
+
export declare const contains: (value: string) => StringTypeFilter;
|
59
59
|
/**
|
60
|
-
* Operator to restrict results
|
60
|
+
* Operator to restrict results if some array items match the predicate.
|
61
61
|
*/
|
62
|
-
export declare const includes: (value:
|
62
|
+
export declare const includes: <T>(value: T) => ArrayFilter<T>;
|
63
63
|
/**
|
64
|
-
* Operator to restrict results
|
64
|
+
* Operator to restrict results if all array items match the predicate.
|
65
65
|
*/
|
66
|
-
export declare const
|
66
|
+
export declare const includesAll: <T>(value: T) => ArrayFilter<T>;
|
67
67
|
/**
|
68
|
-
* Operator to restrict results
|
68
|
+
* Operator to restrict results if none array items match the predicate.
|
69
69
|
*/
|
70
|
-
export declare const
|
71
|
-
|
72
|
-
|
70
|
+
export declare const includesNone: <T>(value: T) => ArrayFilter<T>;
|
71
|
+
/**
|
72
|
+
* Operator to restrict results if some array items match the predicate.
|
73
|
+
*/
|
74
|
+
export declare const includesAny: <T>(value: T) => ArrayFilter<T>;
|
package/dist/schema/operators.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.includesAny = exports.includesNone = exports.includesAll = exports.includes = exports.contains = exports.isNot = exports.is = exports.pattern = exports.endsWith = exports.startsWith = exports.notExists = exports.exists = exports.le = exports.lte = exports.lt = exports.gte = exports.ge = exports.gt = void 0;
|
4
4
|
/**
|
5
5
|
* Operator to restrict results to only values that are greater than the given value.
|
6
6
|
*/
|
@@ -71,21 +71,23 @@ exports.isNot = isNot;
|
|
71
71
|
*/
|
72
72
|
const contains = (value) => ({ $contains: value });
|
73
73
|
exports.contains = contains;
|
74
|
-
// TODO: these can only be applied to columns of type "multiple"
|
75
74
|
/**
|
76
|
-
* Operator to restrict results
|
75
|
+
* Operator to restrict results if some array items match the predicate.
|
77
76
|
*/
|
78
77
|
const includes = (value) => ({ $includes: value });
|
79
78
|
exports.includes = includes;
|
80
79
|
/**
|
81
|
-
* Operator to restrict results
|
80
|
+
* Operator to restrict results if all array items match the predicate.
|
82
81
|
*/
|
83
|
-
const includesSubstring = (value) => ({ $includesSubstring: value });
|
84
|
-
exports.includesSubstring = includesSubstring;
|
85
|
-
/**
|
86
|
-
* Operator to restrict results to only arrays that include a value matching the given pattern.
|
87
|
-
*/
|
88
|
-
const includesPattern = (value) => ({ $includesPattern: value });
|
89
|
-
exports.includesPattern = includesPattern;
|
90
82
|
const includesAll = (value) => ({ $includesAll: value });
|
91
83
|
exports.includesAll = includesAll;
|
84
|
+
/**
|
85
|
+
* Operator to restrict results if none array items match the predicate.
|
86
|
+
*/
|
87
|
+
const includesNone = (value) => ({ $includesNone: value });
|
88
|
+
exports.includesNone = includesNone;
|
89
|
+
/**
|
90
|
+
* Operator to restrict results if some array items match the predicate.
|
91
|
+
*/
|
92
|
+
const includesAny = (value) => ({ $includesAny: value });
|
93
|
+
exports.includesAny = includesAny;
|
package/dist/schema/query.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import { FilterExpression } from '../api/schemas';
|
2
2
|
import { NonEmptyArray, RequiredBy } from '../util/types';
|
3
|
-
import {
|
3
|
+
import { Filter } from './filters';
|
4
4
|
import { Page, Paginable, PaginationOptions, PaginationQueryMeta } from './pagination';
|
5
5
|
import { XataRecord } from './record';
|
6
6
|
import { Repository } from './repository';
|
7
7
|
import { SelectableColumn, SelectedPick, ValueAtColumn } from './selection';
|
8
|
+
import { SortDirection, SortFilter } from './sorting';
|
8
9
|
export declare type QueryOptions<T extends XataRecord> = {
|
9
10
|
page?: PaginationOptions;
|
10
11
|
columns?: NonEmptyArray<SelectableColumn<T>>;
|
@@ -28,25 +29,25 @@ export declare class Query<Record extends XataRecord, Result extends XataRecord
|
|
28
29
|
* @param queries An array of subqueries.
|
29
30
|
* @returns A new Query object.
|
30
31
|
*/
|
31
|
-
any(...queries: Query<Record,
|
32
|
+
any(...queries: Query<Record, any>[]): Query<Record, Result>;
|
32
33
|
/**
|
33
34
|
* Builds a new query object representing a logical AND between the given subqueries.
|
34
35
|
* @param queries An array of subqueries.
|
35
36
|
* @returns A new Query object.
|
36
37
|
*/
|
37
|
-
all(...queries: Query<Record,
|
38
|
+
all(...queries: Query<Record, any>[]): Query<Record, Result>;
|
38
39
|
/**
|
39
40
|
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
40
41
|
* @param queries An array of subqueries.
|
41
42
|
* @returns A new Query object.
|
42
43
|
*/
|
43
|
-
not(...queries: Query<Record,
|
44
|
+
not(...queries: Query<Record, any>[]): Query<Record, Result>;
|
44
45
|
/**
|
45
46
|
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
46
47
|
* @param queries An array of subqueries.
|
47
48
|
* @returns A new Query object.
|
48
49
|
*/
|
49
|
-
none(...queries: Query<Record,
|
50
|
+
none(...queries: Query<Record, any>[]): Query<Record, Result>;
|
50
51
|
/**
|
51
52
|
* Builds a new query object adding one or more constraints. Examples:
|
52
53
|
*
|
@@ -60,11 +61,10 @@ export declare class Query<Record extends XataRecord, Result extends XataRecord
|
|
60
61
|
* })
|
61
62
|
* ```
|
62
63
|
*
|
63
|
-
* @param constraints
|
64
64
|
* @returns A new Query object.
|
65
65
|
*/
|
66
|
-
filter(
|
67
|
-
filter<F extends SelectableColumn<Record>>(column: F, value:
|
66
|
+
filter(filters: Filter<Record>): Query<Record, Result>;
|
67
|
+
filter<F extends SelectableColumn<Record>>(column: F, value: Filter<ValueAtColumn<Record, F>>): Query<Record, Result>;
|
68
68
|
/**
|
69
69
|
* Builds a new query with a new sort option.
|
70
70
|
* @param column The column name.
|
package/dist/schema/record.d.ts
CHANGED
@@ -27,14 +27,14 @@ export interface XataRecord extends Identifiable {
|
|
27
27
|
/**
|
28
28
|
* Retrieves a refreshed copy of the current record from the database.
|
29
29
|
*/
|
30
|
-
read(): Promise<SelectedPick<this, ['*']
|
30
|
+
read(): Promise<Readonly<SelectedPick<this, ['*']>> | null>;
|
31
31
|
/**
|
32
32
|
* Performs a partial update of the current record. On success a new object is
|
33
33
|
* returned and the current object is not mutated.
|
34
34
|
* @param data The columns and their values that have to be updated.
|
35
35
|
* @returns A new record containing the latest values for all the columns of the current record.
|
36
36
|
*/
|
37
|
-
update(
|
37
|
+
update(partialUpdate: Partial<EditableData<Omit<this, keyof XataRecord>>>): Promise<Readonly<SelectedPick<this, ['*']>>>;
|
38
38
|
/**
|
39
39
|
* Performs a deletion of the current record in the database.
|
40
40
|
*
|
@@ -46,14 +46,14 @@ export declare type Link<Record extends XataRecord> = Omit<XataRecord, 'read' |
|
|
46
46
|
/**
|
47
47
|
* Retrieves a refreshed copy of the current record from the database.
|
48
48
|
*/
|
49
|
-
read(): Promise<SelectedPick<Record, ['*']
|
49
|
+
read(): Promise<Readonly<SelectedPick<Record, ['*']>> | null>;
|
50
50
|
/**
|
51
51
|
* Performs a partial update of the current record. On success a new object is
|
52
52
|
* returned and the current object is not mutated.
|
53
53
|
* @param data The columns and their values that have to be updated.
|
54
54
|
* @returns A new record containing the latest values for all the columns of the current record.
|
55
55
|
*/
|
56
|
-
update(
|
56
|
+
update(partialUpdate: Partial<EditableData<Omit<Record, keyof XataRecord>>>): Promise<Readonly<SelectedPick<Record, ['*']>>>;
|
57
57
|
};
|
58
58
|
export declare function isIdentifiable(x: any): x is Identifiable & Record<string, unknown>;
|
59
59
|
export declare function isXataRecord(x: any): x is XataRecord & Record<string, unknown>;
|
@@ -62,5 +62,5 @@ export declare type EditableData<O extends BaseData> = {
|
|
62
62
|
id: string;
|
63
63
|
} : NonNullable<O[K]> extends XataRecord ? {
|
64
64
|
id: string;
|
65
|
-
} | undefined : O[K];
|
65
|
+
} | null | undefined : O[K];
|
66
66
|
};
|