@xata.io/client 0.0.0-beta.f46df88 → 0.0.0-beta.fcefb29

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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4803b6f: Memoize ApiClient namespaces
8
+ - 1f268d7: Add search in XataClient
9
+ - d58c3d9: Hide private helper utilities
10
+ - f3b731b: Expose branch resolution API
11
+
12
+ ## 0.7.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 01aef78: Fix bundle for browsers
17
+ - 56be1fd: Allow sending updates with link object
18
+ - fc51771: Add includes operator helper methods
19
+
20
+ ## 0.7.0
21
+
22
+ ### Minor Changes
23
+
24
+ - 6ce5512: Add bulk operations for all methods
25
+ - 2a1fa4f: Introduced automatic branch resolution mechanism
26
+
27
+ ### Patch Changes
28
+
29
+ - d033f3a: Improve column selection output type with non-nullable columns
30
+ - b1e92db: Include stack trace with errors
31
+ - deed570: Improve sorting with multiple properties
32
+ - 80b5417: Improve filtering types
33
+
3
34
  ## 0.6.0
4
35
 
5
36
  ### Minor Changes
@@ -5,7 +5,7 @@ import type * as Responses from './responses';
5
5
  import type * as Schemas from './schemas';
6
6
  export interface XataApiClientOptions {
7
7
  fetch?: FetchImpl;
8
- apiKey: string;
8
+ apiKey?: string;
9
9
  host?: HostProvider;
10
10
  }
11
11
  export declare class XataApiClient {
@@ -10,50 +10,63 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  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");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _XataApiClient_extraProps;
13
+ var _XataApiClient_extraProps, _XataApiClient_namespaces;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.XataApiClient = void 0;
16
+ const config_1 = require("../util/config");
17
+ const fetch_1 = require("../util/fetch");
16
18
  const components_1 = require("./components");
17
19
  const providers_1 = require("./providers");
18
20
  class XataApiClient {
19
21
  constructor(options) {
20
22
  var _a, _b;
21
23
  _XataApiClient_extraProps.set(this, void 0);
22
- const globalFetch = typeof fetch !== 'undefined' ? fetch : undefined;
23
- const fetchImpl = (_a = options.fetch) !== null && _a !== void 0 ? _a : globalFetch;
24
- if (!fetchImpl) {
25
- /** @todo add a link after docs exist */
26
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
24
+ _XataApiClient_namespaces.set(this, {});
25
+ const provider = (_a = options.host) !== null && _a !== void 0 ? _a : 'production';
26
+ const apiKey = (_b = options === null || options === void 0 ? void 0 : options.apiKey) !== null && _b !== void 0 ? _b : (0, config_1.getAPIKey)();
27
+ if (!apiKey) {
28
+ throw new Error('Could not resolve a valid apiKey');
27
29
  }
28
- const provider = (_b = options.host) !== null && _b !== void 0 ? _b : 'production';
29
30
  __classPrivateFieldSet(this, _XataApiClient_extraProps, {
30
31
  apiUrl: (0, providers_1.getHostUrl)(provider, 'main'),
31
32
  workspacesApiUrl: (0, providers_1.getHostUrl)(provider, 'workspaces'),
32
- fetchImpl,
33
- apiKey: options.apiKey
33
+ fetchImpl: (0, fetch_1.getFetchImplementation)(options.fetch),
34
+ apiKey
34
35
  }, "f");
35
36
  }
36
37
  get user() {
37
- return new UserApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
38
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").user)
39
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").user = new UserApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
40
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").user;
38
41
  }
39
42
  get workspaces() {
40
- return new WorkspaceApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
43
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").workspaces)
44
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").workspaces = new WorkspaceApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
45
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").workspaces;
41
46
  }
42
47
  get databases() {
43
- return new DatabaseApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
48
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").databases)
49
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").databases = new DatabaseApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
50
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").databases;
44
51
  }
45
52
  get branches() {
46
- return new BranchApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
53
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").branches)
54
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").branches = new BranchApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
55
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").branches;
47
56
  }
48
57
  get tables() {
49
- return new TableApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
58
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").tables)
59
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").tables = new TableApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
60
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").tables;
50
61
  }
51
62
  get records() {
52
- return new RecordsApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
63
+ if (!__classPrivateFieldGet(this, _XataApiClient_namespaces, "f").records)
64
+ __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").records = new RecordsApi(__classPrivateFieldGet(this, _XataApiClient_extraProps, "f"));
65
+ return __classPrivateFieldGet(this, _XataApiClient_namespaces, "f").records;
53
66
  }
54
67
  }
55
68
  exports.XataApiClient = XataApiClient;
56
- _XataApiClient_extraProps = new WeakMap();
69
+ _XataApiClient_extraProps = new WeakMap(), _XataApiClient_namespaces = new WeakMap();
57
70
  class UserApi {
58
71
  constructor(extraProps) {
59
72
  this.extraProps = extraProps;
@@ -221,7 +234,9 @@ class RecordsApi {
221
234
  deleteRecord(workspace, database, branch, tableName, recordId) {
222
235
  return components_1.operationsByTag.records.deleteRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId } }, this.extraProps));
223
236
  }
224
- getRecord(workspace, database, branch, tableName, recordId, options = {}) {
237
+ getRecord(workspace, database, branch, tableName, recordId,
238
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
239
+ options = {}) {
225
240
  return components_1.operationsByTag.records.getRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId } }, this.extraProps));
