@xata.io/client 0.5.0 → 0.7.0
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/.eslintrc.cjs +13 -0
- package/CHANGELOG.md +33 -0
- package/dist/api/client.d.ts +2 -2
- package/dist/api/client.js +12 -9
- package/dist/api/components.d.ts +27 -31
- package/dist/api/components.js +27 -31
- package/dist/api/fetcher.d.ts +15 -0
- package/dist/api/fetcher.js +23 -22
- package/dist/api/providers.js +3 -2
- package/dist/api/responses.d.ts +6 -0
- package/dist/schema/config.d.ts +4 -0
- package/dist/schema/config.js +83 -0
- package/dist/schema/filters.d.ts +93 -17
- package/dist/schema/filters.js +0 -22
- package/dist/schema/filters.spec.d.ts +1 -0
- package/dist/schema/filters.spec.js +175 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +4 -1
- package/dist/schema/operators.d.ts +17 -27
- package/dist/schema/operators.js +1 -14
- package/dist/schema/pagination.d.ts +13 -13
- package/dist/schema/pagination.js +0 -1
- package/dist/schema/query.d.ts +39 -50
- package/dist/schema/query.js +25 -37
- package/dist/schema/record.d.ts +25 -3
- package/dist/schema/record.js +11 -0
- package/dist/schema/repository.d.ts +79 -35
- package/dist/schema/repository.js +208 -111
- package/dist/schema/selection.d.ts +24 -11
- package/dist/schema/selection.spec.d.ts +1 -0
- package/dist/schema/selection.spec.js +203 -0
- 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 +9 -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 +3 -0
- package/dist/util/lang.js +13 -1
- package/dist/util/types.d.ts +22 -1
- package/package.json +2 -2
package/dist/schema/filters.d.ts
CHANGED
@@ -1,20 +1,96 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { SingleOrArray } from '../util/types';
|
2
|
+
import { SelectableColumn, ValueAtColumn } from './selection';
|
3
|
+
/**
|
4
|
+
* PropertyMatchFilter
|
5
|
+
* Example:
|
6
|
+
{
|
7
|
+
"filter": {
|
8
|
+
"name": "value",
|
9
|
+
"name": {
|
10
|
+
"$is": "value",
|
11
|
+
"$any": [ "value1", "value2" ],
|
12
|
+
},
|
13
|
+
"settings.plan": {"$any": ["free", "paid"]},
|
14
|
+
"settings.plan": "free",
|
15
|
+
"settings": {
|
16
|
+
"plan": "free"
|
17
|
+
},
|
18
|
+
}
|
19
|
+
}
|
20
|
+
*/
|
21
|
+
declare type PropertyAccessFilter<Record> = {
|
22
|
+
[key in SelectableColumn<Record>]?: NestedApiFilter<ValueAtColumn<Record, key>> | PropertyFilter<ValueAtColumn<Record, key>>;
|
5
23
|
};
|
6
|
-
export declare type
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
[
|
24
|
+
export declare type PropertyFilter<T> = T | {
|
25
|
+
$is: T;
|
26
|
+
} | {
|
27
|
+
$isNot: T;
|
28
|
+
} | {
|
29
|
+
$any: T[];
|
30
|
+
} | {
|
31
|
+
$none: T[];
|
32
|
+
} | ValueTypeFilters<T>;
|
33
|
+
declare type IncludesFilter<T> = PropertyFilter<T> | {
|
34
|
+
[key in '$all' | '$none' | '$any']?: IncludesFilter<T> | Array<IncludesFilter<T> | {
|
35
|
+
$not: IncludesFilter<T>;
|
36
|
+
}>;
|
14
37
|
};
|
15
|
-
export declare type
|
16
|
-
[key in
|
17
|
-
} : Constraint<T>;
|
18
|
-
export declare type FilterConstraints<T> = {
|
19
|
-
[key in keyof T]?: T[key] extends Record<string, any> ? FilterConstraints<T[key]> : T[key] | DeepConstraint<T[key]>;
|
38
|
+
export declare type StringTypeFilter = {
|
39
|
+
[key in '$contains' | '$pattern' | '$startsWith' | '$endsWith']?: string;
|
20
40
|
};
|
41
|
+
export declare type ComparableType = number | Date;
|
42
|
+
export declare type ComparableTypeFilter<T extends ComparableType> = {
|
43
|
+
[key in '$gt' | '$lt' | '$ge' | '$le']?: T;
|
44
|
+
};
|
45
|
+
export declare type ArrayFilter<T> = {
|
46
|
+
[key in '$includes']?: SingleOrArray<PropertyFilter<T> | ValueTypeFilters<T>> | IncludesFilter<T>;
|
47
|
+
} | {
|
48
|
+
[key in '$includesAll' | '$includesNone' | '$includesAny']?: T | Array<PropertyFilter<T> | {
|
49
|
+
$not: PropertyFilter<T>;
|
50
|
+
}>;
|
51
|
+
};
|
52
|
+
declare type ValueTypeFilters<T> = T | T extends string ? StringTypeFilter : T extends number ? ComparableTypeFilter<number> : T extends Date ? ComparableTypeFilter<Date> : T extends Array<infer T> ? ArrayFilter<T> : never;
|
53
|
+
/**
|
54
|
+
* AggregatorFilter
|
55
|
+
* Example:
|
56
|
+
{
|
57
|
+
"filter": {
|
58
|
+
"$any": {
|
59
|
+
"settings.dark": true,
|
60
|
+
"settings.plan": "free"
|
61
|
+
}
|
62
|
+
},
|
63
|
+
}
|
64
|
+
{
|
65
|
+
"filter": {
|
66
|
+
"$any": [
|
67
|
+
{
|
68
|
+
"name": "r1",
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "r2",
|
72
|
+
},
|
73
|
+
],
|
74
|
+
}
|
75
|
+
*/
|
76
|
+
declare type AggregatorFilter<Record> = {
|
77
|
+
[key in '$all' | '$any' | '$not' | '$none']?: SingleOrArray<Filter<Record>>;
|
78
|
+
};
|
79
|
+
/**
|
80
|
+
* Existance filter
|
81
|
+
* Example: { filter: { $exists: "settings" } }
|
82
|
+
*/
|
83
|
+
export declare type ExistanceFilter<Record> = {
|
84
|
+
[key in '$exists' | '$notExists']?: SelectableColumn<Record>;
|
85
|
+
};
|
86
|
+
declare type BaseApiFilter<Record> = PropertyAccessFilter<Record> | AggregatorFilter<Record> | ExistanceFilter<Record>;
|
87
|
+
/**
|
88
|
+
* Nested filter
|
89
|
+
* Injects the Api filters on nested properties
|
90
|
+
* Example: { filter: { settings: { plan: { $any: ['free', 'trial'] } } } }
|
91
|
+
*/
|
92
|
+
declare type NestedApiFilter<T> = T extends Record<string, any> ? {
|
93
|
+
[key in keyof T]?: T[key] extends Record<string, any> ? SingleOrArray<Filter<T[key]>> : PropertyFilter<T[key]>;
|
94
|
+
} : PropertyFilter<T>;
|
95
|
+
export declare type Filter<Record> = BaseApiFilter<Record> | NestedApiFilter<Record>;
|
96
|
+
export {};
|
package/dist/schema/filters.js
CHANGED
@@ -1,24 +1,2 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.buildSortFilter = exports.isSortFilterObject = void 0;
|
4
|
-
function isSortFilterObject(filter) {
|
5
|
-
return typeof filter === 'object' && filter.column !== undefined;
|
6
|
-
}
|
7
|
-
exports.isSortFilterObject = isSortFilterObject;
|
8
|
-
function buildSortFilter(filter) {
|
9
|
-
if (!filter)
|
10
|
-
return undefined;
|
11
|
-
const filters = Array.isArray(filter) ? filter : [filter];
|
12
|
-
return filters.reduce((acc, item) => {
|
13
|
-
if (typeof item === 'string') {
|
14
|
-
return Object.assign(Object.assign({}, acc), { [item]: 'asc' });
|
15
|
-
}
|
16
|
-
else if (isSortFilterObject(item)) {
|
17
|
-
return Object.assign(Object.assign({}, acc), { [item.column]: item.direction });
|
18
|
-
}
|
19
|
-
else {
|
20
|
-
return acc;
|
21
|
-
}
|
22
|
-
}, {});
|
23
|
-
}
|
24
|
-
exports.buildSortFilter = buildSortFilter;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,175 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
// Single column with implicit is
|
4
|
+
const singleColumnWithImplicitIs = { name: 'r2' };
|
5
|
+
// Single column with explicit is
|
6
|
+
const singleColumnWithExplicitIs = { name: { $is: 'r2' } };
|
7
|
+
// Is string
|
8
|
+
const isString = { string: 'string' };
|
9
|
+
// Is true
|
10
|
+
const isTrue = { boolean: true };
|
11
|
+
// Is false
|
12
|
+
const isFalse = { boolean: false };
|
13
|
+
// Is pos int
|
14
|
+
const isPosInt = { number: 1234567 };
|
15
|
+
// Is neg int
|
16
|
+
const isNegInt = { number: -42 };
|
17
|
+
// Is float
|
18
|
+
const isFloat = { number: 3.14 };
|
19
|
+
// with dots
|
20
|
+
const withDots = { 'settings.plan': 'free' };
|
21
|
+
// Nested columns
|
22
|
+
const nestedColumns = { settings: { plan: 'free' } };
|
23
|
+
// Nested columns array
|
24
|
+
const nestedColumnsArray = { settings: [{ dark: false }, { plan: 'free' }] };
|
25
|
+
// Nested columns any
|
26
|
+
const nestedColumnsAny = { settings: { $any: [{ plan: 'free' }, { plan: 'trial' }] } };
|
27
|
+
// Nested columns any value
|
28
|
+
const nestedColumnsAnyValue = { settings: { plan: { $any: ['free', 'trial'] } } };
|
29
|
+
// Or with $any
|
30
|
+
const orWithAny = { 'settings.plan': { $any: ['free', 'paid'] } };
|
31
|
+
// Multiple columns implicit and
|
32
|
+
const multipleColumnsImplicitAnd = { 'settings.dark': true, 'settings.plan': 'free' };
|
33
|
+
// Explicit $all with multi-key filter list
|
34
|
+
const explicitAllWithMultiKeyFilterList = {
|
35
|
+
$all: { 'settings.dark': true, 'settings.plan': 'free' }
|
36
|
+
};
|
37
|
+
// Explicit $all with filter list
|
38
|
+
const explicitAllWithFilterList = {
|
39
|
+
$all: [{ 'settings.dark': true }, { 'settings.plan': 'free' }]
|
40
|
+
};
|
41
|
+
// Explicit $any with multi-key filter list
|
42
|
+
const explicitAnyWithMultiKeyFilterList = {
|
43
|
+
$all: { 'settings.dark': true, 'settings.plan': 'free' }
|
44
|
+
};
|
45
|
+
// Explicit $any with filter list
|
46
|
+
const explicitAnyWithFilterList = {
|
47
|
+
$any: [{ 'settings.dark': true }, { 'settings.plan': 'free' }]
|
48
|
+
};
|
49
|
+
// $any with multiple values
|
50
|
+
const anyWithMultipleValues = { number: { $any: [1, 2, 3] } };
|
51
|
+
// $none with multiple values
|
52
|
+
const noneWithMultipleValues = { number: { $none: [1, 2, 3] } };
|
53
|
+
// Exists filter
|
54
|
+
const existsFilter = { $exists: 'test' };
|
55
|
+
// Not exists filter
|
56
|
+
const notExistsFilter = { $notExists: 'test' };
|
57
|
+
// Exists with all
|
58
|
+
const existsWithAll = { $all: [{ $exists: 'settings' }, { $exists: 'name' }] };
|
59
|
+
// Nest any with not
|
60
|
+
const nestAnyWithNot = { $not: { $any: { 'settings.dark': true, 'settings.plan': 'free' } } };
|
61
|
+
// Mix $all and $any with extra keys
|
62
|
+
const mixAllAndAnyWithExtraKeys = {
|
63
|
+
$all: { $any: { 'settings.dark': false, 'settings.plan': 'free' }, name: 'r1' }
|
64
|
+
};
|
65
|
+
// Range query with less first
|
66
|
+
const rangeQueryWithLessFirst = { age: { $lt: 30, $ge: 20 } };
|
67
|
+
// Range query with greater first
|
68
|
+
const rangeQueryWithGreaterFirst = { age: { $ge: 20, $lt: 30 } };
|
69
|
+
// Ordered op
|
70
|
+
const orderedOp = { age: { $lt: 30 } };
|
71
|
+
// Simple includes
|
72
|
+
const simpleIncludes = { labels: { $includes: 'test' } };
|
73
|
+
// Simple includes with op
|
74
|
+
const simpleIncludesWithOp = { labels: { $includes: { $contains: 'test' } } };
|
75
|
+
// Simple includes multiple
|
76
|
+
const simpleIncludesMultiple = { labels: { $includes: ['a', 'b', 'c'] } };
|
77
|
+
// Simple includes multiple with op
|
78
|
+
const simpleIncludesMultipleWithOp = {
|
79
|
+
labels: { $includes: [{ $is: 'a' }, { $is: 'b' }, { $is: 'c' }] }
|
80
|
+
};
|
81
|
+
// Includes with many comparisons
|
82
|
+
const includesWithManyComparisons = {
|
83
|
+
labels: { $includes: { $all: [{ $contains: 'a' }, { $contains: 'b' }] } }
|
84
|
+
};
|
85
|
+
// Simple includes multiple op and value
|
86
|
+
const simpleIncludesMultipleOpAndValue = { labels: { $includes: [{ $contains: 'a' }, 'b'] } };
|
87
|
+
// Includes with mode and array of filters
|
88
|
+
const includesWithModeAndArrayOfFilters = {
|
89
|
+
labels: { $includesNone: [{ $contains: 'test' }, 'abc', { $endsWith: 'bad' }] }
|
90
|
+
};
|
91
|
+
// Includes with mix of any and all in predicate position
|
92
|
+
const includesWithMixOfAnyAndAllInPredicatePosition = {
|
93
|
+
labels: { $includes: { $any: { $all: [{ $startsWith: 'test' }, { $contains: 'x' }], $any: ['a', 'b'] } } }
|
94
|
+
};
|
95
|
+
// Simple $includesany
|
96
|
+
const simpleIncludesAny = { labels: { $includesAny: 'test' } };
|
97
|
+
// Simple $includesall
|
98
|
+
const simpleIncludesAll = { labels: { $includesAll: 'test' } };
|
99
|
+
// Simple $includesnone
|
100
|
+
const simpleIncludesNone = { labels: { $includesNone: 'test' } };
|
101
|
+
// Exists value must be string not int
|
102
|
+
// @ts-expect-error
|
103
|
+
const existsValueMustBeStringNotInt = { $exists: 42 };
|
104
|
+
// Exists value must be string not objct
|
105
|
+
// @ts-expect-error
|
106
|
+
const existsValueMustBeStringNotObject = { $exists: { field: 'settings.unknown' } };
|
107
|
+
// Filter by one column
|
108
|
+
const filterByOneColumn = { name: 'r1' };
|
109
|
+
// Filter with the $is operator
|
110
|
+
const filterWithTheIsOperator = { name: { $is: 'r1' } };
|
111
|
+
// Filter with dot notation
|
112
|
+
const filterWithDotNotation = { 'settings.plan': 'free' };
|
113
|
+
// Filter with nested object
|
114
|
+
const filterWithNestedObject = { 'settings.plan': { $is: 'free' } };
|
115
|
+
// Filter with $any operation
|
116
|
+
const filterWithAnyOperation = { 'settings.plan': { $any: ['free', 'paid'] } };
|
117
|
+
// Filter with and operations
|
118
|
+
const filterWithAndOperations = { 'settings.dark': true, 'settings.plan': 'free' };
|
119
|
+
// Filter with both and and any operations
|
120
|
+
const filterWithBothAndAndAnyOperations = {
|
121
|
+
$any: { 'settings.dark': true, 'settings.plan': 'free' }
|
122
|
+
};
|
123
|
+
// Filter with both and and any operations in array
|
124
|
+
const filterWithBothAndAndAnyOperationsInArray = { $any: [{ name: 'r1' }, { name: 'r2' }] };
|
125
|
+
// Filter with exists operation
|
126
|
+
const filterWithExistsOperation = { $exists: 'settings' };
|
127
|
+
// Filter with exists, and and any operations
|
128
|
+
const filterWithExistsAndAndAnyOperations = {
|
129
|
+
$all: [{ $exists: 'settings' }, { $exists: 'name' }]
|
130
|
+
};
|
131
|
+
// Filter with not exists operation
|
132
|
+
const filterWithNotExistsOperation = { $notExists: 'settings' };
|
133
|
+
// Filter with partial match
|
134
|
+
const filterWithPartialMatch = { name: { $contains: 'value' } };
|
135
|
+
// Filter with pattern operator
|
136
|
+
const filterWithPatternOperator = { name: { $pattern: 'value' } };
|
137
|
+
// Filter with $startsWith and $endsWith operators
|
138
|
+
const filterWithStartsWithAndEndsWithOperators = {
|
139
|
+
name: { $startsWith: 'value', $endsWith: 'value' }
|
140
|
+
};
|
141
|
+
// Filter with numeric ranges
|
142
|
+
const filterWithNumericRanges = { age: { $lt: 30, $ge: 20 } };
|
143
|
+
// Filter with negations
|
144
|
+
const filterWithNegations = { $not: { name: 'r1' } };
|
145
|
+
// Filter with complex negations
|
146
|
+
const filterWithComplexNegations = { $not: { $any: [{ name: 'r1' }, { name: 'r2' }] } };
|
147
|
+
// Filter with arrays complex negations
|
148
|
+
const filterWithArraysComplexNegations = {
|
149
|
+
labels: {
|
150
|
+
$includes: {
|
151
|
+
$all: [{ $contains: 'label' }, { $not: { $endsWith: '-debug' } }]
|
152
|
+
}
|
153
|
+
}
|
154
|
+
};
|
155
|
+
// Filters with $includesAll
|
156
|
+
const filtersWithIncludesAll = {
|
157
|
+
'settings.labels': {
|
158
|
+
$includesAll: [{ $contains: 'label' }]
|
159
|
+
}
|
160
|
+
};
|
161
|
+
// Filter with invalid property type
|
162
|
+
// @ts-expect-error
|
163
|
+
const filterWithInvalidPropertyType = { name: 42 };
|
164
|
+
// Filter with invalid dot notation property type
|
165
|
+
// @ts-expect-error
|
166
|
+
const filterWithInvalidNestedPropertyType = { 'settings.plan': 42 };
|
167
|
+
// Filter with invalid nested object property type
|
168
|
+
// @ts-expect-error
|
169
|
+
const filterWithInvalidNestedObjectPropertyType = { settings: { plan: 42 } };
|
170
|
+
// Filter with invalid property $is type
|
171
|
+
// @ts-expect-error
|
172
|
+
const filterWithInvalidOperator = { name: { $is: 42 } };
|
173
|
+
test('fake test', () => {
|
174
|
+
// This is a fake test to make sure that the type definitions in this file are working
|
175
|
+
});
|
package/dist/schema/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export * from './operators';
|
2
2
|
export * from './pagination';
|
3
3
|
export { Query } from './query';
|
4
|
+
export { isIdentifiable, isXataRecord } from './record';
|
4
5
|
export type { Identifiable, XataRecord } from './record';
|
5
6
|
export { BaseClient, Repository, RestRepository, RestRespositoryFactory } from './repository';
|
6
7
|
export type { XataClientOptions } from './repository';
|
package/dist/schema/index.js
CHANGED
@@ -14,11 +14,14 @@ 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.RestRespositoryFactory = exports.RestRepository = exports.Repository = exports.BaseClient = exports.Query = void 0;
|
17
|
+
exports.RestRespositoryFactory = exports.RestRepository = exports.Repository = exports.BaseClient = exports.isXataRecord = exports.isIdentifiable = exports.Query = void 0;
|
18
18
|
__exportStar(require("./operators"), exports);
|
19
19
|
__exportStar(require("./pagination"), exports);
|
20
20
|
var query_1 = require("./query");
|
21
21
|
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_1.Query; } });
|
22
|
+
var record_1 = require("./record");
|
23
|
+
Object.defineProperty(exports, "isIdentifiable", { enumerable: true, get: function () { return record_1.isIdentifiable; } });
|
24
|
+
Object.defineProperty(exports, "isXataRecord", { enumerable: true, get: function () { return record_1.isXataRecord; } });
|
22
25
|
var repository_1 = require("./repository");
|
23
26
|
Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return repository_1.BaseClient; } });
|
24
27
|
Object.defineProperty(exports, "Repository", { enumerable: true, get: function () { return repository_1.Repository; } });
|
@@ -1,72 +1,62 @@
|
|
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
60
|
* Operator to restrict results to only arrays that include the given value.
|
61
61
|
*/
|
62
|
-
export declare const includes: (value:
|
63
|
-
/**
|
64
|
-
* Operator to restrict results to only arrays that include a value matching the given substring.
|
65
|
-
*/
|
66
|
-
export declare const includesSubstring: (value: string) => Constraint<string>;
|
67
|
-
/**
|
68
|
-
* Operator to restrict results to only arrays that include a value matching the given pattern.
|
69
|
-
*/
|
70
|
-
export declare const includesPattern: (value: string) => Constraint<string>;
|
71
|
-
export declare const includesAll: (value: string) => Constraint<string>;
|
72
|
-
export {};
|
62
|
+
export declare const includes: <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.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,8 @@ 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
75
|
* Operator to restrict results to only arrays that include the given value.
|
77
76
|
*/
|
78
77
|
const includes = (value) => ({ $includes: value });
|
79
78
|
exports.includes = includes;
|
80
|
-
/**
|
81
|
-
* Operator to restrict results to only arrays that include a value matching the given substring.
|
82
|
-
*/
|
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
|
-
const includesAll = (value) => ({ $includesAll: value });
|
91
|
-
exports.includesAll = includesAll;
|
@@ -6,20 +6,20 @@ export declare type PaginationQueryMeta = {
|
|
6
6
|
more: boolean;
|
7
7
|
};
|
8
8
|
};
|
9
|
-
export interface Paginable<
|
9
|
+
export interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
|
10
10
|
meta: PaginationQueryMeta;
|
11
|
-
records:
|
12
|
-
nextPage(size?: number, offset?: number): Promise<Page<
|
13
|
-
previousPage(size?: number, offset?: number): Promise<Page<
|
14
|
-
firstPage(size?: number, offset?: number): Promise<Page<
|
15
|
-
lastPage(size?: number, offset?: number): Promise<Page<
|
11
|
+
records: Result[];
|
12
|
+
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
13
|
+
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
14
|
+
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
15
|
+
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
16
16
|
hasNextPage(): boolean;
|
17
17
|
}
|
18
18
|
/**
|
19
19
|
* A Page contains a set of results from a query plus metadata about the retrieved
|
20
20
|
* set of values such as the cursor, required to retrieve additional records.
|
21
21
|
*/
|
22
|
-
export declare class Page<
|
22
|
+
export declare class Page<Record extends XataRecord, Result extends XataRecord = Record> implements Paginable<Record, Result> {
|
23
23
|
#private;
|
24
24
|
/**
|
25
25
|
* Page metadata, required to retrieve additional records.
|
@@ -28,36 +28,36 @@ export declare class Page<T extends XataRecord, R extends XataRecord = T> implem
|
|
28
28
|
/**
|
29
29
|
* The set of results for this page.
|
30
30
|
*/
|
31
|
-
readonly records:
|
32
|
-
constructor(query: Query<
|
31
|
+
readonly records: Result[];
|
32
|
+
constructor(query: Query<Record, Result>, meta: PaginationQueryMeta, records?: Result[]);
|
33
33
|
/**
|
34
34
|
* Retrieves the next page of results.
|
35
35
|
* @param size Maximum number of results to be retrieved.
|
36
36
|
* @param offset Number of results to skip when retrieving the results.
|
37
37
|
* @returns The next page or results.
|
38
38
|
*/
|
39
|
-
nextPage(size?: number, offset?: number): Promise<Page<
|
39
|
+
nextPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
40
40
|
/**
|
41
41
|
* Retrieves the previous page of results.
|
42
42
|
* @param size Maximum number of results to be retrieved.
|
43
43
|
* @param offset Number of results to skip when retrieving the results.
|
44
44
|
* @returns The previous page or results.
|
45
45
|
*/
|
46
|
-
previousPage(size?: number, offset?: number): Promise<Page<
|
46
|
+
previousPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
47
47
|
/**
|
48
48
|
* Retrieves the first page of results.
|
49
49
|
* @param size Maximum number of results to be retrieved.
|
50
50
|
* @param offset Number of results to skip when retrieving the results.
|
51
51
|
* @returns The first page or results.
|
52
52
|
*/
|
53
|
-
firstPage(size?: number, offset?: number): Promise<Page<
|
53
|
+
firstPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
54
54
|
/**
|
55
55
|
* Retrieves the last page of results.
|
56
56
|
* @param size Maximum number of results to be retrieved.
|
57
57
|
* @param offset Number of results to skip when retrieving the results.
|
58
58
|
* @returns The last page or results.
|
59
59
|
*/
|
60
|
-
lastPage(size?: number, offset?: number): Promise<Page<
|
60
|
+
lastPage(size?: number, offset?: number): Promise<Page<Record, Result>>;
|
61
61
|
/**
|
62
62
|
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
63
63
|
* @returns Whether or not there will be additional results in the next page of results.
|
@@ -77,7 +77,6 @@ class Page {
|
|
77
77
|
return __classPrivateFieldGet(this, _Page_query, "f").getPaginated({ page: { size, offset, last: this.meta.page.cursor } });
|
78
78
|
});
|
79
79
|
}
|
80
|
-
// TODO: We need to add something on the backend if we want a hasPreviousPage
|
81
80
|
/**
|
82
81
|
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
83
82
|
* @returns Whether or not there will be additional results in the next page of results.
|