@xata.io/client 0.0.0-beta.914c21b → 0.0.0-beta.9559ec0

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 ADDED
@@ -0,0 +1,49 @@
1
+ # @xata.io/client
2
+
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 084f5df: Add type inference for columns
8
+ - bb73c89: Unify create and insert in a single method overload
9
+
10
+ ### Patch Changes
11
+
12
+ - 716c487: Forward nullable types on links
13
+ - bb66bb2: Fix error handling with createMany
14
+ - 084f5df: Fix circular dependencies on selectable column
15
+
16
+ ## 0.5.1
17
+
18
+ ### Patch Changes
19
+
20
+ - 12729ab: Make API client fetch implementation optional
21
+
22
+ ## 0.5.0
23
+
24
+ ### Patch Changes
25
+
26
+ - 14ec7d1: Fix in Selectable type
27
+
28
+ ## 0.4.0
29
+
30
+ ### Patch Changes
31
+
32
+ - b951331: Add support for new float column
33
+ - d470610: Add new getAll() method
34
+ - eaf92a8: Expose pagination constants (size and offset limits)
35
+ - 57fde77: Reduce subrequests for createMany
36
+ - eaf92a8: Implement schema-less client
37
+ - 97a3caa: Make createBranch from optional with empty branch
38
+
39
+ ## 0.3.0
40
+
41
+ ### Minor Changes
42
+
43
+ - 1c0a454: Add API Client and internally use it
44
+
45
+ ### Patch Changes
46
+
47
+ - 122321c: Fix client in CF workers and Deno
48
+ - a2671b5: Allow cancel or resend workspace invites
49
+ - e73d470: Split insert and create
@@ -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
  }
@@ -40,6 +40,8 @@ declare class WorkspaceApi {
40
40
  updateWorkspaceMemberRole(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID, role: Schemas.Role): Promise<void>;
41
41
  removeWorkspaceMember(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID): Promise<void>;
42
42
  inviteWorkspaceMember(workspaceId: Schemas.WorkspaceID, email: string, role: Schemas.Role): Promise<Schemas.WorkspaceInvite>;
43
+ cancelWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteId: Schemas.InviteID): Promise<void>;
44
+ resendWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteId: Schemas.InviteID): Promise<void>;
43
45
  acceptWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteKey: Schemas.InviteKey): Promise<void>;
44
46
  }
45
47
  declare class DatabaseApi {
@@ -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'),
@@ -107,6 +108,12 @@ class WorkspaceApi {
107
108
  inviteWorkspaceMember(workspaceId, email, role) {
108
109
  return components_1.operationsByTag.workspaces.inviteWorkspaceMember(Object.assign({ pathParams: { workspaceId }, body: { email, role } }, this.extraProps));
109
110
  }
111
+ cancelWorkspaceMemberInvite(workspaceId, inviteId) {
112
+ return components_1.operationsByTag.workspaces.cancelWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteId } }, this.extraProps));
113
+ }
114
+ resendWorkspaceMemberInvite(workspaceId, inviteId) {
115
+ return components_1.operationsByTag.workspaces.resendWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteId } }, this.extraProps));
116
+ }
110
117
  acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
111
118
  return components_1.operationsByTag.workspaces.acceptWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteKey } }, this.extraProps));
112
119
  }
@@ -135,7 +142,7 @@ class BranchApi {
135
142
  getBranchDetails(workspace, database, branch) {
136
143
  return components_1.operationsByTag.branch.getBranchDetails(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
137
144
  }
138
- createBranch(workspace, database, branch, from, options = {}) {
145
+ createBranch(workspace, database, branch, from = '', options = {}) {
139
146
  return components_1.operationsByTag.branch.createBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, queryParams: { from }, body: options }, this.extraProps));
140
147
  }