226
241
  }
227
242
  bulkInsertTableRecords(workspace, database, branch, tableName, records) {
@@ -990,8 +990,9 @@ export declare type QueryTableVariables = {
990
990
  * },
991
991
  * {
992
992
  * "name": "r2",
993
- * },
994
- * ],
993
+ * }
994
+ * ]
995
+ * }
995
996
  * }
996
997
  * ```
997
998
  *
@@ -1001,7 +1002,7 @@ export declare type QueryTableVariables = {
1001
1002
  * {
1002
1003
  * "filter": {
1003
1004
  * "$exists": "settings",
1004
- * },
1005
+ * }
1005
1006
  * }
1006
1007
  * ```
1007
1008
  *
@@ -1016,8 +1017,8 @@ export declare type QueryTableVariables = {
1016
1017
  * },
1017
1018
  * {
1018
1019
  * "$exists": "name",
1019
- * },
1020
- * ],
1020
+ * }
1021
+ * ]
1021
1022
  * }
1022
1023
  * }
1023
1024
  * ```
@@ -1028,7 +1029,7 @@ export declare type QueryTableVariables = {
1028
1029
  * {
1029
1030
  * "filter": {
1030
1031
  * "$notExists": "settings",
1031
- * },
1032
+ * }
1032
1033
  * }
1033
1034
  * ```
1034
1035
  *
@@ -573,8 +573,9 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
573
573
  * },
574
574
  * {
575
575
  * "name": "r2",
576
- * },
577
- * ],
576
+ * }
577
+ * ]
578
+ * }
578
579
  * }
579
580
  * ```
580
581
  *
@@ -584,7 +585,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
584
585
  * {
585
586
  * "filter": {
586
587
  * "$exists": "settings",
587
- * },
588
+ * }
588
589
  * }
589
590
  * ```
590
591
  *
@@ -599,8 +600,8 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
599
600
  * },
600
601
  * {
601
602
  * "$exists": "name",
602
- * },
603
- * ],
603
+ * }
604
+ * ]
604
605
  * }
605
606
  * }
606
607
  * ```
@@ -611,7 +612,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
611
612
  * {
612
613
  * "filter": {
613
614
  * "$notExists": "settings",
614
- * },
615
+ * }
615
616
  * }
616
617
  * ```
617
618
  *
@@ -23,3 +23,18 @@ export declare type FetcherOptions<TBody, THeaders, TQueryParams, TPathParams> =
23
23
  pathParams?: TPathParams;
24
24
  };
25
25
  export declare function fetch<TData, TBody extends Record<string, unknown> | undefined, THeaders extends Record<string, unknown>, TQueryParams extends Record<string, unknown>, TPathParams extends Record<string, string>>({ url: path, method, body, headers, pathParams, queryParams, fetchImpl, apiKey, apiUrl, workspacesApiUrl }: FetcherOptions<TBody, THeaders, TQueryParams, TPathParams> & FetcherExtraProps): Promise<TData>;
26
+ export declare class FetcherError extends Error {
27
+ status: number;
28
+ errors: Array<{
29
+ status: number;
30
+ message?: string;
31
+ }> | undefined;
32
+ constructor(data: {
33
+ message: string;
34
+ status: number;
35
+ errors?: Array<{
36
+ status: number;
37
+ message?: string;
38
+ }>;
39
+ }, parent?: Error);
40
+ }
@@ -9,9 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.fetch = void 0;
13
- /* eslint-disable @typescript-eslint/no-throw-literal */
14
- /* eslint-disable @typescript-eslint/ban-types */
12
+ exports.FetcherError = exports.fetch = void 0;
15
13
  const lang_1 = require("../util/lang");
16
14
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
17
15
  const query = new URLSearchParams(queryParams).toString();
