@xata.io/client 0.0.0-beta.d4d1df0 → 0.0.0-beta.e5ce1d8

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 ADDED
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ ignorePatterns: ["dist"],
3
+ parserOptions: {
4
+ ecmaVersion: 2020,
5
+ sourceType: 'module',
6
+ project: 'client/tsconfig.json'
7
+ },
8
+ rules: {
9
+ '@typescript-eslint/no-explicit-any': 'off',
10
+ '@typescript-eslint/ban-types': 'off',
11
+ '@typescript-eslint/no-floating-promises': 'error',
12
+ }
13
+ };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 12729ab: Make API client fetch implementation optional
8
+
9
+ ## 0.5.0
10
+
11
+ ### Patch Changes
12
+
13
+ - 14ec7d1: Fix in Selectable type
14
+
15
+ ## 0.4.0
16
+
17
+ ### Patch Changes
18
+
19
+ - b951331: Add support for new float column
20
+ - d470610: Add new getAll() method
21
+ - eaf92a8: Expose pagination constants (size and offset limits)
22
+ - 57fde77: Reduce subrequests for createMany
23
+ - eaf92a8: Implement schema-less client
24
+ - 97a3caa: Make createBranch from optional with empty branch
25
+
3
26
  ## 0.3.0
4
27
 
5
28
  ### Minor Changes
@@ -4,7 +4,7 @@ import { HostProvider } from './providers';
4
4
  import type * as Responses from './responses';
5
5
  import type * as Schemas from './schemas';
6
6
  export interface XataApiClientOptions {
7
- fetch: FetchImpl;
7
+ fetch?: FetchImpl;
8
8
  apiKey: string;
9
9
  host?: HostProvider;
10
10
  }
@@ -17,14 +17,15 @@ const components_1 = require("./components");
17
17
  const providers_1 = require("./providers");