141
148
  deleteBranch(workspace, database, branch) {
@@ -161,6 +161,28 @@ export declare type InviteWorkspaceMemberVariables = {
161
161
  * Invite some user to join the workspace with the given role
162
162
  */
163
163
  export declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
164
+ export declare type CancelWorkspaceMemberInvitePathParams = {
165
+ workspaceId: Schemas.WorkspaceID;
166
+ inviteId: Schemas.InviteID;
167
+ };
168
+ export declare type CancelWorkspaceMemberInviteVariables = {
169
+ pathParams: CancelWorkspaceMemberInvitePathParams;
170
+ } & FetcherExtraProps;
171
+ /**
172
+ * This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
173
+ */
174
+ export declare const cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
175
+ export declare type ResendWorkspaceMemberInvitePathParams = {
176
+ workspaceId: Schemas.WorkspaceID;
177
+ inviteId: Schemas.InviteID;
178
+ };
179
+ export declare type ResendWorkspaceMemberInviteVariables = {
180
+ pathParams: ResendWorkspaceMemberInvitePathParams;
181
+ } & FetcherExtraProps;
182
+ /**
183
+ * This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
184
+ */
185
+ export declare const resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
164
186
  export declare type AcceptWorkspaceMemberInvitePathParams = {
165
187
  workspaceId: Schemas.WorkspaceID;
166
188
  inviteKey: Schemas.InviteKey;
@@ -853,7 +875,7 @@ export declare type QueryTableVariables = {
853
875
  * `$none`, etc.
854
876
  *
855
877
  * All operators start with an `$` to differentiate them from column names
856
- * (which are not allowed to start with an underscore).
878
+ * (which are not allowed to start with an dollar sign).
857
879
  *
858
880
  * #### Exact matching and control operators
859
881
  *
@@ -921,27 +943,17 @@ export declare type QueryTableVariables = {
921
943
  * }
922
944
  * ```
923
945
  *
924
- * 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:
925
947
  *
926
948
  * ```json
927
949
  * {
928
950
  * "filter": {
929
- * "settings.plan": ["free", "paid"]
951
+ * "settings.plan": {"$any": ["free", "paid"]}
930
952
  * },
931
953
  * }
932
954
  * ```
933
955
  *
934
- * Same query with `$is` operator:
935
- *
936
- * ```json
937
- * {
938
- * "filter": {
939
- * "settings.plan": { "$is": ["free", "paid"]}
940
- * },
941
- * }
942
- * ```
943
- *
944
- * Specifying multiple columns, ANDs them together:
956
+ * If you specify multiple columns in the same filter, they are logically AND'ed together:
945
957
  *
946
958
  * ```json
947
959
  * {
@@ -952,6 +964,8 @@ export declare type QueryTableVariables = {
952
964
  * }
953
965
  * ```
954
966
  *
967
+ * The above matches if both conditions are met.
968
+ *
955
969
  * To be more explicit about it, you can use `$all` or `$any`:
956
970
  *
957
971
  * ```json
@@ -959,13 +973,13 @@ export declare type QueryTableVariables = {
959
973
  * "filter": {
960
974
  * "$any": {
961
975
  * "settings.dark": true,
962
- * "settings.plan": "free",
976
+ * "settings.plan": "free"
963
977
  * }
964
978
  * },
965
979
  * }
966
980
  * ```
967
981
  *
968
- * `$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:
969
983
  *
970
984
  * ```json
971
985
  * {
@@ -1008,7 +1022,7 @@ export declare type QueryTableVariables = {
1008
1022
  * }
1009
1023
  * ```
1010
1024
  *
1011
- * We can also make the negation version, `$notExists` :
1025
+ * Or you can use the inverse operator `$notExists`:
1012
1026
  *
1013
1027
  * ```json
1014
1028
  * {
@@ -1061,7 +1075,7 @@ export declare type QueryTableVariables = {
1061
1075
  * }
1062
1076
  * ```
1063
1077
  *
1064
- * #### Numeric/date ranges
1078
+ * #### Numeric ranges
1065
1079
  *
1066
1080
  * ```json
1067
1081
  * {
@@ -1076,18 +1090,6 @@ export declare type QueryTableVariables = {
1076
1090
  *
1077
1091
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
1078
1092
  *
1079
- * Date ranges would support the same operators, with the date as string in RFC 3339:
1080
- *
1081
- * ```json
1082
- * {
1083
- * "filter": {
1084
- * "<column_name>": {
1085
- * "$gt": "2019-10-12T07:20:50.52Z",
1086
- * "$lt": "2021-10-12T07:20:50.52Z"
1087
- * }
1088
- * }
1089
- * }
1090
- * ```
1091
1093
  *
1092
1094
  * #### Negations
1093
1095
  *
@@ -1140,7 +1142,7 @@ export declare type QueryTableVariables = {
1140
1142
  * }
1141
1143
  * ```
1142
1144
  *
1143
- * 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:
1144
1146
  *
1145
1147
  * ```json
1146
1148
  * {
@@ -1191,6 +1193,22 @@ export declare type QueryTableVariables = {
1191
1193
  * predicate. The `$includes` operator is a synonym for the `$includesAny`
1192
1194
  * operator.
1193
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
+ *
1194
1212
  * ### Sorting
1195
1213
  *
1196
1214
  * Sorting by one element:
@@ -1371,6 +1389,8 @@ export declare const operationsByTag: {
1371
1389
  updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
1372
1390
  removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
1373
1391
  inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
1392
+ cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
1393
+ resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
1374
1394
  acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
1375
1395
  };
1376
1396
  database: {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.operationsByTag = exports.searchBranch = exports.queryTable = exports.bulkInsertTableRecords = exports.getRecord = exports.deleteRecord = exports.upsertRecordWithID = exports.updateRecordWithID = exports.insertRecordWithID = exports.insertRecord = exports.updateColumn = exports.deleteColumn = exports.getColumn = exports.addTableColumn = exports.getTableColumns = exports.setTableSchema = exports.getTableSchema = exports.updateTable = exports.deleteTable = exports.createTable = exports.getBranchStats = exports.getBranchMigrationPlan = exports.executeBranchMigrationPlan = exports.getBranchMigrationHistory = exports.getBranchMetadata = exports.updateBranchMetadata = exports.deleteBranch = exports.createBranch = exports.getBranchDetails = exports.deleteDatabase = exports.createDatabase = exports.getBranchList = exports.getDatabaseList = exports.acceptWorkspaceMemberInvite = exports.inviteWorkspaceMember = exports.removeWorkspaceMember = exports.updateWorkspaceMemberRole = exports.getWorkspaceMembersList = exports.deleteWorkspace = exports.updateWorkspace = exports.getWorkspace = exports.getWorkspacesList = exports.createWorkspace = exports.deleteUserAPIKey = exports.createUserAPIKey = exports.getUserAPIKeys = exports.deleteUser = exports.updateUser = exports.getUser = void 0;
3
+ exports.searchBranch = exports.queryTable = exports.bulkInsertTableRecords = exports.getRecord = exports.deleteRecord = exports.upsertRecordWithID = exports.updateRecordWithID = exports.insertRecordWithID = exports.insertRecord = exports.updateColumn = exports.deleteColumn = exports.getColumn = exports.addTableColumn = exports.getTableColumns = exports.setTableSchema = exports.getTableSchema = exports.updateTable = exports.deleteTable = exports.createTable = exports.getBranchStats = exports.getBranchMigrationPlan = exports.executeBranchMigrationPlan = exports.getBranchMigrationHistory = exports.getBranchMetadata = exports.updateBranchMetadata = exports.deleteBranch = exports.createBranch = exports.getBranchDetails = exports.deleteDatabase = exports.createDatabase = exports.getBranchList = exports.getDatabaseList = exports.acceptWorkspaceMemberInvite = exports.resendWorkspaceMemberInvite = exports.cancelWorkspaceMemberInvite = exports.inviteWorkspaceMember = exports.removeWorkspaceMember = exports.updateWorkspaceMemberRole = exports.getWorkspaceMembersList = exports.deleteWorkspace = exports.updateWorkspace = exports.getWorkspace = exports.getWorkspacesList = exports.createWorkspace = exports.deleteUserAPIKey = exports.createUserAPIKey = exports.getUserAPIKeys = exports.deleteUser = exports.updateUser = exports.getUser = void 0;
4
+ exports.operationsByTag = void 0;
4
5
  /**
5
6
  * Generated by @openapi-codegen
6
7
  *
@@ -82,6 +83,16 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
82
83
  */
83
84
  const inviteWorkspaceMember = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites', method: 'post' }, variables));
84
85
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
86
+ /**
87
+ * This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
88
+ */
89
+ const cancelWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}', method: 'delete' }, variables));
90
+ exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
91
+ /**
92
+ * This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
93
+ */
94
+ const resendWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}/resend', method: 'post' }, variables));
95
+ exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
85
96
  /**
86
97
  * Accept the invitation to join a workspace. If the operation succeeds the user will be a member of the workspace
87
98
  */
@@ -447,7 +458,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
447
458
  * `$none`, etc.
448
459
  *
449
460
  * All operators start with an `$` to differentiate them from column names
450
- * (which are not allowed to start with an underscore).
461
+ * (which are not allowed to start with an dollar sign).
451
462
  *
452
463
  * #### Exact matching and control operators
453
464
  *
@@ -515,27 +526,17 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
515
526
  * }
516
527
  * ```
517
528
  *
518
- * 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:
519
530
  *
520
531
  * ```json
521
532
  * {
522
533
  * "filter": {
523
- * "settings.plan": ["free", "paid"]
534
+ * "settings.plan": {"$any": ["free", "paid"]}
524
535
  * },
525
536
  * }
526
537
  * ```
527
538
  *
528
- * Same query with `$is` operator:
529
- *
530
- * ```json
531
- * {
532
- * "filter": {
533
- * "settings.plan": { "$is": ["free", "paid"]}
534
- * },
535
- * }
536
- * ```
537
- *
538
- * Specifying multiple columns, ANDs them together:
539
+ * If you specify multiple columns in the same filter, they are logically AND'ed together:
539
540
  *
540
541
  * ```json
541
542
  * {
@@ -546,6 +547,8 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
546
547
  * }
547
548
  * ```
548
549
  *
550
+ * The above matches if both conditions are met.
551
+ *
549
552
  * To be more explicit about it, you can use `$all` or `$any`:
550
553
  *
551
554
  * ```json
@@ -553,13 +556,13 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
553
556
  * "filter": {
554
557
  * "$any": {
555
558
  * "settings.dark": true,
556
- * "settings.plan": "free",
559
+ * "settings.plan": "free"
557
560
  * }
558
561
  * },
559
562
  * }
560
563
  * ```
561
564
  *
562
- * `$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:
563
566
  *
564
567
  * ```json
565
568
  * {
@@ -602,7 +605,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
602
605
  * }
603
606
  * ```
604
607
  *
605
- * We can also make the negation version, `$notExists` :
608
+ * Or you can use the inverse operator `$notExists`:
606
609
  *
607
610
  * ```json
608
611
  * {
@@ -655,7 +658,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
655
658
  * }
656
659
  * ```
657
660
  *
658
- * #### Numeric/date ranges
661
+ * #### Numeric ranges
659
662
  *
660
663
  * ```json
661
664
  * {
@@ -670,18 +673,6 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
670
673
  *
671
674
  * The supported operators are `$gt`, `$lt`, `$ge`, `$le`.
672
675
  *
673
- * Date ranges would support the same operators, with the date as string in RFC 3339:
674
- *
675
- * ```json
676
- * {
677
- * "filter": {
678
- * "<column_name>": {
679
- * "$gt": "2019-10-12T07:20:50.52Z",
680
- * "$lt": "2021-10-12T07:20:50.52Z"
681
- * }
682
- * }
683
- * }
684
- * ```
685
676
  *
686
677
  * #### Negations
687
678
  *
@@ -734,7 +725,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
734
725
  * }
735
726
  * ```
736
727
  *
737
- * 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:
738
729
  *
739
730
  * ```json
740
731
  * {
@@ -785,6 +776,22 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
785
776
  * predicate. The `$includes` operator is a synonym for the `$includesAny`
786
777
  * operator.
787
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
+ *
788
795
  * ### Sorting
789
796
  *
790
797
  * Sorting by one element:
@@ -947,6 +954,8 @@ exports.operationsByTag = {
947
954
  updateWorkspaceMemberRole: exports.updateWorkspaceMemberRole,
948
955
  removeWorkspaceMember: exports.removeWorkspaceMember,
949
956
  inviteWorkspaceMember: exports.inviteWorkspaceMember,
957
+ cancelWorkspaceMemberInvite: exports.cancelWorkspaceMemberInvite,
958
+ resendWorkspaceMemberInvite: exports.resendWorkspaceMemberInvite,
950
959
  acceptWorkspaceMemberInvite: exports.acceptWorkspaceMemberInvite
951
960
  },
952
961
  database: { getDatabaseList: exports.getDatabaseList, createDatabase: exports.createDatabase, deleteDatabase: exports.deleteDatabase },
@@ -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 }));
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type * as Schemas from './schemas';
7
7
  export declare type APIKeyNameParam = Schemas.APIKeyName;
8
+ export declare type InviteIDParam = Schemas.InviteID;
8
9
  export declare type InviteKeyParam = Schemas.InviteKey;
9
10
  export declare type UserIDParam = Schemas.UserID;
10
11
  export declare type WorkspaceIDParam = Schemas.WorkspaceID;
@@ -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;
@@ -130,7 +130,7 @@ export declare type Table = {
130
130
  */
131
131
  export declare type Column = {
132
132
  name: string;
133
- type: 'bool' | 'int' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
133
+ type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
134
134
  link?: {
135
135
  table: string;
136
136
  };
@@ -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; } });