@@ -54,20 +52,28 @@ function fetch({ url: path, method, body, headers, pathParams, queryParams, fetc
54
52
  return jsonResponse;
55
53
  }
56
54
  const { message = 'Unknown error', errors } = jsonResponse;
57
- throw withStatus({ message, errors }, response.status);
55
+ throw new FetcherError({ message, status: response.status, errors });
58
56
  }
59
- catch (e) {
60
- if (isError(e)) {
61
- throw withStatus(e, response.status);
62
- }
63
- else {
64
- throw withStatus({ message: 'Network response was not ok' }, response.status);
65
- }
57
+ catch (error) {
58
+ const message = hasMessage(error) ? error.message : 'Unknown network error';
59
+ const parent = error instanceof Error ? error : undefined;
60
+ throw new FetcherError({ message, status: response.status }, parent);
66
61
  }
67
62
  });
68
63
  }
69
64
  exports.fetch = fetch;
70
- const isError = (error) => {
65
+ const hasMessage = (error) => {
71
66
  return (0, lang_1.isObject)(error) && (0, lang_1.isString)(error.message);
72
67
  };
73
- const withStatus = (error, status) => (0, lang_1.compactObject)(Object.assign(Object.assign({}, error), { status }));
68
+ class FetcherError extends Error {
69
+ constructor(data, parent) {
70
+ super(data.message);
71
+ this.status = data.status;
72
+ this.errors = data.errors;
73
+ if (parent) {
74
+ this.stack = parent.stack;
75
+ this.cause = parent.cause;
76
+ }
77
+ }
78
+ }
79
+ exports.FetcherError = FetcherError;
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export declare class XataError extends Error {
4
4
  }
5
5
  export * from './api';
6
6
  export * from './schema';
7
+ export * from './util/config';
package/dist/index.js CHANGED
@@ -24,3 +24,4 @@ class XataError extends Error {
24
24
  exports.XataError = XataError;
25
25
  __exportStar(require("./api"), exports);
26
26
  __exportStar(require("./schema"), exports);
27
+ __exportStar(require("./util/config"), exports);
@@ -1,22 +1,96 @@
1
- import { XataRecord } from './record';
2
- import { SelectableColumn } from './selection';
3
- export declare type SortDirection = 'asc' | 'desc';
4
- export declare type SortFilterExtended<T extends XataRecord> = {
5
- column: SelectableColumn<T>;
6
- direction?: SortDirection;
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>>;
7
23
  };
8
- export declare type SortFilter<T extends XataRecord> = SelectableColumn<T> | SortFilterExtended<T>;
9
- export declare function isSortFilterObject<T extends XataRecord>(filter: SortFilter<T>): filter is SortFilterExtended<T>;
10
- export declare type FilterOperator = '$gt' | '$lt' | '$ge' | '$le' | '$exists' | '$notExists' | '$endsWith' | '$startsWith' | '$pattern' | '$is' | '$isNot' | '$contains' | '$includes' | '$includesSubstring' | '$includesPattern' | '$includesAll';
11
- export declare function buildSortFilter<T extends XataRecord>(filter?: SortFilter<T> | SortFilter<T>[]): {
12
- [key: string]: SortDirection;
13
- } | undefined;
14
- export declare type Constraint<T> = {
15
- [key in FilterOperator]?: T;
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
+ }>;
16
37
  };
17
- export declare type DeepConstraint<T> = T extends Record<string, any> ? {
18
- [key in keyof T]?: T[key] | DeepConstraint<T[key]>;
19
- } : Constraint<T>;
20
- export declare type FilterConstraints<T> = {
21
- [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;
22
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 {};
@@ -1,25 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSortFilter = exports.isSortFilterObject = void 0;
4
- const lang_1 = require("../util/lang");
5
- function isSortFilterObject(filter) {
6
- return (0, lang_1.isObject)(filter) && filter.column !== undefined;
7
- }
8
- exports.isSortFilterObject = isSortFilterObject;
9
- function buildSortFilter(filter) {
10
- if (!filter)
11
- return undefined;
12
- const filters = Array.isArray(filter) ? filter : [filter];
13
- return filters.reduce((acc, item) => {
14
- if (typeof item === 'string') {
15
- return Object.assign(Object.assign({}, acc), { [item]: 'asc' });
16
- }
17
- else if (isSortFilterObject(item)) {
18
- return Object.assign(Object.assign({}, acc), { [item.column]: item.direction });
19
- }
20
- else {
21
- return acc;
22
- }
23
- }, {});
24
- }
25
- exports.buildSortFilter = buildSortFilter;
@@ -0,0 +1 @@
1
+ export {};
@@ -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
+ });