18
18
  class XataApiClient {
19
19
  constructor(options) {
20
- var _a;
20
+ var _a, _b;
21
21
  _XataApiClient_extraProps.set(this, void 0);
22
- const fetchImpl = typeof fetch !== 'undefined' ? fetch : options.fetch;
22
+ const globalFetch = typeof fetch !== 'undefined' ? fetch : undefined;
23
+ const fetchImpl = (_a = options.fetch) !== null && _a !== void 0 ? _a : globalFetch;
23
24
  if (!fetchImpl) {
24
25
  /** @todo add a link after docs exist */
25
26
  throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
26
27
  }
27
- const provider = (_a = options.host) !== null && _a !== void 0 ? _a : 'production';
28
+ const provider = (_b = options.host) !== null && _b !== void 0 ? _b : 'production';
28
29
  __classPrivateFieldSet(this, _XataApiClient_extraProps, {
29
30
  apiUrl: (0, providers_1.getHostUrl)(provider, 'main'),
30
31
  workspacesApiUrl: (0, providers_1.getHostUrl)(provider, 'workspaces'),
@@ -141,7 +142,7 @@ class BranchApi {
141
142
  getBranchDetails(workspace, database, branch) {
142
143
  return components_1.operationsByTag.branch.getBranchDetails(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
143
144
  }
144
- createBranch(workspace, database, branch, from, options = {}) {
145
+ createBranch(workspace, database, branch, from = '', options = {}) {
145
146
  return components_1.operationsByTag.branch.createBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, queryParams: { from }, body: options }, this.extraProps));
146
147
  }
147
148
  deleteBranch(workspace, database, branch) {
@@ -875,7 +875,7 @@ export declare type QueryTableVariables = {
875
875
  * `$none`, etc.
876
876
  *
877
877
  * All operators start with an `$` to differentiate them from column names
878
- * (which are not allowed to start with an underscore).
878
+ * (which are not allowed to start with an dollar sign).
879
879
  *
880
880
  * #### Exact matching and control operators
881
881
  *
@@ -943,27 +943,17 @@ export declare type QueryTableVariables = {
943
943
  * }
944
944
  * ```
945
945
  *
946
- * If you want to OR together multiple values, you can use an array of values:
946
+ * If you want to OR together multiple values, you can use the `$any` operator with an array of values:
947
947
  *
948
948
  * ```json
949
949
  * {
950
950
  * "filter": {
951
- * "settings.plan": ["free", "paid"]
951
+ * "settings.plan": {"$any": ["free", "paid"]}
952
952
  * },
953
953
  * }
954
954
  * ```
955
955
  *
956
- * Same query with `$is` operator:
957
- *
958
- * ```json
959
- * {
960
- * "filter": {
961
- * "settings.plan": { "$is": ["free", "paid"]}
962
- * },
963
- * }
964
- * ```
965
- *
966
- * Specifying multiple columns, ANDs them together:
956
+ * If you specify multiple columns in the same filter, they are logically AND'ed together:
967
957
  *
968
958
  * ```json
969
959
  * {
@@ -974,6 +964,8 @@ export declare type QueryTableVariables = {
974
964
  * }
975
965
  * ```
976
966
  *
967
+ * The above matches if both conditions are met.
968
+ *
977
969
  * To be more explicit about it, you can use `$all` or `$any`:
978
970
  *
979
971
  * ```json
@@ -981,13 +973,13 @@ export declare type QueryTableVariables = {
981
973
  * "filter": {
982
974
  * "$any": {
983
975
  * "settings.dark": true,
984
- * "settings.plan": "free",
976
+ * "settings.plan": "free"
985
977
  * }
986
978
  * },
987
979
  * }
988
980
  * ```
989
981
  *
990
- * `$all` and `$any` can also receive an array of objects, which allows for repeating columns:
982
+ * The `$all` and `$any` operators can also receive an array of objects, which allows for repeating column names:
991
983
  *
992
984
  * ```json
993
985
  * {
@@ -1030,7 +1022,7 @@ export declare type QueryTableVariables = {
1030
1022
  * }
1031
1023
  * ```
1032
1024
  *
1033
- * We can also make the negation version, `$notExists` :
1025
+ * Or you can use the inverse operator `$notExists`:
1034
1026
  *
1035
1027
  * ```json
1036
1028
  * {
@@ -1083,7 +1075,7 @@ export declare type QueryTableVariables = {
1083
1075
  * }
1084
1076
  * ```
1085
1077
  *
1086
- * #### Numeric/date ranges
1078
+ * #### Numeric ranges
1087
1079
  *
1088
1080
  * ```json
1089
1081
  * {
@@ -1098,18 +1090,6 @@ export declare type QueryTableVariables = {
1098
1090
  *
1099
1091
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
1100
1092
  *
1101
- * Date ranges would support the same operators, with the date as string in RFC 3339:
1102
- *
1103
- * ```json
1104
- * {
1105
- * "filter": {
1106
- * "<column_name>": {
1107
- * "$gt": "2019-10-12T07:20:50.52Z",
1108
- * "$lt": "2021-10-12T07:20:50.52Z"
1109
- * }
1110
- * }
1111
- * }
1112
- * ```
1113
1093
  *
1114
1094
  * #### Negations
1115
1095
  *
@@ -1162,7 +1142,7 @@ export declare type QueryTableVariables = {
1162
1142
  * }
1163
1143
  * ```
1164
1144
  *
1165
- * In addition, we can add specific operators like `$isNot` to simplify expressions:
1145
+ * In addition, you can use operators like `$isNot` or `$notExists` to simplify expressions:
1166
1146
  *
1167
1147
  * ```json
1168
1148
  * {
@@ -1213,6 +1193,22 @@ export declare type QueryTableVariables = {
1213
1193
  * predicate. The `$includes` operator is a synonym for the `$includesAny`
1214
1194
  * operator.
1215
1195
  *
1196
+ * Here is an example of using the `$includesAll` operator:
1197
+ *
1198
+ * ```json
1199
+ * {
1200
+ * "filter": {
1201
+ * "settings.labels": {
1202
+ * "$includesAll": [
1203
+ * {"$contains": "label"},
1204
+ * ]
1205
+ * }
1206
+ * }
1207
+ * }
1208
+ * ```
1209
+ *
1210
+ * The above matches if all label values contain the string "labels".
1211
+ *
1216
1212
  * ### Sorting
1217
1213
  *
1218
1214
  * Sorting by one element:
@@ -458,7 +458,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
458
458
  * `$none`, etc.
459
459
  *
460
460
  * All operators start with an `$` to differentiate them from column names
461
- * (which are not allowed to start with an underscore).
461
+ * (which are not allowed to start with an dollar sign).
462
462
  *
463
463
  * #### Exact matching and control operators
464
464
  *
@@ -526,27 +526,17 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
526
526
  * }
527
527
  * ```
528
528
  *
529
- * If you want to OR together multiple values, you can use an array of values:
529
+ * If you want to OR together multiple values, you can use the `$any` operator with an array of values:
530
530
  *
531
531
  * ```json
532
532
  * {
533
533
  * "filter": {
534
- * "settings.plan": ["free", "paid"]
534
+ * "settings.plan": {"$any": ["free", "paid"]}
535
535
  * },
536
536
  * }
537
537
  * ```
538
538
  *
539
- * Same query with `$is` operator:
540
- *
541
- * ```json
542
- * {
543
- * "filter": {
544
- * "settings.plan": { "$is": ["free", "paid"]}
545
- * },
546
- * }
547
- * ```
548
- *
549
- * Specifying multiple columns, ANDs them together:
539
+ * If you specify multiple columns in the same filter, they are logically AND'ed together:
550
540
  *
551
541
  * ```json
552
542
  * {
@@ -557,6 +547,8 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
557
547
  * }
558
548
  * ```
559
549
  *
550
+ * The above matches if both conditions are met.
551
+ *
560
552
  * To be more explicit about it, you can use `$all` or `$any`:
561
553
  *
562
554
  * ```json
@@ -564,13 +556,13 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
564
556
  * "filter": {
565
557
  * "$any": {
566
558
  * "settings.dark": true,
567
- * "settings.plan": "free",
559
+ * "settings.plan": "free"
568
560
  * }
569
561
  * },
570
562
  * }
571
563
  * ```
572
564
  *
573
- * `$all` and `$any` can also receive an array of objects, which allows for repeating columns:
565
+ * The `$all` and `$any` operators can also receive an array of objects, which allows for repeating column names:
574
566
  *
575
567
  * ```json
576
568
  * {
@@ -613,7 +605,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
613
605
  * }
614
606
  * ```
615
607
  *
616
- * We can also make the negation version, `$notExists` :
608
+ * Or you can use the inverse operator `$notExists`:
617
609
  *
618
610
  * ```json
619
611
  * {
@@ -666,7 +658,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
666
658
  * }
667
659
  * ```
668
660
  *
669
- * #### Numeric/date ranges
661
+ * #### Numeric ranges
670
662
  *
671
663
  * ```json
672
664
  * {
@@ -681,18 +673,6 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
681
673
  *
682
674
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
683
675
  *
684
- * Date ranges would support the same operators, with the date as string in RFC 3339:
685
- *
686
- * ```json
687
- * {
688
- * "filter": {
689
- * "<column_name>": {
690
- * "$gt": "2019-10-12T07:20:50.52Z",
691
- * "$lt": "2021-10-12T07:20:50.52Z"
692
- * }
693
- * }
694
- * }
695
- * ```
696
676
  *
697
677
  * #### Negations
698
678
  *
@@ -745,7 +725,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
745
725
  * }
746
726
  * ```
747
727
  *
748
- * In addition, we can add specific operators like `$isNot` to simplify expressions:
728
+ * In addition, you can use operators like `$isNot` or `$notExists` to simplify expressions:
749
729
  *
750
730
  * ```json
751
731
  * {
@@ -796,6 +776,22 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
796
776
  * predicate. The `$includes` operator is a synonym for the `$includesAny`
797
777
  * operator.
798
778
  *
779
+ * Here is an example of using the `$includesAll` operator:
780
+ *
781
+ * ```json
782
+ * {
783
+ * "filter": {
784
+ * "settings.labels": {
785
+ * "$includesAll": [
786
+ * {"$contains": "label"},
787
+ * ]
788
+ * }
789
+ * }
790
+ * }
791
+ * ```
792
+ *
793
+ * The above matches if all label values contain the string "labels".
794
+ *
799
795
  * ### Sorting
800
796
  *
801
797
  * Sorting by one element:
@@ -10,12 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.fetch = void 0;
13
+ /* eslint-disable @typescript-eslint/no-throw-literal */
14
+ /* eslint-disable @typescript-eslint/ban-types */
15
+ const lang_1 = require("../util/lang");
13
16
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
14
17
  const query = new URLSearchParams(queryParams).toString();
15
18
  const queryString = query.length > 0 ? `?${query}` : '';
16
19
  return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
17
20
  };
18
- const fallbackError = { message: 'Network response was not ok' };
19
21
  function buildBaseUrl({ path, workspacesApiUrl, apiUrl, pathParams }) {
20
22
  if (!(pathParams === null || pathParams === void 0 ? void 0 : pathParams.workspace))
21
23
  return `${apiUrl}${path}`;
@@ -51,28 +53,21 @@ function fetch({ url: path, method, body, headers, pathParams, queryParams, fetc
51
53
  if (response.ok) {
52
54
  return jsonResponse;
53
55
  }
54
- if (jsonResponse.message) {
55
- throw withStatus({ message: jsonResponse.message }, response.status);
56
- }
57
- else {
58
- throw withStatus(fallbackError, response.status);
59
- }
56
+ const { message = 'Unknown error', errors } = jsonResponse;
57
+ throw withStatus({ message, errors }, response.status);
60
58
  }
61
59
  catch (e) {
62
- if (e instanceof Error) {
63
- const error = {
64
- message: e.message
65
- };
66
- throw withStatus(error, response.status);
67
- }
68
- else if (typeof e === 'object' && typeof e.message === 'string') {
60
+ if (isError(e)) {
69
61
  throw withStatus(e, response.status);
70
62
  }
71
63
  else {
72
- throw withStatus(fallbackError, response.status);
64
+ throw withStatus({ message: 'Network response was not ok' }, response.status);
73
65
  }
74
66
  }
75
67
  });
76
68
  }
77
69
  exports.fetch = fetch;
78
- const withStatus = (error, status) => (Object.assign(Object.assign({}, error), { status }));
70
+ const isError = (error) => {
71
+ return (0, lang_1.isObject)(error) && (0, lang_1.isString)(error.message);
72
+ };
73
+ const withStatus = (error, status) => (0, lang_1.compactObject)(Object.assign(Object.assign({}, error), { status }));
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getHostUrl = void 0;
4
+ const lang_1 = require("../util/lang");
4
5
  function getHostUrl(provider, type) {
5
6
  if (isValidAlias(provider)) {
6
7
  return providers[provider][type];
@@ -22,8 +23,8 @@ const providers = {
22
23
  }
23
24
  };
24
25
  function isValidAlias(alias) {
25
- return typeof alias === 'string' && Object.keys(providers).includes(alias);
26
+ return (0, lang_1.isString)(alias) && Object.keys(providers).includes(alias);
26
27
  }
27
28
  function isValidBuilder(builder) {
28
- return typeof builder === 'object' && typeof builder.main === 'string' && typeof builder.workspaces === 'string';
29
+ return (0, lang_1.isObject)(builder) && (0, lang_1.isString)(builder.main) && (0, lang_1.isString)(builder.workspaces);
29
30
  }
@@ -19,6 +19,12 @@ export declare type AuthError = {
19
19
  id?: string;
20
20
  message: string;
21
21
  };
22
+ export declare type BulkError = {
23
+ errors: {
24
+ message?: string;
25
+ status?: number;
26
+ }[];
27
+ };
22
28
  export declare type BranchMigrationPlan = {
23
29
  version: number;
24
30
  migration: Schemas.BranchMigration;
@@ -1,12 +1,14 @@
1
+ import { XataRecord } from './record';
2
+ import { SelectableColumn } from './selection';
1
3
  export declare type SortDirection = 'asc' | 'desc';
2
- export declare type SortFilterExtended<T> = {
3
- column: keyof T;
4
+ export declare type SortFilterExtended<T extends XataRecord> = {
5
+ column: SelectableColumn<T>;
4
6
  direction?: SortDirection;
5
7
  };
6
- export declare type SortFilter<T> = SortFilterExtended<T> | keyof T;
7
- export declare function isSortFilterObject<T>(filter: SortFilter<T>): filter is SortFilterExtended<T>;
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>;
8
10
  export declare type FilterOperator = '$gt' | '$lt' | '$ge' | '$le' | '$exists' | '$notExists' | '$endsWith' | '$startsWith' | '$pattern' | '$is' | '$isNot' | '$contains' | '$includes' | '$includesSubstring' | '$includesPattern' | '$includesAll';
9
- export declare function buildSortFilter<T>(filter?: SortFilter<T> | SortFilter<T>[]): {
11
+ export declare function buildSortFilter<T extends XataRecord>(filter?: SortFilter<T> | SortFilter<T>[]): {
10
12
  [key: string]: SortDirection;
11
13
  } | undefined;
12
14
  export declare type Constraint<T> = {
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildSortFilter = exports.isSortFilterObject = void 0;
4
+ const lang_1 = require("../util/lang");
4
5
  function isSortFilterObject(filter) {
5
- return typeof filter === 'object' && filter.column !== undefined;
6
+ return (0, lang_1.isObject)(filter) && filter.column !== undefined;
6
7
  }
7
8
  exports.isSortFilterObject = isSortFilterObject;
8
9
  function buildSortFilter(filter) {
@@ -1,5 +1,7 @@
1
1
  export * from './operators';
2
- export type { XataRecord } from './record';
3
- export { Repository, RestRepository, RestRespositoryFactory, BaseClient } from './repository';
4
- export type { XataClientOptions } from './repository';
2
+ export * from './pagination';
5
3
  export { Query } from './query';
4
+ export { isIdentifiable, isXataRecord } from './record';
5
+ export type { Identifiable, XataRecord } from './record';
6
+ export { BaseClient, Repository, RestRepository, RestRespositoryFactory } from './repository';
7
+ export type { XataClientOptions } from './repository';
@@ -14,12 +14,16 @@ 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.Query = exports.BaseClient = exports.RestRespositoryFactory = exports.RestRepository = exports.Repository = 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
+ __exportStar(require("./pagination"), exports);
20
+ var query_1 = require("./query");
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; } });
19
25
  var repository_1 = require("./repository");
26
+ Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return repository_1.BaseClient; } });
20
27
  Object.defineProperty(exports, "Repository", { enumerable: true, get: function () { return repository_1.Repository; } });
21
28
  Object.defineProperty(exports, "RestRepository", { enumerable: true, get: function () { return repository_1.RestRepository; } });
22
29
  Object.defineProperty(exports, "RestRespositoryFactory", { enumerable: true, get: function () { return repository_1.RestRespositoryFactory; } });
23
- Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return repository_1.BaseClient; } });
24
- var query_1 = require("./query");
25
- Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_1.Query; } });
@@ -1,25 +1,25 @@
1
- import { XataRecord } from '..';
2
1
  import { Query } from './query';
2
+ import { XataRecord } from './record';
3
3
  export declare type PaginationQueryMeta = {
4
4
  page: {
5
5
  cursor: string;
6
6
  more: boolean;
7
7
  };
8
8
  };
9
- export interface Paginable<T extends XataRecord, R extends XataRecord = T> {
9
+ export interface Paginable<Record extends XataRecord, Result extends XataRecord = Record> {
10
10
  meta: PaginationQueryMeta;
11
- records: R[];
12
- nextPage(size?: number, offset?: number): Promise<Page<T, R>>;
13
- previousPage(size?: number, offset?: number): Promise<Page<T, R>>;
14
- firstPage(size?: number, offset?: number): Promise<Page<T, R>>;
15
- lastPage(size?: number, offset?: number): Promise<Page<T, R>>;
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<T extends XataRecord, R extends XataRecord> implements Paginable<T, R> {
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> implements
28
28
  /**
29
29
  * The set of results for this page.
30
30
  */
31
- readonly records: R[];
32
- constructor(query: Query<T, R>, meta: PaginationQueryMeta, records?: R[]);
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<T, R>>;
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<T, R>>;
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<T, R>>;
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<T, R>>;
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,3 +77,7 @@ export declare type OffsetNavigationOptions = {
77
77
  offset?: number;
78
78
  };
79
79
  export declare type PaginationOptions = CursorNavigationOptions & OffsetNavigationOptions;
80
+ export declare const PAGINATION_MAX_SIZE = 200;
81
+ export declare const PAGINATION_DEFAULT_SIZE = 200;
82
+ export declare const PAGINATION_MAX_OFFSET = 800;
83
+ export declare const PAGINATION_DEFAULT_OFFSET = 0;
@@ -21,7 +21,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
21
21
  };
22
22
  var _Page_query;
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.Page = void 0;
24
+ exports.PAGINATION_DEFAULT_OFFSET = exports.PAGINATION_MAX_OFFSET = exports.PAGINATION_DEFAULT_SIZE = exports.PAGINATION_MAX_SIZE = exports.Page = void 0;
25
25
  /**
26
26
  * A Page contains a set of results from a query plus metadata about the retrieved
27
27
  * set of values such as the cursor, required to retrieve additional records.
@@ -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.
@@ -88,3 +87,7 @@ class Page {
88
87
  }
89
88
  exports.Page = Page;
90
89
  _Page_query = new WeakMap();
90
+ exports.PAGINATION_MAX_SIZE = 200;
91
+ exports.PAGINATION_DEFAULT_SIZE = 200;
92
+ exports.PAGINATION_MAX_OFFSET = 800;
93
+ exports.PAGINATION_DEFAULT_OFFSET = 0;